Changes in / [d321cd7:8f198c9] in mainline


Ignore:
Location:
uspace
Files:
2 deleted
10 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/usbinfo/info.c

    rd321cd7 r8f198c9  
    3939#include <usb/usbdrv.h>
    4040#include <usb/pipes.h>
    41 #include <usb/recognise.h>
    4241#include <usb/request.h>
    4342#include "usbinfo.h"
     
    4847        usb_device_connection_t wire;
    4948        usb_endpoint_pipe_t ctrl_pipe;
     49        ctrl_pipe.hc_phone = -1;
     50
     51        int hc_phone = devman_device_connect(hc_handle, 0);
     52        if (hc_phone < 0) {
     53                fprintf(stderr,
     54                    NAME ": failed to connect to host controller (%zu): %s.\n",
     55                        (size_t) hc_handle, str_error(hc_phone));
     56                return hc_phone;
     57        }
     58
     59        /*
     60         * Dump information about possible match ids.
     61         */
     62        match_id_list_t match_id_list;
     63        init_match_ids(&match_id_list);
     64        rc = usb_drv_create_device_match_ids(hc_phone, &match_id_list, address);
     65        if (rc != EOK) {
     66                fprintf(stderr,
     67                    NAME ": failed to fetch match ids of the device: %s.\n",
     68                    str_error(rc));
     69                goto leave;
     70        }
     71        dump_match_ids(&match_id_list);
    5072
    5173        /*
     
    7395                goto leave;
    7496        }
    75 
    76         /*
    77          * Dump information about possible match ids.
    78          */
    79         match_id_list_t match_id_list;
    80         init_match_ids(&match_id_list);
    81         rc = usb_device_create_match_ids(&ctrl_pipe, &match_id_list);
    82         if (rc != EOK) {
    83                 fprintf(stderr,
    84                     NAME ": failed to fetch match ids of the device: %s.\n",
    85                     str_error(rc));
    86                 goto leave;
    87         }
    88         dump_match_ids(&match_id_list);
    8997
    9098        /*
     
    133141leave:
    134142        /* Ignoring errors here. */
     143        async_hangup(hc_phone);
    135144        usb_endpoint_pipe_end_session(&ctrl_pipe);
    136145
  • uspace/drv/uhci-rhd/port.c

    rd321cd7 r8f198c9  
    3333 */
    3434#include <errno.h>
    35 #include <str_error.h>
    3635
    3736#include <usb/usb.h>    /* usb_address_t */
    3837#include <usb/usbdrv.h> /* usb_drv_*     */
    3938#include <usb/debug.h>
    40 #include <usb/recognise.h>
    4139
    4240#include "port.h"
     
    206204        assert(port->attached_device == 0);
    207205
    208         devman_handle_t hc_handle;
    209         ret = usb_drv_find_hc(port->rh, &hc_handle);
    210         if (ret != EOK) {
    211                 usb_log_error("Failed to get handle of host controller: %s.\n",
    212                     str_error(ret));
    213                 uhci_port_set_enabled(port, false);
    214                 return ENOMEM;
    215         }
    216 
    217         ret = usb_device_register_child_in_devman(usb_address, hc_handle,
    218             port->rh, &port->attached_device);
     206        ret = usb_drv_register_child_in_devman(port->hc_phone, port->rh,
     207          usb_address, &port->attached_device);
     208
    219209        if (ret != EOK) { /* something went wrong */
    220210                usb_log_error("Failed(%d) in usb_drv_register_child.\n", ret);
  • uspace/drv/usbhid/main.c

    rd321cd7 r8f198c9  
    401401
    402402        rc = usb_endpoint_pipe_initialize(&kbd_dev->poll_pipe, &kbd_dev->wire,
    403             GUESSED_POLL_ENDPOINT, USB_TRANSFER_INTERRUPT, 8, USB_DIRECTION_IN);
     403            GUESSED_POLL_ENDPOINT, USB_TRANSFER_INTERRUPT, USB_DIRECTION_IN);
    404404        if (rc != EOK) {
    405405                printf("Failed to initialize interrupt in pipe: %s.\n",
  • uspace/drv/usbhub/usbhub.c

    rd321cd7 r8f198c9  
    3636#include <bool.h>
    3737#include <errno.h>
    38 #include <str_error.h>
    3938
    4039#include <usb_iface.h>
    4140#include <usb/usbdrv.h>
    4241#include <usb/descriptor.h>
    43 #include <usb/recognise.h>
    4442#include <usb/devreq.h>
    4543#include <usb/classes/hub.h>
     
    319317        }
    320318
    321         devman_handle_t hc_handle;
    322         opResult = usb_drv_find_hc(hub->device, &hc_handle);
    323         if (opResult != EOK) {
    324                 usb_log_error("Failed to get handle of host controller: %s.\n",
    325                     str_error(opResult));
    326                 return;
    327         }
    328 
    329319        devman_handle_t child_handle;
    330         opResult = usb_device_register_child_in_devman(new_device_address,
    331             hc_handle, hub->device, &child_handle);
     320        opResult = usb_drv_register_child_in_devman(hc, hub->device,
     321            new_device_address, &child_handle);
    332322        if (opResult != EOK) {
    333323                dprintf(USB_LOG_LEVEL_ERROR, "could not start driver for new device");
  • uspace/drv/vhc/hub.c

    rd321cd7 r8f198c9  
    4141#include <driver.h>
    4242#include <usb/usbdrv.h>
    43 #include <usb/recognise.h>
    4443
    4544#include "hub.h"
     
    9493
    9594        devman_handle_t hub_handle;
    96         usb_device_register_child_in_devman(hub_address, hc_dev->handle,
    97             hc_dev, &hub_handle);
    98         //usb_drv_register_child_in_devman(hc, hc_dev, hub_address, &hub_handle);
     95        usb_drv_register_child_in_devman(hc, hc_dev, hub_address, &hub_handle);
    9996        usb_drv_bind_address(hc, hub_address, hub_handle);
    10097
  • uspace/lib/usb/Makefile

    rd321cd7 r8f198c9  
    4444        src/localdrv.c \
    4545        src/pipes.c \
    46         src/pipesinit.c \
    4746        src/recognise.c \
    4847        src/remotedrv.c \
  • uspace/lib/usb/include/usb/pipes.h

    rd321cd7 r8f198c9  
    3838#include <sys/types.h>
    3939#include <usb/usb.h>
    40 #include <usb/descriptor.h>
    4140#include <ipc/devman.h>
    4241#include <driver.h>
     
    7473        usb_direction_t direction;
    7574
    76         /** Maximum packet size for the endpoint. */
    77         size_t max_packet_size;
    78 
    7975        /** Phone to the host controller.
    8076         * Negative when no session is active.
     
    8379} usb_endpoint_pipe_t;
    8480
    85 
    86 /** Description of endpoint characteristics. */
    87 typedef struct {
    88         /** Transfer type (e.g. control or interrupt). */
    89         usb_transfer_type_t transfer_type;
    90         /** Transfer direction (to or from a device). */
    91         usb_direction_t direction;
    92         /** Interface class this endpoint belongs to (-1 for any). */
    93         int interface_class;
    94         /** Interface subclass this endpoint belongs to (-1 for any). */
    95         int interface_subclass;
    96         /** Interface protocol this endpoint belongs to (-1 for any). */
    97         int interface_protocol;
    98         /** Extra endpoint flags. */
    99         unsigned int flags;
    100 } usb_endpoint_description_t;
    101 
    102 /** Mapping of endpoint pipes and endpoint descriptions. */
    103 typedef struct {
    104         /** Endpoint pipe. */
    105         usb_endpoint_pipe_t *pipe;
    106         /** Endpoint description. */
    107         const usb_endpoint_description_t *description;
    108         /** Found descriptor fitting the description. */
    109         usb_standard_endpoint_descriptor_t *descriptor;
    110         /** Interface the endpoint belongs to. */
    111         usb_standard_interface_descriptor_t *interface;
    112         /** Whether the endpoint was actually found. */
    113         bool present;
    114 } usb_endpoint_mapping_t;
    11581
    11682int usb_device_connection_initialize_from_device(usb_device_connection_t *,
     
    12187int usb_endpoint_pipe_initialize(usb_endpoint_pipe_t *,
    12288    usb_device_connection_t *,
    123     usb_endpoint_t, usb_transfer_type_t, size_t, usb_direction_t);
     89    usb_endpoint_t, usb_transfer_type_t, usb_direction_t);
    12490int usb_endpoint_pipe_initialize_default_control(usb_endpoint_pipe_t *,
    12591    usb_device_connection_t *);
    126 int usb_endpoint_pipe_initialize_from_configuration(usb_endpoint_mapping_t *,
    127     size_t, uint8_t *, size_t, usb_device_connection_t *);
    12892
    12993
  • uspace/lib/usb/include/usb/usbdrv.h

    rd321cd7 r8f198c9  
    106106    const void *, size_t);
    107107
     108int usb_drv_create_device_match_ids(int, match_id_list_t *, usb_address_t);
     109int usb_drv_register_child_in_devman(int, device_t *, usb_address_t,
     110    devman_handle_t *);
     111
    108112
    109113#endif
  • uspace/lib/usb/src/pipes.c

    rd321cd7 r8f198c9  
    123123 * @param endpoint_no Endpoint number (in USB 1.1 in range 0 to 15).
    124124 * @param transfer_type Transfer type (e.g. interrupt or bulk).
    125  * @param max_packet_size Maximum packet size in bytes.
    126125 * @param direction Endpoint direction (in/out).
    127126 * @return Error code.
     
    129128int usb_endpoint_pipe_initialize(usb_endpoint_pipe_t *pipe,
    130129    usb_device_connection_t *connection, usb_endpoint_t endpoint_no,
    131     usb_transfer_type_t transfer_type, size_t max_packet_size,
    132     usb_direction_t direction)
     130    usb_transfer_type_t transfer_type, usb_direction_t direction)
    133131{
    134132        assert(pipe);
     
    139137        pipe->endpoint_no = endpoint_no;
    140138        pipe->transfer_type = transfer_type;
    141         pipe->max_packet_size = max_packet_size;
    142139        pipe->direction = direction;
    143140
     
    159156
    160157        int rc = usb_endpoint_pipe_initialize(pipe, connection,
    161             0, USB_TRANSFER_CONTROL, 8, USB_DIRECTION_BOTH);
     158            0, USB_TRANSFER_CONTROL, USB_DIRECTION_BOTH);
    162159
    163160        return rc;
  • uspace/lib/usb/src/recognise.c

    rd321cd7 r8f198c9  
    3636#include <usb_iface.h>
    3737#include <usb/usbdrv.h>
    38 #include <usb/pipes.h>
    39 #include <usb/recognise.h>
    40 #include <usb/request.h>
    4138#include <usb/classes/classes.h>
    4239#include <stdio.h>
    4340#include <errno.h>
    44 
    45 static size_t device_name_index = 0;
    46 static FIBRIL_MUTEX_INITIALIZE(device_name_index_mutex);
    4741
    4842/** Callback for getting host controller handle.
     
    247241/** Add match ids based on configuration descriptor.
    248242 *
    249  * @param pipe Control pipe to the device.
     243 * @param hc Open phone to host controller.
    250244 * @param matches Match ids list to add matches to.
     245 * @param address USB address of the attached device.
    251246 * @param config_count Number of configurations the device has.
    252247 * @return Error code.
    253248 */
    254 static int usb_add_config_descriptor_match_ids(usb_endpoint_pipe_t *pipe,
    255     match_id_list_t *matches, int config_count)
     249static int usb_add_config_descriptor_match_ids(int hc,
     250    match_id_list_t *matches, usb_address_t address,
     251    int config_count)
    256252{
    257253        int final_rc = EOK;
     
    261257                int rc;
    262258                usb_standard_configuration_descriptor_t config_descriptor;
    263                 rc = usb_request_get_bare_configuration_descriptor(pipe,
    264                     config_index, &config_descriptor);
     259                rc = usb_drv_req_get_bare_configuration_descriptor(hc,
     260                    address,  config_index, &config_descriptor);
    265261                if (rc != EOK) {
    266262                        final_rc = rc;
     
    271267                void *full_config_descriptor
    272268                    = malloc(config_descriptor.total_length);
    273                 rc = usb_request_get_full_configuration_descriptor(pipe,
    274                     config_index,
     269                rc = usb_drv_req_get_full_configuration_descriptor(hc,
     270                    address, config_index,
    275271                    full_config_descriptor, config_descriptor.total_length,
    276272                    &full_config_descriptor_size);
     
    303299 * function exits with error.
    304300 *
    305  * @param ctrl_pipe Control pipe to given device (session must be already
    306  *      started).
     301 * @param hc Open phone to host controller.
    307302 * @param matches Initialized list of match ids.
    308  * @return Error code.
    309  */
    310 int usb_device_create_match_ids(usb_endpoint_pipe_t *ctrl_pipe,
    311     match_id_list_t *matches)
     303 * @param address USB address of the attached device.
     304 * @return Error code.
     305 */
     306int usb_drv_create_device_match_ids(int hc, match_id_list_t *matches,
     307    usb_address_t address)
    312308{
    313309        int rc;
     310       
    314311        /*
    315312         * Retrieve device descriptor and add matches from it.
     
    317314        usb_standard_device_descriptor_t device_descriptor;
    318315
    319         rc = usb_request_get_device_descriptor(ctrl_pipe, &device_descriptor);
     316        rc = usb_drv_req_get_device_descriptor(hc, address,
     317            &device_descriptor);
    320318        if (rc != EOK) {
    321319                return rc;
    322320        }
    323 
     321       
    324322        rc = usb_drv_create_match_ids_from_device_descriptor(matches,
    325323            &device_descriptor);
     
    327325                return rc;
    328326        }
    329 
     327       
    330328        /*
    331329         * Go through all configurations and add matches
    332330         * based on interface class.
    333331         */
    334         rc = usb_add_config_descriptor_match_ids(ctrl_pipe, matches,
    335             device_descriptor.configuration_count);
     332        rc = usb_add_config_descriptor_match_ids(hc, matches,
     333            address, device_descriptor.configuration_count);
    336334        if (rc != EOK) {
    337335                return rc;
     
    349347}
    350348
     349
    351350/** Probe for device kind and register it in devman.
    352351 *
     352 * @param[in] hc Open phone to the host controller.
     353 * @param[in] parent Parent device.
    353354 * @param[in] address Address of the (unknown) attached device.
    354  * @param[in] hc_handle Handle of the host controller.
    355  * @param[in] parent Parent device.
    356355 * @param[out] child_handle Handle of the child device.
    357356 * @return Error code.
    358357 */
    359 int usb_device_register_child_in_devman(usb_address_t address,
    360     devman_handle_t hc_handle,
    361     device_t *parent, devman_handle_t *child_handle)
    362 {
     358int usb_drv_register_child_in_devman(int hc, device_t *parent,
     359    usb_address_t address, devman_handle_t *child_handle)
     360{
     361        static size_t device_name_index = 0;
     362        static FIBRIL_MUTEX_INITIALIZE(device_name_index_mutex);
     363
    363364        size_t this_device_name_index;
    364365
     
    368369        fibril_mutex_unlock(&device_name_index_mutex);
    369370
     371
    370372        device_t *child = NULL;
    371373        char *child_name = NULL;
    372374        int rc;
    373         usb_device_connection_t dev_connection;
    374         usb_endpoint_pipe_t ctrl_pipe;
    375 
    376         rc = usb_device_connection_initialize(&dev_connection, hc_handle, address);
    377         if (rc != EOK) {
    378                 goto failure;
    379         }
    380 
    381         rc = usb_endpoint_pipe_initialize_default_control(&ctrl_pipe,
    382             &dev_connection);
    383         if (rc != EOK) {
    384                 goto failure;
    385         }
    386375
    387376        child = create_device();
     
    402391        child->name = child_name;
    403392        child->ops = &child_ops;
    404 
    405         rc = usb_endpoint_pipe_start_session(&ctrl_pipe);
    406         if (rc != EOK) {
    407                 goto failure;
    408         }
    409 
    410         rc = usb_device_create_match_ids(&ctrl_pipe, &child->match_ids);
    411         if (rc != EOK) {
    412                 goto failure;
    413         }
    414 
    415         rc = usb_endpoint_pipe_end_session(&ctrl_pipe);
     393       
     394        rc = usb_drv_create_device_match_ids(hc, &child->match_ids, address);
    416395        if (rc != EOK) {
    417396                goto failure;
     
    426405                *child_handle = child->handle;
    427406        }
    428 
     407       
    429408        return EOK;
    430409
     
    440419
    441420        return rc;
     421
    442422}
    443423
Note: See TracChangeset for help on using the changeset viewer.