]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Protocol/UsbFunctionIo.h
MdePkg FirmwareManagement.h: Fix typo EFI_SECURITY_VIOLATIO
[mirror_edk2.git] / MdePkg / Include / Protocol / UsbFunctionIo.h
CommitLineData
21bd4958
FT
1/** @file\r
2 The USB Function Protocol provides an I/O abstraction for a USB Controller\r
3 operating in Function mode (also commonly referred to as Device, Peripheral,\r
4 or Target mode) and the mechanisms by which the USB Function can communicate\r
5 with the USB Host. It is used by other UEFI drivers or applications to\r
6 perform data transactions and basic USB controller management over a USB\r
7 Function port.\r
8\r
9 This simple protocol only supports USB 2.0 bulk transfers on systems with a\r
10 single configuration and a single interface. It does not support isochronous\r
11 or interrupt transfers, alternate interfaces, or USB 3.0 functionality.\r
12 Future revisions of this protocol may support these or additional features.\r
13\r
1683ecec 14 Copyright (c) 2015 - 2017, Intel Corporation. All rights reserved.<BR>\r
21bd4958
FT
15 This program and the accompanying materials\r
16 are licensed and made available under the terms and conditions of the BSD License\r
17 which accompanies this distribution. The full text of the license may be found at\r
18 http://opensource.org/licenses/bsd-license.php\r
19\r
20 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
21 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
22\r
23**/\r
24\r
25#ifndef __USB_FUNCTION_IO_H__\r
26#define __USB_FUNCTION_IO_H__\r
27\r
28#include <Protocol/UsbIo.h>\r
29\r
30#define EFI_USBFN_IO_PROTOCOL_GUID \\r
31 { \\r
32 0x32d2963a, 0xfe5d, 0x4f30, {0xb6, 0x33, 0x6e, 0x5d, 0xc5, 0x58, 0x3, 0xcc} \\r
33 }\r
34\r
35typedef struct _EFI_USBFN_IO_PROTOCOL EFI_USBFN_IO_PROTOCOL;\r
36\r
37#define EFI_USBFN_IO_PROTOCOL_REVISION 0x00010001\r
38\r
39typedef enum _EFI_USBFN_PORT_TYPE {\r
40 EfiUsbUnknownPort = 0,\r
41 EfiUsbStandardDownstreamPort,\r
42 EfiUsbChargingDownstreamPort,\r
43 EfiUsbDedicatedChargingPort,\r
44 EfiUsbInvalidDedicatedChargingPort\r
45} EFI_USBFN_PORT_TYPE;\r
46\r
47typedef struct {\r
48 EFI_USB_INTERFACE_DESCRIPTOR *InterfaceDescriptor;\r
49 EFI_USB_ENDPOINT_DESCRIPTOR **EndpointDescriptorTable;\r
50} EFI_USB_INTERFACE_INFO;\r
51\r
52typedef struct {\r
53 EFI_USB_CONFIG_DESCRIPTOR *ConfigDescriptor;\r
54 EFI_USB_INTERFACE_INFO **InterfaceInfoTable;\r
55} EFI_USB_CONFIG_INFO;\r
56\r
57typedef struct {\r
58 EFI_USB_DEVICE_DESCRIPTOR *DeviceDescriptor;\r
59 EFI_USB_CONFIG_INFO **ConfigInfoTable;\r
60} EFI_USB_DEVICE_INFO;\r
61\r
62typedef enum _EFI_USB_ENDPOINT_TYPE {\r
63 UsbEndpointControl = 0x00,\r
64 //UsbEndpointIsochronous = 0x01,\r
65 UsbEndpointBulk = 0x02,\r
66 //UsbEndpointInterrupt = 0x03\r
67} EFI_USB_ENDPOINT_TYPE;\r
68\r
69typedef enum _EFI_USBFN_DEVICE_INFO_ID {\r
70 EfiUsbDeviceInfoUnknown = 0,\r
71 EfiUsbDeviceInfoSerialNumber,\r
72 EfiUsbDeviceInfoManufacturerName,\r
73 EfiUsbDeviceInfoProductName\r
74} EFI_USBFN_DEVICE_INFO_ID;\r
75\r
76typedef enum _EFI_USBFN_ENDPOINT_DIRECTION {\r
77 EfiUsbEndpointDirectionHostOut = 0,\r
78 EfiUsbEndpointDirectionHostIn,\r
79 EfiUsbEndpointDirectionDeviceTx = EfiUsbEndpointDirectionHostIn,\r
80 EfiUsbEndpointDirectionDeviceRx = EfiUsbEndpointDirectionHostOut\r
81} EFI_USBFN_ENDPOINT_DIRECTION;\r
82\r
83typedef enum _EFI_USBFN_MESSAGE {\r
84 //\r
85 // Nothing\r
86 //\r
87 EfiUsbMsgNone = 0,\r
88 //\r
89 // SETUP packet is received, returned Buffer contains\r
90 // EFI_USB_DEVICE_REQUEST struct\r
91 //\r
92 EfiUsbMsgSetupPacket,\r
93 //\r
94 // Indicates that some of the requested data has been received from the\r
95 // host. It is the responsibility of the class driver to determine if it\r
96 // needs to wait for any remaining data. Returned Buffer contains\r
97 // EFI_USBFN_TRANSFER_RESULT struct containing endpoint number, transfer\r
98 // status and count of bytes received.\r
99 //\r
100 EfiUsbMsgEndpointStatusChangedRx,\r
101 //\r
102 // Indicates that some of the requested data has been transmitted to the\r
103 // host. It is the responsibility of the class driver to determine if any\r
104 // remaining data needs to be resent. Returned Buffer contains\r
105 // EFI_USBFN_TRANSFER_RESULT struct containing endpoint number, transfer\r
106 // status and count of bytes sent.\r
107 //\r
108 EfiUsbMsgEndpointStatusChangedTx,\r
109 //\r
110 // DETACH bus event signaled\r
111 //\r
112 EfiUsbMsgBusEventDetach,\r
113 //\r
114 // ATTACH bus event signaled\r
115 //\r
116 EfiUsbMsgBusEventAttach,\r
117 //\r
118 // RESET bus event signaled\r
119 //\r
120 EfiUsbMsgBusEventReset,\r
121 //\r
122 // SUSPEND bus event signaled\r
123 //\r
124 EfiUsbMsgBusEventSuspend,\r
125 //\r
126 // RESUME bus event signaled\r
127 //\r
128 EfiUsbMsgBusEventResume,\r
129 //\r
130 // Bus speed updated, returned buffer indicated bus speed using\r
131 // following enumeration named EFI_USB_BUS_SPEED\r
132 //\r
133 EfiUsbMsgBusEventSpeed\r
134} EFI_USBFN_MESSAGE;\r
135\r
136typedef enum _EFI_USBFN_TRANSFER_STATUS {\r
137 UsbTransferStatusUnknown = 0,\r
138 UsbTransferStatusComplete,\r
139 UsbTransferStatusAborted,\r
140 UsbTransferStatusActive,\r
141 UsbTransferStatusNone\r
142} EFI_USBFN_TRANSFER_STATUS;\r
143\r
144typedef struct _EFI_USBFN_TRANSFER_RESULT {\r
145 UINTN BytesTransferred;\r
146 EFI_USBFN_TRANSFER_STATUS TransferStatus;\r
147 UINT8 EndpointIndex;\r
148 EFI_USBFN_ENDPOINT_DIRECTION Direction;\r
149 VOID *Buffer;\r
150} EFI_USBFN_TRANSFER_RESULT;\r
151\r
152typedef enum _EFI_USB_BUS_SPEED {\r
153 UsbBusSpeedUnknown = 0,\r
154 UsbBusSpeedLow,\r
155 UsbBusSpeedFull,\r
156 UsbBusSpeedHigh,\r
157 UsbBusSpeedSuper,\r
158 UsbBusSpeedMaximum = UsbBusSpeedSuper\r
159} EFI_USB_BUS_SPEED;\r
160\r
161typedef union _EFI_USBFN_MESSAGE_PAYLOAD {\r
162 EFI_USB_DEVICE_REQUEST udr;\r
163 EFI_USBFN_TRANSFER_RESULT utr;\r
164 EFI_USB_BUS_SPEED ubs;\r
165} EFI_USBFN_MESSAGE_PAYLOAD;\r
166\r
167typedef enum _EFI_USBFN_POLICY_TYPE {\r
168 EfiUsbPolicyUndefined = 0,\r
169 EfiUsbPolicyMaxTransactionSize,\r
170 EfiUsbPolicyZeroLengthTerminationSupport,\r
171 EfiUsbPolicyZeroLengthTermination\r
172} EFI_USBFN_POLICY_TYPE;\r
173\r
174/**\r
175 Returns information about what USB port type was attached.\r
176\r
177 @param[in] This A pointer to the EFI_USBFN_IO_PROTOCOL instance.\r
178 @param[out] PortType Returns the USB port type.\r
179\r
180 @retval EFI_SUCCESS The function returned successfully.\r
181 @retval EFI_INVALID_PARAMETER A parameter is invalid.\r
182 @retval EFI_DEVICE_ERROR The physical device reported an error.\r
183 @retval EFI_NOT_READY The physical device is busy or not ready to\r
184 process this request or there is no USB port\r
185 attached to the device.\r
186\r
187**/\r
188typedef\r
189EFI_STATUS\r
190(EFIAPI *EFI_USBFN_IO_DETECT_PORT) (\r
191 IN EFI_USBFN_IO_PROTOCOL *This,\r
192 OUT EFI_USBFN_PORT_TYPE *PortType\r
193 );\r
194\r
195/**\r
196 Configures endpoints based on supplied device and configuration descriptors.\r
197\r
198 Assuming that the hardware has already been initialized, this function configures\r
199 the endpoints using the device information supplied by DeviceInfo, activates the\r
200 port, and starts receiving USB events.\r
201\r
202 This function must ignore the bMaxPacketSize0field of the Standard Device Descriptor\r
203 and the wMaxPacketSize field of the Standard Endpoint Descriptor that are made\r
204 available through DeviceInfo.\r
205\r
206 @param[in] This A pointer to the EFI_USBFN_IO_PROTOCOL instance.\r
207 @param[out] DeviceInfo A pointer to EFI_USBFN_DEVICE_INFO instance.\r
208\r
209 @retval EFI_SUCCESS The function returned successfully.\r
210 @retval EFI_INVALID_PARAMETER A parameter is invalid.\r
211 @retval EFI_DEVICE_ERROR The physical device reported an error.\r
212 @retval EFI_NOT_READY The physical device is busy or not ready to process\r
213 this request.\r
214 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to lack of\r
215 resources.\r
216\r
217**/\r
218typedef\r
219EFI_STATUS\r
220(EFIAPI *EFI_USBFN_IO_CONFIGURE_ENABLE_ENDPOINTS) (\r
221 IN EFI_USBFN_IO_PROTOCOL *This,\r
222 OUT EFI_USB_DEVICE_INFO *DeviceInfo\r
223 );\r
224\r
225/**\r
226 Returns the maximum packet size of the specified endpoint type for the supplied\r
227 bus speed.\r
228\r
229 If the BusSpeed is UsbBusSpeedUnknown, the maximum speed the underlying controller\r
230 supports is assumed.\r
231\r
232 This protocol currently does not support isochronous or interrupt transfers. Future\r
233 revisions of this protocol may eventually support it.\r
234\r
235 @param[in] This A pointer to the EFI_USBFN_IO_PROTOCOLinstance.\r
236 @param[in] EndpointType Endpoint type as defined as EFI_USB_ENDPOINT_TYPE.\r
237 @param[in] BusSpeed Bus speed as defined as EFI_USB_BUS_SPEED.\r
238 @param[out] MaxPacketSize The maximum packet size, in bytes, of the specified\r
239 endpoint type.\r
240\r
241 @retval EFI_SUCCESS The function returned successfully.\r
242 @retval EFI_INVALID_PARAMETER A parameter is invalid.\r
243 @retval EFI_DEVICE_ERROR The physical device reported an error.\r
244 @retval EFI_NOT_READY The physical device is busy or not ready to process\r
245 this request.\r
246\r
247**/\r
248typedef\r
249EFI_STATUS\r
250(EFIAPI *EFI_USBFN_IO_GET_ENDPOINT_MAXPACKET_SIZE) (\r
251 IN EFI_USBFN_IO_PROTOCOL *This,\r
252 IN EFI_USB_ENDPOINT_TYPE EndpointType,\r
253 IN EFI_USB_BUS_SPEED BusSpeed,\r
254 OUT UINT16 *MaxPacketSize\r
255 );\r
256\r
257/**\r
258 Returns device specific information based on the supplied identifier as a Unicode string.\r
259\r
260 If the supplied Buffer isn't large enough, or is NULL, the method fails with\r
261 EFI_BUFFER_TOO_SMALL and the required size is returned through BufferSize. All returned\r
262 strings are in Unicode format.\r
263\r
264 An Id of EfiUsbDeviceInfoUnknown is treated as an invalid parameter.\r
265\r
266 @param[in] This A pointer to the EFI_USBFN_IO_PROTOCOLinstance.\r
267 @param[in] Id The requested information id.\r
268\r
269\r
270 @param[in] BufferSize On input, the size of the Buffer in bytes. On output, the\r
271 amount of data returned in Buffer in bytes.\r
272 @param[out] Buffer A pointer to a buffer to returnthe requested information\r
273 as a Unicode string.\r
274\r
275 @retval EFI_SUCCESS The function returned successfully.\r
1683ecec
SZ
276 @retval EFI_INVALID_PARAMETER One or more of the following conditions is TRUE:\r
277 BufferSize is NULL.\r
278 *BufferSize is not 0 and Buffer is NULL.\r
279 Id in invalid.\r
21bd4958 280 @retval EFI_DEVICE_ERROR The physical device reported an error.\r
1683ecec
SZ
281 @retval EFI_BUFFER_TOO_SMALL The buffer is too small to hold the buffer.\r
282 *BufferSize has been updated with the size needed to hold the request string.\r
21bd4958
FT
283\r
284**/\r
285typedef\r
286EFI_STATUS\r
287(EFIAPI *EFI_USBFN_IO_GET_DEVICE_INFO) (\r
288 IN EFI_USBFN_IO_PROTOCOL *This,\r
289 IN EFI_USBFN_DEVICE_INFO_ID Id,\r
290 IN OUT UINTN *BufferSize,\r
291 OUT VOID *Buffer OPTIONAL\r
292);\r
293\r
294/**\r
295 Returns the vendor-id and product-id of the device.\r
296\r
297 @param[in] This A pointer to the EFI_USBFN_IO_PROTOCOL instance.\r
298 @param[out] Vid Returned vendor-id of the device.\r
299 @param[out] Pid Returned product-id of the device.\r
300\r
301 @retval EFI_SUCCESS The function returned successfully.\r
302 @retval EFI_INVALID_PARAMETER A parameter is invalid.\r
303 @retval EFI_NOT_FOUND Unable to return the vendor-id or the product-id.\r
304\r
305**/\r
306typedef\r
307EFI_STATUS\r
308(EFIAPI *EFI_USBFN_IO_GET_VENDOR_ID_PRODUCT_ID) (\r
309 IN EFI_USBFN_IO_PROTOCOL *This,\r
310 OUT UINT16 *Vid,\r
311 OUT UINT16 *Pid\r
312);\r
313\r
314/**\r
315 Aborts the transfer on the specified endpoint.\r
316\r
317 This function should fail with EFI_INVALID_PARAMETER if the specified direction\r
318 is incorrect for the endpoint.\r
319\r
320 @param[in] This A pointer to the EFI_USBFN_IO_PROTOCOL instance.\r
321 @param[in] EndpointIndex Indicates the endpoint on which the ongoing transfer\r
322 needs to be canceled.\r
323 @param[in] Direction Direction of the endpoint.\r
324\r
325 @retval EFI_SUCCESS The function returned successfully.\r
326 @retval EFI_INVALID_PARAMETER A parameter is invalid.\r
327 @retval EFI_DEVICE_ERROR The physical device reported an error.\r
328 @retval EFI_NOT_READY The physical device is busy or not ready to process\r
329 this request.\r
330\r
331**/\r
332typedef\r
333EFI_STATUS\r
334(EFIAPI *EFI_USBFN_IO_ABORT_TRANSFER) (\r
335 IN EFI_USBFN_IO_PROTOCOL *This,\r
336 IN UINT8 EndpointIndex,\r
337 IN EFI_USBFN_ENDPOINT_DIRECTION Direction\r
338);\r
339\r
340/**\r
341 Returns the stall state on the specified endpoint.\r
342\r
343 This function should fail with EFI_INVALID_PARAMETER if the specified direction\r
344 is incorrect for the endpoint.\r
345\r
346 @param[in] This A pointer to the EFI_USBFN_IO_PROTOCOL instance.\r
347 @param[in] EndpointIndex Indicates the endpoint.\r
348 @param[in] Direction Direction of the endpoint.\r
349 @param[in, out] State Boolean, true value indicates that the endpoint\r
350 is in a stalled state, false otherwise.\r
351\r
352 @retval EFI_SUCCESS The function returned successfully.\r
353 @retval EFI_INVALID_PARAMETER A parameter is invalid.\r
354 @retval EFI_DEVICE_ERROR The physical device reported an error.\r
355 @retval EFI_NOT_READY The physical device is busy or not ready to process\r
356 this request.\r
357\r
358**/\r
359typedef\r
360EFI_STATUS\r
361(EFIAPI *EFI_USBFN_IO_GET_ENDPOINT_STALL_STATE) (\r
362 IN EFI_USBFN_IO_PROTOCOL *This,\r
363 IN UINT8 EndpointIndex,\r
364 IN EFI_USBFN_ENDPOINT_DIRECTION Direction,\r
365 IN OUT BOOLEAN *State\r
366);\r
367\r
368/**\r
369 Sets or clears the stall state on the specified endpoint.\r
370\r
371 This function should fail with EFI_INVALID_PARAMETER if the specified direction\r
372 is incorrect for the endpoint.\r
373\r
374 @param[in] This A pointer to the EFI_USBFN_IO_PROTOCOL instance.\r
375 @param[in] EndpointIndex Indicates the endpoint.\r
376 @param[in] Direction Direction of the endpoint.\r
377 @param[in] State Requested stall state on the specified endpoint.\r
378 True value causes the endpoint to stall; false\r
379 value clears an existing stall.\r
380\r
381 @retval EFI_SUCCESS The function returned successfully.\r
382 @retval EFI_INVALID_PARAMETER A parameter is invalid.\r
383 @retval EFI_DEVICE_ERROR The physical device reported an error.\r
384 @retval EFI_NOT_READY The physical device is busy or not ready to process\r
385 this request.\r
386\r
387**/\r
388typedef\r
389EFI_STATUS\r
390(EFIAPI *EFI_USBFN_IO_SET_ENDPOINT_STALL_STATE) (\r
391 IN EFI_USBFN_IO_PROTOCOL *This,\r
392 IN UINT8 EndpointIndex,\r
393 IN EFI_USBFN_ENDPOINT_DIRECTION Direction,\r
394 IN OUT BOOLEAN *State\r
395);\r
396\r
397/**\r
398 This function is called repeatedly to get information on USB bus states,\r
399 receive-completion and transmit-completion events on the endpoints, and\r
400 notification on setup packet on endpoint 0.\r
401\r
402 A class driver must call EFI_USBFN_IO_PROTOCOL.EventHandler()repeatedly\r
403 to receive updates on the transfer status and number of bytes transferred\r
404 on various endpoints.\r
405\r
406 @param[in] This A pointer to the EFI_USBFN_IO_PROTOCOL instance.\r
407 @param[out] Message Indicates the event that initiated this notification.\r
408 @param[in, out] PayloadSize On input, the size of the memory pointed by\r
409 Payload. On output, the amount ofdata returned\r
410 in Payload.\r
411 @param[out] Payload A pointer to EFI_USBFN_MESSAGE_PAYLOAD instance\r
412 to return additional payload for current message.\r
413\r
414 @retval EFI_SUCCESS The function returned successfully.\r
415 @retval EFI_INVALID_PARAMETER A parameter is invalid.\r
416 @retval EFI_DEVICE_ERROR The physical device reported an error.\r
417 @retval EFI_NOT_READY The physical device is busy or not ready to process\r
418 this request.\r
419 @retval EFI_BUFFER_TOO_SMALL The Supplied buffer is not large enough to hold\r
420 the message payload.\r
421\r
422**/\r
423typedef\r
424EFI_STATUS\r
425(EFIAPI *EFI_USBFN_IO_EVENTHANDLER) (\r
426 IN EFI_USBFN_IO_PROTOCOL *This,\r
427 OUT EFI_USBFN_MESSAGE *Message,\r
428 IN OUT UINTN *PayloadSize,\r
429 OUT EFI_USBFN_MESSAGE_PAYLOAD *Payload\r
430);\r
431\r
432/**\r
433 This function handles transferring data to or from the host on the specified\r
434 endpoint, depending on the direction specified.\r
435\r
436 A class driver must call EFI_USBFN_IO_PROTOCOL.EventHandler() repeatedly to\r
437 receive updates on the transfer status and the number of bytes transferred on\r
438 various endpoints. Upon an update of the transfer status, the Buffer field of\r
439 the EFI_USBFN_TRANSFER_RESULT structure (as described in the function description\r
440 for EFI_USBFN_IO_PROTOCOL.EventHandler()) must be initialized with the Buffer\r
441 pointer that was supplied to this method.\r
442\r
443 The overview of the call sequence is illustrated in the Figure 54.\r
444\r
445 This function should fail with EFI_INVALID_PARAMETER if the specified direction\r
446 is incorrect for the endpoint.\r
447\r
448 @param[in] This A pointer to the EFI_USBFN_IO_PROTOCOL instance.\r
449 @param[in] EndpointIndex Indicates the endpoint on which TX or RX transfer\r
450 needs to take place.\r
451 @param[in] Direction Direction of the endpoint.\r
452 @param[in, out] BufferSize If Direction is EfiUsbEndpointDirectionDeviceRx:\r
453 On input, the size of the Bufferin bytes.\r
454 On output, the amount of data returned in Buffer\r
455 in bytes.\r
456 If Direction is EfiUsbEndpointDirectionDeviceTx:\r
457 On input, the size of the Bufferin bytes.\r
458 On output, the amount of data transmitted in bytes.\r
459 @param[in, out] Buffer If Direction is EfiUsbEndpointDirectionDeviceRx:\r
460 The Buffer to return the received data.\r
461 If Directionis EfiUsbEndpointDirectionDeviceTx:\r
462 The Buffer that contains the data to be transmitted.\r
463\r
464 @retval EFI_SUCCESS The function returned successfully.\r
465 @retval EFI_INVALID_PARAMETER A parameter is invalid.\r
466 @retval EFI_DEVICE_ERROR The physical device reported an error.\r
467 @retval EFI_NOT_READY The physical device is busy or not ready to process\r
468 this request.\r
469\r
470**/\r
471typedef\r
472EFI_STATUS\r
473(EFIAPI *EFI_USBFN_IO_TRANSFER) (\r
474 IN EFI_USBFN_IO_PROTOCOL *This,\r
475 IN UINT8 EndpointIndex,\r
476 IN EFI_USBFN_ENDPOINT_DIRECTION Direction,\r
477 IN OUT UINTN *BufferSize,\r
478 IN OUT VOID *Buffer\r
479);\r
480\r
481/**\r
482 Returns the maximum supported transfer size.\r
483\r
484 Returns the maximum number of bytes that the underlying controller can accommodate\r
485 in a single transfer.\r
486\r
487 @param[in] This A pointer to the EFI_USBFN_IO_PROTOCOL instance.\r
488 @param[out] MaxTransferSize The maximum supported transfer size, in bytes.\r
489\r
490 @retval EFI_SUCCESS The function returned successfully.\r
491 @retval EFI_INVALID_PARAMETER A parameter is invalid.\r
492 @retval EFI_DEVICE_ERROR The physical device reported an error.\r
493 @retval EFI_NOT_READY The physical device is busy or not ready to process\r
494 this request.\r
495\r
496**/\r
497typedef\r
498EFI_STATUS\r
499(EFIAPI *EFI_USBFN_IO_GET_MAXTRANSFER_SIZE) (\r
500 IN EFI_USBFN_IO_PROTOCOL *This,\r
501 OUT UINTN *MaxTransferSize\r
502 );\r
503\r
504/**\r
505 Allocates a transfer buffer of the specified sizethat satisfies the controller\r
506 requirements.\r
507\r
508 The AllocateTransferBuffer() function allocates a memory region of Size bytes and\r
509 returns the address of the allocated memory that satisfies the underlying controller\r
510 requirements in the location referenced by Buffer.\r
511\r
512 The allocated transfer buffer must be freed using a matching call to\r
513 EFI_USBFN_IO_PROTOCOL.FreeTransferBuffer()function.\r
514\r
515 @param[in] This A pointer to the EFI_USBFN_IO_PROTOCOL instance.\r
516 @param[in] Size The number of bytes to allocate for the transfer buffer.\r
517 @param[out] Buffer A pointer to a pointer to the allocated buffer if the\r
518 call succeeds; undefined otherwise.\r
519\r
520 @retval EFI_SUCCESS The function returned successfully.\r
521 @retval EFI_INVALID_PARAMETER A parameter is invalid.\r
522 @retval EFI_OUT_OF_RESOURCES The requested transfer buffer could not be allocated.\r
523\r
524**/\r
525typedef\r
526EFI_STATUS\r
527(EFIAPI *EFI_USBFN_IO_ALLOCATE_TRANSFER_BUFFER) (\r
528 IN EFI_USBFN_IO_PROTOCOL *This,\r
529 IN UINTN Size,\r
530 OUT VOID **Buffer\r
531 );\r
532\r
533/**\r
534 Deallocates the memory allocated for the transfer buffer by the\r
535 EFI_USBFN_IO_PROTOCOL.AllocateTransferBuffer() function.\r
536\r
537 The EFI_USBFN_IO_PROTOCOL.FreeTransferBuffer() function deallocates the\r
538 memory specified by Buffer. The Buffer that is freed must have been allocated\r
539 by EFI_USBFN_IO_PROTOCOL.AllocateTransferBuffer().\r
540\r
541 @param[in] This A pointer to the EFI_USBFN_IO_PROTOCOL instance.\r
542 @param[in] Buffer A pointer to the transfer buffer to deallocate.\r
543\r
544 @retval EFI_SUCCESS The function returned successfully.\r
545 @retval EFI_INVALID_PARAMETER A parameter is invalid.\r
546\r
547**/\r
548typedef\r
549EFI_STATUS\r
550(EFIAPI *EFI_USBFN_IO_FREE_TRANSFER_BUFFER) (\r
551 IN EFI_USBFN_IO_PROTOCOL *This,\r
552 IN VOID *Buffer\r
553 );\r
554\r
555/**\r
556 This function supplies power to the USB controller if needed and initializes\r
557 the hardware and the internal data structures. The port must not be activated\r
558 by this function.\r
559\r
560 @param[in] This A pointer to the EFI_USBFN_IO_PROTOCOL instance.\r
561\r
562 @retval EFI_SUCCESS The function returned successfully.\r
563 @retval EFI_INVALID_PARAMETER A parameter is invalid.\r
564 @retval EFI_DEVICE_ERROR The physical device reported an error.\r
565\r
566**/\r
567typedef\r
568EFI_STATUS\r
569(EFIAPI *EFI_USBFN_IO_START_CONTROLLER) (\r
570 IN EFI_USBFN_IO_PROTOCOL *This\r
571 );\r
572\r
573/**\r
574 This function stops the USB hardware device.\r
575\r
576 @param[in] This A pointer to the EFI_USBFN_IO_PROTOCOL instance.\r
577\r
578 @retval EFI_SUCCESS The function returned successfully.\r
579 @retval EFI_INVALID_PARAMETER A parameter is invalid.\r
580 @retval EFI_DEVICE_ERROR The physical device reported an error.\r
581\r
582**/\r
583typedef\r
584EFI_STATUS\r
585(EFIAPI *EFI_USBFN_IO_STOP_CONTROLLER) (\r
586 IN EFI_USBFN_IO_PROTOCOL *This\r
587 );\r
588\r
589/**\r
590 This function sets the configuration policy for the specified non-control\r
591 endpoint.\r
592\r
593 This function can only be called before EFI_USBFN_IO_PROTOCOL.StartController()\r
594 or after EFI_USBFN_IO_PROTOCOL.StopController() has been called.\r
595\r
596 @param[in] This A pointer to the EFI_USBFN_IO_PROTOCOL instance.\r
597 @param[in] EndpointIndex Indicates the non-control endpoint for which the\r
598 policy needs to be set.\r
599 @param[in] Direction Direction of the endpoint.\r
600 @param[in] PolicyType Policy type the user is trying to set for the\r
601 specified non-control endpoint.\r
602 @param[in] BufferSize The size of the Bufferin bytes.\r
603 @param[in] Buffer The new value for the policy parameter that\r
604 PolicyType specifies.\r
605\r
606 @retval EFI_SUCCESS The function returned successfully.\r
607 @retval EFI_INVALID_PARAMETER A parameter is invalid.\r
608 @retval EFI_DEVICE_ERROR The physical device reported an error.\r
609 @retval EFI_UNSUPPORTED Changing this policy value is not supported.\r
610\r
611**/\r
612typedef\r
613EFI_STATUS\r
614(EFIAPI *EFI_USBFN_IO_SET_ENDPOINT_POLICY) (\r
615 IN EFI_USBFN_IO_PROTOCOL *This,\r
616 IN UINT8 EndpointIndex,\r
617 IN EFI_USBFN_ENDPOINT_DIRECTION Direction,\r
618 IN EFI_USBFN_POLICY_TYPE PolicyType,\r
619 IN UINTN BufferSize,\r
620 IN VOID *Buffer\r
621 );\r
622\r
623/**\r
624 This function sets the configuration policy for the specified non-control\r
625 endpoint.\r
626\r
627 This function can only be called before EFI_USBFN_IO_PROTOCOL.StartController()\r
628 or after EFI_USBFN_IO_PROTOCOL.StopController() has been called.\r
629\r
630 @param[in] This A pointer to the EFI_USBFN_IO_PROTOCOL instance.\r
631 @param[in] EndpointIndex Indicates the non-control endpoint for which the\r
632 policy needs to be set.\r
633 @param[in] Direction Direction of the endpoint.\r
634 @param[in] PolicyType Policy type the user is trying to retrieve for\r
635 the specified non-control endpoint.\r
636 @param[in, out] BufferSize On input, the size of Bufferin bytes. On output,\r
637 the amount of data returned in Bufferin bytes.\r
638 @param[in, out] Buffer A pointer to a buffer to return requested endpoint\r
639 policy value.\r
640\r
641 @retval EFI_SUCCESS The function returned successfully.\r
642 @retval EFI_INVALID_PARAMETER A parameter is invalid.\r
643 @retval EFI_DEVICE_ERROR The specified policy value is not supported.\r
644 @retval EFI_BUFFER_TOO_SMALL Supplied buffer is not large enough to hold requested\r
645 policy value.\r
646\r
647**/\r
648typedef\r
649EFI_STATUS\r
650(EFIAPI *EFI_USBFN_IO_GET_ENDPOINT_POLICY) (\r
651 IN EFI_USBFN_IO_PROTOCOL *This,\r
652 IN UINT8 EndpointIndex,\r
653 IN EFI_USBFN_ENDPOINT_DIRECTION Direction,\r
654 IN EFI_USBFN_POLICY_TYPE PolicyType,\r
655 IN OUT UINTN *BufferSize,\r
656 IN OUT VOID *Buffer\r
657 );\r
658\r
659///\r
660/// The EFI_USBFN_IO_PROTOCOL provides basic data transactions and basic USB\r
661/// controller management for a USB Function port.\r
662///\r
663struct _EFI_USBFN_IO_PROTOCOL {\r
664 UINT32 Revision;\r
665 EFI_USBFN_IO_DETECT_PORT DetectPort;\r
666 EFI_USBFN_IO_CONFIGURE_ENABLE_ENDPOINTS ConfigureEnableEndpoints;\r
667 EFI_USBFN_IO_GET_ENDPOINT_MAXPACKET_SIZE GetEndpointMaxPacketSize;\r
668 EFI_USBFN_IO_GET_DEVICE_INFO GetDeviceInfo;\r
669 EFI_USBFN_IO_GET_VENDOR_ID_PRODUCT_ID GetVendorIdProductId;\r
670 EFI_USBFN_IO_ABORT_TRANSFER AbortTransfer;\r
671 EFI_USBFN_IO_GET_ENDPOINT_STALL_STATE GetEndpointStallState;\r
672 EFI_USBFN_IO_SET_ENDPOINT_STALL_STATE SetEndpointStallState;\r
673 EFI_USBFN_IO_EVENTHANDLER EventHandler;\r
674 EFI_USBFN_IO_TRANSFER Transfer;\r
675 EFI_USBFN_IO_GET_MAXTRANSFER_SIZE GetMaxTransferSize;\r
676 EFI_USBFN_IO_ALLOCATE_TRANSFER_BUFFER AllocateTransferBuffer;\r
677 EFI_USBFN_IO_FREE_TRANSFER_BUFFER FreeTransferBuffer;\r
678 EFI_USBFN_IO_START_CONTROLLER StartController;\r
679 EFI_USBFN_IO_STOP_CONTROLLER StopController;\r
680 EFI_USBFN_IO_SET_ENDPOINT_POLICY SetEndpointPolicy;\r
681 EFI_USBFN_IO_GET_ENDPOINT_POLICY GetEndpointPolicy;\r
682};\r
683\r
684extern EFI_GUID gEfiUsbFunctionIoProtocolGuid;\r
685\r
686#endif\r
687\r