1#ifndef __USB100_H__ 2#define __USB100_H__ 3 4 5//#include "PSHPACK1.H" 6#include "pshpack1.h" 7 8typedef struct _LIST_ENTRY{ 9 struct _LIST_ENTRY *Flink; 10 struct _LIST_ENTRY *Blink; 11}LIST_ENTRY, *PLIST_ENTRY; 12 13//bmRequest.Dir 14#define BMREQUEST_HOST_TO_DEVICE 0 15#define BMREQUEST_DEVICE_TO_HOST 1 16 17//bmRequest.Type 18#define BMREQUEST_STANDARD 0 19#define BMREQUEST_CLASS 1 20#define BMREQUEST_VENDOR 2 21 22//bmRequest.Recipient 23#define BMREQUEST_TO_DEVICE 0 24#define BMREQUEST_TO_INTERFACE 1 25#define BMREQUEST_TO_ENDPOINT 2 26#define BMREQUEST_TO_OTHER 3 27 28 29#define MAXIMUM_USB_STRING_LENGTH 255 30 31// values for the bits returned by the USB GET_STATUS command 32#define USB_GETSTATUS_SELF_POWERED 0x01 33#define USB_GETSTATUS_REMOTE_WAKEUP_ENABLED 0x02 34 35 36#define USB_DEVICE_DESCRIPTOR_TYPE 0x01 37#define USB_CONFIGURATION_DESCRIPTOR_TYPE 0x02 38#define USB_STRING_DESCRIPTOR_TYPE 0x03 39#define USB_INTERFACE_DESCRIPTOR_TYPE 0x04 40#define USB_ENDPOINT_DESCRIPTOR_TYPE 0x05 41 42// descriptor types defined by DWG documents 43#define USB_RESERVED_DESCRIPTOR_TYPE 0x06 44#define USB_CONFIG_POWER_DESCRIPTOR_TYPE 0x07 45#define USB_INTERFACE_POWER_DESCRIPTOR_TYPE 0x08 46 47#define USB_DESCRIPTOR_MAKE_TYPE_AND_INDEX(d, i) ((USHORT)((USHORT)d<<8 | i)) 48 49// 50// Values for bmAttributes field of an 51// endpoint descriptor 52// 53/* 54#define USB_ENDPOINT_TYPE_MASK 0x03 55 56#define USB_ENDPOINT_TYPE_CONTROL 0x00 57#define USB_ENDPOINT_TYPE_ISOCHRONOUS 0x01 58#define USB_ENDPOINT_TYPE_BULK 0x02 59#define USB_ENDPOINT_TYPE_INTERRUPT 0x03 60*/ 61 62// 63// definitions for bits in the bmAttributes field of a 64// configuration descriptor. 65// 66#define USB_CONFIG_POWERED_MASK 0xc0 67 68#define USB_CONFIG_BUS_POWERED 0x80 69#define USB_CONFIG_SELF_POWERED 0x40 70#define USB_CONFIG_REMOTE_WAKEUP 0x20 71 72// 73// Endpoint direction bit, stored in address 74// 75 76#define USB_ENDPOINT_DIRECTION_MASK 0x80 77 78// test direction bit in the bEndpointAddress field of 79// an endpoint descriptor. 80#define USB_ENDPOINT_DIRECTION_OUT(addr) (!((addr) & USB_ENDPOINT_DIRECTION_MASK)) 81#define USB_ENDPOINT_DIRECTION_IN(addr) ((addr) & USB_ENDPOINT_DIRECTION_MASK) 82 83//#include "POPPACK.H" 84// USB defined request codes 85// see chapter 9 of the USB 1.0 specifcation for 86// more information. 87// 88 89// These are the correct values based on the USB 1.0 90// specification 91 92#define USB_REQUEST_GET_STATUS 0x00 93#define USB_REQUEST_CLEAR_FEATURE 0x01 94 95#define USB_REQUEST_SET_FEATURE 0x03 96 97#define USB_REQUEST_SET_ADDRESS 0x05 98#define USB_REQUEST_GET_DESCRIPTOR 0x06 99#define USB_REQUEST_SET_DESCRIPTOR 0x07 100#define USB_REQUEST_GET_CONFIGURATION 0x08 101#define USB_REQUEST_SET_CONFIGURATION 0x09 102#define USB_REQUEST_GET_INTERFACE 0x0A 103#define USB_REQUEST_SET_INTERFACE 0x0B 104#define USB_REQUEST_SYNC_FRAME 0x0C 105 106 107// 108// defined USB device classes 109// 110 111 112#define USB_DEVICE_CLASS_RESERVED 0x00 113#define USB_DEVICE_CLASS_AUDIO 0x01 114#define USB_DEVICE_CLASS_COMMUNICATIONS 0x02 115#define USB_DEVICE_CLASS_HUMAN_INTERFACE 0x03 116#define USB_DEVICE_CLASS_MONITOR 0x04 117#define USB_DEVICE_CLASS_PHYSICAL_INTERFACE 0x05 118#define USB_DEVICE_CLASS_POWER 0x06 119#define USB_DEVICE_CLASS_PRINTER 0x07 120#define USB_DEVICE_CLASS_STORAGE 0x08 121#define USB_DEVICE_CLASS_HUB 0x09 122#define USB_DEVICE_CLASS_VENDOR_SPECIFIC 0xFF 123 124// 125// USB Core defined Feature selectors 126// 127 128#define USB_FEATURE_ENDPOINT_STALL 0x0000 129#define USB_FEATURE_REMOTE_WAKEUP 0x0001 130 131// 132// USB DWG defined Feature selectors 133// 134 135#define USB_FEATURE_INTERFACE_POWER_D0 0x0002 136#define USB_FEATURE_INTERFACE_POWER_D1 0x0003 137#define USB_FEATURE_INTERFACE_POWER_D2 0x0004 138#define USB_FEATURE_INTERFACE_POWER_D3 0x0005 139 140typedef struct _USB_DEVICE_DESCRIPTOR { 141 UCHAR bLength; 142 UCHAR bDescriptorType; 143 USHORT bcdUSB; 144 UCHAR bDeviceClass; 145 UCHAR bDeviceSubClass; 146 UCHAR bDeviceProtocol; 147 UCHAR bMaxPacketSize0; 148 USHORT idVendor; 149 USHORT idProduct; 150 USHORT bcdDevice; 151 UCHAR iManufacturer; 152 UCHAR iProduct; 153 UCHAR iSerialNumber; 154 UCHAR bNumConfigurations; 155} USB_DEVICE_DESCRIPTOR, *PUSB_DEVICE_DESCRIPTOR; 156 157typedef struct _USB_ENDPOINT_DESCRIPTOR { 158 UCHAR bLength; 159 UCHAR bDescriptorType; 160 UCHAR bEndpointAddress; 161 UCHAR bmAttributes; 162 USHORT wMaxPacketSize; 163 UCHAR bInterval; 164} USB_ENDPOINT_DESCRIPTOR, *PUSB_ENDPOINT_DESCRIPTOR; 165 166typedef struct _USB_CONFIGURATION_DESCRIPTOR { 167 UCHAR bLength; 168 UCHAR bDescriptorType; 169 USHORT wTotalLength; 170 UCHAR bNumInterfaces; 171 UCHAR bConfigurationValue; 172 UCHAR iConfiguration; 173 UCHAR bmAttributes; 174 UCHAR MaxPower; 175} USB_CONFIGURATION_DESCRIPTOR, *PUSB_CONFIGURATION_DESCRIPTOR; 176 177typedef struct _USB_INTERFACE_DESCRIPTOR { 178 UCHAR bLength; 179 UCHAR bDescriptorType; 180 UCHAR bInterfaceNumber; 181 UCHAR bAlternateSetting; 182 UCHAR bNumEndpoints; 183 UCHAR bInterfaceClass; 184 UCHAR bInterfaceSubClass; 185 UCHAR bInterfaceProtocol; 186 UCHAR iInterface; 187} USB_INTERFACE_DESCRIPTOR, *PUSB_INTERFACE_DESCRIPTOR; 188 189typedef struct _USB_STRING_DESCRIPTOR { 190 UCHAR bLength; 191 UCHAR bDescriptorType; 192 WCHAR bString[1]; 193} USB_STRING_DESCRIPTOR, *PUSB_STRING_DESCRIPTOR; 194 195typedef struct _USB_COMMON_DESCRIPTOR { 196 UCHAR bLength; 197 UCHAR bDescriptorType; 198} USB_COMMON_DESCRIPTOR, *PUSB_COMMON_DESCRIPTOR; 199 200 201// 202// Standard USB HUB definitions 203// 204// See Chapter 11 USB core specification 205// 206 207typedef struct _USB_HUB_DESCRIPTOR { 208 UCHAR bDescriptorLength; // Length of this descriptor 209 UCHAR bDescriptorType; // Hub configuration type 210 UCHAR bNumberOfPorts; // number of ports on this hub 211 USHORT wHubCharacteristics; // Hub Charateristics 212 UCHAR bPowerOnToPowerGood; // port power on till power good in 2ms 213 UCHAR bHubControlCurrent; // max current in mA 214 // 215 // room for 255 ports power control and removable bitmask 216 UCHAR bRemoveAndPowerMask[64]; 217} USB_HUB_DESCRIPTOR, *PUSB_HUB_DESCRIPTOR; 218 219 220// 221// Structures defined by various DWG feature documents 222// 223 224 225// 226// See DWG USB Feature Specification: Interface Power Management 227// 228 229#define USB_SUPPORT_D0_COMMAND 0x01 230#define USB_SUPPORT_D1_COMMAND 0x02 231#define USB_SUPPORT_D2_COMMAND 0x04 232#define USB_SUPPORT_D3_COMMAND 0x08 233 234#define USB_SUPPORT_D1_WAKEUP 0x10 235#define USB_SUPPORT_D2_WAKEUP 0x20 236 237 238typedef struct _USB_CONFIGURATION_POWER_DESCRIPTOR { 239 UCHAR bLength; 240 UCHAR bDescriptorType; 241 UCHAR SelfPowerConsumedD0[3]; 242 UCHAR bPowerSummaryId; 243 UCHAR bBusPowerSavingD1; 244 UCHAR bSelfPowerSavingD1; 245 UCHAR bBusPowerSavingD2; 246 UCHAR bSelfPowerSavingD2; 247 UCHAR bBusPowerSavingD3; 248 UCHAR bSelfPowerSavingD3; 249 USHORT TransitionTimeFromD1; 250 USHORT TransitionTimeFromD2; 251 USHORT TransitionTimeFromD3; 252} USB_CONFIGURATION_POWER_DESCRIPTOR, *PUSB_CONFIGURATION_POWER_DESCRIPTOR; 253 254 255typedef struct _USB_INTERFACE_POWER_DESCRIPTOR { 256 UCHAR bLength; 257 UCHAR bDescriptorType; 258 UCHAR bmCapabilitiesFlags; 259 UCHAR bBusPowerSavingD1; 260 UCHAR bSelfPowerSavingD1; 261 UCHAR bBusPowerSavingD2; 262 UCHAR bSelfPowerSavingD2; 263 UCHAR bBusPowerSavingD3; 264 UCHAR bSelfPowerSavingD3; 265 USHORT TransitionTimeFromD1; 266 USHORT TransitionTimeFromD2; 267 USHORT TransitionTimeFromD3; 268} USB_INTERFACE_POWER_DESCRIPTOR, *PUSB_INTERFACE_POWER_DESCRIPTOR; 269 270 271//#include "POPPACK.H" 272#include "poppack.h" 273 274#endif /* __USB100_H__ */ 275 276