1 #include <u.h> 2 #include <libc.h> 3 #include <bio.h> 4 5 #include "scsireq.h" 6 7 static char* key[16] = { 8 "no sense", 9 "recovered error", 10 "not ready", 11 "medium error", 12 "hardware error", 13 "illegal request", 14 "unit attention", 15 "data protect", 16 "blank check", 17 "vendor specific", 18 "copy aborted", 19 "aborted command", 20 "equal", 21 "volume overflow", 22 "miscompare", 23 "reserved", 24 }; 25 26 static struct { 27 uchar asc; 28 uchar ascq; 29 char* diag; 30 } code[] = { /* see /sys/lib/scsicodes */ 31 0x00,0x01, "filemark detected", 32 0x00,0x17, "cleaning requested", 33 0x01,0x00, "no index/sector signal", 34 0x02,0x00, "no seek complete", 35 0x03,0x00, "peripheral device write fault", 36 0x04,0x00, "drive not ready", 37 0x04,0x01, "drive becoming ready", 38 0x04,0x01, "drive need initializing cmd", 39 0x05,0x00, "logical unit does not respond to selection", 40 0x08,0x00, "logical unit communication failure", 41 0x09,0x00, "track-following error", 42 0x0c,0x00, "write error", 43 0x0c,0x01, "write error - recovered with auto reallocation", 44 0x0c,0x02, "write error - auto reallocation failed", 45 0x0c,0x03, "write error - recommend reassignment", 46 47 0x11,0x00, "unrecovered read error", 48 0x15,0x00, "positioning error", 49 0x17,0x00, "recovered read data with retries", 50 0x18,0x00, "recovered read with ecc correction", 51 0x1A,0x00, "parameter list length error", 52 0x1B,0x00, "synchronous data transfer error", 53 54 0x20,0x00, "invalid command", 55 0x21,0x00, "invalid block address", 56 0x22,0x00, "illegal function (use 20 00, 24 00, or 26 00)", 57 0x24,0x00, "illegal field in command list", 58 0x25,0x00, "invalid lun", 59 0x26,0x00, "invalid field in parameter list", 60 0x27,0x00, "write protected", 61 0x28,0x00, "medium changed", 62 0x29,0x00, "power-on reset or bus reset occurred", 63 0x2C,0x00, "command sequence error", 64 65 0x30,0x00, "incompatible medium installed", 66 0x31,0x00, "medium format corrupted", 67 0x33,0x00, "tape length error / monitor atip error", 68 0x34,0x00, "enclosure failure / absorption control error", 69 0x3A,0x00, "medium not present", 70 0x3B,0x00, "sequential positioning error", 71 0x3B,0x01, "tape position error at beginning-of-medium", 72 0x3B,0x02, "tape position error at end-of-medium", 73 0x3B,0x08, "reposition error", 74 0x3B,0x09, "read past end of medium", 75 0x3B,0x0A, "read past beginning of medium", 76 0x3B,0x0B, "position past end of medium", 77 0x3B,0x0C, "position past beginning of medium", 78 0x3B,0x0D, "medium destination element full", 79 0x3B,0x0E, "medium source element empty", 80 0x3B,0x0F, "end of medium reached", 81 0x3B,0x16, "mechanical positioning or changer error", 82 0x3D,0x00, "invalid bits in identify message", 83 0x3E,0x00, "logical unit has not self-configured yet", 84 85 0x40,0x00, "diagnostic failure", 86 0x42,0x00, "power-on or self test failure", 87 0x44,0x00, "internal controller error", 88 0x47,0x00, "scsi parity error", 89 90 0x50,0x00, "write append error", 91 0x51,0x00, "erase failure", 92 0x53,0x00, "medium load or eject failed", 93 0x54,0x00, "scsi to host system interface failure", 94 0x55,0x00, "system resource failure", 95 0x57,0x00, "unable to read toc, pma or subcode", 96 0x5A,0x00, "operator medium removal request", 97 0x5D,0x00, "failure prediction threshold exceeded", 98 99 /* cd/dvd? */ 100 0x63,0x00, "end of user area encountered on this track", 101 0x64,0x00, "illegal mode for this track", 102 0x65,0x00, "verify failed", 103 0x67,0x00, "configuration failure", 104 0x68,0x00, "logical unit not configured", 105 0x69,0x00, "data loss on logical unit", 106 0x6f,0x01, "copy protection key exchange failure - key not present", 107 0x6f,0x02, "copy protection key exchange failure - key not established", 108 0x6f,0x03, "read of scrambled sector without authentication", 109 0x6f,0x04, "media region code is mismatched to logical unit region", 110 0x6f,0x05, "drive region must be permanent/region reset count error", 111 0x6f,0x00, "copy protection key exchange failure", 112 113 0x72,0x00, "session fixation error", 114 0x73,0x00, "cd control error", 115 0x74,0x00, "security error", 116 117 /* vendor specific */ 118 119 0x81,0x00, "illegal track", 120 0x82,0x00, "command now not valid", 121 0x83,0x00, "medium removal is prevented", 122 123 0xA0,0x00, "stopped on non-data block", 124 0xA1,0x00, "invalid start address", 125 0xA2,0x00, "attempt to cross track boundary", 126 0xA3,0x00, "illegal medium", 127 0xA4,0x00, "disc write-protected", 128 0xA5,0x00, "application code conflict", 129 0xA6,0x00, "illegal block-size for command", 130 0xA7,0x00, "block-size conflict", 131 0xA8,0x00, "illegal transfer-length", 132 0xA9,0x00, "request for fixation failed", 133 0xAA,0x00, "end of medium reached", 134 0xAB,0x00, "illegal track number", 135 0xAC,0x00, "data track length error", 136 0xAD,0x00, "buffer underrun", 137 0xAE,0x00, "illegal track mode", 138 0xAF,0x00, "optimum power calibration error", 139 140 0xB0,0x00, "calibration area almost full", 141 0xB1,0x00, "current programme area empty", 142 0xB2,0x00, "no efm at search address", 143 0xB3,0x00, "link area encountered", 144 0xB4,0x00, "calibration area full", 145 0xB5,0x00, "dummy blocks added", 146 0xB6,0x00, "block size format conflict", 147 0xB7,0x00, "current command aborted", 148 149 /* cd/dvd burning? */ 150 0xD0,0x00, "recovery needed", 151 0xD1,0x00, "can't recover from track", 152 0xD2,0x00, "can't recover from program memory area", 153 0xD3,0x00, "can't recover from leadin area", 154 0xD4,0x00, "can't recover from leadout area", 155 0xD5,0x00, "can't recover from optical power calibration area", 156 0xD6,0x00, "eeprom failure", 157 }; 158 159 extern Biobuf bout; 160 161 void 162 makesense(ScsiReq *rp) 163 { 164 int i; 165 166 Bprint(&bout, "sense data: %s", key[rp->sense[2] & 0x0F]); 167 for(i=0; i<nelem(code); i++) 168 if(code[i].asc == rp->sense[0x0C]) 169 if(code[i].ascq == 0 || code[i].ascq == rp->sense[0x0D]) 170 break; 171 if(rp->sense[7] >= 5 && i < nelem(code)) 172 Bprint(&bout, ": %s", code[i].diag); 173 Bprint(&bout, "\n\t"); 174 for(i = 0; i < 8+rp->sense[7]; i++) 175 Bprint(&bout, " %2.2ux", rp->sense[i]); 176 Bprint(&bout, "\n"); 177 } 178