Ignore:
File:
1 edited

Legend:

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

    r563fb40 r15b0432  
    3939
    4040#include <usb_iface.h>
    41 #include <usb/usbdrv.h>
     41#include <usb/ddfiface.h>
    4242#include <usb/descriptor.h>
    4343#include <usb/recognise.h>
    44 #include <usb/devreq.h>
     44#include <usb/request.h>
    4545#include <usb/classes/hub.h>
    4646
     
    4949#include "port_status.h"
    5050#include "usb/usb.h"
    51 
    52 static int iface_get_hc_handle(device_t *device, devman_handle_t *handle)
    53 {
    54         return usb_hc_find(device->handle, handle);
    55 }
    56 
    57 static usb_iface_t hub_usb_iface = {
    58         .get_hc_handle = iface_get_hc_handle
     51#include "usb/pipes.h"
     52#include "usb/classes/classes.h"
     53
     54static device_ops_t hub_device_ops = {
     55        .interfaces[USB_DEV_IFACE] = &usb_iface_hub_impl
    5956};
    6057
    61 static device_ops_t hub_device_ops = {
    62         .interfaces[USB_DEV_IFACE] = &hub_usb_iface
     58/** Hub status-change endpoint description */
     59static usb_endpoint_description_t status_change_endpoint_description = {
     60        .transfer_type = USB_TRANSFER_INTERRUPT,
     61        .direction = USB_DIRECTION_IN,
     62        .interface_class = USB_CLASS_HUB,
     63        .flags = 0
    6364};
     65
    6466
    6567//*********************************************
     
    6971//*********************************************
    7072
    71 usb_hub_info_t * usb_create_hub_info(device_t * device, int hc) {
     73/**
     74 * Initialize connnections to host controller, device, and device
     75 * control endpoint
     76 * @param hub
     77 * @param device
     78 * @return
     79 */
     80static int usb_hub_init_communication(usb_hub_info_t * hub){
     81        int opResult;
     82        opResult = usb_device_connection_initialize_from_device(
     83                        &hub->device_connection,
     84                        hub->device);
     85        if(opResult != EOK){
     86                dprintf(USB_LOG_LEVEL_ERROR,
     87                                "could not initialize connection to hc, errno %d",opResult);
     88                return opResult;
     89        }
     90        opResult = usb_hc_connection_initialize_from_device(&hub->connection,
     91                        hub->device);
     92        if(opResult != EOK){
     93                dprintf(USB_LOG_LEVEL_ERROR,
     94                                "could not initialize connection to device, errno %d",opResult);
     95                return opResult;
     96        }
     97        opResult = usb_endpoint_pipe_initialize_default_control(&hub->endpoints.control,
     98            &hub->device_connection);
     99        if(opResult != EOK){
     100                dprintf(USB_LOG_LEVEL_ERROR,
     101                                "could not initialize connection to device endpoint, errno %d",opResult);
     102        }
     103        return opResult;
     104}
     105
     106/**
     107 * When entering this function, hub->endpoints.control should be active.
     108 * @param hub
     109 * @return
     110 */
     111static int usb_hub_process_configuration_descriptors(
     112        usb_hub_info_t * hub){
     113        if(hub==NULL) {
     114                return EINVAL;
     115        }
     116        int opResult;
     117       
     118        //device descriptor
     119        usb_standard_device_descriptor_t std_descriptor;
     120        opResult = usb_request_get_device_descriptor(&hub->endpoints.control,
     121            &std_descriptor);
     122        if(opResult!=EOK){
     123                dprintf(USB_LOG_LEVEL_ERROR, "could not get device descriptor, %d",opResult);
     124                return opResult;
     125        }
     126        dprintf(USB_LOG_LEVEL_INFO, "hub has %d configurations",
     127                        std_descriptor.configuration_count);
     128        if(std_descriptor.configuration_count<1){
     129                dprintf(USB_LOG_LEVEL_ERROR, "THERE ARE NO CONFIGURATIONS AVAILABLE");
     130                //shouldn`t I return?
     131        }
     132
     133        //configuration descriptor
     134        /// \TODO check other configurations
     135        usb_standard_configuration_descriptor_t config_descriptor;
     136        opResult = usb_request_get_bare_configuration_descriptor(
     137            &hub->endpoints.control, 0,
     138        &config_descriptor);
     139        if(opResult!=EOK){
     140                dprintf(USB_LOG_LEVEL_ERROR, "could not get configuration descriptor, %d",opResult);
     141                return opResult;
     142        }
     143        //set configuration
     144        opResult = usb_request_set_configuration(&hub->endpoints.control,
     145                config_descriptor.configuration_number);
     146
     147        if (opResult != EOK) {
     148                dprintf(USB_LOG_LEVEL_ERROR,
     149                                "something went wrong when setting hub`s configuration, %d",
     150                                opResult);
     151                return opResult;
     152        }
     153        dprintf(USB_LOG_LEVEL_DEBUG, "\tused configuration %d",
     154                        config_descriptor.configuration_number);
     155
     156        //full configuration descriptor
     157        size_t transferred = 0;
     158        uint8_t * descriptors = (uint8_t *)malloc(config_descriptor.total_length);
     159        if (descriptors == NULL) {
     160                dprintf(USB_LOG_LEVEL_ERROR, "insufficient memory");
     161                return ENOMEM;
     162        }
     163        opResult = usb_request_get_full_configuration_descriptor(&hub->endpoints.control,
     164            0, descriptors,
     165            config_descriptor.total_length, &transferred);
     166        if(opResult!=EOK){
     167                free(descriptors);
     168                dprintf(USB_LOG_LEVEL_ERROR,
     169                                "could not get full configuration descriptor, %d",opResult);
     170                return opResult;
     171        }
     172        if (transferred != config_descriptor.total_length) {
     173                dprintf(USB_LOG_LEVEL_ERROR,
     174                                "received incorrect full configuration descriptor");
     175                return ELIMIT;
     176        }
     177
     178        /**
     179         * Initialize the interrupt in endpoint.
     180         * \TODO this code should be checked...
     181         */
     182        usb_endpoint_mapping_t endpoint_mapping[1] = {
     183                {
     184                        .pipe = &hub->endpoints.status_change,
     185                        .description = &status_change_endpoint_description,
     186                        .interface_no =
     187                            usb_device_get_assigned_interface(hub->device)
     188                }
     189        };
     190        opResult = usb_endpoint_pipe_initialize_from_configuration(
     191            endpoint_mapping, 1,
     192            descriptors, config_descriptor.total_length,
     193            &hub->device_connection);
     194        if (opResult != EOK) {
     195                dprintf(USB_LOG_LEVEL_ERROR,
     196                                "Failed to initialize status change pipe: %s",
     197                    str_error(opResult));
     198                return opResult;
     199        }
     200        if (!endpoint_mapping[0].present) {
     201                dprintf(USB_LOG_LEVEL_ERROR,"Not accepting device, " \
     202                    "cannot understand what is happenning");
     203                return EREFUSED;
     204        }
     205
     206        free(descriptors);
     207        return EOK;
     208       
     209
     210        // Initialize the interrupt(=status change) endpoint.
     211        /*usb_endpoint_pipe_initialize(
     212                &result->endpoints->status_change,
     213                &result->device_connection, );USB_TRANSFER_INTERRUPT
     214        USB_DIRECTION_IN*/
     215
     216}
     217
     218
     219/**
     220 * Create hub representation from device information.
     221 * @param device
     222 * @return pointer to created structure or NULL in case of error
     223 */
     224usb_hub_info_t * usb_create_hub_info(device_t * device) {
    72225        usb_hub_info_t* result = usb_new(usb_hub_info_t);
     226        result->device = device;
     227        int opResult;
     228        opResult = usb_hub_init_communication(result);
     229        if(opResult != EOK){
     230                free(result);
     231                return NULL;
     232        }
     233
    73234        //result->device = device;
    74235        result->port_count = -1;
    75         /// \TODO is this correct? is the device stored?
    76236        result->device = device;
    77237
    78 
    79         dprintf(USB_LOG_LEVEL_DEBUG, "phone to hc = %d", hc);
    80         if (hc < 0) {
    81                 return result;
    82         }
    83         //get some hub info
    84         usb_address_t addr = usb_drv_get_my_address(hc, device);
    85         dprintf(USB_LOG_LEVEL_DEBUG, "address of newly created hub = %d", addr);
    86         /*if(addr<0){
    87                 //return result;
    88 
    89         }*/
    90 
    91         result->address = addr;
     238        //result->usb_device = usb_new(usb_hcd_attached_device_info_t);
     239        size_t received_size;
    92240
    93241        // get hub descriptor
    94 
    95242        dprintf(USB_LOG_LEVEL_DEBUG, "creating serialized descripton");
    96243        void * serialized_descriptor = malloc(USB_HUB_MAX_DESCRIPTOR_SIZE);
    97244        usb_hub_descriptor_t * descriptor;
    98         size_t received_size;
    99         int opResult;
    100245        dprintf(USB_LOG_LEVEL_DEBUG, "starting control transaction");
    101        
    102         opResult = usb_drv_req_get_descriptor(hc, addr,
     246        usb_endpoint_pipe_start_session(&result->endpoints.control);
     247        opResult = usb_request_get_descriptor(&result->endpoints.control,
    103248                        USB_REQUEST_TYPE_CLASS,
    104249                        USB_DESCTYPE_HUB, 0, 0, serialized_descriptor,
    105250                        USB_HUB_MAX_DESCRIPTOR_SIZE, &received_size);
     251        usb_endpoint_pipe_end_session(&result->endpoints.control);
    106252
    107253        if (opResult != EOK) {
     
    117263                return result;
    118264        }
     265
     266       
    119267        dprintf(USB_LOG_LEVEL_INFO, "setting port count to %d",descriptor->ports_count);
    120268        result->port_count = descriptor->ports_count;
    121         result->attached_devs = (usb_hub_attached_device_t*)
    122             malloc((result->port_count+1) * sizeof(usb_hub_attached_device_t));
     269        result->attached_devs = (usb_hc_attached_device_t*)
     270            malloc((result->port_count+1) * sizeof(usb_hc_attached_device_t));
    123271        int i;
    124272        for(i=0;i<result->port_count+1;++i){
    125                 result->attached_devs[i].devman_handle=0;
     273                result->attached_devs[i].handle=0;
    126274                result->attached_devs[i].address=0;
    127275        }
     
    138286}
    139287
     288/**
     289 * Create hub representation and add it into hub list
     290 * @param dev
     291 * @return
     292 */
    140293int usb_add_hub_device(device_t *dev) {
    141294        dprintf(USB_LOG_LEVEL_INFO, "add_hub_device(handle=%d)", (int) dev->handle);
    142295
    143         /*
    144          * We are some (probably deeply nested) hub.
    145          * Thus, assign our own operations and explore already
    146          * connected devices.
    147          */
    148296        dev->ops = &hub_device_ops;
    149297
    150         //create the hub structure
    151         //get hc connection
    152         int hc = usb_drv_hc_connect_auto(dev, 0);
    153         if (hc < 0) {
    154                 return hc;
    155         }
    156 
    157         usb_hub_info_t * hub_info = usb_create_hub_info(dev, hc);
     298        usb_hub_info_t * hub_info = usb_create_hub_info(dev);
     299
     300        int opResult;
     301
     302        //perform final configurations
     303        usb_endpoint_pipe_start_session(&hub_info->endpoints.control);
     304        // process descriptors
     305        opResult = usb_hub_process_configuration_descriptors(hub_info);
     306        if(opResult != EOK){
     307                dprintf(USB_LOG_LEVEL_ERROR,"could not get condiguration descriptors, %d",
     308                                opResult);
     309                return opResult;
     310        }
     311        //power ports
     312        usb_device_request_setup_packet_t request;
    158313        int port;
    159         int opResult;
    160         usb_target_t target;
    161         target.address = hub_info->address;
    162         target.endpoint = 0;
    163 
    164         //get configuration descriptor
    165         // this is not fully correct - there are more configurations
    166         // and all should be checked
    167         usb_standard_device_descriptor_t std_descriptor;
    168         opResult = usb_drv_req_get_device_descriptor(hc, target.address,
    169             &std_descriptor);
    170         if(opResult!=EOK){
    171                 dprintf(USB_LOG_LEVEL_ERROR, "could not get device descriptor, %d",opResult);
    172                 return opResult;
    173         }
    174         dprintf(USB_LOG_LEVEL_INFO, "hub has %d configurations",std_descriptor.configuration_count);
    175         if(std_descriptor.configuration_count<1){
    176                 dprintf(USB_LOG_LEVEL_ERROR, "THERE ARE NO CONFIGURATIONS AVAILABLE");
    177                 //shouldn`t I return?
    178         }
    179         /// \TODO check other configurations
    180         usb_standard_configuration_descriptor_t config_descriptor;
    181         opResult = usb_drv_req_get_bare_configuration_descriptor(hc,
    182         target.address, 0,
    183         &config_descriptor);
    184         if(opResult!=EOK){
    185                 dprintf(USB_LOG_LEVEL_ERROR, "could not get configuration descriptor, %d",opResult);
    186                 return opResult;
    187         }
    188         //set configuration
    189         opResult = usb_drv_req_set_configuration(hc, target.address,
    190     config_descriptor.configuration_number);
    191 
    192         if (opResult != EOK) {
    193                 dprintf(USB_LOG_LEVEL_ERROR, "something went wrong when setting hub`s configuration, %d", opResult);
    194         }
    195 
    196         usb_device_request_setup_packet_t request;
    197314        for (port = 1; port < hub_info->port_count+1; ++port) {
    198315                usb_hub_set_power_port_request(&request, port);
    199                 opResult = usb_drv_sync_control_write(hc, target, &request, NULL, 0);
     316                opResult = usb_endpoint_pipe_control_write(&hub_info->endpoints.control,
     317                                &request,sizeof(usb_device_request_setup_packet_t), NULL, 0);
    200318                dprintf(USB_LOG_LEVEL_INFO, "powering port %d",port);
    201319                if (opResult != EOK) {
     
    204322        }
    205323        //ports powered, hub seems to be enabled
    206 
    207         async_hangup(hc);
     324        usb_endpoint_pipe_end_session(&hub_info->endpoints.control);
    208325
    209326        //add the hub to list
     
    215332        //(void)hub_info;
    216333        usb_hub_check_hub_changes();
    217 
    218334       
    219 
    220335        dprintf(USB_LOG_LEVEL_INFO, "hub dev added");
     336        //address is lost...
    221337        dprintf(USB_LOG_LEVEL_DEBUG, "\taddress %d, has %d ports ",
    222                         hub_info->address,
     338                        //hub_info->endpoints.control.,
    223339                        hub_info->port_count);
    224         dprintf(USB_LOG_LEVEL_DEBUG, "\tused configuration %d",config_descriptor.configuration_number);
    225340
    226341        return EOK;
     
    236351
    237352/**
    238  * Convenience function for releasing default address and writing debug info
    239  * (these few lines are used too often to be written again and again).
    240  * @param hc
    241  * @return
    242  */
    243 inline static int usb_hub_release_default_address(int hc){
    244         int opResult;
    245         dprintf(USB_LOG_LEVEL_INFO, "releasing default address");
    246         opResult = usb_drv_release_default_address(hc);
    247         if (opResult != EOK) {
    248                 dprintf(USB_LOG_LEVEL_WARNING, "failed to release default address");
    249         }
    250         return opResult;
    251 }
    252 
    253 /**
    254353 * Reset the port with new device and reserve the default address.
    255354 * @param hc
     
    257356 * @param target
    258357 */
    259 static void usb_hub_init_add_device(int hc, uint16_t port, usb_target_t target) {
     358static void usb_hub_init_add_device(usb_hub_info_t * hub, uint16_t port) {
    260359        usb_device_request_setup_packet_t request;
    261360        int opResult;
    262361        dprintf(USB_LOG_LEVEL_INFO, "some connection changed");
     362        assert(hub->endpoints.control.hc_phone);
    263363        //get default address
    264         opResult = usb_drv_reserve_default_address(hc);
     364        //opResult = usb_drv_reserve_default_address(hc);
     365        opResult = usb_hc_reserve_default_address(&hub->connection, USB_SPEED_LOW);
     366
    265367        if (opResult != EOK) {
    266368                dprintf(USB_LOG_LEVEL_WARNING, "cannot assign default address, it is probably used");
     
    269371        //reset port
    270372        usb_hub_set_reset_port_request(&request, port);
    271         opResult = usb_drv_sync_control_write(
    272                         hc, target,
    273                         &request,
     373        opResult = usb_endpoint_pipe_control_write(
     374                        &hub->endpoints.control,
     375                        &request,sizeof(usb_device_request_setup_packet_t),
    274376                        NULL, 0
    275377                        );
    276378        if (opResult != EOK) {
    277379                dprintf(USB_LOG_LEVEL_ERROR, "something went wrong when reseting a port");
    278                 usb_hub_release_default_address(hc);
     380                //usb_hub_release_default_address(hc);
     381                usb_hc_release_default_address(&hub->connection);
    279382        }
    280383}
     
    287390 */
    288391static void usb_hub_finalize_add_device( usb_hub_info_t * hub,
    289                 int hc, uint16_t port, usb_target_t target) {
     392                uint16_t port) {
    290393
    291394        int opResult;
    292395        dprintf(USB_LOG_LEVEL_INFO, "finalizing add device");
    293         opResult = usb_hub_clear_port_feature(hc, target.address,
     396        opResult = usb_hub_clear_port_feature(&hub->endpoints.control,
    294397            port, USB_HUB_FEATURE_C_PORT_RESET);
     398
    295399        if (opResult != EOK) {
    296400                dprintf(USB_LOG_LEVEL_ERROR, "failed to clear port reset feature");
    297                 usb_hub_release_default_address(hc);
    298                 return;
    299         }
    300 
    301         /* Request address at from host controller. */
    302         usb_address_t new_device_address = usb_drv_request_address(hc);
     401                usb_hc_release_default_address(&hub->connection);
     402                return;
     403        }
     404        //create connection to device
     405        usb_endpoint_pipe_t new_device_pipe;
     406        usb_device_connection_t new_device_connection;
     407        usb_device_connection_initialize_on_default_address(
     408                        &new_device_connection,
     409                        &hub->connection
     410                        );
     411        usb_endpoint_pipe_initialize_default_control(
     412                        &new_device_pipe,
     413                        &new_device_connection);
     414        /// \TODO get highspeed info
     415
     416
     417
     418
     419
     420        /* Request address from host controller. */
     421        usb_address_t new_device_address = usb_hc_request_address(
     422                        &hub->connection,
     423                        USB_SPEED_LOW/// \TODO fullspeed??
     424                        );
    303425        if (new_device_address < 0) {
    304426                dprintf(USB_LOG_LEVEL_ERROR, "failed to get free USB address");
    305427                opResult = new_device_address;
    306                 usb_hub_release_default_address(hc);
     428                usb_hc_release_default_address(&hub->connection);
    307429                return;
    308430        }
    309431        dprintf(USB_LOG_LEVEL_INFO, "setting new address %d",new_device_address);
    310         opResult = usb_drv_req_set_address(hc, USB_ADDRESS_DEFAULT,
    311             new_device_address);
     432        //opResult = usb_drv_req_set_address(hc, USB_ADDRESS_DEFAULT,
     433        //    new_device_address);
     434        opResult = usb_request_set_address(&new_device_pipe,new_device_address);
    312435
    313436        if (opResult != EOK) {
    314437                dprintf(USB_LOG_LEVEL_ERROR, "could not set address for new device");
    315                 usb_hub_release_default_address(hc);
    316                 return;
    317         }
    318 
    319 
    320         opResult = usb_hub_release_default_address(hc);
     438                usb_hc_release_default_address(&hub->connection);
     439                return;
     440        }
     441
     442
     443        //opResult = usb_hub_release_default_address(hc);
     444        opResult = usb_hc_release_default_address(&hub->connection);
    321445        if(opResult!=EOK){
    322446                return;
    323447        }
    324448
    325         devman_handle_t hc_handle;
    326         opResult = usb_drv_find_hc(hub->device, &hc_handle);
    327         if (opResult != EOK) {
    328                 usb_log_error("Failed to get handle of host controller: %s.\n",
    329                     str_error(opResult));
    330                 return;
    331         }
    332 
    333449        devman_handle_t child_handle;
    334         opResult = usb_device_register_child_in_devman(new_device_address,
    335             hc_handle, hub->device, &child_handle);
     450        //??
     451    opResult = usb_device_register_child_in_devman(new_device_address,
     452            hub->connection.hc_handle, hub->device, &child_handle);
     453
    336454        if (opResult != EOK) {
    337455                dprintf(USB_LOG_LEVEL_ERROR, "could not start driver for new device");
    338456                return;
    339457        }
    340         hub->attached_devs[port].devman_handle = child_handle;
     458        hub->attached_devs[port].handle = child_handle;
    341459        hub->attached_devs[port].address = new_device_address;
    342460
    343         opResult = usb_drv_bind_address(hc, new_device_address, child_handle);
     461        //opResult = usb_drv_bind_address(hc, new_device_address, child_handle);
     462        opResult = usb_hc_register_device(
     463                        &hub->connection,
     464                        &hub->attached_devs[port]);
    344465        if (opResult != EOK) {
    345466                dprintf(USB_LOG_LEVEL_ERROR, "could not assign address of device in hcd");
     
    358479 */
    359480static void usb_hub_removed_device(
    360     usb_hub_info_t * hub, int hc, uint16_t port, usb_target_t target) {
     481    usb_hub_info_t * hub,uint16_t port) {
    361482        //usb_device_request_setup_packet_t request;
    362483        int opResult;
     
    365486         * devide manager
    366487         */
    367 
    368         hub->attached_devs[port].devman_handle=0;
     488       
    369489        //close address
    370490        if(hub->attached_devs[port].address!=0){
    371                 opResult = usb_drv_release_address(hc,hub->attached_devs[port].address);
     491                //opResult = usb_drv_release_address(hc,hub->attached_devs[port].address);
     492                opResult = usb_hc_unregister_device(
     493                                &hub->connection, hub->attached_devs[port].address);
    372494                if(opResult != EOK) {
    373495                        dprintf(USB_LOG_LEVEL_WARNING, "could not release address of " \
     
    375497                }
    376498                hub->attached_devs[port].address = 0;
     499                hub->attached_devs[port].handle = 0;
    377500        }else{
    378501                dprintf(USB_LOG_LEVEL_WARNING, "this is strange, disconnected device had no address");
    379502                //device was disconnected before it`s port was reset - return default address
    380                 usb_drv_release_default_address(hc);
     503                //usb_drv_release_default_address(hc);
     504                usb_hc_release_default_address(&hub->connection);
    381505        }
    382506}
     
    388512 * @param target
    389513 */
    390 static void usb_hub_process_interrupt(usb_hub_info_t * hub, int hc,
    391         uint16_t port, usb_address_t address) {
     514static void usb_hub_process_interrupt(usb_hub_info_t * hub,
     515        uint16_t port) {
    392516        dprintf(USB_LOG_LEVEL_DEBUG, "interrupt at port %d", port);
    393517        //determine type of change
     518        usb_endpoint_pipe_t *pipe = &hub->endpoints.control;
     519        int opResult = usb_endpoint_pipe_start_session(pipe);
     520       
     521        if(opResult != EOK){
     522                dprintf(USB_LOG_LEVEL_ERROR, "cannot open pipe %d", opResult);
     523        }
     524
     525        /*
    394526        usb_target_t target;
    395527        target.address=address;
    396528        target.endpoint=0;
     529        */
     530
    397531        usb_port_status_t status;
    398532        size_t rcvd_size;
    399533        usb_device_request_setup_packet_t request;
    400         int opResult;
     534        //int opResult;
    401535        usb_hub_set_port_status_request(&request, port);
    402536        //endpoint 0
    403537
    404         opResult = usb_drv_sync_control_read(
    405                         hc, target,
    406                         &request,
     538        opResult = usb_endpoint_pipe_control_read(
     539                        pipe,
     540                        &request, sizeof(usb_device_request_setup_packet_t),
    407541                        &status, 4, &rcvd_size
    408542                        );
     
    417551        //something connected/disconnected
    418552        if (usb_port_connect_change(&status)) {
    419                 opResult = usb_hub_clear_port_feature(hc, target.address,
     553                opResult = usb_hub_clear_port_feature(pipe,
    420554                    port, USB_HUB_FEATURE_C_PORT_CONNECTION);
    421555                // TODO: check opResult
    422556                if (usb_port_dev_connected(&status)) {
    423557                        dprintf(USB_LOG_LEVEL_INFO, "some connection changed");
    424                         usb_hub_init_add_device(hc, port, target);
     558                        usb_hub_init_add_device(hub, port);
    425559                } else {
    426                         usb_hub_removed_device(hub, hc, port, target);
     560                        usb_hub_removed_device(hub, port);
    427561                }
    428562        }
     
    431565                dprintf(USB_LOG_LEVEL_INFO, "port reset complete");
    432566                if (usb_port_enabled(&status)) {
    433                         usb_hub_finalize_add_device(hub, hc, port, target);
     567                        usb_hub_finalize_add_device(hub, port);
    434568                } else {
    435569                        dprintf(USB_LOG_LEVEL_WARNING, "ERROR: port reset, but port still not enabled");
     
    447581        /// \TODO handle other changes
    448582        /// \TODO debug log for various situations
     583        usb_endpoint_pipe_end_session(pipe);
     584
    449585
    450586}
     
    464600                fibril_mutex_unlock(&usb_hub_list_lock);
    465601                usb_hub_info_t * hub_info = ((usb_hub_info_t*)lst_item->data);
     602                int opResult;
     603
     604                opResult = usb_endpoint_pipe_start_session(&hub_info->endpoints.status_change);
     605                if(opResult != EOK){
     606                        continue;
     607                }
    466608                /*
    467609                 * Check status change pipe of this hub.
    468610                 */
    469 
     611                /*
    470612                usb_target_t target;
    471613                target.address = hub_info->address;
     
    473615                dprintf(USB_LOG_LEVEL_INFO, "checking changes for hub at addr %d",
    474616                    target.address);
    475 
     617                */
    476618                size_t port_count = hub_info->port_count;
    477619
    478620                /*
    479621                 * Connect to respective HC.
    480                  */
     622                 *
    481623                int hc = usb_drv_hc_connect_auto(hub_info->device, 0);
    482624                if (hc < 0) {
    483625                        continue;
    484                 }
     626                }*/
    485627
    486628                /// FIXME: count properly
     
    489631                void *change_bitmap = malloc(byte_length);
    490632                size_t actual_size;
    491                 usb_handle_t handle;
     633                //usb_handle_t handle;
    492634
    493635                /*
    494636                 * Send the request.
    495637                 */
    496                 int opResult = usb_drv_async_interrupt_in(hc, target,
    497                                 change_bitmap, byte_length, &actual_size,
    498                                 &handle);
    499 
    500                 usb_drv_async_wait_for(handle);
     638                opResult = usb_endpoint_pipe_read(
     639                                &hub_info->endpoints.status_change,
     640                                change_bitmap, byte_length, &actual_size
     641                                );
     642
     643                //usb_drv_async_wait_for(handle);
    501644
    502645                if (opResult != EOK) {
     
    511654                        if (interrupt) {
    512655                                usb_hub_process_interrupt(
    513                                         hub_info, hc, port, hub_info->address);
     656                                        hub_info, port);
    514657                        }
    515658                }
     659                usb_endpoint_pipe_end_session(&hub_info->endpoints.status_change);
    516660                free(change_bitmap);
    517 
    518                 async_hangup(hc);
     661               
     662
     663                //async_hangup(hc);
    519664                fibril_mutex_lock(&usb_hub_list_lock);
    520665        }
Note: See TracChangeset for help on using the changeset viewer.