diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2009-05-30 03:59:28 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2009-05-30 03:59:28 +0000 |
commit | 3bccf2afe27cd1f05408d98b05e842f4a918eaf6 (patch) | |
tree | 60f78ef5f841110982786de496d37fae00f36d5c | |
parent | 66bcdc88972ebb369e24361435f4e8816de95a2f (diff) |
When booting in `install software' mode from the SGI boot menu, do not try to
load bsd.rd but bsd.rd.IP## matching the IP code of the machine.
-rw-r--r-- | sys/arch/sgi/stand/boot/arcbios.c | 72 | ||||
-rw-r--r-- | sys/arch/sgi/stand/boot/boot.c | 43 | ||||
-rw-r--r-- | sys/arch/sgi/stand/boot/strstr.c | 5 |
3 files changed, 96 insertions, 24 deletions
diff --git a/sys/arch/sgi/stand/boot/arcbios.c b/sys/arch/sgi/stand/boot/arcbios.c index f828bf109ef..02a4139f624 100644 --- a/sys/arch/sgi/stand/boot/arcbios.c +++ b/sys/arch/sgi/stand/boot/arcbios.c @@ -1,4 +1,4 @@ -/* $OpenBSD: arcbios.c,v 1.9 2009/05/14 18:57:43 miod Exp $ */ +/* $OpenBSD: arcbios.c,v 1.10 2009/05/30 03:59:27 miod Exp $ */ /*- * Copyright (c) 1996 M. Warner Losh. All rights reserved. * Copyright (c) 1996-2004 Opsycon AB. All rights reserved. @@ -27,17 +27,30 @@ #include <sys/param.h> #include <lib/libkern/libkern.h> -#include <machine/autoconf.h> + #include <mips64/arcbios.h> #include <mips64/archtype.h> +#include <machine/autoconf.h> +#include <machine/mnode.h> + #include <stand.h> static int bios_is_32bit; -void arcbios_init(void); +int arcbios_init(void); const char *boot_get_path_component(const char *, char *, int *); const char *boot_getnr(const char *, int *); +static const struct systypes { + char *sys_name; + int sys_ip; +} sys_types[] = { + { "SGI-IP30", 30 }, + { "SGI-IP32", 32 } +}; + +#define KNOWNSYSTEMS (nitems(sys_types)) + /* * ARCBios trampoline code. */ @@ -138,9 +151,15 @@ putchar(int c) /* * Identify ARCBios type. */ -void +int arcbios_init() { + arc_config_t *cf; + arc_sid_t *sid; + char *sysid = NULL; + int sysid_len; + int i; + /* * Figure out if this is an ARCBios machine and if it is, see if we're * dealing with a 32 or 64 bit version. @@ -152,6 +171,51 @@ arcbios_init() (ArcBiosBase64->magic == ARC_PARAM_BLK_MAGIC_BUG)) { bios_is_32bit = 0; } + + /* + * Minimal system identification. + */ + sid = (arc_sid_t *)Bios_GetSystemId(); + cf = (arc_config_t *)Bios_GetChild(NULL); + if (cf != NULL) { + if (bios_is_32bit) { + sysid = (char *)(long)cf->id; + sysid_len = cf->id_len; + } else { + sysid = (char *)((arc_config64_t *)cf)->id; + sysid_len = ((arc_config64_t *)cf)->id_len; + } + + if (sysid_len > 0 && sysid != NULL) { + sysid_len--; + for (i = 0; i < KNOWNSYSTEMS; i++) { + if (strlen(sys_types[i].sys_name) != sysid_len) + continue; + if (strncmp(sys_types[i].sys_name, sysid, + sysid_len) != 0) + continue; + return sys_types[i].sys_ip; /* Found it. */ + } + } + } else { +#ifdef __LP64__ + if (IP27_KLD_KLCONFIG(0)->magic == IP27_KLDIR_MAGIC) { + /* + * If we find a kldir assume IP27. Boot blocks + * do not need to tell IP27 and IP35 apart. + */ + return 27; + } +#endif + } + + printf("UNRECOGNIZED SYSTEM '%s' VENDOR '%8.8s' PRODUCT '%8.8s'\n", + cf == NULL || sysid == NULL ? "(null)" : sysid, + sid->vendor, sid->prodid); + printf("Halting system!\n"); + Bios_Halt(); + printf("Halting failed, use manual reset!\n"); + for (;;) ; } /* diff --git a/sys/arch/sgi/stand/boot/boot.c b/sys/arch/sgi/stand/boot/boot.c index f966ec4c0e3..25b559c9f00 100644 --- a/sys/arch/sgi/stand/boot/boot.c +++ b/sys/arch/sgi/stand/boot/boot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: boot.c,v 1.12 2009/05/14 18:57:43 miod Exp $ */ +/* $OpenBSD: boot.c,v 1.13 2009/05/30 03:59:27 miod Exp $ */ /* * Copyright (c) 2004 Opsycon AB, www.opsycon.se. @@ -28,6 +28,7 @@ #include <sys/param.h> #include <sys/stat.h> +#include <lib/libkern/libkern.h> #include <stand.h> #include <mips64/arcbios.h> @@ -35,6 +36,8 @@ #include "loadfile.h" +char *strstr(char *, const char *); /* strstr.c */ + int main(int, char **); void dobootopts(int, char **); @@ -48,6 +51,7 @@ enum { char *OSLoadPartition = NULL; char *OSLoadFilename = NULL; +int IP; /* * OpenBSD/sgi Boot Loader. @@ -59,25 +63,24 @@ main(int argc, char *argv[]) u_int64_t *esym; char line[1024]; u_long entry; - int fd, i; - extern void arcbios_init(void); + int fd; + extern int arcbios_init(void); + + IP = arcbios_init(); - arcbios_init(); + printf("\nOpenBSD/sgi-IP%d ARCBios boot\n", IP); dobootopts(argc, argv); if (OSLoadPartition != NULL) { strlcpy(line, OSLoadPartition, sizeof(line)); - i = strlen(line); if (OSLoadFilename != NULL) - strlcpy(&line[i], OSLoadFilename, sizeof(line) - i - 1); + strlcat(line, OSLoadFilename, sizeof(line)); } else - strlcpy("invalid argument setup", line, sizeof(line)); + strlcpy(line, "invalid argument setup", sizeof(line)); for (entry = 0; entry < argc; entry++) printf("arg %d: %s\n", entry, argv[entry]); - printf("\nOpenBSD/sgi ARCBios boot\n"); - printf("Boot: %s\n", line); /* @@ -109,6 +112,7 @@ __dead void _rtt() { Bios_EnterInteractiveMode(); + for (;;) ; } /* @@ -117,6 +121,7 @@ _rtt() void dobootopts(int argc, char **argv) { + static char filenamebuf[1 + 32]; char *SystemPartition = NULL; char *cp; int i; @@ -153,18 +158,20 @@ dobootopts(int argc, char **argv) strlcpy(loadpart, argv[0], sizeof loadpart); if ((p = strstr(loadpart, "partition(8)")) != NULL) { p += strlen("partition("); + } else if (strncmp(loadpart, "dksc(", 5) == 0) { + p = strstr(loadpart, ",8)"); + if (p != NULL) + p++; + } else + p = NULL; + + if (p != NULL) { p[0] = '0'; p[2] = '\0'; + snprintf(filenamebuf, sizeof filenamebuf, + "/bsd.rd.IP%d", IP); OSLoadPartition = loadpart; - OSLoadFilename = "/bsd.rd"; - } else if (strncmp(loadpart, "dksc(", 5) == 0) { - p = strstr(loadpart, ",8)"); - if (p != NULL) { - p[1] = '0'; - p[3] = '\0'; - OSLoadPartition = loadpart; - OSLoadFilename = "/bsd.rd"; - } + OSLoadFilename = filenamebuf; } } } diff --git a/sys/arch/sgi/stand/boot/strstr.c b/sys/arch/sgi/stand/boot/strstr.c index a920ce9d27e..95832a656b8 100644 --- a/sys/arch/sgi/stand/boot/strstr.c +++ b/sys/arch/sgi/stand/boot/strstr.c @@ -31,12 +31,13 @@ */ #include <sys/param.h> +#include <lib/libkern/libkern.h> /* * Find the first occurrence of find in s. */ char * -strstr(const char *s, const char *find) +strstr(char *s, const char *find) { char c, sc; size_t len; @@ -51,5 +52,5 @@ strstr(const char *s, const char *find) } while (strncmp(s, find, len) != 0); s--; } - return ((char *)s); + return s; } |