Home | History | Annotate | Download | only in UsbBusDxe
      1 /** @file
      2 
      3     Usb Bus Driver Binding and Bus IO Protocol.
      4 
      5 Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.<BR>
      6 This program and the accompanying materials
      7 are licensed and made available under the terms and conditions of the BSD License
      8 which accompanies this distribution.  The full text of the license may be found at
      9 http://opensource.org/licenses/bsd-license.php
     10 
     11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
     12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
     13 
     14 **/
     15 
     16 #ifndef _EFI_USB_BUS_H_
     17 #define _EFI_USB_BUS_H_
     18 
     19 
     20 #include <Uefi.h>
     21 
     22 #include <Protocol/Usb2HostController.h>
     23 #include <Protocol/UsbHostController.h>
     24 #include <Protocol/UsbIo.h>
     25 #include <Protocol/DevicePath.h>
     26 
     27 #include <Library/BaseLib.h>
     28 #include <Library/DebugLib.h>
     29 #include <Library/BaseMemoryLib.h>
     30 #include <Library/UefiDriverEntryPoint.h>
     31 #include <Library/UefiBootServicesTableLib.h>
     32 #include <Library/UefiLib.h>
     33 #include <Library/DevicePathLib.h>
     34 #include <Library/MemoryAllocationLib.h>
     35 #include <Library/ReportStatusCodeLib.h>
     36 
     37 
     38 #include <IndustryStandard/Usb.h>
     39 
     40 typedef struct _USB_DEVICE     USB_DEVICE;
     41 typedef struct _USB_INTERFACE  USB_INTERFACE;
     42 typedef struct _USB_BUS        USB_BUS;
     43 typedef struct _USB_HUB_API    USB_HUB_API;
     44 
     45 
     46 #include "UsbUtility.h"
     47 #include "UsbDesc.h"
     48 #include "UsbHub.h"
     49 #include "UsbEnumer.h"
     50 
     51 //
     52 // USB bus timeout experience values
     53 //
     54 
     55 #define USB_MAX_LANG_ID           16
     56 #define USB_MAX_INTERFACE         16
     57 #define USB_MAX_DEVICES           128
     58 
     59 #define USB_BUS_1_MILLISECOND     1000
     60 
     61 //
     62 // Roothub and hub's polling interval, set by experience,
     63 // The unit of roothub is 100us, means 100ms as interval, and
     64 // the unit of hub is 1ms, means 64ms as interval.
     65 //
     66 #define USB_ROOTHUB_POLL_INTERVAL (100 * 10000U)
     67 #define USB_HUB_POLL_INTERVAL     64
     68 
     69 //
     70 // Wait for port stable to work, refers to specification
     71 // [USB20-9.1.2]
     72 //
     73 #define USB_WAIT_PORT_STABLE_STALL  (100 * USB_BUS_1_MILLISECOND)
     74 
     75 //
     76 // Wait for port statue reg change, set by experience
     77 //
     78 #define USB_WAIT_PORT_STS_CHANGE_STALL (100)
     79 
     80 //
     81 // Wait for set device address, refers to specification
     82 // [USB20-9.2.6.3, it says 2ms]
     83 //
     84 #define USB_SET_DEVICE_ADDRESS_STALL   (2 * USB_BUS_1_MILLISECOND)
     85 
     86 //
     87 // Wait for retry max packet size, set by experience
     88 //
     89 #define USB_RETRY_MAX_PACK_SIZE_STALL  (100 * USB_BUS_1_MILLISECOND)
     90 
     91 //
     92 // Wait for hub port power-on, refers to specification
     93 // [USB20-11.23.2]
     94 //
     95 #define USB_SET_PORT_POWER_STALL       (2 * USB_BUS_1_MILLISECOND)
     96 
     97 //
     98 // Wait for port reset, refers to specification
     99 // [USB20-7.1.7.5, it says 10ms for hub and 50ms for
    100 // root hub]
    101 //
    102 // According to USB2.0, Chapter 11.5.1.5 Resetting,
    103 // the worst case for TDRST is 20ms
    104 //
    105 #define USB_SET_PORT_RESET_STALL       (20 * USB_BUS_1_MILLISECOND)
    106 #define USB_SET_ROOT_PORT_RESET_STALL  (50 * USB_BUS_1_MILLISECOND)
    107 
    108 //
    109 // Wait for port recovery to accept SetAddress, refers to specification
    110 // [USB20-7.1.7.5, it says 10 ms for TRSTRCY]
    111 //
    112 #define USB_SET_PORT_RECOVERY_STALL    (10 * USB_BUS_1_MILLISECOND)
    113 
    114 //
    115 // Wait for clear roothub port reset, set by experience
    116 //
    117 #define USB_CLR_ROOT_PORT_RESET_STALL  (20 * USB_BUS_1_MILLISECOND)
    118 
    119 //
    120 // Wait for set roothub port enable, set by experience
    121 //
    122 #define USB_SET_ROOT_PORT_ENABLE_STALL (20 * USB_BUS_1_MILLISECOND)
    123 
    124 //
    125 // Send general device request timeout.
    126 //
    127 // The USB Specification 2.0, section 11.24.1 recommends a value of
    128 // 50 milliseconds.  We use a value of 500 milliseconds to work
    129 // around slower hubs and devices.
    130 //
    131 #define USB_GENERAL_DEVICE_REQUEST_TIMEOUT 500
    132 
    133 //
    134 // Send clear feature request timeout, set by experience
    135 //
    136 #define USB_CLEAR_FEATURE_REQUEST_TIMEOUT  10
    137 
    138 //
    139 // Bus raises TPL to TPL_NOTIFY to serialize all its operations
    140 // to protect shared data structures.
    141 //
    142 #define  USB_BUS_TPL               TPL_NOTIFY
    143 
    144 #define  USB_INTERFACE_SIGNATURE   SIGNATURE_32 ('U', 'S', 'B', 'I')
    145 #define  USB_BUS_SIGNATURE         SIGNATURE_32 ('U', 'S', 'B', 'B')
    146 
    147 #define USB_BIT(a)                  ((UINTN)(1 << (a)))
    148 #define USB_BIT_IS_SET(Data, Bit)   ((BOOLEAN)(((Data) & (Bit)) == (Bit)))
    149 
    150 #define USB_INTERFACE_FROM_USBIO(a) \
    151           CR(a, USB_INTERFACE, UsbIo, USB_INTERFACE_SIGNATURE)
    152 
    153 #define USB_BUS_FROM_THIS(a) \
    154           CR(a, USB_BUS, BusId, USB_BUS_SIGNATURE)
    155 
    156 //
    157 // Used to locate USB_BUS
    158 // UsbBusProtocol is the private protocol.
    159 // gEfiCallerIdGuid will be used as its protocol guid.
    160 //
    161 typedef struct _EFI_USB_BUS_PROTOCOL {
    162   UINT64                    Reserved;
    163 } EFI_USB_BUS_PROTOCOL;
    164 
    165 
    166 //
    167 // Stands for the real USB device. Each device may
    168 // has several seperately working interfaces.
    169 //
    170 struct _USB_DEVICE {
    171   USB_BUS                   *Bus;
    172 
    173   //
    174   // Configuration information
    175   //
    176   UINT8                     Speed;
    177   UINT8                     Address;
    178   UINT32                    MaxPacket0;
    179 
    180   //
    181   // The device's descriptors and its configuration
    182   //
    183   USB_DEVICE_DESC           *DevDesc;
    184   USB_CONFIG_DESC           *ActiveConfig;
    185 
    186   UINT16                    LangId [USB_MAX_LANG_ID];
    187   UINT16                    TotalLangId;
    188 
    189   UINT8                     NumOfInterface;
    190   USB_INTERFACE             *Interfaces [USB_MAX_INTERFACE];
    191 
    192   //
    193   // Parent child relationship
    194   //
    195   EFI_USB2_HC_TRANSACTION_TRANSLATOR Translator;
    196 
    197   UINT8                     ParentAddr;
    198   USB_INTERFACE             *ParentIf;
    199   UINT8                     ParentPort;       // Start at 0
    200   UINT8                     Tier;
    201   BOOLEAN                   DisconnectFail;
    202 };
    203 
    204 //
    205 // Stands for different functions of USB device
    206 //
    207 struct _USB_INTERFACE {
    208   UINTN                     Signature;
    209   USB_DEVICE                *Device;
    210   USB_INTERFACE_DESC        *IfDesc;
    211   USB_INTERFACE_SETTING     *IfSetting;
    212 
    213   //
    214   // Handles and protocols
    215   //
    216   EFI_HANDLE                Handle;
    217   EFI_USB_IO_PROTOCOL       UsbIo;
    218   EFI_DEVICE_PATH_PROTOCOL  *DevicePath;
    219   BOOLEAN                   IsManaged;
    220 
    221   //
    222   // Hub device special data
    223   //
    224   BOOLEAN                   IsHub;
    225   USB_HUB_API               *HubApi;
    226   UINT8                     NumOfPort;
    227   EFI_EVENT                 HubNotify;
    228 
    229   //
    230   // Data used only by normal hub devices
    231   //
    232   USB_ENDPOINT_DESC         *HubEp;
    233   UINT8                     *ChangeMap;
    234 
    235   //
    236   // Data used only by root hub to hand over device to
    237   // companion UHCI driver if low/full speed devices are
    238   // connected to EHCI.
    239   //
    240   UINT8                     MaxSpeed;
    241 };
    242 
    243 //
    244 // Stands for the current USB Bus
    245 //
    246 struct _USB_BUS {
    247   UINTN                     Signature;
    248   EFI_USB_BUS_PROTOCOL      BusId;
    249 
    250   //
    251   // Managed USB host controller
    252   //
    253   EFI_HANDLE                HostHandle;
    254   EFI_DEVICE_PATH_PROTOCOL  *DevicePath;
    255   EFI_USB2_HC_PROTOCOL      *Usb2Hc;
    256   EFI_USB_HC_PROTOCOL       *UsbHc;
    257 
    258   //
    259   // Recorded the max supported usb devices.
    260   // XHCI can support up to 255 devices.
    261   // EHCI/UHCI/OHCI supports up to 127 devices.
    262   //
    263   UINT32                    MaxDevices;
    264   //
    265   // An array of device that is on the bus. Devices[0] is
    266   // for root hub. Device with address i is at Devices[i].
    267   //
    268   USB_DEVICE                *Devices[256];
    269 
    270   //
    271   // USB Bus driver need to control the recursive connect policy of the bus, only those wanted
    272   // usb child device will be recursively connected.
    273   //
    274   // WantedUsbIoDPList tracks the Usb child devices which user want to recursivly fully connecte,
    275   // every wanted child device is stored in a item of the WantedUsbIoDPList, whose structrure is
    276   // DEVICE_PATH_LIST_ITEM
    277   //
    278   LIST_ENTRY                WantedUsbIoDPList;
    279 
    280 };
    281 
    282 //
    283 // USB Hub Api
    284 //
    285 struct _USB_HUB_API{
    286   USB_HUB_INIT                Init;
    287   USB_HUB_GET_PORT_STATUS     GetPortStatus;
    288   USB_HUB_CLEAR_PORT_CHANGE   ClearPortChange;
    289   USB_HUB_SET_PORT_FEATURE    SetPortFeature;
    290   USB_HUB_CLEAR_PORT_FEATURE  ClearPortFeature;
    291   USB_HUB_RESET_PORT          ResetPort;
    292   USB_HUB_RELEASE             Release;
    293 };
    294 
    295 #define USB_US_LAND_ID   0x0409
    296 
    297 #define DEVICE_PATH_LIST_ITEM_SIGNATURE     SIGNATURE_32('d','p','l','i')
    298 typedef struct _DEVICE_PATH_LIST_ITEM{
    299   UINTN                                 Signature;
    300   LIST_ENTRY                            Link;
    301   EFI_DEVICE_PATH_PROTOCOL              *DevicePath;
    302 } DEVICE_PATH_LIST_ITEM;
    303 
    304 typedef struct {
    305   USB_CLASS_DEVICE_PATH           UsbClass;
    306   EFI_DEVICE_PATH_PROTOCOL        End;
    307 } USB_CLASS_FORMAT_DEVICE_PATH;
    308 
    309 /**
    310   Free a DEVICE_PATH_LIST_ITEM list.
    311 
    312   @param  UsbIoDPList            a DEVICE_PATH_LIST_ITEM list pointer.
    313 
    314   @retval EFI_INVALID_PARAMETER  If parameters are invalid, return this value.
    315   @retval EFI_SUCCESS            If free operation is successful, return this value.
    316 
    317 **/
    318 EFI_STATUS
    319 EFIAPI
    320 UsbBusFreeUsbDPList (
    321   IN     LIST_ENTRY                                 *UsbIoDPList
    322   );
    323 
    324 /**
    325   Store a wanted usb child device info (its Usb part of device path) which is indicated by
    326   RemainingDevicePath in a Usb bus which  is indicated by UsbBusId.
    327 
    328   @param  UsbBusId               Point to EFI_USB_BUS_PROTOCOL interface.
    329   @param  RemainingDevicePath    The remaining device patch.
    330 
    331   @retval EFI_SUCCESS            Add operation is successful.
    332   @retval EFI_INVALID_PARAMETER  The parameters are invalid.
    333 
    334 **/
    335 EFI_STATUS
    336 EFIAPI
    337 UsbBusAddWantedUsbIoDP (
    338   IN EFI_USB_BUS_PROTOCOL         *UsbBusId,
    339   IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath
    340   );
    341 
    342 /**
    343   Check whether a usb child device is the wanted device in a bus.
    344 
    345   @param  Bus     The Usb bus's private data pointer.
    346   @param  UsbIf   The usb child device inferface.
    347 
    348   @retval True    If a usb child device is the wanted device in a bus.
    349   @retval False   If a usb child device is *NOT* the wanted device in a bus.
    350 
    351 **/
    352 BOOLEAN
    353 EFIAPI
    354 UsbBusIsWantedUsbIO (
    355   IN USB_BUS                 *Bus,
    356   IN USB_INTERFACE           *UsbIf
    357   );
    358 
    359 /**
    360   Recursively connnect every wanted usb child device to ensure they all fully connected.
    361   Check all the child Usb IO handles in this bus, recursively connecte if it is wanted usb child device.
    362 
    363   @param  UsbBusId                  Point to EFI_USB_BUS_PROTOCOL interface.
    364 
    365   @retval EFI_SUCCESS               Connect is done successfully.
    366   @retval EFI_INVALID_PARAMETER     The parameter is invalid.
    367 
    368 **/
    369 EFI_STATUS
    370 EFIAPI
    371 UsbBusRecursivelyConnectWantedUsbIo (
    372   IN EFI_USB_BUS_PROTOCOL         *UsbBusId
    373   );
    374 
    375 /**
    376   USB_IO function to execute a control transfer. This
    377   function will execute the USB transfer. If transfer
    378   successes, it will sync the internal state of USB bus
    379   with device state.
    380 
    381   @param  This                   The USB_IO instance
    382   @param  Request                The control transfer request
    383   @param  Direction              Direction for data stage
    384   @param  Timeout                The time to wait before timeout
    385   @param  Data                   The buffer holding the data
    386   @param  DataLength             Then length of the data
    387   @param  UsbStatus              USB result
    388 
    389   @retval EFI_INVALID_PARAMETER  The parameters are invalid
    390   @retval EFI_SUCCESS            The control transfer succeded.
    391   @retval Others                 Failed to execute the transfer
    392 
    393 **/
    394 EFI_STATUS
    395 EFIAPI
    396 UsbIoControlTransfer (
    397   IN  EFI_USB_IO_PROTOCOL     *This,
    398   IN  EFI_USB_DEVICE_REQUEST  *Request,
    399   IN  EFI_USB_DATA_DIRECTION  Direction,
    400   IN  UINT32                  Timeout,
    401   IN  OUT VOID                *Data,      OPTIONAL
    402   IN  UINTN                   DataLength, OPTIONAL
    403   OUT UINT32                  *UsbStatus
    404   );
    405 
    406 /**
    407   Execute a bulk transfer to the device endpoint.
    408 
    409   @param  This                   The USB IO instance.
    410   @param  Endpoint               The device endpoint.
    411   @param  Data                   The data to transfer.
    412   @param  DataLength             The length of the data to transfer.
    413   @param  Timeout                Time to wait before timeout.
    414   @param  UsbStatus              The result of USB transfer.
    415 
    416   @retval EFI_SUCCESS            The bulk transfer is OK.
    417   @retval EFI_INVALID_PARAMETER  Some parameters are invalid.
    418   @retval Others                 Failed to execute transfer, reason returned in
    419                                  UsbStatus.
    420 
    421 **/
    422 EFI_STATUS
    423 EFIAPI
    424 UsbIoBulkTransfer (
    425   IN  EFI_USB_IO_PROTOCOL *This,
    426   IN  UINT8               Endpoint,
    427   IN  OUT VOID            *Data,
    428   IN  OUT UINTN           *DataLength,
    429   IN  UINTN               Timeout,
    430   OUT UINT32              *UsbStatus
    431   );
    432 
    433 /**
    434   Execute a synchronous interrupt transfer.
    435 
    436   @param  This                   The USB IO instance.
    437   @param  Endpoint               The device endpoint.
    438   @param  Data                   The data to transfer.
    439   @param  DataLength             The length of the data to transfer.
    440   @param  Timeout                Time to wait before timeout.
    441   @param  UsbStatus              The result of USB transfer.
    442 
    443   @retval EFI_SUCCESS            The synchronous interrupt transfer is OK.
    444   @retval EFI_INVALID_PARAMETER  Some parameters are invalid.
    445   @retval Others                 Failed to execute transfer, reason returned in
    446                                  UsbStatus.
    447 
    448 **/
    449 EFI_STATUS
    450 EFIAPI
    451 UsbIoSyncInterruptTransfer (
    452   IN  EFI_USB_IO_PROTOCOL *This,
    453   IN  UINT8               Endpoint,
    454   IN  OUT VOID            *Data,
    455   IN  OUT UINTN           *DataLength,
    456   IN  UINTN               Timeout,
    457   OUT UINT32              *UsbStatus
    458   );
    459 
    460 /**
    461   Queue a new asynchronous interrupt transfer, or remove the old
    462   request if (IsNewTransfer == FALSE).
    463 
    464   @param  This                   The USB_IO instance.
    465   @param  Endpoint               The device endpoint.
    466   @param  IsNewTransfer          Whether this is a new request, if it's old, remove
    467                                  the request.
    468   @param  PollInterval           The interval to poll the transfer result, (in ms).
    469   @param  DataLength             The length of perodic data transfer.
    470   @param  Callback               The function to call periodicaly when transfer is
    471                                  ready.
    472   @param  Context                The context to the callback.
    473 
    474   @retval EFI_SUCCESS            New transfer is queued or old request is removed.
    475   @retval EFI_INVALID_PARAMETER  Some parameters are invalid.
    476   @retval Others                 Failed to queue the new request or remove the old
    477                                  request.
    478 
    479 **/
    480 EFI_STATUS
    481 EFIAPI
    482 UsbIoAsyncInterruptTransfer (
    483   IN EFI_USB_IO_PROTOCOL              *This,
    484   IN UINT8                            Endpoint,
    485   IN BOOLEAN                          IsNewTransfer,
    486   IN UINTN                            PollInterval,       OPTIONAL
    487   IN UINTN                            DataLength,         OPTIONAL
    488   IN EFI_ASYNC_USB_TRANSFER_CALLBACK  Callback,           OPTIONAL
    489   IN VOID                             *Context            OPTIONAL
    490   );
    491 
    492 /**
    493   Execute a synchronous isochronous transfer.
    494 
    495   @param  This                   The USB IO instance.
    496   @param  DeviceEndpoint         The device endpoint.
    497   @param  Data                   The data to transfer.
    498   @param  DataLength             The length of the data to transfer.
    499   @param  UsbStatus              The result of USB transfer.
    500 
    501   @retval EFI_UNSUPPORTED        Currently isochronous transfer isn't supported.
    502 
    503 **/
    504 EFI_STATUS
    505 EFIAPI
    506 UsbIoIsochronousTransfer (
    507   IN  EFI_USB_IO_PROTOCOL *This,
    508   IN  UINT8               DeviceEndpoint,
    509   IN  OUT VOID            *Data,
    510   IN  UINTN               DataLength,
    511   OUT UINT32              *Status
    512   );
    513 
    514 /**
    515   Queue an asynchronous isochronous transfer.
    516 
    517   @param  This                   The USB_IO instance.
    518   @param  DeviceEndpoint         The device endpoint.
    519   @param  Data                   The data to transfer.
    520   @param  DataLength             The length of perodic data transfer.
    521   @param  IsochronousCallBack    The function to call periodicaly when transfer is
    522                                  ready.
    523   @param  Context                The context to the callback.
    524 
    525   @retval EFI_UNSUPPORTED        Currently isochronous transfer isn't supported.
    526 
    527 **/
    528 EFI_STATUS
    529 EFIAPI
    530 UsbIoAsyncIsochronousTransfer (
    531   IN EFI_USB_IO_PROTOCOL              *This,
    532   IN UINT8                            DeviceEndpoint,
    533   IN OUT VOID                         *Data,
    534   IN UINTN                            DataLength,
    535   IN EFI_ASYNC_USB_TRANSFER_CALLBACK  IsochronousCallBack,
    536   IN VOID                             *Context              OPTIONAL
    537   );
    538 
    539 /**
    540   Retrieve the device descriptor of the device.
    541 
    542   @param  This                   The USB IO instance.
    543   @param  Descriptor             The variable to receive the device descriptor.
    544 
    545   @retval EFI_SUCCESS            The device descriptor is returned.
    546   @retval EFI_INVALID_PARAMETER  The parameter is invalid.
    547 
    548 **/
    549 EFI_STATUS
    550 EFIAPI
    551 UsbIoGetDeviceDescriptor (
    552   IN  EFI_USB_IO_PROTOCOL       *This,
    553   OUT EFI_USB_DEVICE_DESCRIPTOR *Descriptor
    554   );
    555 
    556 /**
    557   Return the configuration descriptor of the current active configuration.
    558 
    559   @param  This                   The USB IO instance.
    560   @param  Descriptor             The USB configuration descriptor.
    561 
    562   @retval EFI_SUCCESS            The active configuration descriptor is returned.
    563   @retval EFI_INVALID_PARAMETER  Some parameter is invalid.
    564   @retval EFI_NOT_FOUND          Currently no active configuration is selected.
    565 
    566 **/
    567 EFI_STATUS
    568 EFIAPI
    569 UsbIoGetActiveConfigDescriptor (
    570   IN  EFI_USB_IO_PROTOCOL       *This,
    571   OUT EFI_USB_CONFIG_DESCRIPTOR *Descriptor
    572   );
    573 
    574 /**
    575   Retrieve the active interface setting descriptor for this USB IO instance.
    576 
    577   @param  This                   The USB IO instance.
    578   @param  Descriptor             The variable to receive active interface setting.
    579 
    580   @retval EFI_SUCCESS            The active interface setting is returned.
    581   @retval EFI_INVALID_PARAMETER  Some parameter is invalid.
    582 
    583 **/
    584 EFI_STATUS
    585 EFIAPI
    586 UsbIoGetInterfaceDescriptor (
    587   IN  EFI_USB_IO_PROTOCOL           *This,
    588   OUT EFI_USB_INTERFACE_DESCRIPTOR  *Descriptor
    589   );
    590 
    591 /**
    592   Retrieve the endpoint descriptor from this interface setting.
    593 
    594   @param  This                   The USB IO instance.
    595   @param  Index                  The index (start from zero) of the endpoint to
    596                                  retrieve.
    597   @param  Descriptor             The variable to receive the descriptor.
    598 
    599   @retval EFI_SUCCESS            The endpoint descriptor is returned.
    600   @retval EFI_INVALID_PARAMETER  Some parameter is invalid.
    601 
    602 **/
    603 EFI_STATUS
    604 EFIAPI
    605 UsbIoGetEndpointDescriptor (
    606   IN  EFI_USB_IO_PROTOCOL         *This,
    607   IN  UINT8                       Index,
    608   OUT EFI_USB_ENDPOINT_DESCRIPTOR *Descriptor
    609   );
    610 
    611 /**
    612   Retrieve the supported language ID table from the device.
    613 
    614   @param  This                   The USB IO instance.
    615   @param  LangIDTable            The table to return the language IDs.
    616   @param  TableSize              The size, in bytes, of the table LangIDTable.
    617 
    618   @retval EFI_SUCCESS            The language ID is return.
    619 
    620 **/
    621 EFI_STATUS
    622 EFIAPI
    623 UsbIoGetSupportedLanguages (
    624   IN  EFI_USB_IO_PROTOCOL *This,
    625   OUT UINT16              **LangIDTable,
    626   OUT UINT16              *TableSize
    627   );
    628 
    629 /**
    630   Retrieve an indexed string in the language of LangID.
    631 
    632   @param  This                   The USB IO instance.
    633   @param  LangID                 The language ID of the string to retrieve.
    634   @param  StringIndex            The index of the string.
    635   @param  String                 The variable to receive the string.
    636 
    637   @retval EFI_SUCCESS            The string is returned.
    638   @retval EFI_NOT_FOUND          No such string existed.
    639 
    640 **/
    641 EFI_STATUS
    642 EFIAPI
    643 UsbIoGetStringDescriptor (
    644   IN  EFI_USB_IO_PROTOCOL   *This,
    645   IN  UINT16                LangID,
    646   IN  UINT8                 StringIndex,
    647   OUT CHAR16                **String
    648   );
    649 
    650 /**
    651   Reset the device, then if that succeeds, reconfigure the
    652   device with its address and current active configuration.
    653 
    654   @param  This                   The USB IO instance.
    655 
    656   @retval EFI_SUCCESS            The device is reset and configured.
    657   @retval Others                 Failed to reset the device.
    658 
    659 **/
    660 EFI_STATUS
    661 EFIAPI
    662 UsbIoPortReset (
    663   IN EFI_USB_IO_PROTOCOL  *This
    664   );
    665 
    666 /**
    667   Install Usb Bus Protocol on host controller, and start the Usb bus.
    668 
    669   @param This                    The USB bus driver binding instance.
    670   @param Controller              The controller to check.
    671   @param RemainingDevicePath     The remaining device patch.
    672 
    673   @retval EFI_SUCCESS            The controller is controlled by the usb bus.
    674   @retval EFI_ALREADY_STARTED    The controller is already controlled by the usb bus.
    675   @retval EFI_OUT_OF_RESOURCES   Failed to allocate resources.
    676 
    677 **/
    678 EFI_STATUS
    679 EFIAPI
    680 UsbBusBuildProtocol (
    681   IN EFI_DRIVER_BINDING_PROTOCOL  *This,
    682   IN EFI_HANDLE                   Controller,
    683   IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath
    684   );
    685 
    686 /**
    687   The USB bus driver entry pointer.
    688 
    689   @param ImageHandle       The driver image handle.
    690   @param SystemTable       The system table.
    691 
    692   @return EFI_SUCCESS      The component name protocol is installed.
    693   @return Others           Failed to init the usb driver.
    694 
    695 **/
    696 EFI_STATUS
    697 EFIAPI
    698 UsbBusDriverEntryPoint (
    699   IN EFI_HANDLE           ImageHandle,
    700   IN EFI_SYSTEM_TABLE     *SystemTable
    701   );
    702 
    703 /**
    704   Check whether USB bus driver support this device.
    705 
    706   @param  This                   The USB bus driver binding protocol.
    707   @param  Controller             The controller handle to check.
    708   @param  RemainingDevicePath    The remaining device path.
    709 
    710   @retval EFI_SUCCESS            The bus supports this controller.
    711   @retval EFI_UNSUPPORTED        This device isn't supported.
    712 
    713 **/
    714 EFI_STATUS
    715 EFIAPI
    716 UsbBusControllerDriverSupported (
    717   IN EFI_DRIVER_BINDING_PROTOCOL  *This,
    718   IN EFI_HANDLE                   Controller,
    719   IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath
    720   );
    721 
    722 /**
    723   Start to process the controller.
    724 
    725   @param  This                   The USB bus driver binding instance.
    726   @param  Controller             The controller to check.
    727   @param  RemainingDevicePath    The remaining device patch.
    728 
    729   @retval EFI_SUCCESS            The controller is controlled by the usb bus.
    730   @retval EFI_ALREADY_STARTED    The controller is already controlled by the usb
    731                                  bus.
    732   @retval EFI_OUT_OF_RESOURCES   Failed to allocate resources.
    733 
    734 **/
    735 EFI_STATUS
    736 EFIAPI
    737 UsbBusControllerDriverStart (
    738   IN EFI_DRIVER_BINDING_PROTOCOL  *This,
    739   IN EFI_HANDLE                   Controller,
    740   IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath
    741   );
    742 
    743 /**
    744   Stop handle the controller by this USB bus driver.
    745 
    746   @param  This                   The USB bus driver binding protocol.
    747   @param  Controller             The controller to release.
    748   @param  NumberOfChildren       The child of USB bus that opened controller
    749                                  BY_CHILD.
    750   @param  ChildHandleBuffer      The array of child handle.
    751 
    752   @retval EFI_SUCCESS            The controller or children are stopped.
    753   @retval EFI_DEVICE_ERROR       Failed to stop the driver.
    754 
    755 **/
    756 EFI_STATUS
    757 EFIAPI
    758 UsbBusControllerDriverStop (
    759   IN EFI_DRIVER_BINDING_PROTOCOL  *This,
    760   IN EFI_HANDLE                   Controller,
    761   IN UINTN                        NumberOfChildren,
    762   IN EFI_HANDLE                   *ChildHandleBuffer
    763   );
    764 
    765 extern EFI_USB_IO_PROTOCOL            mUsbIoProtocol;
    766 extern EFI_DRIVER_BINDING_PROTOCOL    mUsbBusDriverBinding;
    767 extern EFI_COMPONENT_NAME_PROTOCOL    mUsbBusComponentName;
    768 extern EFI_COMPONENT_NAME2_PROTOCOL   mUsbBusComponentName2;
    769 
    770 #endif
    771