summaryrefslogtreecommitdiffstats
path: root/sys/alpha
diff options
context:
space:
mode:
authordfr <dfr@FreeBSD.org>1998-09-26 12:22:53 +0000
committerdfr <dfr@FreeBSD.org>1998-09-26 12:22:53 +0000
commit968dcc7cb58ee3c99fbd00e5fd281241ee1fc152 (patch)
treed373abd7e8b5dcb53333094bb1ce696961e13dc8 /sys/alpha
parent6e6c3928674b9454652dc0eb2c23f9c038c9a7cc (diff)
downloadFreeBSD-src-968dcc7cb58ee3c99fbd00e5fd281241ee1fc152.zip
FreeBSD-src-968dcc7cb58ee3c99fbd00e5fd281241ee1fc152.tar.gz
Automatically detect which disk was booted and change the root to that disk.
Diffstat (limited to 'sys/alpha')
-rw-r--r--sys/alpha/alpha/autoconf.c128
-rw-r--r--sys/alpha/include/md_var.h4
2 files changed, 125 insertions, 7 deletions
diff --git a/sys/alpha/alpha/autoconf.c b/sys/alpha/alpha/autoconf.c
index 9a76894..3a6621d 100644
--- a/sys/alpha/alpha/autoconf.c
+++ b/sys/alpha/alpha/autoconf.c
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: autoconf.c,v 1.7 1998/08/20 08:27:10 dfr Exp $
+ * $Id: autoconf.c,v 1.8 1998/09/16 08:19:29 dfr Exp $
*/
#include <sys/param.h>
@@ -36,12 +36,21 @@
#include <sys/mount.h>
#include <sys/sysctl.h>
#include <sys/bus.h>
+#include <sys/devicestat.h>
#include <machine/cons.h>
#include <machine/ipl.h>
#include <machine/md_var.h>
#include <machine/cpuconf.h>
#include <machine/rpb.h>
+#include <machine/bootinfo.h>
+
+#include <cam/cam.h>
+#include <cam/cam_ccb.h>
+#include <cam/cam_sim.h>
+#include <cam/cam_periph.h>
+#include <cam/cam_xpt_sim.h>
+#include <cam/cam_debug.h>
#include "scbus.h"
@@ -50,7 +59,8 @@ SYSINIT(configure, SI_SUB_CONFIGURE, SI_ORDER_FIRST, configure, NULL)
static void configure_finish __P((void));
static void configure_start __P((void));
-device_t isa_bus_device = 0;
+device_t isa_bus_device = 0;
+struct cam_sim *boot_sim = 0;
extern void xpt_init __P((void));
@@ -69,6 +79,98 @@ configure_finish()
extern void pci_configure(void);
+static int
+atoi(const char *s)
+{
+ int n = 0;
+ while (*s >= '0' && *s <= '9')
+ n = n * 10 + (*s++ - '0');
+ return n;
+}
+
+static const char *
+bootdev_field(int which)
+{
+ char *p = bootinfo.booted_dev;
+ char *q;
+ static char field[128];
+
+ /* Skip characters to find the right field */
+ for (; which; which--) {
+ while (*p != ' ' && *p != '\0')
+ p++;
+ if (*p)
+ p++;
+ }
+
+ /* Copy out the field and return it */
+ q = field;
+ while (*p != ' ' && *p != '\0')
+ *q++ = *p++;
+ *q = '\0';
+
+ return field;
+}
+
+static const char *
+bootdev_protocol(void)
+{
+ return bootdev_field(0);
+}
+
+static int
+bootdev_bus(void)
+{
+ return atoi(bootdev_field(1));
+}
+
+static int
+bootdev_slot(void)
+{
+ return atoi(bootdev_field(2));
+}
+
+static int
+bootdev_channel(void)
+{
+ return atoi(bootdev_field(3));
+}
+
+static const char *
+bootdev_remote_address(void)
+{
+ return bootdev_field(4);
+}
+
+static int
+bootdev_unit(void)
+{
+ return atoi(bootdev_field(5));
+}
+
+static int
+bootdev_boot_dev_type(void)
+{
+ return atoi(bootdev_field(6));
+}
+
+static const char *
+bootdev_ctrl_dev_type(void)
+{
+ return bootdev_field(7);
+}
+
+void
+alpha_register_pci_scsi(int bus, int slot, struct cam_sim *sim)
+{
+ if (!strcmp(bootdev_protocol(), "SCSI")) {
+ int boot_slot = bootdev_slot();
+ if (bus == boot_slot / 1000
+ && slot == boot_slot % 1000)
+ boot_sim = sim;
+ }
+}
+
/*
* Determine i/o configuration for a machine.
*/
@@ -107,14 +209,28 @@ void
cpu_rootconf()
{
static char rootname[] = "da0a";
+
mountrootfsname = "ufs";
+ if (boot_sim) {
+ struct cam_path *path;
+ struct cam_periph *periph;
+
+ xpt_create_path(&path, NULL,
+ cam_sim_path(boot_sim),
+ bootdev_unit() / 100, 0);
+ periph = cam_periph_find(path, "da");
+
+ if (periph)
+ rootdev = makedev(4, dkmakeminor(periph->unit_number,
+ COMPATIBILITY_SLICE, 0));
+
+ xpt_free_path(path);
+ }
+
rootdevs[0] = rootdev;
- rootname[2] += dkunit(rootdev);
+ rootname[2] += dkunit(minor(rootdev));
rootdevnames[0] = rootname;
-
- rootdevs[1] = makedev(4, dkmakeminor(0, COMPATIBILITY_SLICE, 0));
- rootdevnames[1] = "da0a";
}
void
diff --git a/sys/alpha/include/md_var.h b/sys/alpha/include/md_var.h
index cd2e667..b3925f7 100644
--- a/sys/alpha/include/md_var.h
+++ b/sys/alpha/include/md_var.h
@@ -23,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: md_var.h,v 1.2 1998/07/12 16:32:09 dfr Exp $
+ * $Id: md_var.h,v 1.3 1998/09/14 22:43:24 jdp Exp $
*/
#ifndef _MACHINE_MD_VAR_H_
@@ -42,6 +42,7 @@ extern void (*netisrs[32]) __P((void));
struct fpreg;
struct proc;
struct reg;
+struct cam_sim;
void cpu_power_down __P((void));
void cpu_halt __P((void));
@@ -53,5 +54,6 @@ int fill_regs __P((struct proc *, struct reg *));
int set_regs __P((struct proc *, struct reg *));
int fill_fpregs __P((struct proc *, struct fpreg *));
int set_fpregs __P((struct proc *, struct fpreg *));
+void alpha_register_pci_scsi __P((int bus, int slot, struct cam_sim *sim));
#endif /* !_MACHINE_MD_VAR_H_ */
OpenPOWER on IntegriCloud