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 "boot-file" support. now one can auto...
details: https://anonhg.NetBSD.org/src/rev/00e2cadd7b9d
branches: trunk
changeset: 445384:00e2cadd7b9d
user: mrg <mrg%NetBSD.org@localhost>
date: Fri Oct 26 20:56:35 2018 +0000
description:
add "boot-file" support. now one can automatically boot a
non-default kernel with "setenv boot-file host/netbsd".
this is particularly useful with the current net / tftp
kernel boot, so the tftproot does not need a "/netbsd"
visible to all hosts, but some host-specific path.
some minor clean up.
version 1.4.
ok jmcneill@.
diffstat:
sys/stand/efiboot/boot.c | 72 ++++++++++++++++++++++++++++++--------------
sys/stand/efiboot/efiboot.h | 10 +++---
sys/stand/efiboot/version | 3 +-
3 files changed, 56 insertions(+), 29 deletions(-)
diffs (198 lines):
diff -r 7c6a4d196517 -r 00e2cadd7b9d sys/stand/efiboot/boot.c
--- a/sys/stand/efiboot/boot.c Fri Oct 26 18:16:42 2018 +0000
+++ b/sys/stand/efiboot/boot.c Fri Oct 26 20:56:35 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: boot.c,v 1.10 2018/10/12 22:08:04 jmcneill Exp $ */
+/* $NetBSD: boot.c,v 1.11 2018/10/26 20:56:35 mrg Exp $ */
/*-
* Copyright (c) 2016 Kimihiro Nonaka <nonaka%netbsd.org@localhost>
@@ -43,20 +43,23 @@
extern char twiddle_toggle;
-static const char * const names[][2] = {
- { "netbsd", "netbsd.gz" },
- { "onetbsd", "onetbsd.gz" },
- { "netbsd.old", "netbsd.old.gz" },
+static const char * const names[] = {
+ "netbsd", "netbsd.gz",
+ "onetbsd", "onetbsd.gz",
+ "netbsd.old", "netbsd.old.gz",
};
#define NUMNAMES __arraycount(names)
-#define DEFFILENAME names[0][0]
-
-#define DEFTIMEOUT 5
static char default_device[32];
static char initrd_path[255];
static char dtb_path[255];
+static char bootfile[255];
+
+#define DEFTIMEOUT 5
+#define DEFFILENAME names[0]
+
+int set_bootfile(const char *);
void command_boot(char *);
void command_dev(char *);
@@ -106,9 +109,13 @@
command_boot(char *arg)
{
char *fname = arg;
+ const char *kernel = *fname ? fname : bootfile;
char *bootargs = gettrailer(arg);
- exec_netbsd(*fname ? fname : DEFFILENAME, bootargs);
+ if (!kernel || !*kernel)
+ kernel = DEFFILENAME;
+
+ exec_netbsd(kernel, bootargs);
}
void
@@ -227,7 +234,7 @@
}
int
-set_default_device(char *arg)
+set_default_device(const char *arg)
{
if (strlen(arg) + 1 > sizeof(default_device))
return ERANGE;
@@ -242,7 +249,7 @@
}
int
-set_initrd_path(char *arg)
+set_initrd_path(const char *arg)
{
if (strlen(arg) + 1 > sizeof(initrd_path))
return ERANGE;
@@ -257,7 +264,7 @@
}
int
-set_dtb_path(char *arg)
+set_dtb_path(const char *arg)
{
if (strlen(arg) + 1 > sizeof(dtb_path))
return ERANGE;
@@ -271,6 +278,15 @@
return dtb_path;
}
+int
+set_bootfile(const char *arg)
+{
+ if (strlen(arg) + 1 > sizeof(bootfile))
+ return ERANGE;
+ strcpy(bootfile, arg);
+ return 0;
+}
+
void
print_banner(void)
{
@@ -302,6 +318,15 @@
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
@@ -318,23 +343,24 @@
int currname, c;
read_env();
-
print_banner();
+ printf("Press return to boot now, any other key for boot prompt\n");
- printf("Press return to boot now, any other key for boot prompt\n");
- for (currname = 0; currname < NUMNAMES; currname++) {
- printf("booting %s - starting in ", names[currname][0]);
+ if (bootfile[0] != '\0')
+ currname = -1;
+ else
+ currname = 0;
+
+ for (; currname < NUMNAMES; currname++) {
+ if (currname >= 0)
+ set_bootfile(names[currname]);
+ printf("booting %s - starting in ", bootfile);
c = awaitkey(DEFTIMEOUT, 1);
- if ((c != '\r') && (c != '\n') && (c != '\0')) {
+ if (c != '\r' && c != '\n' && c != '\0')
bootprompt(); /* does not return */
- }
- /*
- * try pairs of names[] entries, foo and foo.gz
- */
- exec_netbsd(names[currname][0], "");
- exec_netbsd(names[currname][1], "");
+ exec_netbsd(bootfile, "");
}
bootprompt(); /* does not return */
diff -r 7c6a4d196517 -r 00e2cadd7b9d sys/stand/efiboot/efiboot.h
--- a/sys/stand/efiboot/efiboot.h Fri Oct 26 18:16:42 2018 +0000
+++ b/sys/stand/efiboot/efiboot.h Fri Oct 26 20:56:35 2018 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: efiboot.h,v 1.7 2018/09/15 17:06:32 jmcneill Exp $ */
+/* $NetBSD: efiboot.h,v 1.8 2018/10/26 20:56:35 mrg Exp $ */
/*-
* Copyright (c) 2016 Kimihiro Nonaka <nonaka%netbsd.org@localhost>
@@ -52,13 +52,12 @@
void print_banner(void);
extern const struct boot_command commands[];
void command_help(char *);
-int set_default_device(char *);
+int set_default_device(const char *);
char *get_default_device(void);
-int set_initrd_path(char *);
+int set_initrd_path(const char *);
char *get_initrd_path(void);
-int set_dtb_path(char *);
+int set_dtb_path(const char *);
char *get_dtb_path(void);
-extern int howto;
/* console.c */
int ischar(void);
@@ -71,6 +70,7 @@
void efi_exit(void);
void efi_delay(int);
void efi_reboot(void);
+extern int howto;
/* efichar.c */
size_t ucs2len(const CHAR16 *);
diff -r 7c6a4d196517 -r 00e2cadd7b9d sys/stand/efiboot/version
--- a/sys/stand/efiboot/version Fri Oct 26 18:16:42 2018 +0000
+++ b/sys/stand/efiboot/version Fri Oct 26 20:56:35 2018 +0000
@@ -1,4 +1,4 @@
-$NetBSD: version,v 1.4 2018/10/21 00:57:38 jmcneill Exp $
+$NetBSD: version,v 1.5 2018/10/26 20:56:35 mrg 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
@@ -8,3 +8,4 @@
1.1: Add PXE booting support.
1.2: Add environment variable support.
1.3: Add ACPI support.
+1.4: Add bootfile support.
Home |
Main Index |
Thread Index |
Old Index