2 * ASCII values for a number of symbolic constants, printing functions, 4 * Additions for SCSI 2 and Linux 2.2.x by D. Gilbert (990422) 9 #include <linux/module.h> 11 #include <linux/config.h> 12 #include <linux/blk.h> 13 #include <linux/kernel.h> 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 26 static const char unknown
[] ="UNKNOWN"; 28 #ifdef CONFIG_SCSI_CONSTANTS 32 #define CONSTANTS (CONST_COMMAND | CONST_STATUS | CONST_SENSE | CONST_XSENSE \ 33 | CONST_CMND | CONST_MSG | CONST_HOST | CONST_DRIVER) 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
, 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", 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", 60 /* 3d-3f */"Update Block","Read Long","Write Long", 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
, 77 /* The following are 12 byte commands in group 5 */ 78 static const char*group_5_commands
[] = { 79 /* a0-a5 */ unknown
, unknown
, unknown
, unknown
, unknown
, 80 "Move medium/play audio(12)", 81 /* a6-a9 */"Exchange medium", unknown
,"Read(12)","Play track relative(12)", 82 /* aa-ae */"Write(12)", unknown
,"Erase(12)", unknown
, 83 "Write and verify(12)", 84 /* af-b1 */"Verify(12)","Search data high(12)","Search data equal(12)", 85 /* b2-b4 */"Search data low(12)","Set limits(12)", unknown
, 86 /* b5-b6 */"Request volume element address","Send volume tag", 87 /* b7-b9 */"Read defect data(12)","Read element status", unknown
, 88 /* ba-bf */ unknown
, unknown
, unknown
, unknown
, unknown
, unknown
, 93 #define group(opcode) (((opcode) >> 5) & 7) 95 #define RESERVED_GROUP 0 96 #define VENDOR_GROUP 1 98 static const char**commands
[] = { 99 group_0_commands
, group_1_commands
, group_2_commands
, 100 (const char**) RESERVED_GROUP
, (const char**) RESERVED_GROUP
, 101 group_5_commands
, (const char**) VENDOR_GROUP
, 102 (const char**) VENDOR_GROUP
105 static const char reserved
[] ="RESERVED"; 106 static const char vendor
[] ="VENDOR SPECIFIC"; 108 static voidprint_opcode(int opcode
) { 109 const char**table
= commands
[group(opcode
) ]; 110 switch((unsigned long) table
) { 112 printk("%s(0x%02x) ", reserved
, opcode
); 115 printk("%s(0x%02x) ", vendor
, opcode
); 118 if(table
[opcode
&0x1f] != unknown
) 119 printk("%s ",table
[opcode
&0x1f]); 121 printk("%s(0x%02x) ", unknown
, opcode
); 125 #else/* CONST & CONST_COMMAND */ 126 static voidprint_opcode(int opcode
) { 127 printk("0x%02x ", opcode
); 131 voidprint_command(unsigned char*command
) { 133 print_opcode(command
[0]); 134 for( i
=1, s
=COMMAND_SIZE(command
[0]); i
< s
; ++i
) 135 printk("%02x ", command
[i
]); 139 #if (CONSTANTS & CONST_STATUS) 140 static const char* statuses
[] = { 141 /* 0-4 */"Good","Check Condition","Condition Met", unknown
,"Busy", 142 /* 5-9 */ unknown
, unknown
, unknown
,"Intermediate", unknown
, 143 /* a-c */"Intermediate-Condition Met", unknown
,"Reservation Conflict", 144 /* d-10 */ unknown
, unknown
, unknown
, unknown
, 145 /* 11-14 */"Command Terminated", unknown
, unknown
,"Queue Full", 146 /* 15-1a */ unknown
, unknown
, unknown
, unknown
, unknown
, unknown
, 147 /* 1b-1f */ unknown
, unknown
, unknown
, unknown
, unknown
, 151 voidprint_status(int status
) { 152 status
= (status
>>1) &0x1f; 153 #if (CONSTANTS & CONST_STATUS) 154 printk("%s ",statuses
[status
]); 156 printk("0x%0x ", status
); 160 #if (CONSTANTS & CONST_XSENSE) 161 #define D 0x001/* DIRECT ACCESS DEVICE (disk) */ 162 #define T 0x002/* SEQUENTIAL ACCESS DEVICE (tape) */ 163 #define L 0x004/* PRINTER DEVICE */ 164 #define P 0x008/* PROCESSOR DEVICE */ 165 #define W 0x010/* WRITE ONCE READ MULTIPLE DEVICE */ 166 #define R 0x020/* READ ONLY (CD-ROM) DEVICE */ 167 #define S 0x040/* SCANNER DEVICE */ 168 #define O 0x080/* OPTICAL MEMORY DEVICE */ 169 #define M 0x100/* MEDIA CHANGER DEVICE */ 170 #define C 0x200/* COMMUNICATION DEVICE */ 173 unsigned char code1
, code2
; 174 unsigned short int devices
; 179 unsigned char code1
, code2_min
, code2_max
; 180 unsigned short int devices
; 184 static struct error_info2 additional2
[] = 186 {0x40,0x00,0x7f,D
,"Ram failure (%x)"}, 187 {0x40,0x80,0xff,D
|T
|L
|P
|W
|R
|S
|O
|M
|C
,"Diagnostic failure on component (%x)"}, 188 {0x41,0x00,0xff,D
,"Data path failure (%x)"}, 189 {0x42,0x00,0xff,D
,"Power-on or self-test failure (%x)"}, 193 static struct error_info additional
[] = 195 {0x00,0x01,T
,"Filemark detected"}, 196 {0x00,0x02,T
|S
,"End-of-partition/medium detected"}, 197 {0x00,0x03,T
,"Setmark detected"}, 198 {0x00,0x04,T
|S
,"Beginning-of-partition/medium detected"}, 199 {0x00,0x05,T
|S
,"End-of-data detected"}, 200 {0x00,0x06,D
|T
|L
|P
|W
|R
|S
|O
|M
|C
,"I/O process terminated"}, 201 {0x00,0x11,R
,"Audio play operation in progress"}, 202 {0x00,0x12,R
,"Audio play operation paused"}, 203 {0x00,0x13,R
,"Audio play operation successfully completed"}, 204 {0x00,0x14,R
,"Audio play operation stopped due to error"}, 205 {0x00,0x15,R
,"No current audio status to return"}, 206 {0x01,0x00,D
|W
|O
,"No index/sector signal"}, 207 {0x02,0x00,D
|W
|R
|O
|M
,"No seek complete"}, 208 {0x03,0x00,D
|T
|L
|W
|S
|O
,"Peripheral device write fault"}, 209 {0x03,0x01,T
,"No write current"}, 210 {0x03,0x02,T
,"Excessive write errors"}, 211 {0x04,0x00,D
|T
|L
|P
|W
|R
|S
|O
|M
|C
, 212 "Logical unit not ready, cause not reportable"}, 213 {0x04,0x01,D
|T
|L
|P
|W
|R
|S
|O
|M
|C
, 214 "Logical unit is in process of becoming ready"}, 215 {0x04,0x02,D
|T
|L
|P
|W
|R
|S
|O
|M
|C
, 216 "Logical unit not ready, initializing command required"}, 217 {0x04,0x03,D
|T
|L
|P
|W
|R
|S
|O
|M
|C
, 218 "Logical unit not ready, manual intervention required"}, 219 {0x04,0x04,D
|T
|L
|O
,"Logical unit not ready, format in progress"}, 220 {0x05,0x00,D
|T
|L
|W
|R
|S
|O
|M
|C
,"Logical unit does not respond to selection"}, 221 {0x06,0x00,D
|W
|R
|O
|M
,"No reference position found"}, 222 {0x07,0x00,D
|T
|L
|W
|R
|S
|O
|M
,"Multiple peripheral devices selected"}, 223 {0x08,0x00,D
|T
|L
|W
|R
|S
|O
|M
|C
,"Logical unit communication failure"}, 224 {0x08,0x01,D
|T
|L
|W
|R
|S
|O
|M
|C
,"Logical unit communication time-out"}, 225 {0x08,0x02,D
|T
|L
|W
|R
|S
|O
|M
|C
,"Logical unit communication parity error"}, 226 {0x09,0x00,D
|T
|W
|R
|O
,"Track following error"}, 227 {0x09,0x01,W
|R
|O
,"Tracking servo failure"}, 228 {0x09,0x02,W
|R
|O
,"Focus servo failure"}, 229 {0x09,0x03,W
|R
|O
,"Spindle servo failure"}, 230 {0x0A,0x00,D
|T
|L
|P
|W
|R
|S
|O
|M
|C
,"Error log overflow"}, 231 {0x0C,0x00,T
|S
,"Write error"}, 232 {0x0C,0x01,D
|W
|O
,"Write error recovered with auto reallocation"}, 233 {0x0C,0x02,D
|W
|O
,"Write error - auto reallocation failed"}, 234 {0x10,0x00,D
|W
|O
,"Id crc or ecc error"}, 235 {0x11,0x00,D
|T
|W
|R
|S
|O
,"Unrecovered read error"}, 236 {0x11,0x01,D
|T
|W
|S
|O
,"Read retries exhausted"}, 237 {0x11,0x02,D
|T
|W
|S
|O
,"Error too long to correct"}, 238 {0x11,0x03,D
|T
|W
|S
|O
,"Multiple read errors"}, 239 {0x11,0x04,D
|W
|O
,"Unrecovered read error - auto reallocate failed"}, 240 {0x11,0x05,W
|R
|O
,"L-ec uncorrectable error"}, 241 {0x11,0x06,W
|R
|O
,"Circ unrecovered error"}, 242 {0x11,0x07,W
|O
,"Data resynchronization error"}, 243 {0x11,0x08,T
,"Incomplete block read"}, 244 {0x11,0x09,T
,"No gap found"}, 245 {0x11,0x0A,D
|T
|O
,"Miscorrected error"}, 246 {0x11,0x0B,D
|W
|O
,"Unrecovered read error - recommend reassignment"}, 247 {0x11,0x0C,D
|W
|O
,"Unrecovered read error - recommend rewrite the data"}, 248 {0x12,0x00,D
|W
|O
,"Address mark not found for id field"}, 249 {0x13,0x00,D
|W
|O
,"Address mark not found for data field"}, 250 {0x14,0x00,D
|T
|L
|W
|R
|S
|O
,"Recorded entity not found"}, 251 {0x14,0x01,D
|T
|W
|R
|O
,"Record not found"}, 252 {0x14,0x02,T
,"Filemark or setmark not found"}, 253 {0x14,0x03,T
,"End-of-data not found"}, 254 {0x14,0x04,T
,"Block sequence error"}, 255 {0x15,0x00,D
|T
|L
|W
|R
|S
|O
|M
,"Random positioning error"}, 256 {0x15,0x01,D
|T
|L
|W
|R
|S
|O
|M
,"Mechanical positioning error"}, 257 {0x15,0x02,D
|T
|W
|R
|O
,"Positioning error detected by read of medium"}, 258 {0x16,0x00,D
|W
|O
,"Data synchronization mark error"}, 259 {0x17,0x00,D
|T
|W
|R
|S
|O
,"Recovered data with no error correction applied"}, 260 {0x17,0x01,D
|T
|W
|R
|S
|O
,"Recovered data with retries"}, 261 {0x17,0x02,D
|T
|W
|R
|O
,"Recovered data with positive head offset"}, 262 {0x17,0x03,D
|T
|W
|R
|O
,"Recovered data with negative head offset"}, 263 {0x17,0x04,W
|R
|O
,"Recovered data with retries and/or circ applied"}, 264 {0x17,0x05,D
|W
|R
|O
,"Recovered data using previous sector id"}, 265 {0x17,0x06,D
|W
|O
,"Recovered data without ecc - data auto-reallocated"}, 266 {0x17,0x07,D
|W
|O
,"Recovered data without ecc - recommend reassignment"}, 267 {0x18,0x00,D
|T
|W
|R
|O
,"Recovered data with error correction applied"}, 268 {0x18,0x01,D
|W
|R
|O
,"Recovered data with error correction and retries applied"}, 269 {0x18,0x02,D
|W
|R
|O
,"Recovered data - data auto-reallocated"}, 270 {0x18,0x03,R
,"Recovered data with circ"}, 271 {0x18,0x04,R
,"Recovered data with lec"}, 272 {0x18,0x05,D
|W
|R
|O
,"Recovered data - recommend reassignment"}, 273 {0x19,0x00,D
|O
,"Defect list error"}, 274 {0x19,0x01,D
|O
,"Defect list not available"}, 275 {0x19,0x02,D
|O
,"Defect list error in primary list"}, 276 {0x19,0x03,D
|O
,"Defect list error in grown list"}, 277 {0x1A,0x00,D
|T
|L
|P
|W
|R
|S
|O
|M
|C
,"Parameter list length error"}, 278 {0x1B,0x00,D
|T
|L
|P
|W
|R
|S
|O
|M
|C
,"Synchronous data transfer error"}, 279 {0x1C,0x00,D
|O
,"Defect list not found"}, 280 {0x1C,0x01,D
|O
,"Primary defect list not found"}, 281 {0x1C,0x02,D
|O
,"Grown defect list not found"}, 282 {0x1D,0x00,D
|W
|O
,"Miscompare during verify operation"}, 283 {0x1E,0x00,D
|W
|O
,"Recovered id with ecc correction"}, 284 {0x20,0x00,D
|T
|L
|P
|W
|R
|S
|O
|M
|C
,"Invalid command operation code"}, 285 {0x21,0x00,D
|T
|W
|R
|O
|M
,"Logical block address out of range"}, 286 {0x21,0x01,M
,"Invalid element address"}, 287 {0x22,0x00,D
,"Illegal function (should use 20 00, 24 00, or 26 00)"}, 288 {0x24,0x00,D
|T
|L
|P
|W
|R
|S
|O
|M
|C
,"Invalid field in cdb"}, 289 {0x25,0x00,D
|T
|L
|P
|W
|R
|S
|O
|M
|C
,"Logical unit not supported"}, 290 {0x26,0x00,D
|T
|L
|P
|W
|R
|S
|O
|M
|C
,"Invalid field in parameter list"}, 291 {0x26,0x01,D
|T
|L
|P
|W
|R
|S
|O
|M
|C
,"Parameter not supported"}, 292 {0x26,0x02,D
|T
|L
|P
|W
|R
|S
|O
|M
|C
,"Parameter value invalid"}, 293 {0x26,0x03,D
|T
|L
|P
|W
|R
|S
|O
|M
|C
,"Threshold parameters not supported"}, 294 {0x27,0x00,D
|T
|W
|O
,"Write protected"}, 295 {0x28,0x00,D
|T
|L
|P
|W
|R
|S
|O
|M
|C
,"Not ready to ready transition (medium may have changed)"}, 296 {0x28,0x01,M
,"Import or export element accessed"}, 297 {0x29,0x00,D
|T
|L
|P
|W
|R
|S
|O
|M
|C
,"Power on, reset, or bus device reset occurred"}, 298 {0x2A,0x00,D
|T
|L
|W
|R
|S
|O
|M
|C
,"Parameters changed"}, 299 {0x2A,0x01,D
|T
|L
|W
|R
|S
|O
|M
|C
,"Mode parameters changed"}, 300 {0x2A,0x02,D
|T
|L
|W
|R
|S
|O
|M
|C
,"Log parameters changed"}, 301 {0x2B,0x00,D
|T
|L
|P
|W
|R
|S
|O
|C
,"Copy cannot execute since host cannot disconnect"}, 302 {0x2C,0x00,D
|T
|L
|P
|W
|R
|S
|O
|M
|C
,"Command sequence error"}, 303 {0x2C,0x01,S
,"Too many windows specified"}, 304 {0x2C,0x02,S
,"Invalid combination of windows specified"}, 305 {0x2D,0x00,T
,"Overwrite error on update in place"}, 306 {0x2F,0x00,D
|T
|L
|P
|W
|R
|S
|O
|M
|C
,"Commands cleared by another initiator"}, 307 {0x30,0x00,D
|T
|W
|R
|O
|M
,"Incompatible medium installed"}, 308 {0x30,0x01,D
|T
|W
|R
|O
,"Cannot read medium - unknown format"}, 309 {0x30,0x02,D
|T
|W
|R
|O
,"Cannot read medium - incompatible format"}, 310 {0x30,0x03,D
|T
,"Cleaning cartridge installed"}, 311 {0x31,0x00,D
|T
|W
|O
,"Medium format corrupted"}, 312 {0x31,0x01,D
|L
|O
,"Format command failed"}, 313 {0x32,0x00,D
|W
|O
,"No defect spare location available"}, 314 {0x32,0x01,D
|W
|O
,"Defect list update failure"}, 315 {0x33,0x00,T
,"Tape length error"}, 316 {0x36,0x00,L
,"Ribbon, ink, or toner failure"}, 317 {0x37,0x00,D
|T
|L
|W
|R
|S
|O
|M
|C
,"Rounded parameter"}, 318 {0x39,0x00,D
|T
|L
|W
|R
|S
|O
|M
|C
,"Saving parameters not supported"}, 319 {0x3A,0x00,D
|T
|L
|W
|R
|S
|O
|M
,"Medium not present"}, 320 {0x3B,0x00,T
|L
,"Sequential positioning error"}, 321 {0x3B,0x01,T
,"Tape position error at beginning-of-medium"}, 322 {0x3B,0x02,T
,"Tape position error at end-of-medium"}, 323 {0x3B,0x03,L
,"Tape or electronic vertical forms unit not ready"}, 324 {0x3B,0x04,L
,"Slew failure"}, 325 {0x3B,0x05,L
,"Paper jam"}, 326 {0x3B,0x06,L
,"Failed to sense top-of-form"}, 327 {0x3B,0x07,L
,"Failed to sense bottom-of-form"}, 328 {0x3B,0x08,T
,"Reposition error"}, 329 {0x3B,0x09,S
,"Read past end of medium"}, 330 {0x3B,0x0A,S
,"Read past beginning of medium"}, 331 {0x3B,0x0B,S
,"Position past end of medium"}, 332 {0x3B,0x0C,S
,"Position past beginning of medium"}, 333 {0x3B,0x0D,M
,"Medium destination element full"}, 334 {0x3B,0x0E,M
,"Medium source element empty"}, 335 {0x3D,0x00,D
|T
|L
|P
|W
|R
|S
|O
|M
|C
,"Invalid bits in identify message"}, 336 {0x3E,0x00,D
|T
|L
|P
|W
|R
|S
|O
|M
|C
,"Logical unit has not self-configured yet"}, 337 {0x3F,0x00,D
|T
|L
|P
|W
|R
|S
|O
|M
|C
,"Target operating conditions have changed"}, 338 {0x3F,0x01,D
|T
|L
|P
|W
|R
|S
|O
|M
|C
,"Microcode has been changed"}, 339 {0x3F,0x02,D
|T
|L
|P
|W
|R
|S
|O
|M
|C
,"Changed operating definition"}, 340 {0x3F,0x03,D
|T
|L
|P
|W
|R
|S
|O
|M
|C
,"Inquiry data has changed"}, 341 {0x43,0x00,D
|T
|L
|P
|W
|R
|S
|O
|M
|C
,"Message error"}, 342 {0x44,0x00,D
|T
|L
|P
|W
|R
|S
|O
|M
|C
,"Internal target failure"}, 343 {0x45,0x00,D
|T
|L
|P
|W
|R
|S
|O
|M
|C
,"Select or reselect failure"}, 344 {0x46,0x00,D
|T
|L
|P
|W
|R
|S
|O
|M
|C
,"Unsuccessful soft reset"}, 345 {0x47,0x00,D
|T
|L
|P
|W
|R
|S
|O
|M
|C
,"Scsi parity error"}, 346 {0x48,0x00,D
|T
|L
|P
|W
|R
|S
|O
|M
|C
,"Initiator detected error message received"}, 347 {0x49,0x00,D
|T
|L
|P
|W
|R
|S
|O
|M
|C
,"Invalid message error"}, 348 {0x4A,0x00,D
|T
|L
|P
|W
|R
|S
|O
|M
|C
,"Command phase error"}, 349 {0x4B,0x00,D
|T
|L
|P
|W
|R
|S
|O
|M
|C
,"Data phase error"}, 350 {0x4C,0x00,D
|T
|L
|P
|W
|R
|S
|O
|M
|C
,"Logical unit failed self-configuration"}, 351 {0x4E,0x00,D
|T
|L
|P
|W
|R
|S
|O
|M
|C
,"Overlapped commands attempted"}, 352 {0x50,0x00,T
,"Write append error"}, 353 {0x50,0x01,T
,"Write append position error"}, 354 {0x50,0x02,T
,"Position error related to timing"}, 355 {0x51,0x00,T
|O
,"Erase failure"}, 356 {0x52,0x00,T
,"Cartridge fault"}, 357 {0x53,0x00,D
|T
|L
|W
|R
|S
|O
|M
,"Media load or eject failed"}, 358 {0x53,0x01,T
,"Unload tape failure"}, 359 {0x53,0x02,D
|T
|W
|R
|O
|M
,"Medium removal prevented"}, 360 {0x54,0x00,P
,"Scsi to host system interface failure"}, 361 {0x55,0x00,P
,"System resource failure"}, 362 {0x57,0x00,R
,"Unable to recover table-of-contents"}, 363 {0x58,0x00,O
,"Generation does not exist"}, 364 {0x59,0x00,O
,"Updated block read"}, 365 {0x5A,0x00,D
|T
|L
|P
|W
|R
|S
|O
|M
,"Operator request or state change input (unspecified)"}, 366 {0x5A,0x01,D
|T
|W
|R
|O
|M
,"Operator medium removal request"}, 367 {0x5A,0x02,D
|T
|W
|O
,"Operator selected write protect"}, 368 {0x5A,0x03,D
|T
|W
|O
,"Operator selected write permit"}, 369 {0x5B,0x00,D
|T
|L
|P
|W
|R
|S
|O
|M
,"Log exception"}, 370 {0x5B,0x01,D
|T
|L
|P
|W
|R
|S
|O
|M
,"Threshold condition met"}, 371 {0x5B,0x02,D
|T
|L
|P
|W
|R
|S
|O
|M
,"Log counter at maximum"}, 372 {0x5B,0x03,D
|T
|L
|P
|W
|R
|S
|O
|M
,"Log list codes exhausted"}, 373 {0x5C,0x00,D
|O
,"Rpl status change"}, 374 {0x5C,0x01,D
|O
,"Spindles synchronized"}, 375 {0x5C,0x02,D
|O
,"Spindles not synchronized"}, 376 {0x60,0x00,S
,"Lamp failure"}, 377 {0x61,0x00,S
,"Video acquisition error"}, 378 {0x61,0x01,S
,"Unable to acquire video"}, 379 {0x61,0x02,S
,"Out of focus"}, 380 {0x62,0x00,S
,"Scan head positioning error"}, 381 {0x63,0x00,R
,"End of user area encountered on this track"}, 382 {0x64,0x00,R
,"Illegal mode for this track"}, 387 #if (CONSTANTS & CONST_SENSE) 388 static const char*snstext
[] = { 389 "None",/* There is no sense information */ 390 "Recovered Error",/* The last command completed successfully 391 but used error correction */ 392 "Not Ready",/* The addressed target is not ready */ 393 "Medium Error",/* Data error detected on the medium */ 394 "Hardware Error",/* Controller or device failure */ 396 "Unit Attention",/* Removable medium was changed, or 397 the target has been reset */ 398 "Data Protect",/* Access to the data is blocked */ 399 "Blank Check",/* Reached unexpected written or unwritten 400 region of the medium */ 401 "Key=9",/* Vendor specific */ 402 "Copy Aborted",/* COPY or COMPARE was aborted */ 403 "Aborted Command",/* The target aborted the command */ 404 "Equal",/* A SEARCH DATA command found data equal */ 405 "Volume Overflow",/* Medium full with still data to be written */ 406 "Miscompare",/* Source data and data on the medium 408 "Key=15"/* Reserved */ 412 /* Print sense information */ 413 voidprint_sense(const char* devclass
, Scsi_Cmnd
* SCpnt
) 416 int sense_class
, valid
, code
; 417 unsigned char* sense_buffer
= SCpnt
->sense_buffer
; 418 const char* error
= NULL
; 420 sense_class
= (sense_buffer
[0] >>4) &0x07; 421 code
= sense_buffer
[0] &0xf; 422 valid
= sense_buffer
[0] &0x80; 424 if(sense_class
==7) {/* extended sense data */ 425 s
= sense_buffer
[7] +8; 426 if(s
>sizeof(SCpnt
->sense_buffer
)) 427 s
=sizeof(SCpnt
->sense_buffer
); 430 printk("[valid=0] "); 431 printk("Info fld=0x%x, ", (int)((sense_buffer
[3] <<24) | 432 (sense_buffer
[4] <<16) | (sense_buffer
[5] <<8) | 434 if(sense_buffer
[2] &0x80) 435 printk("FMK ");/* current command has read a filemark */ 436 if(sense_buffer
[2] &0x40) 437 printk("EOM ");/* end-of-medium condition exists */ 438 if(sense_buffer
[2] &0x20) 439 printk("ILI ");/* incorrect block length requested */ 443 error
="Current";/* error concerns current command */ 446 error
="Deferred";/* error concerns some earlier command */ 447 /* e.g., an earlier write to disk cache succeeded, but 448 now the disk discovers that it cannot write the data */ 454 printk("%s ", error
); 456 #if (CONSTANTS & CONST_SENSE) 457 printk("%s%s: sense key %s\n", devclass
, 458 kdevname(SCpnt
->request
.rq_dev
), snstext
[sense_buffer
[2] &0x0f]); 460 printk("%s%s: sns = %2x %2x\n", devclass
, 461 kdevname(SCpnt
->request
.rq_dev
), sense_buffer
[0], sense_buffer
[2]); 464 /* Check to see if additional sense information is available */ 465 if(sense_buffer
[7] +7<13|| 466 (sense_buffer
[12] ==0&& sense_buffer
[13] ==0))goto done
; 468 #if (CONSTANTS & CONST_XSENSE) 469 for(i
=0; additional
[i
].text
; i
++) 470 if(additional
[i
].code1
== sense_buffer
[12] && 471 additional
[i
].code2
== sense_buffer
[13]) 472 printk("Additional sense indicates %s\n", additional
[i
].text
); 474 for(i
=0; additional2
[i
].text
; i
++) 475 if(additional2
[i
].code1
== sense_buffer
[12] && 476 additional2
[i
].code2_min
>= sense_buffer
[13] && 477 additional2
[i
].code2_max
<= sense_buffer
[13]) { 478 printk("Additional sense indicates "); 479 printk(additional2
[i
].text
, sense_buffer
[13]); 483 printk("ASC=%2x ASCQ=%2x\n", sense_buffer
[12], sense_buffer
[13]); 485 }else{/* non-extended sense data */ 489 * sense_buffer[0] & 0200 : address valid 490 * sense_buffer[0] & 0177 : vendor-specific error code 491 * sense_buffer[1] & 0340 : vendor-specific 492 * sense_buffer[1..3] : 21-bit logical block address 495 #if (CONSTANTS & CONST_SENSE) 496 if(sense_buffer
[0] <15) 497 printk("%s%s: old sense key %s\n", devclass
, 498 kdevname(SCpnt
->request
.rq_dev
), snstext
[sense_buffer
[0] &0x0f]); 501 printk("%s%s: sns = %2x %2x\n", devclass
, 502 kdevname(SCpnt
->request
.rq_dev
), sense_buffer
[0], sense_buffer
[2]); 504 printk("Non-extended sense class %d code 0x%0x ", sense_class
, code
); 509 #if !(CONSTANTS & CONST_SENSE) 510 printk("Raw sense data:"); 511 for(i
=0; i
< s
; ++i
) 512 printk("0x%02x ", sense_buffer
[i
]); 518 #if (CONSTANTS & CONST_MSG) 519 static const char*one_byte_msgs
[] = { 520 /* 0x00 */"Command Complete", NULL
,"Save Pointers", 521 /* 0x03 */"Restore Pointers","Disconnect","Initiator Error", 522 /* 0x06 */"Abort","Message Reject","Nop","Message Parity Error", 523 /* 0x0a */"Linked Command Complete","Linked Command Complete w/flag", 524 /* 0x0c */"Bus device reset","Abort Tag","Clear Queue", 525 /* 0x0f */"Initiate Recovery","Release Recovery" 528 #define NO_ONE_BYTE_MSGS (sizeof(one_byte_msgs) / sizeof (const char *)) 530 static const char*two_byte_msgs
[] = { 531 /* 0x20 */"Simple Queue Tag","Head of Queue Tag","Ordered Queue Tag" 532 /* 0x23 */"Ignore Wide Residue" 535 #define NO_TWO_BYTE_MSGS (sizeof(two_byte_msgs) / sizeof (const char *)) 537 static const char*extended_msgs
[] = { 538 /* 0x00 */"Modify Data Pointer","Synchronous Data Transfer Request", 539 /* 0x02 */"SCSI-I Extended Identify","Wide Data Transfer Request" 542 #define NO_EXTENDED_MSGS (sizeof(two_byte_msgs) / sizeof (const char *)) 543 #endif/* (CONSTANTS & CONST_MSG) */ 545 intprint_msg(const unsigned char*msg
) { 547 if(msg
[0] == EXTENDED_MESSAGE
) { 549 #if (CONSTANTS & CONST_MSG) 550 if(msg
[2] < NO_EXTENDED_MSGS
) 551 printk("%s ", extended_msgs
[msg
[2]]); 553 printk("Extended Message, reserved code (0x%02x) ", (int) msg
[2]); 555 case EXTENDED_MODIFY_DATA_POINTER
: 556 printk("pointer = %d", (int) (msg
[3] <<24) | (msg
[4] <<16) | 557 (msg
[5] <<8) | msg
[6]); 560 printk("period = %d ns, offset = %d", (int) msg
[3] *4, (int) 564 printk("width = 2^%d bytes", msg
[3]); 567 for(i
=2; i
< len
; ++i
) 568 printk("%02x ", msg
[i
]); 571 for(i
=0; i
< len
; ++i
) 572 printk("%02x ", msg
[i
]); 575 }else if(msg
[0] &0x80) { 576 #if (CONSTANTS & CONST_MSG) 577 printk("Identify disconnect %sallowed %s %d ", 578 (msg
[0] &0x40) ?"":"not ", 579 (msg
[0] &0x20) ?"target routine":"lun", 582 printk("%02x ", msg
[0]); 585 /* Normal One byte */ 586 }else if(msg
[0] <0x1f) { 587 #if (CONSTANTS & CONST_MSG) 588 if(msg
[0] < NO_ONE_BYTE_MSGS
) 589 printk(one_byte_msgs
[msg
[0]]); 591 printk("reserved (%02x) ", msg
[0]); 593 printk("%02x ", msg
[0]); 597 }else if(msg
[0] <=0x2f) { 598 #if (CONSTANTS & CONST_MSG) 599 if((msg
[0] -0x20) < NO_TWO_BYTE_MSGS
) 600 printk("%s %02x ", two_byte_msgs
[msg
[0] -0x20], 603 printk("reserved two byte (%02x %02x) ", 606 printk("%02x %02x", msg
[0], msg
[1]); 610 #if (CONSTANTS & CONST_MSG) 613 printk("%02x ", msg
[0]); 618 voidprint_Scsi_Cmnd(Scsi_Cmnd
*cmd
) { 619 printk("scsi%d : destination target %d, lun %d\n", 623 printk(" command = "); 624 print_command(cmd
->cmnd
); 627 #if (CONSTANTS & CONST_HOST) 628 static const char* hostbyte_table
[]={ 629 "DID_OK","DID_NO_CONNECT","DID_BUS_BUSY","DID_TIME_OUT","DID_BAD_TARGET", 630 "DID_ABORT","DID_PARITY","DID_ERROR","DID_RESET","DID_BAD_INTR", 631 "DID_PASSTHROUGH","DID_SOFT_ERROR", NULL
}; 633 voidprint_hostbyte(int scsiresult
) 634 {static int maxcode
=0; 638 for(i
=0;hostbyte_table
[i
];i
++) ; 641 printk("Hostbyte=0x%02x",host_byte(scsiresult
)); 642 if(host_byte(scsiresult
)>maxcode
) { 643 printk("is invalid "); 646 printk("(%s) ",hostbyte_table
[host_byte(scsiresult
)]); 649 voidprint_hostbyte(int scsiresult
) 650 {printk("Hostbyte=0x%02x ",host_byte(scsiresult
)); 654 #if (CONSTANTS & CONST_DRIVER) 655 static const char* driverbyte_table
[]={ 656 "DRIVER_OK","DRIVER_BUSY","DRIVER_SOFT","DRIVER_MEDIA","DRIVER_ERROR", 657 "DRIVER_INVALID","DRIVER_TIMEOUT","DRIVER_HARD",NULL
}; 659 static const char* driversuggest_table
[]={"SUGGEST_OK", 660 "SUGGEST_RETRY","SUGGEST_ABORT","SUGGEST_REMAP","SUGGEST_DIE", 661 unknown
,unknown
,unknown
,"SUGGEST_SENSE",NULL
}; 664 voidprint_driverbyte(int scsiresult
) 665 {static int driver_max
=0,suggest_max
=0; 666 int i
,dr
=driver_byte(scsiresult
)&DRIVER_MASK
, 667 su
=(driver_byte(scsiresult
)&SUGGEST_MASK
)>>4; 670 for(i
=0;driverbyte_table
[i
];i
++) ; 672 for(i
=0;driversuggest_table
[i
];i
++) ; 675 printk("Driverbyte=0x%02x",driver_byte(scsiresult
)); 677 dr
<driver_max
? driverbyte_table
[dr
]:"invalid", 678 su
<suggest_max
? driversuggest_table
[su
]:"invalid"); 681 voidprint_driverbyte(int scsiresult
) 682 {printk("Driverbyte=0x%02x ",driver_byte(scsiresult
)); 687 * Overrides for Emacs so that we almost follow Linus's tabbing style. 688 * Emacs will notice this stuff at the end of the file and automatically 689 * adjust the settings for this buffer only. This must remain at the end 691 * --------------------------------------------------------------------------- 694 * c-brace-imaginary-offset: 0 696 * c-argdecl-indent: 4 698 * c-continued-statement-offset: 4 699 * c-continued-brace-offset: 0 700 * indent-tabs-mode: nil