1*f334afcfSToomas Soome /** @file
2*f334afcfSToomas Soome   EFI Usb I/O Protocol as defined in UEFI specification.
3*f334afcfSToomas Soome   This protocol is used by code, typically drivers, running in the EFI
4*f334afcfSToomas Soome   boot services environment to access USB devices like USB keyboards,
5*f334afcfSToomas Soome   mice and mass storage devices. In particular, functions for managing devices
6*f334afcfSToomas Soome   on USB buses are defined here.
7*f334afcfSToomas Soome 
8*f334afcfSToomas Soome   Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>
9*f334afcfSToomas Soome   SPDX-License-Identifier: BSD-2-Clause-Patent
10*f334afcfSToomas Soome 
11*f334afcfSToomas Soome **/
12*f334afcfSToomas Soome 
13*f334afcfSToomas Soome #ifndef __USB_IO_H__
14*f334afcfSToomas Soome #define __USB_IO_H__
15*f334afcfSToomas Soome 
16*f334afcfSToomas Soome #include <IndustryStandard/Usb.h>
17*f334afcfSToomas Soome 
18*f334afcfSToomas Soome //
19*f334afcfSToomas Soome // Global ID for the USB I/O Protocol
20*f334afcfSToomas Soome //
21*f334afcfSToomas Soome #define EFI_USB_IO_PROTOCOL_GUID \
22*f334afcfSToomas Soome   { \
23*f334afcfSToomas Soome     0x2B2F68D6, 0x0CD2, 0x44cf, {0x8E, 0x8B, 0xBB, 0xA2, 0x0B, 0x1B, 0x5B, 0x75 } \
24*f334afcfSToomas Soome   }
25*f334afcfSToomas Soome 
26*f334afcfSToomas Soome typedef struct _EFI_USB_IO_PROTOCOL EFI_USB_IO_PROTOCOL;
27*f334afcfSToomas Soome 
28*f334afcfSToomas Soome //
29*f334afcfSToomas Soome // Related Definition for EFI USB I/O protocol
30*f334afcfSToomas Soome //
31*f334afcfSToomas Soome 
32*f334afcfSToomas Soome //
33*f334afcfSToomas Soome // USB standard descriptors and reqeust
34*f334afcfSToomas Soome //
35*f334afcfSToomas Soome typedef USB_DEVICE_REQUEST       EFI_USB_DEVICE_REQUEST;
36*f334afcfSToomas Soome typedef USB_DEVICE_DESCRIPTOR    EFI_USB_DEVICE_DESCRIPTOR;
37*f334afcfSToomas Soome typedef USB_CONFIG_DESCRIPTOR    EFI_USB_CONFIG_DESCRIPTOR;
38*f334afcfSToomas Soome typedef USB_INTERFACE_DESCRIPTOR EFI_USB_INTERFACE_DESCRIPTOR;
39*f334afcfSToomas Soome typedef USB_ENDPOINT_DESCRIPTOR  EFI_USB_ENDPOINT_DESCRIPTOR;
40*f334afcfSToomas Soome 
41*f334afcfSToomas Soome ///
42*f334afcfSToomas Soome /// USB data transfer direction
43*f334afcfSToomas Soome ///
44*f334afcfSToomas Soome typedef enum {
45*f334afcfSToomas Soome   EfiUsbDataIn,
46*f334afcfSToomas Soome   EfiUsbDataOut,
47*f334afcfSToomas Soome   EfiUsbNoData
48*f334afcfSToomas Soome } EFI_USB_DATA_DIRECTION;
49*f334afcfSToomas Soome 
50*f334afcfSToomas Soome //
51*f334afcfSToomas Soome // USB Transfer Results
52*f334afcfSToomas Soome //
53*f334afcfSToomas Soome #define EFI_USB_NOERROR         0x00
54*f334afcfSToomas Soome #define EFI_USB_ERR_NOTEXECUTE  0x01
55*f334afcfSToomas Soome #define EFI_USB_ERR_STALL       0x02
56*f334afcfSToomas Soome #define EFI_USB_ERR_BUFFER      0x04
57*f334afcfSToomas Soome #define EFI_USB_ERR_BABBLE      0x08
58*f334afcfSToomas Soome #define EFI_USB_ERR_NAK         0x10
59*f334afcfSToomas Soome #define EFI_USB_ERR_CRC         0x20
60*f334afcfSToomas Soome #define EFI_USB_ERR_TIMEOUT     0x40
61*f334afcfSToomas Soome #define EFI_USB_ERR_BITSTUFF    0x80
62*f334afcfSToomas Soome #define EFI_USB_ERR_SYSTEM      0x100
63*f334afcfSToomas Soome 
64*f334afcfSToomas Soome /**
65*f334afcfSToomas Soome   Async USB transfer callback routine.
66*f334afcfSToomas Soome 
67*f334afcfSToomas Soome   @param  Data                  Data received or sent via the USB Asynchronous Transfer, if the
68*f334afcfSToomas Soome                                 transfer completed successfully.
69*f334afcfSToomas Soome   @param  DataLength            The length of Data received or sent via the Asynchronous
70*f334afcfSToomas Soome                                 Transfer, if transfer successfully completes.
71*f334afcfSToomas Soome   @param  Context               Data passed from UsbAsyncInterruptTransfer() request.
72*f334afcfSToomas Soome   @param  Status                Indicates the result of the asynchronous transfer.
73*f334afcfSToomas Soome 
74*f334afcfSToomas Soome   @retval EFI_SUCCESS           The asynchronous USB transfer request has been successfully executed.
75*f334afcfSToomas Soome   @retval EFI_DEVICE_ERROR      The asynchronous USB transfer request failed.
76*f334afcfSToomas Soome 
77*f334afcfSToomas Soome **/
78*f334afcfSToomas Soome typedef
79*f334afcfSToomas Soome EFI_STATUS
80*f334afcfSToomas Soome (EFIAPI *EFI_ASYNC_USB_TRANSFER_CALLBACK)(
81*f334afcfSToomas Soome   IN VOID         *Data,
82*f334afcfSToomas Soome   IN UINTN        DataLength,
83*f334afcfSToomas Soome   IN VOID         *Context,
84*f334afcfSToomas Soome   IN UINT32       Status
85*f334afcfSToomas Soome   );
86*f334afcfSToomas Soome 
87*f334afcfSToomas Soome //
88*f334afcfSToomas Soome // Prototype for EFI USB I/O protocol
89*f334afcfSToomas Soome //
90*f334afcfSToomas Soome 
91*f334afcfSToomas Soome /**
92*f334afcfSToomas Soome   This function is used to manage a USB device with a control transfer pipe. A control transfer is
93*f334afcfSToomas Soome   typically used to perform device initialization and configuration.
94*f334afcfSToomas Soome 
95*f334afcfSToomas Soome   @param  This                  A pointer to the EFI_USB_IO_PROTOCOL instance.
96*f334afcfSToomas Soome   @param  Request               A pointer to the USB device request that will be sent to the USB
97*f334afcfSToomas Soome                                 device.
98*f334afcfSToomas Soome   @param  Direction             Indicates the data direction.
99*f334afcfSToomas Soome   @param  Timeout               Indicating the transfer should be completed within this time frame.
100*f334afcfSToomas Soome                                 The units are in milliseconds.
101*f334afcfSToomas Soome   @param  Data                  A pointer to the buffer of data that will be transmitted to USB
102*f334afcfSToomas Soome                                 device or received from USB device.
103*f334afcfSToomas Soome   @param  DataLength            The size, in bytes, of the data buffer specified by Data.
104*f334afcfSToomas Soome   @param  Status                A pointer to the result of the USB transfer.
105*f334afcfSToomas Soome 
106*f334afcfSToomas Soome   @retval EFI_SUCCESS           The control transfer has been successfully executed.
107*f334afcfSToomas Soome   @retval EFI_DEVICE_ERROR      The transfer failed. The transfer status is returned in Status.
108*f334afcfSToomas Soome   @retval EFI_INVALID_PARAMETE  One or more parameters are invalid.
109*f334afcfSToomas Soome   @retval EFI_OUT_OF_RESOURCES  The request could not be completed due to a lack of resources.
110*f334afcfSToomas Soome   @retval EFI_TIMEOUT           The control transfer fails due to timeout.
111*f334afcfSToomas Soome 
112*f334afcfSToomas Soome **/
113*f334afcfSToomas Soome typedef
114*f334afcfSToomas Soome EFI_STATUS
115*f334afcfSToomas Soome (EFIAPI *EFI_USB_IO_CONTROL_TRANSFER)(
116*f334afcfSToomas Soome   IN EFI_USB_IO_PROTOCOL                        *This,
117*f334afcfSToomas Soome   IN EFI_USB_DEVICE_REQUEST                     *Request,
118*f334afcfSToomas Soome   IN EFI_USB_DATA_DIRECTION                     Direction,
119*f334afcfSToomas Soome   IN UINT32                                     Timeout,
120*f334afcfSToomas Soome   IN OUT VOID                                   *Data OPTIONAL,
121*f334afcfSToomas Soome   IN UINTN                                      DataLength  OPTIONAL,
122*f334afcfSToomas Soome   OUT UINT32                                    *Status
123*f334afcfSToomas Soome   );
124*f334afcfSToomas Soome 
125*f334afcfSToomas Soome /**
126*f334afcfSToomas Soome   This function is used to manage a USB device with the bulk transfer pipe. Bulk Transfers are
127*f334afcfSToomas Soome   typically used to transfer large amounts of data to/from USB devices.
128*f334afcfSToomas Soome 
129*f334afcfSToomas Soome   @param  This                  A pointer to the EFI_USB_IO_PROTOCOL instance.
130*f334afcfSToomas Soome   @param  DeviceEndpoint        The destination USB device endpoint to which the
131*f334afcfSToomas Soome                                 device request is being sent. DeviceEndpoint must
132*f334afcfSToomas Soome                                 be between 0x01 and 0x0F or between 0x81 and 0x8F,
133*f334afcfSToomas Soome                                 otherwise EFI_INVALID_PARAMETER is returned. If
134*f334afcfSToomas Soome                                 the endpoint is not a BULK endpoint, EFI_INVALID_PARAMETER
135*f334afcfSToomas Soome                                 is returned. The MSB of this parameter indicates
136*f334afcfSToomas Soome                                 the endpoint direction. The number "1" stands for
137*f334afcfSToomas Soome                                 an IN endpoint, and "0" stands for an OUT endpoint.
138*f334afcfSToomas Soome   @param  Data                  A pointer to the buffer of data that will be transmitted to USB
139*f334afcfSToomas Soome                                 device or received from USB device.
140*f334afcfSToomas Soome   @param  DataLength            The size, in bytes, of the data buffer specified by Data.
141*f334afcfSToomas Soome                                 On input, the size, in bytes, of the data buffer specified by Data.
142*f334afcfSToomas Soome                                 On output, the number of bytes that were actually transferred.
143*f334afcfSToomas Soome   @param  Timeout               Indicating the transfer should be completed within this time frame.
144*f334afcfSToomas Soome                                 The units are in milliseconds. If Timeout is 0, then the
145*f334afcfSToomas Soome                                 caller must wait for the function to be completed until
146*f334afcfSToomas Soome                                 EFI_SUCCESS or EFI_DEVICE_ERROR is returned.
147*f334afcfSToomas Soome   @param  Status                This parameter indicates the USB transfer status.
148*f334afcfSToomas Soome 
149*f334afcfSToomas Soome   @retval EFI_SUCCESS           The bulk transfer has been successfully executed.
150*f334afcfSToomas Soome   @retval EFI_DEVICE_ERROR      The transfer failed. The transfer status is returned in Status.
151*f334afcfSToomas Soome   @retval EFI_INVALID_PARAMETE  One or more parameters are invalid.
152*f334afcfSToomas Soome   @retval EFI_OUT_OF_RESOURCES  The request could not be submitted due to a lack of resources.
153*f334afcfSToomas Soome   @retval EFI_TIMEOUT           The control transfer fails due to timeout.
154*f334afcfSToomas Soome 
155*f334afcfSToomas Soome **/
156*f334afcfSToomas Soome typedef
157*f334afcfSToomas Soome EFI_STATUS
158*f334afcfSToomas Soome (EFIAPI *EFI_USB_IO_BULK_TRANSFER)(
159*f334afcfSToomas Soome   IN EFI_USB_IO_PROTOCOL            *This,
160*f334afcfSToomas Soome   IN UINT8                          DeviceEndpoint,
161*f334afcfSToomas Soome   IN OUT VOID                       *Data,
162*f334afcfSToomas Soome   IN OUT UINTN                      *DataLength,
163*f334afcfSToomas Soome   IN UINTN                          Timeout,
164*f334afcfSToomas Soome   OUT UINT32                        *Status
165*f334afcfSToomas Soome   );
166*f334afcfSToomas Soome 
167*f334afcfSToomas Soome /**
168*f334afcfSToomas Soome   This function is used to manage a USB device with an interrupt transfer pipe. An Asynchronous
169*f334afcfSToomas Soome   Interrupt Transfer is typically used to query a device's status at a fixed rate. For example,
170*f334afcfSToomas Soome   keyboard, mouse, and hub devices use this type of transfer to query their interrupt endpoints at
171*f334afcfSToomas Soome   a fixed rate.
172*f334afcfSToomas Soome 
173*f334afcfSToomas Soome   @param  This                  A pointer to the EFI_USB_IO_PROTOCOL instance.
174*f334afcfSToomas Soome   @param  DeviceEndpoint        The destination USB device endpoint to which the
175*f334afcfSToomas Soome                                 device request is being sent. DeviceEndpoint must
176*f334afcfSToomas Soome                                 be between 0x01 and 0x0F or between 0x81 and 0x8F,
177*f334afcfSToomas Soome                                 otherwise EFI_INVALID_PARAMETER is returned. If
178*f334afcfSToomas Soome                                 the endpoint is not a BULK endpoint, EFI_INVALID_PARAMETER
179*f334afcfSToomas Soome                                 is returned. The MSB of this parameter indicates
180*f334afcfSToomas Soome                                 the endpoint direction. The number "1" stands for
181*f334afcfSToomas Soome                                 an IN endpoint, and "0" stands for an OUT endpoint.
182*f334afcfSToomas Soome   @param  IsNewTransfer         If TRUE, a new transfer will be submitted to USB controller. If
183*f334afcfSToomas Soome                                 FALSE, the interrupt transfer is deleted from the device's interrupt
184*f334afcfSToomas Soome                                 transfer queue.
185*f334afcfSToomas Soome   @param  PollingInterval       Indicates the periodic rate, in milliseconds, that the transfer is to be
186*f334afcfSToomas Soome                                 executed.This parameter is required when IsNewTransfer is TRUE. The
187*f334afcfSToomas Soome                                 value must be between 1 to 255, otherwise EFI_INVALID_PARAMETER is returned.
188*f334afcfSToomas Soome                                 The units are in milliseconds.
189*f334afcfSToomas Soome   @param  DataLength            Specifies the length, in bytes, of the data to be received from the
190*f334afcfSToomas Soome                                 USB device. This parameter is only required when IsNewTransfer is TRUE.
191*f334afcfSToomas Soome   @param  InterruptCallback     The Callback function. This function is called if the asynchronous
192*f334afcfSToomas Soome                                 interrupt transfer is completed. This parameter is required
193*f334afcfSToomas Soome                                 when IsNewTransfer is TRUE.
194*f334afcfSToomas Soome   @param  Context               Data passed to the InterruptCallback function. This is an optional
195*f334afcfSToomas Soome                                 parameter and may be NULL.
196*f334afcfSToomas Soome 
197*f334afcfSToomas Soome   @retval EFI_SUCCESS           The asynchronous USB transfer request transfer has been successfully executed.
198*f334afcfSToomas Soome   @retval EFI_DEVICE_ERROR      The asynchronous USB transfer request failed.
199*f334afcfSToomas Soome 
200*f334afcfSToomas Soome **/
201*f334afcfSToomas Soome typedef
202*f334afcfSToomas Soome EFI_STATUS
203*f334afcfSToomas Soome (EFIAPI *EFI_USB_IO_ASYNC_INTERRUPT_TRANSFER)(
204*f334afcfSToomas Soome   IN EFI_USB_IO_PROTOCOL                                 *This,
205*f334afcfSToomas Soome   IN UINT8                                               DeviceEndpoint,
206*f334afcfSToomas Soome   IN BOOLEAN                                             IsNewTransfer,
207*f334afcfSToomas Soome   IN UINTN                                               PollingInterval    OPTIONAL,
208*f334afcfSToomas Soome   IN UINTN                                               DataLength         OPTIONAL,
209*f334afcfSToomas Soome   IN EFI_ASYNC_USB_TRANSFER_CALLBACK                     InterruptCallBack  OPTIONAL,
210*f334afcfSToomas Soome   IN VOID                                                *Context OPTIONAL
211*f334afcfSToomas Soome   );
212*f334afcfSToomas Soome 
213*f334afcfSToomas Soome /**
214*f334afcfSToomas Soome   This function is used to manage a USB device with an interrupt transfer pipe.
215*f334afcfSToomas Soome 
216*f334afcfSToomas Soome   @param  This                  A pointer to the EFI_USB_IO_PROTOCOL instance.
217*f334afcfSToomas Soome   @param  DeviceEndpoint        The destination USB device endpoint to which the
218*f334afcfSToomas Soome                                 device request is being sent. DeviceEndpoint must
219*f334afcfSToomas Soome                                 be between 0x01 and 0x0F or between 0x81 and 0x8F,
220*f334afcfSToomas Soome                                 otherwise EFI_INVALID_PARAMETER is returned. If
221*f334afcfSToomas Soome                                 the endpoint is not a BULK endpoint, EFI_INVALID_PARAMETER
222*f334afcfSToomas Soome                                 is returned. The MSB of this parameter indicates
223*f334afcfSToomas Soome                                 the endpoint direction. The number "1" stands for
224*f334afcfSToomas Soome                                 an IN endpoint, and "0" stands for an OUT endpoint.
225*f334afcfSToomas Soome   @param  Data                  A pointer to the buffer of data that will be transmitted to USB
226*f334afcfSToomas Soome                                 device or received from USB device.
227*f334afcfSToomas Soome   @param  DataLength            On input, then size, in bytes, of the buffer Data. On output, the
228*f334afcfSToomas Soome                                 amount of data actually transferred.
229*f334afcfSToomas Soome   @param  Timeout               The time out, in seconds, for this transfer. If Timeout is 0,
230*f334afcfSToomas Soome                                 then the caller must wait for the function to be completed
231*f334afcfSToomas Soome                                 until EFI_SUCCESS or EFI_DEVICE_ERROR is returned. If the
232*f334afcfSToomas Soome                                 transfer is not completed in this time frame, then EFI_TIMEOUT is returned.
233*f334afcfSToomas Soome   @param  Status                This parameter indicates the USB transfer status.
234*f334afcfSToomas Soome 
235*f334afcfSToomas Soome   @retval EFI_SUCCESS           The sync interrupt transfer has been successfully executed.
236*f334afcfSToomas Soome   @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
237*f334afcfSToomas Soome   @retval EFI_DEVICE_ERROR      The sync interrupt transfer request failed.
238*f334afcfSToomas Soome   @retval EFI_OUT_OF_RESOURCES  The request could not be submitted due to a lack of resources.
239*f334afcfSToomas Soome   @retval EFI_TIMEOUT           The transfer fails due to timeout.
240*f334afcfSToomas Soome **/
241*f334afcfSToomas Soome typedef
242*f334afcfSToomas Soome EFI_STATUS
243*f334afcfSToomas Soome (EFIAPI *EFI_USB_IO_SYNC_INTERRUPT_TRANSFER)(
244*f334afcfSToomas Soome   IN EFI_USB_IO_PROTOCOL            *This,
245*f334afcfSToomas Soome   IN     UINT8                      DeviceEndpoint,
246*f334afcfSToomas Soome   IN OUT VOID                       *Data,
247*f334afcfSToomas Soome   IN OUT UINTN                      *DataLength,
248*f334afcfSToomas Soome   IN     UINTN                      Timeout,
249*f334afcfSToomas Soome   OUT    UINT32                     *Status
250*f334afcfSToomas Soome   );
251*f334afcfSToomas Soome 
252*f334afcfSToomas Soome /**
253*f334afcfSToomas Soome   This function is used to manage a USB device with an isochronous transfer pipe. An Isochronous
254*f334afcfSToomas Soome   transfer is typically used to transfer streaming data.
255*f334afcfSToomas Soome 
256*f334afcfSToomas Soome   @param  This                  A pointer to the EFI_USB_IO_PROTOCOL instance.
257*f334afcfSToomas Soome   @param  DeviceEndpoint        The destination USB device endpoint to which the
258*f334afcfSToomas Soome                                 device request is being sent. DeviceEndpoint must
259*f334afcfSToomas Soome                                 be between 0x01 and 0x0F or between 0x81 and 0x8F,
260*f334afcfSToomas Soome                                 otherwise EFI_INVALID_PARAMETER is returned. If
261*f334afcfSToomas Soome                                 the endpoint is not a BULK endpoint, EFI_INVALID_PARAMETER
262*f334afcfSToomas Soome                                 is returned. The MSB of this parameter indicates
263*f334afcfSToomas Soome                                 the endpoint direction. The number "1" stands for
264*f334afcfSToomas Soome                                 an IN endpoint, and "0" stands for an OUT endpoint.
265*f334afcfSToomas Soome   @param  Data                  A pointer to the buffer of data that will be transmitted to USB
266*f334afcfSToomas Soome                                 device or received from USB device.
267*f334afcfSToomas Soome   @param  DataLength            The size, in bytes, of the data buffer specified by Data.
268*f334afcfSToomas Soome   @param  Status                This parameter indicates the USB transfer status.
269*f334afcfSToomas Soome 
270*f334afcfSToomas Soome   @retval EFI_SUCCESS           The isochronous transfer has been successfully executed.
271*f334afcfSToomas Soome   @retval EFI_INVALID_PARAMETER The parameter DeviceEndpoint is not valid.
272*f334afcfSToomas Soome   @retval EFI_DEVICE_ERROR      The transfer failed due to the reason other than timeout, The error status
273*f334afcfSToomas Soome                                 is returned in Status.
274*f334afcfSToomas Soome   @retval EFI_OUT_OF_RESOURCES  The request could not be submitted due to a lack of resources.
275*f334afcfSToomas Soome   @retval EFI_TIMEOUT           The transfer fails due to timeout.
276*f334afcfSToomas Soome **/
277*f334afcfSToomas Soome typedef
278*f334afcfSToomas Soome EFI_STATUS
279*f334afcfSToomas Soome (EFIAPI *EFI_USB_IO_ISOCHRONOUS_TRANSFER)(
280*f334afcfSToomas Soome   IN EFI_USB_IO_PROTOCOL            *This,
281*f334afcfSToomas Soome   IN     UINT8                      DeviceEndpoint,
282*f334afcfSToomas Soome   IN OUT VOID                       *Data,
283*f334afcfSToomas Soome   IN     UINTN                      DataLength,
284*f334afcfSToomas Soome   OUT    UINT32                     *Status
285*f334afcfSToomas Soome   );
286*f334afcfSToomas Soome 
287*f334afcfSToomas Soome /**
288*f334afcfSToomas Soome   This function is used to manage a USB device with an isochronous transfer pipe. An Isochronous
289*f334afcfSToomas Soome   transfer is typically used to transfer streaming data.
290*f334afcfSToomas Soome 
291*f334afcfSToomas Soome   @param  This                  A pointer to the EFI_USB_IO_PROTOCOL instance.
292*f334afcfSToomas Soome   @param  DeviceEndpoint        The destination USB device endpoint to which the
293*f334afcfSToomas Soome                                 device request is being sent. DeviceEndpoint must
294*f334afcfSToomas Soome                                 be between 0x01 and 0x0F or between 0x81 and 0x8F,
295*f334afcfSToomas Soome                                 otherwise EFI_INVALID_PARAMETER is returned. If
296*f334afcfSToomas Soome                                 the endpoint is not a BULK endpoint, EFI_INVALID_PARAMETER
297*f334afcfSToomas Soome                                 is returned. The MSB of this parameter indicates
298*f334afcfSToomas Soome                                 the endpoint direction. The number "1" stands for
299*f334afcfSToomas Soome                                 an IN endpoint, and "0" stands for an OUT endpoint.
300*f334afcfSToomas Soome   @param  Data                  A pointer to the buffer of data that will be transmitted to USB
301*f334afcfSToomas Soome                                 device or received from USB device.
302*f334afcfSToomas Soome   @param  DataLength            The size, in bytes, of the data buffer specified by Data.
303*f334afcfSToomas Soome                                 This is an optional parameter and may be NULL.
304*f334afcfSToomas Soome   @param  IsochronousCallback   The IsochronousCallback() function.This function is
305*f334afcfSToomas Soome                                 called if the requested isochronous transfer is completed.
306*f334afcfSToomas Soome   @param  Context               Data passed to the IsochronousCallback() function.
307*f334afcfSToomas Soome 
308*f334afcfSToomas Soome   @retval EFI_SUCCESS           The asynchronous isochronous transfer has been successfully submitted
309*f334afcfSToomas Soome                                 to the system.
310*f334afcfSToomas Soome   @retval EFI_INVALID_PARAMETER The parameter DeviceEndpoint is not valid.
311*f334afcfSToomas Soome   @retval EFI_OUT_OF_RESOURCES  The request could not be submitted due to a lack of resources.
312*f334afcfSToomas Soome 
313*f334afcfSToomas Soome **/
314*f334afcfSToomas Soome typedef
315*f334afcfSToomas Soome EFI_STATUS
316*f334afcfSToomas Soome (EFIAPI *EFI_USB_IO_ASYNC_ISOCHRONOUS_TRANSFER)(
317*f334afcfSToomas Soome   IN EFI_USB_IO_PROTOCOL              *This,
318*f334afcfSToomas Soome   IN UINT8                            DeviceEndpoint,
319*f334afcfSToomas Soome   IN OUT VOID                         *Data,
320*f334afcfSToomas Soome   IN     UINTN                        DataLength,
321*f334afcfSToomas Soome   IN EFI_ASYNC_USB_TRANSFER_CALLBACK  IsochronousCallBack,
322*f334afcfSToomas Soome   IN VOID                             *Context OPTIONAL
323*f334afcfSToomas Soome   );
324*f334afcfSToomas Soome 
325*f334afcfSToomas Soome /**
326*f334afcfSToomas Soome   Resets and reconfigures the USB controller. This function will work for all USB devices except
327*f334afcfSToomas Soome   USB Hub Controllers.
328*f334afcfSToomas Soome 
329*f334afcfSToomas Soome   @param  This                  A pointer to the EFI_USB_IO_PROTOCOL instance.
330*f334afcfSToomas Soome 
331*f334afcfSToomas Soome   @retval EFI_SUCCESS           The USB controller was reset.
332*f334afcfSToomas Soome   @retval EFI_INVALID_PARAMETER If the controller specified by This is a USB hub.
333*f334afcfSToomas Soome   @retval EFI_DEVICE_ERROR      An error occurred during the reconfiguration process.
334*f334afcfSToomas Soome 
335*f334afcfSToomas Soome **/
336*f334afcfSToomas Soome typedef
337*f334afcfSToomas Soome EFI_STATUS
338*f334afcfSToomas Soome (EFIAPI *EFI_USB_IO_PORT_RESET)(
339*f334afcfSToomas Soome   IN EFI_USB_IO_PROTOCOL    *This
340*f334afcfSToomas Soome   );
341*f334afcfSToomas Soome 
342*f334afcfSToomas Soome /**
343*f334afcfSToomas Soome   Retrieves the USB Device Descriptor.
344*f334afcfSToomas Soome 
345*f334afcfSToomas Soome   @param  This                  A pointer to the EFI_USB_IO_PROTOCOL instance.
346*f334afcfSToomas Soome   @param  DeviceDescriptor      A pointer to the caller allocated USB Device Descriptor.
347*f334afcfSToomas Soome 
348*f334afcfSToomas Soome   @retval EFI_SUCCESS           The device descriptor was retrieved successfully.
349*f334afcfSToomas Soome   @retval EFI_INVALID_PARAMETER DeviceDescriptor is NULL.
350*f334afcfSToomas Soome   @retval EFI_NOT_FOUND         The device descriptor was not found. The device may not be configured.
351*f334afcfSToomas Soome 
352*f334afcfSToomas Soome **/
353*f334afcfSToomas Soome typedef
354*f334afcfSToomas Soome EFI_STATUS
355*f334afcfSToomas Soome (EFIAPI *EFI_USB_IO_GET_DEVICE_DESCRIPTOR)(
356*f334afcfSToomas Soome   IN EFI_USB_IO_PROTOCOL            *This,
357*f334afcfSToomas Soome   OUT EFI_USB_DEVICE_DESCRIPTOR     *DeviceDescriptor
358*f334afcfSToomas Soome   );
359*f334afcfSToomas Soome 
360*f334afcfSToomas Soome /**
361*f334afcfSToomas Soome   Retrieves the USB Device Descriptor.
362*f334afcfSToomas Soome 
363*f334afcfSToomas Soome   @param  This                    A pointer to the EFI_USB_IO_PROTOCOL instance.
364*f334afcfSToomas Soome   @param  ConfigurationDescriptor A pointer to the caller allocated USB Active Configuration
365*f334afcfSToomas Soome                                   Descriptor.
366*f334afcfSToomas Soome   @retval EFI_SUCCESS             The active configuration descriptor was retrieved successfully.
367*f334afcfSToomas Soome   @retval EFI_INVALID_PARAMETER   ConfigurationDescriptor is NULL.
368*f334afcfSToomas Soome   @retval EFI_NOT_FOUND           An active configuration descriptor cannot be found. The device may not
369*f334afcfSToomas Soome                                   be configured.
370*f334afcfSToomas Soome 
371*f334afcfSToomas Soome **/
372*f334afcfSToomas Soome typedef
373*f334afcfSToomas Soome EFI_STATUS
374*f334afcfSToomas Soome (EFIAPI *EFI_USB_IO_GET_CONFIG_DESCRIPTOR)(
375*f334afcfSToomas Soome   IN EFI_USB_IO_PROTOCOL            *This,
376*f334afcfSToomas Soome   OUT EFI_USB_CONFIG_DESCRIPTOR     *ConfigurationDescriptor
377*f334afcfSToomas Soome   );
378*f334afcfSToomas Soome 
379*f334afcfSToomas Soome /**
380*f334afcfSToomas Soome   Retrieves the Interface Descriptor for a USB Device Controller. As stated earlier, an interface
381*f334afcfSToomas Soome   within a USB device is equivalently to a USB Controller within the current configuration.
382*f334afcfSToomas Soome 
383*f334afcfSToomas Soome   @param  This                    A pointer to the EFI_USB_IO_PROTOCOL instance.
384*f334afcfSToomas Soome   @param  InterfaceDescriptor     A pointer to the caller allocated USB Interface Descriptor within
385*f334afcfSToomas Soome                                   the configuration setting.
386*f334afcfSToomas Soome   @retval EFI_SUCCESS             The interface descriptor retrieved successfully.
387*f334afcfSToomas Soome   @retval EFI_INVALID_PARAMETER   InterfaceDescriptor is NULL.
388*f334afcfSToomas Soome   @retval EFI_NOT_FOUND           The interface descriptor cannot be found. The device may not be
389*f334afcfSToomas Soome                                   correctly configured.
390*f334afcfSToomas Soome 
391*f334afcfSToomas Soome **/
392*f334afcfSToomas Soome typedef
393*f334afcfSToomas Soome EFI_STATUS
394*f334afcfSToomas Soome (EFIAPI *EFI_USB_IO_GET_INTERFACE_DESCRIPTOR)(
395*f334afcfSToomas Soome   IN EFI_USB_IO_PROTOCOL            *This,
396*f334afcfSToomas Soome   OUT EFI_USB_INTERFACE_DESCRIPTOR  *InterfaceDescriptor
397*f334afcfSToomas Soome   );
398*f334afcfSToomas Soome 
399*f334afcfSToomas Soome /**
400*f334afcfSToomas Soome   Retrieves an Endpoint Descriptor within a USB Controller.
401*f334afcfSToomas Soome 
402*f334afcfSToomas Soome   @param  This                    A pointer to the EFI_USB_IO_PROTOCOL instance.
403*f334afcfSToomas Soome   @param  EndpointIndex           Indicates which endpoint descriptor to retrieve.
404*f334afcfSToomas Soome   @param  EndpointDescriptor      A pointer to the caller allocated USB Endpoint Descriptor of
405*f334afcfSToomas Soome                                   a USB controller.
406*f334afcfSToomas Soome 
407*f334afcfSToomas Soome   @retval EFI_SUCCESS             The endpoint descriptor was retrieved successfully.
408*f334afcfSToomas Soome   @retval EFI_INVALID_PARAMETER   One or more parameters are invalid.
409*f334afcfSToomas Soome   @retval EFI_NOT_FOUND           The endpoint descriptor cannot be found. The device may not be
410*f334afcfSToomas Soome                                   correctly configured.
411*f334afcfSToomas Soome 
412*f334afcfSToomas Soome **/
413*f334afcfSToomas Soome typedef
414*f334afcfSToomas Soome EFI_STATUS
415*f334afcfSToomas Soome (EFIAPI *EFI_USB_IO_GET_ENDPOINT_DESCRIPTOR)(
416*f334afcfSToomas Soome   IN EFI_USB_IO_PROTOCOL            *This,
417*f334afcfSToomas Soome   IN  UINT8                         EndpointIndex,
418*f334afcfSToomas Soome   OUT EFI_USB_ENDPOINT_DESCRIPTOR   *EndpointDescriptor
419*f334afcfSToomas Soome   );
420*f334afcfSToomas Soome 
421*f334afcfSToomas Soome /**
422*f334afcfSToomas Soome   Retrieves a string stored in a USB Device.
423*f334afcfSToomas Soome 
424*f334afcfSToomas Soome   @param  This                    A pointer to the EFI_USB_IO_PROTOCOL instance.
425*f334afcfSToomas Soome   @param  LangID                  The Language ID for the string being retrieved.
426*f334afcfSToomas Soome   @param  StringID                The ID of the string being retrieved.
427*f334afcfSToomas Soome   @param  String                  A pointer to a buffer allocated by this function with
428*f334afcfSToomas Soome                                   AllocatePool() to store the string.If this function
429*f334afcfSToomas Soome                                   returns EFI_SUCCESS, it stores the string the caller
430*f334afcfSToomas Soome                                   wants to get. The caller should release the string
431*f334afcfSToomas Soome                                   buffer with FreePool() after the string is not used any more.
432*f334afcfSToomas Soome 
433*f334afcfSToomas Soome   @retval EFI_SUCCESS             The string was retrieved successfully.
434*f334afcfSToomas Soome   @retval EFI_NOT_FOUND           The string specified by LangID and StringID was not found.
435*f334afcfSToomas Soome   @retval EFI_OUT_OF_RESOURCES    There are not enough resources to allocate the return buffer String.
436*f334afcfSToomas Soome 
437*f334afcfSToomas Soome **/
438*f334afcfSToomas Soome typedef
439*f334afcfSToomas Soome EFI_STATUS
440*f334afcfSToomas Soome (EFIAPI *EFI_USB_IO_GET_STRING_DESCRIPTOR)(
441*f334afcfSToomas Soome   IN EFI_USB_IO_PROTOCOL            *This,
442*f334afcfSToomas Soome   IN  UINT16                        LangID,
443*f334afcfSToomas Soome   IN  UINT8                         StringID,
444*f334afcfSToomas Soome   OUT CHAR16                        **String
445*f334afcfSToomas Soome   );
446*f334afcfSToomas Soome 
447*f334afcfSToomas Soome /**
448*f334afcfSToomas Soome   Retrieves all the language ID codes that the USB device supports.
449*f334afcfSToomas Soome 
450*f334afcfSToomas Soome   @param  This                    A pointer to the EFI_USB_IO_PROTOCOL instance.
451*f334afcfSToomas Soome   @param  LangIDTable             Language ID for the string the caller wants to get.
452*f334afcfSToomas Soome                                   This is a 16-bit ID defined by Microsoft. This
453*f334afcfSToomas Soome                                   buffer pointer is allocated and maintained by
454*f334afcfSToomas Soome                                   the USB Bus Driver, the caller should not modify
455*f334afcfSToomas Soome                                   its contents.
456*f334afcfSToomas Soome   @param  TableSize               The size, in bytes, of the table LangIDTable.
457*f334afcfSToomas Soome 
458*f334afcfSToomas Soome   @retval EFI_SUCCESS             The support languages were retrieved successfully.
459*f334afcfSToomas Soome 
460*f334afcfSToomas Soome **/
461*f334afcfSToomas Soome typedef
462*f334afcfSToomas Soome EFI_STATUS
463*f334afcfSToomas Soome (EFIAPI *EFI_USB_IO_GET_SUPPORTED_LANGUAGE)(
464*f334afcfSToomas Soome   IN EFI_USB_IO_PROTOCOL            *This,
465*f334afcfSToomas Soome   OUT UINT16                        **LangIDTable,
466*f334afcfSToomas Soome   OUT UINT16                        *TableSize
467*f334afcfSToomas Soome   );
468*f334afcfSToomas Soome 
469*f334afcfSToomas Soome ///
470*f334afcfSToomas Soome /// The EFI_USB_IO_PROTOCOL provides four basic transfers types described
471*f334afcfSToomas Soome /// in the USB 1.1 Specification. These include control transfer, interrupt
472*f334afcfSToomas Soome /// transfer, bulk transfer and isochronous transfer. The EFI_USB_IO_PROTOCOL
473*f334afcfSToomas Soome /// also provides some basic USB device/controller management and configuration
474*f334afcfSToomas Soome /// interfaces. A USB device driver uses the services of this protocol to manage USB devices.
475*f334afcfSToomas Soome ///
476*f334afcfSToomas Soome struct _EFI_USB_IO_PROTOCOL {
477*f334afcfSToomas Soome   //
478*f334afcfSToomas Soome   // IO transfer
479*f334afcfSToomas Soome   //
480*f334afcfSToomas Soome   EFI_USB_IO_CONTROL_TRANSFER              UsbControlTransfer;
481*f334afcfSToomas Soome   EFI_USB_IO_BULK_TRANSFER                 UsbBulkTransfer;
482*f334afcfSToomas Soome   EFI_USB_IO_ASYNC_INTERRUPT_TRANSFER      UsbAsyncInterruptTransfer;
483*f334afcfSToomas Soome   EFI_USB_IO_SYNC_INTERRUPT_TRANSFER       UsbSyncInterruptTransfer;
484*f334afcfSToomas Soome   EFI_USB_IO_ISOCHRONOUS_TRANSFER          UsbIsochronousTransfer;
485*f334afcfSToomas Soome   EFI_USB_IO_ASYNC_ISOCHRONOUS_TRANSFER    UsbAsyncIsochronousTransfer;
486*f334afcfSToomas Soome 
487*f334afcfSToomas Soome   //
488*f334afcfSToomas Soome   // Common device request
489*f334afcfSToomas Soome   //
490*f334afcfSToomas Soome   EFI_USB_IO_GET_DEVICE_DESCRIPTOR         UsbGetDeviceDescriptor;
491*f334afcfSToomas Soome   EFI_USB_IO_GET_CONFIG_DESCRIPTOR         UsbGetConfigDescriptor;
492*f334afcfSToomas Soome   EFI_USB_IO_GET_INTERFACE_DESCRIPTOR      UsbGetInterfaceDescriptor;
493*f334afcfSToomas Soome   EFI_USB_IO_GET_ENDPOINT_DESCRIPTOR       UsbGetEndpointDescriptor;
494*f334afcfSToomas Soome   EFI_USB_IO_GET_STRING_DESCRIPTOR         UsbGetStringDescriptor;
495*f334afcfSToomas Soome   EFI_USB_IO_GET_SUPPORTED_LANGUAGE        UsbGetSupportedLanguages;
496*f334afcfSToomas Soome 
497*f334afcfSToomas Soome   //
498*f334afcfSToomas Soome   // Reset controller's parent port
499*f334afcfSToomas Soome   //
500*f334afcfSToomas Soome   EFI_USB_IO_PORT_RESET                    UsbPortReset;
501*f334afcfSToomas Soome };
502*f334afcfSToomas Soome 
503*f334afcfSToomas Soome extern EFI_GUID  gEfiUsbIoProtocolGuid;
504*f334afcfSToomas Soome 
505*f334afcfSToomas Soome #endif
506