Changeset 357a302 in mainline for uspace/lib/drv


Ignore:
Timestamp:
2011-02-20T14:17:40Z (14 years ago)
Author:
Vojtech Horky <vojtechhorky@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
b68b279
Parents:
3ae93a8
Message:

USB interfaces reorganization

The most important change is that getting USB address of a device
is an operation of generic USB interface, not USB-HC interface.
That is needed for proper functionality of a MID driver.

Also added sample implementation of USB interface operations as is
needed by most drivers (sample does not mean unfunctional or partially
implemented here).
They are stored in libusb/ddfiface.h

Updated UHCI, UHCI-RH, hub, VHC drivers to use these sample
implementations.

Updated libusb device recognition routines to route get_address requests
through USB interface.

Location:
uspace/lib/drv
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/drv/generic/remote_usb.c

    r3ae93a8 r357a302  
    4141
    4242static void remote_usb_get_hc_handle(device_t *, void *, ipc_callid_t, ipc_call_t *);
     43static void remote_usb_get_address(device_t *, void *, ipc_callid_t, ipc_call_t *);
    4344//static void remote_usb(device_t *, void *, ipc_callid_t, ipc_call_t *);
    4445
    4546/** Remote USB interface operations. */
    4647static remote_iface_func_ptr_t remote_usb_iface_ops [] = {
     48        remote_usb_get_address,
    4749        remote_usb_get_hc_handle
    4850};
     
    5557        .methods = remote_usb_iface_ops
    5658};
     59
     60
     61void remote_usb_get_address(device_t *device, void *iface,
     62    ipc_callid_t callid, ipc_call_t *call)
     63{
     64        usb_iface_t *usb_iface = (usb_iface_t *) iface;
     65
     66        if (usb_iface->get_address == NULL) {
     67                async_answer_0(callid, ENOTSUP);
     68                return;
     69        }
     70
     71        devman_handle_t handle = DEV_IPC_GET_ARG1(*call);
     72
     73        usb_address_t address;
     74        int rc = usb_iface->get_address(device, handle, &address);
     75        if (rc != EOK) {
     76                async_answer_0(callid, rc);
     77        } else {
     78                async_answer_1(callid, EOK, address);
     79        }
     80}
    5781
    5882
  • uspace/lib/drv/generic/remote_usbhc.c

    r3ae93a8 r357a302  
    4343#define HACK_MAX_PACKET_SIZE_INTERRUPT_IN 4
    4444
    45 static void remote_usbhc_get_address(device_t *, void *, ipc_callid_t, ipc_call_t *);
    4645static void remote_usbhc_interrupt_out(device_t *, void *, ipc_callid_t, ipc_call_t *);
    4746static void remote_usbhc_interrupt_in(device_t *, void *, ipc_callid_t, ipc_call_t *);
     
    5958/** Remote USB host controller interface operations. */
    6059static remote_iface_func_ptr_t remote_usbhc_iface_ops [] = {
    61         remote_usbhc_get_address,
    62 
    6360        remote_usbhc_reserve_default_address,
    6461        remote_usbhc_release_default_address,
     
    124121
    125122        return trans;
    126 }
    127 
    128 void remote_usbhc_get_address(device_t *device, void *iface,
    129     ipc_callid_t callid, ipc_call_t *call)
    130 {
    131         usbhc_iface_t *usb_iface = (usbhc_iface_t *) iface;
    132 
    133         if (!usb_iface->tell_address) {
    134                 async_answer_0(callid, ENOTSUP);
    135                 return;
    136         }
    137 
    138         devman_handle_t handle = DEV_IPC_GET_ARG1(*call);
    139 
    140         usb_address_t address;
    141         int rc = usb_iface->tell_address(device, handle, &address);
    142         if (rc != EOK) {
    143                 async_answer_0(callid, rc);
    144         } else {
    145                 async_answer_1(callid, EOK, address);
    146         }
    147123}
    148124
  • uspace/lib/drv/include/usb_iface.h

    r3ae93a8 r357a302  
    4141#include <usb/usb.h>
    4242typedef enum {
     43        /** Tell USB address assigned to device.
     44         * Parameters:
     45         * - devman handle id
     46         * Answer:
     47         * - EINVAL - unknown handle or handle not managed by this driver
     48         * - ENOTSUP - operation not supported (shall not happen)
     49         * - arbitrary error code if returned by remote implementation
     50         * - EOK - handle found, first parameter contains the USB address
     51         */
     52        IPC_M_USB_GET_ADDRESS,
     53
    4354        /** Tell devman handle of device host controller.
    4455         * Parameters:
     
    5566/** USB device communication interface. */
    5667typedef struct {
     68        int (*get_address)(device_t *, devman_handle_t, usb_address_t *);
    5769        int (*get_hc_handle)(device_t *, devman_handle_t *);
    5870} usb_iface_t;
  • uspace/lib/drv/include/usbhc_iface.h

    r3ae93a8 r357a302  
    8585 */
    8686typedef enum {
    87         /** Tell USB address assigned to device.
    88          * Parameters:
    89          * - devman handle id
    90          * Answer:
    91          * - EINVAL - unknown handle or handle not managed by this driver
    92          * - ENOTSUP - operation not supported by HC (shall not happen)
    93          * - arbitrary error code if returned by remote implementation
    94          * - EOK - handle found, first parameter contains the USB address
    95          */
    96         IPC_M_USBHC_GET_ADDRESS,
    97 
    98 
    9987        /** Reserve usage of default address.
    10088         * This call informs the host controller that the caller will be
     
    206194/** USB host controller communication interface. */
    207195typedef struct {
    208         int (*tell_address)(device_t *, devman_handle_t, usb_address_t *);
    209 
    210196        int (*reserve_default_address)(device_t *, usb_speed_t);
    211197        int (*release_default_address)(device_t *);
Note: See TracChangeset for help on using the changeset viewer.