Annotation of 43BSDReno/sys/hpstand/nhpib.c, revision 1.1

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:  *     @(#)nhpib.c     7.1 (Berkeley) 5/8/90
        !            21:  */
        !            22: 
        !            23: /*
        !            24:  * Internal/98624 HPIB driver
        !            25:  */
        !            26: 
        !            27: #include "param.h"
        !            28: #include "../hpdev/nhpibreg.h"
        !            29: #include "hpibvar.h"
        !            30: 
        !            31: nhpibinit(unit)
        !            32: {
        !            33:        register struct hpib_softc *hs = &hpib_softc[unit];
        !            34:        register struct nhpibdevice *hd = (struct nhpibdevice *)hs->sc_addr;
        !            35:        extern int internalhpib;
        !            36: 
        !            37:        if ((int)hd == internalhpib) {
        !            38:                hs->sc_type = HPIBA;
        !            39:                hs->sc_ba = HPIBA_BA;
        !            40:        }
        !            41:        else if (hd->hpib_cid == HPIBB) {
        !            42:                hs->sc_type = HPIBB;
        !            43:                hs->sc_ba = hd->hpib_csa & CSA_BA;
        !            44:        }
        !            45:        else
        !            46:                return(0);
        !            47:        nhpibreset(unit);
        !            48:        return(1);
        !            49: }
        !            50: 
        !            51: nhpibreset(unit)
        !            52: {
        !            53:        register struct hpib_softc *hs = &hpib_softc[unit];
        !            54:        register struct nhpibdevice *hd;
        !            55: 
        !            56:        hd = (struct nhpibdevice *)hs->sc_addr;
        !            57:        hd->hpib_acr = AUX_SSWRST;
        !            58:        hd->hpib_ar = hs->sc_ba;
        !            59:        hd->hpib_lim = 0;
        !            60:        hd->hpib_mim = 0;
        !            61:        hd->hpib_acr = AUX_CDAI;
        !            62:        hd->hpib_acr = AUX_CSHDW;
        !            63:        hd->hpib_acr = AUX_SSTD1;
        !            64:        hd->hpib_acr = AUX_SVSTD1;
        !            65:        hd->hpib_acr = AUX_CPP;
        !            66:        hd->hpib_acr = AUX_CHDFA;
        !            67:        hd->hpib_acr = AUX_CHDFE;
        !            68:        hd->hpib_acr = AUX_RHDF;
        !            69:        hd->hpib_acr = AUX_CSWRST;
        !            70:        hd->hpib_acr = AUX_TCA;
        !            71:        hd->hpib_acr = AUX_CSRE;
        !            72:        hd->hpib_acr = AUX_SSIC;
        !            73:        DELAY(100);
        !            74:        hd->hpib_acr = AUX_CSIC;
        !            75:        hd->hpib_acr = AUX_SSRE;
        !            76:        hd->hpib_data = C_DCL;
        !            77:        DELAY(100000);
        !            78: }
        !            79: 
        !            80: nhpibsend(unit, slave, sec, buf, cnt)
        !            81:        register char *buf;
        !            82:        register int cnt;
        !            83: {
        !            84:        register struct hpib_softc *hs = &hpib_softc[unit];
        !            85:        register struct nhpibdevice *hd;
        !            86:        register int origcnt = cnt;
        !            87: 
        !            88:        hd = (struct nhpibdevice *)hs->sc_addr;
        !            89:        hd->hpib_acr = AUX_TCA;
        !            90:        hd->hpib_data = C_UNL;
        !            91:        nhpibowait(hd);
        !            92:        hd->hpib_data = C_TAG + hs->sc_ba;
        !            93:        hd->hpib_acr = AUX_STON;
        !            94:        nhpibowait(hd);
        !            95:        hd->hpib_data = C_LAG + slave;
        !            96:        nhpibowait(hd);
        !            97:        if (sec != -1) {
        !            98:                hd->hpib_data = C_SCG + sec;
        !            99:                nhpibowait(hd);
        !           100:        }
        !           101:        hd->hpib_acr = AUX_GTS;
        !           102:        if (cnt) {
        !           103:                while (--cnt) {
        !           104:                        hd->hpib_data = *buf++;
        !           105:                        if (nhpibowait(hd) < 0)
        !           106:                                break;
        !           107:                }
        !           108:                hd->hpib_acr = AUX_EOI;
        !           109:                hd->hpib_data = *buf;
        !           110:                if (nhpibowait(hd) < 0)
        !           111:                        cnt++;
        !           112:                hd->hpib_acr = AUX_TCA;
        !           113:        }
        !           114:        return(origcnt - cnt);
        !           115: }
        !           116: 
        !           117: nhpibrecv(unit, slave, sec, buf, cnt)
        !           118:        register char *buf;
        !           119:        register int cnt;
        !           120: {
        !           121:        register struct hpib_softc *hs = &hpib_softc[unit];
        !           122:        register struct nhpibdevice *hd;
        !           123:        register int origcnt = cnt;
        !           124: 
        !           125:        hd = (struct nhpibdevice *)hs->sc_addr;
        !           126:        hd->hpib_acr = AUX_TCA;
        !           127:        hd->hpib_data = C_UNL;
        !           128:        nhpibowait(hd);
        !           129:        hd->hpib_data = C_LAG + hs->sc_ba;
        !           130:        hd->hpib_acr = AUX_SLON;
        !           131:        nhpibowait(hd);
        !           132:        hd->hpib_data = C_TAG + slave;
        !           133:        nhpibowait(hd);
        !           134:        if (sec != -1) {
        !           135:                hd->hpib_data = C_SCG + sec;
        !           136:                nhpibowait(hd);
        !           137:        }
        !           138:        hd->hpib_acr = AUX_RHDF;
        !           139:        hd->hpib_acr = AUX_GTS;
        !           140:        if (cnt) {
        !           141:                while (--cnt >= 0) {
        !           142:                        if (nhpibiwait(hd) < 0)
        !           143:                                break;
        !           144:                        *buf++ = hd->hpib_data;
        !           145:                }
        !           146:                cnt++;
        !           147:                hd->hpib_acr = AUX_TCA;
        !           148:        }
        !           149:        return(origcnt - cnt);
        !           150: }
        !           151: 
        !           152: nhpibppoll(unit)
        !           153:        register int unit;
        !           154: {
        !           155:        register struct hpib_softc *hs = &hpib_softc[unit];
        !           156:        register struct nhpibdevice *hd;
        !           157:        register int ppoll;
        !           158: 
        !           159:        hd = (struct nhpibdevice *)hs->sc_addr;
        !           160:        hd->hpib_acr = AUX_SPP;
        !           161:        DELAY(25);
        !           162:        ppoll = hd->hpib_cpt;
        !           163:        hd->hpib_acr = AUX_CPP;
        !           164:        return(ppoll);
        !           165: }
        !           166: 
        !           167: nhpibowait(hd)
        !           168:        register struct nhpibdevice *hd;
        !           169: {
        !           170:        register int timo = 100000;
        !           171: 
        !           172:        while ((hd->hpib_mis & MIS_BO) == 0 && --timo)
        !           173:                ;
        !           174:        if (timo == 0)
        !           175:                return(-1);
        !           176:        return(0);
        !           177: }
        !           178: 
        !           179: nhpibiwait(hd)
        !           180:        register struct nhpibdevice *hd;
        !           181: {
        !           182:        register int timo = 100000;
        !           183: 
        !           184:        while ((hd->hpib_mis & MIS_BI) == 0 && --timo)
        !           185:                ;
        !           186:        if (timo == 0)
        !           187:                return(-1);
        !           188:        return(0);
        !           189: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.