From owner-svn-src-head@freebsd.org Fri Jul 13 16:43:33 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D66C31043846; Fri, 13 Jul 2018 16:43:32 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id DE0B38E3ED; Fri, 13 Jul 2018 16:43:31 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 3E17512D07; Fri, 13 Jul 2018 16:43:31 +0000 (UTC) (envelope-from imp@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w6DGhVVI089021; Fri, 13 Jul 2018 16:43:31 GMT (envelope-from imp@FreeBSD.org) Received: (from imp@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w6DGhTqV089013; Fri, 13 Jul 2018 16:43:29 GMT (envelope-from imp@FreeBSD.org) Message-Id: <201807131643.w6DGhTqV089013@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: imp set sender to imp@FreeBSD.org using -f From: Warner Losh Date: Fri, 13 Jul 2018 16:43:29 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r336247 - in head/stand: common efi/loader i386/libi386 userboot/userboot X-SVN-Group: head X-SVN-Commit-Author: imp X-SVN-Commit-Paths: in head/stand: common efi/loader i386/libi386 userboot/userboot X-SVN-Commit-Revision: 336247 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.27 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 Jul 2018 16:43:33 -0000 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 #include #include +#include #include #include #include @@ -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 __FBSDID("$FreeBSD$"); +#include + #include #include #include +#include #include -#include #include #include #include @@ -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); } /*