|
|
1.1 ! root 1: /* ! 2: * Copyright (c) 1982, 1990 The Regents of the University of California. ! 3: * All rights reserved. ! 4: * ! 5: * Redistribution is only permitted until one year after the first shipment ! 6: * of 4.4BSD by the Regents. Otherwise, redistribution and use in source and ! 7: * binary forms are permitted provided that: (1) source distributions retain ! 8: * this entire copyright notice and comment, and (2) distributions including ! 9: * binaries display the following acknowledgement: This product includes ! 10: * software developed by the University of California, Berkeley and its ! 11: * contributors'' in the documentation or other materials provided with the ! 12: * distribution and in all advertising materials mentioning features or use ! 13: * of this software. Neither the name of the University nor the names of ! 14: * its contributors may be used to endorse or promote products derived from ! 15: * this software without specific prior written permission. ! 16: * THIS SOFTWARE IS PROVIDED AS IS'' AND WITHOUT ANY EXPRESS OR IMPLIED ! 17: * WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF ! 18: * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. ! 19: * ! 20: * @(#)fhpib.c 7.1 (Berkeley) 5/8/90 ! 21: */ ! 22: ! 23: /* ! 24: * 98625A/B HPIB driver ! 25: */ ! 26: ! 27: #include "param.h" ! 28: #include "../hpdev/fhpibreg.h" ! 29: #include "hpibvar.h" ! 30: ! 31: fhpibinit(unit) ! 32: register int unit; ! 33: { ! 34: register struct hpib_softc *hs = &hpib_softc[unit]; ! 35: register struct fhpibdevice *hd = (struct fhpibdevice *)hs->sc_addr; ! 36: ! 37: if (hd->hpib_cid != HPIBC) ! 38: return(0); ! 39: hs->sc_type = HPIBC; ! 40: hs->sc_ba = HPIBC_BA; ! 41: fhpibreset(unit); ! 42: return(1); ! 43: } ! 44: ! 45: fhpibreset(unit) ! 46: { ! 47: register struct hpib_softc *hs = &hpib_softc[unit]; ! 48: register struct fhpibdevice *hd; ! 49: ! 50: hd = (struct fhpibdevice *)hs->sc_addr; ! 51: hd->hpib_cid = 0xFF; ! 52: DELAY(100); ! 53: hd->hpib_cmd = CT_8BIT; ! 54: hd->hpib_ar = AR_ARONC; ! 55: hd->hpib_cmd |= CT_IFC; ! 56: hd->hpib_cmd |= CT_INITFIFO; ! 57: DELAY(100); ! 58: hd->hpib_cmd &= ~CT_IFC; ! 59: hd->hpib_cmd |= CT_REN; ! 60: hd->hpib_stat = ST_ATN; ! 61: hd->hpib_data = C_DCL; ! 62: DELAY(100000); ! 63: } ! 64: ! 65: fhpibsend(unit, slave, sec, buf, cnt) ! 66: register char *buf; ! 67: register int cnt; ! 68: { ! 69: register struct hpib_softc *hs = &hpib_softc[unit]; ! 70: register struct fhpibdevice *hd; ! 71: int origcnt = cnt; ! 72: ! 73: hd = (struct fhpibdevice *)hs->sc_addr; ! 74: hd->hpib_stat = 0; ! 75: hd->hpib_imask = IM_IDLE | IM_ROOM; ! 76: fhpibwait(hd, IM_IDLE); ! 77: hd->hpib_stat = ST_ATN; ! 78: hd->hpib_data = C_UNL; ! 79: hd->hpib_data = C_TAG + hs->sc_ba; ! 80: hd->hpib_data = C_LAG + slave; ! 81: if (sec != -1) ! 82: hd->hpib_data = C_SCG + sec; ! 83: fhpibwait(hd, IM_IDLE); ! 84: hd->hpib_stat = ST_WRITE; ! 85: if (cnt) { ! 86: while (--cnt) { ! 87: hd->hpib_data = *buf++; ! 88: if (fhpibwait(hd, IM_ROOM) < 0) ! 89: break; ! 90: } ! 91: hd->hpib_stat = ST_EOI; ! 92: hd->hpib_data = *buf; ! 93: if (fhpibwait(hd, IM_ROOM) < 0) ! 94: cnt++; ! 95: hd->hpib_stat = ST_ATN; ! 96: /* XXX: HP-UX claims bug with CS80 transparent messages */ ! 97: if (sec == 0x12) ! 98: DELAY(150); ! 99: hd->hpib_data = C_UNL; ! 100: fhpibwait(hd, IM_IDLE); ! 101: } ! 102: hd->hpib_imask = 0; ! 103: return(origcnt - cnt); ! 104: } ! 105: ! 106: fhpibrecv(unit, slave, sec, buf, cnt) ! 107: register char *buf; ! 108: register int cnt; ! 109: { ! 110: register struct hpib_softc *hs = &hpib_softc[unit]; ! 111: register struct fhpibdevice *hd; ! 112: int origcnt = cnt; ! 113: ! 114: hd = (struct fhpibdevice *)hs->sc_addr; ! 115: hd->hpib_stat = 0; ! 116: hd->hpib_imask = IM_IDLE | IM_ROOM | IM_BYTE; ! 117: fhpibwait(hd, IM_IDLE); ! 118: hd->hpib_stat = ST_ATN; ! 119: hd->hpib_data = C_UNL; ! 120: hd->hpib_data = C_LAG + hs->sc_ba; ! 121: hd->hpib_data = C_TAG + slave; ! 122: if (sec != -1) ! 123: hd->hpib_data = C_SCG + sec; ! 124: fhpibwait(hd, IM_IDLE); ! 125: hd->hpib_stat = ST_READ0; ! 126: hd->hpib_data = 0; ! 127: if (cnt) { ! 128: while (--cnt >= 0) { ! 129: if (fhpibwait(hd, IM_BYTE) < 0) ! 130: break; ! 131: *buf++ = hd->hpib_data; ! 132: } ! 133: cnt++; ! 134: fhpibwait(hd, IM_ROOM); ! 135: hd->hpib_stat = ST_ATN; ! 136: hd->hpib_data = (slave == 31) ? C_UNA : C_UNT; ! 137: fhpibwait(hd, IM_IDLE); ! 138: } ! 139: hd->hpib_imask = 0; ! 140: return(origcnt - cnt); ! 141: } ! 142: ! 143: fhpibppoll(unit) ! 144: register int unit; ! 145: { ! 146: register struct hpib_softc *hs = &hpib_softc[unit]; ! 147: register struct fhpibdevice *hd; ! 148: register int ppoll; ! 149: ! 150: hd = (struct fhpibdevice *)hs->sc_addr; ! 151: hd->hpib_stat = 0; ! 152: hd->hpib_psense = 0; ! 153: hd->hpib_pmask = 0xFF; ! 154: hd->hpib_imask = IM_PPRESP | IM_PABORT; ! 155: DELAY(25); ! 156: hd->hpib_intr = IM_PABORT; ! 157: ppoll = hd->hpib_data; ! 158: if (hd->hpib_intr & IM_PABORT) ! 159: ppoll = 0; ! 160: hd->hpib_imask = 0; ! 161: hd->hpib_pmask = 0; ! 162: hd->hpib_stat = ST_IENAB; ! 163: return(ppoll); ! 164: } ! 165: ! 166: fhpibwait(hd, x) ! 167: register struct fhpibdevice *hd; ! 168: { ! 169: register int timo = 100000; ! 170: ! 171: while ((hd->hpib_intr & x) == 0 && --timo) ! 172: ; ! 173: if (timo == 0) ! 174: return(-1); ! 175: return(0); ! 176: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.