msc_scsi.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /*!
  2. \file msc_scsi.h
  3. \brief definitions for the USB MSC SCSI commands
  4. \version 2023-06-30, V2.1.6, firmware for GD32F30x
  5. */
  6. /*
  7. Copyright (c) 2023, GigaDevice Semiconductor Inc.
  8. Redistribution and use in source and binary forms, with or without modification,
  9. are permitted provided that the following conditions are met:
  10. 1. Redistributions of source code must retain the above copyright notice, this
  11. list of conditions and the following disclaimer.
  12. 2. Redistributions in binary form must reproduce the above copyright notice,
  13. this list of conditions and the following disclaimer in the documentation
  14. and/or other materials provided with the distribution.
  15. 3. Neither the name of the copyright holder nor the names of its contributors
  16. may be used to endorse or promote products derived from this software without
  17. specific prior written permission.
  18. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  19. AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  20. WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  21. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
  22. INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
  23. NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  24. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  25. WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  26. ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
  27. OF SUCH DAMAGE.
  28. */
  29. #ifndef __MSC_SCSI_H
  30. #define __MSC_SCSI_H
  31. #include "usb_ch9_std.h"
  32. /* SCSI commands */
  33. #define SCSI_FORMAT_UNIT 0x04U
  34. #define SCSI_INQUIRY 0x12U
  35. #define SCSI_MODE_SELECT6 0x15U
  36. #define SCSI_MODE_SELECT10 0x55U
  37. #define SCSI_MODE_SENSE6 0x1AU
  38. #define SCSI_READ_TOC_DATA 0x43U
  39. #define SCSI_MODE_SENSE10 0x5AU
  40. #define SCSI_ALLOW_MEDIUM_REMOVAL 0x1EU
  41. #define SCSI_READ6 0x08U
  42. #define SCSI_READ10 0x28U
  43. #define SCSI_READ12 0xA8U
  44. #define SCSI_READ16 0x88U
  45. #define SCSI_READ_CAPACITY10 0x25U
  46. #define SCSI_READ_CAPACITY16 0x9EU
  47. #define SCSI_REQUEST_SENSE 0x03U
  48. #define SCSI_START_STOP_UNIT 0x1BU
  49. #define SCSI_TEST_UNIT_READY 0x00U
  50. #define SCSI_WRITE6 0x0AU
  51. #define SCSI_WRITE10 0x2AU
  52. #define SCSI_WRITE12 0xAAU
  53. #define SCSI_WRITE16 0x8AU
  54. #define SCSI_VERIFY10 0x2FU
  55. #define SCSI_VERIFY12 0xAFU
  56. #define SCSI_VERIFY16 0x8FU
  57. #define SCSI_SEND_DIAGNOSTIC 0x1DU
  58. #define SCSI_READ_FORMAT_CAPACITIES 0x23U
  59. #define INVALID_CDB 0x20U
  60. #define INVALID_FIELED_IN_COMMAND 0x24U
  61. #define PARAMETER_LIST_LENGTH_ERROR 0x1AU
  62. #define INVALID_FIELD_IN_PARAMETER_LIST 0x26U
  63. #define ADDRESS_OUT_OF_RANGE 0x21U
  64. #define MEDIUM_NOT_PRESENT 0x3AU
  65. #define MEDIUM_HAVE_CHANGED 0x28U
  66. #define WRITE_PROTECTED 0x27U
  67. #define UNRECOVERED_READ_ERROR 0x11U
  68. #define WRITE_FAULT 0x03U
  69. #define READ_FORMAT_CAPACITY_DATA_LEN 0x0CU
  70. #define READ_CAPACITY10_DATA_LEN 0x08U
  71. #define MODE_SENSE10_DATA_LEN 0x08U
  72. #define MODE_SENSE6_DATA_LEN 0x04U
  73. #define READ_TOC_CMD_LEN 0x14U
  74. #define REQUEST_SENSE_DATA_LEN 0x12U
  75. #define STANDARD_INQUIRY_DATA_LEN 0x24U
  76. #define BLKVFY 0x04U
  77. enum sense_state {
  78. NO_SENSE = 0U,
  79. RECOVERED_ERROR,
  80. NOT_READY,
  81. MEDIUM_ERROR,
  82. HARDWARE_ERROR,
  83. ILLEGAL_REQUEST,
  84. UNIT_ATTENTION,
  85. DATA_PROTECT,
  86. BLANK_CHECK,
  87. VENDOR_SPECIFIC,
  88. COPY_ABORTED,
  89. ABORTED_COMMAND,
  90. RESERVED,
  91. VOLUME_OVERFLOW,
  92. MISCOMPARE
  93. };
  94. typedef struct {
  95. uint8_t SenseKey;
  96. uint32_t Information;
  97. uint8_t ASC;
  98. uint8_t ASCQ;
  99. } msc_scsi_sense;
  100. #endif /* __MSC_SCSI_H */