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