Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

269 lines
7.6 KiB

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