Changeset b00163f in mainline


Ignore:
Timestamp:
2011-01-25T21:05:46Z (14 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
d03ade7
Parents:
89a0485a
Message:

Move transfer initialization an queue to uhci_add_transfer()

Use uhci add transfer for all transfers
Error message fixes

Location:
uspace/drv/uhci
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/uhci/main.c

    r89a0485a rb00163f  
    5555static int uhci_add_device(device_t *device)
    5656{
    57 //      usb_dprintf(NAME, DEBUG, "uhci_add_device() called\n");
    5857        uhci_print_info( "uhci_add_device() called\n" );
    5958        device->ops = &uhci_ops;
    6059
    61         uhci_init( device, (void*)0xc020 );
     60        // TODO: get this value out of pci driver
     61        uhci_init(device, (void*)0xc020);
    6262
    6363        return EOK;
     
    7878         * Do some global initializations.
    7979         */
    80         sleep( 5 );
     80        sleep(5);
    8181        usb_dprintf_enable(NAME, DEBUG_LEVEL_MAX);
    8282
  • uspace/drv/uhci/uhci.c

    r89a0485a rb00163f  
    99#include "uhci.h"
    1010
    11 static int init_tranfer_lists(transfer_list_t list[]);
    12 
    13 //static int init_transfer();
     11static int uhci_init_tranfer_lists(transfer_list_t list[]);
     12
     13static inline int uhci_add_transfer(
     14  device_t *dev,
     15        usb_target_t target,
     16  usb_transfer_type_t transfer_type,
     17        usb_packet_id pid,
     18  void *buffer, size_t size,
     19  usbhc_iface_transfer_out_callback_t callback_out,
     20  usbhc_iface_transfer_in_callback_t callback_in,
     21        void *arg );
    1422
    1523int uhci_init(device_t *device, void *regs)
     
    5866        pio_write_32(&instance->registers->flbaseadd, (uint32_t)pa);
    5967
    60         ret = init_tranfer_lists(instance->transfers);
     68        ret = uhci_init_tranfer_lists(instance->transfers);
    6169        if (ret != EOK) {
    6270                uhci_print_error("Transfer list initialization failed.\n");
     
    8290            usb_str_transfer_type(transfer_type),
    8391            size);
     92        return uhci_add_transfer(
     93          dev, target, transfer_type, USB_PID_IN, buffer, size, NULL, callback, arg);
     94}
     95/*----------------------------------------------------------------------------*/
     96int uhci_out(
     97  device_t *dev,
     98  usb_target_t target,
     99  usb_transfer_type_t transfer_type,
     100  void *buffer, size_t size,
     101        usbhc_iface_transfer_out_callback_t callback, void *arg
     102  )
     103{
     104        uhci_print_info( "transfer OUT [%d.%d (%s); %zu]\n",
     105            target.address, target.endpoint,
     106            usb_str_transfer_type(transfer_type),
     107            size);
     108        return uhci_add_transfer(
     109          dev, target, transfer_type, USB_PID_OUT, buffer, size, callback, NULL, arg);
     110}
     111/*----------------------------------------------------------------------------*/
     112int uhci_setup(
     113  device_t *dev,
     114  usb_target_t target,
     115  usb_transfer_type_t transfer_type,
     116  void *buffer, size_t size,
     117  usbhc_iface_transfer_out_callback_t callback, void *arg
     118  )
     119{
     120        uhci_print_info( "transfer SETUP [%d.%d (%s); %zu]\n",
     121            target.address, target.endpoint,
     122            usb_str_transfer_type(transfer_type),
     123            size);
     124        uhci_print_info("Setup packet content: %x %x.\n", ((uint8_t*)buffer)[0],
     125          ((uint8_t*)buffer)[1]);
     126        return uhci_add_transfer( dev,
     127          target, transfer_type, USB_PID_SETUP, buffer, size, callback, NULL, arg);
     128
     129}
     130/*----------------------------------------------------------------------------*/
     131int uhci_init_tranfer_lists(transfer_list_t transfers[])
     132{
     133        //TODO:refactor
     134        transfers[USB_TRANSFER_ISOCHRONOUS].first = NULL;
     135        transfers[USB_TRANSFER_ISOCHRONOUS].last = NULL;
     136
     137        int ret;
     138        ret = transfer_list_init(&transfers[USB_TRANSFER_BULK], NULL);
     139        if (ret != EOK) {
     140                uhci_print_error("Failed to initialize bulk queue.\n");
     141                return ret;
     142        }
     143
     144        ret = transfer_list_init(
     145          &transfers[USB_TRANSFER_CONTROL], &transfers[USB_TRANSFER_BULK]);
     146        if (ret != EOK) {
     147                uhci_print_error("Failed to initialize control queue.\n");
     148                transfer_list_fini(&transfers[USB_TRANSFER_BULK]);
     149                return ret;
     150        }
     151
     152        ret = transfer_list_init(
     153          &transfers[USB_TRANSFER_INTERRUPT], &transfers[USB_TRANSFER_CONTROL]);
     154        if (ret != EOK) {
     155                uhci_print_error("Failed to initialize interrupt queue.\n");
     156                transfer_list_fini(&transfers[USB_TRANSFER_CONTROL]);
     157                transfer_list_fini(&transfers[USB_TRANSFER_BULK]);
     158                return ret;
     159        }
     160
     161        return EOK;
     162}
     163/*----------------------------------------------------------------------------*/
     164static inline int uhci_add_transfer(
     165  device_t *dev,
     166        usb_target_t target,
     167  usb_transfer_type_t transfer_type,
     168        usb_packet_id pid,
     169  void *buffer, size_t size,
     170  usbhc_iface_transfer_out_callback_t callback_out,
     171  usbhc_iface_transfer_in_callback_t callback_in,
     172        void *arg )
     173{
     174        // TODO: Add support for isochronous transfers
     175        if (transfer_type == USB_TRANSFER_ISOCHRONOUS)
     176                return ENOTSUP;
    84177
    85178        if (size >= 1024)
     
    106199        CHECK_RET_TRANS_FREE_JOB_TD("Failed to allocate callback structure.\n");
    107200
    108         ret = callback_in_init(job, dev, buffer, size, callback, arg);
     201        ret = callback_init(job, dev, buffer, size, callback_in, callback_out, arg);
    109202        CHECK_RET_TRANS_FREE_JOB_TD("Failed to initialize callback structure.\n");
    110203
     
    113206        CHECK_RET_TRANS_FREE_JOB_TD("Failed to allocate tranfer descriptor.\n");
    114207
    115         ret = transfer_descriptor_init(td, 3, size, false, target, USB_PID_IN);
     208        ret = transfer_descriptor_init(td, 3, size, false, target, pid);
    116209        CHECK_RET_TRANS_FREE_JOB_TD("Failed to initialize transfer descriptor.\n");
    117210
     
    127220        return EOK;
    128221}
    129 /*----------------------------------------------------------------------------*/
    130 int uhci_out(
    131   device_t *dev,
    132   usb_target_t target,
    133   usb_transfer_type_t transfer_type,
    134   void *buffer, size_t size,
    135         usbhc_iface_transfer_out_callback_t callback, void *arg
    136   )
    137 {
    138         uhci_print_info( "transfer OUT [%d.%d (%s); %zu]\n",
    139             target.address, target.endpoint,
    140             usb_str_transfer_type(transfer_type),
    141             size);
    142 
    143         callback( dev, USB_OUTCOME_OK, arg );
    144         return EOK;
    145 }
    146 /*----------------------------------------------------------------------------*/
    147 int uhci_setup(
    148   device_t *dev,
    149   usb_target_t target,
    150   usb_transfer_type_t transfer_type,
    151   void *buffer, size_t size,
    152   usbhc_iface_transfer_out_callback_t callback, void *arg
    153   )
    154 {
    155         uhci_print_info( "transfer SETUP [%d.%d (%s); %zu]\n",
    156             target.address, target.endpoint,
    157             usb_str_transfer_type(transfer_type),
    158             size);
    159         uhci_print_info("Setup packet content: %x %x.\n", ((uint8_t*)buffer)[0],
    160           ((uint8_t*)buffer)[1]);
    161 
    162         callback( dev, USB_OUTCOME_OK, arg );
    163         return EOK;
    164 }
    165 /*----------------------------------------------------------------------------*/
    166 int init_tranfer_lists(transfer_list_t transfers[])
    167 {
    168         //TODO:refactor
    169         transfers[USB_TRANSFER_ISOCHRONOUS].first = NULL;
    170         transfers[USB_TRANSFER_ISOCHRONOUS].last = NULL;
    171         int ret;
    172         ret = transfer_list_init(&transfers[USB_TRANSFER_BULK], NULL);
    173         if (ret != EOK) {
    174                 uhci_print_error("Failed to inititalize bulk queue.\n");
    175                 return ret;
    176         }
    177 
    178         ret = transfer_list_init(
    179           &transfers[USB_TRANSFER_CONTROL], &transfers[USB_TRANSFER_BULK]);
    180         if (ret != EOK) {
    181                 uhci_print_error("Failed to inititalize control queue.\n");
    182                 transfer_list_fini(&transfers[USB_TRANSFER_BULK]);
    183                 return ret;
    184         }
    185 
    186         ret = transfer_list_init(
    187           &transfers[USB_TRANSFER_INTERRUPT], &transfers[USB_TRANSFER_CONTROL]);
    188         if (ret != EOK) {
    189                 uhci_print_error("Failed to interrupt control queue.\n");
    190                 transfer_list_fini(&transfers[USB_TRANSFER_CONTROL]);
    191                 transfer_list_fini(&transfers[USB_TRANSFER_BULK]);
    192                 return ret;
    193         }
    194 
    195         return EOK;
    196 }
Note: See TracChangeset for help on using the changeset viewer.