Leaked source code of windows server 2003
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.

525 lines
19 KiB

  1. /*++
  2. Copyright (C) Microsoft Corporation, 1992 - 1999
  3. Module Name:
  4. classkd.c
  5. Abstract:
  6. Debugger Extension Api for interpretting scsiport structures
  7. Author:
  8. ervinp
  9. Environment:
  10. User Mode.
  11. Revision History:
  12. --*/
  13. #include "pch.h"
  14. #include "classpnp.h" // #defines ALLOCATE_SRB_FROM_POOL as needed
  15. #include "classp.h" // Classpnp's private definitions
  16. #include "cdrom.h"
  17. #include "classkd.h" // routines that are useful for all class drivers
  18. char *HexNumberStrings[] = {
  19. "00", "01", "02", "03", "04", "05", "06", "07",
  20. "08", "09", "0A", "0B", "0C", "0D", "0E", "0F",
  21. "10", "11", "12", "13", "14", "15", "16", "17",
  22. "18", "19", "1A", "1B", "1C", "1D", "1E", "1F",
  23. "20", "21", "22", "23", "24", "25", "26", "27",
  24. "28", "29", "2A", "2B", "2C", "2D", "2E", "2F",
  25. "30", "31", "32", "33", "34", "35", "36", "37",
  26. "38", "39", "3A", "3B", "3C", "3D", "3E", "3F",
  27. "40", "41", "42", "43", "44", "45", "46", "47",
  28. "48", "49", "4A", "4B", "4C", "4D", "4E", "4F",
  29. "50", "51", "52", "53", "54", "55", "56", "57",
  30. "58", "59", "5A", "5B", "5C", "5D", "5E", "5F",
  31. "60", "61", "62", "63", "64", "65", "66", "67",
  32. "68", "69", "6A", "6B", "6C", "6D", "6E", "6F",
  33. "70", "71", "72", "73", "74", "75", "76", "77",
  34. "78", "79", "7A", "7B", "7C", "7D", "7E", "7F",
  35. "80", "81", "82", "83", "84", "85", "86", "87",
  36. "88", "89", "8A", "8B", "8C", "8D", "8E", "8F",
  37. "90", "91", "92", "93", "94", "95", "96", "97",
  38. "98", "99", "9A", "9B", "9C", "9D", "9E", "9F",
  39. "A0", "A1", "A2", "A3", "A4", "A5", "A6", "A7",
  40. "A8", "A9", "AA", "AB", "AC", "AD", "AE", "AF",
  41. "B0", "B1", "B2", "B3", "B4", "B5", "B6", "B7",
  42. "B8", "B9", "BA", "BB", "BC", "BD", "BE", "BF",
  43. "C0", "C1", "C2", "C3", "C4", "C5", "C6", "C7",
  44. "C8", "C9", "CA", "CB", "CC", "CD", "CE", "CF",
  45. "D0", "D1", "D2", "D3", "D4", "D5", "D6", "D7",
  46. "D8", "D9", "DA", "DB", "DC", "DD", "DE", "DF",
  47. "E0", "E1", "E2", "E3", "E4", "E5", "E6", "E7",
  48. "E8", "E9", "EA", "EB", "EC", "ED", "EE", "EF",
  49. "F0", "F1", "F2", "F3", "F4", "F5", "F6", "F7",
  50. "F8", "F9", "FA", "FB", "FC", "FD", "FE", "FF"
  51. };
  52. char *DbgGetIoctlStr(ULONG ioctl)
  53. {
  54. char *ioctlStr = "?";
  55. switch (ioctl){
  56. #undef MAKE_CASE
  57. #define MAKE_CASE(ioctlCode) case ioctlCode: ioctlStr = #ioctlCode; break;
  58. MAKE_CASE(IOCTL_STORAGE_CHECK_VERIFY)
  59. MAKE_CASE(IOCTL_STORAGE_CHECK_VERIFY2)
  60. MAKE_CASE(IOCTL_STORAGE_MEDIA_REMOVAL)
  61. MAKE_CASE(IOCTL_STORAGE_EJECT_MEDIA)
  62. MAKE_CASE(IOCTL_STORAGE_LOAD_MEDIA)
  63. MAKE_CASE(IOCTL_STORAGE_LOAD_MEDIA2)
  64. MAKE_CASE(IOCTL_STORAGE_RESERVE)
  65. MAKE_CASE(IOCTL_STORAGE_RELEASE)
  66. MAKE_CASE(IOCTL_STORAGE_FIND_NEW_DEVICES)
  67. MAKE_CASE(IOCTL_STORAGE_EJECTION_CONTROL)
  68. MAKE_CASE(IOCTL_STORAGE_MCN_CONTROL)
  69. MAKE_CASE(IOCTL_STORAGE_GET_MEDIA_TYPES)
  70. MAKE_CASE(IOCTL_STORAGE_GET_MEDIA_TYPES_EX)
  71. MAKE_CASE(IOCTL_STORAGE_GET_MEDIA_SERIAL_NUMBER)
  72. MAKE_CASE(IOCTL_STORAGE_GET_HOTPLUG_INFO)
  73. MAKE_CASE(IOCTL_STORAGE_RESET_BUS)
  74. MAKE_CASE(IOCTL_STORAGE_RESET_DEVICE)
  75. MAKE_CASE(IOCTL_STORAGE_GET_DEVICE_NUMBER)
  76. MAKE_CASE(IOCTL_STORAGE_PREDICT_FAILURE)
  77. MAKE_CASE(IOCTL_STORAGE_QUERY_PROPERTY)
  78. MAKE_CASE(OBSOLETE_IOCTL_STORAGE_RESET_BUS)
  79. MAKE_CASE(OBSOLETE_IOCTL_STORAGE_RESET_DEVICE)
  80. }
  81. return ioctlStr;
  82. }
  83. char *DbgGetScsiOpStr(UCHAR ScsiOp)
  84. {
  85. char *scsiOpStr = HexNumberStrings[ScsiOp];
  86. switch (ScsiOp){
  87. #undef MAKE_CASE
  88. #define MAKE_CASE(scsiOpCode) case scsiOpCode: scsiOpStr = #scsiOpCode; break;
  89. MAKE_CASE(SCSIOP_TEST_UNIT_READY)
  90. MAKE_CASE(SCSIOP_REWIND) // aka SCSIOP_REZERO_UNIT
  91. MAKE_CASE(SCSIOP_REQUEST_BLOCK_ADDR)
  92. MAKE_CASE(SCSIOP_REQUEST_SENSE)
  93. MAKE_CASE(SCSIOP_FORMAT_UNIT)
  94. MAKE_CASE(SCSIOP_READ_BLOCK_LIMITS)
  95. MAKE_CASE(SCSIOP_INIT_ELEMENT_STATUS) // aka SCSIOP_REASSIGN_BLOCKS
  96. MAKE_CASE(SCSIOP_RECEIVE) // aka SCSIOP_READ6
  97. MAKE_CASE(SCSIOP_SEND) // aka SCSIOP_WRITE6, SCSIOP_PRINT
  98. MAKE_CASE(SCSIOP_SLEW_PRINT) // aka SCSIOP_SEEK6, SCSIOP_TRACK_SELECT
  99. MAKE_CASE(SCSIOP_SEEK_BLOCK)
  100. MAKE_CASE(SCSIOP_PARTITION)
  101. MAKE_CASE(SCSIOP_READ_REVERSE)
  102. MAKE_CASE(SCSIOP_FLUSH_BUFFER) // aka SCSIOP_WRITE_FILEMARKS
  103. MAKE_CASE(SCSIOP_SPACE)
  104. MAKE_CASE(SCSIOP_INQUIRY)
  105. MAKE_CASE(SCSIOP_VERIFY6)
  106. MAKE_CASE(SCSIOP_RECOVER_BUF_DATA)
  107. MAKE_CASE(SCSIOP_MODE_SELECT)
  108. MAKE_CASE(SCSIOP_RESERVE_UNIT)
  109. MAKE_CASE(SCSIOP_RELEASE_UNIT)
  110. MAKE_CASE(SCSIOP_COPY)
  111. MAKE_CASE(SCSIOP_ERASE)
  112. MAKE_CASE(SCSIOP_MODE_SENSE)
  113. MAKE_CASE(SCSIOP_START_STOP_UNIT) // aka SCSIOP_STOP_PRINT, SCSIOP_LOAD_UNLOAD
  114. MAKE_CASE(SCSIOP_RECEIVE_DIAGNOSTIC)
  115. MAKE_CASE(SCSIOP_SEND_DIAGNOSTIC)
  116. MAKE_CASE(SCSIOP_MEDIUM_REMOVAL)
  117. MAKE_CASE(SCSIOP_READ_FORMATTED_CAPACITY)
  118. MAKE_CASE(SCSIOP_READ_CAPACITY)
  119. MAKE_CASE(SCSIOP_READ)
  120. MAKE_CASE(SCSIOP_WRITE)
  121. MAKE_CASE(SCSIOP_SEEK) // aka SCSIOP_LOCATE, SCSIOP_POSITION_TO_ELEMENT
  122. MAKE_CASE(SCSIOP_WRITE_VERIFY)
  123. MAKE_CASE(SCSIOP_VERIFY)
  124. MAKE_CASE(SCSIOP_SEARCH_DATA_HIGH)
  125. MAKE_CASE(SCSIOP_SEARCH_DATA_EQUAL)
  126. MAKE_CASE(SCSIOP_SEARCH_DATA_LOW)
  127. MAKE_CASE(SCSIOP_SET_LIMITS)
  128. MAKE_CASE(SCSIOP_READ_POSITION)
  129. MAKE_CASE(SCSIOP_SYNCHRONIZE_CACHE)
  130. MAKE_CASE(SCSIOP_COMPARE)
  131. MAKE_CASE(SCSIOP_COPY_COMPARE)
  132. MAKE_CASE(SCSIOP_WRITE_DATA_BUFF)
  133. MAKE_CASE(SCSIOP_READ_DATA_BUFF)
  134. MAKE_CASE(SCSIOP_CHANGE_DEFINITION)
  135. MAKE_CASE(SCSIOP_READ_SUB_CHANNEL)
  136. MAKE_CASE(SCSIOP_READ_TOC)
  137. MAKE_CASE(SCSIOP_READ_HEADER)
  138. MAKE_CASE(SCSIOP_PLAY_AUDIO)
  139. MAKE_CASE(SCSIOP_GET_CONFIGURATION)
  140. MAKE_CASE(SCSIOP_PLAY_AUDIO_MSF)
  141. MAKE_CASE(SCSIOP_PLAY_TRACK_INDEX)
  142. MAKE_CASE(SCSIOP_PLAY_TRACK_RELATIVE)
  143. MAKE_CASE(SCSIOP_GET_EVENT_STATUS)
  144. MAKE_CASE(SCSIOP_PAUSE_RESUME)
  145. MAKE_CASE(SCSIOP_LOG_SELECT)
  146. MAKE_CASE(SCSIOP_LOG_SENSE)
  147. MAKE_CASE(SCSIOP_STOP_PLAY_SCAN)
  148. MAKE_CASE(SCSIOP_READ_DISK_INFORMATION)
  149. MAKE_CASE(SCSIOP_READ_TRACK_INFORMATION)
  150. MAKE_CASE(SCSIOP_RESERVE_TRACK_RZONE)
  151. MAKE_CASE(SCSIOP_SEND_OPC_INFORMATION)
  152. MAKE_CASE(SCSIOP_MODE_SELECT10)
  153. MAKE_CASE(SCSIOP_MODE_SENSE10)
  154. MAKE_CASE(SCSIOP_CLOSE_TRACK_SESSION)
  155. MAKE_CASE(SCSIOP_READ_BUFFER_CAPACITY)
  156. MAKE_CASE(SCSIOP_SEND_CUE_SHEET)
  157. MAKE_CASE(SCSIOP_PERSISTENT_RESERVE_IN)
  158. MAKE_CASE(SCSIOP_PERSISTENT_RESERVE_OUT)
  159. MAKE_CASE(SCSIOP_REPORT_LUNS)
  160. MAKE_CASE(SCSIOP_BLANK)
  161. MAKE_CASE(SCSIOP_SEND_KEY)
  162. MAKE_CASE(SCSIOP_REPORT_KEY)
  163. MAKE_CASE(SCSIOP_MOVE_MEDIUM)
  164. MAKE_CASE(SCSIOP_LOAD_UNLOAD_SLOT) // aka SCSIOP_EXCHANGE_MEDIUM
  165. MAKE_CASE(SCSIOP_SET_READ_AHEAD)
  166. MAKE_CASE(SCSIOP_READ_DVD_STRUCTURE)
  167. MAKE_CASE(SCSIOP_REQUEST_VOL_ELEMENT)
  168. MAKE_CASE(SCSIOP_SEND_VOLUME_TAG)
  169. MAKE_CASE(SCSIOP_READ_ELEMENT_STATUS)
  170. MAKE_CASE(SCSIOP_READ_CD_MSF)
  171. MAKE_CASE(SCSIOP_SCAN_CD)
  172. MAKE_CASE(SCSIOP_SET_CD_SPEED)
  173. MAKE_CASE(SCSIOP_PLAY_CD)
  174. MAKE_CASE(SCSIOP_MECHANISM_STATUS)
  175. MAKE_CASE(SCSIOP_READ_CD)
  176. MAKE_CASE(SCSIOP_SEND_DVD_STRUCTURE)
  177. MAKE_CASE(SCSIOP_INIT_ELEMENT_RANGE)
  178. }
  179. return scsiOpStr;
  180. }
  181. char *DbgGetSrbStatusStr(UCHAR SrbStat)
  182. {
  183. char *srbStatStr = HexNumberStrings[SrbStat];
  184. switch (SrbStat){
  185. #undef MAKE_CASE
  186. #define MAKE_CASE(srbStat) \
  187. case srbStat: \
  188. srbStatStr = #srbStat; \
  189. break; \
  190. case srbStat|SRB_STATUS_QUEUE_FROZEN: \
  191. srbStatStr = #srbStat "|SRB_STATUS_QUEUE_FROZEN"; \
  192. break; \
  193. case srbStat|SRB_STATUS_AUTOSENSE_VALID: \
  194. srbStatStr = #srbStat "|SRB_STATUS_AUTOSENSE_VALID"; \
  195. break; \
  196. case srbStat|SRB_STATUS_QUEUE_FROZEN|SRB_STATUS_AUTOSENSE_VALID: \
  197. srbStatStr = #srbStat "|SRB_STATUS_QUEUE_FROZEN|SRB_STATUS_AUTOSENSE_VALID"; \
  198. break;
  199. MAKE_CASE(SRB_STATUS_PENDING)
  200. MAKE_CASE(SRB_STATUS_SUCCESS)
  201. MAKE_CASE(SRB_STATUS_ABORTED)
  202. MAKE_CASE(SRB_STATUS_ABORT_FAILED)
  203. MAKE_CASE(SRB_STATUS_ERROR)
  204. MAKE_CASE(SRB_STATUS_BUSY)
  205. MAKE_CASE(SRB_STATUS_INVALID_REQUEST)
  206. MAKE_CASE(SRB_STATUS_INVALID_PATH_ID)
  207. MAKE_CASE(SRB_STATUS_NO_DEVICE)
  208. MAKE_CASE(SRB_STATUS_TIMEOUT)
  209. MAKE_CASE(SRB_STATUS_SELECTION_TIMEOUT)
  210. MAKE_CASE(SRB_STATUS_COMMAND_TIMEOUT)
  211. MAKE_CASE(0x0C)
  212. MAKE_CASE(SRB_STATUS_MESSAGE_REJECTED)
  213. MAKE_CASE(SRB_STATUS_BUS_RESET)
  214. MAKE_CASE(SRB_STATUS_PARITY_ERROR)
  215. MAKE_CASE(SRB_STATUS_REQUEST_SENSE_FAILED)
  216. MAKE_CASE(SRB_STATUS_NO_HBA)
  217. MAKE_CASE(SRB_STATUS_DATA_OVERRUN)
  218. MAKE_CASE(SRB_STATUS_UNEXPECTED_BUS_FREE)
  219. MAKE_CASE(SRB_STATUS_PHASE_SEQUENCE_FAILURE)
  220. MAKE_CASE(SRB_STATUS_BAD_SRB_BLOCK_LENGTH)
  221. MAKE_CASE(SRB_STATUS_REQUEST_FLUSHED)
  222. MAKE_CASE(SRB_STATUS_INVALID_LUN)
  223. MAKE_CASE(SRB_STATUS_INVALID_TARGET_ID)
  224. MAKE_CASE(SRB_STATUS_BAD_FUNCTION)
  225. MAKE_CASE(SRB_STATUS_ERROR_RECOVERY)
  226. MAKE_CASE(SRB_STATUS_NOT_POWERED)
  227. MAKE_CASE(0x25)
  228. MAKE_CASE(0x26)
  229. MAKE_CASE(0x27)
  230. MAKE_CASE(0x28)
  231. MAKE_CASE(0x29)
  232. MAKE_CASE(0x2A)
  233. MAKE_CASE(0x2B)
  234. MAKE_CASE(0x2C)
  235. MAKE_CASE(0x2D)
  236. MAKE_CASE(0x2E)
  237. MAKE_CASE(0x2F)
  238. MAKE_CASE(SRB_STATUS_INTERNAL_ERROR)
  239. MAKE_CASE(0x31)
  240. MAKE_CASE(0x32)
  241. MAKE_CASE(0x33)
  242. MAKE_CASE(0x34)
  243. MAKE_CASE(0x35)
  244. MAKE_CASE(0x36)
  245. MAKE_CASE(0x37)
  246. MAKE_CASE(0x38)
  247. MAKE_CASE(0x39)
  248. MAKE_CASE(0x3A)
  249. MAKE_CASE(0x3B)
  250. MAKE_CASE(0x3C)
  251. MAKE_CASE(0x3D)
  252. MAKE_CASE(0x3E)
  253. MAKE_CASE(0x3F)
  254. }
  255. return srbStatStr;
  256. }
  257. char *DbgGetSenseCodeStr(UCHAR SrbStat, ULONG64 SenseDataAddr)
  258. {
  259. char *senseCodeStr = "??";
  260. if (SrbStat & SRB_STATUS_AUTOSENSE_VALID){
  261. UCHAR senseCode;
  262. senseCode = GetUCHARField(SenseDataAddr, "classpnp!_SENSE_DATA", "SenseKey");
  263. if (senseCode != BAD_VALUE){
  264. senseCode &= 0x0f;
  265. senseCodeStr = HexNumberStrings[senseCode];
  266. switch (senseCode){
  267. #undef MAKE_CASE
  268. #define MAKE_CASE(snsCod) case snsCod: senseCodeStr = #snsCod; break;
  269. MAKE_CASE(SCSI_SENSE_NO_SENSE)
  270. MAKE_CASE(SCSI_SENSE_RECOVERED_ERROR)
  271. MAKE_CASE(SCSI_SENSE_NOT_READY)
  272. MAKE_CASE(SCSI_SENSE_MEDIUM_ERROR)
  273. MAKE_CASE(SCSI_SENSE_HARDWARE_ERROR)
  274. MAKE_CASE(SCSI_SENSE_ILLEGAL_REQUEST)
  275. MAKE_CASE(SCSI_SENSE_UNIT_ATTENTION)
  276. MAKE_CASE(SCSI_SENSE_DATA_PROTECT)
  277. MAKE_CASE(SCSI_SENSE_BLANK_CHECK)
  278. MAKE_CASE(SCSI_SENSE_UNIQUE)
  279. MAKE_CASE(SCSI_SENSE_COPY_ABORTED)
  280. MAKE_CASE(SCSI_SENSE_ABORTED_COMMAND)
  281. MAKE_CASE(SCSI_SENSE_EQUAL)
  282. MAKE_CASE(SCSI_SENSE_VOL_OVERFLOW)
  283. MAKE_CASE(SCSI_SENSE_MISCOMPARE)
  284. MAKE_CASE(SCSI_SENSE_RESERVED)
  285. }
  286. }
  287. }
  288. return senseCodeStr;
  289. }
  290. char *DbgGetAdditionalSenseCodeStr(UCHAR SrbStat, ULONG64 SenseDataAddr)
  291. {
  292. char *adSenseCodeStr = "?";
  293. if (SrbStat & SRB_STATUS_AUTOSENSE_VALID){
  294. UCHAR adSenseCode;
  295. adSenseCode = GetUCHARField(SenseDataAddr, "classpnp!_SENSE_DATA", "AdditionalSenseCode");
  296. adSenseCodeStr = HexNumberStrings[adSenseCode];
  297. if (adSenseCode != BAD_VALUE){
  298. switch (adSenseCode){
  299. #undef MAKE_CASE
  300. #define MAKE_CASE(adSnsCod) case adSnsCod: adSenseCodeStr = #adSnsCod; break;
  301. MAKE_CASE(SCSI_ADSENSE_NO_SENSE)
  302. MAKE_CASE(SCSI_ADSENSE_NO_SEEK_COMPLETE)
  303. MAKE_CASE(SCSI_ADSENSE_LUN_NOT_READY)
  304. MAKE_CASE(SCSI_ADSENSE_WRITE_ERROR)
  305. MAKE_CASE(SCSI_ADSENSE_TRACK_ERROR)
  306. MAKE_CASE(SCSI_ADSENSE_SEEK_ERROR)
  307. MAKE_CASE(SCSI_ADSENSE_REC_DATA_NOECC)
  308. MAKE_CASE(SCSI_ADSENSE_REC_DATA_ECC)
  309. MAKE_CASE(SCSI_ADSENSE_ILLEGAL_COMMAND)
  310. MAKE_CASE(SCSI_ADSENSE_ILLEGAL_BLOCK)
  311. MAKE_CASE(SCSI_ADSENSE_INVALID_CDB)
  312. MAKE_CASE(SCSI_ADSENSE_INVALID_LUN)
  313. MAKE_CASE(SCSI_ADSENSE_WRITE_PROTECT) // aka SCSI_ADWRITE_PROTECT
  314. MAKE_CASE(SCSI_ADSENSE_MEDIUM_CHANGED)
  315. MAKE_CASE(SCSI_ADSENSE_BUS_RESET)
  316. MAKE_CASE(SCSI_ADSENSE_INSUFFICIENT_TIME_FOR_OPERATION)
  317. MAKE_CASE(SCSI_ADSENSE_INVALID_MEDIA)
  318. MAKE_CASE(SCSI_ADSENSE_NO_MEDIA_IN_DEVICE)
  319. MAKE_CASE(SCSI_ADSENSE_POSITION_ERROR)
  320. MAKE_CASE(SCSI_ADSENSE_OPERATOR_REQUEST)
  321. MAKE_CASE(SCSI_ADSENSE_FAILURE_PREDICTION_THRESHOLD_EXCEEDED)
  322. MAKE_CASE(SCSI_ADSENSE_ILLEGAL_MODE_FOR_THIS_TRACK)
  323. MAKE_CASE(SCSI_ADSENSE_COPY_PROTECTION_FAILURE)
  324. MAKE_CASE(SCSI_ADSENSE_POWER_CALIBRATION_ERROR)
  325. MAKE_CASE(SCSI_ADSENSE_VENDOR_UNIQUE)
  326. MAKE_CASE(SCSI_ADSENSE_MUSIC_AREA)
  327. MAKE_CASE(SCSI_ADSENSE_DATA_AREA)
  328. MAKE_CASE(SCSI_ADSENSE_VOLUME_OVERFLOW)
  329. }
  330. }
  331. }
  332. return adSenseCodeStr;
  333. }
  334. char *DbgGetAdditionalSenseCodeQualifierStr(UCHAR SrbStat, ULONG64 SenseDataAddr)
  335. {
  336. char *adSenseCodeQualStr = "?";
  337. if (SrbStat & SRB_STATUS_AUTOSENSE_VALID){
  338. UCHAR adSenseCode, adSenseCodeQual;
  339. adSenseCode = GetUCHARField(SenseDataAddr, "classpnp!_SENSE_DATA", "AdditionalSenseCode");
  340. adSenseCodeQual = GetUCHARField(SenseDataAddr, "classpnp!_SENSE_DATA", "AdditionalSenseCodeQualifier");
  341. adSenseCodeQualStr = HexNumberStrings[adSenseCodeQual];
  342. if ((adSenseCode != BAD_VALUE) && (adSenseCodeQual != BAD_VALUE)){
  343. switch (adSenseCode){
  344. #undef MAKE_CASE
  345. #define MAKE_CASE(adSnsCodQual) case adSnsCodQual: adSenseCodeQualStr = #adSnsCodQual; break;
  346. case SCSI_ADSENSE_LUN_NOT_READY:
  347. switch (adSenseCodeQual){
  348. MAKE_CASE(SCSI_SENSEQ_CAUSE_NOT_REPORTABLE)
  349. MAKE_CASE(SCSI_SENSEQ_BECOMING_READY)
  350. MAKE_CASE(SCSI_SENSEQ_INIT_COMMAND_REQUIRED)
  351. MAKE_CASE(SCSI_SENSEQ_MANUAL_INTERVENTION_REQUIRED)
  352. MAKE_CASE(SCSI_SENSEQ_FORMAT_IN_PROGRESS)
  353. MAKE_CASE(SCSI_SENSEQ_REBUILD_IN_PROGRESS)
  354. MAKE_CASE(SCSI_SENSEQ_RECALCULATION_IN_PROGRESS)
  355. MAKE_CASE(SCSI_SENSEQ_OPERATION_IN_PROGRESS)
  356. MAKE_CASE(SCSI_SENSEQ_LONG_WRITE_IN_PROGRESS)
  357. }
  358. break;
  359. case SCSI_ADSENSE_NO_SENSE:
  360. switch (adSenseCodeQual){
  361. MAKE_CASE(SCSI_SENSEQ_FILEMARK_DETECTED)
  362. MAKE_CASE(SCSI_SENSEQ_END_OF_MEDIA_DETECTED)
  363. MAKE_CASE(SCSI_SENSEQ_SETMARK_DETECTED)
  364. MAKE_CASE(SCSI_SENSEQ_BEGINNING_OF_MEDIA_DETECTED)
  365. }
  366. break;
  367. case SCSI_ADSENSE_ILLEGAL_BLOCK:
  368. switch (adSenseCodeQual){
  369. MAKE_CASE(SCSI_SENSEQ_ILLEGAL_ELEMENT_ADDR)
  370. }
  371. break;
  372. case SCSI_ADSENSE_POSITION_ERROR:
  373. switch (adSenseCodeQual){
  374. MAKE_CASE(SCSI_SENSEQ_DESTINATION_FULL)
  375. MAKE_CASE(SCSI_SENSEQ_SOURCE_EMPTY)
  376. }
  377. break;
  378. case SCSI_ADSENSE_INVALID_MEDIA:
  379. switch (adSenseCodeQual){
  380. MAKE_CASE(SCSI_SENSEQ_INCOMPATIBLE_MEDIA_INSTALLED)
  381. MAKE_CASE(SCSI_SENSEQ_UNKNOWN_FORMAT)
  382. MAKE_CASE(SCSI_SENSEQ_INCOMPATIBLE_FORMAT)
  383. MAKE_CASE(SCSI_SENSEQ_CLEANING_CARTRIDGE_INSTALLED)
  384. }
  385. break;
  386. case SCSI_ADSENSE_OPERATOR_REQUEST:
  387. switch (adSenseCodeQual){
  388. MAKE_CASE(SCSI_SENSEQ_STATE_CHANGE_INPUT)
  389. MAKE_CASE(SCSI_SENSEQ_MEDIUM_REMOVAL)
  390. MAKE_CASE(SCSI_SENSEQ_WRITE_PROTECT_ENABLE)
  391. MAKE_CASE(SCSI_SENSEQ_WRITE_PROTECT_DISABLE)
  392. }
  393. break;
  394. case SCSI_ADSENSE_COPY_PROTECTION_FAILURE:
  395. switch (adSenseCodeQual){
  396. MAKE_CASE(SCSI_SENSEQ_AUTHENTICATION_FAILURE)
  397. MAKE_CASE(SCSI_SENSEQ_KEY_NOT_PRESENT)
  398. MAKE_CASE(SCSI_SENSEQ_KEY_NOT_ESTABLISHED)
  399. MAKE_CASE(SCSI_SENSEQ_READ_OF_SCRAMBLED_SECTOR_WITHOUT_AUTHENTICATION)
  400. MAKE_CASE(SCSI_SENSEQ_MEDIA_CODE_MISMATCHED_TO_LOGICAL_UNIT)
  401. MAKE_CASE(SCSI_SENSEQ_LOGICAL_UNIT_RESET_COUNT_ERROR)
  402. }
  403. break;
  404. }
  405. }
  406. }
  407. return adSenseCodeQualStr;
  408. }
  409. /*
  410. * DbgGetMediaTypeStr
  411. *
  412. * Convert MEDIA_TYPE (defined in ntdddisk.h) to a string.
  413. */
  414. char *DbgGetMediaTypeStr(ULONG MediaType)
  415. {
  416. char *mediaTypeStr = "?";
  417. if (MediaType < 0xff)
  418. {
  419. mediaTypeStr = HexNumberStrings[MediaType];
  420. }
  421. switch (MediaType){
  422. #undef MAKE_CASE
  423. #define MAKE_CASE(mtype) case mtype: mediaTypeStr = #mtype; break;
  424. MAKE_CASE(Unknown)
  425. MAKE_CASE(F5_1Pt2_512)
  426. MAKE_CASE(F3_1Pt44_512)
  427. MAKE_CASE(F3_2Pt88_512)
  428. MAKE_CASE(F3_20Pt8_512)
  429. MAKE_CASE(F3_720_512)
  430. MAKE_CASE(F5_360_512)
  431. MAKE_CASE(F5_320_512)
  432. MAKE_CASE(F5_320_1024)
  433. MAKE_CASE(F5_180_512)
  434. MAKE_CASE(F5_160_512)
  435. MAKE_CASE(RemovableMedia)
  436. MAKE_CASE(FixedMedia)
  437. MAKE_CASE(F3_120M_512)
  438. MAKE_CASE(F3_640_512)
  439. MAKE_CASE(F5_640_512)
  440. MAKE_CASE(F5_720_512)
  441. MAKE_CASE(F3_1Pt2_512)
  442. MAKE_CASE(F3_1Pt23_1024)
  443. MAKE_CASE(F5_1Pt23_1024)
  444. MAKE_CASE(F3_128Mb_512)
  445. MAKE_CASE(F3_230Mb_512)
  446. MAKE_CASE(F8_256_128)
  447. MAKE_CASE(F3_200Mb_512)
  448. MAKE_CASE(F3_240M_512)
  449. MAKE_CASE(F3_32M_512)
  450. }
  451. return mediaTypeStr;
  452. }