]>
Commit | Line | Data |
---|---|---|
a7ed1e2e | 1 | /** @file\r |
2 | Support for USB 1.1 standard.\r | |
3 | \r | |
196d5cd1 | 4 | Copyright (c) 2006 - 2007, Intel Corporation\r |
5 | All rights reserved. This program and the accompanying materials\r | |
6 | are licensed and made available under the terms and conditions of the BSD License\r | |
7 | which accompanies this distribution. The full text of the license may be found at\r | |
8 | http://opensource.org/licenses/bsd-license.php\r | |
a7ed1e2e | 9 | \r |
196d5cd1 | 10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
a7ed1e2e | 12 | \r |
a7ed1e2e | 13 | **/\r |
14 | \r | |
15 | #ifndef __USB_H__\r | |
16 | #define __USB_H__\r | |
17 | \r | |
9d1f975f | 18 | //\r |
19 | // Standard device request and request type\r | |
20 | // By [Spec-USB20/Chapter-9.4]\r | |
21 | //\r | |
22 | #define USB_DEV_GET_STATUS 0x00\r | |
23 | #define USB_DEV_GET_STATUS_REQ_TYPE_D 0x80 // Receiver : Device\r | |
24 | #define USB_DEV_GET_STATUS_REQ_TYPE_I 0x81 // Receiver : Interface\r | |
25 | #define USB_DEV_GET_STATUS_REQ_TYPE_E 0x82 // Receiver : Endpoint\r | |
26 | \r | |
27 | #define USB_DEV_CLEAR_FEATURE 0x01\r | |
28 | #define USB_DEV_CLEAR_FEATURE_REQ_TYPE_D 0x00 // Receiver : Device\r | |
29 | #define USB_DEV_CLEAR_FEATURE_REQ_TYPE_I 0x01 // Receiver : Interface\r | |
30 | #define USB_DEV_CLEAR_FEATURE_REQ_TYPE_E 0x02 // Receiver : Endpoint\r | |
31 | \r | |
32 | #define USB_DEV_SET_FEATURE 0x03\r | |
33 | #define USB_DEV_SET_FEATURE_REQ_TYPE_D 0x00 // Receiver : Device\r | |
34 | #define USB_DEV_SET_FEATURE_REQ_TYPE_I 0x01 // Receiver : Interface\r | |
35 | #define USB_DEV_SET_FEATURE_REQ_TYPE_E 0x02 // Receiver : Endpoint\r | |
36 | \r | |
37 | #define USB_DEV_SET_ADDRESS 0x05\r | |
38 | #define USB_DEV_SET_ADDRESS_REQ_TYPE 0x00\r | |
39 | \r | |
40 | #define USB_DEV_GET_DESCRIPTOR 0x06\r | |
41 | #define USB_DEV_GET_DESCRIPTOR_REQ_TYPE 0x80\r | |
42 | \r | |
43 | #define USB_DEV_SET_DESCRIPTOR 0x07\r | |
44 | #define USB_DEV_SET_DESCRIPTOR_REQ_TYPE 0x00\r | |
45 | \r | |
46 | #define USB_DEV_GET_CONFIGURATION 0x08\r | |
47 | #define USB_DEV_GET_CONFIGURATION_REQ_TYPE 0x80\r | |
48 | \r | |
49 | #define USB_DEV_SET_CONFIGURATION 0x09\r | |
50 | #define USB_DEV_SET_CONFIGURATION_REQ_TYPE 0x00\r | |
51 | \r | |
52 | #define USB_DEV_GET_INTERFACE 0x0A\r | |
53 | #define USB_DEV_GET_INTERFACE_REQ_TYPE 0x81\r | |
54 | \r | |
55 | #define USB_DEV_SET_INTERFACE 0x0B\r | |
56 | #define USB_DEV_SET_INTERFACE_REQ_TYPE 0x01\r | |
57 | \r | |
58 | #define USB_DEV_SYNCH_FRAME 0x0C\r | |
59 | #define USB_DEV_SYNCH_FRAME_REQ_TYPE 0x82\r | |
a7ed1e2e | 60 | \r |
a7ed1e2e | 61 | \r |
a7ed1e2e | 62 | //\r |
196d5cd1 | 63 | // USB standard descriptors and reqeust\r |
a7ed1e2e | 64 | //\r |
196d5cd1 | 65 | #pragma pack(1)\r |
a7ed1e2e | 66 | typedef struct {\r |
196d5cd1 | 67 | UINT8 RequestType;\r |
68 | UINT8 Request;\r | |
69 | UINT16 Value;\r | |
70 | UINT16 Index;\r | |
71 | UINT16 Length;\r | |
e3c6b3d9 | 72 | } USB_DEVICE_REQUEST;\r |
a7ed1e2e | 73 | \r |
196d5cd1 | 74 | typedef struct {\r |
75 | UINT8 Length;\r | |
76 | UINT8 DescriptorType;\r | |
77 | UINT16 BcdUSB;\r | |
78 | UINT8 DeviceClass;\r | |
79 | UINT8 DeviceSubClass;\r | |
80 | UINT8 DeviceProtocol;\r | |
81 | UINT8 MaxPacketSize0;\r | |
82 | UINT16 IdVendor;\r | |
83 | UINT16 IdProduct;\r | |
84 | UINT16 BcdDevice;\r | |
85 | UINT8 StrManufacturer;\r | |
86 | UINT8 StrProduct;\r | |
87 | UINT8 StrSerialNumber;\r | |
88 | UINT8 NumConfigurations;\r | |
e3c6b3d9 | 89 | } USB_DEVICE_DESCRIPTOR;\r |
a7ed1e2e | 90 | \r |
a7ed1e2e | 91 | typedef struct {\r |
196d5cd1 | 92 | UINT8 Length;\r |
93 | UINT8 DescriptorType;\r | |
94 | UINT16 TotalLength;\r | |
95 | UINT8 NumInterfaces;\r | |
96 | UINT8 ConfigurationValue;\r | |
97 | UINT8 Configuration;\r | |
98 | UINT8 Attributes;\r | |
99 | UINT8 MaxPower;\r | |
e3c6b3d9 | 100 | } USB_CONFIG_DESCRIPTOR;\r |
a7ed1e2e | 101 | \r |
a7ed1e2e | 102 | typedef struct {\r |
196d5cd1 | 103 | UINT8 Length;\r |
104 | UINT8 DescriptorType;\r | |
105 | UINT8 InterfaceNumber;\r | |
106 | UINT8 AlternateSetting;\r | |
107 | UINT8 NumEndpoints;\r | |
108 | UINT8 InterfaceClass;\r | |
109 | UINT8 InterfaceSubClass;\r | |
110 | UINT8 InterfaceProtocol;\r | |
111 | UINT8 Interface;\r | |
e3c6b3d9 | 112 | } USB_INTERFACE_DESCRIPTOR;\r |
a7ed1e2e | 113 | \r |
a7ed1e2e | 114 | typedef struct {\r |
196d5cd1 | 115 | UINT8 Length;\r |
116 | UINT8 DescriptorType;\r | |
117 | UINT8 EndpointAddress;\r | |
118 | UINT8 Attributes;\r | |
119 | UINT16 MaxPacketSize;\r | |
120 | UINT8 Interval;\r | |
e3c6b3d9 | 121 | } USB_ENDPOINT_DESCRIPTOR;\r |
a7ed1e2e | 122 | \r |
a7ed1e2e | 123 | typedef struct {\r |
196d5cd1 | 124 | UINT8 Length;\r |
125 | UINT8 DescriptorType;\r | |
126 | CHAR16 String[1];\r | |
a7ed1e2e | 127 | } EFI_USB_STRING_DESCRIPTOR;\r |
128 | \r | |
196d5cd1 | 129 | #pragma pack()\r |
a7ed1e2e | 130 | \r |
a7ed1e2e | 131 | \r |
196d5cd1 | 132 | enum {\r |
133 | //\r | |
134 | // USB request type\r | |
135 | //\r | |
136 | USB_REQ_TYPE_STANDARD = (0x00 << 5),\r | |
137 | USB_REQ_TYPE_CLASS = (0x01 << 5),\r | |
138 | USB_REQ_TYPE_VENDOR = (0x02 << 5),\r | |
139 | \r | |
140 | //\r | |
141 | // Standard control transfer request type, or the value\r | |
142 | // to fill in EFI_USB_DEVICE_REQUEST.Request\r | |
143 | //\r | |
144 | USB_REQ_GET_STATUS = 0x00,\r | |
145 | USB_REQ_CLEAR_FEATURE = 0x01,\r | |
146 | USB_REQ_SET_FEATURE = 0x03,\r | |
147 | USB_REQ_SET_ADDRESS = 0x05,\r | |
148 | USB_REQ_GET_DESCRIPTOR = 0x06,\r | |
149 | USB_REQ_SET_DESCRIPTOR = 0x07,\r | |
150 | USB_REQ_GET_CONFIG = 0x08,\r | |
151 | USB_REQ_SET_CONFIG = 0x09,\r | |
152 | USB_REQ_GET_INTERFACE = 0x0A,\r | |
153 | USB_REQ_SET_INTERFACE = 0x0B,\r | |
154 | USB_REQ_SYNCH_FRAME = 0x0C,\r | |
155 | \r | |
156 | //\r | |
157 | // Usb control transfer target\r | |
158 | //\r | |
159 | USB_TARGET_DEVICE = 0,\r | |
160 | USB_TARGET_INTERFACE = 0x01,\r | |
161 | USB_TARGET_ENDPOINT = 0x02,\r | |
162 | USB_TARGET_OTHER = 0x03,\r | |
163 | \r | |
164 | //\r | |
165 | // USB Descriptor types\r | |
166 | //\r | |
167 | USB_DESC_TYPE_DEVICE = 0x01,\r | |
168 | USB_DESC_TYPE_CONFIG = 0x02,\r | |
169 | USB_DESC_TYPE_STRING = 0x03,\r | |
170 | USB_DESC_TYPE_INTERFACE = 0x04,\r | |
171 | USB_DESC_TYPE_ENDPOINT = 0x05,\r | |
172 | USB_DESC_TYPE_HID = 0x21,\r | |
173 | \r | |
174 | //\r | |
175 | // Features to be cleared by CLEAR_FEATURE requests\r | |
176 | //\r | |
177 | USB_FEATURE_ENDPOINT_HALT = 0,\r | |
178 | \r | |
179 | //\r | |
180 | // USB endpoint types: 00: control, 01: isochronous, 10: bulk, 11: interrupt\r | |
181 | //\r | |
182 | USB_ENDPOINT_CONTROL = 0x00,\r | |
183 | USB_ENDPOINT_ISO = 0x01,\r | |
184 | USB_ENDPOINT_BULK = 0x02,\r | |
185 | USB_ENDPOINT_INTERRUPT = 0x03,\r | |
186 | \r | |
187 | USB_ENDPOINT_TYPE_MASK = 0x03,\r | |
188 | USB_ENDPOINT_DIR_IN = 0x80,\r | |
189 | \r | |
190 | //\r | |
191 | //Use 200 ms to increase the error handling response time\r | |
192 | //\r | |
1b2afeaa | 193 | EFI_USB_INTERRUPT_DELAY = 2000000\r |
196d5cd1 | 194 | };\r |
9d1f975f | 195 | \r |
196 | \r | |
197 | //\r | |
198 | // HID constants definition, see HID rev1.0\r | |
199 | //\r | |
200 | \r | |
201 | //\r | |
202 | // HID report item format\r | |
203 | //\r | |
204 | #define HID_ITEM_FORMAT_SHORT 0\r | |
205 | #define HID_ITEM_FORMAT_LONG 1\r | |
206 | \r | |
207 | //\r | |
208 | // Special tag indicating long items\r | |
209 | //\r | |
210 | #define HID_ITEM_TAG_LONG 15\r | |
211 | \r | |
212 | //\r | |
213 | // HID report descriptor item type (prefix bit 2,3)\r | |
214 | //\r | |
215 | #define HID_ITEM_TYPE_MAIN 0\r | |
216 | #define HID_ITEM_TYPE_GLOBAL 1\r | |
217 | #define HID_ITEM_TYPE_LOCAL 2\r | |
218 | #define HID_ITEM_TYPE_RESERVED 3\r | |
219 | \r | |
220 | //\r | |
221 | // HID report descriptor main item tags\r | |
222 | //\r | |
223 | #define HID_MAIN_ITEM_TAG_INPUT 8\r | |
224 | #define HID_MAIN_ITEM_TAG_OUTPUT 9\r | |
225 | #define HID_MAIN_ITEM_TAG_FEATURE 11\r | |
226 | #define HID_MAIN_ITEM_TAG_BEGIN_COLLECTION 10\r | |
227 | #define HID_MAIN_ITEM_TAG_END_COLLECTION 12\r | |
228 | \r | |
229 | //\r | |
230 | // HID report descriptor main item contents\r | |
231 | //\r | |
232 | #define HID_MAIN_ITEM_CONSTANT 0x001\r | |
233 | #define HID_MAIN_ITEM_VARIABLE 0x002\r | |
234 | #define HID_MAIN_ITEM_RELATIVE 0x004\r | |
235 | #define HID_MAIN_ITEM_WRAP 0x008\r | |
236 | #define HID_MAIN_ITEM_NONLINEAR 0x010\r | |
237 | #define HID_MAIN_ITEM_NO_PREFERRED 0x020\r | |
238 | #define HID_MAIN_ITEM_NULL_STATE 0x040\r | |
239 | #define HID_MAIN_ITEM_VOLATILE 0x080\r | |
240 | #define HID_MAIN_ITEM_BUFFERED_BYTE 0x100\r | |
241 | \r | |
242 | //\r | |
243 | // HID report descriptor collection item types\r | |
244 | //\r | |
245 | #define HID_COLLECTION_PHYSICAL 0\r | |
246 | #define HID_COLLECTION_APPLICATION 1\r | |
247 | #define HID_COLLECTION_LOGICAL 2\r | |
248 | \r | |
249 | //\r | |
250 | // HID report descriptor global item tags\r | |
251 | //\r | |
252 | #define HID_GLOBAL_ITEM_TAG_USAGE_PAGE 0\r | |
253 | #define HID_GLOBAL_ITEM_TAG_LOGICAL_MINIMUM 1\r | |
254 | #define HID_GLOBAL_ITEM_TAG_LOGICAL_MAXIMUM 2\r | |
255 | #define HID_GLOBAL_ITEM_TAG_PHYSICAL_MINIMUM 3\r | |
256 | #define HID_GLOBAL_ITEM_TAG_PHYSICAL_MAXIMUM 4\r | |
257 | #define HID_GLOBAL_ITEM_TAG_UNIT_EXPONENT 5\r | |
258 | #define HID_GLOBAL_ITEM_TAG_UNIT 6\r | |
259 | #define HID_GLOBAL_ITEM_TAG_REPORT_SIZE 7\r | |
260 | #define HID_GLOBAL_ITEM_TAG_REPORT_ID 8\r | |
261 | #define HID_GLOBAL_ITEM_TAG_REPORT_COUNT 9\r | |
262 | #define HID_GLOBAL_ITEM_TAG_PUSH 10\r | |
263 | #define HID_GLOBAL_ITEM_TAG_POP 11\r | |
264 | \r | |
265 | //\r | |
266 | // HID report descriptor local item tags\r | |
267 | //\r | |
268 | #define HID_LOCAL_ITEM_TAG_USAGE 0\r | |
269 | #define HID_LOCAL_ITEM_TAG_USAGE_MINIMUM 1\r | |
270 | #define HID_LOCAL_ITEM_TAG_USAGE_MAXIMUM 2\r | |
271 | #define HID_LOCAL_ITEM_TAG_DESIGNATOR_INDEX 3\r | |
272 | #define HID_LOCAL_ITEM_TAG_DESIGNATOR_MINIMUM 4\r | |
273 | #define HID_LOCAL_ITEM_TAG_DESIGNATOR_MAXIMUM 5\r | |
274 | #define HID_LOCAL_ITEM_TAG_STRING_INDEX 7\r | |
275 | #define HID_LOCAL_ITEM_TAG_STRING_MINIMUM 8\r | |
276 | #define HID_LOCAL_ITEM_TAG_STRING_MAXIMUM 9\r | |
277 | #define HID_LOCAL_ITEM_TAG_DELIMITER 10\r | |
278 | \r | |
279 | //\r | |
280 | // HID report types\r | |
281 | //\r | |
282 | #define HID_INPUT_REPORT 1\r | |
283 | #define HID_OUTPUT_REPORT 2\r | |
284 | #define HID_FEATURE_REPORT 3\r | |
285 | \r | |
286 | //\r | |
287 | // HID class protocol request\r | |
288 | //\r | |
289 | #define EFI_USB_GET_REPORT_REQUEST 0x01\r | |
290 | #define EFI_USB_GET_IDLE_REQUEST 0x02\r | |
291 | #define EFI_USB_GET_PROTOCOL_REQUEST 0x03\r | |
292 | #define EFI_USB_SET_REPORT_REQUEST 0x09\r | |
293 | #define EFI_USB_SET_IDLE_REQUEST 0x0a\r | |
294 | #define EFI_USB_SET_PROTOCOL_REQUEST 0x0b\r | |
295 | \r | |
296 | #pragma pack(1)\r | |
297 | //\r | |
298 | // Descriptor header for Report/Physical Descriptors\r | |
299 | //\r | |
300 | typedef struct hid_class_descriptor {\r | |
301 | UINT8 DescriptorType;\r | |
302 | UINT16 DescriptorLength;\r | |
303 | } EFI_USB_HID_CLASS_DESCRIPTOR;\r | |
304 | \r | |
305 | typedef struct hid_descriptor {\r | |
306 | UINT8 Length;\r | |
307 | UINT8 DescriptorType;\r | |
308 | UINT16 BcdHID;\r | |
309 | UINT8 CountryCode;\r | |
310 | UINT8 NumDescriptors;\r | |
311 | EFI_USB_HID_CLASS_DESCRIPTOR HidClassDesc[1];\r | |
312 | } EFI_USB_HID_DESCRIPTOR;\r | |
313 | \r | |
314 | #pragma pack()\r | |
315 | \r | |
a7ed1e2e | 316 | #endif\r |