autoconf.c revision 1.2 1 1.2 matt /* $NetBSD: autoconf.c,v 1.2 2009/12/14 00:46:02 matt Exp $ */
2 1.2 matt
3 1.2 matt /*
4 1.2 matt * Copyright 2002 Wasabi Systems, Inc.
5 1.2 matt * All rights reserved.
6 1.2 matt *
7 1.2 matt * Written by Simon Burge for Wasabi Systems, Inc.
8 1.2 matt *
9 1.2 matt * Redistribution and use in source and binary forms, with or without
10 1.2 matt * modification, are permitted provided that the following conditions
11 1.2 matt * are met:
12 1.2 matt * 1. Redistributions of source code must retain the above copyright
13 1.2 matt * notice, this list of conditions and the following disclaimer.
14 1.2 matt * 2. Redistributions in binary form must reproduce the above copyright
15 1.2 matt * notice, this list of conditions and the following disclaimer in the
16 1.2 matt * documentation and/or other materials provided with the distribution.
17 1.2 matt * 3. All advertising materials mentioning features or use of this software
18 1.2 matt * must display the following acknowledgement:
19 1.2 matt * This product includes software developed for the NetBSD Project by
20 1.2 matt * Wasabi Systems, Inc.
21 1.2 matt * 4. The name of Wasabi Systems, Inc. may not be used to endorse
22 1.2 matt * or promote products derived from this software without specific prior
23 1.2 matt * written permission.
24 1.2 matt *
25 1.2 matt * THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND
26 1.2 matt * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27 1.2 matt * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 1.2 matt * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC
29 1.2 matt * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 1.2 matt * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 1.2 matt * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 1.2 matt * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 1.2 matt * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 1.2 matt * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 1.2 matt * POSSIBILITY OF SUCH DAMAGE.
36 1.2 matt */
37 1.2 matt
38 1.2 matt #include <sys/cdefs.h>
39 1.2 matt __KERNEL_RCSID(0, "$NetBSD: autoconf.c,v 1.2 2009/12/14 00:46:02 matt Exp $");
40 1.2 matt
41 1.2 matt #include <sys/param.h>
42 1.2 matt #include <sys/systm.h>
43 1.2 matt #include <sys/buf.h>
44 1.2 matt #include <sys/conf.h>
45 1.2 matt #include <sys/device.h>
46 1.2 matt #include <sys/cpu.h>
47 1.2 matt
48 1.2 matt static void findroot(void);
49 1.2 matt
50 1.2 matt void
51 1.2 matt cpu_configure()
52 1.2 matt {
53 1.2 matt
54 1.2 matt intr_init();
55 1.2 matt
56 1.2 matt /* Kick off autoconfiguration. */
57 1.2 matt (void)splhigh();
58 1.2 matt if (config_rootfound("mainbus", NULL) == NULL)
59 1.2 matt panic("no mainbus found");
60 1.2 matt
61 1.2 matt /*
62 1.2 matt * Hardware interrupts will be enabled in
63 1.2 matt * sys/arch/mips/mips/mips3_clockintr.c:mips3_initclocks()
64 1.2 matt * to avoid hardclock(9) by CPU INT5 before softclockintr is
65 1.2 matt * initialized in initclocks().
66 1.2 matt */
67 1.2 matt }
68 1.2 matt
69 1.2 matt void
70 1.2 matt cpu_rootconf()
71 1.2 matt {
72 1.2 matt findroot();
73 1.2 matt
74 1.2 matt printf("boot device: %s\n",
75 1.2 matt booted_device ? booted_device->dv_xname : "<unknown>");
76 1.2 matt
77 1.2 matt setroot(booted_device, booted_partition);
78 1.2 matt }
79 1.2 matt
80 1.2 matt extern char bootstring[];
81 1.2 matt extern int netboot;
82 1.2 matt
83 1.2 matt static void
84 1.2 matt findroot(void)
85 1.2 matt {
86 1.2 matt struct device *dv;
87 1.2 matt
88 1.2 matt if (booted_device)
89 1.2 matt return;
90 1.2 matt
91 1.2 matt if ((booted_device == NULL) && netboot == 0)
92 1.2 matt for (dv = TAILQ_FIRST(&alldevs); dv != NULL;
93 1.2 matt dv = TAILQ_NEXT(dv, dv_list))
94 1.2 matt if (device_class(dv) == DV_DISK &&
95 1.2 matt device_is_a(dv, "wd"))
96 1.2 matt booted_device = dv;
97 1.2 matt
98 1.2 matt /*
99 1.2 matt * XXX Match up MBR boot specification with BSD disklabel for root?
100 1.2 matt */
101 1.2 matt booted_partition = 0;
102 1.2 matt
103 1.2 matt return;
104 1.2 matt }
105 1.2 matt
106 1.2 matt void
107 1.2 matt device_register(dev, aux)
108 1.2 matt struct device *dev;
109 1.2 matt void *aux;
110 1.2 matt {
111 1.2 matt if ((booted_device == NULL) && (netboot == 1))
112 1.2 matt if (device_class(dev) == DV_IFNET)
113 1.2 matt booted_device = dev;
114 1.2 matt }
115