Source-Changes-HG archive

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

[src/trunk]: src/sys/stand/efiboot Add dtoverlay command to specify device tr...



details:   https://anonhg.NetBSD.org/src/rev/e95c05443f69
branches:  trunk
changeset: 1011320:e95c05443f69
user:      thorpej <thorpej%NetBSD.org@localhost>
date:      Fri Jun 26 03:23:04 2020 +0000

description:
Add dtoverlay command to specify device tree overlays from the boot
loader command line.  Add support for specifying device tree overlays
in boot.cfg, with the syntax:

dtoverlay=/path/to/overlay.dtbo
dtoverlay=hd0e:/overlays/example.dtbo

Multiple overlays can be specified, and they are loaded in the order
they appear in boot.cfg.

Remove support for efiboot.plist.

diffstat:

 sys/stand/efiboot/Makefile.efiboot |    4 +-
 sys/stand/efiboot/boot.c           |   77 +++++++++++------------
 sys/stand/efiboot/bootmenu.c       |    5 +-
 sys/stand/efiboot/efiboot.c        |    8 +--
 sys/stand/efiboot/efiboot.h        |    8 +--
 sys/stand/efiboot/efienv.c         |   65 +-------------------
 sys/stand/efiboot/efienv.h         |    3 +-
 sys/stand/efiboot/exec.c           |  121 ++----------------------------------
 sys/stand/efiboot/overlay.c        |  114 ++++++++++++++++++++++++++++++++++
 sys/stand/efiboot/overlay.h        |   37 +++++++++++
 sys/stand/efiboot/version          |    3 +-
 11 files changed, 208 insertions(+), 237 deletions(-)

diffs (truncated from 700 to 300 lines):

diff -r 4fd8f635b994 -r e95c05443f69 sys/stand/efiboot/Makefile.efiboot
--- a/sys/stand/efiboot/Makefile.efiboot        Thu Jun 25 22:50:56 2020 +0000
+++ b/sys/stand/efiboot/Makefile.efiboot        Fri Jun 26 03:23:04 2020 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.efiboot,v 1.15 2020/06/21 23:53:26 jmcneill Exp $
+# $NetBSD: Makefile.efiboot,v 1.16 2020/06/26 03:23:04 thorpej Exp $
 
 S=             ${.CURDIR}/../../..
 
@@ -22,7 +22,7 @@
 .PATH: ${EFIDIR}/gnuefi
 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 panic.c prompt.c
+               module.c overlay.c panic.c prompt.c
 SOURCES+=      efiboot.c efichar.c efidev.c efienv.c efigetsecs.c efifdt.c \
                efifile.c efiblock.c efinet.c efipxe.c efiacpi.c efirng.c smbios.c
 
diff -r 4fd8f635b994 -r e95c05443f69 sys/stand/efiboot/boot.c
--- a/sys/stand/efiboot/boot.c  Thu Jun 25 22:50:56 2020 +0000
+++ b/sys/stand/efiboot/boot.c  Fri Jun 26 03:23:04 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: boot.c,v 1.23 2020/06/21 23:53:26 jmcneill Exp $       */
+/*     $NetBSD: boot.c,v 1.24 2020/06/26 03:23:04 thorpej Exp $        */
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka <nonaka%netbsd.org@localhost>
@@ -34,6 +34,7 @@
 #include "efienv.h"
 #include "efirng.h"
 #include "module.h"
+#include "overlay.h"
 #include "bootmenu.h"
 
 #include <sys/bootblock.h>
@@ -76,7 +77,6 @@
 static char default_device[32];
 static char initrd_path[255];
 static char dtb_path[255];
-static char efibootplist_path[255];
 static char netbsd_path[255];
 static char netbsd_args[255];
 static char rndseed_path[255];
@@ -90,9 +90,10 @@
 void   command_boot(char *);
 void   command_dev(char *);
 void   command_dtb(char *);
-void   command_plist(char *);
 void   command_initrd(char *);
 void   command_rndseed(char *);
+void   command_dtoverlay(char *);
+void   command_dtoverlays(char *);
 void   command_modules(char *);
 void   command_load(char *);
 void   command_unload(char *);
@@ -111,9 +112,10 @@
        { "boot",       command_boot,           "boot [dev:][filename] [args]\n     (ex. \"hd0a:\\netbsd.old -s\"" },
        { "dev",        command_dev,            "dev" },
        { "dtb",        command_dtb,            "dtb [dev:][filename]" },
-       { "plist",      command_plist,          "plist [dev:][filename]" },
        { "initrd",     command_initrd,         "initrd [dev:][filename]" },
        { "rndseed",    command_rndseed,        "rndseed [dev:][filename]" },
+       { "dtoverlay",  command_dtoverlay,      "dtoverlay [dev:][filename]" },
+       { "dtoverlays", command_dtoverlays,     "dtoverlays [{on|off|reset}]" },
        { "modules",    command_modules,        "modules [{on|off|reset}]" },
        { "load",       command_load,           "load <module_name>" },
        { "unload",     command_unload,         "unload <module_name>" },
@@ -185,13 +187,6 @@
 }
 
 void
-command_plist(char *arg)
-{
-       if (set_efibootplist_path(arg) == 0)
-               load_efibootplist(false);
-}
-
-void
 command_initrd(char *arg)
 {
        set_initrd_path(arg);
@@ -204,6 +199,37 @@
 }
 
 void
+command_dtoverlays(char *arg)
+{
+       if (arg && *arg) {
+               if (strcmp(arg, "on") == 0)
+                       dtoverlay_enable(1);
+               else if (strcmp(arg, "off") == 0)
+                       dtoverlay_enable(0);
+               else if (strcmp(arg, "reset") == 0)
+                       dtoverlay_remove_all();
+               else {
+                       command_help("");
+                       return;
+               }
+       } else {
+               printf("Device Tree overlays are %sabled\n",
+                   dtoverlay_enabled ? "en" : "dis");
+       }
+}
+
+void
+command_dtoverlay(char *arg)
+{
+       if (!arg || !*arg) {
+               command_help("");
+               return;
+       }
+
+       dtoverlay_add(arg);
+}
+
+void
 command_modules(char *arg)
 {
        if (arg && *arg) {
@@ -410,20 +436,6 @@
 }
 
 int
-set_efibootplist_path(const char *arg)
-{
-       if (strlen(arg) + 1 > sizeof(efibootplist_path))
-               return ERANGE;
-       strcpy(efibootplist_path, arg);
-       return 0;
-}
-
-char *get_efibootplist_path(void)
-{
-       return efibootplist_path;
-}
-
-int
 set_rndseed_path(const char *arg)
 {
        if (strlen(arg) + 1 > sizeof(rndseed_path))
@@ -469,21 +481,6 @@
 {
        char *s;
 
-       s = efi_env_get("efibootplist");
-       if (s) {
-#ifdef EFIBOOT_DEBUG
-               printf(">> Setting efiboot.plist path to '%s' from environment\n", s);
-#endif
-               set_efibootplist_path(s);
-               FreePool(s);
-       }
-
-       /*
-        * Read the efiboot.plist now as it may contain additional
-        * environment variables.
-        */
-       load_efibootplist(true);
-
        s = efi_env_get("fdtfile");
        if (s) {
 #ifdef EFIBOOT_DEBUG
diff -r 4fd8f635b994 -r e95c05443f69 sys/stand/efiboot/bootmenu.c
--- a/sys/stand/efiboot/bootmenu.c      Thu Jun 25 22:50:56 2020 +0000
+++ b/sys/stand/efiboot/bootmenu.c      Fri Jun 26 03:23:04 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: bootmenu.c,v 1.1 2020/06/21 23:53:26 jmcneill Exp $    */
+/*     $NetBSD: bootmenu.c,v 1.2 2020/06/26 03:23:04 thorpej Exp $     */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -40,6 +40,7 @@
 #include "bootmenu.h"
 #include "efiboot.h"
 #include "module.h"
+#include "overlay.h"
 
 static void docommandchoice(int);
 
@@ -63,6 +64,8 @@
        else if (strcmp(cmd, BOOTCFG_CMD_USERCONF) == 0)
                userconf_add(arg);
 #endif
+       else if (strcmp(cmd, "dtoverlay") == 0)
+               dtoverlay_add(arg);
 }
 
 int
diff -r 4fd8f635b994 -r e95c05443f69 sys/stand/efiboot/efiboot.c
--- a/sys/stand/efiboot/efiboot.c       Thu Jun 25 22:50:56 2020 +0000
+++ b/sys/stand/efiboot/efiboot.c       Fri Jun 26 03:23:04 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: efiboot.c,v 1.19 2020/06/21 23:53:26 jmcneill Exp $ */
+/* $NetBSD: efiboot.c,v 1.20 2020/06/26 03:23:04 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -57,8 +57,6 @@
 
 EFI_STATUS EFIAPI efi_main(EFI_HANDLE, EFI_SYSTEM_TABLE *);
 
-prop_dictionary_t efibootplist;
-
 EFI_STATUS EFIAPI
 efi_main(EFI_HANDLE imageHandle, EFI_SYSTEM_TABLE *systemTable)
 {
@@ -186,10 +184,6 @@
        UINTN nentries, mapkey, descsize;
        UINT32 descver;
 
-       if (efibootplist) {
-               prop_object_release(efibootplist);
-       }
-
        memmap = LibMemoryMap(&nentries, &mapkey, &descsize, &descver);
 
        status = uefi_call_wrapper(BS->ExitBootServices, 2, IH, mapkey);
diff -r 4fd8f635b994 -r e95c05443f69 sys/stand/efiboot/efiboot.h
--- a/sys/stand/efiboot/efiboot.h       Thu Jun 25 22:50:56 2020 +0000
+++ b/sys/stand/efiboot/efiboot.h       Fri Jun 26 03:23:04 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: efiboot.h,v 1.11 2019/12/18 21:46:03 riastradh Exp $   */
+/*     $NetBSD: efiboot.h,v 1.12 2020/06/26 03:23:04 thorpej Exp $     */
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka <nonaka%netbsd.org@localhost>
@@ -35,8 +35,6 @@
 #include <loadfile.h>
 #include <net.h>
 
-#include <prop/proplib.h>
-
 #include "efiboot_machdep.h"
 
 struct boot_command {
@@ -62,8 +60,6 @@
 char *get_initrd_path(void);
 int set_dtb_path(const char *);
 char *get_dtb_path(void);
-int set_efibootplist_path(const char *);
-char *get_efibootplist_path(void);
 int set_rndseed_path(const char *);
 char *get_rndseed_path(void);
 
@@ -79,7 +75,6 @@
 void efi_delay(int);
 void efi_reboot(void);
 extern int howto;
-extern prop_dictionary_t efibootplist;
 
 /* efichar.c */
 size_t ucs2len(const CHAR16 *);
@@ -108,7 +103,6 @@
 
 /* exec.c */
 int exec_netbsd(const char *, const char *);
-void load_efibootplist(bool);
 
 /* panic.c */
 __dead VOID Panic(IN CHAR16 *, ...);
diff -r 4fd8f635b994 -r e95c05443f69 sys/stand/efiboot/efienv.c
--- a/sys/stand/efiboot/efienv.c        Thu Jun 25 22:50:56 2020 +0000
+++ b/sys/stand/efiboot/efienv.c        Fri Jun 26 03:23:04 2020 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: efienv.c,v 1.5 2020/05/14 08:34:18 msaitoh Exp $ */
+/* $NetBSD: efienv.c,v 1.6 2020/06/26 03:23:04 thorpej Exp $ */
 
 /*-
  * Copyright (c) 2019 Jason R. Thorpe
@@ -36,69 +36,6 @@
 static EFI_GUID EfibootVendorGuid = EFIBOOT_VENDOR_GUID;
 
 void
-efi_env_from_efibootplist(void)
-{
-       /*
-        * We support pre-loading the EFI environment from efiboot.plist
-        * using the following schema:
-        *
-        *      <key>environment-variables</key>
-        *      <dict>
-        *              <key>varname1</key>
-        *              <string>value_for_varname1</string>
-        *              <key>varname2</key>
-        *              <string>value_for_varname2</string>
-        *      </dict>
-        *
-        * Only string values are supported.
-        */
-       prop_dictionary_t environment;
-       prop_dictionary_keysym_t key;
-       prop_string_t value;
-       prop_object_iterator_t iter;
-
-       const char *env_key;
-       char *env_value;
-
-       environment = prop_dictionary_get(efibootplist,
-           "environment-variables");
-       if (environment == NULL)



Home | Main Index | Thread Index | Old Index