|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1988 University of Utah. ! 3: * Copyright (c) 1982, 1990 The Regents of the University of California. ! 4: * All rights reserved. ! 5: * ! 6: * This code is derived from software contributed to Berkeley by ! 7: * the Systems Programming Group of the University of Utah Computer ! 8: * Science Department. ! 9: * ! 10: * Redistribution is only permitted until one year after the first shipment ! 11: * of 4.4BSD by the Regents. Otherwise, redistribution and use in source and ! 12: * binary forms are permitted provided that: (1) source distributions retain ! 13: * this entire copyright notice and comment, and (2) distributions including ! 14: * binaries display the following acknowledgement: This product includes ! 15: * software developed by the University of California, Berkeley and its ! 16: * contributors'' in the documentation or other materials provided with the ! 17: * distribution and in all advertising materials mentioning features or use ! 18: * of this software. Neither the name of the University nor the names of ! 19: * its contributors may be used to endorse or promote products derived from ! 20: * this software without specific prior written permission. ! 21: * THIS SOFTWARE IS PROVIDED AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED ! 22: * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF ! 23: * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ! 24: * ! 25: * from: Utah $Hdr: rd.c 1.14 89/02/27$ ! 26: * ! 27: * @(#)rd.c 7.1 (Berkeley) 5/8/90 ! 28: */ ! 29: ! 30: /* ! 31: * CS80/SS80 disk driver ! 32: */ ! 33: #include "saio.h" ! 34: #include "samachdep.h" ! 35: ! 36: #include "../hpdev/rdreg.h" ! 37: ! 38: struct rd_iocmd rd_ioc; ! 39: struct rd_rscmd rd_rsc; ! 40: struct rd_stat rd_stat; ! 41: struct rd_ssmcmd rd_ssmc; ! 42: ! 43: struct rd_softc { ! 44: char sc_retry; ! 45: char sc_alive; ! 46: short sc_type; ! 47: } rd_softc[NRD]; ! 48: ! 49: #define RDRETRY 5 ! 50: ! 51: int rdcyloff[][8] = { ! 52: { 1, 143, 0, 143, 0, 0, 323, 503, }, /* 7945A */ ! 53: { 1, 167, 0, 0, 0, 0, 0, 0, }, /* 9134D */ ! 54: { 0, 0, 0, 0, 0, 0, 0, 0, }, /* 9122S */ ! 55: { 0, 71, 0, 221, 292, 542, 221, 0, }, /* 7912P */ ! 56: { 1, 72, 0, 72, 362, 802, 252, 362, }, /* 7914P */ ! 57: { 1, 28, 0, 140, 167, 444, 140, 721, }, /* 7933H */ ! 58: { 1, 200, 0, 200, 0, 0, 450, 600, }, /* 9134L */ ! 59: { 1, 105, 0, 105, 380, 736, 265, 380, }, /* 7957A */ ! 60: { 1, 65, 0, 65, 257, 657, 193, 257, }, /* 7958A */ ! 61: { 1, 128, 0, 128, 518, 918, 388, 518, }, /* 7957B */ ! 62: { 1, 44, 0, 44, 174, 496, 131, 174, }, /* 7958B */ ! 63: { 1, 44, 0, 44, 218, 918, 174, 218, }, /* 7959B */ ! 64: { 1, 20, 0, 98, 117, 256, 98, 397, }, /* 7936H */ ! 65: { 1, 11, 0, 53, 63, 217, 53, 371, }, /* 7937H */ ! 66: }; ! 67: ! 68: struct rdinfo { ! 69: int nbpc; ! 70: int hwid; ! 71: int *cyloff; ! 72: } rdinfo[] = { ! 73: NRD7945ABPT*NRD7945ATRK, RD7946AID, rdcyloff[0], ! 74: NRD9134DBPT*NRD9134DTRK, RD9134DID, rdcyloff[1], ! 75: NRD9122SBPT*NRD9122STRK, RD9134LID, rdcyloff[2], ! 76: NRD7912PBPT*NRD7912PTRK, RD7912PID, rdcyloff[3], ! 77: NRD7914PBPT*NRD7914PTRK, RD7914PID, rdcyloff[4], ! 78: NRD7958ABPT*NRD7958ATRK, RD7958AID, rdcyloff[8], ! 79: NRD7957ABPT*NRD7957ATRK, RD7957AID, rdcyloff[7], ! 80: NRD7933HBPT*NRD7933HTRK, RD7933HID, rdcyloff[5], ! 81: NRD9134LBPT*NRD9134LTRK, RD9134LID, rdcyloff[6], ! 82: NRD7936HBPT*NRD7936HTRK, RD7936HID, rdcyloff[12], ! 83: NRD7937HBPT*NRD7937HTRK, RD7937HID, rdcyloff[13], ! 84: NRD7914PBPT*NRD7914PTRK, RD7914CTID,rdcyloff[4], ! 85: NRD7945ABPT*NRD7945ATRK, RD7946AID, rdcyloff[0], ! 86: NRD9122SBPT*NRD9122STRK, RD9134LID, rdcyloff[2], ! 87: NRD7957BBPT*NRD7957BTRK, RD7957BID, rdcyloff[9], ! 88: NRD7958BBPT*NRD7958BTRK, RD7958BID, rdcyloff[10], ! 89: NRD7959BBPT*NRD7959BTRK, RD7959BID, rdcyloff[11], ! 90: }; ! 91: int nrdinfo = sizeof(rdinfo) / sizeof(rdinfo[0]); ! 92: ! 93: rdinit(unit) ! 94: register int unit; ! 95: { ! 96: register struct rd_softc *rs; ! 97: u_char stat; ! 98: ! 99: if (unit > NRD) ! 100: return (0); ! 101: rs = &rd_softc[unit]; ! 102: rs->sc_type = rdident(unit); ! 103: if (rs->sc_type < 0) ! 104: return (0); ! 105: rs->sc_alive = 1; ! 106: return (1); ! 107: } ! 108: ! 109: rdreset(unit) ! 110: { ! 111: u_char stat; ! 112: ! 113: rd_ssmc.c_unit = C_SUNIT(0); ! 114: rd_ssmc.c_cmd = C_SSM; ! 115: rd_ssmc.c_refm = REF_MASK; ! 116: rd_ssmc.c_fefm = FEF_MASK; ! 117: rd_ssmc.c_aefm = AEF_MASK; ! 118: rd_ssmc.c_iefm = IEF_MASK; ! 119: hpibsend(unit, C_CMD, &rd_ssmc, sizeof(rd_ssmc)); ! 120: hpibswait(unit); ! 121: hpibrecv(unit, C_QSTAT, &stat, 1); ! 122: } ! 123: ! 124: rdident(unit) ! 125: { ! 126: struct rd_describe desc; ! 127: u_char stat, cmd[3]; ! 128: char name[7]; ! 129: register int id, i; ! 130: ! 131: id = hpibid(unit); ! 132: if ((id & 0x200) == 0) ! 133: return(-1); ! 134: for (i = 0; i < nrdinfo; i++) ! 135: if (id == rdinfo[i].hwid) ! 136: break; ! 137: if (i == nrdinfo) ! 138: return(-1); ! 139: id = i; ! 140: rdreset(unit); ! 141: cmd[0] = C_SUNIT(0); ! 142: cmd[1] = C_SVOL(0); ! 143: cmd[2] = C_DESC; ! 144: hpibsend(unit, C_CMD, cmd, sizeof(cmd)); ! 145: hpibrecv(unit, C_EXEC, &desc, 37); ! 146: hpibrecv(unit, C_QSTAT, &stat, sizeof(stat)); ! 147: bzero(name, sizeof(name)); ! 148: if (!stat) { ! 149: register int n = desc.d_name; ! 150: for (i = 5; i >= 0; i--) { ! 151: name[i] = (n & 0xf) + '0'; ! 152: n >>= 4; ! 153: } ! 154: } ! 155: /* ! 156: * Take care of a couple of anomolies: ! 157: * 1. 7945A and 7946A both return same HW id ! 158: * 2. 9122S and 9134D both return same HW id ! 159: * 3. 9122D and 9134L both return same HW id ! 160: */ ! 161: switch (rdinfo[id].hwid) { ! 162: case RD7946AID: ! 163: if (bcmp(name, "079450", 6) == 0) ! 164: id = RD7945A; ! 165: else ! 166: id = RD7946A; ! 167: break; ! 168: ! 169: case RD9134LID: ! 170: if (bcmp(name, "091340", 6) == 0) ! 171: id = RD9134L; ! 172: else ! 173: id = RD9122D; ! 174: break; ! 175: ! 176: case RD9134DID: ! 177: if (bcmp(name, "091220", 6) == 0) ! 178: id = RD9122S; ! 179: else ! 180: id = RD9134D; ! 181: break; ! 182: } ! 183: return(id); ! 184: } ! 185: ! 186: rdopen(io) ! 187: struct iob *io; ! 188: { ! 189: register int unit = io->i_unit; ! 190: register struct rd_softc *rs = &rd_softc[unit]; ! 191: struct rdinfo *ri; ! 192: ! 193: if (hpibalive(unit) == 0) ! 194: _stop("rd controller not configured"); ! 195: if (rs->sc_alive == 0) ! 196: if (rdinit(unit) == 0) ! 197: _stop("rd init failed"); ! 198: if (io->i_boff < 0 || io->i_boff > 7) ! 199: _stop("rd bad minor"); ! 200: ri = &rdinfo[rs->sc_type]; ! 201: io->i_boff = ri->cyloff[io->i_boff] * ri->nbpc; ! 202: } ! 203: ! 204: rdstrategy(io, func) ! 205: register struct iob *io; ! 206: register int func; ! 207: { ! 208: register int unit = io->i_unit; ! 209: register struct rd_softc *rs = &rd_softc[unit]; ! 210: char stat; ! 211: ! 212: rs->sc_retry = 0; ! 213: rd_ioc.c_unit = C_SUNIT(0); ! 214: rd_ioc.c_volume = C_SVOL(0); ! 215: rd_ioc.c_saddr = C_SADDR; ! 216: rd_ioc.c_hiaddr = 0; ! 217: rd_ioc.c_addr = RDBTOS(io->i_bn); ! 218: rd_ioc.c_nop2 = C_NOP; ! 219: rd_ioc.c_slen = C_SLEN; ! 220: rd_ioc.c_len = io->i_cc; ! 221: rd_ioc.c_cmd = func == READ ? C_READ : C_WRITE; ! 222: retry: ! 223: hpibsend(unit, C_CMD, &rd_ioc.c_unit, sizeof(rd_ioc)-2); ! 224: hpibswait(unit); ! 225: hpibgo(unit, C_EXEC, io->i_ma, io->i_cc, func); ! 226: hpibswait(unit); ! 227: hpibrecv(unit, C_QSTAT, &stat, 1); ! 228: if (stat) { ! 229: if (rderror(unit) == 0) ! 230: return(-1); ! 231: if (++rs->sc_retry > RDRETRY) ! 232: return(-1); ! 233: else ! 234: goto retry; ! 235: } ! 236: return(io->i_cc); ! 237: } ! 238: ! 239: rderror(unit) ! 240: register int unit; ! 241: { ! 242: register struct rd_softc *rd = &rd_softc[unit]; ! 243: char stat; ! 244: ! 245: rd_rsc.c_unit = C_SUNIT(0); ! 246: rd_rsc.c_sram = C_SRAM; ! 247: rd_rsc.c_ram = C_RAM; ! 248: rd_rsc.c_cmd = C_STATUS; ! 249: hpibsend(unit, C_CMD, &rd_rsc, sizeof(rd_rsc)); ! 250: hpibrecv(unit, C_EXEC, &rd_stat, sizeof(rd_stat)); ! 251: hpibrecv(unit, C_QSTAT, &stat, 1); ! 252: if (stat) { ! 253: printf("rd(%d,?): request status fail %d\n", unit, stat); ! 254: return(0); ! 255: } ! 256: printf("rd(%d,?) err: vu 0x%x", unit, rd_stat.c_vu); ! 257: if ((rd_stat.c_aef & AEF_UD) || (rd_stat.c_ief & (IEF_MD|IEF_RD))) ! 258: printf(", block %d", rd_stat.c_blk); ! 259: printf(", R0x%x F0x%x A0x%x I0x%x\n", ! 260: rd_stat.c_ref, rd_stat.c_fef, rd_stat.c_aef, rd_stat.c_ief); ! 261: return(1); ! 262: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.