Module Name:    src
Committed By:   jmcneill
Date:           Sat Jun 27 17:23:08 UTC 2020

Modified Files:
        src/sys/stand/efiboot: boot.c efifile.c efifile.h

Log Message:
Load boot.cfg from the EFI system partition instead of the first FFS
partition on that device.


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/stand/efiboot/boot.c
cvs rdiff -u -r1.3 -r1.4 src/sys/stand/efiboot/efifile.c
cvs rdiff -u -r1.1 -r1.2 src/sys/stand/efiboot/efifile.h

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/stand/efiboot/boot.c
diff -u src/sys/stand/efiboot/boot.c:1.24 src/sys/stand/efiboot/boot.c:1.25
--- src/sys/stand/efiboot/boot.c:1.24	Fri Jun 26 03:23:04 2020
+++ src/sys/stand/efiboot/boot.c	Sat Jun 27 17:23:08 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: boot.c,v 1.24 2020/06/26 03:23:04 thorpej Exp $	*/
+/*	$NetBSD: boot.c,v 1.25 2020/06/27 17:23:08 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka <[email protected]>
@@ -29,6 +29,7 @@
 
 #include "efiboot.h"
 #include "efiblock.h"
+#include "efifile.h"
 #include "efifdt.h"
 #include "efiacpi.h"
 #include "efienv.h"
@@ -539,11 +540,15 @@ read_env(void)
 void
 boot(void)
 {
+	char pathbuf[80];
 	int currname, c;
 
 	read_env();
 
-	parsebootconf(BOOTCFG_FILENAME);
+	if (efi_bootdp != NULL && efi_file_path(efi_bootdp, BOOTCFG_FILENAME, pathbuf, sizeof(pathbuf)) == 0) {
+		twiddle_toggle = 1;
+		parsebootconf(pathbuf);
+	}
 
 	if (bootcfg_info.clear)
 		uefi_call_wrapper(ST->ConOut->ClearScreen, 1, ST->ConOut);
@@ -551,7 +556,6 @@ boot(void)
 	print_banner();
 
 	/* Display menu if configured */
-	twiddle_toggle = 1;
 	if (bootcfg_info.nummenu > 0) {
 		doboottypemenu();	/* No return */
 	}

Index: src/sys/stand/efiboot/efifile.c
diff -u src/sys/stand/efiboot/efifile.c:1.3 src/sys/stand/efiboot/efifile.c:1.4
--- src/sys/stand/efiboot/efifile.c:1.3	Sun Aug 26 21:28:18 2018
+++ src/sys/stand/efiboot/efifile.c	Sat Jun 27 17:23:08 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: efifile.c,v 1.3 2018/08/26 21:28:18 jmcneill Exp $ */
+/* $NetBSD: efifile.c,v 1.4 2020/06/27 17:23:08 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill <[email protected]>
@@ -146,3 +146,22 @@ efi_file_strategy(void *devdata, int rw,
 
 	return 0;
 }
+
+int
+efi_file_path(EFI_DEVICE_PATH *dp, const char *fname, char *buf, size_t buflen)
+{
+	UINTN vol;
+	int depth;
+
+	depth = efi_device_path_depth(dp, END_DEVICE_PATH_TYPE);
+
+	for (vol = 0; vol < efi_nvol; vol++) {
+		if (efi_device_path_ncmp(dp, DevicePathFromHandle(efi_vol[vol]), depth) == 0)
+			break;
+	}
+	if (vol == efi_nvol)
+		return ENOENT;
+
+	snprintf(buf, buflen, "fs%u:%s", (u_int)vol, fname);
+	return 0;
+}

Index: src/sys/stand/efiboot/efifile.h
diff -u src/sys/stand/efiboot/efifile.h:1.1 src/sys/stand/efiboot/efifile.h:1.2
--- src/sys/stand/efiboot/efifile.h:1.1	Fri Aug 24 02:01:06 2018
+++ src/sys/stand/efiboot/efifile.h	Sat Jun 27 17:23:08 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: efifile.h,v 1.1 2018/08/24 02:01:06 jmcneill Exp $ */
+/* $NetBSD: efifile.h,v 1.2 2020/06/27 17:23:08 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill <[email protected]>
@@ -31,3 +31,5 @@ void efi_file_system_probe(void);
 int efi_file_open(struct open_file *, ...);
 int efi_file_close(struct open_file *);
 int efi_file_strategy(void *, int, daddr_t, size_t, void *, size_t *);
+int efi_file_path(EFI_DEVICE_PATH *, const char *, char *, size_t);
+

Reply via email to