]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/IndustryStandard/Usb.h
Do not use statically macros of EFI_SPECIFICATION_VERSION: Use gST->Hdr.Revision...
[mirror_edk2.git] / MdePkg / Include / IndustryStandard / Usb.h
CommitLineData
a7ed1e2e 1/** @file\r
4135253b 2 Support for USB 2.0 standard.\r
a7ed1e2e 3\r
4135253b 4 Copyright (c) 2006 - 2008, Intel Corporation\r
196d5cd1 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
4135253b 20// USB 2.0 spec, Section 9.4\r
9d1f975f 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
4135253b 65\r
66///\r
67/// Format of Setup Data for USB Device Requests\r
68/// USB 2.0 spec, Section 9.3\r
69///\r
a7ed1e2e 70typedef struct {\r
196d5cd1 71 UINT8 RequestType;\r
72 UINT8 Request;\r
73 UINT16 Value;\r
74 UINT16 Index;\r
75 UINT16 Length;\r
e3c6b3d9 76} USB_DEVICE_REQUEST;\r
a7ed1e2e 77\r
4135253b 78///\r
79/// Standard Device Descriptor\r
80/// USB 2.0 spec, Section 9.6.1\r
81///\r
196d5cd1 82typedef struct {\r
83 UINT8 Length;\r
84 UINT8 DescriptorType;\r
85 UINT16 BcdUSB;\r
86 UINT8 DeviceClass;\r
87 UINT8 DeviceSubClass;\r
88 UINT8 DeviceProtocol;\r
89 UINT8 MaxPacketSize0;\r
90 UINT16 IdVendor;\r
91 UINT16 IdProduct;\r
92 UINT16 BcdDevice;\r
93 UINT8 StrManufacturer;\r
94 UINT8 StrProduct;\r
95 UINT8 StrSerialNumber;\r
96 UINT8 NumConfigurations;\r
e3c6b3d9 97} USB_DEVICE_DESCRIPTOR;\r
a7ed1e2e 98\r
4135253b 99///\r
100/// Standard Configuration Descriptor\r
101/// USB 2.0 spec, Section 9.6.3\r
102///\r
a7ed1e2e 103typedef struct {\r
196d5cd1 104 UINT8 Length;\r
105 UINT8 DescriptorType;\r
106 UINT16 TotalLength;\r
107 UINT8 NumInterfaces;\r
108 UINT8 ConfigurationValue;\r
109 UINT8 Configuration;\r
110 UINT8 Attributes;\r
111 UINT8 MaxPower;\r
e3c6b3d9 112} USB_CONFIG_DESCRIPTOR;\r
a7ed1e2e 113\r
4135253b 114///\r
115/// Standard Interface Descriptor\r
116/// USB 2.0 spec, Section 9.6.5\r
117///\r
a7ed1e2e 118typedef struct {\r
196d5cd1 119 UINT8 Length;\r
120 UINT8 DescriptorType;\r
121 UINT8 InterfaceNumber;\r
122 UINT8 AlternateSetting;\r
123 UINT8 NumEndpoints;\r
124 UINT8 InterfaceClass;\r
125 UINT8 InterfaceSubClass;\r
126 UINT8 InterfaceProtocol;\r
127 UINT8 Interface;\r
e3c6b3d9 128} USB_INTERFACE_DESCRIPTOR;\r
a7ed1e2e 129\r
4135253b 130///\r
131/// Standard Endpoint Descriptor\r
132/// USB 2.0 spec, Section 9.6.6\r
133///\r
a7ed1e2e 134typedef struct {\r
196d5cd1 135 UINT8 Length;\r
136 UINT8 DescriptorType;\r
137 UINT8 EndpointAddress;\r
138 UINT8 Attributes;\r
139 UINT16 MaxPacketSize;\r
140 UINT8 Interval;\r
e3c6b3d9 141} USB_ENDPOINT_DESCRIPTOR;\r
a7ed1e2e 142\r
4135253b 143///\r
144/// UNICODE String Descriptor\r
145/// USB 2.0 spec, Section 9.6.7\r
146///\r
a7ed1e2e 147typedef struct {\r
196d5cd1 148 UINT8 Length;\r
149 UINT8 DescriptorType;\r
150 CHAR16 String[1];\r
a7ed1e2e 151} EFI_USB_STRING_DESCRIPTOR;\r
152\r
42eedea9 153typedef enum {\r
196d5cd1 154 //\r
155 // USB request type\r
156 //\r
157 USB_REQ_TYPE_STANDARD = (0x00 << 5),\r
158 USB_REQ_TYPE_CLASS = (0x01 << 5),\r
159 USB_REQ_TYPE_VENDOR = (0x02 << 5),\r
160\r
161 //\r
162 // Standard control transfer request type, or the value\r
163 // to fill in EFI_USB_DEVICE_REQUEST.Request\r
164 //\r
165 USB_REQ_GET_STATUS = 0x00,\r
166 USB_REQ_CLEAR_FEATURE = 0x01,\r
167 USB_REQ_SET_FEATURE = 0x03,\r
168 USB_REQ_SET_ADDRESS = 0x05,\r
169 USB_REQ_GET_DESCRIPTOR = 0x06,\r
170 USB_REQ_SET_DESCRIPTOR = 0x07,\r
171 USB_REQ_GET_CONFIG = 0x08,\r
172 USB_REQ_SET_CONFIG = 0x09,\r
173 USB_REQ_GET_INTERFACE = 0x0A,\r
174 USB_REQ_SET_INTERFACE = 0x0B,\r
175 USB_REQ_SYNCH_FRAME = 0x0C,\r
176\r
177 //\r
178 // Usb control transfer target\r
179 //\r
180 USB_TARGET_DEVICE = 0,\r
181 USB_TARGET_INTERFACE = 0x01,\r
182 USB_TARGET_ENDPOINT = 0x02,\r
183 USB_TARGET_OTHER = 0x03,\r
184\r
185 //\r
186 // USB Descriptor types\r
187 //\r
188 USB_DESC_TYPE_DEVICE = 0x01,\r
189 USB_DESC_TYPE_CONFIG = 0x02,\r
190 USB_DESC_TYPE_STRING = 0x03,\r
191 USB_DESC_TYPE_INTERFACE = 0x04,\r
192 USB_DESC_TYPE_ENDPOINT = 0x05,\r
193 USB_DESC_TYPE_HID = 0x21,\r
11ceade4 194 USB_DESC_TYPE_REPORT = 0x22,\r
196d5cd1 195\r
196 //\r
197 // Features to be cleared by CLEAR_FEATURE requests\r
198 //\r
199 USB_FEATURE_ENDPOINT_HALT = 0,\r
200\r
201 //\r
202 // USB endpoint types: 00: control, 01: isochronous, 10: bulk, 11: interrupt\r
203 //\r
204 USB_ENDPOINT_CONTROL = 0x00,\r
205 USB_ENDPOINT_ISO = 0x01,\r
206 USB_ENDPOINT_BULK = 0x02,\r
207 USB_ENDPOINT_INTERRUPT = 0x03,\r
208\r
209 USB_ENDPOINT_TYPE_MASK = 0x03,\r
210 USB_ENDPOINT_DIR_IN = 0x80,\r
211\r
212 //\r
213 //Use 200 ms to increase the error handling response time\r
214 //\r
1b2afeaa 215 EFI_USB_INTERRUPT_DELAY = 2000000\r
42eedea9 216} USB_TYPES_DEFINITION;\r
9d1f975f 217\r
218\r
219//\r
4135253b 220// HID constants definition, see Device Class Definition\r
221// for Human Interface Devices (HID) rev1.11\r
9d1f975f 222//\r
223\r
11ceade4
LG
224//\r
225// HID standard GET_DESCRIPTOR request.\r
226//\r
227#define USB_HID_GET_DESCRIPTOR_REQ_TYPE 0x81\r
228\r
229//\r
230// HID specific requests.\r
231//\r
232#define USB_HID_CLASS_GET_REQ_TYPE 0xa1\r
233#define USB_HID_CLASS_SET_REQ_TYPE 0x21\r
234\r
9d1f975f 235//\r
236// HID report item format\r
237//\r
238#define HID_ITEM_FORMAT_SHORT 0\r
239#define HID_ITEM_FORMAT_LONG 1\r
240\r
241//\r
242// Special tag indicating long items\r
243//\r
244#define HID_ITEM_TAG_LONG 15\r
245\r
246//\r
247// HID report descriptor item type (prefix bit 2,3)\r
248//\r
249#define HID_ITEM_TYPE_MAIN 0\r
250#define HID_ITEM_TYPE_GLOBAL 1\r
251#define HID_ITEM_TYPE_LOCAL 2\r
252#define HID_ITEM_TYPE_RESERVED 3\r
253\r
254//\r
255// HID report descriptor main item tags\r
256//\r
257#define HID_MAIN_ITEM_TAG_INPUT 8\r
258#define HID_MAIN_ITEM_TAG_OUTPUT 9\r
259#define HID_MAIN_ITEM_TAG_FEATURE 11\r
260#define HID_MAIN_ITEM_TAG_BEGIN_COLLECTION 10\r
261#define HID_MAIN_ITEM_TAG_END_COLLECTION 12\r
262\r
263//\r
264// HID report descriptor main item contents\r
265//\r
266#define HID_MAIN_ITEM_CONSTANT 0x001\r
267#define HID_MAIN_ITEM_VARIABLE 0x002\r
268#define HID_MAIN_ITEM_RELATIVE 0x004\r
269#define HID_MAIN_ITEM_WRAP 0x008\r
270#define HID_MAIN_ITEM_NONLINEAR 0x010\r
271#define HID_MAIN_ITEM_NO_PREFERRED 0x020\r
272#define HID_MAIN_ITEM_NULL_STATE 0x040\r
273#define HID_MAIN_ITEM_VOLATILE 0x080\r
274#define HID_MAIN_ITEM_BUFFERED_BYTE 0x100\r
275\r
276//\r
277// HID report descriptor collection item types\r
278//\r
279#define HID_COLLECTION_PHYSICAL 0\r
280#define HID_COLLECTION_APPLICATION 1\r
281#define HID_COLLECTION_LOGICAL 2\r
282\r
283//\r
284// HID report descriptor global item tags\r
285//\r
286#define HID_GLOBAL_ITEM_TAG_USAGE_PAGE 0\r
287#define HID_GLOBAL_ITEM_TAG_LOGICAL_MINIMUM 1\r
288#define HID_GLOBAL_ITEM_TAG_LOGICAL_MAXIMUM 2\r
289#define HID_GLOBAL_ITEM_TAG_PHYSICAL_MINIMUM 3\r
290#define HID_GLOBAL_ITEM_TAG_PHYSICAL_MAXIMUM 4\r
291#define HID_GLOBAL_ITEM_TAG_UNIT_EXPONENT 5\r
292#define HID_GLOBAL_ITEM_TAG_UNIT 6\r
293#define HID_GLOBAL_ITEM_TAG_REPORT_SIZE 7\r
294#define HID_GLOBAL_ITEM_TAG_REPORT_ID 8\r
295#define HID_GLOBAL_ITEM_TAG_REPORT_COUNT 9\r
296#define HID_GLOBAL_ITEM_TAG_PUSH 10\r
297#define HID_GLOBAL_ITEM_TAG_POP 11\r
298\r
299//\r
300// HID report descriptor local item tags\r
301//\r
302#define HID_LOCAL_ITEM_TAG_USAGE 0\r
303#define HID_LOCAL_ITEM_TAG_USAGE_MINIMUM 1\r
304#define HID_LOCAL_ITEM_TAG_USAGE_MAXIMUM 2\r
305#define HID_LOCAL_ITEM_TAG_DESIGNATOR_INDEX 3\r
306#define HID_LOCAL_ITEM_TAG_DESIGNATOR_MINIMUM 4\r
307#define HID_LOCAL_ITEM_TAG_DESIGNATOR_MAXIMUM 5\r
308#define HID_LOCAL_ITEM_TAG_STRING_INDEX 7\r
309#define HID_LOCAL_ITEM_TAG_STRING_MINIMUM 8\r
310#define HID_LOCAL_ITEM_TAG_STRING_MAXIMUM 9\r
311#define HID_LOCAL_ITEM_TAG_DELIMITER 10\r
312\r
313//\r
314// HID report types\r
315//\r
316#define HID_INPUT_REPORT 1\r
317#define HID_OUTPUT_REPORT 2\r
318#define HID_FEATURE_REPORT 3\r
319\r
320//\r
321// HID class protocol request\r
322//\r
323#define EFI_USB_GET_REPORT_REQUEST 0x01\r
324#define EFI_USB_GET_IDLE_REQUEST 0x02\r
325#define EFI_USB_GET_PROTOCOL_REQUEST 0x03\r
326#define EFI_USB_SET_REPORT_REQUEST 0x09\r
327#define EFI_USB_SET_IDLE_REQUEST 0x0a\r
328#define EFI_USB_SET_PROTOCOL_REQUEST 0x0b\r
329\r
330#pragma pack(1)\r
1bc5d021 331///\r
332/// Descriptor header for Report/Physical Descriptors\r
333///\r
9d1f975f 334typedef struct hid_class_descriptor {\r
335 UINT8 DescriptorType;\r
336 UINT16 DescriptorLength;\r
337} EFI_USB_HID_CLASS_DESCRIPTOR;\r
54569f0f 338#pragma pack()\r
9d1f975f 339\r
4135253b 340///\r
341/// The HID descriptor identifies the length and type\r
342/// of subordinate descriptors for a device.\r
343///\r
9d1f975f 344typedef struct hid_descriptor {\r
345 UINT8 Length;\r
346 UINT8 DescriptorType;\r
347 UINT16 BcdHID;\r
348 UINT8 CountryCode;\r
349 UINT8 NumDescriptors;\r
350 EFI_USB_HID_CLASS_DESCRIPTOR HidClassDesc[1];\r
351} EFI_USB_HID_DESCRIPTOR;\r
352\r
a7ed1e2e 353#endif\r