svn commit: r336247 - in head/stand: common efi/loader i386/libi386 userboot/userboot
Warner Losh
imp at FreeBSD.org
Fri Jul 13 16:43:33 UTC 2018
Author: imp
Date: Fri Jul 13 16:43:29 2018
New Revision: 336247
URL: https://svnweb.freebsd.org/changeset/base/336247
Log:
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
Modified:
head/stand/common/boot.c
head/stand/common/bootstrap.h
head/stand/common/metadata.c
head/stand/efi/loader/bootinfo.c
head/stand/efi/loader/main.c
head/stand/i386/libi386/bootinfo.c
head/stand/userboot/userboot/bootinfo.c
Modified: head/stand/common/boot.c
==============================================================================
--- head/stand/common/boot.c Fri Jul 13 16:43:23 2018 (r336246)
+++ head/stand/common/boot.c Fri Jul 13 16:43:29 2018 (r336247)
@@ -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)
{
Modified: head/stand/common/bootstrap.h
==============================================================================
--- head/stand/common/bootstrap.h Fri Jul 13 16:43:23 2018 (r336246)
+++ head/stand/common/bootstrap.h Fri Jul 13 16:43:29 2018 (r336247)
@@ -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[]);
Modified: head/stand/common/metadata.c
==============================================================================
--- head/stand/common/metadata.c Fri Jul 13 16:43:23 2018 (r336246)
+++ head/stand/common/metadata.c Fri Jul 13 16:43:29 2018 (r336247)
@@ -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;
Modified: head/stand/efi/loader/bootinfo.c
==============================================================================
--- head/stand/efi/loader/bootinfo.c Fri Jul 13 16:43:23 2018 (r336246)
+++ head/stand/efi/loader/bootinfo.c Fri Jul 13 16:43:29 2018 (r336247)
@@ -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_offse
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) {
@@ -81,21 +77,6 @@ bi_getboothowto(char *kargs)
howto |= RB_SERIAL;
if (strcmp(console, "nullconsole") == 0)
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);
Modified: head/stand/efi/loader/main.c
==============================================================================
--- head/stand/efi/loader/main.c Fri Jul 13 16:43:23 2018 (r336246)
+++ head/stand/efi/loader/main.c Fri Jul 13 16:43:29 2018 (r336247)
@@ -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
Modified: head/stand/i386/libi386/bootinfo.c
==============================================================================
--- head/stand/i386/libi386/bootinfo.c Fri Jul 13 16:43:23 2018 (r336246)
+++ head/stand/i386/libi386/bootinfo.c Fri Jul 13 16:43:29 2018 (r336247)
@@ -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);
}
/*
Modified: head/stand/userboot/userboot/bootinfo.c
==============================================================================
--- head/stand/userboot/userboot/bootinfo.c Fri Jul 13 16:43:23 2018 (r336246)
+++ head/stand/userboot/userboot/bootinfo.c Fri Jul 13 16:43:29 2018 (r336247)
@@ -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);
}
/*
More information about the svn-src-head
mailing list