usb_winusb.h 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. #pragma once
  2. #include <stdint.h>
  3. /*- Definitions -------------------------------------------------------------*/
  4. #define USB_PACK __attribute__((packed))
  5. #define USB_WINUSB_VENDOR_CODE 0x20
  6. #define USB_WINUSB_WINDOWS_VERSION 0x06030000 // Windows 8.1
  7. #define USB_WINUSB_PLATFORM_CAPABILITY_ID \
  8. { \
  9. 0xdf, 0x60, 0xdd, 0xd8, 0x89, 0x45, 0xc7, 0x4c, 0x9c, 0xd2, 0x65, 0x9d, 0x9e, 0x64, 0x8a, \
  10. 0x9f \
  11. }
  12. enum // WinUSB Microsoft OS 2.0 descriptor request codes
  13. {
  14. USB_WINUSB_DESCRIPTOR_INDEX = 0x07,
  15. USB_WINUSB_SET_ALT_ENUMERATION = 0x08,
  16. };
  17. enum // wDescriptorType
  18. {
  19. USB_WINUSB_SET_HEADER_DESCRIPTOR = 0x00,
  20. USB_WINUSB_SUBSET_HEADER_CONFIGURATION = 0x01,
  21. USB_WINUSB_SUBSET_HEADER_FUNCTION = 0x02,
  22. USB_WINUSB_FEATURE_COMPATBLE_ID = 0x03,
  23. USB_WINUSB_FEATURE_REG_PROPERTY = 0x04,
  24. USB_WINUSB_FEATURE_MIN_RESUME_TIME = 0x05,
  25. USB_WINUSB_FEATURE_MODEL_ID = 0x06,
  26. USB_WINUSB_FEATURE_CCGP_DEVICE = 0x07,
  27. USB_WINUSB_FEATURE_VENDOR_REVISION = 0x08,
  28. };
  29. enum // wPropertyDataType
  30. {
  31. USB_WINUSB_PROPERTY_DATA_TYPE_SZ = 1,
  32. USB_WINUSB_PROPERTY_DATA_TYPE_EXPAND_SZ = 2,
  33. USB_WINUSB_PROPERTY_DATA_TYPE_BINARY = 3,
  34. USB_WINUSB_PROPERTY_DATA_TYPE_DWORD_LITTLE_ENDIAN = 4,
  35. USB_WINUSB_PROPERTY_DATA_TYPE_DWORD_BIG_ENDIAN = 5,
  36. USB_WINUSB_PROPERTY_DATA_TYPE_LINK = 6,
  37. USB_WINUSB_PROPERTY_DATA_TYPE_MULTI_SZ = 7,
  38. };
  39. /*- Types BOS -------------------------------------------------------------------*/
  40. typedef struct USB_PACK {
  41. uint8_t bLength;
  42. uint8_t bDescriptorType;
  43. uint16_t wTotalLength;
  44. uint8_t bNumDeviceCaps;
  45. } usb_binary_object_store_descriptor_t;
  46. /*- Types WinUSB -------------------------------------------------------------------*/
  47. typedef struct USB_PACK {
  48. uint8_t bLength;
  49. uint8_t bDescriptorType;
  50. uint8_t bDevCapabilityType;
  51. uint8_t bReserved;
  52. uint8_t PlatformCapabilityUUID[16];
  53. uint32_t dwWindowsVersion;
  54. uint16_t wMSOSDescriptorSetTotalLength;
  55. uint8_t bMS_VendorCode;
  56. uint8_t bAltEnumCode;
  57. } usb_winusb_capability_descriptor_t;
  58. typedef struct USB_PACK {
  59. uint16_t wLength;
  60. uint16_t wDescriptorType;
  61. uint32_t dwWindowsVersion;
  62. uint16_t wDescriptorSetTotalLength;
  63. } usb_winusb_set_header_descriptor_t;
  64. typedef struct USB_PACK {
  65. uint16_t wLength;
  66. uint16_t wDescriptorType;
  67. uint8_t bConfigurationValue;
  68. uint8_t bReserved;
  69. uint16_t wTotalLength;
  70. } usb_winusb_subset_header_configuration_t;
  71. typedef struct USB_PACK {
  72. uint16_t wLength;
  73. uint16_t wDescriptorType;
  74. uint8_t bFirstInterface;
  75. uint8_t bReserved;
  76. uint16_t wSubsetLength;
  77. } usb_winusb_subset_header_function_t;
  78. typedef struct USB_PACK {
  79. uint16_t wLength;
  80. uint16_t wDescriptorType;
  81. uint8_t CompatibleID[8];
  82. uint8_t SubCompatibleID[8];
  83. } usb_winusb_feature_compatble_id_t;
  84. typedef struct USB_PACK {
  85. uint16_t wLength;
  86. uint16_t wDescriptorType;
  87. uint16_t wPropertyDataType;
  88. //uint16_t wPropertyNameLength;
  89. //uint8_t PropertyName[...];
  90. //uint16_t wPropertyDataLength
  91. //uint8_t PropertyData[...];
  92. } usb_winusb_feature_reg_property_t;
  93. typedef struct USB_PACK {
  94. uint16_t wLength;
  95. uint16_t wDescriptorType;
  96. uint16_t wPropertyDataType;
  97. uint16_t wPropertyNameLength;
  98. uint8_t PropertyName[42];
  99. uint16_t wPropertyDataLength;
  100. uint8_t PropertyData[80];
  101. } usb_winusb_feature_reg_property_guids_t;
  102. typedef struct USB_PACK {
  103. uint16_t wLength;
  104. uint16_t wDescriptorType;
  105. uint8_t bResumeRecoveryTime;
  106. uint8_t bResumeSignalingTime;
  107. } usb_winusb_feature_min_resume_time_t;
  108. typedef struct USB_PACK {
  109. uint16_t wLength;
  110. uint16_t wDescriptorType;
  111. uint8_t ModelID[16];
  112. } usb_winusb_feature_model_id_t;
  113. typedef struct USB_PACK {
  114. uint16_t wLength;
  115. uint16_t wDescriptorType;
  116. } usb_winusb_feature_ccgp_device_t;
  117. typedef struct USB_PACK {
  118. uint16_t wLength;
  119. uint16_t wDescriptorType;
  120. uint16_t VendorRevision;
  121. } usb_winusb_feature_vendor_revision_t;