summaryrefslogtreecommitdiff
path: root/sys/arch/loongson
diff options
context:
space:
mode:
authorOtto Moerbeek <otto@cvs.openbsd.org>2010-02-04 16:41:17 +0000
committerOtto Moerbeek <otto@cvs.openbsd.org>2010-02-04 16:41:17 +0000
commit27feb5e6232be663429eb3cfae5c0a4a695f3c00 (patch)
tree4687b35785ff2ccce8b38c405e7de27779f71713 /sys/arch/loongson
parent24089afb2ba9f594a13b76c8312582aa7baffea5 (diff)
basic bootpath -> bootdev translation; ok miod@
Diffstat (limited to 'sys/arch/loongson')
-rw-r--r--sys/arch/loongson/loongson/autoconf.c72
-rw-r--r--sys/arch/loongson/loongson/machdep.c8
2 files changed, 77 insertions, 3 deletions
diff --git a/sys/arch/loongson/loongson/autoconf.c b/sys/arch/loongson/loongson/autoconf.c
index a8eba2f81e9..76f6671bf8a 100644
--- a/sys/arch/loongson/loongson/autoconf.c
+++ b/sys/arch/loongson/loongson/autoconf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: autoconf.c,v 1.1 2009/11/24 11:28:11 miod Exp $ */
+/* $OpenBSD: autoconf.c,v 1.2 2010/02/04 16:41:16 otto Exp $ */
/*
* Copyright (c) 2009 Miodrag Vallat.
*
@@ -22,9 +22,14 @@
#include <sys/reboot.h>
extern void dumpconf(void);
+void parsepmonbp(void);
int cold = 1;
struct device *bootdv = NULL;
+char bootdev[16];
+enum devclass bootdev_class = DV_DULL;
+
+extern char pmon_bootp[];
void
cpu_configure(void)
@@ -39,8 +44,38 @@ cpu_configure(void)
}
void
+parsepmonbp(void)
+{
+ char *p, *q;
+ size_t len;
+
+ if (strncmp(pmon_bootp, "tftp://", 7) == 0) {
+ bootdev_class = DV_IFNET;
+ strlcpy(bootdev, "netboot", sizeof bootdev);
+ return;
+ }
+ strlcpy(bootdev, "unknown", sizeof bootdev);
+
+ p = strchr(pmon_bootp, '@');
+ if (p == NULL)
+ return;
+ p++;
+ q = strchr(p, '/');
+ if (q == NULL)
+ return;
+ len = q - p;
+ if (len <= 2 || len >= sizeof bootdev - 1)
+ return;
+ memcpy(bootdev, p, len);
+ bootdev[len] = '\0';
+ bootdev_class = DV_DISK;
+}
+
+void
diskconf(void)
{
+ printf("pmon bootpath: %s\n", pmon_bootp);
+
if (bootdv != NULL)
printf("boot device: %s\n", bootdv->dv_xname);
@@ -51,10 +86,43 @@ diskconf(void)
void
device_register(struct device *dev, void *aux)
{
+ const char *drvrname = dev->dv_cfdata->cf_driver->cd_name;
+ const char *name = dev->dv_xname;
+
if (bootdv != NULL)
return;
- /* ... */
+ if (dev->dv_class != bootdev_class)
+ return;
+ /*
+ * The device numbering must match. There's no way
+ * pmon tells us more info. Depending on the usb slot
+ * and hubs used you may be lucky. Also, assume umass/sd for usb
+ * attached devices.
+ */
+ switch (bootdev_class) {
+ case DV_DISK:
+ if (strcmp(drvrname, "wd") == 0 && strcmp(name, bootdev) == 0)
+ bootdv = dev;
+ else {
+ /* XXX this really only works safely for usb0... */
+ if ((strcmp(drvrname, "sd") == 0 ||
+ strcmp(drvrname, "cd") == 0) &&
+ strncmp(bootdev, "usb", 3) == 0 &&
+ strcmp(name + 2, bootdev + 3) == 0)
+ bootdv = dev;
+ }
+ break;
+ case DV_IFNET:
+ /*
+ * This relies on the onboard Ethernet interface being
+ * attached before any other (usb) interface.
+ */
+ bootdv = dev;
+ break;
+ default:
+ break;
+ }
}
struct nam2blk nam2blk[] = {
diff --git a/sys/arch/loongson/loongson/machdep.c b/sys/arch/loongson/loongson/machdep.c
index 087b2c39bbf..8658e3f4d09 100644
--- a/sys/arch/loongson/loongson/machdep.c
+++ b/sys/arch/loongson/loongson/machdep.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: machdep.c,v 1.7 2010/02/03 21:46:42 miod Exp $ */
+/* $OpenBSD: machdep.c,v 1.8 2010/02/04 16:41:16 otto Exp $ */
/*
* Copyright (c) 2009 Miodrag Vallat.
@@ -82,6 +82,7 @@
/* The following is used externally (sysctl_hw) */
char machine[] = MACHINE; /* Machine "architecture" */
char cpu_model[30];
+char pmon_bootp[80];
/*
* Declare these as initialized data so we can patch them.
@@ -122,6 +123,7 @@ static void dobootopts(int);
void build_trampoline(vaddr_t, vaddr_t);
void dumpsys(void);
void dumpconf(void);
+extern void parsepmonbp(void);
vaddr_t mips_init(int32_t, int32_t, int32_t, int32_t);
extern void loongson2e_setup(u_long, u_long);
@@ -567,6 +569,10 @@ dobootopts(int argc)
if (*arg != '-') {
/* found filename or non-option argument */
+ if (*pmon_bootp == '\0') {
+ strlcpy(pmon_bootp, arg, sizeof pmon_bootp);
+ parsepmonbp();
+ }
ignore = 0;
continue;
}