]> git.proxmox.com Git - mirror_edk2.git/blame - EdkCompatibilityPkg/Foundation/Include/IndustryStandard/usb.h
Update the copyright notice format
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Include / IndustryStandard / usb.h
CommitLineData
3eb9473e 1/*++\r
2\r
f57387d5
HT
3Copyright (c) 2004 - 2007, Intel Corporation. All rights reserved.<BR>\r
4This program and the accompanying materials \r
3eb9473e 5are licensed and made available under the terms and conditions of the BSD License \r
6which accompanies this distribution. The full text of the license may be found at \r
7http://opensource.org/licenses/bsd-license.php \r
8 \r
9THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
10WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
11\r
12Module Name:\r
13\r
14 usb.h\r
15\r
16Abstract:\r
c7f33ca4 17 Support for USB standard.\r
3eb9473e 18\r
19\r
20\r
21\r
22Revision History\r
23\r
24--*/\r
25\r
c7f33ca4 26#ifndef _USB_INDUSTRY_H_\r
27#define _USB_INDUSTRY_H_\r
28\r
29//\r
30// USB Transfer Results\r
31//\r
32#define EFI_USB_NOERROR 0x00\r
33#define EFI_USB_ERR_NOTEXECUTE 0x01\r
34#define EFI_USB_ERR_STALL 0x02\r
35#define EFI_USB_ERR_BUFFER 0x04\r
36#define EFI_USB_ERR_BABBLE 0x08\r
37#define EFI_USB_ERR_NAK 0x10\r
38#define EFI_USB_ERR_CRC 0x20\r
39#define EFI_USB_ERR_TIMEOUT 0x40\r
40#define EFI_USB_ERR_BITSTUFF 0x80\r
41#define EFI_USB_ERR_SYSTEM 0x100\r
42\r
43//\r
44// Constant value for Port Status & Port Change Status\r
45//\r
46#define USB_PORT_STAT_CONNECTION 0x0001\r
47#define USB_PORT_STAT_ENABLE 0x0002\r
48#define USB_PORT_STAT_SUSPEND 0x0004\r
49#define USB_PORT_STAT_OVERCURRENT 0x0008\r
50#define USB_PORT_STAT_RESET 0x0010\r
51#define USB_PORT_STAT_POWER 0x0100\r
52#define USB_PORT_STAT_LOW_SPEED 0x0200\r
53#define USB_PORT_STAT_HIGH_SPEED 0x0400\r
54#define USB_PORT_STAT_OWNER 0x0800\r
55\r
56#define USB_PORT_STAT_C_CONNECTION 0x0001\r
57#define USB_PORT_STAT_C_ENABLE 0x0002\r
58#define USB_PORT_STAT_C_SUSPEND 0x0004\r
59#define USB_PORT_STAT_C_OVERCURRENT 0x0008\r
60#define USB_PORT_STAT_C_RESET 0x0010\r
61\r
62//\r
63// Usb data transfer direction\r
64//\r
65typedef enum {\r
66 EfiUsbDataIn,\r
67 EfiUsbDataOut,\r
68 EfiUsbNoData\r
69} EFI_USB_DATA_DIRECTION;\r
70\r
71//\r
72// Usb data recipient type\r
73//\r
74typedef enum {\r
75 EfiUsbDevice,\r
76 EfiUsbInterface,\r
77 EfiUsbEndpoint\r
78} EFI_USB_RECIPIENT;\r
79\r
80//\r
81// Usb port features\r
82//\r
83typedef enum {\r
84 EfiUsbPortEnable = 1,\r
85 EfiUsbPortSuspend = 2,\r
86 EfiUsbPortReset = 4,\r
87 EfiUsbPortPower = 8,\r
88 EfiUsbPortOwner = 13,\r
89 EfiUsbPortConnectChange = 16,\r
90 EfiUsbPortEnableChange = 17,\r
91 EfiUsbPortSuspendChange = 18,\r
92 EfiUsbPortOverCurrentChange = 19,\r
93 EfiUsbPortResetChange = 20\r
94} EFI_USB_PORT_FEATURE;\r
95\r
96//\r
97// Following are definitions not specified by UEFI spec.\r
98// Add new definitions below this line\r
99//\r
100enum {\r
101 //\r
102 // USB request type\r
103 //\r
104 USB_REQ_TYPE_STANDARD = (0x00 << 5),\r
105 USB_REQ_TYPE_CLASS = (0x01 << 5),\r
106 USB_REQ_TYPE_VENDOR = (0x02 << 5),\r
107\r
108 //\r
109 // Standard control transfer request type, or the value \r
110 // to fill in EFI_USB_DEVICE_REQUEST.Request\r
111 //\r
112 USB_REQ_GET_STATUS = 0x00,\r
113 USB_REQ_CLEAR_FEATURE = 0x01,\r
114 USB_REQ_SET_FEATURE = 0x03,\r
115 USB_REQ_SET_ADDRESS = 0x05,\r
116 USB_REQ_GET_DESCRIPTOR = 0x06,\r
117 USB_REQ_SET_DESCRIPTOR = 0x07,\r
118 USB_REQ_GET_CONFIG = 0x08,\r
119 USB_REQ_SET_CONFIG = 0x09,\r
120 USB_REQ_GET_INTERFACE = 0x0A,\r
121 USB_REQ_SET_INTERFACE = 0x0B,\r
122 USB_REQ_SYNCH_FRAME = 0x0C,\r
123\r
124 //\r
125 // Usb control transfer target \r
126 //\r
127 USB_TARGET_DEVICE = 0,\r
128 USB_TARGET_INTERFACE = 0x01,\r
129 USB_TARGET_ENDPOINT = 0x02,\r
130 USB_TARGET_OTHER = 0x03,\r
131\r
132 //\r
133 // USB Descriptor types\r
134 //\r
135 USB_DESC_TYPE_DEVICE = 0x01,\r
136 USB_DESC_TYPE_CONFIG = 0x02,\r
137 USB_DESC_TYPE_STRING = 0x03,\r
138 USB_DESC_TYPE_INTERFACE = 0x04,\r
139 USB_DESC_TYPE_ENDPOINT = 0x05,\r
140 USB_DESC_TYPE_HID = 0x21,\r
141\r
142 //\r
143 // Features to be cleared by CLEAR_FEATURE requests\r
144 //\r
145 USB_FEATURE_ENDPOINT_HALT = 0,\r
146 \r
147 //\r
148 // USB endpoint types: 00: control, 01: isochronous, 10: bulk, 11: interrupt\r
149 // \r
150 USB_ENDPOINT_CONTROL = 0x00,\r
151 USB_ENDPOINT_ISO = 0x01,\r
152 USB_ENDPOINT_BULK = 0x02,\r
153 USB_ENDPOINT_INTERRUPT = 0x03,\r
154\r
155 USB_ENDPOINT_TYPE_MASK = 0x03,\r
156 USB_ENDPOINT_DIR_IN = 0x80,\r
157\r
158 MAXBYTES = 8,\r
159 \r
160 //\r
161 //Use 200 ms to increase the error handling response time\r
162 //\r
4cb43192 163 EFI_USB_INTERRUPT_DELAY = 2000000\r
c7f33ca4 164};\r
165\r
166\r
167//\r
168// USB standard descriptors and reqeust \r
169//\r
170#pragma pack(1)\r
171\r
172typedef struct {\r
173 UINT8 RequestType;\r
174 UINT8 Request;\r
175 UINT16 Value;\r
176 UINT16 Index;\r
177 UINT16 Length;\r
178} EFI_USB_DEVICE_REQUEST;\r
179\r
180typedef struct {\r
181 UINT8 Length;\r
182 UINT8 DescriptorType;\r
183 UINT16 BcdUSB;\r
184 UINT8 DeviceClass;\r
185 UINT8 DeviceSubClass;\r
186 UINT8 DeviceProtocol;\r
187 UINT8 MaxPacketSize0;\r
188 UINT16 IdVendor;\r
189 UINT16 IdProduct;\r
190 UINT16 BcdDevice;\r
191 UINT8 StrManufacturer;\r
192 UINT8 StrProduct;\r
193 UINT8 StrSerialNumber;\r
194 UINT8 NumConfigurations;\r
195} EFI_USB_DEVICE_DESCRIPTOR;\r
196\r
197typedef struct {\r
198 UINT8 Length;\r
199 UINT8 DescriptorType;\r
200 UINT16 TotalLength;\r
201 UINT8 NumInterfaces;\r
202 UINT8 ConfigurationValue;\r
203 UINT8 Configuration;\r
204 UINT8 Attributes;\r
205 UINT8 MaxPower;\r
206} EFI_USB_CONFIG_DESCRIPTOR;\r
207\r
208typedef struct {\r
209 UINT8 Length;\r
210 UINT8 DescriptorType;\r
211 UINT8 InterfaceNumber;\r
212 UINT8 AlternateSetting;\r
213 UINT8 NumEndpoints;\r
214 UINT8 InterfaceClass;\r
215 UINT8 InterfaceSubClass;\r
216 UINT8 InterfaceProtocol;\r
217 UINT8 Interface;\r
218} EFI_USB_INTERFACE_DESCRIPTOR;\r
219\r
220typedef struct {\r
221 UINT8 Length;\r
222 UINT8 DescriptorType;\r
223 UINT8 EndpointAddress;\r
224 UINT8 Attributes;\r
225 UINT16 MaxPacketSize;\r
226 UINT8 Interval;\r
227} EFI_USB_ENDPOINT_DESCRIPTOR;\r
228\r
229typedef struct {\r
230 UINT8 Length;\r
231 UINT8 DescriptorType;\r
232 CHAR16 String[1];\r
233} EFI_USB_STRING_DESCRIPTOR;\r
234\r
235typedef struct {\r
236 UINT16 PortStatus;\r
237 UINT16 PortChangeStatus;\r
238} EFI_USB_PORT_STATUS;\r
239\r
240typedef struct {\r
241 UINT8 Length;\r
242 UINT8 DescriptorType;\r
243 UINT8 NbrPorts;\r
244 UINT8 HubCharacteristics[2];\r
245 UINT8 PwrOn2PwrGood;\r
246 UINT8 HubContrCurrent;\r
247 UINT8 Filler[MAXBYTES];\r
248} EFI_USB_HUB_DESCRIPTOR;\r
249\r
250#pragma pack()\r
251\r
252\r
253///////////////////////////////////////////////////////////////////////////\r
254/////////////////// Backward Compatibility ///////////////////\r
255///////////////////////////////////////////////////////////////////////////\r
256\r
3eb9473e 257//\r
258// USB Descriptor types\r
259//\r
260#define USB_DT_DEVICE 0x01\r
261#define USB_DT_CONFIG 0x02\r
262#define USB_DT_STRING 0x03\r
263#define USB_DT_INTERFACE 0x04\r
264#define USB_DT_ENDPOINT 0x05\r
265#define USB_DT_HUB 0x29\r
266#define USB_DT_HID 0x21\r
267\r
268//\r
269// USB request type\r
270//\r
271#define USB_TYPE_STANDARD (0x00 << 5)\r
272#define USB_TYPE_CLASS (0x01 << 5)\r
273#define USB_TYPE_VENDOR (0x02 << 5)\r
274#define USB_TYPE_RESERVED (0x03 << 5)\r
275\r
276//\r
277// USB request targer device\r
278//\r
279#define USB_RECIP_DEVICE 0x00\r
280#define USB_RECIP_INTERFACE 0x01\r
281#define USB_RECIP_ENDPOINT 0x02\r
282#define USB_RECIP_OTHER 0x03\r
283\r
284//\r
285// Request target types.\r
286//\r
287#define USB_RT_DEVICE 0x00\r
288#define USB_RT_INTERFACE 0x01\r
289#define USB_RT_ENDPOINT 0x02\r
290#define USB_RT_HUB (USB_TYPE_CLASS | USB_RECIP_DEVICE)\r
291#define USB_RT_PORT (USB_TYPE_CLASS | USB_RECIP_OTHER)\r
292\r
3eb9473e 293typedef enum {\r
294 EfiUsbEndpointHalt,\r
295 EfiUsbDeviceRemoteWakeup\r
296} EFI_USB_STANDARD_FEATURE_SELECTOR;\r
297\r
3eb9473e 298//\r
299// Standard USB request\r
300//\r
301#define USB_DEV_GET_STATUS 0x00\r
3eb9473e 302#define USB_DEV_CLEAR_FEATURE 0x01\r
3eb9473e 303#define USB_DEV_SET_FEATURE 0x03\r
3eb9473e 304#define USB_DEV_SET_ADDRESS 0x05\r
305#define USB_DEV_SET_ADDRESS_REQ_TYPE 0x00\r
3eb9473e 306#define USB_DEV_GET_DESCRIPTOR 0x06\r
307#define USB_DEV_GET_DESCRIPTOR_REQ_TYPE 0x80\r
3eb9473e 308#define USB_DEV_SET_DESCRIPTOR 0x07\r
309#define USB_DEV_SET_DESCRIPTOR_REQ_TYPE 0x00\r
3eb9473e 310#define USB_DEV_GET_CONFIGURATION 0x08\r
311#define USB_DEV_GET_CONFIGURATION_REQ_TYPE 0x80\r
3eb9473e 312#define USB_DEV_SET_CONFIGURATION 0x09\r
313#define USB_DEV_SET_CONFIGURATION_REQ_TYPE 0x00\r
3eb9473e 314#define USB_DEV_GET_INTERFACE 0x0A\r
315#define USB_DEV_GET_INTERFACE_REQ_TYPE 0x81\r
3eb9473e 316#define USB_DEV_SET_INTERFACE 0x0B\r
317#define USB_DEV_SET_INTERFACE_REQ_TYPE 0x01\r
3eb9473e 318#define USB_DEV_SYNCH_FRAME 0x0C\r
319#define USB_DEV_SYNCH_FRAME_REQ_TYPE 0x82\r
320\r
c7f33ca4 321#pragma pack(1)\r
3eb9473e 322//\r
323// Supported String Languages\r
324//\r
325typedef struct {\r
326 UINT8 Length;\r
327 UINT8 DescriptorType;\r
328 UINT16 SupportedLanID[1];\r
329} EFI_USB_SUPPORTED_LANGUAGES;\r
330\r
331//\r
c7f33ca4 332// USB alternate setting\r
3eb9473e 333//\r
3eb9473e 334typedef struct {\r
c7f33ca4 335 EFI_USB_INTERFACE_DESCRIPTOR *Interface;\r
336} USB_ALT_SETTING;\r
3eb9473e 337\r
338#pragma pack()\r
339\r
c7f33ca4 340///////////////////////////////////////////////////////////////////////////\r
341///////////////////////////////////////////////////////////////////////////\r
342///////////////////////////////////////////////////////////////////////////\r
343\r
3eb9473e 344#endif\r