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