Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/drv/include/usb_iface.h

    rb7fd2a0 r5a6cc679  
    3232 */
    3333/** @file
    34  * @brief USB interface definition.
     34 * @brief USB device interface definition.
    3535 */
    3636
     
    4040#include "ddf/driver.h"
    4141#include <async.h>
     42#include <usbhc_iface.h>
    4243
    4344typedef async_sess_t usb_dev_session_t;
    4445
    45 /** USB speeds. */
    46 typedef enum {
    47         /** USB 1.1 low speed (1.5Mbits/s). */
    48         USB_SPEED_LOW,
    49         /** USB 1.1 full speed (12Mbits/s). */
    50         USB_SPEED_FULL,
    51         /** USB 2.0 high speed (480Mbits/s). */
    52         USB_SPEED_HIGH,
    53         /** Psuedo-speed serving as a boundary. */
    54         USB_SPEED_MAX
    55 } usb_speed_t;
    56 
    57 /** USB endpoint number type.
    58  * Negative values could be used to indicate error.
    59  */
    60 typedef int16_t usb_endpoint_t;
    61 
    62 /** USB address type.
    63  * Negative values could be used to indicate error.
    64  */
    65 typedef int16_t usb_address_t;
    66 
    67 /** USB transfer type. */
    68 typedef enum {
    69         USB_TRANSFER_CONTROL = 0,
    70         USB_TRANSFER_ISOCHRONOUS = 1,
    71         USB_TRANSFER_BULK = 2,
    72         USB_TRANSFER_INTERRUPT = 3
    73 } usb_transfer_type_t;
    74 
    75 /** USB data transfer direction. */
    76 typedef enum {
    77         USB_DIRECTION_IN,
    78         USB_DIRECTION_OUT,
    79         USB_DIRECTION_BOTH
    80 } usb_direction_t;
    81 
    82 /** USB complete address type.
    83  * Pair address + endpoint is identification of transaction recipient.
    84  */
    85 typedef union {
    86         struct {
    87                 usb_address_t address;
    88                 usb_endpoint_t endpoint;
    89         } __attribute__((packed));
    90         uint32_t packed;
    91 } usb_target_t;
     46typedef struct {
     47        usb_address_t address;          /** Current USB address */
     48        uint8_t depth;                  /** Depth in the hub hiearchy */
     49        usb_speed_t speed;              /** Speed of the device */
     50        devman_handle_t handle;         /** Handle to DDF function of the HC driver */
     51        int iface;                      /** Interface set by multi interface driver, -1 if none */
     52} usb_device_desc_t;
    9253
    9354extern usb_dev_session_t *usb_dev_connect(devman_handle_t);
     
    9556extern void usb_dev_disconnect(usb_dev_session_t *);
    9657
    97 extern errno_t usb_get_my_interface(async_exch_t *, int *);
    98 extern errno_t usb_get_my_device_handle(async_exch_t *, devman_handle_t *);
    99 
    100 extern errno_t usb_reserve_default_address(async_exch_t *, usb_speed_t);
    101 extern errno_t usb_release_default_address(async_exch_t *);
    102 
    103 extern errno_t usb_device_enumerate(async_exch_t *, unsigned port);
    104 extern errno_t usb_device_remove(async_exch_t *, unsigned port);
    105 
    106 extern errno_t usb_register_endpoint(async_exch_t *, usb_endpoint_t,
    107     usb_transfer_type_t, usb_direction_t, size_t, unsigned, unsigned);
    108 extern errno_t usb_unregister_endpoint(async_exch_t *, usb_endpoint_t,
    109     usb_direction_t);
    110 extern errno_t usb_read(async_exch_t *, usb_endpoint_t, uint64_t, void *, size_t,
    111     size_t *);
    112 extern errno_t usb_write(async_exch_t *, usb_endpoint_t, uint64_t, const void *,
    113     size_t);
    114 
    115 /** Callback for outgoing transfer. */
    116 typedef void (*usb_iface_transfer_out_callback_t)(errno_t, void *);
    117 
    118 /** Callback for incoming transfer. */
    119 typedef void (*usb_iface_transfer_in_callback_t)(errno_t, size_t, void *);
     58extern errno_t usb_get_my_description(async_exch_t *, usb_device_desc_t *);
    12059
    12160/** USB device communication interface. */
    12261typedef struct {
    123         errno_t (*get_my_interface)(ddf_fun_t *, int *);
    124         errno_t (*get_my_device_handle)(ddf_fun_t *, devman_handle_t *);
    125 
    126         errno_t (*reserve_default_address)(ddf_fun_t *, usb_speed_t);
    127         errno_t (*release_default_address)(ddf_fun_t *);
    128 
    129         errno_t (*device_enumerate)(ddf_fun_t *, unsigned);
    130         errno_t (*device_remove)(ddf_fun_t *, unsigned);
    131 
    132         errno_t (*register_endpoint)(ddf_fun_t *, usb_endpoint_t,
    133             usb_transfer_type_t, usb_direction_t, size_t, unsigned, unsigned);
    134         errno_t (*unregister_endpoint)(ddf_fun_t *, usb_endpoint_t,
    135             usb_direction_t);
    136 
    137         errno_t (*read)(ddf_fun_t *, usb_endpoint_t, uint64_t, uint8_t *, size_t,
    138             usb_iface_transfer_in_callback_t, void *);
    139         errno_t (*write)(ddf_fun_t *, usb_endpoint_t, uint64_t, const uint8_t *,
    140             size_t, usb_iface_transfer_out_callback_t, void *);
     62        errno_t (*get_my_description)(ddf_fun_t *, usb_device_desc_t *);
    14163} usb_iface_t;
    14264
Note: See TracChangeset for help on using the changeset viewer.