Ignore:
File:
1 edited

Legend:

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

    rfbefd0e r09daa8b  
    132132                return opResult;
    133133        }
    134         usb_log_debug("setting port count to %d\n",descriptor->ports_count);
     134        usb_log_info("setting port count to %d\n",descriptor->ports_count);
    135135        hub_info->port_count = descriptor->ports_count;
    136136        hub_info->attached_devs = (usb_hc_attached_device_t*)
     
    157157static int usb_hub_set_configuration(usb_hub_info_t * hub_info){
    158158        //device descriptor
    159         usb_standard_device_descriptor_t *std_descriptor
    160             = &hub_info->usb_device->descriptors.device;
    161         usb_log_debug("hub has %d configurations\n",
    162             std_descriptor->configuration_count);
    163         if(std_descriptor->configuration_count<1){
     159        usb_standard_device_descriptor_t std_descriptor;
     160        int opResult = usb_request_get_device_descriptor(
     161                &hub_info->usb_device->ctrl_pipe,
     162            &std_descriptor);
     163        if(opResult!=EOK){
     164                usb_log_error("could not get device descriptor, %d\n",opResult);
     165                return opResult;
     166        }
     167        usb_log_info("hub has %d configurations\n",
     168                        std_descriptor.configuration_count);
     169        if(std_descriptor.configuration_count<1){
    164170                usb_log_error("THERE ARE NO CONFIGURATIONS AVAILABLE\n");
    165171                //shouldn`t I return?
    166                 //definitely
    167                 return EINVAL;
    168         }
    169 
     172        }
     173
     174        /* Retrieve full configuration descriptor. */
     175        uint8_t *descriptors = NULL;
     176        size_t descriptors_size = 0;
     177        opResult = usb_request_get_full_configuration_descriptor_alloc(
     178            &hub_info->usb_device->ctrl_pipe, 0,
     179            (void **) &descriptors, &descriptors_size);
     180        if (opResult != EOK) {
     181                usb_log_error("Could not get configuration descriptor: %s.\n",
     182                    str_error(opResult));
     183                return opResult;
     184        }
    170185        usb_standard_configuration_descriptor_t *config_descriptor
    171             = (usb_standard_configuration_descriptor_t *)
    172             hub_info->usb_device->descriptors.configuration;
     186            = (usb_standard_configuration_descriptor_t *) descriptors;
    173187
    174188        /* Set configuration. */
    175         int opResult = usb_request_set_configuration(
    176             &hub_info->usb_device->ctrl_pipe,
     189        opResult = usb_request_set_configuration(&hub_info->usb_device->ctrl_pipe,
    177190            config_descriptor->configuration_number);
    178191
     
    184197        usb_log_debug("\tused configuration %d\n",
    185198                        config_descriptor->configuration_number);
    186 
     199        free(descriptors);
    187200        return EOK;
    188201}
     
    211224        }
    212225       
    213         usb_pipe_start_session(hub_info->control_pipe);
     226        usb_endpoint_pipe_start_session(hub_info->control_pipe);
    214227        //set hub configuration
    215228        opResult = usb_hub_set_configuration(hub_info);
     
    226239                return opResult;
    227240        }
    228         usb_pipe_end_session(hub_info->control_pipe);
     241        usb_endpoint_pipe_end_session(hub_info->control_pipe);
    229242
    230243
    231244        /// \TODO what is this?
    232         usb_log_debug("Creating `hub' function.\n");
     245        usb_log_debug("adding to ddf");
    233246        ddf_fun_t *hub_fun = ddf_fun_create(hub_info->usb_device->ddf_dev,
    234247                        fun_exposed, "hub");
     
    244257        fid_t fid = fibril_create(usb_hub_control_loop, hub_info);
    245258        if (fid == 0) {
    246                 usb_log_error("failed to start monitoring fibril for new hub.\n");
     259                usb_log_error("failed to start monitoring fibril for new hub");
    247260                return ENOMEM;
    248261        }
    249262        fibril_add_ready(fid);
    250         usb_log_debug("Hub fibril created.\n");
    251 
    252         usb_log_info("Controlling hub `%s' (%d ports).\n",
    253             hub_info->usb_device->ddf_dev->name, hub_info->port_count);
     263        usb_log_debug("hub fibril created");
     264        usb_log_debug("has %d ports ",hub_info->port_count);
    254265        return EOK;
    255266}
     
    290301        //if this hub already uses default address, it cannot request it once more
    291302        if(hub->is_default_address_used) return;
    292         usb_log_debug("some connection changed\n");
     303        usb_log_info("some connection changed\n");
    293304        assert(hub->control_pipe->hc_phone);
    294305        int opResult = usb_hub_clear_port_feature(hub->control_pipe,
     
    310321        //reset port
    311322        usb_hub_set_reset_port_request(&request, port);
    312         opResult = usb_pipe_control_write(
     323        opResult = usb_endpoint_pipe_control_write(
    313324                        hub->control_pipe,
    314325                        &request,sizeof(usb_device_request_setup_packet_t),
     
    333344
    334345        int opResult;
    335         usb_log_debug("finalizing add device\n");
     346        usb_log_info("finalizing add device\n");
    336347        opResult = usb_hub_clear_port_feature(hub->control_pipe,
    337348            port, USB_HUB_FEATURE_C_PORT_RESET);
     
    343354        }
    344355        //create connection to device
    345         usb_pipe_t new_device_pipe;
     356        usb_endpoint_pipe_t new_device_pipe;
    346357        usb_device_connection_t new_device_connection;
    347358        usb_device_connection_initialize_on_default_address(
     
    349360                        &hub->connection
    350361                        );
    351         usb_pipe_initialize_default_control(
     362        usb_endpoint_pipe_initialize_default_control(
    352363                        &new_device_pipe,
    353364                        &new_device_connection);
    354         usb_pipe_probe_default_control(&new_device_pipe);
     365        usb_endpoint_pipe_probe_default_control(&new_device_pipe);
    355366
    356367        /* Request address from host controller. */
     
    365376                return;
    366377        }
    367         usb_log_debug("setting new address %d\n",new_device_address);
     378        usb_log_info("setting new address %d\n",new_device_address);
    368379        //opResult = usb_drv_req_set_address(hc, USB_ADDRESS_DEFAULT,
    369380        //    new_device_address);
    370         usb_pipe_start_session(&new_device_pipe);
     381        usb_endpoint_pipe_start_session(&new_device_pipe);
    371382        opResult = usb_request_set_address(&new_device_pipe,new_device_address);
    372         usb_pipe_end_session(&new_device_pipe);
     383        usb_endpoint_pipe_end_session(&new_device_pipe);
    373384        if (opResult != EOK) {
    374385                usb_log_error("could not set address for new device %d\n",opResult);
     
    405416                return;
    406417        }
    407         usb_log_info("Detected new device on `%s' (port %d), " \
    408             "address %d (handle %llu).\n",
    409             hub->usb_device->ddf_dev->name, (int) port,
     418        usb_log_info("new device address %d, handle %zu\n",
    410419            new_device_address, child_handle);
     420
    411421}
    412422
     
    478488        usb_log_debug("interrupt at port %d\n", port);
    479489        //determine type of change
    480         usb_pipe_t *pipe = hub->control_pipe;
     490        usb_endpoint_pipe_t *pipe = hub->control_pipe;
    481491       
    482492        int opResult;
     
    489499        //endpoint 0
    490500
    491         opResult = usb_pipe_control_read(
     501        opResult = usb_endpoint_pipe_control_read(
    492502                        pipe,
    493503                        &request, sizeof(usb_device_request_setup_packet_t),
     
    505515        if (usb_port_connect_change(&status)) {
    506516                if (usb_port_dev_connected(&status)) {
    507                         usb_log_debug("some connection changed\n");
     517                        usb_log_info("some connection changed\n");
    508518                        usb_hub_init_add_device(hub, port, usb_port_speed(&status));
    509519                } else {
     
    517527                        usb_hub_over_current(hub,port);
    518528                }else{
    519                         usb_log_debug("over current condition was auto-resolved on port %d\n",
     529                        usb_log_info("over current condition was auto-resolved on port %d\n",
    520530                                        port);
    521531                }
     
    523533        //port reset
    524534        if (usb_port_reset_completed(&status)) {
    525                 usb_log_debug("port reset complete\n");
     535                usb_log_info("port reset complete");
    526536                if (usb_port_enabled(&status)) {
    527537                        usb_hub_finalize_add_device(hub, port, usb_port_speed(&status));
     
    550560int usb_hub_check_hub_changes(usb_hub_info_t * hub_info){
    551561        int opResult;
    552         opResult = usb_pipe_start_session(
     562        opResult = usb_endpoint_pipe_start_session(
    553563                        hub_info->status_change_pipe);
    554564        if(opResult != EOK){
     
    568578         * Send the request.
    569579         */
    570         opResult = usb_pipe_read(
     580        opResult = usb_endpoint_pipe_read(
    571581                        hub_info->status_change_pipe,
    572582                        change_bitmap, byte_length, &actual_size
     
    576586                free(change_bitmap);
    577587                usb_log_warning("something went wrong while getting status of hub\n");
    578                 usb_pipe_end_session(hub_info->status_change_pipe);
     588                usb_endpoint_pipe_end_session(hub_info->status_change_pipe);
    579589                return opResult;
    580590        }
    581591        unsigned int port;
    582         opResult = usb_pipe_start_session(hub_info->control_pipe);
     592        opResult = usb_endpoint_pipe_start_session(hub_info->control_pipe);
    583593        if(opResult!=EOK){
    584594                usb_log_error("could not start control pipe session %d\n", opResult);
    585                 usb_pipe_end_session(hub_info->status_change_pipe);
     595                usb_endpoint_pipe_end_session(hub_info->status_change_pipe);
    586596                return opResult;
    587597        }
     
    590600                usb_log_error("could not start host controller session %d\n",
    591601                                opResult);
    592                 usb_pipe_end_session(hub_info->control_pipe);
    593                 usb_pipe_end_session(hub_info->status_change_pipe);
     602                usb_endpoint_pipe_end_session(hub_info->control_pipe);
     603                usb_endpoint_pipe_end_session(hub_info->status_change_pipe);
    594604                return opResult;
    595605        }
     
    605615        }
    606616        usb_hc_connection_close(&hub_info->connection);
    607         usb_pipe_end_session(hub_info->control_pipe);
    608         usb_pipe_end_session(hub_info->status_change_pipe);
     617        usb_endpoint_pipe_end_session(hub_info->control_pipe);
     618        usb_endpoint_pipe_end_session(hub_info->status_change_pipe);
    609619        free(change_bitmap);
    610620        return EOK;
Note: See TracChangeset for help on using the changeset viewer.