iPXE
usb.h
Go to the documentation of this file.
00001 #ifndef _IPXE_USB_H
00002 #define _IPXE_USB_H
00003 
00004 /** @file
00005  *
00006  * Universal Serial Bus (USB)
00007  *
00008  */
00009 
00010 FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
00011 
00012 #include <byteswap.h>
00013 #include <ipxe/list.h>
00014 #include <ipxe/device.h>
00015 #include <ipxe/process.h>
00016 #include <ipxe/iobuf.h>
00017 #include <ipxe/tables.h>
00018 
00019 /** USB protocols */
00020 enum usb_protocol {
00021         /** USB 2.0 */
00022         USB_PROTO_2_0 = 0x0200,
00023         /** USB 3.0 */
00024         USB_PROTO_3_0 = 0x0300,
00025         /** USB 3.1 */
00026         USB_PROTO_3_1 = 0x0301,
00027 };
00028 
00029 /** Define a USB speed
00030  *
00031  * @v mantissa          Mantissa
00032  * @v exponent          Exponent (in engineering terms: 1=k, 2=M, 3=G)
00033  * @ret speed           USB speed
00034  */
00035 #define USB_SPEED( mantissa, exponent ) ( (exponent << 16) | (mantissa) )
00036 
00037 /** Extract USB speed mantissa */
00038 #define USB_SPEED_MANTISSA(speed) ( (speed) & 0xffff )
00039 
00040 /** Extract USB speed exponent */
00041 #define USB_SPEED_EXPONENT(speed) ( ( (speed) >> 16 ) & 0x3 )
00042 
00043 /** USB device speeds */
00044 enum usb_speed {
00045         /** Not connected */
00046         USB_SPEED_NONE = 0,
00047         /** Low speed (1.5Mbps) */
00048         USB_SPEED_LOW = USB_SPEED ( 1500, 1 ),
00049         /** Full speed (12Mbps) */
00050         USB_SPEED_FULL = USB_SPEED ( 12, 2 ),
00051         /** High speed (480Mbps) */
00052         USB_SPEED_HIGH = USB_SPEED ( 480, 2 ),
00053         /** Super speed (5Gbps) */
00054         USB_SPEED_SUPER = USB_SPEED ( 5, 3 ),
00055 };
00056 
00057 /** USB packet IDs */
00058 enum usb_pid {
00059         /** IN PID */
00060         USB_PID_IN = 0x69,
00061         /** OUT PID */
00062         USB_PID_OUT = 0xe1,
00063         /** SETUP PID */
00064         USB_PID_SETUP = 0x2d,
00065 };
00066 
00067 /** A USB setup data packet */
00068 struct usb_setup_packet {
00069         /** Request */
00070         uint16_t request;
00071         /** Value parameter */
00072         uint16_t value;
00073         /** Index parameter */
00074         uint16_t index;
00075         /** Length of data stage */
00076         uint16_t len;
00077 } __attribute__ (( packed ));
00078 
00079 /** Data transfer is from host to device */
00080 #define USB_DIR_OUT ( 0 << 7 )
00081 
00082 /** Data transfer is from device to host */
00083 #define USB_DIR_IN ( 1 << 7 )
00084 
00085 /** Standard request type */
00086 #define USB_TYPE_STANDARD ( 0 << 5 )
00087 
00088 /** Class-specific request type */
00089 #define USB_TYPE_CLASS ( 1 << 5 )
00090 
00091 /** Vendor-specific request type */
00092 #define USB_TYPE_VENDOR ( 2 << 5 )
00093 
00094 /** Request recipient mask */
00095 #define USB_RECIP_MASK ( 0x1f << 0 )
00096 
00097 /** Request recipient is the device */
00098 #define USB_RECIP_DEVICE ( 0 << 0 )
00099 
00100 /** Request recipient is an interface */
00101 #define USB_RECIP_INTERFACE ( 1 << 0 )
00102 
00103 /** Request recipient is an endpoint */
00104 #define USB_RECIP_ENDPOINT ( 2 << 0 )
00105 
00106 /** Construct USB request type */
00107 #define USB_REQUEST_TYPE(type) ( (type) << 8 )
00108 
00109 /** Get status */
00110 #define USB_GET_STATUS ( USB_DIR_IN | USB_REQUEST_TYPE ( 0 ) )
00111 
00112 /** Clear feature */
00113 #define USB_CLEAR_FEATURE ( USB_DIR_OUT | USB_REQUEST_TYPE ( 1 ) )
00114 
00115 /** Set feature */
00116 #define USB_SET_FEATURE ( USB_DIR_OUT | USB_REQUEST_TYPE ( 3 ) )
00117 
00118 /** Set address */
00119 #define USB_SET_ADDRESS ( USB_DIR_OUT | USB_REQUEST_TYPE ( 5 ) )
00120 
00121 /** Get descriptor */
00122 #define USB_GET_DESCRIPTOR ( USB_DIR_IN | USB_REQUEST_TYPE ( 6 ) )
00123 
00124 /** Set descriptor */
00125 #define USB_SET_DESCRIPTOR ( USB_DIR_OUT | USB_REQUEST_TYPE ( 7 ) )
00126 
00127 /** Get configuration */
00128 #define USB_GET_CONFIGURATION ( USB_DIR_IN | USB_REQUEST_TYPE ( 8 ) )
00129 
00130 /** Set configuration */
00131 #define USB_SET_CONFIGURATION ( USB_DIR_OUT | USB_REQUEST_TYPE ( 9 ) )
00132 
00133 /** Get interface */
00134 #define USB_GET_INTERFACE \
00135         ( USB_DIR_IN | USB_RECIP_INTERFACE | USB_REQUEST_TYPE ( 10 ) )
00136 
00137 /** Set interface */
00138 #define USB_SET_INTERFACE \
00139         ( USB_DIR_OUT | USB_RECIP_INTERFACE | USB_REQUEST_TYPE ( 11 ) )
00140 
00141 /** Endpoint halt feature */
00142 #define USB_ENDPOINT_HALT 0
00143 
00144 /** A USB class code tuple */
00145 struct usb_class {
00146         /** Class code */
00147         uint8_t class;
00148         /** Subclass code */
00149         uint8_t subclass;
00150         /** Protocol code */
00151         uint8_t protocol;
00152 } __attribute__ (( packed ));
00153 
00154 /** Class code for USB hubs */
00155 #define USB_CLASS_HUB 9
00156 
00157 /** A USB descriptor header */
00158 struct usb_descriptor_header {
00159         /** Length of descriptor */
00160         uint8_t len;
00161         /** Descriptor type */
00162         uint8_t type;
00163 } __attribute__ (( packed ));
00164 
00165 /** A USB device descriptor */
00166 struct usb_device_descriptor {
00167         /** Descriptor header */
00168         struct usb_descriptor_header header;
00169         /** USB specification release number in BCD */
00170         uint16_t protocol;
00171         /** Device class */
00172         struct usb_class class;
00173         /** Maximum packet size for endpoint zero */
00174         uint8_t mtu;
00175         /** Vendor ID */
00176         uint16_t vendor;
00177         /** Product ID */
00178         uint16_t product;
00179         /** Device release number in BCD */
00180         uint16_t release;
00181         /** Manufacturer string */
00182         uint8_t manufacturer;
00183         /** Product string */
00184         uint8_t name;
00185         /** Serial number string */
00186         uint8_t serial;
00187         /** Number of possible configurations */
00188         uint8_t configurations;
00189 } __attribute__ (( packed ));
00190 
00191 /** A USB device descriptor */
00192 #define USB_DEVICE_DESCRIPTOR 1
00193 
00194 /** A USB configuration descriptor */
00195 struct usb_configuration_descriptor {
00196         /** Descriptor header */
00197         struct usb_descriptor_header header;
00198         /** Total length */
00199         uint16_t len;
00200         /** Number of interfaces */
00201         uint8_t interfaces;
00202         /** Configuration value */
00203         uint8_t config;
00204         /** Configuration string */
00205         uint8_t name;
00206         /** Attributes */
00207         uint8_t attributes;
00208         /** Maximum power consumption */
00209         uint8_t power;
00210 } __attribute__ (( packed ));
00211 
00212 /** A USB configuration descriptor */
00213 #define USB_CONFIGURATION_DESCRIPTOR 2
00214 
00215 /** A USB string descriptor */
00216 struct usb_string_descriptor {
00217         /** Descriptor header */
00218         struct usb_descriptor_header header;
00219         /** String */
00220         char string[0];
00221 } __attribute__ (( packed ));
00222 
00223 /** A USB string descriptor */
00224 #define USB_STRING_DESCRIPTOR 3
00225 
00226 /** Language ID for English */
00227 #define USB_LANG_ENGLISH 0x0409
00228 
00229 /** A USB interface descriptor */
00230 struct usb_interface_descriptor {
00231         /** Descriptor header */
00232         struct usb_descriptor_header header;
00233         /** Interface number */
00234         uint8_t interface;
00235         /** Alternate setting */
00236         uint8_t alternate;
00237         /** Number of endpoints */
00238         uint8_t endpoints;
00239         /** Interface class */
00240         struct usb_class class;
00241         /** Interface name */
00242         uint8_t name;
00243 } __attribute__ (( packed ));
00244 
00245 /** A USB interface descriptor */
00246 #define USB_INTERFACE_DESCRIPTOR 4
00247 
00248 /** A USB endpoint descriptor */
00249 struct usb_endpoint_descriptor {
00250         /** Descriptor header */
00251         struct usb_descriptor_header header;
00252         /** Endpoint address */
00253         uint8_t endpoint;
00254         /** Attributes */
00255         uint8_t attributes;
00256         /** Maximum packet size and burst size */
00257         uint16_t sizes;
00258         /** Polling interval */
00259         uint8_t interval;
00260 } __attribute__ (( packed ));
00261 
00262 /** A USB endpoint descriptor */
00263 #define USB_ENDPOINT_DESCRIPTOR 5
00264 
00265 /** Endpoint attribute transfer type mask */
00266 #define USB_ENDPOINT_ATTR_TYPE_MASK 0x03
00267 
00268 /** Endpoint periodic type */
00269 #define USB_ENDPOINT_ATTR_PERIODIC 0x01
00270 
00271 /** Control endpoint transfer type */
00272 #define USB_ENDPOINT_ATTR_CONTROL 0x00
00273 
00274 /** Bulk endpoint transfer type */
00275 #define USB_ENDPOINT_ATTR_BULK 0x02
00276 
00277 /** Interrupt endpoint transfer type */
00278 #define USB_ENDPOINT_ATTR_INTERRUPT 0x03
00279 
00280 /** Bulk OUT endpoint (internal) type */
00281 #define USB_BULK_OUT ( USB_ENDPOINT_ATTR_BULK | USB_DIR_OUT )
00282 
00283 /** Bulk IN endpoint (internal) type */
00284 #define USB_BULK_IN ( USB_ENDPOINT_ATTR_BULK | USB_DIR_IN )
00285 
00286 /** Interrupt IN endpoint (internal) type */
00287 #define USB_INTERRUPT_IN ( USB_ENDPOINT_ATTR_INTERRUPT | USB_DIR_IN )
00288 
00289 /** Interrupt OUT endpoint (internal) type */
00290 #define USB_INTERRUPT_OUT ( USB_ENDPOINT_ATTR_INTERRUPT | USB_DIR_OUT )
00291 
00292 /** USB endpoint MTU */
00293 #define USB_ENDPOINT_MTU(sizes) ( ( (sizes) >> 0 ) & 0x07ff )
00294 
00295 /** USB endpoint maximum burst size */
00296 #define USB_ENDPOINT_BURST(sizes) ( ( (sizes) >> 11 ) & 0x0003 )
00297 
00298 /** A USB endpoint companion descriptor */
00299 struct usb_endpoint_companion_descriptor {
00300         /** Descriptor header */
00301         struct usb_descriptor_header header;
00302         /** Maximum burst size */
00303         uint8_t burst;
00304         /** Extended attributes */
00305         uint8_t extended;
00306         /** Number of bytes per service interval */
00307         uint16_t periodic;
00308 } __attribute__ (( packed ));
00309 
00310 /** A USB endpoint companion descriptor */
00311 #define USB_ENDPOINT_COMPANION_DESCRIPTOR 48
00312 
00313 /** A USB interface association descriptor */
00314 struct usb_interface_association_descriptor {
00315         /** Descriptor header */
00316         struct usb_descriptor_header header;
00317         /** First interface number */
00318         uint8_t first;
00319         /** Interface count */
00320         uint8_t count;
00321         /** Association class */
00322         struct usb_class class;
00323         /** Association name */
00324         uint8_t name;
00325 } __attribute__ (( packed ));
00326 
00327 /** A USB interface association descriptor */
00328 #define USB_INTERFACE_ASSOCIATION_DESCRIPTOR 11
00329 
00330 /** A class-specific interface descriptor */
00331 #define USB_CS_INTERFACE_DESCRIPTOR 36
00332 
00333 /** A class-specific endpoint descriptor */
00334 #define USB_CS_ENDPOINT_DESCRIPTOR 37
00335 
00336 /**
00337  * Get next USB descriptor
00338  *
00339  * @v desc              USB descriptor header
00340  * @ret next            Next USB descriptor header
00341  */
00342 static inline __attribute__ (( always_inline )) struct usb_descriptor_header *
00343 usb_next_descriptor ( struct usb_descriptor_header *desc ) {
00344 
00345         return ( ( ( void * ) desc ) + desc->len );
00346 }
00347 
00348 /**
00349  * Check that descriptor lies within a configuration descriptor
00350  *
00351  * @v config            Configuration descriptor
00352  * @v desc              Descriptor header
00353  * @v is_within         Descriptor is within the configuration descriptor
00354  */
00355 static inline __attribute__ (( always_inline )) int
00356 usb_is_within_config ( struct usb_configuration_descriptor *config,
00357                        struct usb_descriptor_header *desc ) {
00358         struct usb_descriptor_header *end =
00359                 ( ( ( void * ) config ) + le16_to_cpu ( config->len ) );
00360 
00361         /* Check that descriptor starts within the configuration
00362          * descriptor, and that the length does not exceed the
00363          * configuration descriptor.  This relies on the fact that
00364          * usb_next_descriptor() needs to access only the first byte
00365          * of the descriptor in order to determine the length.
00366          */
00367         return ( ( desc < end ) && ( usb_next_descriptor ( desc ) <= end ) );
00368 }
00369 
00370 /** Iterate over all configuration descriptors */
00371 #define for_each_config_descriptor( desc, config )                         \
00372         for ( desc = container_of ( &(config)->header,                     \
00373                                     typeof ( *desc ), header ) ;           \
00374               usb_is_within_config ( (config), &desc->header ) ;           \
00375               desc = container_of ( usb_next_descriptor ( &desc->header ), \
00376                                     typeof ( *desc ), header ) )
00377 
00378 /** Iterate over all configuration descriptors within an interface descriptor */
00379 #define for_each_interface_descriptor( desc, config, interface )           \
00380         for ( desc = container_of ( usb_next_descriptor ( &(interface)->   \
00381                                                           header ),        \
00382                                     typeof ( *desc ), header ) ;           \
00383               ( usb_is_within_config ( (config), &desc->header ) &&        \
00384                 ( desc->header.type != USB_INTERFACE_DESCRIPTOR ) ) ;      \
00385               desc = container_of ( usb_next_descriptor ( &desc->header ), \
00386                                     typeof ( *desc ), header ) )
00387 
00388 /** A USB endpoint */
00389 struct usb_endpoint {
00390         /** USB device */
00391         struct usb_device *usb;
00392         /** Endpoint address */
00393         unsigned int address;
00394         /** Attributes */
00395         unsigned int attributes;
00396         /** Maximum transfer size */
00397         size_t mtu;
00398         /** Maximum burst size */
00399         unsigned int burst;
00400         /** Interval (in microframes) */
00401         unsigned int interval;
00402 
00403         /** Endpoint is open */
00404         int open;
00405         /** Buffer fill level */
00406         unsigned int fill;
00407 
00408         /** List of halted endpoints */
00409         struct list_head halted;
00410 
00411         /** Host controller operations */
00412         struct usb_endpoint_host_operations *host;
00413         /** Host controller private data */
00414         void *priv;
00415         /** Driver operations */
00416         struct usb_endpoint_driver_operations *driver;
00417 
00418         /** Recycled I/O buffer list */
00419         struct list_head recycled;
00420         /** Refill buffer reserved header length */
00421         size_t reserve;
00422         /** Refill buffer payload length */
00423         size_t len;
00424         /** Maximum fill level */
00425         unsigned int max;
00426 };
00427 
00428 /** USB endpoint host controller operations */
00429 struct usb_endpoint_host_operations {
00430         /** Open endpoint
00431          *
00432          * @v ep                USB endpoint
00433          * @ret rc              Return status code
00434          */
00435         int ( * open ) ( struct usb_endpoint *ep );
00436         /** Close endpoint
00437          *
00438          * @v ep                USB endpoint
00439          */
00440         void ( * close ) ( struct usb_endpoint *ep );
00441         /**
00442          * Reset endpoint
00443          *
00444          * @v ep                USB endpoint
00445          * @ret rc              Return status code
00446          */
00447         int ( * reset ) ( struct usb_endpoint *ep );
00448         /** Update MTU
00449          *
00450          * @v ep                USB endpoint
00451          * @ret rc              Return status code
00452          */
00453         int ( * mtu ) ( struct usb_endpoint *ep );
00454         /** Enqueue message transfer
00455          *
00456          * @v ep                USB endpoint
00457          * @v iobuf             I/O buffer
00458          * @ret rc              Return status code
00459          */
00460         int ( * message ) ( struct usb_endpoint *ep,
00461                             struct io_buffer *iobuf );
00462         /** Enqueue stream transfer
00463          *
00464          * @v ep                USB endpoint
00465          * @v iobuf             I/O buffer
00466          * @v zlp               Append a zero-length packet
00467          * @ret rc              Return status code
00468          */
00469         int ( * stream ) ( struct usb_endpoint *ep, struct io_buffer *iobuf,
00470                            int zlp );
00471 };
00472 
00473 /** USB endpoint driver operations */
00474 struct usb_endpoint_driver_operations {
00475         /** Complete transfer
00476          *
00477          * @v ep                USB endpoint
00478          * @v iobuf             I/O buffer
00479          * @v rc                Completion status code
00480          */
00481         void ( * complete ) ( struct usb_endpoint *ep,
00482                               struct io_buffer *iobuf, int rc );
00483 };
00484 
00485 /** Control endpoint address */
00486 #define USB_EP0_ADDRESS 0x00
00487 
00488 /** Control endpoint attributes */
00489 #define USB_EP0_ATTRIBUTES 0x00
00490 
00491 /** Calculate default MTU based on device speed
00492  *
00493  * @v speed             Device speed
00494  * @ret mtu             Default MTU
00495  */
00496 #define USB_EP0_DEFAULT_MTU(speed)                      \
00497         ( ( (speed) >= USB_SPEED_SUPER ) ? 512 :        \
00498           ( ( (speed) >= USB_SPEED_FULL ) ? 64 : 8 ) )
00499 
00500 /** Control endpoint maximum burst size */
00501 #define USB_EP0_BURST 0
00502 
00503 /** Control endpoint interval */
00504 #define USB_EP0_INTERVAL 0
00505 
00506 /** Maximum endpoint number */
00507 #define USB_ENDPOINT_MAX 0x0f
00508 
00509 /** Endpoint direction is in */
00510 #define USB_ENDPOINT_IN 0x80
00511 
00512 /** Construct endpoint index from endpoint address */
00513 #define USB_ENDPOINT_IDX(address)                                       \
00514         ( ( (address) & USB_ENDPOINT_MAX ) |                            \
00515           ( ( (address) & USB_ENDPOINT_IN ) >> 3 ) )
00516 
00517 /**
00518  * Initialise USB endpoint
00519  *
00520  * @v ep                USB endpoint
00521  * @v usb               USB device
00522  * @v driver            Driver operations
00523  */
00524 static inline __attribute__ (( always_inline )) void
00525 usb_endpoint_init ( struct usb_endpoint *ep, struct usb_device *usb,
00526                     struct usb_endpoint_driver_operations *driver ) {
00527 
00528         ep->usb = usb;
00529         ep->driver = driver;
00530 }
00531 
00532 /**
00533  * Describe USB endpoint
00534  *
00535  * @v ep                USB endpoint
00536  * @v address           Endpoint address
00537  * @v attributes        Attributes
00538  * @v mtu               Maximum packet size
00539  * @v burst             Maximum burst size
00540  * @v interval          Interval (in microframes)
00541  */
00542 static inline __attribute__ (( always_inline )) void
00543 usb_endpoint_describe ( struct usb_endpoint *ep, unsigned int address,
00544                         unsigned int attributes, size_t mtu,
00545                         unsigned int burst, unsigned int interval ) {
00546 
00547         ep->address = address;
00548         ep->attributes = attributes;
00549         ep->mtu = mtu;
00550         ep->burst = burst;
00551         ep->interval = interval;
00552 }
00553 
00554 /**
00555  * Set USB endpoint host controller private data
00556  *
00557  * @v ep                USB endpoint
00558  * @v priv              Host controller private data
00559  */
00560 static inline __attribute__ (( always_inline )) void
00561 usb_endpoint_set_hostdata ( struct usb_endpoint *ep, void *priv ) {
00562         ep->priv = priv;
00563 }
00564 
00565 /**
00566  * Get USB endpoint host controller private data
00567  *
00568  * @v ep                USB endpoint
00569  * @ret priv            Host controller private data
00570  */
00571 static inline __attribute__ (( always_inline )) void *
00572 usb_endpoint_get_hostdata ( struct usb_endpoint *ep ) {
00573         return ep->priv;
00574 }
00575 
00576 extern const char * usb_endpoint_name ( struct usb_endpoint *ep );
00577 extern int
00578 usb_endpoint_described ( struct usb_endpoint *ep,
00579                          struct usb_configuration_descriptor *config,
00580                          struct usb_interface_descriptor *interface,
00581                          unsigned int type, unsigned int index );
00582 extern int usb_endpoint_open ( struct usb_endpoint *ep );
00583 extern void usb_endpoint_close ( struct usb_endpoint *ep );
00584 extern int usb_message ( struct usb_endpoint *ep, unsigned int request,
00585                          unsigned int value, unsigned int index,
00586                          struct io_buffer *iobuf );
00587 extern int usb_stream ( struct usb_endpoint *ep, struct io_buffer *iobuf,
00588                         int terminate );
00589 extern void usb_complete_err ( struct usb_endpoint *ep,
00590                                struct io_buffer *iobuf, int rc );
00591 
00592 /**
00593  * Initialise USB endpoint refill
00594  *
00595  * @v ep                USB endpoint
00596  * @v reserve           Refill buffer reserved header length
00597  * @v len               Refill buffer payload length (zero for endpoint's MTU)
00598  * @v max               Maximum fill level
00599  */
00600 static inline __attribute__ (( always_inline )) void
00601 usb_refill_init ( struct usb_endpoint *ep, size_t reserve, size_t len,
00602                   unsigned int max ) {
00603 
00604         INIT_LIST_HEAD ( &ep->recycled );
00605         ep->reserve = reserve;
00606         ep->len = len;
00607         ep->max = max;
00608 }
00609 
00610 /**
00611  * Recycle I/O buffer
00612  *
00613  * @v ep                USB endpoint
00614  * @v iobuf             I/O buffer
00615  */
00616 static inline __attribute__ (( always_inline )) void
00617 usb_recycle ( struct usb_endpoint *ep, struct io_buffer *iobuf ) {
00618 
00619         list_add_tail ( &iobuf->list, &ep->recycled );
00620 }
00621 
00622 extern int usb_prefill ( struct usb_endpoint *ep );
00623 extern int usb_refill ( struct usb_endpoint *ep );
00624 extern void usb_flush ( struct usb_endpoint *ep );
00625 
00626 /** A USB class descriptor */
00627 union usb_class_descriptor {
00628         /** Class */
00629         struct usb_class class;
00630         /** Scalar value */
00631         uint32_t scalar;
00632 };
00633 
00634 /**
00635  * A USB function descriptor
00636  *
00637  * This is an internal descriptor used to represent an association of
00638  * interfaces within a USB device.
00639  */
00640 struct usb_function_descriptor {
00641         /** Vendor ID */
00642         uint16_t vendor;
00643         /** Product ID */
00644         uint16_t product;
00645         /** Class */
00646         union usb_class_descriptor class;
00647         /** Number of interfaces */
00648         unsigned int count;
00649 };
00650 
00651 /**
00652  * A USB function
00653  *
00654  * A USB function represents an association of interfaces within a USB
00655  * device.
00656  */
00657 struct usb_function {
00658         /** Name */
00659         const char *name;
00660         /** USB device */
00661         struct usb_device *usb;
00662         /** Function descriptor */
00663         struct usb_function_descriptor desc;
00664         /** Generic device */
00665         struct device dev;
00666         /** List of functions within this USB device */
00667         struct list_head list;
00668 
00669         /** Driver */
00670         struct usb_driver *driver;
00671         /** Driver private data */
00672         void *priv;
00673         /** Driver device ID */
00674         struct usb_device_id *id;
00675 
00676         /** List of interface numbers
00677          *
00678          * This must be the last field within the structure.
00679          */
00680         uint8_t interface[0];
00681 };
00682 
00683 /**
00684  * Set USB function driver private data
00685  *
00686  * @v func              USB function
00687  * @v priv              Driver private data
00688  */
00689 static inline __attribute__ (( always_inline )) void
00690 usb_func_set_drvdata ( struct usb_function *func, void *priv ) {
00691         func->priv = priv;
00692 }
00693 
00694 /**
00695  * Get USB function driver private data
00696  *
00697  * @v function          USB function
00698  * @ret priv            Driver private data
00699  */
00700 static inline __attribute__ (( always_inline )) void *
00701 usb_func_get_drvdata ( struct usb_function *func ) {
00702         return func->priv;
00703 }
00704 
00705 /** A USB device */
00706 struct usb_device {
00707         /** Name */
00708         char name[32];
00709         /** USB port */
00710         struct usb_port *port;
00711         /** Device speed */
00712         unsigned int speed;
00713         /** List of devices on this bus */
00714         struct list_head list;
00715         /** Device address, if assigned */
00716         unsigned int address;
00717         /** Device descriptor */
00718         struct usb_device_descriptor device;
00719         /** List of functions */
00720         struct list_head functions;
00721 
00722         /** Host controller operations */
00723         struct usb_device_host_operations *host;
00724         /** Host controller private data */
00725         void *priv;
00726 
00727         /** Endpoint list */
00728         struct usb_endpoint *ep[32];
00729 
00730         /** Control endpoint */
00731         struct usb_endpoint control;
00732         /** Completed control transfers */
00733         struct list_head complete;
00734 
00735         /** Default language ID (if known) */
00736         unsigned int language;
00737 };
00738 
00739 /** USB device host controller operations */
00740 struct usb_device_host_operations {
00741         /** Open device
00742          *
00743          * @v usb               USB device
00744          * @ret rc              Return status code
00745          */
00746         int ( * open ) ( struct usb_device *usb );
00747         /** Close device
00748          *
00749          * @v usb               USB device
00750          */
00751         void ( * close ) ( struct usb_device *usb );
00752         /** Assign device address
00753          *
00754          * @v usb               USB device
00755          * @ret rc              Return status code
00756          */
00757         int ( * address ) ( struct usb_device *usb );
00758 };
00759 
00760 /**
00761  * Set USB device host controller private data
00762  *
00763  * @v usb               USB device
00764  * @v priv              Host controller private data
00765  */
00766 static inline __attribute__ (( always_inline )) void
00767 usb_set_hostdata ( struct usb_device *usb, void *priv ) {
00768         usb->priv = priv;
00769 }
00770 
00771 /**
00772  * Get USB device host controller private data
00773  *
00774  * @v usb               USB device
00775  * @ret priv            Host controller private data
00776  */
00777 static inline __attribute__ (( always_inline )) void *
00778 usb_get_hostdata ( struct usb_device *usb ) {
00779         return usb->priv;
00780 }
00781 
00782 /**
00783  * Get USB endpoint
00784  *
00785  * @v usb               USB device
00786  * @v address           Endpoint address
00787  * @ret ep              USB endpoint, or NULL if not opened
00788  */
00789 static inline struct usb_endpoint * usb_endpoint ( struct usb_device *usb,
00790                                                    unsigned int address ) {
00791 
00792         return usb->ep[ USB_ENDPOINT_IDX ( address ) ];
00793 }
00794 
00795 /** A USB port */
00796 struct usb_port {
00797         /** USB hub */
00798         struct usb_hub *hub;
00799         /** Port address */
00800         unsigned int address;
00801         /** Port protocol */
00802         unsigned int protocol;
00803         /** Port speed */
00804         unsigned int speed;
00805         /** Port disconnection has been detected
00806          *
00807          * This should be set whenever the underlying hardware reports
00808          * a connection status change.
00809          */
00810         int disconnected;
00811         /** Port has an attached device */
00812         int attached;
00813         /** Currently attached device (if in use)
00814          *
00815          * Note that this field will be NULL if the attached device
00816          * has been freed (e.g. because there were no drivers found).
00817          */
00818         struct usb_device *usb;
00819         /** List of changed ports */
00820         struct list_head changed;
00821 };
00822 
00823 /** A USB hub */
00824 struct usb_hub {
00825         /** Name */
00826         const char *name;
00827         /** USB bus */
00828         struct usb_bus *bus;
00829         /** Underlying USB device, if any */
00830         struct usb_device *usb;
00831         /** Hub protocol */
00832         unsigned int protocol;
00833         /** Number of ports */
00834         unsigned int ports;
00835 
00836         /** List of hubs */
00837         struct list_head list;
00838 
00839         /** Host controller operations */
00840         struct usb_hub_host_operations *host;
00841         /** Driver operations */
00842         struct usb_hub_driver_operations *driver;
00843         /** Driver private data */
00844         void *priv;
00845 
00846         /** Port list
00847          *
00848          * This must be the last field within the structure.
00849          */
00850         struct usb_port port[0];
00851 };
00852 
00853 /** USB hub host controller operations */
00854 struct usb_hub_host_operations {
00855         /** Open hub
00856          *
00857          * @v hub               USB hub
00858          * @ret rc              Return status code
00859          */
00860         int ( * open ) ( struct usb_hub *hub );
00861         /** Close hub
00862          *
00863          * @v hub               USB hub
00864          */
00865         void ( * close ) ( struct usb_hub *hub );
00866 };
00867 
00868 /** USB hub driver operations */
00869 struct usb_hub_driver_operations {
00870         /** Open hub
00871          *
00872          * @v hub               USB hub
00873          * @ret rc              Return status code
00874          */
00875         int ( * open ) ( struct usb_hub *hub );
00876         /** Close hub
00877          *
00878          * @v hub               USB hub
00879          */
00880         void ( * close ) ( struct usb_hub *hub );
00881         /** Enable port
00882          *
00883          * @v hub               USB hub
00884          * @v port              USB port
00885          * @ret rc              Return status code
00886          */
00887         int ( * enable ) ( struct usb_hub *hub, struct usb_port *port );
00888         /** Disable port
00889          *
00890          * @v hub               USB hub
00891          * @v port              USB port
00892          * @ret rc              Return status code
00893          */
00894         int ( * disable ) ( struct usb_hub *hub, struct usb_port *port );
00895         /** Update port speed
00896          *
00897          * @v hub               USB hub
00898          * @v port              USB port
00899          * @ret rc              Return status code
00900          */
00901         int ( * speed ) ( struct usb_hub *hub, struct usb_port *port );
00902         /** Clear transaction translator buffer
00903          *
00904          * @v hub               USB hub
00905          * @v port              USB port
00906          * @v ep                USB endpoint
00907          * @ret rc              Return status code
00908          */
00909         int ( * clear_tt ) ( struct usb_hub *hub, struct usb_port *port,
00910                              struct usb_endpoint *ep );
00911 };
00912 
00913 /**
00914  * Set USB hub driver private data
00915  *
00916  * @v hub               USB hub
00917  * @v priv              Driver private data
00918  */
00919 static inline __attribute__ (( always_inline )) void
00920 usb_hub_set_drvdata ( struct usb_hub *hub, void *priv ) {
00921         hub->priv = priv;
00922 }
00923 
00924 /**
00925  * Get USB hub driver private data
00926  *
00927  * @v hub               USB hub
00928  * @ret priv            Driver private data
00929  */
00930 static inline __attribute__ (( always_inline )) void *
00931 usb_hub_get_drvdata ( struct usb_hub *hub ) {
00932         return hub->priv;
00933 }
00934 
00935 /**
00936  * Get USB port
00937  *
00938  * @v hub               USB hub
00939  * @v address           Port address
00940  * @ret port            USB port
00941  */
00942 static inline __attribute__ (( always_inline )) struct usb_port *
00943 usb_port ( struct usb_hub *hub, unsigned int address ) {
00944 
00945         return &hub->port[ address - 1 ];
00946 }
00947 
00948 /** A USB bus */
00949 struct usb_bus {
00950         /** Name */
00951         const char *name;
00952         /** Underlying hardware device */
00953         struct device *dev;
00954         /** Host controller operations set */
00955         struct usb_host_operations *op;
00956 
00957         /** Largest transfer allowed on the bus */
00958         size_t mtu;
00959         /** Address in-use mask
00960          *
00961          * This is used only by buses which perform manual address
00962          * assignment.  USB allows for addresses in the range [1,127].
00963          * We use a simple bitmask which restricts us to the range
00964          * [1,64]; this is unlikely to be a problem in practice.  For
00965          * comparison: controllers which perform autonomous address
00966          * assignment (such as xHCI) typically allow for only 32
00967          * devices per bus anyway.
00968          */
00969         unsigned long long addresses;
00970 
00971         /** Root hub */
00972         struct usb_hub *hub;
00973 
00974         /** List of USB buses */
00975         struct list_head list;
00976         /** List of devices */
00977         struct list_head devices;
00978         /** List of hubs */
00979         struct list_head hubs;
00980 
00981         /** Host controller operations */
00982         struct usb_bus_host_operations *host;
00983         /** Host controller private data */
00984         void *priv;
00985 };
00986 
00987 /** USB bus host controller operations */
00988 struct usb_bus_host_operations {
00989         /** Open bus
00990          *
00991          * @v bus               USB bus
00992          * @ret rc              Return status code
00993          */
00994         int ( * open ) ( struct usb_bus *bus );
00995         /** Close bus
00996          *
00997          * @v bus               USB bus
00998          */
00999         void ( * close ) ( struct usb_bus *bus );
01000         /** Poll bus
01001          *
01002          * @v bus               USB bus
01003          */
01004         void ( * poll ) ( struct usb_bus *bus );
01005 };
01006 
01007 /** USB host controller operations */
01008 struct usb_host_operations {
01009         /** Endpoint operations */
01010         struct usb_endpoint_host_operations endpoint;
01011         /** Device operations */
01012         struct usb_device_host_operations device;
01013         /** Bus operations */
01014         struct usb_bus_host_operations bus;
01015         /** Hub operations */
01016         struct usb_hub_host_operations hub;
01017         /** Root hub operations */
01018         struct usb_hub_driver_operations root;
01019 };
01020 
01021 /**
01022  * Set USB bus host controller private data
01023  *
01024  * @v bus               USB bus
01025  * @v priv              Host controller private data
01026  */
01027 static inline __attribute__ (( always_inline )) void
01028 usb_bus_set_hostdata ( struct usb_bus *bus, void *priv ) {
01029         bus->priv = priv;
01030 }
01031 
01032 /**
01033  * Get USB bus host controller private data
01034  *
01035  * @v bus               USB bus
01036  * @ret priv            Host controller private data
01037  */
01038 static inline __attribute__ (( always_inline )) void *
01039 usb_bus_get_hostdata ( struct usb_bus *bus ) {
01040         return bus->priv;
01041 }
01042 
01043 /**
01044  * Poll USB bus
01045  *
01046  * @v bus               USB bus
01047  */
01048 static inline __attribute__ (( always_inline )) void
01049 usb_poll ( struct usb_bus *bus ) {
01050         bus->host->poll ( bus );
01051 }
01052 
01053 /** Iterate over all USB buses */
01054 #define for_each_usb_bus( bus ) \
01055         list_for_each_entry ( (bus), &usb_buses, list )
01056 
01057 /**
01058  * Complete transfer (without error)
01059  *
01060  * @v ep                USB endpoint
01061  * @v iobuf             I/O buffer
01062  */
01063 static inline __attribute__ (( always_inline )) void
01064 usb_complete ( struct usb_endpoint *ep, struct io_buffer *iobuf ) {
01065         usb_complete_err ( ep, iobuf, 0 );
01066 }
01067 
01068 extern int usb_control ( struct usb_device *usb, unsigned int request,
01069                          unsigned int value, unsigned int index, void *data,
01070                          size_t len );
01071 extern int usb_get_string_descriptor ( struct usb_device *usb,
01072                                        unsigned int index,
01073                                        unsigned int language,
01074                                        char *buf, size_t len );
01075 
01076 /**
01077  * Get status
01078  *
01079  * @v usb               USB device
01080  * @v type              Request type
01081  * @v index             Target index
01082  * @v data              Status to fill in
01083  * @v len               Length of status descriptor
01084  * @ret rc              Return status code
01085  */
01086 static inline __attribute__ (( always_inline )) int
01087 usb_get_status ( struct usb_device *usb, unsigned int type, unsigned int index,
01088                  void *data, size_t len ) {
01089 
01090         return usb_control ( usb, ( USB_GET_STATUS | type ), 0, index,
01091                              data, len );
01092 }
01093 
01094 /**
01095  * Clear feature
01096  *
01097  * @v usb               USB device
01098  * @v type              Request type
01099  * @v feature           Feature selector
01100  * @v index             Target index
01101  * @ret rc              Return status code
01102  */
01103 static inline __attribute__ (( always_inline )) int
01104 usb_clear_feature ( struct usb_device *usb, unsigned int type,
01105                     unsigned int feature, unsigned int index ) {
01106 
01107         return usb_control ( usb, ( USB_CLEAR_FEATURE | type ),
01108                              feature, index, NULL, 0 );
01109 }
01110 
01111 /**
01112  * Set feature
01113  *
01114  * @v usb               USB device
01115  * @v type              Request type
01116  * @v feature           Feature selector
01117  * @v index             Target index
01118  * @ret rc              Return status code
01119  */
01120 static inline __attribute__ (( always_inline )) int
01121 usb_set_feature ( struct usb_device *usb, unsigned int type,
01122                   unsigned int feature, unsigned int index ) {
01123 
01124         return usb_control ( usb, ( USB_SET_FEATURE | type ),
01125                              feature, index, NULL, 0 );
01126 }
01127 
01128 /**
01129  * Set address
01130  *
01131  * @v usb               USB device
01132  * @v address           Device address
01133  * @ret rc              Return status code
01134  */
01135 static inline __attribute__ (( always_inline )) int
01136 usb_set_address ( struct usb_device *usb, unsigned int address ) {
01137 
01138         return usb_control ( usb, USB_SET_ADDRESS, address, 0, NULL, 0 );
01139 }
01140 
01141 /**
01142  * Get USB descriptor
01143  *
01144  * @v usb               USB device
01145  * @v type              Request type
01146  * @v desc              Descriptor type
01147  * @v index             Descriptor index
01148  * @v language          Language ID (for string descriptors)
01149  * @v data              Descriptor to fill in
01150  * @v len               Maximum length of descriptor
01151  * @ret rc              Return status code
01152  */
01153 static inline __attribute__ (( always_inline )) int
01154 usb_get_descriptor ( struct usb_device *usb, unsigned int type,
01155                      unsigned int desc, unsigned int index,
01156                      unsigned int language, struct usb_descriptor_header *data,
01157                      size_t len ) {
01158 
01159         return usb_control ( usb, ( USB_GET_DESCRIPTOR | type ),
01160                              ( ( desc << 8 ) | index ), language, data, len );
01161 }
01162 
01163 /**
01164  * Get first part of USB device descriptor (up to and including MTU)
01165  *
01166  * @v usb               USB device
01167  * @v data              Device descriptor to (partially) fill in
01168  * @ret rc              Return status code
01169  */
01170 static inline __attribute__ (( always_inline )) int
01171 usb_get_mtu ( struct usb_device *usb, struct usb_device_descriptor *data ) {
01172 
01173         return usb_get_descriptor ( usb, 0, USB_DEVICE_DESCRIPTOR, 0, 0,
01174                                     &data->header,
01175                                     ( offsetof ( typeof ( *data ), mtu ) +
01176                                       sizeof ( data->mtu ) ) );
01177 }
01178 
01179 /**
01180  * Get USB device descriptor
01181  *
01182  * @v usb               USB device
01183  * @v data              Device descriptor to fill in
01184  * @ret rc              Return status code
01185  */
01186 static inline __attribute__ (( always_inline )) int
01187 usb_get_device_descriptor ( struct usb_device *usb,
01188                             struct usb_device_descriptor *data ) {
01189 
01190         return usb_get_descriptor ( usb, 0, USB_DEVICE_DESCRIPTOR, 0, 0,
01191                                     &data->header, sizeof ( *data ) );
01192 }
01193 
01194 /**
01195  * Get USB configuration descriptor
01196  *
01197  * @v usb               USB device
01198  * @v index             Configuration index
01199  * @v data              Configuration descriptor to fill in
01200  * @ret rc              Return status code
01201  */
01202 static inline __attribute__ (( always_inline )) int
01203 usb_get_config_descriptor ( struct usb_device *usb, unsigned int index,
01204                             struct usb_configuration_descriptor *data,
01205                             size_t len ) {
01206 
01207         return usb_get_descriptor ( usb, 0, USB_CONFIGURATION_DESCRIPTOR, index,
01208                                     0, &data->header, len );
01209 }
01210 
01211 /**
01212  * Set USB configuration
01213  *
01214  * @v usb               USB device
01215  * @v index             Configuration index
01216  * @ret rc              Return status code
01217  */
01218 static inline __attribute__ (( always_inline )) int
01219 usb_set_configuration ( struct usb_device *usb, unsigned int index ) {
01220 
01221         return usb_control ( usb, USB_SET_CONFIGURATION, index, 0, NULL, 0 );
01222 }
01223 
01224 /**
01225  * Set USB interface alternate setting
01226  *
01227  * @v usb               USB device
01228  * @v interface         Interface number
01229  * @v alternate         Alternate setting
01230  * @ret rc              Return status code
01231  */
01232 static inline __attribute__ (( always_inline )) int
01233 usb_set_interface ( struct usb_device *usb, unsigned int interface,
01234                     unsigned int alternate ) {
01235 
01236         return usb_control ( usb, USB_SET_INTERFACE, alternate, interface,
01237                              NULL, 0 );
01238 }
01239 
01240 extern struct list_head usb_buses;
01241 
01242 extern struct usb_interface_descriptor *
01243 usb_interface_descriptor ( struct usb_configuration_descriptor *config,
01244                            unsigned int interface, unsigned int alternate );
01245 extern struct usb_endpoint_descriptor *
01246 usb_endpoint_descriptor ( struct usb_configuration_descriptor *config,
01247                           struct usb_interface_descriptor *interface,
01248                           unsigned int type, unsigned int index );
01249 extern struct usb_endpoint_companion_descriptor *
01250 usb_endpoint_companion_descriptor ( struct usb_configuration_descriptor *config,
01251                                     struct usb_endpoint_descriptor *desc );
01252 
01253 extern struct usb_hub * alloc_usb_hub ( struct usb_bus *bus,
01254                                         struct usb_device *usb,
01255                                         unsigned int ports,
01256                                         struct usb_hub_driver_operations *op );
01257 extern int register_usb_hub ( struct usb_hub *hub );
01258 extern void unregister_usb_hub ( struct usb_hub *hub );
01259 extern void free_usb_hub ( struct usb_hub *hub );
01260 
01261 extern void usb_port_changed ( struct usb_port *port );
01262 
01263 extern struct usb_bus * alloc_usb_bus ( struct device *dev,
01264                                         unsigned int ports, size_t mtu,
01265                                         struct usb_host_operations *op );
01266 extern int register_usb_bus ( struct usb_bus *bus );
01267 extern void unregister_usb_bus ( struct usb_bus *bus );
01268 extern void free_usb_bus ( struct usb_bus *bus );
01269 extern struct usb_bus * find_usb_bus_by_location ( unsigned int bus_type,
01270                                                    unsigned int location );
01271 
01272 extern int usb_alloc_address ( struct usb_bus *bus );
01273 extern void usb_free_address ( struct usb_bus *bus, unsigned int address );
01274 extern unsigned int usb_route_string ( struct usb_device *usb );
01275 extern unsigned int usb_depth ( struct usb_device *usb );
01276 extern struct usb_port * usb_root_hub_port ( struct usb_device *usb );
01277 extern struct usb_port * usb_transaction_translator ( struct usb_device *usb );
01278 
01279 /** Minimum reset time
01280  *
01281  * Section 7.1.7.5 of the USB2 specification states that root hub
01282  * ports should assert reset signalling for at least 50ms.
01283  */
01284 #define USB_RESET_DELAY_MS 50
01285 
01286 /** Reset recovery time
01287  *
01288  * Section 9.2.6.2 of the USB2 specification states that the
01289  * "recovery" interval after a port reset is 10ms.
01290  */
01291 #define USB_RESET_RECOVER_DELAY_MS 10
01292 
01293 /** Maximum time to wait for a control transaction to complete
01294  *
01295  * Section 9.2.6.1 of the USB2 specification states that the upper
01296  * limit for commands to be processed is 5 seconds.
01297  */
01298 #define USB_CONTROL_MAX_WAIT_MS 5000
01299 
01300 /** Set address recovery time
01301  *
01302  * Section 9.2.6.3 of the USB2 specification states that devices are
01303  * allowed a 2ms recovery interval after receiving a new address.
01304  */
01305 #define USB_SET_ADDRESS_RECOVER_DELAY_MS 2
01306 
01307 /** Time to wait for ports to stabilise
01308  *
01309  * Section 7.1.7.3 of the USB specification states that we must allow
01310  * 100ms for devices to signal attachment, and an additional 100ms for
01311  * connection debouncing.  (This delay is parallelised across all
01312  * ports on a hub; we do not delay separately for each port.)
01313  */
01314 #define USB_PORT_DELAY_MS 200
01315 
01316 /** A USB device ID */
01317 struct usb_device_id {
01318         /** Name */
01319         const char *name;
01320         /** Vendor ID */
01321         uint16_t vendor;
01322         /** Product ID */
01323         uint16_t product;
01324         /** Arbitrary driver data */
01325         unsigned long driver_data;
01326 };
01327 
01328 /** Match-anything ID */
01329 #define USB_ANY_ID 0xffff
01330 
01331 /** A USB class ID */
01332 struct usb_class_id {
01333         /** Class */
01334         union usb_class_descriptor class;
01335         /** Class mask */
01336         union usb_class_descriptor mask;
01337 };
01338 
01339 /** Construct USB class ID
01340  *
01341  * @v base              Base class code (or USB_ANY_ID)
01342  * @v subclass          Subclass code (or USB_ANY_ID)
01343  * @v protocol          Protocol code (or USB_ANY_ID)
01344  */
01345 #define USB_CLASS_ID( base, subclass, protocol ) {                      \
01346         .class = {                                                      \
01347                 .class = {                                              \
01348                         ( (base) & 0xff ),                              \
01349                         ( (subclass) & 0xff ),                          \
01350                         ( (protocol) & 0xff ),                          \
01351                 },                                                      \
01352         },                                                              \
01353         .mask = {                                                       \
01354                 .class = {                                              \
01355                         ( ( (base) == USB_ANY_ID ) ? 0x00 : 0xff ),     \
01356                         ( ( (subclass) == USB_ANY_ID ) ? 0x00 : 0xff ), \
01357                         ( ( (protocol) == USB_ANY_ID ) ? 0x00 : 0xff ), \
01358                 },                                                      \
01359                 },                                                      \
01360         }
01361 
01362 /** A USB driver */
01363 struct usb_driver {
01364         /** USB ID table */
01365         struct usb_device_id *ids;
01366         /** Number of entries in ID table */
01367         unsigned int id_count;
01368         /** Class ID */
01369         struct usb_class_id class;
01370         /** Driver score
01371          *
01372          * This is used to determine the preferred configuration for a
01373          * USB device.
01374          */
01375         unsigned int score;
01376         /**
01377          * Probe device
01378          *
01379          * @v func              USB function
01380          * @v config            Configuration descriptor
01381          * @ret rc              Return status code
01382          */
01383         int ( * probe ) ( struct usb_function *func,
01384                           struct usb_configuration_descriptor *config );
01385         /**
01386          * Remove device
01387          *
01388          * @v func              USB function
01389          */
01390         void ( * remove ) ( struct usb_function *func );
01391 };
01392 
01393 /** USB driver table */
01394 #define USB_DRIVERS __table ( struct usb_driver, "usb_drivers" )
01395 
01396 /** Declare a USB driver */
01397 #define __usb_driver __table_entry ( USB_DRIVERS, 01 )
01398 
01399 /** USB driver scores */
01400 enum usb_driver_score {
01401         /** Fallback driver (has no effect on overall score) */
01402         USB_SCORE_FALLBACK = 0,
01403         /** Deprecated driver */
01404         USB_SCORE_DEPRECATED = 1,
01405         /** Normal driver */
01406         USB_SCORE_NORMAL = 2,
01407 };
01408 
01409 extern struct usb_driver *
01410 usb_find_driver ( struct usb_function_descriptor *desc,
01411                   struct usb_device_id **id );
01412 
01413 #endif /* _IPXE_USB_H */