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