Changeset eb1a2f4 in mainline for uspace/lib/usb


Ignore:
Timestamp:
2011-02-22T23:30:56Z (14 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
3b5d1535, a9c674e0
Parents:
dbe25f1 (diff), 664af708 (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 mainline changes (DDF refactoring)

This merge includes DDF refactoring that brought multifunctional devices
(i.e. ddf_dev_t and ddf_fun_t). Please, see ticket #295 at HelenOS
upstream Trac.

The conflicts themselves were easy to solve (merely several renamings).

Changes to USB subsystem:

  • drivers uses ddf_dev_t and ddf_fun_t
  • different signatures of many library functions
  • several hacks around communication with parent device (now the communication is clearer and somehow what we have now is hack about other hacks)
    • will repair and clean later
  • maybe added some extra debugging messages (the diff has about 240K, and I admit I have no energy to double check that)

WARNING:

  • the diff is VERY long, recommended is viewing partial diffs of the merge (i.e. merges in mainline branch that lead to the parent one)
  • merging with your branches might involve huge renamings, sorry, no other way is possible

BUGS:

  • hub driver will not work (no function created)

GOOD NEWS:

  • QEMU keyboard seems to work with QEMU 0.13 and 0.14
  • we are up-to-date with mainline again
Location:
uspace/lib/usb
Files:
11 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usb/include/usb/ddfiface.h

    rdbe25f1 reb1a2f4  
    4040#include <usb_iface.h>
    4141
    42 int usb_iface_get_hc_handle_hub_impl(device_t *, devman_handle_t *);
    43 int usb_iface_get_address_hub_impl(device_t *, devman_handle_t,
     42int usb_iface_get_hc_handle_hub_impl(ddf_fun_t *, devman_handle_t *);
     43int usb_iface_get_address_hub_impl(ddf_fun_t *, devman_handle_t,
    4444    usb_address_t *);
    4545extern usb_iface_t usb_iface_hub_impl;
    4646
    47 int usb_iface_get_hc_handle_hub_child_impl(device_t *, devman_handle_t *);
    48 int usb_iface_get_address_hub_child_impl(device_t *, devman_handle_t,
     47int usb_iface_get_hc_handle_hub_child_impl(ddf_fun_t *, devman_handle_t *);
     48int usb_iface_get_address_hub_child_impl(ddf_fun_t *, devman_handle_t,
    4949    usb_address_t *);
    5050extern usb_iface_t usb_iface_hub_child_impl;
    5151
    52 int usb_iface_get_hc_handle_hc_impl(device_t *, devman_handle_t *);
     52int usb_iface_get_hc_handle_hc_impl(ddf_fun_t *, devman_handle_t *);
    5353
    5454
  • uspace/lib/usb/include/usb/hub.h

    rdbe25f1 reb1a2f4  
    3939#include <usb/usbdevice.h>
    4040
    41 int usb_hc_new_device_wrapper(device_t *, usb_hc_connection_t *, usb_speed_t,
    42     int (*)(int, void *), int, void *, usb_address_t *, devman_handle_t *);
     41int usb_hc_new_device_wrapper(ddf_dev_t *, usb_hc_connection_t *, usb_speed_t,
     42    int (*)(int, void *), int, void *,
     43    usb_address_t *, devman_handle_t *,
     44    ddf_dev_ops_t *, void *, ddf_fun_t **);
    4345
    4446/** Info about device attached to host controller.
  • uspace/lib/usb/include/usb/pipes.h

    rdbe25f1 reb1a2f4  
    4141#include <usb/descriptor.h>
    4242#include <ipc/devman.h>
    43 #include <driver.h>
     43#include <ddf/driver.h>
    4444
    4545/**
     
    120120    usb_device_connection_t *, usb_hc_connection_t *);
    121121int usb_device_connection_initialize_from_device(usb_device_connection_t *,
    122     device_t *);
     122    ddf_dev_t *);
    123123int usb_device_connection_initialize(usb_device_connection_t *,
    124124    devman_handle_t, usb_address_t);
    125125
    126 int usb_device_get_assigned_interface(device_t *);
     126int usb_device_get_assigned_interface(ddf_dev_t *);
    127127
    128128int usb_endpoint_pipe_initialize(usb_endpoint_pipe_t *,
  • uspace/lib/usb/include/usb/recognise.h

    rdbe25f1 reb1a2f4  
    5050int usb_device_create_match_ids(usb_endpoint_pipe_t *, match_id_list_t *);
    5151
    52 int usb_device_register_child_in_devman(usb_address_t address, devman_handle_t hc_handle,
    53     device_t *parent, devman_handle_t *child_handle);
     52int usb_device_register_child_in_devman(usb_address_t, devman_handle_t,
     53    ddf_dev_t *, devman_handle_t *, ddf_dev_ops_t *, void *, ddf_fun_t **);
    5454
    5555#endif
  • uspace/lib/usb/include/usb/usbdevice.h

    rdbe25f1 reb1a2f4  
    3838#include <sys/types.h>
    3939#include <ipc/devman.h>
    40 #include <driver.h>
     40#include <ddf/driver.h>
    4141#include <bool.h>
    4242#include <usb/usb.h>
     
    5353
    5454int usb_hc_connection_initialize_from_device(usb_hc_connection_t *,
    55     device_t *);
     55    ddf_dev_t *);
    5656int usb_hc_connection_initialize(usb_hc_connection_t *, devman_handle_t);
    5757
  • uspace/lib/usb/src/ddfiface.c

    rdbe25f1 reb1a2f4  
    3434 */
    3535#include <ipc/devman.h>
     36#include <devman.h>
     37#include <async.h>
    3638#include <usb/ddfiface.h>
     39#include <usb/debug.h>
    3740#include <errno.h>
     41#include <assert.h>
    3842
    3943/** DDF interface for USB device, implementation for typical hub. */
     
    5660 * @return Error code.
    5761 */
    58 int usb_iface_get_hc_handle_hub_impl(device_t *device, devman_handle_t *handle)
     62int usb_iface_get_hc_handle_hub_impl(ddf_fun_t *fun, devman_handle_t *handle)
    5963{
    60         assert(device);
    61         return usb_hc_find(device->handle, handle);
     64        assert(fun);
     65        return usb_hc_find(fun->handle, handle);
    6266}
    6367
     
    6973 * @return Error code.
    7074 */
    71 int usb_iface_get_hc_handle_hub_child_impl(device_t *device,
     75int usb_iface_get_hc_handle_hub_child_impl(ddf_fun_t *fun,
    7276    devman_handle_t *handle)
    7377{
    74         assert(device);
    75         device_t *parent = device->parent;
     78        assert(fun != NULL);
    7679
    77         /* Default error, device does not support this operation. */
    78         int rc = ENOTSUP;
    79 
    80         if (parent && parent->ops && parent->ops->interfaces[USB_DEV_IFACE]) {
    81                 usb_iface_t *usb_iface
    82                     = (usb_iface_t *) parent->ops->interfaces[USB_DEV_IFACE];
    83                 assert(usb_iface != NULL);
    84 
    85                 if (usb_iface->get_hc_handle) {
    86                         rc = usb_iface->get_hc_handle(parent, handle);
    87                 }
     80        int parent_phone = devman_parent_device_connect(fun->handle,
     81            IPC_FLAG_BLOCKING);
     82        if (parent_phone < 0) {
     83                return parent_phone;
    8884        }
    8985
    90         return rc;
     86        sysarg_t hc_handle;
     87        int rc = async_req_1_1(parent_phone, DEV_IFACE_ID(USB_DEV_IFACE),
     88            IPC_M_USB_GET_HOST_CONTROLLER_HANDLE, &hc_handle);
     89
     90        if (rc != EOK) {
     91                return rc;
     92        }
     93
     94        *handle = hc_handle;
     95
     96        return EOK;
    9197}
    9298
     
    97103 * @return Always EOK.
    98104 */
    99 int usb_iface_get_hc_handle_hc_impl(device_t *device, devman_handle_t *handle)
     105int usb_iface_get_hc_handle_hc_impl(ddf_fun_t *fun, devman_handle_t *handle)
    100106{
    101         assert(device);
     107        assert(fun);
    102108
    103109        if (handle != NULL) {
    104                 *handle = device->handle;
     110                *handle = fun->handle;
    105111        }
    106112
     
    115121 * @return Error code.
    116122 */
    117 int usb_iface_get_address_hub_impl(device_t *device, devman_handle_t handle,
     123int usb_iface_get_address_hub_impl(ddf_fun_t *fun, devman_handle_t handle,
    118124    usb_address_t *address)
    119125{
    120         assert(device);
    121         int parent_phone = devman_parent_device_connect(device->handle,
     126        assert(fun);
     127        int parent_phone = devman_parent_device_connect(fun->handle,
    122128            IPC_FLAG_BLOCKING);
    123129        if (parent_phone < 0) {
     
    150156 * @return Error code.
    151157 */
    152 int usb_iface_get_address_hub_child_impl(device_t *device,
     158int usb_iface_get_address_hub_child_impl(ddf_fun_t *fun,
    153159    devman_handle_t handle, usb_address_t *address)
    154160{
    155         assert(device);
    156         device_t *parent = device->parent;
    157 
    158         /* Default error, device does not support this operation. */
    159         int rc = ENOTSUP;
    160 
    161         if (parent && parent->ops && parent->ops->interfaces[USB_DEV_IFACE]) {
    162                 usb_iface_t *usb_iface
    163                     = (usb_iface_t *) parent->ops->interfaces[USB_DEV_IFACE];
    164                 assert(usb_iface != NULL);
    165 
    166                 if (usb_iface->get_address) {
    167                         rc = usb_iface->get_address(parent, handle, address);
    168                 }
     161        if (handle == 0) {
     162                handle = fun->handle;
    169163        }
    170 
    171         return rc;
     164        return usb_iface_get_address_hub_impl(fun, handle, address);
    172165}
    173166
  • uspace/lib/usb/src/hub.c

    rdbe25f1 reb1a2f4  
    3939#include <usbhc_iface.h>
    4040#include <errno.h>
     41#include <assert.h>
    4142
    4243/** Check that HC connection is alright.
     
    172173 *      request or requests for descriptors when creating match ids).
    173174 */
    174 int usb_hc_new_device_wrapper(device_t *parent, usb_hc_connection_t *connection,
     175int usb_hc_new_device_wrapper(ddf_dev_t *parent, usb_hc_connection_t *connection,
    175176    usb_speed_t dev_speed,
    176177    int (*enable_port)(int port_no, void *arg), int port_no, void *arg,
    177     usb_address_t *assigned_address, devman_handle_t *assigned_handle)
     178    usb_address_t *assigned_address, devman_handle_t *assigned_handle,
     179    ddf_dev_ops_t *dev_ops, void *new_dev_data, ddf_fun_t **new_fun)
    178180{
    179181        CHECK_CONNECTION(connection);
     
    251253        devman_handle_t child_handle;
    252254        rc = usb_device_register_child_in_devman(dev_addr, dev_conn.hc_handle,
    253             parent, &child_handle);
     255            parent, &child_handle,
     256            dev_ops, new_dev_data, new_fun);
    254257        if (rc != EOK) {
    255258                rc = ESTALL;
  • uspace/lib/usb/src/pipes.c

    rdbe25f1 reb1a2f4  
    3535#include <usb/usb.h>
    3636#include <usb/pipes.h>
     37#include <usb/debug.h>
    3738#include <usbhc_iface.h>
    3839#include <usb_iface.h>
     40#include <devman.h>
    3941#include <errno.h>
    4042#include <assert.h>
     
    4648 * @return USB address or error code.
    4749 */
    48 static usb_address_t get_my_address(int phone, device_t *dev)
     50static usb_address_t get_my_address(int phone, ddf_dev_t *dev)
    4951{
    5052        sysarg_t address;
     53
     54
     55        /*
     56         * We are sending special value as a handle - zero - to get
     57         * handle of the parent function (that handle was used
     58         * when registering our device @p dev.
     59         */
    5160        int rc = async_req_2_1(phone, DEV_IFACE_ID(USB_DEV_IFACE),
    5261            IPC_M_USB_GET_ADDRESS,
    53             dev->handle, &address);
     62            0, &address);
    5463
    5564        if (rc != EOK) {
     
    6574 * @return Interface number (negative code means any).
    6675 */
    67 int usb_device_get_assigned_interface(device_t *device)
     76int usb_device_get_assigned_interface(ddf_dev_t *device)
    6877{
    6978        int parent_phone = devman_parent_device_connect(device->handle,
     
    94103 */
    95104int usb_device_connection_initialize_from_device(
    96     usb_device_connection_t *connection, device_t *device)
     105    usb_device_connection_t *connection, ddf_dev_t *dev)
    97106{
    98107        assert(connection);
    99         assert(device);
     108        assert(dev);
    100109
    101110        int rc;
     
    103112        usb_address_t my_address;
    104113
    105         rc = usb_hc_find(device->handle, &hc_handle);
     114        rc = usb_hc_find(dev->handle, &hc_handle);
    106115        if (rc != EOK) {
    107116                return rc;
    108117        }
    109118
    110         int parent_phone = devman_parent_device_connect(device->handle,
     119        int parent_phone = devman_parent_device_connect(dev->handle,
    111120            IPC_FLAG_BLOCKING);
    112121        if (parent_phone < 0) {
     
    114123        }
    115124
    116         my_address = get_my_address(parent_phone, device);
     125        my_address = get_my_address(parent_phone, dev);
    117126        if (my_address < 0) {
    118127                rc = my_address;
  • uspace/lib/usb/src/recognise.c

    rdbe25f1 reb1a2f4  
    3434 */
    3535#include <sys/types.h>
     36#include <fibril_synch.h>
    3637#include <usb/pipes.h>
    3738#include <usb/recognise.h>
     
    4142#include <stdio.h>
    4243#include <errno.h>
     44#include <assert.h>
    4345
    4446static size_t device_name_index = 0;
    4547static FIBRIL_MUTEX_INITIALIZE(device_name_index_mutex);
    4648
    47 device_ops_t child_ops = {
     49ddf_dev_ops_t child_ops = {
    4850        .interfaces[USB_DEV_IFACE] = &usb_iface_hub_child_impl
    4951};
     
    326328int usb_device_register_child_in_devman(usb_address_t address,
    327329    devman_handle_t hc_handle,
    328     device_t *parent, devman_handle_t *child_handle)
     330    ddf_dev_t *parent, devman_handle_t *child_handle,
     331    ddf_dev_ops_t *dev_ops, void *dev_data, ddf_fun_t **child_fun)
    329332{
    330333        size_t this_device_name_index;
     
    335338        fibril_mutex_unlock(&device_name_index_mutex);
    336339
    337         device_t *child = NULL;
     340        ddf_fun_t *child = NULL;
    338341        char *child_name = NULL;
    339342        int rc;
     
    352355        }
    353356
    354         child = create_device();
     357        /*
     358         * TODO: Once the device driver framework support persistent
     359         * naming etc., something more descriptive could be created.
     360         */
     361        rc = asprintf(&child_name, "usbdev%02zu", this_device_name_index);
     362        if (rc < 0) {
     363                goto failure;
     364        }
     365
     366        child = ddf_fun_create(parent, fun_inner, child_name);
    355367        if (child == NULL) {
    356368                rc = ENOMEM;
     
    358370        }
    359371
    360         /*
    361          * TODO: Once the device driver framework support persistent
    362          * naming etc., something more descriptive could be created.
    363          */
    364         rc = asprintf(&child_name, "usbdev%02zu", this_device_name_index);
    365         if (rc < 0) {
    366                 goto failure;
    367         }
    368         child->parent = parent;
    369         child->name = child_name;
    370         child->ops = &child_ops;
     372        if (dev_ops != NULL) {
     373                child->ops = dev_ops;
     374        } else {
     375                child->ops = &child_ops;
     376        }
     377
     378        child->driver_data = dev_data;
    371379
    372380        rc = usb_endpoint_pipe_start_session(&ctrl_pipe);
     
    385393        }
    386394
    387         rc = child_device_register(child, parent);
     395        rc = ddf_fun_bind(child);
    388396        if (rc != EOK) {
    389397                goto failure;
     
    392400        if (child_handle != NULL) {
    393401                *child_handle = child->handle;
     402        }
     403
     404        if (child_fun != NULL) {
     405                *child_fun = child;
    394406        }
    395407
     
    400412                child->name = NULL;
    401413                /* This takes care of match_id deallocation as well. */
    402                 delete_device(child);
     414                ddf_fun_destroy(child);
    403415        }
    404416        if (child_name != NULL) {
  • uspace/lib/usb/src/request.c

    rdbe25f1 reb1a2f4  
    3535#include <usb/request.h>
    3636#include <errno.h>
     37#include <assert.h>
    3738
    3839#define MAX_DATA_LENGTH ((size_t)(0xFFFF))
  • uspace/lib/usb/src/usbdevice.c

    rdbe25f1 reb1a2f4  
    3737#include <usb_iface.h>
    3838#include <usb/usbdevice.h>
     39#include <usb/debug.h>
    3940#include <errno.h>
     41#include <assert.h>
    4042
    4143/** Find host controller handle that is ancestor of given device.
     
    5557
    5658        devman_handle_t h;
     59        usb_log_debug("asking for HC handle (my handle is %zu).\n", device_handle);
    5760        int rc = async_req_1_1(parent_phone, DEV_IFACE_ID(USB_DEV_IFACE),
    5861            IPC_M_USB_GET_HOST_CONTROLLER_HANDLE, &h);
     
    7881 */
    7982int usb_hc_connection_initialize_from_device(usb_hc_connection_t *connection,
    80     device_t *device)
     83    ddf_dev_t *device)
    8184{
    8285        assert(connection);
Note: See TracChangeset for help on using the changeset viewer.