Annotation of sys/arch/vax/vax/autoconf.c, Revision 1.1.1.1
1.1 nbrk 1: /* $OpenBSD: autoconf.c,v 1.29 2007/06/01 19:25:10 deraadt Exp $ */
2: /* $NetBSD: autoconf.c,v 1.45 1999/10/23 14:56:05 ragge Exp $ */
3:
4: /*
5: * Copyright (c) 1988 University of Utah.
6: * Copyright (c) 1982, 1986, 1990 The Regents of the University of California.
7: * Copyright (c) 1994 Ludd, University of Lule}, Sweden.
8: * All rights reserved.
9: *
10: * Redistribution and use in source and binary forms, with or without
11: * modification, are permitted provided that the following conditions
12: * are met:
13: * 1. Redistributions of source code must retain the above copyright
14: * notice, this list of conditions and the following disclaimer.
15: * 2. Redistributions in binary form must reproduce the above copyright
16: * notice, this list of conditions and the following disclaimer in the
17: * documentation and/or other materials provided with the distribution.
18: * 3. All advertising materials mentioning features or use of this software
19: * must display the following acknowledgement:
20: * This product includes software developed at Ludd, University of Lule}.
21: * 4. The name of the author may not be used to endorse or promote products
22: * derived from this software without specific prior written permission
23: *
24: * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
25: * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
26: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
27: * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
28: * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
29: * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
30: * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
31: * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
32: * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
33: * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34: */
35:
36: #include <sys/param.h>
37: #include <sys/types.h>
38: #include <sys/systm.h>
39: #include <sys/device.h>
40: #include <sys/reboot.h>
41: #include <sys/disklabel.h>
42: #include <sys/conf.h>
43:
44: #include <uvm/uvm_extern.h>
45:
46: #include <machine/cpu.h>
47: #include <machine/sid.h>
48: #include <machine/param.h>
49: #include <machine/vmparam.h>
50: #include <machine/nexus.h>
51: #include <machine/ioa.h>
52: #include <machine/ka820.h>
53: #include <machine/ka750.h>
54: #include <machine/ka650.h>
55: #include <machine/clock.h>
56: #include <machine/rpb.h>
57:
58: #include <dev/cons.h>
59:
60: #include "led.h"
61:
62: #include <vax/vax/gencons.h>
63:
64: #include <vax/bi/bireg.h>
65:
66: void dumpconf(void); /* machdep.c */
67: void gencnslask(void);
68:
69: struct cpu_dep *dep_call;
70:
71: int mastercpu; /* chief of the system */
72:
73: struct device *bootdv;
74: int booted_partition; /* defaults to 0 (aka 'a' partition */
75:
76: void
77: cpu_configure()
78: {
79: if (config_rootfound("mainbus", NULL) == NULL)
80: panic("mainbus not configured");
81:
82: /*
83: * We're ready to start up. Clear CPU cold start flag.
84: */
85: cold = 0;
86:
87: if (dep_call->cpu_clrf)
88: (*dep_call->cpu_clrf)();
89: }
90:
91: void
92: diskconf(void)
93: {
94: printf("boot device: %s\n",
95: bootdv ? bootdv->dv_xname : "<unknown>");
96:
97: setroot(bootdv, booted_partition, RB_USERREQ);
98: dumpconf();
99: }
100:
101: int mainbus_print(void *, const char *);
102: int mainbus_match(struct device *, struct cfdata *, void *);
103: void mainbus_attach(struct device *, struct device *, void *);
104:
105: int
106: mainbus_print(aux, hej)
107: void *aux;
108: const char *hej;
109: {
110: struct mainbus_attach_args *maa = aux;
111:
112: if (maa->maa_bustype == VAX_LEDS)
113: return (QUIET);
114:
115: if (hej) {
116: printf("nothing at %s", hej);
117: }
118: return (UNCONF);
119: }
120:
121: int
122: mainbus_match(parent, cf, aux)
123: struct device *parent;
124: struct cfdata *cf;
125: void *aux;
126: {
127: if (cf->cf_unit == 0 &&
128: strcmp(cf->cf_driver->cd_name, "mainbus") == 0)
129: return 1; /* First (and only) mainbus */
130:
131: return (0);
132: }
133:
134: void
135: mainbus_attach(parent, self, hej)
136: struct device *parent, *self;
137: void *hej;
138: {
139: struct mainbus_attach_args maa;
140:
141: printf("\n");
142:
143: maa.maa_bustype = vax_bustype;
144: config_found(self, &maa, mainbus_print);
145:
146: #if VAX53
147: /* These models have both vsbus and ibus */
148: if (vax_boardtype == VAX_BTYP_1303) {
149: maa.maa_bustype = VAX_VSBUS;
150: config_found(self, &maa, mainbus_print);
151: }
152: #endif
153:
154: if (dep_call->cpu_subconf)
155: (*dep_call->cpu_subconf)(self);
156:
157: #if NLED > 0
158: maa.maa_bustype = VAX_LEDS;
159: config_found(self, &maa, mainbus_print);
160: #endif
161:
162: #if 1 /* boot blocks too old */
163: if (rpb.rpb_base == (void *)-1)
164: printf("\nWARNING: you must update your boot blocks.\n\n");
165: #endif
166:
167: }
168:
169: struct cfattach mainbus_ca = {
170: sizeof(struct device), (cfmatch_t) mainbus_match, mainbus_attach
171: };
172:
173: struct cfdriver mainbus_cd = {
174: NULL, "mainbus", DV_DULL
175: };
176:
177: #include "sd.h"
178: #include "cd.h"
179: #if NRL > 0
180: #include "rl.h"
181: #endif
182: #include "ra.h"
183: #include "hp.h"
184: #if NRY > 0
185: #include "ry.h"
186: #endif
187:
188: static int ubtest(void *);
189: static int jmfr(char *, struct device *, int);
190: static int booted_qe(struct device *, void *);
191: static int booted_le(struct device *, void *);
192: static int booted_ze(struct device *, void *);
193: static int booted_de(struct device *, void *);
194: static int booted_ni(struct device *, void *);
195: #if NSD > 0 || NCD > 0
196: static int booted_sd(struct device *, void *);
197: #endif
198: #if NRL > 0
199: static int booted_rl(struct device *, void *);
200: #endif
201: #if NRA
202: static int booted_ra(struct device *, void *);
203: #endif
204: #if NHP
205: static int booted_hp(struct device *, void *);
206: #endif
207: #if NRD
208: static int booted_rd(struct device *, void *);
209: #endif
210:
211: int (*devreg[])(struct device *, void *) = {
212: booted_qe,
213: booted_le,
214: booted_ze,
215: booted_de,
216: booted_ni,
217: #if NSD > 0 || NCD > 0
218: booted_sd,
219: #endif
220: #if NRL > 0
221: booted_rl,
222: #endif
223: #if NRA
224: booted_ra,
225: #endif
226: #if NHP
227: booted_hp,
228: #endif
229: #if NRD
230: booted_hd,
231: #endif
232: 0,
233: };
234:
235: #define ubreg(x) ((x) & 017777)
236:
237: void
238: device_register(struct device *dev, void *aux)
239: {
240: int (**dp)(struct device *, void *) = devreg;
241:
242: /* If there's a synthetic RPB, we can't trust it */
243: if (rpb.rpb_base == (void *)-1)
244: return;
245:
246: while (*dp) {
247: if ((*dp)(dev, aux)) {
248: if (bootdv == NULL)
249: bootdv = dev;
250: break;
251: }
252: dp++;
253: }
254: }
255:
256: /*
257: * Simple checks. Return 1 on fail.
258: */
259: int
260: jmfr(char *n, struct device *dev, int nr)
261: {
262: if (rpb.devtyp != nr)
263: return 1;
264: return strcmp(n, dev->dv_cfdata->cf_driver->cd_name);
265: }
266:
267: #include <arch/vax/qbus/ubavar.h>
268: int
269: ubtest(void *aux)
270: {
271: paddr_t p;
272:
273: p = kvtophys(((struct uba_attach_args *)aux)->ua_ioh);
274: if (rpb.csrphy != p)
275: return 1;
276: return 0;
277: }
278:
279: #if 1 /* NNI */
280: #include <arch/vax/bi/bivar.h>
281: int
282: booted_ni(struct device *dev, void *aux)
283: {
284: struct bi_attach_args *ba = aux;
285:
286: if (jmfr("ni", dev, BDEV_NI) || (kvtophys(ba->ba_ioh) != rpb.csrphy))
287: return 0;
288:
289: return 1;
290: }
291: #endif /* NNI */
292:
293: #if 1 /* NDE */
294: int
295: booted_de(struct device *dev, void *aux)
296: {
297:
298: if (jmfr("de", dev, BDEV_DE) || ubtest(aux))
299: return 0;
300:
301: return 1;
302: }
303: #endif /* NDE */
304:
305: int
306: booted_le(struct device *dev, void *aux)
307: {
308: if (jmfr("le", dev, BDEV_LE))
309: return 0;
310: return 1;
311: }
312:
313: int
314: booted_ze(struct device *dev, void *aux)
315: {
316: if (jmfr("ze", dev, BDEV_ZE))
317: return 0;
318: return 1;
319: }
320:
321: #if 1 /* NQE */
322: int
323: booted_qe(struct device *dev, void *aux)
324: {
325: if (jmfr("qe", dev, BDEV_QE) || ubtest(aux))
326: return 0;
327:
328: return 1;
329: }
330: #endif /* NQE */
331:
332: #if NSD > 0 || NCD > 0
333: #include <scsi/scsi_all.h>
334: #include <scsi/scsiconf.h>
335: int
336: booted_sd(struct device *dev, void *aux)
337: {
338: struct scsi_attach_args *sa = aux;
339: struct device *ppdev;
340:
341: /* Is this a SCSI device? */
342: if (jmfr("sd", dev, BDEV_SD) && jmfr("cd", dev, BDEV_SD) &&
343: jmfr("sd", dev, BDEV_SDN) && jmfr("cd", dev, BDEV_SDN))
344: return 0;
345:
346: #ifdef __NetBSD__
347: if (sa->sa_periph->periph_channel->chan_bustype->bustype_type !=
348: SCSIPI_BUSTYPE_SCSI)
349: return 0; /* ``Cannot happen'' */
350: #endif
351:
352: if (sa->sa_sc_link->target != rpb.unit)
353: return 0; /* Wrong unit */
354:
355: ppdev = dev->dv_parent->dv_parent;
356:
357: /* VS3100 NCR 53C80 (si) & VS4000 NCR 53C94 (asc) */
358: if (((jmfr("ncr", ppdev, BDEV_SD) == 0) || /* old name */
359: (jmfr("asc", ppdev, BDEV_SD) == 0) ||
360: (jmfr("asc", ppdev, BDEV_SDN) == 0)) &&
361: (ppdev->dv_cfdata->cf_loc[0] == rpb.csrphy))
362: return 1;
363:
364: return 0; /* Where did we come from??? */
365: }
366: #endif
367: #if NRL > 0
368: #include <dev/qbus/rlvar.h>
369: int
370: booted_rl(struct device *dev, void *aux)
371: {
372: struct rlc_attach_args *raa = aux;
373: static int ub;
374:
375: if (jmfr("rlc", dev, BDEV_RL) == 0)
376: ub = ubtest(aux);
377: if (ub)
378: return 0;
379: if (jmfr("rl", dev, BDEV_RL))
380: return 0;
381: if (raa->hwid != rpb.unit)
382: return 0; /* Wrong unit number */
383: return 1;
384: }
385: #endif
386:
387: #if NRA
388: #include <arch/vax/mscp/mscp.h>
389: #include <arch/vax/mscp/mscpreg.h>
390: #include <arch/vax/mscp/mscpvar.h>
391: int
392: booted_ra(struct device *dev, void *aux)
393: {
394: struct drive_attach_args *da = aux;
395: struct mscp_softc *pdev = (void *)dev->dv_parent;
396: paddr_t ioaddr;
397:
398: if (jmfr("ra", dev, BDEV_UDA))
399: return 0;
400:
401: if (da->da_mp->mscp_unit != rpb.unit)
402: return 0; /* Wrong unit number */
403:
404: ioaddr = kvtophys(pdev->mi_iph); /* Get phys addr of CSR */
405: if (rpb.devtyp == BDEV_UDA && rpb.csrphy == ioaddr)
406: return 1; /* Did match CSR */
407:
408: return 0;
409: }
410: #endif
411: #if NHP
412: #include <vax/mba/mbavar.h>
413: int
414: booted_hp(struct device *dev, void *aux)
415: {
416: static int mbaaddr;
417:
418: /* Save last adapter address */
419: if (jmfr("mba", dev, BDEV_HP) == 0) {
420: struct sbi_attach_args *sa = aux;
421:
422: mbaaddr = kvtophys(sa->sa_ioh);
423: return 0;
424: }
425:
426: if (jmfr("hp", dev, BDEV_HP))
427: return 0;
428:
429: if (((struct mba_attach_args *)aux)->ma_unit != rpb.unit)
430: return 0;
431:
432: if (mbaaddr != rpb.adpphy)
433: return 0;
434:
435: return 1;
436: }
437: #endif
438: #if NHD
439: int
440: booted_hd(struct device *dev, void *aux)
441: {
442: int *nr = aux; /* XXX - use the correct attach struct */
443:
444: if (jmfr("hd", dev, BDEV_RD))
445: return 0;
446:
447: if (*nr != rpb.unit)
448: return 0;
449:
450: return 1;
451: }
452: #endif
453:
454: struct ngcconf {
455: struct cfdriver *ng_cf;
456: dev_t ng_root;
457: };
458:
459: struct nam2blk nam2blk[] = {
460: { "ra", 9 },
461: { "rx", 12 },
462: #ifdef notyet
463: { "rl", 14 },
464: #endif
465: { "hd", 19 },
466: { "sd", 20 },
467: { "cd", 22 },
468: { "rd", 23 },
469: { "raid", 25 },
470: { NULL, -1 }
471: };
CVSweb