My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

sbc_protocol.h 5.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173
  1. /**
  2. * \file
  3. *
  4. * \brief SCSI Block Commands
  5. *
  6. * This file contains definitions of some of the commands found in the
  7. * SCSI SBC-2 standard.
  8. *
  9. * Note that the SBC specification depends on several commands defined
  10. * by the SCSI Primary Commands (SPC) standard. Each version of the SBC
  11. * standard is meant to be used in conjunction with a specific version
  12. * of the SPC standard, as follows:
  13. * - SBC depends on SPC
  14. * - SBC-2 depends on SPC-3
  15. * - SBC-3 depends on SPC-4
  16. *
  17. * Copyright (c) 2014-2015 Atmel Corporation. All rights reserved.
  18. *
  19. * \asf_license_start
  20. *
  21. * \page License
  22. *
  23. * Redistribution and use in source and binary forms, with or without
  24. * modification, are permitted provided that the following conditions are met:
  25. *
  26. * 1. Redistributions of source code must retain the above copyright notice,
  27. * this list of conditions and the following disclaimer.
  28. *
  29. * 2. Redistributions in binary form must reproduce the above copyright notice,
  30. * this list of conditions and the following disclaimer in the documentation
  31. * and/or other materials provided with the distribution.
  32. *
  33. * 3. The name of Atmel may not be used to endorse or promote products derived
  34. * from this software without specific prior written permission.
  35. *
  36. * 4. This software may only be redistributed and used in connection with an
  37. * Atmel microcontroller product.
  38. *
  39. * THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR IMPLIED
  40. * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  41. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
  42. * EXPRESSLY AND SPECIFICALLY DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR
  43. * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  44. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  45. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  46. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
  47. * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
  48. * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  49. * POSSIBILITY OF SUCH DAMAGE.
  50. *
  51. * \asf_license_stop
  52. *
  53. */
  54. /*
  55. * Support and FAQ: visit <a href="https://www.atmel.com/design-support/">Atmel Support</a>
  56. */
  57. #ifndef _SBC_PROTOCOL_H_
  58. #define _SBC_PROTOCOL_H_
  59. /**
  60. * \ingroup usb_msc_protocol
  61. * \defgroup usb_sbc_protocol SCSI Block Commands protocol definitions
  62. *
  63. * @{
  64. */
  65. //! \name SCSI commands defined by SBC-2
  66. //@{
  67. #define SBC_FORMAT_UNIT 0x04
  68. #define SBC_READ6 0x08
  69. #define SBC_WRITE6 0x0A
  70. #define SBC_START_STOP_UNIT 0x1B
  71. #define SBC_READ_CAPACITY10 0x25
  72. #define SBC_READ10 0x28
  73. #define SBC_WRITE10 0x2A
  74. #define SBC_VERIFY10 0x2F
  75. //@}
  76. //! \name SBC-2 Mode page definitions
  77. //@{
  78. enum scsi_sbc_mode {
  79. SCSI_MS_MODE_RW_ERR_RECOV = 0x01, //!< Read-Write Error Recovery mode page
  80. SCSI_MS_MODE_FORMAT_DEVICE = 0x03, //!< Format Device mode page
  81. SCSI_MS_MODE_FLEXIBLE_DISK = 0x05, //!< Flexible Disk mode page
  82. SCSI_MS_MODE_CACHING = 0x08, //!< Caching mode page
  83. };
  84. //! \name SBC-2 Device-Specific Parameter
  85. //@{
  86. #define SCSI_MS_SBC_WP 0x80 //!< Write Protected
  87. #define SCSI_MS_SBC_DPOFUA 0x10 //!< DPO and FUA supported
  88. //@}
  89. /**
  90. * \brief SBC-2 Short LBA mode parameter block descriptor
  91. */
  92. struct sbc_slba_block_desc {
  93. be32_t nr_blocks; //!< Number of Blocks
  94. be32_t block_len; //!< Block Length
  95. #define SBC_SLBA_BLOCK_LEN_MASK 0x00FFFFFFU //!< Mask reserved bits
  96. };
  97. /**
  98. * \brief SBC-2 Caching mode page
  99. */
  100. struct sbc_caching_mode_page {
  101. uint8_t page_code;
  102. uint8_t page_length;
  103. uint8_t flags2;
  104. #define SBC_MP_CACHE_IC (1 << 7) //!< Initiator Control
  105. #define SBC_MP_CACHE_ABPF (1 << 6) //!< Abort Pre-Fetch
  106. #define SBC_MP_CACHE_CAP (1 << 5) //!< Catching Analysis Permitted
  107. #define SBC_MP_CACHE_DISC (1 << 4) //!< Discontinuity
  108. #define SBC_MP_CACHE_SIZE (1 << 3) //!< Size enable
  109. #define SBC_MP_CACHE_WCE (1 << 2) //!< Write back Cache Enable
  110. #define SBC_MP_CACHE_MF (1 << 1) //!< Multiplication Factor
  111. #define SBC_MP_CACHE_RCD (1 << 0) //!< Read Cache Disable
  112. uint8_t retention;
  113. be16_t dis_pf_transfer_len;
  114. be16_t min_prefetch;
  115. be16_t max_prefetch;
  116. be16_t max_prefetch_ceil;
  117. uint8_t flags12;
  118. #define SBC_MP_CACHE_FSW (1 << 7) //!< Force Sequential Write
  119. #define SBC_MP_CACHE_LBCSS (1 << 6) //!< Logical Blk Cache Seg Sz
  120. #define SBC_MP_CACHE_DRA (1 << 5) //!< Disable Read-Ahead
  121. #define SBC_MP_CACHE_NV_DIS (1 << 0) //!< Non-Volatile Cache Disable
  122. uint8_t nr_cache_segments;
  123. be16_t cache_segment_size;
  124. uint8_t reserved[4];
  125. };
  126. /**
  127. * \brief SBC-2 Read-Write Error Recovery mode page
  128. */
  129. struct sbc_rdwr_error_recovery_mode_page {
  130. uint8_t page_code;
  131. uint8_t page_length;
  132. #define SPC_MP_RW_ERR_RECOV_PAGE_LENGTH 0x0A
  133. uint8_t flags1;
  134. #define SBC_MP_RW_ERR_RECOV_AWRE (1 << 7)
  135. #define SBC_MP_RW_ERR_RECOV_ARRE (1 << 6)
  136. #define SBC_MP_RW_ERR_RECOV_TB (1 << 5)
  137. #define SBC_MP_RW_ERR_RECOV_RC (1 << 4)
  138. #define SBC_MP_RW_ERR_RECOV_ERR (1 << 3)
  139. #define SBC_MP_RW_ERR_RECOV_PER (1 << 2)
  140. #define SBC_MP_RW_ERR_RECOV_DTE (1 << 1)
  141. #define SBC_MP_RW_ERR_RECOV_DCR (1 << 0)
  142. uint8_t read_retry_count;
  143. uint8_t correction_span;
  144. uint8_t head_offset_count;
  145. uint8_t data_strobe_offset_count;
  146. uint8_t flags2;
  147. uint8_t write_retry_count;
  148. uint8_t flags3;
  149. be16_t recovery_time_limit;
  150. };
  151. //@}
  152. /**
  153. * \brief SBC-2 READ CAPACITY (10) parameter data
  154. */
  155. struct sbc_read_capacity10_data {
  156. be32_t max_lba; //!< LBA of last logical block
  157. be32_t block_len; //!< Number of bytes in the last logical block
  158. };
  159. //@}
  160. #endif // _SBC_PROTOCOL_H_