diff options
author | Miod Vallat <miod@cvs.openbsd.org> | 2010-04-18 15:09:03 +0000 |
---|---|---|
committer | Miod Vallat <miod@cvs.openbsd.org> | 2010-04-18 15:09:03 +0000 |
commit | 17e4ae72a78d51c260502f7562f5e3e51ea465c5 (patch) | |
tree | b94de261e57a7197514664971ce3a077371b26d3 | |
parent | 62f2a437013e836bee23ffbf58501094084626f3 (diff) |
Parse commandline options in netboot, and force the onboard ethernet address
to be 00:00:00:00:00:00 if `-z' is passed; this allows netboot to work on a
machine which has lost its nvram (despite the ethernet address not being
stored in nvram at all, stupid prom can't be bothered to get it right...).
Crank netboot version.
-rw-r--r-- | sys/arch/aviion/stand/libsa/libsa.h | 8 | ||||
-rw-r--r-- | sys/arch/aviion/stand/libsa/parse_args.c | 78 | ||||
-rw-r--r-- | sys/arch/aviion/stand/netboot/boot.c | 6 | ||||
-rw-r--r-- | sys/arch/aviion/stand/netboot/dev_net.c | 7 | ||||
-rw-r--r-- | sys/arch/aviion/stand/netboot/version.c | 4 |
5 files changed, 78 insertions, 25 deletions
diff --git a/sys/arch/aviion/stand/libsa/libsa.h b/sys/arch/aviion/stand/libsa/libsa.h index 47e96d5636d..34899a06018 100644 --- a/sys/arch/aviion/stand/libsa/libsa.h +++ b/sys/arch/aviion/stand/libsa/libsa.h @@ -1,4 +1,4 @@ -/* $OpenBSD: libsa.h,v 1.1 2006/05/16 22:48:18 miod Exp $ */ +/* $OpenBSD: libsa.h,v 1.2 2010/04/18 15:09:00 miod Exp $ */ /* * libsa prototypes @@ -6,5 +6,9 @@ #include <machine/prom.h> +extern int boothowto; + +#define BOOT_ETHERNET_ZERO 0x0001 + void exec_aout(char *, const char *, int, int, int); -int parse_args(char *, char **); +int parse_args(char *, char **, int); diff --git a/sys/arch/aviion/stand/libsa/parse_args.c b/sys/arch/aviion/stand/libsa/parse_args.c index efcb229ceb5..3c37072cb36 100644 --- a/sys/arch/aviion/stand/libsa/parse_args.c +++ b/sys/arch/aviion/stand/libsa/parse_args.c @@ -1,4 +1,4 @@ -/* $OpenBSD: parse_args.c,v 1.1 2006/05/16 22:48:18 miod Exp $ */ +/* $OpenBSD: parse_args.c,v 1.2 2010/04/18 15:09:00 miod Exp $ */ /*- * Copyright (c) 1995 Theo de Raadt @@ -36,14 +36,34 @@ #define KERNEL_NAME "bsd" +int boothowto = 0; + +/* skip end of token and whitespace */ +static char *stws(char *); +static char * +stws(char *p) +{ + while (*p != ' ' && *p != '\0') + p++; + + while (*p == ' ') + p++; + + return p; +} + int -parse_args(char *line, char **filep) +parse_args(char *line, char **filep, int first) { - char *name = NULL, *p; + char *s = NULL, *p; + char *name; + size_t namelen; - /* recognize the special ``halt'' keyword */ - if (strcmp(line, "halt") == 0) - return (1); + if (first == 0) { + /* recognize the special ``halt'' keyword */ + if (strcmp(line, "halt") == 0) + return (1); + } /* * The command line should be under the form @@ -62,20 +82,46 @@ parse_args(char *line, char **filep) if (*p != '\0') { for (p = line; *p != '\0' && *p != ')'; p++) ; if (*p != '\0') - name = ++p; + s = ++p; } - if (name == NULL) - name = line; + if (s == NULL) + s = line; - /* now insert a NUL before any option */ - for (p = name; *p != '\0' && *p != ' '; p++) ; - *p = '\0'; + /* figure out how long the kernel name is */ + for (p = s; *p != '\0' && *p != ' '; p++) ; + namelen = p - s; - /* no name, use the default */ - if (*name == '\0') + /* empty, use the default */ + if (namelen == 0) name = KERNEL_NAME; - + else { + name = (char *)alloc(1 + namelen); + if (name == NULL) + panic("out of memory"); + bcopy(s, name, namelen); + name[namelen] = '\0'; + } *filep = name; - return (0); + + /* + * If this commandline is the one passed by the PROM, then look + * for options specific to the standalone code. + */ + + if (first) { + p = stws(p); + while (*p != '\0') { + if (*p++ == '-') + while (*p != ' ' && *p != '\0') + switch (*p++) { + case 'z': + boothowto |= BOOT_ETHERNET_ZERO; + break; + } + p = stws(p); + } + } + + return 0; } diff --git a/sys/arch/aviion/stand/netboot/boot.c b/sys/arch/aviion/stand/netboot/boot.c index 2971cfedde3..4c596d97539 100644 --- a/sys/arch/aviion/stand/netboot/boot.c +++ b/sys/arch/aviion/stand/netboot/boot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: boot.c,v 1.1 2006/05/16 22:48:18 miod Exp $ */ +/* $OpenBSD: boot.c,v 1.2 2010/04/18 15:09:02 miod Exp $ */ /*- * Copyright (c) 1995 Theo de Raadt @@ -74,13 +74,13 @@ netboot(const char *args, int bootdev, int bootunit, int bootpart) printf(">> OpenBSD/" MACHINE " netboot %s\n", version); - ret = parse_args((char *)args, &file); + ret = parse_args((char *)args, &file, 1); for (;;) { if (ask) { printf("boot: "); gets(line); if (line[0]) - ret = parse_args(line, &file); + ret = parse_args(line, &file, 0); } if (ret != 0) return; diff --git a/sys/arch/aviion/stand/netboot/dev_net.c b/sys/arch/aviion/stand/netboot/dev_net.c index 1b3355605c4..e58ccbae649 100644 --- a/sys/arch/aviion/stand/netboot/dev_net.c +++ b/sys/arch/aviion/stand/netboot/dev_net.c @@ -1,4 +1,4 @@ -/* $OpenBSD: dev_net.c,v 1.1 2006/05/16 22:48:18 miod Exp $ */ +/* $OpenBSD: dev_net.c,v 1.2 2010/04/18 15:09:02 miod Exp $ */ /* * Copyright (c) 1995 Gordon W. Ross @@ -189,5 +189,8 @@ void machdep_common_ether(ether) u_char *ether; { - scm_getenaddr(ether); + if (boothowto & BOOT_ETHERNET_ZERO) + bzero(ether, 6); + else + scm_getenaddr(ether); } diff --git a/sys/arch/aviion/stand/netboot/version.c b/sys/arch/aviion/stand/netboot/version.c index 5a20b698bd1..3e1443206bb 100644 --- a/sys/arch/aviion/stand/netboot/version.c +++ b/sys/arch/aviion/stand/netboot/version.c @@ -1,3 +1,3 @@ -/* $OpenBSD: version.c,v 1.1 2006/05/16 22:48:18 miod Exp $ */ +/* $OpenBSD: version.c,v 1.2 2010/04/18 15:09:02 miod Exp $ */ -const char version[] = "1.1"; +const char version[] = "1.2"; |