aboutsummaryrefslogtreecommitdiff
path: root/stand
diff options
context:
space:
mode:
authorWarner Losh <imp@FreeBSD.org>2018-07-13 16:43:29 +0000
committerWarner Losh <imp@FreeBSD.org>2018-07-13 16:43:29 +0000
commitc96ac12e5ceb855b1a6191c2f017af5fc08aafdc (patch)
tree3d79c015e86836e83a366bf976e38fe076015ab6 /stand
parent4569e91328cd8d92f8d3da9bdd299222de185c3e (diff)
downloadsrc-c96ac12e5ceb855b1a6191c2f017af5fc08aafdc.tar.gz
src-c96ac12e5ceb855b1a6191c2f017af5fc08aafdc.zip
Transition to boot_env_to_howto and boot_howto_to_env in the boot
loader. Sponsored by: Netflix Differential Revision: https://reviews.freebsd.org/D16205
Notes
Notes: svn path=/head/; revision=336247
Diffstat (limited to 'stand')
-rw-r--r--stand/common/boot.c24
-rw-r--r--stand/common/bootstrap.h2
-rw-r--r--stand/common/metadata.c2
-rw-r--r--stand/efi/loader/bootinfo.c25
-rw-r--r--stand/efi/loader/main.c6
-rw-r--r--stand/i386/libi386/bootinfo.c4
-rw-r--r--stand/userboot/userboot/bootinfo.c4
7 files changed, 12 insertions, 55 deletions
diff --git a/stand/common/boot.c b/stand/common/boot.c
index 2781778b4622..f965dedb3bcf 100644
--- a/stand/common/boot.c
+++ b/stand/common/boot.c
@@ -160,30 +160,6 @@ autoboot_maybe()
autoboot(-1, NULL); /* try to boot automatically */
}
-int
-bootenv_flags()
-{
- int i, howto;
- char *val;
-
- for (howto = 0, i = 0; howto_names[i].ev != NULL; i++) {
- val = getenv(howto_names[i].ev);
- if (val != NULL && strcasecmp(val, "no") != 0)
- howto |= howto_names[i].mask;
- }
- return (howto);
-}
-
-void
-bootenv_set(int howto)
-{
- int i;
-
- for (i = 0; howto_names[i].ev != NULL; i++)
- if (howto & howto_names[i].mask)
- setenv(howto_names[i].ev, "YES", 1);
-}
-
static int
autoboot(int timeout, char *prompt)
{
diff --git a/stand/common/bootstrap.h b/stand/common/bootstrap.h
index 5a7a84f6398a..41037b999c5e 100644
--- a/stand/common/bootstrap.h
+++ b/stand/common/bootstrap.h
@@ -63,8 +63,6 @@ int parse(int *argc, char ***argv, const char *str);
/* boot.c */
void autoboot_maybe(void);
int getrootmount(char *rootdev);
-int bootenv_flags(void);
-void bootenv_set(int);
/* misc.c */
char *unargv(int argc, char *argv[]);
diff --git a/stand/common/metadata.c b/stand/common/metadata.c
index 9e3f5149ae80..96fad5b662ac 100644
--- a/stand/common/metadata.c
+++ b/stand/common/metadata.c
@@ -101,7 +101,7 @@ md_getboothowto(char *kargs)
/* Parse kargs */
howto = boot_parse_cmdline(kargs);
- howto |= bootenv_flags();
+ howto |= boot_env_to_howto();
#if defined(__sparc64__)
if (md_bootserial() != -1)
howto |= RB_SERIAL;
diff --git a/stand/efi/loader/bootinfo.c b/stand/efi/loader/bootinfo.c
index 43db6d7cfab1..f432a3734dc9 100644
--- a/stand/efi/loader/bootinfo.c
+++ b/stand/efi/loader/bootinfo.c
@@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/linker.h>
#include <sys/reboot.h>
+#include <sys/boot.h>
#include <machine/cpufunc.h>
#include <machine/elf.h>
#include <machine/metadata.h>
@@ -59,12 +60,6 @@ int bi_load(char *args, vm_offset_t *modulep, vm_offset_t *kernendp);
extern EFI_SYSTEM_TABLE *ST;
-static const char howto_switches[] = "aCdrgDmphsv";
-static int howto_masks[] = {
- RB_ASKNAME, RB_CDROM, RB_KDB, RB_DFLTROOT, RB_GDB, RB_MULTIPLE,
- RB_MUTE, RB_PAUSE, RB_SERIAL, RB_SINGLE, RB_VERBOSE
-};
-
static int
bi_getboothowto(char *kargs)
{
@@ -73,7 +68,8 @@ bi_getboothowto(char *kargs)
char *console;
int howto;
- howto = bootenv_flags();
+ howto = boot_parse_cmdline(kargs);
+ howto |= boot_env_to_howto();
console = getenv("console");
if (console != NULL) {
@@ -83,21 +79,6 @@ bi_getboothowto(char *kargs)
howto |= RB_MUTE;
}
- /* Parse kargs */
- if (kargs == NULL)
- return (howto);
-
- opts = strchr(kargs, '-');
- while (opts != NULL) {
- while (*(++opts) != '\0') {
- sw = strchr(howto_switches, *opts);
- if (sw == NULL)
- break;
- howto |= howto_masks[sw - howto_switches];
- }
- opts = strchr(opts, '-');
- }
-
return (howto);
}
diff --git a/stand/efi/loader/main.c b/stand/efi/loader/main.c
index 25fe0cf9407f..5de99d7948c9 100644
--- a/stand/efi/loader/main.c
+++ b/stand/efi/loader/main.c
@@ -28,11 +28,13 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
+#include <stand.h>
+
#include <sys/disk.h>
#include <sys/param.h>
#include <sys/reboot.h>
+#include <sys/boot.h>
#include <stdint.h>
-#include <stand.h>
#include <string.h>
#include <setjmp.h>
#include <disk.h>
@@ -481,7 +483,7 @@ main(int argc, CHAR16 *argv[])
howto = parse_args(argc, argv, has_kbd);
- bootenv_set(howto);
+ boot_howto_to_env(howto);
/*
* XXX we need fallback to this stuff after looking at the ConIn, ConOut and ConErr variables
diff --git a/stand/i386/libi386/bootinfo.c b/stand/i386/libi386/bootinfo.c
index d49aa0ec315a..41901e5f928f 100644
--- a/stand/i386/libi386/bootinfo.c
+++ b/stand/i386/libi386/bootinfo.c
@@ -44,7 +44,7 @@ bi_getboothowto(char *kargs)
int vidconsole;
howto = boot_parse_cmdline(kargs);
- howto |= bootenv_flags();
+ howto |= boot_env_to_howto();
/* Enable selected consoles */
string = next = strdup(getenv("console"));
@@ -80,7 +80,7 @@ void
bi_setboothowto(int howto)
{
- bootenv_set(howto);
+ boot_howto_to_env(howto);
}
/*
diff --git a/stand/userboot/userboot/bootinfo.c b/stand/userboot/userboot/bootinfo.c
index 0aeb4ee496d7..43088e2a7c0e 100644
--- a/stand/userboot/userboot/bootinfo.c
+++ b/stand/userboot/userboot/bootinfo.c
@@ -44,7 +44,7 @@ bi_getboothowto(char *kargs)
int vidconsole;
howto = boot_parse_cmdline(kargs);
- howto |= bootenv_flags();
+ howto |= boot_env_to_howto();
/* Enable selected consoles */
string = next = strdup(getenv("console"));
@@ -81,7 +81,7 @@ void
bi_setboothowto(int howto)
{
- bootenv_set(howto);
+ boot_howto_to_env(howto);
}
/*