Ignore:
File:
1 edited

Legend:

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

    r60b3bea r361fcec  
    4545
    4646/**
    47  * standart device descriptor for ohci root hub
     47 *      standart device descriptor for ohci root hub
    4848 */
    4949static const usb_standard_device_descriptor_t ohci_rh_device_descriptor = {
     
    6969 */
    7070static const usb_standard_configuration_descriptor_t ohci_rh_conf_descriptor = {
     71        /// \TODO some values are default or guessed
    7172        .attributes = 1 << 7,
    7273        .configuration_number = 1,
     
    8687        .endpoint_count = 1,
    8788        .interface_class = USB_CLASS_HUB,
     89        /// \TODO is this correct?
    8890        .interface_number = 1,
    8991        .interface_protocol = 0,
     
    105107};
    106108
    107 /**
    108  * bitmask of hub features that are valid to be cleared
    109  */
    110109static const uint32_t hub_clear_feature_valid_mask =
    111     (1 << USB_HUB_FEATURE_C_HUB_LOCAL_POWER) |
     110        (1 << USB_HUB_FEATURE_C_HUB_LOCAL_POWER) |
    112111(1 << USB_HUB_FEATURE_C_HUB_OVER_CURRENT);
    113112
    114 /**
    115  * bitmask of hub features that are cleared by writing 1 (and not 0)
    116  */
    117113static const uint32_t hub_clear_feature_by_writing_one_mask =
    118     1 << USB_HUB_FEATURE_C_HUB_LOCAL_POWER;
    119 
    120 /**
    121  * bitmask of hub features that are valid to be set
    122  */
     114        1 << USB_HUB_FEATURE_C_HUB_LOCAL_POWER;
     115
    123116static const uint32_t hub_set_feature_valid_mask =
    124     (1 << USB_HUB_FEATURE_C_HUB_OVER_CURRENT) |
     117        (1 << USB_HUB_FEATURE_C_HUB_OVER_CURRENT) |
    125118(1 << USB_HUB_FEATURE_C_HUB_LOCAL_POWER);
    126119
    127 /**
    128  * bitmask of hub features that are set by writing 1 and cleared by writing 0
    129  */
     120
    130121static const uint32_t hub_set_feature_direct_mask =
    131     (1 << USB_HUB_FEATURE_C_HUB_OVER_CURRENT);
    132 
    133 /**
    134  * bitmask of port features that are valid to be set
    135  */
     122        (1 << USB_HUB_FEATURE_C_HUB_OVER_CURRENT);
     123
    136124static const uint32_t port_set_feature_valid_mask =
    137     (1 << USB_HUB_FEATURE_PORT_ENABLE) |
     125        (1 << USB_HUB_FEATURE_PORT_ENABLE) |
    138126(1 << USB_HUB_FEATURE_PORT_SUSPEND) |
    139127(1 << USB_HUB_FEATURE_PORT_RESET) |
    140128(1 << USB_HUB_FEATURE_PORT_POWER);
    141129
    142 /**
    143  * bitmask of port features that can be cleared
    144  */
    145130static const uint32_t port_clear_feature_valid_mask =
    146     (1 << USB_HUB_FEATURE_PORT_CONNECTION) |
     131        (1 << USB_HUB_FEATURE_PORT_CONNECTION) |
    147132(1 << USB_HUB_FEATURE_PORT_SUSPEND) |
    148133(1 << USB_HUB_FEATURE_PORT_OVER_CURRENT) |
     
    156141//USB_HUB_FEATURE_PORT_LOW_SPEED
    157142
    158 /**
    159  * bitmask with port status changes
    160  */
    161143static const uint32_t port_status_change_mask =
    162     (1 << USB_HUB_FEATURE_C_PORT_CONNECTION) |
    163 (1 << USB_HUB_FEATURE_C_PORT_ENABLE) |
    164 (1 << USB_HUB_FEATURE_C_PORT_OVER_CURRENT) |
    165 (1 << USB_HUB_FEATURE_C_PORT_RESET) |
    166 (1 << USB_HUB_FEATURE_C_PORT_SUSPEND);
     144(1<< USB_HUB_FEATURE_C_PORT_CONNECTION) |
     145(1<< USB_HUB_FEATURE_C_PORT_ENABLE) |
     146(1<< USB_HUB_FEATURE_C_PORT_OVER_CURRENT) |
     147(1<< USB_HUB_FEATURE_C_PORT_RESET) |
     148(1<< USB_HUB_FEATURE_C_PORT_SUSPEND);
    167149
    168150
     
    172154
    173155static int process_get_port_status_request(rh_t *instance, uint16_t port,
    174     usb_transfer_batch_t * request);
     156        usb_transfer_batch_t * request);
    175157
    176158static int process_get_hub_status_request(rh_t *instance,
    177     usb_transfer_batch_t * request);
     159        usb_transfer_batch_t * request);
    178160
    179161static int process_get_status_request(rh_t *instance,
    180     usb_transfer_batch_t * request);
     162        usb_transfer_batch_t * request);
    181163
    182164static void create_interrupt_mask_in_instance(rh_t *instance);
    183165
    184166static int process_get_descriptor_request(rh_t *instance,
    185     usb_transfer_batch_t *request);
     167        usb_transfer_batch_t *request);
    186168
    187169static int process_get_configuration_request(rh_t *instance,
    188     usb_transfer_batch_t *request);
     170        usb_transfer_batch_t *request);
    189171
    190172static int process_hub_feature_set_request(rh_t *instance, uint16_t feature);
    191173
    192174static int process_hub_feature_clear_request(rh_t *instance,
    193     uint16_t feature);
     175        uint16_t feature);
    194176
    195177static int process_port_feature_set_request(rh_t *instance,
    196     uint16_t feature, uint16_t port);
     178        uint16_t feature, uint16_t port);
    197179
    198180static int process_port_feature_clear_request(rh_t *instance,
    199     uint16_t feature, uint16_t port);
     181        uint16_t feature, uint16_t port);
    200182
    201183static int process_address_set_request(rh_t *instance,
    202     uint16_t address);
     184        uint16_t address);
    203185
    204186static int process_request_with_output(rh_t *instance,
    205     usb_transfer_batch_t *request);
     187        usb_transfer_batch_t *request);
    206188
    207189static int process_request_with_input(rh_t *instance,
    208     usb_transfer_batch_t *request);
     190        usb_transfer_batch_t *request);
    209191
    210192static int process_request_without_data(rh_t *instance,
    211     usb_transfer_batch_t *request);
     193        usb_transfer_batch_t *request);
    212194
    213195static int process_ctrl_request(rh_t *instance, usb_transfer_batch_t *request);
     
    216198
    217199static bool is_zeros(void * buffer, size_t size);
     200
     201
    218202
    219203/** Root hub initialization
     
    226210            (instance->registers->rh_desc_a >> RHDA_NDS_SHIFT) & RHDA_NDS_MASK;
    227211        int opResult = rh_init_descriptors(instance);
    228         if (opResult != EOK) {
     212        if(opResult != EOK){
    229213                return opResult;
    230214        }
     
    232216        instance->registers->rh_desc_a |= RHDA_NPS_FLAG;
    233217        instance->unfinished_interrupt_transfer = NULL;
    234         instance->interrupt_mask_size = (instance->port_count + 8) / 8;
     218        instance->interrupt_mask_size = (instance->port_count + 8)/8;
    235219        instance->interrupt_buffer = malloc(instance->interrupt_mask_size);
    236         if (!instance->interrupt_buffer)
     220        if(!instance->interrupt_buffer)
    237221                return ENOMEM;
    238 
    239         usb_log_info("OHCI root hub with %zu ports initialized.\n",
    240             instance->port_count);
    241 
     222       
     223
     224        usb_log_info("OHCI root hub with %d ports.\n", instance->port_count);
    242225        return EOK;
    243226}
     
    262245                usb_log_info("Root hub got INTERRUPT packet\n");
    263246                create_interrupt_mask_in_instance(instance);
    264                 if (is_zeros(instance->interrupt_buffer,
    265                     instance->interrupt_mask_size)) {
     247                if(is_zeros(instance->interrupt_buffer,
     248                    instance->interrupt_mask_size)){
    266249                        usb_log_debug("no changes..\n");
    267250                        instance->unfinished_interrupt_transfer = request;
    268251                        //will be finished later
    269                 } else {
     252                }else{
    270253                        usb_log_debug("processing changes..\n");
    271254                        process_interrupt_mask_in_instance(instance, request);
     
    273256                opResult = EOK;
    274257        } else {
    275 
    276258                opResult = EINVAL;
    277259                usb_transfer_batch_finish_error(request, opResult);
     
    289271 */
    290272void rh_interrupt(rh_t *instance) {
    291         if (!instance->unfinished_interrupt_transfer) {
     273        if(!instance->unfinished_interrupt_transfer){
    292274                return;
    293275        }
     
    310292static int create_serialized_hub_descriptor(rh_t *instance) {
    311293        size_t size = 7 +
    312             ((instance->port_count + 7) / 8) * 2;
    313         size_t var_size = (instance->port_count + 7) / 8;
     294            ((instance->port_count +7 )/ 8) * 2;
     295        size_t var_size = (instance->port_count +7 )/ 8;
    314296        uint8_t * result = (uint8_t*) malloc(size);
    315         if (!result) return ENOMEM;
     297        if(!result) return ENOMEM;
    316298
    317299        bzero(result, size);
     
    323305        uint32_t hub_desc_reg = instance->registers->rh_desc_a;
    324306        result[3] =
    325             ((hub_desc_reg >> 8) % 2) +
    326             (((hub_desc_reg >> 9) % 2) << 1) +
    327             (((hub_desc_reg >> 10) % 2) << 2) +
    328             (((hub_desc_reg >> 11) % 2) << 3) +
    329             (((hub_desc_reg >> 12) % 2) << 4);
     307                ((hub_desc_reg >> 8) % 2) +
     308                (((hub_desc_reg >> 9) % 2) << 1) +
     309                (((hub_desc_reg >> 10) % 2) << 2) +
     310                (((hub_desc_reg >> 11) % 2) << 3) +
     311                (((hub_desc_reg >> 12) % 2) << 4);
    330312        result[4] = 0;
    331313        result[5] = /*descriptor->pwr_on_2_good_time*/ 50;
    332314        result[6] = 50;
    333315
    334         size_t port;
     316        int port;
    335317        for (port = 1; port <= instance->port_count; ++port) {
    336318                uint8_t is_non_removable =
    337                     instance->registers->rh_desc_b >> port % 2;
     319                        instance->registers->rh_desc_b >> port % 2;
    338320                result[7 + port / 8] +=
    339                     is_non_removable << (port % 8);
     321                        is_non_removable << (port % 8);
    340322        }
    341323        size_t i;
     
    345327        instance->hub_descriptor = result;
    346328        instance->descriptor_size = size;
    347 
    348329        return EOK;
    349330}
     
    359340static int rh_init_descriptors(rh_t *instance) {
    360341        memcpy(&instance->descriptors.device, &ohci_rh_device_descriptor,
    361             sizeof (ohci_rh_device_descriptor)
    362             );
     342                sizeof (ohci_rh_device_descriptor)
     343                );
    363344        usb_standard_configuration_descriptor_t descriptor;
    364345        memcpy(&descriptor, &ohci_rh_conf_descriptor,
    365             sizeof (ohci_rh_conf_descriptor));
     346                sizeof (ohci_rh_conf_descriptor));
    366347
    367348        int opResult = create_serialized_hub_descriptor(instance);
    368         if (opResult != EOK) {
     349        if(opResult != EOK){
    369350                return opResult;
    370351        }
    371352        descriptor.total_length =
    372             sizeof (usb_standard_configuration_descriptor_t) +
    373             sizeof (usb_standard_endpoint_descriptor_t) +
    374             sizeof (usb_standard_interface_descriptor_t) +
    375             instance->descriptor_size;
     353                sizeof (usb_standard_configuration_descriptor_t) +
     354                sizeof (usb_standard_endpoint_descriptor_t) +
     355                sizeof (usb_standard_interface_descriptor_t) +
     356                instance->descriptor_size;
    376357
    377358        uint8_t * full_config_descriptor =
    378             (uint8_t*) malloc(descriptor.total_length);
    379         if (!full_config_descriptor) {
     359                (uint8_t*) malloc(descriptor.total_length);
     360        if(!full_config_descriptor){
    380361                return ENOMEM;
    381362        }
    382363        memcpy(full_config_descriptor, &descriptor, sizeof (descriptor));
    383364        memcpy(full_config_descriptor + sizeof (descriptor),
    384             &ohci_rh_iface_descriptor, sizeof (ohci_rh_iface_descriptor));
     365                &ohci_rh_iface_descriptor, sizeof (ohci_rh_iface_descriptor));
    385366        memcpy(full_config_descriptor + sizeof (descriptor) +
    386             sizeof (ohci_rh_iface_descriptor),
    387             &ohci_rh_ep_descriptor, sizeof (ohci_rh_ep_descriptor));
     367                sizeof (ohci_rh_iface_descriptor),
     368                &ohci_rh_ep_descriptor, sizeof (ohci_rh_ep_descriptor));
    388369        memcpy(full_config_descriptor + sizeof (descriptor) +
    389             sizeof (ohci_rh_iface_descriptor) +
    390             sizeof (ohci_rh_ep_descriptor),
    391             instance->hub_descriptor, instance->descriptor_size);
    392 
     370                sizeof (ohci_rh_iface_descriptor) +
     371                sizeof (ohci_rh_ep_descriptor),
     372                instance->hub_descriptor, instance->descriptor_size);
     373       
    393374        instance->descriptors.configuration = full_config_descriptor;
    394375        instance->descriptors.configuration_size = descriptor.total_length;
    395 
    396376        return EOK;
    397377}
     
    409389 */
    410390static int process_get_port_status_request(rh_t *instance, uint16_t port,
    411     usb_transfer_batch_t * request) {
     391        usb_transfer_batch_t * request) {
    412392        if (port < 1 || port > instance->port_count)
    413393                return EINVAL;
     
    418398        int i;
    419399        for (i = 0; i < instance->port_count; ++i) {
    420 
    421400                usb_log_debug("port status %d,x%x\n",
    422                     instance->registers->rh_port_status[i],
    423                     instance->registers->rh_port_status[i]);
     401                        instance->registers->rh_port_status[i],
     402                        instance->registers->rh_port_status[i]);
    424403        }
    425404#endif
     
    438417 */
    439418static int process_get_hub_status_request(rh_t *instance,
    440     usb_transfer_batch_t * request) {
     419        usb_transfer_batch_t * request) {
    441420        uint32_t * uint32_buffer = (uint32_t*) request->data_buffer;
    442421        request->transfered_size = 4;
     
    444423        uint32_t mask = 1 | (1 << 1) | (1 << 16) | (1 << 17);
    445424        uint32_buffer[0] = mask & instance->registers->rh_status;
    446 
    447425        return EOK;
    448426}
     
    459437 */
    460438static int process_get_status_request(rh_t *instance,
    461     usb_transfer_batch_t * request) {
     439        usb_transfer_batch_t * request) {
    462440        size_t buffer_size = request->buffer_size;
    463441        usb_device_request_setup_packet_t * request_packet =
    464             (usb_device_request_setup_packet_t*)
    465             request->setup_buffer;
     442                (usb_device_request_setup_packet_t*)
     443                request->setup_buffer;
    466444
    467445        usb_hub_bm_request_type_t request_type = request_packet->request_type;
     
    475453        if (request_type == USB_HUB_REQ_TYPE_GET_PORT_STATUS)
    476454                return process_get_port_status_request(instance,
    477             request_packet->index,
    478             request);
    479 
     455                request_packet->index,
     456                request);
    480457        return ENOTSUP;
    481458}
     
    495472        uint8_t * bitmap = (uint8_t*) (instance->interrupt_buffer);
    496473        uint32_t mask = (1 << (USB_HUB_FEATURE_C_HUB_LOCAL_POWER + 16))
    497             | (1 << (USB_HUB_FEATURE_C_HUB_OVER_CURRENT + 16));
     474                | (1 << (USB_HUB_FEATURE_C_HUB_OVER_CURRENT + 16));
    498475        bzero(bitmap, instance->interrupt_mask_size);
    499476        if (instance->registers->rh_status & mask) {
    500477                bitmap[0] = 1;
    501478        }
    502         size_t port;
     479        int port;
    503480        mask = port_status_change_mask;
    504481        for (port = 1; port <= instance->port_count; ++port) {
    505482                if (mask & instance->registers->rh_port_status[port - 1]) {
    506 
    507483                        bitmap[(port) / 8] += 1 << (port % 8);
    508484                }
     
    521497 */
    522498static int process_get_descriptor_request(rh_t *instance,
    523     usb_transfer_batch_t *request) {
     499        usb_transfer_batch_t *request) {
    524500        usb_device_request_setup_packet_t * setup_request =
    525             (usb_device_request_setup_packet_t*) request->setup_buffer;
     501                (usb_device_request_setup_packet_t*) request->setup_buffer;
    526502        size_t size;
    527503        const void * result_descriptor = NULL;
     
    567543                {
    568544                        usb_log_debug("USB_DESCTYPE_EINVAL %d \n",
    569                             setup_request->value);
     545                                setup_request->value);
    570546                        usb_log_debug("\ttype %d\n\trequest %d\n\tvalue "
    571                             "%d\n\tindex %d\n\tlen %d\n ",
    572                             setup_request->request_type,
    573                             setup_request->request,
    574                             setup_request_value,
    575                             setup_request->index,
    576                             setup_request->length
    577                             );
     547                                "%d\n\tindex %d\n\tlen %d\n ",
     548                                setup_request->request_type,
     549                                setup_request->request,
     550                                setup_request_value,
     551                                setup_request->index,
     552                                setup_request->length
     553                                );
    578554                        return EINVAL;
    579555                }
     
    584560        request->transfered_size = size;
    585561        memcpy(request->data_buffer, result_descriptor, size);
    586 
    587562        return EOK;
    588563}
     
    598573 */
    599574static int process_get_configuration_request(rh_t *instance,
    600     usb_transfer_batch_t *request) {
     575        usb_transfer_batch_t *request) {
    601576        //set and get configuration requests do not have any meaning, only dummy
    602577        //values are returned
     
    605580        request->data_buffer[0] = 1;
    606581        request->transfered_size = 1;
    607 
    608582        return EOK;
    609583}
     
    618592 */
    619593static int process_hub_feature_set_request(rh_t *instance,
    620     uint16_t feature) {
     594        uint16_t feature) {
    621595        if (!((1 << feature) & hub_set_feature_valid_mask))
    622596                return EINVAL;
    623         if (feature == USB_HUB_FEATURE_C_HUB_LOCAL_POWER)
     597        if(feature == USB_HUB_FEATURE_C_HUB_LOCAL_POWER)
    624598                feature = USB_HUB_FEATURE_C_HUB_LOCAL_POWER << 16;
    625599        instance->registers->rh_status =
    626             (instance->registers->rh_status | (1 << feature))
    627             & (~hub_clear_feature_by_writing_one_mask);
    628 
     600                (instance->registers->rh_status | (1 << feature))
     601                & (~hub_clear_feature_by_writing_one_mask);
    629602        return EOK;
    630603}
     
    639612 */
    640613static int process_hub_feature_clear_request(rh_t *instance,
    641     uint16_t feature) {
     614        uint16_t feature) {
    642615        if (!((1 << feature) & hub_clear_feature_valid_mask))
    643616                return EINVAL;
     
    645618        if ((1 << feature) & hub_set_feature_direct_mask) {
    646619                instance->registers->rh_status =
    647                     (instance->registers->rh_status & (~(1 << feature)))
    648                     & (~hub_clear_feature_by_writing_one_mask);
     620                        (instance->registers->rh_status & (~(1 << feature)))
     621                        & (~hub_clear_feature_by_writing_one_mask);
    649622        } else {//the feature is cleared by writing '1'
    650 
    651623                instance->registers->rh_status =
    652                     (instance->registers->rh_status
    653                     & (~hub_clear_feature_by_writing_one_mask))
    654                     | (1 << feature);
     624                        (instance->registers->rh_status
     625                        & (~hub_clear_feature_by_writing_one_mask))
     626                        | (1 << feature);
    655627        }
    656628        return EOK;
     
    668640 */
    669641static int process_port_feature_set_request(rh_t *instance,
    670     uint16_t feature, uint16_t port) {
     642        uint16_t feature, uint16_t port) {
    671643        if (!((1 << feature) & port_set_feature_valid_mask))
    672644                return EINVAL;
     
    674646                return EINVAL;
    675647        instance->registers->rh_port_status[port - 1] =
    676             (instance->registers->rh_port_status[port - 1] | (1 << feature))
    677             & (~port_clear_feature_valid_mask);
     648                (instance->registers->rh_port_status[port - 1] | (1 << feature))
     649                & (~port_clear_feature_valid_mask);
    678650        /// \TODO any error?
    679 
    680651        return EOK;
    681652}
     
    692663 */
    693664static int process_port_feature_clear_request(rh_t *instance,
    694     uint16_t feature, uint16_t port) {
     665        uint16_t feature, uint16_t port) {
    695666        if (!((1 << feature) & port_clear_feature_valid_mask))
    696667                return EINVAL;
     
    702673                feature = USB_HUB_FEATURE_PORT_OVER_CURRENT;
    703674        instance->registers->rh_port_status[port - 1] =
    704             (instance->registers->rh_port_status[port - 1]
    705             & (~port_clear_feature_valid_mask))
    706             | (1 << feature);
     675                (instance->registers->rh_port_status[port - 1]
     676                & (~port_clear_feature_valid_mask))
     677                | (1 << feature);
    707678        /// \TODO any error?
    708 
    709679        return EOK;
    710680}
     
    719689 */
    720690static int process_address_set_request(rh_t *instance,
    721     uint16_t address) {
     691        uint16_t address) {
    722692        instance->address = address;
    723 
    724693        return EOK;
    725694}
     
    736705 */
    737706static int process_request_with_output(rh_t *instance,
    738     usb_transfer_batch_t *request) {
     707        usb_transfer_batch_t *request) {
    739708        usb_device_request_setup_packet_t * setup_request =
    740             (usb_device_request_setup_packet_t*) request->setup_buffer;
     709                (usb_device_request_setup_packet_t*) request->setup_buffer;
    741710        if (setup_request->request == USB_DEVREQ_GET_STATUS) {
    742711                usb_log_debug("USB_DEVREQ_GET_STATUS\n");
     
    749718        if (setup_request->request == USB_DEVREQ_GET_CONFIGURATION) {
    750719                usb_log_debug("USB_DEVREQ_GET_CONFIGURATION\n");
    751 
    752720                return process_get_configuration_request(instance, request);
    753721        }
     
    766734 */
    767735static int process_request_with_input(rh_t *instance,
    768     usb_transfer_batch_t *request) {
     736        usb_transfer_batch_t *request) {
    769737        usb_device_request_setup_packet_t * setup_request =
    770             (usb_device_request_setup_packet_t*) request->setup_buffer;
     738                (usb_device_request_setup_packet_t*) request->setup_buffer;
    771739        request->transfered_size = 0;
    772740        if (setup_request->request == USB_DEVREQ_SET_DESCRIPTOR) {
     
    776744                //set and get configuration requests do not have any meaning,
    777745                //only dummy values are returned
    778 
    779746                return EOK;
    780747        }
     
    793760 */
    794761static int process_request_without_data(rh_t *instance,
    795     usb_transfer_batch_t *request) {
     762        usb_transfer_batch_t *request) {
    796763        usb_device_request_setup_packet_t * setup_request =
    797             (usb_device_request_setup_packet_t*) request->setup_buffer;
     764                (usb_device_request_setup_packet_t*) request->setup_buffer;
    798765        request->transfered_size = 0;
    799766        if (setup_request->request == USB_DEVREQ_CLEAR_FEATURE) {
     
    801768                        usb_log_debug("USB_HUB_REQ_TYPE_SET_HUB_FEATURE\n");
    802769                        return process_hub_feature_clear_request(instance,
    803                             setup_request->value);
     770                                setup_request->value);
    804771                }
    805772                if (setup_request->request_type == USB_HUB_REQ_TYPE_SET_PORT_FEATURE) {
    806773                        usb_log_debug("USB_HUB_REQ_TYPE_SET_PORT_FEATURE\n");
    807774                        return process_port_feature_clear_request(instance,
    808                             setup_request->value,
    809                             setup_request->index);
     775                                setup_request->value,
     776                                setup_request->index);
    810777                }
    811778                usb_log_debug("USB_HUB_REQ_TYPE_INVALID %d\n",
    812                     setup_request->request_type);
     779                        setup_request->request_type);
    813780                return EINVAL;
    814781        }
     
    817784                        usb_log_debug("USB_HUB_REQ_TYPE_SET_HUB_FEATURE\n");
    818785                        return process_hub_feature_set_request(instance,
    819                             setup_request->value);
     786                                setup_request->value);
    820787                }
    821788                if (setup_request->request_type == USB_HUB_REQ_TYPE_SET_PORT_FEATURE) {
    822789                        usb_log_debug("USB_HUB_REQ_TYPE_SET_PORT_FEATURE\n");
    823790                        return process_port_feature_set_request(instance,
    824                             setup_request->value,
    825                             setup_request->index);
     791                                setup_request->value,
     792                                setup_request->index);
    826793                }
    827794                usb_log_debug("USB_HUB_REQ_TYPE_INVALID %d\n",
    828                     setup_request->request_type);
     795                        setup_request->request_type);
    829796                return EINVAL;
    830797        }
     
    832799                usb_log_debug("USB_DEVREQ_SET_ADDRESS\n");
    833800                return process_address_set_request(instance,
    834                     setup_request->value);
     801                        setup_request->value);
    835802        }
    836803        usb_log_debug("USB_DEVREQ_SET_ENOTSUP %d\n",
    837             setup_request->request_type);
    838 
     804                setup_request->request_type);
    839805        return ENOTSUP;
    840806}
     
    870836        }
    871837        usb_log_info("CTRL packet: %s.\n",
    872             usb_debug_str_buffer(
    873             (const uint8_t *) request->setup_buffer, 8, 8));
     838                usb_debug_str_buffer(
     839                (const uint8_t *) request->setup_buffer, 8, 8));
    874840        usb_device_request_setup_packet_t * setup_request =
    875             (usb_device_request_setup_packet_t*)
    876             request->setup_buffer;
     841                (usb_device_request_setup_packet_t*)
     842                request->setup_buffer;
    877843        switch (setup_request->request) {
    878844                case USB_DEVREQ_GET_STATUS:
     
    881847                        usb_log_debug("processing request with output\n");
    882848                        opResult = process_request_with_output(
    883                             instance, request);
     849                                instance, request);
    884850                        break;
    885851                case USB_DEVREQ_CLEAR_FEATURE:
     
    887853                case USB_DEVREQ_SET_ADDRESS:
    888854                        usb_log_debug("processing request without "
    889                             "additional data\n");
     855                                "additional data\n");
    890856                        opResult = process_request_without_data(
    891                             instance, request);
     857                                instance, request);
    892858                        break;
    893859                case USB_DEVREQ_SET_DESCRIPTOR:
    894860                case USB_DEVREQ_SET_CONFIGURATION:
    895861                        usb_log_debug("processing request with "
    896                             "input\n");
     862                                "input\n");
    897863                        opResult = process_request_with_input(
    898                             instance, request);
    899 
     864                                instance, request);
    900865                        break;
    901866                default:
    902867                        usb_log_warning("received unsuported request: "
    903                             "%d\n",
    904                             setup_request->request
    905                             );
     868                                "%d\n",
     869                                setup_request->request
     870                                );
    906871                        opResult = ENOTSUP;
    907872        }
     
    923888 * @return
    924889 */
    925 static int process_interrupt_mask_in_instance(rh_t *instance, usb_transfer_batch_t * request) {
     890static int process_interrupt_mask_in_instance(rh_t *instance, usb_transfer_batch_t * request){
    926891        memcpy(request->data_buffer, instance->interrupt_buffer,
    927892            instance->interrupt_mask_size);
     
    929894        instance->unfinished_interrupt_transfer = NULL;
    930895        usb_transfer_batch_finish_error(request, EOK);
    931 
    932896        return EOK;
    933897}
     
    943907 * @return
    944908 */
    945 static bool is_zeros(void * buffer, size_t size) {
    946         if (!buffer) return true;
    947         if (!size) return true;
     909static bool is_zeros(void * buffer, size_t size){
     910        if(!buffer) return true;
     911        if(!size) return true;
    948912        size_t i;
    949         for (i = 0; i < size; ++i) {
    950                 if (((char*) buffer)[i])
     913        for(i=0;i<size;++i){
     914                if(((char*)buffer)[i])
    951915                        return false;
    952916        }
Note: See TracChangeset for help on using the changeset viewer.