usb_scsi.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190
  1. /*
  2. * Copyright (c) 2022 OpenLuat & AirM2M
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a copy of
  5. * this software and associated documentation files (the "Software"), to deal in
  6. * the Software without restriction, including without limitation the rights to
  7. * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
  8. * the Software, and to permit persons to whom the Software is furnished to do so,
  9. * subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included in all
  12. * copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  15. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
  16. * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
  17. * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
  18. * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  19. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  20. */
  21. #ifndef __USB_MSC_SCSI_H__
  22. #define __USB_MSC_SCSI_H__
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26. /* Includes ------------------------------------------------------------------*/
  27. #include "bsp_common.h"
  28. #define MODE_SENSE6_LEN 0x17U
  29. #define MODE_SENSE10_LEN 0x1BU
  30. #define LENGTH_INQUIRY_PAGE00 0x06U
  31. #define LENGTH_INQUIRY_PAGE80 0x08U
  32. #define LENGTH_FORMAT_CAPACITIES 0x14U
  33. #define SENSE_LIST_DEEPTH 8U
  34. /* SCSI Commands */
  35. #define SCSI_FORMAT_UNIT 0x04U
  36. #define SCSI_INQUIRY 0x12U
  37. #define SCSI_MODE_SELECT6 0x15U
  38. #define SCSI_MODE_SELECT10 0x55U
  39. #define SCSI_MODE_SENSE6 0x1AU
  40. #define SCSI_MODE_SENSE10 0x5AU
  41. #define SCSI_ALLOW_MEDIUM_REMOVAL 0x1EU
  42. #define SCSI_READ6 0x08U
  43. #define SCSI_READ10 0x28U
  44. #define SCSI_READ12 0xA8U
  45. #define SCSI_READ16 0x88U
  46. #define SCSI_READ_CAPACITY10 0x25U
  47. #define SCSI_READ_CAPACITY16 0x9EU
  48. #define SCSI_REQUEST_SENSE 0x03U
  49. #define SCSI_START_STOP_UNIT 0x1BU
  50. #define SCSI_TEST_UNIT_READY 0x00U
  51. #define SCSI_WRITE6 0x0AU
  52. #define SCSI_WRITE10 0x2AU
  53. #define SCSI_WRITE12 0xAAU
  54. #define SCSI_WRITE16 0x8AU
  55. #define SCSI_VERIFY10 0x2FU
  56. #define SCSI_VERIFY12 0xAFU
  57. #define SCSI_VERIFY16 0x8FU
  58. #define SCSI_SEND_DIAGNOSTIC 0x1DU
  59. #define SCSI_READ_FORMAT_CAPACITIES 0x23U
  60. #define SCSI_SEEK10 0x2BU
  61. #define SCSI_WRITE_VERIFY 0x2EU
  62. #define SENSE_KEY_NO_SENSE 0U
  63. #define SENSE_KEY_RECOVERED_ERROR 1U
  64. #define SENSE_KEY_NOT_READY 2U
  65. #define SENSE_KEY_MEDIUM_ERROR 3U
  66. #define SENSE_KEY_HARDWARE_ERROR 4U
  67. #define SENSE_KEY_ILLEGAL_REQUEST 5U
  68. #define SENSE_KEY_UNIT_ATTENTION 6U
  69. #define SENSE_KEY_DATA_PROTECT 7U
  70. #define SENSE_KEY_BLANK_CHECK 8U
  71. #define SENSE_KEY_VENDOR_SPECIFIC 9U
  72. #define SENSE_KEY_COPY_ABORTED 10U
  73. #define SENSE_KEY_ABORTED_COMMAND 11U
  74. #define SENSE_KEY_VOLUME_OVERFLOW 13U
  75. #define SENSE_KEY_MISCOMPARE 14U
  76. #define INVALID_COMMAND_OPERATION_CODE 0x20U
  77. #define INVALID_FIELED_IN_COMMAND 0x24U
  78. #define PARAMETER_LIST_LENGTH_ERROR 0x1AU
  79. #define INVALID_FIELD_IN_PARAMETER_LIST 0x26U
  80. #define ADDRESS_OUT_OF_RANGE 0x21U
  81. #define MEDIUM_NOT_PRESENT 0x3AU
  82. #define MEDIUM_HAVE_CHANGED 0x28U
  83. #define WRITE_PROTECTED 0x27U
  84. #define UNRECOVERED_READ_ERROR 0x11U
  85. #define WRITE_FAULT 0x03U
  86. #define READ_FORMAT_CAPACITY_DATA_LEN 0x0CU
  87. #define READ_CAPACITY10_DATA_LEN 0x08U
  88. #define REQUEST_SENSE_DATA_LEN 0x12U
  89. #define STANDARD_INQUIRY_DATA_LEN 0x24U
  90. #define BLKVFY 0x04U
  91. #define SCSI_MEDIUM_UNLOCKED 0x00U
  92. #define SCSI_MEDIUM_LOCKED 0x01U
  93. #define SCSI_MEDIUM_EJECTED 0x02U
  94. typedef struct
  95. {
  96. uint8_t Skey;
  97. uint8_t ASC;
  98. uint8_t ASCQ;
  99. PV_Union uData;
  100. } SCSI_SenseTypeDef;
  101. typedef struct
  102. {
  103. union
  104. {
  105. uint8_t Byte0;
  106. struct
  107. {
  108. uint8_t Type:5;
  109. uint8_t Zero:3;
  110. }Byte0_b;
  111. };
  112. union
  113. {
  114. uint8_t Byte1;
  115. struct
  116. {
  117. uint8_t Zero:7;
  118. uint8_t RMB:1;
  119. }Byte1_b;
  120. };
  121. union
  122. {
  123. uint8_t Byte2;
  124. struct
  125. {
  126. uint8_t ANSI:3;
  127. uint8_t ECMA:3;
  128. uint8_t ISO:2;
  129. }Byte2_b;
  130. };
  131. union
  132. {
  133. uint8_t Byte3;
  134. struct
  135. {
  136. uint8_t ResponseDataFormat:4;
  137. uint8_t Zero:4;
  138. }Byte3_b;
  139. };
  140. uint8_t RestLen;
  141. uint8_t Zero[3];
  142. uint8_t VendorInfo[8];
  143. uint8_t ProductInfo[16];
  144. uint8_t ProductVersion[4];
  145. } SCSI_InquiryDataTypeDef;
  146. /**
  147. * @}
  148. */
  149. #ifdef __cplusplus
  150. }
  151. #endif
  152. #endif /* __USBD_MSC_SCSI_H */
  153. /**
  154. * @}
  155. */
  156. /**
  157. * @}
  158. */
  159. /**
  160. * @}
  161. */
  162. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/