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.10 1998/09/26 14:48:19 dfr Exp $
29 #include "opt_bootp.h"
31 #include "opt_cd9660.h"
33 #include "opt_nfsroot.h"
35 #include <sys/param.h>
36 #include <sys/systm.h>
38 #include <sys/disklabel.h>
39 #include <sys/diskslice.h> /* for BASE_SLICE, MAX_SLICES */
40 #include <sys/reboot.h>
41 #include <sys/kernel.h>
42 #include <sys/mount.h>
43 #include <sys/sysctl.h>
45 #include <sys/devicestat.h>
47 #include <machine/cons.h>
48 #include <machine/ipl.h>
49 #include <machine/md_var.h>
50 #include <machine/cpuconf.h>
51 #include <machine/rpb.h>
52 #include <machine/bootinfo.h>
55 #include <cam/cam_ccb.h>
56 #include <cam/cam_sim.h>
57 #include <cam/cam_periph.h>
58 #include <cam/cam_xpt_sim.h>
59 #include <cam/cam_debug.h>
63 static void configure __P((void *));
64 SYSINIT(configure, SI_SUB_CONFIGURE, SI_ORDER_FIRST, configure, NULL)
66 static void configure_finish __P((void));
67 static void configure_start __P((void));
68 device_t isa_bus_device = 0;
69 struct cam_sim *boot_sim = 0;
71 extern void xpt_init __P((void));
86 extern void pci_configure(void);
92 while (*s >= '0' && *s <= '9')
93 n = n * 10 + (*s++ - '0');
98 bootdev_field(int which)
100 char *p = bootinfo.booted_dev;
102 static char field[128];
104 /* Skip characters to find the right field */
105 for (; which; which--) {
106 while (*p != ' ' && *p != '\0')
112 /* Copy out the field and return it */
114 while (*p != ' ' && *p != '\0')
122 bootdev_protocol(void)
124 return bootdev_field(0);
130 return atoi(bootdev_field(1));
136 return atoi(bootdev_field(2));
140 bootdev_channel(void)
142 return atoi(bootdev_field(3));
146 bootdev_remote_address(void)
148 return bootdev_field(4);
154 return atoi(bootdev_field(5));
158 bootdev_boot_dev_type(void)
160 return atoi(bootdev_field(6));
164 bootdev_ctrl_dev_type(void)
166 return bootdev_field(7);
170 alpha_register_pci_scsi(int bus, int slot, struct cam_sim *sim)
172 if (!strcmp(bootdev_protocol(), "SCSI")) {
173 int boot_slot = bootdev_slot();
174 if (bus == 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)){
197 * Probe ISA devices after everything.
200 bus_generic_attach(isa_bus_device);
207 * Now we're ready to handle (pending) interrupts.
208 * XXX this is slightly misplaced.
219 if (!mountrootfsname) {
221 printf("Considering MFS root f/s.\n");
222 mountrootfsname = "mfs";
226 #if defined(FFS) || defined(FFS_ROOT)
227 if (!mountrootfsname) {
228 static char rootname[] = "da0a";
231 printf("Considering UFS root f/s.\n");
232 mountrootfsname = "ufs";
235 struct cam_path *path;
236 struct cam_periph *periph;
238 xpt_create_path(&path, NULL,
239 cam_sim_path(boot_sim),
240 bootdev_unit() / 100, 0);
241 periph = cam_periph_find(path, "da");
244 rootdev = makedev(4, dkmakeminor(periph->unit_number,
245 COMPATIBILITY_SLICE, 0));
250 rootdevs[0] = rootdev;
251 rootname[2] += dkunit(minor(rootdev));
252 rootdevnames[0] = rootname;