autoconf.c revision 1.7.6.2 1 1.7.6.2 tls /* $NetBSD: autoconf.c,v 1.7.6.2 2013/02/25 00:28:48 tls Exp $ */
2 1.7.6.2 tls
3 1.7.6.2 tls /*
4 1.7.6.2 tls * Copyright (c) 1992 OMRON Corporation.
5 1.7.6.2 tls *
6 1.7.6.2 tls * This code is derived from software contributed to Berkeley by
7 1.7.6.2 tls * OMRON Corporation.
8 1.7.6.2 tls *
9 1.7.6.2 tls * Redistribution and use in source and binary forms, with or without
10 1.7.6.2 tls * modification, are permitted provided that the following conditions
11 1.7.6.2 tls * are met:
12 1.7.6.2 tls * 1. Redistributions of source code must retain the above copyright
13 1.7.6.2 tls * notice, this list of conditions and the following disclaimer.
14 1.7.6.2 tls * 2. Redistributions in binary form must reproduce the above copyright
15 1.7.6.2 tls * notice, this list of conditions and the following disclaimer in the
16 1.7.6.2 tls * documentation and/or other materials provided with the distribution.
17 1.7.6.2 tls * 3. All advertising materials mentioning features or use of this software
18 1.7.6.2 tls * must display the following acknowledgement:
19 1.7.6.2 tls * This product includes software developed by the University of
20 1.7.6.2 tls * California, Berkeley and its contributors.
21 1.7.6.2 tls * 4. Neither the name of the University nor the names of its contributors
22 1.7.6.2 tls * may be used to endorse or promote products derived from this software
23 1.7.6.2 tls * without specific prior written permission.
24 1.7.6.2 tls *
25 1.7.6.2 tls * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26 1.7.6.2 tls * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 1.7.6.2 tls * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 1.7.6.2 tls * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29 1.7.6.2 tls * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 1.7.6.2 tls * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 1.7.6.2 tls * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 1.7.6.2 tls * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 1.7.6.2 tls * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 1.7.6.2 tls * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 1.7.6.2 tls * SUCH DAMAGE.
36 1.7.6.2 tls *
37 1.7.6.2 tls * @(#)autoconf.c 8.1 (Berkeley) 6/10/93
38 1.7.6.2 tls */
39 1.7.6.2 tls /*
40 1.7.6.2 tls * Copyright (c) 1992, 1993
41 1.7.6.2 tls * The Regents of the University of California. All rights reserved.
42 1.7.6.2 tls *
43 1.7.6.2 tls * This code is derived from software contributed to Berkeley by
44 1.7.6.2 tls * OMRON Corporation.
45 1.7.6.2 tls *
46 1.7.6.2 tls * Redistribution and use in source and binary forms, with or without
47 1.7.6.2 tls * modification, are permitted provided that the following conditions
48 1.7.6.2 tls * are met:
49 1.7.6.2 tls * 1. Redistributions of source code must retain the above copyright
50 1.7.6.2 tls * notice, this list of conditions and the following disclaimer.
51 1.7.6.2 tls * 2. Redistributions in binary form must reproduce the above copyright
52 1.7.6.2 tls * notice, this list of conditions and the following disclaimer in the
53 1.7.6.2 tls * documentation and/or other materials provided with the distribution.
54 1.7.6.2 tls * 3. Neither the name of the University nor the names of its contributors
55 1.7.6.2 tls * may be used to endorse or promote products derived from this software
56 1.7.6.2 tls * without specific prior written permission.
57 1.7.6.2 tls *
58 1.7.6.2 tls * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
59 1.7.6.2 tls * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
60 1.7.6.2 tls * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
61 1.7.6.2 tls * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
62 1.7.6.2 tls * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
63 1.7.6.2 tls * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
64 1.7.6.2 tls * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
65 1.7.6.2 tls * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
66 1.7.6.2 tls * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
67 1.7.6.2 tls * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
68 1.7.6.2 tls * SUCH DAMAGE.
69 1.7.6.2 tls *
70 1.7.6.2 tls * @(#)autoconf.c 8.1 (Berkeley) 6/10/93
71 1.7.6.2 tls */
72 1.7.6.2 tls
73 1.7.6.2 tls /*
74 1.7.6.2 tls * autoconf.c -- Determine mass storage and memory configuration for a machine.
75 1.7.6.2 tls * by A.Fujita, NOV-30-1991
76 1.7.6.2 tls *
77 1.7.6.2 tls * Modified by A.Fujita, FEB-04-1992
78 1.7.6.2 tls */
79 1.7.6.2 tls
80 1.7.6.2 tls
81 1.7.6.2 tls #include <sys/param.h>
82 1.7.6.2 tls #include <sys/dkstat.h>
83 1.7.6.2 tls #include <machine/cpu.h>
84 1.7.6.2 tls #include <lib/libkern/libkern.h>
85 1.7.6.2 tls #include <luna68k/stand/boot/samachdep.h>
86 1.7.6.2 tls #include <luna68k/stand/boot/device.h>
87 1.7.6.2 tls
88 1.7.6.2 tls int dkn; /* number of iostat dk numbers assigned so far */
89 1.7.6.2 tls struct hp_hw sc_table[MAX_CTLR];
90 1.7.6.2 tls
91 1.7.6.2 tls #ifdef DEBUG
92 1.7.6.2 tls int acdebug = 1;
93 1.7.6.2 tls #endif
94 1.7.6.2 tls
95 1.7.6.2 tls static int find_controller(struct hp_hw *);
96 1.7.6.2 tls static int find_device(struct hp_hw *);
97 1.7.6.2 tls static void find_slaves(struct hp_ctlr *);
98 1.7.6.2 tls static int same_hw_device(struct hp_hw *, struct hp_device *);
99 1.7.6.2 tls
100 1.7.6.2 tls /*
101 1.7.6.2 tls * Determine mass storage and memory configuration for a machine.
102 1.7.6.2 tls */
103 1.7.6.2 tls void
104 1.7.6.2 tls configure(void)
105 1.7.6.2 tls {
106 1.7.6.2 tls struct hp_hw *hw;
107 1.7.6.2 tls int found;
108 1.7.6.2 tls
109 1.7.6.2 tls /*
110 1.7.6.2 tls * Look over each hardware device actually found and attempt
111 1.7.6.2 tls * to match it with an ioconf.c table entry.
112 1.7.6.2 tls */
113 1.7.6.2 tls for (hw = sc_table; hw->hw_type; hw++) {
114 1.7.6.2 tls if (hw->hw_type & CONTROLLER)
115 1.7.6.2 tls found = find_controller(hw);
116 1.7.6.2 tls else
117 1.7.6.2 tls found = find_device(hw);
118 1.7.6.2 tls #ifdef DEBUG
119 1.7.6.2 tls if (!found) {
120 1.7.6.2 tls printf("unconfigured %s ", hw->hw_name);
121 1.7.6.2 tls printf("at 0x%x\n", (u_int)hw->hw_addr);
122 1.7.6.2 tls }
123 1.7.6.2 tls #endif
124 1.7.6.2 tls }
125 1.7.6.2 tls
126 1.7.6.2 tls }
127 1.7.6.2 tls
128 1.7.6.2 tls #define dr_type(d, s) \
129 1.7.6.2 tls (strcmp((d)->d_name, (s)) == 0)
130 1.7.6.2 tls
131 1.7.6.2 tls #define same_hw_ctlr(hw, hc) \
132 1.7.6.2 tls ((hw)->hw_type == SCSI && dr_type((hc)->hp_driver, "sc"))
133 1.7.6.2 tls
134 1.7.6.2 tls int
135 1.7.6.2 tls find_controller(struct hp_hw *hw)
136 1.7.6.2 tls {
137 1.7.6.2 tls struct hp_ctlr *hc;
138 1.7.6.2 tls struct hp_ctlr *match_c;
139 1.7.6.2 tls uint8_t *addr, *oaddr;
140 1.7.6.2 tls
141 1.7.6.2 tls #ifdef DEBUG
142 1.7.6.2 tls if (acdebug)
143 1.7.6.2 tls printf("find_controller: hw: %s at sc%d (%x), type %x...",
144 1.7.6.2 tls hw->hw_name, hw->hw_sc, (u_int)hw->hw_addr, hw->hw_type);
145 1.7.6.2 tls #endif
146 1.7.6.2 tls addr = hw->hw_addr;
147 1.7.6.2 tls match_c = NULL;
148 1.7.6.2 tls for (hc = hp_cinit; hc->hp_driver; hc++) {
149 1.7.6.2 tls if (hc->hp_alive)
150 1.7.6.2 tls continue;
151 1.7.6.2 tls /*
152 1.7.6.2 tls * Make sure we are looking at the right
153 1.7.6.2 tls * controller type.
154 1.7.6.2 tls */
155 1.7.6.2 tls if (!same_hw_ctlr(hw, hc))
156 1.7.6.2 tls continue;
157 1.7.6.2 tls /*
158 1.7.6.2 tls * Exact match; all done
159 1.7.6.2 tls */
160 1.7.6.2 tls if (hc->hp_addr == addr) {
161 1.7.6.2 tls match_c = hc;
162 1.7.6.2 tls break;
163 1.7.6.2 tls }
164 1.7.6.2 tls /*
165 1.7.6.2 tls * Wildcard; possible match so remember first instance
166 1.7.6.2 tls * but continue looking for exact match.
167 1.7.6.2 tls */
168 1.7.6.2 tls if ((int)hc->hp_addr == WILD_CARD_CTLR && match_c == NULL)
169 1.7.6.2 tls match_c = hc;
170 1.7.6.2 tls }
171 1.7.6.2 tls #ifdef DEBUG
172 1.7.6.2 tls if (acdebug) {
173 1.7.6.2 tls if (match_c)
174 1.7.6.2 tls printf("found %s%d\n",
175 1.7.6.2 tls match_c->hp_driver->d_name,
176 1.7.6.2 tls match_c->hp_unit);
177 1.7.6.2 tls else
178 1.7.6.2 tls printf("not found\n");
179 1.7.6.2 tls }
180 1.7.6.2 tls #endif
181 1.7.6.2 tls /*
182 1.7.6.2 tls * Didn't find an ioconf entry for this piece of hardware,
183 1.7.6.2 tls * just ignore it.
184 1.7.6.2 tls */
185 1.7.6.2 tls if (match_c == NULL)
186 1.7.6.2 tls return(0);
187 1.7.6.2 tls /*
188 1.7.6.2 tls * Found a match, attempt to initialize and configure all attached
189 1.7.6.2 tls * slaves. Note, we can still fail if HW won't initialize.
190 1.7.6.2 tls */
191 1.7.6.2 tls hc = match_c;
192 1.7.6.2 tls oaddr = hc->hp_addr;
193 1.7.6.2 tls hc->hp_addr = hw->hw_addr;
194 1.7.6.2 tls if ((*hc->hp_driver->d_init)(hc)) {
195 1.7.6.2 tls hc->hp_alive = 1;
196 1.7.6.2 tls printf("%s%d", hc->hp_driver->d_name, hc->hp_unit);
197 1.7.6.2 tls printf(" at %p,", hc->hp_addr);
198 1.7.6.2 tls printf(" ipl %d", hc->hp_ipl);
199 1.7.6.2 tls if (hc->hp_flags)
200 1.7.6.2 tls printf(" flags 0x%x", hc->hp_flags);
201 1.7.6.2 tls printf("\n");
202 1.7.6.2 tls find_slaves(hc);
203 1.7.6.2 tls } else
204 1.7.6.2 tls hc->hp_addr = oaddr;
205 1.7.6.2 tls return(1);
206 1.7.6.2 tls }
207 1.7.6.2 tls
208 1.7.6.2 tls int
209 1.7.6.2 tls find_device(struct hp_hw *hw)
210 1.7.6.2 tls {
211 1.7.6.2 tls struct hp_device *hd;
212 1.7.6.2 tls struct hp_device *match_d;
213 1.7.6.2 tls uint8_t *addr, *oaddr;
214 1.7.6.2 tls
215 1.7.6.2 tls #ifdef DEBUG
216 1.7.6.2 tls if (acdebug)
217 1.7.6.2 tls printf("find_device: hw: %s at sc%d (%x), type %x...",
218 1.7.6.2 tls hw->hw_name, hw->hw_sc, (u_int)hw->hw_addr, hw->hw_type);
219 1.7.6.2 tls #endif
220 1.7.6.2 tls match_d = NULL;
221 1.7.6.2 tls for (hd = hp_dinit; hd->hp_driver; hd++) {
222 1.7.6.2 tls if (hd->hp_alive)
223 1.7.6.2 tls continue;
224 1.7.6.2 tls /* Must not be a slave */
225 1.7.6.2 tls if (hd->hp_cdriver)
226 1.7.6.2 tls continue;
227 1.7.6.2 tls addr = hd->hp_addr;
228 1.7.6.2 tls /*
229 1.7.6.2 tls * Exact match; all done.
230 1.7.6.2 tls */
231 1.7.6.2 tls if (addr != NULL && addr == hw->hw_addr) {
232 1.7.6.2 tls match_d = hd;
233 1.7.6.2 tls break;
234 1.7.6.2 tls }
235 1.7.6.2 tls /*
236 1.7.6.2 tls * Wildcard; possible match so remember first instance
237 1.7.6.2 tls * but continue looking for exact match.
238 1.7.6.2 tls */
239 1.7.6.2 tls if (addr == NULL && same_hw_device(hw, hd) && match_d == NULL)
240 1.7.6.2 tls match_d = hd;
241 1.7.6.2 tls }
242 1.7.6.2 tls #ifdef DEBUG
243 1.7.6.2 tls if (acdebug) {
244 1.7.6.2 tls if (match_d)
245 1.7.6.2 tls printf("found %s%d\n",
246 1.7.6.2 tls match_d->hp_driver->d_name,
247 1.7.6.2 tls match_d->hp_unit);
248 1.7.6.2 tls else
249 1.7.6.2 tls printf("not found\n");
250 1.7.6.2 tls }
251 1.7.6.2 tls #endif
252 1.7.6.2 tls /*
253 1.7.6.2 tls * Didn't find an ioconf entry for this piece
254 1.7.6.2 tls * of hardware, just ignore it.
255 1.7.6.2 tls */
256 1.7.6.2 tls if (match_d == NULL)
257 1.7.6.2 tls return(0);
258 1.7.6.2 tls /*
259 1.7.6.2 tls * Found a match, attempt to initialize.
260 1.7.6.2 tls * Note, we can still fail if HW won't initialize.
261 1.7.6.2 tls */
262 1.7.6.2 tls hd = match_d;
263 1.7.6.2 tls oaddr = hd->hp_addr;
264 1.7.6.2 tls hd->hp_addr = hw->hw_addr;
265 1.7.6.2 tls if ((*hd->hp_driver->d_init)(hd)) {
266 1.7.6.2 tls hd->hp_alive = 1;
267 1.7.6.2 tls printf("%s%d", hd->hp_driver->d_name, hd->hp_unit);
268 1.7.6.2 tls printf(" at %p", hd->hp_addr);
269 1.7.6.2 tls if (hd->hp_ipl)
270 1.7.6.2 tls printf(", ipl %d", hd->hp_ipl);
271 1.7.6.2 tls if (hd->hp_flags)
272 1.7.6.2 tls printf(", flags 0x%x", hd->hp_flags);
273 1.7.6.2 tls printf("\n");
274 1.7.6.2 tls } else
275 1.7.6.2 tls hd->hp_addr = oaddr;
276 1.7.6.2 tls return(1);
277 1.7.6.2 tls }
278 1.7.6.2 tls
279 1.7.6.2 tls /*
280 1.7.6.2 tls * Search each BUS controller found for slaves attached to it.
281 1.7.6.2 tls * The bad news is that we don't know how to uniquely identify all slaves
282 1.7.6.2 tls * (e.g. PPI devices on HP-IB). The good news is that we can at least
283 1.7.6.2 tls * differentiate those from slaves we can identify. At worst (a totally
284 1.7.6.2 tls * wildcarded entry) this will cause us to locate such a slave at the first
285 1.7.6.2 tls * unused position instead of where it really is. To save grief, non-
286 1.7.6.2 tls * identifing devices should always be fully qualified.
287 1.7.6.2 tls */
288 1.7.6.2 tls void
289 1.7.6.2 tls find_slaves(struct hp_ctlr *hc)
290 1.7.6.2 tls {
291 1.7.6.2 tls int s;
292 1.7.6.2 tls struct hp_device *hd;
293 1.7.6.2 tls struct hp_device *match_s;
294 1.7.6.2 tls int maxslaves = MAXSLAVES-1;
295 1.7.6.2 tls int new_s, new_c, old_s, old_c;
296 1.7.6.2 tls int rescan;
297 1.7.6.2 tls
298 1.7.6.2 tls #ifdef DEBUG
299 1.7.6.2 tls if (acdebug)
300 1.7.6.2 tls printf("find_slaves: for %s%d\n",
301 1.7.6.2 tls hc->hp_driver->d_name, hc->hp_unit);
302 1.7.6.2 tls #endif
303 1.7.6.2 tls for (s = 0; s < maxslaves; s++) {
304 1.7.6.2 tls rescan = 1;
305 1.7.6.2 tls match_s = NULL;
306 1.7.6.2 tls for (hd = hp_dinit; hd->hp_driver; hd++) {
307 1.7.6.2 tls /*
308 1.7.6.2 tls * Rule out the easy ones:
309 1.7.6.2 tls * 1. slave already assigned or not a slave
310 1.7.6.2 tls * 2. not of the proper type
311 1.7.6.2 tls * 3. controller specified but not this one
312 1.7.6.2 tls * 4. slave specified but not this one
313 1.7.6.2 tls */
314 1.7.6.2 tls if (hd->hp_alive || hd->hp_cdriver == NULL)
315 1.7.6.2 tls continue;
316 1.7.6.2 tls if (!dr_type(hc->hp_driver, hd->hp_cdriver->d_name))
317 1.7.6.2 tls continue;
318 1.7.6.2 tls if (hd->hp_ctlr >= 0 && hd->hp_ctlr != hc->hp_unit)
319 1.7.6.2 tls continue;
320 1.7.6.2 tls if (hd->hp_slave >= 0 && hd->hp_slave != s)
321 1.7.6.2 tls continue;
322 1.7.6.2 tls /*
323 1.7.6.2 tls * Case 0: first possible match.
324 1.7.6.2 tls * Remember it and keep looking for better.
325 1.7.6.2 tls */
326 1.7.6.2 tls if (match_s == NULL) {
327 1.7.6.2 tls match_s = hd;
328 1.7.6.2 tls new_c = hc->hp_unit;
329 1.7.6.2 tls new_s = s;
330 1.7.6.2 tls continue;
331 1.7.6.2 tls }
332 1.7.6.2 tls /*
333 1.7.6.2 tls * Case 1: exact match.
334 1.7.6.2 tls * All done. Note that we do not attempt any other
335 1.7.6.2 tls * matches if this one fails. This allows us to
336 1.7.6.2 tls * "reserve" locations for dynamic addition of
337 1.7.6.2 tls * disk/tape drives by fully qualifing the location.
338 1.7.6.2 tls */
339 1.7.6.2 tls if (hd->hp_slave == s && hd->hp_ctlr == hc->hp_unit) {
340 1.7.6.2 tls match_s = hd;
341 1.7.6.2 tls rescan = 0;
342 1.7.6.2 tls break;
343 1.7.6.2 tls }
344 1.7.6.2 tls /*
345 1.7.6.2 tls * Case 2: right controller, wildcarded slave.
346 1.7.6.2 tls * Remember first and keep looking for an exact match.
347 1.7.6.2 tls */
348 1.7.6.2 tls if (hd->hp_ctlr == hc->hp_unit &&
349 1.7.6.2 tls match_s->hp_ctlr < 0) {
350 1.7.6.2 tls match_s = hd;
351 1.7.6.2 tls new_s = s;
352 1.7.6.2 tls continue;
353 1.7.6.2 tls }
354 1.7.6.2 tls /*
355 1.7.6.2 tls * Case 3: right slave, wildcarded controller.
356 1.7.6.2 tls * Remember and keep looking for a better match.
357 1.7.6.2 tls */
358 1.7.6.2 tls if (hd->hp_slave == s &&
359 1.7.6.2 tls match_s->hp_ctlr < 0 && match_s->hp_slave < 0) {
360 1.7.6.2 tls match_s = hd;
361 1.7.6.2 tls new_c = hc->hp_unit;
362 1.7.6.2 tls continue;
363 1.7.6.2 tls }
364 1.7.6.2 tls /*
365 1.7.6.2 tls * OW: we had a totally wildcarded spec.
366 1.7.6.2 tls * If we got this far, we have found a possible
367 1.7.6.2 tls * match already (match_s != NULL) so there is no
368 1.7.6.2 tls * reason to remember this one.
369 1.7.6.2 tls */
370 1.7.6.2 tls continue;
371 1.7.6.2 tls }
372 1.7.6.2 tls /*
373 1.7.6.2 tls * Found a match. We need to set hp_ctlr/hp_slave properly
374 1.7.6.2 tls * for the init routines but we also need to remember all
375 1.7.6.2 tls * the old values in case this doesn't pan out.
376 1.7.6.2 tls */
377 1.7.6.2 tls if (match_s) {
378 1.7.6.2 tls hd = match_s;
379 1.7.6.2 tls old_c = hd->hp_ctlr;
380 1.7.6.2 tls old_s = hd->hp_slave;
381 1.7.6.2 tls if (hd->hp_ctlr < 0)
382 1.7.6.2 tls hd->hp_ctlr = new_c;
383 1.7.6.2 tls if (hd->hp_slave < 0)
384 1.7.6.2 tls hd->hp_slave = new_s;
385 1.7.6.2 tls #ifdef DEBUG
386 1.7.6.2 tls if (acdebug)
387 1.7.6.2 tls printf("looking for %s%d at slave %d...",
388 1.7.6.2 tls hd->hp_driver->d_name,
389 1.7.6.2 tls hd->hp_unit, hd->hp_slave);
390 1.7.6.2 tls #endif
391 1.7.6.2 tls
392 1.7.6.2 tls if ((*hd->hp_driver->d_init)(hd)) {
393 1.7.6.2 tls #ifdef DEBUG
394 1.7.6.2 tls if (acdebug)
395 1.7.6.2 tls printf("found\n");
396 1.7.6.2 tls #endif
397 1.7.6.2 tls printf("%s%d at %s%d, slave %d",
398 1.7.6.2 tls hd->hp_driver->d_name, hd->hp_unit,
399 1.7.6.2 tls hc->hp_driver->d_name, hd->hp_ctlr,
400 1.7.6.2 tls hd->hp_slave);
401 1.7.6.2 tls if (hd->hp_flags)
402 1.7.6.2 tls printf(" flags 0x%x", hd->hp_flags);
403 1.7.6.2 tls printf("\n");
404 1.7.6.2 tls hd->hp_alive = 1;
405 1.7.6.2 tls if (hd->hp_dk && dkn < DK_NDRIVE)
406 1.7.6.2 tls hd->hp_dk = dkn++;
407 1.7.6.2 tls else
408 1.7.6.2 tls hd->hp_dk = -1;
409 1.7.6.2 tls rescan = 1;
410 1.7.6.2 tls } else {
411 1.7.6.2 tls #ifdef DEBUG
412 1.7.6.2 tls if (acdebug)
413 1.7.6.2 tls printf("not found\n");
414 1.7.6.2 tls #endif
415 1.7.6.2 tls hd->hp_ctlr = old_c;
416 1.7.6.2 tls hd->hp_slave = old_s;
417 1.7.6.2 tls }
418 1.7.6.2 tls /*
419 1.7.6.2 tls * XXX: This should be handled better.
420 1.7.6.2 tls * Re-scan a slave. There are two reasons to do this.
421 1.7.6.2 tls * 1. It is possible to have both a tape and disk
422 1.7.6.2 tls * (e.g. 7946) or two disks (e.g. 9122) at the
423 1.7.6.2 tls * same slave address. Here we need to rescan
424 1.7.6.2 tls * looking only at entries with a different
425 1.7.6.2 tls * physical unit number (hp_flags).
426 1.7.6.2 tls * 2. It is possible that an init failed because the
427 1.7.6.2 tls * slave was there but of the wrong type. In this
428 1.7.6.2 tls * case it may still be possible to match the slave
429 1.7.6.2 tls * to another ioconf entry of a different type.
430 1.7.6.2 tls * Here we need to rescan looking only at entries
431 1.7.6.2 tls * of different types.
432 1.7.6.2 tls * In both cases we avoid looking at undesirable
433 1.7.6.2 tls * ioconf entries of the same type by setting their
434 1.7.6.2 tls * alive fields to -1.
435 1.7.6.2 tls */
436 1.7.6.2 tls if (rescan) {
437 1.7.6.2 tls for (hd = hp_dinit; hd->hp_driver; hd++) {
438 1.7.6.2 tls if (hd->hp_alive)
439 1.7.6.2 tls continue;
440 1.7.6.2 tls if (match_s->hp_alive == 1) { /* 1 */
441 1.7.6.2 tls if (hd->hp_flags == match_s->hp_flags)
442 1.7.6.2 tls hd->hp_alive = -1;
443 1.7.6.2 tls } else { /* 2 */
444 1.7.6.2 tls if (hd->hp_driver == match_s->hp_driver)
445 1.7.6.2 tls hd->hp_alive = -1;
446 1.7.6.2 tls }
447 1.7.6.2 tls }
448 1.7.6.2 tls s--;
449 1.7.6.2 tls continue;
450 1.7.6.2 tls }
451 1.7.6.2 tls }
452 1.7.6.2 tls /*
453 1.7.6.2 tls * Reset bogon alive fields prior to attempting next slave
454 1.7.6.2 tls */
455 1.7.6.2 tls for (hd = hp_dinit; hd->hp_driver; hd++)
456 1.7.6.2 tls if (hd->hp_alive == -1)
457 1.7.6.2 tls hd->hp_alive = 0;
458 1.7.6.2 tls }
459 1.7.6.2 tls }
460 1.7.6.2 tls
461 1.7.6.2 tls int
462 1.7.6.2 tls same_hw_device(struct hp_hw *hw, struct hp_device *hd)
463 1.7.6.2 tls {
464 1.7.6.2 tls int found = 0;
465 1.7.6.2 tls
466 1.7.6.2 tls switch (hw->hw_type) {
467 1.7.6.2 tls case NET:
468 1.7.6.2 tls found = dr_type(hd->hp_driver, "le");
469 1.7.6.2 tls break;
470 1.7.6.2 tls case SCSI:
471 1.7.6.2 tls found = dr_type(hd->hp_driver, "scsi");
472 1.7.6.2 tls break;
473 1.7.6.2 tls case VME:
474 1.7.6.2 tls case MISC:
475 1.7.6.2 tls break;
476 1.7.6.2 tls }
477 1.7.6.2 tls return(found);
478 1.7.6.2 tls }
479 1.7.6.2 tls
480 1.7.6.2 tls #define setup_hw(hw, addr, type, name) \
481 1.7.6.2 tls (hw)->hw_addr = addr; \
482 1.7.6.2 tls (hw)->hw_type = type; \
483 1.7.6.2 tls (hw)->hw_name = name
484 1.7.6.2 tls
485 1.7.6.2 tls void
486 1.7.6.2 tls find_devs(void)
487 1.7.6.2 tls {
488 1.7.6.2 tls struct hp_hw *hw = sc_table;
489 1.7.6.2 tls
490 1.7.6.2 tls setup_hw(hw, (uint8_t *)0x51000000, SIO, "uPD7201A (SIO)");
491 1.7.6.2 tls hw++;
492 1.7.6.2 tls
493 1.7.6.2 tls setup_hw(hw, (uint8_t *)0x51000004, KEYBOARD, "uPD7201A (KBD)");
494 1.7.6.2 tls hw++;
495 1.7.6.2 tls
496 1.7.6.2 tls setup_hw(hw, (uint8_t *)0xe1000000, SCSI, "MB89352 (SPC)");
497 1.7.6.2 tls hw++;
498 1.7.6.2 tls
499 1.7.6.2 tls if (machtype == LUNA_II && !badaddr((void *) 0xe1000040)) {
500 1.7.6.2 tls setup_hw(hw, (uint8_t *)0xe1000040, SCSI, "MB89352 (SPC)");
501 1.7.6.2 tls hw++;
502 1.7.6.2 tls }
503 1.7.6.2 tls if (!badaddr((void *) 0xf1000000)) {
504 1.7.6.2 tls setup_hw(hw, (uint8_t *)0xf1000000, NET, "Am7990 (LANCE)");
505 1.7.6.2 tls hw++;
506 1.7.6.2 tls }
507 1.7.6.2 tls }
508