1 /*
2  * ASCII values for a number of symbolic constants, printing functions,
3  * etc.
4  * Additions for SCSI 2 and Linux 2.2.x by D. Gilbert (990422)
5  *
6  */
7 
8 #define __NO_VERSION__
9 #include <linux/module.h>
10 
11 #include <linux/config.h>
12 #include <linux/blk.h>
13 #include <linux/kernel.h>
14 #include "scsi.h"
15 #include "hosts.h"
16 
17 #define CONST_COMMAND   0x01
18 #define CONST_STATUS    0x02
19 #define CONST_SENSE     0x04
20 #define CONST_XSENSE    0x08
21 #define CONST_CMND      0x10
22 #define CONST_MSG       0x20
23 #define CONST_HOST	0x40
24 #define CONST_DRIVER	0x80
25 
26 static const char unknown[] = "UNKNOWN";
27 
28 #ifdef CONFIG_SCSI_CONSTANTS
29 #ifdef CONSTANTS
30 #undef CONSTANTS
31 #endif
32 #define CONSTANTS (CONST_COMMAND | CONST_STATUS | CONST_SENSE | CONST_XSENSE \
33 		   | CONST_CMND | CONST_MSG | CONST_HOST | CONST_DRIVER)
34 #endif
35 
36 #if (CONSTANTS & CONST_COMMAND)
37 static const char * group_0_commands[] = {
38 /* 00-03 */ "Test Unit Ready", "Rezero Unit", unknown, "Request Sense",
39 /* 04-07 */ "Format Unit", "Read Block Limits", unknown, "Reasssign Blocks",
40 /* 08-0d */ "Read (6)", unknown, "Write (6)", "Seek (6)", unknown, unknown,
41 /* 0e-12 */ unknown, "Read Reverse", "Write Filemarks", "Space", "Inquiry",
42 /* 13-16 */ "Verify", "Recover Buffered Data", "Mode Select", "Reserve",
43 /* 17-1b */ "Release", "Copy", "Erase", "Mode Sense", "Start/Stop Unit",
44 /* 1c-1d */ "Receive Diagnostic", "Send Diagnostic",
45 /* 1e-1f */ "Prevent/Allow Medium Removal", unknown,
46 };
47 
48 
49 static const char *group_1_commands[] = {
50 /* 20-22 */  unknown, unknown, unknown,
51 /* 23-28 */ unknown, "Define window parameters", "Read Capacity",
52             unknown, unknown, "Read (10)",
53 /* 29-2d */ "Read Generation", "Write (10)", "Seek (10)", "Erase",
54             "Read updated block",
55 /* 2e-31 */ "Write Verify","Verify", "Search High", "Search Equal",
56 /* 32-34 */ "Search Low", "Set Limits", "Prefetch or Read Position",
57 /* 35-37 */ "Synchronize Cache","Lock/Unlock Cache", "Read Defect Data",
58 /* 38-3c */ "Medium Scan", "Compare", "Copy Verify", "Write Buffer",
59             "Read Buffer",
60 /* 3d-3f */ "Update Block", "Read Long",  "Write Long",
61 };
62 
63 
64 static const char *group_2_commands[] = {
65 /* 40-41 */ "Change Definition", "Write Same",
66 /* 42-48 */ "Read sub-channel", "Read TOC", "Read header",
67             "Play audio (10)", unknown, "Play audio msf",
68             "Play audio track/index",
69 /* 49-4f */ "Play track relative (10)", unknown, "Pause/resume",
70             "Log Select", "Log Sense", unknown, unknown,
71 /* 50-55 */ unknown, unknown, unknown, unknown, unknown, "Mode Select (10)",
72 /* 56-5b */ unknown, unknown, unknown, unknown, "Mode Sense (10)", unknown,
73 /* 5c-5f */ unknown, unknown, unknown,
74 };
75 
76 
77 /* The following are 16 byte commands in group 4 */
78 static const char *group_4_commands[] = {
79 /* 80-84 */ unknown, unknown, unknown, unknown, unknown,
80 /* 85-89 */ "Memory Export In (16)", unknown, unknown, unknown,
81             "Memory Export Out (16)",
82 /* 8a-8f */ unknown, unknown, unknown, unknown, unknown, unknown,
83 /* 90-94 */ unknown, unknown, unknown, unknown, unknown,
84 /* 95-99 */ unknown, unknown, unknown, unknown, unknown,
85 /* 9a-9f */ unknown, unknown, unknown, unknown, unknown, unknown,
86 };
87 
88 
89 /* The following are 12 byte commands in group 5 */
90 static const char *group_5_commands[] = {
91 /* a0-a5 */ unknown, unknown, unknown, unknown, unknown,
92             "Move medium/play audio(12)",
93 /* a6-a9 */ "Exchange medium", unknown, "Read(12)", "Play track relative(12)",
94 /* aa-ae */ "Write(12)", unknown, "Erase(12)", unknown,
95             "Write and verify(12)",
96 /* af-b1 */ "Verify(12)", "Search data high(12)", "Search data equal(12)",
97 /* b2-b4 */ "Search data low(12)", "Set limits(12)", unknown,
98 /* b5-b6 */ "Request volume element address", "Send volume tag",
99 /* b7-b9 */ "Read defect data(12)", "Read element status", unknown,
100 /* ba-bf */ unknown, unknown, unknown, unknown, unknown, unknown,
101 };
102 
103 
104 
105 #define group(opcode) (((opcode) >> 5) & 7)
106 
107 #define RESERVED_GROUP  0
108 #define VENDOR_GROUP    1
109 
110 static const char **commands[] = {
111     group_0_commands, group_1_commands, group_2_commands,
112     (const char **) RESERVED_GROUP, group_4_commands,
113     group_5_commands, (const char **) VENDOR_GROUP,
114     (const char **) VENDOR_GROUP
115 };
116 
117 static const char reserved[] = "RESERVED";
118 static const char vendor[] = "VENDOR SPECIFIC";
119 
print_opcode(int opcode)120 static void print_opcode(int opcode) {
121     const char **table = commands[ group(opcode) ];
122     switch ((unsigned long) table) {
123     case RESERVED_GROUP:
124 	printk("%s(0x%02x) ", reserved, opcode);
125 	break;
126     case VENDOR_GROUP:
127 	printk("%s(0x%02x) ", vendor, opcode);
128 	break;
129     default:
130 	if (table[opcode & 0x1f] != unknown)
131 	    printk("%s ",table[opcode & 0x1f]);
132 	else
133 	    printk("%s(0x%02x) ", unknown, opcode);
134 	break;
135     }
136 }
137 #else /* CONST & CONST_COMMAND */
print_opcode(int opcode)138 static void print_opcode(int opcode) {
139     printk("0x%02x ", opcode);
140 }
141 #endif
142 
print_command(unsigned char * command)143 void print_command (unsigned char *command) {
144     int i,s;
145     print_opcode(command[0]);
146     for ( i = 1, s = COMMAND_SIZE(command[0]); i < s; ++i)
147 	printk("%02x ", command[i]);
148     printk("\n");
149 }
150 
151 #if (CONSTANTS & CONST_STATUS)
152 static const char * statuses[] = {
153 /* 0-4 */ "Good", "Check Condition", "Condition Met", unknown, "Busy",
154 /* 5-9 */ unknown, unknown, unknown, "Intermediate", unknown,
155 /* a-c */ "Intermediate-Condition Met", unknown, "Reservation Conflict",
156 /* d-10 */ unknown, unknown, unknown, unknown,
157 /* 11-14 */ "Command Terminated", unknown, unknown, "Queue Full",
158 /* 15-1a */ unknown, unknown, unknown, unknown, unknown, unknown,
159 /* 1b-1f */ unknown, unknown, unknown, unknown, unknown,
160 };
161 #endif
162 
print_status(int status)163 void print_status (int status) {
164     status = (status >> 1) & 0x1f;
165 #if (CONSTANTS & CONST_STATUS)
166     printk("%s ",statuses[status]);
167 #else
168     printk("0x%0x ", status);
169 #endif
170 }
171 
172 #if (CONSTANTS & CONST_XSENSE)
173 #define D 0x0001  /* DIRECT ACCESS DEVICE (disk) */
174 #define T 0x0002  /* SEQUENTIAL ACCESS DEVICE (tape) */
175 #define L 0x0004  /* PRINTER DEVICE */
176 #define P 0x0008  /* PROCESSOR DEVICE */
177 #define W 0x0010  /* WRITE ONCE READ MULTIPLE DEVICE */
178 #define R 0x0020  /* READ ONLY (CD-ROM) DEVICE */
179 #define S 0x0040  /* SCANNER DEVICE */
180 #define O 0x0080  /* OPTICAL MEMORY DEVICE */
181 #define M 0x0100  /* MEDIA CHANGER DEVICE */
182 #define C 0x0200  /* COMMUNICATION DEVICE */
183 #define A 0x0400  /* ARRAY STORAGE */
184 #define E 0x0800  /* ENCLOSURE SERVICES DEVICE */
185 #define B 0x1000  /* SIMPLIFIED DIRECT ACCESS DEVICE */
186 #define K 0x2000  /* OPTICAL CARD READER/WRITER DEVICE */
187 
188 struct error_info{
189     unsigned char code1, code2;
190     unsigned short int devices;
191     const char * text;
192 };
193 
194 struct error_info2{
195     unsigned char code1, code2_min, code2_max;
196     unsigned short int devices;
197     const char * text;
198 };
199 
200 static struct error_info2 additional2[] =
201 {
202   {0x40,0x00,0x7f,D,"Ram failure (%x)"},
203   {0x40,0x80,0xff,D|T|L|P|W|R|S|O|M|C,"Diagnostic failure on component (%x)"},
204   {0x41,0x00,0xff,D,"Data path failure (%x)"},
205   {0x42,0x00,0xff,D,"Power-on or self-test failure (%x)"},
206   {0, 0, 0, 0, NULL}
207 };
208 
209 static struct error_info additional[] =
210 {
211   {0x00,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"No additional sense information"},
212   {0x00,0x01,T,"Filemark detected"},
213   {0x00,0x02,T|S,"End-of-partition/medium detected"},
214   {0x00,0x03,T,"Setmark detected"},
215   {0x00,0x04,T|S,"Beginning-of-partition/medium detected"},
216   {0x00,0x05,T|L|S,"End-of-data detected"},
217   {0x00,0x06,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"I/O process terminated"},
218   {0x00,0x11,R,"Audio play operation in progress"},
219   {0x00,0x12,R,"Audio play operation paused"},
220   {0x00,0x13,R,"Audio play operation successfully completed"},
221   {0x00,0x14,R,"Audio play operation stopped due to error"},
222   {0x00,0x15,R,"No current audio status to return"},
223   {0x00,0x16,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Operation in progress"},
224   {0x00,0x17,D|T|L|W|R|S|O|M|A|E|B|K,"Cleaning requested"},
225   {0x01,0x00,D|W|O|B|K,"No index/sector signal"},
226   {0x02,0x00,D|W|R|O|M|B|K,"No seek complete"},
227   {0x03,0x00,D|T|L|W|S|O|B|K,"Peripheral device write fault"},
228   {0x03,0x01,T,"No write current"},
229   {0x03,0x02,T,"Excessive write errors"},
230   {0x04,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Logical unit not ready,cause not reportable"},
231   {0x04,0x01,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Logical unit is in process of becoming ready"},
232   {0x04,0x02,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Logical unit not ready,initializing cmd. required"},
233   {0x04,0x03,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Logical unit not ready,manual intervention required"},
234   {0x04,0x04,D|T|L|R|O|B,"Logical unit not ready,format in progress"},
235   {0x04,0x05,D|T|W|O|M|C|A|B|K,"Logical unit not ready,rebuild in progress"},
236   {0x04,0x06,D|T|W|O|M|C|A|B|K,"Logical unit not ready,recalculation in progress"},
237   {0x04,0x07,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Logical unit not ready,operation in progress"},
238   {0x04,0x08,R,"Logical unit not ready,long write in progress"},
239   {0x04,0x09,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Logical unit not ready,self-test in progress"},
240   {0x05,0x00,D|T|L|W|R|S|O|M|C|A|E|B|K,"Logical unit does not respond to selection"},
241   {0x06,0x00,D|W|R|O|M|B|K,"No reference position found"},
242   {0x07,0x00,D|T|L|W|R|S|O|M|B|K,"Multiple peripheral devices selected"},
243   {0x08,0x00,D|T|L|W|R|S|O|M|C|A|E|B|K,"Logical unit communication failure"},
244   {0x08,0x01,D|T|L|W|R|S|O|M|C|A|E|B|K,"Logical unit communication time-out"},
245   {0x08,0x02,D|T|L|W|R|S|O|M|C|A|E|B|K,"Logical unit communication parity error"},
246   {0x08,0x03,D|T|R|O|M|B|K,"Logical unit communication CRC error (Ultra-DMA/32)"},
247   {0x08,0x04,D|T|L|P|W|R|S|O|C|K,"Unreachable copy target"},
248   {0x09,0x00,D|T|W|R|O|B,"Track following error"},
249   {0x09,0x01,W|R|O|K,"Tracking servo failure"},
250   {0x09,0x02,W|R|O|K,"Focus servo failure"},
251   {0x09,0x03,W|R|O,"Spindle servo failure"},
252   {0x09,0x04,D|T|W|R|O|B,"Head select fault"},
253   {0x0A,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Error log overflow"},
254   {0x0B,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Warning"},
255   {0x0B,0x01,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Warning - specified temperature exceeded"},
256   {0x0B,0x02,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Warning - enclosure degraded"},
257   {0x0C,0x00,T|R|S,"Write error"},
258   {0x0C,0x01,K,"Write error - recovered with auto reallocation"},
259   {0x0C,0x02,D|W|O|B|K,"Write error - auto reallocation failed"},
260   {0x0C,0x03,D|W|O|B|K,"Write error - recommend reassignment"},
261   {0x0C,0x04,D|T|W|O|B,"Compression check miscompare error"},
262   {0x0C,0x05,D|T|W|O|B,"Data expansion occurred during compression"},
263   {0x0C,0x06,D|T|W|O|B,"Block not compressible"},
264   {0x0C,0x07,R,"Write error - recovery needed"},
265   {0x0C,0x08,R,"Write error - recovery failed"},
266   {0x0C,0x09,R,"Write error - loss of streaming"},
267   {0x0C,0x0A,R,"Write error - padding blocks added"},
268   {0x10,0x00,D|W|O|B|K,"Id CRC or ECC error"},
269   {0x11,0x00,D|T|W|R|S|O|B|K,"Unrecovered read error"},
270   {0x11,0x01,D|T|W|R|S|O|B|K,"Read retries exhausted"},
271   {0x11,0x02,D|T|W|R|S|O|B|K,"Error too long to correct"},
272   {0x11,0x03,D|T|W|S|O|B|K,"Multiple read errors"},
273   {0x11,0x04,D|W|O|B|K,"Unrecovered read error - auto reallocate failed"},
274   {0x11,0x05,W|R|O|B,"L-EC uncorrectable error"},
275   {0x11,0x06,W|R|O|B,"CIRC unrecovered error"},
276   {0x11,0x07,W|O|B,"Data re-synchronization error"},
277   {0x11,0x08,T,"Incomplete block read"},
278   {0x11,0x09,T,"No gap found"},
279   {0x11,0x0A,D|T|O|B|K,"Miscorrected error"},
280   {0x11,0x0B,D|W|O|B|K,"Unrecovered read error - recommend reassignment"},
281   {0x11,0x0C,D|W|O|B|K,"Unrecovered read error - recommend rewrite the data"},
282   {0x11,0x0D,D|T|W|R|O|B,"De-compression CRC error"},
283   {0x11,0x0E,D|T|W|R|O|B,"Cannot decompress using declared algorithm"},
284   {0x11,0x0F,R,"Error reading UPC/EAN number"},
285   {0x11,0x10,R,"Error reading ISRC number"},
286   {0x11,0x11,R,"Read error - loss of streaming"},
287   {0x12,0x00,D|W|O|B|K,"Address mark not found for id field"},
288   {0x13,0x00,D|W|O|B|K,"Address mark not found for data field"},
289   {0x14,0x00,D|T|L|W|R|S|O|B|K,"Recorded entity not found"},
290   {0x14,0x01,D|T|W|R|O|B|K,"Record not found"},
291   {0x14,0x02,T,"Filemark or setmark not found"},
292   {0x14,0x03,T,"End-of-data not found"},
293   {0x14,0x04,T,"Block sequence error"},
294   {0x14,0x05,D|T|W|O|B|K,"Record not found - recommend reassignment"},
295   {0x14,0x06,D|T|W|O|B|K,"Record not found - data auto-reallocated"},
296   {0x15,0x00,D|T|L|W|R|S|O|M|B|K,"Random positioning error"},
297   {0x15,0x01,D|T|L|W|R|S|O|M|B|K,"Mechanical positioning error"},
298   {0x15,0x02,D|T|W|R|O|B|K,"Positioning error detected by read of medium"},
299   {0x16,0x00,D|W|O|B|K,"Data synchronization mark error"},
300   {0x16,0x01,D|W|O|B|K,"Data sync error - data rewritten"},
301   {0x16,0x02,D|W|O|B|K,"Data sync error - recommend rewrite"},
302   {0x16,0x03,D|W|O|B|K,"Data sync error - data auto-reallocated"},
303   {0x16,0x04,D|W|O|B|K,"Data sync error - recommend reassignment"},
304   {0x17,0x00,D|T|W|R|S|O|B|K,"Recovered data with no error correction applied"},
305   {0x17,0x01,D|T|W|R|S|O|B|K,"Recovered data with retries"},
306   {0x17,0x02,D|T|W|R|O|B|K,"Recovered data with positive head offset"},
307   {0x17,0x03,D|T|W|R|O|B|K,"Recovered data with negative head offset"},
308   {0x17,0x04,W|R|O|B,"Recovered data with retries and/or circ applied"},
309   {0x17,0x05,D|W|R|O|B|K,"Recovered data using previous sector id"},
310   {0x17,0x06,D|W|O|B|K,"Recovered data without ecc - data auto-reallocated"},
311   {0x17,0x07,D|W|R|O|B|K,"Recovered data without ecc - recommend reassignment"},
312   {0x17,0x08,D|W|R|O|B|K,"Recovered data without ecc - recommend rewrite"},
313   {0x17,0x09,D|W|R|O|B|K,"Recovered data without ecc - data rewritten"},
314   {0x18,0x00,D|T|W|R|O|B|K,"Recovered data with error correction applied"},
315   {0x18,0x01,D|W|R|O|B|K,"Recovered data with error corr. & retries applied"},
316   {0x18,0x02,D|W|R|O|B|K,"Recovered data - data auto-reallocated"},
317   {0x18,0x03,R,"Recovered data with CIRC"},
318   {0x18,0x04,R,"Recovered data with L-EC"},
319   {0x18,0x05,D|W|R|O|B|K,"Recovered data - recommend reassignment"},
320   {0x18,0x06,D|W|R|O|B|K,"Recovered data - recommend rewrite"},
321   {0x18,0x07,D|W|O|B|K,"Recovered data with ecc - data rewritten"},
322   {0x19,0x00,D|O|K,"Defect list error"},
323   {0x19,0x01,D|O|K,"Defect list not available"},
324   {0x19,0x02,D|O|K,"Defect list error in primary list"},
325   {0x19,0x03,D|O|K,"Defect list error in grown list"},
326   {0x1A,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Parameter list length error"},
327   {0x1B,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Synchronous data transfer error"},
328   {0x1C,0x00,D|O|B|K,"Defect list not found"},
329   {0x1C,0x01,D|O|B|K,"Primary defect list not found"},
330   {0x1C,0x02,D|O|B|K,"Grown defect list not found"},
331   {0x1D,0x00,D|T|W|R|O|B|K,"Miscompare during verify operation"},
332   {0x1E,0x00,D|W|O|B|K,"Recovered id with ecc correction"},
333   {0x1F,0x00,D|O|K,"Partial defect list transfer"},
334   {0x20,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Invalid command operation code"},
335   {0x21,0x00,D|T|W|R|O|M|B|K,"Logical block address out of range"},
336   {0x21,0x01,D|T|W|R|O|M|B|K,"Invalid element address"},
337   {0x22,0x00,D,"Illegal function (use 20 00,24 00,or 26 00)"},
338   {0x24,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Invalid field in cdb"},
339   {0x24,0x01,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"CDB decryption error"},
340   {0x25,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Logical unit not supported"},
341   {0x26,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Invalid field in parameter list"},
342   {0x26,0x01,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Parameter not supported"},
343   {0x26,0x02,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Parameter value invalid"},
344   {0x26,0x03,D|T|L|P|W|R|S|O|M|C|A|E|K,"Threshold parameters not supported"},
345   {0x26,0x04,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Invalid release of persistent reservation"},
346   {0x26,0x05,D|T|L|P|W|R|S|O|M|C|A|B|K,"Data decryption error"},
347   {0x26,0x06,D|T|L|P|W|R|S|O|C|K,"Too many target descriptors"},
348   {0x26,0x07,D|T|L|P|W|R|S|O|C|K,"Unsupported target descriptor type code"},
349   {0x26,0x08,D|T|L|P|W|R|S|O|C|K,"Too many segment descriptors"},
350   {0x26,0x09,D|T|L|P|W|R|S|O|C|K,"Unsupported segment descriptor type code"},
351   {0x26,0x0A,D|T|L|P|W|R|S|O|C|K,"Unexpected inexact segment"},
352   {0x26,0x0B,D|T|L|P|W|R|S|O|C|K,"Inline data length exceeded"},
353   {0x26,0x0C,D|T|L|P|W|R|S|O|C|K,"Invalid operation for copy source or destination"},
354   {0x26,0x0D,D|T|L|P|W|R|S|O|C|K,"Copy segment granularity violation"},
355   {0x27,0x00,D|T|W|R|O|B|K,"Write protected"},
356   {0x27,0x01,D|T|W|R|O|B|K,"Hardware write protected"},
357   {0x27,0x02,D|T|W|R|O|B|K,"Logical unit software write protected"},
358   {0x27,0x03,T|R,"Associated write protect"},
359   {0x27,0x04,T|R,"Persistent write protect"},
360   {0x27,0x05,T|R,"Permanent write protect"},
361   {0x28,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Not ready to ready change,medium may have changed"},
362   {0x28,0x01,D|T|W|R|O|M|B,"Import or export element accessed"},
363   {0x29,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Power on,reset,or bus device reset occurred"},
364   {0x29,0x01,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Power on occurred"},
365   {0x29,0x02,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Scsi bus reset occurred"},
366   {0x29,0x03,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Bus device reset function occurred"},
367   {0x29,0x04,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Device internal reset"},
368   {0x29,0x05,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Transceiver mode changed to single-ended"},
369   {0x29,0x06,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Transceiver mode changed to lvd"},
370   {0x2A,0x00,D|T|L|W|R|S|O|M|C|A|E|B|K,"Parameters changed"},
371   {0x2A,0x01,D|T|L|W|R|S|O|M|C|A|E|B|K,"Mode parameters changed"},
372   {0x2A,0x02,D|T|L|W|R|S|O|M|C|A|E|K,"Log parameters changed"},
373   {0x2A,0x03,D|T|L|P|W|R|S|O|M|C|A|E|K,"Reservations preempted"},
374   {0x2A,0x04,D|T|L|P|W|R|S|O|M|C|A|E,"Reservations released"},
375   {0x2A,0x05,D|T|L|P|W|R|S|O|M|C|A|E,"Registrations preempted"},
376   {0x2B,0x00,D|T|L|P|W|R|S|O|C|K,"Copy cannot execute since host cannot disconnect"},
377   {0x2C,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Command sequence error"},
378   {0x2C,0x01,S,"Too many windows specified"},
379   {0x2C,0x02,S,"Invalid combination of windows specified"},
380   {0x2C,0x03,R,"Current program area is not empty"},
381   {0x2C,0x04,R,"Current program area is empty"},
382   {0x2C,0x05,B,"Illegal power condition request"},
383   {0x2D,0x00,T,"Overwrite error on update in place"},
384   {0x2F,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Commands cleared by another initiator"},
385   {0x30,0x00,D|T|W|R|O|M|B|K,"Incompatible medium installed"},
386   {0x30,0x01,D|T|W|R|O|B|K,"Cannot read medium - unknown format"},
387   {0x30,0x02,D|T|W|R|O|B|K,"Cannot read medium - incompatible format"},
388   {0x30,0x03,D|T|R|K,"Cleaning cartridge installed"},
389   {0x30,0x04,D|T|W|R|O|B|K,"Cannot write medium - unknown format"},
390   {0x30,0x05,D|T|W|R|O|B|K,"Cannot write medium - incompatible format"},
391   {0x30,0x06,D|T|W|R|O|B,"Cannot format medium - incompatible medium"},
392   {0x30,0x07,D|T|L|W|R|S|O|M|A|E|B|K,"Cleaning failure"},
393   {0x30,0x08,R,"Cannot write - application code mismatch"},
394   {0x30,0x09,R,"Current session not fixated for append"},
395   {0x31,0x00,D|T|W|R|O|B|K,"Medium format corrupted"},
396   {0x31,0x01,D|L|R|O|B,"Format command failed"},
397   {0x32,0x00,D|W|O|B|K,"No defect spare location available"},
398   {0x32,0x01,D|W|O|B|K,"Defect list update failure"},
399   {0x33,0x00,T,"Tape length error"},
400   {0x34,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Enclosure failure"},
401   {0x35,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Enclosure services failure"},
402   {0x35,0x01,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Unsupported enclosure function"},
403   {0x35,0x02,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Enclosure services unavailable"},
404   {0x35,0x03,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Enclosure services transfer failure"},
405   {0x35,0x04,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Enclosure services transfer refused"},
406   {0x36,0x00,L,"Ribbon,ink,or toner failure"},
407   {0x37,0x00,D|T|L|W|R|S|O|M|C|A|E|B|K,"Rounded parameter"},
408   {0x38,0x00,B,"Event status notification"},
409   {0x38,0x02,B,"Esn - power management class event"},
410   {0x38,0x04,B,"Esn - media class event"},
411   {0x38,0x06,B,"Esn - device busy class event"},
412   {0x39,0x00,D|T|L|W|R|S|O|M|C|A|E|K,"Saving parameters not supported"},
413   {0x3A,0x00,D|T|L|W|R|S|O|M|B|K,"Medium not present"},
414   {0x3A,0x01,D|T|W|R|O|M|B|K,"Medium not present - tray closed"},
415   {0x3A,0x02,D|T|W|R|O|M|B|K,"Medium not present - tray open"},
416   {0x3A,0x03,D|T|W|R|O|M|B,"Medium not present - loadable"},
417   {0x3A,0x04,D|T|W|R|O|M|B,"Medium not present - medium auxiliary memory accessible"},
418   {0x3B,0x00,T|L,"Sequential positioning error"},
419   {0x3B,0x01,T,"Tape position error at beginning-of-medium"},
420   {0x3B,0x02,T,"Tape position error at end-of-medium"},
421   {0x3B,0x03,L,"Tape or electronic vertical forms unit not ready"},
422   {0x3B,0x04,L,"Slew failure"},
423   {0x3B,0x05,L,"Paper jam"},
424   {0x3B,0x06,L,"Failed to sense top-of-form"},
425   {0x3B,0x07,L,"Failed to sense bottom-of-form"},
426   {0x3B,0x08,T,"Reposition error"},
427   {0x3B,0x09,S,"Read past end of medium"},
428   {0x3B,0x0A,S,"Read past beginning of medium"},
429   {0x3B,0x0B,S,"Position past end of medium"},
430   {0x3B,0x0C,T|S,"Position past beginning of medium"},
431   {0x3B,0x0D,D|T|W|R|O|M|B|K,"Medium destination element full"},
432   {0x3B,0x0E,D|T|W|R|O|M|B|K,"Medium source element empty"},
433   {0x3B,0x0F,R,"End of medium reached"},
434   {0x3B,0x11,D|T|W|R|O|M|B|K,"Medium magazine not accessible"},
435   {0x3B,0x12,D|T|W|R|O|M|B|K,"Medium magazine removed"},
436   {0x3B,0x13,D|T|W|R|O|M|B|K,"Medium magazine inserted"},
437   {0x3B,0x14,D|T|W|R|O|M|B|K,"Medium magazine locked"},
438   {0x3B,0x15,D|T|W|R|O|M|B|K,"Medium magazine unlocked"},
439   {0x3B,0x16,R,"Mechanical positioning or changer error"},
440   {0x3D,0x00,D|T|L|P|W|R|S|O|M|C|A|E|K,"Invalid bits in identify message"},
441   {0x3E,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Logical unit has not self-configured yet"},
442   {0x3E,0x01,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Logical unit failure"},
443   {0x3E,0x02,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Timeout on logical unit"},
444   {0x3E,0x03,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Logical unit failed self-test"},
445   {0x3E,0x04,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Logical unit unable to update self-test log"},
446   {0x3F,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Target operating conditions have changed"},
447   {0x3F,0x01,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Microcode has been changed"},
448   {0x3F,0x02,D|T|L|P|W|R|S|O|M|C|B|K,"Changed operating definition"},
449   {0x3F,0x03,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Inquiry data has changed"},
450   {0x3F,0x04,D|T|W|R|O|M|C|A|E|B|K,"Component device attached"},
451   {0x3F,0x05,D|T|W|R|O|M|C|A|E|B|K,"Device identifier changed"},
452   {0x3F,0x06,D|T|W|R|O|M|C|A|E|B,"Redundancy group created or modified"},
453   {0x3F,0x07,D|T|W|R|O|M|C|A|E|B,"Redundancy group deleted"},
454   {0x3F,0x08,D|T|W|R|O|M|C|A|E|B,"Spare created or modified"},
455   {0x3F,0x09,D|T|W|R|O|M|C|A|E|B,"Spare deleted"},
456   {0x3F,0x0A,D|T|W|R|O|M|C|A|E|B|K,"Volume set created or modified"},
457   {0x3F,0x0B,D|T|W|R|O|M|C|A|E|B|K,"Volume set deleted"},
458   {0x3F,0x0C,D|T|W|R|O|M|C|A|E|B|K,"Volume set deassigned"},
459   {0x3F,0x0D,D|T|W|R|O|M|C|A|E|B|K,"Volume set reassigned"},
460   {0x3F,0x0E,D|T|L|P|W|R|S|O|M|C|A|E,"Reported luns data has changed"},
461   {0x3F,0x10,D|T|W|R|O|M|B,"Medium loadable"},
462   {0x3F,0x11,D|T|W|R|O|M|B,"Medium auxiliary memory accessible"},
463   {0x40,0x00,D,"Ram failure (should use 40 nn)"},
464   /*
465    * FIXME(eric) - need a way to represent wildcards here.
466    */
467   {0x40,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Diagnostic failure on component nn (80h-ffh)"},
468   {0x41,0x00,D,"Data path failure (should use 40 nn)"},
469   {0x42,0x00,D,"Power-on or self-test failure (should use 40 nn)"},
470   {0x43,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Message error"},
471   {0x44,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Internal target failure"},
472   {0x45,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Select or reselect failure"},
473   {0x46,0x00,D|T|L|P|W|R|S|O|M|C|B|K,"Unsuccessful soft reset"},
474   {0x47,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Scsi parity error"},
475   {0x47,0x01,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Data phase CRC error detected"},
476   {0x47,0x02,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Scsi parity error detected during st data phase"},
477   {0x47,0x03,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Information unit CRC error detected"},
478   {0x47,0x04,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Asynchronous information protection error detected"},
479   {0x48,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Initiator detected error message received"},
480   {0x49,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Invalid message error"},
481   {0x4A,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Command phase error"},
482   {0x4B,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Data phase error"},
483   {0x4C,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Logical unit failed self-configuration"},
484   /*
485    * FIXME(eric) - need a way to represent wildcards here.
486    */
487   {0x4D,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Tagged overlapped commands (nn = queue tag)"},
488   {0x4E,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Overlapped commands attempted"},
489   {0x50,0x00,T,"Write append error"},
490   {0x50,0x01,T,"Write append position error"},
491   {0x50,0x02,T,"Position error related to timing"},
492   {0x51,0x00,T|R|O,"Erase failure"},
493   {0x52,0x00,T,"Cartridge fault"},
494   {0x53,0x00,D|T|L|W|R|S|O|M|B|K,"Media load or eject failed"},
495   {0x53,0x01,T,"Unload tape failure"},
496   {0x53,0x02,D|T|W|R|O|M|B|K,"Medium removal prevented"},
497   {0x54,0x00,P,"Scsi to host system interface failure"},
498   {0x55,0x00,P,"System resource failure"},
499   {0x55,0x01,D|O|B|K,"System buffer full"},
500   {0x55,0x02,D|T|L|P|W|R|S|O|M|A|E|K,"Insufficient reservation resources"},
501   {0x55,0x03,D|T|L|P|W|R|S|O|M|C|A|E,"Insufficient resources"},
502   {0x55,0x04,D|T|L|P|W|R|S|O|M|A|E,"Insufficient registration resources"},
503   {0x57,0x00,R,"Unable to recover table-of-contents"},
504   {0x58,0x00,O,"Generation does not exist"},
505   {0x59,0x00,O,"Updated block read"},
506   {0x5A,0x00,D|T|L|P|W|R|S|O|M|B|K,"Operator request or state change input"},
507   {0x5A,0x01,D|T|W|R|O|M|B|K,"Operator medium removal request"},
508   {0x5A,0x02,D|T|W|R|O|A|B|K,"Operator selected write protect"},
509   {0x5A,0x03,D|T|W|R|O|A|B|K,"Operator selected write permit"},
510   {0x5B,0x00,D|T|L|P|W|R|S|O|M|K,"Log exception"},
511   {0x5B,0x01,D|T|L|P|W|R|S|O|M|K,"Threshold condition met"},
512   {0x5B,0x02,D|T|L|P|W|R|S|O|M|K,"Log counter at maximum"},
513   {0x5B,0x03,D|T|L|P|W|R|S|O|M|K,"Log list codes exhausted"},
514   {0x5C,0x00,D|O,"Rpl status change"},
515   {0x5C,0x01,D|O,"Spindles synchronized"},
516   {0x5C,0x02,D|O,"Spindles not synchronized"},
517   {0x5D,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Failure prediction threshold exceeded"},
518   {0x5D,0x01,R|B,"Media failure prediction threshold exceeded"},
519   {0x5D,0x02,R,"Logical unit failure prediction threshold exceeded"},
520   {0x5D,0x10,D|B,"Hardware impending failure general hard drive failure"},
521   {0x5D,0x11,D|B,"Hardware impending failure drive error rate too high"},
522   {0x5D,0x12,D|B,"Hardware impending failure data error rate too high"},
523   {0x5D,0x13,D|B,"Hardware impending failure seek error rate too high"},
524   {0x5D,0x14,D|B,"Hardware impending failure too many block reassigns"},
525   {0x5D,0x15,D|B,"Hardware impending failure access times too high"},
526   {0x5D,0x16,D|B,"Hardware impending failure start unit times too high"},
527   {0x5D,0x17,D|B,"Hardware impending failure channel parametrics"},
528   {0x5D,0x18,D|B,"Hardware impending failure controller detected"},
529   {0x5D,0x19,D|B,"Hardware impending failure throughput performance"},
530   {0x5D,0x1A,D|B,"Hardware impending failure seek time performance"},
531   {0x5D,0x1B,D|B,"Hardware impending failure spin-up retry count"},
532   {0x5D,0x1C,D|B,"Hardware impending failure drive calibration retry count"},
533   {0x5D,0x20,D|B,"Controller impending failure general hard drive failure"},
534   {0x5D,0x21,D|B,"Controller impending failure drive error rate too high"},
535   {0x5D,0x22,D|B,"Controller impending failure data error rate too high"},
536   {0x5D,0x23,D|B,"Controller impending failure seek error rate too high"},
537   {0x5D,0x24,D|B,"Controller impending failure too many block reassigns"},
538   {0x5D,0x25,D|B,"Controller impending failure access times too high"},
539   {0x5D,0x26,D|B,"Controller impending failure start unit times too high"},
540   {0x5D,0x27,D|B,"Controller impending failure channel parametrics"},
541   {0x5D,0x28,D|B,"Controller impending failure controller detected"},
542   {0x5D,0x29,D|B,"Controller impending failure throughput performance"},
543   {0x5D,0x2A,D|B,"Controller impending failure seek time performance"},
544   {0x5D,0x2B,D|B,"Controller impending failure spin-up retry count"},
545   {0x5D,0x2C,D|B,"Controller impending failure drive calibration retry count"},
546   {0x5D,0x30,D|B,"Data channel impending failure general hard drive failure"},
547   {0x5D,0x31,D|B,"Data channel impending failure drive error rate too high"},
548   {0x5D,0x32,D|B,"Data channel impending failure data error rate too high"},
549   {0x5D,0x33,D|B,"Data channel impending failure seek error rate too high"},
550   {0x5D,0x34,D|B,"Data channel impending failure too many block reassigns"},
551   {0x5D,0x35,D|B,"Data channel impending failure access times too high"},
552   {0x5D,0x36,D|B,"Data channel impending failure start unit times too high"},
553   {0x5D,0x37,D|B,"Data channel impending failure channel parametrics"},
554   {0x5D,0x38,D|B,"Data channel impending failure controller detected"},
555   {0x5D,0x39,D|B,"Data channel impending failure throughput performance"},
556   {0x5D,0x3A,D|B,"Data channel impending failure seek time performance"},
557   {0x5D,0x3B,D|B,"Data channel impending failure spin-up retry count"},
558   {0x5D,0x3C,D|B,"Data channel impending failure drive calibration retry count"},
559   {0x5D,0x40,D|B,"Servo impending failure general hard drive failure"},
560   {0x5D,0x41,D|B,"Servo impending failure drive error rate too high"},
561   {0x5D,0x42,D|B,"Servo impending failure data error rate too high"},
562   {0x5D,0x43,D|B,"Servo impending failure seek error rate too high"},
563   {0x5D,0x44,D|B,"Servo impending failure too many block reassigns"},
564   {0x5D,0x45,D|B,"Servo impending failure access times too high"},
565   {0x5D,0x46,D|B,"Servo impending failure start unit times too high"},
566   {0x5D,0x47,D|B,"Servo impending failure channel parametrics"},
567   {0x5D,0x48,D|B,"Servo impending failure controller detected"},
568   {0x5D,0x49,D|B,"Servo impending failure throughput performance"},
569   {0x5D,0x4A,D|B,"Servo impending failure seek time performance"},
570   {0x5D,0x4B,D|B,"Servo impending failure spin-up retry count"},
571   {0x5D,0x4C,D|B,"Servo impending failure drive calibration retry count"},
572   {0x5D,0x50,D|B,"Spindle impending failure general hard drive failure"},
573   {0x5D,0x51,D|B,"Spindle impending failure drive error rate too high"},
574   {0x5D,0x52,D|B,"Spindle impending failure data error rate too high"},
575   {0x5D,0x53,D|B,"Spindle impending failure seek error rate too high"},
576   {0x5D,0x54,D|B,"Spindle impending failure too many block reassigns"},
577   {0x5D,0x55,D|B,"Spindle impending failure access times too high"},
578   {0x5D,0x56,D|B,"Spindle impending failure start unit times too high"},
579   {0x5D,0x57,D|B,"Spindle impending failure channel parametrics"},
580   {0x5D,0x58,D|B,"Spindle impending failure controller detected"},
581   {0x5D,0x59,D|B,"Spindle impending failure throughput performance"},
582   {0x5D,0x5A,D|B,"Spindle impending failure seek time performance"},
583   {0x5D,0x5B,D|B,"Spindle impending failure spin-up retry count"},
584   {0x5D,0x5C,D|B,"Spindle impending failure drive calibration retry count"},
585   {0x5D,0x60,D|B,"Firmware impending failure general hard drive failure"},
586   {0x5D,0x61,D|B,"Firmware impending failure drive error rate too high"},
587   {0x5D,0x62,D|B,"Firmware impending failure data error rate too high"},
588   {0x5D,0x63,D|B,"Firmware impending failure seek error rate too high"},
589   {0x5D,0x64,D|B,"Firmware impending failure too many block reassigns"},
590   {0x5D,0x65,D|B,"Firmware impending failure access times too high"},
591   {0x5D,0x66,D|B,"Firmware impending failure start unit times too high"},
592   {0x5D,0x67,D|B,"Firmware impending failure channel parametrics"},
593   {0x5D,0x68,D|B,"Firmware impending failure controller detected"},
594   {0x5D,0x69,D|B,"Firmware impending failure throughput performance"},
595   {0x5D,0x6A,D|B,"Firmware impending failure seek time performance"},
596   {0x5D,0x6B,D|B,"Firmware impending failure spin-up retry count"},
597   {0x5D,0x6C,D|B,"Firmware impending failure drive calibration retry count"},
598   {0x5D,0xFF,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Failure prediction threshold exceeded (false)"},
599   {0x5E,0x00,D|T|L|P|W|R|S|O|C|A|K,"Low power condition on"},
600   {0x5E,0x01,D|T|L|P|W|R|S|O|C|A|K,"Idle condition activated by timer"},
601   {0x5E,0x02,D|T|L|P|W|R|S|O|C|A|K,"Standby condition activated by timer"},
602   {0x5E,0x03,D|T|L|P|W|R|S|O|C|A|K,"Idle condition activated by command"},
603   {0x5E,0x04,D|T|L|P|W|R|S|O|C|A|K,"Standby condition activated by command"},
604   {0x5E,0x41,B,"Power state change to active"},
605   {0x5E,0x42,B,"Power state change to idle"},
606   {0x5E,0x43,B,"Power state change to standby"},
607   {0x5E,0x45,B,"Power state change to sleep"},
608   {0x5E,0x47,B|K,"Power state change to device control"},
609   {0x60,0x00,S,"Lamp failure"},
610   {0x61,0x00,S,"Video acquisition error"},
611   {0x61,0x01,S,"Unable to acquire video"},
612   {0x61,0x02,S,"Out of focus"},
613   {0x62,0x00,S,"Scan head positioning error"},
614   {0x63,0x00,R,"End of user area encountered on this track"},
615   {0x63,0x01,R,"Packet does not fit in available space"},
616   {0x64,0x00,R,"Illegal mode for this track"},
617   {0x64,0x01,R,"Invalid packet size"},
618   {0x65,0x00,D|T|L|P|W|R|S|O|M|C|A|E|B|K,"Voltage fault"},
619   {0x66,0x00,S,"Automatic document feeder cover up"},
620   {0x66,0x01,S,"Automatic document feeder lift up"},
621   {0x66,0x02,S,"Document jam in automatic document feeder"},
622   {0x66,0x03,S,"Document miss feed automatic in document feeder"},
623   {0x67,0x00,A,"Configuration failure"},
624   {0x67,0x01,A,"Configuration of incapable logical units failed"},
625   {0x67,0x02,A,"Add logical unit failed"},
626   {0x67,0x03,A,"Modification of logical unit failed"},
627   {0x67,0x04,A,"Exchange of logical unit failed"},
628   {0x67,0x05,A,"Remove of logical unit failed"},
629   {0x67,0x06,A,"Attachment of logical unit failed"},
630   {0x67,0x07,A,"Creation of logical unit failed"},
631   {0x67,0x08,A,"Assign failure occurred"},
632   {0x67,0x09,A,"Multiply assigned logical unit"},
633   {0x68,0x00,A,"Logical unit not configured"},
634   {0x69,0x00,A,"Data loss on logical unit"},
635   {0x69,0x01,A,"Multiple logical unit failures"},
636   {0x69,0x02,A,"Parity/data mismatch"},
637   {0x6A,0x00,A,"Informational,refer to log"},
638   {0x6B,0x00,A,"State change has occurred"},
639   {0x6B,0x01,A,"Redundancy level got better"},
640   {0x6B,0x02,A,"Redundancy level got worse"},
641   {0x6C,0x00,A,"Rebuild failure occurred"},
642   {0x6D,0x00,A,"Recalculate failure occurred"},
643   {0x6E,0x00,A,"Command to logical unit failed"},
644   {0x6F,0x00,R,"Copy protection key exchange failure - authentication failure"},
645   {0x6F,0x01,R,"Copy protection key exchange failure - key not present"},
646   {0x6F,0x02,R,"Copy protection key exchange failure - key not established"},
647   {0x6F,0x03,R,"Read of scrambled sector without authentication"},
648   {0x6F,0x04,R,"Media region code is mismatched to logical unit region"},
649   {0x6F,0x05,R,"Drive region must be permanent/region reset count error"},
650   /*
651    * FIXME(eric) - need a way to represent wildcards here.
652    */
653   {0x70,0x00,T,"Decompression exception short algorithm id of nn"},
654   {0x71,0x00,T,"Decompression exception long algorithm id"},
655   {0x72,0x00,R,"Session fixation error"},
656   {0x72,0x01,R,"Session fixation error writing lead-in"},
657   {0x72,0x02,R,"Session fixation error writing lead-out"},
658   {0x72,0x03,R,"Session fixation error - incomplete track in session"},
659   {0x72,0x04,R,"Empty or partially written reserved track"},
660   {0x72,0x05,R,"No more track reservations allowed"},
661   {0x73,0x00,R,"Cd control error"},
662   {0x73,0x01,R,"Power calibration area almost full"},
663   {0x73,0x02,R,"Power calibration area is full"},
664   {0x73,0x03,R,"Power calibration area error"},
665   {0x73,0x04,R,"Program memory area update failure"},
666   {0x73,0x05,R,"Program memory area is full"},
667   {0x73,0x06,R,"RMA/PMA is full"},
668   {0, 0, 0, NULL}
669 };
670 #endif
671 
672 #if (CONSTANTS & CONST_SENSE)
673 static const char *snstext[] = {
674     "None",                     /* There is no sense information */
675     "Recovered Error",          /* The last command completed successfully
676                                    but used error correction */
677     "Not Ready",                /* The addressed target is not ready */
678     "Medium Error",             /* Data error detected on the medium */
679     "Hardware Error",           /* Controller or device failure */
680     "Illegal Request",
681     "Unit Attention",           /* Removable medium was changed, or
682                                    the target has been reset */
683     "Data Protect",             /* Access to the data is blocked */
684     "Blank Check",              /* Reached unexpected written or unwritten
685                                    region of the medium */
686     "Key=9",                    /* Vendor specific */
687     "Copy Aborted",             /* COPY or COMPARE was aborted */
688     "Aborted Command",          /* The target aborted the command */
689     "Equal",                    /* A SEARCH DATA command found data equal */
690     "Volume Overflow",          /* Medium full with still data to be written */
691     "Miscompare",               /* Source data and data on the medium
692                                    do not agree */
693     "Key=15"                    /* Reserved */
694 };
695 #endif
696 
697 /* Print sense information */
698 static
print_sense_internal(const char * devclass,const unsigned char * sense_buffer,kdev_t dev)699 void print_sense_internal(const char * devclass,
700 			  const unsigned char * sense_buffer,
701 			  kdev_t dev)
702 {
703     int i, s;
704     int sense_class, valid, code, info;
705     const char * error = NULL;
706 
707     sense_class = (sense_buffer[0] >> 4) & 0x07;
708     code = sense_buffer[0] & 0xf;
709     valid = sense_buffer[0] & 0x80;
710 
711     if (sense_class == 7) {	/* extended sense data */
712 	s = sense_buffer[7] + 8;
713 	if(s > SCSI_SENSE_BUFFERSIZE)
714 	   s = SCSI_SENSE_BUFFERSIZE;
715 
716 	info = ((sense_buffer[3] << 24) | (sense_buffer[4] << 16) |
717 		(sense_buffer[5] << 8) | sense_buffer[6]);
718 	if (info || valid) {
719 		printk("Info fld=0x%x", info);
720 		if (!valid)	/* info data not according to standard */
721 			printk(" (nonstd)");
722 		printk(", ");
723 	}
724 	if (sense_buffer[2] & 0x80)
725            printk( "FMK ");	/* current command has read a filemark */
726 	if (sense_buffer[2] & 0x40)
727            printk( "EOM ");	/* end-of-medium condition exists */
728 	if (sense_buffer[2] & 0x20)
729            printk( "ILI ");	/* incorrect block length requested */
730 
731 	switch (code) {
732 	case 0x0:
733 	    error = "Current";	/* error concerns current command */
734 	    break;
735 	case 0x1:
736 	    error = "Deferred";	/* error concerns some earlier command */
737             	/* e.g., an earlier write to disk cache succeeded, but
738                    now the disk discovers that it cannot write the data */
739 	    break;
740 	default:
741 	    error = "Invalid";
742 	}
743 
744 	printk("%s ", error);
745 
746 #if (CONSTANTS & CONST_SENSE)
747 	printk( "%s%s: sense key %s\n", devclass,
748 	       kdevname(dev), snstext[sense_buffer[2] & 0x0f]);
749 #else
750 	printk("%s%s: sns = %2x %2x\n", devclass,
751 	       kdevname(dev), sense_buffer[0], sense_buffer[2]);
752 #endif
753 
754 	/* Check to see if additional sense information is available */
755 	if(sense_buffer[7] + 7 < 13 ||
756 	   (sense_buffer[12] == 0  && sense_buffer[13] ==  0)) goto done;
757 
758 #if (CONSTANTS & CONST_XSENSE)
759 	for(i=0; additional[i].text; i++)
760 	    if(additional[i].code1 == sense_buffer[12] &&
761 	       additional[i].code2 == sense_buffer[13])
762 		printk("Additional sense indicates %s\n", additional[i].text);
763 
764 	for(i=0; additional2[i].text; i++)
765 	    if(additional2[i].code1 == sense_buffer[12] &&
766 	       additional2[i].code2_min >= sense_buffer[13]  &&
767 	       additional2[i].code2_max <= sense_buffer[13]) {
768 		printk("Additional sense indicates ");
769 		printk(additional2[i].text, sense_buffer[13]);
770 		printk("\n");
771 	    };
772 #else
773 	printk("ASC=%2x ASCQ=%2x\n", sense_buffer[12], sense_buffer[13]);
774 #endif
775     } else {	/* non-extended sense data */
776 
777          /*
778           * Standard says:
779           *    sense_buffer[0] & 0200 : address valid
780           *    sense_buffer[0] & 0177 : vendor-specific error code
781           *    sense_buffer[1] & 0340 : vendor-specific
782           *    sense_buffer[1..3] : 21-bit logical block address
783           */
784 
785 #if (CONSTANTS & CONST_SENSE)
786 	if (sense_buffer[0] < 15)
787 	    printk("%s%s: old sense key %s\n", devclass,
788 	      kdevname(dev), snstext[sense_buffer[0] & 0x0f]);
789 	else
790 #endif
791 	    printk("%s%s: sns = %2x %2x\n", devclass,
792 	      kdevname(dev), sense_buffer[0], sense_buffer[2]);
793 
794 	printk("Non-extended sense class %d code 0x%0x\n", sense_class, code);
795 	s = 4;
796     }
797 
798  done:
799 #if !(CONSTANTS & CONST_SENSE)
800     printk("Raw sense data:");
801     for (i = 0; i < s; ++i)
802 	printk("0x%02x ", sense_buffer[i]);
803     printk("\n");
804 #endif
805     return;
806 }
807 
print_sense(const char * devclass,Scsi_Cmnd * SCpnt)808 void print_sense(const char * devclass, Scsi_Cmnd * SCpnt)
809 {
810 	print_sense_internal(devclass, SCpnt->sense_buffer,
811 			     SCpnt->request.rq_dev);
812 }
813 
print_req_sense(const char * devclass,Scsi_Request * SRpnt)814 void print_req_sense(const char * devclass, Scsi_Request * SRpnt)
815 {
816 	print_sense_internal(devclass, SRpnt->sr_sense_buffer,
817 			     SRpnt->sr_request.rq_dev);
818 }
819 
820 #if (CONSTANTS & CONST_MSG)
821 static const char *one_byte_msgs[] = {
822 /* 0x00 */ "Command Complete", NULL, "Save Pointers",
823 /* 0x03 */ "Restore Pointers", "Disconnect", "Initiator Error",
824 /* 0x06 */ "Abort", "Message Reject", "Nop", "Message Parity Error",
825 /* 0x0a */ "Linked Command Complete", "Linked Command Complete w/flag",
826 /* 0x0c */ "Bus device reset", "Abort Tag", "Clear Queue",
827 /* 0x0f */ "Initiate Recovery", "Release Recovery"
828 };
829 
830 #define NO_ONE_BYTE_MSGS (sizeof(one_byte_msgs)  / sizeof (const char *))
831 
832 static const char *two_byte_msgs[] = {
833 /* 0x20 */ "Simple Queue Tag", "Head of Queue Tag", "Ordered Queue Tag"
834 /* 0x23 */ "Ignore Wide Residue"
835 };
836 
837 #define NO_TWO_BYTE_MSGS (sizeof(two_byte_msgs)  / sizeof (const char *))
838 
839 static const char *extended_msgs[] = {
840 /* 0x00 */ "Modify Data Pointer", "Synchronous Data Transfer Request",
841 /* 0x02 */ "SCSI-I Extended Identify", "Wide Data Transfer Request"
842 };
843 
844 #define NO_EXTENDED_MSGS (sizeof(two_byte_msgs)  / sizeof (const char *))
845 #endif /* (CONSTANTS & CONST_MSG) */
846 
print_msg(const unsigned char * msg)847 int print_msg (const unsigned char *msg) {
848     int len = 0, i;
849     if (msg[0] == EXTENDED_MESSAGE) {
850 	len = 3 + msg[1];
851 #if (CONSTANTS & CONST_MSG)
852 	if (msg[2] < NO_EXTENDED_MSGS)
853 	    printk ("%s ", extended_msgs[msg[2]]);
854 	else
855 	    printk ("Extended Message, reserved code (0x%02x) ", (int) msg[2]);
856 	switch (msg[2]) {
857 	case EXTENDED_MODIFY_DATA_POINTER:
858 	    printk("pointer = %d", (int) (msg[3] << 24) | (msg[4] << 16) |
859 		   (msg[5] << 8) | msg[6]);
860 	    break;
861 	case EXTENDED_SDTR:
862 	    printk("period = %d ns, offset = %d", (int) msg[3] * 4, (int)
863 		   msg[4]);
864 	    break;
865 	case EXTENDED_WDTR:
866 	    printk("width = 2^%d bytes", msg[3]);
867 	    break;
868 	default:
869 	    for (i = 2; i < len; ++i)
870 		printk("%02x ", msg[i]);
871 	}
872 #else
873 	for (i = 0; i < len; ++i)
874 	    printk("%02x ", msg[i]);
875 #endif
876 	/* Identify */
877     } else if (msg[0] & 0x80) {
878 #if (CONSTANTS & CONST_MSG)
879 	printk("Identify disconnect %sallowed %s %d ",
880 	       (msg[0] & 0x40) ? "" : "not ",
881 	       (msg[0] & 0x20) ? "target routine" : "lun",
882 	       msg[0] & 0x7);
883 #else
884 	printk("%02x ", msg[0]);
885 #endif
886 	len = 1;
887 	/* Normal One byte */
888     } else if (msg[0] < 0x1f) {
889 #if (CONSTANTS & CONST_MSG)
890 	if (msg[0] < NO_ONE_BYTE_MSGS)
891 	    printk(one_byte_msgs[msg[0]]);
892 	else
893 	    printk("reserved (%02x) ", msg[0]);
894 #else
895 	printk("%02x ", msg[0]);
896 #endif
897 	len = 1;
898 	/* Two byte */
899     } else if (msg[0] <= 0x2f) {
900 #if (CONSTANTS & CONST_MSG)
901 	if ((msg[0] - 0x20) < NO_TWO_BYTE_MSGS)
902 	    printk("%s %02x ", two_byte_msgs[msg[0] - 0x20],
903 		   msg[1]);
904 	else
905 	    printk("reserved two byte (%02x %02x) ",
906 		   msg[0], msg[1]);
907 #else
908 	printk("%02x %02x", msg[0], msg[1]);
909 #endif
910 	len = 2;
911     } else
912 #if (CONSTANTS & CONST_MSG)
913 	printk(reserved);
914 #else
915     printk("%02x ", msg[0]);
916 #endif
917     return len;
918 }
919 
print_Scsi_Cmnd(Scsi_Cmnd * cmd)920 void print_Scsi_Cmnd (Scsi_Cmnd *cmd) {
921     printk("scsi%d : destination target %d, lun %d\n",
922 	   cmd->host->host_no,
923 	   cmd->target,
924 	   cmd->lun);
925     printk("        command = ");
926     print_command (cmd->cmnd);
927 }
928 
929 #if (CONSTANTS & CONST_HOST)
930 static const char * hostbyte_table[]={
931 "DID_OK", "DID_NO_CONNECT", "DID_BUS_BUSY", "DID_TIME_OUT", "DID_BAD_TARGET",
932 "DID_ABORT", "DID_PARITY", "DID_ERROR", "DID_RESET", "DID_BAD_INTR",
933 "DID_PASSTHROUGH", "DID_SOFT_ERROR", NULL};
934 
print_hostbyte(int scsiresult)935 void print_hostbyte(int scsiresult)
936 {   static int maxcode=0;
937     int i;
938 
939     if(!maxcode) {
940 	for(i=0;hostbyte_table[i];i++) ;
941 	maxcode=i-1;
942     }
943     printk("Hostbyte=0x%02x",host_byte(scsiresult));
944     if(host_byte(scsiresult)>maxcode) {
945 	printk("is invalid ");
946 	return;
947     }
948     printk("(%s) ",hostbyte_table[host_byte(scsiresult)]);
949 }
950 #else
print_hostbyte(int scsiresult)951 void print_hostbyte(int scsiresult)
952 {   printk("Hostbyte=0x%02x ",host_byte(scsiresult));
953 }
954 #endif
955 
956 #if (CONSTANTS & CONST_DRIVER)
957 static const char * driverbyte_table[]={
958 "DRIVER_OK", "DRIVER_BUSY", "DRIVER_SOFT",  "DRIVER_MEDIA", "DRIVER_ERROR",
959 "DRIVER_INVALID", "DRIVER_TIMEOUT", "DRIVER_HARD",NULL };
960 
961 static const char * driversuggest_table[]={"SUGGEST_OK",
962 "SUGGEST_RETRY", "SUGGEST_ABORT", "SUGGEST_REMAP", "SUGGEST_DIE",
963 unknown,unknown,unknown, "SUGGEST_SENSE",NULL};
964 
965 
print_driverbyte(int scsiresult)966 void print_driverbyte(int scsiresult)
967 {   static int driver_max=0,suggest_max=0;
968     int i,dr=driver_byte(scsiresult)&DRIVER_MASK,
969 	su=(driver_byte(scsiresult)&SUGGEST_MASK)>>4;
970 
971     if(!driver_max) {
972         for(i=0;driverbyte_table[i];i++) ;
973         driver_max=i;
974 	for(i=0;driversuggest_table[i];i++) ;
975 	suggest_max=i;
976     }
977     printk("Driverbyte=0x%02x",driver_byte(scsiresult));
978     printk("(%s,%s) ",
979 	dr<driver_max  ? driverbyte_table[dr]:"invalid",
980 	su<suggest_max ? driversuggest_table[su]:"invalid");
981 }
982 #else
print_driverbyte(int scsiresult)983 void print_driverbyte(int scsiresult)
984 {   printk("Driverbyte=0x%02x ",driver_byte(scsiresult));
985 }
986 #endif
987 
988 /*
989  * Overrides for Emacs so that we almost follow Linus's tabbing style.
990  * Emacs will notice this stuff at the end of the file and automatically
991  * adjust the settings for this buffer only.  This must remain at the end
992  * of the file.
993  * ---------------------------------------------------------------------------
994  * Local variables:
995  * c-indent-level: 4
996  * c-brace-imaginary-offset: 0
997  * c-brace-offset: -4
998  * c-argdecl-indent: 4
999  * c-label-offset: -4
1000  * c-continued-statement-offset: 4
1001  * c-continued-brace-offset: 0
1002  * indent-tabs-mode: nil
1003  * tab-width: 8
1004  * End:
1005  */
1006