Changeset 481dec00 in mainline


Ignore:
Timestamp:
2011-12-06T21:48:35Z (12 years ago)
Author:
Jan Vesely <jano.vesely@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
b25199bc
Parents:
2963a0d
Message:

ohci, root hub: Follow standard more closely.

File:
1 edited

Legend:

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

    r2963a0d r481dec00  
    487487        case USB_DESCTYPE_HUB:
    488488                usb_log_debug2("USB_DESCTYPE_HUB\n");
    489                 /* Hub descriptor was generated locally */
     489                /* Hub descriptor was generated locally.
     490                 * Class specific request. */
    490491                TRANSFER_END_DATA(request, instance->descriptors.hub,
    491492                    instance->hub_descriptor_size);
     
    493494        case USB_DESCTYPE_DEVICE:
    494495                usb_log_debug2("USB_DESCTYPE_DEVICE\n");
    495                 /* Device descriptor is shared (No one should ask for it) */
     496                /* Device descriptor is shared
     497                 * (No one should ask for it, as the device is already setup)
     498                 * Standard USB device request. */
    496499                TRANSFER_END_DATA(request, &ohci_rh_device_descriptor,
    497500                    sizeof(ohci_rh_device_descriptor));
     
    500503                usb_log_debug2("USB_DESCTYPE_CONFIGURATION\n");
    501504                /* Start with configuration and add others depending on
    502                  * request size */
     505                 * request size. Standard USB request. */
    503506                TRANSFER_END_DATA(request, &instance->descriptors,
    504507                    instance->descriptors.configuration.total_length);
     
    507510                usb_log_debug2("USB_DESCTYPE_INTERFACE\n");
    508511                /* Use local interface descriptor. There is one and it
    509                  * might be modified */
     512                 * might be modified. Hub driver should not ask or this
     513                 * descriptor as it is not part of standard requests set. */
    510514                TRANSFER_END_DATA(request, &instance->descriptors.interface,
    511515                    sizeof(instance->descriptors.interface));
     
    513517        case USB_DESCTYPE_ENDPOINT:
    514518                /* Use local endpoint descriptor. There is one
    515                  * it might have max_packet_size field modified*/
     519                 * it might have max_packet_size field modified. Hub driver
     520                 * should not ask for this descriptor as it is not part
     521                 * of standard requests set. */
    516522                usb_log_debug2("USB_DESCTYPE_ENDPOINT\n");
    517523                TRANSFER_END_DATA(request, &instance->descriptors.endpoint,
     
    658664                usb_log_error("Invalid HUB set feature request.\n");
    659665                TRANSFER_END(request, ENOTSUP);
     666        //TODO: Consider standard USB requests: REMOTE WAKEUP, ENDPOINT STALL
    660667        default:
    661668                usb_log_error("Invalid set feature request type: %d\n",
    662669                    setup_request->request_type);
    663                 TRANSFER_END(request, EINVAL);
     670                TRANSFER_END(request, ENOTSUP);
    664671        }
    665672}
     
    703710                        TRANSFER_END(request, EOK);
    704711                }
     712        //TODO: Consider standard USB requests: REMOTE WAKEUP, ENDPOINT STALL
    705713        default:
    706714                usb_log_error("Invalid clear feature request type: %d\n",
    707715                    setup_request->request_type);
    708                 TRANSFER_END(request, EINVAL);
     716                TRANSFER_END(request, ENOTSUP);
    709717        }
    710718}
     
    777785
    778786        case USB_DEVREQ_SET_ADDRESS:
    779                 usb_log_debug("USB_DEVREQ_SET_ADDRESS\n");
     787                usb_log_debug("USB_DEVREQ_SET_ADDRESS: %u\n",
     788                    setup_request->value);
     789                if (uint16_usb2host(setup_request->value) > 127)
     790                        TRANSFER_END(request, EINVAL);
     791
    780792                instance->address = setup_request->value;
    781793                TRANSFER_END(request, EOK);
    782794
    783795        case USB_DEVREQ_SET_CONFIGURATION:
    784                 usb_log_debug("USB_DEVREQ_SET_CONFIGURATION\n");
    785                 /* We don't need to do anything */
     796                usb_log_debug("USB_DEVREQ_SET_CONFIGURATION: %u\n",
     797                    setup_request->value);
     798                /* We have only one configuration, it's number is 1 */
     799                if (uint16_usb2host(setup_request->value) != 1)
     800                        TRANSFER_END(request, EINVAL);
    786801                TRANSFER_END(request, EOK);
    787802
    788         case USB_DEVREQ_SET_DESCRIPTOR: /* Not supported by OHCI RH */
     803        /* Both class specific and std is optional for hubs */
     804        case USB_DEVREQ_SET_DESCRIPTOR:
     805        /* Hubs have only one interface GET/SET is not supported */
     806        case USB_DEVREQ_GET_INTERFACE:
     807        case USB_DEVREQ_SET_INTERFACE:
    789808        default:
     809                /* Hub class GET_STATE(2) falls in here too. */
    790810                usb_log_error("Received unsupported request: %d.\n",
    791811                    setup_request->request);
Note: See TracChangeset for help on using the changeset viewer.