VirtualBox

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

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