root/drivers/scsi/constants.c

/* [previous][next][first][last][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. print_opcode
  2. print_opcode
  3. print_command
  4. print_status
  5. print_sense
  6. print_msg
  7. print_Scsi_Cmnd

   1 /* 
   2  * ASCII values for a number of symbolic constants, printing functions,
   3  * etc.
   4  */
   5 
   6 #ifdef MODULE
   7 /*
   8  * Don't import our own symbols, as this would severely mess up our
   9  * symbol tables.
  10  */
  11 #define _SCSI_SYMS_VER_
  12 #include <linux/autoconf.h>
  13 #include <linux/module.h>
  14 #include <linux/version.h>
  15 #else
  16 #define MOD_INC_USE_COUNT
  17 #define MOD_DEC_USE_COUNT
  18 #endif
  19 
  20 #include <linux/config.h>
  21 #include "../block/blk.h"
  22 #include <linux/kernel.h>
  23 #include "scsi.h"
  24 #include "hosts.h"
  25 
  26 #define CONST_COMMAND   0x01
  27 #define CONST_STATUS    0x02
  28 #define CONST_SENSE     0x04
  29 #define CONST_XSENSE    0x08
  30 #define CONST_CMND      0x10
  31 #define CONST_MSG       0x20
  32 
  33 static const char unknown[] = "UNKNOWN";
  34 
  35 #ifdef CONFIG_SCSI_CONSTANTS
  36 #ifdef CONSTANTS
  37 #undef CONSTANTS
  38 #endif
  39 #define CONSTANTS (CONST_COMMAND | CONST_STATUS | CONST_SENSE | CONST_XSENSE | CONST_CMND | CONST_MSG)
  40 #endif
  41 
  42 #if (CONSTANTS & CONST_COMMAND)
  43 static const char * group_0_commands[] = {
  44 /* 00-03 */ "Test Unit Ready", "Rezero Unit", unknown, "Request Sense",
  45 /* 04-07 */ "Format Unit", "Read Block Limits", unknown, "Reasssign Blocks",
  46 /* 08-0d */ "Read (6)", unknown, "Write (6)", "Seek (6)", unknown, unknown,
  47 /* 0e-12 */ unknown, "Read Reverse", "Write Filemarks", "Space", "Inquiry",  
  48 /* 13-16 */ unknown, "Recover Buffered Data", "Mode Select", "Reserve",
  49 /* 17-1b */ "Release", "Copy", "Erase", "Mode Sense", "Start/Stop Unit",
  50 /* 1c-1d */ "Receive Diagnostic", "Send Diagnostic", 
  51 /* 1e-1f */ "Prevent/Allow Medium Removal", unknown,
  52 };
  53 
  54 
  55 static const char *group_1_commands[] = {
  56 /* 20-22 */  unknown, unknown, unknown,
  57 /* 23-28 */ unknown, unknown, "Read Capacity", unknown, unknown, "Read (10)", 
  58 /* 29-2d */ unknown, "Write (10)", "Seek (10)", unknown, unknown, 
  59 /* 2e-31 */ "Write Verify","Verify", "Search High", "Search Equal", 
  60 /* 32-34 */ "Search Low", "Set Limits", "Prefetch or Read Position", 
  61 /* 35-37 */ "Synchronize Cache","Lock/Unlock Cache", "Read Defect Data", 
  62 /* 38-3c */ "Medium Scan", "Compare","Copy Verify", "Write Buffer", "Read Buffer", 
  63 /* 3d-3f */ "Update Block", "Read Long",  "Write Long",
  64 };
  65 
  66 
  67 static const char *group_2_commands[] = {
  68 /* 40-41 */ "Change Definition", "Write Same", 
  69 /* 42-48 */ unknown, unknown, unknown, unknown, unknown, unknown, unknown, 
  70 /* 49-4f */ unknown, unknown, unknown, "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 
  78 #define group(opcode) (((opcode) >> 5) & 7)
  79 
  80 #define RESERVED_GROUP  0
  81 #define VENDOR_GROUP    1
  82 #define NOTEXT_GROUP    2
  83 
  84 static const char **commands[] = {
  85     group_0_commands, group_1_commands, group_2_commands, 
  86     (const char **) RESERVED_GROUP, (const char **) RESERVED_GROUP, 
  87     (const char **) NOTEXT_GROUP, (const char **) VENDOR_GROUP, 
  88     (const char **) VENDOR_GROUP
  89 };
  90 
  91 static const char reserved[] = "RESERVED";
  92 static const char vendor[] = "VENDOR SPECIFIC";
  93 
  94 static void print_opcode(int opcode) {
     /* [previous][next][first][last][top][bottom][index][help] */
  95     const char **table = commands[ group(opcode) ];
  96     switch ((unsigned long) table) {
  97     case RESERVED_GROUP:
  98         printk("%s(0x%02x) ", reserved, opcode); 
  99         break;
 100     case NOTEXT_GROUP:
 101         printk("%s(0x%02x) ", unknown, opcode); 
 102         break;
 103     case VENDOR_GROUP:
 104         printk("%s(0x%02x) ", vendor, opcode); 
 105         break;
 106     default:
 107         printk("%s ",table[opcode & 0x1f]);
 108     }
 109 }
 110 #else /* CONST & CONST_COMMAND */
 111 static void print_opcode(int opcode) {
     /* [previous][next][first][last][top][bottom][index][help] */
 112     printk("0x%02x ", opcode);
 113 }
 114 #endif  
 115 
 116 void print_command (unsigned char *command) {
     /* [previous][next][first][last][top][bottom][index][help] */
 117     int i,s;
 118     print_opcode(command[0]);
 119     for ( i = 1, s = COMMAND_SIZE(command[0]); i < s; ++i) 
 120         printk("%02x ", command[i]);
 121     printk("\n");
 122 }
 123 
 124 #if (CONSTANTS & CONST_STATUS)
 125 static const char * statuses[] = {
 126 /* 0-4 */ "Good", "Check Condition", "Condition Good", unknown, "Busy", 
 127 /* 5-9 */ unknown, unknown, unknown, "Intermediate Good", unknown, 
 128 /* a-d */ "Intermediate Good", unknown, "Reservation Conflict", unknown,
 129 /* e-f */ unknown, unknown,
 130 };
 131 #endif
 132 
 133 void print_status (int status) {
     /* [previous][next][first][last][top][bottom][index][help] */
 134     status = (status >> 1) & 0xf;
 135 #if (CONSTANTS & CONST_STATUS)
 136     printk("%s ",statuses[status]);
 137 #else
 138     printk("0x%0x ", status); 
 139 #endif 
 140 }
 141 
 142 #if (CONSTANTS & CONST_XSENSE)
 143 #define D 0x001  /* DIRECT ACCESS DEVICE (disk) */
 144 #define T 0x002  /* SEQUENTIAL ACCESS DEVICE (tape) */
 145 #define L 0x004  /* PRINTER DEVICE */
 146 #define P 0x008  /* PROCESSOR DEVICE */
 147 #define W 0x010  /* WRITE ONCE READ MULTIPLE DEVICE */
 148 #define R 0x020  /* READ ONLY (CD-ROM) DEVICE */
 149 #define S 0x040  /* SCANNER DEVICE */
 150 #define O 0x080  /* OPTICAL MEMORY DEVICE */
 151 #define M 0x100  /* MEDIA CHANGER DEVICE */
 152 #define C 0x200  /* COMMUNICATION DEVICE */
 153 
 154 struct error_info{
 155     unsigned char code1, code2;
 156     unsigned short int devices;
 157     const char * text;
 158 };
 159 
 160 struct error_info2{
 161     unsigned char code1, code2_min, code2_max;
 162     unsigned short int devices;
 163     const char * text;
 164 };
 165 
 166 static struct error_info2 additional2[] =
 167 {
 168   {0x40,0x00,0x7f,D,"Ram failure (%x)"},
 169   {0x40,0x80,0xff,D|T|L|P|W|R|S|O|M|C,"Diagnostic failure on component (%x)"},
 170   {0x41,0x00,0xff,D,"Data path failure (%x)"},
 171   {0x42,0x00,0xff,D,"Power-on or self-test failure (%x)"},
 172   {0, 0, 0, 0, NULL}
 173 };
 174 
 175 static struct error_info additional[] =
 176 {
 177   {0x00,0x01,T,"Filemark detected"},
 178   {0x00,0x02,T|S,"End-of-partition/medium detected"},
 179   {0x00,0x03,T,"Setmark detected"},
 180   {0x00,0x04,T|S,"Beginning-of-partition/medium detected"},
 181   {0x00,0x05,T|S,"End-of-data detected"},
 182   {0x00,0x06,D|T|L|P|W|R|S|O|M|C,"I/O process terminated"},
 183   {0x00,0x11,R,"Audio play operation in progress"},
 184   {0x00,0x12,R,"Audio play operation paused"},
 185   {0x00,0x13,R,"Audio play operation successfully completed"},
 186   {0x00,0x14,R,"Audio play operation stopped due to error"},
 187   {0x00,0x15,R,"No current audio status to return"},
 188   {0x01,0x00,D|W|O,"No index/sector signal"},
 189   {0x02,0x00,D|W|R|O|M,"No seek complete"},
 190   {0x03,0x00,D|T|L|W|S|O,"Peripheral device write fault"},
 191   {0x03,0x01,T,"No write current"},
 192   {0x03,0x02,T,"Excessive write errors"},
 193   {0x04,0x00,D|T|L|P|W|R|S|O|M|C,
 194      "Logical unit not ready, cause not reportable"},
 195   {0x04,0x01,D|T|L|P|W|R|S|O|M|C,
 196      "Logical unit is in process of becoming ready"},
 197   {0x04,0x02,D|T|L|P|W|R|S|O|M|C,
 198      "Logical unit not ready, initializing command required"},
 199   {0x04,0x03,D|T|L|P|W|R|S|O|M|C,
 200      "Logical unit not ready, manual intervention required"},
 201   {0x04,0x04,D|T|L|O,"Logical unit not ready, format in progress"},
 202   {0x05,0x00,D|T|L|W|R|S|O|M|C,"Logical unit does not respond to selection"},
 203   {0x06,0x00,D|W|R|O|M,"No reference position found"},
 204   {0x07,0x00,D|T|L|W|R|S|O|M,"Multiple peripheral devices selected"},
 205   {0x08,0x00,D|T|L|W|R|S|O|M|C,"Logical unit communication failure"},
 206   {0x08,0x01,D|T|L|W|R|S|O|M|C,"Logical unit communication time-out"},
 207   {0x08,0x02,D|T|L|W|R|S|O|M|C,"Logical unit communication parity error"},
 208   {0x09,0x00,D|T|W|R|O,"Track following error"},
 209   {0x09,0x01,W|R|O,"Tracking servo failure"},
 210   {0x09,0x02,W|R|O,"Focus servo failure"},
 211   {0x09,0x03,W|R|O,"Spindle servo failure"},
 212   {0x0A,0x00,D|T|L|P|W|R|S|O|M|C,"Error log overflow"},
 213   {0x0C,0x00,T|S,"Write error"},
 214   {0x0C,0x01,D|W|O,"Write error recovered with auto reallocation"},
 215   {0x0C,0x02,D|W|O,"Write error - auto reallocation failed"},
 216   {0x10,0x00,D|W|O,"Id crc or ecc error"},
 217   {0x11,0x00,D|T|W|R|S|O,"Unrecovered read error"},
 218   {0x11,0x01,D|T|W|S|O,"Read retries exhausted"},
 219   {0x11,0x02,D|T|W|S|O,"Error too long to correct"},
 220   {0x11,0x03,D|T|W|S|O,"Multiple read errors"},
 221   {0x11,0x04,D|W|O,"Unrecovered read error - auto reallocate failed"},
 222   {0x11,0x05,W|R|O,"L-ec uncorrectable error"},
 223   {0x11,0x06,W|R|O,"Circ unrecovered error"},
 224   {0x11,0x07,W|O,"Data resynchronization error"},
 225   {0x11,0x08,T,"Incomplete block read"},
 226   {0x11,0x09,T,"No gap found"},
 227   {0x11,0x0A,D|T|O,"Miscorrected error"},
 228   {0x11,0x0B,D|W|O,"Unrecovered read error - recommend reassignment"},
 229   {0x11,0x0C,D|W|O,"Unrecovered read error - recommend rewrite the data"},
 230   {0x12,0x00,D|W|O,"Address mark not found for id field"},
 231   {0x13,0x00,D|W|O,"Address mark not found for data field"},
 232   {0x14,0x00,D|T|L|W|R|S|O,"Recorded entity not found"},
 233   {0x14,0x01,D|T|W|R|O,"Record not found"},
 234   {0x14,0x02,T,"Filemark or setmark not found"},
 235   {0x14,0x03,T,"End-of-data not found"},
 236   {0x14,0x04,T,"Block sequence error"},
 237   {0x15,0x00,D|T|L|W|R|S|O|M,"Random positioning error"},
 238   {0x15,0x01,D|T|L|W|R|S|O|M,"Mechanical positioning error"},
 239   {0x15,0x02,D|T|W|R|O,"Positioning error detected by read of medium"},
 240   {0x16,0x00,D|W|O,"Data synchronization mark error"},
 241   {0x17,0x00,D|T|W|R|S|O,"Recovered data with no error correction applied"},
 242   {0x17,0x01,D|T|W|R|S|O,"Recovered data with retries"},
 243   {0x17,0x02,D|T|W|R|O,"Recovered data with positive head offset"},
 244   {0x17,0x03,D|T|W|R|O,"Recovered data with negative head offset"},
 245   {0x17,0x04,W|R|O,"Recovered data with retries and/or circ applied"},
 246   {0x17,0x05,D|W|R|O,"Recovered data using previous sector id"},
 247   {0x17,0x06,D|W|O,"Recovered data without ecc - data auto-reallocated"},
 248   {0x17,0x07,D|W|O,"Recovered data without ecc - recommend reassignment"},
 249   {0x18,0x00,D|T|W|R|O,"Recovered data with error correction applied"},
 250   {0x18,0x01,D|W|R|O,"Recovered data with error correction and retries applied"},
 251   {0x18,0x02,D|W|R|O,"Recovered data - data auto-reallocated"},
 252   {0x18,0x03,R,"Recovered data with circ"},
 253   {0x18,0x04,R,"Recovered data with lec"},
 254   {0x18,0x05,D|W|R|O,"Recovered data - recommend reassignment"},
 255   {0x19,0x00,D|O,"Defect list error"},
 256   {0x19,0x01,D|O,"Defect list not available"},
 257   {0x19,0x02,D|O,"Defect list error in primary list"},
 258   {0x19,0x03,D|O,"Defect list error in grown list"},
 259   {0x1A,0x00,D|T|L|P|W|R|S|O|M|C,"Parameter list length error"},
 260   {0x1B,0x00,D|T|L|P|W|R|S|O|M|C,"Synchronous data transfer error"},
 261   {0x1C,0x00,D|O,"Defect list not found"},
 262   {0x1C,0x01,D|O,"Primary defect list not found"},
 263   {0x1C,0x02,D|O,"Grown defect list not found"},
 264   {0x1D,0x00,D|W|O,"Miscompare during verify operation"},
 265   {0x1E,0x00,D|W|O,"Recovered id with ecc correction"},
 266   {0x20,0x00,D|T|L|P|W|R|S|O|M|C,"Invalid command operation code"},
 267   {0x21,0x00,D|T|W|R|O|M,"Logical block address out of range"},
 268   {0x21,0x01,M,"Invalid element address"},
 269   {0x22,0x00,D,"Illegal function (should use 20 00, 24 00, or 26 00)"},
 270   {0x24,0x00,D|T|L|P|W|R|S|O|M|C,"Invalid field in cdb"},
 271   {0x25,0x00,D|T|L|P|W|R|S|O|M|C,"Logical unit not supported"},
 272   {0x26,0x00,D|T|L|P|W|R|S|O|M|C,"Invalid field in parameter list"},
 273   {0x26,0x01,D|T|L|P|W|R|S|O|M|C,"Parameter not supported"},
 274   {0x26,0x02,D|T|L|P|W|R|S|O|M|C,"Parameter value invalid"},
 275   {0x26,0x03,D|T|L|P|W|R|S|O|M|C,"Threshold parameters not supported"},
 276   {0x27,0x00,D|T|W|O,"Write protected"},
 277   {0x28,0x00,D|T|L|P|W|R|S|O|M|C,"Not ready to ready transition (medium may have changed)"},
 278   {0x28,0x01,M,"Import or export element accessed"},
 279   {0x29,0x00,D|T|L|P|W|R|S|O|M|C,"Power on, reset, or bus device reset occurred"},
 280   {0x2A,0x00,D|T|L|W|R|S|O|M|C,"Parameters changed"},
 281   {0x2A,0x01,D|T|L|W|R|S|O|M|C,"Mode parameters changed"},
 282   {0x2A,0x02,D|T|L|W|R|S|O|M|C,"Log parameters changed"},
 283   {0x2B,0x00,D|T|L|P|W|R|S|O|C,"Copy cannot execute since host cannot disconnect"},
 284   {0x2C,0x00,D|T|L|P|W|R|S|O|M|C,"Command sequence error"},
 285   {0x2C,0x01,S,"Too many windows specified"},
 286   {0x2C,0x02,S,"Invalid combination of windows specified"},
 287   {0x2D,0x00,T,"Overwrite error on update in place"},
 288   {0x2F,0x00,D|T|L|P|W|R|S|O|M|C,"Commands cleared by another initiator"},
 289   {0x30,0x00,D|T|W|R|O|M,"Incompatible medium installed"},
 290   {0x30,0x01,D|T|W|R|O,"Cannot read medium - unknown format"},
 291   {0x30,0x02,D|T|W|R|O,"Cannot read medium - incompatible format"},
 292   {0x30,0x03,D|T,"Cleaning cartridge installed"},
 293   {0x31,0x00,D|T|W|O,"Medium format corrupted"},
 294   {0x31,0x01,D|L|O,"Format command failed"},
 295   {0x32,0x00,D|W|O,"No defect spare location available"},
 296   {0x32,0x01,D|W|O,"Defect list update failure"},
 297   {0x33,0x00,T,"Tape length error"},
 298   {0x36,0x00,L,"Ribbon, ink, or toner failure"},
 299   {0x37,0x00,D|T|L|W|R|S|O|M|C,"Rounded parameter"},
 300   {0x39,0x00,D|T|L|W|R|S|O|M|C,"Saving parameters not supported"},
 301   {0x3A,0x00,D|T|L|W|R|S|O|M,"Medium not present"},
 302   {0x3B,0x00,T|L,"Sequential positioning error"},
 303   {0x3B,0x01,T,"Tape position error at beginning-of-medium"},
 304   {0x3B,0x02,T,"Tape position error at end-of-medium"},
 305   {0x3B,0x03,L,"Tape or electronic vertical forms unit not ready"},
 306   {0x3B,0x04,L,"Slew failure"},
 307   {0x3B,0x05,L,"Paper jam"},
 308   {0x3B,0x06,L,"Failed to sense top-of-form"},
 309   {0x3B,0x07,L,"Failed to sense bottom-of-form"},
 310   {0x3B,0x08,T,"Reposition error"},
 311   {0x3B,0x09,S,"Read past end of medium"},
 312   {0x3B,0x0A,S,"Read past beginning of medium"},
 313   {0x3B,0x0B,S,"Position past end of medium"},
 314   {0x3B,0x0C,S,"Position past beginning of medium"},
 315   {0x3B,0x0D,M,"Medium destination element full"},
 316   {0x3B,0x0E,M,"Medium source element empty"},
 317   {0x3D,0x00,D|T|L|P|W|R|S|O|M|C,"Invalid bits in identify message"},
 318   {0x3E,0x00,D|T|L|P|W|R|S|O|M|C,"Logical unit has not self-configured yet"},
 319   {0x3F,0x00,D|T|L|P|W|R|S|O|M|C,"Target operating conditions have changed"},
 320   {0x3F,0x01,D|T|L|P|W|R|S|O|M|C,"Microcode has been changed"},
 321   {0x3F,0x02,D|T|L|P|W|R|S|O|M|C,"Changed operating definition"},
 322   {0x3F,0x03,D|T|L|P|W|R|S|O|M|C,"Inquiry data has changed"},
 323   {0x43,0x00,D|T|L|P|W|R|S|O|M|C,"Message error"},
 324   {0x44,0x00,D|T|L|P|W|R|S|O|M|C,"Internal target failure"},
 325   {0x45,0x00,D|T|L|P|W|R|S|O|M|C,"Select or reselect failure"},
 326   {0x46,0x00,D|T|L|P|W|R|S|O|M|C,"Unsuccessful soft reset"},
 327   {0x47,0x00,D|T|L|P|W|R|S|O|M|C,"Scsi parity error"},
 328   {0x48,0x00,D|T|L|P|W|R|S|O|M|C,"Initiator detected error message received"},
 329   {0x49,0x00,D|T|L|P|W|R|S|O|M|C,"Invalid message error"},
 330   {0x4A,0x00,D|T|L|P|W|R|S|O|M|C,"Command phase error"},
 331   {0x4B,0x00,D|T|L|P|W|R|S|O|M|C,"Data phase error"},
 332   {0x4C,0x00,D|T|L|P|W|R|S|O|M|C,"Logical unit failed self-configuration"},
 333   {0x4E,0x00,D|T|L|P|W|R|S|O|M|C,"Overlapped commands attempted"},
 334   {0x50,0x00,T,"Write append error"},
 335   {0x50,0x01,T,"Write append position error"},
 336   {0x50,0x02,T,"Position error related to timing"},
 337   {0x51,0x00,T|O,"Erase failure"},
 338   {0x52,0x00,T,"Cartridge fault"},
 339   {0x53,0x00,D|T|L|W|R|S|O|M,"Media load or eject failed"},
 340   {0x53,0x01,T,"Unload tape failure"},
 341   {0x53,0x02,D|T|W|R|O|M,"Medium removal prevented"},
 342   {0x54,0x00,P,"Scsi to host system interface failure"},
 343   {0x55,0x00,P,"System resource failure"},
 344   {0x57,0x00,R,"Unable to recover table-of-contents"},
 345   {0x58,0x00,O,"Generation does not exist"},
 346   {0x59,0x00,O,"Updated block read"},
 347   {0x5A,0x00,D|T|L|P|W|R|S|O|M,"Operator request or state change input (unspecified)"},
 348   {0x5A,0x01,D|T|W|R|O|M,"Operator medium removal request"},
 349   {0x5A,0x02,D|T|W|O,"Operator selected write protect"},
 350   {0x5A,0x03,D|T|W|O,"Operator selected write permit"},
 351   {0x5B,0x00,D|T|L|P|W|R|S|O|M,"Log exception"},
 352   {0x5B,0x01,D|T|L|P|W|R|S|O|M,"Threshold condition met"},
 353   {0x5B,0x02,D|T|L|P|W|R|S|O|M,"Log counter at maximum"},
 354   {0x5B,0x03,D|T|L|P|W|R|S|O|M,"Log list codes exhausted"},
 355   {0x5C,0x00,D|O,"Rpl status change"},
 356   {0x5C,0x01,D|O,"Spindles synchronized"},
 357   {0x5C,0x02,D|O,"Spindles not synchronized"},
 358   {0x60,0x00,S,"Lamp failure"},
 359   {0x61,0x00,S,"Video acquisition error"},
 360   {0x61,0x01,S,"Unable to acquire video"},
 361   {0x61,0x02,S,"Out of focus"},
 362   {0x62,0x00,S,"Scan head positioning error"},
 363   {0x63,0x00,R,"End of user area encountered on this track"},
 364   {0x64,0x00,R,"Illegal mode for this track"},
 365   {0, 0, 0, NULL}
 366 };
 367 #endif
 368 
 369 #if (CONSTANTS & CONST_SENSE)
 370 static const char *snstext[] = {
 371     "None","Recovered Error","Not Ready","Medium Error","Hardware Error",
 372     "Illegal Request","Unit Attention","Data Protect","Blank Check",
 373     "Key=9","Copy Aborted","Aborted Command","End-Of-Medium",
 374     "Volume Overflow", "Miscompare", "Key=15"};
 375 #endif
 376 
 377 
 378 /* Print sense information */
 379 void print_sense(const char * devclass, Scsi_Cmnd * SCpnt)
     /* [previous][next][first][last][top][bottom][index][help] */
 380 {
 381     int i, s;
 382     int sense_class, valid, code;
 383     unsigned char * sense_buffer = SCpnt->sense_buffer;
 384     const char * error = NULL;
 385     int dev = SCpnt->request.dev;
 386     
 387     sense_class = (sense_buffer[0] >> 4) & 0x07;
 388     code = sense_buffer[0] & 0xf;
 389     valid = sense_buffer[0] & 0x80;
 390     
 391     if (sense_class == 7) { 
 392         s = sense_buffer[7] + 8;
 393         if(s > sizeof(SCpnt->sense_buffer)) s = sizeof(SCpnt->sense_buffer);
 394         
 395         if (!valid)
 396             printk("extra data not valid ");
 397         
 398         if (sense_buffer[2] & 0x80) printk( "FMK ");
 399         if (sense_buffer[2] & 0x40) printk( "EOM ");
 400         if (sense_buffer[2] & 0x20) printk( "ILI ");
 401         
 402         switch (code) {
 403         case 0x0:
 404             error = "Current";
 405             break;
 406         case 0x1:
 407             error = "Deferred";
 408             break;
 409         default:
 410             error = "Invalid";
 411         }
 412         
 413         printk("%s error ", error);
 414         
 415 #if (CONSTANTS & CONST_SENSE)
 416         printk( "%s%x: sense key %s\n", devclass, dev, snstext[sense_buffer[2] & 0x0f]);
 417 #else
 418         printk("%s%x: sns = %2x %2x\n", devclass, dev, sense_buffer[0], sense_buffer[2]);
 419 #endif
 420         
 421         /* Check to see if additional sense information is available */
 422         if(sense_buffer[7] + 7 < 13 ||
 423            (sense_buffer[12] == 0  && sense_buffer[13] ==  0)) goto done;
 424         
 425 #if (CONSTANTS & CONST_XSENSE)
 426         for(i=0; additional[i].text; i++)
 427             if(additional[i].code1 == sense_buffer[12] &&
 428                additional[i].code2 == sense_buffer[13])
 429                 printk("Additional sense indicates %s\n", additional[i].text);
 430         
 431         for(i=0; additional2[i].text; i++)
 432             if(additional2[i].code1 == sense_buffer[12] &&
 433                additional2[i].code2_min >= sense_buffer[13]  &&
 434                additional2[i].code2_max <= sense_buffer[13]) {
 435                 printk("Additional sense indicates ");
 436                 printk(additional2[i].text, sense_buffer[13]);
 437                 printk("\n");
 438             };
 439 #else
 440         printk("ASC=%2x ASCQ=%2x\n", sense_buffer[12], sense_buffer[13]);
 441 #endif
 442     } else { 
 443         
 444 #if (CONSTANTS & CONST_SENSE)
 445         if (sense_buffer[0] < 15)
 446             printk("%s%x: old sense key %s\n", devclass, dev, snstext[sense_buffer[0] & 0x0f]);
 447         else
 448 #endif
 449             printk("%s%x: sns = %2x %2x\n", devclass, dev, sense_buffer[0], sense_buffer[2]);
 450         
 451         printk("Non-extended sense class %d code 0x%0x ", sense_class, code);
 452         s = 4;
 453     }
 454     
 455  done:
 456 #if !(CONSTANTS & CONST_SENSE)
 457     printk("Raw sense data:");
 458     for (i = 0; i < s; ++i) 
 459         printk("0x%02x ", sense_buffer[i]);
 460     printk("\n");
 461 #endif
 462     return;
 463 }
 464 
 465 #if (CONSTANTS & CONST_MSG) 
 466 static const char *one_byte_msgs[] = {
 467 /* 0x00 */ "Command Complete", NULL, "Save Pointers",
 468 /* 0x03 */ "Restore Pointers", "Disconnect", "Initiator Error", 
 469 /* 0x06 */ "Abort", "Message Reject", "Nop", "Message Parity Error",
 470 /* 0x0a */ "Linked Command Complete", "Linked Command Complete w/flag",
 471 /* 0x0c */ "Bus device reset", "Abort Tag", "Clear Queue", 
 472 /* 0x0f */ "Initiate Recovery", "Release Recovery"
 473 };
 474 
 475 #define NO_ONE_BYTE_MSGS (sizeof(one_byte_msgs)  / sizeof (const char *))
 476 
 477 static const char *two_byte_msgs[] = {
 478 /* 0x20 */ "Simple Queue Tag", "Head of Queue Tag", "Ordered Queue Tag"
 479 /* 0x23 */ "Ignore Wide Residue"
 480 };
 481 
 482 #define NO_TWO_BYTE_MSGS (sizeof(two_byte_msgs)  / sizeof (const char *))
 483 
 484 static const char *extended_msgs[] = {
 485 /* 0x00 */ "Modify Data Pointer", "Synchronous Data Transfer Request",
 486 /* 0x02 */ "SCSI-I Extended Identify", "Wide Data Transfer Request"
 487 };
 488 
 489 #define NO_EXTENDED_MSGS (sizeof(two_byte_msgs)  / sizeof (const char *))
 490 #endif /* (CONSTANTS & CONST_MSG) */
 491 
 492 int print_msg (const unsigned char *msg) {
     /* [previous][next][first][last][top][bottom][index][help] */
 493     int len = 0, i;
 494     if (msg[0] == EXTENDED_MESSAGE) {
 495         len = 3 + msg[1];
 496 #if (CONSTANTS & CONST_MSG)
 497         if (msg[2] < NO_EXTENDED_MSGS)
 498             printk ("%s ", extended_msgs[msg[2]]); 
 499         else 
 500             printk ("Extended Message, reserved code (0x%02x) ", (int) msg[2]);
 501         switch (msg[2]) {
 502         case EXTENDED_MODIFY_DATA_POINTER:
 503             printk("pointer = %d", (int) (msg[3] << 24) | (msg[4] << 16) | 
 504                    (msg[5] << 8) | msg[6]);
 505             break;
 506         case EXTENDED_SDTR:
 507             printk("period = %d ns, offset = %d", (int) msg[3] * 4, (int) 
 508                    msg[4]);
 509             break;
 510         case EXTENDED_WDTR:
 511             printk("width = 2^%d bytes", msg[3]);
 512             break;
 513         default:
 514             for (i = 2; i < len; ++i) 
 515                 printk("%02x ", msg[i]);
 516         }
 517 #else
 518         for (i = 0; i < len; ++i)
 519             printk("%02x ", msg[i]);
 520 #endif
 521         /* Identify */
 522     } else if (msg[0] & 0x80) {
 523 #if (CONSTANTS & CONST_MSG)
 524         printk("Identify disconnect %sallowed %s %d ",
 525                (msg[0] & 0x40) ? "" : "not ",
 526                (msg[0] & 0x20) ? "target routine" : "lun",
 527                msg[0] & 0x7);
 528 #else
 529         printk("%02x ", msg[0]);
 530 #endif
 531         len = 1;
 532         /* Normal One byte */
 533     } else if (msg[0] < 0x1f) {
 534 #if (CONSTANTS & CONST_MSG)
 535         if (msg[0] < NO_ONE_BYTE_MSGS)
 536             printk(one_byte_msgs[msg[0]]);
 537         else
 538             printk("reserved (%02x) ", msg[0]);
 539 #else
 540         printk("%02x ", msg[0]);
 541 #endif
 542         len = 1;
 543         /* Two byte */
 544     } else if (msg[0] <= 0x2f) {
 545 #if (CONSTANTS & CONST_MSG)
 546         if ((msg[0] - 0x20) < NO_TWO_BYTE_MSGS)
 547             printk("%s %02x ", two_byte_msgs[msg[0] - 0x20], 
 548                    msg[1]);
 549         else 
 550             printk("reserved two byte (%02x %02x) ", 
 551                    msg[0], msg[1]);
 552 #else
 553         printk("%02x %02x", msg[0], msg[1]);
 554 #endif
 555         len = 2;
 556     } else 
 557 #if (CONSTANTS & CONST_MSG)
 558         printk(reserved);
 559 #else
 560     printk("%02x ", msg[0]);
 561 #endif
 562     return len;
 563 }
 564 
 565 void print_Scsi_Cmnd (Scsi_Cmnd *cmd) {
     /* [previous][next][first][last][top][bottom][index][help] */
 566     printk("scsi%d : destination target %d, lun %d\n", 
 567            cmd->host->host_no, 
 568            cmd->target, 
 569            cmd->lun);
 570     printk("        command = ");
 571     print_command (cmd->cmnd);
 572 }
 573 
 574 /*
 575  * Overrides for Emacs so that we almost follow Linus's tabbing style.
 576  * Emacs will notice this stuff at the end of the file and automatically
 577  * adjust the settings for this buffer only.  This must remain at the end
 578  * of the file.
 579  * ---------------------------------------------------------------------------
 580  * Local variables:
 581  * c-indent-level: 4
 582  * c-brace-imaginary-offset: 0
 583  * c-brace-offset: -4
 584  * c-argdecl-indent: 4
 585  * c-label-offset: -4
 586  * c-continued-statement-offset: 4
 587  * c-continued-brace-offset: 0
 588  * indent-tabs-mode: nil
 589  * tab-width: 8
 590  * End:
 591  */

/* [previous][next][first][last][top][bottom][index][help] */