Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/stand/efiboot Remove support for storing settings in EFI...



details:   https://anonhg.NetBSD.org/src/rev/56f15013bbe2
branches:  trunk
changeset: 935269:56f15013bbe2
user:      jmcneill <jmcneill%NetBSD.org@localhost>
date:      Sun Jun 28 11:39:50 2020 +0000

description:
Remove support for storing settings in EFI environment variables now that
we have boot.cfg support.

diffstat:

 sys/stand/efiboot/Makefile.efiboot |    4 +-
 sys/stand/efiboot/boot.c           |  120 +---------------------------------
 sys/stand/efiboot/efienv.c         |  133 -------------------------------------
 sys/stand/efiboot/efienv.h         |   33 ---------
 sys/stand/efiboot/exec.c           |    3 +-
 sys/stand/efiboot/version          |    3 +-
 6 files changed, 6 insertions(+), 290 deletions(-)

diffs (truncated from 391 to 300 lines):

diff -r 9aaf4dd14a15 -r 56f15013bbe2 sys/stand/efiboot/Makefile.efiboot
--- a/sys/stand/efiboot/Makefile.efiboot        Sun Jun 28 11:06:26 2020 +0000
+++ b/sys/stand/efiboot/Makefile.efiboot        Sun Jun 28 11:39:50 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.efiboot,v 1.16 2020/06/26 03:23:04 thorpej Exp $
+# $NetBSD: Makefile.efiboot,v 1.17 2020/06/28 11:39:50 jmcneill Exp $
 
 S=             ${.CURDIR}/../../..
 
@@ -23,7 +23,7 @@
 SOURCES=       crt0-efi-${GNUEFIARCH}.S reloc_${GNUEFIARCH}.c
 SOURCES+=      boot.c bootmenu.c conf.c console.c dev_net.c devopen.c exec.c \
                module.c overlay.c panic.c prompt.c
-SOURCES+=      efiboot.c efichar.c efidev.c efienv.c efigetsecs.c efifdt.c \
+SOURCES+=      efiboot.c efichar.c efidev.c efigetsecs.c efifdt.c \
                efifile.c efiblock.c efinet.c efipxe.c efiacpi.c efirng.c smbios.c
 
 .PATH: ${S}/external/bsd/libfdt/dist
diff -r 9aaf4dd14a15 -r 56f15013bbe2 sys/stand/efiboot/boot.c
--- a/sys/stand/efiboot/boot.c  Sun Jun 28 11:06:26 2020 +0000
+++ b/sys/stand/efiboot/boot.c  Sun Jun 28 11:39:50 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: boot.c,v 1.26 2020/06/27 18:52:24 jmcneill Exp $       */
+/*     $NetBSD: boot.c,v 1.27 2020/06/28 11:39:50 jmcneill Exp $       */
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka <nonaka%netbsd.org@localhost>
@@ -32,7 +32,6 @@
 #include "efifile.h"
 #include "efifdt.h"
 #include "efiacpi.h"
-#include "efienv.h"
 #include "efirng.h"
 #include "module.h"
 #include "overlay.h"
@@ -101,10 +100,6 @@
 void   command_ls(char *);
 void   command_mem(char *);
 void   command_menu(char *);
-void   command_printenv(char *);
-void   command_setenv(char *);
-void   command_clearenv(char *);
-void   command_resetenv(char *);
 void   command_reset(char *);
 void   command_version(char *);
 void   command_quit(char *);
@@ -123,10 +118,6 @@
        { "ls",         command_ls,             "ls [hdNn:/path]" },
        { "mem",        command_mem,            "mem" },
        { "menu",       command_menu,           "menu" },
-       { "printenv",   command_printenv,       "printenv [key]" },
-       { "setenv",     command_setenv,         "setenv <key> <value>" },
-       { "clearenv",   command_clearenv,       "clearenv <key>" },
-       { "resetenv",   command_resetenv,       "resetenv" },
        { "reboot",     command_reset,          "reboot|reset" },
        { "reset",      command_reset,          NULL },
        { "version",    command_version,        "version" },
@@ -311,53 +302,6 @@
 }
 
 void
-command_printenv(char *arg)
-{
-       char *val;
-
-       if (arg && *arg) {
-               val = efi_env_get(arg);
-               if (val) {
-                       printf("\"%s\" = \"%s\"\n", arg, val);
-                       FreePool(val);
-               }
-       } else {
-               efi_env_print();
-       }
-}
-
-void
-command_setenv(char *arg)
-{
-       char *spc;
-
-       spc = strchr(arg, ' ');
-       if (spc == NULL || spc[1] == '\0') {
-               command_help("");
-               return;
-       }
-
-       *spc = '\0';
-       efi_env_set(arg, spc + 1);
-}
-
-void
-command_clearenv(char *arg)
-{
-       if (*arg == '\0') {
-               command_help("");
-               return;
-       }
-       efi_env_clear(arg);
-}
-
-void
-command_resetenv(char *arg)
-{
-       efi_env_reset();
-}
-
-void
 command_version(char *arg)
 {
        char pathbuf[80];
@@ -482,74 +426,12 @@
            bootprog_name, bootprog_rev);
 }
 
-static void
-read_env(void)
-{
-       char *s;
-
-       s = efi_env_get("fdtfile");
-       if (s) {
-#ifdef EFIBOOT_DEBUG
-               printf(">> Setting DTB path to '%s' from environment\n", s);
-#endif
-               set_dtb_path(s);
-               FreePool(s);
-       }
-
-       s = efi_env_get("initrd");
-       if (s) {
-#ifdef EFIBOOT_DEBUG
-               printf(">> Setting initrd path to '%s' from environment\n", s);
-#endif
-               set_initrd_path(s);
-               FreePool(s);
-       }
-
-       s = efi_env_get("bootfile");
-       if (s) {
-#ifdef EFIBOOT_DEBUG
-               printf(">> Setting bootfile path to '%s' from environment\n", s);
-#endif
-               set_bootfile(s);
-               FreePool(s);
-       }
-
-       s = efi_env_get("rootdev");
-       if (s) {
-#ifdef EFIBOOT_DEBUG
-               printf(">> Setting default device to '%s' from environment\n", s);
-#endif
-               set_default_device(s);
-               FreePool(s);
-       }
-
-       s = efi_env_get("bootargs");
-       if (s) {
-#ifdef EFIBOOT_DEBUG
-               printf(">> Setting default boot args to '%s' from environment\n", s);
-#endif
-               set_bootargs(s);
-               FreePool(s);
-       }
-
-       s = efi_env_get("rndseed");
-       if (s) {
-#ifdef EFIBOOT_DEBUG
-               printf(">> Setting rndseed path to '%s' from environment\n", s);
-#endif
-               set_rndseed_path(s);
-               FreePool(s);
-       }
-}
-
 void
 boot(void)
 {
        char pathbuf[80];
        int currname, c;
 
-       read_env();
-
        if (efi_bootdp != NULL && efi_file_path(efi_bootdp, BOOTCFG_FILENAME, pathbuf, sizeof(pathbuf)) == 0) {
                twiddle_toggle = 1;
                parsebootconf(pathbuf);
diff -r 9aaf4dd14a15 -r 56f15013bbe2 sys/stand/efiboot/efienv.c
--- a/sys/stand/efiboot/efienv.c        Sun Jun 28 11:06:26 2020 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,133 +0,0 @@
-/* $NetBSD: efienv.c,v 1.6 2020/06/26 03:23:04 thorpej Exp $ */
-
-/*-
- * Copyright (c) 2019 Jason R. Thorpe
- * Copyright (c) 2018 Jared McNeill <jmcneill%invisible.ca@localhost>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- */
-
-#include "efiboot.h"
-#include "efienv.h"
-
-#define EFIBOOT_VENDOR_GUID \
-       { 0x97cde9bd, 0xac88, 0x4cf9, { 0x84, 0x86, 0x01, 0x33, 0x0f, 0xe1, 0x95, 0xd4 } }
-
-static EFI_GUID EfibootVendorGuid = EFIBOOT_VENDOR_GUID;
-
-void
-efi_env_set(const char *key, char *val)
-{
-       EFI_STATUS status;
-       CHAR16 *ukey;
-       size_t len;
-
-       ukey = NULL;
-       utf8_to_ucs2(key, &ukey, &len);
-       status = LibSetNVVariable(ukey, &EfibootVendorGuid, strlen(val) + 1, val);
-       FreePool(ukey);
-
-       if (EFI_ERROR(status))
-               printf("env: failed to set variable '%s': %#lx\n", key, (u_long)status);
-}
-
-char *
-efi_env_get(const char *key)
-{
-       CHAR16 *ukey;
-       size_t len;
-       char *ret;
-
-       ukey = NULL;
-       utf8_to_ucs2(key, &ukey, &len);
-       ret = LibGetVariable(ukey, &EfibootVendorGuid);
-       FreePool(ukey);
-
-       return ret;
-}
-
-void
-efi_env_clear(const char *key)
-{
-       CHAR16 *ukey;
-       size_t len;
-
-       ukey = NULL;
-       utf8_to_ucs2(key, &ukey, &len);
-       LibDeleteVariable(ukey, &EfibootVendorGuid);
-       FreePool(ukey);
-}
-
-void
-efi_env_reset(void)
-{
-       EFI_STATUS status;
-       CHAR16 ukey[256];
-       EFI_GUID vendor;
-       UINTN size;
-
-retry:
-       ukey[0] = '\0';
-       vendor = NullGuid;
-
-       for (;;) {
-               size = sizeof(ukey);
-               status = uefi_call_wrapper(RT->GetNextVariableName, 3, &size, ukey, &vendor);
-               if (status != EFI_SUCCESS)
-                       break;
-
-               if (CompareGuid(&vendor, &EfibootVendorGuid) == 0) {
-                       LibDeleteVariable(ukey, &vendor);
-                       goto retry;
-               }
-       }
-}
-
-void
-efi_env_print(void)
-{
-       EFI_STATUS status;
-       CHAR16 ukey[256];



Home | Main Index | Thread Index | Old Index