]>
Commit | Line | Data |
---|---|---|
a7ed1e2e | 1 | /** @file\r |
2 | Support for USB 1.1 standard.\r | |
3 | \r | |
4 | Copyright (c) 2006, Intel Corporation \r | |
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 | |
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 | |
a7ed1e2e | 13 | **/\r |
14 | \r | |
15 | #ifndef __USB_H__\r | |
16 | #define __USB_H__\r | |
17 | \r | |
18 | //\r | |
19 | // USB Descriptor types\r | |
20 | //\r | |
21 | #define USB_DT_DEVICE 0x01\r | |
22 | #define USB_DT_CONFIG 0x02\r | |
23 | #define USB_DT_STRING 0x03\r | |
24 | #define USB_DT_INTERFACE 0x04\r | |
25 | #define USB_DT_ENDPOINT 0x05\r | |
26 | #define USB_DT_HUB 0x29\r | |
27 | #define USB_DT_HID 0x21\r | |
28 | \r | |
29 | //\r | |
30 | // USB request type\r | |
31 | //\r | |
32 | #define USB_TYPE_STANDARD (0x00 << 5)\r | |
33 | #define USB_TYPE_CLASS (0x01 << 5)\r | |
34 | #define USB_TYPE_VENDOR (0x02 << 5)\r | |
35 | #define USB_TYPE_RESERVED (0x03 << 5)\r | |
36 | \r | |
37 | //\r | |
38 | // USB request targer device\r | |
39 | //\r | |
40 | #define USB_RECIP_DEVICE 0x00\r | |
41 | #define USB_RECIP_INTERFACE 0x01\r | |
42 | #define USB_RECIP_ENDPOINT 0x02\r | |
43 | #define USB_RECIP_OTHER 0x03\r | |
44 | \r | |
45 | //\r | |
46 | // Request target types.\r | |
47 | //\r | |
48 | #define USB_RT_DEVICE 0x00\r | |
49 | #define USB_RT_INTERFACE 0x01\r | |
50 | #define USB_RT_ENDPOINT 0x02\r | |
51 | #define USB_RT_HUB (USB_TYPE_CLASS | USB_RECIP_DEVICE)\r | |
52 | #define USB_RT_PORT (USB_TYPE_CLASS | USB_RECIP_OTHER)\r | |
53 | \r | |
54 | //\r | |
55 | // USB Transfer Results\r | |
56 | //\r | |
57 | #define EFI_USB_NOERROR 0x00\r | |
58 | #define EFI_USB_ERR_NOTEXECUTE 0x01\r | |
59 | #define EFI_USB_ERR_STALL 0x02\r | |
60 | #define EFI_USB_ERR_BUFFER 0x04\r | |
61 | #define EFI_USB_ERR_BABBLE 0x08\r | |
62 | #define EFI_USB_ERR_NAK 0x10\r | |
63 | #define EFI_USB_ERR_CRC 0x20\r | |
64 | #define EFI_USB_ERR_TIMEOUT 0x40\r | |
65 | #define EFI_USB_ERR_BITSTUFF 0x80\r | |
66 | #define EFI_USB_ERR_SYSTEM 0x100\r | |
67 | \r | |
68 | //\r | |
69 | //Use 200 ms to increase the error handling response time\r | |
70 | //\r | |
71 | #define EFI_USB_INTERRUPT_DELAY 2000000\r | |
72 | \r | |
73 | //\r | |
74 | // USB transation direction\r | |
75 | //\r | |
76 | typedef enum {\r | |
77 | EfiUsbDataIn,\r | |
78 | EfiUsbDataOut,\r | |
79 | EfiUsbNoData\r | |
80 | } EFI_USB_DATA_DIRECTION;\r | |
81 | \r | |
82 | //\r | |
83 | // Usb Data recipient type\r | |
84 | //\r | |
85 | typedef enum {\r | |
86 | EfiUsbDevice,\r | |
87 | EfiUsbInterface,\r | |
88 | EfiUsbEndpoint\r | |
89 | } EFI_USB_RECIPIENT;\r | |
90 | \r | |
91 | typedef enum {\r | |
92 | EfiUsbEndpointHalt,\r | |
93 | EfiUsbDeviceRemoteWakeup\r | |
94 | } EFI_USB_STANDARD_FEATURE_SELECTOR;\r | |
95 | \r | |
96 | #pragma pack(1)\r | |
97 | //\r | |
98 | // Usb device request structure\r | |
99 | //\r | |
100 | typedef struct {\r | |
101 | UINT8 RequestType;\r | |
102 | UINT8 Request;\r | |
103 | UINT16 Value;\r | |
104 | UINT16 Index;\r | |
105 | UINT16 Length;\r | |
106 | } EFI_USB_DEVICE_REQUEST;\r | |
107 | \r | |
108 | //\r | |
109 | // Standard USB request\r | |
110 | //\r | |
111 | #define USB_DEV_GET_STATUS 0x00\r | |
112 | \r | |
113 | #define USB_DEV_CLEAR_FEATURE 0x01\r | |
114 | \r | |
115 | #define USB_DEV_SET_FEATURE 0x03\r | |
116 | \r | |
117 | #define USB_DEV_SET_ADDRESS 0x05\r | |
118 | #define USB_DEV_SET_ADDRESS_REQ_TYPE 0x00\r | |
119 | \r | |
120 | #define USB_DEV_GET_DESCRIPTOR 0x06\r | |
121 | #define USB_DEV_GET_DESCRIPTOR_REQ_TYPE 0x80\r | |
122 | \r | |
123 | #define USB_DEV_SET_DESCRIPTOR 0x07\r | |
124 | #define USB_DEV_SET_DESCRIPTOR_REQ_TYPE 0x00\r | |
125 | \r | |
126 | #define USB_DEV_GET_CONFIGURATION 0x08\r | |
127 | #define USB_DEV_GET_CONFIGURATION_REQ_TYPE 0x80\r | |
128 | \r | |
129 | #define USB_DEV_SET_CONFIGURATION 0x09\r | |
130 | #define USB_DEV_SET_CONFIGURATION_REQ_TYPE 0x00\r | |
131 | \r | |
132 | #define USB_DEV_GET_INTERFACE 0x0A\r | |
133 | #define USB_DEV_GET_INTERFACE_REQ_TYPE 0x81\r | |
134 | \r | |
135 | #define USB_DEV_SET_INTERFACE 0x0B\r | |
136 | #define USB_DEV_SET_INTERFACE_REQ_TYPE 0x01\r | |
137 | \r | |
138 | #define USB_DEV_SYNCH_FRAME 0x0C\r | |
139 | #define USB_DEV_SYNCH_FRAME_REQ_TYPE 0x82\r | |
140 | \r | |
141 | //\r | |
142 | // Device descriptor. refer USB1.1\r | |
143 | //\r | |
144 | typedef struct usb_device_descriptor {\r | |
145 | UINT8 Length;\r | |
146 | UINT8 DescriptorType;\r | |
147 | UINT16 BcdUSB;\r | |
148 | UINT8 DeviceClass;\r | |
149 | UINT8 DeviceSubClass;\r | |
150 | UINT8 DeviceProtocol;\r | |
151 | UINT8 MaxPacketSize0;\r | |
152 | UINT16 IdVendor;\r | |
153 | UINT16 IdProduct;\r | |
154 | UINT16 BcdDevice;\r | |
155 | UINT8 StrManufacturer;\r | |
156 | UINT8 StrProduct;\r | |
157 | UINT8 StrSerialNumber;\r | |
158 | UINT8 NumConfigurations;\r | |
159 | } EFI_USB_DEVICE_DESCRIPTOR;\r | |
160 | \r | |
161 | //\r | |
162 | // Endpoint descriptor\r | |
163 | //\r | |
164 | typedef struct {\r | |
165 | UINT8 Length;\r | |
166 | UINT8 DescriptorType;\r | |
167 | UINT8 EndpointAddress;\r | |
168 | UINT8 Attributes;\r | |
169 | UINT16 MaxPacketSize;\r | |
170 | UINT8 Interval;\r | |
171 | } EFI_USB_ENDPOINT_DESCRIPTOR;\r | |
172 | \r | |
173 | //\r | |
174 | // Interface descriptor\r | |
175 | //\r | |
176 | typedef struct {\r | |
177 | UINT8 Length;\r | |
178 | UINT8 DescriptorType;\r | |
179 | UINT8 InterfaceNumber;\r | |
180 | UINT8 AlternateSetting;\r | |
181 | UINT8 NumEndpoints;\r | |
182 | UINT8 InterfaceClass;\r | |
183 | UINT8 InterfaceSubClass;\r | |
184 | UINT8 InterfaceProtocol;\r | |
185 | UINT8 Interface;\r | |
186 | } EFI_USB_INTERFACE_DESCRIPTOR;\r | |
187 | \r | |
188 | //\r | |
189 | // USB alternate setting\r | |
190 | //\r | |
191 | typedef struct {\r | |
192 | EFI_USB_INTERFACE_DESCRIPTOR *Interface;\r | |
193 | } USB_ALT_SETTING;\r | |
194 | \r | |
195 | //\r | |
196 | // Configuration descriptor\r | |
197 | //\r | |
198 | typedef struct {\r | |
199 | UINT8 Length;\r | |
200 | UINT8 DescriptorType;\r | |
201 | UINT16 TotalLength;\r | |
202 | UINT8 NumInterfaces;\r | |
203 | UINT8 ConfigurationValue;\r | |
204 | UINT8 Configuration;\r | |
205 | UINT8 Attributes;\r | |
206 | UINT8 MaxPower;\r | |
207 | } EFI_USB_CONFIG_DESCRIPTOR;\r | |
208 | \r | |
209 | //\r | |
210 | // Supported String Languages\r | |
211 | //\r | |
212 | typedef struct {\r | |
213 | UINT8 Length;\r | |
214 | UINT8 DescriptorType;\r | |
215 | UINT16 SupportedLanID[1];\r | |
216 | } EFI_USB_SUPPORTED_LANGUAGES;\r | |
217 | \r | |
218 | //\r | |
219 | // String descriptor\r | |
220 | //\r | |
221 | typedef struct {\r | |
222 | UINT8 Length;\r | |
223 | UINT8 DescriptorType;\r | |
224 | CHAR16 String[1];\r | |
225 | } EFI_USB_STRING_DESCRIPTOR;\r | |
226 | \r | |
227 | //\r | |
228 | // Hub descriptor\r | |
229 | //\r | |
230 | #define MAXBYTES 8\r | |
231 | typedef struct {\r | |
232 | UINT8 Length;\r | |
233 | UINT8 DescriptorType;\r | |
234 | UINT8 NbrPorts;\r | |
235 | UINT8 HubCharacteristics[2];\r | |
236 | UINT8 PwrOn2PwrGood;\r | |
237 | UINT8 HubContrCurrent;\r | |
238 | UINT8 Filler[MAXBYTES];\r | |
239 | } EFI_USB_HUB_DESCRIPTOR;\r | |
240 | \r | |
241 | typedef struct {\r | |
242 | UINT16 PortStatus;\r | |
243 | UINT16 PortChangeStatus;\r | |
244 | } EFI_USB_PORT_STATUS;\r | |
245 | \r | |
246 | //\r | |
247 | // Constant value for Port Status & Port Change Status\r | |
248 | //\r | |
249 | #define USB_PORT_STAT_CONNECTION 0x0001\r | |
250 | #define USB_PORT_STAT_ENABLE 0x0002\r | |
251 | #define USB_PORT_STAT_SUSPEND 0x0004\r | |
252 | #define USB_PORT_STAT_OVERCURRENT 0x0008\r | |
253 | #define USB_PORT_STAT_RESET 0x0010\r | |
254 | #define USB_PORT_STAT_POWER 0x0100\r | |
255 | #define USB_PORT_STAT_LOW_SPEED 0x0200\r | |
256 | #define USB_PORT_STAT_HIGH_SPEED 0x0400\r | |
257 | #define USB_PORT_STAT_OWNER 0x0800\r | |
258 | \r | |
259 | #define USB_PORT_STAT_C_CONNECTION 0x0001\r | |
260 | #define USB_PORT_STAT_C_ENABLE 0x0002\r | |
261 | #define USB_PORT_STAT_C_SUSPEND 0x0004\r | |
262 | #define USB_PORT_STAT_C_OVERCURRENT 0x0008\r | |
263 | #define USB_PORT_STAT_C_RESET 0x0010\r | |
264 | \r | |
265 | //\r | |
266 | // Used for set/clear port feature request\r | |
267 | //\r | |
268 | typedef enum {\r | |
269 | EfiUsbPortEnable = 1,\r | |
270 | EfiUsbPortSuspend = 2,\r | |
271 | EfiUsbPortReset = 4,\r | |
272 | EfiUsbPortPower = 8,\r | |
273 | EfiUsbPortOwner = 13,\r | |
274 | EfiUsbPortConnectChange = 16,\r | |
275 | EfiUsbPortEnableChange = 17,\r | |
276 | EfiUsbPortSuspendChange = 18,\r | |
277 | EfiUsbPortOverCurrentChange = 19,\r | |
278 | EfiUsbPortResetChange = 20\r | |
279 | } EFI_USB_PORT_FEATURE;\r | |
280 | \r | |
281 | #pragma pack()\r | |
282 | \r | |
283 | #endif\r |