|
|
1.1 ! root 1: #include "scsi.h" ! 2: ! 3: static ! 4: internal(n, b1, nb, o) ! 5: struct scsi_o *o; ! 6: { ! 7: struct scsi_i input; ! 8: ! 9: input.bus_id = scsi_id; ! 10: input.cmd[0] = 0x1D; ! 11: input.cmd[1] = b1; ! 12: input.cmd[2] = 0; ! 13: input.cmd[3] = 0; ! 14: input.cmd[4] = 10; ! 15: input.cmd[5] = 0; ! 16: input.data[0] = n; ! 17: input.data[1] = b1>>8; ! 18: input.data[2] = 0; ! 19: input.data[3] = 0; ! 20: input.data[4] = 0; ! 21: input.data[5] = 0; ! 22: input.data[6] = 0; ! 23: input.data[7] = 0; ! 24: input.data[8] = 0; ! 25: input.data[9] = 0; ! 26: if(scsiio(&input, 10, o, 0, "internal") < 0) ! 27: return(1); ! 28: if(s_diag(0, nb, o)) ! 29: return(1); ! 30: if(CHECK(*o)){ ! 31: prcheck(1, o); ! 32: return(1); ! 33: } ! 34: return(0); ! 35: } ! 36: ! 37: static char *cmd[] = { ! 38: "internal command table", ! 39: "error information table", ! 40: "arm controller diagnostics", ! 41: "scsi control board diagnostics", ! 42: "drive controller diagnostics", ! 43: "jukebox status", ! 44: 0 ! 45: }; ! 46: ! 47: static char *msg1[16] = ! 48: { ! 49: "drive not connected or powered off", ! 50: "drive connected but no disk", ! 51: "diagnostic aborted: write-protect", ! 52: "diagnostic aborted: write area full", ! 53: "urk 4", "urk 5", "urk 6", "urk 7", "urk 8", "urk 9", "urk 10", ! 54: "urk 11", "urk 12", "urk 13", "urk 14", "urk 15" ! 55: }; ! 56: ! 57: static char *testn[10] = ! 58: { ! 59: "drive on/off", ! 60: "read disk id", ! 61: "move", ! 62: "seek", ! 63: "blank sector search", ! 64: "written sector search", ! 65: "search writable area", ! 66: "write", ! 67: "ECC margin check", ! 68: "read data compare" ! 69: }; ! 70: ! 71: s_internal(n, drive) ! 72: { ! 73: struct scsi_o output; ! 74: struct scsi_i input; ! 75: register unsigned char *d; ! 76: int i; ! 77: long t1, t2; ! 78: int lower; ! 79: extern char *cmesg[]; ! 80: extern char *i0com[], *i1err[], *scsicmd[], *busid[], *scsiident[]; ! 81: ! 82: switch(n) ! 83: { ! 84: case -1: ! 85: for(i = 0; cmd[i]; i++) ! 86: Fprint(1, "internal %d: %s\n", i, cmd[i]); ! 87: break; ! 88: case 0: ! 89: if(internal(0xe5, 0, 256, &output)) ! 90: return(1); ! 91: Fprint(1, "%s:\n", cmd[n]); ! 92: Fprint(1, "Diagnostic #E5: last 16 internal tasks (drive,shelf)\n"); ! 93: for(i = 0, d = output.data; i < 16; i++, d += 16){ ! 94: Fprint(1, "[%d] %s (%d,%d)\n", ! 95: d[0], i0com[d[1]], d[2], d[3]); ! 96: } ! 97: break; ! 98: case 1: ! 99: if(internal(0xe4, 0, 256, &output)) ! 100: return(1); ! 101: Fprint(1, "%s:\n", cmd[n]); ! 102: Fprint(1, "Diagnostic #E4: last 16 errors; initiator[identify] error[sense] (cmd)\n"); ! 103: for(i = 0, d = output.data; i < 16; i++, d += 16){ ! 104: Fprint(1, "%s[%s]: %s[#%x] (%s)\n", ! 105: busid[d[0]], scsiident[d[1]], i1err[d[14]], d[15], scsicmd[d[4]]); ! 106: } ! 107: break; ! 108: case 2: ! 109: Fprint(1, "%s:\n", cmd[n]); ! 110: Fflush(1); ! 111: time(&t1); ! 112: if(internal(0x90, 0, 8, &output)) ! 113: return(1); ! 114: time(&t2); ! 115: d = output.data; ! 116: if(d[0] == 0) ! 117: Fprint(1, "\tended normally"); ! 118: else ! 119: Fprint(1, "\tfailed, error codes=#%x, #%x, #%x", ! 120: d[0], d[1], d[2]); ! 121: Fprint(1, " (time: %lds)\n", t2-t1); ! 122: break; ! 123: case 3: ! 124: Fprint(1, "%s:\n", cmd[n]); ! 125: Fflush(1); ! 126: time(&t1); ! 127: if(internal(0xe0, 0, 8, &output)) ! 128: return(1); ! 129: time(&t2); ! 130: d = output.data; ! 131: if(d[0] == 0) ! 132: Fprint(1, "\tended normally"); ! 133: else ! 134: Fprint(1, "\tfailed, error codes=#%x, #%x, #%x", ! 135: d[0], d[1], d[2]); ! 136: Fprint(1, " (time: %lds)\n", t2-t1); ! 137: break; ! 138: case 4: ! 139: if(s_istatus(drive, &output)) ! 140: return(1); ! 141: if((output.data[100]&0x80) && (drive == (output.data[100]&7))) ! 142: lower = 0x100; ! 143: else if((output.data[101]&0x80) && (drive == (output.data[101]&7))) ! 144: lower = 0x200; ! 145: else { ! 146: fprint(2, "drive %d not occupied\n", drive); ! 147: return(1); ! 148: } ! 149: Fprint(1, "drive %d[%ser]: %s\n", drive, (lower == 0x200)?"low":"upp", cmd[n]); ! 150: Fflush(1); ! 151: time(&t1); ! 152: if(internal(0x18, lower|((drive&7)<<5)|1, 256, &output)) ! 153: return(1); ! 154: time(&t2); ! 155: d = output.data; ! 156: if(d[1]&0x80){ ! 157: Fprint(1, "diagnostic result:"); ! 158: if((d[1]&0x70) == 0) ! 159: Fprint(1, " no faults"); ! 160: else { ! 161: if(d[1]&0x10) ! 162: Fprint(1, " controller-fault"); ! 163: if(d[1]&0x20) ! 164: Fprint(1, " drive-fault"); ! 165: if(d[1]&0x10) ! 166: Fprint(1, " disk-fault"); ! 167: Fprint(1, " (last error code 0x%2.2ux)", d[4]); ! 168: } ! 169: } else ! 170: Fprint(1, "diagnostic not performed: %s", msg1[d[1]&0xF]); ! 171: Fprint(1, " (time: %lds)\n", t2-t1); ! 172: for(i = 0; i < 10; i++) ! 173: Fprint(1, "test %d[%s]: %s\n", i, testn[i], cmesg[d[i*8+drive+8]]); ! 174: Fprint(1, "diagnostic count (drive:avail):"); ! 175: for(d += 104, i = 0; i < 8; i++, d += 2) ! 176: Fprint(1, " %d:%d", i, d[0]+d[1]*256); ! 177: Fprint(1, "\n"); ! 178: Fflush(1); ! 179: break; ! 180: case 5: ! 181: input.bus_id = scsi_id; ! 182: input.cmd[0] = 0xD3; ! 183: input.cmd[1] = drive<<5; ! 184: input.cmd[2] = 0; ! 185: input.cmd[3] = 0; ! 186: input.cmd[4] = 0; ! 187: input.cmd[5] = 0; ! 188: input.cmd[6] = 0; ! 189: input.cmd[7] = 0; ! 190: input.cmd[8] = 0; ! 191: input.cmd[9] = 0; ! 192: if(scsiio(&input, 0, &output, 20, "alternate 5") < 0) ! 193: return(1); ! 194: if(CHECK(output)){ ! 195: prcheck(1, &output); ! 196: return(1); ! 197: } ! 198: Fprint(1, "%s: component(fatal err/err/cmds)\n", cmd[n]); ! 199: d = output.data; ! 200: #define ONE(str, x, sep) Fprint(1, "%s(%d/%d/%d)%c", str, d[x+3], d[x+2], d[x+1]+256*d[x], sep) ! 201: ! 202: ONE("upper drive", 4, ' '); ! 203: ONE("lower drive", 8, ' '); ! 204: ONE("sys control", 12, ' '); ! 205: Fprint(1, "backup mem(0/%d/%d)\n", d[19]+256*d[18], d[17]+256*d[16]); ! 206: break; ! 207: } ! 208: return(0); ! 209: } ! 210:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.