]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Include/IndustryStandard/Usb.h
MdePkg: TpmPtp: Add CapCRBIdleBypass definition
[mirror_edk2.git] / MdePkg / Include / IndustryStandard / Usb.h
index e37389151adc83ded26a8f5c1faf89dfad705dc0..c27ea15b4122af09cd49bda3daa4fcf42ad9eacf 100644 (file)
@@ -1,8 +1,8 @@
 /** @file\r
-  Support for USB 1.1 standard.\r
+  Support for USB 2.0 standard.\r
 \r
-  Copyright (c) 2006 - 2007, Intel Corporation\r
-  All rights reserved. This program and the accompanying materials\r
+  Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
+  This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
   http://opensource.org/licenses/bsd-license.php\r
 #ifndef __USB_H__\r
 #define __USB_H__\r
 \r
-\r
 //\r
-// Definitions defined in UEFI spec\r
+// Subset of Class and Subclass definitions from USB Specs\r
 //\r
 \r
 //\r
-// USB Transfer Results\r
+// Usb mass storage class code\r
 //\r
-#define EFI_USB_NOERROR             0x00\r
-#define EFI_USB_ERR_NOTEXECUTE      0x01\r
-#define EFI_USB_ERR_STALL           0x02\r
-#define EFI_USB_ERR_BUFFER          0x04\r
-#define EFI_USB_ERR_BABBLE          0x08\r
-#define EFI_USB_ERR_NAK             0x10\r
-#define EFI_USB_ERR_CRC             0x20\r
-#define EFI_USB_ERR_TIMEOUT         0x40\r
-#define EFI_USB_ERR_BITSTUFF        0x80\r
-#define EFI_USB_ERR_SYSTEM          0x100\r
+#define USB_MASS_STORE_CLASS    0x08\r
 \r
 //\r
-// Constant value for Port Status & Port Change Status\r
+// Usb mass storage subclass code, specify the command set used.\r
 //\r
-#define USB_PORT_STAT_CONNECTION    0x0001\r
-#define USB_PORT_STAT_ENABLE        0x0002\r
-#define USB_PORT_STAT_SUSPEND       0x0004\r
-#define USB_PORT_STAT_OVERCURRENT   0x0008\r
-#define USB_PORT_STAT_RESET         0x0010\r
-#define USB_PORT_STAT_POWER         0x0100\r
-#define USB_PORT_STAT_LOW_SPEED     0x0200\r
-#define USB_PORT_STAT_HIGH_SPEED    0x0400\r
-#define USB_PORT_STAT_OWNER         0x0800\r
-\r
-#define USB_PORT_STAT_C_CONNECTION  0x0001\r
-#define USB_PORT_STAT_C_ENABLE      0x0002\r
-#define USB_PORT_STAT_C_SUSPEND     0x0004\r
-#define USB_PORT_STAT_C_OVERCURRENT 0x0008\r
-#define USB_PORT_STAT_C_RESET       0x0010\r
+#define USB_MASS_STORE_RBC      0x01 ///< Reduced Block Commands\r
+#define USB_MASS_STORE_8020I    0x02 ///< SFF-8020i, typically a CD/DVD device\r
+#define USB_MASS_STORE_QIC      0x03 ///< Typically a tape device\r
+#define USB_MASS_STORE_UFI      0x04 ///< Typically a floppy disk driver device\r
+#define USB_MASS_STORE_8070I    0x05 ///< SFF-8070i, typically a floppy disk driver device.\r
+#define USB_MASS_STORE_SCSI     0x06 ///< SCSI transparent command set\r
 \r
 //\r
-// USB data transfer direction\r
+// Usb mass storage protocol code, specify the transport protocol\r
 //\r
-typedef enum {\r
-  EfiUsbDataIn,\r
-  EfiUsbDataOut,\r
-  EfiUsbNoData\r
-} EFI_USB_DATA_DIRECTION;\r
+#define USB_MASS_STORE_CBI0     0x00 ///< CBI protocol with command completion interrupt\r
+#define USB_MASS_STORE_CBI1     0x01 ///< CBI protocol without command completion interrupt\r
+#define USB_MASS_STORE_BOT      0x50 ///< Bulk-Only Transport\r
 \r
 //\r
-// Usb port features\r
+// Standard device request and request type\r
+// USB 2.0 spec, Section 9.4\r
 //\r
-typedef enum {\r
-  EfiUsbPortEnable            = 1,\r
-  EfiUsbPortSuspend           = 2,\r
-  EfiUsbPortReset             = 4,\r
-  EfiUsbPortPower             = 8,\r
-  EfiUsbPortOwner             = 13,\r
-  EfiUsbPortConnectChange     = 16,\r
-  EfiUsbPortEnableChange      = 17,\r
-  EfiUsbPortSuspendChange     = 18,\r
-  EfiUsbPortOverCurrentChange = 19,\r
-  EfiUsbPortResetChange       = 20\r
-} EFI_USB_PORT_FEATURE;\r
+#define USB_DEV_GET_STATUS                  0x00\r
+#define USB_DEV_GET_STATUS_REQ_TYPE_D       0x80 // Receiver : Device\r
+#define USB_DEV_GET_STATUS_REQ_TYPE_I       0x81 // Receiver : Interface\r
+#define USB_DEV_GET_STATUS_REQ_TYPE_E       0x82 // Receiver : Endpoint\r
+\r
+#define USB_DEV_CLEAR_FEATURE               0x01\r
+#define USB_DEV_CLEAR_FEATURE_REQ_TYPE_D    0x00 // Receiver : Device\r
+#define USB_DEV_CLEAR_FEATURE_REQ_TYPE_I    0x01 // Receiver : Interface\r
+#define USB_DEV_CLEAR_FEATURE_REQ_TYPE_E    0x02 // Receiver : Endpoint\r
+\r
+#define USB_DEV_SET_FEATURE                 0x03\r
+#define USB_DEV_SET_FEATURE_REQ_TYPE_D      0x00 // Receiver : Device\r
+#define USB_DEV_SET_FEATURE_REQ_TYPE_I      0x01 // Receiver : Interface\r
+#define USB_DEV_SET_FEATURE_REQ_TYPE_E      0x02 // Receiver : Endpoint\r
+\r
+#define USB_DEV_SET_ADDRESS                 0x05\r
+#define USB_DEV_SET_ADDRESS_REQ_TYPE        0x00\r
+\r
+#define USB_DEV_GET_DESCRIPTOR              0x06\r
+#define USB_DEV_GET_DESCRIPTOR_REQ_TYPE     0x80\r
+\r
+#define USB_DEV_SET_DESCRIPTOR              0x07\r
+#define USB_DEV_SET_DESCRIPTOR_REQ_TYPE     0x00\r
+\r
+#define USB_DEV_GET_CONFIGURATION           0x08\r
+#define USB_DEV_GET_CONFIGURATION_REQ_TYPE  0x80\r
+\r
+#define USB_DEV_SET_CONFIGURATION           0x09\r
+#define USB_DEV_SET_CONFIGURATION_REQ_TYPE  0x00\r
+\r
+#define USB_DEV_GET_INTERFACE               0x0A\r
+#define USB_DEV_GET_INTERFACE_REQ_TYPE      0x81\r
+\r
+#define USB_DEV_SET_INTERFACE               0x0B\r
+#define USB_DEV_SET_INTERFACE_REQ_TYPE      0x01\r
+\r
+#define USB_DEV_SYNCH_FRAME                 0x0C\r
+#define USB_DEV_SYNCH_FRAME_REQ_TYPE        0x82\r
 \r
 \r
 //\r
 // USB standard descriptors and reqeust\r
 //\r
 #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
-} EFI_USB_DEVICE_REQUEST;\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
@@ -106,8 +121,12 @@ typedef struct {
   UINT8           StrProduct;\r
   UINT8           StrSerialNumber;\r
   UINT8           NumConfigurations;\r
-} EFI_USB_DEVICE_DESCRIPTOR;\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
@@ -117,8 +136,12 @@ typedef struct {
   UINT8           Configuration;\r
   UINT8           Attributes;\r
   UINT8           MaxPower;\r
-} EFI_USB_CONFIG_DESCRIPTOR;\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
@@ -129,8 +152,12 @@ typedef struct {
   UINT8           InterfaceSubClass;\r
   UINT8           InterfaceProtocol;\r
   UINT8           Interface;\r
-} EFI_USB_INTERFACE_DESCRIPTOR;\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
@@ -138,8 +165,12 @@ typedef struct {
   UINT8           Attributes;\r
   UINT16          MaxPacketSize;\r
   UINT8           Interval;\r
-} EFI_USB_ENDPOINT_DESCRIPTOR;\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
@@ -148,17 +179,8 @@ typedef struct {
 \r
 #pragma pack()\r
 \r
-typedef struct {\r
-  UINT16          PortStatus;\r
-  UINT16          PortChangeStatus;\r
-} EFI_USB_PORT_STATUS;\r
-\r
 \r
-//\r
-// Following are definitions not specified by UEFI spec.\r
-// Add new definitions below this line\r
-//\r
-enum {\r
+typedef enum {\r
   //\r
   // USB request type\r
   //\r
@@ -199,6 +221,7 @@ enum {
   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
@@ -219,6 +242,145 @@ enum {
   //\r
   //Use 200 ms to increase the error handling response time\r
   //\r
-  EFI_USB_INTERRUPT_DELAY = 2000000,\r
-};\r
+  EFI_USB_INTERRUPT_DELAY = 2000000\r
+} USB_TYPES_DEFINITION;\r
+\r
+\r
+//\r
+// HID constants definition, see Device Class Definition\r
+// for Human Interface Devices (HID) rev1.11\r
+//\r
+\r
+//\r
+// HID standard GET_DESCRIPTOR request.\r
+//\r
+#define USB_HID_GET_DESCRIPTOR_REQ_TYPE  0x81\r
+\r
+//\r
+// HID specific requests.\r
+//\r
+#define USB_HID_CLASS_GET_REQ_TYPE       0xa1\r
+#define USB_HID_CLASS_SET_REQ_TYPE       0x21\r
+\r
+//\r
+// HID report item format\r
+//\r
+#define HID_ITEM_FORMAT_SHORT 0\r
+#define HID_ITEM_FORMAT_LONG  1\r
+\r
+//\r
+// Special tag indicating long items\r
+//\r
+#define HID_ITEM_TAG_LONG 15\r
+\r
+//\r
+// HID report descriptor item type (prefix bit 2,3)\r
+//\r
+#define HID_ITEM_TYPE_MAIN      0\r
+#define HID_ITEM_TYPE_GLOBAL    1\r
+#define HID_ITEM_TYPE_LOCAL     2\r
+#define HID_ITEM_TYPE_RESERVED  3\r
+\r
+//\r
+// HID report descriptor main item tags\r
+//\r
+#define HID_MAIN_ITEM_TAG_INPUT             8\r
+#define HID_MAIN_ITEM_TAG_OUTPUT            9\r
+#define HID_MAIN_ITEM_TAG_FEATURE           11\r
+#define HID_MAIN_ITEM_TAG_BEGIN_COLLECTION  10\r
+#define HID_MAIN_ITEM_TAG_END_COLLECTION    12\r
+\r
+//\r
+// HID report descriptor main item contents\r
+//\r
+#define HID_MAIN_ITEM_CONSTANT      0x001\r
+#define HID_MAIN_ITEM_VARIABLE      0x002\r
+#define HID_MAIN_ITEM_RELATIVE      0x004\r
+#define HID_MAIN_ITEM_WRAP          0x008\r
+#define HID_MAIN_ITEM_NONLINEAR     0x010\r
+#define HID_MAIN_ITEM_NO_PREFERRED  0x020\r
+#define HID_MAIN_ITEM_NULL_STATE    0x040\r
+#define HID_MAIN_ITEM_VOLATILE      0x080\r
+#define HID_MAIN_ITEM_BUFFERED_BYTE 0x100\r
+\r
+//\r
+// HID report descriptor collection item types\r
+//\r
+#define HID_COLLECTION_PHYSICAL     0\r
+#define HID_COLLECTION_APPLICATION  1\r
+#define HID_COLLECTION_LOGICAL      2\r
+\r
+//\r
+// HID report descriptor global item tags\r
+//\r
+#define HID_GLOBAL_ITEM_TAG_USAGE_PAGE        0\r
+#define HID_GLOBAL_ITEM_TAG_LOGICAL_MINIMUM   1\r
+#define HID_GLOBAL_ITEM_TAG_LOGICAL_MAXIMUM   2\r
+#define HID_GLOBAL_ITEM_TAG_PHYSICAL_MINIMUM  3\r
+#define HID_GLOBAL_ITEM_TAG_PHYSICAL_MAXIMUM  4\r
+#define HID_GLOBAL_ITEM_TAG_UNIT_EXPONENT     5\r
+#define HID_GLOBAL_ITEM_TAG_UNIT              6\r
+#define HID_GLOBAL_ITEM_TAG_REPORT_SIZE       7\r
+#define HID_GLOBAL_ITEM_TAG_REPORT_ID         8\r
+#define HID_GLOBAL_ITEM_TAG_REPORT_COUNT      9\r
+#define HID_GLOBAL_ITEM_TAG_PUSH              10\r
+#define HID_GLOBAL_ITEM_TAG_POP               11\r
+\r
+//\r
+// HID report descriptor local item tags\r
+//\r
+#define HID_LOCAL_ITEM_TAG_USAGE              0\r
+#define HID_LOCAL_ITEM_TAG_USAGE_MINIMUM      1\r
+#define HID_LOCAL_ITEM_TAG_USAGE_MAXIMUM      2\r
+#define HID_LOCAL_ITEM_TAG_DESIGNATOR_INDEX   3\r
+#define HID_LOCAL_ITEM_TAG_DESIGNATOR_MINIMUM 4\r
+#define HID_LOCAL_ITEM_TAG_DESIGNATOR_MAXIMUM 5\r
+#define HID_LOCAL_ITEM_TAG_STRING_INDEX       7\r
+#define HID_LOCAL_ITEM_TAG_STRING_MINIMUM     8\r
+#define HID_LOCAL_ITEM_TAG_STRING_MAXIMUM     9\r
+#define HID_LOCAL_ITEM_TAG_DELIMITER          10\r
+\r
+//\r
+// HID report types\r
+//\r
+#define HID_INPUT_REPORT    1\r
+#define HID_OUTPUT_REPORT   2\r
+#define HID_FEATURE_REPORT  3\r
+\r
+//\r
+// HID class protocol request\r
+//\r
+#define EFI_USB_GET_REPORT_REQUEST    0x01\r
+#define EFI_USB_GET_IDLE_REQUEST      0x02\r
+#define EFI_USB_GET_PROTOCOL_REQUEST  0x03\r
+#define EFI_USB_SET_REPORT_REQUEST    0x09\r
+#define EFI_USB_SET_IDLE_REQUEST      0x0a\r
+#define EFI_USB_SET_PROTOCOL_REQUEST  0x0b\r
+\r
+#pragma pack(1)\r
+///\r
+/// Descriptor header for Report/Physical Descriptors\r
+/// HID 1.1, section 6.2.1\r
+///\r
+typedef struct hid_class_descriptor {\r
+  UINT8   DescriptorType;\r
+  UINT16  DescriptorLength;\r
+} EFI_USB_HID_CLASS_DESCRIPTOR;\r
+\r
+///\r
+/// The HID descriptor identifies the length and type\r
+/// of subordinate descriptors for a device.\r
+/// HID 1.1, section 6.2.1\r
+///\r
+typedef struct hid_descriptor {\r
+  UINT8                         Length;\r
+  UINT8                         DescriptorType;\r
+  UINT16                        BcdHID;\r
+  UINT8                         CountryCode;\r
+  UINT8                         NumDescriptors;\r
+  EFI_USB_HID_CLASS_DESCRIPTOR  HidClassDesc[1];\r
+} EFI_USB_HID_DESCRIPTOR;\r
+\r
+#pragma pack()\r
+\r
 #endif\r