Changes in / [3b543d5:6c6a95d2] in mainline


Ignore:
Location:
uspace/drv
Files:
4 edited

Legend:

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

    r3b543d5 r6c6a95d2  
    108108
    109109static const uint32_t hub_clear_feature_valid_mask =
    110     (1 << USB_HUB_FEATURE_C_HUB_LOCAL_POWER) |
     110        (1 << USB_HUB_FEATURE_C_HUB_LOCAL_POWER) |
    111111(1 << USB_HUB_FEATURE_C_HUB_OVER_CURRENT);
    112112
    113113static const uint32_t hub_clear_feature_by_writing_one_mask =
    114     1 << USB_HUB_FEATURE_C_HUB_LOCAL_POWER;
     114        1 << USB_HUB_FEATURE_C_HUB_LOCAL_POWER;
    115115
    116116static const uint32_t hub_set_feature_valid_mask =
    117     (1 << USB_HUB_FEATURE_C_HUB_OVER_CURRENT) |
     117        (1 << USB_HUB_FEATURE_C_HUB_OVER_CURRENT) |
    118118(1 << USB_HUB_FEATURE_C_HUB_LOCAL_POWER);
    119119
    120120
    121121static const uint32_t hub_set_feature_direct_mask =
    122     (1 << USB_HUB_FEATURE_C_HUB_OVER_CURRENT);
     122        (1 << USB_HUB_FEATURE_C_HUB_OVER_CURRENT);
    123123
    124124static const uint32_t port_set_feature_valid_mask =
    125     (1 << USB_HUB_FEATURE_PORT_ENABLE) |
     125        (1 << USB_HUB_FEATURE_PORT_ENABLE) |
    126126(1 << USB_HUB_FEATURE_PORT_SUSPEND) |
    127127(1 << USB_HUB_FEATURE_PORT_RESET) |
     
    129129
    130130static const uint32_t port_clear_feature_valid_mask =
    131     (1 << USB_HUB_FEATURE_PORT_CONNECTION) |
     131        (1 << USB_HUB_FEATURE_PORT_CONNECTION) |
    132132(1 << USB_HUB_FEATURE_PORT_SUSPEND) |
    133133(1 << USB_HUB_FEATURE_PORT_OVER_CURRENT) |
     
    142142
    143143static const uint32_t port_status_change_mask =
    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);
     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);
    149149
    150150
     
    153153static int rh_init_descriptors(rh_t *instance);
    154154
    155 static void rh_check_port_connectivity(rh_t * instance);
    156 
    157155static int process_get_port_status_request(rh_t *instance, uint16_t port,
    158     usb_transfer_batch_t * request);
     156        usb_transfer_batch_t * request);
    159157
    160158static int process_get_hub_status_request(rh_t *instance,
    161     usb_transfer_batch_t * request);
     159        usb_transfer_batch_t * request);
    162160
    163161static int process_get_status_request(rh_t *instance,
    164     usb_transfer_batch_t * request);
     162        usb_transfer_batch_t * request);
    165163
    166164static void create_interrupt_mask_in_instance(rh_t *instance);
    167165
    168166static int process_get_descriptor_request(rh_t *instance,
    169     usb_transfer_batch_t *request);
     167        usb_transfer_batch_t *request);
    170168
    171169static int process_get_configuration_request(rh_t *instance,
    172     usb_transfer_batch_t *request);
     170        usb_transfer_batch_t *request);
    173171
    174172static int process_hub_feature_set_request(rh_t *instance, uint16_t feature);
    175173
    176174static int process_hub_feature_clear_request(rh_t *instance,
    177     uint16_t feature);
     175        uint16_t feature);
    178176
    179177static int process_port_feature_set_request(rh_t *instance,
    180     uint16_t feature, uint16_t port);
     178        uint16_t feature, uint16_t port);
    181179
    182180static int process_port_feature_clear_request(rh_t *instance,
    183     uint16_t feature, uint16_t port);
     181        uint16_t feature, uint16_t port);
    184182
    185183static int process_address_set_request(rh_t *instance,
    186     uint16_t address);
     184        uint16_t address);
    187185
    188186static int process_request_with_output(rh_t *instance,
    189     usb_transfer_batch_t *request);
     187        usb_transfer_batch_t *request);
    190188
    191189static int process_request_with_input(rh_t *instance,
    192     usb_transfer_batch_t *request);
     190        usb_transfer_batch_t *request);
    193191
    194192static int process_request_without_data(rh_t *instance,
    195     usb_transfer_batch_t *request);
     193        usb_transfer_batch_t *request);
    196194
    197195static int process_ctrl_request(rh_t *instance, usb_transfer_batch_t *request);
     
    200198
    201199static bool is_zeros(void * buffer, size_t size);
     200
     201
    202202
    203203/** Root hub initialization
     
    210210            (instance->registers->rh_desc_a >> RHDA_NDS_SHIFT) & RHDA_NDS_MASK;
    211211        int opResult = rh_init_descriptors(instance);
    212         if (opResult != EOK) {
     212        if(opResult != EOK){
    213213                return opResult;
    214214        }
     
    216216        instance->registers->rh_desc_a |= RHDA_NPS_FLAG;
    217217        instance->unfinished_interrupt_transfer = NULL;
    218         instance->interrupt_mask_size = (instance->port_count + 8) / 8;
     218        instance->interrupt_mask_size = (instance->port_count + 8)/8;
    219219        instance->interrupt_buffer = malloc(instance->interrupt_mask_size);
    220         if (!instance->interrupt_buffer)
     220        if(!instance->interrupt_buffer)
    221221                return ENOMEM;
    222         rh_check_port_connectivity(instance);
    223 
     222       
    224223
    225224        usb_log_info("OHCI root hub with %d ports.\n", instance->port_count);
    226 
    227225        return EOK;
    228226}
     
    247245                usb_log_info("Root hub got INTERRUPT packet\n");
    248246                create_interrupt_mask_in_instance(instance);
    249                 if (is_zeros(instance->interrupt_buffer,
    250                     instance->interrupt_mask_size)) {
     247                if(is_zeros(instance->interrupt_buffer,
     248                    instance->interrupt_mask_size)){
    251249                        usb_log_debug("no changes..\n");
    252250                        instance->unfinished_interrupt_transfer = request;
    253251                        //will be finished later
    254                 } else {
     252                }else{
    255253                        usb_log_debug("processing changes..\n");
    256254                        process_interrupt_mask_in_instance(instance, request);
     
    258256                opResult = EOK;
    259257        } else {
    260 
    261258                opResult = EINVAL;
    262259                usb_transfer_batch_finish_error(request, opResult);
     
    274271 */
    275272void rh_interrupt(rh_t *instance) {
    276         if (!instance->unfinished_interrupt_transfer) {
    277 
     273        if(!instance->unfinished_interrupt_transfer){
    278274                return;
    279275        }
     
    296292static int create_serialized_hub_descriptor(rh_t *instance) {
    297293        size_t size = 7 +
    298             ((instance->port_count + 7) / 8) * 2;
    299         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;
    300296        uint8_t * result = (uint8_t*) malloc(size);
    301         if (!result) return ENOMEM;
     297        if(!result) return ENOMEM;
    302298
    303299        bzero(result, size);
     
    309305        uint32_t hub_desc_reg = instance->registers->rh_desc_a;
    310306        result[3] =
    311             ((hub_desc_reg >> 8) % 2) +
    312             (((hub_desc_reg >> 9) % 2) << 1) +
    313             (((hub_desc_reg >> 10) % 2) << 2) +
    314             (((hub_desc_reg >> 11) % 2) << 3) +
    315             (((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);
    316312        result[4] = 0;
    317313        result[5] = /*descriptor->pwr_on_2_good_time*/ 50;
    318314        result[6] = 50;
    319315
    320         size_t port;
     316        int port;
    321317        for (port = 1; port <= instance->port_count; ++port) {
    322318                uint8_t is_non_removable =
    323                     instance->registers->rh_desc_b >> port % 2;
     319                        instance->registers->rh_desc_b >> port % 2;
    324320                result[7 + port / 8] +=
    325                     is_non_removable << (port % 8);
     321                        is_non_removable << (port % 8);
    326322        }
    327323        size_t i;
     
    331327        instance->hub_descriptor = result;
    332328        instance->descriptor_size = size;
    333 
    334329        return EOK;
    335330}
     
    345340static int rh_init_descriptors(rh_t *instance) {
    346341        memcpy(&instance->descriptors.device, &ohci_rh_device_descriptor,
    347             sizeof (ohci_rh_device_descriptor)
    348             );
     342                sizeof (ohci_rh_device_descriptor)
     343                );
    349344        usb_standard_configuration_descriptor_t descriptor;
    350345        memcpy(&descriptor, &ohci_rh_conf_descriptor,
    351             sizeof (ohci_rh_conf_descriptor));
     346                sizeof (ohci_rh_conf_descriptor));
    352347
    353348        int opResult = create_serialized_hub_descriptor(instance);
    354         if (opResult != EOK) {
     349        if(opResult != EOK){
    355350                return opResult;
    356351        }
    357352        descriptor.total_length =
    358             sizeof (usb_standard_configuration_descriptor_t) +
    359             sizeof (usb_standard_endpoint_descriptor_t) +
    360             sizeof (usb_standard_interface_descriptor_t) +
    361             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;
    362357
    363358        uint8_t * full_config_descriptor =
    364             (uint8_t*) malloc(descriptor.total_length);
    365         if (!full_config_descriptor) {
     359                (uint8_t*) malloc(descriptor.total_length);
     360        if(!full_config_descriptor){
    366361                return ENOMEM;
    367362        }
    368363        memcpy(full_config_descriptor, &descriptor, sizeof (descriptor));
    369364        memcpy(full_config_descriptor + sizeof (descriptor),
    370             &ohci_rh_iface_descriptor, sizeof (ohci_rh_iface_descriptor));
     365                &ohci_rh_iface_descriptor, sizeof (ohci_rh_iface_descriptor));
    371366        memcpy(full_config_descriptor + sizeof (descriptor) +
    372             sizeof (ohci_rh_iface_descriptor),
    373             &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));
    374369        memcpy(full_config_descriptor + sizeof (descriptor) +
    375             sizeof (ohci_rh_iface_descriptor) +
    376             sizeof (ohci_rh_ep_descriptor),
    377             instance->hub_descriptor, instance->descriptor_size);
    378 
     370                sizeof (ohci_rh_iface_descriptor) +
     371                sizeof (ohci_rh_ep_descriptor),
     372                instance->hub_descriptor, instance->descriptor_size);
     373       
    379374        instance->descriptors.configuration = full_config_descriptor;
    380375        instance->descriptors.configuration_size = descriptor.total_length;
    381 
    382         return EOK;
    383 }
    384 /*----------------------------------------------------------------------------*/
    385 
    386 /**
    387  * check whether there are connected devices on ports and if yes, indicate
    388  * connection change
    389  *
    390  * @param instance
    391  */
    392 static void rh_check_port_connectivity(rh_t * instance) {
    393         size_t port;
    394         for (port = 1; port < instance->port_count; ++port) {
    395                 bool connected =
    396                     ((instance->registers->rh_port_status[port - 1]) &
    397                     (1 << USB_HUB_FEATURE_PORT_CONNECTION)) != 0;
    398                 if (connected) {
    399                         usb_log_debug("port %d has connected device\n", port);
    400                         instance->registers->rh_port_status[port - 1] =
    401                             instance->registers->rh_port_status[port - 1]
    402                             | (1 << USB_HUB_FEATURE_C_PORT_CONNECTION);
    403                         usb_log_debug("change indicated to status "
    404                             "register\n");
    405                 }
    406         }
    407 }
    408 
    409 
     376        return EOK;
     377}
    410378/*----------------------------------------------------------------------------*/
    411379
     
    421389 */
    422390static int process_get_port_status_request(rh_t *instance, uint16_t port,
    423     usb_transfer_batch_t * request) {
     391        usb_transfer_batch_t * request) {
    424392        if (port < 1 || port > instance->port_count)
    425393                return EINVAL;
     
    430398        int i;
    431399        for (i = 0; i < instance->port_count; ++i) {
    432 
    433400                usb_log_debug("port status %d,x%x\n",
    434                     instance->registers->rh_port_status[i],
    435                     instance->registers->rh_port_status[i]);
     401                        instance->registers->rh_port_status[i],
     402                        instance->registers->rh_port_status[i]);
    436403        }
    437404#endif
     
    450417 */
    451418static int process_get_hub_status_request(rh_t *instance,
    452     usb_transfer_batch_t * request) {
     419        usb_transfer_batch_t * request) {
    453420        uint32_t * uint32_buffer = (uint32_t*) request->data_buffer;
    454421        request->transfered_size = 4;
     
    456423        uint32_t mask = 1 | (1 << 1) | (1 << 16) | (1 << 17);
    457424        uint32_buffer[0] = mask & instance->registers->rh_status;
    458 
    459425        return EOK;
    460426}
     
    471437 */
    472438static int process_get_status_request(rh_t *instance,
    473     usb_transfer_batch_t * request) {
     439        usb_transfer_batch_t * request) {
    474440        size_t buffer_size = request->buffer_size;
    475441        usb_device_request_setup_packet_t * request_packet =
    476             (usb_device_request_setup_packet_t*)
    477             request->setup_buffer;
     442                (usb_device_request_setup_packet_t*)
     443                request->setup_buffer;
    478444
    479445        usb_hub_bm_request_type_t request_type = request_packet->request_type;
     
    487453        if (request_type == USB_HUB_REQ_TYPE_GET_PORT_STATUS)
    488454                return process_get_port_status_request(instance,
    489             request_packet->index,
    490             request);
    491 
     455                request_packet->index,
     456                request);
    492457        return ENOTSUP;
    493458}
     
    507472        uint8_t * bitmap = (uint8_t*) (instance->interrupt_buffer);
    508473        uint32_t mask = (1 << (USB_HUB_FEATURE_C_HUB_LOCAL_POWER + 16))
    509             | (1 << (USB_HUB_FEATURE_C_HUB_OVER_CURRENT + 16));
     474                | (1 << (USB_HUB_FEATURE_C_HUB_OVER_CURRENT + 16));
    510475        bzero(bitmap, instance->interrupt_mask_size);
    511476        if (instance->registers->rh_status & mask) {
    512477                bitmap[0] = 1;
    513478        }
    514         size_t port;
     479        int port;
    515480        mask = port_status_change_mask;
    516481        for (port = 1; port <= instance->port_count; ++port) {
    517482                if (mask & instance->registers->rh_port_status[port - 1]) {
    518 
    519483                        bitmap[(port) / 8] += 1 << (port % 8);
    520484                }
     
    533497 */
    534498static int process_get_descriptor_request(rh_t *instance,
    535     usb_transfer_batch_t *request) {
     499        usb_transfer_batch_t *request) {
    536500        usb_device_request_setup_packet_t * setup_request =
    537             (usb_device_request_setup_packet_t*) request->setup_buffer;
     501                (usb_device_request_setup_packet_t*) request->setup_buffer;
    538502        size_t size;
    539503        const void * result_descriptor = NULL;
     
    579543                {
    580544                        usb_log_debug("USB_DESCTYPE_EINVAL %d \n",
    581                             setup_request->value);
     545                                setup_request->value);
    582546                        usb_log_debug("\ttype %d\n\trequest %d\n\tvalue "
    583                             "%d\n\tindex %d\n\tlen %d\n ",
    584                             setup_request->request_type,
    585                             setup_request->request,
    586                             setup_request_value,
    587                             setup_request->index,
    588                             setup_request->length
    589                             );
     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                                );
    590554                        return EINVAL;
    591555                }
     
    596560        request->transfered_size = size;
    597561        memcpy(request->data_buffer, result_descriptor, size);
    598 
    599562        return EOK;
    600563}
     
    610573 */
    611574static int process_get_configuration_request(rh_t *instance,
    612     usb_transfer_batch_t *request) {
     575        usb_transfer_batch_t *request) {
    613576        //set and get configuration requests do not have any meaning, only dummy
    614577        //values are returned
     
    617580        request->data_buffer[0] = 1;
    618581        request->transfered_size = 1;
    619 
    620582        return EOK;
    621583}
     
    630592 */
    631593static int process_hub_feature_set_request(rh_t *instance,
    632     uint16_t feature) {
     594        uint16_t feature) {
    633595        if (!((1 << feature) & hub_set_feature_valid_mask))
    634596                return EINVAL;
    635         if (feature == USB_HUB_FEATURE_C_HUB_LOCAL_POWER)
     597        if(feature == USB_HUB_FEATURE_C_HUB_LOCAL_POWER)
    636598                feature = USB_HUB_FEATURE_C_HUB_LOCAL_POWER << 16;
    637599        instance->registers->rh_status =
    638             (instance->registers->rh_status | (1 << feature))
    639             & (~hub_clear_feature_by_writing_one_mask);
    640 
     600                (instance->registers->rh_status | (1 << feature))
     601                & (~hub_clear_feature_by_writing_one_mask);
    641602        return EOK;
    642603}
     
    651612 */
    652613static int process_hub_feature_clear_request(rh_t *instance,
    653     uint16_t feature) {
     614        uint16_t feature) {
    654615        if (!((1 << feature) & hub_clear_feature_valid_mask))
    655616                return EINVAL;
     
    657618        if ((1 << feature) & hub_set_feature_direct_mask) {
    658619                instance->registers->rh_status =
    659                     (instance->registers->rh_status & (~(1 << feature)))
    660                     & (~hub_clear_feature_by_writing_one_mask);
     620                        (instance->registers->rh_status & (~(1 << feature)))
     621                        & (~hub_clear_feature_by_writing_one_mask);
    661622        } else {//the feature is cleared by writing '1'
    662 
    663623                instance->registers->rh_status =
    664                     (instance->registers->rh_status
    665                     & (~hub_clear_feature_by_writing_one_mask))
    666                     | (1 << feature);
     624                        (instance->registers->rh_status
     625                        & (~hub_clear_feature_by_writing_one_mask))
     626                        | (1 << feature);
    667627        }
    668628        return EOK;
     
    680640 */
    681641static int process_port_feature_set_request(rh_t *instance,
    682     uint16_t feature, uint16_t port) {
     642        uint16_t feature, uint16_t port) {
    683643        if (!((1 << feature) & port_set_feature_valid_mask))
    684644                return EINVAL;
     
    686646                return EINVAL;
    687647        instance->registers->rh_port_status[port - 1] =
    688             (instance->registers->rh_port_status[port - 1] | (1 << feature))
    689             & (~port_clear_feature_valid_mask);
     648                (instance->registers->rh_port_status[port - 1] | (1 << feature))
     649                & (~port_clear_feature_valid_mask);
    690650        /// \TODO any error?
    691 
    692651        return EOK;
    693652}
     
    704663 */
    705664static int process_port_feature_clear_request(rh_t *instance,
    706     uint16_t feature, uint16_t port) {
     665        uint16_t feature, uint16_t port) {
    707666        if (!((1 << feature) & port_clear_feature_valid_mask))
    708667                return EINVAL;
     
    714673                feature = USB_HUB_FEATURE_PORT_OVER_CURRENT;
    715674        instance->registers->rh_port_status[port - 1] =
    716             (instance->registers->rh_port_status[port - 1]
    717             & (~port_clear_feature_valid_mask))
    718             | (1 << feature);
     675                (instance->registers->rh_port_status[port - 1]
     676                & (~port_clear_feature_valid_mask))
     677                | (1 << feature);
    719678        /// \TODO any error?
    720 
    721679        return EOK;
    722680}
     
    731689 */
    732690static int process_address_set_request(rh_t *instance,
    733     uint16_t address) {
     691        uint16_t address) {
    734692        instance->address = address;
    735 
    736693        return EOK;
    737694}
     
    748705 */
    749706static int process_request_with_output(rh_t *instance,
    750     usb_transfer_batch_t *request) {
     707        usb_transfer_batch_t *request) {
    751708        usb_device_request_setup_packet_t * setup_request =
    752             (usb_device_request_setup_packet_t*) request->setup_buffer;
     709                (usb_device_request_setup_packet_t*) request->setup_buffer;
    753710        if (setup_request->request == USB_DEVREQ_GET_STATUS) {
    754711                usb_log_debug("USB_DEVREQ_GET_STATUS\n");
     
    761718        if (setup_request->request == USB_DEVREQ_GET_CONFIGURATION) {
    762719                usb_log_debug("USB_DEVREQ_GET_CONFIGURATION\n");
    763 
    764720                return process_get_configuration_request(instance, request);
    765721        }
     
    778734 */
    779735static int process_request_with_input(rh_t *instance,
    780     usb_transfer_batch_t *request) {
     736        usb_transfer_batch_t *request) {
    781737        usb_device_request_setup_packet_t * setup_request =
    782             (usb_device_request_setup_packet_t*) request->setup_buffer;
     738                (usb_device_request_setup_packet_t*) request->setup_buffer;
    783739        request->transfered_size = 0;
    784740        if (setup_request->request == USB_DEVREQ_SET_DESCRIPTOR) {
     
    788744                //set and get configuration requests do not have any meaning,
    789745                //only dummy values are returned
    790 
    791746                return EOK;
    792747        }
     
    805760 */
    806761static int process_request_without_data(rh_t *instance,
    807     usb_transfer_batch_t *request) {
     762        usb_transfer_batch_t *request) {
    808763        usb_device_request_setup_packet_t * setup_request =
    809             (usb_device_request_setup_packet_t*) request->setup_buffer;
     764                (usb_device_request_setup_packet_t*) request->setup_buffer;
    810765        request->transfered_size = 0;
    811766        if (setup_request->request == USB_DEVREQ_CLEAR_FEATURE) {
     
    813768                        usb_log_debug("USB_HUB_REQ_TYPE_SET_HUB_FEATURE\n");
    814769                        return process_hub_feature_clear_request(instance,
    815                             setup_request->value);
     770                                setup_request->value);
    816771                }
    817772                if (setup_request->request_type == USB_HUB_REQ_TYPE_SET_PORT_FEATURE) {
    818773                        usb_log_debug("USB_HUB_REQ_TYPE_SET_PORT_FEATURE\n");
    819774                        return process_port_feature_clear_request(instance,
    820                             setup_request->value,
    821                             setup_request->index);
     775                                setup_request->value,
     776                                setup_request->index);
    822777                }
    823778                usb_log_debug("USB_HUB_REQ_TYPE_INVALID %d\n",
    824                     setup_request->request_type);
     779                        setup_request->request_type);
    825780                return EINVAL;
    826781        }
     
    829784                        usb_log_debug("USB_HUB_REQ_TYPE_SET_HUB_FEATURE\n");
    830785                        return process_hub_feature_set_request(instance,
    831                             setup_request->value);
     786                                setup_request->value);
    832787                }
    833788                if (setup_request->request_type == USB_HUB_REQ_TYPE_SET_PORT_FEATURE) {
    834789                        usb_log_debug("USB_HUB_REQ_TYPE_SET_PORT_FEATURE\n");
    835790                        return process_port_feature_set_request(instance,
    836                             setup_request->value,
    837                             setup_request->index);
     791                                setup_request->value,
     792                                setup_request->index);
    838793                }
    839794                usb_log_debug("USB_HUB_REQ_TYPE_INVALID %d\n",
    840                     setup_request->request_type);
     795                        setup_request->request_type);
    841796                return EINVAL;
    842797        }
     
    844799                usb_log_debug("USB_DEVREQ_SET_ADDRESS\n");
    845800                return process_address_set_request(instance,
    846                     setup_request->value);
     801                        setup_request->value);
    847802        }
    848803        usb_log_debug("USB_DEVREQ_SET_ENOTSUP %d\n",
    849             setup_request->request_type);
    850 
     804                setup_request->request_type);
    851805        return ENOTSUP;
    852806}
     
    882836        }
    883837        usb_log_info("CTRL packet: %s.\n",
    884             usb_debug_str_buffer(
    885             (const uint8_t *) request->setup_buffer, 8, 8));
     838                usb_debug_str_buffer(
     839                (const uint8_t *) request->setup_buffer, 8, 8));
    886840        usb_device_request_setup_packet_t * setup_request =
    887             (usb_device_request_setup_packet_t*)
    888             request->setup_buffer;
     841                (usb_device_request_setup_packet_t*)
     842                request->setup_buffer;
    889843        switch (setup_request->request) {
    890844                case USB_DEVREQ_GET_STATUS:
     
    893847                        usb_log_debug("processing request with output\n");
    894848                        opResult = process_request_with_output(
    895                             instance, request);
     849                                instance, request);
    896850                        break;
    897851                case USB_DEVREQ_CLEAR_FEATURE:
     
    899853                case USB_DEVREQ_SET_ADDRESS:
    900854                        usb_log_debug("processing request without "
    901                             "additional data\n");
     855                                "additional data\n");
    902856                        opResult = process_request_without_data(
    903                             instance, request);
     857                                instance, request);
    904858                        break;
    905859                case USB_DEVREQ_SET_DESCRIPTOR:
    906860                case USB_DEVREQ_SET_CONFIGURATION:
    907861                        usb_log_debug("processing request with "
    908                             "input\n");
     862                                "input\n");
    909863                        opResult = process_request_with_input(
    910                             instance, request);
    911 
     864                                instance, request);
    912865                        break;
    913866                default:
    914867                        usb_log_warning("received unsuported request: "
    915                             "%d\n",
    916                             setup_request->request
    917                             );
     868                                "%d\n",
     869                                setup_request->request
     870                                );
    918871                        opResult = ENOTSUP;
    919872        }
     
    935888 * @return
    936889 */
    937 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){
    938891        memcpy(request->data_buffer, instance->interrupt_buffer,
    939892            instance->interrupt_mask_size);
     
    941894        instance->unfinished_interrupt_transfer = NULL;
    942895        usb_transfer_batch_finish_error(request, EOK);
    943 
    944896        return EOK;
    945897}
     
    955907 * @return
    956908 */
    957 static bool is_zeros(void * buffer, size_t size) {
    958         if (!buffer) return true;
    959         if (!size) return true;
     909static bool is_zeros(void * buffer, size_t size){
     910        if(!buffer) return true;
     911        if(!size) return true;
    960912        size_t i;
    961         for (i = 0; i < size; ++i) {
    962                 if (((char*) buffer)[i])
     913        for(i=0;i<size;++i){
     914                if(((char*)buffer)[i])
    963915                        return false;
    964916        }
  • uspace/drv/ohci/root_hub.h

    r3b543d5 r6c6a95d2  
    5151        usb_address_t address;
    5252        /** hub port count */
    53         size_t port_count;
     53        int port_count;
    5454        /** hubs descriptors */
    5555        usb_device_descriptors_t descriptors;
  • uspace/drv/usbhid/main.c

    r3b543d5 r6c6a95d2  
    202202        printf(NAME ": HelenOS USB HID driver.\n");
    203203
    204         //usb_log_enable(USB_LOG_LEVEL_DEBUG, NAME);
     204        usb_log_enable(USB_LOG_LEVEL_DEBUG, NAME);
    205205
    206206        return usb_driver_main(&usb_hid_driver);
  • uspace/drv/usbhub/ports.c

    r3b543d5 r6c6a95d2  
    137137            &status, USB_HUB_FEATURE_C_PORT_OVER_CURRENT,false);
    138138        /// \TODO what about port power change?
    139         unsigned int bit_idx;
    140         for(bit_idx = 16;bit_idx<32;++bit_idx){
    141                 if(status & (1<<bit_idx)){
    142                         usb_log_info(
    143                             "there was unsupported change on port %d: %d\n",
    144                         port, bit_idx);
    145                         int opResult = usb_hub_clear_port_feature(
    146                             hub->control_pipe,
    147                             port, USB_HUB_FEATURE_C_PORT_CONNECTION);
    148                         if (opResult != EOK) {
    149                                 usb_log_warning(
    150                                     "could not clear port flag %d: %d\n",
    151                                     bit_idx, opResult
    152                                     );
    153                         }
    154                         usb_port_status_set_bit(
    155                             &status, bit_idx,false);
    156                 }
    157         }
    158139        if (status >> 16) {
    159140                usb_log_info("there was unsupported change on port %d: %X\n",
    160141                        port, status);
     142
    161143        }
    162144}
     
    240222                    "Port %zu reset complete but port not enabled.\n",
    241223                    (size_t) port);
    242         }
    243         /* Clear the port reset change. */
    244         int rc = usb_hub_clear_port_feature(hub->control_pipe,
    245             port, USB_HUB_FEATURE_C_PORT_RESET);
    246         if (rc != EOK) {
    247                 usb_log_error("Failed to clear port %d reset feature: %s.\n",
    248                     port, str_error(rc));
    249224        }
    250225}
     
    344319        fibril_mutex_unlock(&my_port->reset_mutex);
    345320
     321        /* Clear the port reset change. */
     322        rc = usb_hub_clear_port_feature(hub->control_pipe,
     323            port_no, USB_HUB_FEATURE_C_PORT_RESET);
     324        if (rc != EOK) {
     325                usb_log_error("Failed to clear port %d reset feature: %s.\n",
     326                    port_no, str_error(rc));
     327                return rc;
     328        }
     329
    346330        if (my_port->reset_okay) {
    347331                return EOK;
Note: See TracChangeset for help on using the changeset viewer.