Annotation of Gnu-Mach/i386/i386at/gpl/linux/scsi/constants.c, revision 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, unknown, 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:        printk("%s ",table[opcode & 0x1f]);
        !           105:     }
        !           106: }
        !           107: #else /* CONST & CONST_COMMAND */
        !           108: static void print_opcode(int opcode) {
        !           109:     printk("0x%02x ", opcode);
        !           110: }
        !           111: #endif  
        !           112: 
        !           113: void print_command (unsigned char *command) {
        !           114:     int i,s;
        !           115:     print_opcode(command[0]);
        !           116:     for ( i = 1, s = COMMAND_SIZE(command[0]); i < s; ++i) 
        !           117:        printk("%02x ", command[i]);
        !           118:     printk("\n");
        !           119: }
        !           120: 
        !           121: #if (CONSTANTS & CONST_STATUS)
        !           122: static const char * statuses[] = {
        !           123: /* 0-4 */ "Good", "Check Condition", "Condition Good", unknown, "Busy", 
        !           124: /* 5-9 */ unknown, unknown, unknown, "Intermediate Good", unknown, 
        !           125: /* a-d */ "Intermediate Good", unknown, "Reservation Conflict", unknown,
        !           126: /* e-f */ unknown, unknown,
        !           127: };
        !           128: #endif
        !           129: 
        !           130: void print_status (int status) {
        !           131:     status = (status >> 1) & 0xf;
        !           132: #if (CONSTANTS & CONST_STATUS)
        !           133:     printk("%s ",statuses[status]);
        !           134: #else
        !           135:     printk("0x%0x ", status); 
        !           136: #endif 
        !           137: }
        !           138: 
        !           139: #if (CONSTANTS & CONST_XSENSE)
        !           140: #define D 0x001  /* DIRECT ACCESS DEVICE (disk) */
        !           141: #define T 0x002  /* SEQUENTIAL ACCESS DEVICE (tape) */
        !           142: #define L 0x004  /* PRINTER DEVICE */
        !           143: #define P 0x008  /* PROCESSOR DEVICE */
        !           144: #define W 0x010  /* WRITE ONCE READ MULTIPLE DEVICE */
        !           145: #define R 0x020  /* READ ONLY (CD-ROM) DEVICE */
        !           146: #define S 0x040  /* SCANNER DEVICE */
        !           147: #define O 0x080  /* OPTICAL MEMORY DEVICE */
        !           148: #define M 0x100  /* MEDIA CHANGER DEVICE */
        !           149: #define C 0x200  /* COMMUNICATION DEVICE */
        !           150: 
        !           151: struct error_info{
        !           152:     unsigned char code1, code2;
        !           153:     unsigned short int devices;
        !           154:     const char * text;
        !           155: };
        !           156: 
        !           157: struct error_info2{
        !           158:     unsigned char code1, code2_min, code2_max;
        !           159:     unsigned short int devices;
        !           160:     const char * text;
        !           161: };
        !           162: 
        !           163: static struct error_info2 additional2[] =
        !           164: {
        !           165:   {0x40,0x00,0x7f,D,"Ram failure (%x)"},
        !           166:   {0x40,0x80,0xff,D|T|L|P|W|R|S|O|M|C,"Diagnostic failure on component (%x)"},
        !           167:   {0x41,0x00,0xff,D,"Data path failure (%x)"},
        !           168:   {0x42,0x00,0xff,D,"Power-on or self-test failure (%x)"},
        !           169:   {0, 0, 0, 0, NULL}
        !           170: };
        !           171: 
        !           172: static struct error_info additional[] =
        !           173: {
        !           174:   {0x00,0x01,T,"Filemark detected"},
        !           175:   {0x00,0x02,T|S,"End-of-partition/medium detected"},
        !           176:   {0x00,0x03,T,"Setmark detected"},
        !           177:   {0x00,0x04,T|S,"Beginning-of-partition/medium detected"},
        !           178:   {0x00,0x05,T|S,"End-of-data detected"},
        !           179:   {0x00,0x06,D|T|L|P|W|R|S|O|M|C,"I/O process terminated"},
        !           180:   {0x00,0x11,R,"Audio play operation in progress"},
        !           181:   {0x00,0x12,R,"Audio play operation paused"},
        !           182:   {0x00,0x13,R,"Audio play operation successfully completed"},
        !           183:   {0x00,0x14,R,"Audio play operation stopped due to error"},
        !           184:   {0x00,0x15,R,"No current audio status to return"},
        !           185:   {0x01,0x00,D|W|O,"No index/sector signal"},
        !           186:   {0x02,0x00,D|W|R|O|M,"No seek complete"},
        !           187:   {0x03,0x00,D|T|L|W|S|O,"Peripheral device write fault"},
        !           188:   {0x03,0x01,T,"No write current"},
        !           189:   {0x03,0x02,T,"Excessive write errors"},
        !           190:   {0x04,0x00,D|T|L|P|W|R|S|O|M|C,
        !           191:      "Logical unit not ready, cause not reportable"},
        !           192:   {0x04,0x01,D|T|L|P|W|R|S|O|M|C,
        !           193:      "Logical unit is in process of becoming ready"},
        !           194:   {0x04,0x02,D|T|L|P|W|R|S|O|M|C,
        !           195:      "Logical unit not ready, initializing command required"},
        !           196:   {0x04,0x03,D|T|L|P|W|R|S|O|M|C,
        !           197:      "Logical unit not ready, manual intervention required"},
        !           198:   {0x04,0x04,D|T|L|O,"Logical unit not ready, format in progress"},
        !           199:   {0x05,0x00,D|T|L|W|R|S|O|M|C,"Logical unit does not respond to selection"},
        !           200:   {0x06,0x00,D|W|R|O|M,"No reference position found"},
        !           201:   {0x07,0x00,D|T|L|W|R|S|O|M,"Multiple peripheral devices selected"},
        !           202:   {0x08,0x00,D|T|L|W|R|S|O|M|C,"Logical unit communication failure"},
        !           203:   {0x08,0x01,D|T|L|W|R|S|O|M|C,"Logical unit communication time-out"},
        !           204:   {0x08,0x02,D|T|L|W|R|S|O|M|C,"Logical unit communication parity error"},
        !           205:   {0x09,0x00,D|T|W|R|O,"Track following error"},
        !           206:   {0x09,0x01,W|R|O,"Tracking servo failure"},
        !           207:   {0x09,0x02,W|R|O,"Focus servo failure"},
        !           208:   {0x09,0x03,W|R|O,"Spindle servo failure"},
        !           209:   {0x0A,0x00,D|T|L|P|W|R|S|O|M|C,"Error log overflow"},
        !           210:   {0x0C,0x00,T|S,"Write error"},
        !           211:   {0x0C,0x01,D|W|O,"Write error recovered with auto reallocation"},
        !           212:   {0x0C,0x02,D|W|O,"Write error - auto reallocation failed"},
        !           213:   {0x10,0x00,D|W|O,"Id crc or ecc error"},
        !           214:   {0x11,0x00,D|T|W|R|S|O,"Unrecovered read error"},
        !           215:   {0x11,0x01,D|T|W|S|O,"Read retries exhausted"},
        !           216:   {0x11,0x02,D|T|W|S|O,"Error too long to correct"},
        !           217:   {0x11,0x03,D|T|W|S|O,"Multiple read errors"},
        !           218:   {0x11,0x04,D|W|O,"Unrecovered read error - auto reallocate failed"},
        !           219:   {0x11,0x05,W|R|O,"L-ec uncorrectable error"},
        !           220:   {0x11,0x06,W|R|O,"Circ unrecovered error"},
        !           221:   {0x11,0x07,W|O,"Data resynchronization error"},
        !           222:   {0x11,0x08,T,"Incomplete block read"},
        !           223:   {0x11,0x09,T,"No gap found"},
        !           224:   {0x11,0x0A,D|T|O,"Miscorrected error"},
        !           225:   {0x11,0x0B,D|W|O,"Unrecovered read error - recommend reassignment"},
        !           226:   {0x11,0x0C,D|W|O,"Unrecovered read error - recommend rewrite the data"},
        !           227:   {0x12,0x00,D|W|O,"Address mark not found for id field"},
        !           228:   {0x13,0x00,D|W|O,"Address mark not found for data field"},
        !           229:   {0x14,0x00,D|T|L|W|R|S|O,"Recorded entity not found"},
        !           230:   {0x14,0x01,D|T|W|R|O,"Record not found"},
        !           231:   {0x14,0x02,T,"Filemark or setmark not found"},
        !           232:   {0x14,0x03,T,"End-of-data not found"},
        !           233:   {0x14,0x04,T,"Block sequence error"},
        !           234:   {0x15,0x00,D|T|L|W|R|S|O|M,"Random positioning error"},
        !           235:   {0x15,0x01,D|T|L|W|R|S|O|M,"Mechanical positioning error"},
        !           236:   {0x15,0x02,D|T|W|R|O,"Positioning error detected by read of medium"},
        !           237:   {0x16,0x00,D|W|O,"Data synchronization mark error"},
        !           238:   {0x17,0x00,D|T|W|R|S|O,"Recovered data with no error correction applied"},
        !           239:   {0x17,0x01,D|T|W|R|S|O,"Recovered data with retries"},
        !           240:   {0x17,0x02,D|T|W|R|O,"Recovered data with positive head offset"},
        !           241:   {0x17,0x03,D|T|W|R|O,"Recovered data with negative head offset"},
        !           242:   {0x17,0x04,W|R|O,"Recovered data with retries and/or circ applied"},
        !           243:   {0x17,0x05,D|W|R|O,"Recovered data using previous sector id"},
        !           244:   {0x17,0x06,D|W|O,"Recovered data without ecc - data auto-reallocated"},
        !           245:   {0x17,0x07,D|W|O,"Recovered data without ecc - recommend reassignment"},
        !           246:   {0x18,0x00,D|T|W|R|O,"Recovered data with error correction applied"},
        !           247:   {0x18,0x01,D|W|R|O,"Recovered data with error correction and retries applied"},
        !           248:   {0x18,0x02,D|W|R|O,"Recovered data - data auto-reallocated"},
        !           249:   {0x18,0x03,R,"Recovered data with circ"},
        !           250:   {0x18,0x04,R,"Recovered data with lec"},
        !           251:   {0x18,0x05,D|W|R|O,"Recovered data - recommend reassignment"},
        !           252:   {0x19,0x00,D|O,"Defect list error"},
        !           253:   {0x19,0x01,D|O,"Defect list not available"},
        !           254:   {0x19,0x02,D|O,"Defect list error in primary list"},
        !           255:   {0x19,0x03,D|O,"Defect list error in grown list"},
        !           256:   {0x1A,0x00,D|T|L|P|W|R|S|O|M|C,"Parameter list length error"},
        !           257:   {0x1B,0x00,D|T|L|P|W|R|S|O|M|C,"Synchronous data transfer error"},
        !           258:   {0x1C,0x00,D|O,"Defect list not found"},
        !           259:   {0x1C,0x01,D|O,"Primary defect list not found"},
        !           260:   {0x1C,0x02,D|O,"Grown defect list not found"},
        !           261:   {0x1D,0x00,D|W|O,"Miscompare during verify operation"},
        !           262:   {0x1E,0x00,D|W|O,"Recovered id with ecc correction"},
        !           263:   {0x20,0x00,D|T|L|P|W|R|S|O|M|C,"Invalid command operation code"},
        !           264:   {0x21,0x00,D|T|W|R|O|M,"Logical block address out of range"},
        !           265:   {0x21,0x01,M,"Invalid element address"},
        !           266:   {0x22,0x00,D,"Illegal function (should use 20 00, 24 00, or 26 00)"},
        !           267:   {0x24,0x00,D|T|L|P|W|R|S|O|M|C,"Invalid field in cdb"},
        !           268:   {0x25,0x00,D|T|L|P|W|R|S|O|M|C,"Logical unit not supported"},
        !           269:   {0x26,0x00,D|T|L|P|W|R|S|O|M|C,"Invalid field in parameter list"},
        !           270:   {0x26,0x01,D|T|L|P|W|R|S|O|M|C,"Parameter not supported"},
        !           271:   {0x26,0x02,D|T|L|P|W|R|S|O|M|C,"Parameter value invalid"},
        !           272:   {0x26,0x03,D|T|L|P|W|R|S|O|M|C,"Threshold parameters not supported"},
        !           273:   {0x27,0x00,D|T|W|O,"Write protected"},
        !           274:   {0x28,0x00,D|T|L|P|W|R|S|O|M|C,"Not ready to ready transition (medium may have changed)"},
        !           275:   {0x28,0x01,M,"Import or export element accessed"},
        !           276:   {0x29,0x00,D|T|L|P|W|R|S|O|M|C,"Power on, reset, or bus device reset occurred"},
        !           277:   {0x2A,0x00,D|T|L|W|R|S|O|M|C,"Parameters changed"},
        !           278:   {0x2A,0x01,D|T|L|W|R|S|O|M|C,"Mode parameters changed"},
        !           279:   {0x2A,0x02,D|T|L|W|R|S|O|M|C,"Log parameters changed"},
        !           280:   {0x2B,0x00,D|T|L|P|W|R|S|O|C,"Copy cannot execute since host cannot disconnect"},
        !           281:   {0x2C,0x00,D|T|L|P|W|R|S|O|M|C,"Command sequence error"},
        !           282:   {0x2C,0x01,S,"Too many windows specified"},
        !           283:   {0x2C,0x02,S,"Invalid combination of windows specified"},
        !           284:   {0x2D,0x00,T,"Overwrite error on update in place"},
        !           285:   {0x2F,0x00,D|T|L|P|W|R|S|O|M|C,"Commands cleared by another initiator"},
        !           286:   {0x30,0x00,D|T|W|R|O|M,"Incompatible medium installed"},
        !           287:   {0x30,0x01,D|T|W|R|O,"Cannot read medium - unknown format"},
        !           288:   {0x30,0x02,D|T|W|R|O,"Cannot read medium - incompatible format"},
        !           289:   {0x30,0x03,D|T,"Cleaning cartridge installed"},
        !           290:   {0x31,0x00,D|T|W|O,"Medium format corrupted"},
        !           291:   {0x31,0x01,D|L|O,"Format command failed"},
        !           292:   {0x32,0x00,D|W|O,"No defect spare location available"},
        !           293:   {0x32,0x01,D|W|O,"Defect list update failure"},
        !           294:   {0x33,0x00,T,"Tape length error"},
        !           295:   {0x36,0x00,L,"Ribbon, ink, or toner failure"},
        !           296:   {0x37,0x00,D|T|L|W|R|S|O|M|C,"Rounded parameter"},
        !           297:   {0x39,0x00,D|T|L|W|R|S|O|M|C,"Saving parameters not supported"},
        !           298:   {0x3A,0x00,D|T|L|W|R|S|O|M,"Medium not present"},
        !           299:   {0x3B,0x00,T|L,"Sequential positioning error"},
        !           300:   {0x3B,0x01,T,"Tape position error at beginning-of-medium"},
        !           301:   {0x3B,0x02,T,"Tape position error at end-of-medium"},
        !           302:   {0x3B,0x03,L,"Tape or electronic vertical forms unit not ready"},
        !           303:   {0x3B,0x04,L,"Slew failure"},
        !           304:   {0x3B,0x05,L,"Paper jam"},
        !           305:   {0x3B,0x06,L,"Failed to sense top-of-form"},
        !           306:   {0x3B,0x07,L,"Failed to sense bottom-of-form"},
        !           307:   {0x3B,0x08,T,"Reposition error"},
        !           308:   {0x3B,0x09,S,"Read past end of medium"},
        !           309:   {0x3B,0x0A,S,"Read past beginning of medium"},
        !           310:   {0x3B,0x0B,S,"Position past end of medium"},
        !           311:   {0x3B,0x0C,S,"Position past beginning of medium"},
        !           312:   {0x3B,0x0D,M,"Medium destination element full"},
        !           313:   {0x3B,0x0E,M,"Medium source element empty"},
        !           314:   {0x3D,0x00,D|T|L|P|W|R|S|O|M|C,"Invalid bits in identify message"},
        !           315:   {0x3E,0x00,D|T|L|P|W|R|S|O|M|C,"Logical unit has not self-configured yet"},
        !           316:   {0x3F,0x00,D|T|L|P|W|R|S|O|M|C,"Target operating conditions have changed"},
        !           317:   {0x3F,0x01,D|T|L|P|W|R|S|O|M|C,"Microcode has been changed"},
        !           318:   {0x3F,0x02,D|T|L|P|W|R|S|O|M|C,"Changed operating definition"},
        !           319:   {0x3F,0x03,D|T|L|P|W|R|S|O|M|C,"Inquiry data has changed"},
        !           320:   {0x43,0x00,D|T|L|P|W|R|S|O|M|C,"Message error"},
        !           321:   {0x44,0x00,D|T|L|P|W|R|S|O|M|C,"Internal target failure"},
        !           322:   {0x45,0x00,D|T|L|P|W|R|S|O|M|C,"Select or reselect failure"},
        !           323:   {0x46,0x00,D|T|L|P|W|R|S|O|M|C,"Unsuccessful soft reset"},
        !           324:   {0x47,0x00,D|T|L|P|W|R|S|O|M|C,"Scsi parity error"},
        !           325:   {0x48,0x00,D|T|L|P|W|R|S|O|M|C,"Initiator detected error message received"},
        !           326:   {0x49,0x00,D|T|L|P|W|R|S|O|M|C,"Invalid message error"},
        !           327:   {0x4A,0x00,D|T|L|P|W|R|S|O|M|C,"Command phase error"},
        !           328:   {0x4B,0x00,D|T|L|P|W|R|S|O|M|C,"Data phase error"},
        !           329:   {0x4C,0x00,D|T|L|P|W|R|S|O|M|C,"Logical unit failed self-configuration"},
        !           330:   {0x4E,0x00,D|T|L|P|W|R|S|O|M|C,"Overlapped commands attempted"},
        !           331:   {0x50,0x00,T,"Write append error"},
        !           332:   {0x50,0x01,T,"Write append position error"},
        !           333:   {0x50,0x02,T,"Position error related to timing"},
        !           334:   {0x51,0x00,T|O,"Erase failure"},
        !           335:   {0x52,0x00,T,"Cartridge fault"},
        !           336:   {0x53,0x00,D|T|L|W|R|S|O|M,"Media load or eject failed"},
        !           337:   {0x53,0x01,T,"Unload tape failure"},
        !           338:   {0x53,0x02,D|T|W|R|O|M,"Medium removal prevented"},
        !           339:   {0x54,0x00,P,"Scsi to host system interface failure"},
        !           340:   {0x55,0x00,P,"System resource failure"},
        !           341:   {0x57,0x00,R,"Unable to recover table-of-contents"},
        !           342:   {0x58,0x00,O,"Generation does not exist"},
        !           343:   {0x59,0x00,O,"Updated block read"},
        !           344:   {0x5A,0x00,D|T|L|P|W|R|S|O|M,"Operator request or state change input (unspecified)"},
        !           345:   {0x5A,0x01,D|T|W|R|O|M,"Operator medium removal request"},
        !           346:   {0x5A,0x02,D|T|W|O,"Operator selected write protect"},
        !           347:   {0x5A,0x03,D|T|W|O,"Operator selected write permit"},
        !           348:   {0x5B,0x00,D|T|L|P|W|R|S|O|M,"Log exception"},
        !           349:   {0x5B,0x01,D|T|L|P|W|R|S|O|M,"Threshold condition met"},
        !           350:   {0x5B,0x02,D|T|L|P|W|R|S|O|M,"Log counter at maximum"},
        !           351:   {0x5B,0x03,D|T|L|P|W|R|S|O|M,"Log list codes exhausted"},
        !           352:   {0x5C,0x00,D|O,"Rpl status change"},
        !           353:   {0x5C,0x01,D|O,"Spindles synchronized"},
        !           354:   {0x5C,0x02,D|O,"Spindles not synchronized"},
        !           355:   {0x60,0x00,S,"Lamp failure"},
        !           356:   {0x61,0x00,S,"Video acquisition error"},
        !           357:   {0x61,0x01,S,"Unable to acquire video"},
        !           358:   {0x61,0x02,S,"Out of focus"},
        !           359:   {0x62,0x00,S,"Scan head positioning error"},
        !           360:   {0x63,0x00,R,"End of user area encountered on this track"},
        !           361:   {0x64,0x00,R,"Illegal mode for this track"},
        !           362:   {0, 0, 0, NULL}
        !           363: };
        !           364: #endif
        !           365: 
        !           366: #if (CONSTANTS & CONST_SENSE)
        !           367: static const char *snstext[] = {
        !           368:     "None","Recovered Error","Not Ready","Medium Error","Hardware Error",
        !           369:     "Illegal Request","Unit Attention","Data Protect","Blank Check",
        !           370:     "Key=9","Copy Aborted","Aborted Command","End-Of-Medium",
        !           371:     "Volume Overflow", "Miscompare", "Key=15"};
        !           372: #endif
        !           373: 
        !           374: 
        !           375: /* Print sense information */
        !           376: void print_sense(const char * devclass, Scsi_Cmnd * SCpnt)
        !           377: {
        !           378:     int i, s;
        !           379:     int sense_class, valid, code;
        !           380:     unsigned char * sense_buffer = SCpnt->sense_buffer;
        !           381:     const char * error = NULL;
        !           382:     
        !           383:     sense_class = (sense_buffer[0] >> 4) & 0x07;
        !           384:     code = sense_buffer[0] & 0xf;
        !           385:     valid = sense_buffer[0] & 0x80;
        !           386:     
        !           387:     if (sense_class == 7) { 
        !           388:        s = sense_buffer[7] + 8;
        !           389:        if(s > sizeof(SCpnt->sense_buffer)) s = sizeof(SCpnt->sense_buffer);
        !           390:        
        !           391:        if (!valid)
        !           392:            printk("extra data not valid ");
        !           393:        
        !           394:        if (sense_buffer[2] & 0x80) printk( "FMK ");
        !           395:        if (sense_buffer[2] & 0x40) printk( "EOM ");
        !           396:        if (sense_buffer[2] & 0x20) printk( "ILI ");
        !           397:        
        !           398:        switch (code) {
        !           399:        case 0x0:
        !           400:            error = "Current";
        !           401:            break;
        !           402:        case 0x1:
        !           403:            error = "Deferred";
        !           404:            break;
        !           405:        default:
        !           406:            error = "Invalid";
        !           407:        }
        !           408:        
        !           409:        printk("%s error ", error);
        !           410:        
        !           411: #if (CONSTANTS & CONST_SENSE)
        !           412:        printk( "%s%s: sense key %s\n", devclass,
        !           413:               kdevname(SCpnt->request.rq_dev), snstext[sense_buffer[2] & 0x0f]);
        !           414: #else
        !           415:        printk("%s%s: sns = %2x %2x\n", devclass,
        !           416:               kdevname(SCpnt->request.rq_dev), sense_buffer[0], sense_buffer[2]);
        !           417: #endif
        !           418:        
        !           419:        /* Check to see if additional sense information is available */
        !           420:        if(sense_buffer[7] + 7 < 13 ||
        !           421:           (sense_buffer[12] == 0  && sense_buffer[13] ==  0)) goto done;
        !           422:        
        !           423: #if (CONSTANTS & CONST_XSENSE)
        !           424:        for(i=0; additional[i].text; i++)
        !           425:            if(additional[i].code1 == sense_buffer[12] &&
        !           426:               additional[i].code2 == sense_buffer[13])
        !           427:                printk("Additional sense indicates %s\n", additional[i].text);
        !           428:        
        !           429:        for(i=0; additional2[i].text; i++)
        !           430:            if(additional2[i].code1 == sense_buffer[12] &&
        !           431:               additional2[i].code2_min >= sense_buffer[13]  &&
        !           432:               additional2[i].code2_max <= sense_buffer[13]) {
        !           433:                printk("Additional sense indicates ");
        !           434:                printk(additional2[i].text, sense_buffer[13]);
        !           435:                printk("\n");
        !           436:            };
        !           437: #else
        !           438:        printk("ASC=%2x ASCQ=%2x\n", sense_buffer[12], sense_buffer[13]);
        !           439: #endif
        !           440:     } else { 
        !           441:        
        !           442: #if (CONSTANTS & CONST_SENSE)
        !           443:        if (sense_buffer[0] < 15)
        !           444:            printk("%s%s: old sense key %s\n", devclass,
        !           445:              kdevname(SCpnt->request.rq_dev), snstext[sense_buffer[0] & 0x0f]);
        !           446:        else
        !           447: #endif
        !           448:            printk("%s%s: sns = %2x %2x\n", devclass,
        !           449:              kdevname(SCpnt->request.rq_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) {
        !           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) {
        !           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: #if (CONSTANTS & CONST_HOST)
        !           575: static const char * hostbyte_table[]={
        !           576: "DID_OK", "DID_NO_CONNECT", "DID_BUS_BUSY", "DID_TIME_OUT", "DID_BAD_TARGET", 
        !           577: "DID_ABORT", "DID_PARITY", "DID_ERROR", "DID_RESET", "DID_BAD_INTR",NULL};
        !           578: 
        !           579: void print_hostbyte(int scsiresult)
        !           580: {   static int maxcode=0;
        !           581:     int i;
        !           582:    
        !           583:     if(!maxcode) {
        !           584:        for(i=0;hostbyte_table[i];i++) ;
        !           585:        maxcode=i-1;
        !           586:     }
        !           587:     printk("Hostbyte=0x%02x",host_byte(scsiresult));
        !           588:     if(host_byte(scsiresult)>maxcode) {
        !           589:        printk("is invalid "); 
        !           590:        return;
        !           591:     }
        !           592:     printk("(%s) ",hostbyte_table[host_byte(scsiresult)]);
        !           593: }
        !           594: #else
        !           595: void print_hostbyte(int scsiresult)
        !           596: {   printk("Hostbyte=0x%02x ",host_byte(scsiresult));
        !           597: }
        !           598: #endif
        !           599: 
        !           600: #if (CONSTANTS & CONST_DRIVER)
        !           601: static const char * driverbyte_table[]={
        !           602: "DRIVER_OK", "DRIVER_BUSY", "DRIVER_SOFT",  "DRIVER_MEDIA", "DRIVER_ERROR", 
        !           603: "DRIVER_INVALID", "DRIVER_TIMEOUT", "DRIVER_HARD",NULL };
        !           604: 
        !           605: static const char * driversuggest_table[]={"SUGGEST_OK",
        !           606: "SUGGEST_RETRY", "SUGGEST_ABORT", "SUGGEST_REMAP", "SUGGEST_DIE",
        !           607: unknown,unknown,unknown, "SUGGEST_SENSE",NULL};
        !           608: 
        !           609: 
        !           610: void print_driverbyte(int scsiresult)
        !           611: {   static int driver_max=0,suggest_max=0;
        !           612:     int i,dr=driver_byte(scsiresult)&DRIVER_MASK, 
        !           613:        su=(driver_byte(scsiresult)&SUGGEST_MASK)>>4;
        !           614: 
        !           615:     if(!driver_max) {
        !           616:         for(i=0;driverbyte_table[i];i++) ;
        !           617:         driver_max=i;
        !           618:        for(i=0;driversuggest_table[i];i++) ;
        !           619:        suggest_max=i;
        !           620:     }
        !           621:     printk("Driverbyte=0x%02x",driver_byte(scsiresult));
        !           622:     printk("(%s,%s) ",
        !           623:        dr<driver_max  ? driverbyte_table[dr]:"invalid",
        !           624:        su<suggest_max ? driversuggest_table[su]:"invalid");
        !           625: }
        !           626: #else
        !           627: void print_driverbyte(int scsiresult)
        !           628: {   printk("Driverbyte=0x%02x ",driver_byte(scsiresult));
        !           629: }
        !           630: #endif
        !           631: 
        !           632: /*
        !           633:  * Overrides for Emacs so that we almost follow Linus's tabbing style.
        !           634:  * Emacs will notice this stuff at the end of the file and automatically
        !           635:  * adjust the settings for this buffer only.  This must remain at the end
        !           636:  * of the file.
        !           637:  * ---------------------------------------------------------------------------
        !           638:  * Local variables:
        !           639:  * c-indent-level: 4
        !           640:  * c-brace-imaginary-offset: 0
        !           641:  * c-brace-offset: -4
        !           642:  * c-argdecl-indent: 4
        !           643:  * c-label-offset: -4
        !           644:  * c-continued-statement-offset: 4
        !           645:  * c-continued-brace-offset: 0
        !           646:  * indent-tabs-mode: nil
        !           647:  * tab-width: 8
        !           648:  * End:
        !           649:  */

unix.superglobalmegacorp.com

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