VirtualBox

source: vbox/trunk/src/VBox/Devices/EFI/FirmwareOld/MdePkg/Include/IndustryStandard/Usb.h@ 59775

Last change on this file since 59775 was 48674, checked in by vboxsync, 12 years ago

EFI: Export newly imported tinaocore UEFI sources to OSE.

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

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette