Browse Source

[efi] Add USB headers and GUID definitions

Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 8 years ago
parent
commit
fa18bc4205

+ 362
- 0
src/include/ipxe/efi/IndustryStandard/Usb.h View File

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

+ 603
- 0
src/include/ipxe/efi/Protocol/Usb2HostController.h View File

@@ -0,0 +1,603 @@
1
+/** @file
2
+  EFI_USB2_HC_PROTOCOL as defined in UEFI 2.0.
3
+  The USB Host Controller Protocol is used by code, typically USB bus drivers,
4
+  running in the EFI boot services environment, to perform data transactions over
5
+  a USB bus. In addition, it provides an abstraction for the root hub of the USB bus.
6
+
7
+  Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
8
+  This program and the accompanying materials
9
+  are licensed and made available under the terms and conditions of the BSD License
10
+  which accompanies this distribution.  The full text of the license may be found at
11
+  http://opensource.org/licenses/bsd-license.php
12
+
13
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15
+
16
+**/
17
+
18
+#ifndef _USB2_HOSTCONTROLLER_H_
19
+#define _USB2_HOSTCONTROLLER_H_
20
+
21
+FILE_LICENCE ( BSD3 );
22
+
23
+#include <ipxe/efi/Protocol/UsbIo.h>
24
+
25
+#define EFI_USB2_HC_PROTOCOL_GUID \
26
+  { \
27
+    0x3e745226, 0x9818, 0x45b6, {0xa2, 0xac, 0xd7, 0xcd, 0xe, 0x8b, 0xa2, 0xbc } \
28
+  }
29
+
30
+///
31
+/// Forward reference for pure ANSI compatability
32
+///
33
+typedef struct _EFI_USB2_HC_PROTOCOL EFI_USB2_HC_PROTOCOL;
34
+
35
+
36
+typedef struct {
37
+  UINT16          PortStatus;        ///< Contains current port status bitmap.
38
+  UINT16          PortChangeStatus;  ///< Contains current port status change bitmap.
39
+} EFI_USB_PORT_STATUS;
40
+
41
+///
42
+/// EFI_USB_PORT_STATUS.PortStatus bit definition
43
+///
44
+#define USB_PORT_STAT_CONNECTION    0x0001
45
+#define USB_PORT_STAT_ENABLE        0x0002
46
+#define USB_PORT_STAT_SUSPEND       0x0004
47
+#define USB_PORT_STAT_OVERCURRENT   0x0008
48
+#define USB_PORT_STAT_RESET         0x0010
49
+#define USB_PORT_STAT_POWER         0x0100
50
+#define USB_PORT_STAT_LOW_SPEED     0x0200
51
+#define USB_PORT_STAT_HIGH_SPEED    0x0400
52
+#define USB_PORT_STAT_SUPER_SPEED   0x0800
53
+#define USB_PORT_STAT_OWNER         0x2000
54
+
55
+///
56
+/// EFI_USB_PORT_STATUS.PortChangeStatus bit definition
57
+///
58
+#define USB_PORT_STAT_C_CONNECTION  0x0001
59
+#define USB_PORT_STAT_C_ENABLE      0x0002
60
+#define USB_PORT_STAT_C_SUSPEND     0x0004
61
+#define USB_PORT_STAT_C_OVERCURRENT 0x0008
62
+#define USB_PORT_STAT_C_RESET       0x0010
63
+
64
+
65
+///
66
+/// Usb port features value
67
+/// Each value indicates its bit index in the port status and status change bitmaps,
68
+/// if combines these two bitmaps into a 32-bit bitmap.
69
+///
70
+typedef enum {
71
+  EfiUsbPortEnable            = 1,
72
+  EfiUsbPortSuspend           = 2,
73
+  EfiUsbPortReset             = 4,
74
+  EfiUsbPortPower             = 8,
75
+  EfiUsbPortOwner             = 13,
76
+  EfiUsbPortConnectChange     = 16,
77
+  EfiUsbPortEnableChange      = 17,
78
+  EfiUsbPortSuspendChange     = 18,
79
+  EfiUsbPortOverCurrentChange = 19,
80
+  EfiUsbPortResetChange       = 20
81
+} EFI_USB_PORT_FEATURE;
82
+
83
+#define EFI_USB_SPEED_FULL      0x0000  ///< 12 Mb/s, USB 1.1 OHCI and UHCI HC.
84
+#define EFI_USB_SPEED_LOW       0x0001  ///< 1 Mb/s, USB 1.1 OHCI and UHCI HC.
85
+#define EFI_USB_SPEED_HIGH      0x0002  ///< 480 Mb/s, USB 2.0 EHCI HC.
86
+#define EFI_USB_SPEED_SUPER     0x0003  ///< 4.8 Gb/s, USB 3.0 XHCI HC.
87
+
88
+typedef struct {
89
+  UINT8      TranslatorHubAddress; ///< device address
90
+  UINT8      TranslatorPortNumber; ///< the port number of the hub that device is connected to.
91
+} EFI_USB2_HC_TRANSACTION_TRANSLATOR;
92
+
93
+//
94
+// Protocol definitions
95
+//
96
+
97
+/**
98
+  Retrieves the Host Controller capabilities.
99
+
100
+  @param  This           A pointer to the EFI_USB2_HC_PROTOCOL instance.
101
+  @param  MaxSpeed       Host controller data transfer speed.
102
+  @param  PortNumber     Number of the root hub ports.
103
+  @param  Is64BitCapable TRUE if controller supports 64-bit memory addressing,
104
+                         FALSE otherwise.
105
+
106
+  @retval EFI_SUCCESS           The host controller capabilities were retrieved successfully.
107
+  @retval EFI_INVALID_PARAMETER One of the input args was NULL.
108
+  @retval EFI_DEVICE_ERROR      An error was encountered while attempting to
109
+                                retrieve the capabilities.
110
+
111
+**/
112
+typedef
113
+EFI_STATUS
114
+(EFIAPI *EFI_USB2_HC_PROTOCOL_GET_CAPABILITY)(
115
+  IN  EFI_USB2_HC_PROTOCOL  *This,
116
+  OUT UINT8                 *MaxSpeed,
117
+  OUT UINT8                 *PortNumber,
118
+  OUT UINT8                 *Is64BitCapable
119
+  );
120
+
121
+#define EFI_USB_HC_RESET_GLOBAL             0x0001
122
+#define EFI_USB_HC_RESET_HOST_CONTROLLER    0x0002
123
+#define EFI_USB_HC_RESET_GLOBAL_WITH_DEBUG  0x0004
124
+#define EFI_USB_HC_RESET_HOST_WITH_DEBUG    0x0008
125
+/**
126
+  Provides software reset for the USB host controller.
127
+
128
+  @param  This       A pointer to the EFI_USB2_HC_PROTOCOL instance.
129
+  @param  Attributes A bit mask of the reset operation to perform.
130
+
131
+  @retval EFI_SUCCESS           The reset operation succeeded.
132
+  @retval EFI_INVALID_PARAMETER Attributes is not valid.
133
+  @retval EFI_UNSUPPORTED       The type of reset specified by Attributes is not currently
134
+                                supported by the host controller hardware.
135
+  @retval EFI_ACCESS_DENIED     Reset operation is rejected due to the debug port being configured
136
+                                and active; only EFI_USB_HC_RESET_GLOBAL_WITH_DEBUG or
137
+                                EFI_USB_HC_RESET_HOST_WITH_DEBUG reset Attributes can be used to
138
+                                perform reset operation for this host controller.
139
+  @retval EFI_DEVICE_ERROR      An error was encountered while attempting to
140
+                                retrieve the capabilities.
141
+
142
+**/
143
+typedef
144
+EFI_STATUS
145
+(EFIAPI *EFI_USB2_HC_PROTOCOL_RESET)(
146
+  IN EFI_USB2_HC_PROTOCOL   *This,
147
+  IN UINT16                 Attributes
148
+  );
149
+
150
+/**
151
+  Enumration value for status of USB HC.
152
+**/
153
+typedef enum {
154
+  EfiUsbHcStateHalt,                ///< The host controller is in halt
155
+                                    ///< state. No USB transactions can occur
156
+                                    ///< while in this state. The host
157
+                                    ///< controller can enter this state for
158
+                                    ///< three reasons: 1) After host
159
+                                    ///< controller hardware reset. 2)
160
+                                    ///< Explicitly set by software. 3)
161
+                                    ///< Triggered by a fatal error such as
162
+                                    ///< consistency check failure.
163
+
164
+  EfiUsbHcStateOperational,         ///< The host controller is in an
165
+                                    ///< operational state. When in
166
+                                    ///< this state, the host
167
+                                    ///< controller can execute bus
168
+                                    ///< traffic. This state must be
169
+                                    ///< explicitly set to enable the
170
+                                    ///< USB bus traffic.
171
+
172
+  EfiUsbHcStateSuspend,             ///< The host controller is in the
173
+                                    ///< suspend state. No USB
174
+                                    ///< transactions can occur while in
175
+                                    ///< this state. The host controller
176
+                                    ///< enters this state for the
177
+                                    ///< following reasons: 1) Explicitly
178
+                                    ///< set by software. 2) Triggered
179
+                                    ///< when there is no bus traffic for
180
+                                    ///< 3 microseconds.
181
+
182
+  EfiUsbHcStateMaximum              ///< Maximum value for enumration value of HC status.
183
+} EFI_USB_HC_STATE;
184
+
185
+/**
186
+  Retrieves current state of the USB host controller.
187
+
188
+  @param  This  A pointer to the EFI_USB2_HC_PROTOCOL instance.
189
+  @param  State A pointer to the EFI_USB_HC_STATE data structure that
190
+                indicates current state of the USB host controller.
191
+
192
+  @retval EFI_SUCCESS           The state information of the host controller was returned in State.
193
+  @retval EFI_INVALID_PARAMETER State is NULL.
194
+  @retval EFI_DEVICE_ERROR      An error was encountered while attempting to retrieve the
195
+                                host controller's current state.
196
+
197
+**/
198
+typedef
199
+EFI_STATUS
200
+(EFIAPI *EFI_USB2_HC_PROTOCOL_GET_STATE)(
201
+  IN        EFI_USB2_HC_PROTOCOL    *This,
202
+  OUT       EFI_USB_HC_STATE        *State
203
+);
204
+
205
+/**
206
+  Sets the USB host controller to a specific state.
207
+
208
+  @param  This  A pointer to the EFI_USB2_HC_PROTOCOL instance.
209
+  @param  State Indicates the state of the host controller that will be set.
210
+
211
+  @retval EFI_SUCCESS           The USB host controller was successfully placed in the state
212
+                                specified by State.
213
+  @retval EFI_INVALID_PARAMETER State is not valid.
214
+  @retval EFI_DEVICE_ERROR      Failed to set the state specified by State due to device error.
215
+
216
+**/
217
+typedef
218
+EFI_STATUS
219
+(EFIAPI *EFI_USB2_HC_PROTOCOL_SET_STATE)(
220
+  IN EFI_USB2_HC_PROTOCOL    *This,
221
+  IN EFI_USB_HC_STATE        State
222
+  );
223
+
224
+/**
225
+  Submits control transfer to a target USB device.
226
+
227
+  @param  This                A pointer to the EFI_USB2_HC_PROTOCOL instance.
228
+  @param  DeviceAddress       Represents the address of the target device on the USB.
229
+  @param  DeviceSpeed         Indicates device speed.
230
+  @param  MaximumPacketLength Indicates the maximum packet size that the default control transfer
231
+                              endpoint is capable of sending or receiving.
232
+  @param  Request             A pointer to the USB device request that will be sent to the USB device.
233
+  @param  TransferDirection   Specifies the data direction for the transfer. There are three values
234
+                              available, EfiUsbDataIn, EfiUsbDataOut and EfiUsbNoData.
235
+  @param  Data                A pointer to the buffer of data that will be transmitted to USB device or
236
+                              received from USB device.
237
+  @param  DataLength          On input, indicates the size, in bytes, of the data buffer specified by Data.
238
+                              On output, indicates the amount of data actually transferred.
239
+  @param  TimeOut             Indicates the maximum time, in milliseconds, which the transfer is
240
+                              allowed to complete.
241
+  @param  Translator          A pointer to the transaction translator data.
242
+  @param  TransferResult      A pointer to the detailed result information generated by this control
243
+                              transfer.
244
+
245
+  @retval EFI_SUCCESS           The control transfer was completed successfully.
246
+  @retval EFI_INVALID_PARAMETER Some parameters are invalid.
247
+  @retval EFI_OUT_OF_RESOURCES  The control transfer could not be completed due to a lack of resources.
248
+  @retval EFI_TIMEOUT           The control transfer failed due to timeout.
249
+  @retval EFI_DEVICE_ERROR      The control transfer failed due to host controller or device error.
250
+                                Caller should check TransferResult for detailed error information.
251
+
252
+**/
253
+typedef
254
+EFI_STATUS
255
+(EFIAPI *EFI_USB2_HC_PROTOCOL_CONTROL_TRANSFER)(
256
+  IN     EFI_USB2_HC_PROTOCOL               *This,
257
+  IN     UINT8                              DeviceAddress,
258
+  IN     UINT8                              DeviceSpeed,
259
+  IN     UINTN                              MaximumPacketLength,
260
+  IN     EFI_USB_DEVICE_REQUEST             *Request,
261
+  IN     EFI_USB_DATA_DIRECTION             TransferDirection,
262
+  IN OUT VOID                               *Data       OPTIONAL,
263
+  IN OUT UINTN                              *DataLength OPTIONAL,
264
+  IN     UINTN                              TimeOut,
265
+  IN     EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,
266
+  OUT    UINT32                             *TransferResult
267
+  );
268
+
269
+#define EFI_USB_MAX_BULK_BUFFER_NUM 10
270
+
271
+/**
272
+  Submits bulk transfer to a bulk endpoint of a USB device.
273
+
274
+  @param  This                A pointer to the EFI_USB2_HC_PROTOCOL instance.
275
+  @param  DeviceAddress       Represents the address of the target device on the USB.
276
+  @param  EndPointAddress     The combination of an endpoint number and an endpoint direction of the
277
+                              target USB device.
278
+  @param  DeviceSpeed         Indicates device speed.
279
+  @param  MaximumPacketLength Indicates the maximum packet size the target endpoint is capable of
280
+                              sending or receiving.
281
+  @param  DataBuffersNumber   Number of data buffers prepared for the transfer.
282
+  @param  Data                Array of pointers to the buffers of data that will be transmitted to USB
283
+                              device or received from USB device.
284
+  @param  DataLength          When input, indicates the size, in bytes, of the data buffers specified by
285
+                              Data. When output, indicates the actually transferred data size.
286
+  @param  DataToggle          A pointer to the data toggle value.
287
+  @param  TimeOut             Indicates the maximum time, in milliseconds, which the transfer is
288
+                              allowed to complete.
289
+  @param  Translator          A pointer to the transaction translator data.
290
+  @param  TransferResult      A pointer to the detailed result information of the bulk transfer.
291
+
292
+  @retval EFI_SUCCESS           The bulk transfer was completed successfully.
293
+  @retval EFI_INVALID_PARAMETER Some parameters are invalid.
294
+  @retval EFI_OUT_OF_RESOURCES  The bulk transfer could not be submitted due to a lack of resources.
295
+  @retval EFI_TIMEOUT           The bulk transfer failed due to timeout.
296
+  @retval EFI_DEVICE_ERROR      The bulk transfer failed due to host controller or device error.
297
+                                Caller should check TransferResult for detailed error information.
298
+
299
+**/
300
+typedef
301
+EFI_STATUS
302
+(EFIAPI *EFI_USB2_HC_PROTOCOL_BULK_TRANSFER)(
303
+  IN     EFI_USB2_HC_PROTOCOL               *This,
304
+  IN     UINT8                              DeviceAddress,
305
+  IN     UINT8                              EndPointAddress,
306
+  IN     UINT8                              DeviceSpeed,
307
+  IN     UINTN                              MaximumPacketLength,
308
+  IN     UINT8                              DataBuffersNumber,
309
+  IN OUT VOID                               *Data[EFI_USB_MAX_BULK_BUFFER_NUM],
310
+  IN OUT UINTN                              *DataLength,
311
+  IN OUT UINT8                              *DataToggle,
312
+  IN     UINTN                              TimeOut,
313
+  IN     EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,
314
+  OUT    UINT32                             *TransferResult
315
+  );
316
+
317
+/**
318
+  Submits an asynchronous interrupt transfer to an interrupt endpoint of a USB device.
319
+  Translator parameter doesn't exist in UEFI2.0 spec, but it will be updated in the following specification version.
320
+
321
+  @param  This                A pointer to the EFI_USB2_HC_PROTOCOL instance.
322
+  @param  DeviceAddress       Represents the address of the target device on the USB.
323
+  @param  EndPointAddress     The combination of an endpoint number and an endpoint direction of the
324
+                              target USB device.
325
+  @param  DeviceSpeed         Indicates device speed.
326
+  @param  MaximumPacketLength Indicates the maximum packet size the target endpoint is capable of
327
+                              sending or receiving.
328
+  @param  IsNewTransfer       If TRUE, an asynchronous interrupt pipe is built between the host and the
329
+                              target interrupt endpoint. If FALSE, the specified asynchronous interrupt
330
+                              pipe is canceled. If TRUE, and an interrupt transfer exists for the target
331
+                              end point, then EFI_INVALID_PARAMETER is returned.
332
+  @param  DataToggle          A pointer to the data toggle value.
333
+  @param  PollingInterval     Indicates the interval, in milliseconds, that the asynchronous interrupt
334
+                              transfer is polled.
335
+  @param  DataLength          Indicates the length of data to be received at the rate specified by
336
+                              PollingInterval from the target asynchronous interrupt endpoint.
337
+  @param  Translator          A pointr to the transaction translator data.
338
+  @param  CallBackFunction    The Callback function. This function is called at the rate specified by
339
+                              PollingInterval.
340
+  @param  Context             The context that is passed to the CallBackFunction. This is an
341
+                              optional parameter and may be NULL.
342
+
343
+  @retval EFI_SUCCESS           The asynchronous interrupt transfer request has been successfully
344
+                                submitted or canceled.
345
+  @retval EFI_INVALID_PARAMETER Some parameters are invalid.
346
+  @retval EFI_OUT_OF_RESOURCES  The request could not be completed due to a lack of resources.
347
+
348
+**/
349
+typedef
350
+EFI_STATUS
351
+(EFIAPI *EFI_USB2_HC_PROTOCOL_ASYNC_INTERRUPT_TRANSFER)(
352
+  IN     EFI_USB2_HC_PROTOCOL                                *This,
353
+  IN     UINT8                                               DeviceAddress,
354
+  IN     UINT8                                               EndPointAddress,
355
+  IN     UINT8                                               DeviceSpeed,
356
+  IN     UINTN                                               MaxiumPacketLength,
357
+  IN     BOOLEAN                                             IsNewTransfer,
358
+  IN OUT UINT8                                               *DataToggle,
359
+  IN     UINTN                                               PollingInterval  OPTIONAL,
360
+  IN     UINTN                                               DataLength       OPTIONAL,
361
+  IN     EFI_USB2_HC_TRANSACTION_TRANSLATOR                  *Translator      OPTIONAL,
362
+  IN     EFI_ASYNC_USB_TRANSFER_CALLBACK                     CallBackFunction OPTIONAL,
363
+  IN     VOID                                                *Context         OPTIONAL
364
+  );
365
+
366
+/**
367
+  Submits synchronous interrupt transfer to an interrupt endpoint of a USB device.
368
+  Translator parameter doesn't exist in UEFI2.0 spec, but it will be updated in the following specification version.
369
+
370
+  @param  This                  A pointer to the EFI_USB2_HC_PROTOCOL instance.
371
+  @param  DeviceAddress         Represents the address of the target device on the USB.
372
+  @param  EndPointAddress       The combination of an endpoint number and an endpoint direction of the
373
+                                target USB device.
374
+  @param  DeviceSpeed           Indicates device speed.
375
+  @param  MaximumPacketLength   Indicates the maximum packet size the target endpoint is capable of
376
+                                sending or receiving.
377
+  @param  Data                  A pointer to the buffer of data that will be transmitted to USB device or
378
+                                received from USB device.
379
+  @param  DataLength            On input, the size, in bytes, of the data buffer specified by Data. On
380
+                                output, the number of bytes transferred.
381
+  @param  DataToggle            A pointer to the data toggle value.
382
+  @param  TimeOut               Indicates the maximum time, in milliseconds, which the transfer is
383
+                                allowed to complete.
384
+  @param  Translator            A pointr to the transaction translator data.
385
+  @param  TransferResult        A pointer to the detailed result information from the synchronous
386
+                                interrupt transfer.
387
+
388
+  @retval EFI_SUCCESS           The synchronous interrupt transfer was completed successfully.
389
+  @retval EFI_INVALID_PARAMETER Some parameters are invalid.
390
+  @retval EFI_OUT_OF_RESOURCES  The synchronous interrupt transfer could not be submitted due to a lack of resources.
391
+  @retval EFI_TIMEOUT           The synchronous interrupt transfer failed due to timeout.
392
+  @retval EFI_DEVICE_ERROR      The synchronous interrupt transfer failed due to host controller or device error.
393
+                                Caller should check TransferResult for detailed error information.
394
+
395
+**/
396
+typedef
397
+EFI_STATUS
398
+(EFIAPI *EFI_USB2_HC_PROTOCOL_SYNC_INTERRUPT_TRANSFER)(
399
+  IN     EFI_USB2_HC_PROTOCOL                        *This,
400
+  IN     UINT8                                       DeviceAddress,
401
+  IN     UINT8                                       EndPointAddress,
402
+  IN     UINT8                                       DeviceSpeed,
403
+  IN     UINTN                                       MaximumPacketLength,
404
+  IN OUT VOID                                        *Data,
405
+  IN OUT UINTN                                       *DataLength,
406
+  IN OUT UINT8                                       *DataToggle,
407
+  IN     UINTN                                       TimeOut,
408
+  IN     EFI_USB2_HC_TRANSACTION_TRANSLATOR          *Translator,
409
+  OUT    UINT32                                      *TransferResult
410
+  );
411
+
412
+#define EFI_USB_MAX_ISO_BUFFER_NUM  7
413
+#define EFI_USB_MAX_ISO_BUFFER_NUM1 2
414
+
415
+/**
416
+  Submits isochronous transfer to an isochronous endpoint of a USB device.
417
+
418
+  @param  This                  A pointer to the EFI_USB2_HC_PROTOCOL instance.
419
+  @param  DeviceAddress         Represents the address of the target device on the USB.
420
+  @param  EndPointAddress       The combination of an endpoint number and an endpoint direction of the
421
+                                target USB device.
422
+  @param  DeviceSpeed           Indicates device speed.
423
+  @param  MaximumPacketLength   Indicates the maximum packet size the target endpoint is capable of
424
+                                sending or receiving.
425
+  @param  DataBuffersNumber     Number of data buffers prepared for the transfer.
426
+  @param  Data                  Array of pointers to the buffers of data that will be transmitted to USB
427
+                                device or received from USB device.
428
+  @param  DataLength            Specifies the length, in bytes, of the data to be sent to or received from
429
+                                the USB device.
430
+  @param  Translator            A pointer to the transaction translator data.
431
+  @param  TransferResult        A pointer to the detailed result information of the isochronous transfer.
432
+
433
+  @retval EFI_SUCCESS           The isochronous transfer was completed successfully.
434
+  @retval EFI_INVALID_PARAMETER Some parameters are invalid.
435
+  @retval EFI_OUT_OF_RESOURCES  The isochronous transfer could not be submitted due to a lack of resources.
436
+  @retval EFI_TIMEOUT           The isochronous transfer cannot be completed within the one USB frame time.
437
+  @retval EFI_DEVICE_ERROR      The isochronous transfer failed due to host controller or device error.
438
+                                Caller should check TransferResult for detailed error information.
439
+
440
+**/
441
+typedef
442
+EFI_STATUS
443
+(EFIAPI *EFI_USB2_HC_PROTOCOL_ISOCHRONOUS_TRANSFER)(
444
+  IN     EFI_USB2_HC_PROTOCOL               *This,
445
+  IN     UINT8                              DeviceAddress,
446
+  IN     UINT8                              EndPointAddress,
447
+  IN     UINT8                              DeviceSpeed,
448
+  IN     UINTN                              MaximumPacketLength,
449
+  IN     UINT8                              DataBuffersNumber,
450
+  IN OUT VOID                               *Data[EFI_USB_MAX_ISO_BUFFER_NUM],
451
+  IN     UINTN                              DataLength,
452
+  IN     EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,
453
+  OUT    UINT32                             *TransferResult
454
+  );
455
+
456
+/**
457
+  Submits nonblocking isochronous transfer to an isochronous endpoint of a USB device.
458
+
459
+  @param  This                  A pointer to the EFI_USB2_HC_PROTOCOL instance.
460
+  @param  DeviceAddress         Represents the address of the target device on the USB.
461
+  @param  EndPointAddress       The combination of an endpoint number and an endpoint direction of the
462
+                                target USB device.
463
+  @param  DeviceSpeed           Indicates device speed.
464
+  @param  MaximumPacketLength   Indicates the maximum packet size the target endpoint is capable of
465
+                                sending or receiving.
466
+  @param  DataBuffersNumber     Number of data buffers prepared for the transfer.
467
+  @param  Data                  Array of pointers to the buffers of data that will be transmitted to USB
468
+                                device or received from USB device.
469
+  @param  DataLength            Specifies the length, in bytes, of the data to be sent to or received from
470
+                                the USB device.
471
+  @param  Translator            A pointer to the transaction translator data.
472
+  @param  IsochronousCallback   The Callback function. This function is called if the requested
473
+                                isochronous transfer is completed.
474
+  @param  Context               Data passed to the IsochronousCallback function. This is an
475
+                                optional parameter and may be NULL.
476
+
477
+  @retval EFI_SUCCESS           The asynchronous isochronous transfer request has been successfully
478
+                                submitted or canceled.
479
+  @retval EFI_INVALID_PARAMETER Some parameters are invalid.
480
+  @retval EFI_OUT_OF_RESOURCES  The asynchronous isochronous transfer could not be submitted due to
481
+                                a lack of resources.
482
+
483
+**/
484
+typedef
485
+EFI_STATUS
486
+(EFIAPI *EFI_USB2_HC_PROTOCOL_ASYNC_ISOCHRONOUS_TRANSFER)(
487
+  IN     EFI_USB2_HC_PROTOCOL               *This,
488
+  IN     UINT8                              DeviceAddress,
489
+  IN     UINT8                              EndPointAddress,
490
+  IN     UINT8                              DeviceSpeed,
491
+  IN     UINTN                              MaximumPacketLength,
492
+  IN     UINT8                              DataBuffersNumber,
493
+  IN OUT VOID                               *Data[EFI_USB_MAX_ISO_BUFFER_NUM],
494
+  IN     UINTN                              DataLength,
495
+  IN     EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,
496
+  IN     EFI_ASYNC_USB_TRANSFER_CALLBACK    IsochronousCallBack,
497
+  IN     VOID                               *Context OPTIONAL
498
+  );
499
+
500
+/**
501
+  Retrieves the current status of a USB root hub port.
502
+
503
+  @param  This       A pointer to the EFI_USB2_HC_PROTOCOL instance.
504
+  @param  PortNumber Specifies the root hub port from which the status is to be retrieved.
505
+                     This value is zero based.
506
+  @param  PortStatus A pointer to the current port status bits and port status change bits.
507
+
508
+  @retval EFI_SUCCESS           The status of the USB root hub port specified by PortNumber
509
+                                was returned in PortStatus.
510
+  @retval EFI_INVALID_PARAMETER PortNumber is invalid.
511
+
512
+**/
513
+typedef
514
+EFI_STATUS
515
+(EFIAPI *EFI_USB2_HC_PROTOCOL_GET_ROOTHUB_PORT_STATUS)(
516
+  IN        EFI_USB2_HC_PROTOCOL    *This,
517
+  IN        UINT8                   PortNumber,
518
+  OUT       EFI_USB_PORT_STATUS     *PortStatus
519
+  );
520
+
521
+/**
522
+  Sets a feature for the specified root hub port.
523
+
524
+  @param  This        A pointer to the EFI_USB2_HC_PROTOCOL instance.
525
+  @param  PortNumber  Specifies the root hub port whose feature is requested to be set. This
526
+                      value is zero based.
527
+  @param  PortFeature Indicates the feature selector associated with the feature set request.
528
+
529
+  @retval EFI_SUCCESS           The feature specified by PortFeature was set for the USB
530
+                                root hub port specified by PortNumber.
531
+  @retval EFI_INVALID_PARAMETER PortNumber is invalid or PortFeature is invalid for this function.
532
+
533
+**/
534
+typedef
535
+EFI_STATUS
536
+(EFIAPI *EFI_USB2_HC_PROTOCOL_SET_ROOTHUB_PORT_FEATURE)(
537
+  IN EFI_USB2_HC_PROTOCOL    *This,
538
+  IN UINT8                   PortNumber,
539
+  IN EFI_USB_PORT_FEATURE    PortFeature
540
+  );
541
+
542
+/**
543
+  Clears a feature for the specified root hub port.
544
+
545
+  @param  This        A pointer to the EFI_USB2_HC_PROTOCOL instance.
546
+  @param  PortNumber  Specifies the root hub port whose feature is requested to be cleared. This
547
+                      value is zero based.
548
+  @param  PortFeature Indicates the feature selector associated with the feature clear request.
549
+
550
+  @retval EFI_SUCCESS           The feature specified by PortFeature was cleared for the USB
551
+                                root hub port specified by PortNumber.
552
+  @retval EFI_INVALID_PARAMETER PortNumber is invalid or PortFeature is invalid for this function.
553
+
554
+**/
555
+typedef
556
+EFI_STATUS
557
+(EFIAPI *EFI_USB2_HC_PROTOCOL_CLEAR_ROOTHUB_PORT_FEATURE)(
558
+  IN EFI_USB2_HC_PROTOCOL    *This,
559
+  IN UINT8                   PortNumber,
560
+  IN EFI_USB_PORT_FEATURE    PortFeature
561
+  );
562
+
563
+///
564
+/// The EFI_USB2_HC_PROTOCOL provides USB host controller management, basic
565
+/// data transactions over a USB bus, and USB root hub access. A device driver
566
+/// that wishes to manage a USB bus in a system retrieves the EFI_USB2_HC_PROTOCOL
567
+/// instance that is associated with the USB bus to be managed. A device handle
568
+/// for a USB host controller will minimally contain an EFI_DEVICE_PATH_PROTOCOL
569
+/// instance, and an EFI_USB2_HC_PROTOCOL instance.
570
+///
571
+struct _EFI_USB2_HC_PROTOCOL {
572
+  EFI_USB2_HC_PROTOCOL_GET_CAPABILITY              GetCapability;
573
+  EFI_USB2_HC_PROTOCOL_RESET                       Reset;
574
+  EFI_USB2_HC_PROTOCOL_GET_STATE                   GetState;
575
+  EFI_USB2_HC_PROTOCOL_SET_STATE                   SetState;
576
+  EFI_USB2_HC_PROTOCOL_CONTROL_TRANSFER            ControlTransfer;
577
+  EFI_USB2_HC_PROTOCOL_BULK_TRANSFER               BulkTransfer;
578
+  EFI_USB2_HC_PROTOCOL_ASYNC_INTERRUPT_TRANSFER    AsyncInterruptTransfer;
579
+  EFI_USB2_HC_PROTOCOL_SYNC_INTERRUPT_TRANSFER     SyncInterruptTransfer;
580
+  EFI_USB2_HC_PROTOCOL_ISOCHRONOUS_TRANSFER        IsochronousTransfer;
581
+  EFI_USB2_HC_PROTOCOL_ASYNC_ISOCHRONOUS_TRANSFER  AsyncIsochronousTransfer;
582
+  EFI_USB2_HC_PROTOCOL_GET_ROOTHUB_PORT_STATUS     GetRootHubPortStatus;
583
+  EFI_USB2_HC_PROTOCOL_SET_ROOTHUB_PORT_FEATURE    SetRootHubPortFeature;
584
+  EFI_USB2_HC_PROTOCOL_CLEAR_ROOTHUB_PORT_FEATURE  ClearRootHubPortFeature;
585
+
586
+  ///
587
+  /// The major revision number of the USB host controller. The revision information
588
+  /// indicates the release of the Universal Serial Bus Specification with which the
589
+  /// host controller is compliant.
590
+  ///
591
+  UINT16                                           MajorRevision;
592
+
593
+  ///
594
+  /// The minor revision number of the USB host controller. The revision information
595
+  /// indicates the release of the Universal Serial Bus Specification with which the
596
+  /// host controller is compliant.
597
+  ///
598
+  UINT16                                           MinorRevision;
599
+};
600
+
601
+extern EFI_GUID gEfiUsb2HcProtocolGuid;
602
+
603
+#endif

+ 510
- 0
src/include/ipxe/efi/Protocol/UsbHostController.h View File

@@ -0,0 +1,510 @@
1
+/** @file
2
+  EFI_USB_HC_PROTOCOL as defined in EFI 1.10.
3
+
4
+  The USB Host Controller Protocol is used by code, typically USB bus drivers,
5
+  running in the EFI boot services environment, to perform data transactions
6
+  over a USB bus. In addition, it provides an abstraction for the root hub of the USB bus.
7
+
8
+  Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
9
+  This program and the accompanying materials
10
+  are licensed and made available under the terms and conditions of the BSD License
11
+  which accompanies this distribution.  The full text of the license may be found at
12
+  http://opensource.org/licenses/bsd-license.php
13
+
14
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
15
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16
+
17
+**/
18
+
19
+#ifndef _USB_HOSTCONTROLLER_H_
20
+#define _USB_HOSTCONTROLLER_H_
21
+
22
+FILE_LICENCE ( BSD3 );
23
+
24
+#include <ipxe/efi/Protocol/Usb2HostController.h>
25
+
26
+#define EFI_USB_HC_PROTOCOL_GUID \
27
+  { \
28
+    0xf5089266, 0x1aa0, 0x4953, {0x97, 0xd8, 0x56, 0x2f, 0x8a, 0x73, 0xb5, 0x19 } \
29
+  }
30
+
31
+///
32
+/// Forward reference for pure ANSI compatability
33
+///
34
+typedef struct _EFI_USB_HC_PROTOCOL EFI_USB_HC_PROTOCOL;
35
+
36
+//
37
+// Protocol definitions
38
+//
39
+
40
+/**
41
+  Provides software reset for the USB host controller.
42
+
43
+  @param  This                  A pointer to the EFI_USB_HC_PROTOCOL instance.
44
+  @param  Attributes            A bit mask of the reset operation to perform.
45
+
46
+  @retval EFI_SUCCESS           The reset operation succeeded.
47
+  @retval EFI_UNSUPPORTED       The type of reset specified by Attributes is not currently supported
48
+                                by the host controller hardware.
49
+  @retval EFI_INVALID_PARAMETER Attributes is not valid.
50
+  @retval EFI_DEVICE_ERROR      An error was encountered while attempting to perform the reset operation.
51
+
52
+**/
53
+typedef
54
+EFI_STATUS
55
+(EFIAPI *EFI_USB_HC_PROTOCOL_RESET)(
56
+  IN EFI_USB_HC_PROTOCOL     *This,
57
+  IN UINT16                  Attributes
58
+  );
59
+
60
+/**
61
+  Retrieves current state of the USB host controller.
62
+
63
+  @param  This                  A pointer to the EFI_USB_HC_PROTOCOL instance.
64
+  @param  State                 A pointer to the EFI_USB_HC_STATE data structure that
65
+                                indicates current state of the USB host controller.
66
+
67
+  @retval EFI_SUCCESS           The state information of the host controller was returned in State.
68
+  @retval EFI_INVALID_PARAMETER State is NULL.
69
+  @retval EFI_DEVICE_ERROR      An error was encountered while attempting to retrieve the host controller's
70
+                                current state.
71
+
72
+**/
73
+typedef
74
+EFI_STATUS
75
+(EFIAPI *EFI_USB_HC_PROTOCOL_GET_STATE)(
76
+  IN  EFI_USB_HC_PROTOCOL    *This,
77
+  OUT EFI_USB_HC_STATE       *State
78
+  );
79
+
80
+/**
81
+  Sets the USB host controller to a specific state.
82
+
83
+  @param  This                  A pointer to the EFI_USB_HC_PROTOCOL instance.
84
+  @param  State                 Indicates the state of the host controller that will be set.
85
+
86
+  @retval EFI_SUCCESS           The USB host controller was successfully placed in the state specified by
87
+                                State.
88
+  @retval EFI_INVALID_PARAMETER State is NULL.
89
+  @retval EFI_DEVICE_ERROR      Failed to set the state specified by State due to device error.
90
+
91
+**/
92
+typedef
93
+EFI_STATUS
94
+(EFIAPI *EFI_USB_HC_PROTOCOL_SET_STATE)(
95
+  IN EFI_USB_HC_PROTOCOL     *This,
96
+  IN EFI_USB_HC_STATE        State
97
+  );
98
+
99
+/**
100
+  Submits control transfer to a target USB device.
101
+
102
+  @param  This                  A pointer to the EFI_USB_HC_PROTOCOL instance.
103
+  @param  DeviceAddress         Represents the address of the target device on the USB, which is
104
+                                assigned during USB enumeration.
105
+  @param  IsSlowDevice          Indicates whether the target device is slow device or full-speed
106
+                                device.
107
+  @param  MaximumPacketLength   Indicates the maximum packet size that the default control
108
+                                transfer endpoint is capable of sending or receiving.
109
+  @param  Request               A pointer to the USB device request that will be sent to the USB
110
+                                device.
111
+  @param  TransferDirection     Specifies the data direction for the transfer. There are three
112
+                                values available, EfiUsbDataIn, EfiUsbDataOut and EfiUsbNoData.
113
+  @param  Data                  A pointer to the buffer of data that will be transmitted to USB
114
+                                device or received from USB device.
115
+  @param  DataLength            On input, indicates the size, in bytes, of the data buffer specified
116
+                                by Data. On output, indicates the amount of data actually
117
+                                transferred.
118
+  @param  TimeOut               Indicates the maximum time, in milliseconds, which the transfer
119
+                                is allowed to complete.
120
+  @param  TransferResult        A pointer to the detailed result information generated by this
121
+                                control transfer.
122
+
123
+  @retval EFI_SUCCESS           The control transfer was completed successfully.
124
+  @retval EFI_OUT_OF_RESOURCES  The control transfer could not be completed due to a lack of resources.
125
+  @retval EFI_INVALID_PARAMETER Some parameters are invalid.
126
+  @retval EFI_TIMEOUT           The control transfer failed due to timeout.
127
+  @retval EFI_DEVICE_ERROR      The control transfer failed due to host controller or device error.
128
+
129
+**/
130
+typedef
131
+EFI_STATUS
132
+(EFIAPI *EFI_USB_HC_PROTOCOL_CONTROL_TRANSFER)(
133
+  IN     EFI_USB_HC_PROTOCOL       *This,
134
+  IN     UINT8                     DeviceAddress,
135
+  IN     BOOLEAN                   IsSlowDevice,
136
+  IN     UINT8                     MaximumPacketLength,
137
+  IN     EFI_USB_DEVICE_REQUEST    *Request,
138
+  IN     EFI_USB_DATA_DIRECTION    TransferDirection,
139
+  IN OUT VOID                      *Data       OPTIONAL,
140
+  IN OUT UINTN                     *DataLength OPTIONAL,
141
+  IN     UINTN                     TimeOut,
142
+  OUT    UINT32                    *TransferResult
143
+  );
144
+
145
+/**
146
+  Submits bulk transfer to a bulk endpoint of a USB device.
147
+
148
+  @param  This                  A pointer to the EFI_USB_HC_PROTOCOL instance.
149
+  @param  DeviceAddress         Represents the address of the target device on the USB, which is
150
+                                assigned during USB enumeration.
151
+  @param  EndPointAddress       The combination of an endpoint number and an endpoint
152
+                                direction of the target USB device. Each endpoint address
153
+                                supports data transfer in one direction except the control
154
+                                endpoint (whose default endpoint address is 0). It is the
155
+                                caller's responsibility to make sure that the EndPointAddress
156
+                                represents a bulk endpoint.
157
+  @param  MaximumPacketLength   Indicates the maximum packet size that the default control
158
+                                transfer endpoint is capable of sending or receiving.
159
+  @param  Data                  A pointer to the buffer of data that will be transmitted to USB
160
+                                device or received from USB device.
161
+  @param  DataLength            On input, indicates the size, in bytes, of the data buffer specified
162
+                                by Data. On output, indicates the amount of data actually
163
+                                transferred.
164
+  @param  DataToggle            A pointer to the data toggle value.
165
+  @param  TimeOut               Indicates the maximum time, in milliseconds, which the transfer
166
+                                is allowed to complete.
167
+  @param  TransferResult        A pointer to the detailed result information of the bulk transfer.
168
+
169
+  @retval EFI_SUCCESS           The bulk transfer was completed successfully.
170
+  @retval EFI_OUT_OF_RESOURCES  The bulk transfer could not be completed due to a lack of resources.
171
+  @retval EFI_INVALID_PARAMETER Some parameters are invalid.
172
+  @retval EFI_TIMEOUT           The bulk transfer failed due to timeout.
173
+  @retval EFI_DEVICE_ERROR      The bulk transfer failed due to host controller or device error.
174
+
175
+**/
176
+typedef
177
+EFI_STATUS
178
+(EFIAPI *EFI_USB_HC_PROTOCOL_BULK_TRANSFER)(
179
+  IN     EFI_USB_HC_PROTOCOL    *This,
180
+  IN     UINT8                  DeviceAddress,
181
+  IN     UINT8                  EndPointAddress,
182
+  IN     UINT8                  MaximumPacketLength,
183
+  IN OUT VOID                   *Data,
184
+  IN OUT UINTN                  *DataLength,
185
+  IN OUT UINT8                  *DataToggle,
186
+  IN     UINTN                  TimeOut,
187
+  OUT    UINT32                 *TransferResult
188
+  );
189
+
190
+/**
191
+  Submits an asynchronous interrupt transfer to an interrupt endpoint of a USB device.
192
+
193
+  @param  This                  A pointer to the EFI_USB_HC_PROTOCOL instance.
194
+  @param  DeviceAddress         Represents the address of the target device on the USB, which is
195
+                                assigned during USB enumeration.
196
+  @param  EndPointAddress       The combination of an endpoint number and an endpoint
197
+                                direction of the target USB device. Each endpoint address
198
+                                supports data transfer in one direction except the control
199
+                                endpoint (whose default endpoint address is zero). It is the
200
+                                caller's responsibility to make sure that the
201
+                                EndPointAddress represents an interrupt endpoint.
202
+  @param  IsSlowDevice          Indicates whether the target device is slow device or full-speed
203
+                                device.
204
+  @param  MaximumPacketLength   Indicates the maximum packet size that the default control
205
+                                transfer endpoint is capable of sending or receiving.
206
+  @param  IsNewTransfer         If TRUE, an asynchronous interrupt pipe is built between the host
207
+                                and the target interrupt endpoint. If FALSE, the specified asynchronous
208
+                                interrupt pipe is canceled. If TRUE, and an interrupt transfer exists
209
+                                for the target end point, then EFI_INVALID_PARAMETER is returned.
210
+  @param  DataToggle            A pointer to the data toggle value. On input, it is valid when
211
+                                IsNewTransfer is TRUE, and it indicates the initial data toggle
212
+                                value the asynchronous interrupt transfer should adopt. On output,
213
+                                it is valid when IsNewTransfer is FALSE, and it is updated to indicate
214
+                                the data toggle value of the subsequent asynchronous interrupt transfer.
215
+  @param  PollingInterval       Indicates the interval, in milliseconds, that the asynchronous
216
+                                interrupt transfer is polled.
217
+  @param  DataLength            Indicates the length of data to be received at the rate specified by
218
+                                PollingInterval from the target asynchronous interrupt
219
+                                endpoint. This parameter is only required when IsNewTransfer is TRUE.
220
+  @param  CallBackFunction      The Callback function. This function is called at the rate specified by
221
+                                PollingInterval. This parameter is only required when IsNewTransfer is TRUE.
222
+  @param  Context               The context that is passed to the CallBackFunction.
223
+
224
+  @retval EFI_SUCCESS           The asynchronous interrupt transfer request has been successfully
225
+                                submitted or canceled.
226
+  @retval EFI_OUT_OF_RESOURCES  The request could not be completed due to a lack of resources.
227
+  @retval EFI_INVALID_PARAMETER Some parameters are invalid.
228
+  @retval EFI_TIMEOUT           The bulk transfer failed due to timeout.
229
+  @retval EFI_DEVICE_ERROR      The bulk transfer failed due to host controller or device error.
230
+
231
+**/
232
+typedef
233
+EFI_STATUS
234
+(EFIAPI *EFI_USB_HC_PROTOCOL_ASYNC_INTERRUPT_TRANSFER)(
235
+  IN     EFI_USB_HC_PROTOCOL                                 *This,
236
+  IN     UINT8                                               DeviceAddress,
237
+  IN     UINT8                                               EndPointAddress,
238
+  IN     BOOLEAN                                             IsSlowDevice,
239
+  IN     UINT8                                               MaxiumPacketLength,
240
+  IN     BOOLEAN                                             IsNewTransfer,
241
+  IN OUT UINT8                                               *DataToggle,
242
+  IN     UINTN                                               PollingInterval  OPTIONAL,
243
+  IN     UINTN                                               DataLength       OPTIONAL,
244
+  IN     EFI_ASYNC_USB_TRANSFER_CALLBACK                     CallBackFunction OPTIONAL,
245
+  IN     VOID                                                *Context         OPTIONAL
246
+  );
247
+
248
+/**
249
+  Submits synchronous interrupt transfer to an interrupt endpoint of a USB device.
250
+
251
+  @param  This                  A pointer to the EFI_USB_HC_PROTOCOL instance.
252
+  @param  DeviceAddress         Represents the address of the target device on the USB, which is
253
+                                assigned during USB enumeration.
254
+  @param  EndPointAddress       The combination of an endpoint number and an endpoint
255
+                                direction of the target USB device. Each endpoint address
256
+                                supports data transfer in one direction except the control
257
+                                endpoint (whose default endpoint address is zero). It is the
258
+                                caller's responsibility to make sure that the
259
+                                EndPointAddress represents an interrupt endpoint.
260
+  @param  IsSlowDevice          Indicates whether the target device is slow device or full-speed
261
+                                device.
262
+  @param  MaximumPacketLength   Indicates the maximum packet size that the default control
263
+                                transfer endpoint is capable of sending or receiving.
264
+  @param  Data                  A pointer to the buffer of data that will be transmitted to USB
265
+                                device or received from USB device.                                                                                            asynchronous interrupt pipe is canceled.
266
+  @param  DataLength            On input, the size, in bytes, of the data buffer specified by Data.
267
+                                On output, the number of bytes transferred.
268
+  @param  DataToggle            A pointer to the data toggle value. On input, it indicates the initial
269
+                                data toggle value the synchronous interrupt transfer should adopt;
270
+                                on output, it is updated to indicate the data toggle value of the
271
+                                subsequent synchronous interrupt transfer.
272
+  @param  TimeOut               Indicates the maximum time, in milliseconds, which the transfer
273
+                                is allowed to complete.
274
+  @param  TransferResult        A pointer to the detailed result information from the synchronous
275
+                                interrupt transfer.
276
+
277
+  @retval EFI_SUCCESS           The synchronous interrupt transfer was completed successfully.
278
+  @retval EFI_OUT_OF_RESOURCES  The request could not be completed due to a lack of resources.
279
+  @retval EFI_INVALID_PARAMETER Some parameters are invalid.
280
+  @retval EFI_TIMEOUT           The synchronous interrupt transfer failed due to timeout.
281
+  @retval EFI_DEVICE_ERROR      The synchronous interrupt transfer failed due to host controller or device error.
282
+
283
+**/
284
+typedef
285
+EFI_STATUS
286
+(EFIAPI *EFI_USB_HC_PROTOCOL_SYNC_INTERRUPT_TRANSFER)(
287
+  IN     EFI_USB_HC_PROTOCOL    *This,
288
+  IN     UINT8                  DeviceAddress,
289
+  IN     UINT8                  EndPointAddress,
290
+  IN     BOOLEAN                IsSlowDevice,
291
+  IN     UINT8                  MaximumPacketLength,
292
+  IN OUT VOID                   *Data,
293
+  IN OUT UINTN                  *DataLength,
294
+  IN OUT UINT8                  *DataToggle,
295
+  IN     UINTN                  TimeOut,
296
+  OUT    UINT32                 *TransferResult
297
+  );
298
+
299
+/**
300
+  Submits isochronous transfer to an isochronous endpoint of a USB device.
301
+
302
+  @param  This                  A pointer to the EFI_USB_HC_PROTOCOL instance.
303
+  @param  DeviceAddress         Represents the address of the target device on the USB, which is
304
+                                assigned during USB enumeration.
305
+  @param  EndPointAddress       The combination of an endpoint number and an endpoint
306
+                                direction of the target USB device. Each endpoint address
307
+                                supports data transfer in one direction except the control
308
+                                endpoint (whose default endpoint address is 0). It is the caller's
309
+                                responsibility to make sure that the EndPointAddress
310
+                                represents an isochronous endpoint.
311
+  @param  MaximumPacketLength   Indicates the maximum packet size that the default control
312
+                                transfer endpoint is capable of sending or receiving.
313
+  @param  Data                  A pointer to the buffer of data that will be transmitted to USB
314
+                                device or received from USB device.                                                                                            asynchronous interrupt pipe is canceled.
315
+  @param  DataLength            Specifies the length, in bytes, of the data to be sent to or received
316
+                                from the USB device.
317
+  @param  TransferResult        A pointer to the detailed result information from the isochronous
318
+                                transfer.
319
+
320
+  @retval EFI_SUCCESS           The isochronous transfer was completed successfully.
321
+  @retval EFI_OUT_OF_RESOURCES  The isochronous could not be completed due to a lack of resources.
322
+  @retval EFI_INVALID_PARAMETER Some parameters are invalid.
323
+  @retval EFI_TIMEOUT           The isochronous transfer failed due to timeout.
324
+  @retval EFI_DEVICE_ERROR      The isochronous transfer failed due to host controller or device error.
325
+
326
+**/
327
+typedef
328
+EFI_STATUS
329
+(EFIAPI *EFI_USB_HC_PROTOCOL_ISOCHRONOUS_TRANSFER)(
330
+  IN     EFI_USB_HC_PROTOCOL    *This,
331
+  IN     UINT8                  DeviceAddress,
332
+  IN     UINT8                  EndPointAddress,
333
+  IN     UINT8                  MaximumPacketLength,
334
+  IN OUT VOID                   *Data,
335
+  IN     UINTN                  DataLength,
336
+  OUT    UINT32                 *TransferResult
337
+  );
338
+
339
+/**
340
+  Submits nonblocking isochronous transfer to an isochronous endpoint of a USB device.
341
+
342
+  @param  This                  A pointer to the EFI_USB_HC_PROTOCOL instance.
343
+  @param  DeviceAddress         Represents the address of the target device on the USB, which is
344
+                                assigned during USB enumeration.
345
+  @param  EndPointAddress       The combination of an endpoint number and an endpoint
346
+                                direction of the target USB device. Each endpoint address
347
+                                supports data transfer in one direction except the control
348
+                                endpoint (whose default endpoint address is zero). It is the
349
+                                caller's responsibility to make sure that the
350
+                                EndPointAddress represents an isochronous endpoint.
351
+  @param  MaximumPacketLength   Indicates the maximum packet size that the default control
352
+                                transfer endpoint is capable of sending or receiving. For isochronous
353
+                                endpoints, this value is used to reserve the bus time in the schedule,
354
+                                required for the perframe data payloads. The pipe may, on an ongoing basis,
355
+                                actually use less bandwidth than that reserved.
356
+  @param  Data                  A pointer to the buffer of data that will be transmitted to USB
357
+                                device or received from USB device.                                                                                            asynchronous interrupt pipe is canceled.
358
+  @param  DataLength            Specifies the length, in bytes, of the data to be sent to or received
359
+                                from the USB device.
360
+  @param  IsochronousCallback   The Callback function.This function is called if the requested
361
+                                isochronous transfer is completed.
362
+  @param  Context               Data passed to the IsochronousCallback function. This is
363
+                                an optional parameter and may be NULL.
364
+
365
+  @retval EFI_SUCCESS           The asynchronous isochronous transfer was completed successfully.
366
+  @retval EFI_OUT_OF_RESOURCES  The asynchronous isochronous could not be completed due to a lack of resources.
367
+  @retval EFI_INVALID_PARAMETER Some parameters are invalid.
368
+
369
+**/
370
+typedef
371
+EFI_STATUS
372
+(EFIAPI *EFI_USB_HC_PROTOCOL_ASYNC_ISOCHRONOUS_TRANSFER)(
373
+  IN     EFI_USB_HC_PROTOCOL                *This,
374
+  IN     UINT8                              DeviceAddress,
375
+  IN     UINT8                              EndPointAddress,
376
+  IN     UINT8                              MaximumPacketLength,
377
+  IN OUT VOID                               *Data,
378
+  IN     UINTN                              DataLength,
379
+  IN     EFI_ASYNC_USB_TRANSFER_CALLBACK    IsochronousCallBack,
380
+  IN     VOID                               *Context OPTIONAL
381
+  );
382
+
383
+/**
384
+  Retrieves the number of root hub ports.
385
+
386
+  @param  This                  A pointer to the EFI_USB_HC_PROTOCOL instance.
387
+  @param  PortNumber            A pointer to the number of the root hub ports.
388
+
389
+  @retval EFI_SUCCESS           The port number was retrieved successfully.
390
+  @retval EFI_DEVICE_ERROR      An error was encountered while attempting to retrieve the port number.
391
+  @retval EFI_INVALID_PARAMETER PortNumber is NULL.
392
+
393
+**/
394
+typedef
395
+EFI_STATUS
396
+(EFIAPI *EFI_USB_HC_PROTOCOL_GET_ROOTHUB_PORT_NUMBER)(
397
+  IN EFI_USB_HC_PROTOCOL    *This,
398
+  OUT UINT8                 *PortNumber
399
+  );
400
+
401
+/**
402
+  Retrieves the current status of a USB root hub port.
403
+
404
+  @param  This                  A pointer to the EFI_USB_HC_PROTOCOL instance.
405
+  @param  PortNumber            Specifies the root hub port from which the status is to be retrieved.
406
+                                This value is zero based. For example, if a root hub has two ports,
407
+                                then the first port is numbered 0, and the second port is
408
+                                numbered 1.
409
+  @param  PortStatus            A pointer to the current port status bits and port status change bits.
410
+
411
+  @retval EFI_SUCCESS           The status of the USB root hub port specified by PortNumber
412
+                                was returned in PortStatus.
413
+  @retval EFI_INVALID_PARAMETER PortNumber is invalid.
414
+
415
+**/
416
+typedef
417
+EFI_STATUS
418
+(EFIAPI *EFI_USB_HC_PROTOCOL_GET_ROOTHUB_PORT_STATUS)(
419
+  IN EFI_USB_HC_PROTOCOL     *This,
420
+  IN  UINT8                  PortNumber,
421
+  OUT EFI_USB_PORT_STATUS    *PortStatus
422
+  );
423
+
424
+/**
425
+  Sets a feature for the specified root hub port.
426
+
427
+  @param  This                  A pointer to the EFI_USB_HC_PROTOCOL instance.
428
+  @param  PortNumber            Specifies the root hub port from which the status is to be retrieved.
429
+                                This value is zero based. For example, if a root hub has two ports,
430
+                                then the first port is numbered 0, and the second port is
431
+                                numbered 1.
432
+  @param  PortFeature           Indicates the feature selector associated with the feature set
433
+                                request.
434
+
435
+  @retval EFI_SUCCESS           The feature specified by PortFeature was set for the USB
436
+                                root hub port specified by PortNumber.
437
+  @retval EFI_INVALID_PARAMETER PortNumber is invalid or PortFeature is invalid for this function.
438
+
439
+**/
440
+typedef
441
+EFI_STATUS
442
+(EFIAPI *EFI_USB_HC_PROTOCOL_SET_ROOTHUB_PORT_FEATURE)(
443
+  IN EFI_USB_HC_PROTOCOL     *This,
444
+  IN UINT8                   PortNumber,
445
+  IN EFI_USB_PORT_FEATURE    PortFeature
446
+  );
447
+
448
+/**
449
+  Clears a feature for the specified root hub port.
450
+
451
+  @param  This                  A pointer to the EFI_USB_HC_PROTOCOL instance.
452
+  @param  PortNumber            Specifies the root hub port from which the status is to be retrieved.
453
+                                This value is zero based. For example, if a root hub has two ports,
454
+                                then the first port is numbered 0, and the second port is
455
+                                numbered 1.
456
+  @param  PortFeature           Indicates the feature selector associated with the feature clear
457
+                                request.
458
+
459
+  @retval EFI_SUCCESS           The feature specified by PortFeature was cleared for the USB
460
+                                root hub port specified by PortNumber.
461
+  @retval EFI_INVALID_PARAMETER PortNumber is invalid or PortFeature is invalid for this function.
462
+
463
+**/
464
+typedef
465
+EFI_STATUS
466
+(EFIAPI *EFI_USB_HC_PROTOCOL_CLEAR_ROOTHUB_PORT_FEATURE)(
467
+  IN EFI_USB_HC_PROTOCOL     *This,
468
+  IN UINT8                   PortNumber,
469
+  IN EFI_USB_PORT_FEATURE    PortFeature
470
+  );
471
+
472
+
473
+///
474
+/// The EFI_USB_HC_PROTOCOL provides USB host controller management, basic data transactions
475
+/// over a USB bus, and USB root hub access. A device driver that wishes to manage a USB bus in a
476
+/// system retrieves the EFI_USB_HC_PROTOCOL instance that is associated with the USB bus to be
477
+/// managed. A device handle for a USB host controller will minimally contain an
478
+/// EFI_DEVICE_PATH_PROTOCOL instance, and an EFI_USB_HC_PROTOCOL instance.
479
+///
480
+struct _EFI_USB_HC_PROTOCOL {
481
+  EFI_USB_HC_PROTOCOL_RESET                       Reset;
482
+  EFI_USB_HC_PROTOCOL_GET_STATE                   GetState;
483
+  EFI_USB_HC_PROTOCOL_SET_STATE                   SetState;
484
+  EFI_USB_HC_PROTOCOL_CONTROL_TRANSFER            ControlTransfer;
485
+  EFI_USB_HC_PROTOCOL_BULK_TRANSFER               BulkTransfer;
486
+  EFI_USB_HC_PROTOCOL_ASYNC_INTERRUPT_TRANSFER    AsyncInterruptTransfer;
487
+  EFI_USB_HC_PROTOCOL_SYNC_INTERRUPT_TRANSFER     SyncInterruptTransfer;
488
+  EFI_USB_HC_PROTOCOL_ISOCHRONOUS_TRANSFER        IsochronousTransfer;
489
+  EFI_USB_HC_PROTOCOL_ASYNC_ISOCHRONOUS_TRANSFER  AsyncIsochronousTransfer;
490
+  EFI_USB_HC_PROTOCOL_GET_ROOTHUB_PORT_NUMBER     GetRootHubPortNumber;
491
+  EFI_USB_HC_PROTOCOL_GET_ROOTHUB_PORT_STATUS     GetRootHubPortStatus;
492
+  EFI_USB_HC_PROTOCOL_SET_ROOTHUB_PORT_FEATURE    SetRootHubPortFeature;
493
+  EFI_USB_HC_PROTOCOL_CLEAR_ROOTHUB_PORT_FEATURE  ClearRootHubPortFeature;
494
+  ///
495
+  /// The major revision number of the USB host controller. The revision information
496
+  /// indicates the release of the Universal Serial Bus Specification with which the
497
+  /// host controller is compliant.
498
+  ///
499
+  UINT16                                          MajorRevision;
500
+  ///
501
+  /// The minor revision number of the USB host controller. The revision information
502
+  /// indicates the release of the Universal Serial Bus Specification with which the
503
+  /// host controller is compliant.
504
+  ///
505
+  UINT16                                          MinorRevision;
506
+};
507
+
508
+extern EFI_GUID gEfiUsbHcProtocolGuid;
509
+
510
+#endif

+ 514
- 0
src/include/ipxe/efi/Protocol/UsbIo.h View File

@@ -0,0 +1,514 @@
1
+/** @file
2
+  EFI Usb I/O Protocol as defined in UEFI specification.
3
+  This protocol is used by code, typically drivers, running in the EFI
4
+  boot services environment to access USB devices like USB keyboards,
5
+  mice and mass storage devices. In particular, functions for managing devices
6
+  on USB buses are defined here.
7
+
8
+  Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
9
+  This program and the accompanying materials
10
+  are licensed and made available under the terms and conditions of the BSD License
11
+  which accompanies this distribution.  The full text of the license may be found at
12
+  http://opensource.org/licenses/bsd-license.php
13
+
14
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
15
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16
+
17
+**/
18
+
19
+#ifndef __USB_IO_H__
20
+#define __USB_IO_H__
21
+
22
+FILE_LICENCE ( BSD3 );
23
+
24
+#include <ipxe/efi/IndustryStandard/Usb.h>
25
+
26
+//
27
+// Global ID for the USB I/O Protocol
28
+//
29
+#define EFI_USB_IO_PROTOCOL_GUID \
30
+  { \
31
+    0x2B2F68D6, 0x0CD2, 0x44cf, {0x8E, 0x8B, 0xBB, 0xA2, 0x0B, 0x1B, 0x5B, 0x75 } \
32
+  }
33
+
34
+typedef struct _EFI_USB_IO_PROTOCOL   EFI_USB_IO_PROTOCOL;
35
+
36
+//
37
+// Related Definition for EFI USB I/O protocol
38
+//
39
+
40
+//
41
+// USB standard descriptors and reqeust
42
+//
43
+typedef USB_DEVICE_REQUEST        EFI_USB_DEVICE_REQUEST;
44
+typedef USB_DEVICE_DESCRIPTOR     EFI_USB_DEVICE_DESCRIPTOR;
45
+typedef USB_CONFIG_DESCRIPTOR     EFI_USB_CONFIG_DESCRIPTOR;
46
+typedef USB_INTERFACE_DESCRIPTOR  EFI_USB_INTERFACE_DESCRIPTOR;
47
+typedef USB_ENDPOINT_DESCRIPTOR   EFI_USB_ENDPOINT_DESCRIPTOR;
48
+
49
+///
50
+/// USB data transfer direction
51
+///
52
+typedef enum {
53
+  EfiUsbDataIn,
54
+  EfiUsbDataOut,
55
+  EfiUsbNoData
56
+} EFI_USB_DATA_DIRECTION;
57
+
58
+//
59
+// USB Transfer Results
60
+//
61
+#define EFI_USB_NOERROR             0x00
62
+#define EFI_USB_ERR_NOTEXECUTE      0x01
63
+#define EFI_USB_ERR_STALL           0x02
64
+#define EFI_USB_ERR_BUFFER          0x04
65
+#define EFI_USB_ERR_BABBLE          0x08
66
+#define EFI_USB_ERR_NAK             0x10
67
+#define EFI_USB_ERR_CRC             0x20
68
+#define EFI_USB_ERR_TIMEOUT         0x40
69
+#define EFI_USB_ERR_BITSTUFF        0x80
70
+#define EFI_USB_ERR_SYSTEM          0x100
71
+
72
+/**
73
+  Async USB transfer callback routine.
74
+
75
+  @param  Data                  Data received or sent via the USB Asynchronous Transfer, if the
76
+                                transfer completed successfully.
77
+  @param  DataLength            The length of Data received or sent via the Asynchronous
78
+                                Transfer, if transfer successfully completes.
79
+  @param  Context               Data passed from UsbAsyncInterruptTransfer() request.
80
+  @param  Status                Indicates the result of the asynchronous transfer.
81
+
82
+  @retval EFI_SUCCESS           The asynchronous USB transfer request has been successfully executed.
83
+  @retval EFI_DEVICE_ERROR      The asynchronous USB transfer request failed.
84
+
85
+**/
86
+typedef
87
+EFI_STATUS
88
+(EFIAPI *EFI_ASYNC_USB_TRANSFER_CALLBACK)(
89
+  IN VOID         *Data,
90
+  IN UINTN        DataLength,
91
+  IN VOID         *Context,
92
+  IN UINT32       Status
93
+  );
94
+
95
+//
96
+// Prototype for EFI USB I/O protocol
97
+//
98
+
99
+
100
+/**
101
+  This function is used to manage a USB device with a control transfer pipe. A control transfer is
102
+  typically used to perform device initialization and configuration.
103
+
104
+  @param  This                  A pointer to the EFI_USB_IO_PROTOCOL instance.
105
+  @param  Request               A pointer to the USB device request that will be sent to the USB
106
+                                device.
107
+  @param  Direction             Indicates the data direction.
108
+  @param  Timeout               Indicating the transfer should be completed within this time frame.
109
+                                The units are in milliseconds.
110
+  @param  Data                  A pointer to the buffer of data that will be transmitted to USB
111
+                                device or received from USB device.
112
+  @param  DataLength            The size, in bytes, of the data buffer specified by Data.
113
+  @param  Status                A pointer to the result of the USB transfer.
114
+
115
+  @retval EFI_SUCCESS           The control transfer has been successfully executed.
116
+  @retval EFI_DEVICE_ERROR      The transfer failed. The transfer status is returned in Status.
117
+  @retval EFI_INVALID_PARAMETE  One or more parameters are invalid.
118
+  @retval EFI_OUT_OF_RESOURCES  The request could not be completed due to a lack of resources.
119
+  @retval EFI_TIMEOUT           The control transfer fails due to timeout.
120
+
121
+**/
122
+typedef
123
+EFI_STATUS
124
+(EFIAPI *EFI_USB_IO_CONTROL_TRANSFER)(
125
+  IN EFI_USB_IO_PROTOCOL                        *This,
126
+  IN EFI_USB_DEVICE_REQUEST                     *Request,
127
+  IN EFI_USB_DATA_DIRECTION                     Direction,
128
+  IN UINT32                                     Timeout,
129
+  IN OUT VOID                                   *Data OPTIONAL,
130
+  IN UINTN                                      DataLength  OPTIONAL,
131
+  OUT UINT32                                    *Status
132
+  );
133
+
134
+/**
135
+  This function is used to manage a USB device with the bulk transfer pipe. Bulk Transfers are
136
+  typically used to transfer large amounts of data to/from USB devices.
137
+
138
+  @param  This                  A pointer to the EFI_USB_IO_PROTOCOL instance.
139
+  @param  DeviceEndpoint        The destination USB device endpoint to which the
140
+                                device request is being sent. DeviceEndpoint must
141
+                                be between 0x01 and 0x0F or between 0x81 and 0x8F,
142
+                                otherwise EFI_INVALID_PARAMETER is returned. If
143
+                                the endpoint is not a BULK endpoint, EFI_INVALID_PARAMETER
144
+                                is returned. The MSB of this parameter indicates
145
+                                the endpoint direction. The number "1" stands for
146
+                                an IN endpoint, and "0" stands for an OUT endpoint.
147
+  @param  Data                  A pointer to the buffer of data that will be transmitted to USB
148
+                                device or received from USB device.
149
+  @param  DataLength            The size, in bytes, of the data buffer specified by Data.
150
+                                On input, the size, in bytes, of the data buffer specified by Data.
151
+                                On output, the number of bytes that were actually transferred.
152
+  @param  Timeout               Indicating the transfer should be completed within this time frame.
153
+                                The units are in milliseconds. If Timeout is 0, then the
154
+                                caller must wait for the function to be completed until
155
+                                EFI_SUCCESS or EFI_DEVICE_ERROR is returned.
156
+  @param  Status                This parameter indicates the USB transfer status.
157
+
158
+  @retval EFI_SUCCESS           The bulk transfer has been successfully executed.
159
+  @retval EFI_DEVICE_ERROR      The transfer failed. The transfer status is returned in Status.
160
+  @retval EFI_INVALID_PARAMETE  One or more parameters are invalid.
161
+  @retval EFI_OUT_OF_RESOURCES  The request could not be submitted due to a lack of resources.
162
+  @retval EFI_TIMEOUT           The control transfer fails due to timeout.
163
+
164
+**/
165
+typedef
166
+EFI_STATUS
167
+(EFIAPI *EFI_USB_IO_BULK_TRANSFER)(
168
+  IN EFI_USB_IO_PROTOCOL            *This,
169
+  IN UINT8                          DeviceEndpoint,
170
+  IN OUT VOID                       *Data,
171
+  IN OUT UINTN                      *DataLength,
172
+  IN UINTN                          Timeout,
173
+  OUT UINT32                        *Status
174
+  );
175
+
176
+/**
177
+  This function is used to manage a USB device with an interrupt transfer pipe. An Asynchronous
178
+  Interrupt Transfer is typically used to query a device's status at a fixed rate. For example,
179
+  keyboard, mouse, and hub devices use this type of transfer to query their interrupt endpoints at
180
+  a fixed rate.
181
+
182
+  @param  This                  A pointer to the EFI_USB_IO_PROTOCOL instance.
183
+  @param  DeviceEndpoint        The destination USB device endpoint to which the
184
+                                device request is being sent. DeviceEndpoint must
185
+                                be between 0x01 and 0x0F or between 0x81 and 0x8F,
186
+                                otherwise EFI_INVALID_PARAMETER is returned. If
187
+                                the endpoint is not a BULK endpoint, EFI_INVALID_PARAMETER
188
+                                is returned. The MSB of this parameter indicates
189
+                                the endpoint direction. The number "1" stands for
190
+                                an IN endpoint, and "0" stands for an OUT endpoint.
191
+  @param  IsNewTransfer         If TRUE, a new transfer will be submitted to USB controller. If
192
+                                FALSE, the interrupt transfer is deleted from the device's interrupt
193
+                                transfer queue.
194
+  @param  PollingInterval       Indicates the periodic rate, in milliseconds, that the transfer is to be
195
+                                executed.This parameter is required when IsNewTransfer is TRUE. The
196
+                                value must be between 1 to 255, otherwise EFI_INVALID_PARAMETER is returned.
197
+                                The units are in milliseconds.
198
+  @param  DataLength            Specifies the length, in bytes, of the data to be received from the
199
+                                USB device. This parameter is only required when IsNewTransfer is TRUE.
200
+  @param  InterruptCallback     The Callback function. This function is called if the asynchronous
201
+                                interrupt transfer is completed. This parameter is required
202
+                                when IsNewTransfer is TRUE.
203
+  @param  Context               Data passed to the InterruptCallback function. This is an optional
204
+                                parameter and may be NULL.
205
+
206
+  @retval EFI_SUCCESS           The asynchronous USB transfer request transfer has been successfully executed.
207
+  @retval EFI_DEVICE_ERROR      The asynchronous USB transfer request failed.
208
+
209
+**/
210
+typedef
211
+EFI_STATUS
212
+(EFIAPI *EFI_USB_IO_ASYNC_INTERRUPT_TRANSFER)(
213
+  IN EFI_USB_IO_PROTOCOL                                 *This,
214
+  IN UINT8                                               DeviceEndpoint,
215
+  IN BOOLEAN                                             IsNewTransfer,
216
+  IN UINTN                                               PollingInterval    OPTIONAL,
217
+  IN UINTN                                               DataLength         OPTIONAL,
218
+  IN EFI_ASYNC_USB_TRANSFER_CALLBACK                     InterruptCallBack  OPTIONAL,
219
+  IN VOID                                                *Context OPTIONAL
220
+  );
221
+
222
+/**
223
+  This function is used to manage a USB device with an interrupt transfer pipe.
224
+
225
+  @param  This                  A pointer to the EFI_USB_IO_PROTOCOL instance.
226
+  @param  DeviceEndpoint        The destination USB device endpoint to which the
227
+                                device request is being sent. DeviceEndpoint must
228
+                                be between 0x01 and 0x0F or between 0x81 and 0x8F,
229
+                                otherwise EFI_INVALID_PARAMETER is returned. If
230
+                                the endpoint is not a BULK endpoint, EFI_INVALID_PARAMETER
231
+                                is returned. The MSB of this parameter indicates
232
+                                the endpoint direction. The number "1" stands for
233
+                                an IN endpoint, and "0" stands for an OUT endpoint.
234
+  @param  Data                  A pointer to the buffer of data that will be transmitted to USB
235
+                                device or received from USB device.
236
+  @param  DataLength            On input, then size, in bytes, of the buffer Data. On output, the
237
+                                amount of data actually transferred.
238
+  @param  Timeout               The time out, in seconds, for this transfer. If Timeout is 0,
239
+                                then the caller must wait for the function to be completed
240
+                                until EFI_SUCCESS or EFI_DEVICE_ERROR is returned. If the
241
+                                transfer is not completed in this time frame, then EFI_TIMEOUT is returned.
242
+  @param  Status                This parameter indicates the USB transfer status.
243
+
244
+  @retval EFI_SUCCESS           The sync interrupt transfer has been successfully executed.
245
+  @retval EFI_INVALID_PARAMETER One or more parameters are invalid.
246
+  @retval EFI_DEVICE_ERROR      The sync interrupt transfer request failed.
247
+  @retval EFI_OUT_OF_RESOURCES  The request could not be submitted due to a lack of resources.
248
+  @retval EFI_TIMEOUT           The transfer fails due to timeout.
249
+**/
250
+typedef
251
+EFI_STATUS
252
+(EFIAPI *EFI_USB_IO_SYNC_INTERRUPT_TRANSFER)(
253
+  IN EFI_USB_IO_PROTOCOL            *This,
254
+  IN     UINT8                      DeviceEndpoint,
255
+  IN OUT VOID                       *Data,
256
+  IN OUT UINTN                      *DataLength,
257
+  IN     UINTN                      Timeout,
258
+  OUT    UINT32                     *Status
259
+  );
260
+
261
+/**
262
+  This function is used to manage a USB device with an isochronous transfer pipe. An Isochronous
263
+  transfer is typically used to transfer streaming data.
264
+
265
+  @param  This                  A pointer to the EFI_USB_IO_PROTOCOL instance.
266
+  @param  DeviceEndpoint        The destination USB device endpoint to which the
267
+                                device request is being sent. DeviceEndpoint must
268
+                                be between 0x01 and 0x0F or between 0x81 and 0x8F,
269
+                                otherwise EFI_INVALID_PARAMETER is returned. If
270
+                                the endpoint is not a BULK endpoint, EFI_INVALID_PARAMETER
271
+                                is returned. The MSB of this parameter indicates
272
+                                the endpoint direction. The number "1" stands for
273
+                                an IN endpoint, and "0" stands for an OUT endpoint.
274
+  @param  Data                  A pointer to the buffer of data that will be transmitted to USB
275
+                                device or received from USB device.
276
+  @param  DataLength            The size, in bytes, of the data buffer specified by Data.
277
+  @param  Status                This parameter indicates the USB transfer status.
278
+
279
+  @retval EFI_SUCCESS           The isochronous transfer has been successfully executed.
280
+  @retval EFI_INVALID_PARAMETER The parameter DeviceEndpoint is not valid.
281
+  @retval EFI_DEVICE_ERROR      The transfer failed due to the reason other than timeout, The error status
282
+                                is returned in Status.
283
+  @retval EFI_OUT_OF_RESOURCES  The request could not be submitted due to a lack of resources.
284
+  @retval EFI_TIMEOUT           The transfer fails due to timeout.
285
+**/
286
+typedef
287
+EFI_STATUS
288
+(EFIAPI *EFI_USB_IO_ISOCHRONOUS_TRANSFER)(
289
+  IN EFI_USB_IO_PROTOCOL            *This,
290
+  IN     UINT8                      DeviceEndpoint,
291
+  IN OUT VOID                       *Data,
292
+  IN     UINTN                      DataLength,
293
+  OUT    UINT32                     *Status
294
+  );
295
+
296
+/**
297
+  This function is used to manage a USB device with an isochronous transfer pipe. An Isochronous
298
+  transfer is typically used to transfer streaming data.
299
+
300
+  @param  This                  A pointer to the EFI_USB_IO_PROTOCOL instance.
301
+  @param  DeviceEndpoint        The destination USB device endpoint to which the
302
+                                device request is being sent. DeviceEndpoint must
303
+                                be between 0x01 and 0x0F or between 0x81 and 0x8F,
304
+                                otherwise EFI_INVALID_PARAMETER is returned. If
305
+                                the endpoint is not a BULK endpoint, EFI_INVALID_PARAMETER
306
+                                is returned. The MSB of this parameter indicates
307
+                                the endpoint direction. The number "1" stands for
308
+                                an IN endpoint, and "0" stands for an OUT endpoint.
309
+  @param  Data                  A pointer to the buffer of data that will be transmitted to USB
310
+                                device or received from USB device.
311
+  @param  DataLength            The size, in bytes, of the data buffer specified by Data.
312
+                                This is an optional parameter and may be NULL.
313
+  @param  IsochronousCallback   The IsochronousCallback() function.This function is
314
+                                called if the requested isochronous transfer is completed.
315
+  @param  Context               Data passed to the IsochronousCallback() function.
316
+
317
+  @retval EFI_SUCCESS           The asynchronous isochronous transfer has been successfully submitted
318
+                                to the system.
319
+  @retval EFI_INVALID_PARAMETER The parameter DeviceEndpoint is not valid.
320
+  @retval EFI_OUT_OF_RESOURCES  The request could not be submitted due to a lack of resources.
321
+
322
+**/
323
+typedef
324
+EFI_STATUS
325
+(EFIAPI *EFI_USB_IO_ASYNC_ISOCHRONOUS_TRANSFER)(
326
+  IN EFI_USB_IO_PROTOCOL              *This,
327
+  IN UINT8                            DeviceEndpoint,
328
+  IN OUT VOID                         *Data,
329
+  IN     UINTN                        DataLength,
330
+  IN EFI_ASYNC_USB_TRANSFER_CALLBACK  IsochronousCallBack,
331
+  IN VOID                             *Context OPTIONAL
332
+  );
333
+
334
+/**
335
+  Resets and reconfigures the USB controller. This function will work for all USB devices except
336
+  USB Hub Controllers.
337
+
338
+  @param  This                  A pointer to the EFI_USB_IO_PROTOCOL instance.
339
+
340
+  @retval EFI_SUCCESS           The USB controller was reset.
341
+  @retval EFI_INVALID_PARAMETER If the controller specified by This is a USB hub.
342
+  @retval EFI_DEVICE_ERROR      An error occurred during the reconfiguration process.
343
+
344
+**/
345
+typedef
346
+EFI_STATUS
347
+(EFIAPI *EFI_USB_IO_PORT_RESET)(
348
+  IN EFI_USB_IO_PROTOCOL    *This
349
+  );
350
+
351
+/**
352
+  Retrieves the USB Device Descriptor.
353
+
354
+  @param  This                  A pointer to the EFI_USB_IO_PROTOCOL instance.
355
+  @param  DeviceDescriptor      A pointer to the caller allocated USB Device Descriptor.
356
+
357
+  @retval EFI_SUCCESS           The device descriptor was retrieved successfully.
358
+  @retval EFI_INVALID_PARAMETER DeviceDescriptor is NULL.
359
+  @retval EFI_NOT_FOUND         The device descriptor was not found. The device may not be configured.
360
+
361
+**/
362
+typedef
363
+EFI_STATUS
364
+(EFIAPI *EFI_USB_IO_GET_DEVICE_DESCRIPTOR)(
365
+  IN EFI_USB_IO_PROTOCOL            *This,
366
+  OUT EFI_USB_DEVICE_DESCRIPTOR     *DeviceDescriptor
367
+  );
368
+
369
+/**
370
+  Retrieves the USB Device Descriptor.
371
+
372
+  @param  This                    A pointer to the EFI_USB_IO_PROTOCOL instance.
373
+  @param  ConfigurationDescriptor A pointer to the caller allocated USB Active Configuration
374
+                                  Descriptor.
375
+  @retval EFI_SUCCESS             The active configuration descriptor was retrieved successfully.
376
+  @retval EFI_INVALID_PARAMETER   ConfigurationDescriptor is NULL.
377
+  @retval EFI_NOT_FOUND           An active configuration descriptor cannot be found. The device may not
378
+                                  be configured.
379
+
380
+**/
381
+typedef
382
+EFI_STATUS
383
+(EFIAPI *EFI_USB_IO_GET_CONFIG_DESCRIPTOR)(
384
+  IN EFI_USB_IO_PROTOCOL            *This,
385
+  OUT EFI_USB_CONFIG_DESCRIPTOR     *ConfigurationDescriptor
386
+  );
387
+
388
+/**
389
+  Retrieves the Interface Descriptor for a USB Device Controller. As stated earlier, an interface
390
+  within a USB device is equivalently to a USB Controller within the current configuration.
391
+
392
+  @param  This                    A pointer to the EFI_USB_IO_PROTOCOL instance.
393
+  @param  InterfaceDescriptor     A pointer to the caller allocated USB Interface Descriptor within
394
+                                  the configuration setting.
395
+  @retval EFI_SUCCESS             The interface descriptor retrieved successfully.
396
+  @retval EFI_INVALID_PARAMETER   InterfaceDescriptor is NULL.
397
+  @retval EFI_NOT_FOUND           The interface descriptor cannot be found. The device may not be
398
+                                  correctly configured.
399
+
400
+**/
401
+typedef
402
+EFI_STATUS
403
+(EFIAPI *EFI_USB_IO_GET_INTERFACE_DESCRIPTOR)(
404
+  IN EFI_USB_IO_PROTOCOL            *This,
405
+  OUT EFI_USB_INTERFACE_DESCRIPTOR  *InterfaceDescriptor
406
+  );
407
+
408
+/**
409
+  Retrieves an Endpoint Descriptor within a USB Controller.
410
+
411
+  @param  This                    A pointer to the EFI_USB_IO_PROTOCOL instance.
412
+  @param  EndpointIndex           Indicates which endpoint descriptor to retrieve.
413
+  @param  EndpointDescriptor      A pointer to the caller allocated USB Endpoint Descriptor of
414
+                                  a USB controller.
415
+
416
+  @retval EFI_SUCCESS             The endpoint descriptor was retrieved successfully.
417
+  @retval EFI_INVALID_PARAMETER   One or more parameters are invalid.
418
+  @retval EFI_NOT_FOUND           The endpoint descriptor cannot be found. The device may not be
419
+                                  correctly configured.
420
+
421
+**/
422
+typedef
423
+EFI_STATUS
424
+(EFIAPI *EFI_USB_IO_GET_ENDPOINT_DESCRIPTOR)(
425
+  IN EFI_USB_IO_PROTOCOL            *This,
426
+  IN  UINT8                         EndpointIndex,
427
+  OUT EFI_USB_ENDPOINT_DESCRIPTOR   *EndpointDescriptor
428
+  );
429
+
430
+/**
431
+  Retrieves a string stored in a USB Device.
432
+
433
+  @param  This                    A pointer to the EFI_USB_IO_PROTOCOL instance.
434
+  @param  LangID                  The Language ID for the string being retrieved.
435
+  @param  StringID                The ID of the string being retrieved.
436
+  @param  String                  A pointer to a buffer allocated by this function with
437
+                                  AllocatePool() to store the string.If this function
438
+                                  returns EFI_SUCCESS, it stores the string the caller
439
+                                  wants to get. The caller should release the string
440
+                                  buffer with FreePool() after the string is not used any more.
441
+
442
+  @retval EFI_SUCCESS             The string was retrieved successfully.
443
+  @retval EFI_NOT_FOUND           The string specified by LangID and StringID was not found.
444
+  @retval EFI_OUT_OF_RESOURCES    There are not enough resources to allocate the return buffer String.
445
+
446
+**/
447
+typedef
448
+EFI_STATUS
449
+(EFIAPI *EFI_USB_IO_GET_STRING_DESCRIPTOR)(
450
+  IN EFI_USB_IO_PROTOCOL            *This,
451
+  IN  UINT16                        LangID,
452
+  IN  UINT8                         StringID,
453
+  OUT CHAR16                        **String
454
+  );
455
+
456
+/**
457
+  Retrieves all the language ID codes that the USB device supports.
458
+
459
+  @param  This                    A pointer to the EFI_USB_IO_PROTOCOL instance.
460
+  @param  LangIDTable             Language ID for the string the caller wants to get.
461
+                                  This is a 16-bit ID defined by Microsoft. This
462
+                                  buffer pointer is allocated and maintained by
463
+                                  the USB Bus Driver, the caller should not modify
464
+                                  its contents.
465
+  @param  TableSize               The size, in bytes, of the table LangIDTable.
466
+
467
+  @retval EFI_SUCCESS             The support languages were retrieved successfully.
468
+
469
+**/
470
+typedef
471
+EFI_STATUS
472
+(EFIAPI *EFI_USB_IO_GET_SUPPORTED_LANGUAGE)(
473
+  IN EFI_USB_IO_PROTOCOL            *This,
474
+  OUT UINT16                        **LangIDTable,
475
+  OUT UINT16                        *TableSize
476
+  );
477
+
478
+///
479
+/// The EFI_USB_IO_PROTOCOL provides four basic transfers types described
480
+/// in the USB 1.1 Specification. These include control transfer, interrupt
481
+/// transfer, bulk transfer and isochronous transfer. The EFI_USB_IO_PROTOCOL
482
+/// also provides some basic USB device/controller management and configuration
483
+/// interfaces. A USB device driver uses the services of this protocol to manage USB devices.
484
+///
485
+struct _EFI_USB_IO_PROTOCOL {
486
+  //
487
+  // IO transfer
488
+  //
489
+  EFI_USB_IO_CONTROL_TRANSFER           UsbControlTransfer;
490
+  EFI_USB_IO_BULK_TRANSFER              UsbBulkTransfer;
491
+  EFI_USB_IO_ASYNC_INTERRUPT_TRANSFER   UsbAsyncInterruptTransfer;
492
+  EFI_USB_IO_SYNC_INTERRUPT_TRANSFER    UsbSyncInterruptTransfer;
493
+  EFI_USB_IO_ISOCHRONOUS_TRANSFER       UsbIsochronousTransfer;
494
+  EFI_USB_IO_ASYNC_ISOCHRONOUS_TRANSFER UsbAsyncIsochronousTransfer;
495
+
496
+  //
497
+  // Common device request
498
+  //
499
+  EFI_USB_IO_GET_DEVICE_DESCRIPTOR      UsbGetDeviceDescriptor;
500
+  EFI_USB_IO_GET_CONFIG_DESCRIPTOR      UsbGetConfigDescriptor;
501
+  EFI_USB_IO_GET_INTERFACE_DESCRIPTOR   UsbGetInterfaceDescriptor;
502
+  EFI_USB_IO_GET_ENDPOINT_DESCRIPTOR    UsbGetEndpointDescriptor;
503
+  EFI_USB_IO_GET_STRING_DESCRIPTOR      UsbGetStringDescriptor;
504
+  EFI_USB_IO_GET_SUPPORTED_LANGUAGE     UsbGetSupportedLanguages;
505
+
506
+  //
507
+  // Reset controller's parent port
508
+  //
509
+  EFI_USB_IO_PORT_RESET                 UsbPortReset;
510
+};
511
+
512
+extern EFI_GUID gEfiUsbIoProtocolGuid;
513
+
514
+#endif

+ 3
- 0
src/include/ipxe/efi/efi.h View File

@@ -199,6 +199,9 @@ extern EFI_GUID efi_udp4_protocol_guid;
199 199
 extern EFI_GUID efi_udp4_service_binding_protocol_guid;
200 200
 extern EFI_GUID efi_uga_draw_protocol_guid;
201 201
 extern EFI_GUID efi_unicode_collation_protocol_guid;
202
+extern EFI_GUID efi_usb_hc_protocol_guid;
203
+extern EFI_GUID efi_usb2_hc_protocol_guid;
204
+extern EFI_GUID efi_usb_io_protocol_guid;
202 205
 extern EFI_GUID efi_vlan_config_protocol_guid;
203 206
 
204 207
 extern EFI_HANDLE efi_image_handle;

+ 6
- 0
src/interface/efi/efi_debug.c View File

@@ -163,6 +163,12 @@ static struct efi_well_known_guid efi_well_known_guids[] = {
163 163
 	  "UgaDraw" },
164 164
 	{ &efi_unicode_collation_protocol_guid,
165 165
 	  "UnicodeCollation" },
166
+	{ &efi_usb_hc_protocol_guid,
167
+	  "UsbHc" },
168
+	{ &efi_usb2_hc_protocol_guid,
169
+	  "Usb2Hc" },
170
+	{ &efi_usb_io_protocol_guid,
171
+	  "UsbIo" },
166 172
 	{ &efi_vlan_config_protocol_guid,
167 173
 	  "VlanConfig" },
168 174
 	{ &efi_vlan_config_dxe_guid,

+ 15
- 0
src/interface/efi/efi_guid.c View File

@@ -61,6 +61,9 @@ FILE_LICENCE ( GPL2_OR_LATER_OR_UBDL );
61 61
 #include <ipxe/efi/Protocol/Udp4.h>
62 62
 #include <ipxe/efi/Protocol/UgaDraw.h>
63 63
 #include <ipxe/efi/Protocol/UnicodeCollation.h>
64
+#include <ipxe/efi/Protocol/UsbHostController.h>
65
+#include <ipxe/efi/Protocol/Usb2HostController.h>
66
+#include <ipxe/efi/Protocol/UsbIo.h>
64 67
 #include <ipxe/efi/Protocol/VlanConfig.h>
65 68
 
66 69
 /** @file
@@ -258,6 +261,18 @@ EFI_GUID efi_uga_draw_protocol_guid
258 261
 EFI_GUID efi_unicode_collation_protocol_guid
259 262
 	= EFI_UNICODE_COLLATION_PROTOCOL_GUID;
260 263
 
264
+/** USB host controller protocol GUID */
265
+EFI_GUID efi_usb_hc_protocol_guid
266
+	= EFI_USB_HC_PROTOCOL_GUID;
267
+
268
+/** USB2 host controller protocol GUID */
269
+EFI_GUID efi_usb2_hc_protocol_guid
270
+	= EFI_USB2_HC_PROTOCOL_GUID;
271
+
272
+/** USB I/O protocol GUID */
273
+EFI_GUID efi_usb_io_protocol_guid
274
+	= EFI_USB_IO_PROTOCOL_GUID;
275
+
261 276
 /** VLAN configuration protocol GUID */
262 277
 EFI_GUID efi_vlan_config_protocol_guid
263 278
 	= EFI_VLAN_CONFIG_PROTOCOL_GUID;

Loading…
Cancel
Save