Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/usbhub/usbhub.c

    rf40a1e2 r6986418  
    4646#include "usbhub_private.h"
    4747#include "port_status.h"
    48 #include "usb/usb.h"
    4948
    5049static usb_iface_t hub_usb_iface = {
     
    7675        //get some hub info
    7776        usb_address_t addr = usb_drv_get_my_address(hc, device);
    78         dprintf(1,"[usb_hub] address of newly created hub = %d", addr);
     77        dprintf(1,"[usb_hub] addres of newly created hub = %d", addr);
    7978        /*if(addr<0){
    8079                //return result;
     
    8685
    8786        // get hub descriptor
     87        usb_target_t target;
     88        target.address = addr;
     89        target.endpoint = 0;
     90        usb_device_request_setup_packet_t request;
     91        //printf("[usb_hub] creating descriptor request\n");
     92        usb_hub_set_descriptor_request(&request);
    8893
    8994        //printf("[usb_hub] creating serialized descriptor\n");
     
    9398        int opResult;
    9499        //printf("[usb_hub] starting control transaction\n");
    95        
    96         opResult = usb_drv_req_get_descriptor(hc, addr,
    97                         USB_REQUEST_TYPE_CLASS,
    98                         USB_DESCTYPE_HUB, 0, 0, serialized_descriptor,
     100        opResult = usb_drv_sync_control_read(
     101                        hc, target, &request, serialized_descriptor,
    99102                        USB_HUB_MAX_DESCRIPTOR_SIZE, &received_size);
    100 
    101103        if (opResult != EOK) {
    102104                dprintf(1,"[usb_hub] failed when receiving hub descriptor, badcode = %d",opResult);
     
    153155        int port;
    154156        int opResult;
     157        usb_device_request_setup_packet_t request;
    155158        usb_target_t target;
    156159        target.address = hub_info->usb_device->address;
     
    170173        if(std_descriptor.configuration_count<1){
    171174                dprintf(1,"[usb_hub] THERE ARE NO CONFIGURATIONS AVAILABLE");
    172                 //shouldn`t I return?
    173         }
    174         /// \TODO check other configurations
     175        }
    175176        usb_standard_configuration_descriptor_t config_descriptor;
    176177        opResult = usb_drv_req_get_bare_configuration_descriptor(hc,
     
    182183        }
    183184        //set configuration
    184         opResult = usb_drv_req_set_configuration(hc, target.address,
    185     config_descriptor.configuration_number);
    186 
     185        request.request_type = 0;
     186        request.request = USB_DEVREQ_SET_CONFIGURATION;
     187        request.index=0;
     188        request.length=0;
     189        request.value_high=0;
     190        request.value_low = config_descriptor.configuration_number;
     191        opResult = usb_drv_sync_control_write(hc, target, &request, NULL, 0);
    187192        if (opResult != EOK) {
    188193                dprintf(1,"[usb_hub]something went wrong when setting hub`s configuration, %d", opResult);
    189194        }
    190195
    191         usb_device_request_setup_packet_t request;
     196
    192197        for (port = 1; port < hub_info->port_count+1; ++port) {
    193198                usb_hub_set_power_port_request(&request, port);
     
    200205        //ports powered, hub seems to be enabled
    201206
     207
    202208        ipc_hangup(hc);
    203209
    204210        //add the hub to list
    205         futex_down(&usb_hub_list_lock);
    206211        usb_lst_append(&usb_hub_list, hub_info);
    207         futex_up(&usb_hub_list_lock);
    208 
    209212        dprintf(1,"[usb_hub] hub info added to list");
    210213        //(void)hub_info;
     
    224227
    225228
     229
    226230//*********************************************
    227231//
     
    231235
    232236/**
    233  * Convenience function for releasing default address and writing debug info
    234  * (these few lines are used too often to be written again and again).
    235  * @param hc
    236  * @return
    237  */
    238 inline static int usb_hub_release_default_address(int hc){
    239         int opResult;
    240         dprintf(1,"[usb_hub] releasing default address");
    241         opResult = usb_drv_release_default_address(hc);
    242         if (opResult != EOK) {
    243                 dprintf(1,"[usb_hub] failed to release default address");
    244         }
    245         return opResult;
    246 }
    247 
    248 /**
    249  * Reset the port with new device and reserve the default address.
     237 * reset the port with new device and reserve the default address
    250238 * @param hc
    251239 * @param port
     
    271259        if (opResult != EOK) {
    272260                dprintf(1,"[usb_hub] something went wrong when reseting a port");
    273                 usb_hub_release_default_address(hc);
    274261        }
    275262}
    276263
    277264/**
    278  * Finalize adding new device after port reset
     265 * convenience function for releasing default address and writing debug info
     266 * (these few lines are used too often to be written again and again)
     267 * @param hc
     268 * @return
     269 */
     270inline static int usb_hub_release_default_address(int hc){
     271        int opResult;
     272        dprintf(1,"[usb_hub] releasing default address");
     273        opResult = usb_drv_release_default_address(hc);
     274        if (opResult != EOK) {
     275                dprintf(1,"[usb_hub] failed to release default address");
     276        }
     277        return opResult;
     278}
     279
     280
     281/**
     282 * finalize adding new device after port reset
    279283 * @param hc
    280284 * @param port
     
    339343
    340344/**
    341  * Unregister device address in hc
     345 * unregister device address in hc, close the port
    342346 * @param hc
    343347 * @param port
     
    348352        //usb_device_request_setup_packet_t request;
    349353        int opResult;
    350        
    351         /** \TODO remove device from device manager - not yet implemented in
    352          * devide manager
    353          */
     354        //disable port
     355        /*usb_hub_set_disable_port_request(&request, port);
     356        opResult = usb_drv_sync_control_write(
     357                        hc, target,
     358                        &request,
     359                        NULL, 0
     360                        );
     361        if (opResult != EOK) {
     362                //continue;
     363                printf("[usb_hub] something went wrong when disabling a port\n");
     364        }*/
     365        /// \TODO remove device
    354366
    355367        hub->attached_devs[port].devman_handle=0;
     
    372384
    373385/**
    374  * Process interrupts on given hub port
     386 * process interrupts on given hub port
    375387 * @param hc
    376388 * @param port
     
    430442        usb_port_set_reset_completed(&status, false);
    431443        usb_port_set_dev_connected(&status, false);
    432         if (status>>16) {
    433                 dprintf(1,"[usb_hub]there was some unsupported change on port %d: %X",port,status);
    434 
     444        if (status) {
     445                dprintf(1,"[usb_hub]there was some unsupported change on port %d",port);
    435446        }
    436447        /// \TODO handle other changes
     
    439450}
    440451
    441 /**
    442  * Check changes on all known hubs.
     452/* Check changes on all known hubs.
    443453 */
    444454void usb_hub_check_hub_changes(void) {
     
    447457         */
    448458        usb_general_list_t * lst_item;
    449         futex_down(&usb_hub_list_lock);
    450459        for (lst_item = usb_hub_list.next;
    451460                        lst_item != &usb_hub_list;
    452461                        lst_item = lst_item->next) {
    453                 futex_up(&usb_hub_list_lock);
    454462                usb_hub_info_t * hub_info = ((usb_hub_info_t*)lst_item->data);
    455463                /*
     
    460468                target.address = hub_info->usb_device->address;
    461469                target.endpoint = 1;/// \TODO get from endpoint descriptor
    462                 dprintf(1,"[usb_hub] checking changes for hub at addr %d",
    463                     target.address);
     470                /*dprintf(1,"[usb_hub] checking changes for hub at addr %d",
     471                    target.address);*/
    464472
    465473                size_t port_count = hub_info->port_count;
     
    502510                        }
    503511                }
    504                 free(change_bitmap);
    505512
    506513                ipc_hangup(hc);
    507                 futex_down(&usb_hub_list_lock);
    508         }
    509         futex_up(&usb_hub_list_lock);
     514        }
    510515}
    511516
Note: See TracChangeset for help on using the changeset viewer.