Fork us on GitHub Follow us on Facebook Follow us on Twitter

Changeset 7d5708d in mainline


Ignore:
Timestamp:
2011-07-12T10:58:45Z (10 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master
Children:
b4f291d
Parents:
0c224b2
Message:

OHCI: Root hub: Final touches.

Simplify mask size computation.
Remove useless bit_field_size variable in create_hub_descriptor,
value in instance→interrupt_mask_size can be used.
Set interrupt endpoint max packet size to match mask size.
rh_request always returns EOK as errors are indicated via
usb_transfer_batch mechanism, change return type to void.
Get rid of request_without_data function and consolidate request type switch
into one function.
Use new get_feature/set_feature functions to replace the functionality
of removed request_without_data.
Rename:

port_feature_set_request ⇒ set_feature_port
port_feature_clear_request ⇒ clear_feature_port

Location:
uspace/drv/bus/usb/ohci
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/ohci/hc.c

    r0c224b2 r7d5708d  
    373373        /* Check for root hub communication */
    374374        if (batch->ep->address == instance->rh.address) {
    375                 return rh_request(&instance->rh, batch);
     375                rh_request(&instance->rh, batch);
     376                return EOK;
    376377        }
    377378
  • uspace/drv/bus/usb/ohci/root_hub.c

    r0c224b2 r7d5708d  
    5757        .device_subclass = 0,
    5858        .device_version = 0,
    59         .length = sizeof (usb_standard_device_descriptor_t),
     59        .length = sizeof(usb_standard_device_descriptor_t),
    6060        .max_packet_size = 64,
    61         .vendor_id = 0x16db,
     61        .vendor_id = 0x16db, /* HelenOS does not have USB vendor ID assigned.*/
    6262        .product_id = 0x0001,
    6363        .str_serial_number = 0,
     
    7474        .descriptor_type = USB_DESCTYPE_CONFIGURATION,
    7575        .interface_count = 1,
    76         .length = sizeof (usb_standard_configuration_descriptor_t),
     76        .length = sizeof(usb_standard_configuration_descriptor_t),
    7777        .max_power = 0, /* root hubs don't need no power */
    7878        .str_configuration = 0,
     
    9090        .interface_protocol = 0,
    9191        .interface_subclass = 0,
    92         .length = sizeof (usb_standard_interface_descriptor_t),
     92        .length = sizeof(usb_standard_interface_descriptor_t),
    9393        .str_interface = 0,
    9494};
     
    106106};
    107107
    108 /**
    109  * bitmask of port features that are valid to be set
    110  */
    111 static const uint32_t port_set_feature_valid_mask =
    112     RHPS_SET_PORT_ENABLE |
    113     RHPS_SET_PORT_SUSPEND |
    114     RHPS_SET_PORT_RESET |
    115     RHPS_SET_PORT_POWER;
    116 
    117 /**
    118  * bitmask of port features that can be cleared
    119  */
    120 static const uint32_t port_clear_feature_valid_mask =
    121     RHPS_CCS_FLAG |
    122     RHPS_SET_PORT_SUSPEND |
    123     RHPS_POCI_FLAG |
    124     RHPS_SET_PORT_POWER |
    125     RHPS_CSC_FLAG |
    126     RHPS_PESC_FLAG |
    127     RHPS_PSSC_FLAG |
    128     RHPS_OCIC_FLAG |
    129     RHPS_PRSC_FLAG;
    130 
    131 //note that USB_HUB_FEATURE_PORT_POWER bit is translated into
    132 //USB_HUB_FEATURE_PORT_LOW_SPEED for port set feature request
    133 
    134108static void create_serialized_hub_descriptor(rh_t *instance);
    135109static void rh_init_descriptors(rh_t *instance);
    136110static uint16_t create_interrupt_mask(rh_t *instance);
    137 static int get_status_request(rh_t *instance, usb_transfer_batch_t *request);
    138 static int get_descriptor_request(
    139     rh_t *instance, usb_transfer_batch_t *request);
    140 static int port_feature_set_request(
    141     rh_t *instance, uint16_t feature, uint16_t port);
    142 static int port_feature_clear_request(
    143     rh_t *instance, uint16_t feature, uint16_t port);
    144 static int request_with_output(rh_t *instance, usb_transfer_batch_t *request);
    145 static int request_without_data(rh_t *instance, usb_transfer_batch_t *request);
    146 static int ctrl_request(rh_t *instance, usb_transfer_batch_t *request);
     111static int get_status(rh_t *instance, usb_transfer_batch_t *request);
     112static int get_descriptor(rh_t *instance, usb_transfer_batch_t *request);
     113static int set_feature(rh_t *instance, usb_transfer_batch_t *request);
     114static int clear_feature(rh_t *instance, usb_transfer_batch_t *request);
     115static int set_feature_port(rh_t *instance, uint16_t feature, uint16_t port);
     116static int clear_feature_port(rh_t *instance, uint16_t feature, uint16_t port);
     117static int control_request(rh_t *instance, usb_transfer_batch_t *request);
     118static inline void interrupt_request(
     119    usb_transfer_batch_t *request, uint16_t mask, size_t size)
     120{
     121        assert(request);
     122
     123        memcpy(request->data_buffer, &mask, size);
     124        request->transfered_size = size;
     125        usb_transfer_batch_finish_error(request, EOK);
     126}
    147127
    148128#define TRANSFER_OK(bytes) \
     
    154134#define OHCI_POWER 2
    155135
    156 /** Root hub initialization
    157  * @return Error code.
     136/** Root Hub driver structure initialization.
     137 *
     138 * Reads info registers and prepares descriptors. Sets power mode.
    158139 */
    159140void rh_init(rh_t *instance, ohci_regs_t *regs)
     
    166147            (instance->registers->rh_desc_a >> RHDA_NDS_SHIFT) & RHDA_NDS_MASK;
    167148        if (instance->port_count > 15) {
    168                 usb_log_error("OHCI specification does not allow more than 15"
     149                usb_log_warning("OHCI specification does not allow more than 15"
    169150                    " ports. Max 15 ports will be used");
    170151                instance->port_count = 15;
     
    172153
    173154        /* Don't forget the hub status bit and round up */
    174         instance->interrupt_mask_size = (instance->port_count + 1 + 8) / 8;
     155        instance->interrupt_mask_size = 1 + (instance->port_count / 8);
    175156        instance->unfinished_interrupt_transfer = NULL;
     157
    176158#if OHCI_POWER == 0
    177159        /* Set port power mode to no power-switching. (always on) */
     
    216198 * @return Error code
    217199 */
    218 int rh_request(rh_t *instance, usb_transfer_batch_t *request)
     200void rh_request(rh_t *instance, usb_transfer_batch_t *request)
    219201{
    220202        assert(instance);
    221203        assert(request);
    222204
    223         int opResult;
    224205        switch (request->ep->transfer_type)
    225206        {
    226207        case USB_TRANSFER_CONTROL:
    227208                usb_log_debug("Root hub got CONTROL packet\n");
    228                 opResult = ctrl_request(instance, request);
    229                 usb_transfer_batch_finish_error(request, opResult);
     209                const int ret = control_request(instance, request);
     210                usb_transfer_batch_finish_error(request, ret);
    230211                break;
    231212        case USB_TRANSFER_INTERRUPT:
     
    234215                if (mask == 0) {
    235216                        usb_log_debug("No changes..\n");
     217                        assert(instance->unfinished_interrupt_transfer == NULL);
    236218                        instance->unfinished_interrupt_transfer = request;
    237                         //will be finished later
    238                 } else {
    239                         usb_log_debug("Processing changes..\n");
    240                         memcpy(request->data_buffer, &mask,
    241                             instance->interrupt_mask_size);
    242                         request->transfered_size = instance->interrupt_mask_size;
    243                         instance->unfinished_interrupt_transfer = NULL;
    244                         usb_transfer_batch_finish_error(request, EOK);
     219                        break;
    245220                }
     221                usb_log_debug("Processing changes...\n");
     222                interrupt_request(request, mask, instance->interrupt_mask_size);
    246223                break;
     224
    247225        default:
    248226                usb_log_error("Root hub got unsupported request.\n");
    249227                usb_transfer_batch_finish_error(request, EINVAL);
    250228        }
    251         return EOK;
    252 }
    253 /*----------------------------------------------------------------------------*/
    254 /**
    255  * process interrupt on a hub
     229}
     230/*----------------------------------------------------------------------------*/
     231/**
     232 * Process interrupt on a hub device.
    256233 *
    257234 * If there is no pending interrupt transfer, nothing happens.
     
    260237void rh_interrupt(rh_t *instance)
    261238{
     239        assert(instance);
     240
    262241        if (!instance->unfinished_interrupt_transfer)
    263242                return;
     
    265244        usb_log_debug("Finalizing interrupt transfer\n");
    266245        const uint16_t mask = create_interrupt_mask(instance);
    267         memcpy(instance->unfinished_interrupt_transfer->data_buffer,
    268             &mask, instance->interrupt_mask_size);
    269         instance->unfinished_interrupt_transfer->transfered_size =
    270            instance->interrupt_mask_size;
    271         usb_transfer_batch_finish(instance->unfinished_interrupt_transfer);
     246        interrupt_request(instance->unfinished_interrupt_transfer,
     247            mask, instance->interrupt_mask_size);
    272248
    273249        instance->unfinished_interrupt_transfer = NULL;
     
    286262        assert(instance);
    287263
    288         const size_t bit_field_size = (instance->port_count + 1 + 7) / 8;
    289         assert(bit_field_size == 2 || bit_field_size == 1);
    290264        /* 7 bytes + 2 port bit fields (port count + global bit) */
    291         const size_t size = 7 + (bit_field_size * 2);
     265        const size_t size = 7 + (instance->interrupt_mask_size * 2);
    292266        assert(size <= HUB_DESCRIPTOR_MAX_SIZE);
    293267        instance->hub_descriptor_size = size;
     
    325299            (port_desc >> RHDB_DR_SHIFT) & RHDB_DR_MASK & 0xff;
    326300        instance->descriptors.hub[8] = 0xff;
    327         if (bit_field_size == 2) {
     301        if (instance->interrupt_mask_size == 2) {
    328302                instance->descriptors.hub[8] =
    329303                    (port_desc >> RHDB_DR_SHIFT) & RHDB_DR_MASK >> 8;
     
    335309/** Initialize hub descriptors.
    336310 *
    337  * Device and full configuration descriptor are created. These need to
    338  * be initialized only once per hub.
     311 * A full configuration descriptor is assembled. The configuration and endpoint
     312 * descriptors have local modifications.
    339313 * @param instance Root hub instance
    340314 * @return Error code
     
    348322        instance->descriptors.endpoint = ohci_rh_ep_descriptor;
    349323        create_serialized_hub_descriptor(instance);
     324
     325        instance->descriptors.endpoint.max_packet_size =
     326            instance->interrupt_mask_size;
    350327
    351328        instance->descriptors.configuration.total_length =
     
    357334/*----------------------------------------------------------------------------*/
    358335/**
     336 * Create bitmap of changes to answer status interrupt.
     337 *
     338 * Result contains bitmap where bit 0 indicates change on hub and
     339 * bit i indicates change on i`th port (i>0). For more info see
     340 * Hub and Port status bitmap specification in USB specification
     341 * (chapter 11.13.4).
     342 * @param instance root hub instance
     343 * @return Mask of changes.
     344 */
     345uint16_t create_interrupt_mask(rh_t *instance)
     346{
     347        assert(instance);
     348        uint16_t mask = 0;
     349
     350        /* Only local power source change and over-current change can happen */
     351        if (instance->registers->rh_status & (RHS_LPSC_FLAG | RHS_OCIC_FLAG)) {
     352                mask |= 1;
     353        }
     354        size_t port = 1;
     355        for (; port <= instance->port_count; ++port) {
     356                /* Write-clean bits are those that indicate change */
     357                if (RHPS_CHANGE_WC_MASK
     358                    & instance->registers->rh_port_status[port - 1]) {
     359
     360                        mask |= (1 << port);
     361                }
     362        }
     363        /* USB is little endian */
     364        return host2uint32_t_le(mask);
     365}
     366/*----------------------------------------------------------------------------*/
     367/**
    359368 * Create answer to status request.
    360369 *
     
    365374 * @return error code
    366375 */
    367 int get_status_request(rh_t *instance, usb_transfer_batch_t *request)
     376int get_status(rh_t *instance, usb_transfer_batch_t *request)
    368377{
    369378        assert(instance);
     
    403412/*----------------------------------------------------------------------------*/
    404413/**
    405  * Create bitmap of changes to answer status interrupt.
    406  *
    407  * Result contains bitmap where bit 0 indicates change on hub and
    408  * bit i indicates change on i`th port (i>0). For more info see
    409  * Hub and Port status bitmap specification in USB specification
    410  * (chapter 11.13.4).
    411  * Uses instance`s interrupt buffer to store the interrupt information.
    412  * @param instance root hub instance
    413  */
    414 uint16_t create_interrupt_mask(rh_t *instance)
    415 {
    416         assert(instance);
    417         uint16_t mask = 0;
    418 
    419         /* Only local power source change and over-current change can happen */
    420         if (instance->registers->rh_status & (RHS_LPSC_FLAG | RHS_OCIC_FLAG)) {
    421                 mask |= 1;
    422         }
    423         size_t port = 1;
    424         for (; port <= instance->port_count; ++port) {
    425                 /* Write-clean bits are those that indicate change */
    426                 if (RHPS_CHANGE_WC_MASK
    427                     & instance->registers->rh_port_status[port - 1]) {
    428 
    429                         mask |= (1 << port);
    430                 }
    431         }
    432         return host2uint32_t_le(mask);
    433 }
    434 /*----------------------------------------------------------------------------*/
    435 /**
    436414 * Create answer to a descriptor request.
    437415 *
     
    442420 * @return Error code
    443421 */
    444 int get_descriptor_request(
    445     rh_t *instance, usb_transfer_batch_t *request)
     422int get_descriptor(rh_t *instance, usb_transfer_batch_t *request)
    446423{
    447424        assert(instance);
     
    451428            (usb_device_request_setup_packet_t *) request->setup_buffer;
    452429        size_t size;
    453         const void * result_descriptor = NULL;
     430        const void *descriptor = NULL;
    454431        const uint16_t setup_request_value = setup_request->value_high;
    455432        //(setup_request->value_low << 8);
     
    458435        case USB_DESCTYPE_HUB:
    459436                usb_log_debug2("USB_DESCTYPE_HUB\n");
    460                 result_descriptor = instance->descriptors.hub;
     437                /* Hub descriptor was generated locally */
     438                descriptor = instance->descriptors.hub;
    461439                size = instance->hub_descriptor_size;
    462440                break;
     
    464442        case USB_DESCTYPE_DEVICE:
    465443                usb_log_debug2("USB_DESCTYPE_DEVICE\n");
    466                 result_descriptor = &ohci_rh_device_descriptor;
     444                /* Device descriptor is shared (No one should ask for it)*/
     445                descriptor = &ohci_rh_device_descriptor;
    467446                size = sizeof(ohci_rh_device_descriptor);
    468447                break;
     
    470449        case USB_DESCTYPE_CONFIGURATION:
    471450                usb_log_debug2("USB_DESCTYPE_CONFIGURATION\n");
    472                 result_descriptor = &instance->descriptors;
     451                /* Start with configuration and add others depending on
     452                 * request size */
     453                descriptor = &instance->descriptors;
    473454                size = instance->descriptors.configuration.total_length;
    474455                break;
     
    476457        case USB_DESCTYPE_INTERFACE:
    477458                usb_log_debug2("USB_DESCTYPE_INTERFACE\n");
    478                 result_descriptor = &ohci_rh_iface_descriptor;
    479                 size = sizeof(ohci_rh_iface_descriptor);
     459                /* Use local interface descriptor. There is one and it
     460                 * might be modified */
     461                descriptor = &instance->descriptors.interface;
     462                size = sizeof(instance->descriptors.interface);
    480463                break;
    481464
    482465        case USB_DESCTYPE_ENDPOINT:
     466                /* Use local endpoint descriptor. There is one
     467                 * it might have max_packet_size field modified*/
    483468                usb_log_debug2("USB_DESCTYPE_ENDPOINT\n");
    484                 result_descriptor = &ohci_rh_ep_descriptor;
    485                 size = sizeof(ohci_rh_ep_descriptor);
     469                descriptor = &instance->descriptors.endpoint;
     470                size = sizeof(instance->descriptors.endpoint);
    486471                break;
    487472
     
    500485        }
    501486
    502         memcpy(request->data_buffer, result_descriptor, size);
     487        memcpy(request->data_buffer, descriptor, size);
    503488        TRANSFER_OK(size);
    504489}
     
    513498 * @return error code
    514499 */
    515 int port_feature_set_request(rh_t *instance, uint16_t feature, uint16_t port)
     500int set_feature_port(rh_t *instance, uint16_t feature, uint16_t port)
    516501{
    517502        assert(instance);
     
    544529/*----------------------------------------------------------------------------*/
    545530/**
    546  * process feature-disabling request on hub
     531 * Process feature clear request.
    547532 *
    548533 * @param instance root hub instance
     
    552537 * @return error code
    553538 */
    554 int port_feature_clear_request(rh_t *instance, uint16_t feature, uint16_t port)
     539int clear_feature_port(rh_t *instance, uint16_t feature, uint16_t port)
    555540{
    556541        assert(instance);
     
    594579                instance->registers->rh_port_status[port - 1] = (1 << feature);
    595580                return EOK;
     581
    596582        default:
    597583                return ENOTSUP;
    598584        }
    599 }
    600 /*----------------------------------------------------------------------------*/
    601 /**
    602  * Process a request that requires output data.
    603  *
    604  * Request can be one of USB_DEVREQ_GET_STATUS, USB_DEVREQ_GET_DESCRIPTOR or
    605  * USB_DEVREQ_GET_CONFIGURATION.
    606  * @param instance root hub instance
    607  * @param request structure containing both request and response information
    608  * @return error code
    609  */
    610 int request_with_output(rh_t *instance, usb_transfer_batch_t *request)
    611 {
    612         assert(instance);
    613         assert(request);
    614 
    615         const usb_device_request_setup_packet_t *setup_request =
    616             (usb_device_request_setup_packet_t *) request->setup_buffer;
    617         switch (setup_request->request)
    618         {
    619         case USB_DEVREQ_GET_STATUS:
    620                 usb_log_debug("USB_DEVREQ_GET_STATUS\n");
    621                 return get_status_request(instance, request);
    622         case USB_DEVREQ_GET_DESCRIPTOR:
    623                 usb_log_debug("USB_DEVREQ_GET_DESCRIPTOR\n");
    624                 return get_descriptor_request(instance, request);
    625         case USB_DEVREQ_GET_CONFIGURATION:
    626                 usb_log_debug("USB_DEVREQ_GET_CONFIGURATION\n");
    627                 if (request->buffer_size != 1)
    628                         return EINVAL;
    629                 request->data_buffer[0] = 1;
    630                 TRANSFER_OK(1);
    631         }
    632         return ENOTSUP;
    633585}
    634586/*----------------------------------------------------------------------------*/
     
    642594 * @return error code
    643595 */
    644 int request_without_data(rh_t *instance, usb_transfer_batch_t *request)
     596int set_feature(rh_t *instance, usb_transfer_batch_t *request)
     597{
     598        assert(instance);
     599        assert(request);
     600
     601        const usb_device_request_setup_packet_t *setup_request =
     602            (usb_device_request_setup_packet_t *) request->setup_buffer;
     603        switch (setup_request->request_type)
     604        {
     605        case USB_HUB_REQ_TYPE_SET_PORT_FEATURE:
     606                usb_log_debug("USB_HUB_REQ_TYPE_SET_PORT_FEATURE\n");
     607                return set_feature_port(instance,
     608                    setup_request->value, setup_request->index);
     609
     610        case USB_HUB_REQ_TYPE_SET_HUB_FEATURE:
     611                /* Chapter 11.16.2 specifies that hub can be recipient
     612                 * only for C_HUB_LOCAL_POWER and C_HUB_OVER_CURRENT
     613                 * features. It makes no sense to SET either. */
     614                usb_log_error("Invalid HUB set feature request.\n");
     615                return ENOTSUP;
     616        default:
     617                usb_log_error("Invalid set feature request type: %d\n",
     618                    setup_request->request_type);
     619                return EINVAL;
     620        }
     621}
     622/*----------------------------------------------------------------------------*/
     623/**
     624 * process one of requests that do not request nor carry additional data
     625 *
     626 * Request can be one of USB_DEVREQ_CLEAR_FEATURE, USB_DEVREQ_SET_FEATURE or
     627 * USB_DEVREQ_SET_ADDRESS.
     628 * @param instance root hub instance
     629 * @param request structure containing both request and response information
     630 * @return error code
     631 */
     632int clear_feature(rh_t *instance, usb_transfer_batch_t *request)
    645633{
    646634        assert(instance);
     
    650638            (usb_device_request_setup_packet_t *) request->setup_buffer;
    651639        request->transfered_size = 0;
    652         const int request_type = setup_request->request_type;
    653         switch (setup_request->request)
     640        switch (setup_request->request_type)
    654641        {
    655         case USB_DEVREQ_CLEAR_FEATURE:
    656                 if (request_type == USB_HUB_REQ_TYPE_CLEAR_PORT_FEATURE) {
    657                         usb_log_debug("USB_HUB_REQ_TYPE_CLEAR_PORT_FEATURE\n");
    658                         return port_feature_clear_request(instance,
    659                             setup_request->value, setup_request->index);
     642        case USB_HUB_REQ_TYPE_CLEAR_PORT_FEATURE:
     643                usb_log_debug("USB_HUB_REQ_TYPE_CLEAR_PORT_FEATURE\n");
     644                return clear_feature_port(instance,
     645                    setup_request->value, setup_request->index);
     646
     647        case USB_HUB_REQ_TYPE_CLEAR_HUB_FEATURE:
     648                usb_log_debug("USB_HUB_REQ_TYPE_CLEAR_HUB_FEATURE\n");
     649                /*
     650                 * Chapter 11.16.2 specifies that only C_HUB_LOCAL_POWER and
     651                 * C_HUB_OVER_CURRENT are supported. C_HUB_OVER_CURRENT is represented
     652                 * by OHCI RHS_OCIC_FLAG. C_HUB_LOCAL_POWER is not supported
     653                 * as root hubs do not support local power status feature.
     654                 * (OHCI pg. 127) */
     655                if (setup_request->value == USB_HUB_FEATURE_C_HUB_OVER_CURRENT) {
     656                        instance->registers->rh_status = RHS_OCIC_FLAG;
     657                        TRANSFER_OK(0);
    660658                }
    661                 if (request_type == USB_HUB_REQ_TYPE_CLEAR_HUB_FEATURE) {
    662                         usb_log_debug("USB_HUB_REQ_TYPE_CLEAR_HUB_FEATURE\n");
    663         /*
    664          * Chapter 11.16.2 specifies that only C_HUB_LOCAL_POWER and
    665          * C_HUB_OVER_CURRENT are supported. C_HUB_OVER_CURRENT is represented
    666          * by OHCI RHS_OCIC_FLAG. C_HUB_LOCAL_POWER is not supported
    667          * as root hubs do not support local power status feature.
    668          * (OHCI pg. 127) */
    669         if (setup_request->value == USB_HUB_FEATURE_C_HUB_OVER_CURRENT) {
    670                 instance->registers->rh_status = RHS_OCIC_FLAG;
    671                 return EOK;
    672         }
    673                 }
    674                         usb_log_error("Invalid clear feature request type: %d\n",
    675                             request_type);
    676                         return EINVAL;
    677 
    678         case USB_DEVREQ_SET_FEATURE:
    679                 switch (request_type)
    680                 {
    681                 case USB_HUB_REQ_TYPE_SET_PORT_FEATURE:
    682                         usb_log_debug("USB_HUB_REQ_TYPE_SET_PORT_FEATURE\n");
    683                         return port_feature_set_request(instance,
    684                             setup_request->value, setup_request->index);
    685 
    686                 case USB_HUB_REQ_TYPE_SET_HUB_FEATURE:
    687                 /* Chapter 11.16.2 specifies that hub can be recipient
    688                  * only for C_HUB_LOCAL_POWER and C_HUB_OVER_CURRENT
    689                  * features. It makes no sense to SET either. */
    690                         usb_log_error("Invalid HUB set feature request.\n");
    691                         return ENOTSUP;
    692                 default:
    693                         usb_log_error("Invalid set feature request type: %d\n",
    694                             request_type);
    695                         return EINVAL;
    696                 }
    697 
    698         case USB_DEVREQ_SET_ADDRESS:
    699                 usb_log_debug("USB_DEVREQ_SET_ADDRESS\n");
    700                 instance->address = setup_request->value;
    701                 TRANSFER_OK(0);
    702         case USB_DEVREQ_SET_CONFIGURATION:
    703                 usb_log_debug("USB_DEVREQ_SET_CONFIGURATION\n");
    704                 /* We don't need to do anything */
    705                 TRANSFER_OK(0);
    706 
    707659        default:
    708                 usb_log_error("Invalid HUB request: %d\n",
    709                     setup_request->request);
    710                 return ENOTSUP;
     660                usb_log_error("Invalid clear feature request type: %d\n",
     661                    setup_request->request_type);
     662                return EINVAL;
    711663        }
    712664}
     
    730682 * @return error code
    731683 */
    732 int ctrl_request(rh_t *instance, usb_transfer_batch_t *request)
     684int control_request(rh_t *instance, usb_transfer_batch_t *request)
    733685{
    734686        assert(instance);
     
    739691                return EINVAL;
    740692        }
     693
    741694        if (sizeof(usb_device_request_setup_packet_t) > request->setup_size) {
    742695                usb_log_error("Setup packet too small\n");
    743696                return EOVERFLOW;
    744697        }
     698
    745699        usb_log_debug2("CTRL packet: %s.\n",
    746700            usb_debug_str_buffer((uint8_t *) request->setup_buffer, 8, 8));
     
    750704        {
    751705        case USB_DEVREQ_GET_STATUS:
     706                usb_log_debug("USB_DEVREQ_GET_STATUS\n");
     707                return get_status(instance, request);
     708
    752709        case USB_DEVREQ_GET_DESCRIPTOR:
     710                usb_log_debug("USB_DEVREQ_GET_DESCRIPTOR\n");
     711                return get_descriptor(instance, request);
     712
    753713        case USB_DEVREQ_GET_CONFIGURATION:
    754                 usb_log_debug2("Processing request with output\n");
    755                 return request_with_output(instance, request);
     714                usb_log_debug("USB_DEVREQ_GET_CONFIGURATION\n");
     715                if (request->buffer_size != 1)
     716                        return EINVAL;
     717                request->data_buffer[0] = 1;
     718                TRANSFER_OK(1);
     719
    756720        case USB_DEVREQ_CLEAR_FEATURE:
    757         case USB_DEVREQ_SET_FEATURE:
    758         case USB_DEVREQ_SET_ADDRESS:
    759         case USB_DEVREQ_SET_CONFIGURATION:
    760721                usb_log_debug2("Processing request without "
    761722                    "additional data\n");
    762                 return request_without_data(instance, request);
     723                return clear_feature(instance, request);
     724        case USB_DEVREQ_SET_FEATURE:
     725                usb_log_debug2("Processing request without "
     726                    "additional data\n");
     727                return set_feature(instance, request);
     728
     729        case USB_DEVREQ_SET_ADDRESS:
     730                usb_log_debug("USB_DEVREQ_SET_ADDRESS\n");
     731                instance->address = setup_request->value;
     732                TRANSFER_OK(0);
     733
     734        case USB_DEVREQ_SET_CONFIGURATION:
     735                usb_log_debug("USB_DEVREQ_SET_CONFIGURATION\n");
     736                /* We don't need to do anything */
     737                TRANSFER_OK(0);
     738
    763739        case USB_DEVREQ_SET_DESCRIPTOR: /* Not supported by OHCI RH */
    764740        default:
  • uspace/drv/bus/usb/ohci/root_hub.h

    r0c224b2 r7d5708d  
    5757        /** size of interrupt buffer */
    5858        size_t interrupt_mask_size;
    59 
    6059        /** Descriptors */
    6160        struct {
     
    7271void rh_init(rh_t *instance, ohci_regs_t *regs);
    7372
    74 int rh_request(rh_t *instance, usb_transfer_batch_t *request);
     73void rh_request(rh_t *instance, usb_transfer_batch_t *request);
    7574
    7675void rh_interrupt(rh_t *instance);
Note: See TracChangeset for help on using the changeset viewer.