2 Support for USB 1.1 standard.
4 Copyright (c) 2006 - 2007, Intel Corporation
5 All rights reserved. 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
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.
19 // Standard device request and request type
20 // By [Spec-USB20/Chapter-9.4]
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
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
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
37 #define USB_DEV_SET_ADDRESS 0x05
38 #define USB_DEV_SET_ADDRESS_REQ_TYPE 0x00
40 #define USB_DEV_GET_DESCRIPTOR 0x06
41 #define USB_DEV_GET_DESCRIPTOR_REQ_TYPE 0x80
43 #define USB_DEV_SET_DESCRIPTOR 0x07
44 #define USB_DEV_SET_DESCRIPTOR_REQ_TYPE 0x00
46 #define USB_DEV_GET_CONFIGURATION 0x08
47 #define USB_DEV_GET_CONFIGURATION_REQ_TYPE 0x80
49 #define USB_DEV_SET_CONFIGURATION 0x09
50 #define USB_DEV_SET_CONFIGURATION_REQ_TYPE 0x00
52 #define USB_DEV_GET_INTERFACE 0x0A
53 #define USB_DEV_GET_INTERFACE_REQ_TYPE 0x81
55 #define USB_DEV_SET_INTERFACE 0x0B
56 #define USB_DEV_SET_INTERFACE_REQ_TYPE 0x01
58 #define USB_DEV_SYNCH_FRAME 0x0C
59 #define USB_DEV_SYNCH_FRAME_REQ_TYPE 0x82
63 // USB standard descriptors and reqeust
85 UINT8 StrManufacturer
;
87 UINT8 StrSerialNumber
;
88 UINT8 NumConfigurations
;
89 } USB_DEVICE_DESCRIPTOR
;
96 UINT8 ConfigurationValue
;
100 } USB_CONFIG_DESCRIPTOR
;
104 UINT8 DescriptorType
;
105 UINT8 InterfaceNumber
;
106 UINT8 AlternateSetting
;
108 UINT8 InterfaceClass
;
109 UINT8 InterfaceSubClass
;
110 UINT8 InterfaceProtocol
;
112 } USB_INTERFACE_DESCRIPTOR
;
116 UINT8 DescriptorType
;
117 UINT8 EndpointAddress
;
119 UINT16 MaxPacketSize
;
121 } USB_ENDPOINT_DESCRIPTOR
;
125 UINT8 DescriptorType
;
127 } EFI_USB_STRING_DESCRIPTOR
;
136 USB_REQ_TYPE_STANDARD
= (0x00 << 5),
137 USB_REQ_TYPE_CLASS
= (0x01 << 5),
138 USB_REQ_TYPE_VENDOR
= (0x02 << 5),
141 // Standard control transfer request type, or the value
142 // to fill in EFI_USB_DEVICE_REQUEST.Request
144 USB_REQ_GET_STATUS
= 0x00,
145 USB_REQ_CLEAR_FEATURE
= 0x01,
146 USB_REQ_SET_FEATURE
= 0x03,
147 USB_REQ_SET_ADDRESS
= 0x05,
148 USB_REQ_GET_DESCRIPTOR
= 0x06,
149 USB_REQ_SET_DESCRIPTOR
= 0x07,
150 USB_REQ_GET_CONFIG
= 0x08,
151 USB_REQ_SET_CONFIG
= 0x09,
152 USB_REQ_GET_INTERFACE
= 0x0A,
153 USB_REQ_SET_INTERFACE
= 0x0B,
154 USB_REQ_SYNCH_FRAME
= 0x0C,
157 // Usb control transfer target
159 USB_TARGET_DEVICE
= 0,
160 USB_TARGET_INTERFACE
= 0x01,
161 USB_TARGET_ENDPOINT
= 0x02,
162 USB_TARGET_OTHER
= 0x03,
165 // USB Descriptor types
167 USB_DESC_TYPE_DEVICE
= 0x01,
168 USB_DESC_TYPE_CONFIG
= 0x02,
169 USB_DESC_TYPE_STRING
= 0x03,
170 USB_DESC_TYPE_INTERFACE
= 0x04,
171 USB_DESC_TYPE_ENDPOINT
= 0x05,
172 USB_DESC_TYPE_HID
= 0x21,
173 USB_DESC_TYPE_REPORT
= 0x22,
176 // Features to be cleared by CLEAR_FEATURE requests
178 USB_FEATURE_ENDPOINT_HALT
= 0,
181 // USB endpoint types: 00: control, 01: isochronous, 10: bulk, 11: interrupt
183 USB_ENDPOINT_CONTROL
= 0x00,
184 USB_ENDPOINT_ISO
= 0x01,
185 USB_ENDPOINT_BULK
= 0x02,
186 USB_ENDPOINT_INTERRUPT
= 0x03,
188 USB_ENDPOINT_TYPE_MASK
= 0x03,
189 USB_ENDPOINT_DIR_IN
= 0x80,
192 //Use 200 ms to increase the error handling response time
194 EFI_USB_INTERRUPT_DELAY
= 2000000
195 } USB_TYPES_DEFINITION
;
199 // HID constants definition, see HID rev1.0
203 // HID standard GET_DESCRIPTOR request.
205 #define USB_HID_GET_DESCRIPTOR_REQ_TYPE 0x81
208 // HID specific requests.
210 #define USB_HID_CLASS_GET_REQ_TYPE 0xa1
211 #define USB_HID_CLASS_SET_REQ_TYPE 0x21
214 // HID report item format
216 #define HID_ITEM_FORMAT_SHORT 0
217 #define HID_ITEM_FORMAT_LONG 1
220 // Special tag indicating long items
222 #define HID_ITEM_TAG_LONG 15
225 // HID report descriptor item type (prefix bit 2,3)
227 #define HID_ITEM_TYPE_MAIN 0
228 #define HID_ITEM_TYPE_GLOBAL 1
229 #define HID_ITEM_TYPE_LOCAL 2
230 #define HID_ITEM_TYPE_RESERVED 3
233 // HID report descriptor main item tags
235 #define HID_MAIN_ITEM_TAG_INPUT 8
236 #define HID_MAIN_ITEM_TAG_OUTPUT 9
237 #define HID_MAIN_ITEM_TAG_FEATURE 11
238 #define HID_MAIN_ITEM_TAG_BEGIN_COLLECTION 10
239 #define HID_MAIN_ITEM_TAG_END_COLLECTION 12
242 // HID report descriptor main item contents
244 #define HID_MAIN_ITEM_CONSTANT 0x001
245 #define HID_MAIN_ITEM_VARIABLE 0x002
246 #define HID_MAIN_ITEM_RELATIVE 0x004
247 #define HID_MAIN_ITEM_WRAP 0x008
248 #define HID_MAIN_ITEM_NONLINEAR 0x010
249 #define HID_MAIN_ITEM_NO_PREFERRED 0x020
250 #define HID_MAIN_ITEM_NULL_STATE 0x040
251 #define HID_MAIN_ITEM_VOLATILE 0x080
252 #define HID_MAIN_ITEM_BUFFERED_BYTE 0x100
255 // HID report descriptor collection item types
257 #define HID_COLLECTION_PHYSICAL 0
258 #define HID_COLLECTION_APPLICATION 1
259 #define HID_COLLECTION_LOGICAL 2
262 // HID report descriptor global item tags
264 #define HID_GLOBAL_ITEM_TAG_USAGE_PAGE 0
265 #define HID_GLOBAL_ITEM_TAG_LOGICAL_MINIMUM 1
266 #define HID_GLOBAL_ITEM_TAG_LOGICAL_MAXIMUM 2
267 #define HID_GLOBAL_ITEM_TAG_PHYSICAL_MINIMUM 3
268 #define HID_GLOBAL_ITEM_TAG_PHYSICAL_MAXIMUM 4
269 #define HID_GLOBAL_ITEM_TAG_UNIT_EXPONENT 5
270 #define HID_GLOBAL_ITEM_TAG_UNIT 6
271 #define HID_GLOBAL_ITEM_TAG_REPORT_SIZE 7
272 #define HID_GLOBAL_ITEM_TAG_REPORT_ID 8
273 #define HID_GLOBAL_ITEM_TAG_REPORT_COUNT 9
274 #define HID_GLOBAL_ITEM_TAG_PUSH 10
275 #define HID_GLOBAL_ITEM_TAG_POP 11
278 // HID report descriptor local item tags
280 #define HID_LOCAL_ITEM_TAG_USAGE 0
281 #define HID_LOCAL_ITEM_TAG_USAGE_MINIMUM 1
282 #define HID_LOCAL_ITEM_TAG_USAGE_MAXIMUM 2
283 #define HID_LOCAL_ITEM_TAG_DESIGNATOR_INDEX 3
284 #define HID_LOCAL_ITEM_TAG_DESIGNATOR_MINIMUM 4
285 #define HID_LOCAL_ITEM_TAG_DESIGNATOR_MAXIMUM 5
286 #define HID_LOCAL_ITEM_TAG_STRING_INDEX 7
287 #define HID_LOCAL_ITEM_TAG_STRING_MINIMUM 8
288 #define HID_LOCAL_ITEM_TAG_STRING_MAXIMUM 9
289 #define HID_LOCAL_ITEM_TAG_DELIMITER 10
294 #define HID_INPUT_REPORT 1
295 #define HID_OUTPUT_REPORT 2
296 #define HID_FEATURE_REPORT 3
299 // HID class protocol request
301 #define EFI_USB_GET_REPORT_REQUEST 0x01
302 #define EFI_USB_GET_IDLE_REQUEST 0x02
303 #define EFI_USB_GET_PROTOCOL_REQUEST 0x03
304 #define EFI_USB_SET_REPORT_REQUEST 0x09
305 #define EFI_USB_SET_IDLE_REQUEST 0x0a
306 #define EFI_USB_SET_PROTOCOL_REQUEST 0x0b
310 /// Descriptor header for Report/Physical Descriptors
312 typedef struct hid_class_descriptor
{
313 UINT8 DescriptorType
;
314 UINT16 DescriptorLength
;
315 } EFI_USB_HID_CLASS_DESCRIPTOR
;
317 typedef struct hid_descriptor
{
319 UINT8 DescriptorType
;
322 UINT8 NumDescriptors
;
323 EFI_USB_HID_CLASS_DESCRIPTOR HidClassDesc
[1];
324 } EFI_USB_HID_DESCRIPTOR
;