Changeset 41ef5b9 in mainline for uspace/drv/usbhub


Ignore:
Timestamp:
2011-03-21T17:16:10Z (15 years ago)
Author:
Matus Dekanek <smekideki@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
4d0c40b
Parents:
fd9f6e4c (diff), 434ef65 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

merge from usb/development

Location:
uspace/drv/usbhub
Files:
4 edited

Legend:

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

    rfd9f6e4c r41ef5b9  
    4242#include "usbhub_private.h"
    4343
    44 
    45 usb_endpoint_description_t hub_status_change_endpoint_description = {
     44/** Hub status-change endpoint description.
     45 *
     46 * For more information see section 11.15.1 of USB 1.1 specification.
     47 */
     48static usb_endpoint_description_t hub_status_change_endpoint_description = {
    4649        .transfer_type = USB_TRANSFER_INTERRUPT,
    4750        .direction = USB_DIRECTION_IN,
     
    5760};
    5861
     62static usb_endpoint_description_t *usb_hub_endpoints[] = {
     63        &hub_status_change_endpoint_description,
     64        NULL
     65};
     66
    5967static usb_driver_t usb_hub_driver = {
    60         .name = "usbhub",
    61         .ops = &usb_hub_driver_ops
     68        .name = NAME,
     69        .ops = &usb_hub_driver_ops,
     70        .endpoints = usb_hub_endpoints
    6271};
    6372
     
    6574int main(int argc, char *argv[])
    6675{
     76        printf(NAME ": HelenOS USB hub driver.\n");
     77
    6778        usb_log_enable(USB_LOG_LEVEL_DEBUG, NAME);
    68         usb_log_info("starting hub driver\n");
    69 
    7079       
    71         usb_hub_driver.endpoints = (usb_endpoint_description_t**)
    72                         malloc(2 * sizeof(usb_endpoint_description_t*));
    73         usb_hub_driver.endpoints[0] = &hub_status_change_endpoint_description;
    74         usb_hub_driver.endpoints[1] = NULL;
    75 
    7680        return usb_driver_main(&usb_hub_driver);
    7781}
  • uspace/drv/usbhub/usbhub.c

    rfd9f6e4c r41ef5b9  
    157157static int usb_hub_set_configuration(usb_hub_info_t * hub_info){
    158158        //device descriptor
    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         }
     159        usb_standard_device_descriptor_t *std_descriptor
     160            = &hub_info->usb_device->descriptors.device;
    167161        usb_log_info("hub has %d configurations\n",
    168                         std_descriptor.configuration_count);
    169         if(std_descriptor.configuration_count<1){
     162            std_descriptor->configuration_count);
     163        if(std_descriptor->configuration_count<1){
    170164                usb_log_error("THERE ARE NO CONFIGURATIONS AVAILABLE\n");
    171165                //shouldn`t I return?
    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         }
     166                //definitely
     167                return EINVAL;
     168        }
     169
    185170        usb_standard_configuration_descriptor_t *config_descriptor
    186             = (usb_standard_configuration_descriptor_t *) descriptors;
     171            = (usb_standard_configuration_descriptor_t *)
     172            hub_info->usb_device->descriptors.configuration;
    187173
    188174        /* Set configuration. */
    189         opResult = usb_request_set_configuration(&hub_info->usb_device->ctrl_pipe,
     175        int opResult = usb_request_set_configuration(
     176            &hub_info->usb_device->ctrl_pipe,
    190177            config_descriptor->configuration_number);
    191178
     
    197184        usb_log_debug("\tused configuration %d\n",
    198185                        config_descriptor->configuration_number);
    199         free(descriptors);
     186
    200187        return EOK;
    201188}
     
    224211        }
    225212       
    226         usb_endpoint_pipe_start_session(hub_info->control_pipe);
     213        usb_pipe_start_session(hub_info->control_pipe);
    227214        //set hub configuration
    228215        opResult = usb_hub_set_configuration(hub_info);
     
    239226                return opResult;
    240227        }
    241         usb_endpoint_pipe_end_session(hub_info->control_pipe);
     228        usb_pipe_end_session(hub_info->control_pipe);
    242229
    243230
    244231        /// \TODO what is this?
    245         usb_log_debug("adding to ddf");
     232        usb_log_debug("Creating `hub' function.\n");
    246233        ddf_fun_t *hub_fun = ddf_fun_create(hub_info->usb_device->ddf_dev,
    247234                        fun_exposed, "hub");
     
    257244        fid_t fid = fibril_create(usb_hub_control_loop, hub_info);
    258245        if (fid == 0) {
    259                 usb_log_error("failed to start monitoring fibril for new hub");
     246                usb_log_error("failed to start monitoring fibril for new hub.\n");
    260247                return ENOMEM;
    261248        }
    262249        fibril_add_ready(fid);
    263         usb_log_debug("hub fibril created");
    264         usb_log_debug("has %d ports ",hub_info->port_count);
     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);
    265254        return EOK;
    266255}
     
    321310        //reset port
    322311        usb_hub_set_reset_port_request(&request, port);
    323         opResult = usb_endpoint_pipe_control_write(
     312        opResult = usb_pipe_control_write(
    324313                        hub->control_pipe,
    325314                        &request,sizeof(usb_device_request_setup_packet_t),
     
    354343        }
    355344        //create connection to device
    356         usb_endpoint_pipe_t new_device_pipe;
     345        usb_pipe_t new_device_pipe;
    357346        usb_device_connection_t new_device_connection;
    358347        usb_device_connection_initialize_on_default_address(
     
    360349                        &hub->connection
    361350                        );
    362         usb_endpoint_pipe_initialize_default_control(
     351        usb_pipe_initialize_default_control(
    363352                        &new_device_pipe,
    364353                        &new_device_connection);
    365         usb_endpoint_pipe_probe_default_control(&new_device_pipe);
     354        usb_pipe_probe_default_control(&new_device_pipe);
    366355
    367356        /* Request address from host controller. */
     
    379368        //opResult = usb_drv_req_set_address(hc, USB_ADDRESS_DEFAULT,
    380369        //    new_device_address);
    381         usb_endpoint_pipe_start_session(&new_device_pipe);
     370        usb_pipe_start_session(&new_device_pipe);
    382371        opResult = usb_request_set_address(&new_device_pipe,new_device_address);
    383         usb_endpoint_pipe_end_session(&new_device_pipe);
     372        usb_pipe_end_session(&new_device_pipe);
    384373        if (opResult != EOK) {
    385374                usb_log_error("could not set address for new device %d\n",opResult);
     
    488477        usb_log_debug("interrupt at port %d\n", port);
    489478        //determine type of change
    490         usb_endpoint_pipe_t *pipe = hub->control_pipe;
     479        usb_pipe_t *pipe = hub->control_pipe;
    491480       
    492481        int opResult;
     
    499488        //endpoint 0
    500489
    501         opResult = usb_endpoint_pipe_control_read(
     490        opResult = usb_pipe_control_read(
    502491                        pipe,
    503492                        &request, sizeof(usb_device_request_setup_packet_t),
     
    533522        //port reset
    534523        if (usb_port_reset_completed(&status)) {
    535                 usb_log_info("port reset complete");
     524                usb_log_info("port reset complete\n");
    536525                if (usb_port_enabled(&status)) {
    537526                        usb_hub_finalize_add_device(hub, port, usb_port_speed(&status));
     
    560549int usb_hub_check_hub_changes(usb_hub_info_t * hub_info){
    561550        int opResult;
    562         opResult = usb_endpoint_pipe_start_session(
     551        opResult = usb_pipe_start_session(
    563552                        hub_info->status_change_pipe);
    564553        if(opResult != EOK){
     
    578567         * Send the request.
    579568         */
    580         opResult = usb_endpoint_pipe_read(
     569        opResult = usb_pipe_read(
    581570                        hub_info->status_change_pipe,
    582571                        change_bitmap, byte_length, &actual_size
     
    586575                free(change_bitmap);
    587576                usb_log_warning("something went wrong while getting status of hub\n");
    588                 usb_endpoint_pipe_end_session(hub_info->status_change_pipe);
     577                usb_pipe_end_session(hub_info->status_change_pipe);
    589578                return opResult;
    590579        }
    591580        unsigned int port;
    592         opResult = usb_endpoint_pipe_start_session(hub_info->control_pipe);
     581        opResult = usb_pipe_start_session(hub_info->control_pipe);
    593582        if(opResult!=EOK){
    594583                usb_log_error("could not start control pipe session %d\n", opResult);
    595                 usb_endpoint_pipe_end_session(hub_info->status_change_pipe);
     584                usb_pipe_end_session(hub_info->status_change_pipe);
    596585                return opResult;
    597586        }
     
    600589                usb_log_error("could not start host controller session %d\n",
    601590                                opResult);
    602                 usb_endpoint_pipe_end_session(hub_info->control_pipe);
    603                 usb_endpoint_pipe_end_session(hub_info->status_change_pipe);
     591                usb_pipe_end_session(hub_info->control_pipe);
     592                usb_pipe_end_session(hub_info->status_change_pipe);
    604593                return opResult;
    605594        }
     
    615604        }
    616605        usb_hc_connection_close(&hub_info->connection);
    617         usb_endpoint_pipe_end_session(hub_info->control_pipe);
    618         usb_endpoint_pipe_end_session(hub_info->status_change_pipe);
     606        usb_pipe_end_session(hub_info->control_pipe);
     607        usb_pipe_end_session(hub_info->status_change_pipe);
    619608        free(change_bitmap);
    620609        return EOK;
  • uspace/drv/usbhub/usbhub.h

    rfd9f6e4c r41ef5b9  
    4848
    4949
    50 /** Hub status-change endpoint description
    51  *
    52  * For more see usb hub specification in 11.15.1 of
    53  */
    54 extern usb_endpoint_description_t hub_status_change_endpoint_description;
    55 
    56 
    57 
    58 /* Hub endpoints. */
    59 /*typedef struct {
    60         usb_endpoint_pipe_t control;
    61         usb_endpoint_pipe_t status_change;
    62 } usb_hub_endpoints_t;
    63 */
    64 
    65 
    6650/** Information about attached hub. */
    6751typedef struct {
     
    8872         * searched again and again for the 'right pipe'.
    8973         */
    90         usb_endpoint_pipe_t * status_change_pipe;
     74        usb_pipe_t * status_change_pipe;
    9175
    9276        /** convenience pointer to control pipe
     
    9680         * searched again and again for the 'right pipe'.
    9781         */
    98         usb_endpoint_pipe_t * control_pipe;
     82        usb_pipe_t * control_pipe;
    9983
    10084        /** generic usb device data*/
  • uspace/drv/usbhub/usbhub_private.h

    rfd9f6e4c r41ef5b9  
    9595 * @return Operation result
    9696 */
    97 static inline int usb_hub_clear_port_feature(usb_endpoint_pipe_t *pipe,
     97static inline int usb_hub_clear_port_feature(usb_pipe_t *pipe,
    9898    int port_index,
    9999    usb_hub_class_feature_t feature) {
     
    106106        };
    107107        clear_request.value = feature;
    108         return usb_endpoint_pipe_control_write(pipe, &clear_request,
     108        return usb_pipe_control_write(pipe, &clear_request,
    109109            sizeof(clear_request), NULL, 0);
    110110}
Note: See TracChangeset for help on using the changeset viewer.