1 /* $NetBSD: hpib.c,v 1.8 2006/07/02 11:10:28 tsutsui Exp $ */
4 * Copyright (c) 1982, 1990, 1993
5 * The Regents of the University of California. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * 3. Neither the name of the University nor the names of its contributors
16 * may be used to endorse or promote products derived from this software
17 * without specific prior written permission.
19 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * @(#)hpib.c 8.1 (Berkeley) 6/10/93
37 #include <sys/param.h>
38 #include <sys/reboot.h>
40 #include <lib/libsa/stand.h>
42 #include <hp300/stand/common/device.h>
43 #include <hp300/stand/common/hpibvar.h>
44 #include <hp300/stand/common/samachdep.h>
46 #include <hp300/dev/dioreg.h>
48 int internalhpib
= IIOV(DIO_IHPIBADDR
);
50 struct hpib_softc hpib_softc
[NHPIB
];
56 struct hpib_softc
*hs
;
60 for (hw
= sc_table
; i
< NHPIB
&& hw
< &sc_table
[MAXCTLRS
]; hw
++) {
64 hs
->sc_addr
= hw
->hw_kva
;
65 if (nhpibinit(i
) == 0)
66 if (fhpibinit(i
) == 0)
68 if (howto
& RB_ASKNAME
)
69 printf("hpib%d at sc%d\n", i
, hw
->hw_sc
);
70 hw
->hw_pa
= (void *) i
; /* XXX for autoconfig */
79 if (unit
>= NHPIB
|| hpib_softc
[unit
].sc_alive
== 0)
85 hpibid(int unit
, int slave
)
90 if (hpib_softc
[unit
].sc_type
== HPIBC
)
91 rv
= fhpibrecv(unit
, 31, slave
, (uint8_t *)&id
, 2);
93 rv
= nhpibrecv(unit
, 31, slave
, (uint8_t *)&id
, 2);
100 hpibsend(int unit
, int slave
, int sec
, uint8_t *buf
, int cnt
)
103 if (hpib_softc
[unit
].sc_type
== HPIBC
)
104 return (fhpibsend(unit
, slave
, sec
, buf
, cnt
));
105 return nhpibsend(unit
, slave
, sec
, buf
, cnt
);
109 hpibrecv(int unit
, int slave
, int sec
, uint8_t *buf
, int cnt
)
112 if (hpib_softc
[unit
].sc_type
== HPIBC
)
113 return (fhpibrecv(unit
, slave
, sec
, buf
, cnt
));
114 return nhpibrecv(unit
, slave
, sec
, buf
, cnt
);
118 hpibswait(int unit
, int slave
)
123 slave
= 0x80 >> slave
;
124 if (hpib_softc
[unit
].sc_type
== HPIBC
)
128 while (((*poll
)(unit
) & slave
) == 0)
137 hpibgo(int unit
, int slave
, int sec
, uint8_t *addr
, int count
, int flag
)
140 if (hpib_softc
[unit
].sc_type
== HPIBC
)
142 fhpibrecv(unit
, slave
, sec
, addr
, count
);
144 fhpibsend(unit
, slave
, sec
, addr
, count
);
147 nhpibrecv(unit
, slave
, sec
, addr
, count
);
149 nhpibsend(unit
, slave
, sec
, addr
, count
);