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