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