xref: /original-bsd/sys/vax/bi/bi.c (revision 183db9ee)
1 /*
2  * Copyright (c) 1988 Regents of the University of California.
3  * All rights reserved.
4  *
5  * This code is derived from software contributed to Berkeley by
6  * Chris Torek.
7  *
8  * Redistribution and use in source and binary forms are permitted
9  * provided that the above copyright notice and this paragraph are
10  * duplicated in all such forms and that any documentation,
11  * advertising materials, and other materials related to such
12  * distribution and use acknowledge that the software was developed
13  * by the University of California, Berkeley.  The name of the
14  * University may not be used to endorse or promote products derived
15  * from this software without specific prior written permission.
16  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
17  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
18  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
19  *
20  *	@(#)bi.c	7.2 (Berkeley) 07/09/88
21  */
22 
23 /*
24  * VAXBI specific routines.
25  */
26 
27 #include "param.h"
28 
29 #include "../vax/cpu.h"
30 #include "../vax/mtpr.h"
31 #include "../vax/nexus.h"
32 
33 #include "bireg.h"
34 
35 bi_reset(bi)
36 	register struct biiregs *bi;
37 {
38 
39 	bi->bi_csr |= BICSR_NRST;
40 	DELAY(10000);		/* ??? */
41 }
42 
43 /*
44  * Reset with self test.  Return true iff reset fails.
45  * BEWARE, THIS RESETS THE BI ARBITRATION LEVEL TO ARB_NONE
46  * does self test ever cause a bi bus error?
47  */
48 bi_selftest(bi)
49 	register struct biiregs *bi;
50 {
51 	register int timo;
52 
53 	bi->bi_csr |= BICSR_ARB_NONE;	/* why? */
54 	bi->bi_csr |= BICSR_STS | BICSR_INIT;/* must this be separate? */
55 	DELAY(50);			/* why? */
56 	timo = todr() + 1000;
57 	while (bi->bi_csr & BICSR_BROKE) {
58 		if (todr() > timo)	/* reset failed */
59 			return (-1);
60 	}
61 	return (0);			/* reset OK */
62 }
63 
64 /*
65  * THIS SHOULD PROBABLY WORK MORE LIKE ubaerror()
66  * (but then we would need to be able to reset BI nodes)
67  * (we need a per-BI-device driver structure!)
68  */
69 bi_buserr(binum)
70 	int binum;
71 {
72 	register struct bi_node *bi;
73 	register int node;
74 	extern int bi_nodes;
75 	extern int cold;
76 
77 	printf("vaxbi%d: bus error\n", binum);
78 	bi = (struct bi_node *) &nexus[binum * NNODEBI];/* XXX */
79 	for (node = 0; node < 16; node++, bi++) {
80 		if ((bi_nodes & (1 << node)) == 0)	/* XXX crude */
81 			continue;
82 		printf("node %x: ber=%b\n", node, bi->biic.bi_ber, BIBER_BITS);
83 	}
84 	panic("bi_buserr");
85 }
86