2 * Copyright (c) 1998 Doug Rabson
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26 * $Id: autoconf.c,v 1.29 1999/07/17 20:47:40 phk Exp $
29 #include "opt_bootp.h"
31 #include "opt_cd9660.h"
32 #include "opt_nfsroot.h"
34 #include <sys/param.h>
35 #include <sys/systm.h>
37 #include <sys/disklabel.h>
38 #include <sys/diskslice.h> /* for BASE_SLICE, MAX_SLICES */
39 #include <sys/reboot.h>
40 #include <sys/kernel.h>
41 #include <sys/mount.h>
42 #include <sys/sysctl.h>
44 #include <sys/devicestat.h>
46 #include <machine/cons.h>
47 #include <machine/ipl.h>
48 #include <machine/md_var.h>
49 #include <machine/cpuconf.h>
50 #include <machine/rpb.h>
51 #include <machine/bootinfo.h>
54 #include <cam/cam_ccb.h>
55 #include <cam/cam_sim.h>
56 #include <cam/cam_periph.h>
57 #include <cam/cam_xpt_sim.h>
58 #include <cam/cam_debug.h>
60 static void configure __P((void *));
61 SYSINIT(configure, SI_SUB_CONFIGURE, SI_ORDER_THIRD, configure, NULL)
63 static void configure_finish __P((void));
64 static void configure_start __P((void));
66 device_t isa_bus_device = 0;
67 struct cam_sim *boot_sim = 0;
68 extern int nfs_diskless_valid;
70 dev_t rootdev = NODEV;
71 dev_t dumpdev = NODEV;
87 while (*s >= '0' && *s <= '9')
88 n = n * 10 + (*s++ - '0');
93 bootdev_field(int which)
95 char *p = bootinfo.booted_dev;
97 static char field[128];
99 /* Skip characters to find the right field */
100 for (; which; which--) {
101 while (*p != ' ' && *p != '\0')
107 /* Copy out the field and return it */
109 while (*p != ' ' && *p != '\0')
117 bootdev_protocol(void)
119 return bootdev_field(0);
125 return atoi(bootdev_field(2));
131 return atoi(bootdev_field(5));
139 return atoi(bootdev_field(1));
143 bootdev_channel(void)
145 return atoi(bootdev_field(3));
149 bootdev_remote_address(void)
151 return bootdev_field(4);
155 bootdev_boot_dev_type(void)
157 return atoi(bootdev_field(6));
161 bootdev_ctrl_dev_type(void)
163 return bootdev_field(7);
169 alpha_register_pci_scsi(int bus, int slot, struct cam_sim *sim)
171 if (!strcmp(bootdev_protocol(), "SCSI")) {
172 int boot_slot = bootdev_slot();
173 if (((bus == boot_slot / 1000 )
174 || (bus == 1 && (boot_slot < 1000)))
175 && slot == boot_slot % 1000)
181 * Determine i/o configuration for a machine.
184 configure(void *dummy)
188 device_add_child(root_bus, platform.iobus, 0, 0);
190 root_bus_configure();
192 if((hwrpb->rpb_type != ST_DEC_3000_300) &&
193 (hwrpb->rpb_type != ST_DEC_3000_500)){
195 * Probe ISA devices after everything.
198 bus_generic_attach(isa_bus_device);
205 * Now we're ready to handle (pending) interrupts.
206 * XXX this is slightly misplaced.
217 if (!strcmp(bootdev_protocol(), "BOOTP")
218 && !mountrootfsname && !nfs_diskless_valid) {
220 printf("Considering BOOTP NFS root f/s.\n");
221 mountrootfsname = "nfs";
223 #endif /* BOOTP_NFSROOT */
224 #if defined(NFS) || defined(NFS_ROOT)
225 if (!mountrootfsname && nfs_diskless_valid) {
227 printf("Considering NFS root f/s.\n");
228 mountrootfsname = "nfs";
233 #if defined(FFS) || defined(FFS_ROOT)
234 if (!mountrootfsname) {
235 static char rootname[] = "da0a";
238 printf("Considering UFS root f/s.\n");
239 mountrootfsname = "ufs";
242 struct cam_path *path;
243 struct cam_periph *periph;
245 xpt_create_path(&path, NULL,
246 cam_sim_path(boot_sim),
247 bootdev_unit() / 100, 0);
248 periph = cam_periph_find(path, "da");
252 (4, dkmakeminor(periph->unit_number,
253 COMPATIBILITY_SLICE, 0));
258 rootdevs[0] = rootdev;
259 rootname[2] += dkunit(rootdev);
260 rootdevnames[0] = rootname;