]>
Commit | Line | Data |
---|---|---|
4b1bf81c | 1 | /** @file\r |
2 | Common Libarary for PEI USB.\r | |
3 | \r | |
4 | Copyright (c) 1999 - 2010, Intel Corporation. All rights reserved.<BR>\r | |
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_LIB_H_\r | |
18 | #define _PEI_USB_LIB_H_\r | |
19 | //\r | |
20 | // Standard device request and request type\r | |
21 | // By [Spec-USB20/Chapter-9.4]\r | |
22 | //\r | |
23 | #define USB_DEV_GET_STATUS 0x00\r | |
24 | #define USB_DEV_GET_STATUS_REQ_TYPE_D 0x80 // Receiver : Device\r | |
25 | #define USB_DEV_GET_STATUS_REQ_TYPE_I 0x81 // Receiver : Interface\r | |
26 | #define USB_DEV_GET_STATUS_REQ_TYPE_E 0x82 // Receiver : Endpoint\r | |
27 | \r | |
28 | #define USB_DEV_CLEAR_FEATURE 0x01\r | |
29 | #define USB_DEV_CLEAR_FEATURE_REQ_TYPE_D 0x00 // Receiver : Device\r | |
30 | #define USB_DEV_CLEAR_FEATURE_REQ_TYPE_I 0x01 // Receiver : Interface\r | |
31 | #define USB_DEV_CLEAR_FEATURE_REQ_TYPE_E 0x02 // Receiver : Endpoint\r | |
32 | \r | |
33 | #define USB_DEV_SET_FEATURE 0x03\r | |
34 | #define USB_DEV_SET_FEATURE_REQ_TYPE_D 0x00 // Receiver : Device\r | |
35 | #define USB_DEV_SET_FEATURE_REQ_TYPE_I 0x01 // Receiver : Interface\r | |
36 | #define USB_DEV_SET_FEATURE_REQ_TYPE_E 0x02 // Receiver : Endpoint\r | |
37 | \r | |
38 | #define USB_DEV_SET_ADDRESS 0x05\r | |
39 | #define USB_DEV_SET_ADDRESS_REQ_TYPE 0x00\r | |
40 | \r | |
41 | #define USB_DEV_GET_DESCRIPTOR 0x06\r | |
42 | #define USB_DEV_GET_DESCRIPTOR_REQ_TYPE 0x80\r | |
43 | \r | |
44 | #define USB_DEV_SET_DESCRIPTOR 0x07\r | |
45 | #define USB_DEV_SET_DESCRIPTOR_REQ_TYPE 0x00\r | |
46 | \r | |
47 | #define USB_DEV_GET_CONFIGURATION 0x08\r | |
48 | #define USB_DEV_GET_CONFIGURATION_REQ_TYPE 0x80\r | |
49 | \r | |
50 | #define USB_DEV_SET_CONFIGURATION 0x09\r | |
51 | #define USB_DEV_SET_CONFIGURATION_REQ_TYPE 0x00\r | |
52 | \r | |
53 | #define USB_DEV_GET_INTERFACE 0x0A\r | |
54 | #define USB_DEV_GET_INTERFACE_REQ_TYPE 0x81\r | |
55 | \r | |
56 | #define USB_DEV_SET_INTERFACE 0x0B\r | |
57 | #define USB_DEV_SET_INTERFACE_REQ_TYPE 0x01\r | |
58 | \r | |
59 | #define USB_DEV_SYNCH_FRAME 0x0C\r | |
60 | #define USB_DEV_SYNCH_FRAME_REQ_TYPE 0x82\r | |
61 | \r | |
62 | //\r | |
63 | // USB Descriptor types\r | |
64 | //\r | |
65 | #define USB_DT_DEVICE 0x01\r | |
66 | #define USB_DT_CONFIG 0x02\r | |
67 | #define USB_DT_STRING 0x03\r | |
68 | #define USB_DT_INTERFACE 0x04\r | |
69 | #define USB_DT_ENDPOINT 0x05\r | |
70 | #define USB_DT_HUB 0x29\r | |
71 | #define USB_DT_HID 0x21\r | |
72 | \r | |
73 | //\r | |
74 | // USB request type\r | |
75 | //\r | |
76 | #define USB_TYPE_STANDARD (0x00 << 5)\r | |
77 | #define USB_TYPE_CLASS (0x01 << 5)\r | |
78 | #define USB_TYPE_VENDOR (0x02 << 5)\r | |
79 | #define USB_TYPE_RESERVED (0x03 << 5)\r | |
80 | \r | |
81 | //\r | |
82 | // USB request targer device\r | |
83 | //\r | |
84 | #define USB_RECIP_DEVICE 0x00\r | |
85 | #define USB_RECIP_INTERFACE 0x01\r | |
86 | #define USB_RECIP_ENDPOINT 0x02\r | |
87 | #define USB_RECIP_OTHER 0x03\r | |
88 | \r | |
89 | typedef enum {\r | |
90 | EfiUsbEndpointHalt,\r | |
91 | EfiUsbDeviceRemoteWakeup\r | |
92 | } EFI_USB_STANDARD_FEATURE_SELECTOR;\r | |
93 | \r | |
94 | //\r | |
95 | // Usb Data recipient type\r | |
96 | //\r | |
97 | typedef enum {\r | |
98 | EfiUsbDevice,\r | |
99 | EfiUsbInterface,\r | |
100 | EfiUsbEndpoint\r | |
101 | } EFI_USB_RECIPIENT;\r | |
102 | \r | |
103 | /**\r | |
104 | Get a given usb descriptor.\r | |
105 | \r | |
106 | @param PeiServices General-purpose services that are available to every PEIM.\r | |
107 | @param UsbIoPpi Indicates the PEI_USB_IO_PPI instance.\r | |
108 | @param Value Request Value.\r | |
109 | @param Index Request Index.\r | |
110 | @param DescriptorLength Request descriptor Length.\r | |
111 | @param Descriptor Request descriptor.\r | |
112 | \r | |
113 | \r | |
114 | @retval EFI_SUCCESS Usb descriptor is obtained successfully.\r | |
115 | @retval EFI_DEVICE_ERROR Cannot get the usb descriptor due to a hardware error.\r | |
116 | @retval Others Other failure occurs.\r | |
117 | \r | |
118 | **/\r | |
119 | EFI_STATUS\r | |
120 | PeiUsbGetDescriptor (\r | |
121 | IN EFI_PEI_SERVICES **PeiServices,\r | |
122 | IN PEI_USB_IO_PPI *UsbIoPpi,\r | |
123 | IN UINT16 Value,\r | |
124 | IN UINT16 Index,\r | |
125 | IN UINT16 DescriptorLength,\r | |
126 | OUT VOID *Descriptor\r | |
127 | );\r | |
128 | \r | |
129 | /**\r | |
130 | Set a usb device with a specified address.\r | |
131 | \r | |
132 | @param PeiServices General-purpose services that are available to every PEIM.\r | |
133 | @param UsbIoPpi Indicates the PEI_USB_IO_PPI instance.\r | |
134 | @param AddressValue The address to assign.\r | |
135 | \r | |
136 | @retval EFI_SUCCESS Usb device address is set successfully.\r | |
137 | @retval EFI_DEVICE_ERROR Cannot set the usb address due to a hardware error.\r | |
138 | @retval Others Other failure occurs.\r | |
139 | \r | |
140 | **/\r | |
141 | EFI_STATUS\r | |
142 | PeiUsbSetDeviceAddress (\r | |
143 | IN EFI_PEI_SERVICES **PeiServices,\r | |
144 | IN PEI_USB_IO_PPI *UsbIoPpi,\r | |
145 | IN UINT16 AddressValue\r | |
146 | );\r | |
147 | \r | |
148 | /**\r | |
149 | Clear a given usb feature.\r | |
150 | \r | |
151 | @param PeiServices General-purpose services that are available to every PEIM.\r | |
152 | @param UsbIoPpi Indicates the PEI_USB_IO_PPI instance.\r | |
153 | @param Recipient The recipient of ClearFeature Request, should be one of Device/Interface/Endpoint.\r | |
154 | @param Value Request Value.\r | |
155 | @param Target Request Index.\r | |
156 | \r | |
157 | @retval EFI_SUCCESS Usb feature is cleared successfully.\r | |
158 | @retval EFI_DEVICE_ERROR Cannot clear the usb feature due to a hardware error.\r | |
159 | @retval Others Other failure occurs.\r | |
160 | \r | |
161 | **/\r | |
162 | EFI_STATUS\r | |
163 | PeiUsbClearDeviceFeature (\r | |
164 | IN EFI_PEI_SERVICES **PeiServices,\r | |
165 | IN PEI_USB_IO_PPI *UsbIoPpi,\r | |
166 | IN EFI_USB_RECIPIENT Recipient,\r | |
167 | IN UINT16 Value,\r | |
168 | IN UINT16 Target\r | |
169 | );\r | |
170 | \r | |
171 | /**\r | |
172 | Configure a usb device to Configuration 1.\r | |
173 | \r | |
174 | @param PeiServices General-purpose services that are available to every PEIM.\r | |
175 | @param UsbIoPpi Indicates the PEI_USB_IO_PPI instance.\r | |
176 | \r | |
177 | @retval EFI_SUCCESS Usb device is set to use Configuration 1 successfully.\r | |
178 | @retval EFI_DEVICE_ERROR Cannot set the usb device due to a hardware error.\r | |
179 | @retval Others Other failure occurs.\r | |
180 | \r | |
181 | **/\r | |
182 | EFI_STATUS\r | |
183 | PeiUsbSetConfiguration (\r | |
184 | IN EFI_PEI_SERVICES **PeiServices,\r | |
185 | IN PEI_USB_IO_PPI *UsbIoPpi\r | |
186 | );\r | |
187 | \r | |
188 | /**\r | |
189 | Clear Endpoint Halt.\r | |
190 | \r | |
191 | @param PeiServices General-purpose services that are available to every PEIM.\r | |
192 | @param UsbIoPpi Indicates the PEI_USB_IO_PPI instance.\r | |
193 | @param EndpointAddress The endpoint address.\r | |
194 | \r | |
195 | @retval EFI_SUCCESS Endpoint halt is cleared successfully.\r | |
196 | @retval EFI_DEVICE_ERROR Cannot clear the endpoint halt status due to a hardware error.\r | |
197 | @retval Others Other failure occurs.\r | |
198 | \r | |
199 | **/\r | |
200 | EFI_STATUS\r | |
201 | PeiUsbClearEndpointHalt (\r | |
202 | IN EFI_PEI_SERVICES **PeiServices,\r | |
203 | IN PEI_USB_IO_PPI *UsbIoPpi,\r | |
204 | IN UINT8 EndpointAddress\r | |
205 | );\r | |
206 | \r | |
207 | /**\r | |
208 | Judge if the port is connected with a usb device or not.\r | |
209 | \r | |
210 | @param PortStatus The usb port status gotten.\r | |
211 | \r | |
212 | @retval TRUE A usb device is connected with the port.\r | |
213 | @retval FALSE No usb device is connected with the port.\r | |
214 | \r | |
215 | **/\r | |
216 | BOOLEAN\r | |
217 | IsPortConnect (\r | |
218 | IN UINT16 PortStatus\r | |
219 | );\r | |
220 | \r | |
221 | /**\r | |
222 | Judge if the port is connected with a low-speed usb device or not.\r | |
223 | \r | |
224 | @param PortStatus The usb port status gotten.\r | |
225 | \r | |
226 | @retval TRUE A low-speed usb device is connected with the port.\r | |
227 | @retval FALSE No low-speed usb device is connected with the port.\r | |
228 | \r | |
229 | **/\r | |
230 | BOOLEAN\r | |
231 | IsPortLowSpeedDeviceAttached (\r | |
232 | IN UINT16 PortStatus\r | |
233 | );\r | |
234 | \r | |
235 | /**\r | |
236 | Judge if the port is in "connection change" status or not.\r | |
237 | \r | |
238 | @param PortChangeStatus The usb port change status gotten.\r | |
239 | \r | |
240 | @retval TRUE The port is in "connection change" status.\r | |
241 | @retval FALSE The port is NOT in "connection change" status.\r | |
242 | \r | |
243 | **/\r | |
244 | BOOLEAN\r | |
245 | IsPortConnectChange (\r | |
246 | IN UINT16 PortChangeStatus\r | |
247 | );\r | |
248 | #endif\r |