xref: /original-bsd/sys/vax/bi/bi.c (revision 648cab2a)
1 /*
2  *	@(#)bi.c	7.1 (Berkeley) 05/14/88
3  *
4  * VAXBI specific routines.
5  */
6 
7 #include "param.h"
8 
9 #include "../vax/cpu.h"
10 #include "../vax/mtpr.h"
11 #include "../vax/nexus.h"
12 
13 #include "bireg.h"
14 
15 bi_reset(bi)
16 	register struct biiregs *bi;
17 {
18 
19 	bi->bi_csr |= BICSR_NRST;
20 	DELAY(10000);		/* ??? */
21 }
22 
23 /*
24  * Reset with self test.  Return true iff reset fails.
25  * BEWARE, THIS RESETS THE BI ARBITRATION LEVEL TO ARB_NONE
26  * does self test ever cause a bi bus error?
27  */
28 bi_selftest(bi)
29 	register struct biiregs *bi;
30 {
31 	register int timo;
32 
33 	bi->bi_csr |= BICSR_ARB_NONE;	/* why? */
34 	bi->bi_csr |= BICSR_STS | BICSR_INIT;/* must this be separate? */
35 	DELAY(50);			/* why? */
36 	timo = todr() + 1000;
37 	while (bi->bi_csr & BICSR_BROKE) {
38 		if (todr() > timo)	/* reset failed */
39 			return (-1);
40 	}
41 	return (0);			/* reset OK */
42 }
43 
44 /*
45  * THIS SHOULD PROBABLY WORK MORE LIKE ubaerror()
46  * (but then we would need to be able to reset BI nodes)
47  * (we need a per-BI-device driver structure!)
48  */
49 bi_buserr(binum)
50 	int binum;
51 {
52 	register struct bi_node *bi;
53 	register int node;
54 	extern int bi_nodes;
55 	extern int cold;
56 
57 	printf("vaxbi%d: bus error\n", binum);
58 	bi = (struct bi_node *) &nexus[binum * NNODEBI];/* XXX */
59 	for (node = 0; node < 16; node++, bi++) {
60 		if ((bi_nodes & (1 << node)) == 0)	/* XXX crude */
61 			continue;
62 		printf("node %x: ber=%b\n", node, bi->biic.bi_ber, BIBER_BITS);
63 	}
64 	panic("bi_buserr");
65 }
66