Source code of Windows XP (NT5)
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.

230 lines
7.6 KiB

  1. /******************************************************************************
  2. **
  3. ** Module Name: ScsiThings.h
  4. **
  5. ** Notes: This file created using 4 spaces per tab.
  6. **
  7. ******************************************************************************/
  8. #ifndef __SCSITHINGS_H__
  9. #define __SCSITHINGS_H__
  10. /*
  11. ** Make sure structures are packed and undecorated.
  12. */
  13. #ifdef _MSC_VER
  14. #pragma pack(push,1)
  15. #endif //__MSC_VER
  16. #ifdef __cplusplus
  17. extern "C" {
  18. #endif //__cplusplus
  19. // SCSI CDB Opcodes.
  20. #define SCSI_CMD_INQUIRY 0x12
  21. #define SCSI_CMD_INQUIRY_LENGTH 6
  22. #define SCSI_CMD_MODE_SELECT10 0x55
  23. #define SCSI_CMD_MODE_SELECT10_LENGTH 10
  24. #define SCSI_CMD_MODE_SENSE10 0x5a
  25. #define SCSI_CMD_MODE_SENSE10_LENGTH 10
  26. #define SCSI_CMD_PREVENT_ALLOW_MEDIUM_REM 0x1e
  27. #define SCSI_CMD_PREVENT_ALLOW_MEDIUM_REM_LENGTH 6
  28. #define SCSI_CMD_TUR 0x00
  29. #define SCSI_CMD_LENGTH_TUR 6
  30. // Ricoh CDB Opcodes.
  31. #define SCSI_RICOH_CDBOPCODE_FLUSH_CACHE 0x35
  32. #define SCSI_RICOH_CDBLENGTH_FLUSH_CACHE 10
  33. #define SCSI_RICOH_CDBOPCODE_GETNEXTADDRESS 0xe2
  34. #define SCSI_RICOH_CDBLENGTH_GETNEXTADDRESS 10
  35. #define SCSI_RICOH_CDBOPCODE_READ_TRACK_INFO 0xe5
  36. #define SCSI_RICOH_CDBLENGTH_READ_TRACK_INFO 10
  37. #define SCSI_RICOH_CDBOPCODE_WRITE_TRACK 0xe6
  38. #define SCSI_RICOH_CDBLENGTH_WRITE_TRACK 10
  39. #define SCSI_RICOH_CDBOPCODE_FIXATION 0xe9
  40. #define SCSI_RICOH_CDBLENGTH_FIXATION 10
  41. // End Ricoh
  42. // SCSI Sense Keys
  43. #define SCSI_SENSEKEY_NOTREADY 0x02
  44. #define SCSI_SENSEKEY_MEDIUM_ERROR 0x03
  45. #define SCSI_SENSEKEY_HARDWARE_ERROR 0x04
  46. #define SCSI_SENSEKEY_ILLEGALREQUEST 0x05
  47. #define SCSI_SENSEKEY_UNITATTENTION 0x06
  48. // SCSI Additional Sense Codes
  49. #define SCSI_ASC_COMMUNICATIONFAILURE 0x08
  50. #define SCSI_ASC_WRITEERROR 0x0c
  51. #define SCSI_ASC_PARAMETERLISTLENGTH 0x1a
  52. #define SCSI_ASC_INVALIDOPCODE 0x20
  53. #define SCSI_ASC_LBAOUTOFRANGE 0x21
  54. #define SCSI_ASC_INVALIDFIELDCDB 0x24
  55. #define SCSI_ASC_INVALIDFIELDPARAMLIST 0x26
  56. #define SCSI_ASC_PARAMETERSCHANGED 0x2a
  57. #define SCSI_ASC_MEDIUMNOTPRESENT 0x3a
  58. #define SCSI_ASC_DUMMYBLOCKSADDED 0xb5
  59. #define SCSI_ASC_ILLEGALMODEFORTRACK 0x64
  60. // SCSI Data structs.
  61. #define SCSI_INQUIRY_RMB 0x80
  62. #define SCSI_DEVICE_TYPE_WORM 0x04
  63. #define SCSI_DEVICE_TYPE_CDROM 0x05
  64. // Other things
  65. #define SCSI_MODE_SENSE_PAGE_CODE_MASK 0x3f
  66. // Ricoh things.
  67. #define SCSI_RICOH_TRACK_INFO_TRACK_STATUS_MASK 0xf0
  68. #define SCSI_RICOH_TRACK_INFO_TRACK_STATUS_UNKNOWN 0x40
  69. #define SCSI_RICOH_TRACK_INFO_TRACK_MODE_MASK 0x0f
  70. #define SCSI_RICOH_TRACK_INFO_TRACK_MODE_AUDIO_WITHOUT 0x00
  71. #define SCSI_RICOH_TRACK_INFO_TRACK_MODE_AUDIO_WITH 0x01
  72. #define SCSI_RICOH_TRACK_INFO_TRACK_MODE_DATA_UNINT 0x04
  73. #define SCSI_RICOH_TRACK_INFO_TRACK_MODE_DATA_INT 0x05
  74. #define SCSI_RICOH_TRACK_INFO_INCREMENTAL_MASK 0xf0
  75. #define SCSI_RICOH_TRACK_INFO_INCREMENTAL_NOTNOTNONOT 0x00
  76. #define SCSI_RICOH_TRACK_INFO_DATA_MODE_MASK 0x0f
  77. #define SCSI_RICOH_TRACK_INFO_DATA_MODE_UNKNOWN 0x0f
  78. #define SCSI_RICOH_TRACK_INFO_DATA_MODE_YELLOWBOOK 0x01
  79. #define SCSI_RICOH_TRACK_INFO_DATA_MODE_YELLOWBOOK_F1F2 0x02
  80. #define SCSI_RICOH_MODE_PAGE_CODE_WRITE 0x21
  81. #define SCSI_RICOH_MEDIUM_TYPE_PRESENT 0x80
  82. #define SCSI_RICOH_MEDIUM_TYPE_SIZE_120MM 0x20
  83. #define SCSI_RICOH_MEDIUM_TYPE_WRITE_ENABLE 0x08
  84. #define SCSI_RICOH_MEDIUM_TYPE_AUDIO_EXIST 0x04
  85. #define SCSI_RICOH_MODE_PAGE_WRITE_COPY 0x20
  86. #define SCSI_RICOH_MODE_PAGE_WRITE_AUDIO 0x04
  87. #define SCSI_RICOH_MODE_PAGE_WRITE_MODE_MODE1 0x01
  88. #define SCSI_RICOH_MODE_PAGE_CODE_SPEED 0x31
  89. #define SCSI_RICOH_MODE_PAGE_SPEED_SPEEDMASK 0xf0
  90. #define SCSI_RICOH_MODE_PAGE_SPEED_TEST_WRITING_FLAG 0x01
  91. #define SCSI_RICOH_FIXATION_FLAG_IMMED 0x01
  92. #define SCSI_RICOH_FIXATION_TOCTYPE_CDROM 0x01
  93. #define SCSI_RICOH_FIXATION_TOCTYPE_CDDA 0x00
  94. // End Ricoh
  95. typedef struct {
  96. BYTE byPeripheralDeviceType;
  97. BYTE byDeviceTypeModifier; // 01
  98. BYTE byVersionISOECMAANSI; // 02
  99. BYTE byResponseDataFormat; // 03
  100. BYTE byAdditionalLength; // 04
  101. BYTE byaReserved0[ 3 ]; // 05
  102. BYTE byaVendorID[ 8 ]; // 08
  103. BYTE byaProductID[ 16 ]; // 10
  104. BYTE byaProductRevision[ 4 ]; // 20
  105. //BYTE byaReserved1[ 210 ]; // 24
  106. } SCSI_INQUIRY, *PSCSI_INQUIRY;
  107. typedef struct {
  108. BYTE byError;
  109. BYTE bySegment; // 01
  110. BYTE bySenseKey; // 02
  111. BYTE byaInfo[ 4 ]; // 03
  112. BYTE byAdditionalSenseLength; // 07
  113. BYTE byaCommandSpecific[ 4 ]; // 08
  114. BYTE byASC; // 0c
  115. BYTE byASCQ; // 0d
  116. //BYTE byFieldReplacable; // 0e
  117. //BYTE byaSenseKeySpecific[ 3 ];
  118. //BYTE byaAdditionalBytes[ 220 ];
  119. } SCSI_SENSE_DATA, *PSCSI_SENSE_DATA;
  120. // Begin Ricoh drive specific things.
  121. typedef struct {
  122. BYTE byBufferLength;
  123. BYTE byNumberOfTracks;
  124. BYTE byaStartAddress[ 4 ];
  125. BYTE byaTrackLength[ 4 ];
  126. BYTE byTrackStatusMode;
  127. BYTE byIncrementalDataMode;
  128. BYTE byaFreeBlocks[ 4 ];
  129. BYTE byaFixedPacketSize[ 4 ];
  130. } SCSI_RICOH_TRACK_INFO_BLOCK, *PSCSI_RICOH_TRACK_INFO_BLOCK;
  131. typedef struct {
  132. // Header
  133. BYTE byaModeDataLength[ 2 ];
  134. BYTE byMediumType;
  135. BYTE byaReserved[ 3 ];
  136. BYTE byaBlockDescLen[ 2 ];
  137. // Block Descriptor
  138. BYTE byDensityCode;
  139. BYTE byaNumberOfBlocks[ 3 ];
  140. BYTE byReserved2;
  141. BYTE byaBlockSize[ 3 ];
  142. // Write Page
  143. BYTE byPageCode; // x21
  144. BYTE byParameterLength; // x0e
  145. BYTE byReserved3;
  146. BYTE byCopyAudioMode;
  147. BYTE byTrackNumber;
  148. BYTE byaISRC[ 9 ];
  149. BYTE byaReserved4[ 2 ];
  150. } SCSI_RICOH_MODE_PAGE_WRITE, *PSCSI_RICOH_MODE_PAGE_WRITE;
  151. typedef struct {
  152. // Header
  153. BYTE byaModeDataLength[ 2 ];
  154. BYTE byMediumType;
  155. BYTE byaReserved[ 3 ];
  156. BYTE byaBlockDescLen[ 2 ];
  157. // Block Descriptor
  158. BYTE byDensityCode;
  159. BYTE byaNumberOfBlocks[ 3 ];
  160. BYTE byReserved2;
  161. BYTE byaBlockSize[ 3 ];
  162. // Speed page
  163. BYTE byPageCode; // x31
  164. BYTE byParameterLength; // x02
  165. BYTE byReserved5;
  166. BYTE bySpeedSelectEmulation;
  167. } SCSI_RICOH_MODE_PAGE_SPEED, *PSCSI_RICOH_MODE_PAGE_SPEED;
  168. typedef struct {
  169. BYTE byDataBlockLength;
  170. BYTE byaLogicalBlockAddress[ 4 ];
  171. BYTE byReserved;
  172. } SCSI_RICOH_NEXT_WRITABLE_ADDRESS, *PSCSI_RICOH_NEXT_WRITABLE_ADDRESS;
  173. // End Ricoh
  174. // Macros
  175. #define SCSI_TRIPLE( HA, ID, LUN ) (DWORD)( (( (DWORD)HA << 24 ) & 0xff000000 ) + \
  176. (( (DWORD)ID << 16 ) & 0x00ff0000 ) + \
  177. (( (DWORD)LUN << 8 ) & 0x0000ff00 ))
  178. #define SCSI_TRIPLE_TO_HA( Triple ) (BYTE)(( (DWORD)Triple >> 24 ) & 0x000000ff )
  179. #define SCSI_TRIPLE_TO_ID( Triple ) (BYTE)(( (DWORD)Triple >> 16 ) & 0x000000ff )
  180. #define SCSI_TRIPLE_TO_LUN( Triple ) (BYTE)(( (DWORD)Triple >> 8 ) & 0x000000ff )
  181. /*
  182. ** Restore compiler default packing and close off the C declarations.
  183. */
  184. #ifdef __cplusplus
  185. }
  186. #endif //__cplusplus
  187. #ifdef _MSC_VER
  188. #pragma pack(pop)
  189. #endif //_MSC_VER
  190. #endif //__SCSITHINGS_H__