Annotation of Net2/arch/hp300/stand/hpib.c, revision 1.1.1.2

1.1       root        1: /*
                      2:  * Copyright (c) 1982, 1990 The Regents of the University of California.
                      3:  * All rights reserved.
                      4:  *
                      5:  * Redistribution and use in source and binary forms, with or without
                      6:  * modification, are permitted provided that the following conditions
                      7:  * are met:
                      8:  * 1. Redistributions of source code must retain the above copyright
                      9:  *    notice, this list of conditions and the following disclaimer.
                     10:  * 2. Redistributions in binary form must reproduce the above copyright
                     11:  *    notice, this list of conditions and the following disclaimer in the
                     12:  *    documentation and/or other materials provided with the distribution.
                     13:  * 3. All advertising materials mentioning features or use of this software
                     14:  *    must display the following acknowledgement:
                     15:  *     This product includes software developed by the University of
                     16:  *     California, Berkeley and its contributors.
                     17:  * 4. Neither the name of the University nor the names of its contributors
                     18:  *    may be used to endorse or promote products derived from this software
                     19:  *    without specific prior written permission.
                     20:  *
                     21:  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
                     22:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
                     23:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
                     24:  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
                     25:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
                     26:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
                     27:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
                     28:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
                     29:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
                     30:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
                     31:  * SUCH DAMAGE.
                     32:  *
1.1.1.2 ! root       33:  *     from: @(#)hpib.c        7.5 (Berkeley) 5/7/91
        !            34:  *     hpib.c,v 1.2 1993/05/22 07:58:57 cgd Exp
1.1       root       35:  */
                     36: 
                     37: /*
                     38:  * HPIB driver
                     39:  */
                     40: #include <sys/param.h>
                     41: #include <sys/reboot.h>
                     42: #include "../dev/device.h"
                     43: #include "hpibvar.h"
                     44: 
                     45: #include "saio.h"
                     46: #include "samachdep.h"
                     47: 
                     48: int    internalhpib = IIOV(0x478000);
                     49: int    fhpibppoll(), nhpibppoll();
                     50: 
                     51: struct hpib_softc hpib_softc[NHPIB];
                     52: 
                     53: #define        hpibunit(x)     ((x) >> 3)
                     54: #define        hpibslave(x)    ((x) & 7)
                     55: 
                     56: hpibinit()
                     57: {
                     58:        extern struct hp_hw sc_table[];
                     59:        register struct hp_hw *hw;
                     60:        register struct hpib_softc *hs;
                     61:        register int i, addr;
                     62:        static int first = 1;
                     63:        
                     64:        i = 0;
                     65:        for (hw = sc_table; i < NHPIB && hw < &sc_table[MAXCTLRS]; hw++) {
                     66:                if (!HW_ISHPIB(hw))
                     67:                        continue;
                     68:                hs = &hpib_softc[i];
                     69:                hs->sc_addr = hw->hw_kva;
                     70:                if (nhpibinit(i) == 0)
                     71:                        if (fhpibinit(i) == 0)
                     72:                                continue;
                     73:                if (howto & RB_ASKNAME)
                     74:                        printf("hpib%d at sc%d\n", i, hw->hw_sc);
                     75:                /*
                     76:                 * Adjust devtype on first call.  This routine assumes that
                     77:                 * adaptor is in the high byte of devtype.
                     78:                 */
                     79:                if (first && ((devtype >> 24) & 0xff) == hw->hw_sc) {
                     80:                        devtype = (devtype & 0x00ffffff) | (i << 24);
                     81:                        first = 0;
                     82:                }
                     83:                hs->sc_alive = 1;
                     84:                i++;
                     85:        }
                     86: }
                     87: 
                     88: hpibalive(unit)
                     89:        register int unit;
                     90: {
                     91:        unit = hpibunit(unit);
                     92:        if (unit >= NHPIB || hpib_softc[unit].sc_alive == 0)
                     93:                return (0);
                     94:        return (1);
                     95: }
                     96: 
                     97: hpibid(unit)
                     98:        register int unit;
                     99: {
                    100:        register struct hpib_softc *hs = &hpib_softc[hpibunit(unit)];
                    101:        register int slave;
                    102:        short id;
                    103: 
                    104:        slave = hpibslave(unit);
                    105:        unit = hpibunit(unit);
                    106:        if (hs->sc_type == HPIBC)
                    107:                slave = fhpibrecv(unit, 31, slave, &id, 2);
                    108:        else
                    109:                slave = nhpibrecv(unit, 31, slave, &id, 2);
                    110:        if (slave != 2)
                    111:                return (0);
                    112:        return (id);
                    113: }
                    114: 
                    115: hpibsend(unit, sec, buf, cnt)
                    116:        register char *buf;
                    117:        register int cnt;
                    118: {
                    119:        register struct hpib_softc *hs = &hpib_softc[hpibunit(unit)];
                    120:        register int slave;
                    121: 
                    122:        slave = hpibslave(unit);
                    123:        unit = hpibunit(unit);
                    124:        if (hs->sc_type == HPIBC)
                    125:                return (fhpibsend(unit, slave, sec, buf, cnt));
                    126:        else
                    127:                return (nhpibsend(unit, slave, sec, buf, cnt));
                    128: }
                    129: 
                    130: hpibrecv(unit, sec, buf, cnt)
                    131:        register char *buf;
                    132:        register int cnt;
                    133: {
                    134:        register struct hpib_softc *hs = &hpib_softc[hpibunit(unit)];
                    135:        register int slave;
                    136: 
                    137:        slave = hpibslave(unit);
                    138:        unit = hpibunit(unit);
                    139:        if (hs->sc_type == HPIBC)
                    140:                return (fhpibrecv(unit, slave, sec, buf, cnt));
                    141:        else
                    142:                return (nhpibrecv(unit, slave, sec, buf, cnt));
                    143: }
                    144: 
                    145: hpibswait(unit)
                    146:        register int unit;
                    147: {
                    148:        register int timo = 1000000;
                    149:        register int slave = 0x80 >> hpibslave(unit);
                    150:        register int (*poll)();
                    151: 
                    152:        unit = hpibunit(unit);
                    153:        if (hpib_softc[unit].sc_type == HPIBC)
                    154:                poll = fhpibppoll;
                    155:        else
                    156:                poll = nhpibppoll;
                    157:        while (((*poll)(unit) & slave) == 0)
                    158:                if (--timo == 0)
                    159:                        break;
                    160:        if (timo == 0)
                    161:                return (-1);
                    162:        return (0);
                    163: }
                    164: 
                    165: hpibgo(unit, sec, addr, count, flag)
                    166:        register int unit;
                    167:        char *addr;
                    168: {
                    169:        register int slave;
                    170: 
                    171:        slave = hpibslave(unit);
                    172:        unit = hpibunit(unit);
                    173:        if (hpib_softc[unit].sc_type == HPIBC)
                    174:                if (flag == F_READ)
                    175:                        fhpibrecv(unit, slave, sec, addr, count);
                    176:                else
                    177:                        fhpibsend(unit, slave, sec, addr, count);
                    178:        else
                    179:                if (flag == F_READ)
                    180:                        nhpibrecv(unit, slave, sec, addr, count);
                    181:                else
                    182:                        nhpibsend(unit, slave, sec, addr, count);
                    183: }

unix.superglobalmegacorp.com

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