]>
Commit | Line | Data |
---|---|---|
4b1bf81c | 1 | /** @file\r |
2 | Usb Peim definition.\r | |
3 | \r | |
506560e7 | 4 | Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved. <BR>\r |
4b1bf81c | 5 | \r |
6 | This program and the accompanying materials\r | |
7 | are licensed and made available under the terms and conditions\r | |
8 | of the BSD License which accompanies this distribution. The\r | |
9 | full text of the license may be found at\r | |
10 | http://opensource.org/licenses/bsd-license.php\r | |
11 | \r | |
12 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
13 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
14 | \r | |
15 | **/\r | |
16 | \r | |
17 | #ifndef _PEI_USB_PEIM_H_\r | |
18 | #define _PEI_USB_PEIM_H_\r | |
19 | \r | |
20 | \r | |
21 | #include <PiPei.h>\r | |
22 | \r | |
23 | #include <Ppi/UsbHostController.h>\r | |
24 | #include <Ppi/Usb2HostController.h>\r | |
25 | #include <Ppi/UsbIo.h>\r | |
26 | \r | |
27 | #include <Library/DebugLib.h>\r | |
28 | #include <Library/PeimEntryPoint.h>\r | |
29 | #include <Library/PeiServicesLib.h>\r | |
30 | #include <Library/BaseMemoryLib.h>\r | |
31 | #include <Library/TimerLib.h>\r | |
32 | #include <Library/PcdLib.h>\r | |
33 | \r | |
34 | #include <IndustryStandard/Usb.h>\r | |
35 | \r | |
36 | #define MAX_ROOT_PORT 2\r | |
8a718ba9 | 37 | #define MAX_INTERFACE 8\r |
4b1bf81c | 38 | #define MAX_ENDPOINT 16\r |
39 | \r | |
40 | #define USB_SLOW_SPEED_DEVICE 0x01\r | |
41 | #define USB_FULL_SPEED_DEVICE 0x02\r | |
42 | \r | |
43 | #define PEI_USB_DEVICE_SIGNATURE SIGNATURE_32 ('U', 's', 'b', 'D')\r | |
44 | typedef struct {\r | |
45 | UINTN Signature;\r | |
46 | PEI_USB_IO_PPI UsbIoPpi;\r | |
47 | EFI_PEI_PPI_DESCRIPTOR UsbIoPpiList;\r | |
48 | UINT8 DeviceAddress;\r | |
49 | UINT8 MaxPacketSize0;\r | |
50 | UINT8 DeviceSpeed;\r | |
4b1bf81c | 51 | UINT8 IsHub;\r |
506560e7 | 52 | UINT16 DataToggle;\r |
4b1bf81c | 53 | UINT8 DownStreamPortNo;\r |
506560e7 | 54 | UINT8 Reserved; // Padding for IPF\r |
4b1bf81c | 55 | UINTN AllocateAddress;\r |
56 | PEI_USB_HOST_CONTROLLER_PPI *UsbHcPpi;\r | |
57 | PEI_USB2_HOST_CONTROLLER_PPI *Usb2HcPpi;\r | |
58 | UINT8 ConfigurationData[1024];\r | |
59 | EFI_USB_CONFIG_DESCRIPTOR *ConfigDesc;\r | |
60 | EFI_USB_INTERFACE_DESCRIPTOR *InterfaceDesc;\r | |
8a718ba9 | 61 | EFI_USB_INTERFACE_DESCRIPTOR *InterfaceDescList[MAX_INTERFACE];\r |
4b1bf81c | 62 | EFI_USB_ENDPOINT_DESCRIPTOR *EndpointDesc[MAX_ENDPOINT];\r |
8a718ba9 | 63 | EFI_USB_ENDPOINT_DESCRIPTOR *EndpointDescList[MAX_INTERFACE][MAX_ENDPOINT];\r |
4b1bf81c | 64 | EFI_USB2_HC_TRANSACTION_TRANSLATOR Translator; \r |
65 | } PEI_USB_DEVICE;\r | |
66 | \r | |
67 | #define PEI_USB_DEVICE_FROM_THIS(a) CR (a, PEI_USB_DEVICE, UsbIoPpi, PEI_USB_DEVICE_SIGNATURE)\r | |
68 | \r | |
69 | \r | |
70 | /**\r | |
71 | Submits control transfer to a target USB device.\r | |
72 | \r | |
73 | @param PeiServices The pointer of EFI_PEI_SERVICES.\r | |
74 | @param This The pointer of PEI_USB_IO_PPI.\r | |
75 | @param Request USB device request to send.\r | |
76 | @param Direction Specifies the data direction for the data stage.\r | |
ca243131 FT |
77 | @param Timeout Indicates the maximum timeout, in millisecond. If Timeout\r |
78 | is 0, then the caller must wait for the function to be\r | |
79 | completed until EFI_SUCCESS or EFI_DEVICE_ERROR is returned.\r | |
4b1bf81c | 80 | @param Data Data buffer to be transmitted or received from USB device.\r |
81 | @param DataLength The size (in bytes) of the data buffer.\r | |
82 | \r | |
83 | @retval EFI_SUCCESS Transfer was completed successfully.\r | |
84 | @retval EFI_OUT_OF_RESOURCES The transfer failed due to lack of resources.\r | |
85 | @retval EFI_INVALID_PARAMETER Some parameters are invalid.\r | |
86 | @retval EFI_TIMEOUT Transfer failed due to timeout.\r | |
87 | @retval EFI_DEVICE_ERROR Transfer failed due to host controller or device error.\r | |
88 | \r | |
89 | **/\r | |
90 | EFI_STATUS\r | |
91 | EFIAPI\r | |
92 | PeiUsbControlTransfer (\r | |
93 | IN EFI_PEI_SERVICES **PeiServices,\r | |
94 | IN PEI_USB_IO_PPI *This,\r | |
95 | IN EFI_USB_DEVICE_REQUEST *Request,\r | |
96 | IN EFI_USB_DATA_DIRECTION Direction,\r | |
97 | IN UINT32 Timeout,\r | |
98 | IN OUT VOID *Data, OPTIONAL\r | |
99 | IN UINTN DataLength OPTIONAL\r | |
100 | );\r | |
101 | \r | |
102 | /**\r | |
103 | Submits bulk transfer to a bulk endpoint of a USB device.\r | |
104 | \r | |
105 | @param PeiServices The pointer of EFI_PEI_SERVICES.\r | |
106 | @param This The pointer of PEI_USB_IO_PPI.\r | |
107 | @param DeviceEndpoint Endpoint number and its direction in bit 7.\r | |
108 | @param Data A pointer to the buffer of data to transmit \r | |
109 | from or receive into.\r | |
110 | @param DataLength The lenght of the data buffer.\r | |
111 | @param Timeout Indicates the maximum time, in millisecond, which the\r | |
ca243131 FT |
112 | transfer is allowed to complete. If Timeout is 0, then\r |
113 | the caller must wait for the function to be completed\r | |
114 | until EFI_SUCCESS or EFI_DEVICE_ERROR is returned.\r | |
4b1bf81c | 115 | \r |
116 | @retval EFI_SUCCESS The transfer was completed successfully.\r | |
117 | @retval EFI_OUT_OF_RESOURCES The transfer failed due to lack of resource.\r | |
118 | @retval EFI_INVALID_PARAMETER Parameters are invalid.\r | |
119 | @retval EFI_TIMEOUT The transfer failed due to timeout.\r | |
120 | @retval EFI_DEVICE_ERROR The transfer failed due to host controller error.\r | |
121 | \r | |
122 | **/\r | |
123 | EFI_STATUS\r | |
124 | EFIAPI\r | |
125 | PeiUsbBulkTransfer (\r | |
126 | IN EFI_PEI_SERVICES **PeiServices,\r | |
127 | IN PEI_USB_IO_PPI *This,\r | |
128 | IN UINT8 DeviceEndpoint,\r | |
129 | IN OUT VOID *Data,\r | |
130 | IN OUT UINTN *DataLength,\r | |
131 | IN UINTN Timeout\r | |
132 | );\r | |
133 | \r | |
134 | /**\r | |
135 | Get the usb interface descriptor.\r | |
136 | \r | |
137 | @param PeiServices General-purpose services that are available to every PEIM.\r | |
138 | @param This Indicates the PEI_USB_IO_PPI instance.\r | |
139 | @param InterfaceDescriptor Request interface descriptor.\r | |
140 | \r | |
141 | \r | |
142 | @retval EFI_SUCCESS Usb interface descriptor is obtained successfully.\r | |
143 | \r | |
144 | **/\r | |
145 | EFI_STATUS\r | |
146 | EFIAPI\r | |
147 | PeiUsbGetInterfaceDescriptor (\r | |
148 | IN EFI_PEI_SERVICES **PeiServices,\r | |
149 | IN PEI_USB_IO_PPI *This,\r | |
150 | OUT EFI_USB_INTERFACE_DESCRIPTOR **InterfaceDescriptor\r | |
151 | );\r | |
152 | \r | |
153 | /**\r | |
154 | Get the usb endpoint descriptor.\r | |
155 | \r | |
156 | @param PeiServices General-purpose services that are available to every PEIM.\r | |
157 | @param This Indicates the PEI_USB_IO_PPI instance.\r | |
158 | @param EndpointIndex The valid index of the specified endpoint.\r | |
159 | @param EndpointDescriptor Request endpoint descriptor.\r | |
160 | \r | |
161 | @retval EFI_SUCCESS Usb endpoint descriptor is obtained successfully.\r | |
162 | @retval EFI_NOT_FOUND Usb endpoint descriptor is NOT found.\r | |
163 | \r | |
164 | **/\r | |
165 | EFI_STATUS\r | |
166 | EFIAPI\r | |
167 | PeiUsbGetEndpointDescriptor (\r | |
168 | IN EFI_PEI_SERVICES **PeiServices,\r | |
169 | IN PEI_USB_IO_PPI *This,\r | |
170 | IN UINT8 EndpointIndex,\r | |
171 | OUT EFI_USB_ENDPOINT_DESCRIPTOR **EndpointDescriptor\r | |
172 | );\r | |
173 | \r | |
174 | /**\r | |
175 | Reset the port and re-configure the usb device.\r | |
176 | \r | |
177 | @param PeiServices General-purpose services that are available to every PEIM.\r | |
178 | @param This Indicates the PEI_USB_IO_PPI instance.\r | |
179 | \r | |
180 | @retval EFI_SUCCESS Usb device is reset and configured successfully.\r | |
181 | @retval Others Other failure occurs.\r | |
182 | \r | |
183 | **/\r | |
184 | EFI_STATUS\r | |
185 | EFIAPI\r | |
186 | PeiUsbPortReset (\r | |
187 | IN EFI_PEI_SERVICES **PeiServices,\r | |
188 | IN PEI_USB_IO_PPI *This\r | |
189 | );\r | |
190 | \r | |
191 | /**\r | |
192 | Send reset signal over the given root hub port.\r | |
193 | \r | |
194 | @param PeiServices Describes the list of possible PEI Services.\r | |
195 | @param UsbHcPpi The pointer of PEI_USB_HOST_CONTROLLER_PPI instance.\r | |
196 | @param Usb2HcPpi The pointer of PEI_USB2_HOST_CONTROLLER_PPI instance.\r | |
197 | @param PortNum The port to be reset.\r | |
198 | @param RetryIndex The retry times.\r | |
199 | \r | |
200 | **/\r | |
201 | VOID\r | |
202 | ResetRootPort (\r | |
203 | IN EFI_PEI_SERVICES **PeiServices,\r | |
204 | IN PEI_USB_HOST_CONTROLLER_PPI *UsbHcPpi,\r | |
205 | IN PEI_USB2_HOST_CONTROLLER_PPI *Usb2HcPpi,\r | |
206 | IN UINT8 PortNum,\r | |
207 | IN UINT8 RetryIndex\r | |
208 | );\r | |
209 | \r | |
210 | #endif\r |