📄 constants.c
字号:
{0x50,0x01,T,"Write append position error"}, {0x50,0x02,T,"Position error related to timing"}, {0x51,0x00,T|O,"Erase failure"}, {0x52,0x00,T,"Cartridge fault"}, {0x53,0x00,D|T|L|W|R|S|O|M,"Media load or eject failed"}, {0x53,0x01,T,"Unload tape failure"}, {0x53,0x02,D|T|W|R|O|M,"Medium removal prevented"}, {0x54,0x00,P,"Scsi to host system interface failure"}, {0x55,0x00,P,"System resource failure"}, {0x57,0x00,R,"Unable to recover table-of-contents"}, {0x58,0x00,O,"Generation does not exist"}, {0x59,0x00,O,"Updated block read"}, {0x5A,0x00,D|T|L|P|W|R|S|O|M,"Operator request or state change input (unspecified)"}, {0x5A,0x01,D|T|W|R|O|M,"Operator medium removal request"}, {0x5A,0x02,D|T|W|O,"Operator selected write protect"}, {0x5A,0x03,D|T|W|O,"Operator selected write permit"}, {0x5B,0x00,D|T|L|P|W|R|S|O|M,"Log exception"}, {0x5B,0x01,D|T|L|P|W|R|S|O|M,"Threshold condition met"}, {0x5B,0x02,D|T|L|P|W|R|S|O|M,"Log counter at maximum"}, {0x5B,0x03,D|T|L|P|W|R|S|O|M,"Log list codes exhausted"}, {0x5C,0x00,D|O,"Rpl status change"}, {0x5C,0x01,D|O,"Spindles synchronized"}, {0x5C,0x02,D|O,"Spindles not synchronized"}, {0x60,0x00,S,"Lamp failure"}, {0x61,0x00,S,"Video acquisition error"}, {0x61,0x01,S,"Unable to acquire video"}, {0x61,0x02,S,"Out of focus"}, {0x62,0x00,S,"Scan head positioning error"}, {0x63,0x00,R,"End of user area encountered on this track"}, {0x64,0x00,R,"Illegal mode for this track"}, {0, 0, 0, NULL}};#endif#if (CONSTANTS & CONST_SENSE)static const char *snstext[] = { "None", /* There is no sense information */ "Recovered Error", /* The last command completed successfully but used error correction */ "Not Ready", /* The addressed target is not ready */ "Medium Error", /* Data error detected on the medium */ "Hardware Error", /* Controller or device failure */ "Illegal Request", "Unit Attention", /* Removable medium was changed, or the target has been reset */ "Data Protect", /* Access to the data is blocked */ "Blank Check", /* Reached unexpected written or unwritten region of the medium */ "Key=9", /* Vendor specific */ "Copy Aborted", /* COPY or COMPARE was aborted */ "Aborted Command", /* The target aborted the command */ "Equal", /* A SEARCH DATA command found data equal */ "Volume Overflow", /* Medium full with still data to be written */ "Miscompare", /* Source data and data on the medium do not agree */ "Key=15" /* Reserved */};#endif/* Print sense information */void print_sense(const char * devclass, Scsi_Cmnd * SCpnt){ int i, s; int sense_class, valid, code; unsigned char * sense_buffer = SCpnt->sense_buffer; const char * error = NULL; sense_class = (sense_buffer[0] >> 4) & 0x07; code = sense_buffer[0] & 0xf; valid = sense_buffer[0] & 0x80; if (sense_class == 7) { /* extended sense data */ s = sense_buffer[7] + 8; if(s > sizeof(SCpnt->sense_buffer)) s = sizeof(SCpnt->sense_buffer); if (!valid) printk("[valid=0] "); printk("Info fld=0x%x, ", (int)((sense_buffer[3] << 24) | (sense_buffer[4] << 16) | (sense_buffer[5] << 8) | sense_buffer[6])); if (sense_buffer[2] & 0x80) printk( "FMK "); /* current command has read a filemark */ if (sense_buffer[2] & 0x40) printk( "EOM "); /* end-of-medium condition exists */ if (sense_buffer[2] & 0x20) printk( "ILI "); /* incorrect block length requested */ switch (code) { case 0x0: error = "Current"; /* error concerns current command */ break; case 0x1: error = "Deferred"; /* error concerns some earlier command */ /* e.g., an earlier write to disk cache succeeded, but now the disk discovers that it cannot write the data */ break; default: error = "Invalid"; } printk("%s ", error); #if (CONSTANTS & CONST_SENSE) printk( "%s%s: sense key %s\n", devclass, kdevname(SCpnt->request.rq_dev), snstext[sense_buffer[2] & 0x0f]);#else printk("%s%s: sns = %2x %2x\n", devclass, kdevname(SCpnt->request.rq_dev), sense_buffer[0], sense_buffer[2]);#endif /* Check to see if additional sense information is available */ if(sense_buffer[7] + 7 < 13 || (sense_buffer[12] == 0 && sense_buffer[13] == 0)) goto done; #if (CONSTANTS & CONST_XSENSE) for(i=0; additional[i].text; i++) if(additional[i].code1 == sense_buffer[12] && additional[i].code2 == sense_buffer[13]) printk("Additional sense indicates %s\n", additional[i].text); for(i=0; additional2[i].text; i++) if(additional2[i].code1 == sense_buffer[12] && additional2[i].code2_min >= sense_buffer[13] && additional2[i].code2_max <= sense_buffer[13]) { printk("Additional sense indicates "); printk(additional2[i].text, sense_buffer[13]); printk("\n"); };#else printk("ASC=%2x ASCQ=%2x\n", sense_buffer[12], sense_buffer[13]);#endif } else { /* non-extended sense data */ /* * Standard says: * sense_buffer[0] & 0200 : address valid * sense_buffer[0] & 0177 : vendor-specific error code * sense_buffer[1] & 0340 : vendor-specific * sense_buffer[1..3] : 21-bit logical block address */ #if (CONSTANTS & CONST_SENSE) if (sense_buffer[0] < 15) printk("%s%s: old sense key %s\n", devclass, kdevname(SCpnt->request.rq_dev), snstext[sense_buffer[0] & 0x0f]); else#endif printk("%s%s: sns = %2x %2x\n", devclass, kdevname(SCpnt->request.rq_dev), sense_buffer[0], sense_buffer[2]); printk("Non-extended sense class %d code 0x%0x ", sense_class, code); s = 4; } done:#if !(CONSTANTS & CONST_SENSE) printk("Raw sense data:"); for (i = 0; i < s; ++i) printk("0x%02x ", sense_buffer[i]); printk("\n");#endif return;}#if (CONSTANTS & CONST_MSG) static const char *one_byte_msgs[] = {/* 0x00 */ "Command Complete", NULL, "Save Pointers",/* 0x03 */ "Restore Pointers", "Disconnect", "Initiator Error", /* 0x06 */ "Abort", "Message Reject", "Nop", "Message Parity Error",/* 0x0a */ "Linked Command Complete", "Linked Command Complete w/flag",/* 0x0c */ "Bus device reset", "Abort Tag", "Clear Queue", /* 0x0f */ "Initiate Recovery", "Release Recovery"};#define NO_ONE_BYTE_MSGS (sizeof(one_byte_msgs) / sizeof (const char *))static const char *two_byte_msgs[] = {/* 0x20 */ "Simple Queue Tag", "Head of Queue Tag", "Ordered Queue Tag"/* 0x23 */ "Ignore Wide Residue"};#define NO_TWO_BYTE_MSGS (sizeof(two_byte_msgs) / sizeof (const char *))static const char *extended_msgs[] = {/* 0x00 */ "Modify Data Pointer", "Synchronous Data Transfer Request",/* 0x02 */ "SCSI-I Extended Identify", "Wide Data Transfer Request"};#define NO_EXTENDED_MSGS (sizeof(two_byte_msgs) / sizeof (const char *))#endif /* (CONSTANTS & CONST_MSG) */int print_msg (const unsigned char *msg) { int len = 0, i; if (msg[0] == EXTENDED_MESSAGE) { len = 3 + msg[1];#if (CONSTANTS & CONST_MSG) if (msg[2] < NO_EXTENDED_MSGS) printk ("%s ", extended_msgs[msg[2]]); else printk ("Extended Message, reserved code (0x%02x) ", (int) msg[2]); switch (msg[2]) { case EXTENDED_MODIFY_DATA_POINTER: printk("pointer = %d", (int) (msg[3] << 24) | (msg[4] << 16) | (msg[5] << 8) | msg[6]); break; case EXTENDED_SDTR: printk("period = %d ns, offset = %d", (int) msg[3] * 4, (int) msg[4]); break; case EXTENDED_WDTR: printk("width = 2^%d bytes", msg[3]); break; default: for (i = 2; i < len; ++i) printk("%02x ", msg[i]); }#else for (i = 0; i < len; ++i) printk("%02x ", msg[i]);#endif /* Identify */ } else if (msg[0] & 0x80) {#if (CONSTANTS & CONST_MSG) printk("Identify disconnect %sallowed %s %d ", (msg[0] & 0x40) ? "" : "not ", (msg[0] & 0x20) ? "target routine" : "lun", msg[0] & 0x7);#else printk("%02x ", msg[0]);#endif len = 1; /* Normal One byte */ } else if (msg[0] < 0x1f) {#if (CONSTANTS & CONST_MSG) if (msg[0] < NO_ONE_BYTE_MSGS) printk(one_byte_msgs[msg[0]]); else printk("reserved (%02x) ", msg[0]);#else printk("%02x ", msg[0]);#endif len = 1; /* Two byte */ } else if (msg[0] <= 0x2f) {#if (CONSTANTS & CONST_MSG) if ((msg[0] - 0x20) < NO_TWO_BYTE_MSGS) printk("%s %02x ", two_byte_msgs[msg[0] - 0x20], msg[1]); else printk("reserved two byte (%02x %02x) ", msg[0], msg[1]);#else printk("%02x %02x", msg[0], msg[1]);#endif len = 2; } else #if (CONSTANTS & CONST_MSG) printk(reserved);#else printk("%02x ", msg[0]);#endif return len;}void print_Scsi_Cmnd (Scsi_Cmnd *cmd) { printk("scsi%d : destination target %d, lun %d\n", cmd->host->host_no, cmd->target, cmd->lun); printk(" command = "); print_command (cmd->cmnd);}#if (CONSTANTS & CONST_HOST)static const char * hostbyte_table[]={"DID_OK", "DID_NO_CONNECT", "DID_BUS_BUSY", "DID_TIME_OUT", "DID_BAD_TARGET", "DID_ABORT", "DID_PARITY", "DID_ERROR", "DID_RESET", "DID_BAD_INTR","DID_PASSTHROUGH", "DID_SOFT_ERROR", NULL};void print_hostbyte(int scsiresult){ static int maxcode=0; int i; if(!maxcode) { for(i=0;hostbyte_table[i];i++) ; maxcode=i-1; } printk("Hostbyte=0x%02x",host_byte(scsiresult)); if(host_byte(scsiresult)>maxcode) { printk("is invalid "); return; } printk("(%s) ",hostbyte_table[host_byte(scsiresult)]);}#elsevoid print_hostbyte(int scsiresult){ printk("Hostbyte=0x%02x ",host_byte(scsiresult));}#endif#if (CONSTANTS & CONST_DRIVER)static const char * driverbyte_table[]={"DRIVER_OK", "DRIVER_BUSY", "DRIVER_SOFT", "DRIVER_MEDIA", "DRIVER_ERROR", "DRIVER_INVALID", "DRIVER_TIMEOUT", "DRIVER_HARD",NULL };static const char * driversuggest_table[]={"SUGGEST_OK","SUGGEST_RETRY", "SUGGEST_ABORT", "SUGGEST_REMAP", "SUGGEST_DIE",unknown,unknown,unknown, "SUGGEST_SENSE",NULL};void print_driverbyte(int scsiresult){ static int driver_max=0,suggest_max=0; int i,dr=driver_byte(scsiresult)&DRIVER_MASK, su=(driver_byte(scsiresult)&SUGGEST_MASK)>>4; if(!driver_max) { for(i=0;driverbyte_table[i];i++) ; driver_max=i; for(i=0;driversuggest_table[i];i++) ; suggest_max=i; } printk("Driverbyte=0x%02x",driver_byte(scsiresult)); printk("(%s,%s) ", dr<driver_max ? driverbyte_table[dr]:"invalid", su<suggest_max ? driversuggest_table[su]:"invalid");}#elsevoid print_driverbyte(int scsiresult){ printk("Driverbyte=0x%02x ",driver_byte(scsiresult));}#endif/* * Overrides for Emacs so that we almost follow Linus's tabbing style. * Emacs will notice this stuff at the end of the file and automatically * adjust the settings for this buffer only. This must remain at the end * of the file. * --------------------------------------------------------------------------- * Local variables: * c-indent-level: 4 * c-brace-imaginary-offset: 0 * c-brace-offset: -4 * c-argdecl-indent: 4 * c-label-offset: -4 * c-continued-statement-offset: 4 * c-continued-brace-offset: 0 * indent-tabs-mode: nil * tab-width: 8 * End: */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -