]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/IndustryStandard/Usb.h
MdePkg: Fix typos in comments
[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
431dac94 4 Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
9df063a0 5 This program and the accompanying materials\r
196d5cd1 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
431dac94 18//\r
19// Subset of Class and Subclass definitions from USB Specs\r
20//\r
21\r
22//\r
23// Usb mass storage class code\r
24//\r
25#define USB_MASS_STORE_CLASS 0x08\r
26\r
27//\r
28// Usb mass storage subclass code, specify the command set used.\r
29//\r
30#define USB_MASS_STORE_RBC 0x01 ///< Reduced Block Commands\r
31#define USB_MASS_STORE_8020I 0x02 ///< SFF-8020i, typically a CD/DVD device\r
32#define USB_MASS_STORE_QIC 0x03 ///< Typically a tape device\r
33#define USB_MASS_STORE_UFI 0x04 ///< Typically a floppy disk driver device\r
34#define USB_MASS_STORE_8070I 0x05 ///< SFF-8070i, typically a floppy disk driver device.\r
35#define USB_MASS_STORE_SCSI 0x06 ///< SCSI transparent command set\r
36\r
37//\r
38// Usb mass storage protocol code, specify the transport protocol\r
39//\r
40#define USB_MASS_STORE_CBI0 0x00 ///< CBI protocol with command completion interrupt\r
41#define USB_MASS_STORE_CBI1 0x01 ///< CBI protocol without command completion interrupt\r
42#define USB_MASS_STORE_BOT 0x50 ///< Bulk-Only Transport\r
43\r
9d1f975f 44//\r
45// Standard device request and request type\r
4135253b 46// USB 2.0 spec, Section 9.4\r
9d1f975f 47//\r
48#define USB_DEV_GET_STATUS 0x00\r
49#define USB_DEV_GET_STATUS_REQ_TYPE_D 0x80 // Receiver : Device\r
50#define USB_DEV_GET_STATUS_REQ_TYPE_I 0x81 // Receiver : Interface\r
51#define USB_DEV_GET_STATUS_REQ_TYPE_E 0x82 // Receiver : Endpoint\r
52\r
53#define USB_DEV_CLEAR_FEATURE 0x01\r
54#define USB_DEV_CLEAR_FEATURE_REQ_TYPE_D 0x00 // Receiver : Device\r
55#define USB_DEV_CLEAR_FEATURE_REQ_TYPE_I 0x01 // Receiver : Interface\r
56#define USB_DEV_CLEAR_FEATURE_REQ_TYPE_E 0x02 // Receiver : Endpoint\r
57\r
58#define USB_DEV_SET_FEATURE 0x03\r
59#define USB_DEV_SET_FEATURE_REQ_TYPE_D 0x00 // Receiver : Device\r
60#define USB_DEV_SET_FEATURE_REQ_TYPE_I 0x01 // Receiver : Interface\r
61#define USB_DEV_SET_FEATURE_REQ_TYPE_E 0x02 // Receiver : Endpoint\r
62\r
63#define USB_DEV_SET_ADDRESS 0x05\r
64#define USB_DEV_SET_ADDRESS_REQ_TYPE 0x00\r
65\r
66#define USB_DEV_GET_DESCRIPTOR 0x06\r
67#define USB_DEV_GET_DESCRIPTOR_REQ_TYPE 0x80\r
68\r
69#define USB_DEV_SET_DESCRIPTOR 0x07\r
70#define USB_DEV_SET_DESCRIPTOR_REQ_TYPE 0x00\r
71\r
72#define USB_DEV_GET_CONFIGURATION 0x08\r
73#define USB_DEV_GET_CONFIGURATION_REQ_TYPE 0x80\r
74\r
75#define USB_DEV_SET_CONFIGURATION 0x09\r
76#define USB_DEV_SET_CONFIGURATION_REQ_TYPE 0x00\r
77\r
78#define USB_DEV_GET_INTERFACE 0x0A\r
79#define USB_DEV_GET_INTERFACE_REQ_TYPE 0x81\r
80\r
81#define USB_DEV_SET_INTERFACE 0x0B\r
82#define USB_DEV_SET_INTERFACE_REQ_TYPE 0x01\r
83\r
84#define USB_DEV_SYNCH_FRAME 0x0C\r
85#define USB_DEV_SYNCH_FRAME_REQ_TYPE 0x82\r
a7ed1e2e 86\r
a7ed1e2e 87\r
a7ed1e2e 88//\r
196d5cd1 89// USB standard descriptors and reqeust\r
a7ed1e2e 90//\r
766f4bc1 91#pragma pack(1)\r
4135253b 92\r
93///\r
94/// Format of Setup Data for USB Device Requests\r
95/// USB 2.0 spec, Section 9.3\r
96///\r
a7ed1e2e 97typedef struct {\r
196d5cd1 98 UINT8 RequestType;\r
99 UINT8 Request;\r
100 UINT16 Value;\r
101 UINT16 Index;\r
102 UINT16 Length;\r
e3c6b3d9 103} USB_DEVICE_REQUEST;\r
a7ed1e2e 104\r
4135253b 105///\r
106/// Standard Device Descriptor\r
107/// USB 2.0 spec, Section 9.6.1\r
108///\r
196d5cd1 109typedef struct {\r
110 UINT8 Length;\r
111 UINT8 DescriptorType;\r
112 UINT16 BcdUSB;\r
113 UINT8 DeviceClass;\r
114 UINT8 DeviceSubClass;\r
115 UINT8 DeviceProtocol;\r
116 UINT8 MaxPacketSize0;\r
117 UINT16 IdVendor;\r
118 UINT16 IdProduct;\r
119 UINT16 BcdDevice;\r
120 UINT8 StrManufacturer;\r
121 UINT8 StrProduct;\r
122 UINT8 StrSerialNumber;\r
123 UINT8 NumConfigurations;\r
e3c6b3d9 124} USB_DEVICE_DESCRIPTOR;\r
a7ed1e2e 125\r
4135253b 126///\r
127/// Standard Configuration Descriptor\r
128/// USB 2.0 spec, Section 9.6.3\r
129///\r
a7ed1e2e 130typedef struct {\r
196d5cd1 131 UINT8 Length;\r
132 UINT8 DescriptorType;\r
133 UINT16 TotalLength;\r
134 UINT8 NumInterfaces;\r
135 UINT8 ConfigurationValue;\r
136 UINT8 Configuration;\r
137 UINT8 Attributes;\r
138 UINT8 MaxPower;\r
e3c6b3d9 139} USB_CONFIG_DESCRIPTOR;\r
a7ed1e2e 140\r
4135253b 141///\r
142/// Standard Interface Descriptor\r
143/// USB 2.0 spec, Section 9.6.5\r
144///\r
a7ed1e2e 145typedef struct {\r
196d5cd1 146 UINT8 Length;\r
147 UINT8 DescriptorType;\r
148 UINT8 InterfaceNumber;\r
149 UINT8 AlternateSetting;\r
150 UINT8 NumEndpoints;\r
151 UINT8 InterfaceClass;\r
152 UINT8 InterfaceSubClass;\r
153 UINT8 InterfaceProtocol;\r
154 UINT8 Interface;\r
e3c6b3d9 155} USB_INTERFACE_DESCRIPTOR;\r
a7ed1e2e 156\r
4135253b 157///\r
158/// Standard Endpoint Descriptor\r
159/// USB 2.0 spec, Section 9.6.6\r
160///\r
a7ed1e2e 161typedef struct {\r
196d5cd1 162 UINT8 Length;\r
163 UINT8 DescriptorType;\r
164 UINT8 EndpointAddress;\r
165 UINT8 Attributes;\r
166 UINT16 MaxPacketSize;\r
167 UINT8 Interval;\r
e3c6b3d9 168} USB_ENDPOINT_DESCRIPTOR;\r
a7ed1e2e 169\r
4135253b 170///\r
171/// UNICODE String Descriptor\r
172/// USB 2.0 spec, Section 9.6.7\r
173///\r
a7ed1e2e 174typedef struct {\r
196d5cd1 175 UINT8 Length;\r
176 UINT8 DescriptorType;\r
177 CHAR16 String[1];\r
a7ed1e2e 178} EFI_USB_STRING_DESCRIPTOR;\r
179\r
766f4bc1 180#pragma pack()\r
181\r
182\r
42eedea9 183typedef enum {\r
196d5cd1 184 //\r
185 // USB request type\r
186 //\r
187 USB_REQ_TYPE_STANDARD = (0x00 << 5),\r
188 USB_REQ_TYPE_CLASS = (0x01 << 5),\r
189 USB_REQ_TYPE_VENDOR = (0x02 << 5),\r
190\r
191 //\r
192 // Standard control transfer request type, or the value\r
193 // to fill in EFI_USB_DEVICE_REQUEST.Request\r
194 //\r
195 USB_REQ_GET_STATUS = 0x00,\r
196 USB_REQ_CLEAR_FEATURE = 0x01,\r
197 USB_REQ_SET_FEATURE = 0x03,\r
198 USB_REQ_SET_ADDRESS = 0x05,\r
199 USB_REQ_GET_DESCRIPTOR = 0x06,\r
200 USB_REQ_SET_DESCRIPTOR = 0x07,\r
201 USB_REQ_GET_CONFIG = 0x08,\r
202 USB_REQ_SET_CONFIG = 0x09,\r
203 USB_REQ_GET_INTERFACE = 0x0A,\r
204 USB_REQ_SET_INTERFACE = 0x0B,\r
205 USB_REQ_SYNCH_FRAME = 0x0C,\r
206\r
207 //\r
208 // Usb control transfer target\r
209 //\r
210 USB_TARGET_DEVICE = 0,\r
211 USB_TARGET_INTERFACE = 0x01,\r
212 USB_TARGET_ENDPOINT = 0x02,\r
213 USB_TARGET_OTHER = 0x03,\r
214\r
215 //\r
216 // USB Descriptor types\r
217 //\r
218 USB_DESC_TYPE_DEVICE = 0x01,\r
219 USB_DESC_TYPE_CONFIG = 0x02,\r
220 USB_DESC_TYPE_STRING = 0x03,\r
221 USB_DESC_TYPE_INTERFACE = 0x04,\r
222 USB_DESC_TYPE_ENDPOINT = 0x05,\r
223 USB_DESC_TYPE_HID = 0x21,\r
11ceade4 224 USB_DESC_TYPE_REPORT = 0x22,\r
196d5cd1 225\r
226 //\r
227 // Features to be cleared by CLEAR_FEATURE requests\r
228 //\r
229 USB_FEATURE_ENDPOINT_HALT = 0,\r
230\r
231 //\r
232 // USB endpoint types: 00: control, 01: isochronous, 10: bulk, 11: interrupt\r
233 //\r
234 USB_ENDPOINT_CONTROL = 0x00,\r
235 USB_ENDPOINT_ISO = 0x01,\r
236 USB_ENDPOINT_BULK = 0x02,\r
237 USB_ENDPOINT_INTERRUPT = 0x03,\r
238\r
239 USB_ENDPOINT_TYPE_MASK = 0x03,\r
240 USB_ENDPOINT_DIR_IN = 0x80,\r
241\r
242 //\r
243 //Use 200 ms to increase the error handling response time\r
244 //\r
1b2afeaa 245 EFI_USB_INTERRUPT_DELAY = 2000000\r
42eedea9 246} USB_TYPES_DEFINITION;\r
9d1f975f 247\r
248\r
249//\r
4135253b 250// HID constants definition, see Device Class Definition\r
251// for Human Interface Devices (HID) rev1.11\r
9d1f975f 252//\r
253\r
11ceade4
LG
254//\r
255// HID standard GET_DESCRIPTOR request.\r
256//\r
257#define USB_HID_GET_DESCRIPTOR_REQ_TYPE 0x81\r
258\r
259//\r
260// HID specific requests.\r
261//\r
262#define USB_HID_CLASS_GET_REQ_TYPE 0xa1\r
263#define USB_HID_CLASS_SET_REQ_TYPE 0x21\r
264\r
9d1f975f 265//\r
266// HID report item format\r
267//\r
268#define HID_ITEM_FORMAT_SHORT 0\r
269#define HID_ITEM_FORMAT_LONG 1\r
270\r
271//\r
272// Special tag indicating long items\r
273//\r
274#define HID_ITEM_TAG_LONG 15\r
275\r
276//\r
277// HID report descriptor item type (prefix bit 2,3)\r
278//\r
279#define HID_ITEM_TYPE_MAIN 0\r
280#define HID_ITEM_TYPE_GLOBAL 1\r
281#define HID_ITEM_TYPE_LOCAL 2\r
282#define HID_ITEM_TYPE_RESERVED 3\r
283\r
284//\r
285// HID report descriptor main item tags\r
286//\r
287#define HID_MAIN_ITEM_TAG_INPUT 8\r
288#define HID_MAIN_ITEM_TAG_OUTPUT 9\r
289#define HID_MAIN_ITEM_TAG_FEATURE 11\r
290#define HID_MAIN_ITEM_TAG_BEGIN_COLLECTION 10\r
291#define HID_MAIN_ITEM_TAG_END_COLLECTION 12\r
292\r
293//\r
294// HID report descriptor main item contents\r
295//\r
296#define HID_MAIN_ITEM_CONSTANT 0x001\r
297#define HID_MAIN_ITEM_VARIABLE 0x002\r
298#define HID_MAIN_ITEM_RELATIVE 0x004\r
299#define HID_MAIN_ITEM_WRAP 0x008\r
300#define HID_MAIN_ITEM_NONLINEAR 0x010\r
301#define HID_MAIN_ITEM_NO_PREFERRED 0x020\r
302#define HID_MAIN_ITEM_NULL_STATE 0x040\r
303#define HID_MAIN_ITEM_VOLATILE 0x080\r
304#define HID_MAIN_ITEM_BUFFERED_BYTE 0x100\r
305\r
306//\r
307// HID report descriptor collection item types\r
308//\r
309#define HID_COLLECTION_PHYSICAL 0\r
310#define HID_COLLECTION_APPLICATION 1\r
311#define HID_COLLECTION_LOGICAL 2\r
312\r
313//\r
314// HID report descriptor global item tags\r
315//\r
316#define HID_GLOBAL_ITEM_TAG_USAGE_PAGE 0\r
317#define HID_GLOBAL_ITEM_TAG_LOGICAL_MINIMUM 1\r
318#define HID_GLOBAL_ITEM_TAG_LOGICAL_MAXIMUM 2\r
319#define HID_GLOBAL_ITEM_TAG_PHYSICAL_MINIMUM 3\r
320#define HID_GLOBAL_ITEM_TAG_PHYSICAL_MAXIMUM 4\r
321#define HID_GLOBAL_ITEM_TAG_UNIT_EXPONENT 5\r
322#define HID_GLOBAL_ITEM_TAG_UNIT 6\r
323#define HID_GLOBAL_ITEM_TAG_REPORT_SIZE 7\r
324#define HID_GLOBAL_ITEM_TAG_REPORT_ID 8\r
325#define HID_GLOBAL_ITEM_TAG_REPORT_COUNT 9\r
326#define HID_GLOBAL_ITEM_TAG_PUSH 10\r
327#define HID_GLOBAL_ITEM_TAG_POP 11\r
328\r
329//\r
330// HID report descriptor local item tags\r
331//\r
332#define HID_LOCAL_ITEM_TAG_USAGE 0\r
333#define HID_LOCAL_ITEM_TAG_USAGE_MINIMUM 1\r
334#define HID_LOCAL_ITEM_TAG_USAGE_MAXIMUM 2\r
335#define HID_LOCAL_ITEM_TAG_DESIGNATOR_INDEX 3\r
336#define HID_LOCAL_ITEM_TAG_DESIGNATOR_MINIMUM 4\r
337#define HID_LOCAL_ITEM_TAG_DESIGNATOR_MAXIMUM 5\r
338#define HID_LOCAL_ITEM_TAG_STRING_INDEX 7\r
339#define HID_LOCAL_ITEM_TAG_STRING_MINIMUM 8\r
340#define HID_LOCAL_ITEM_TAG_STRING_MAXIMUM 9\r
341#define HID_LOCAL_ITEM_TAG_DELIMITER 10\r
342\r
343//\r
344// HID report types\r
345//\r
346#define HID_INPUT_REPORT 1\r
347#define HID_OUTPUT_REPORT 2\r
348#define HID_FEATURE_REPORT 3\r
349\r
350//\r
351// HID class protocol request\r
352//\r
353#define EFI_USB_GET_REPORT_REQUEST 0x01\r
354#define EFI_USB_GET_IDLE_REQUEST 0x02\r
355#define EFI_USB_GET_PROTOCOL_REQUEST 0x03\r
356#define EFI_USB_SET_REPORT_REQUEST 0x09\r
357#define EFI_USB_SET_IDLE_REQUEST 0x0a\r
358#define EFI_USB_SET_PROTOCOL_REQUEST 0x0b\r
359\r
360#pragma pack(1)\r
1bc5d021 361///\r
362/// Descriptor header for Report/Physical Descriptors\r
427987f5 363/// HID 1.1, section 6.2.1\r
1bc5d021 364///\r
9d1f975f 365typedef struct hid_class_descriptor {\r
366 UINT8 DescriptorType;\r
367 UINT16 DescriptorLength;\r
368} EFI_USB_HID_CLASS_DESCRIPTOR;\r
369\r
4135253b 370///\r
371/// The HID descriptor identifies the length and type\r
372/// of subordinate descriptors for a device.\r
427987f5 373/// HID 1.1, section 6.2.1\r
4135253b 374///\r
9d1f975f 375typedef struct hid_descriptor {\r
376 UINT8 Length;\r
377 UINT8 DescriptorType;\r
378 UINT16 BcdHID;\r
379 UINT8 CountryCode;\r
380 UINT8 NumDescriptors;\r
381 EFI_USB_HID_CLASS_DESCRIPTOR HidClassDesc[1];\r
382} EFI_USB_HID_DESCRIPTOR;\r
766f4bc1 383\r
c76a83cc 384#pragma pack()\r
9d1f975f 385\r
a7ed1e2e 386#endif\r