1 /*-
2 * Copyright (c) 1990 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * This code is derived from software contributed to Berkeley by
6 * William Jolitz.
7 *
8 * Redistribution and use in source and binary forms, with or without
9 * modification, are permitted provided that the following conditions
10 * are met:
11 * 1. Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * 2. Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in the
15 * documentation and/or other materials provided with the distribution.
16 * 3. All advertising materials mentioning features or use of this software
17 * must display the following acknowledgement:
18 * This product includes software developed by the University of
19 * California, Berkeley and its contributors.
20 * 4. Neither the name of the University nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
25 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34 * SUCH DAMAGE.
35 *
36 * from: @(#)autoconf.c 7.1 (Berkeley) 5/9/91
37 * $FreeBSD: releng/5.0/sys/i386/i386/autoconf.c 103770 2002-09-22 00:59:02Z jake $
38 */
39
40 /*
41 * Setup the system to run on the current machine.
42 *
43 * Configure() is called at boot time and initializes the vba
44 * device tables and the memory controller monitoring. Available
45 * devices are determined (from possibilities mentioned in ioconf.c),
46 * and the drivers are initialized.
47 */
48 #include "opt_bootp.h"
49 #include "opt_isa.h"
50 #include "opt_nfs.h"
51 #include "opt_nfsroot.h"
52 #include "opt_bus.h"
53
54 #include <sys/param.h>
55 #include <sys/systm.h>
56 #include <sys/bus.h>
57 #include <sys/conf.h>
58 #include <sys/reboot.h>
59 #include <sys/kernel.h>
60 #include <sys/malloc.h>
61 #include <sys/mount.h>
62 #include <sys/cons.h>
63
64 #include <sys/socket.h>
65 #include <net/if.h>
66 #include <net/if_dl.h>
67 #include <net/if_types.h>
68 #include <net/if_var.h>
69 #include <net/ethernet.h>
70 #include <netinet/in.h>
71 #include <nfs/rpcv2.h>
72 #include <nfs/nfsproto.h>
73 #include <nfsclient/nfs.h>
74 #include <nfsclient/nfsdiskless.h>
75
76 #include <machine/bootinfo.h>
77 #include <machine/md_var.h>
78 #ifdef APIC_IO
79 #include <machine/smp.h>
80 #else
81 #include <i386/isa/icu.h>
82 #endif /* APIC_IO */
83
84 #ifdef DEV_ISA
85 #include <isa/isavar.h>
86
87 device_t isa_bus_device = 0;
88 #endif
89
90 static void configure_first(void *);
91 static void configure(void *);
92 static void configure_final(void *);
93
94 SYSINIT(configure1, SI_SUB_CONFIGURE, SI_ORDER_FIRST, configure_first, NULL);
95 /* SI_ORDER_SECOND is hookable */
96 SYSINIT(configure2, SI_SUB_CONFIGURE, SI_ORDER_THIRD, configure, NULL);
97 /* SI_ORDER_MIDDLE is hookable */
98 SYSINIT(configure3, SI_SUB_CONFIGURE, SI_ORDER_ANY, configure_final, NULL);
99
100 device_t nexus_dev;
101
102 /*
103 * Determine i/o configuration for a machine.
104 */
105 static void
106 configure_first(dummy)
107 void *dummy;
108 {
109 }
110
111 static void
112 configure(dummy)
113 void *dummy;
114 {
115
116 /*
117 * Activate the ICU's. Note that we are explicitly at splhigh()
118 * at present as we have no way to disable stray PCI level triggered
119 * interrupts until the devices have had a driver attached. This
120 * is particularly a problem when the interrupts are shared. For
121 * example, if IRQ 10 is shared between a disk and network device
122 * and the disk device generates an interrupt, if we "activate"
123 * IRQ 10 when the network driver is set up, then we will get
124 * recursive interrupt 10's as nothing will know how to turn off
125 * the disk device's interrupt.
126 *
127 * Having the ICU's active means we can probe interrupt routing to
128 * see if a device causes the corresponding pending bit to be set.
129 *
130 * This is all rather inconvenient.
131 */
132 #ifdef APIC_IO
133 bsp_apic_configure();
134 enable_intr();
135 #else
136 enable_intr();
137 INTREN(IRQ_SLAVE);
138 #endif /* APIC_IO */
139
140 /* nexus0 is the top of the i386 device tree */
141 device_add_child(root_bus, "nexus", 0);
142
143 /* initialize new bus architecture */
144 root_bus_configure();
145
146 #ifdef DEV_ISA
147 /*
148 * Explicitly probe and attach ISA last. The isa bus saves
149 * it's device node at attach time for us here.
150 */
151 if (isa_bus_device)
152 isa_probe_children(isa_bus_device);
153 #endif
154
155 /*
156 * Now we're ready to handle (pending) interrupts.
157 * XXX this is slightly misplaced.
158 */
159 spl0();
160 }
161
162 static void
163 configure_final(dummy)
164 void *dummy;
165 {
166 int i;
167
168 cninit_finish();
169
170 if (bootverbose) {
171
172 #ifdef APIC_IO
173 imen_dump();
174 #endif /* APIC_IO */
175
176 /*
177 * Print out the BIOS's idea of the disk geometries.
178 */
179 printf("BIOS Geometries:\n");
180 for (i = 0; i < N_BIOS_GEOM; i++) {
181 unsigned long bios_geom;
182 int max_cylinder, max_head, max_sector;
183
184 bios_geom = bootinfo.bi_bios_geom[i];
185
186 /*
187 * XXX the bootstrap punts a 1200K floppy geometry
188 * when the get-disk-geometry interrupt fails. Skip
189 * drives that have this geometry.
190 */
191 if (bios_geom == 0x4f010f)
192 continue;
193
194 printf(" %x:%08lx ", i, bios_geom);
195 max_cylinder = bios_geom >> 16;
196 max_head = (bios_geom >> 8) & 0xff;
197 max_sector = bios_geom & 0xff;
198 printf(
199 "0..%d=%d cylinders, 0..%d=%d heads, 1..%d=%d sectors\n",
200 max_cylinder, max_cylinder + 1,
201 max_head, max_head + 1,
202 max_sector, max_sector);
203 }
204 printf(" %d accounted for\n", bootinfo.bi_n_bios_used);
205
206 printf("Device configuration finished.\n");
207 }
208 cold = 0;
209 }
210
211 /*
212 * Do legacy root filesystem discovery.
213 */
214 void
215 cpu_rootconf()
216 {
217 #ifdef BOOTP
218 bootpc_init();
219 #endif
220 #if defined(NFSCLIENT) && defined(NFS_ROOT)
221 #if !defined(BOOTP_NFSROOT)
222 nfs_setup_diskless();
223 if (nfs_diskless_valid)
224 #endif
225 rootdevnames[0] = "nfs:";
226 #endif
227 }
228 SYSINIT(cpu_rootconf, SI_SUB_ROOT_CONF, SI_ORDER_FIRST, cpu_rootconf, NULL)
Cache object: eb8659c476dae7a72a939a27eafbcad1
|