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

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

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