Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/stand/efiboot efiboot: Add support for 'userconf' command.
details: https://anonhg.NetBSD.org/src/rev/12b64ac9f1eb
branches: trunk
changeset: 364449:12b64ac9f1eb
user: jmcneill <jmcneill%NetBSD.org@localhost>
date: Fri Mar 25 21:23:00 2022 +0000
description:
efiboot: Add support for 'userconf' command.
Add support for the 'userconf' command at the boot prompt and in boot.cfg,
and for FDT based booting, pass the commands as a string list property
named "netbsd,userconf" on the /chosen node.
diffstat:
sys/stand/efiboot/Makefile.efiboot | 4 +-
sys/stand/efiboot/boot.c | 10 ++++-
sys/stand/efiboot/bootmenu.c | 4 +-
sys/stand/efiboot/efiboot.h | 6 ++-
sys/stand/efiboot/efifdt.c | 17 +++++++-
sys/stand/efiboot/efifdt.h | 3 +-
sys/stand/efiboot/userconf.c | 81 ++++++++++++++++++++++++++++++++++++++
sys/stand/efiboot/version | 3 +-
8 files changed, 118 insertions(+), 10 deletions(-)
diffs (247 lines):
diff -r e25f5542a1fe -r 12b64ac9f1eb sys/stand/efiboot/Makefile.efiboot
--- a/sys/stand/efiboot/Makefile.efiboot Fri Mar 25 21:16:04 2022 +0000
+++ b/sys/stand/efiboot/Makefile.efiboot Fri Mar 25 21:23:00 2022 +0000
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.efiboot,v 1.25 2021/10/17 14:12:54 jmcneill Exp $
+# $NetBSD: Makefile.efiboot,v 1.26 2022/03/25 21:23:00 jmcneill 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 panic.c prompt.c userconf.c
SOURCES+= efiboot.c efichar.c efidev.c efigetsecs.c \
efifile.c efiblock.c efinet.c efipxe.c efirng.c \
efiwatchdog.c efigop.c smbios.c
diff -r e25f5542a1fe -r 12b64ac9f1eb sys/stand/efiboot/boot.c
--- a/sys/stand/efiboot/boot.c Fri Mar 25 21:16:04 2022 +0000
+++ b/sys/stand/efiboot/boot.c Fri Mar 25 21:23:00 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: boot.c,v 1.42 2021/11/04 07:28:34 skrll Exp $ */
+/* $NetBSD: boot.c,v 1.43 2022/03/25 21:23:00 jmcneill Exp $ */
/*-
* Copyright (c) 2016 Kimihiro Nonaka <nonaka%netbsd.org@localhost>
@@ -114,6 +114,7 @@
void command_menu(char *);
void command_reset(char *);
void command_setup(char *);
+void command_userconf(char *);
void command_version(char *);
void command_quit(char *);
@@ -141,6 +142,7 @@
{ "reboot", command_reset, "reboot|reset" },
{ "reset", command_reset, NULL },
{ "setup", command_setup, "setup" },
+ { "userconf", command_userconf, "userconf <command>" },
{ "version", command_version, "version" },
{ "ver", command_version, NULL },
{ "help", command_help, "help|?" },
@@ -450,6 +452,12 @@
efi_reboot();
}
+void
+command_userconf(char *arg)
+{
+ userconf_add(arg);
+}
+
int
set_default_device(const char *arg)
{
diff -r e25f5542a1fe -r 12b64ac9f1eb sys/stand/efiboot/bootmenu.c
--- a/sys/stand/efiboot/bootmenu.c Fri Mar 25 21:16:04 2022 +0000
+++ b/sys/stand/efiboot/bootmenu.c Fri Mar 25 21:23:00 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: bootmenu.c,v 1.3 2021/10/06 10:13:19 jmcneill Exp $ */
+/* $NetBSD: bootmenu.c,v 1.4 2022/03/25 21:23:00 jmcneill Exp $ */
/*-
* Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -60,10 +60,8 @@
{
if (strcmp(cmd, BOOTCFG_CMD_LOAD) == 0)
module_add(arg);
-#if notyet
else if (strcmp(cmd, BOOTCFG_CMD_USERCONF) == 0)
userconf_add(arg);
-#endif
#ifdef EFIBOOT_FDT
else if (strcmp(cmd, "dtoverlay") == 0)
dtoverlay_add(arg);
diff -r e25f5542a1fe -r 12b64ac9f1eb sys/stand/efiboot/efiboot.h
--- a/sys/stand/efiboot/efiboot.h Fri Mar 25 21:16:04 2022 +0000
+++ b/sys/stand/efiboot/efiboot.h Fri Mar 25 21:23:00 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: efiboot.h,v 1.18 2021/10/06 10:13:19 jmcneill Exp $ */
+/* $NetBSD: efiboot.h,v 1.19 2022/03/25 21:23:00 jmcneill Exp $ */
/*-
* Copyright (c) 2016 Kimihiro Nonaka <nonaka%netbsd.org@localhost>
@@ -131,3 +131,7 @@
void docommand(char *);
char awaitkey(int, int);
__dead void bootprompt(void);
+
+/* userconf.c */
+void userconf_add(const char *);
+void userconf_foreach(void (*)(const char *));
diff -r e25f5542a1fe -r 12b64ac9f1eb sys/stand/efiboot/efifdt.c
--- a/sys/stand/efiboot/efifdt.c Fri Mar 25 21:16:04 2022 +0000
+++ b/sys/stand/efiboot/efifdt.c Fri Mar 25 21:23:00 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: efifdt.c,v 1.33 2021/11/06 19:44:22 jmcneill Exp $ */
+/* $NetBSD: efifdt.c,v 1.34 2022/03/25 21:23:00 jmcneill Exp $ */
/*-
* Copyright (c) 2019 Jason R. Thorpe
@@ -442,6 +442,20 @@
}
}
+static void
+efi_fdt_userconf_addprop(const char *cmd)
+{
+ const int chosen = efi_fdt_chosen();
+
+ fdt_appendprop_string(fdt_data, chosen, "netbsd,userconf", cmd);
+}
+
+void
+efi_fdt_userconf(void)
+{
+ userconf_foreach(efi_fdt_userconf_addprop);
+}
+
void
efi_fdt_initrd(u_long initrd_addr, u_long initrd_size)
{
@@ -615,6 +629,7 @@
efi_fdt_rndseed(rndseed_addr, rndseed_size);
efi_fdt_efirng(efirng_addr, efirng_size);
efi_fdt_bootargs(args);
+ efi_fdt_userconf();
efi_fdt_system_table();
efi_fdt_gop();
efi_fdt_memory_map();
diff -r e25f5542a1fe -r 12b64ac9f1eb sys/stand/efiboot/efifdt.h
--- a/sys/stand/efiboot/efifdt.h Fri Mar 25 21:16:04 2022 +0000
+++ b/sys/stand/efiboot/efifdt.h Fri Mar 25 21:23:00 2022 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: efifdt.h,v 1.11 2021/10/06 10:13:19 jmcneill Exp $ */
+/* $NetBSD: efifdt.h,v 1.12 2022/03/25 21:23:00 jmcneill Exp $ */
/*-
* Copyright (c) 2018 Jared McNeill <jmcneill%invisible.ca@localhost>
@@ -44,6 +44,7 @@
void efi_fdt_rndseed(u_long, u_long);
void efi_fdt_efirng(u_long, u_long);
void efi_fdt_module(const char *, u_long, u_long);
+void efi_fdt_userconf(void);
void efi_fdt_init(u_long, u_long);
void efi_fdt_fini(void);
void efi_fdt_system_table(void);
diff -r e25f5542a1fe -r 12b64ac9f1eb sys/stand/efiboot/userconf.c
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/sys/stand/efiboot/userconf.c Fri Mar 25 21:23:00 2022 +0000
@@ -0,0 +1,81 @@
+/* $NetBSD: userconf.c,v 1.1 2022/03/25 21:23:00 jmcneill Exp $ */
+
+/*-
+ * Copyright (c) 2022 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Jared McNeill <jmcneill%invisible.ca@localhost>.
+ *
+ * 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 NETBSD FOUNDATION, INC. 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 FOUNDATION 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 <sys/queue.h>
+
+struct userconf_command {
+ const char *uc_text;
+ TAILQ_ENTRY(userconf_command) entries;
+};
+TAILQ_HEAD(, userconf_command) userconf_commands =
+ TAILQ_HEAD_INITIALIZER(userconf_commands);
+
+void
+userconf_foreach(void (*fn)(const char *))
+{
+ struct userconf_command *uc;
+
+ TAILQ_FOREACH(uc, &userconf_commands, entries) {
+ fn(uc->uc_text);
+ }
+}
+
+void
+userconf_add(const char *cmd)
+{
+ struct userconf_command *uc;
+ size_t len;
+ char *text;
+
+ while (*cmd == ' ' || *cmd == '\t') {
+ ++cmd;
+ }
+ if (*cmd == '\0') {
+ return;
+ }
+
+ uc = alloc(sizeof(*uc));
+ if (uc == NULL) {
+ panic("couldn't allocate userconf command");
+ }
+
+ len = strlen(cmd) + 1;
+ text = alloc(len);
+ if (text == NULL) {
+ panic("couldn't allocate userconf command buffer");
+ }
+ memcpy(text, cmd, len);
+
+ uc->uc_text = text;
+ TAILQ_INSERT_TAIL(&userconf_commands, uc, entries);
+}
diff -r e25f5542a1fe -r 12b64ac9f1eb sys/stand/efiboot/version
--- a/sys/stand/efiboot/version Fri Mar 25 21:16:04 2022 +0000
+++ b/sys/stand/efiboot/version Fri Mar 25 21:23:00 2022 +0000
@@ -1,4 +1,4 @@
-$NetBSD: version,v 1.29 2021/09/28 11:37:45 jmcneill Exp $
+$NetBSD: version,v 1.30 2022/03/25 21:23:00 jmcneill Exp $
NOTE ANY CHANGES YOU MAKE TO THE EFI BOOTLOADER HERE. The format of this
file is important - make sure the entries are appended on end, last item
@@ -32,3 +32,4 @@
2.9: Watchdog support.
2.10: Use disk I/O protocol for block devices.
2.11: Add support for changing the video mode.
+2.12: Add userconf support.
Home |
Main Index |
Thread Index |
Old Index