diff --git a/sys/boot/ia64/libski/bootinfo.c b/sys/boot/ia64/libski/bootinfo.c index d3d95cab9dfb..9bb0f3e59c63 100644 --- a/sys/boot/ia64/libski/bootinfo.c +++ b/sys/boot/ia64/libski/bootinfo.c @@ -35,8 +35,93 @@ #include #include "bootstrap.h" +/* + * Return a 'boothowto' value corresponding to the kernel arguments in + * (kargs) and any relevant environment variables. + */ +static struct +{ + const char *ev; + int mask; +} howto_names[] = { + {"boot_askname", RB_ASKNAME}, + {"boot_cdrom", RB_CDROM}, + {"boot_userconfig", RB_CONFIG}, + {"boot_ddb", RB_KDB}, + {"boot_gdb", RB_GDB}, + {"boot_single", RB_SINGLE}, + {"boot_verbose", RB_VERBOSE}, + {NULL, 0} +}; + extern char *ski_fmtdev(void *vdev); +int +bi_getboothowto(char *kargs) +{ + char *cp; + int howto; + int active; + int i; + + /* Parse kargs */ + howto = 0; + if (kargs != NULL) { + cp = kargs; + active = 0; + while (*cp != 0) { + if (!active && (*cp == '-')) { + active = 1; + } else if (active) + switch (*cp) { + case 'a': + howto |= RB_ASKNAME; + break; + case 'c': + howto |= RB_CONFIG; + break; + case 'C': + howto |= RB_CDROM; + break; + case 'd': + howto |= RB_KDB; + break; + case 'm': + howto |= RB_MUTE; + break; + case 'g': + howto |= RB_GDB; + break; + case 'h': + howto |= RB_SERIAL; + break; + case 'r': + howto |= RB_DFLTROOT; + break; + case 's': + howto |= RB_SINGLE; + break; + case 'v': + howto |= RB_VERBOSE; + break; + default: + active = 0; + break; + } + cp++; + } + } + /* get equivalents from the environment */ + for (i = 0; howto_names[i].ev != NULL; i++) + if (getenv(howto_names[i].ev) != NULL) + howto |= howto_names[i].mask; + if (!strcmp(getenv("console"), "comconsole")) + howto |= RB_SERIAL; + if (!strcmp(getenv("console"), "nullconsole")) + howto |= RB_MUTE; + return(howto); +} + /* * Copy the environment into the load area starting at (addr). * Each variable is formatted as =, with a single nul @@ -150,7 +235,7 @@ bi_copymodules(vm_offset_t addr) * - Module metadata are formatted and placed in kernel space. */ int -bi_load(struct bootinfo *bi, struct preloaded_file *fp) +bi_load(struct bootinfo *bi, struct preloaded_file *fp, char *args) { char *rootdevname; struct ski_devdesc *rootdev; @@ -161,6 +246,17 @@ bi_load(struct bootinfo *bi, struct preloaded_file *fp) vm_offset_t ssym, esym; struct file_metadata *md; + /* + * Version 1 bootinfo. + */ + bi->bi_magic = BOOTINFO_MAGIC; + bi->bi_version = 1; + + /* + * Calculate boothowto. + */ + bi->bi_boothowto = bi_getboothowto(fp->f_args); + /* * Allow the environment variable 'rootdev' to override the supplied device * This should perhaps go to MI code and/or have $rootdev tested/set by diff --git a/sys/boot/ia64/libski/elf_freebsd.c b/sys/boot/ia64/libski/elf_freebsd.c index 336048e92a2b..e1ec0d24257f 100644 --- a/sys/boot/ia64/libski/elf_freebsd.c +++ b/sys/boot/ia64/libski/elf_freebsd.c @@ -90,7 +90,6 @@ #define _KERNEL static int elf_exec(struct preloaded_file *amp); -int bi_load(struct bootinfo *, struct preloaded_file *); struct file_format ia64_elf = { elf_loadfile, elf_exec }; diff --git a/sys/boot/ia64/libski/libski.h b/sys/boot/ia64/libski/libski.h index e4d0932c8d73..d29227823d4a 100644 --- a/sys/boot/ia64/libski/libski.h +++ b/sys/boot/ia64/libski/libski.h @@ -74,6 +74,10 @@ extern ssize_t ski_readin(int fd, vm_offset_t dest, size_t len); extern int ski_boot(void); extern int ski_autoload(void); +struct bootinfo; +struct preloaded_file; +extern int bi_load(struct bootinfo *, struct preloaded_file *); + #define SSC_CONSOLE_INIT 20 #define SSC_GETCHAR 21 #define SSC_PUTCHAR 31 diff --git a/sys/boot/ia64/ski/bootinfo.c b/sys/boot/ia64/ski/bootinfo.c index d3d95cab9dfb..9bb0f3e59c63 100644 --- a/sys/boot/ia64/ski/bootinfo.c +++ b/sys/boot/ia64/ski/bootinfo.c @@ -35,8 +35,93 @@ #include #include "bootstrap.h" +/* + * Return a 'boothowto' value corresponding to the kernel arguments in + * (kargs) and any relevant environment variables. + */ +static struct +{ + const char *ev; + int mask; +} howto_names[] = { + {"boot_askname", RB_ASKNAME}, + {"boot_cdrom", RB_CDROM}, + {"boot_userconfig", RB_CONFIG}, + {"boot_ddb", RB_KDB}, + {"boot_gdb", RB_GDB}, + {"boot_single", RB_SINGLE}, + {"boot_verbose", RB_VERBOSE}, + {NULL, 0} +}; + extern char *ski_fmtdev(void *vdev); +int +bi_getboothowto(char *kargs) +{ + char *cp; + int howto; + int active; + int i; + + /* Parse kargs */ + howto = 0; + if (kargs != NULL) { + cp = kargs; + active = 0; + while (*cp != 0) { + if (!active && (*cp == '-')) { + active = 1; + } else if (active) + switch (*cp) { + case 'a': + howto |= RB_ASKNAME; + break; + case 'c': + howto |= RB_CONFIG; + break; + case 'C': + howto |= RB_CDROM; + break; + case 'd': + howto |= RB_KDB; + break; + case 'm': + howto |= RB_MUTE; + break; + case 'g': + howto |= RB_GDB; + break; + case 'h': + howto |= RB_SERIAL; + break; + case 'r': + howto |= RB_DFLTROOT; + break; + case 's': + howto |= RB_SINGLE; + break; + case 'v': + howto |= RB_VERBOSE; + break; + default: + active = 0; + break; + } + cp++; + } + } + /* get equivalents from the environment */ + for (i = 0; howto_names[i].ev != NULL; i++) + if (getenv(howto_names[i].ev) != NULL) + howto |= howto_names[i].mask; + if (!strcmp(getenv("console"), "comconsole")) + howto |= RB_SERIAL; + if (!strcmp(getenv("console"), "nullconsole")) + howto |= RB_MUTE; + return(howto); +} + /* * Copy the environment into the load area starting at (addr). * Each variable is formatted as =, with a single nul @@ -150,7 +235,7 @@ bi_copymodules(vm_offset_t addr) * - Module metadata are formatted and placed in kernel space. */ int -bi_load(struct bootinfo *bi, struct preloaded_file *fp) +bi_load(struct bootinfo *bi, struct preloaded_file *fp, char *args) { char *rootdevname; struct ski_devdesc *rootdev; @@ -161,6 +246,17 @@ bi_load(struct bootinfo *bi, struct preloaded_file *fp) vm_offset_t ssym, esym; struct file_metadata *md; + /* + * Version 1 bootinfo. + */ + bi->bi_magic = BOOTINFO_MAGIC; + bi->bi_version = 1; + + /* + * Calculate boothowto. + */ + bi->bi_boothowto = bi_getboothowto(fp->f_args); + /* * Allow the environment variable 'rootdev' to override the supplied device * This should perhaps go to MI code and/or have $rootdev tested/set by diff --git a/sys/boot/ia64/ski/elf_freebsd.c b/sys/boot/ia64/ski/elf_freebsd.c index 336048e92a2b..e1ec0d24257f 100644 --- a/sys/boot/ia64/ski/elf_freebsd.c +++ b/sys/boot/ia64/ski/elf_freebsd.c @@ -90,7 +90,6 @@ #define _KERNEL static int elf_exec(struct preloaded_file *amp); -int bi_load(struct bootinfo *, struct preloaded_file *); struct file_format ia64_elf = { elf_loadfile, elf_exec }; diff --git a/sys/boot/ia64/ski/libski.h b/sys/boot/ia64/ski/libski.h index e4d0932c8d73..d29227823d4a 100644 --- a/sys/boot/ia64/ski/libski.h +++ b/sys/boot/ia64/ski/libski.h @@ -74,6 +74,10 @@ extern ssize_t ski_readin(int fd, vm_offset_t dest, size_t len); extern int ski_boot(void); extern int ski_autoload(void); +struct bootinfo; +struct preloaded_file; +extern int bi_load(struct bootinfo *, struct preloaded_file *); + #define SSC_CONSOLE_INIT 20 #define SSC_GETCHAR 21 #define SSC_PUTCHAR 31