bi.c revision 1.16 1 1.16 ragge /* $NetBSD: bi.c,v 1.16 2000/07/26 12:41:40 ragge Exp $ */
2 1.1 ragge /*
3 1.1 ragge * Copyright (c) 1996 Ludd, University of Lule}, Sweden.
4 1.1 ragge * All rights reserved.
5 1.1 ragge *
6 1.1 ragge * Redistribution and use in source and binary forms, with or without
7 1.1 ragge * modification, are permitted provided that the following conditions
8 1.1 ragge * are met:
9 1.1 ragge * 1. Redistributions of source code must retain the above copyright
10 1.1 ragge * notice, this list of conditions and the following disclaimer.
11 1.1 ragge * 2. Redistributions in binary form must reproduce the above copyright
12 1.1 ragge * notice, this list of conditions and the following disclaimer in the
13 1.1 ragge * documentation and/or other materials provided with the distribution.
14 1.1 ragge * 3. All advertising materials mentioning features or use of this software
15 1.1 ragge * must display the following acknowledgement:
16 1.1 ragge * This product includes software developed at Ludd, University of
17 1.1 ragge * Lule}, Sweden and its contributors.
18 1.1 ragge * 4. The name of the author may not be used to endorse or promote products
19 1.1 ragge * derived from this software without specific prior written permission
20 1.1 ragge *
21 1.1 ragge * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
22 1.1 ragge * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 1.1 ragge * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 1.1 ragge * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
25 1.1 ragge * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 1.1 ragge * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 1.1 ragge * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 1.1 ragge * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 1.1 ragge * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 1.1 ragge * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 1.1 ragge */
32 1.1 ragge
33 1.1 ragge
34 1.1 ragge
35 1.1 ragge /*
36 1.1 ragge * VAXBI specific routines.
37 1.1 ragge */
38 1.1 ragge /*
39 1.1 ragge * TODO
40 1.1 ragge * handle BIbus errors more gracefully.
41 1.1 ragge */
42 1.1 ragge
43 1.1 ragge #include <sys/param.h>
44 1.7 ragge #include <sys/systm.h>
45 1.1 ragge
46 1.13 ragge #include <machine/bus.h>
47 1.1 ragge #include <machine/cpu.h>
48 1.1 ragge
49 1.13 ragge #include <dev/bi/bireg.h>
50 1.13 ragge #include <dev/bi/bivar.h>
51 1.1 ragge
52 1.2 cgd static int bi_print __P((void *, const char *));
53 1.1 ragge
54 1.1 ragge struct bi_list bi_list[] = {
55 1.16 ragge {BIDT_MS820, DT_HAVDRV, "ms820"},
56 1.16 ragge {BIDT_DRB32, DT_UNSUPP, "drb32"},
57 1.16 ragge {BIDT_DWBUA, DT_HAVDRV|DT_ADAPT, "dwbua"},
58 1.16 ragge {BIDT_KLESI, DT_HAVDRV|DT_ADAPT, "klesi"},
59 1.16 ragge {BIDT_KA820, DT_HAVDRV, "ka820"},
60 1.16 ragge {BIDT_DB88, DT_HAVDRV|DT_QUIET, "db88"},
61 1.16 ragge {BIDT_CIBCA, DT_UNSUPP, "cibca"},
62 1.16 ragge {BIDT_DMB32, DT_UNSUPP, "dmb32"},
63 1.16 ragge {BIDT_CIBCI, DT_UNSUPP, "cibci"},
64 1.16 ragge {BIDT_KA800, DT_UNSUPP, "ka800"},
65 1.16 ragge {BIDT_KDB50, DT_HAVDRV|DT_VEC, "kdb50"},
66 1.16 ragge {BIDT_DWMBA, DT_HAVDRV|DT_QUIET, "dwmba"},
67 1.16 ragge {BIDT_KFBTA, DT_UNSUPP, "kfbta"},
68 1.16 ragge {BIDT_DEBNK, DT_HAVDRV|DT_VEC, "debnk"},
69 1.16 ragge {BIDT_DEBNA, DT_HAVDRV|DT_VEC, "debna"},
70 1.1 ragge {0,0,0}
71 1.1 ragge };
72 1.1 ragge
73 1.1 ragge int
74 1.1 ragge bi_print(aux, name)
75 1.1 ragge void *aux;
76 1.2 cgd const char *name;
77 1.1 ragge {
78 1.1 ragge struct bi_attach_args *ba = aux;
79 1.1 ragge struct bi_list *bl;
80 1.15 ragge u_int16_t nr;
81 1.1 ragge
82 1.15 ragge nr = bus_space_read_2(ba->ba_iot, ba->ba_ioh, 0);
83 1.7 ragge for (bl = &bi_list[0]; bl->bl_nr; bl++)
84 1.15 ragge if (bl->bl_nr == nr)
85 1.7 ragge break;
86 1.7 ragge
87 1.1 ragge if (name) {
88 1.1 ragge if (bl->bl_nr == 0)
89 1.16 ragge printf("unknown device 0x%x", nr);
90 1.7 ragge else
91 1.7 ragge printf(bl->bl_name);
92 1.4 christos printf(" at %s", name);
93 1.1 ragge }
94 1.4 christos printf(" node %d", ba->ba_nodenr);
95 1.16 ragge if (bl->bl_havedriver & DT_VEC)
96 1.16 ragge printf(" vec %o", ba->ba_ivec & 511);
97 1.8 ragge #ifdef DEBUG
98 1.13 ragge if (bus_space_read_4(ba->ba_iot, ba->ba_ioh, BIREG_SADR) &&
99 1.13 ragge bus_space_read_4(ba->ba_iot, ba->ba_ioh, BIREG_EADR))
100 1.13 ragge printf(" [sadr %x eadr %x]",
101 1.13 ragge bus_space_read_4(ba->ba_iot, ba->ba_ioh, BIREG_SADR),
102 1.13 ragge bus_space_read_4(ba->ba_iot, ba->ba_ioh, BIREG_EADR));
103 1.8 ragge #endif
104 1.16 ragge if (bl->bl_havedriver & DT_QUIET)
105 1.16 ragge printf("\n");
106 1.16 ragge return bl->bl_havedriver & DT_QUIET ? QUIET :
107 1.16 ragge bl->bl_havedriver & DT_HAVDRV ? UNCONF : UNSUPP;
108 1.1 ragge }
109 1.1 ragge
110 1.1 ragge void
111 1.13 ragge bi_attach(sc)
112 1.13 ragge struct bi_softc *sc;
113 1.1 ragge {
114 1.1 ragge struct bi_attach_args ba;
115 1.1 ragge int nodenr;
116 1.1 ragge
117 1.4 christos printf("\n");
118 1.1 ragge
119 1.13 ragge ba.ba_iot = sc->sc_iot;
120 1.13 ragge ba.ba_busnr = sc->sc_busnr;
121 1.14 ragge ba.ba_dmat = sc->sc_dmat;
122 1.14 ragge ba.ba_intcpu = sc->sc_intcpu;
123 1.16 ragge ba.ba_icookie = sc;
124 1.13 ragge /*
125 1.16 ragge * Interrupt numbers. Assign them as described in
126 1.16 ragge * VAX 8800 system maintenance manual; this means like nexus
127 1.16 ragge * adapters have them assigned.
128 1.16 ragge * XXX - must address Unibus adapters.
129 1.13 ragge */
130 1.1 ragge for (nodenr = 0; nodenr < NNODEBI; nodenr++) {
131 1.13 ragge if (bus_space_map(sc->sc_iot, sc->sc_addr + BI_NODE(nodenr),
132 1.15 ragge BI_NODESIZE, 0, &ba.ba_ioh)) {
133 1.13 ragge printf("bi_attach: bus_space_map failed, node %d\n",
134 1.13 ragge nodenr);
135 1.13 ragge return;
136 1.13 ragge }
137 1.16 ragge if (badaddr((caddr_t)ba.ba_ioh, 4) ||
138 1.16 ragge (bus_space_read_2(ba.ba_iot, ba.ba_ioh, 0) == 0)) {
139 1.16 ragge bus_space_unmap(ba.ba_iot, ba.ba_ioh, BI_NODESIZE);
140 1.14 ragge continue;
141 1.11 ragge }
142 1.14 ragge ba.ba_nodenr = nodenr;
143 1.16 ragge ba.ba_ivec = sc->sc_lastiv + 64 + 4 * nodenr; /* all on spl5 */
144 1.14 ragge config_found(&sc->sc_dev, &ba, bi_print);
145 1.1 ragge }
146 1.1 ragge }
147