1
0

usb_msos10.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. /* This file is the part of the Lightweight USB device Stack for STM32 microcontrollers
  2. *
  3. * Copyright ©2016 Dmitry Filimonchuk <dmitrystu[at]gmail[dot]com>
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS,
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License.
  14. */
  15. #ifndef _USB_MSOS10_H_
  16. #define _USB_MSOS10_H_
  17. #ifdef __cplusplus
  18. extern "C" {
  19. #endif
  20. #define USB_MS_INDEX 0xEE // MS OS string descriptor index
  21. #define USB_MS_GET_DESCRIPTOR 0x69
  22. /// @brief MS OS String descriptor
  23. struct usb_msos_descriptor {
  24. uint8_t bLength; //< Size of the descriptor in bytes
  25. uint8_t bDescriptorType; //< USB_DTYPE_STRING
  26. uint16_t qwSignature[7]; //< Signature field 'MSFT100'
  27. uint8_t bMS_VendorCode; //< Vendor Code
  28. uint8_t bPad; //< Pad field (0x00)
  29. } __attribute__((packed));
  30. #define USB_MS_MSFT100 {0x004D, 0x0053, 0x0046, 0x0054, 0x0031, 0x0030, 0x0030}
  31. struct usb_ms_extcompatid_header {
  32. uint32_t dwLength; //< The length of the entire descriptor,
  33. // including the header section. Windows
  34. // uses this value to retrieve the complete
  35. // descriptor.
  36. uint16_t bcdVersion;
  37. uint16_t wIndex; //< An index that identifies the particular
  38. // OS feature descriptor
  39. uint8_t bCount; //< Number of the Extended compat functions
  40. uint8_t baReserved[7]; //< Reserved. Must be 0
  41. } __attribute__((packed));
  42. #define USB_MS_GENRE_ID 0x01 //< Genre ID descriptor
  43. #define USB_MS_EXTCOMAPT_ID 0x04 //< Extended compat ID descriptor
  44. #define USB_MS_EXTPROPERTY_ID 0x05 //< Extended property ID descriptor
  45. struct usb_ms_extcompatid_function {
  46. uint8_t bFirstInterfaceNum;
  47. uint8_t bReserved; //< Reserved. Set this value to 0x01.
  48. uint8_t baCompatibleID[8];
  49. uint8_t baSubCompatibleID[8];
  50. uint8_t baReserved[6]; //< Reserved. Fill this value with NULLs.
  51. } __attribute__((packed));
  52. #define USB_MS_COMPID_NONE {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
  53. #define USB_MS_COMPID_RNDIS {0x52, 0x4E, 0x44, 0x49, 0x53, 0x00, 0x00, 0x00}
  54. #define USB_MS_COMPID_PTP {0x50, 0x54, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00}
  55. #define USB_MS_COMPID_MTP {0x4D, 0x54, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00}
  56. #define USB_MS_COMPID_XUSB20 {0x58, 0x55, 0x53, 0x42, 0x32, 0x30, 0x00, 0x00}
  57. #define USB_MS_COMPID_BLUETOOTH {0x42, 0x4C, 0x55, 0x54, 0x55, 0x54, 0x48, 0x00}
  58. #define USB_MS_COMPID_WINUSB {'W', 'I', 'N', 'U', 'S', 'B', 0x00, 0x00}
  59. #define USB_MS_COMPID_LIBUSB0 {'L', 'I', 'B', 'U', 'S', 'B', '0', 0x00}
  60. #define USB_MS_COMPID_LIBUSBK {'L', 'I', 'B', 'U', 'S', 'B', 'K', 0x00}
  61. #define USB_MS_SUBCOMPID_BT11 {0x31, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
  62. #define USB_MS_SUBCOMPID_BT12 {0x31, 0x32, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
  63. #define USB_MS_SUBCOMPID_BTEDR {0x45, 0x44, 0x52, 0x00, 0x00, 0x00, 0x00, 0x00}
  64. #define USB_MS_PTYPE_RESERVED 0x00 //<
  65. #define USB_MS_PTYPE_REGSZ 0x01 //< NULL-terminated Unicode String (REG_SZ)
  66. #define USB_MS_PTYPE_REGEXSZ 0x02 //< NULL-terminated Unicode String that
  67. // includes environment variables (REG_EXPAND_SZ)
  68. #define USB_MS_PTYPE_REGBINARY 0x03 //< Free-form binary (REG_BINARY)
  69. #define USB_MS_PTYPE_REGDWLE 0x04 //< A little-endian 32-bit integer (REG_DWORD_LITTLE_ENDIAN)
  70. #define USB_MS_PTYPE_REGDWBE 0x05 //< A big-endian 32-bit integer (REG_DWORD_BIG_ENDIAN)
  71. #define USB_MS_PTYPE_REGLINK 0x06 //< A NULL-terminated Unicode string that contains a symbolic link (REG_LINK)
  72. #define USB_MS_PTYPE_REGMULTISZ 0x07 //< Multiple NULL-terminated Unicode strings (REG_MULTI_SZ)
  73. #define USB_MS_PNAME_IFACEGUID u"DeviceInterfaceGUID"
  74. struct usb_ms_extproperty_header {
  75. uint32_t dwLength;
  76. uint16_t bcdVersion;
  77. uint16_t wIndex;
  78. uint16_t wCount;
  79. } __attribute__((packed));
  80. struct usb_ms_extproperty_name {
  81. uint32_t dwSize;
  82. uint32_t dwDataType;
  83. uint16_t wNameLength;
  84. uint16_t wName[];
  85. } __attribute__((packed));
  86. struct usb_ms_extproperty_data {
  87. uint32_t dwDataLength;
  88. uint8_t baData[];
  89. } __attribute__((packed));
  90. #define construct_ms_propu_desc(id, name, prop) \
  91. struct {\
  92. uint32_t dwSize;\
  93. uint32_t dwDataType;\
  94. uint16_t wNameLength;\
  95. uint16_t wName[sizeof(name)/2];\
  96. uint32_t dwDataLength;\
  97. uint16_t baData[sizeof(prop)/2];\
  98. } __attribute__((packed)) id
  99. #define construct_ms_propb_desc(id, name, prop) \
  100. struct {\
  101. uint32_t dwSize;\
  102. uint32_t dwDataType;\
  103. uint16_t wNameLength;\
  104. uint16_t wName[sizeof(name)/2];\
  105. uint32_t dwDataLength;\
  106. uint8_t baData[sizeof(prop)];\
  107. } __attribute__((packed)) id
  108. #define construct_ms_propi_desc(id, name, prop) \
  109. struct {\
  110. uint32_t dwSize;\
  111. uint32_t dwDataType;\
  112. uint16_t wNameLength;\
  113. uint16_t wName[sizeof(name)];\
  114. uint32_t dwDataLength;\
  115. uint32_t baData;\
  116. } __attribute__((packed)) id
  117. #ifdef __cplusplus
  118. }
  119. #endif
  120. #endif /* _USB_MSOS10_H_ */