📄 scsi_base.c
字号:
{ 0x11, 0x0C, "Uncorrected Read Error - Recommend Rewrite the Data" }, { 0x12, 0x00, "Address Mark Not Found for ID Field" }, { 0x13, 0x00, "Address Mark Not Found for Data Field" }, { 0x14, 0x00, "Recorded Entity Not Found" }, { 0x14, 0x01, "Record Not Found" }, { 0x14, 0x02, "Filemark or Setmark Not Found" }, { 0x14, 0x03, "End-Of-Data Not Found" }, { 0x14, 0x04, "Block Sequence Error" }, { 0x15, 0x00, "Random Positioning Error" }, { 0x15, 0x01, "Mechanical Positioning Error" }, { 0x15, 0x02, "Positioning Error Detected By Read of Medium" }, { 0x16, 0x00, "Data Synchronization Mark Error" }, { 0x17, 0x00, "Recovered Data With No Error Correction Applied" }, { 0x17, 0x01, "Recovered Data With Retries" }, { 0x17, 0x02, "Recovered Data With Positive Head Offset" }, { 0x17, 0x03, "Recovered Data With Negative Head Offset" }, { 0x17, 0x04, "Recovered Data With Retries and/or CIRC Applied" }, { 0x17, 0x05, "Recovered Data Using Previous Sector ID" }, { 0x17, 0x06, "Recovered Data Without ECC - Data Auto-Reallocated" }, { 0x17, 0x07, "Recovered Data Without ECC - Recommend Reassignment" }, { 0x17, 0x08, "Recovered Data Without ECC - Recommend Rewrite" }, { 0x18, 0x00, "Recovered Data With Error Correction Applied" }, { 0x18, 0x01, "Recovered Data With Error Correction & Retries Applied" }, { 0x18, 0x02, "Recovered Data - Data Auto-Reallocated" }, { 0x18, 0x03, "Recovered Data With CIRC" }, { 0x18, 0x04, "Recovered Data With LEC" }, { 0x18, 0x05, "Recovered Data - Recommend Reassignment" }, { 0x18, 0x06, "Recovered Data - Recommend Rewrite" }, { 0x19, 0x00, "Defect List Error" }, { 0x19, 0x01, "Defect List Not Available" }, { 0x19, 0x02, "Defect List Error in Primary List" }, { 0x19, 0x03, "Defect List Error in Grown List" }, { 0x1A, 0x00, "Parameter List Length Error" }, { 0x1B, 0x00, "Synchronous Data Transfer Error" }, { 0x1C, 0x00, "Defect List Not Found" }, { 0x1C, 0x01, "Primary Defect List Not Found" }, { 0x1C, 0x02, "Grown Defect List Not Found" }, { 0x1D, 0x00, "Miscompare During Verify Operation" }, { 0x1E, 0x00, "Recovered ID with ECC" }, { 0x20, 0x00, "Invalid Command Operation Code" }, { 0x21, 0x00, "Logical Block Address Out of Range" }, { 0x21, 0x01, "Invalid Element Address" }, { 0x22, 0x00, "Illegal Function (Should 20 00, 24 00, or 26 00)" }, { 0x24, 0x00, "Illegal Field in CDB" }, { 0x25, 0x00, "Logical Unit Not Supported" }, { 0x26, 0x00, "Invalid Field In Parameter List" }, { 0x26, 0x01, "Parameter Not Supported" }, { 0x26, 0x02, "Parameter Value Invalid" }, { 0x26, 0x03, "Threshold Parameters Not Supported" }, { 0x27, 0x00, "Write Protected" }, { 0x28, 0x00, "Not Ready To Ready Transition (Medium May Have Changed)" }, { 0x28, 0x01, "Import Or Export Element Accessed" }, { 0x29, 0x00, "Power On, Reset, or Bus Device Reset Occurred" }, { 0x2A, 0x00, "Parameters Changed" }, { 0x2A, 0x01, "Mode Parameters Changed" }, { 0x2A, 0x02, "Log Parameters Changed" }, { 0x2B, 0x00, "Copy Cannot Execute Since Host Cannot Disconnect" }, { 0x2C, 0x00, "Command Sequence Error" }, { 0x2C, 0x01, "Too Many Windows Specified" }, { 0x2C, 0x02, "Invalid Combination of Windows Specified" }, { 0x2D, 0x00, "Overwrite Error On Update In Place" }, { 0x2F, 0x00, "Commands Cleared By Another Initiator" }, { 0x30, 0x00, "Incompatible Medium Installed" }, { 0x30, 0x01, "Cannot Read Medium - Unknown Format" }, { 0x30, 0x02, "Cannot Read Medium - Incompatible Format" }, { 0x30, 0x03, "Cleaning Cartridge Installed" }, { 0x31, 0x00, "Medium Format Corrupted" }, { 0x31, 0x01, "Format Command Failed" }, { 0x32, 0x00, "No Defect Spare Location Available" }, { 0x32, 0x01, "Defect List Update Failure" }, { 0x33, 0x00, "Tape Length Error" }, { 0x36, 0x00, "Ribbon, Ink, or Toner Failure" }, { 0x37, 0x00, "Rounded Parameter" }, { 0x39, 0x00, "Saving Parameters Not Supported" }, { 0x3A, 0x00, "Medium Not Present" }, { 0x3B, 0x00, "Positioning Error" }, { 0x3B, 0x01, "Tape Position Error At Beginning-of-Medium" }, { 0x3B, 0x02, "Tape Position Error At End-of-Medium" }, { 0x3B, 0x03, "Tape or Electronic Vertical Forms Unit Not Ready" }, { 0x3B, 0x04, "Slew Failure" }, { 0x3B, 0x05, "Paper Jam" }, { 0x3B, 0x06, "Failed To Sense Top-Of-Form" }, { 0x3B, 0x07, "Failed To Sense Bottom-Of-Form" }, { 0x3B, 0x08, "Reposition Error" }, { 0x3B, 0x09, "Read Past End Of Medium" }, { 0x3B, 0x0A, "Read Past Begining Of Medium" }, { 0x3B, 0x0B, "Position Past End Of Medium" }, { 0x3B, 0x0C, "Position Past Beginning Of Medium" }, { 0x3B, 0x0D, "Medium Destination Element Full" }, { 0x3B, 0x0E, "Medium Source Element Empty" }, { 0x3D, 0x00, "Invalid Bits In IDENTFY Message" }, { 0x3E, 0x00, "Logical Unit Has Not Self-Configured Yet" }, { 0x3F, 0x00, "Target Operating Conditions Have Changed" }, { 0x3F, 0x01, "Microcode Has Changed" }, { 0x3F, 0x02, "Changed Operating Definition" }, { 0x3F, 0x03, "INQUIRY Data Has Changed" }, { 0x40, 0x00, "RAM FAILURE (Should Use 40 NN)" }, { 0x41, 0x00, "Data Path FAILURE (Should Use 40 NN)" }, { 0x42, 0x00, "Power-On or Self-Test FAILURE (Should Use 40 NN)" }, { 0x43, 0x00, "Message Error" }, { 0x44, 0x00, "Internal Target Failure" }, { 0x45, 0x00, "Select Or Reselect Failure" }, { 0x46, 0x00, "Unsuccessful Soft Reset" }, { 0x47, 0x00, "SCSI Parity Error" }, { 0x48, 0x00, "INITIATOR DETECTED ERROR Message Received" }, { 0x49, 0x00, "Invalid Message Error" }, { 0x4A, 0x00, "Command Phase Error" }, { 0x4B, 0x00, "Data Phase Error" }, { 0x4C, 0x00, "Logical Unit Failed Self-Configuration" }, { 0x4E, 0x00, "Overlapped Commands Attempted" }, { 0x50, 0x00, "Write Append Error" }, { 0x50, 0x01, "Write Append Position Error" }, { 0x50, 0x02, "Position Error Related To Timing" }, { 0x51, 0x00, "Erase Failure" }, { 0x52, 0x00, "Cartridge Fault" }, { 0x53, 0x00, "Media Load or Eject Failed" }, { 0x53, 0x01, "Unload Tape Failure" }, { 0x53, 0x02, "Medium Removal Prevented" }, { 0x54, 0x00, "SCSI To Host System Interface Failure" }, { 0x55, 0x00, "System Resource Failure" }, { 0x57, 0x00, "Unable To Recover Table-Of-Contents" }, { 0x58, 0x00, "Generation Does Not Exist" }, { 0x59, 0x00, "Updated Block Read" }, { 0x5A, 0x00, "Operator Request or State Change Input (Unspecified)" }, { 0x5A, 0x01, "Operator Medium Removal Requested" }, { 0x5A, 0x02, "Operator Selected Write Protect" }, { 0x5A, 0x03, "Operator Selected Write Permit" }, { 0x5B, 0x00, "Log Exception" }, { 0x5B, 0x01, "Threshold Condition Met" }, { 0x5B, 0x02, "Log Counter At Maximum" }, { 0x5B, 0x03, "Log List Codes Exhausted" }, { 0x5C, 0x00, "RPL Status Change" }, { 0x5C, 0x01, "Spindles Synchronized" }, { 0x5C, 0x02, "Spindles Not Synchronized" }, { 0x60, 0x00, "Lamp Failure" }, { 0x61, 0x00, "Video Acquisition Error" }, { 0x61, 0x01, "Unable To Acquire Video" }, { 0x61, 0x02, "Out Of Focus" }, { 0x62, 0x00, "Scan Head Positioning Error" }, { 0x63, 0x00, "End Of User Area Encountered On This Track" }, { 0x64, 0x00, "Illegal Mode For This Track" }, { 0x00, 0x00, NULL }};static __inline voidasc2ascii(asc, ascq, result) u_char asc, ascq; char *result;{ register int i = 0; while (adesc[i].description != NULL) { if (adesc[i].asc == asc && adesc[i].ascq == ascq) break; i++; } if (adesc[i].description == NULL) { if (asc == 0x40 && ascq != 0) { (void) sprintf(result, "Diagnostic Failure on Component 0x%02x", ascq & 0xff); } else { (void) sprintf(result, "ASC 0x%02x ASCQ 0x%02x", asc & 0xff, ascq & 0xff); } } else { (void) strcpy(result, adesc[i].description); }}#elsestatic __inline voidasc2ascii(asc, ascq, result) u_char asc, ascq; char *result;{ (void) sprintf(result, "ASC 0x%02x ASCQ 0x%02x", asc & 0xff, ascq & 0xff);}#endif /* SCSITERSE */voidscsi_print_sense(xs, verbosity) struct scsi_xfer *xs; int verbosity;{ int32_t info; register int i, j, k; char *sbs, *s; sc_print_addr(xs->sc_link); s = (char *) &xs->sense; printf("Check Condition on opcode 0x%x\n", xs->cmd->opcode); /* * Basics- print out SENSE KEY */ printf(" SENSE KEY: %s\n", scsi_decode_sense(s, 0)); /* * Print out, unqualified but aligned, FMK, EOM and ILI status. */ if (s[2] & 0xe0) { char pad = ' '; printf(" "); if (s[2] & SSD_FILEMARK) { printf("%c Filemark Detected", pad); pad = ','; } if (s[2] & SSD_EOM) { printf("%c EOM Detected", pad); pad = ','; } if (s[2] & SSD_ILI) printf("%c Incorrect Length Indicator Set", pad); printf("\n"); } /* * Now we should figure out, based upon device type, how * to format the information field. Unfortunately, that's * not convenient here, so we'll print it as a signed * 32 bit integer. */ info = _4btol(&s[3]); if (info) printf(" INFO FIELD: %u\n", info); /* * Now we check additional length to see whether there is * more information to extract. */ /* enough for command specific information? */ if (s[7] < 4) return; info = _4btol(&s[8]); if (info) printf(" COMMAND INFO: %d (0x%x)\n", info, info); /* * Decode ASC && ASCQ info, plus FRU, plus the rest... */ sbs = scsi_decode_sense(s, 1); if (sbs) printf(" ASC/ASCQ: %s\n", sbs); if (s[14] != 0) printf(" FRU CODE: 0x%x\n", s[14] & 0xff); sbs = scsi_decode_sense(s, 3); if (sbs) printf(" SKSV: %s\n", sbs); if (verbosity == 0) return; /* * Now figure whether we should print any additional informtion. * * Where should we start from? If we had SKSV data, * start from offset 18, else from offset 15. * * From that point until the end of the buffer, check for any * nonzero data. If we have some, go back and print the lot, * otherwise we're done. */ if (sbs) i = 18; else i = 15; for (j = i; j < sizeof (xs->sense); j++) if (s[j]) break; if (j == sizeof (xs->sense)) return; printf(" Additional Sense Information (byte %d out...):\n", i); if (i == 15) { printf(" %2d:", i); k = 7; } else { printf(" %2d:", i); k = 2; j -= 2; } while (j > 0) { if (i >= sizeof (xs->sense)) break; if (k == 8) { k = 0; printf("\n %2d:", i); } printf(" 0x%02x", s[i] & 0xff); k++; j--; i++; } printf("\n");}char *scsi_decode_sense(sinfo, flag) void *sinfo; int flag;{ u_char *snsbuf, skey; static char rqsbuf[132]; skey = 0; snsbuf = (u_char *) sinfo; if (flag == 0 || flag == 2 || flag == 3) { skey = snsbuf[2] & 0xf; } if (flag == 0) { /* Sense Key Only */ (void) strcpy(rqsbuf, sense_keys[skey]); return (rqsbuf); } else if (flag == 1) { /* ASC/ASCQ Only */ asc2ascii(snsbuf[12], snsbuf[13], rqsbuf); return (rqsbuf); } else if (flag == 2) { /* Sense Key && ASC/ASCQ */ asc2ascii(snsbuf[12], snsbuf[13], rqsbuf + sprintf(rqsbuf, "%s, ", sense_keys[skey])); return (rqsbuf); } else if (flag == 3 && snsbuf[7] >= 9 && (snsbuf[15] & 0x80)) { /* * SKSV Data */ switch (skey) { case 0x5: /* Illegal Request */ if (snsbuf[15] & 0x8) { (void) sprintf(rqsbuf, "Error in %s, Offset %d, bit %d", (snsbuf[15] & 0x40)? "CDB" : "Parameters", (snsbuf[16] & 0xff) << 8 | (snsbuf[17] & 0xff), snsbuf[15] & 0xf); } else { (void) sprintf(rqsbuf, "Error in %s, Offset %d", (snsbuf[15] & 0x40)? "CDB" : "Parameters", (snsbuf[16] & 0xff) << 8 | (snsbuf[17] & 0xff)); } return (rqsbuf); case 0x1: case 0x3: case 0x4: (void) sprintf(rqsbuf, "Actual Retry Count: %d", (snsbuf[16] & 0xff) << 8 | (snsbuf[17] & 0xff)); return (rqsbuf); case 0x2: (void) sprintf(rqsbuf, "Progress Indicator: %d", (snsbuf[16] & 0xff) << 8 | (snsbuf[17] & 0xff)); return (rqsbuf); default: break; } } return (NULL);}#ifdef SCSIDEBUG/* * Given a scsi_xfer, dump the request, in all it's glory */voidshow_scsi_xs(xs) struct scsi_xfer *xs;{ printf("xs(%p): ", xs); printf("flg(0x%x)", xs->flags); printf("sc_link(%p)", xs->sc_link); printf("retr(0x%x)", xs->retries); printf("timo(0x%x)", xs->timeout); printf("cmd(%p)", xs->cmd); printf("len(0x%x)", xs->cmdlen); printf("data(%p)", xs->data); printf("len(0x%x)", xs->datalen); printf("res(0x%x)", xs->resid); printf("err(0x%x)", xs->error); printf("bp(%p)", xs->bp); show_scsi_cmd(xs);}voidshow_scsi_cmd(xs) struct scsi_xfer *xs;{ u_char *b = (u_char *) xs->cmd; int i = 0; sc_print_addr(xs->sc_link); printf("command: "); if ((xs->flags & SCSI_RESET) == 0) { while (i < xs->cmdlen) { if (i) printf(","); printf("%x", b[i++]); } printf("-[%d bytes]\n", xs->datalen); if (xs->datalen) show_mem(xs->data, min(64, xs->datalen)); } else printf("-RESET-\n");}voidshow_mem(address, num) u_char *address; int num;{ int x; printf("------------------------------"); for (x = 0; x < num; x++) { if ((x % 16) == 0) printf("\n%03d: ", x); printf("%02x ", *address++); } printf("\n------------------------------\n");}#endif /* SCSIDEBUG */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -