|
|
1.1 ! root 1: #include "scsi.h" ! 2: ! 3: static ! 4: drdiag1(drive, lower, o) ! 5: struct scsi_o *o; ! 6: { ! 7: struct scsi_i input; ! 8: int i, n; ! 9: struct scsi_o output; ! 10: ! 11: input.bus_id = 1<<scsi_id; ! 12: input.cmd[0] = 0x1D; ! 13: input.cmd[1] = drive<<5; ! 14: input.cmd[2] = 0; ! 15: input.cmd[3] = 0; ! 16: input.cmd[4] = 10; ! 17: input.cmd[5] = 0; ! 18: input.data[0] = 0x18; /* drive diagnostic */ ! 19: input.data[1] = lower? 2:1; ! 20: input.data[2] = 0; ! 21: input.data[3] = 0; ! 22: input.data[4] = 0; ! 23: input.data[5] = 0; ! 24: input.data[6] = 0; ! 25: input.data[7] = 0; ! 26: input.data[8] = 0; ! 27: input.data[9] = 0; ! 28: if(scsiio(&input, o, 10, "drdiag") < 0) ! 29: return(1); ! 30: for(i = 0; i < 15; i++){ ! 31: s_sense(drive, 1); ! 32: sleep(2); ! 33: } ! 34: s_diag(drive, 256, o); ! 35: if(CHECK(*o)){ ! 36: scsidump(o); ! 37: return(1); ! 38: } ! 39: return(0); ! 40: } ! 41: ! 42: static char *msg1[16] = ! 43: { ! 44: "drive not connected or powered off", ! 45: "drive connected but no disk", ! 46: "diagnostic aborted: write-protect", ! 47: "diagnostic aborted: write area full", ! 48: "urk 4", "urk 5", "urk 6", "urk 7", "urk 8", "urk 9", "urk 10", ! 49: "urk 11", "urk 12", "urk 13", "urk 14", "urk 15" ! 50: }; ! 51: static char *cmesg[256] = ! 52: { ! 53: 0 ! 54: }; ! 55: static char *testn[10] = ! 56: { ! 57: "drive on/off", ! 58: "read disk id", ! 59: "move", ! 60: "seek", ! 61: "blank sector search", ! 62: "written sector search", ! 63: "search writable area", ! 64: "write", ! 65: "ECC margin check", ! 66: "read data compare" ! 67: }; ! 68: ! 69: s_drdiag(drive) ! 70: { ! 71: struct scsi_o o; ! 72: int i; ! 73: register unsigned char *d; ! 74: char buf[256]; ! 75: int lower; ! 76: ! 77: if(s_istatus(drive, &o)) ! 78: return(1); ! 79: if((o.data[100]&0x80) && (drive == (o.data[100]&7))) ! 80: lower = 0; ! 81: else if((o.data[101]&0x80) && (drive == (o.data[101]&7))) ! 82: lower = 1; ! 83: else { ! 84: fprint(2, "drive %d not occupied\n", drive); ! 85: return(1); ! 86: } ! 87: Fprint(1, "drive %d[%ser]: drive diagnostic\n", drive, lower?"low":"upp"); ! 88: Fflush(1); ! 89: if(drdiag1(drive, lower, &o)) ! 90: return(1); ! 91: d = o.data; ! 92: if(d[1]&0x80) ! 93: Fprint(1, "diagnostic not performed: %s\n", msg1[d[1]&0xF]); ! 94: else { ! 95: Fprint(1, "diagnostic result:"); ! 96: if((d[1]&0x70) == 0) ! 97: Fprint(1, "no faults"); ! 98: if(d[1]&0x10) ! 99: Fprint(1, " controller-fault"); ! 100: if(d[1]&0x20) ! 101: Fprint(1, " drive-fault"); ! 102: if(d[1]&0x10) ! 103: Fprint(1, " disk-fault"); ! 104: Fprint(1, " (last error code 0x%2.2ux)\n", d[4]); ! 105: } ! 106: if(cmesg[0] == 0){ ! 107: for(i = 0; i < 256; i++){ ! 108: sprint(buf, "error code 0x%x", i); ! 109: cmesg[i] = strdup(buf); ! 110: } ! 111: cmesg[0] = "good"; ! 112: cmesg[0xE0] = "test not done"; ! 113: cmesg[0xFE] = "drive not ready (no disk)"; ! 114: cmesg[0xFF] = "not connected or power off"; ! 115: cmesg[0xEE] = "diagnostic could not be done"; ! 116: } ! 117: for(i = 0; i < 10; i++) ! 118: Fprint(1, "test %d %s: %s\n", i, testn[i], cmesg[d[i*8+drive+8]]); ! 119: Fprint(1, "diagnostic count:"); ! 120: for(i = 104; i < 120; i++) ! 121: Fprint(1, " %2.2ux", d[i]); ! 122: Fprint(1, "\n"); ! 123: Fflush(1); ! 124: return(0); ! 125: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.