1 /** @file
2   EFI_USB2_HC_PROTOCOL as defined in UEFI 2.0.
3   The USB Host Controller Protocol is used by code, typically USB bus drivers,
4   running in the EFI boot services environment, to perform data transactions over
5   a USB bus. In addition, it provides an abstraction for the root hub of the USB bus.
6 
7   Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
8   SPDX-License-Identifier: BSD-2-Clause-Patent
9 
10 **/
11 
12 #ifndef _USB2_HOSTCONTROLLER_H_
13 #define _USB2_HOSTCONTROLLER_H_
14 
15 #include <Protocol/UsbIo.h>
16 
17 #define EFI_USB2_HC_PROTOCOL_GUID \
18   { \
19     0x3e745226, 0x9818, 0x45b6, {0xa2, 0xac, 0xd7, 0xcd, 0xe, 0x8b, 0xa2, 0xbc } \
20   }
21 
22 ///
23 /// Forward reference for pure ANSI compatability
24 ///
25 typedef struct _EFI_USB2_HC_PROTOCOL EFI_USB2_HC_PROTOCOL;
26 
27 
28 typedef struct {
29   UINT16          PortStatus;        ///< Contains current port status bitmap.
30   UINT16          PortChangeStatus;  ///< Contains current port status change bitmap.
31 } EFI_USB_PORT_STATUS;
32 
33 ///
34 /// EFI_USB_PORT_STATUS.PortStatus bit definition
35 ///
36 #define USB_PORT_STAT_CONNECTION    0x0001
37 #define USB_PORT_STAT_ENABLE        0x0002
38 #define USB_PORT_STAT_SUSPEND       0x0004
39 #define USB_PORT_STAT_OVERCURRENT   0x0008
40 #define USB_PORT_STAT_RESET         0x0010
41 #define USB_PORT_STAT_POWER         0x0100
42 #define USB_PORT_STAT_LOW_SPEED     0x0200
43 #define USB_PORT_STAT_HIGH_SPEED    0x0400
44 #define USB_PORT_STAT_SUPER_SPEED   0x0800
45 #define USB_PORT_STAT_OWNER         0x2000
46 
47 ///
48 /// EFI_USB_PORT_STATUS.PortChangeStatus bit definition
49 ///
50 #define USB_PORT_STAT_C_CONNECTION  0x0001
51 #define USB_PORT_STAT_C_ENABLE      0x0002
52 #define USB_PORT_STAT_C_SUSPEND     0x0004
53 #define USB_PORT_STAT_C_OVERCURRENT 0x0008
54 #define USB_PORT_STAT_C_RESET       0x0010
55 
56 
57 ///
58 /// Usb port features value
59 /// Each value indicates its bit index in the port status and status change bitmaps,
60 /// if combines these two bitmaps into a 32-bit bitmap.
61 ///
62 typedef enum {
63   EfiUsbPortEnable            = 1,
64   EfiUsbPortSuspend           = 2,
65   EfiUsbPortReset             = 4,
66   EfiUsbPortPower             = 8,
67   EfiUsbPortOwner             = 13,
68   EfiUsbPortConnectChange     = 16,
69   EfiUsbPortEnableChange      = 17,
70   EfiUsbPortSuspendChange     = 18,
71   EfiUsbPortOverCurrentChange = 19,
72   EfiUsbPortResetChange       = 20
73 } EFI_USB_PORT_FEATURE;
74 
75 #define EFI_USB_SPEED_FULL      0x0000  ///< 12 Mb/s, USB 1.1 OHCI and UHCI HC.
76 #define EFI_USB_SPEED_LOW       0x0001  ///< 1 Mb/s, USB 1.1 OHCI and UHCI HC.
77 #define EFI_USB_SPEED_HIGH      0x0002  ///< 480 Mb/s, USB 2.0 EHCI HC.
78 #define EFI_USB_SPEED_SUPER     0x0003  ///< 4.8 Gb/s, USB 3.0 XHCI HC.
79 
80 typedef struct {
81   UINT8      TranslatorHubAddress; ///< device address
82   UINT8      TranslatorPortNumber; ///< the port number of the hub that device is connected to.
83 } EFI_USB2_HC_TRANSACTION_TRANSLATOR;
84 
85 //
86 // Protocol definitions
87 //
88 
89 /**
90   Retrieves the Host Controller capabilities.
91 
92   @param  This           A pointer to the EFI_USB2_HC_PROTOCOL instance.
93   @param  MaxSpeed       Host controller data transfer speed.
94   @param  PortNumber     Number of the root hub ports.
95   @param  Is64BitCapable TRUE if controller supports 64-bit memory addressing,
96                          FALSE otherwise.
97 
98   @retval EFI_SUCCESS           The host controller capabilities were retrieved successfully.
99   @retval EFI_INVALID_PARAMETER One of the input args was NULL.
100   @retval EFI_DEVICE_ERROR      An error was encountered while attempting to
101                                 retrieve the capabilities.
102 
103 **/
104 typedef
105 EFI_STATUS
106 (EFIAPI *EFI_USB2_HC_PROTOCOL_GET_CAPABILITY)(
107   IN  EFI_USB2_HC_PROTOCOL  *This,
108   OUT UINT8                 *MaxSpeed,
109   OUT UINT8                 *PortNumber,
110   OUT UINT8                 *Is64BitCapable
111   );
112 
113 #define EFI_USB_HC_RESET_GLOBAL             0x0001
114 #define EFI_USB_HC_RESET_HOST_CONTROLLER    0x0002
115 #define EFI_USB_HC_RESET_GLOBAL_WITH_DEBUG  0x0004
116 #define EFI_USB_HC_RESET_HOST_WITH_DEBUG    0x0008
117 /**
118   Provides software reset for the USB host controller.
119 
120   @param  This       A pointer to the EFI_USB2_HC_PROTOCOL instance.
121   @param  Attributes A bit mask of the reset operation to perform.
122 
123   @retval EFI_SUCCESS           The reset operation succeeded.
124   @retval EFI_INVALID_PARAMETER Attributes is not valid.
125   @retval EFI_UNSUPPORTED       The type of reset specified by Attributes is not currently
126                                 supported by the host controller hardware.
127   @retval EFI_ACCESS_DENIED     Reset operation is rejected due to the debug port being configured
128                                 and active; only EFI_USB_HC_RESET_GLOBAL_WITH_DEBUG or
129                                 EFI_USB_HC_RESET_HOST_WITH_DEBUG reset Attributes can be used to
130                                 perform reset operation for this host controller.
131   @retval EFI_DEVICE_ERROR      An error was encountered while attempting to
132                                 retrieve the capabilities.
133 
134 **/
135 typedef
136 EFI_STATUS
137 (EFIAPI *EFI_USB2_HC_PROTOCOL_RESET)(
138   IN EFI_USB2_HC_PROTOCOL   *This,
139   IN UINT16                 Attributes
140   );
141 
142 /**
143   Enumration value for status of USB HC.
144 **/
145 typedef enum {
146   EfiUsbHcStateHalt,                ///< The host controller is in halt
147                                     ///< state. No USB transactions can occur
148                                     ///< while in this state. The host
149                                     ///< controller can enter this state for
150                                     ///< three reasons: 1) After host
151                                     ///< controller hardware reset. 2)
152                                     ///< Explicitly set by software. 3)
153                                     ///< Triggered by a fatal error such as
154                                     ///< consistency check failure.
155 
156   EfiUsbHcStateOperational,         ///< The host controller is in an
157                                     ///< operational state. When in
158                                     ///< this state, the host
159                                     ///< controller can execute bus
160                                     ///< traffic. This state must be
161                                     ///< explicitly set to enable the
162                                     ///< USB bus traffic.
163 
164   EfiUsbHcStateSuspend,             ///< The host controller is in the
165                                     ///< suspend state. No USB
166                                     ///< transactions can occur while in
167                                     ///< this state. The host controller
168                                     ///< enters this state for the
169                                     ///< following reasons: 1) Explicitly
170                                     ///< set by software. 2) Triggered
171                                     ///< when there is no bus traffic for
172                                     ///< 3 microseconds.
173 
174   EfiUsbHcStateMaximum              ///< Maximum value for enumration value of HC status.
175 } EFI_USB_HC_STATE;
176 
177 /**
178   Retrieves current state of the USB host controller.
179 
180   @param  This  A pointer to the EFI_USB2_HC_PROTOCOL instance.
181   @param  State A pointer to the EFI_USB_HC_STATE data structure that
182                 indicates current state of the USB host controller.
183 
184   @retval EFI_SUCCESS           The state information of the host controller was returned in State.
185   @retval EFI_INVALID_PARAMETER State is NULL.
186   @retval EFI_DEVICE_ERROR      An error was encountered while attempting to retrieve the
187                                 host controller's current state.
188 
189 **/
190 typedef
191 EFI_STATUS
192 (EFIAPI *EFI_USB2_HC_PROTOCOL_GET_STATE)(
193   IN        EFI_USB2_HC_PROTOCOL    *This,
194   OUT       EFI_USB_HC_STATE        *State
195 );
196 
197 /**
198   Sets the USB host controller to a specific state.
199 
200   @param  This  A pointer to the EFI_USB2_HC_PROTOCOL instance.
201   @param  State Indicates the state of the host controller that will be set.
202 
203   @retval EFI_SUCCESS           The USB host controller was successfully placed in the state
204                                 specified by State.
205   @retval EFI_INVALID_PARAMETER State is not valid.
206   @retval EFI_DEVICE_ERROR      Failed to set the state specified by State due to device error.
207 
208 **/
209 typedef
210 EFI_STATUS
211 (EFIAPI *EFI_USB2_HC_PROTOCOL_SET_STATE)(
212   IN EFI_USB2_HC_PROTOCOL    *This,
213   IN EFI_USB_HC_STATE        State
214   );
215 
216 /**
217   Submits control transfer to a target USB device.
218 
219   @param  This                A pointer to the EFI_USB2_HC_PROTOCOL instance.
220   @param  DeviceAddress       Represents the address of the target device on the USB.
221   @param  DeviceSpeed         Indicates device speed.
222   @param  MaximumPacketLength Indicates the maximum packet size that the default control transfer
223                               endpoint is capable of sending or receiving.
224   @param  Request             A pointer to the USB device request that will be sent to the USB device.
225   @param  TransferDirection   Specifies the data direction for the transfer. There are three values
226                               available, EfiUsbDataIn, EfiUsbDataOut and EfiUsbNoData.
227   @param  Data                A pointer to the buffer of data that will be transmitted to USB device or
228                               received from USB device.
229   @param  DataLength          On input, indicates the size, in bytes, of the data buffer specified by Data.
230                               On output, indicates the amount of data actually transferred.
231   @param  TimeOut             Indicates the maximum time, in milliseconds, which the transfer is
232                               allowed to complete.
233   @param  Translator          A pointer to the transaction translator data.
234   @param  TransferResult      A pointer to the detailed result information generated by this control
235                               transfer.
236 
237   @retval EFI_SUCCESS           The control transfer was completed successfully.
238   @retval EFI_INVALID_PARAMETER Some parameters are invalid.
239   @retval EFI_OUT_OF_RESOURCES  The control transfer could not be completed due to a lack of resources.
240   @retval EFI_TIMEOUT           The control transfer failed due to timeout.
241   @retval EFI_DEVICE_ERROR      The control transfer failed due to host controller or device error.
242                                 Caller should check TransferResult for detailed error information.
243 
244 **/
245 typedef
246 EFI_STATUS
247 (EFIAPI *EFI_USB2_HC_PROTOCOL_CONTROL_TRANSFER)(
248   IN     EFI_USB2_HC_PROTOCOL               *This,
249   IN     UINT8                              DeviceAddress,
250   IN     UINT8                              DeviceSpeed,
251   IN     UINTN                              MaximumPacketLength,
252   IN     EFI_USB_DEVICE_REQUEST             *Request,
253   IN     EFI_USB_DATA_DIRECTION             TransferDirection,
254   IN OUT VOID                               *Data       OPTIONAL,
255   IN OUT UINTN                              *DataLength OPTIONAL,
256   IN     UINTN                              TimeOut,
257   IN     EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,
258   OUT    UINT32                             *TransferResult
259   );
260 
261 #define EFI_USB_MAX_BULK_BUFFER_NUM 10
262 
263 /**
264   Submits bulk transfer to a bulk endpoint of a USB device.
265 
266   @param  This                A pointer to the EFI_USB2_HC_PROTOCOL instance.
267   @param  DeviceAddress       Represents the address of the target device on the USB.
268   @param  EndPointAddress     The combination of an endpoint number and an endpoint direction of the
269                               target USB device.
270   @param  DeviceSpeed         Indicates device speed.
271   @param  MaximumPacketLength Indicates the maximum packet size the target endpoint is capable of
272                               sending or receiving.
273   @param  DataBuffersNumber   Number of data buffers prepared for the transfer.
274   @param  Data                Array of pointers to the buffers of data that will be transmitted to USB
275                               device or received from USB device.
276   @param  DataLength          When input, indicates the size, in bytes, of the data buffers specified by
277                               Data. When output, indicates the actually transferred data size.
278   @param  DataToggle          A pointer to the data toggle value.
279   @param  TimeOut             Indicates the maximum time, in milliseconds, which the transfer is
280                               allowed to complete.
281   @param  Translator          A pointer to the transaction translator data.
282   @param  TransferResult      A pointer to the detailed result information of the bulk transfer.
283 
284   @retval EFI_SUCCESS           The bulk transfer was completed successfully.
285   @retval EFI_INVALID_PARAMETER Some parameters are invalid.
286   @retval EFI_OUT_OF_RESOURCES  The bulk transfer could not be submitted due to a lack of resources.
287   @retval EFI_TIMEOUT           The bulk transfer failed due to timeout.
288   @retval EFI_DEVICE_ERROR      The bulk transfer failed due to host controller or device error.
289                                 Caller should check TransferResult for detailed error information.
290 
291 **/
292 typedef
293 EFI_STATUS
294 (EFIAPI *EFI_USB2_HC_PROTOCOL_BULK_TRANSFER)(
295   IN     EFI_USB2_HC_PROTOCOL               *This,
296   IN     UINT8                              DeviceAddress,
297   IN     UINT8                              EndPointAddress,
298   IN     UINT8                              DeviceSpeed,
299   IN     UINTN                              MaximumPacketLength,
300   IN     UINT8                              DataBuffersNumber,
301   IN OUT VOID                               *Data[EFI_USB_MAX_BULK_BUFFER_NUM],
302   IN OUT UINTN                              *DataLength,
303   IN OUT UINT8                              *DataToggle,
304   IN     UINTN                              TimeOut,
305   IN     EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,
306   OUT    UINT32                             *TransferResult
307   );
308 
309 /**
310   Submits an asynchronous interrupt transfer to an interrupt endpoint of a USB device.
311   Translator parameter doesn't exist in UEFI2.0 spec, but it will be updated in the following specification version.
312 
313   @param  This                A pointer to the EFI_USB2_HC_PROTOCOL instance.
314   @param  DeviceAddress       Represents the address of the target device on the USB.
315   @param  EndPointAddress     The combination of an endpoint number and an endpoint direction of the
316                               target USB device.
317   @param  DeviceSpeed         Indicates device speed.
318   @param  MaximumPacketLength Indicates the maximum packet size the target endpoint is capable of
319                               sending or receiving.
320   @param  IsNewTransfer       If TRUE, an asynchronous interrupt pipe is built between the host and the
321                               target interrupt endpoint. If FALSE, the specified asynchronous interrupt
322                               pipe is canceled. If TRUE, and an interrupt transfer exists for the target
323                               end point, then EFI_INVALID_PARAMETER is returned.
324   @param  DataToggle          A pointer to the data toggle value.
325   @param  PollingInterval     Indicates the interval, in milliseconds, that the asynchronous interrupt
326                               transfer is polled.
327   @param  DataLength          Indicates the length of data to be received at the rate specified by
328                               PollingInterval from the target asynchronous interrupt endpoint.
329   @param  Translator          A pointr to the transaction translator data.
330   @param  CallBackFunction    The Callback function. This function is called at the rate specified by
331                               PollingInterval.
332   @param  Context             The context that is passed to the CallBackFunction. This is an
333                               optional parameter and may be NULL.
334 
335   @retval EFI_SUCCESS           The asynchronous interrupt transfer request has been successfully
336                                 submitted or canceled.
337   @retval EFI_INVALID_PARAMETER Some parameters are invalid.
338   @retval EFI_OUT_OF_RESOURCES  The request could not be completed due to a lack of resources.
339 
340 **/
341 typedef
342 EFI_STATUS
343 (EFIAPI *EFI_USB2_HC_PROTOCOL_ASYNC_INTERRUPT_TRANSFER)(
344   IN     EFI_USB2_HC_PROTOCOL                                *This,
345   IN     UINT8                                               DeviceAddress,
346   IN     UINT8                                               EndPointAddress,
347   IN     UINT8                                               DeviceSpeed,
348   IN     UINTN                                               MaxiumPacketLength,
349   IN     BOOLEAN                                             IsNewTransfer,
350   IN OUT UINT8                                               *DataToggle,
351   IN     UINTN                                               PollingInterval  OPTIONAL,
352   IN     UINTN                                               DataLength       OPTIONAL,
353   IN     EFI_USB2_HC_TRANSACTION_TRANSLATOR                  *Translator      OPTIONAL,
354   IN     EFI_ASYNC_USB_TRANSFER_CALLBACK                     CallBackFunction OPTIONAL,
355   IN     VOID                                                *Context         OPTIONAL
356   );
357 
358 /**
359   Submits synchronous interrupt transfer to an interrupt endpoint of a USB device.
360   Translator parameter doesn't exist in UEFI2.0 spec, but it will be updated in the following specification version.
361 
362   @param  This                  A pointer to the EFI_USB2_HC_PROTOCOL instance.
363   @param  DeviceAddress         Represents the address of the target device on the USB.
364   @param  EndPointAddress       The combination of an endpoint number and an endpoint direction of the
365                                 target USB device.
366   @param  DeviceSpeed           Indicates device speed.
367   @param  MaximumPacketLength   Indicates the maximum packet size the target endpoint is capable of
368                                 sending or receiving.
369   @param  Data                  A pointer to the buffer of data that will be transmitted to USB device or
370                                 received from USB device.
371   @param  DataLength            On input, the size, in bytes, of the data buffer specified by Data. On
372                                 output, the number of bytes transferred.
373   @param  DataToggle            A pointer to the data toggle value.
374   @param  TimeOut               Indicates the maximum time, in milliseconds, which the transfer is
375                                 allowed to complete.
376   @param  Translator            A pointr to the transaction translator data.
377   @param  TransferResult        A pointer to the detailed result information from the synchronous
378                                 interrupt transfer.
379 
380   @retval EFI_SUCCESS           The synchronous interrupt transfer was completed successfully.
381   @retval EFI_INVALID_PARAMETER Some parameters are invalid.
382   @retval EFI_OUT_OF_RESOURCES  The synchronous interrupt transfer could not be submitted due to a lack of resources.
383   @retval EFI_TIMEOUT           The synchronous interrupt transfer failed due to timeout.
384   @retval EFI_DEVICE_ERROR      The synchronous interrupt transfer failed due to host controller or device error.
385                                 Caller should check TransferResult for detailed error information.
386 
387 **/
388 typedef
389 EFI_STATUS
390 (EFIAPI *EFI_USB2_HC_PROTOCOL_SYNC_INTERRUPT_TRANSFER)(
391   IN     EFI_USB2_HC_PROTOCOL                        *This,
392   IN     UINT8                                       DeviceAddress,
393   IN     UINT8                                       EndPointAddress,
394   IN     UINT8                                       DeviceSpeed,
395   IN     UINTN                                       MaximumPacketLength,
396   IN OUT VOID                                        *Data,
397   IN OUT UINTN                                       *DataLength,
398   IN OUT UINT8                                       *DataToggle,
399   IN     UINTN                                       TimeOut,
400   IN     EFI_USB2_HC_TRANSACTION_TRANSLATOR          *Translator,
401   OUT    UINT32                                      *TransferResult
402   );
403 
404 #define EFI_USB_MAX_ISO_BUFFER_NUM  7
405 #define EFI_USB_MAX_ISO_BUFFER_NUM1 2
406 
407 /**
408   Submits isochronous transfer to an isochronous endpoint of a USB device.
409 
410   This function is used to submit isochronous transfer to a target endpoint of a USB device.
411   The target endpoint is specified by DeviceAddressand EndpointAddress. Isochronous transfers are
412   used when working with isochronous date. It provides periodic, continuous communication between
413   the host and a device. Isochronous transfers can beused only by full-speed, high-speed, and
414   super-speed devices.
415 
416   High-speed isochronous transfers can be performed using multiple data buffers. The number of
417   buffers that are actually prepared for the transfer is specified by DataBuffersNumber. For
418   full-speed isochronous transfers this value is ignored.
419 
420   Data represents a list of pointers to the data buffers. For full-speed isochronous transfers
421   only the data pointed by Data[0]shall be used. For high-speed isochronous transfers and for
422   the split transactions depending on DataLengththere several data buffers canbe used. For the
423   high-speed isochronous transfers the total number of buffers must not exceed EFI_USB_MAX_ISO_BUFFER_NUM.
424 
425   For split transactions performed on full-speed device by high-speed host controller the total
426   number of buffers is limited to EFI_USB_MAX_ISO_BUFFER_NUM1.
427   If the isochronous transfer is successful, then EFI_SUCCESSis returned. The isochronous transfer
428   is designed to be completed within one USB frame time, if it cannot be completed, EFI_TIMEOUT
429   is returned. If an error other than timeout occurs during the USB transfer, then EFI_DEVICE_ERROR
430   is returned and the detailed status code will be returned in TransferResult.
431 
432   EFI_INVALID_PARAMETERis returned if one of the following conditionsis satisfied:
433     - Data is NULL.
434     - DataLength is 0.
435     - DeviceSpeed is not one of the supported values listed above.
436     - MaximumPacketLength is invalid. MaximumPacketLength must be 1023 or less for full-speed devices,
437       and 1024 or less for high-speed and super-speed devices.
438     - TransferResult is NULL.
439 
440   @param  This                  A pointer to the EFI_USB2_HC_PROTOCOL instance.
441   @param  DeviceAddress         Represents the address of the target device on the USB.
442   @param  EndPointAddress       The combination of an endpoint number and an endpoint direction of the
443                                 target USB device.
444   @param  DeviceSpeed           Indicates device speed. The supported values are EFI_USB_SPEED_FULL,
445                                 EFI_USB_SPEED_HIGH, or EFI_USB_SPEED_SUPER.
446   @param  MaximumPacketLength   Indicates the maximum packet size the target endpoint is capable of
447                                 sending or receiving.
448   @param  DataBuffersNumber     Number of data buffers prepared for the transfer.
449   @param  Data                  Array of pointers to the buffers of data that will be transmitted to USB
450                                 device or received from USB device.
451   @param  DataLength            Specifies the length, in bytes, of the data to be sent to or received from
452                                 the USB device.
453   @param  Translator            A pointer to the transaction translator data.
454   @param  TransferResult        A pointer to the detailed result information of the isochronous transfer.
455 
456   @retval EFI_SUCCESS           The isochronous transfer was completed successfully.
457   @retval EFI_INVALID_PARAMETER Some parameters are invalid.
458   @retval EFI_OUT_OF_RESOURCES  The isochronous transfer could not be submitted due to a lack of resources.
459   @retval EFI_TIMEOUT           The isochronous transfer cannot be completed within the one USB frame time.
460   @retval EFI_DEVICE_ERROR      The isochronous transfer failed due to host controller or device error.
461                                 Caller should check TransferResult for detailed error information.
462 
463 **/
464 typedef
465 EFI_STATUS
466 (EFIAPI *EFI_USB2_HC_PROTOCOL_ISOCHRONOUS_TRANSFER)(
467   IN     EFI_USB2_HC_PROTOCOL               *This,
468   IN     UINT8                              DeviceAddress,
469   IN     UINT8                              EndPointAddress,
470   IN     UINT8                              DeviceSpeed,
471   IN     UINTN                              MaximumPacketLength,
472   IN     UINT8                              DataBuffersNumber,
473   IN OUT VOID                               *Data[EFI_USB_MAX_ISO_BUFFER_NUM],
474   IN     UINTN                              DataLength,
475   IN     EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,
476   OUT    UINT32                             *TransferResult
477   );
478 
479 /**
480   Submits nonblocking isochronous transfer to an isochronous endpoint of a USB device.
481 
482   This is an asynchronous type of USB isochronous transfer. If the caller submits a USB
483   isochronous transfer request through this function, this function will return immediately.
484 
485   When the isochronous transfer completes, the IsochronousCallbackfunction will be triggered,
486   the caller can know the transfer results. If the transfer is successful, the caller can get
487   the data received or sent in this callback function.
488 
489   The target endpoint is specified by DeviceAddressand EndpointAddress. Isochronous transfers
490   are used when working with isochronous date. It provides periodic, continuous communication
491   between the host and a device. Isochronous transfers can be used only by full-speed, high-speed,
492   and super-speed devices.
493 
494   High-speed isochronous transfers can be performed using multiple data buffers. The number of
495   buffers that are actually prepared for the transfer is specified by DataBuffersNumber. For
496   full-speed isochronous transfers this value is ignored.
497 
498   Data represents a list of pointers to the data buffers. For full-speed isochronous transfers
499   only the data pointed by Data[0] shall be used. For high-speed isochronous transfers and for
500   the split transactions depending on DataLength there several data buffers can be used. For
501   the high-speed isochronous transfers the total number of buffers must not exceed EFI_USB_MAX_ISO_BUFFER_NUM.
502 
503   For split transactions performed on full-speed device by high-speed host controller the total
504   number of buffers is limited to EFI_USB_MAX_ISO_BUFFER_NUM1.
505 
506   EFI_INVALID_PARAMETER is returned if one of the following conditionsis satisfied:
507     - Data is NULL.
508     - DataLength is 0.
509     - DeviceSpeed is not one of the supported values listed above.
510     - MaximumPacketLength is invalid. MaximumPacketLength must be 1023 or less for full-speed
511       devices and 1024 or less for high-speed and super-speed devices.
512 
513   @param  This                  A pointer to the EFI_USB2_HC_PROTOCOL instance.
514   @param  DeviceAddress         Represents the address of the target device on the USB.
515   @param  EndPointAddress       The combination of an endpoint number and an endpoint direction of the
516                                 target USB device.
517   @param  DeviceSpeed           Indicates device speed. The supported values are EFI_USB_SPEED_FULL,
518                                 EFI_USB_SPEED_HIGH, or EFI_USB_SPEED_SUPER.
519   @param  MaximumPacketLength   Indicates the maximum packet size the target endpoint is capable of
520                                 sending or receiving.
521   @param  DataBuffersNumber     Number of data buffers prepared for the transfer.
522   @param  Data                  Array of pointers to the buffers of data that will be transmitted to USB
523                                 device or received from USB device.
524   @param  DataLength            Specifies the length, in bytes, of the data to be sent to or received from
525                                 the USB device.
526   @param  Translator            A pointer to the transaction translator data.
527   @param  IsochronousCallback   The Callback function. This function is called if the requested
528                                 isochronous transfer is completed.
529   @param  Context               Data passed to the IsochronousCallback function. This is an
530                                 optional parameter and may be NULL.
531 
532   @retval EFI_SUCCESS           The asynchronous isochronous transfer request has been successfully
533                                 submitted or canceled.
534   @retval EFI_INVALID_PARAMETER Some parameters are invalid.
535   @retval EFI_OUT_OF_RESOURCES  The asynchronous isochronous transfer could not be submitted due to
536                                 a lack of resources.
537 
538 **/
539 typedef
540 EFI_STATUS
541 (EFIAPI *EFI_USB2_HC_PROTOCOL_ASYNC_ISOCHRONOUS_TRANSFER)(
542   IN     EFI_USB2_HC_PROTOCOL               *This,
543   IN     UINT8                              DeviceAddress,
544   IN     UINT8                              EndPointAddress,
545   IN     UINT8                              DeviceSpeed,
546   IN     UINTN                              MaximumPacketLength,
547   IN     UINT8                              DataBuffersNumber,
548   IN OUT VOID                               *Data[EFI_USB_MAX_ISO_BUFFER_NUM],
549   IN     UINTN                              DataLength,
550   IN     EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,
551   IN     EFI_ASYNC_USB_TRANSFER_CALLBACK    IsochronousCallBack,
552   IN     VOID                               *Context OPTIONAL
553   );
554 
555 /**
556   Retrieves the current status of a USB root hub port.
557 
558   @param  This       A pointer to the EFI_USB2_HC_PROTOCOL instance.
559   @param  PortNumber Specifies the root hub port from which the status is to be retrieved.
560                      This value is zero based.
561   @param  PortStatus A pointer to the current port status bits and port status change bits.
562 
563   @retval EFI_SUCCESS           The status of the USB root hub port specified by PortNumber
564                                 was returned in PortStatus.
565   @retval EFI_INVALID_PARAMETER PortNumber is invalid.
566 
567 **/
568 typedef
569 EFI_STATUS
570 (EFIAPI *EFI_USB2_HC_PROTOCOL_GET_ROOTHUB_PORT_STATUS)(
571   IN        EFI_USB2_HC_PROTOCOL    *This,
572   IN        UINT8                   PortNumber,
573   OUT       EFI_USB_PORT_STATUS     *PortStatus
574   );
575 
576 /**
577   Sets a feature for the specified root hub port.
578 
579   @param  This        A pointer to the EFI_USB2_HC_PROTOCOL instance.
580   @param  PortNumber  Specifies the root hub port whose feature is requested to be set. This
581                       value is zero based.
582   @param  PortFeature Indicates the feature selector associated with the feature set request.
583 
584   @retval EFI_SUCCESS           The feature specified by PortFeature was set for the USB
585                                 root hub port specified by PortNumber.
586   @retval EFI_INVALID_PARAMETER PortNumber is invalid or PortFeature is invalid for this function.
587 
588 **/
589 typedef
590 EFI_STATUS
591 (EFIAPI *EFI_USB2_HC_PROTOCOL_SET_ROOTHUB_PORT_FEATURE)(
592   IN EFI_USB2_HC_PROTOCOL    *This,
593   IN UINT8                   PortNumber,
594   IN EFI_USB_PORT_FEATURE    PortFeature
595   );
596 
597 /**
598   Clears a feature for the specified root hub port.
599 
600   @param  This        A pointer to the EFI_USB2_HC_PROTOCOL instance.
601   @param  PortNumber  Specifies the root hub port whose feature is requested to be cleared. This
602                       value is zero based.
603   @param  PortFeature Indicates the feature selector associated with the feature clear request.
604 
605   @retval EFI_SUCCESS           The feature specified by PortFeature was cleared for the USB
606                                 root hub port specified by PortNumber.
607   @retval EFI_INVALID_PARAMETER PortNumber is invalid or PortFeature is invalid for this function.
608 
609 **/
610 typedef
611 EFI_STATUS
612 (EFIAPI *EFI_USB2_HC_PROTOCOL_CLEAR_ROOTHUB_PORT_FEATURE)(
613   IN EFI_USB2_HC_PROTOCOL    *This,
614   IN UINT8                   PortNumber,
615   IN EFI_USB_PORT_FEATURE    PortFeature
616   );
617 
618 ///
619 /// The EFI_USB2_HC_PROTOCOL provides USB host controller management, basic
620 /// data transactions over a USB bus, and USB root hub access. A device driver
621 /// that wishes to manage a USB bus in a system retrieves the EFI_USB2_HC_PROTOCOL
622 /// instance that is associated with the USB bus to be managed. A device handle
623 /// for a USB host controller will minimally contain an EFI_DEVICE_PATH_PROTOCOL
624 /// instance, and an EFI_USB2_HC_PROTOCOL instance.
625 ///
626 struct _EFI_USB2_HC_PROTOCOL {
627   EFI_USB2_HC_PROTOCOL_GET_CAPABILITY              GetCapability;
628   EFI_USB2_HC_PROTOCOL_RESET                       Reset;
629   EFI_USB2_HC_PROTOCOL_GET_STATE                   GetState;
630   EFI_USB2_HC_PROTOCOL_SET_STATE                   SetState;
631   EFI_USB2_HC_PROTOCOL_CONTROL_TRANSFER            ControlTransfer;
632   EFI_USB2_HC_PROTOCOL_BULK_TRANSFER               BulkTransfer;
633   EFI_USB2_HC_PROTOCOL_ASYNC_INTERRUPT_TRANSFER    AsyncInterruptTransfer;
634   EFI_USB2_HC_PROTOCOL_SYNC_INTERRUPT_TRANSFER     SyncInterruptTransfer;
635   EFI_USB2_HC_PROTOCOL_ISOCHRONOUS_TRANSFER        IsochronousTransfer;
636   EFI_USB2_HC_PROTOCOL_ASYNC_ISOCHRONOUS_TRANSFER  AsyncIsochronousTransfer;
637   EFI_USB2_HC_PROTOCOL_GET_ROOTHUB_PORT_STATUS     GetRootHubPortStatus;
638   EFI_USB2_HC_PROTOCOL_SET_ROOTHUB_PORT_FEATURE    SetRootHubPortFeature;
639   EFI_USB2_HC_PROTOCOL_CLEAR_ROOTHUB_PORT_FEATURE  ClearRootHubPortFeature;
640 
641   ///
642   /// The major revision number of the USB host controller. The revision information
643   /// indicates the release of the Universal Serial Bus Specification with which the
644   /// host controller is compliant.
645   ///
646   UINT16                                           MajorRevision;
647 
648   ///
649   /// The minor revision number of the USB host controller. The revision information
650   /// indicates the release of the Universal Serial Bus Specification with which the
651   /// host controller is compliant.
652   ///
653   UINT16                                           MinorRevision;
654 };
655 
656 extern EFI_GUID gEfiUsb2HcProtocolGuid;
657 
658 #endif
659