From eb30845ea7279d4233bbfac706c56dcf037c0ee3 Mon Sep 17 00:00:00 2001 From: Miod Vallat Date: Tue, 16 Feb 2010 21:28:40 +0000 Subject: Actually, both the Gdium and the Lemote PMON reset the USB controllers before transferring control to any binary, so trying to boot anything on the Gdium without bringing half the kernel code is a no-go. So, only keep `wd' as a possible boot device, for the Lemote systems, and complain loudly if run on a Gdium. --- sys/arch/loongson/stand/boot/conf.c | 5 ++-- sys/arch/loongson/stand/boot/cons.c | 11 +------- sys/arch/loongson/stand/boot/dev.c | 3 ++- sys/arch/loongson/stand/boot/libsa.h | 8 +----- sys/arch/loongson/stand/boot/machdep.c | 48 +++++++++++++++++++--------------- 5 files changed, 33 insertions(+), 42 deletions(-) (limited to 'sys/arch/loongson/stand') diff --git a/sys/arch/loongson/stand/boot/conf.c b/sys/arch/loongson/stand/boot/conf.c index 4f365911838..2562b38c4ec 100644 --- a/sys/arch/loongson/stand/boot/conf.c +++ b/sys/arch/loongson/stand/boot/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.1 2010/02/14 22:39:33 miod Exp $ */ +/* $OpenBSD: conf.c,v 1.2 2010/02/16 21:28:39 miod Exp $ */ /* * Copyright (c) 1982, 1986, 1990, 1993 @@ -48,8 +48,7 @@ int debug = 0; * Device configuration */ struct devsw devsw[] = { - { "wd", pmon_iostrategy, pmon_ioopen, pmon_ioclose, noioctl }, - { "usbg", pmon_iostrategy, pmon_ioopen, pmon_ioclose, noioctl } + { "wd", pmon_iostrategy, pmon_ioopen, pmon_ioclose, noioctl } }; int ndevs = NENTS(devsw); diff --git a/sys/arch/loongson/stand/boot/cons.c b/sys/arch/loongson/stand/boot/cons.c index fe6dc685d63..714d8050482 100644 --- a/sys/arch/loongson/stand/boot/cons.c +++ b/sys/arch/loongson/stand/boot/cons.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cons.c,v 1.1 2010/02/14 22:39:33 miod Exp $ */ +/* $OpenBSD: cons.c,v 1.2 2010/02/16 21:28:39 miod Exp $ */ /* * Copyright (c) 2010 Miodrag Vallat. @@ -51,17 +51,8 @@ pmon_cngetc(dev_t dev) */ static char buf[1 + PMON_MAXLN]; static char *bufpos = buf; - int c; - /* - * Neither pmon_gets() nor pmon_read() from stdin seem to work - * on the Gdium... - */ - if (pmon_quirks & PQ_GDIUM) { - for (;;) ; - } - if (*bufpos == '\0') { bufpos = buf; if (pmon_gets(buf) == NULL) { diff --git a/sys/arch/loongson/stand/boot/dev.c b/sys/arch/loongson/stand/boot/dev.c index ed8f8c070c4..c60791c8326 100644 --- a/sys/arch/loongson/stand/boot/dev.c +++ b/sys/arch/loongson/stand/boot/dev.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dev.c,v 1.1 2010/02/14 22:39:33 miod Exp $ */ +/* $OpenBSD: dev.c,v 1.2 2010/02/16 21:28:39 miod Exp $ */ /* * Copyright (c) 2010 Miodrag Vallat. @@ -74,6 +74,7 @@ pmon_iostrategy(void *f, int rw, daddr_t dblk, size_t size, void *buf, off_t offs, pos; int rc; + *rsize = 0; if (size == 0) return 0; diff --git a/sys/arch/loongson/stand/boot/libsa.h b/sys/arch/loongson/stand/boot/libsa.h index 55b3b223a92..f0f87ac873d 100644 --- a/sys/arch/loongson/stand/boot/libsa.h +++ b/sys/arch/loongson/stand/boot/libsa.h @@ -1,4 +1,4 @@ -/* $OpenBSD: libsa.h,v 1.1 2010/02/14 22:39:33 miod Exp $ */ +/* $OpenBSD: libsa.h,v 1.2 2010/02/16 21:28:39 miod Exp $ */ /* * Copyright (c) 2010 Miodrag Vallat. @@ -47,10 +47,4 @@ extern int32_t *pmon_argv; extern int32_t *pmon_envp; extern int32_t pmon_callvec; -/* - * Mask of PMON workarounds required due to castration by the vendor. - */ -#define PQ_GDIUM 0x00000001 -extern int pmon_quirks; - extern char pmon_bootdev[]; diff --git a/sys/arch/loongson/stand/boot/machdep.c b/sys/arch/loongson/stand/boot/machdep.c index 9aea20bd3f4..46f529be831 100644 --- a/sys/arch/loongson/stand/boot/machdep.c +++ b/sys/arch/loongson/stand/boot/machdep.c @@ -1,4 +1,4 @@ -/* $OpenBSD: machdep.c,v 1.1 2010/02/14 22:39:33 miod Exp $ */ +/* $OpenBSD: machdep.c,v 1.2 2010/02/16 21:28:39 miod Exp $ */ /* * Copyright (c) 2010 Miodrag Vallat. @@ -48,8 +48,6 @@ #include #include -int pmon_quirks = 0; - /* * Console */ @@ -131,7 +129,7 @@ void devboot(dev_t dev, char *path) { const char *bootpath = NULL; - size_t bootpathlen; + size_t bootpathlen = 0; /* gcc -Wall */ const char *tmp; int i; @@ -140,15 +138,16 @@ devboot(dev_t dev, char *path) * the default device to load the kernel from is the same. * * We may have been loaded in three different ways: - * - automatic load from `al' environment variable. + * - automatic load from `al' environment variable (similar to a + * `load' and `go' sequence). * - manual `boot' command, with path on the commandline. * - manual `load' and `go' commands, with no path on the commandline. */ if (pmon_argc > 0) { - /* manual load */ tmp = (const char *)pmon_getarg(0); if (tmp[0] != 'g') { + /* manual load */ for (i = 1; i < pmon_argc; i++) { tmp = (const char *)pmon_getarg(i); if (tmp[0] != '-') { @@ -156,10 +155,10 @@ devboot(dev_t dev, char *path) break; } } + } else { + /* possible automatic load */ + bootpath = pmon_getenv("al"); } - } else { - /* automatic load */ - bootpath = pmon_getenv("al"); } /* @@ -189,19 +188,18 @@ devboot(dev_t dev, char *path) } } - if (bootpath != NULL) { + if (bootpath != NULL && bootpathlen >= 3) { if (bootpathlen >= BOOTDEVLEN) bootpathlen = BOOTDEVLEN - 1; strncpy(path, bootpath, bootpathlen); path[bootpathlen] = '\0'; + /* only add a partition letter if there is none */ + if (bootpath[bootpathlen - 1] >= '0' && + bootpath[bootpathlen - 1] <= '9') + strlcat(path, "a", BOOTDEVLEN); } else { - tmp = pmon_getenv("Version"); - if (tmp != NULL && strncmp(tmp, "Gdium", 5) == 0) - strlcpy(path, "usbg0", BOOTDEVLEN); - else - strlcpy(path, "wd0", BOOTDEVLEN); + strlcpy(path, "wd0a", BOOTDEVLEN); } - strlcat(path, "a", BOOTDEVLEN); } /* @@ -223,15 +221,23 @@ machdep() { const char *envvar; + cninit(); + /* * Figure out whether we are running on a Gdium system, which - * has an horribly castrated PMON. + * has an horribly castrated PMON. If we do, return immediately. */ envvar = pmon_getenv("Version"); - if (envvar != NULL && strncmp(envvar, "Gdium", 5) == 0) - pmon_quirks |= PQ_GDIUM; - - cninit(); + if (envvar != NULL && strncmp(envvar, "Gdium", 5) == 0) { + /* Here's a nickel, kid. Get yourself a better firmware */ + printf("\n\nSorry, OpenBSD boot blocks do not work on Gdium, " + "because of dire firmware limitations.\n" + "Also, the firmware has reset the USB controller so you " + "will need to power cycle.\n" + "We would apologize for this incovenience, but we have " + "no control about the firmware of your machine.\n\n"); + _rtt(); + } /* * Since we can't have non-blocking input, we will try to -- cgit v1.2.3