]> git.proxmox.com Git - mirror_edk2.git/blob - EmbeddedPkg/Include/Protocol/UsbDevice.h
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / EmbeddedPkg / Include / Protocol / UsbDevice.h
1 /** @file
2
3 Copyright (c) 2013-2014, ARM Ltd. All rights reserved.<BR>
4
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 **/
8
9 #ifndef __USB_DEVICE_PROTOCOL_H__
10 #define __USB_DEVICE_PROTOCOL_H__
11
12 #include <IndustryStandard/Usb.h>
13
14 extern EFI_GUID gUsbDeviceProtocolGuid;
15
16 /*
17 * Note: This Protocol is just the bare minimum for Android Fastboot. It
18 * only makes sense for devices that only do Bulk Transfers and only have one
19 * endpoint.
20 */
21
22 /*
23 Callback to be called when data is received.
24 Buffer is callee-allocated and it's the caller's responsibility to free it with
25 FreePool.
26
27 @param[in] Size Size in bytes of data.
28 @param[in] Buffer Pointer to data.
29 */
30 typedef
31 VOID
32 (*USB_DEVICE_RX_CALLBACK) (
33 IN UINTN Size,
34 IN VOID *Buffer
35 );
36
37 /*
38 Callback to be called when the host asks for data by sending an IN token
39 (excluding during the data stage of a control transfer).
40 When this function is called, data previously buffered by calling Send() has
41 been sent.
42
43 @param[in]Endpoint Endpoint index, as specified in endpoint descriptors, of
44 the endpoint the IN token was sent to.
45 */
46 typedef
47 VOID
48 (*USB_DEVICE_TX_CALLBACK) (
49 IN UINT8 EndpointIndex
50 );
51
52 /*
53 Put data in the Tx buffer to be sent on the next IN token.
54 Don't call this function again until the TxCallback has been called.
55
56 @param[in]Endpoint Endpoint index, as specified in endpoint descriptors, of
57 the endpoint to send the data from.
58 @param[in]Size Size in bytes of data.
59 @param[in]Buffer Pointer to data.
60
61 @retval EFI_SUCCESS The data was queued successfully.
62 @retval EFI_INVALID_PARAMETER There was an error sending the data.
63 */
64 typedef
65 EFI_STATUS
66 (*USB_DEVICE_SEND) (
67 IN UINT8 EndpointIndex,
68 IN UINTN Size,
69 IN CONST VOID *Buffer
70 );
71
72 /*
73 Restart the USB peripheral controller and respond to enumeration.
74
75 @param[in] DeviceDescriptor pointer to device descriptor
76 @param[in] Descriptors Array of pointers to buffers, where
77 Descriptors[n] contains the response to a
78 GET_DESCRIPTOR request for configuration n. From
79 USB Spec section 9.4.3:
80 "The first interface descriptor follows the
81 configuration descriptor. The endpoint
82 descriptors for the first interface follow the
83 first interface descriptor. If there are
84 additional interfaces, their interface
85 descriptor and endpoint descriptors follow the
86 first interface’s endpoint descriptors".
87
88 The size of each buffer is the TotalLength
89 member of the Configuration Descriptor.
90
91 The size of the array is
92 DeviceDescriptor->NumConfigurations.
93 @param[in]RxCallback See USB_DEVICE_RX_CALLBACK
94 @param[in]TxCallback See USB_DEVICE_TX_CALLBACK
95 */
96 typedef
97 EFI_STATUS
98 (*USB_DEVICE_START) (
99 IN USB_DEVICE_DESCRIPTOR *DeviceDescriptor,
100 IN VOID **Descriptors,
101 IN USB_DEVICE_RX_CALLBACK RxCallback,
102 IN USB_DEVICE_TX_CALLBACK TxCallback
103 );
104
105 struct _USB_DEVICE_PROTOCOL {
106 USB_DEVICE_START Start;
107 USB_DEVICE_SEND Send;
108 };
109
110 typedef struct _USB_DEVICE_PROTOCOL USB_DEVICE_PROTOCOL;
111
112 #endif //ifndef __USB_DEVICE_PROTOCOL_H__