usb_winusb.h 3.9 KB

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