X-Git-Url: https://git.proxmox.com/?p=mirror_edk2.git;a=blobdiff_plain;f=MdePkg%2FInclude%2FIndustryStandard%2FUsb.h;h=c4367b58bb8861a6f7f79676961df2f317c59b75;hp=e37389151adc83ded26a8f5c1faf89dfad705dc0;hb=e1c9edd6b6ea5e78f02e382b254de40cf708d20c;hpb=196d5cd166f501c9a4a57638d227bdf9cf98b2c2 diff --git a/MdePkg/Include/IndustryStandard/Usb.h b/MdePkg/Include/IndustryStandard/Usb.h index e37389151a..c4367b58bb 100644 --- a/MdePkg/Include/IndustryStandard/Usb.h +++ b/MdePkg/Include/IndustryStandard/Usb.h @@ -1,8 +1,8 @@ /** @file - Support for USB 1.1 standard. + Support for USB 2.0 standard. - Copyright (c) 2006 - 2007, Intel Corporation - All rights reserved. This program and the accompanying materials + Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.
+ This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at http://opensource.org/licenses/bsd-license.php @@ -15,82 +15,71 @@ #ifndef __USB_H__ #define __USB_H__ - // -// Definitions defined in UEFI spec +// Standard device request and request type +// USB 2.0 spec, Section 9.4 // +#define USB_DEV_GET_STATUS 0x00 +#define USB_DEV_GET_STATUS_REQ_TYPE_D 0x80 // Receiver : Device +#define USB_DEV_GET_STATUS_REQ_TYPE_I 0x81 // Receiver : Interface +#define USB_DEV_GET_STATUS_REQ_TYPE_E 0x82 // Receiver : Endpoint -// -// USB Transfer Results -// -#define EFI_USB_NOERROR 0x00 -#define EFI_USB_ERR_NOTEXECUTE 0x01 -#define EFI_USB_ERR_STALL 0x02 -#define EFI_USB_ERR_BUFFER 0x04 -#define EFI_USB_ERR_BABBLE 0x08 -#define EFI_USB_ERR_NAK 0x10 -#define EFI_USB_ERR_CRC 0x20 -#define EFI_USB_ERR_TIMEOUT 0x40 -#define EFI_USB_ERR_BITSTUFF 0x80 -#define EFI_USB_ERR_SYSTEM 0x100 +#define USB_DEV_CLEAR_FEATURE 0x01 +#define USB_DEV_CLEAR_FEATURE_REQ_TYPE_D 0x00 // Receiver : Device +#define USB_DEV_CLEAR_FEATURE_REQ_TYPE_I 0x01 // Receiver : Interface +#define USB_DEV_CLEAR_FEATURE_REQ_TYPE_E 0x02 // Receiver : Endpoint -// -// Constant value for Port Status & Port Change Status -// -#define USB_PORT_STAT_CONNECTION 0x0001 -#define USB_PORT_STAT_ENABLE 0x0002 -#define USB_PORT_STAT_SUSPEND 0x0004 -#define USB_PORT_STAT_OVERCURRENT 0x0008 -#define USB_PORT_STAT_RESET 0x0010 -#define USB_PORT_STAT_POWER 0x0100 -#define USB_PORT_STAT_LOW_SPEED 0x0200 -#define USB_PORT_STAT_HIGH_SPEED 0x0400 -#define USB_PORT_STAT_OWNER 0x0800 +#define USB_DEV_SET_FEATURE 0x03 +#define USB_DEV_SET_FEATURE_REQ_TYPE_D 0x00 // Receiver : Device +#define USB_DEV_SET_FEATURE_REQ_TYPE_I 0x01 // Receiver : Interface +#define USB_DEV_SET_FEATURE_REQ_TYPE_E 0x02 // Receiver : Endpoint -#define USB_PORT_STAT_C_CONNECTION 0x0001 -#define USB_PORT_STAT_C_ENABLE 0x0002 -#define USB_PORT_STAT_C_SUSPEND 0x0004 -#define USB_PORT_STAT_C_OVERCURRENT 0x0008 -#define USB_PORT_STAT_C_RESET 0x0010 +#define USB_DEV_SET_ADDRESS 0x05 +#define USB_DEV_SET_ADDRESS_REQ_TYPE 0x00 -// -// USB data transfer direction -// -typedef enum { - EfiUsbDataIn, - EfiUsbDataOut, - EfiUsbNoData -} EFI_USB_DATA_DIRECTION; +#define USB_DEV_GET_DESCRIPTOR 0x06 +#define USB_DEV_GET_DESCRIPTOR_REQ_TYPE 0x80 -// -// Usb port features -// -typedef enum { - EfiUsbPortEnable = 1, - EfiUsbPortSuspend = 2, - EfiUsbPortReset = 4, - EfiUsbPortPower = 8, - EfiUsbPortOwner = 13, - EfiUsbPortConnectChange = 16, - EfiUsbPortEnableChange = 17, - EfiUsbPortSuspendChange = 18, - EfiUsbPortOverCurrentChange = 19, - EfiUsbPortResetChange = 20 -} EFI_USB_PORT_FEATURE; +#define USB_DEV_SET_DESCRIPTOR 0x07 +#define USB_DEV_SET_DESCRIPTOR_REQ_TYPE 0x00 + +#define USB_DEV_GET_CONFIGURATION 0x08 +#define USB_DEV_GET_CONFIGURATION_REQ_TYPE 0x80 + +#define USB_DEV_SET_CONFIGURATION 0x09 +#define USB_DEV_SET_CONFIGURATION_REQ_TYPE 0x00 + +#define USB_DEV_GET_INTERFACE 0x0A +#define USB_DEV_GET_INTERFACE_REQ_TYPE 0x81 + +#define USB_DEV_SET_INTERFACE 0x0B +#define USB_DEV_SET_INTERFACE_REQ_TYPE 0x01 + +#define USB_DEV_SYNCH_FRAME 0x0C +#define USB_DEV_SYNCH_FRAME_REQ_TYPE 0x82 // // USB standard descriptors and reqeust // #pragma pack(1) + +/// +/// Format of Setup Data for USB Device Requests +/// USB 2.0 spec, Section 9.3 +/// typedef struct { UINT8 RequestType; UINT8 Request; UINT16 Value; UINT16 Index; UINT16 Length; -} EFI_USB_DEVICE_REQUEST; +} USB_DEVICE_REQUEST; +/// +/// Standard Device Descriptor +/// USB 2.0 spec, Section 9.6.1 +/// typedef struct { UINT8 Length; UINT8 DescriptorType; @@ -106,8 +95,12 @@ typedef struct { UINT8 StrProduct; UINT8 StrSerialNumber; UINT8 NumConfigurations; -} EFI_USB_DEVICE_DESCRIPTOR; +} USB_DEVICE_DESCRIPTOR; +/// +/// Standard Configuration Descriptor +/// USB 2.0 spec, Section 9.6.3 +/// typedef struct { UINT8 Length; UINT8 DescriptorType; @@ -117,8 +110,12 @@ typedef struct { UINT8 Configuration; UINT8 Attributes; UINT8 MaxPower; -} EFI_USB_CONFIG_DESCRIPTOR; +} USB_CONFIG_DESCRIPTOR; +/// +/// Standard Interface Descriptor +/// USB 2.0 spec, Section 9.6.5 +/// typedef struct { UINT8 Length; UINT8 DescriptorType; @@ -129,8 +126,12 @@ typedef struct { UINT8 InterfaceSubClass; UINT8 InterfaceProtocol; UINT8 Interface; -} EFI_USB_INTERFACE_DESCRIPTOR; +} USB_INTERFACE_DESCRIPTOR; +/// +/// Standard Endpoint Descriptor +/// USB 2.0 spec, Section 9.6.6 +/// typedef struct { UINT8 Length; UINT8 DescriptorType; @@ -138,8 +139,12 @@ typedef struct { UINT8 Attributes; UINT16 MaxPacketSize; UINT8 Interval; -} EFI_USB_ENDPOINT_DESCRIPTOR; +} USB_ENDPOINT_DESCRIPTOR; +/// +/// UNICODE String Descriptor +/// USB 2.0 spec, Section 9.6.7 +/// typedef struct { UINT8 Length; UINT8 DescriptorType; @@ -148,17 +153,8 @@ typedef struct { #pragma pack() -typedef struct { - UINT16 PortStatus; - UINT16 PortChangeStatus; -} EFI_USB_PORT_STATUS; - -// -// Following are definitions not specified by UEFI spec. -// Add new definitions below this line -// -enum { +typedef enum { // // USB request type // @@ -199,6 +195,7 @@ enum { USB_DESC_TYPE_INTERFACE = 0x04, USB_DESC_TYPE_ENDPOINT = 0x05, USB_DESC_TYPE_HID = 0x21, + USB_DESC_TYPE_REPORT = 0x22, // // Features to be cleared by CLEAR_FEATURE requests @@ -219,6 +216,145 @@ enum { // //Use 200 ms to increase the error handling response time // - EFI_USB_INTERRUPT_DELAY = 2000000, -}; + EFI_USB_INTERRUPT_DELAY = 2000000 +} USB_TYPES_DEFINITION; + + +// +// HID constants definition, see Device Class Definition +// for Human Interface Devices (HID) rev1.11 +// + +// +// HID standard GET_DESCRIPTOR request. +// +#define USB_HID_GET_DESCRIPTOR_REQ_TYPE 0x81 + +// +// HID specific requests. +// +#define USB_HID_CLASS_GET_REQ_TYPE 0xa1 +#define USB_HID_CLASS_SET_REQ_TYPE 0x21 + +// +// HID report item format +// +#define HID_ITEM_FORMAT_SHORT 0 +#define HID_ITEM_FORMAT_LONG 1 + +// +// Special tag indicating long items +// +#define HID_ITEM_TAG_LONG 15 + +// +// HID report descriptor item type (prefix bit 2,3) +// +#define HID_ITEM_TYPE_MAIN 0 +#define HID_ITEM_TYPE_GLOBAL 1 +#define HID_ITEM_TYPE_LOCAL 2 +#define HID_ITEM_TYPE_RESERVED 3 + +// +// HID report descriptor main item tags +// +#define HID_MAIN_ITEM_TAG_INPUT 8 +#define HID_MAIN_ITEM_TAG_OUTPUT 9 +#define HID_MAIN_ITEM_TAG_FEATURE 11 +#define HID_MAIN_ITEM_TAG_BEGIN_COLLECTION 10 +#define HID_MAIN_ITEM_TAG_END_COLLECTION 12 + +// +// HID report descriptor main item contents +// +#define HID_MAIN_ITEM_CONSTANT 0x001 +#define HID_MAIN_ITEM_VARIABLE 0x002 +#define HID_MAIN_ITEM_RELATIVE 0x004 +#define HID_MAIN_ITEM_WRAP 0x008 +#define HID_MAIN_ITEM_NONLINEAR 0x010 +#define HID_MAIN_ITEM_NO_PREFERRED 0x020 +#define HID_MAIN_ITEM_NULL_STATE 0x040 +#define HID_MAIN_ITEM_VOLATILE 0x080 +#define HID_MAIN_ITEM_BUFFERED_BYTE 0x100 + +// +// HID report descriptor collection item types +// +#define HID_COLLECTION_PHYSICAL 0 +#define HID_COLLECTION_APPLICATION 1 +#define HID_COLLECTION_LOGICAL 2 + +// +// HID report descriptor global item tags +// +#define HID_GLOBAL_ITEM_TAG_USAGE_PAGE 0 +#define HID_GLOBAL_ITEM_TAG_LOGICAL_MINIMUM 1 +#define HID_GLOBAL_ITEM_TAG_LOGICAL_MAXIMUM 2 +#define HID_GLOBAL_ITEM_TAG_PHYSICAL_MINIMUM 3 +#define HID_GLOBAL_ITEM_TAG_PHYSICAL_MAXIMUM 4 +#define HID_GLOBAL_ITEM_TAG_UNIT_EXPONENT 5 +#define HID_GLOBAL_ITEM_TAG_UNIT 6 +#define HID_GLOBAL_ITEM_TAG_REPORT_SIZE 7 +#define HID_GLOBAL_ITEM_TAG_REPORT_ID 8 +#define HID_GLOBAL_ITEM_TAG_REPORT_COUNT 9 +#define HID_GLOBAL_ITEM_TAG_PUSH 10 +#define HID_GLOBAL_ITEM_TAG_POP 11 + +// +// HID report descriptor local item tags +// +#define HID_LOCAL_ITEM_TAG_USAGE 0 +#define HID_LOCAL_ITEM_TAG_USAGE_MINIMUM 1 +#define HID_LOCAL_ITEM_TAG_USAGE_MAXIMUM 2 +#define HID_LOCAL_ITEM_TAG_DESIGNATOR_INDEX 3 +#define HID_LOCAL_ITEM_TAG_DESIGNATOR_MINIMUM 4 +#define HID_LOCAL_ITEM_TAG_DESIGNATOR_MAXIMUM 5 +#define HID_LOCAL_ITEM_TAG_STRING_INDEX 7 +#define HID_LOCAL_ITEM_TAG_STRING_MINIMUM 8 +#define HID_LOCAL_ITEM_TAG_STRING_MAXIMUM 9 +#define HID_LOCAL_ITEM_TAG_DELIMITER 10 + +// +// HID report types +// +#define HID_INPUT_REPORT 1 +#define HID_OUTPUT_REPORT 2 +#define HID_FEATURE_REPORT 3 + +// +// HID class protocol request +// +#define EFI_USB_GET_REPORT_REQUEST 0x01 +#define EFI_USB_GET_IDLE_REQUEST 0x02 +#define EFI_USB_GET_PROTOCOL_REQUEST 0x03 +#define EFI_USB_SET_REPORT_REQUEST 0x09 +#define EFI_USB_SET_IDLE_REQUEST 0x0a +#define EFI_USB_SET_PROTOCOL_REQUEST 0x0b + +#pragma pack(1) +/// +/// Descriptor header for Report/Physical Descriptors +/// HID 1.1, section 6.2.1 +/// +typedef struct hid_class_descriptor { + UINT8 DescriptorType; + UINT16 DescriptorLength; +} EFI_USB_HID_CLASS_DESCRIPTOR; + +/// +/// The HID descriptor identifies the length and type +/// of subordinate descriptors for a device. +/// HID 1.1, section 6.2.1 +/// +typedef struct hid_descriptor { + UINT8 Length; + UINT8 DescriptorType; + UINT16 BcdHID; + UINT8 CountryCode; + UINT8 NumDescriptors; + EFI_USB_HID_CLASS_DESCRIPTOR HidClassDesc[1]; +} EFI_USB_HID_DESCRIPTOR; + +#pragma pack() + #endif