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