From e12d0ec43a42a081d0203ec8e6903460425ad844 Mon Sep 17 00:00:00 2001 From: Mike Smith Date: Sat, 26 Sep 1998 01:29:13 +0000 Subject: [PATCH] console.c Allow the MI code to override the preferred console (eg. so that an RB_SERIAL flag from the i386 boot2 can override the default first active console) isapnp.c Use the standard format for ISA PnP IDs. pnp.c Allow trailing comments on lines, be less picky about line contents. ls.c Cosmetic error message fix. panic.c Print the right arguments. --- sys/boot/common/console.c | 24 ++++++++++++++++++------ sys/boot/common/isapnp.c | 25 ++++++++++++++----------- sys/boot/common/ls.c | 8 +++++++- sys/boot/common/panic.c | 6 +++--- sys/boot/common/pnp.c | 13 +++++++++---- 5 files changed, 51 insertions(+), 25 deletions(-) diff --git a/sys/boot/common/console.c b/sys/boot/common/console.c index 5aed8b1fc63b..ffc41a9b8fc5 100644 --- a/sys/boot/common/console.c +++ b/sys/boot/common/console.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id$ + * $Id: console.c,v 1.1.1.1 1998/08/21 03:17:41 msmith Exp $ */ #include @@ -48,16 +48,28 @@ cons_probe(void) { int cons; int active; + char *prefconsole; - /* Do all console probes, make the fist fully functional console active */ + /* Do all console probes */ for (cons = 0, active = -1; consoles[cons] != NULL; cons++) { consoles[cons]->c_flags = 0; consoles[cons]->c_probe(consoles[cons]); - if ((consoles[cons]->c_flags == (C_PRESENTIN | C_PRESENTOUT)) && (active == -1)) { - consoles[cons]->c_flags |= (C_ACTIVEIN | C_ACTIVEOUT); - active = cons; - } + if ((consoles[cons]->c_flags == (C_PRESENTIN | C_PRESENTOUT)) && (active == -1)) + active = cons; /* first candidate */ } + + /* Check to see if a console preference has already been registered */ + prefconsole = strdup(getenv("console")); + if (prefconsole != NULL) { + unsetenv("console"); /* we want to replace this */ + for (cons = 0; consoles[cons] != NULL; cons++) + /* look for the nominated console, use it if it's functional */ + if (!strcmp(prefconsole, consoles[cons]->c_name) && + (consoles[cons]->c_flags == (C_PRESENTIN | C_PRESENTOUT))) + active = cons; + free(prefconsole); + } + consoles[active]->c_flags |= (C_ACTIVEIN | C_ACTIVEOUT); printf("Console: %s\n", consoles[active]->c_desc); env_setenv("console", 0, consoles[active]->c_name, cons_set, env_nounset); } diff --git a/sys/boot/common/isapnp.c b/sys/boot/common/isapnp.c index 26782228499f..cc28da6c954f 100644 --- a/sys/boot/common/isapnp.c +++ b/sys/boot/common/isapnp.c @@ -24,7 +24,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: pnp.c,v 1.5 1998/02/09 06:08:38 eivind Exp $ + * $Id: isapnp.c,v 1.1 1998/09/18 00:24:25 msmith Exp $ */ /* @@ -126,20 +126,23 @@ isapnp_get_serial(u_int8_t *data) } /* - * Format a pnp id as a string in standard ISA PnP format, 0x + * Format a pnp id as a string in standard ISA PnP format, AAAIIRR + * where 'AAA' is the EISA ID, II is the product ID and RR the revision ID. */ static char * isapnp_format(u_int8_t *data) { - static char idbuf[16]; - u_int32_t i; - - i = data[3]; - i = (i << 8) + data[2]; - i = (i << 8) + data[1]; - i = (i << 8) + data[0]; - sprintf(idbuf, "0x%08x", i); - return(idbuf); + static char idbuf[8]; + const char hextoascii[] = "0123456789abcdef"; + + idbuf[0] = '@' + ((data[0] & 0x7c) >> 2); + idbuf[1] = '@' + (((data[0] & 0x3) << 3) + ((data[1] & 0xe0) >> 5)); + idbuf[2] = '@' + (data[1] & 0x1f); + idbuf[3] = hextoascii[(data[2] >> 4)]; + idbuf[4] = hextoascii[(data[2] & 0xf)]; + idbuf[5] = hextoascii[(data[3] >> 4)]; + idbuf[6] = hextoascii[(data[3] & 0xf)]; + idbuf[7] = 0; } /* diff --git a/sys/boot/common/ls.c b/sys/boot/common/ls.c index 962d4f740869..1596a3abce78 100644 --- a/sys/boot/common/ls.c +++ b/sys/boot/common/ls.c @@ -1,5 +1,5 @@ /* - * $Id: ls.c,v 1.1.1.1 1998/08/21 03:17:41 msmith Exp $ + * $Id: ls.c,v 1.2 1998/09/03 02:10:07 msmith Exp $ * From: $NetBSD: ls.c,v 1.3 1997/06/13 13:48:47 drochner Exp $ */ @@ -107,6 +107,12 @@ command_ls(int argc, char *argv[]) result = CMD_ERROR; goto out; } +#ifdef VERBOSE_LS + /* fixup path for stat()ing files */ + if (!strcmp(path, "/")) + path = ""; +#endif + while ((size = read(fd, dirbuf, DIRBLKSIZ)) == DIRBLKSIZ) { struct direct *dp, *edp; diff --git a/sys/boot/common/panic.c b/sys/boot/common/panic.c index b5315966003f..bee6a0327df4 100644 --- a/sys/boot/common/panic.c +++ b/sys/boot/common/panic.c @@ -1,5 +1,5 @@ /* - * $Id: panic.c,v 1.2 1998/09/17 23:52:02 msmith Exp $ + * $Id: panic.c,v 1.3 1998/09/18 02:01:38 msmith Exp $ * From: $NetBSD: panic.c,v 1.2 1997/03/22 01:48:36 thorpej Exp $ */ @@ -46,9 +46,9 @@ panic(const char *fmt,...) printf("panic: "); va_start(ap, fmt); - printf(fmt, ap); - printf("\n"); + vprintf(fmt, ap); va_end(ap); + printf("\n"); exit(1); } diff --git a/sys/boot/common/pnp.c b/sys/boot/common/pnp.c index 84f3825ad512..4a8ee48d5bd4 100644 --- a/sys/boot/common/pnp.c +++ b/sys/boot/common/pnp.c @@ -129,6 +129,9 @@ pnp_discard(struct pnpinfo **list) * and 'module' fields are required; the 'rev' field is currently * ignored (but should be used), and the 'args' field must come * last. + * + * Comments may be appended to lines; any character including or following + * '#' on a line is ignored. */ static int pnp_readconf(char *path) @@ -153,6 +156,10 @@ pnp_readconf(char *path) /* keep/discard? */ if ((*cp == 0) || (*cp == '#')) continue; + + /* cut trailing comment? */ + if ((ep = strchr(cp, '#')) != NULL) + *ep = 0; /* bus declaration? */ if (*cp == '[') { @@ -210,11 +217,9 @@ pnp_readconf(char *path) cp = ep; } - /* we must have at least ident and module set */ - if ((ident == NULL) || (module == NULL)) { - printf("%s line %d: bad mapping\n", path, line); + /* we must have at least ident and module set to be interesting */ + if ((ident == NULL) || (module == NULL)) continue; - } /* * Loop looking for module/bus that might match this, but aren't already