Changeset aee6c73 in mainline for uspace/drv/ohci/root_hub.c


Ignore:
Timestamp:
2011-03-26T17:19:28Z (14 years ago)
Author:
Matus Dekanek <smekideki@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
0368669c, cee51fd
Parents:
f3da9b2 (diff), c9f5e238 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

merge from development

File:
1 edited

Legend:

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

    rf3da9b2 raee6c73  
    4343#include <usb/classes/hub.h>
    4444
     45static const usb_standard_device_descriptor_t ohci_rh_device_descriptor =
     46{
     47                .configuration_count = 1,
     48                .descriptor_type = USB_DESCTYPE_DEVICE,
     49                .device_class = USB_CLASS_HUB,
     50                .device_protocol = 0,
     51                .device_subclass = 0,
     52                .device_version = 0,
     53                .length = sizeof(usb_standard_device_descriptor_t),
     54                /// \TODO this value is guessed
     55                .max_packet_size = 8,
     56                .vendor_id = 0x16db,
     57                .product_id = 0x0001,
     58                /// \TODO these values migt be different
     59                .str_serial_number = 0,
     60                .usb_spec_version = 0,
     61};
     62
     63static const usb_standard_configuration_descriptor_t ohci_rh_conf_descriptor =
     64{
     65        /// \TODO some values are default or guessed
     66        .attributes = 1<<7,
     67        .configuration_number = 1,
     68        .descriptor_type = USB_DESCTYPE_CONFIGURATION,
     69        .interface_count = 1,
     70        .length = sizeof(usb_standard_configuration_descriptor_t),
     71        .max_power = 100,
     72        .str_configuration = 0,
     73};
     74
     75static const usb_standard_interface_descriptor_t ohci_rh_iface_descriptor =
     76{
     77        .alternate_setting = 0,
     78        .descriptor_type = USB_DESCTYPE_INTERFACE,
     79        .endpoint_count = 1,
     80        .interface_class = USB_CLASS_HUB,
     81        /// \TODO is this correct?
     82        .interface_number = 1,
     83        .interface_protocol = 0,
     84        .interface_subclass = 0,
     85        .length = sizeof(usb_standard_interface_descriptor_t),
     86        .str_interface = 0,
     87};
     88
     89static const usb_standard_endpoint_descriptor_t ohci_rh_ep_descriptor =
     90{
     91        .attributes = USB_TRANSFER_INTERRUPT,
     92        .descriptor_type = USB_DESCTYPE_ENDPOINT,
     93        .endpoint_address = 1 + (1<<7),
     94        .length = sizeof(usb_standard_endpoint_descriptor_t),
     95        .max_packet_size = 8,
     96        .poll_interval = 255,
     97};
    4598
    4699/** Root hub initialization
     
    330383                        (usb_device_request_setup_packet_t*)request->setup_buffer;
    331384        size_t size;
    332         void * result_descriptor;
    333         uint16_t setup_request_value = setup_request->value_high;
     385        const void * result_descriptor = NULL;
     386        const uint16_t setup_request_value = setup_request->value_high;
    334387                        //(setup_request->value_low << 8);
     388#if 0
     389        bool del = false;
     390        //this code was merged from development and has to be reviewed
     391        switch (setup_request_value)
     392        {
     393        case USB_DESCTYPE_HUB: {
     394                uint8_t * descriptor;
     395                usb_create_serialized_hub_descriptor(
     396                    instance, &descriptor, &size);
     397                result_descriptor = descriptor;
     398                break;
     399        }
     400        case USB_DESCTYPE_DEVICE: {
     401                usb_log_debug("USB_DESCTYPE_DEVICE\n");
     402                result_descriptor = &ohci_rh_device_descriptor;
     403                size = sizeof(ohci_rh_device_descriptor);
     404                break;
     405        }
     406        case USB_DESCTYPE_CONFIGURATION: {
     407                usb_log_debug("USB_DESCTYPE_CONFIGURATION\n");
     408                usb_standard_configuration_descriptor_t * descriptor =
     409                                malloc(sizeof(usb_standard_configuration_descriptor_t));
     410                memcpy(descriptor, &ohci_rh_conf_descriptor,
     411                    sizeof(usb_standard_configuration_descriptor_t));
     412                /// \TODO should this include device descriptor?
     413                const size_t hub_descriptor_size = 7 +
     414                                2* (instance->port_count / 8 +
     415                                ((instance->port_count % 8 > 0) ? 1 : 0));
     416                descriptor->total_length =
     417                                sizeof(usb_standard_configuration_descriptor_t)+
     418                                sizeof(usb_standard_endpoint_descriptor_t)+
     419                                sizeof(usb_standard_interface_descriptor_t)+
     420                                hub_descriptor_size;
     421                result_descriptor = descriptor;
     422                size = sizeof(usb_standard_configuration_descriptor_t);
     423                del = true;
     424                break;
     425        }
     426        case USB_DESCTYPE_INTERFACE: {
     427                usb_log_debug("USB_DESCTYPE_INTERFACE\n");
     428                result_descriptor = &ohci_rh_iface_descriptor;
     429                size = sizeof(ohci_rh_iface_descriptor);
     430                break;
     431        }
     432        case USB_DESCTYPE_ENDPOINT: {
     433                usb_log_debug("USB_DESCTYPE_ENDPOINT\n");
     434                result_descriptor = &ohci_rh_ep_descriptor;
     435                size = sizeof(ohci_rh_ep_descriptor);
     436                break;
     437        }
     438        default: {
     439                usb_log_debug("USB_DESCTYPE_EINVAL %d \n",setup_request->value);
     440                usb_log_debug("\ttype %d\n\trequest %d\n\tvalue %d\n\tindex %d\n\tlen %d\n ",
     441                                setup_request->request_type,
     442                                setup_request->request,
     443                                setup_request_value,
     444                                setup_request->index,
     445                                setup_request->length
     446                                );
     447                return EINVAL;
     448        }
     449        }
     450#endif
    335451        if(setup_request_value == USB_DESCTYPE_HUB){
    336452                usb_log_debug("USB_DESCTYPE_HUB\n");
     
    378494        request->transfered_size = size;
    379495        memcpy(request->buffer,result_descriptor,size);
    380         free(result_descriptor);
     496        if (result_descriptor)
     497                free(result_descriptor);
    381498        return EOK;
    382499}
Note: See TracChangeset for help on using the changeset viewer.