+#pragma pack(1)\r
+\r
+///\r
+/// Format of Setup Data for USB Device Requests\r
+/// USB 2.0 spec, Section 9.3\r
+///\r
+typedef struct {\r
+ UINT8 RequestType;\r
+ UINT8 Request;\r
+ UINT16 Value;\r
+ UINT16 Index;\r
+ UINT16 Length;\r
+} USB_DEVICE_REQUEST;\r
+\r
+///\r
+/// Standard Device Descriptor\r
+/// USB 2.0 spec, Section 9.6.1\r
+///\r
+typedef struct {\r
+ UINT8 Length;\r
+ UINT8 DescriptorType;\r
+ UINT16 BcdUSB;\r
+ UINT8 DeviceClass;\r
+ UINT8 DeviceSubClass;\r
+ UINT8 DeviceProtocol;\r
+ UINT8 MaxPacketSize0;\r
+ UINT16 IdVendor;\r
+ UINT16 IdProduct;\r
+ UINT16 BcdDevice;\r
+ UINT8 StrManufacturer;\r
+ UINT8 StrProduct;\r
+ UINT8 StrSerialNumber;\r
+ UINT8 NumConfigurations;\r
+} USB_DEVICE_DESCRIPTOR;\r
+\r
+///\r
+/// Standard Configuration Descriptor\r
+/// USB 2.0 spec, Section 9.6.3\r
+///\r
+typedef struct {\r
+ UINT8 Length;\r
+ UINT8 DescriptorType;\r
+ UINT16 TotalLength;\r
+ UINT8 NumInterfaces;\r
+ UINT8 ConfigurationValue;\r
+ UINT8 Configuration;\r
+ UINT8 Attributes;\r
+ UINT8 MaxPower;\r
+} USB_CONFIG_DESCRIPTOR;\r
+\r
+///\r
+/// Standard Interface Descriptor\r
+/// USB 2.0 spec, Section 9.6.5\r
+///\r
+typedef struct {\r
+ UINT8 Length;\r
+ UINT8 DescriptorType;\r
+ UINT8 InterfaceNumber;\r
+ UINT8 AlternateSetting;\r
+ UINT8 NumEndpoints;\r
+ UINT8 InterfaceClass;\r
+ UINT8 InterfaceSubClass;\r
+ UINT8 InterfaceProtocol;\r
+ UINT8 Interface;\r
+} USB_INTERFACE_DESCRIPTOR;\r
+\r
+///\r
+/// Standard Endpoint Descriptor\r
+/// USB 2.0 spec, Section 9.6.6\r
+///\r
+typedef struct {\r
+ UINT8 Length;\r
+ UINT8 DescriptorType;\r
+ UINT8 EndpointAddress;\r
+ UINT8 Attributes;\r
+ UINT16 MaxPacketSize;\r
+ UINT8 Interval;\r
+} USB_ENDPOINT_DESCRIPTOR;\r
+\r
+///\r
+/// UNICODE String Descriptor\r
+/// USB 2.0 spec, Section 9.6.7\r
+///\r
+typedef struct {\r
+ UINT8 Length;\r
+ UINT8 DescriptorType;\r
+ CHAR16 String[1];\r
+} EFI_USB_STRING_DESCRIPTOR;\r
+\r
+#pragma pack()\r
+\r
+\r
+typedef enum {\r
+ //\r
+ // USB request type\r
+ //\r
+ USB_REQ_TYPE_STANDARD = (0x00 << 5),\r
+ USB_REQ_TYPE_CLASS = (0x01 << 5),\r
+ USB_REQ_TYPE_VENDOR = (0x02 << 5),\r
+\r
+ //\r
+ // Standard control transfer request type, or the value\r
+ // to fill in EFI_USB_DEVICE_REQUEST.Request\r
+ //\r
+ USB_REQ_GET_STATUS = 0x00,\r
+ USB_REQ_CLEAR_FEATURE = 0x01,\r
+ USB_REQ_SET_FEATURE = 0x03,\r
+ USB_REQ_SET_ADDRESS = 0x05,\r
+ USB_REQ_GET_DESCRIPTOR = 0x06,\r
+ USB_REQ_SET_DESCRIPTOR = 0x07,\r
+ USB_REQ_GET_CONFIG = 0x08,\r
+ USB_REQ_SET_CONFIG = 0x09,\r
+ USB_REQ_GET_INTERFACE = 0x0A,\r
+ USB_REQ_SET_INTERFACE = 0x0B,\r
+ USB_REQ_SYNCH_FRAME = 0x0C,\r
+\r
+ //\r
+ // Usb control transfer target\r
+ //\r
+ USB_TARGET_DEVICE = 0,\r
+ USB_TARGET_INTERFACE = 0x01,\r
+ USB_TARGET_ENDPOINT = 0x02,\r
+ USB_TARGET_OTHER = 0x03,\r
+\r
+ //\r
+ // USB Descriptor types\r
+ //\r
+ USB_DESC_TYPE_DEVICE = 0x01,\r
+ USB_DESC_TYPE_CONFIG = 0x02,\r
+ USB_DESC_TYPE_STRING = 0x03,\r
+ USB_DESC_TYPE_INTERFACE = 0x04,\r
+ USB_DESC_TYPE_ENDPOINT = 0x05,\r
+ USB_DESC_TYPE_HID = 0x21,\r
+ USB_DESC_TYPE_REPORT = 0x22,\r
+\r
+ //\r
+ // Features to be cleared by CLEAR_FEATURE requests\r
+ //\r
+ USB_FEATURE_ENDPOINT_HALT = 0,\r
+\r
+ //\r
+ // USB endpoint types: 00: control, 01: isochronous, 10: bulk, 11: interrupt\r
+ //\r
+ USB_ENDPOINT_CONTROL = 0x00,\r
+ USB_ENDPOINT_ISO = 0x01,\r
+ USB_ENDPOINT_BULK = 0x02,\r
+ USB_ENDPOINT_INTERRUPT = 0x03,\r
+\r
+ USB_ENDPOINT_TYPE_MASK = 0x03,\r
+ USB_ENDPOINT_DIR_IN = 0x80,\r
+\r
+ //\r
+ //Use 200 ms to increase the error handling response time\r
+ //\r
+ EFI_USB_INTERRUPT_DELAY = 2000000\r
+} USB_TYPES_DEFINITION;\r
+\r