VirtualBox

source: vbox/trunk/src/VBox/Devices/Storage/Debug.cpp@ 74441

Last change on this file since 74441 was 69500, checked in by vboxsync, 7 years ago

*: scm --update-copyright-year

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 52.8 KB
Line 
1/* $Id: Debug.cpp 69500 2017-10-28 15:14:05Z vboxsync $ */
2/** @file
3 * VBox storage devices: debug helpers
4 */
5
6/*
7 * Copyright (C) 2008-2017 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18
19#include <iprt/assert.h>
20#include <iprt/log.h>
21#include <iprt/types.h>
22#include <iprt/string.h>
23#include <VBox/scsi.h>
24#include <VBox/ata.h>
25
26#ifdef LOG_ENABLED
27
28/**
29 * ATA command codes
30 */
31static const char * const g_apszATACmdNames[256] =
32{
33 "NOP", /* 0x00 */
34 "", /* 0x01 */
35 "", /* 0x02 */
36 "CFA REQUEST EXTENDED ERROR CODE", /* 0x03 */
37 "", /* 0x04 */
38 "", /* 0x05 */
39 "DATA SET MANAGEMENT", /* 0x06 */
40 "", /* 0x07 */
41 "DEVICE RESET", /* 0x08 */
42 "", /* 0x09 */
43 "", /* 0x0a */
44 "", /* 0x0b */
45 "", /* 0x0c */
46 "", /* 0x0d */
47 "", /* 0x0e */
48 "", /* 0x0f */
49 "RECALIBRATE", /* 0x10 */
50 "", /* 0x11 */
51 "", /* 0x12 */
52 "", /* 0x13 */
53 "", /* 0x14 */
54 "", /* 0x15 */
55 "", /* 0x16 */
56 "", /* 0x17 */
57 "", /* 0x18 */
58 "", /* 0x19 */
59 "", /* 0x1a */
60 "", /* 0x1b */
61 "", /* 0x1c */
62 "", /* 0x1d */
63 "", /* 0x1e */
64 "", /* 0x1f */
65 "READ SECTORS", /* 0x20 */
66 "READ SECTORS WITHOUT RETRIES", /* 0x21 */
67 "READ LONG", /* 0x22 */
68 "READ LONG WITHOUT RETRIES", /* 0x23 */
69 "READ SECTORS EXT", /* 0x24 */
70 "READ DMA EXT", /* 0x25 */
71 "READ DMA QUEUED EXT", /* 0x26 */
72 "READ NATIVE MAX ADDRESS EXT", /* 0x27 */
73 "", /* 0x28 */
74 "READ MULTIPLE EXT", /* 0x29 */
75 "READ STREAM DMA EXT", /* 0x2a */
76 "READ STREAM EXT", /* 0x2b */
77 "", /* 0x2c */
78 "", /* 0x2d */
79 "", /* 0x2e */
80 "READ LOG EXT", /* 0x2f */
81 "WRITE SECTORS", /* 0x30 */
82 "WRITE SECTORS WITHOUT RETRIES", /* 0x31 */
83 "WRITE LONG", /* 0x32 */
84 "WRITE LONG WITHOUT RETRIES", /* 0x33 */
85 "WRITE SECTORS EXT", /* 0x34 */
86 "WRITE DMA EXT", /* 0x35 */
87 "WRITE DMA QUEUED EXT", /* 0x36 */
88 "SET MAX ADDRESS EXT", /* 0x37 */
89 "CFA WRITE SECTORS WITHOUT ERASE", /* 0x38 */
90 "WRITE MULTIPLE EXT", /* 0x39 */
91 "WRITE STREAM DMA EXT", /* 0x3a */
92 "WRITE STREAM EXT", /* 0x3b */
93 "WRITE VERIFY", /* 0x3c */
94 "WRITE DMA FUA EXT", /* 0x3d */
95 "WRITE DMA QUEUED FUA EXT", /* 0x3e */
96 "WRITE LOG EXT", /* 0x3f */
97 "READ VERIFY SECTORS", /* 0x40 */
98 "READ VERIFY SECTORS WITHOUT RETRIES", /* 0x41 */
99 "READ VERIFY SECTORS EXT", /* 0x42 */
100 "", /* 0x43 */
101 "", /* 0x44 */
102 "WRITE UNCORRECTABLE EXT", /* 0x45 */
103 "", /* 0x46 */
104 "READ LOG DMA EXT", /* 0x47 */
105 "", /* 0x48 */
106 "", /* 0x49 */
107 "", /* 0x4a */
108 "", /* 0x4b */
109 "", /* 0x4c */
110 "", /* 0x4d */
111 "", /* 0x4e */
112 "", /* 0x4f */
113 "FORMAT TRACK", /* 0x50 */
114 "CONFIGURE STREAM", /* 0x51 */
115 "", /* 0x52 */
116 "", /* 0x53 */
117 "", /* 0x54 */
118 "", /* 0x55 */
119 "", /* 0x56 */
120 "WRITE LOG DMA EXT", /* 0x57 */
121 "", /* 0x58 */
122 "", /* 0x59 */
123 "", /* 0x5a */
124 "", /* 0x5b */
125 "TRUSTED RECEIVE", /* 0x5c */
126 "TRUSTED RECEIVE DMA", /* 0x5d */
127 "TRUSTED SEND", /* 0x5e */
128 "TRUSTED SEND DMA", /* 0x5f */
129 "READ FPDMA QUEUED", /* 0x60 */
130 "WRITE FPDMA QUEUED", /* 0x61 */
131 "", /* 0x62 */
132 "", /* 0x63 */
133 "", /* 0x64 */
134 "", /* 0x65 */
135 "", /* 0x66 */
136 "", /* 0x67 */
137 "", /* 0x68 */
138 "", /* 0x69 */
139 "", /* 0x6a */
140 "", /* 0x6b */
141 "", /* 0x6c */
142 "", /* 0x6d */
143 "", /* 0x6e */
144 "", /* 0x6f */
145 "SEEK", /* 0x70 */
146 "", /* 0x71 */
147 "", /* 0x72 */
148 "", /* 0x73 */
149 "", /* 0x74 */
150 "", /* 0x75 */
151 "", /* 0x76 */
152 "", /* 0x77 */
153 "", /* 0x78 */
154 "", /* 0x79 */
155 "", /* 0x7a */
156 "", /* 0x7b */
157 "", /* 0x7c */
158 "", /* 0x7d */
159 "", /* 0x7e */
160 "", /* 0x7f */
161 "", /* 0x80 */
162 "", /* 0x81 */
163 "", /* 0x82 */
164 "", /* 0x83 */
165 "", /* 0x84 */
166 "", /* 0x85 */
167 "", /* 0x86 */
168 "CFA TRANSLATE SECTOR", /* 0x87 */
169 "", /* 0x88 */
170 "", /* 0x89 */
171 "", /* 0x8a */
172 "", /* 0x8b */
173 "", /* 0x8c */
174 "", /* 0x8d */
175 "", /* 0x8e */
176 "", /* 0x8f */
177 "EXECUTE DEVICE DIAGNOSTIC", /* 0x90 */
178 "INITIALIZE DEVICE PARAMETERS", /* 0x91 */
179 "DOWNLOAD MICROCODE", /* 0x92 */
180 "", /* 0x93 */
181 "STANDBY IMMEDIATE ALT", /* 0x94 */
182 "IDLE IMMEDIATE ALT", /* 0x95 */
183 "STANDBY ALT", /* 0x96 */
184 "IDLE ALT", /* 0x97 */
185 "CHECK POWER MODE ALT", /* 0x98 */
186 "SLEEP ALT", /* 0x99 */
187 "", /* 0x9a */
188 "", /* 0x9b */
189 "", /* 0x9c */
190 "", /* 0x9d */
191 "", /* 0x9e */
192 "", /* 0x9f */
193 "PACKET", /* 0xa0 */
194 "IDENTIFY PACKET DEVICE", /* 0xa1 */
195 "SERVICE", /* 0xa2 */
196 "", /* 0xa3 */
197 "", /* 0xa4 */
198 "", /* 0xa5 */
199 "", /* 0xa6 */
200 "", /* 0xa7 */
201 "", /* 0xa8 */
202 "", /* 0xa9 */
203 "", /* 0xaa */
204 "", /* 0xab */
205 "", /* 0xac */
206 "", /* 0xad */
207 "", /* 0xae */
208 "", /* 0xaf */
209 "SMART", /* 0xb0 */
210 "DEVICE CONFIGURATION OVERLAY", /* 0xb1 */
211 "", /* 0xb2 */
212 "", /* 0xb3 */
213 "", /* 0xb4 */
214 "", /* 0xb5 */
215 "NV CACHE", /* 0xb6 */
216 "", /* 0xb7 */
217 "", /* 0xb8 */
218 "", /* 0xb9 */
219 "", /* 0xba */
220 "", /* 0xbb */
221 "", /* 0xbc */
222 "", /* 0xbd */
223 "", /* 0xbe */
224 "", /* 0xbf */
225 "CFA ERASE SECTORS", /* 0xc0 */
226 "", /* 0xc1 */
227 "", /* 0xc2 */
228 "", /* 0xc3 */
229 "READ MULTIPLE", /* 0xc4 */
230 "WRITE MULTIPLE", /* 0xc5 */
231 "SET MULTIPLE MODE", /* 0xc6 */
232 "READ DMA QUEUED", /* 0xc7 */
233 "READ DMA", /* 0xc8 */
234 "READ DMA WITHOUT RETRIES", /* 0xc9 */
235 "WRITE DMA", /* 0xca */
236 "WRITE DMA WITHOUT RETRIES", /* 0xcb */
237 "WRITE DMA QUEUED", /* 0xcc */
238 "CFA WRITE MULTIPLE WITHOUT ERASE", /* 0xcd */
239 "WRITE MULTIPLE FUA EXT", /* 0xce */
240 "", /* 0xcf */
241 "", /* 0xd0 */
242 "CHECK MEDIA CARD TYPE", /* 0xd1 */
243 "", /* 0xd2 */
244 "", /* 0xd3 */
245 "", /* 0xd4 */
246 "", /* 0xd5 */
247 "", /* 0xd6 */
248 "", /* 0xd7 */
249 "", /* 0xd8 */
250 "", /* 0xd9 */
251 "GET MEDIA STATUS", /* 0xda */
252 "ACKNOWLEDGE MEDIA CHANGE", /* 0xdb */
253 "BOOT POST BOOT", /* 0xdc */
254 "BOOT PRE BOOT", /* 0xdd */
255 "MEDIA LOCK", /* 0xde */
256 "MEDIA UNLOCK", /* 0xdf */
257 "STANDBY IMMEDIATE", /* 0xe0 */
258 "IDLE IMMEDIATE", /* 0xe1 */
259 "STANDBY", /* 0xe2 */
260 "IDLE", /* 0xe3 */
261 "READ BUFFER", /* 0xe4 */
262 "CHECK POWER MODE", /* 0xe5 */
263 "SLEEP", /* 0xe6 */
264 "FLUSH CACHE", /* 0xe7 */
265 "WRITE BUFFER", /* 0xe8 */
266 "WRITE SAME", /* 0xe9 */
267 "FLUSH CACHE EXT", /* 0xea */
268 "", /* 0xeb */
269 "IDENTIFY DEVICE", /* 0xec */
270 "MEDIA EJECT", /* 0xed */
271 "IDENTIFY DMA", /* 0xee */
272 "SET FEATURES", /* 0xef */
273 "", /* 0xf0 */
274 "SECURITY SET PASSWORD", /* 0xf1 */
275 "SECURITY UNLOCK", /* 0xf2 */
276 "SECURITY ERASE PREPARE", /* 0xf3 */
277 "SECURITY ERASE UNIT", /* 0xf4 */
278 "SECURITY FREEZE LOCK", /* 0xf5 */
279 "SECURITY DISABLE PASSWORD", /* 0xf6 */
280 "", /* 0xf7 */
281 "READ NATIVE MAX ADDRESS", /* 0xf8 */
282 "SET MAX", /* 0xf9 */
283 "", /* 0xfa */
284 "", /* 0xfb */
285 "", /* 0xfc */
286 "", /* 0xfd */
287 "", /* 0xfe */
288 "" /* 0xff */
289};
290
291#endif /* LOG_ENABLED */
292
293#if defined(LOG_ENABLED) || defined(RT_STRICT)
294
295/**
296 * SCSI command codes.
297 */
298static const char * const g_apszSCSICmdNames[256] =
299{
300 "TEST UNIT READY", /* 0x00 */
301 "REZERO UNIT", /* 0x01 */
302 "", /* 0x02 */
303 "REQUEST SENSE", /* 0x03 */
304 "FORMAT UNIT", /* 0x04 */
305 "READ BLOCK LIMITS", /* 0x05 */
306 "", /* 0x06 */
307 "REASSIGN BLOCKS", /* 0x07 */
308 "READ (6)", /* 0x08 */
309 "", /* 0x09 */
310 "WRITE (6)", /* 0x0a */
311 "SEEK (6)", /* 0x0b */
312 "", /* 0x0c */
313 "", /* 0x0d */
314 "", /* 0x0e */
315 "READ REVERSE (6)", /* 0x0f */
316 "READ FILEMARKS (6)", /* 0x10 */
317 "SPACE (6)", /* 0x11 */
318 "INQUIRY", /* 0x12 */
319 "VERIFY (6)", /* 0x13 */
320 "RECOVER BUFFERED DATA", /* 0x14 */
321 "MODE SELECT (6)", /* 0x15 */
322 "RESERVE (6)", /* 0x16 */
323 "RELEASE (6)", /* 0x17 */
324 "COPY", /* 0x18 */
325 "ERASE (6)", /* 0x19 */
326 "MODE SENSE (6)", /* 0x1a */
327 "START STOP UNIT", /* 0x1b */
328 "RECEIVE DIAGNOSTIC RESULTS", /* 0x1c */
329 "SEND DIAGNOSTIC", /* 0x1d */
330 "PREVENT ALLOW MEDIUM REMOVAL", /* 0x1e */
331 "", /* 0x1f */
332 "", /* 0x20 */
333 "", /* 0x21 */
334 "", /* 0x22 */
335 "READ FORMAT CAPACITIES", /* 0x23 */
336 "SET WINDOW", /* 0x24 */
337 "READ CAPACITY", /* 0x25 */
338 "", /* 0x26 */
339 "", /* 0x27 */
340 "READ (10)", /* 0x28 */
341 "READ GENERATION", /* 0x29 */
342 "WRITE (10)", /* 0x2a */
343 "SEEK (10)", /* 0x2b */
344 "ERASE (10)", /* 0x2c */
345 "READ UPDATED BLOCK", /* 0x2d */
346 "WRITE AND VERIFY (10)", /* 0x2e */
347 "VERIFY (10)", /* 0x2f */
348 "SEARCH DATA HIGH (10)", /* 0x30 */
349 "SEARCH DATA EQUAL (10)", /* 0x31 */
350 "SEARCH DATA LOW (10)", /* 0x32 */
351 "SET LIMITS (10)", /* 0x33 */
352 "PRE-FETCH (10)", /* 0x34 */
353 "SYNCHRONIZE CACHE (10)", /* 0x35 */
354 "LOCK UNLOCK CACHE (10)", /* 0x36 */
355 "READ DEFECT DATA (10)", /* 0x37 */
356 "MEDIUM SCAN", /* 0x38 */
357 "COMPARE", /* 0x39 */
358 "COPY AND VERIFY", /* 0x3a */
359 "WRITE BUFFER", /* 0x3b */
360 "READ BUFFER", /* 0x3c */
361 "UPDATE BLOCK", /* 0x3d */
362 "READ LONG (10)", /* 0x3e */
363 "WRITE LONG (10)", /* 0x3f */
364 "CHANGE DEFINITION", /* 0x40 */
365 "WRITE SAME (10)", /* 0x41 */
366 "READ SUBCHANNEL", /* 0x42 */
367 "READ TOC/PMA/ATIP", /* 0x43 */
368 "REPORT DENSITY SUPPORT", /* 0x44 */
369 "PLAY AUDIO (10)", /* 0x45 */
370 "GET CONFIGURATION", /* 0x46 */
371 "PLAY AUDIO MSF", /* 0x47 */
372 "", /* 0x48 */
373 "", /* 0x49 */
374 "GET EVENT STATUS NOTIFICATION", /* 0x4a */
375 "PAUSE/RESUME", /* 0x4b */
376 "LOG SELECT", /* 0x4c */
377 "LOG SENSE", /* 0x4d */
378 "STOP PLAY/SCAN", /* 0x4e */
379 "", /* 0x4f */
380 "XDWRITE (10)", /* 0x50 */
381 "READ DISC INFORMATION", /* 0x51 */
382 "READ TRACK INFORMATION", /* 0x52 */
383 "RESERVE TRACK", /* 0x53 */
384 "SEND OPC INFORMATION", /* 0x54 */
385 "MODE SELECT (10)", /* 0x55 */
386 "RESERVE (10)", /* 0x56 */
387 "RELEASE (10)", /* 0x57 */
388 "REPAIR TRACK", /* 0x58 */
389 "", /* 0x59 */
390 "MODE SENSE (10)", /* 0x5a */
391 "CLOSE TRACK/SESSION", /* 0x5b */
392 "READ BUFFER CAPACITY", /* 0x5c */
393 "SEND CUE SHEET", /* 0x5d */
394 "PERSISTENT RESERVE IN", /* 0x5e */
395 "PERSISTENT RESERVE OUT", /* 0x5f */
396 "", /* 0x60 */
397 "", /* 0x61 */
398 "", /* 0x62 */
399 "", /* 0x63 */
400 "", /* 0x64 */
401 "", /* 0x65 */
402 "", /* 0x66 */
403 "", /* 0x67 */
404 "", /* 0x68 */
405 "", /* 0x69 */
406 "", /* 0x6a */
407 "", /* 0x6b */
408 "", /* 0x6c */
409 "", /* 0x6d */
410 "", /* 0x6e */
411 "", /* 0x6f */
412 "", /* 0x70 */
413 "", /* 0x71 */
414 "", /* 0x72 */
415 "", /* 0x73 */
416 "", /* 0x74 */
417 "", /* 0x75 */
418 "", /* 0x76 */
419 "", /* 0x77 */
420 "", /* 0x78 */
421 "", /* 0x79 */
422 "", /* 0x7a */
423 "", /* 0x7b */
424 "", /* 0x7c */
425 "", /* 0x7d */
426 "", /* 0x7e */
427 "", /* 0x7f */
428 "WRITE FILEMARKS (16)", /* 0x80 */
429 "READ REVERSE (16)", /* 0x81 */
430 "REGENERATE (16)", /* 0x82 */
431 "EXTENDED COPY", /* 0x83 */
432 "RECEIVE COPY RESULTS", /* 0x84 */
433 "ATA COMMAND PASS THROUGH (16)", /* 0x85 */
434 "ACCESS CONTROL IN", /* 0x86 */
435 "ACCESS CONTROL OUT", /* 0x87 */
436 "READ (16)", /* 0x88 */
437 "", /* 0x89 */
438 "WRITE(16)", /* 0x8a */
439 "", /* 0x8b */
440 "READ ATTRIBUTE", /* 0x8c */
441 "WRITE ATTRIBUTE", /* 0x8d */
442 "WRITE AND VERIFY (16)", /* 0x8e */
443 "VERIFY (16)", /* 0x8f */
444 "PRE-FETCH (16)", /* 0x90 */
445 "SYNCHRONIZE CACHE (16)", /* 0x91 */
446 "LOCK UNLOCK CACHE (16)", /* 0x92 */
447 "WRITE SAME (16)", /* 0x93 */
448 "", /* 0x94 */
449 "", /* 0x95 */
450 "", /* 0x96 */
451 "", /* 0x97 */
452 "", /* 0x98 */
453 "", /* 0x99 */
454 "", /* 0x9a */
455 "", /* 0x9b */
456 "", /* 0x9c */
457 "", /* 0x9d */
458 "SERVICE ACTION IN (16)", /* 0x9e */
459 "SERVICE ACTION OUT (16)", /* 0x9f */
460 "REPORT LUNS", /* 0xa0 */
461 "BLANK", /* 0xa1 */
462 "SEND EVENT", /* 0xa2 */
463 "SEND KEY", /* 0xa3 */
464 "REPORT KEY", /* 0xa4 */
465 "PLAY AUDIO (12)", /* 0xa5 */
466 "LOAD/UNLOAD MEDIUM", /* 0xa6 */
467 "SET READ AHEAD", /* 0xa7 */
468 "READ (12)", /* 0xa8 */
469 "SERVICE ACTION OUT (12)", /* 0xa9 */
470 "WRITE (12)", /* 0xaa */
471 "SERVICE ACTION IN (12)", /* 0xab */
472 "GET PERFORMANCE", /* 0xac */
473 "READ DVD STRUCTURE", /* 0xad */
474 "WRITE AND VERIFY (12)", /* 0xae */
475 "VERIFY (12)", /* 0xaf */
476 "SEARCH DATA HIGH (12)", /* 0xb0 */
477 "SEARCH DATA EQUAL (12)", /* 0xb1 */
478 "SEARCH DATA LOW (12)", /* 0xb2 */
479 "SET LIMITS (12)", /* 0xb3 */
480 "READ ELEMENT STATUS ATTACHED", /* 0xb4 */
481 "REQUEST VOLUME ELEMENT ADDRESS", /* 0xb5 */
482 "SET STREAMING", /* 0xb6 */
483 "READ DEFECT DATA (12)", /* 0xb7 */
484 "READ ELEMENT STATUS", /* 0xb8 */
485 "READ CD MSF", /* 0xb9 */
486 "SCAN", /* 0xba */
487 "SET CD SPEED", /* 0xbb */
488 "SPARE (IN)", /* 0xbc */
489 "MECHANISM STATUS", /* 0xbd */
490 "READ CD", /* 0xbe */
491 "SEND DVD STRUCTURE", /* 0xbf */
492 "", /* 0xc0 */
493 "", /* 0xc1 */
494 "", /* 0xc2 */
495 "", /* 0xc3 */
496 "", /* 0xc4 */
497 "", /* 0xc5 */
498 "", /* 0xc6 */
499 "", /* 0xc7 */
500 "", /* 0xc8 */
501 "", /* 0xc9 */
502 "", /* 0xca */
503 "", /* 0xcb */
504 "", /* 0xcc */
505 "", /* 0xcd */
506 "", /* 0xce */
507 "", /* 0xcf */
508 "", /* 0xd0 */
509 "", /* 0xd1 */
510 "", /* 0xd2 */
511 "", /* 0xd3 */
512 "", /* 0xd4 */
513 "", /* 0xd5 */
514 "", /* 0xd6 */
515 "", /* 0xd7 */
516 "", /* 0xd8 */
517 "", /* 0xd9 */
518 "", /* 0xda */
519 "", /* 0xdb */
520 "", /* 0xdc */
521 "", /* 0xdd */
522 "", /* 0xde */
523 "", /* 0xdf */
524 "", /* 0xe0 */
525 "", /* 0xe1 */
526 "", /* 0xe2 */
527 "", /* 0xe3 */
528 "", /* 0xe4 */
529 "", /* 0xe5 */
530 "", /* 0xe6 */
531 "", /* 0xe7 */
532 "", /* 0xe8 */
533 "", /* 0xe9 */
534 "", /* 0xea */
535 "", /* 0xeb */
536 "", /* 0xec */
537 "", /* 0xed */
538 "", /* 0xee */
539 "", /* 0xef */
540 "", /* 0xf0 */
541 "", /* 0xf1 */
542 "", /* 0xf2 */
543 "", /* 0xf3 */
544 "", /* 0xf4 */
545 "", /* 0xf5 */
546 "", /* 0xf6 */
547 "", /* 0xf7 */
548 "", /* 0xf8 */
549 "", /* 0xf9 */
550 "", /* 0xfa */
551 "", /* 0xfb */
552 "", /* 0xfc */
553 "", /* 0xfd */
554 "", /* 0xfe */
555 "" /* 0xff */
556};
557
558static const char * const g_apszSCSISenseNames[] =
559{
560 "NO SENSE",
561 "RECOVERED ERROR",
562 "NOT READY",
563 "MEDIUM ERROR",
564 "HARDWARE ERROR",
565 "ILLEGAL REQUEST",
566 "UNIT ATTENTION",
567 "DATA PROTECT",
568 "BLANK CHECK",
569 "VENDOR-SPECIFIC",
570 "COPY ABORTED",
571 "ABORTED COMMAND",
572 "(obsolete)",
573 "VOLUME OVERFLOW",
574 "MISCOMPARE",
575 "(reserved)"
576};
577
578/**
579 * SCSI Sense text
580 */
581static struct
582{
583 uint8_t uASC;
584 uint8_t uASCQ;
585 const char * const pszSenseText;
586} g_aSCSISenseText[]
587=
588{
589 { 0x67, 0x02, "A ADD LOGICAL UNIT FAILED" },
590 { 0x13, 0x00, "ADDRESS MARK NOT FOUND FOR DATA FIELD" },
591 { 0x12, 0x00, "ADDRESS MARK NOT FOUND FOR ID FIELD" },
592 { 0x27, 0x03, "ASSOCIATED WRITE PROTECT" },
593 { 0x67, 0x06, "ATTACHMENT OF LOGICAL UNIT FAILED" },
594 { 0x00, 0x11, "AUDIO PLAY OPERATION IN PROGRESS" },
595 { 0x00, 0x12, "AUDIO PLAY OPERATION PAUSED" },
596 { 0x00, 0x14, "AUDIO PLAY OPERATION STOPPED DUE TO ERROR" },
597 { 0x00, 0x13, "AUDIO PLAY OPERATION SUCCESSFULLY COMPLETED" },
598 { 0x66, 0x00, "AUTOMATIC DOCUMENT FEEDER COVER UP" },
599 { 0x66, 0x01, "AUTOMATIC DOCUMENT FEEDER LIFT UP" },
600 { 0x00, 0x04, "BEGINNING-OF-PARTITION/MEDIUM DETECTED" },
601 { 0x0C, 0x06, "BLOCK NOT COMPRESSIBLE" },
602 { 0x14, 0x04, "BLOCK SEQUENCE ERROR" },
603 { 0x29, 0x03, "BUS DEVICE RESET FUNCTION OCCURRED" },
604 { 0x11, 0x0E, "CANNOT DECOMPRESS USING DECLARED ALGORITHM" },
605 { 0x30, 0x06, "CANNOT FORMAT MEDIUM - INCOMPATIBLE MEDIUM" },
606 { 0x30, 0x02, "CANNOT READ MEDIUM - INCOMPATIBLE FORMAT" },
607 { 0x30, 0x01, "CANNOT READ MEDIUM - UNKNOWN FORMAT" },
608 { 0x30, 0x08, "CANNOT WRITE - APPLICATION CODE MISMATCH" },
609 { 0x30, 0x05, "CANNOT WRITE MEDIUM - INCOMPATIBLE FORMAT" },
610 { 0x30, 0x04, "CANNOT WRITE MEDIUM - UNKNOWN FORMAT" },
611 { 0x52, 0x00, "CARTRIDGE FAULT" },
612 { 0x73, 0x00, "CD CONTROL ERROR" },
613 { 0x3F, 0x02, "CHANGED OPERATING DEFINITION" },
614 { 0x11, 0x06, "CIRC UNRECOVERED ERROR" },
615 { 0x30, 0x03, "CLEANING CARTRIDGE INSTALLED" },
616 { 0x30, 0x07, "CLEANING FAILURE" },
617 { 0x00, 0x17, "CLEANING REQUESTED" },
618 { 0x4A, 0x00, "COMMAND PHASE ERROR" },
619 { 0x2C, 0x00, "COMMAND SEQUENCE ERROR" },
620 { 0x6E, 0x00, "COMMAND TO LOGICAL UNIT FAILED" },
621 { 0x2F, 0x00, "COMMANDS CLEARED BY ANOTHER INITIATOR" },
622 { 0x0C, 0x04, "COMPRESSION CHECK MISCOMPARE ERROR" },
623 { 0x67, 0x00, "CONFIGURATION FAILURE" },
624 { 0x67, 0x01, "CONFIGURATION OF INCAPABLE LOGICAL UNITS FAILED" },
625 { 0x2B, 0x00, "COPY CANNOT EXECUTE SINCE HOST CANNOT DISCONNECT" },
626 { 0x67, 0x07, "CREATION OF LOGICAL UNIT FAILED" },
627 { 0x2C, 0x04, "CURRENT PROGRAM AREA IS EMPTY" },
628 { 0x2C, 0x03, "CURRENT PROGRAM AREA IS NOT EMPTY" },
629 { 0x30, 0x09, "CURRENT SESSION NOT FIXATED FOR APPEND" },
630 { 0x0C, 0x05, "DATA EXPANSION OCCURRED DURING COMPRESSION" },
631 { 0x69, 0x00, "DATA LOSS ON LOGICAL UNIT" },
632 { 0x41, 0x00, "DATA PATH FAILURE (SHOULD USE 40 NN)" },
633 { 0x4B, 0x00, "DATA PHASE ERROR" },
634 { 0x11, 0x07, "DATA RE-SYNCHRONIZATION ERROR" },
635 { 0x16, 0x03, "DATA SYNC ERROR - DATA AUTO-REALLOCATED" },
636 { 0x16, 0x01, "DATA SYNC ERROR - DATA REWRITTEN" },
637 { 0x16, 0x04, "DATA SYNC ERROR - RECOMMEND REASSIGNMENT" },
638 { 0x16, 0x02, "DATA SYNC ERROR - RECOMMEND REWRITE" },
639 { 0x16, 0x00, "DATA SYNCHRONIZATION MARK ERROR" },
640 { 0x11, 0x0D, "DE-COMPRESSION CRC ERROR" },
641 { 0x71, 0x00, "DECOMPRESSION EXCEPTION LONG ALGORITHM ID" },
642 { 0x70, 0xFF, "DECOMPRESSION EXCEPTION SHORT ALGORITHM ID OF NN" },
643 { 0x19, 0x00, "DEFECT LIST ERROR" },
644 { 0x19, 0x03, "DEFECT LIST ERROR IN GROWN LIST" },
645 { 0x19, 0x02, "DEFECT LIST ERROR IN PRIMARY LIST" },
646 { 0x19, 0x01, "DEFECT LIST NOT AVAILABLE" },
647 { 0x1C, 0x00, "DEFECT LIST NOT FOUND" },
648 { 0x32, 0x01, "DEFECT LIST UPDATE FAILURE" },
649 { 0x29, 0x04, "DEVICE INTERNAL RESET" },
650 { 0x40, 0xFF, "DIAGNOSTIC FAILURE ON COMPONENT NN (80H-FFH)" },
651 { 0x66, 0x02, "DOCUMENT JAM IN AUTOMATIC DOCUMENT FEEDER" },
652 { 0x66, 0x03, "DOCUMENT MISS FEED AUTOMATIC IN DOCUMENT FEEDER" },
653 { 0x72, 0x04, "EMPTY OR PARTIALLY WRITTEN RESERVED TRACK" },
654 { 0x34, 0x00, "ENCLOSURE FAILURE" },
655 { 0x35, 0x00, "ENCLOSURE SERVICES FAILURE" },
656 { 0x35, 0x03, "ENCLOSURE SERVICES TRANSFER FAILURE" },
657 { 0x35, 0x04, "ENCLOSURE SERVICES TRANSFER REFUSED" },
658 { 0x35, 0x02, "ENCLOSURE SERVICES UNAVAILABLE" },
659 { 0x3B, 0x0F, "END OF MEDIUM REACHED" },
660 { 0x63, 0x00, "END OF USER AREA ENCOUNTERED ON THIS TRACK" },
661 { 0x00, 0x05, "END-OF-DATA DETECTED" },
662 { 0x14, 0x03, "END-OF-DATA NOT FOUND" },
663 { 0x00, 0x02, "END-OF-PARTITION/MEDIUM DETECTED" },
664 { 0x51, 0x00, "ERASE FAILURE" },
665 { 0x0A, 0x00, "ERROR LOG OVERFLOW" },
666 { 0x11, 0x10, "ERROR READING ISRC NUMBER" },
667 { 0x11, 0x0F, "ERROR READING UPC/EAN NUMBER" },
668 { 0x11, 0x02, "ERROR TOO LONG TO CORRECT" },
669 { 0x03, 0x02, "EXCESSIVE WRITE ERRORS" },
670 { 0x67, 0x04, "EXCHANGE OF LOGICAL UNIT FAILED" },
671 { 0x3B, 0x07, "FAILED TO SENSE BOTTOM-OF-FORM" },
672 { 0x3B, 0x06, "FAILED TO SENSE TOP-OF-FORM" },
673 { 0x5D, 0x00, "FAILURE PREDICTION THRESHOLD EXCEEDED" },
674 { 0x5D, 0xFF, "FAILURE PREDICTION THRESHOLD EXCEEDED (FALSE)" },
675 { 0x00, 0x01, "FILEMARK DETECTED" },
676 { 0x14, 0x02, "FILEMARK OR SETMARK NOT FOUND" },
677 { 0x09, 0x02, "FOCUS SERVO FAILURE" },
678 { 0x31, 0x01, "FORMAT COMMAND FAILED" },
679 { 0x58, 0x00, "GENERATION DOES NOT EXIST" },
680 { 0x1C, 0x02, "GROWN DEFECT LIST NOT FOUND" },
681 { 0x27, 0x01, "HARDWARE WRITE PROTECTED" },
682 { 0x09, 0x04, "HEAD SELECT FAULT" },
683 { 0x00, 0x06, "I/O PROCESS TERMINATED" },
684 { 0x10, 0x00, "ID CRC OR ECC ERROR" },
685 { 0x5E, 0x03, "IDLE CONDITION ACTIVATED BY COMMAND" },
686 { 0x5E, 0x01, "IDLE CONDITION ACTIVATED BY TIMER" },
687 { 0x22, 0x00, "ILLEGAL FUNCTION (USE 20 00, 24 00, OR 26 00)" },
688 { 0x64, 0x00, "ILLEGAL MODE FOR THIS TRACK" },
689 { 0x28, 0x01, "IMPORT OR EXPORT ELEMENT ACCESSED" },
690 { 0x30, 0x00, "INCOMPATIBLE MEDIUM INSTALLED" },
691 { 0x11, 0x08, "INCOMPLETE BLOCK READ" },
692 { 0x6A, 0x00, "INFORMATIONAL, REFER TO LOG" },
693 { 0x48, 0x00, "INITIATOR DETECTED ERROR MESSAGE RECEIVED" },
694 { 0x3F, 0x03, "INQUIRY DATA HAS CHANGED" },
695 { 0x44, 0x00, "INTERNAL TARGET FAILURE" },
696 { 0x3D, 0x00, "INVALID BITS IN IDENTIFY MESSAGE" },
697 { 0x2C, 0x02, "INVALID COMBINATION OF WINDOWS SPECIFIED" },
698 { 0x20, 0x00, "INVALID COMMAND OPERATION CODE" },
699 { 0x21, 0x01, "INVALID ELEMENT ADDRESS" },
700 { 0x24, 0x00, "INVALID FIELD IN CDB" },
701 { 0x26, 0x00, "INVALID FIELD IN PARAMETER LIST" },
702 { 0x49, 0x00, "INVALID MESSAGE ERROR" },
703 { 0x64, 0x01, "INVALID PACKET SIZE" },
704 { 0x26, 0x04, "INVALID RELEASE OF ACTIVE PERSISTENT RESERVATION" },
705 { 0x11, 0x05, "L-EC UNCORRECTABLE ERROR" },
706 { 0x60, 0x00, "LAMP FAILURE" },
707 { 0x5B, 0x02, "LOG COUNTER AT MAXIMUM" },
708 { 0x5B, 0x00, "LOG EXCEPTION" },
709 { 0x5B, 0x03, "LOG LIST CODES EXHAUSTED" },
710 { 0x2A, 0x02, "LOG PARAMETERS CHANGED" },
711 { 0x21, 0x00, "LOGICAL BLOCK ADDRESS OUT OF RANGE" },
712 { 0x08, 0x03, "LOGICAL UNIT COMMUNICATION CRC ERROR (ULTRA-DMA/32)" },
713 { 0x08, 0x00, "LOGICAL UNIT COMMUNICATION FAILURE" },
714 { 0x08, 0x02, "LOGICAL UNIT COMMUNICATION PARITY ERROR" },
715 { 0x08, 0x01, "LOGICAL UNIT COMMUNICATION TIME-OUT" },
716 { 0x05, 0x00, "LOGICAL UNIT DOES NOT RESPOND TO SELECTION" },
717 { 0x4C, 0x00, "LOGICAL UNIT FAILED SELF-CONFIGURATION" },
718 { 0x3E, 0x01, "LOGICAL UNIT FAILURE" },
719 { 0x3E, 0x00, "LOGICAL UNIT HAS NOT SELF-CONFIGURED YET" },
720 { 0x04, 0x01, "LOGICAL UNIT IS IN PROCESS OF BECOMING READY" },
721 { 0x68, 0x00, "LOGICAL UNIT NOT CONFIGURED" },
722 { 0x04, 0x00, "LOGICAL UNIT NOT READY, CAUSE NOT REPORTABLE" },
723 { 0x04, 0x04, "LOGICAL UNIT NOT READY, FORMAT IN PROGRESS" },
724 { 0x04, 0x02, "LOGICAL UNIT NOT READY, INITIALIZING CMD. REQUIRED" },
725 { 0x04, 0x08, "LOGICAL UNIT NOT READY, LONG WRITE IN PROGRESS" },
726 { 0x04, 0x03, "LOGICAL UNIT NOT READY, MANUAL INTERVENTION REQUIRED" },
727 { 0x04, 0x07, "LOGICAL UNIT NOT READY, OPERATION IN PROGRESS" },
728 { 0x04, 0x05, "LOGICAL UNIT NOT READY, REBUILD IN PROGRESS" },
729 { 0x04, 0x06, "LOGICAL UNIT NOT READY, RECALCULATION IN PROGRESS" },
730 { 0x25, 0x00, "LOGICAL UNIT NOT SUPPORTED" },
731 { 0x27, 0x02, "LOGICAL UNIT SOFTWARE WRITE PROTECTED" },
732 { 0x5E, 0x00, "LOW POWER CONDITION ON" },
733 { 0x15, 0x01, "MECHANICAL POSITIONING ERROR" },
734 { 0x53, 0x00, "MEDIA LOAD OR EJECT FAILED" },
735 { 0x3B, 0x0D, "MEDIUM DESTINATION ELEMENT FULL" },
736 { 0x31, 0x00, "MEDIUM FORMAT CORRUPTED" },
737 { 0x3B, 0x13, "MEDIUM MAGAZINE INSERTED" },
738 { 0x3B, 0x14, "MEDIUM MAGAZINE LOCKED" },
739 { 0x3B, 0x11, "MEDIUM MAGAZINE NOT ACCESSIBLE" },
740 { 0x3B, 0x12, "MEDIUM MAGAZINE REMOVED" },
741 { 0x3B, 0x15, "MEDIUM MAGAZINE UNLOCKED" },
742 { 0x3A, 0x00, "MEDIUM NOT PRESENT" },
743 { 0x3A, 0x01, "MEDIUM NOT PRESENT - TRAY CLOSED" },
744 { 0x3A, 0x02, "MEDIUM NOT PRESENT - TRAY OPEN" },
745 { 0x53, 0x02, "MEDIUM REMOVAL PREVENTED" },
746 { 0x3B, 0x0E, "MEDIUM SOURCE ELEMENT EMPTY" },
747 { 0x43, 0x00, "MESSAGE ERROR" },
748 { 0x3F, 0x01, "MICROCODE HAS BEEN CHANGED" },
749 { 0x1D, 0x00, "MISCOMPARE DURING VERIFY OPERATION" },
750 { 0x11, 0x0A, "MISCORRECTED ERROR" },
751 { 0x2A, 0x01, "MODE PARAMETERS CHANGED" },
752 { 0x67, 0x03, "MODIFICATION OF LOGICAL UNIT FAILED" },
753 { 0x69, 0x01, "MULTIPLE LOGICAL UNIT FAILURES" },
754 { 0x07, 0x00, "MULTIPLE PERIPHERAL DEVICES SELECTED" },
755 { 0x11, 0x03, "MULTIPLE READ ERRORS" },
756 { 0x00, 0x00, "NO ADDITIONAL SENSE INFORMATION" },
757 { 0x00, 0x15, "NO CURRENT AUDIO STATUS TO RETURN" },
758 { 0x32, 0x00, "NO DEFECT SPARE LOCATION AVAILABLE" },
759 { 0x11, 0x09, "NO GAP FOUND" },
760 { 0x01, 0x00, "NO INDEX/SECTOR SIGNAL" },
761 { 0x06, 0x00, "NO REFERENCE POSITION FOUND" },
762 { 0x02, 0x00, "NO SEEK COMPLETE" },
763 { 0x03, 0x01, "NO WRITE CURRENT" },
764 { 0x28, 0x00, "NOT READY TO READY CHANGE, MEDIUM MAY HAVE CHANGED" },
765 { 0x00, 0x16, "OPERATION IN PROGRESS" },
766 { 0x5A, 0x01, "OPERATOR MEDIUM REMOVAL REQUEST" },
767 { 0x5A, 0x00, "OPERATOR REQUEST OR STATE CHANGE INPUT" },
768 { 0x5A, 0x03, "OPERATOR SELECTED WRITE PERMIT" },
769 { 0x5A, 0x02, "OPERATOR SELECTED WRITE PROTECT" },
770 { 0x61, 0x02, "OUT OF FOCUS" },
771 { 0x4E, 0x00, "OVERLAPPED COMMANDS ATTEMPTED" },
772 { 0x2D, 0x00, "OVERWRITE ERROR ON UPDATE IN PLACE" },
773 { 0x63, 0x01, "PACKET DOES NOT FIT IN AVAILABLE SPACE" },
774 { 0x3B, 0x05, "PAPER JAM" },
775 { 0x1A, 0x00, "PARAMETER LIST LENGTH ERROR" },
776 { 0x26, 0x01, "PARAMETER NOT SUPPORTED" },
777 { 0x26, 0x02, "PARAMETER VALUE INVALID" },
778 { 0x2A, 0x00, "PARAMETERS CHANGED" },
779 { 0x69, 0x02, "PARITY/DATA MISMATCH" },
780 { 0x1F, 0x00, "PARTIAL DEFECT LIST TRANSFER" },
781 { 0x03, 0x00, "PERIPHERAL DEVICE WRITE FAULT" },
782 { 0x27, 0x05, "PERMANENT WRITE PROTECT" },
783 { 0x27, 0x04, "PERSISTENT WRITE PROTECT" },
784 { 0x50, 0x02, "POSITION ERROR RELATED TO TIMING" },
785 { 0x3B, 0x0C, "POSITION PAST BEGINNING OF MEDIUM" },
786 { 0x3B, 0x0B, "POSITION PAST END OF MEDIUM" },
787 { 0x15, 0x02, "POSITIONING ERROR DETECTED BY READ OF MEDIUM" },
788 { 0x73, 0x01, "POWER CALIBRATION AREA ALMOST FULL" },
789 { 0x73, 0x03, "POWER CALIBRATION AREA ERROR" },
790 { 0x73, 0x02, "POWER CALIBRATION AREA IS FULL" },
791 { 0x29, 0x01, "POWER ON OCCURRED" },
792 { 0x29, 0x00, "POWER ON, RESET, OR BUS DEVICE RESET OCCURRED" },
793 { 0x42, 0x00, "POWER-ON OR SELF-TEST FAILURE (SHOULD USE 40 NN)" },
794 { 0x1C, 0x01, "PRIMARY DEFECT LIST NOT FOUND" },
795 { 0x73, 0x05, "PROGRAM MEMORY AREA IS FULL" },
796 { 0x73, 0x04, "PROGRAM MEMORY AREA UPDATE FAILURE" },
797 { 0x40, 0x00, "RAM FAILURE (SHOULD USE 40 NN)" },
798 { 0x15, 0x00, "RANDOM POSITIONING ERROR" },
799 { 0x11, 0x11, "READ ERROR - LOSS OF STREAMING" },
800 { 0x3B, 0x0A, "READ PAST BEGINNING OF MEDIUM" },
801 { 0x3B, 0x09, "READ PAST END OF MEDIUM" },
802 { 0x11, 0x01, "READ RETRIES EXHAUSTED" },
803 { 0x6C, 0x00, "REBUILD FAILURE OCCURRED" },
804 { 0x6D, 0x00, "RECALCULATE FAILURE OCCURRED" },
805 { 0x14, 0x01, "RECORD NOT FOUND" },
806 { 0x14, 0x06, "RECORD NOT FOUND - DATA AUTO-REALLOCATED" },
807 { 0x14, 0x05, "RECORD NOT FOUND - RECOMMEND REASSIGNMENT" },
808 { 0x14, 0x00, "RECORDED ENTITY NOT FOUND" },
809 { 0x18, 0x02, "RECOVERED DATA - DATA AUTO-REALLOCATED" },
810 { 0x18, 0x05, "RECOVERED DATA - RECOMMEND REASSIGNMENT" },
811 { 0x18, 0x06, "RECOVERED DATA - RECOMMEND REWRITE" },
812 { 0x17, 0x05, "RECOVERED DATA USING PREVIOUS SECTOR ID" },
813 { 0x18, 0x03, "RECOVERED DATA WITH CIRC" },
814 { 0x18, 0x07, "RECOVERED DATA WITH ECC - DATA REWRITTEN" },
815 { 0x18, 0x01, "RECOVERED DATA WITH ERROR CORR. & RETRIES APPLIED" },
816 { 0x18, 0x00, "RECOVERED DATA WITH ERROR CORRECTION APPLIED" },
817 { 0x18, 0x04, "RECOVERED DATA WITH L-EC" },
818 { 0x17, 0x03, "RECOVERED DATA WITH NEGATIVE HEAD OFFSET" },
819 { 0x17, 0x00, "RECOVERED DATA WITH NO ERROR CORRECTION APPLIED" },
820 { 0x17, 0x02, "RECOVERED DATA WITH POSITIVE HEAD OFFSET" },
821 { 0x17, 0x01, "RECOVERED DATA WITH RETRIES" },
822 { 0x17, 0x04, "RECOVERED DATA WITH RETRIES AND/OR CIRC APPLIED" },
823 { 0x17, 0x06, "RECOVERED DATA WITHOUT ECC - DATA AUTO-REALLOCATED" },
824 { 0x17, 0x09, "RECOVERED DATA WITHOUT ECC - DATA REWRITTEN" },
825 { 0x17, 0x07, "RECOVERED DATA WITHOUT ECC - RECOMMEND REASSIGNMENT" },
826 { 0x17, 0x08, "RECOVERED DATA WITHOUT ECC - RECOMMEND REWRITE" },
827 { 0x1E, 0x00, "RECOVERED ID WITH ECC CORRECTION" },
828 { 0x6B, 0x01, "REDUNDANCY LEVEL GOT BETTER" },
829 { 0x6B, 0x02, "REDUNDANCY LEVEL GOT WORSE" },
830 { 0x67, 0x05, "REMOVE OF LOGICAL UNIT FAILED" },
831 { 0x3B, 0x08, "REPOSITION ERROR" },
832 { 0x2A, 0x03, "RESERVATIONS PREEMPTED" },
833 { 0x36, 0x00, "RIBBON, INK, OR TONER FAILURE" },
834 { 0x37, 0x00, "ROUNDED PARAMETER" },
835 { 0x5C, 0x00, "RPL STATUS CHANGE" },
836 { 0x39, 0x00, "SAVING PARAMETERS NOT SUPPORTED" },
837 { 0x62, 0x00, "SCAN HEAD POSITIONING ERROR" },
838 { 0x29, 0x02, "SCSI BUS RESET OCCURRED" },
839 { 0x47, 0x00, "SCSI PARITY ERROR" },
840 { 0x54, 0x00, "SCSI TO HOST SYSTEM INTERFACE FAILURE" },
841 { 0x45, 0x00, "SELECT OR RESELECT FAILURE" },
842 { 0x3B, 0x00, "SEQUENTIAL POSITIONING ERROR" },
843 { 0x72, 0x00, "SESSION FIXATION ERROR" },
844 { 0x72, 0x03, "SESSION FIXATION ERROR - INCOMPLETE TRACK IN SESSION" },
845 { 0x72, 0x01, "SESSION FIXATION ERROR WRITING LEAD-IN" },
846 { 0x72, 0x02, "SESSION FIXATION ERROR WRITING LEAD-OUT" },
847 { 0x00, 0x03, "SETMARK DETECTED" },
848 { 0x3B, 0x04, "SLEW FAILURE" },
849 { 0x09, 0x03, "SPINDLE SERVO FAILURE" },
850 { 0x5C, 0x02, "SPINDLES NOT SYNCHRONIZED" },
851 { 0x5C, 0x01, "SPINDLES SYNCHRONIZED" },
852 { 0x5E, 0x04, "STANDBY CONDITION ACTIVATED BY COMMAND" },
853 { 0x5E, 0x02, "STANDBY CONDITION ACTIVATED BY TIMER" },
854 { 0x6B, 0x00, "STATE CHANGE HAS OCCURRED" },
855 { 0x1B, 0x00, "SYNCHRONOUS DATA TRANSFER ERROR" },
856 { 0x55, 0x01, "SYSTEM BUFFER FULL" },
857 { 0x55, 0x00, "SYSTEM RESOURCE FAILURE" },
858 { 0x4D, 0xFF, "TAGGED OVERLAPPED COMMANDS (NN = QUEUE TAG)" },
859 { 0x33, 0x00, "TAPE LENGTH ERROR" },
860 { 0x3B, 0x03, "TAPE OR ELECTRONIC VERTICAL FORMS UNIT NOT READY" },
861 { 0x3B, 0x01, "TAPE POSITION ERROR AT BEGINNING-OF-MEDIUM" },
862 { 0x3B, 0x02, "TAPE POSITION ERROR AT END-OF-MEDIUM" },
863 { 0x3F, 0x00, "TARGET OPERATING CONDITIONS HAVE CHANGED" },
864 { 0x5B, 0x01, "THRESHOLD CONDITION MET" },
865 { 0x26, 0x03, "THRESHOLD PARAMETERS NOT SUPPORTED" },
866 { 0x3E, 0x02, "TIMEOUT ON LOGICAL UNIT" },
867 { 0x2C, 0x01, "TOO MANY WINDOWS SPECIFIED" },
868 { 0x09, 0x00, "TRACK FOLLOWING ERROR" },
869 { 0x09, 0x01, "TRACKING SERVO FAILURE" },
870 { 0x61, 0x01, "UNABLE TO ACQUIRE VIDEO" },
871 { 0x57, 0x00, "UNABLE TO RECOVER TABLE-OF-CONTENTS" },
872 { 0x53, 0x01, "UNLOAD TAPE FAILURE" },
873 { 0x11, 0x00, "UNRECOVERED READ ERROR" },
874 { 0x11, 0x04, "UNRECOVERED READ ERROR - AUTO REALLOCATE FAILED" },
875 { 0x11, 0x0B, "UNRECOVERED READ ERROR - RECOMMEND REASSIGNMENT" },
876 { 0x11, 0x0C, "UNRECOVERED READ ERROR - RECOMMEND REWRITE THE DATA" },
877 { 0x46, 0x00, "UNSUCCESSFUL SOFT RESET" },
878 { 0x35, 0x01, "UNSUPPORTED ENCLOSURE FUNCTION" },
879 { 0x59, 0x00, "UPDATED BLOCK READ" },
880 { 0x61, 0x00, "VIDEO ACQUISITION ERROR" },
881 { 0x65, 0x00, "VOLTAGE FAULT" },
882 { 0x0B, 0x00, "WARNING" },
883 { 0x0B, 0x02, "WARNING - ENCLOSURE DEGRADED" },
884 { 0x0B, 0x01, "WARNING - SPECIFIED TEMPERATURE EXCEEDED" },
885 { 0x50, 0x00, "WRITE APPEND ERROR" },
886 { 0x50, 0x01, "WRITE APPEND POSITION ERROR" },
887 { 0x0C, 0x00, "WRITE ERROR" },
888 { 0x0C, 0x02, "WRITE ERROR - AUTO REALLOCATION FAILED" },
889 { 0x0C, 0x09, "WRITE ERROR - LOSS OF STREAMING" },
890 { 0x0C, 0x0A, "WRITE ERROR - PADDING BLOCKS ADDED" },
891 { 0x0C, 0x03, "WRITE ERROR - RECOMMEND REASSIGNMENT" },
892 { 0x0C, 0x01, "WRITE ERROR - RECOVERED WITH AUTO REALLOCATION" },
893 { 0x0C, 0x08, "WRITE ERROR - RECOVERY FAILED" },
894 { 0x0C, 0x07, "WRITE ERROR - RECOVERY NEEDED" },
895 { 0x27, 0x00, "WRITE PROTECTED" },
896};
897
898#endif /* LOG_ENABLED || RT_STRICT */
899
900#ifdef LOG_ENABLED
901
902/**
903 * Return the plain text of an ATA command for debugging purposes.
904 * Don't allocate the string as we use this function in Log() statements.
905 */
906const char * ATACmdText(uint8_t uCmd)
907{
908 AssertCompile(RT_ELEMENTS(g_apszATACmdNames) == (1 << (8*sizeof(uCmd))));
909 return g_apszATACmdNames[uCmd];
910}
911
912#endif
913
914#if defined(LOG_ENABLED) || defined(RT_STRICT)
915
916/**
917 * Return the plain text of a SCSI command for debugging purposes.
918 * Don't allocate the string as we use this function in Log() statements.
919 */
920const char * SCSICmdText(uint8_t uCmd)
921{
922 AssertCompile(RT_ELEMENTS(g_apszSCSICmdNames) == (1 << (8*sizeof(uCmd))));
923 return g_apszSCSICmdNames[uCmd];
924}
925
926/**
927 * Return the plain text of a SCSI sense code.
928 * Don't allocate the string as we use this function in Log() statements.
929 */
930const char * SCSISenseText(uint8_t uSense)
931{
932 if (uSense < RT_ELEMENTS(g_apszSCSISenseNames))
933 return g_apszSCSISenseNames[uSense];
934
935 return "(SCSI sense out of range)";
936}
937
938/**
939 * Return the plain text of an extended SCSI sense key.
940 * Don't allocate the string as we use this function in Log() statements.
941 */
942const char * SCSISenseExtText(uint8_t uASC, uint8_t uASCQ)
943{
944 unsigned iIdx;
945
946 /* Linear search. Doesn't hurt as we don't call this function very frequently */
947 for (iIdx = 0; iIdx < RT_ELEMENTS(g_aSCSISenseText); iIdx++)
948 {
949 if ( g_aSCSISenseText[iIdx].uASC == uASC
950 && ( g_aSCSISenseText[iIdx].uASCQ == uASCQ
951 || g_aSCSISenseText[iIdx].uASCQ == 0xff))
952 return g_aSCSISenseText[iIdx].pszSenseText;
953 }
954 return "(Unknown extended sense code)";
955}
956
957/**
958 * Log the write parameters mode page into a given buffer.
959 */
960static int scsiLogWriteParamsModePage(char *pszBuffer, size_t cchBuffer, uint8_t *pbModePage, size_t cbModePage)
961{
962 RT_NOREF(cbModePage);
963 size_t cch = 0;
964 const char *pcsz = NULL;
965
966 switch (pbModePage[2] & 0x0f)
967 {
968 case 0x00: pcsz = "Packet/Incremental"; break;
969 case 0x01: pcsz = "Track At Once"; break;
970 case 0x02: pcsz = "Session At Once"; break;
971 case 0x03: pcsz = "RAW"; break;
972 case 0x04: pcsz = "Layer Jump Recording"; break;
973 default : pcsz = "Unknown/Reserved Write Type"; break;
974 }
975
976 cch = RTStrPrintf(pszBuffer, cchBuffer, "BUFE=%d LS_V=%d TestWrite=%d WriteType=%s\n",
977 pbModePage[2] & RT_BIT(6) ? 1 : 0,
978 pbModePage[2] & RT_BIT(5) ? 1 : 0,
979 pbModePage[2] & RT_BIT(4) ? 1 : 0,
980 pcsz);
981 pszBuffer += cch;
982 cchBuffer -= cch;
983 if (!cchBuffer)
984 return VERR_BUFFER_OVERFLOW;
985
986 switch ((pbModePage[3] & 0xc0) >> 6)
987 {
988 case 0x00: pcsz = "No B0 pointer, no next session"; break;
989 case 0x01: pcsz = "B0 pointer=FF:FF:FF, no next session"; break;
990 case 0x02: pcsz = "Reserved"; break;
991 case 0x03: pcsz = "Next session allowed"; break;
992 default: pcsz = "Impossible multi session field value"; break;
993 }
994
995 cch = RTStrPrintf(pszBuffer, cchBuffer, "MultiSession=%s FP=%d Copy=%d TrackMode=%d\n",
996 pcsz,
997 pbModePage[3] & RT_BIT(5) ? 1 : 0,
998 pbModePage[3] & RT_BIT(4) ? 1 : 0,
999 pbModePage[3] & 0x0f);
1000 pszBuffer += cch;
1001 cchBuffer -= cch;
1002 if (!cchBuffer)
1003 return VERR_BUFFER_OVERFLOW;
1004
1005 switch (pbModePage[4] & 0x0f)
1006 {
1007 case 0: pcsz = "Raw data (2352)"; break;
1008 case 1: pcsz = "Raw data with P and Q Sub-channel (2368)"; break;
1009 case 2: pcsz = "Raw data with P-W Sub-channel (2448)"; break;
1010 case 3: pcsz = "Raw data with raw P-W Sub-channel (2448)"; break;
1011 case 8: pcsz = "Mode 1 (ISO/IEC 10149) (2048)"; break;
1012 case 9: pcsz = "Mode 2 (ISO/IEC 10149) (2336)"; break;
1013 case 10: pcsz = "Mode 2 (CD-ROM XA, form 1) (2048)"; break;
1014 case 11: pcsz = "Mode 2 (CD-ROM XA, form 1) (2056)"; break;
1015 case 12: pcsz = "Mode 2 (CD-ROM XA, form 2) (2324)"; break;
1016 case 13: pcsz = "Mode 2 (CD-ROM XA, form 1, form 2 or mixed form) (2332)"; break;
1017 default: pcsz = "Reserved or vendor specific Data Block Type Code"; break;
1018 }
1019
1020 cch = RTStrPrintf(pszBuffer, cchBuffer, "DataBlockType=%d (%s)\n",
1021 pbModePage[4] & 0x0f,
1022 pcsz);
1023 pszBuffer += cch;
1024 cchBuffer -= cch;
1025 if (!cchBuffer)
1026 return VERR_BUFFER_OVERFLOW;
1027
1028 cch = RTStrPrintf(pszBuffer, cchBuffer, "LinkSize=%d\n", pbModePage[5]);
1029 pszBuffer += cch;
1030 cchBuffer -= cch;
1031 if (!cchBuffer)
1032 return VERR_BUFFER_OVERFLOW;
1033
1034 cch = RTStrPrintf(pszBuffer, cchBuffer, "HostApplicationCode=%d\n",
1035 pbModePage[7] & 0x3f);
1036 pszBuffer += cch;
1037 cchBuffer -= cch;
1038 if (!cchBuffer)
1039 return VERR_BUFFER_OVERFLOW;
1040
1041 switch (pbModePage[8])
1042 {
1043 case 0x00: pcsz = "CD-DA or CD-ROM or other data discs"; break;
1044 case 0x10: pcsz = "CD-I Disc"; break;
1045 case 0x20: pcsz = "CD-ROM XA Disc"; break;
1046 default: pcsz = "Reserved"; break;
1047 }
1048
1049 cch = RTStrPrintf(pszBuffer, cchBuffer, "SessionFormat=%d (%s)\n",
1050 pbModePage[8], pcsz);
1051 pszBuffer += cch;
1052 cchBuffer -= cch;
1053 if (!cchBuffer)
1054 return VERR_BUFFER_OVERFLOW;
1055
1056 return VINF_SUCCESS;
1057}
1058
1059/**
1060 * Log a mode page in a human readable form.
1061 *
1062 * @returns VBox status code.
1063 * @retval VERR_BUFFER_OVERFLOW if the given buffer is not large enough.
1064 * The buffer might contain valid data though.
1065 * @param pszBuffer The buffer to log into.
1066 * @param cchBuffer Size of the buffer in characters.
1067 * @param pbModePage The mode page buffer.
1068 * @param cbModePage Size of the mode page buffer in bytes.
1069 */
1070int SCSILogModePage(char *pszBuffer, size_t cchBuffer, uint8_t *pbModePage,
1071 size_t cbModePage)
1072{
1073 int rc = VINF_SUCCESS;
1074 uint8_t uModePage;
1075 const char *pcszModePage = NULL;
1076 size_t cch = 0;
1077
1078 uModePage = pbModePage[0] & 0x3f;
1079 switch (uModePage)
1080 {
1081 case 0x05: pcszModePage = "Write Parameters"; break;
1082 default:
1083 pcszModePage = "Unknown mode page";
1084 }
1085
1086 cch = RTStrPrintf(pszBuffer, cchBuffer, "Byte 0: PS=%d, Page code=%d (%s)\n",
1087 pbModePage[0] & 0x80 ? 1 : 0, uModePage, pcszModePage);
1088 pszBuffer += cch;
1089 cchBuffer -= cch;
1090 if (!cchBuffer)
1091 return VERR_BUFFER_OVERFLOW;
1092
1093 cch = RTStrPrintf(pszBuffer, cchBuffer, "Byte 1: Page length=%u\n", pbModePage[1]);
1094 pszBuffer += cch;
1095 cchBuffer -= cch;
1096 if (!cchBuffer)
1097 return VERR_BUFFER_OVERFLOW;
1098
1099 switch (uModePage)
1100 {
1101 case 0x05:
1102 rc = scsiLogWriteParamsModePage(pszBuffer, cchBuffer, pbModePage, cbModePage);
1103 break;
1104 default:
1105 break;
1106 }
1107
1108 return rc;
1109}
1110
1111/**
1112 * Log a cue sheet in a human readable form.
1113 *
1114 * @returns VBox status code.
1115 * @retval VERR_BUFFER_OVERFLOW if the given buffer is not large enough.
1116 * The buffer might contain valid data though.
1117 * @param pszBuffer The buffer to log into.
1118 * @param cchBuffer Size of the buffer in characters.
1119 * @param pbCueSheet The cue sheet buffer.
1120 * @param cbCueSheet Size of the cue sheet buffer in bytes.
1121 */
1122int SCSILogCueSheet(char *pszBuffer, size_t cchBuffer, uint8_t *pbCueSheet, size_t cbCueSheet)
1123{
1124 int rc = VINF_SUCCESS;
1125 size_t cch = 0;
1126 size_t cCueSheetEntries = cbCueSheet / 8;
1127
1128 AssertReturn(cbCueSheet % 8 == 0, VERR_INVALID_PARAMETER);
1129
1130 for (size_t i = 0; i < cCueSheetEntries; i++)
1131 {
1132 cch = RTStrPrintf(pszBuffer, cchBuffer,
1133 "CTL/ADR=%#x TNO=%#x INDEX=%#x DATA=%#x SCMS=%#x TIME=%u:%u:%u\n",
1134 pbCueSheet[0], pbCueSheet[1], pbCueSheet[2], pbCueSheet[3],
1135 pbCueSheet[4], pbCueSheet[5], pbCueSheet[6], pbCueSheet[7]);
1136 pszBuffer += cch;
1137 cchBuffer -= cch;
1138 if (!cchBuffer)
1139 {
1140 rc = VERR_BUFFER_OVERFLOW;
1141 break;
1142 }
1143
1144 pbCueSheet += 8;
1145 cbCueSheet -= 8;
1146 }
1147
1148 return rc;
1149}
1150
1151#endif /* LOG_ENABLED || RT_STRICT */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette