Annotation of Gnu-Mach/linux/src/drivers/scsi/constants.c, revision 1.1.1.1

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.