CVS commit: src/sys/stand/efiboot

2024-03-28 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Mar 28 18:24:57 UTC 2024

Modified Files:
src/sys/stand/efiboot: efiboot.c

Log Message:
efiboot: Duplicate efi_bootdp before we clobber it in efi_net_probe.

Patch from jakllsch@.  Makes Socionext Synquacer boot considerably
more reliably.

PR kern/58075


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/stand/efiboot/efiboot.c

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/efiboot.c
diff -u src/sys/stand/efiboot/efiboot.c:1.22 src/sys/stand/efiboot/efiboot.c:1.23
--- src/sys/stand/efiboot/efiboot.c:1.22	Wed Oct  6 10:13:19 2021
+++ src/sys/stand/efiboot/efiboot.c	Thu Mar 28 18:24:57 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: efiboot.c,v 1.22 2021/10/06 10:13:19 jmcneill Exp $ */
+/* $NetBSD: efiboot.c,v 1.23 2024/03/28 18:24:57 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -86,6 +86,8 @@ efi_main(EFI_HANDLE imageHandle, EFI_SYS
 	status = uefi_call_wrapper(BS->HandleProtocol, 3, efi_li->DeviceHandle, , (void **)_bootdp);
 	if (EFI_ERROR(status))
 		efi_bootdp = NULL;
+	else
+		efi_bootdp = DuplicateDevicePath(efi_bootdp);
 
 #ifdef EFIBOOT_DEBUG
 	Print(L"Loaded image  : 0x%" PRIxEFIPTR "\n", efi_li);



CVS commit: src/sys/stand/efiboot

2024-03-28 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Thu Mar 28 18:24:57 UTC 2024

Modified Files:
src/sys/stand/efiboot: efiboot.c

Log Message:
efiboot: Duplicate efi_bootdp before we clobber it in efi_net_probe.

Patch from jakllsch@.  Makes Socionext Synquacer boot considerably
more reliably.

PR kern/58075


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/stand/efiboot/efiboot.c

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



CVS commit: src/sys/stand/efiboot

2024-01-01 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Jan  1 13:38:57 UTC 2024

Modified Files:
src/sys/stand/efiboot: efinet.c

Log Message:
MI efiboot: Revert "Stop using efi_bootdp after exclusive open for PXE"

http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/stand/efiboot/efinet.c#rev1.7

Some UEFI implementations pass multiple boot options as boot device path,
and NULL-clearing it results in boot failures.

Thanks skrll@ for pointing it out.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/stand/efiboot/efinet.c

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



CVS commit: src/sys/stand/efiboot

2024-01-01 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Jan  1 13:38:57 UTC 2024

Modified Files:
src/sys/stand/efiboot: efinet.c

Log Message:
MI efiboot: Revert "Stop using efi_bootdp after exclusive open for PXE"

http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/stand/efiboot/efinet.c#rev1.7

Some UEFI implementations pass multiple boot options as boot device path,
and NULL-clearing it results in boot failures.

Thanks skrll@ for pointing it out.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/stand/efiboot/efinet.c

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/efinet.c
diff -u src/sys/stand/efiboot/efinet.c:1.8 src/sys/stand/efiboot/efinet.c:1.9
--- src/sys/stand/efiboot/efinet.c:1.8	Wed Dec 27 09:40:35 2023
+++ src/sys/stand/efiboot/efinet.c	Mon Jan  1 13:38:57 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: efinet.c,v 1.8 2023/12/27 09:40:35 rin Exp $	*/
+/*	$NetBSD: efinet.c,v 1.9 2024/01/01 13:38:57 rin Exp $	*/
 
 /*-
  * Copyright (c) 2001 Doug Rabson
@@ -333,7 +333,7 @@ efi_net_probe(void)
 	EFI_STATUS status;
 	UINTN i, nhandles;
 	int nifs, depth = -1;
-	bool found, is_bootdp;
+	bool found;
 
 	status = LibLocateHandle(ByProtocol, , NULL,
 	, );
@@ -377,9 +377,6 @@ efi_net_probe(void)
 		if (!found)
 			continue;
 
-		is_bootdp = depth > 0 &&
-		efi_device_path_ncmp(efi_bootdp, dp0, depth) == 0;
-
 		status = uefi_call_wrapper(BS->OpenProtocol, 6, handles[i],
 		, (void **), IH, NULL,
 		EFI_OPEN_PROTOCOL_EXCLUSIVE);
@@ -407,21 +404,10 @@ efi_net_probe(void)
 			return;
 		}
 
-		if (is_bootdp) {
-			/*
-			 * This is boot device...
-			 */
+		if (depth > 0 && efi_device_path_ncmp(efi_bootdp, dp0, depth) == 0) {
 			char devname[9];
-
 			snprintf(devname, sizeof(devname), "net%u", nifs);
 			set_default_device(devname);
-
-			/*
-			 * and now opened for us excluively. Therefore,
-			 * access via device path is illegal.
-			 */
-			efi_bootdp = NULL;
-			depth = -1;
 		}
 
 		nifs++;



CVS commit: src/sys/stand/efiboot

2023-12-27 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Dec 27 09:40:35 UTC 2023

Modified Files:
src/sys/stand/efiboot: efinet.c

Log Message:
MI efiboot: efi_net_probe: Examine Messaging Device Path also

Network devices can be found as Hardware or Messaging Device Paths,
see Sec 10.4.4 of UEFI Spec 2.10.

In addition to Hardware Device Path, try Messaging Device Path also.
This fixes PXE boot on implementations with the latter choice, e.g.,
Raspberry Pi 4 UEFI firmware.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/stand/efiboot/efinet.c

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



CVS commit: src/sys/stand/efiboot

2023-12-27 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Dec 27 09:40:35 UTC 2023

Modified Files:
src/sys/stand/efiboot: efinet.c

Log Message:
MI efiboot: efi_net_probe: Examine Messaging Device Path also

Network devices can be found as Hardware or Messaging Device Paths,
see Sec 10.4.4 of UEFI Spec 2.10.

In addition to Hardware Device Path, try Messaging Device Path also.
This fixes PXE boot on implementations with the latter choice, e.g.,
Raspberry Pi 4 UEFI firmware.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/stand/efiboot/efinet.c

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/efinet.c
diff -u src/sys/stand/efiboot/efinet.c:1.7 src/sys/stand/efiboot/efinet.c:1.8
--- src/sys/stand/efiboot/efinet.c:1.7	Wed Dec 27 09:28:04 2023
+++ src/sys/stand/efiboot/efinet.c	Wed Dec 27 09:40:35 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: efinet.c,v 1.7 2023/12/27 09:28:04 rin Exp $	*/
+/*	$NetBSD: efinet.c,v 1.8 2023/12/27 09:40:35 rin Exp $	*/
 
 /*-
  * Copyright (c) 2001 Doug Rabson
@@ -346,7 +346,15 @@ efi_net_probe(void)
 	memset(enis, 0, nhandles * sizeof(*enis));
 
 	if (efi_bootdp) {
+		/*
+		 * Either Hardware or Messaging Device Paths can be used
+		 * here, see Sec 10.4.4 of UEFI Spec 2.10. Try both.
+		 */
 		depth = efi_device_path_depth(efi_bootdp, HARDWARE_DEVICE_PATH);
+		if (depth == -1) {
+			depth = efi_device_path_depth(efi_bootdp,
+			MESSAGING_DEVICE_PATH);
+		}
 		if (depth == 0)
 			depth = 1;
 	}



CVS commit: src/sys/stand/efiboot

2023-12-27 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Dec 27 09:28:04 UTC 2023

Modified Files:
src/sys/stand/efiboot: efinet.c

Log Message:
MI efiboot: Stop using efi_bootdp after exclusive open for PXE

Once boot device is exclusively opened for Simple Network Protocol,
further access via device path (efi_bootdp) is illegal.

For some implementations, boot device path gets corrupted by
exclusive open, and subsequent access by efi_device_path_depth(),
e.g., causes infinite recursion.

Fix PXE boot for QEMU/aarch64 with EDK2 on some Linux distributions.

Thanks yamaguchi@ for comments and tests.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/stand/efiboot/efinet.c

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/efinet.c
diff -u src/sys/stand/efiboot/efinet.c:1.6 src/sys/stand/efiboot/efinet.c:1.7
--- src/sys/stand/efiboot/efinet.c:1.6	Sun Mar 31 22:24:41 2019
+++ src/sys/stand/efiboot/efinet.c	Wed Dec 27 09:28:04 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: efinet.c,v 1.6 2019/03/31 22:24:41 jmcneill Exp $	*/
+/*	$NetBSD: efinet.c,v 1.7 2023/12/27 09:28:04 rin Exp $	*/
 
 /*-
  * Copyright (c) 2001 Doug Rabson
@@ -333,7 +333,7 @@ efi_net_probe(void)
 	EFI_STATUS status;
 	UINTN i, nhandles;
 	int nifs, depth = -1;
-	bool found;
+	bool found, is_bootdp;
 
 	status = LibLocateHandle(ByProtocol, , NULL,
 	, );
@@ -369,6 +369,9 @@ efi_net_probe(void)
 		if (!found)
 			continue;
 
+		is_bootdp = depth > 0 &&
+		efi_device_path_ncmp(efi_bootdp, dp0, depth) == 0;
+
 		status = uefi_call_wrapper(BS->OpenProtocol, 6, handles[i],
 		, (void **), IH, NULL,
 		EFI_OPEN_PROTOCOL_EXCLUSIVE);
@@ -396,10 +399,21 @@ efi_net_probe(void)
 			return;
 		}
 
-		if (depth > 0 && efi_device_path_ncmp(efi_bootdp, dp0, depth) == 0) {
+		if (is_bootdp) {
+			/*
+			 * This is boot device...
+			 */
 			char devname[9];
+
 			snprintf(devname, sizeof(devname), "net%u", nifs);
 			set_default_device(devname);
+
+			/*
+			 * and now opened for us excluively. Therefore,
+			 * access via device path is illegal.
+			 */
+			efi_bootdp = NULL;
+			depth = -1;
 		}
 
 		nifs++;



CVS commit: src/sys/stand/efiboot

2023-12-27 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Dec 27 09:28:04 UTC 2023

Modified Files:
src/sys/stand/efiboot: efinet.c

Log Message:
MI efiboot: Stop using efi_bootdp after exclusive open for PXE

Once boot device is exclusively opened for Simple Network Protocol,
further access via device path (efi_bootdp) is illegal.

For some implementations, boot device path gets corrupted by
exclusive open, and subsequent access by efi_device_path_depth(),
e.g., causes infinite recursion.

Fix PXE boot for QEMU/aarch64 with EDK2 on some Linux distributions.

Thanks yamaguchi@ for comments and tests.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/stand/efiboot/efinet.c

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



CVS commit: src/sys/stand/efiboot

2023-06-14 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Jun 15 03:20:59 UTC 2023

Modified Files:
src/sys/stand/efiboot: Makefile.efiboot

Log Message:
Add missing include paths for libz. Not used at the moment although.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/stand/efiboot/Makefile.efiboot

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/Makefile.efiboot
diff -u src/sys/stand/efiboot/Makefile.efiboot:1.28 src/sys/stand/efiboot/Makefile.efiboot:1.29
--- src/sys/stand/efiboot/Makefile.efiboot:1.28	Sat Jun  3 21:26:29 2023
+++ src/sys/stand/efiboot/Makefile.efiboot	Thu Jun 15 03:20:58 2023
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.efiboot,v 1.28 2023/06/03 21:26:29 lukem Exp $
+# $NetBSD: Makefile.efiboot,v 1.29 2023/06/15 03:20:58 rin Exp $
 
 S=		${.CURDIR}/../../..
 
@@ -132,6 +132,7 @@ LIBKERN= ${KERNLIB}
 ### find out what to use for libz
 Z_AS= library
 .include "${S}/lib/libz/Makefile.inc"
+CPPFLAGS+=	-I${S}/lib/libz -I${S}/../common/dist/zlib
 LIBZ= ${ZLIB}
 
 ### find out what to use for libgnuefi



CVS commit: src/sys/stand/efiboot

2023-06-14 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Jun 15 03:20:59 UTC 2023

Modified Files:
src/sys/stand/efiboot: Makefile.efiboot

Log Message:
Add missing include paths for libz. Not used at the moment although.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/stand/efiboot/Makefile.efiboot

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



CVS commit: src/sys/stand/efiboot

2023-06-14 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Jun 14 10:26:46 UTC 2023

Modified Files:
src/sys/stand/efiboot: exec.c

Log Message:
Use %zd instead of %ld for ssize_t.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/stand/efiboot/exec.c

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



CVS commit: src/sys/stand/efiboot

2023-06-14 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Jun 14 10:26:46 UTC 2023

Modified Files:
src/sys/stand/efiboot: exec.c

Log Message:
Use %zd instead of %ld for ssize_t.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/stand/efiboot/exec.c

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/exec.c
diff -u src/sys/stand/efiboot/exec.c:1.23 src/sys/stand/efiboot/exec.c:1.24
--- src/sys/stand/efiboot/exec.c:1.23	Wed Oct  6 10:13:19 2021
+++ src/sys/stand/efiboot/exec.c	Wed Jun 14 10:26:45 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: exec.c,v 1.23 2021/10/06 10:13:19 jmcneill Exp $ */
+/* $NetBSD: exec.c,v 1.24 2023/06/14 10:26:45 rin Exp $ */
 
 /*-
  * Copyright (c) 2019 Jason R. Thorpe
@@ -109,7 +109,7 @@ load_file(const char *path, u_long extra
 		if (len < 0) {
 			printf(": %s\n", strerror(errno));
 		} else {
-			printf(": returned %ld (expected %ld)\n", len,
+			printf(": returned %zd (expected %zd)\n", len,
 			expectedlen);
 		}
 		return EIO;



CVS commit: src/sys/stand/efiboot

2023-06-13 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Jun 14 00:52:25 UTC 2023

Modified Files:
src/sys/stand/efiboot: efiblock.c

Log Message:
Avoid void * pointer arithmetic; cast to UINT8 * explicitly.
No binary changes for aarch64 at least.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/stand/efiboot/efiblock.c

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/efiblock.c
diff -u src/sys/stand/efiboot/efiblock.c:1.19 src/sys/stand/efiboot/efiblock.c:1.20
--- src/sys/stand/efiboot/efiblock.c:1.19	Sun Apr 24 06:49:38 2022
+++ src/sys/stand/efiboot/efiblock.c	Wed Jun 14 00:52:25 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: efiblock.c,v 1.19 2022/04/24 06:49:38 mlelstv Exp $ */
+/* $NetBSD: efiblock.c,v 1.20 2023/06/14 00:52:25 rin Exp $ */
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -442,7 +442,7 @@ efi_block_find_partitions_gpt(struct efi
 	}
 
 	for (entry = 0; entry < le32toh(hdr.hdr_entries); entry++) {
-		memcpy(, buf + (entry * le32toh(hdr.hdr_entsz)),
+		memcpy(, (UINT8 *)buf + (entry * le32toh(hdr.hdr_entsz)),
 			sizeof(ent));
 		efi_block_find_partitions_gpt_entry(bdev, , , entry);
 	}



CVS commit: src/sys/stand/efiboot

2023-06-13 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Jun 14 00:52:25 UTC 2023

Modified Files:
src/sys/stand/efiboot: efiblock.c

Log Message:
Avoid void * pointer arithmetic; cast to UINT8 * explicitly.
No binary changes for aarch64 at least.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/stand/efiboot/efiblock.c

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



CVS commit: src/sys/stand/efiboot

2023-06-13 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Jun 14 00:42:21 UTC 2023

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

Log Message:
Add missing member for terminating sentinel.


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/sys/stand/efiboot/boot.c

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.44 src/sys/stand/efiboot/boot.c:1.45
--- src/sys/stand/efiboot/boot.c:1.44	Sun Aug 14 11:26:41 2022
+++ src/sys/stand/efiboot/boot.c	Wed Jun 14 00:42:21 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: boot.c,v 1.44 2022/08/14 11:26:41 jmcneill Exp $	*/
+/*	$NetBSD: boot.c,v 1.45 2023/06/14 00:42:21 rin Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -148,7 +148,7 @@ const struct boot_command commands[] = {
 	{ "help",	command_help,		"help|?" },
 	{ "?",		command_help,		NULL },
 	{ "quit",	command_quit,		"quit" },
-	{ NULL,		NULL },
+	{ NULL,		NULL,			NULL },
 };
 
 static int



CVS commit: src/sys/stand/efiboot

2023-06-13 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Wed Jun 14 00:42:21 UTC 2023

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

Log Message:
Add missing member for terminating sentinel.


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/sys/stand/efiboot/boot.c

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



CVS commit: src/sys/stand/efiboot

2022-09-21 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Sep 21 14:30:01 UTC 2022

Modified Files:
src/sys/stand/efiboot: module.c

Log Message:
efiboot: Handle 9.99.100 by taking four, not two, digits.

We haven't used the revision part of __NetBSD_Version__ = MMmmrrpp00
in almos two decades so we're apparently reclaiming it as MMmm00.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/stand/efiboot/module.c

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



CVS commit: src/sys/stand/efiboot

2022-09-21 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Wed Sep 21 14:30:01 UTC 2022

Modified Files:
src/sys/stand/efiboot: module.c

Log Message:
efiboot: Handle 9.99.100 by taking four, not two, digits.

We haven't used the revision part of __NetBSD_Version__ = MMmmrrpp00
in almos two decades so we're apparently reclaiming it as MMmm00.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/stand/efiboot/module.c

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/module.c
diff -u src/sys/stand/efiboot/module.c:1.1 src/sys/stand/efiboot/module.c:1.2
--- src/sys/stand/efiboot/module.c:1.1	Sun Jun 21 17:24:26 2020
+++ src/sys/stand/efiboot/module.c	Wed Sep 21 14:30:01 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: module.c,v 1.1 2020/06/21 17:24:26 jmcneill Exp $ */
+/* $NetBSD: module.c,v 1.2 2022/09/21 14:30:01 riastradh Exp $ */
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -62,7 +62,7 @@ module_set_prefix(const char *kernel_pat
 #else
 	const u_int vmajor = netbsd_version / 1;
 	const u_int vminor = netbsd_version / 100 % 100;
-	const u_int vpatch = netbsd_version / 100 % 100;
+	const u_int vpatch = netbsd_version / 100 % 1;
 
 	if (vminor == 99) {
 		snprintf(module_prefix, sizeof(module_prefix),



CVS commit: src/sys/stand/efiboot

2022-08-14 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Aug 14 11:26:41 UTC 2022

Modified Files:
src/sys/stand/efiboot: boot.c efiacpi.c efiboot.h efifdt.c efigop.c
efirng.c
src/sys/stand/efiboot/bootaa64: efibootaa64.c

Log Message:
Align output of "version" command.


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sys/stand/efiboot/boot.c
cvs rdiff -u -r1.12 -r1.13 src/sys/stand/efiboot/efiacpi.c
cvs rdiff -u -r1.19 -r1.20 src/sys/stand/efiboot/efiboot.h
cvs rdiff -u -r1.34 -r1.35 src/sys/stand/efiboot/efifdt.c
cvs rdiff -u -r1.2 -r1.3 src/sys/stand/efiboot/efigop.c
cvs rdiff -u -r1.3 -r1.4 src/sys/stand/efiboot/efirng.c
cvs rdiff -u -r1.5 -r1.6 src/sys/stand/efiboot/bootaa64/efibootaa64.c

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.43 src/sys/stand/efiboot/boot.c:1.44
--- src/sys/stand/efiboot/boot.c:1.43	Fri Mar 25 21:23:00 2022
+++ src/sys/stand/efiboot/boot.c	Sun Aug 14 11:26:41 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: boot.c,v 1.43 2022/03/25 21:23:00 jmcneill Exp $	*/
+/*	$NetBSD: boot.c,v 1.44 2022/08/14 11:26:41 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -380,6 +380,18 @@ command_menu(char *arg)
 }
 
 void
+command_printtab(const char *key, const char *fmt, ...)
+{
+	va_list ap;
+
+	printf("%-16s: ", key);
+
+	va_start(ap, fmt);
+	vprintf(fmt, ap);
+	va_end(ap);
+}
+
+void
 command_version(char *arg)
 {
 	char pathbuf[80];
@@ -387,23 +399,26 @@ command_version(char *arg)
 	const UINT64 *osindsup;
 	int rv;
 
-	printf("Version: %s (%s)\n", bootprog_rev, bootprog_kernrev);
-	printf("EFI: %d.%02d\n",
+	command_printtab("Version", "%s (%s)\n",
+	bootprog_rev, bootprog_kernrev);
+	command_printtab("EFI", "%d.%02d\n",
 	ST->Hdr.Revision >> 16, ST->Hdr.Revision & 0x);
+
 	ufirmware = NULL;
 	rv = ucs2_to_utf8(ST->FirmwareVendor, );
 	if (rv == 0) {
-		printf("Firmware: %s (rev 0x%x)\n", ufirmware,
+		command_printtab("Firmware", "%s (rev 0x%x)\n", ufirmware,
 		ST->FirmwareRevision);
 		FreePool(ufirmware);
 	}
 	if (bootcfg_path(pathbuf, sizeof(pathbuf)) == 0) {
-		printf("Config path: %s\n", pathbuf);
+		command_printtab("Config path", "%s\n", pathbuf);
 	}
 
 	osindsup = LibGetVariable(L"OsIndicationsSupported", );
 	if (osindsup != NULL) {
-		printf("UEFI OS indications supported: 0x%" PRIx64 "\n", *osindsup);
+		command_printtab("OS Indications", "0x%" PRIx64 "\n",
+		*osindsup);
 	}
 
 #ifdef EFIBOOT_FDT

Index: src/sys/stand/efiboot/efiacpi.c
diff -u src/sys/stand/efiboot/efiacpi.c:1.12 src/sys/stand/efiboot/efiacpi.c:1.13
--- src/sys/stand/efiboot/efiacpi.c:1.12	Wed Nov  3 22:02:36 2021
+++ src/sys/stand/efiboot/efiacpi.c	Sun Aug 14 11:26:41 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: efiacpi.c,v 1.12 2021/11/03 22:02:36 skrll Exp $ */
+/* $NetBSD: efiacpi.c,v 1.13 2022/08/14 11:26:41 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -145,13 +145,15 @@ efi_acpi_show(void)
 {
 	struct acpi_rdsp *rsdp = acpi_root;
 
-	if (!efi_acpi_available())
+	if (!efi_acpi_available()) {
 		return;
+	}
 
-	printf("ACPI: v%02d %c%c%c%c%c%c\n", rsdp->revision,
+	command_printtab("ACPI", "v%02d %c%c%c%c%c%c\n", rsdp->revision,
 	rsdp->oemid[0], rsdp->oemid[1], rsdp->oemid[2],
 	rsdp->oemid[3], rsdp->oemid[4], rsdp->oemid[5]);
 
-	if (smbios_table)
-		printf("SMBIOS: %s\n", efi_acpi_get_model());
+	if (smbios_table) {
+		command_printtab("SMBIOS", "%s\n", efi_acpi_get_model());
+	}
 }

Index: src/sys/stand/efiboot/efiboot.h
diff -u src/sys/stand/efiboot/efiboot.h:1.19 src/sys/stand/efiboot/efiboot.h:1.20
--- src/sys/stand/efiboot/efiboot.h:1.19	Fri Mar 25 21:23:00 2022
+++ src/sys/stand/efiboot/efiboot.h	Sun Aug 14 11:26:41 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: efiboot.h,v 1.19 2022/03/25 21:23:00 jmcneill Exp $	*/
+/*	$NetBSD: efiboot.h,v 1.20 2022/08/14 11:26:41 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -58,6 +58,7 @@ void boot(void);
 void clearit(void);
 extern const struct boot_command commands[];
 void command_help(char *);
+void command_printtab(const char *, const char *, ...);
 int set_default_device(const char *);
 char *get_default_device(void);
 void set_default_fstype(int);

Index: src/sys/stand/efiboot/efifdt.c
diff -u src/sys/stand/efiboot/efifdt.c:1.34 src/sys/stand/efiboot/efifdt.c:1.35
--- src/sys/stand/efiboot/efifdt.c:1.34	Fri Mar 25 21:23:00 2022
+++ src/sys/stand/efiboot/efifdt.c	Sun Aug 14 11:26:41 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: efifdt.c,v 1.34 2022/03/25 21:23:00 jmcneill Exp $ */
+/* $NetBSD: efifdt.c,v 1.35 2022/08/14 11:26:41 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2019 Jason R. Thorpe
@@ -205,12 +205,14 @@ efi_fdt_show(void)
 	const char *model, *compat;
 	int n, ncompat;
 
-	if (fdt_data == NULL)
+	if (fdt_data == NULL) {
 		return;
+	}
 
 	model = fdt_getprop(fdt_data, 

CVS commit: src/sys/stand/efiboot

2022-08-14 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Aug 14 11:26:41 UTC 2022

Modified Files:
src/sys/stand/efiboot: boot.c efiacpi.c efiboot.h efifdt.c efigop.c
efirng.c
src/sys/stand/efiboot/bootaa64: efibootaa64.c

Log Message:
Align output of "version" command.


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 src/sys/stand/efiboot/boot.c
cvs rdiff -u -r1.12 -r1.13 src/sys/stand/efiboot/efiacpi.c
cvs rdiff -u -r1.19 -r1.20 src/sys/stand/efiboot/efiboot.h
cvs rdiff -u -r1.34 -r1.35 src/sys/stand/efiboot/efifdt.c
cvs rdiff -u -r1.2 -r1.3 src/sys/stand/efiboot/efigop.c
cvs rdiff -u -r1.3 -r1.4 src/sys/stand/efiboot/efirng.c
cvs rdiff -u -r1.5 -r1.6 src/sys/stand/efiboot/bootaa64/efibootaa64.c

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



CVS commit: src/sys/stand/efiboot

2022-04-24 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Apr 24 06:49:38 UTC 2022

Modified Files:
src/sys/stand/efiboot: conf.c efiblock.c efiblock.h

Log Message:
Use physical sector size as unit for disk addresses.
Provide new ioctl to libsa to query for sector size.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/stand/efiboot/conf.c
cvs rdiff -u -r1.18 -r1.19 src/sys/stand/efiboot/efiblock.c
cvs rdiff -u -r1.6 -r1.7 src/sys/stand/efiboot/efiblock.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/conf.c
diff -u src/sys/stand/efiboot/conf.c:1.5 src/sys/stand/efiboot/conf.c:1.6
--- src/sys/stand/efiboot/conf.c:1.5	Sun Oct 11 14:03:33 2020
+++ src/sys/stand/efiboot/conf.c	Sun Apr 24 06:49:38 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: conf.c,v 1.5 2020/10/11 14:03:33 jmcneill Exp $ */
+/* $NetBSD: conf.c,v 1.6 2022/04/24 06:49:38 mlelstv Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -41,7 +41,7 @@
 
 struct devsw devsw[] = {
 	{ "efifile", efi_file_strategy, efi_file_open, efi_file_close, noioctl },
-	{ "efiblock", efi_block_strategy, efi_block_open, efi_block_close, noioctl },
+	{ "efiblock", efi_block_strategy, efi_block_open, efi_block_close, efi_block_ioctl },
 	{ "net", net_strategy, net_open, net_close, noioctl },
 };
 int ndevs = __arraycount(devsw);

Index: src/sys/stand/efiboot/efiblock.c
diff -u src/sys/stand/efiboot/efiblock.c:1.18 src/sys/stand/efiboot/efiblock.c:1.19
--- src/sys/stand/efiboot/efiblock.c:1.18	Sat Oct 30 11:18:51 2021
+++ src/sys/stand/efiboot/efiblock.c	Sun Apr 24 06:49:38 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: efiblock.c,v 1.18 2021/10/30 11:18:51 jmcneill Exp $ */
+/* $NetBSD: efiblock.c,v 1.19 2022/04/24 06:49:38 mlelstv Exp $ */
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -129,20 +129,21 @@ efi_block_do_read_blockio(struct efi_blo
 	EFI_STATUS status;
 	EFI_LBA lba_start, lba_end;
 	UINT64 blkbuf_offset;
-	UINT64 blkbuf_size;
+	UINT64 blkbuf_size, alloc_size;
 
 	lba_start = off / bdev->bio->Media->BlockSize;
-	lba_end = (off + bufsize + bdev->bio->Media->BlockSize - 1) /
-	bdev->bio->Media->BlockSize;
+	lba_end = (off + bufsize - 1) / bdev->bio->Media->BlockSize;
 	blkbuf_offset = off % bdev->bio->Media->BlockSize;
-	blkbuf_size = (lba_end - lba_start) * bdev->bio->Media->BlockSize;
+	blkbuf_size = (lba_end - lba_start + 1) * bdev->bio->Media->BlockSize;
+
+	alloc_size = blkbuf_size;
 	if (bdev->bio->Media->IoAlign > 1) {
-		blkbuf_size = (blkbuf_size + bdev->bio->Media->IoAlign - 1) /
+		alloc_size = (blkbuf_size + bdev->bio->Media->IoAlign - 1) /
 		bdev->bio->Media->IoAlign *
 		bdev->bio->Media->IoAlign;
 	}
 
-	blkbuf = AllocatePool(blkbuf_size);
+	blkbuf = AllocatePool(alloc_size);
 	if (blkbuf == NULL) {
 		return EFI_OUT_OF_RESOURCES;
 	}
@@ -285,18 +286,16 @@ efi_block_find_partitions_disklabel(stru
 struct mbr_sector *mbr, uint32_t start, uint32_t size)
 {
 	struct efi_block_part *bpart;
-	char buf[DEV_BSIZE];
+	char buf[DEV_BSIZE]; /* XXX, arbitrary size >= struct disklabel */
 	struct disklabel d;
 	struct partition *p;
 	EFI_STATUS status;
 	int n;
 
 	status = efi_block_read(bdev,
-	((EFI_LBA)start + LABELSECTOR) * DEV_BSIZE, buf, sizeof(buf));
-	if (EFI_ERROR(status) || getdisklabel(buf, ) != NULL) {
-		FreePool(buf);
+	((EFI_LBA)start + LABELSECTOR) * bdev->bio->Media->BlockSize, buf, sizeof(buf));
+	if (EFI_ERROR(status) || getdisklabel(buf, ) != NULL)
 		return EIO;
-	}
 
 	if (le32toh(d.d_magic) != DISKMAGIC || le32toh(d.d_magic2) != DISKMAGIC)
 		return EINVAL;
@@ -419,7 +418,7 @@ efi_block_find_partitions_gpt(struct efi
 	void *buf;
 	UINTN sz;
 
-	status = efi_block_read(bdev, GPT_HDR_BLKNO * DEV_BSIZE, ,
+	status = efi_block_read(bdev, (EFI_LBA)GPT_HDR_BLKNO * bdev->bio->Media->BlockSize, ,
 	sizeof(hdr));
 	if (EFI_ERROR(status)) {
 		return EIO;
@@ -436,7 +435,7 @@ efi_block_find_partitions_gpt(struct efi
 		return ENOMEM;
 
 	status = efi_block_read(bdev,
-	le64toh(hdr.hdr_lba_table) * DEV_BSIZE, buf, sz);
+	le64toh(hdr.hdr_lba_table) * bdev->bio->Media->BlockSize, buf, sz);
 	if (EFI_ERROR(status)) {
 		FreePool(buf);
 		return EIO;
@@ -682,6 +681,7 @@ int
 efi_block_strategy(void *devdata, int rw, daddr_t dblk, size_t size, void *buf, size_t *rsize)
 {
 	struct efi_block_part *bpart = devdata;
+	struct efi_block_dev *bdev = bpart->bdev;
 	EFI_STATUS status;
 	UINT64 off;
 
@@ -692,13 +692,13 @@ efi_block_strategy(void *devdata, int rw
 
 	switch (bpart->type) {
 	case EFI_BLOCK_PART_DISKLABEL:
-		off = (dblk + bpart->disklabel.part.p_offset) * DEV_BSIZE;
+		off = ((EFI_LBA)dblk + bpart->disklabel.part.p_offset) * bdev->bio->Media->BlockSize;
 		break;
 	case EFI_BLOCK_PART_GPT:
-		off = (dblk + le64toh(bpart->gpt.ent.ent_lba_start)) * DEV_BSIZE;
+		off = ((EFI_LBA)dblk + le64toh(bpart->gpt.ent.ent_lba_start)) * bdev->bio->Media->BlockSize;
 		break;
 	case 

CVS commit: src/sys/stand/efiboot

2022-04-24 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Apr 24 06:49:38 UTC 2022

Modified Files:
src/sys/stand/efiboot: conf.c efiblock.c efiblock.h

Log Message:
Use physical sector size as unit for disk addresses.
Provide new ioctl to libsa to query for sector size.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/stand/efiboot/conf.c
cvs rdiff -u -r1.18 -r1.19 src/sys/stand/efiboot/efiblock.c
cvs rdiff -u -r1.6 -r1.7 src/sys/stand/efiboot/efiblock.h

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



CVS commit: src/sys/stand/efiboot

2022-03-25 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Mar 25 21:23:00 UTC 2022

Modified Files:
src/sys/stand/efiboot: Makefile.efiboot boot.c bootmenu.c efiboot.h
efifdt.c efifdt.h version
Added Files:
src/sys/stand/efiboot: userconf.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/stand/efiboot/Makefile.efiboot
cvs rdiff -u -r1.42 -r1.43 src/sys/stand/efiboot/boot.c
cvs rdiff -u -r1.3 -r1.4 src/sys/stand/efiboot/bootmenu.c
cvs rdiff -u -r1.18 -r1.19 src/sys/stand/efiboot/efiboot.h
cvs rdiff -u -r1.33 -r1.34 src/sys/stand/efiboot/efifdt.c
cvs rdiff -u -r1.11 -r1.12 src/sys/stand/efiboot/efifdt.h
cvs rdiff -u -r0 -r1.1 src/sys/stand/efiboot/userconf.c
cvs rdiff -u -r1.29 -r1.30 src/sys/stand/efiboot/version

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/Makefile.efiboot
diff -u src/sys/stand/efiboot/Makefile.efiboot:1.25 src/sys/stand/efiboot/Makefile.efiboot:1.26
--- src/sys/stand/efiboot/Makefile.efiboot:1.25	Sun Oct 17 14:12:54 2021
+++ src/sys/stand/efiboot/Makefile.efiboot	Fri Mar 25 21:23:00 2022
@@ -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 @@ AFLAGS.start.S= ${${ACTIVE_CC} == "clang
 .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

Index: src/sys/stand/efiboot/boot.c
diff -u src/sys/stand/efiboot/boot.c:1.42 src/sys/stand/efiboot/boot.c:1.43
--- src/sys/stand/efiboot/boot.c:1.42	Thu Nov  4 07:28:34 2021
+++ src/sys/stand/efiboot/boot.c	Fri Mar 25 21:23:00 2022
@@ -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 
@@ -114,6 +114,7 @@ void	command_mem(char *);
 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 @@ const struct boot_command commands[] = {
 	{ "reboot",	command_reset,		"reboot|reset" },
 	{ "reset",	command_reset,		NULL },
 	{ "setup",	command_setup,		"setup" },
+	{ "userconf",	command_userconf,	"userconf " },
 	{ "version",	command_version,	"version" },
 	{ "ver",	command_version,	NULL },
 	{ "help",	command_help,		"help|?" },
@@ -450,6 +452,12 @@ command_setup(char *arg)
 	efi_reboot();
 }
 
+void
+command_userconf(char *arg)
+{
+	userconf_add(arg);
+}
+
 int
 set_default_device(const char *arg)
 {

Index: src/sys/stand/efiboot/bootmenu.c
diff -u src/sys/stand/efiboot/bootmenu.c:1.3 src/sys/stand/efiboot/bootmenu.c:1.4
--- src/sys/stand/efiboot/bootmenu.c:1.3	Wed Oct  6 10:13:19 2021
+++ src/sys/stand/efiboot/bootmenu.c	Fri Mar 25 21:23:00 2022
@@ -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 @@ do_bootcfg_command(const char *cmd, char
 {
 	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);

Index: src/sys/stand/efiboot/efiboot.h
diff -u src/sys/stand/efiboot/efiboot.h:1.18 src/sys/stand/efiboot/efiboot.h:1.19
--- src/sys/stand/efiboot/efiboot.h:1.18	Wed Oct  6 10:13:19 2021
+++ src/sys/stand/efiboot/efiboot.h	Fri Mar 25 21:23:00 2022
@@ -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 
@@ -131,3 +131,7 @@ char *gettrailer(char *);
 void docommand(char *);
 char awaitkey(int, int);
 __dead void bootprompt(void);
+
+/* userconf.c */
+void userconf_add(const char *);
+void userconf_foreach(void (*)(const char *));

Index: src/sys/stand/efiboot/efifdt.c
diff -u src/sys/stand/efiboot/efifdt.c:1.33 src/sys/stand/efiboot/efifdt.c:1.34
--- src/sys/stand/efiboot/efifdt.c:1.33	Sat Nov  6 19:44:22 2021
+++ src/sys/stand/efiboot/efifdt.c	Fri Mar 25 21:23:00 2022
@@ -1,4 +1,4 @@
-/* $NetBSD: efifdt.c,v 1.33 2021/11/06 19:44:22 

CVS commit: src/sys/stand/efiboot

2022-03-25 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Mar 25 21:23:00 UTC 2022

Modified Files:
src/sys/stand/efiboot: Makefile.efiboot boot.c bootmenu.c efiboot.h
efifdt.c efifdt.h version
Added Files:
src/sys/stand/efiboot: userconf.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/stand/efiboot/Makefile.efiboot
cvs rdiff -u -r1.42 -r1.43 src/sys/stand/efiboot/boot.c
cvs rdiff -u -r1.3 -r1.4 src/sys/stand/efiboot/bootmenu.c
cvs rdiff -u -r1.18 -r1.19 src/sys/stand/efiboot/efiboot.h
cvs rdiff -u -r1.33 -r1.34 src/sys/stand/efiboot/efifdt.c
cvs rdiff -u -r1.11 -r1.12 src/sys/stand/efiboot/efifdt.h
cvs rdiff -u -r0 -r1.1 src/sys/stand/efiboot/userconf.c
cvs rdiff -u -r1.29 -r1.30 src/sys/stand/efiboot/version

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



CVS commit: src/sys/stand/efiboot

2021-11-06 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Nov  6 19:44:22 UTC 2021

Modified Files:
src/sys/stand/efiboot: efifdt.c

Log Message:
Revert part of previous commit that broke DT booting.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/stand/efiboot/efifdt.c

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/efifdt.c
diff -u src/sys/stand/efiboot/efifdt.c:1.32 src/sys/stand/efiboot/efifdt.c:1.33
--- src/sys/stand/efiboot/efifdt.c:1.32	Wed Nov  3 22:02:36 2021
+++ src/sys/stand/efiboot/efifdt.c	Sat Nov  6 19:44:22 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: efifdt.c,v 1.32 2021/11/03 22:02:36 skrll Exp $ */
+/* $NetBSD: efifdt.c,v 1.33 2021/11/06 19:44:22 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2019 Jason R. Thorpe
@@ -594,11 +594,7 @@ arch_prepare_boot(const char *fname, con
 		}
 	} else
 #endif
-	if (!dtb_addr || efi_fdt_set_data((void *)(uintptr_t)dtb_addr) != 0) {
-		if (!dtb_addr)
-			printf("boot: no DTB provided\n");
-		else
-			printf("boot: invalid DTB data\n");
+	if (dtb_addr && efi_fdt_set_data((void *)(uintptr_t)dtb_addr) != 0) {
 		return EINVAL;
 	}
 



CVS commit: src/sys/stand/efiboot

2021-11-06 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Nov  6 19:44:22 UTC 2021

Modified Files:
src/sys/stand/efiboot: efifdt.c

Log Message:
Revert part of previous commit that broke DT booting.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/stand/efiboot/efifdt.c

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



CVS commit: src/sys/stand/efiboot

2021-11-04 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Nov  4 07:28:34 UTC 2021

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

Log Message:
Fix non-ACPI builds.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/stand/efiboot/boot.c

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.41 src/sys/stand/efiboot/boot.c:1.42
--- src/sys/stand/efiboot/boot.c:1.41	Wed Nov  3 22:02:36 2021
+++ src/sys/stand/efiboot/boot.c	Thu Nov  4 07:28:34 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: boot.c,v 1.41 2021/11/03 22:02:36 skrll Exp $	*/
+/*	$NetBSD: boot.c,v 1.42 2021/11/04 07:28:34 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -93,7 +93,9 @@ static char rndseed_path[255];
 int	set_bootfile(const char *);
 int	set_bootargs(const char *);
 
+#ifdef EFIBOOT_ACPI
 void	command_acpi(char *);
+#endif
 void	command_boot(char *);
 void	command_dev(char *);
 void	command_initrd(char *);
@@ -116,7 +118,9 @@ void	command_version(char *);
 void	command_quit(char *);
 
 const struct boot_command commands[] = {
+#ifdef EFIBOOT_ACPI
 	{ "acpi",	command_acpi,		"acpi [{on|off}]" },
+#endif
 	{ "boot",	command_boot,		"boot [dev:][filename] [args]\n (ex. \"hd0a:\\netbsd.old -s\"" },
 	{ "dev",	command_dev,		"dev" },
 #ifdef EFIBOOT_FDT
@@ -174,6 +178,7 @@ command_help(char *arg)
 	}
 }
 
+#ifdef EFIBOOT_ACPI
 void
 command_acpi(char *arg)
 {
@@ -191,6 +196,8 @@ command_acpi(char *arg)
 		efi_acpi_enabled() ? "en" : "dis");
 	}
 }
+#endif
+
 void
 command_boot(char *arg)
 {



CVS commit: src/sys/stand/efiboot

2021-11-04 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Thu Nov  4 07:28:34 UTC 2021

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

Log Message:
Fix non-ACPI builds.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 src/sys/stand/efiboot/boot.c

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



CVS commit: src/sys/stand/efiboot

2021-11-03 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Nov  3 22:02:36 UTC 2021

Modified Files:
src/sys/stand/efiboot: boot.c efiacpi.c efifdt.c

Log Message:
Provide the ablity to ignore ACPI with an 'acpi' command:

acpi [{on|off}]


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/stand/efiboot/boot.c
cvs rdiff -u -r1.11 -r1.12 src/sys/stand/efiboot/efiacpi.c
cvs rdiff -u -r1.31 -r1.32 src/sys/stand/efiboot/efifdt.c

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.40 src/sys/stand/efiboot/boot.c:1.41
--- src/sys/stand/efiboot/boot.c:1.40	Sun Oct 17 14:12:54 2021
+++ src/sys/stand/efiboot/boot.c	Wed Nov  3 22:02:36 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: boot.c,v 1.40 2021/10/17 14:12:54 jmcneill Exp $	*/
+/*	$NetBSD: boot.c,v 1.41 2021/11/03 22:02:36 skrll Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -93,6 +93,7 @@ static char rndseed_path[255];
 int	set_bootfile(const char *);
 int	set_bootargs(const char *);
 
+void	command_acpi(char *);
 void	command_boot(char *);
 void	command_dev(char *);
 void	command_initrd(char *);
@@ -115,6 +116,7 @@ void	command_version(char *);
 void	command_quit(char *);
 
 const struct boot_command commands[] = {
+	{ "acpi",	command_acpi,		"acpi [{on|off}]" },
 	{ "boot",	command_boot,		"boot [dev:][filename] [args]\n (ex. \"hd0a:\\netbsd.old -s\"" },
 	{ "dev",	command_dev,		"dev" },
 #ifdef EFIBOOT_FDT
@@ -173,6 +175,23 @@ command_help(char *arg)
 }
 
 void
+command_acpi(char *arg)
+{
+	if (arg && *arg) {
+		if (strcmp(arg, "on") == 0)
+			efi_acpi_enable(1);
+		else if (strcmp(arg, "off") == 0)
+			efi_acpi_enable(0);
+		else {
+			command_help("");
+			return;
+		}
+	} else {
+		printf("ACPI support is %sabled\n",
+		efi_acpi_enabled() ? "en" : "dis");
+	}
+}
+void
 command_boot(char *arg)
 {
 	char *fname = arg;

Index: src/sys/stand/efiboot/efiacpi.c
diff -u src/sys/stand/efiboot/efiacpi.c:1.11 src/sys/stand/efiboot/efiacpi.c:1.12
--- src/sys/stand/efiboot/efiacpi.c:1.11	Wed Oct  6 10:13:19 2021
+++ src/sys/stand/efiboot/efiacpi.c	Wed Nov  3 22:02:36 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: efiacpi.c,v 1.11 2021/10/06 10:13:19 jmcneill Exp $ */
+/* $NetBSD: efiacpi.c,v 1.12 2021/11/03 22:02:36 skrll Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -49,10 +49,11 @@ static EFI_GUID Acpi20TableGuid = ACPI_2
 static EFI_GUID Smbios3TableGuid = SMBIOS3_TABLE_GUID;
 static EFI_GUID SmbiosTableGuid = SMBIOS_TABLE_GUID;
 
-static int acpi_enable = 1;
 static void *acpi_root = NULL;
 static void *smbios_table = NULL;
 
+static int acpi_enabled = 1;
+
 int
 efi_acpi_probe(void)
 {
@@ -76,19 +77,13 @@ efi_acpi_probe(void)
 int
 efi_acpi_available(void)
 {
-	return acpi_root != NULL;
+	return acpi_root != NULL && acpi_enabled;
 }
 
 int
 efi_acpi_enabled(void)
 {
-	return acpi_enable;
-}
-
-void
-efi_acpi_enable(int enable)
-{
-	acpi_enable = enable;
+	return acpi_enabled;
 }
 
 void *
@@ -105,6 +100,15 @@ efi_acpi_smbios(void)
 
 static char model_buf[128];
 
+void
+efi_acpi_enable(int val)
+{
+	if (acpi_root == NULL) {
+		printf("No ACPI node\n");
+	} else
+		acpi_enabled = val;
+}
+
 const char *
 efi_acpi_get_model(void)
 {

Index: src/sys/stand/efiboot/efifdt.c
diff -u src/sys/stand/efiboot/efifdt.c:1.31 src/sys/stand/efiboot/efifdt.c:1.32
--- src/sys/stand/efiboot/efifdt.c:1.31	Wed Oct  6 10:15:20 2021
+++ src/sys/stand/efiboot/efifdt.c	Wed Nov  3 22:02:36 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: efifdt.c,v 1.31 2021/10/06 10:15:20 jmcneill Exp $ */
+/* $NetBSD: efifdt.c,v 1.32 2021/11/03 22:02:36 skrll Exp $ */
 
 /*-
  * Copyright (c) 2019 Jason R. Thorpe
@@ -391,7 +391,7 @@ efi_fdt_gop(void)
 		/*
 		 * In ACPI mode, use GOP as console.
 		 */
-		if (efi_acpi_available() && efi_acpi_enabled()) {
+		if (efi_acpi_available()) {
 			snprintf(buf, sizeof(buf), "/chosen/framebuffer@%" PRIx64, mode->FrameBufferBase);
 			fdt_setprop_string(fdt_data, chosen, "stdout-path", buf);
 		}
@@ -587,17 +587,18 @@ arch_prepare_boot(const char *fname, con
 
 #ifdef EFIBOOT_ACPI
 	/* ACPI support only works for little endian kernels */
-	efi_acpi_enable(netbsd_elf_data == ELFDATA2LSB);
-
-	if (efi_acpi_available() && efi_acpi_enabled()) {
+	if (efi_acpi_available() && netbsd_elf_data == ELFDATA2LSB) {
 		int error = efi_fdt_create_acpifdt();
 		if (error != 0) {
 			return error;
 		}
 	} else
 #endif
-	if (dtb_addr && efi_fdt_set_data((void *)(uintptr_t)dtb_addr) != 0) {
-		printf("boot: invalid DTB data\n");
+	if (!dtb_addr || efi_fdt_set_data((void *)(uintptr_t)dtb_addr) != 0) {
+		if (!dtb_addr)
+			printf("boot: no DTB provided\n");
+		else
+			printf("boot: invalid DTB data\n");
 		return EINVAL;
 	}
 



CVS commit: src/sys/stand/efiboot

2021-11-03 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Wed Nov  3 22:02:36 UTC 2021

Modified Files:
src/sys/stand/efiboot: boot.c efiacpi.c efifdt.c

Log Message:
Provide the ablity to ignore ACPI with an 'acpi' command:

acpi [{on|off}]


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/stand/efiboot/boot.c
cvs rdiff -u -r1.11 -r1.12 src/sys/stand/efiboot/efiacpi.c
cvs rdiff -u -r1.31 -r1.32 src/sys/stand/efiboot/efifdt.c

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



CVS commit: src/sys/stand/efiboot

2021-10-30 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Oct 30 11:18:51 UTC 2021

Modified Files:
src/sys/stand/efiboot: efiblock.c

Log Message:
If a path is not specified, assume /. This makes "ls" and "ls hd0b:" work
as expected.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/stand/efiboot/efiblock.c

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/efiblock.c
diff -u src/sys/stand/efiboot/efiblock.c:1.17 src/sys/stand/efiboot/efiblock.c:1.18
--- src/sys/stand/efiboot/efiblock.c:1.17	Wed Jun 23 21:42:43 2021
+++ src/sys/stand/efiboot/efiblock.c	Sat Oct 30 11:18:51 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: efiblock.c,v 1.17 2021/06/23 21:42:43 jmcneill Exp $ */
+/* $NetBSD: efiblock.c,v 1.18 2021/10/30 11:18:51 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -85,6 +85,10 @@ efi_block_parse(const char *fname, struc
 		*pfile = strchr(fname, ':') + 1;
 	}
 
+	if (*pfile[0] == '\0') {
+		*pfile = __UNCONST("/");
+	}
+
 	if (strncasecmp(full_path, "hd", 2) != 0)
 		return EINVAL;
 	dev = strtoimax(full_path + 2, , 10);



CVS commit: src/sys/stand/efiboot

2021-10-30 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Oct 30 11:18:51 UTC 2021

Modified Files:
src/sys/stand/efiboot: efiblock.c

Log Message:
If a path is not specified, assume /. This makes "ls" and "ls hd0b:" work
as expected.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/stand/efiboot/efiblock.c

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



CVS commit: src/sys/stand/efiboot

2021-10-17 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Oct 17 14:12:54 UTC 2021

Modified Files:
src/sys/stand/efiboot: Makefile.efiboot boot.c

Log Message:
Honour the timeout= entry in boot.cfg


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/stand/efiboot/Makefile.efiboot
cvs rdiff -u -r1.39 -r1.40 src/sys/stand/efiboot/boot.c

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/Makefile.efiboot
diff -u src/sys/stand/efiboot/Makefile.efiboot:1.24 src/sys/stand/efiboot/Makefile.efiboot:1.25
--- src/sys/stand/efiboot/Makefile.efiboot:1.24	Wed Oct  6 10:13:19 2021
+++ src/sys/stand/efiboot/Makefile.efiboot	Sun Oct 17 14:12:54 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.efiboot,v 1.24 2021/10/06 10:13:19 jmcneill Exp $
+# $NetBSD: Makefile.efiboot,v 1.25 2021/10/17 14:12:54 jmcneill Exp $
 
 S=		${.CURDIR}/../../..
 
@@ -92,6 +92,7 @@ CPPFLAGS+= -DSUPPORT_TFTP
 CPPFLAGS+= -DLIBSA_ENABLE_LS_OP
 CPPFLAGS+= -DLIBSA_FFS_EI
 CPPFLAGS+= -DLIBSA_DISKLABEL_EI
+CPPFLAGS+= -DDEFAULT_TIMEOUT=5
 
 #CPPFLAGS+= -DEFIBOOT_DEBUG
 #CPPFLAGS+= -DARP_DEBUG

Index: src/sys/stand/efiboot/boot.c
diff -u src/sys/stand/efiboot/boot.c:1.39 src/sys/stand/efiboot/boot.c:1.40
--- src/sys/stand/efiboot/boot.c:1.39	Sat Oct  9 13:09:17 2021
+++ src/sys/stand/efiboot/boot.c	Sun Oct 17 14:12:54 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: boot.c,v 1.39 2021/10/09 13:09:17 jmcneill Exp $	*/
+/*	$NetBSD: boot.c,v 1.40 2021/10/17 14:12:54 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -88,7 +88,6 @@ static char netbsd_path[255];
 static char netbsd_args[255];
 static char rndseed_path[255];
 
-#define	DEFTIMEOUT	5
 #define DEFFILENAME	names[0]
 
 int	set_bootfile(const char *);
@@ -549,7 +548,7 @@ boot(void)
 		printf("booting %s%s%s - starting in ", netbsd_path,
 		netbsd_args[0] != '\0' ? " " : "", netbsd_args);
 
-		c = awaitkey(DEFTIMEOUT, 1);
+		c = awaitkey(bootcfg_info.timeout, 1);
 		if (c != '\r' && c != '\n' && c != '\0')
 			bootprompt(); /* does not return */
 



CVS commit: src/sys/stand/efiboot

2021-10-17 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Oct 17 14:12:54 UTC 2021

Modified Files:
src/sys/stand/efiboot: Makefile.efiboot boot.c

Log Message:
Honour the timeout= entry in boot.cfg


To generate a diff of this commit:
cvs rdiff -u -r1.24 -r1.25 src/sys/stand/efiboot/Makefile.efiboot
cvs rdiff -u -r1.39 -r1.40 src/sys/stand/efiboot/boot.c

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



CVS commit: src/sys/stand/efiboot

2021-10-09 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Oct  9 13:09:17 UTC 2021

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

Log Message:
efiboot: add "setup" command

The "setup" command sets the 64-bit "OsIndications" variable to the value of
EFI_OS_INDICATIONS_BOOT_TO_FW_UI and requests a reboot. On firmware that
supports this, after reboot the user will be presented with the firmware
setup menu.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sys/stand/efiboot/boot.c

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.38 src/sys/stand/efiboot/boot.c:1.39
--- src/sys/stand/efiboot/boot.c:1.38	Wed Oct  6 10:13:19 2021
+++ src/sys/stand/efiboot/boot.c	Sat Oct  9 13:09:17 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: boot.c,v 1.38 2021/10/06 10:13:19 jmcneill Exp $	*/
+/*	$NetBSD: boot.c,v 1.39 2021/10/09 13:09:17 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -111,6 +111,7 @@ void	command_gop(char *);
 void	command_mem(char *);
 void	command_menu(char *);
 void	command_reset(char *);
+void	command_setup(char *);
 void	command_version(char *);
 void	command_quit(char *);
 
@@ -134,6 +135,7 @@ const struct boot_command commands[] = {
 	{ "menu",	command_menu,		"menu" },
 	{ "reboot",	command_reset,		"reboot|reset" },
 	{ "reset",	command_reset,		NULL },
+	{ "setup",	command_setup,		"setup" },
 	{ "version",	command_version,	"version" },
 	{ "ver",	command_version,	NULL },
 	{ "help",	command_help,		"help|?" },
@@ -355,6 +357,7 @@ command_version(char *arg)
 {
 	char pathbuf[80];
 	char *ufirmware;
+	const UINT64 *osindsup;
 	int rv;
 
 	printf("Version: %s (%s)\n", bootprog_rev, bootprog_kernrev);
@@ -371,6 +374,11 @@ command_version(char *arg)
 		printf("Config path: %s\n", pathbuf);
 	}
 
+	osindsup = LibGetVariable(L"OsIndicationsSupported", );
+	if (osindsup != NULL) {
+		printf("UEFI OS indications supported: 0x%" PRIx64 "\n", *osindsup);
+	}
+
 #ifdef EFIBOOT_FDT
 	efi_fdt_show();
 #endif
@@ -394,6 +402,29 @@ command_reset(char *arg)
 	efi_reboot();
 }
 
+void
+command_setup(char *arg)
+{
+	EFI_STATUS status;
+	const UINT64 *osindsup;
+	UINT64 osind;
+
+	osindsup = LibGetVariable(L"OsIndicationsSupported", );
+	if (osindsup == NULL || (*osindsup & EFI_OS_INDICATIONS_BOOT_TO_FW_UI) == 0) {
+		printf("Not supported by firmware\n");
+		return;
+	}
+
+	osind = EFI_OS_INDICATIONS_BOOT_TO_FW_UI;
+	status = LibSetNVVariable(L"OsIndications", , sizeof(osind), );
+	if (EFI_ERROR(status)) {
+		printf("Failed to set OsIndications variable: %lu\n", (u_long)status);
+		return;
+	}
+
+	efi_reboot();
+}
+
 int
 set_default_device(const char *arg)
 {



CVS commit: src/sys/stand/efiboot

2021-10-09 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Oct  9 13:09:17 UTC 2021

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

Log Message:
efiboot: add "setup" command

The "setup" command sets the 64-bit "OsIndications" variable to the value of
EFI_OS_INDICATIONS_BOOT_TO_FW_UI and requests a reboot. On firmware that
supports this, after reboot the user will be presented with the firmware
setup menu.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sys/stand/efiboot/boot.c

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



CVS commit: src/sys/stand/efiboot/bootriscv64

2021-10-06 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Oct  6 11:26:21 UTC 2021

Modified Files:
src/sys/stand/efiboot/bootriscv64: Makefile

Log Message:
EFIBOOT_FDT=yes for riscv64 too


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/stand/efiboot/bootriscv64/Makefile

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/bootriscv64/Makefile
diff -u src/sys/stand/efiboot/bootriscv64/Makefile:1.2 src/sys/stand/efiboot/bootriscv64/Makefile:1.3
--- src/sys/stand/efiboot/bootriscv64/Makefile:1.2	Wed Oct  6 10:13:20 2021
+++ src/sys/stand/efiboot/bootriscv64/Makefile	Wed Oct  6 11:26:21 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.2 2021/10/06 10:13:20 jmcneill Exp $
+# $NetBSD: Makefile,v 1.3 2021/10/06 11:26:21 jmcneill Exp $
 
 PROG=		bootriscv64.efi
 OBJFMT=		binary
@@ -7,6 +7,8 @@ GNUEFIARCH=	riscv64
 LIBGNUEFI_ARCH=	riscv64
 OBJCOPY_FORMAT=	-O binary
 
+EFIBOOT_FDT=	yes
+
 EXTRA_SOURCES=	efibootriscv64.c
 
 COPTS+=		-mcmodel=medany



CVS commit: src/sys/stand/efiboot/bootriscv64

2021-10-06 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Oct  6 11:26:21 UTC 2021

Modified Files:
src/sys/stand/efiboot/bootriscv64: Makefile

Log Message:
EFIBOOT_FDT=yes for riscv64 too


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/stand/efiboot/bootriscv64/Makefile

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



CVS commit: src/sys/stand/efiboot

2021-10-06 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Oct  6 10:15:20 UTC 2021

Modified Files:
src/sys/stand/efiboot: efifdt.c
src/sys/stand/efiboot/bootarm: Makefile

Log Message:
Fix bootarm build.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/stand/efiboot/efifdt.c
cvs rdiff -u -r1.7 -r1.8 src/sys/stand/efiboot/bootarm/Makefile

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/efifdt.c
diff -u src/sys/stand/efiboot/efifdt.c:1.30 src/sys/stand/efiboot/efifdt.c:1.31
--- src/sys/stand/efiboot/efifdt.c:1.30	Wed Oct  6 10:13:19 2021
+++ src/sys/stand/efiboot/efifdt.c	Wed Oct  6 10:15:20 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: efifdt.c,v 1.30 2021/10/06 10:13:19 jmcneill Exp $ */
+/* $NetBSD: efifdt.c,v 1.31 2021/10/06 10:15:20 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2019 Jason R. Thorpe
@@ -387,6 +387,7 @@ efi_fdt_gop(void)
 		fdt_appendprop_u32(fdt_data, fb, "stride", mode->Info->PixelsPerScanLine * 4);	/* XXX */
 		fdt_appendprop_string(fdt_data, fb, "format", "a8b8g8r8");
 
+#ifdef EFIBOOT_ACPI
 		/*
 		 * In ACPI mode, use GOP as console.
 		 */
@@ -394,6 +395,7 @@ efi_fdt_gop(void)
 			snprintf(buf, sizeof(buf), "/chosen/framebuffer@%" PRIx64, mode->FrameBufferBase);
 			fdt_setprop_string(fdt_data, chosen, "stdout-path", buf);
 		}
+#endif
 
 		return;
 	}

Index: src/sys/stand/efiboot/bootarm/Makefile
diff -u src/sys/stand/efiboot/bootarm/Makefile:1.7 src/sys/stand/efiboot/bootarm/Makefile:1.8
--- src/sys/stand/efiboot/bootarm/Makefile:1.7	Wed Oct  6 10:13:20 2021
+++ src/sys/stand/efiboot/bootarm/Makefile	Wed Oct  6 10:15:20 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile,v 1.7 2021/10/06 10:13:20 jmcneill Exp $
+# $NetBSD: Makefile,v 1.8 2021/10/06 10:15:20 jmcneill Exp $
 
 PROG=		bootarm.efi
 OBJFMT=		binary
@@ -7,6 +7,8 @@ GNUEFIARCH=	arm
 LIBGNUEFI_ARCH=	arm
 OBJCOPY_FORMAT=	-O binary
 
+EFIBOOT_FDT=	yes
+
 EXTRA_SOURCES=	efibootarm.c
 EXTRA_SOURCES+=	cache.S
 



CVS commit: src/sys/stand/efiboot

2021-10-06 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Oct  6 10:15:20 UTC 2021

Modified Files:
src/sys/stand/efiboot: efifdt.c
src/sys/stand/efiboot/bootarm: Makefile

Log Message:
Fix bootarm build.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/stand/efiboot/efifdt.c
cvs rdiff -u -r1.7 -r1.8 src/sys/stand/efiboot/bootarm/Makefile

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



CVS commit: src/sys/stand/efiboot

2021-10-06 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Oct  6 10:13:20 UTC 2021

Modified Files:
src/sys/stand/efiboot: Makefile.efiboot boot.c bootmenu.c efiacpi.c
efiacpi.h efiboot.c efiboot.h efifdt.c efifdt.h efigetsecs.c
efigop.c exec.c
src/sys/stand/efiboot/bootaa64: Makefile
src/sys/stand/efiboot/bootarm: Makefile
src/sys/stand/efiboot/bootriscv64: Makefile

Log Message:
efiboot: Make FDT support optional on a per-arch basis.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/stand/efiboot/Makefile.efiboot
cvs rdiff -u -r1.37 -r1.38 src/sys/stand/efiboot/boot.c
cvs rdiff -u -r1.2 -r1.3 src/sys/stand/efiboot/bootmenu.c \
src/sys/stand/efiboot/efiacpi.h
cvs rdiff -u -r1.10 -r1.11 src/sys/stand/efiboot/efiacpi.c \
src/sys/stand/efiboot/efifdt.h
cvs rdiff -u -r1.21 -r1.22 src/sys/stand/efiboot/efiboot.c
cvs rdiff -u -r1.17 -r1.18 src/sys/stand/efiboot/efiboot.h
cvs rdiff -u -r1.29 -r1.30 src/sys/stand/efiboot/efifdt.c
cvs rdiff -u -r1.4 -r1.5 src/sys/stand/efiboot/efigetsecs.c
cvs rdiff -u -r1.1 -r1.2 src/sys/stand/efiboot/efigop.c
cvs rdiff -u -r1.22 -r1.23 src/sys/stand/efiboot/exec.c
cvs rdiff -u -r1.10 -r1.11 src/sys/stand/efiboot/bootaa64/Makefile
cvs rdiff -u -r1.6 -r1.7 src/sys/stand/efiboot/bootarm/Makefile
cvs rdiff -u -r1.1 -r1.2 src/sys/stand/efiboot/bootriscv64/Makefile

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/Makefile.efiboot
diff -u src/sys/stand/efiboot/Makefile.efiboot:1.23 src/sys/stand/efiboot/Makefile.efiboot:1.24
--- src/sys/stand/efiboot/Makefile.efiboot:1.23	Tue Sep 28 11:37:45 2021
+++ src/sys/stand/efiboot/Makefile.efiboot	Wed Oct  6 10:13:19 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.efiboot,v 1.23 2021/09/28 11:37:45 jmcneill Exp $
+# $NetBSD: Makefile.efiboot,v 1.24 2021/10/06 10:13:19 jmcneill Exp $
 
 S=		${.CURDIR}/../../..
 
@@ -22,15 +22,24 @@ AFLAGS.start.S= ${${ACTIVE_CC} == "clang
 .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 overlay.c panic.c prompt.c
-SOURCES+=	efiboot.c efichar.c efidev.c efigetsecs.c efifdt.c \
-		efifile.c efiblock.c efinet.c efipxe.c efiacpi.c efirng.c \
+		module.c panic.c prompt.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
 
+.if ${EFIBOOT_FDT:Uno} == "yes"
+CPPFLAGS+=	-DEFIBOOT_FDT
+SOURCES+=	efifdt.c overlay.c
 .PATH: ${S}/external/bsd/libfdt/dist
 CPPFLAGS+=	-I${S}/external/bsd/libfdt/dist
 SOURCES+=	fdt.c fdt_addresses.c fdt_empty_tree.c fdt_overlay.c
 SOURCES+=	fdt_ro.c fdt_rw.c fdt_strerror.c fdt_sw.c fdt_wip.c
+.endif
+
+.if ${EFIBOOT_ACPI:Uno} == "yes"
+CPPFLAGS+=	-DEFIBOOT_ACPI
+SOURCES+=	efiacpi.c
+.endif
 
 SRCS= ${SOURCES} ${EXTRA_SOURCES}
 
@@ -146,9 +155,9 @@ VERSIONMACHINE=${MACHINE}
 CLEANFILES+=	${PROG}.so ${PROG}.tmp
 
 ${PROG}: ${PROG}.so
-	${OBJCOPY} -j .text -j .sdata -j .data -j .dynamic -j .dynsym -j .rel \
+	${OBJCOPY} -j .text -j .sdata -j .data -j .dynamic -j .dynsym \
 	-j .rela -j .rel.* -j .rela.* -j .rel* -j .rela* \
-	-j .reloc -O binary ${PROG}.so ${.TARGET}
+	-j .reloc ${OBJCOPY_FORMAT} ${PROG}.so ${.TARGET}
 
 .include 
 

Index: src/sys/stand/efiboot/boot.c
diff -u src/sys/stand/efiboot/boot.c:1.37 src/sys/stand/efiboot/boot.c:1.38
--- src/sys/stand/efiboot/boot.c:1.37	Tue Sep 28 11:37:45 2021
+++ src/sys/stand/efiboot/boot.c	Wed Oct  6 10:13:19 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: boot.c,v 1.37 2021/09/28 11:37:45 jmcneill Exp $	*/
+/*	$NetBSD: boot.c,v 1.38 2021/10/06 10:13:19 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -30,13 +30,19 @@
 #include "efiboot.h"
 #include "efiblock.h"
 #include "efifile.h"
-#include "efifdt.h"
-#include "efiacpi.h"
 #include "efirng.h"
 #include "module.h"
-#include "overlay.h"
 #include "bootmenu.h"
 
+#ifdef EFIBOOT_FDT
+#include "efifdt.h"
+#include "overlay.h"
+#endif
+
+#ifdef EFIBOOT_ACPI
+#include "efiacpi.h"
+#endif
+
 #include 
 #include 
 #include 
@@ -90,11 +96,13 @@ int	set_bootargs(const char *);
 
 void	command_boot(char *);
 void	command_dev(char *);
-void	command_dtb(char *);
 void	command_initrd(char *);
 void	command_rndseed(char *);
+#ifdef EFIBOOT_FDT
+void	command_dtb(char *);
 void	command_dtoverlay(char *);
 void	command_dtoverlays(char *);
+#endif
 void	command_modules(char *);
 void	command_load(char *);
 void	command_unload(char *);
@@ -109,12 +117,14 @@ void	command_quit(char *);
 const struct boot_command commands[] = {
 	{ "boot",	command_boot,		"boot [dev:][filename] [args]\n (ex. \"hd0a:\\netbsd.old -s\"" },
 	{ "dev",	command_dev,		"dev" },
+#ifdef EFIBOOT_FDT
 	{ "dtb",	command_dtb,		"dtb [dev:][filename]" },
+	{ "dtoverlay",	command_dtoverlay,	"dtoverlay [dev:][filename]" },
+	{ 

CVS commit: src/sys/stand/efiboot

2021-10-06 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Oct  6 10:13:20 UTC 2021

Modified Files:
src/sys/stand/efiboot: Makefile.efiboot boot.c bootmenu.c efiacpi.c
efiacpi.h efiboot.c efiboot.h efifdt.c efifdt.h efigetsecs.c
efigop.c exec.c
src/sys/stand/efiboot/bootaa64: Makefile
src/sys/stand/efiboot/bootarm: Makefile
src/sys/stand/efiboot/bootriscv64: Makefile

Log Message:
efiboot: Make FDT support optional on a per-arch basis.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/stand/efiboot/Makefile.efiboot
cvs rdiff -u -r1.37 -r1.38 src/sys/stand/efiboot/boot.c
cvs rdiff -u -r1.2 -r1.3 src/sys/stand/efiboot/bootmenu.c \
src/sys/stand/efiboot/efiacpi.h
cvs rdiff -u -r1.10 -r1.11 src/sys/stand/efiboot/efiacpi.c \
src/sys/stand/efiboot/efifdt.h
cvs rdiff -u -r1.21 -r1.22 src/sys/stand/efiboot/efiboot.c
cvs rdiff -u -r1.17 -r1.18 src/sys/stand/efiboot/efiboot.h
cvs rdiff -u -r1.29 -r1.30 src/sys/stand/efiboot/efifdt.c
cvs rdiff -u -r1.4 -r1.5 src/sys/stand/efiboot/efigetsecs.c
cvs rdiff -u -r1.1 -r1.2 src/sys/stand/efiboot/efigop.c
cvs rdiff -u -r1.22 -r1.23 src/sys/stand/efiboot/exec.c
cvs rdiff -u -r1.10 -r1.11 src/sys/stand/efiboot/bootaa64/Makefile
cvs rdiff -u -r1.6 -r1.7 src/sys/stand/efiboot/bootarm/Makefile
cvs rdiff -u -r1.1 -r1.2 src/sys/stand/efiboot/bootriscv64/Makefile

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



CVS commit: src/sys/stand/efiboot

2021-09-28 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Sep 28 11:38:07 UTC 2021

Added Files:
src/sys/stand/efiboot: efigop.c

Log Message:
efiboot: Add efigop.c


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/stand/efiboot/efigop.c

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



CVS commit: src/sys/stand/efiboot

2021-09-28 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Sep 28 11:38:07 UTC 2021

Added Files:
src/sys/stand/efiboot: efigop.c

Log Message:
efiboot: Add efigop.c


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/stand/efiboot/efigop.c

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

Added files:

Index: src/sys/stand/efiboot/efigop.c
diff -u /dev/null src/sys/stand/efiboot/efigop.c:1.1
--- /dev/null	Tue Sep 28 11:38:07 2021
+++ src/sys/stand/efiboot/efigop.c	Tue Sep 28 11:38:07 2021
@@ -0,0 +1,141 @@
+/* $NetBSD: efigop.c,v 1.1 2021/09/28 11:38:07 jmcneill Exp $ */
+
+/*-
+ * Copyright (c) 2021 Jared McNeill 
+ * 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 
+
+static EFI_GRAPHICS_OUTPUT_PROTOCOL *gop = NULL;
+
+void
+efi_gop_probe(void)
+{
+	EFI_HANDLE *gop_handle;
+	UINTN ngop_handle;
+	EFI_STATUS status;
+
+	status = LibLocateHandle(ByProtocol, , NULL,
+	_handle, _handle);
+	if (EFI_ERROR(status) || ngop_handle == 0) {
+		return;
+	}
+
+	for (size_t n = 0; n < ngop_handle; n++) {
+		status = uefi_call_wrapper(BS->HandleProtocol, 3,
+		gop_handle[n], , (void **));
+		if (EFI_ERROR(status) || gop->Mode == NULL) {
+			gop = NULL;
+			continue;
+		} else {
+			break;
+		}
+	}
+}
+
+static uint32_t
+efi_gop_bpp(EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *info)
+{
+	if (info->PixelFormat == PixelRedGreenBlueReserved8BitPerColor ||
+	info->PixelFormat == PixelBlueGreenRedReserved8BitPerColor) {
+		return 24;
+	}
+
+	return popcount32(info->PixelInformation.RedMask) +
+	popcount32(info->PixelInformation.GreenMask) +
+	popcount32(info->PixelInformation.BlueMask);
+}
+
+static void
+efi_gop_printmode(UINT32 mode, EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *info)
+{
+	char buf[sizeof("N: HxV BB")];
+
+	snprintf(buf, sizeof(buf), "%-5u: %ux%u %u", mode,
+	info->HorizontalResolution, info->VerticalResolution,
+	efi_gop_bpp(info));
+
+	printf("%-21s", buf);
+}
+
+void
+efi_gop_show(void)
+{
+	if (gop == NULL) {
+		return;
+	}
+
+	printf("GOP: ");
+	efi_gop_printmode(gop->Mode->Mode, gop->Mode->Info);
+	printf("\n");
+}
+
+void
+efi_gop_dump(void)
+{
+	EFI_STATUS status;
+	EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *info;
+	UINTN size;
+
+	if (gop == NULL) {
+		return;
+	}
+
+	for (UINT32 mode = 0; mode < gop->Mode->MaxMode; mode++) {
+		status = uefi_call_wrapper(gop->QueryMode, 4, gop, mode,
+		, );
+		if (EFI_ERROR(status)) {
+			continue;
+		}
+		if (mode == gop->Mode->Mode) {
+			printf(" -> ");
+		} else {
+			printf("");
+		}
+		efi_gop_printmode(mode, info);
+		if (mode != gop->Mode->MaxMode - 1 &&
+		mode % 3 == 2) {
+			printf("\n");
+		}
+	}
+	printf("\n");
+}
+
+void
+efi_gop_setmode(UINT32 mode)
+{
+	EFI_STATUS status;
+
+	if (gop == NULL) {
+		return;
+	}
+
+	status = uefi_call_wrapper(gop->SetMode, 2, gop, mode);
+	if (EFI_ERROR(status)) {
+		printf("Failed to set video mode: %ld\n", (long)status);
+	}
+}



CVS commit: src/sys/stand/efiboot

2021-09-28 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Sep 28 11:37:45 UTC 2021

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

Log Message:
efiboot: Add support for changing the video mode.

Add a new "gop" command that can query the list of available video modes.
With a mode number as argument (eg. "gop 16"), the new display mode will
be selected.

The "version" command prints the current display mode.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/stand/efiboot/Makefile.efiboot
cvs rdiff -u -r1.36 -r1.37 src/sys/stand/efiboot/boot.c
cvs rdiff -u -r1.20 -r1.21 src/sys/stand/efiboot/efiboot.c
cvs rdiff -u -r1.16 -r1.17 src/sys/stand/efiboot/efiboot.h
cvs rdiff -u -r1.28 -r1.29 src/sys/stand/efiboot/version

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/Makefile.efiboot
diff -u src/sys/stand/efiboot/Makefile.efiboot:1.22 src/sys/stand/efiboot/Makefile.efiboot:1.23
--- src/sys/stand/efiboot/Makefile.efiboot:1.22	Sun Jun 20 19:10:47 2021
+++ src/sys/stand/efiboot/Makefile.efiboot	Tue Sep 28 11:37:45 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.efiboot,v 1.22 2021/06/20 19:10:47 jmcneill Exp $
+# $NetBSD: Makefile.efiboot,v 1.23 2021/09/28 11:37:45 jmcneill Exp $
 
 S=		${.CURDIR}/../../..
 
@@ -24,8 +24,8 @@ SOURCES=	crt0-efi-${GNUEFIARCH}.S reloc_
 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 efigetsecs.c efifdt.c \
-		efifile.c efiblock.c efinet.c efipxe.c efiacpi.c efirng.c efiwatchdog.c \
-	   	smbios.c
+		efifile.c efiblock.c efinet.c efipxe.c efiacpi.c efirng.c \
+		efiwatchdog.c efigop.c smbios.c
 
 .PATH: ${S}/external/bsd/libfdt/dist
 CPPFLAGS+=	-I${S}/external/bsd/libfdt/dist

Index: src/sys/stand/efiboot/boot.c
diff -u src/sys/stand/efiboot/boot.c:1.36 src/sys/stand/efiboot/boot.c:1.37
--- src/sys/stand/efiboot/boot.c:1.36	Tue Sep  7 11:41:31 2021
+++ src/sys/stand/efiboot/boot.c	Tue Sep 28 11:37:45 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: boot.c,v 1.36 2021/09/07 11:41:31 nia Exp $	*/
+/*	$NetBSD: boot.c,v 1.37 2021/09/28 11:37:45 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -99,6 +99,7 @@ void	command_modules(char *);
 void	command_load(char *);
 void	command_unload(char *);
 void	command_ls(char *);
+void	command_gop(char *);
 void	command_mem(char *);
 void	command_menu(char *);
 void	command_reset(char *);
@@ -118,6 +119,7 @@ const struct boot_command commands[] = {
 	{ "load",	command_load,		"load " },
 	{ "unload",	command_unload,		"unload " },
 	{ "ls",		command_ls,		"ls [hdNn:/path]" },
+	{ "gop",	command_gop,		"gop [mode]" },
 	{ "mem",	command_mem,		"mem" },
 	{ "menu",	command_menu,		"menu" },
 	{ "reboot",	command_reset,		"reboot|reset" },
@@ -290,6 +292,20 @@ command_ls(char *arg)
 }
 
 void
+command_gop(char *arg)
+{
+	UINT32 mode;
+
+	if (!arg || !*arg) {
+		efi_gop_dump();
+		return;
+	}
+
+	mode = atoi(arg);
+	efi_gop_setmode(mode);
+}
+
+void
 command_mem(char *arg)
 {
 	EFI_MEMORY_DESCRIPTOR *md, *memmap;
@@ -347,6 +363,7 @@ command_version(char *arg)
 	efi_acpi_show();
 	efi_rng_show();
 	efi_md_show();
+	efi_gop_show();
 }
 
 void

Index: src/sys/stand/efiboot/efiboot.c
diff -u src/sys/stand/efiboot/efiboot.c:1.20 src/sys/stand/efiboot/efiboot.c:1.21
--- src/sys/stand/efiboot/efiboot.c:1.20	Fri Jun 26 03:23:04 2020
+++ src/sys/stand/efiboot/efiboot.c	Tue Sep 28 11:37:45 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: efiboot.c,v 1.20 2020/06/26 03:23:04 thorpej Exp $ */
+/* $NetBSD: efiboot.c,v 1.21 2021/09/28 11:37:45 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -98,6 +98,7 @@ efi_main(EFI_HANDLE imageHandle, EFI_SYS
 	efi_file_system_probe();
 	efi_block_probe();
 	efi_rng_probe();
+	efi_gop_probe();
 
 	boot();
 

Index: src/sys/stand/efiboot/efiboot.h
diff -u src/sys/stand/efiboot/efiboot.h:1.16 src/sys/stand/efiboot/efiboot.h:1.17
--- src/sys/stand/efiboot/efiboot.h:1.16	Tue Sep  7 11:41:31 2021
+++ src/sys/stand/efiboot/efiboot.h	Tue Sep 28 11:37:45 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: efiboot.h,v 1.16 2021/09/07 11:41:31 nia Exp $	*/
+/*	$NetBSD: efiboot.h,v 1.17 2021/09/28 11:37:45 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -106,6 +106,12 @@ bool efi_pxe_match_booted_interface(cons
 /* efiwatchdog.c */
 void efi_set_watchdog(uint32_t, uint64_t);
 
+/* efigop.c */
+void efi_gop_probe(void);
+void efi_gop_show(void);
+void efi_gop_dump(void);
+void efi_gop_setmode(UINT32);
+
 /* exec.c */
 int exec_netbsd(const char *, const char *);
 

Index: src/sys/stand/efiboot/version
diff -u src/sys/stand/efiboot/version:1.28 src/sys/stand/efiboot/version:1.29
--- src/sys/stand/efiboot/version:1.28	Sun Aug  8 21:50:10 2021
+++ src/sys/stand/efiboot/version	Tue Sep 28 11:37:45 2021
@@ -1,4 +1,4 @@
-$NetBSD: version,v 1.28 

CVS commit: src/sys/stand/efiboot

2021-09-28 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Sep 28 11:37:45 UTC 2021

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

Log Message:
efiboot: Add support for changing the video mode.

Add a new "gop" command that can query the list of available video modes.
With a mode number as argument (eg. "gop 16"), the new display mode will
be selected.

The "version" command prints the current display mode.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/stand/efiboot/Makefile.efiboot
cvs rdiff -u -r1.36 -r1.37 src/sys/stand/efiboot/boot.c
cvs rdiff -u -r1.20 -r1.21 src/sys/stand/efiboot/efiboot.c
cvs rdiff -u -r1.16 -r1.17 src/sys/stand/efiboot/efiboot.h
cvs rdiff -u -r1.28 -r1.29 src/sys/stand/efiboot/version

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



CVS commit: src/sys/stand/efiboot

2021-07-24 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Jul 24 10:22:28 UTC 2021

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

Log Message:
efiboot: Allow "fs" as alias for "initrd", for compat with x86


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/stand/efiboot/boot.c

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.34 src/sys/stand/efiboot/boot.c:1.35
--- src/sys/stand/efiboot/boot.c:1.34	Wed Jun 23 21:43:38 2021
+++ src/sys/stand/efiboot/boot.c	Sat Jul 24 10:22:28 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: boot.c,v 1.34 2021/06/23 21:43:38 jmcneill Exp $	*/
+/*	$NetBSD: boot.c,v 1.35 2021/07/24 10:22:28 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -110,6 +110,7 @@ const struct boot_command commands[] = {
 	{ "dev",	command_dev,		"dev" },
 	{ "dtb",	command_dtb,		"dtb [dev:][filename]" },
 	{ "initrd",	command_initrd,		"initrd [dev:][filename]" },
+	{ "fs",		command_initrd,		NULL },
 	{ "rndseed",	command_rndseed,	"rndseed [dev:][filename]" },
 	{ "dtoverlay",	command_dtoverlay,	"dtoverlay [dev:][filename]" },
 	{ "dtoverlays",	command_dtoverlays,	"dtoverlays [{on|off|reset}]" },



CVS commit: src/sys/stand/efiboot

2021-07-24 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Jul 24 10:22:28 UTC 2021

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

Log Message:
efiboot: Allow "fs" as alias for "initrd", for compat with x86


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/stand/efiboot/boot.c

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



CVS commit: src/sys/stand/efiboot

2021-07-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Jul 23 21:33:00 UTC 2021

Modified Files:
src/sys/stand/efiboot: efiacpi.c smbios.c

Log Message:
efiboot: Add support for SMBIOS 2.x tables.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/stand/efiboot/efiacpi.c
cvs rdiff -u -r1.2 -r1.3 src/sys/stand/efiboot/smbios.c

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/efiacpi.c
diff -u src/sys/stand/efiboot/efiacpi.c:1.9 src/sys/stand/efiboot/efiacpi.c:1.10
--- src/sys/stand/efiboot/efiacpi.c:1.9	Fri May 21 21:53:15 2021
+++ src/sys/stand/efiboot/efiacpi.c	Fri Jul 23 21:33:00 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: efiacpi.c,v 1.9 2021/05/21 21:53:15 jmcneill Exp $ */
+/* $NetBSD: efiacpi.c,v 1.10 2021/07/23 21:33:00 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -52,10 +52,11 @@ struct acpi_rdsp {
 
 static EFI_GUID Acpi20TableGuid = ACPI_20_TABLE_GUID;
 static EFI_GUID Smbios3TableGuid = SMBIOS3_TABLE_GUID;
+static EFI_GUID SmbiosTableGuid = SMBIOS_TABLE_GUID;
 
 static int acpi_enable = 1;
 static void *acpi_root = NULL;
-static void *smbios3_table = NULL;
+static void *smbios_table = NULL;
 
 int
 efi_acpi_probe(void)
@@ -66,9 +67,13 @@ efi_acpi_probe(void)
 	if (EFI_ERROR(status))
 		return EIO;
 
-	status = LibGetSystemConfigurationTable(, _table);
-	if (EFI_ERROR(status))
-		smbios3_table = NULL;
+	status = LibGetSystemConfigurationTable(, _table);
+	if (EFI_ERROR(status)) {
+		status = LibGetSystemConfigurationTable(, _table);
+	}
+	if (EFI_ERROR(status)) {
+		smbios_table = NULL;
+	}
 
 	return 0;
 }
@@ -103,8 +108,8 @@ efi_acpi_get_model(void)
 
 	memset(model_buf, 0, sizeof(model_buf));
 
-	if (smbios3_table != NULL) {
-		smbios_init(smbios3_table);
+	if (smbios_table != NULL) {
+		smbios_init(smbios_table);
 
 		buf = model_buf;
 		smbios.cookie = 0;
@@ -136,7 +141,7 @@ efi_acpi_show(void)
 	rsdp->oemid[0], rsdp->oemid[1], rsdp->oemid[2],
 	rsdp->oemid[3], rsdp->oemid[4], rsdp->oemid[5]);
 
-	if (smbios3_table)
+	if (smbios_table)
 		printf("SMBIOS: %s\n", efi_acpi_get_model());
 }
 
@@ -166,8 +171,8 @@ efi_acpi_create_fdt(void)
 
 	fdt_add_subnode(fdt, fdt_path_offset(fdt, "/"), "chosen");
 	fdt_setprop_u64(fdt, fdt_path_offset(fdt, "/chosen"), "netbsd,acpi-root-table", (uint64_t)(uintptr_t)acpi_root);
-	if (smbios3_table)
-		fdt_setprop_u64(fdt, fdt_path_offset(fdt, "/chosen"), "netbsd,smbios-table", (uint64_t)(uintptr_t)smbios3_table);
+	if (smbios_table)
+		fdt_setprop_u64(fdt, fdt_path_offset(fdt, "/chosen"), "netbsd,smbios-table", (uint64_t)(uintptr_t)smbios_table);
 
 	fdt_add_subnode(fdt, fdt_path_offset(fdt, "/"), "acpi");
 	fdt_setprop_string(fdt, fdt_path_offset(fdt, "/acpi"), "compatible", "netbsd,acpi");

Index: src/sys/stand/efiboot/smbios.c
diff -u src/sys/stand/efiboot/smbios.c:1.2 src/sys/stand/efiboot/smbios.c:1.3
--- src/sys/stand/efiboot/smbios.c:1.2	Fri Dec 27 09:45:27 2019
+++ src/sys/stand/efiboot/smbios.c	Fri Jul 23 21:33:00 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: smbios.c,v 1.2 2019/12/27 09:45:27 msaitoh Exp $	*/
+/*	$NetBSD: smbios.c,v 1.3 2021/07/23 21:33:00 jmcneill Exp $	*/
 
 /*
  * Copyright (c) 1999 The NetBSD Foundation, Inc.
@@ -82,7 +82,7 @@
  */
 
 #include 
-__KERNEL_RCSID(0, "$NetBSD: smbios.c,v 1.2 2019/12/27 09:45:27 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: smbios.c,v 1.3 2021/07/23 21:33:00 jmcneill Exp $");
 
 #include 
 
@@ -91,8 +91,22 @@ __KERNEL_RCSID(0, "$NetBSD: smbios.c,v 1
 
 struct smbios_entry smbios_entry;
 
-void
-smbios_init(uint8_t *p)
+static void
+smbios2_init(uint8_t *p)
+{
+	const struct smbhdr *sh = (const struct smbhdr *)p;
+
+	smbios_entry.addr = (void *)(uintptr_t)sh->addr;
+	smbios_entry.len = sh->size;
+	smbios_entry.rev = 0;
+	smbios_entry.mjr = sh->majrev;
+	smbios_entry.min = sh->minrev;
+	smbios_entry.doc = 0;
+	smbios_entry.count = sh->count;
+}
+
+static void
+smbios3_init(uint8_t *p)
 {
 	const struct smb3hdr *sh = (const struct smb3hdr *)p;
 
@@ -105,6 +119,16 @@ smbios_init(uint8_t *p)
 	smbios_entry.count = UINT16_MAX;
 }
 
+void
+smbios_init(uint8_t *p)
+{
+	if (memcmp(p, "_SM3_", 5) == 0) {
+		smbios3_init(p);
+	} else if (memcmp(p, "_SM_", 4) == 0) {
+		smbios2_init(p);
+	}
+}
+
 /*
  * smbios_find_table() takes a caller supplied smbios struct type and
  * a pointer to a handle (struct smbtable) returning one if the structure
@@ -121,6 +145,10 @@ smbios_find_table(uint8_t type, struct s
 	struct smbtblhdr *hdr;
 	int ret = 0, tcount = 1;
 
+	if (smbios_entry.addr == 0) {
+		return 0;
+	}
+
 	va = smbios_entry.addr;
 	end = va + smbios_entry.len;
 
@@ -173,6 +201,10 @@ smbios_get_string(struct smbtable *st, u
 	char *ret = NULL;
 	int i;
 
+	if (smbios_entry.addr == 0) {
+		return NULL;
+	}
+
 	va = (uint8_t *)st->hdr + st->hdr->size;
 	end = smbios_entry.addr + smbios_entry.len;
 	for (i = 1; va < end && i < indx && *va; i++)



CVS commit: src/sys/stand/efiboot

2021-07-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri Jul 23 21:33:00 UTC 2021

Modified Files:
src/sys/stand/efiboot: efiacpi.c smbios.c

Log Message:
efiboot: Add support for SMBIOS 2.x tables.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/stand/efiboot/efiacpi.c
cvs rdiff -u -r1.2 -r1.3 src/sys/stand/efiboot/smbios.c

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



CVS commit: src/sys/stand/efiboot

2021-06-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Jun 23 21:43:38 UTC 2021

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

Log Message:
When printing memory size, don't promote to next unit size unless it is at
two digits.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/stand/efiboot/boot.c

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.33 src/sys/stand/efiboot/boot.c:1.34
--- src/sys/stand/efiboot/boot.c:1.33	Wed Jun 23 00:38:12 2021
+++ src/sys/stand/efiboot/boot.c	Wed Jun 23 21:43:38 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: boot.c,v 1.33 2021/06/23 00:38:12 jmcneill Exp $	*/
+/*	$NetBSD: boot.c,v 1.34 2021/06/23 21:43:38 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -479,7 +479,7 @@ format_bytes(uint64_t val, uint64_t *pdi
 	*punit = "bytes";
 	*pdiv = 1;
 
-	for (n = 0; n < __arraycount(units) && val >= 1024; n++) {
+	for (n = 0; n < __arraycount(units) && val >= 1024 * 10; n++) {
 		*punit = units[n];
 		*pdiv *= 1024;
 		val /= 1024;



CVS commit: src/sys/stand/efiboot

2021-06-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Jun 23 21:43:38 UTC 2021

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

Log Message:
When printing memory size, don't promote to next unit size unless it is at
two digits.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/stand/efiboot/boot.c

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



CVS commit: src/sys/stand/efiboot

2021-06-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Jun 23 21:42:43 UTC 2021

Modified Files:
src/sys/stand/efiboot: efiblock.c

Log Message:
fix typo


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/stand/efiboot/efiblock.c

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/efiblock.c
diff -u src/sys/stand/efiboot/efiblock.c:1.16 src/sys/stand/efiboot/efiblock.c:1.17
--- src/sys/stand/efiboot/efiblock.c:1.16	Wed Jun 23 20:55:50 2021
+++ src/sys/stand/efiboot/efiblock.c	Wed Jun 23 21:42:43 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: efiblock.c,v 1.16 2021/06/23 20:55:50 jmcneill Exp $ */
+/* $NetBSD: efiblock.c,v 1.17 2021/06/23 21:42:43 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -133,7 +133,7 @@ efi_block_do_read_blockio(struct efi_blo
 	blkbuf_offset = off % bdev->bio->Media->BlockSize;
 	blkbuf_size = (lba_end - lba_start) * bdev->bio->Media->BlockSize;
 	if (bdev->bio->Media->IoAlign > 1) {
-		blkbuf_size = (blkbuf_size + bdev->bio-Media->IoAlign - 1) /
+		blkbuf_size = (blkbuf_size + bdev->bio->Media->IoAlign - 1) /
 		bdev->bio->Media->IoAlign *
 		bdev->bio->Media->IoAlign;
 	}



CVS commit: src/sys/stand/efiboot

2021-06-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Jun 23 21:42:43 UTC 2021

Modified Files:
src/sys/stand/efiboot: efiblock.c

Log Message:
fix typo


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/stand/efiboot/efiblock.c

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



CVS commit: src/sys/stand/efiboot

2021-06-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Jun 23 20:55:50 UTC 2021

Modified Files:
src/sys/stand/efiboot: efiblock.c

Log Message:
Fix buffer size for alignment adjusted block I/O reads.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/stand/efiboot/efiblock.c

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/efiblock.c
diff -u src/sys/stand/efiboot/efiblock.c:1.15 src/sys/stand/efiboot/efiblock.c:1.16
--- src/sys/stand/efiboot/efiblock.c:1.15	Tue Jun 22 21:56:51 2021
+++ src/sys/stand/efiboot/efiblock.c	Wed Jun 23 20:55:50 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: efiblock.c,v 1.15 2021/06/22 21:56:51 jmcneill Exp $ */
+/* $NetBSD: efiblock.c,v 1.16 2021/06/23 20:55:50 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -133,7 +133,9 @@ efi_block_do_read_blockio(struct efi_blo
 	blkbuf_offset = off % bdev->bio->Media->BlockSize;
 	blkbuf_size = (lba_end - lba_start) * bdev->bio->Media->BlockSize;
 	if (bdev->bio->Media->IoAlign > 1) {
-		blkbuf_size += bdev->bio->Media->IoAlign - 1;
+		blkbuf_size = (blkbuf_size + bdev->bio-Media->IoAlign - 1) /
+		bdev->bio->Media->IoAlign *
+		bdev->bio->Media->IoAlign;
 	}
 
 	blkbuf = AllocatePool(blkbuf_size);



CVS commit: src/sys/stand/efiboot

2021-06-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Jun 23 20:55:50 UTC 2021

Modified Files:
src/sys/stand/efiboot: efiblock.c

Log Message:
Fix buffer size for alignment adjusted block I/O reads.


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/stand/efiboot/efiblock.c

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



CVS commit: src/sys/stand/efiboot

2021-06-22 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Jun 23 00:38:12 UTC 2021

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

Log Message:
print_banner: Print memory size like x86 does


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/stand/efiboot/boot.c

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.32 src/sys/stand/efiboot/boot.c:1.33
--- src/sys/stand/efiboot/boot.c:1.32	Mon Jun 21 21:18:47 2021
+++ src/sys/stand/efiboot/boot.c	Wed Jun 23 00:38:12 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: boot.c,v 1.32 2021/06/21 21:18:47 jmcneill Exp $	*/
+/*	$NetBSD: boot.c,v 1.33 2021/06/23 00:38:12 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -450,13 +450,56 @@ set_bootargs(const char *arg)
 	return 0;
 }
 
+static void
+get_memory_info(uint64_t *ptotal)
+{
+	EFI_MEMORY_DESCRIPTOR *md, *memmap;
+	UINTN nentries, mapkey, descsize;
+	UINT32 descver;
+	uint64_t totalpg = 0;
+	int n;
+
+	memmap = LibMemoryMap(, , , );
+	for (n = 0, md = memmap; n < nentries; n++, md = NextMemoryDescriptor(md, descsize)) {
+		if ((md->Attribute & EFI_MEMORY_WB) == 0) {
+			continue;
+		}
+		totalpg += md->NumberOfPages;
+	}
+
+	*ptotal = totalpg * EFI_PAGE_SIZE;
+}
+
+static void
+format_bytes(uint64_t val, uint64_t *pdiv, const char **punit)
+{
+	static const char *units[] = { "KB", "MB", "GB" };
+	unsigned n;
+
+	*punit = "bytes";
+	*pdiv = 1;
+
+	for (n = 0; n < __arraycount(units) && val >= 1024; n++) {
+		*punit = units[n];
+		*pdiv *= 1024;
+		val /= 1024;
+	}
+}
+
 void
 print_banner(void)
 {
+	const char *total_unit;
+	uint64_t total, total_div;
+
+	get_memory_info();
+	format_bytes(total, _div, _unit);
+
 	printf("  \\-__,--,___.\n");
 	printf("   \\__,---`  %s\n", bootprog_name);
 	printf("\\   `---,_.  Revision %s\n", bootprog_rev);
-	printf(" \\-,_,.---`\n");
+	printf(" \\-,_,.---`  Memory: %" PRIu64 " %s\n",
+	total / total_div, total_unit);
 	printf("  \\\n");
 	printf("   \\\n");
 	printf("\\\n\n");



CVS commit: src/sys/stand/efiboot

2021-06-22 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Jun 23 00:38:12 UTC 2021

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

Log Message:
print_banner: Print memory size like x86 does


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/stand/efiboot/boot.c

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



CVS commit: src/sys/stand/efiboot

2021-06-22 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Jun 22 21:56:51 UTC 2021

Modified Files:
src/sys/stand/efiboot: efiblock.c

Log Message:
efiboot: Use EFI_BLOCK_IO_PROTOCOL if EFI_DISK_IO_PROTOCOL is missing

UEFI spec says that firmware should automatically add EFI_DISK_IO_PROTOCOL
for all produced EFI_BLOCK_IO_PROTOCOL interfaces. Unfortunately U-Boot
doesn't do this, so fallback to block I/O if disk I/O is not there.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/stand/efiboot/efiblock.c

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/efiblock.c
diff -u src/sys/stand/efiboot/efiblock.c:1.14 src/sys/stand/efiboot/efiblock.c:1.15
--- src/sys/stand/efiboot/efiblock.c:1.14	Mon Jun 21 21:18:47 2021
+++ src/sys/stand/efiboot/efiblock.c	Tue Jun 22 21:56:51 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: efiblock.c,v 1.14 2021/06/21 21:18:47 jmcneill Exp $ */
+/* $NetBSD: efiblock.c,v 1.15 2021/06/22 21:56:51 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -118,7 +118,74 @@ efi_block_generate_hash_mbr(struct efi_b
 }
 
 static EFI_STATUS
-efi_block_disk_readahead(struct efi_block_dev *bdev, UINT64 off, void *buf,
+efi_block_do_read_blockio(struct efi_block_dev *bdev, UINT64 off, void *buf,
+UINTN bufsize)
+{
+	UINT8 *blkbuf, *blkbuf_start;
+	EFI_STATUS status;
+	EFI_LBA lba_start, lba_end;
+	UINT64 blkbuf_offset;
+	UINT64 blkbuf_size;
+
+	lba_start = off / bdev->bio->Media->BlockSize;
+	lba_end = (off + bufsize + bdev->bio->Media->BlockSize - 1) /
+	bdev->bio->Media->BlockSize;
+	blkbuf_offset = off % bdev->bio->Media->BlockSize;
+	blkbuf_size = (lba_end - lba_start) * bdev->bio->Media->BlockSize;
+	if (bdev->bio->Media->IoAlign > 1) {
+		blkbuf_size += bdev->bio->Media->IoAlign - 1;
+	}
+
+	blkbuf = AllocatePool(blkbuf_size);
+	if (blkbuf == NULL) {
+		return EFI_OUT_OF_RESOURCES;
+	}
+
+	if (bdev->bio->Media->IoAlign > 1) {
+		blkbuf_start = (void *)roundup2((intptr_t)blkbuf,
+		bdev->bio->Media->IoAlign);
+	} else {
+		blkbuf_start = blkbuf;
+	}
+
+	status = uefi_call_wrapper(bdev->bio->ReadBlocks, 5, bdev->bio,
+	bdev->media_id, lba_start, blkbuf_size, blkbuf_start);
+	if (EFI_ERROR(status)) {
+		goto done;
+	}
+
+	memcpy(buf, blkbuf_start + blkbuf_offset, bufsize);
+
+done:
+	FreePool(blkbuf);
+	return status;
+}
+
+static EFI_STATUS
+efi_block_do_read_diskio(struct efi_block_dev *bdev, UINT64 off, void *buf,
+UINTN bufsize)
+{
+	return uefi_call_wrapper(bdev->dio->ReadDisk, 5, bdev->dio,
+	bdev->media_id, off, bufsize, buf);
+}
+
+static EFI_STATUS
+efi_block_do_read(struct efi_block_dev *bdev, UINT64 off, void *buf,
+UINTN bufsize)
+{
+	/*
+	 * Perform read access using EFI_DISK_IO_PROTOCOL if available,
+	 * otherwise use EFI_BLOCK_IO_PROTOCOL.
+	 */
+	if (bdev->dio != NULL) {
+		return efi_block_do_read_diskio(bdev, off, buf, bufsize);
+	} else {
+		return efi_block_do_read_blockio(bdev, off, buf, bufsize);
+	}
+}
+
+static EFI_STATUS
+efi_block_readahead(struct efi_block_dev *bdev, UINT64 off, void *buf,
 UINTN bufsize)
 {
 	EFI_STATUS status;
@@ -140,8 +207,7 @@ efi_block_disk_readahead(struct efi_bloc
 		if (len > mediasize - off) {
 			len = mediasize - off;
 		}
-		status = uefi_call_wrapper(bdev->dio->ReadDisk, 5, bdev->dio,
-		bdev->media_id, off, len, efi_ra_buffer);
+		status = efi_block_do_read(bdev, off, efi_ra_buffer, len);
 		if (EFI_ERROR(status)) {
 			efi_ra_start = efi_ra_length = 0;
 			return status;
@@ -156,15 +222,14 @@ efi_block_disk_readahead(struct efi_bloc
 }
 
 static EFI_STATUS
-efi_block_disk_read(struct efi_block_dev *bdev, UINT64 off, void *buf,
+efi_block_read(struct efi_block_dev *bdev, UINT64 off, void *buf,
 UINTN bufsize)
 {
 	if (efi_ra_enable) {
-		return efi_block_disk_readahead(bdev, off, buf, bufsize);
+		return efi_block_readahead(bdev, off, buf, bufsize);
 	}
 
-	return uefi_call_wrapper(bdev->dio->ReadDisk, 5, bdev->dio,
-	bdev->media_id, off, bufsize, buf);
+	return efi_block_do_read(bdev, off, buf, bufsize);
 }
 
 static int
@@ -176,7 +241,7 @@ efi_block_find_partitions_cd9660(struct 
 	EFI_LBA lba;
 
 	for (lba = 16;; lba++) {
-		status = efi_block_disk_read(bdev,
+		status = efi_block_read(bdev,
 		lba * ISO_DEFAULT_BLOCK_SIZE, , sizeof(vd));
 		if (EFI_ERROR(status)) {
 			goto io_error;
@@ -220,7 +285,7 @@ efi_block_find_partitions_disklabel(stru
 	EFI_STATUS status;
 	int n;
 
-	status = efi_block_disk_read(bdev,
+	status = efi_block_read(bdev,
 	((EFI_LBA)start + LABELSECTOR) * DEV_BSIZE, buf, sizeof(buf));
 	if (EFI_ERROR(status) || getdisklabel(buf, ) != NULL) {
 		FreePool(buf);
@@ -268,7 +333,7 @@ efi_block_find_partitions_mbr(struct efi
 	EFI_STATUS status;
 	int n;
 
-	status = efi_block_disk_read(bdev, 0, , sizeof(mbr));
+	status = efi_block_read(bdev, 0, , sizeof(mbr));
 	if (EFI_ERROR(status))
 		return EIO;
 
@@ -348,7 +413,7 

CVS commit: src/sys/stand/efiboot

2021-06-22 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Jun 22 21:56:51 UTC 2021

Modified Files:
src/sys/stand/efiboot: efiblock.c

Log Message:
efiboot: Use EFI_BLOCK_IO_PROTOCOL if EFI_DISK_IO_PROTOCOL is missing

UEFI spec says that firmware should automatically add EFI_DISK_IO_PROTOCOL
for all produced EFI_BLOCK_IO_PROTOCOL interfaces. Unfortunately U-Boot
doesn't do this, so fallback to block I/O if disk I/O is not there.


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/stand/efiboot/efiblock.c

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



CVS commit: src/sys/stand/efiboot

2021-06-22 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Jun 22 10:19:35 UTC 2021

Modified Files:
src/sys/stand/efiboot: efirng.c

Log Message:
efirng: fix va_num arg to uefi_call_wrapper for GetRNG calls

As far as I can tell this param isn't actually used, but it is supposed to
be the number of arguments passed to the called method.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/stand/efiboot/efirng.c

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/efirng.c
diff -u src/sys/stand/efiboot/efirng.c:1.2 src/sys/stand/efiboot/efirng.c:1.3
--- src/sys/stand/efiboot/efirng.c:1.2	Thu May 14 23:09:29 2020
+++ src/sys/stand/efiboot/efirng.c	Tue Jun 22 10:19:35 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: efirng.c,v 1.2 2020/05/14 23:09:29 jmcneill Exp $	*/
+/*	$NetBSD: efirng.c,v 1.3 2021/06/22 10:19:35 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2020 The NetBSD Foundation, Inc.
@@ -121,14 +121,14 @@ efi_rng(void *buf, UINTN len)
 	if (!efi_rng_available())
 		return EIO;
 
-	status = uefi_call_wrapper(rng->GetRNG, 3, rng, ,
+	status = uefi_call_wrapper(rng->GetRNG, 4, rng, ,
 	len, buf);
 	if (status == EFI_UNSUPPORTED) {
 		/*
 		 * Fall back to any supported RNG `algorithm' even
 		 * though we would prefer raw samples.
 		 */
-		status = uefi_call_wrapper(rng->GetRNG, 3, rng, NULL, len, buf);
+		status = uefi_call_wrapper(rng->GetRNG, 4, rng, NULL, len, buf);
 	}
 	if (EFI_ERROR(status)) {
 		DPRINT(L"efirng: GetRNG: %r\n", status);



CVS commit: src/sys/stand/efiboot

2021-06-22 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Jun 22 10:19:35 UTC 2021

Modified Files:
src/sys/stand/efiboot: efirng.c

Log Message:
efirng: fix va_num arg to uefi_call_wrapper for GetRNG calls

As far as I can tell this param isn't actually used, but it is supposed to
be the number of arguments passed to the called method.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/stand/efiboot/efirng.c

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



CVS commit: src/sys/stand/efiboot

2021-06-21 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Jun 21 21:18:47 UTC 2021

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

Log Message:
efiboot: Add readahead support.

Reading data through libsa file-systems ends up breaking block I/O
accesses into very small (512-byte or 2048-byte) accesses. This can be
very inefficient, and causes Ampere eMAG w/ BMC image direction to take
_minutes_ to load the install image and kernel. So slow in fact that
the default watchdog timeout will fire before it finishes.

So, when loading big files, optimistically read ahead up to 64KB of data.
Brings the time to boot the install ISO down to around 40 seconds -- still
not ideal but way better than before.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/stand/efiboot/boot.c
cvs rdiff -u -r1.13 -r1.14 src/sys/stand/efiboot/efiblock.c
cvs rdiff -u -r1.5 -r1.6 src/sys/stand/efiboot/efiblock.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.31 src/sys/stand/efiboot/boot.c:1.32
--- src/sys/stand/efiboot/boot.c:1.31	Mon Jun 21 19:07:30 2021
+++ src/sys/stand/efiboot/boot.c	Mon Jun 21 21:18:47 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: boot.c,v 1.31 2021/06/21 19:07:30 nia Exp $	*/
+/*	$NetBSD: boot.c,v 1.32 2021/06/21 21:18:47 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -171,7 +171,9 @@ command_boot(char *arg)
 	if (!*bootargs)
 		bootargs = netbsd_args;
 
+	efi_block_set_readahead(true);
 	exec_netbsd(kernel, bootargs);
+	efi_block_set_readahead(false);
 }
 
 void
@@ -498,7 +500,9 @@ boot(void)
 		if (c != '\r' && c != '\n' && c != '\0')
 			bootprompt(); /* does not return */
 
+		efi_block_set_readahead(true);
 		exec_netbsd(netbsd_path, netbsd_args);
+		efi_block_set_readahead(false);
 	}
 
 	bootprompt();	/* does not return */

Index: src/sys/stand/efiboot/efiblock.c
diff -u src/sys/stand/efiboot/efiblock.c:1.13 src/sys/stand/efiboot/efiblock.c:1.14
--- src/sys/stand/efiboot/efiblock.c:1.13	Mon Jun 21 11:11:33 2021
+++ src/sys/stand/efiboot/efiblock.c	Mon Jun 21 21:18:47 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: efiblock.c,v 1.13 2021/06/21 11:11:33 jmcneill Exp $ */
+/* $NetBSD: efiblock.c,v 1.14 2021/06/21 21:18:47 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -38,6 +38,7 @@
 #include "efiboot.h"
 #include "efiblock.h"
 
+#define	EFI_BLOCK_READAHEAD	(64 * 1024)
 #define	EFI_BLOCK_TIMEOUT	120
 #define	EFI_BLOCK_TIMEOUT_CODE	0x810c
 
@@ -52,6 +53,12 @@ static EFI_HANDLE *efi_block;
 static UINTN efi_nblock;
 static struct efi_block_part *efi_block_booted = NULL;
 
+static bool efi_ra_enable = false;
+static UINT8 *efi_ra_buffer = NULL;
+static UINT32 efi_ra_media_id;
+static UINT64 efi_ra_start = 0;
+static UINT64 efi_ra_length = 0;
+
 static TAILQ_HEAD(, efi_block_dev) efi_block_devs = TAILQ_HEAD_INITIALIZER(efi_block_devs);
 
 static int
@@ -111,9 +118,51 @@ efi_block_generate_hash_mbr(struct efi_b
 }
 
 static EFI_STATUS
+efi_block_disk_readahead(struct efi_block_dev *bdev, UINT64 off, void *buf,
+UINTN bufsize)
+{
+	EFI_STATUS status;
+	UINT64 mediasize, len;
+
+	if (efi_ra_buffer == NULL) {
+		efi_ra_buffer = AllocatePool(EFI_BLOCK_READAHEAD);
+		if (efi_ra_buffer == NULL) {
+			return EFI_OUT_OF_RESOURCES;
+		}
+	}
+
+	if (bdev->media_id != efi_ra_media_id ||
+	off < efi_ra_start ||
+	off + bufsize > efi_ra_start + efi_ra_length) {
+		mediasize = bdev->bio->Media->BlockSize *
+		(bdev->bio->Media->LastBlock + 1);
+		len = EFI_BLOCK_READAHEAD;
+		if (len > mediasize - off) {
+			len = mediasize - off;
+		}
+		status = uefi_call_wrapper(bdev->dio->ReadDisk, 5, bdev->dio,
+		bdev->media_id, off, len, efi_ra_buffer);
+		if (EFI_ERROR(status)) {
+			efi_ra_start = efi_ra_length = 0;
+			return status;
+		}
+		efi_ra_start = off;
+		efi_ra_length = len;
+		efi_ra_media_id = bdev->media_id;
+	}
+
+	memcpy(buf, _ra_buffer[off - efi_ra_start], bufsize);
+	return EFI_SUCCESS;
+}
+
+static EFI_STATUS
 efi_block_disk_read(struct efi_block_dev *bdev, UINT64 off, void *buf,
 UINTN bufsize)
 {
+	if (efi_ra_enable) {
+		return efi_block_disk_readahead(bdev, off, buf, bufsize);
+	}
+
 	return uefi_call_wrapper(bdev->dio->ReadDisk, 5, bdev->dio,
 	bdev->media_id, off, bufsize, buf);
 }
@@ -588,3 +637,9 @@ efi_block_strategy(void *devdata, int rw
 
 	return 0;
 }
+
+void
+efi_block_set_readahead(bool onoff)
+{
+	efi_ra_enable = onoff;
+}

Index: src/sys/stand/efiboot/efiblock.h
diff -u src/sys/stand/efiboot/efiblock.h:1.5 src/sys/stand/efiboot/efiblock.h:1.6
--- src/sys/stand/efiboot/efiblock.h:1.5	Mon Jun 21 11:11:33 2021
+++ src/sys/stand/efiboot/efiblock.h	Mon Jun 21 21:18:47 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: efiblock.h,v 1.5 2021/06/21 11:11:33 jmcneill Exp $ */
+/* $NetBSD: efiblock.h,v 1.6 2021/06/21 21:18:47 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 

CVS commit: src/sys/stand/efiboot

2021-06-21 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Jun 21 21:18:47 UTC 2021

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

Log Message:
efiboot: Add readahead support.

Reading data through libsa file-systems ends up breaking block I/O
accesses into very small (512-byte or 2048-byte) accesses. This can be
very inefficient, and causes Ampere eMAG w/ BMC image direction to take
_minutes_ to load the install image and kernel. So slow in fact that
the default watchdog timeout will fire before it finishes.

So, when loading big files, optimistically read ahead up to 64KB of data.
Brings the time to boot the install ISO down to around 40 seconds -- still
not ideal but way better than before.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/stand/efiboot/boot.c
cvs rdiff -u -r1.13 -r1.14 src/sys/stand/efiboot/efiblock.c
cvs rdiff -u -r1.5 -r1.6 src/sys/stand/efiboot/efiblock.h

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



CVS commit: src/sys/stand/efiboot

2021-06-21 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Mon Jun 21 19:07:30 UTC 2021

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

Log Message:
efiboot: Add ASCII art.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/stand/efiboot/boot.c

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.30 src/sys/stand/efiboot/boot.c:1.31
--- src/sys/stand/efiboot/boot.c:1.30	Mon May 31 11:12:42 2021
+++ src/sys/stand/efiboot/boot.c	Mon Jun 21 19:07:30 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: boot.c,v 1.30 2021/05/31 11:12:42 rin Exp $	*/
+/*	$NetBSD: boot.c,v 1.31 2021/06/21 19:07:30 nia Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -451,9 +451,13 @@ set_bootargs(const char *arg)
 void
 print_banner(void)
 {
-	printf("\n\n"
-	">> %s, Revision %s\n",
-	bootprog_name, bootprog_rev);
+	printf("  \\-__,--,___.\n");
+	printf("   \\__,---`  %s\n", bootprog_name);
+	printf("\\   `---,_.  Revision %s\n", bootprog_rev);
+	printf(" \\-,_,.---`\n");
+	printf("  \\\n");
+	printf("   \\\n");
+	printf("\\\n\n");
 }
 
 void



CVS commit: src/sys/stand/efiboot

2021-06-21 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Mon Jun 21 19:07:30 UTC 2021

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

Log Message:
efiboot: Add ASCII art.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/stand/efiboot/boot.c

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



CVS commit: src/sys/stand/efiboot

2021-06-21 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Jun 21 11:11:33 UTC 2021

Modified Files:
src/sys/stand/efiboot: efiblock.c efiblock.h version

Log Message:
efiboot: Use disk I/O protocol for block device access.

EFI_DISK_IO_PROTOCOL is a simplified interface to block devices. Use this
instead of EFI_BLOCK_IO_PROTOCOL for accessing block devices to simplify
the code -- we no longer need to worry about the underlying media's block
I/O size and alignment requirements.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/stand/efiboot/efiblock.c
cvs rdiff -u -r1.4 -r1.5 src/sys/stand/efiboot/efiblock.h
cvs rdiff -u -r1.26 -r1.27 src/sys/stand/efiboot/version

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/efiblock.c
diff -u src/sys/stand/efiboot/efiblock.c:1.12 src/sys/stand/efiboot/efiblock.c:1.13
--- src/sys/stand/efiboot/efiblock.c:1.12	Sun Jun 20 19:10:47 2021
+++ src/sys/stand/efiboot/efiblock.c	Mon Jun 21 11:11:33 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: efiblock.c,v 1.12 2021/06/20 19:10:47 jmcneill Exp $ */
+/* $NetBSD: efiblock.c,v 1.13 2021/06/21 11:11:33 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -110,68 +110,41 @@ efi_block_generate_hash_mbr(struct efi_b
 	MD5Final(bpart->hash, );
 }
 
-static void *
-efi_block_allocate_device_buffer(struct efi_block_dev *bdev, UINTN size,
-	void **buf_start)
+static EFI_STATUS
+efi_block_disk_read(struct efi_block_dev *bdev, UINT64 off, void *buf,
+UINTN bufsize)
 {
-	void *buf;
-
-	if (bdev->bio->Media->IoAlign <= 1)
-		*buf_start = buf = AllocatePool(size);
-	else {
-		buf = AllocatePool(size + bdev->bio->Media->IoAlign - 1);
-		*buf_start = (buf == NULL) ? NULL :
-		(void *)roundup2((intptr_t)buf, bdev->bio->Media->IoAlign);
-	}
-
-	return buf;
+	return uefi_call_wrapper(bdev->dio->ReadDisk, 5, bdev->dio,
+	bdev->media_id, off, bufsize, buf);
 }
 
 static int
 efi_block_find_partitions_cd9660(struct efi_block_dev *bdev)
 {
 	struct efi_block_part *bpart;
-	struct iso_primary_descriptor *vd;
-	void *buf, *buf_start;
+	struct iso_primary_descriptor vd;
 	EFI_STATUS status;
 	EFI_LBA lba;
-	UINT32 sz;
-
-	if (bdev->bio->Media->BlockSize != DEV_BSIZE &&
-	bdev->bio->Media->BlockSize != ISO_DEFAULT_BLOCK_SIZE) {
-		return ENXIO;
-	}
-
-	sz = __MAX(sizeof(*vd), bdev->bio->Media->BlockSize);
-	sz = roundup(sz, bdev->bio->Media->BlockSize);
-	if ((buf = efi_block_allocate_device_buffer(bdev, sz, _start)) == NULL) {
-		return ENOMEM;
-	}
 
 	for (lba = 16;; lba++) {
-		status = uefi_call_wrapper(bdev->bio->ReadBlocks, 5,
-		bdev->bio,
-		bdev->media_id,
-		lba * ISO_DEFAULT_BLOCK_SIZE / bdev->bio->Media->BlockSize,
-		sz,
-		buf_start);
+		status = efi_block_disk_read(bdev,
+		lba * ISO_DEFAULT_BLOCK_SIZE, , sizeof(vd));
 		if (EFI_ERROR(status)) {
 			goto io_error;
 		}
 
-		vd = (struct iso_primary_descriptor *)buf_start;
-		if (memcmp(vd->id, ISO_STANDARD_ID, sizeof vd->id) != 0) {
+		if (memcmp(vd.id, ISO_STANDARD_ID, sizeof vd.id) != 0) {
 			goto io_error;
 		}
-		if (isonum_711(vd->type) == ISO_VD_END) {
+		if (isonum_711(vd.type) == ISO_VD_END) {
 			goto io_error;
 		}
-		if (isonum_711(vd->type) == ISO_VD_PRIMARY) {
+		if (isonum_711(vd.type) == ISO_VD_PRIMARY) {
 			break;
 		}
 	}
 
-	if (isonum_723(vd->logical_block_size) != ISO_DEFAULT_BLOCK_SIZE) {
+	if (isonum_723(vd.logical_block_size) != ISO_DEFAULT_BLOCK_SIZE) {
 		goto io_error;
 	}
 
@@ -181,39 +154,29 @@ efi_block_find_partitions_cd9660(struct 
 	bpart->type = EFI_BLOCK_PART_CD9660;
 	TAILQ_INSERT_TAIL(>partitions, bpart, entries);
 
-	FreePool(buf);
 	return 0;
 
 io_error:
-	FreePool(buf);
 	return EIO;
 }
 
 static int
-efi_block_find_partitions_disklabel(struct efi_block_dev *bdev, struct mbr_sector *mbr, uint32_t start, uint32_t size)
+efi_block_find_partitions_disklabel(struct efi_block_dev *bdev,
+struct mbr_sector *mbr, uint32_t start, uint32_t size)
 {
 	struct efi_block_part *bpart;
+	char buf[DEV_BSIZE];
 	struct disklabel d;
 	struct partition *p;
 	EFI_STATUS status;
-	EFI_LBA lba;
-	void *buf, *buf_start;
-	UINT32 sz;
 	int n;
 
-	sz = __MAX(sizeof(d), bdev->bio->Media->BlockSize);
-	sz = roundup(sz, bdev->bio->Media->BlockSize);
-	if ((buf = efi_block_allocate_device_buffer(bdev, sz, _start)) == NULL)
-		return ENOMEM;
-
-	lba = (((EFI_LBA)start + LABELSECTOR) * DEV_BSIZE) / bdev->bio->Media->BlockSize;
-	status = uefi_call_wrapper(bdev->bio->ReadBlocks, 5, bdev->bio, bdev->media_id,
-		lba, sz, buf_start);
-	if (EFI_ERROR(status) || getdisklabel(buf_start, ) != NULL) {
+	status = efi_block_disk_read(bdev,
+	((EFI_LBA)start + LABELSECTOR) * DEV_BSIZE, buf, sizeof(buf));
+	if (EFI_ERROR(status) || getdisklabel(buf, ) != NULL) {
 		FreePool(buf);
 		return EIO;
 	}
-	FreePool(buf);
 
 	if (le32toh(d.d_magic) != DISKMAGIC || le32toh(d.d_magic2) != DISKMAGIC)
 		

CVS commit: src/sys/stand/efiboot

2021-06-21 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Jun 21 11:11:33 UTC 2021

Modified Files:
src/sys/stand/efiboot: efiblock.c efiblock.h version

Log Message:
efiboot: Use disk I/O protocol for block device access.

EFI_DISK_IO_PROTOCOL is a simplified interface to block devices. Use this
instead of EFI_BLOCK_IO_PROTOCOL for accessing block devices to simplify
the code -- we no longer need to worry about the underlying media's block
I/O size and alignment requirements.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 src/sys/stand/efiboot/efiblock.c
cvs rdiff -u -r1.4 -r1.5 src/sys/stand/efiboot/efiblock.h
cvs rdiff -u -r1.26 -r1.27 src/sys/stand/efiboot/version

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



CVS commit: src/sys/stand/efiboot

2021-06-20 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Jun 20 19:10:47 UTC 2021

Modified Files:
src/sys/stand/efiboot: Makefile.efiboot efiblock.c efiboot.h version
Added Files:
src/sys/stand/efiboot: efiwatchdog.c

Log Message:
Add support for the boot services watchdog and pet it on every block I/O
access. For slow media (like ISO image redirection on Lenovo HR330A BMC)
this is needed because otherwise the default watchdog timeout fires before
we can finish loading the kernel from install media.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/stand/efiboot/Makefile.efiboot
cvs rdiff -u -r1.11 -r1.12 src/sys/stand/efiboot/efiblock.c
cvs rdiff -u -r1.14 -r1.15 src/sys/stand/efiboot/efiboot.h
cvs rdiff -u -r0 -r1.1 src/sys/stand/efiboot/efiwatchdog.c
cvs rdiff -u -r1.25 -r1.26 src/sys/stand/efiboot/version

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



CVS commit: src/sys/stand/efiboot

2021-06-20 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Jun 20 19:10:47 UTC 2021

Modified Files:
src/sys/stand/efiboot: Makefile.efiboot efiblock.c efiboot.h version
Added Files:
src/sys/stand/efiboot: efiwatchdog.c

Log Message:
Add support for the boot services watchdog and pet it on every block I/O
access. For slow media (like ISO image redirection on Lenovo HR330A BMC)
this is needed because otherwise the default watchdog timeout fires before
we can finish loading the kernel from install media.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/stand/efiboot/Makefile.efiboot
cvs rdiff -u -r1.11 -r1.12 src/sys/stand/efiboot/efiblock.c
cvs rdiff -u -r1.14 -r1.15 src/sys/stand/efiboot/efiboot.h
cvs rdiff -u -r0 -r1.1 src/sys/stand/efiboot/efiwatchdog.c
cvs rdiff -u -r1.25 -r1.26 src/sys/stand/efiboot/version

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/Makefile.efiboot
diff -u src/sys/stand/efiboot/Makefile.efiboot:1.21 src/sys/stand/efiboot/Makefile.efiboot:1.22
--- src/sys/stand/efiboot/Makefile.efiboot:1.21	Thu May 27 06:54:45 2021
+++ src/sys/stand/efiboot/Makefile.efiboot	Sun Jun 20 19:10:47 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.efiboot,v 1.21 2021/05/27 06:54:45 mrg Exp $
+# $NetBSD: Makefile.efiboot,v 1.22 2021/06/20 19:10:47 jmcneill Exp $
 
 S=		${.CURDIR}/../../..
 
@@ -24,7 +24,8 @@ SOURCES=	crt0-efi-${GNUEFIARCH}.S reloc_
 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 efigetsecs.c efifdt.c \
-		efifile.c efiblock.c efinet.c efipxe.c efiacpi.c efirng.c smbios.c
+		efifile.c efiblock.c efinet.c efipxe.c efiacpi.c efirng.c efiwatchdog.c \
+	   	smbios.c
 
 .PATH: ${S}/external/bsd/libfdt/dist
 CPPFLAGS+=	-I${S}/external/bsd/libfdt/dist

Index: src/sys/stand/efiboot/efiblock.c
diff -u src/sys/stand/efiboot/efiblock.c:1.11 src/sys/stand/efiboot/efiblock.c:1.12
--- src/sys/stand/efiboot/efiblock.c:1.11	Wed May 26 09:42:36 2021
+++ src/sys/stand/efiboot/efiblock.c	Sun Jun 20 19:10:47 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: efiblock.c,v 1.11 2021/05/26 09:42:36 mrg Exp $ */
+/* $NetBSD: efiblock.c,v 1.12 2021/06/20 19:10:47 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -38,6 +38,9 @@
 #include "efiboot.h"
 #include "efiblock.h"
 
+#define	EFI_BLOCK_TIMEOUT	120
+#define	EFI_BLOCK_TIMEOUT_CODE	0x810c
+
 /*
  * The raidframe support is basic.  Ideally, it should be expanded to
  * consider raid volumes a first-class citizen like the x86 efiboot does,
@@ -605,6 +608,8 @@ efi_block_strategy(void *devdata, int rw
 	if (rw != F_READ)
 		return EROFS;
 
+	efi_set_watchdog(EFI_BLOCK_TIMEOUT, EFI_BLOCK_TIMEOUT_CODE);
+
 	switch (bpart->type) {
 	case EFI_BLOCK_PART_DISKLABEL:
 		if (bpart->bdev->bio->Media->BlockSize != bpart->disklabel.secsize) {

Index: src/sys/stand/efiboot/efiboot.h
diff -u src/sys/stand/efiboot/efiboot.h:1.14 src/sys/stand/efiboot/efiboot.h:1.15
--- src/sys/stand/efiboot/efiboot.h:1.14	Sun Oct 11 14:03:33 2020
+++ src/sys/stand/efiboot/efiboot.h	Sun Jun 20 19:10:47 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: efiboot.h,v 1.14 2020/10/11 14:03:33 jmcneill Exp $	*/
+/*	$NetBSD: efiboot.h,v 1.15 2021/06/20 19:10:47 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -104,6 +104,9 @@ extern struct netif_driver efinetif;
 void efi_pxe_probe(void);
 bool efi_pxe_match_booted_interface(const EFI_MAC_ADDRESS *, UINT32);
 
+/* efiwatchdog.c */
+void efi_set_watchdog(uint32_t, uint64_t);
+
 /* exec.c */
 int exec_netbsd(const char *, const char *);
 

Index: src/sys/stand/efiboot/version
diff -u src/sys/stand/efiboot/version:1.25 src/sys/stand/efiboot/version:1.26
--- src/sys/stand/efiboot/version:1.25	Thu May 27 06:54:45 2021
+++ src/sys/stand/efiboot/version	Sun Jun 20 19:10:47 2021
@@ -1,4 +1,4 @@
-$NetBSD: version,v 1.25 2021/05/27 06:54:45 mrg Exp $
+$NetBSD: version,v 1.26 2021/06/20 19:10:47 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
@@ -29,3 +29,4 @@ is taken as the current.
 2.6:	Disable ACPI support when booting big endian kernels.
 2.7:	Add basic support for booting from RAID1 volumes.
 2.8:	Add bi-endian disklabel and FFS support.
+2.9:	Watchdog support.

Added files:

Index: src/sys/stand/efiboot/efiwatchdog.c
diff -u /dev/null src/sys/stand/efiboot/efiwatchdog.c:1.1
--- /dev/null	Sun Jun 20 19:10:47 2021
+++ src/sys/stand/efiboot/efiwatchdog.c	Sun Jun 20 19:10:47 2021
@@ -0,0 +1,40 @@
+/* $NetBSD: efiwatchdog.c,v 1.1 2021/06/20 19:10:47 jmcneill Exp $ */
+
+/*-
+ * Copyright (c) 2021 Jared McNeill 
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ 

CVS commit: src/sys/stand/efiboot

2021-06-20 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Jun 20 19:07:39 UTC 2021

Modified Files:
src/sys/stand/efiboot: exec.c

Log Message:
Enable the twiddle spinner when loading the kernel, ramdisk images, and
modules.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/stand/efiboot/exec.c

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/exec.c
diff -u src/sys/stand/efiboot/exec.c:1.21 src/sys/stand/efiboot/exec.c:1.22
--- src/sys/stand/efiboot/exec.c:1.21	Fri May 21 21:53:15 2021
+++ src/sys/stand/efiboot/exec.c	Sun Jun 20 19:07:39 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: exec.c,v 1.21 2021/05/21 21:53:15 jmcneill Exp $ */
+/* $NetBSD: exec.c,v 1.22 2021/06/20 19:07:39 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2019 Jason R. Thorpe
@@ -246,6 +246,8 @@ exec_netbsd(const char *fname, const cha
 	EFI_STATUS status;
 	int fd, ohowto;
 
+	twiddle_toggle = 0;
+
 	load_file(get_initrd_path(), 0, false, _addr, _size);
 	load_file(get_dtb_path(), 0, false, _addr, _size);
 	generate_efirng();



CVS commit: src/sys/stand/efiboot

2021-06-20 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Jun 20 19:07:39 UTC 2021

Modified Files:
src/sys/stand/efiboot: exec.c

Log Message:
Enable the twiddle spinner when loading the kernel, ramdisk images, and
modules.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/stand/efiboot/exec.c

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



CVS commit: src/sys/stand/efiboot

2021-05-31 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon May 31 11:12:42 UTC 2021

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

Log Message:
Generalize boot.cfg workaround for ISO9660; fallback to default_device
whenever efi_file_path() fails (due to broken firmware), in addition to
the case of ISO9660 (for which efi_file_path() succeeds but does not
work correctly).


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/stand/efiboot/boot.c

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.29 src/sys/stand/efiboot/boot.c:1.30
--- src/sys/stand/efiboot/boot.c:1.29	Sat Nov 28 14:02:09 2020
+++ src/sys/stand/efiboot/boot.c	Mon May 31 11:12:42 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: boot.c,v 1.29 2020/11/28 14:02:09 jmcneill Exp $	*/
+/*	$NetBSD: boot.c,v 1.30 2021/05/31 11:12:42 rin Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -132,22 +132,18 @@ const struct boot_command commands[] = {
 static int
 bootcfg_path(char *pathbuf, size_t pathbuflen)
 {
-	/*
-	 * Special handling of boot.cfg on ISO9660 because fs protocol doesn't
-	 * seem to work.
-	 */
-	if (default_fstype == FS_ISO9660) {
-		snprintf(pathbuf, pathbuflen, "%s:%s", default_device, BOOTCFG_FILENAME);
-		return 0;
-	}
 
 	/*
-	 * Fall back to fs protocol for loading boot.cfg
+	 * Fallback to default_device
+	 * - for ISO9660 (efi_file_path() succeeds but does not work correctly)
+	 * - or whenever efi_file_path() fails (due to broken firmware)
 	 */
-	if (efi_bootdp == NULL)
-		return ENXIO;
+	if (default_fstype == FS_ISO9660 || efi_bootdp == NULL ||
+	efi_file_path(efi_bootdp, BOOTCFG_FILENAME, pathbuf, pathbuflen))
+		snprintf(pathbuf, pathbuflen, "%s:%s", default_device,
+		BOOTCFG_FILENAME);
 
-	return efi_file_path(efi_bootdp, BOOTCFG_FILENAME, pathbuf, pathbuflen);
+	return 0;
 }
 
 void



CVS commit: src/sys/stand/efiboot

2021-05-31 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon May 31 11:12:42 UTC 2021

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

Log Message:
Generalize boot.cfg workaround for ISO9660; fallback to default_device
whenever efi_file_path() fails (due to broken firmware), in addition to
the case of ISO9660 (for which efi_file_path() succeeds but does not
work correctly).


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/stand/efiboot/boot.c

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



CVS commit: src/sys/stand/efiboot

2021-05-26 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed May 26 09:42:36 UTC 2021

Modified Files:
src/sys/stand/efiboot: efiblock.c version

Log Message:
add basic raidframe support to efiboot.

if raid disklabel or gpt is found, add this partition with
the offset/size adjusted by RF_PROTECTED_SECTORS.  note

don't le32toh() the disklabel.  if it was wrong-endian, then
getdisklabel() will have swapped it.

ok jmcneill thorpej.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/stand/efiboot/efiblock.c
cvs rdiff -u -r1.23 -r1.24 src/sys/stand/efiboot/version

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/efiblock.c
diff -u src/sys/stand/efiboot/efiblock.c:1.10 src/sys/stand/efiboot/efiblock.c:1.11
--- src/sys/stand/efiboot/efiblock.c:1.10	Sat Nov 28 15:24:05 2020
+++ src/sys/stand/efiboot/efiblock.c	Wed May 26 09:42:36 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: efiblock.c,v 1.10 2020/11/28 15:24:05 jmcneill Exp $ */
+/* $NetBSD: efiblock.c,v 1.11 2021/05/26 09:42:36 mrg Exp $ */
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -38,6 +38,13 @@
 #include "efiboot.h"
 #include "efiblock.h"
 
+/*
+ * The raidframe support is basic.  Ideally, it should be expanded to
+ * consider raid volumes a first-class citizen like the x86 efiboot does,
+ * but for now, we simply assume each RAID is potentially bootable.
+ */
+#define	RF_PROTECTED_SECTORS	64	/* XXX refer to <.../rf_optnames.h> */
+
 static EFI_HANDLE *efi_block;
 static UINTN efi_nblock;
 static struct efi_block_part *efi_block_booted = NULL;
@@ -217,6 +224,10 @@ efi_block_find_partitions_disklabel(stru
 		case FS_MSDOS:
 		case FS_BSDLFS:
 			break;
+		case FS_RAID:
+			p->p_size -= RF_PROTECTED_SECTORS;
+			p->p_offset += RF_PROTECTED_SECTORS;
+			break;
 		default:
 			continue;
 		}
@@ -225,7 +236,7 @@ efi_block_find_partitions_disklabel(stru
 		bpart->index = n;
 		bpart->bdev = bdev;
 		bpart->type = EFI_BLOCK_PART_DISKLABEL;
-		bpart->disklabel.secsize = le32toh(d.d_secsize);
+		bpart->disklabel.secsize = d.d_secsize;
 		bpart->disklabel.part = *p;
 		efi_block_generate_hash_mbr(bpart, mbr);
 		TAILQ_INSERT_TAIL(>partitions, bpart, entries);
@@ -310,6 +321,10 @@ efi_block_find_partitions_gpt_entry(stru
 	bpart->type = EFI_BLOCK_PART_GPT;
 	bpart->gpt.fstype = fstype;
 	bpart->gpt.ent = *ent;
+	if (fstype == FS_RAID) {
+		bpart->gpt.ent.ent_lba_start += RF_PROTECTED_SECTORS;
+		bpart->gpt.ent.ent_lba_end -= RF_PROTECTED_SECTORS;
+	}
 	memcpy(bpart->hash, ent->ent_guid, sizeof(bpart->hash));
 	TAILQ_INSERT_TAIL(>partitions, bpart, entries);
 
@@ -436,7 +451,7 @@ efi_block_probe(void)
 	fstype = FS_ISO9660;
 	break;
 }
-if (fstype == FS_BSDFFS || fstype == FS_ISO9660) {
+if (fstype == FS_BSDFFS || fstype == FS_ISO9660 || fstype == FS_RAID) {
 	char devname[9];
 	snprintf(devname, sizeof(devname), "hd%u%c", bdev->index, bpart->index + 'a');
 	set_default_device(devname);

Index: src/sys/stand/efiboot/version
diff -u src/sys/stand/efiboot/version:1.23 src/sys/stand/efiboot/version:1.24
--- src/sys/stand/efiboot/version:1.23	Fri May 21 21:53:15 2021
+++ src/sys/stand/efiboot/version	Wed May 26 09:42:36 2021
@@ -1,4 +1,4 @@
-$NetBSD: version,v 1.23 2021/05/21 21:53:15 jmcneill Exp $
+$NetBSD: version,v 1.24 2021/05/26 09:42:36 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
@@ -27,3 +27,4 @@ is taken as the current.
 2.4:	Add ISO9660 support.
 2.5:	Recognize the EFI system partion as fstype MSDOS.
 2.6:	Disable ACPI support when booting big endian kernels.
+2.7:	Add basic support for booting from RAID1 volumes.



CVS commit: src/sys/stand/efiboot

2021-05-26 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Wed May 26 09:42:36 UTC 2021

Modified Files:
src/sys/stand/efiboot: efiblock.c version

Log Message:
add basic raidframe support to efiboot.

if raid disklabel or gpt is found, add this partition with
the offset/size adjusted by RF_PROTECTED_SECTORS.  note

don't le32toh() the disklabel.  if it was wrong-endian, then
getdisklabel() will have swapped it.

ok jmcneill thorpej.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/stand/efiboot/efiblock.c
cvs rdiff -u -r1.23 -r1.24 src/sys/stand/efiboot/version

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



CVS commit: src/sys/stand/efiboot

2021-05-21 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri May 21 21:53:15 UTC 2021

Modified Files:
src/sys/stand/efiboot: efiacpi.c efiacpi.h efifdt.c exec.c version

Log Message:
Disable ACPI support when booting big endian kernels.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/stand/efiboot/efiacpi.c
cvs rdiff -u -r1.1 -r1.2 src/sys/stand/efiboot/efiacpi.h
cvs rdiff -u -r1.28 -r1.29 src/sys/stand/efiboot/efifdt.c
cvs rdiff -u -r1.20 -r1.21 src/sys/stand/efiboot/exec.c
cvs rdiff -u -r1.22 -r1.23 src/sys/stand/efiboot/version

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/efiacpi.c
diff -u src/sys/stand/efiboot/efiacpi.c:1.8 src/sys/stand/efiboot/efiacpi.c:1.9
--- src/sys/stand/efiboot/efiacpi.c:1.8	Sat Oct 10 19:17:39 2020
+++ src/sys/stand/efiboot/efiacpi.c	Fri May 21 21:53:15 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: efiacpi.c,v 1.8 2020/10/10 19:17:39 jmcneill Exp $ */
+/* $NetBSD: efiacpi.c,v 1.9 2021/05/21 21:53:15 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -53,6 +53,7 @@ struct acpi_rdsp {
 static EFI_GUID Acpi20TableGuid = ACPI_20_TABLE_GUID;
 static EFI_GUID Smbios3TableGuid = SMBIOS3_TABLE_GUID;
 
+static int acpi_enable = 1;
 static void *acpi_root = NULL;
 static void *smbios3_table = NULL;
 
@@ -78,6 +79,18 @@ efi_acpi_available(void)
 	return acpi_root != NULL;
 }
 
+int
+efi_acpi_enabled(void)
+{
+	return acpi_enable;
+}
+
+void
+efi_acpi_enable(int enable)
+{
+	acpi_enable = enable;
+}
+
 static char model_buf[128];
 
 static const char *

Index: src/sys/stand/efiboot/efiacpi.h
diff -u src/sys/stand/efiboot/efiacpi.h:1.1 src/sys/stand/efiboot/efiacpi.h:1.2
--- src/sys/stand/efiboot/efiacpi.h:1.1	Fri Oct 12 22:08:04 2018
+++ src/sys/stand/efiboot/efiacpi.h	Fri May 21 21:53:15 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: efiacpi.h,v 1.1 2018/10/12 22:08:04 jmcneill Exp $ */
+/* $NetBSD: efiacpi.h,v 1.2 2021/05/21 21:53:15 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 The NetBSD Foundation, Inc.
@@ -32,4 +32,6 @@
 int efi_acpi_probe(void);
 void efi_acpi_show(void);
 int efi_acpi_available(void);
+int efi_acpi_enabled(void);
+void efi_acpi_enable(int);
 int efi_acpi_create_fdt(void);

Index: src/sys/stand/efiboot/efifdt.c
diff -u src/sys/stand/efiboot/efifdt.c:1.28 src/sys/stand/efiboot/efifdt.c:1.29
--- src/sys/stand/efiboot/efifdt.c:1.28	Sat Dec 19 08:09:31 2020
+++ src/sys/stand/efiboot/efifdt.c	Fri May 21 21:53:15 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: efifdt.c,v 1.28 2020/12/19 08:09:31 skrll Exp $ */
+/* $NetBSD: efifdt.c,v 1.29 2021/05/21 21:53:15 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2019 Jason R. Thorpe
@@ -370,7 +370,7 @@ efi_fdt_gop(void)
 		/*
 		 * In ACPI mode, use GOP as console.
 		 */
-		if (efi_acpi_available()) {
+		if (efi_acpi_available() && efi_acpi_enabled()) {
 			snprintf(buf, sizeof(buf), "/chosen/framebuffer@%" PRIx64, mode->FrameBufferBase);
 			fdt_setprop_string(fdt_data, chosen, "stdout-path", buf);
 		}

Index: src/sys/stand/efiboot/exec.c
diff -u src/sys/stand/efiboot/exec.c:1.20 src/sys/stand/efiboot/exec.c:1.21
--- src/sys/stand/efiboot/exec.c:1.20	Tue May 11 07:15:10 2021
+++ src/sys/stand/efiboot/exec.c	Fri May 21 21:53:15 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: exec.c,v 1.20 2021/05/11 07:15:10 skrll Exp $ */
+/* $NetBSD: exec.c,v 1.21 2021/05/21 21:53:15 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2019 Jason R. Thorpe
@@ -289,7 +289,10 @@ exec_netbsd(const char *fname, const cha
 	load_offset = 0;
 
 #ifdef EFIBOOT_ACPI
-	if (efi_acpi_available()) {
+	/* ACPI support only works for little endian kernels */
+	efi_acpi_enable(netbsd_elf_data == ELFDATA2LSB);
+
+	if (efi_acpi_available() && efi_acpi_enabled()) {
 		efi_acpi_create_fdt();
 	} else
 #endif

Index: src/sys/stand/efiboot/version
diff -u src/sys/stand/efiboot/version:1.22 src/sys/stand/efiboot/version:1.23
--- src/sys/stand/efiboot/version:1.22	Sun Oct 18 18:09:32 2020
+++ src/sys/stand/efiboot/version	Fri May 21 21:53:15 2021
@@ -1,4 +1,4 @@
-$NetBSD: version,v 1.22 2020/10/18 18:09:32 tnn Exp $
+$NetBSD: version,v 1.23 2021/05/21 21:53:15 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
@@ -26,3 +26,4 @@ is taken as the current.
 2.3:	EFI RT and GOP support for devicetree mode.
 2.4:	Add ISO9660 support.
 2.5:	Recognize the EFI system partion as fstype MSDOS.
+2.6:	Disable ACPI support when booting big endian kernels.



CVS commit: src/sys/stand/efiboot

2021-05-21 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Fri May 21 21:53:15 UTC 2021

Modified Files:
src/sys/stand/efiboot: efiacpi.c efiacpi.h efifdt.c exec.c version

Log Message:
Disable ACPI support when booting big endian kernels.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/stand/efiboot/efiacpi.c
cvs rdiff -u -r1.1 -r1.2 src/sys/stand/efiboot/efiacpi.h
cvs rdiff -u -r1.28 -r1.29 src/sys/stand/efiboot/efifdt.c
cvs rdiff -u -r1.20 -r1.21 src/sys/stand/efiboot/exec.c
cvs rdiff -u -r1.22 -r1.23 src/sys/stand/efiboot/version

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



CVS commit: src/sys/stand/efiboot

2021-05-11 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue May 11 07:15:10 UTC 2021

Modified Files:
src/sys/stand/efiboot: exec.c

Log Message:
Consistently have ALIGN sizes as the power of two size, i.e. change
FDT_ALIGN, and use the same math(s) to round.

In the process fix the load_offset for the kernel to use the EFIBOOT_ALIGN
aligned address if that's what we get from AllocatePages.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/stand/efiboot/exec.c

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/exec.c
diff -u src/sys/stand/efiboot/exec.c:1.19 src/sys/stand/efiboot/exec.c:1.20
--- src/sys/stand/efiboot/exec.c:1.19	Sat Oct 10 19:17:39 2020
+++ src/sys/stand/efiboot/exec.c	Tue May 11 07:15:10 2021
@@ -1,4 +1,4 @@
-/* $NetBSD: exec.c,v 1.19 2020/10/10 19:17:39 jmcneill Exp $ */
+/* $NetBSD: exec.c,v 1.20 2021/05/11 07:15:10 skrll Exp $ */
 
 /*-
  * Copyright (c) 2019 Jason R. Thorpe
@@ -42,7 +42,7 @@ extern char twiddle_toggle;
 u_long load_offset = 0;
 
 #define	FDT_SPACE	(4 * 1024 * 1024)
-#define	FDT_ALIGN	((2 * 1024 * 1024) - 1)
+#define	FDT_ALIGN	(2 * 1024 * 1024)
 
 static EFI_PHYSICAL_ADDRESS initrd_addr, dtb_addr, rndseed_addr, efirng_addr;
 static u_long initrd_size = 0, dtb_size = 0, rndseed_size = 0, efirng_size = 0;
@@ -260,7 +260,7 @@ exec_netbsd(const char *fname, const cha
 		return EIO;
 	}
 	close(fd);
-	marks[MARK_END] = (((u_long) marks[MARK_END] + sizeof(int) - 1)) & (-sizeof(int));
+	marks[MARK_END] = (((u_long) marks[MARK_END] + sizeof(int) - 1)) & -sizeof(int);
 	alloc_size = marks[MARK_END] - marks[MARK_START] + FDT_SPACE + EFIBOOT_ALIGN;
 
 #ifdef EFIBOOT_ALLOCATE_MAX_ADDRESS
@@ -279,7 +279,7 @@ exec_netbsd(const char *fname, const cha
 	}
 
 	memset(marks, 0, sizeof(marks));
-	load_offset = (addr + EFIBOOT_ALIGN) & ~(EFIBOOT_ALIGN - 1);
+	load_offset = (addr + EFIBOOT_ALIGN - 1) & -EFIBOOT_ALIGN;
 	fd = loadfile(fname, marks, LOAD_KERNEL);
 	if (fd < 0) {
 		printf("boot: %s: %s\n", fname, strerror(errno));
@@ -308,7 +308,7 @@ exec_netbsd(const char *fname, const cha
 		load_file(get_rndseed_path(), 0, false,
 		_addr, _size);
 
-		efi_fdt_init((marks[MARK_END] + FDT_ALIGN) & ~FDT_ALIGN, FDT_ALIGN + 1);
+		efi_fdt_init((marks[MARK_END] + FDT_ALIGN - 1) & -FDT_ALIGN, FDT_ALIGN);
 		load_modules(fname);
 		load_fdt_overlays();
 		efi_fdt_initrd(initrd_addr, initrd_size);



CVS commit: src/sys/stand/efiboot

2021-05-11 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Tue May 11 07:15:10 UTC 2021

Modified Files:
src/sys/stand/efiboot: exec.c

Log Message:
Consistently have ALIGN sizes as the power of two size, i.e. change
FDT_ALIGN, and use the same math(s) to round.

In the process fix the load_offset for the kernel to use the EFIBOOT_ALIGN
aligned address if that's what we get from AllocatePages.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/stand/efiboot/exec.c

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



CVS commit: src/sys/stand/efiboot

2021-05-04 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue May  4 19:07:19 UTC 2021

Modified Files:
src/sys/stand/efiboot: Makefile.efiboot

Log Message:
Set VERSIONMACHINE to ${MACHINE} instead of evbarm (oops)


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/stand/efiboot/Makefile.efiboot

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



CVS commit: src/sys/stand/efiboot

2021-05-04 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue May  4 19:07:19 UTC 2021

Modified Files:
src/sys/stand/efiboot: Makefile.efiboot

Log Message:
Set VERSIONMACHINE to ${MACHINE} instead of evbarm (oops)


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/stand/efiboot/Makefile.efiboot

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/Makefile.efiboot
diff -u src/sys/stand/efiboot/Makefile.efiboot:1.19 src/sys/stand/efiboot/Makefile.efiboot:1.20
--- src/sys/stand/efiboot/Makefile.efiboot:1.19	Sun Oct 11 14:03:33 2020
+++ src/sys/stand/efiboot/Makefile.efiboot	Tue May  4 19:07:19 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.efiboot,v 1.19 2020/10/11 14:03:33 jmcneill Exp $
+# $NetBSD: Makefile.efiboot,v 1.20 2021/05/04 19:07:19 jmcneill Exp $
 
 S=		${.CURDIR}/../../..
 
@@ -137,7 +137,7 @@ cleanlibdir:
 
 LIBLIST= ${LIBGNUEFI} ${LIBSA} ${LIBZ} ${LIBKERN} ${LIBSA}
 
-VERSIONMACHINE=evbarm
+VERSIONMACHINE=${MACHINE}
 .include "${S}/conf/newvers_stand.mk"
 
 CLEANFILES+=	${PROG}.so ${PROG}.tmp



CVS commit: src/sys/stand/efiboot/bootriscv64

2021-05-02 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun May  2 15:22:27 UTC 2021

Added Files:
src/sys/stand/efiboot/bootriscv64: Makefile efibootriscv64.c

Log Message:
Add RISC-V 64-bit support.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/stand/efiboot/bootriscv64/Makefile \
src/sys/stand/efiboot/bootriscv64/efibootriscv64.c

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

Added files:

Index: src/sys/stand/efiboot/bootriscv64/Makefile
diff -u /dev/null src/sys/stand/efiboot/bootriscv64/Makefile:1.1
--- /dev/null	Sun May  2 15:22:27 2021
+++ src/sys/stand/efiboot/bootriscv64/Makefile	Sun May  2 15:22:27 2021
@@ -0,0 +1,20 @@
+# $NetBSD: Makefile,v 1.1 2021/05/02 15:22:27 jmcneill Exp $
+
+PROG=		bootriscv64.efi
+OBJFMT=		binary
+NEWVERSWHAT=	"efiboot (riscv64)"
+GNUEFIARCH=	riscv64
+LIBGNUEFI_ARCH=	riscv64
+
+EXTRA_SOURCES=	efibootriscv64.c
+
+COPTS+=		-mcmodel=medany
+AFLAGS+=	-x assembler-with-cpp
+CFLAGS+=	-DEFIBOOT_ALIGN=0x20
+CFLAGS+=	-DEFIBOOT_MODULE_MACHINE=\"riscv\"
+
+.include "${.CURDIR}/../Makefile.efiboot"
+
+release: check_RELEASEDIR
+	${HOST_INSTALL_FILE} -m ${BINMODE} ${PROG} \
+		${RELEASEDIR}/${RELEASEMACHINEDIR}/installation/misc
Index: src/sys/stand/efiboot/bootriscv64/efibootriscv64.c
diff -u /dev/null src/sys/stand/efiboot/bootriscv64/efibootriscv64.c:1.1
--- /dev/null	Sun May  2 15:22:27 2021
+++ src/sys/stand/efiboot/bootriscv64/efibootriscv64.c	Sun May  2 15:22:27 2021
@@ -0,0 +1,78 @@
+/* $NetBSD: efibootriscv64.c,v 1.1 2021/05/02 15:22:27 jmcneill Exp $ */
+
+/*-
+ * Copyright (c) 2021 Jared McNeill 
+ * 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 "../efifdt.h"
+
+#include 
+
+#include 
+#include 
+
+typedef void (*riscv_kernel_entry_t)(register_t, register_t);
+
+static uint32_t
+efi_fdt_get_boot_hartid(void)
+{
+	const int chosen = fdt_path_offset(efi_fdt_data(), "/chosen");
+	const uint32_t *data;
+
+	data = fdt_getprop(efi_fdt_data(), chosen, "boot-hartid", NULL);
+	if (data == NULL) {
+		return 0;	/* XXX */
+	}
+
+	return fdt32_to_cpu(*data);
+}
+
+void
+efi_boot_kernel(u_long marks[MARK_MAX])
+{
+	riscv_kernel_entry_t entry_fn;
+	register_t hart_id; /* a0 */
+	register_t fdt_start; /* a1 */
+
+	entry_fn = (riscv_kernel_entry_t)(uintptr_t)marks[MARK_ENTRY];
+
+	hart_id = efi_fdt_get_boot_hartid();
+	fdt_start = (register_t)efi_fdt_data();
+
+	asm volatile("fence rw,rw; fence.i" ::: "memory");
+
+	entry_fn(hart_id, fdt_start);
+}
+
+void
+efi_md_show(void)
+{
+}
+
+void
+efi_dcache_flush(u_long start, u_long size)
+{
+}



CVS commit: src/sys/stand/efiboot/bootriscv64

2021-05-02 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun May  2 15:22:27 UTC 2021

Added Files:
src/sys/stand/efiboot/bootriscv64: Makefile efibootriscv64.c

Log Message:
Add RISC-V 64-bit support.


To generate a diff of this commit:
cvs rdiff -u -r0 -r1.1 src/sys/stand/efiboot/bootriscv64/Makefile \
src/sys/stand/efiboot/bootriscv64/efibootriscv64.c

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



CVS commit: src/sys/stand/efiboot/bootaa64

2021-01-09 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Jan  9 13:19:27 UTC 2021

Modified Files:
src/sys/stand/efiboot/bootaa64: efibootaa64.c

Log Message:
Flush from kernel start, not the entry point.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/stand/efiboot/bootaa64/efibootaa64.c

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/bootaa64/efibootaa64.c
diff -u src/sys/stand/efiboot/bootaa64/efibootaa64.c:1.4 src/sys/stand/efiboot/bootaa64/efibootaa64.c:1.5
--- src/sys/stand/efiboot/bootaa64/efibootaa64.c:1.4	Sat Jan  9 13:15:15 2021
+++ src/sys/stand/efiboot/bootaa64/efibootaa64.c	Sat Jan  9 13:19:27 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: efibootaa64.c,v 1.4 2021/01/09 13:15:15 jmcneill Exp $	*/
+/*	$NetBSD: efibootaa64.c,v 1.5 2021/01/09 13:19:27 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -56,7 +56,7 @@ efi_boot_kernel(u_long marks[MARK_MAX])
 	fdt_start = (u_long)efi_fdt_data();
 	fdt_size = efi_fdt_size();
 
-	aarch64_dcache_wbinv_range(kernel_entry, kernel_size);
+	aarch64_dcache_wbinv_range(kernel_start, kernel_size);
 	if (efi_fdt_size() > 0) {
 		aarch64_dcache_wbinv_range(fdt_start, fdt_size);
 	}



CVS commit: src/sys/stand/efiboot/bootaa64

2021-01-09 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Jan  9 13:19:27 UTC 2021

Modified Files:
src/sys/stand/efiboot/bootaa64: efibootaa64.c

Log Message:
Flush from kernel start, not the entry point.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/stand/efiboot/bootaa64/efibootaa64.c

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



CVS commit: src/sys/stand/efiboot/bootaa64

2021-01-09 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Jan  9 13:15:15 UTC 2021

Modified Files:
src/sys/stand/efiboot/bootaa64: efibootaa64.c

Log Message:
Style fixes, NFCI.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/stand/efiboot/bootaa64/efibootaa64.c

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/bootaa64/efibootaa64.c
diff -u src/sys/stand/efiboot/bootaa64/efibootaa64.c:1.3 src/sys/stand/efiboot/bootaa64/efibootaa64.c:1.4
--- src/sys/stand/efiboot/bootaa64/efibootaa64.c:1.3	Sat Nov 28 14:02:09 2020
+++ src/sys/stand/efiboot/bootaa64/efibootaa64.c	Sat Jan  9 13:15:15 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: efibootaa64.c,v 1.3 2020/11/28 14:02:09 jmcneill Exp $	*/
+/*	$NetBSD: efibootaa64.c,v 1.4 2021/01/09 13:15:15 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -47,18 +47,22 @@ efi_dcache_flush(u_long start, u_long si
 void
 efi_boot_kernel(u_long marks[MARK_MAX])
 {
-	void (*kernel_entry)(register_t, register_t, register_t, register_t);
-	u_long kernel_size;
+	u_long kernel_start, kernel_size, kernel_entry;
+	u_long fdt_start, fdt_size;
 
-	kernel_entry = (void *)marks[MARK_ENTRY];
-	kernel_size = marks[MARK_END] - marks[MARK_START];
-
-	aarch64_dcache_wbinv_range((u_long)kernel_entry, kernel_size);
-	if (efi_fdt_size() > 0)
-		aarch64_dcache_wbinv_range((u_long)efi_fdt_data(), efi_fdt_size());
+	kernel_start = marks[MARK_START];
+	kernel_size = marks[MARK_END] - kernel_start;
+	kernel_entry = marks[MARK_ENTRY];
+	fdt_start = (u_long)efi_fdt_data();
+	fdt_size = efi_fdt_size();
+
+	aarch64_dcache_wbinv_range(kernel_entry, kernel_size);
+	if (efi_fdt_size() > 0) {
+		aarch64_dcache_wbinv_range(fdt_start, fdt_size);
+	}
 	aarch64_icache_inv_all();
 
-	aarch64_exec_kernel((paddr_t)marks[MARK_ENTRY], (paddr_t)efi_fdt_data());
+	aarch64_exec_kernel((paddr_t)kernel_entry, (paddr_t)fdt_start);
 }
 
 /*



CVS commit: src/sys/stand/efiboot/bootaa64

2021-01-09 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Jan  9 13:15:15 UTC 2021

Modified Files:
src/sys/stand/efiboot/bootaa64: efibootaa64.c

Log Message:
Style fixes, NFCI.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/stand/efiboot/bootaa64/efibootaa64.c

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



CVS commit: src/sys/stand/efiboot

2020-12-19 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Dec 19 08:09:32 UTC 2020

Modified Files:
src/sys/stand/efiboot: efifdt.c

Log Message:
Various clean ups
 - cache node where possible
 - remove a compiler warning
 - improve a comment (the round_page might not be needed)


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/stand/efiboot/efifdt.c

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



CVS commit: src/sys/stand/efiboot

2020-12-19 Thread Nick Hudson
Module Name:src
Committed By:   skrll
Date:   Sat Dec 19 08:09:32 UTC 2020

Modified Files:
src/sys/stand/efiboot: efifdt.c

Log Message:
Various clean ups
 - cache node where possible
 - remove a compiler warning
 - improve a comment (the round_page might not be needed)


To generate a diff of this commit:
cvs rdiff -u -r1.27 -r1.28 src/sys/stand/efiboot/efifdt.c

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/efifdt.c
diff -u src/sys/stand/efiboot/efifdt.c:1.27 src/sys/stand/efiboot/efifdt.c:1.28
--- src/sys/stand/efiboot/efifdt.c:1.27	Thu Oct 22 09:28:30 2020
+++ src/sys/stand/efiboot/efifdt.c	Sat Dec 19 08:09:31 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: efifdt.c,v 1.27 2020/10/22 09:28:30 jmcneill Exp $ */
+/* $NetBSD: efifdt.c,v 1.28 2020/12/19 08:09:31 skrll Exp $ */
 
 /*-
  * Copyright (c) 2019 Jason R. Thorpe
@@ -235,7 +235,7 @@ efi_fdt_memory_map(void)
 	EFI_MEMORY_DESCRIPTOR *md, *memmap;
 	UINT32 descver;
 	UINT64 phys_start, phys_size;
-	int n, memory, chosen;
+	int n, memory;
 
 	memory = fdt_path_offset(fdt_data, FDT_MEMORY_NODE_PATH);
 	if (memory < 0)
@@ -243,8 +243,6 @@ efi_fdt_memory_map(void)
 	if (memory < 0)
 		panic("FDT: Failed to create " FDT_MEMORY_NODE_PATH " node");
 
-	chosen = efi_fdt_chosen();
-
 	fdt_delprop(fdt_data, memory, "reg");
 
 	const int address_cells = fdt_address_cells(fdt_data, fdt_path_offset(fdt_data, "/"));
@@ -252,10 +250,15 @@ efi_fdt_memory_map(void)
 
 	memmap = LibMemoryMap(, , , );
 	for (n = 0, md = memmap; n < nentries; n++, md = NextMemoryDescriptor(md, descsize)) {
-		fdt_appendprop_u32(fdt_data, fdt_path_offset(fdt_data, FDT_CHOSEN_NODE_PATH), "netbsd,uefi-memmap", md->Type);
-		fdt_appendprop_u64(fdt_data, fdt_path_offset(fdt_data, FDT_CHOSEN_NODE_PATH), "netbsd,uefi-memmap", md->PhysicalStart);
-		fdt_appendprop_u64(fdt_data, fdt_path_offset(fdt_data, FDT_CHOSEN_NODE_PATH), "netbsd,uefi-memmap", md->NumberOfPages);
-		fdt_appendprop_u64(fdt_data, fdt_path_offset(fdt_data, FDT_CHOSEN_NODE_PATH), "netbsd,uefi-memmap", md->Attribute);
+		/*
+		 * create / find the chosen node for each iteration as it might have changed
+		 * when adding to the memory node
+		 */
+		int chosen = efi_fdt_chosen();
+		fdt_appendprop_u32(fdt_data, chosen, "netbsd,uefi-memmap", md->Type);
+		fdt_appendprop_u64(fdt_data, chosen, "netbsd,uefi-memmap", md->PhysicalStart);
+		fdt_appendprop_u64(fdt_data, chosen, "netbsd,uefi-memmap", md->NumberOfPages);
+		fdt_appendprop_u64(fdt_data, chosen, "netbsd,uefi-memmap", md->Attribute);
 
 		if ((md->Attribute & EFI_MEMORY_RUNTIME) != 0)
 			continue;
@@ -273,26 +276,31 @@ efi_fdt_memory_map(void)
 		phys_size = md->NumberOfPages * EFI_PAGE_SIZE;
 
 		if (phys_start & EFI_PAGE_MASK) {
-			/* UEFI spec says these should be 4KB aligned, but U-Boot doesn't always.. */
+			/*
+			 * UEFI spec says these should be 4KB aligned, but
+			 * U-Boot doesn't always, so round up to the next
+			 * page.
+			 */
 			phys_start = (phys_start + EFI_PAGE_SIZE) & ~EFI_PAGE_MASK;
 			phys_size -= (EFI_PAGE_SIZE * 2);
 			if (phys_size == 0)
 continue;
 		}
 
+		memory = fdt_path_offset(fdt_data, FDT_MEMORY_NODE_PATH);
 		if (address_cells == 1)
-			fdt_appendprop_u32(fdt_data, fdt_path_offset(fdt_data, FDT_MEMORY_NODE_PATH),
-			"reg", (uint32_t)phys_start);
+			fdt_appendprop_u32(fdt_data, memory, "reg",
+			(uint32_t)phys_start);
 		else
-			fdt_appendprop_u64(fdt_data, fdt_path_offset(fdt_data, FDT_MEMORY_NODE_PATH),
-			"reg", phys_start);
+			fdt_appendprop_u64(fdt_data, memory, "reg",
+			phys_start);
 
 		if (size_cells == 1)
-			fdt_appendprop_u32(fdt_data, fdt_path_offset(fdt_data, FDT_MEMORY_NODE_PATH),
-			"reg", (uint32_t)phys_size);
+			fdt_appendprop_u32(fdt_data, memory, "reg",
+			(uint32_t)phys_size);
 		else
-			fdt_appendprop_u64(fdt_data, fdt_path_offset(fdt_data, FDT_MEMORY_NODE_PATH),
-			"reg", phys_size);
+			fdt_appendprop_u64(fdt_data, memory, "reg",
+			phys_size);
 	}
 }
 



CVS commit: src/sys/stand/efiboot

2020-11-28 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Nov 28 15:24:05 UTC 2020

Modified Files:
src/sys/stand/efiboot: efiblock.c

Log Message:
Deal with devices that report either 512 or 2048 as logical block size
for CD9660 file-systems.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/stand/efiboot/efiblock.c

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/efiblock.c
diff -u src/sys/stand/efiboot/efiblock.c:1.9 src/sys/stand/efiboot/efiblock.c:1.10
--- src/sys/stand/efiboot/efiblock.c:1.9	Sun Oct 18 18:05:48 2020
+++ src/sys/stand/efiboot/efiblock.c	Sat Nov 28 15:24:05 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: efiblock.c,v 1.9 2020/10/18 18:05:48 tnn Exp $ */
+/* $NetBSD: efiblock.c,v 1.10 2020/11/28 15:24:05 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -127,28 +127,43 @@ efi_block_find_partitions_cd9660(struct 
 	EFI_LBA lba;
 	UINT32 sz;
 
+	if (bdev->bio->Media->BlockSize != DEV_BSIZE &&
+	bdev->bio->Media->BlockSize != ISO_DEFAULT_BLOCK_SIZE) {
+		return ENXIO;
+	}
+
 	sz = __MAX(sizeof(*vd), bdev->bio->Media->BlockSize);
 	sz = roundup(sz, bdev->bio->Media->BlockSize);
-	if ((buf = efi_block_allocate_device_buffer(bdev, sz, _start)) == NULL)
+	if ((buf = efi_block_allocate_device_buffer(bdev, sz, _start)) == NULL) {
 		return ENOMEM;
+	}
 
 	for (lba = 16;; lba++) {
-		status = uefi_call_wrapper(bdev->bio->ReadBlocks, 5, bdev->bio, bdev->media_id,
-		lba, sz, buf_start);
-		if (EFI_ERROR(status))
+		status = uefi_call_wrapper(bdev->bio->ReadBlocks, 5,
+		bdev->bio,
+		bdev->media_id,
+		lba * ISO_DEFAULT_BLOCK_SIZE / bdev->bio->Media->BlockSize,
+		sz,
+		buf_start);
+		if (EFI_ERROR(status)) {
 			goto io_error;
+		}
 
 		vd = (struct iso_primary_descriptor *)buf_start;
-		if (memcmp(vd->id, ISO_STANDARD_ID, sizeof vd->id) != 0)
+		if (memcmp(vd->id, ISO_STANDARD_ID, sizeof vd->id) != 0) {
 			goto io_error;
-		if (isonum_711(vd->type) == ISO_VD_END)
+		}
+		if (isonum_711(vd->type) == ISO_VD_END) {
 			goto io_error;
-		if (isonum_711(vd->type) == ISO_VD_PRIMARY)
+		}
+		if (isonum_711(vd->type) == ISO_VD_PRIMARY) {
 			break;
+		}
 	}
 
-	if (isonum_723(vd->logical_block_size) != ISO_DEFAULT_BLOCK_SIZE)
+	if (isonum_723(vd->logical_block_size) != ISO_DEFAULT_BLOCK_SIZE) {
 		goto io_error;
+	}
 
 	bpart = alloc(sizeof(*bpart));
 	bpart->index = 0;
@@ -593,6 +608,7 @@ efi_block_strategy(void *devdata, int rw
 		dblk += le64toh(bpart->gpt.ent.ent_lba_start);
 		break;
 	case EFI_BLOCK_PART_CD9660:
+		dblk *= ISO_DEFAULT_BLOCK_SIZE / bpart->bdev->bio->Media->BlockSize;
 		break;
 	default:
 		return EINVAL;
@@ -603,8 +619,9 @@ efi_block_strategy(void *devdata, int rw
 		allocated_buf = NULL;
 		aligned_buf = buf;
 	} else if ((allocated_buf = efi_block_allocate_device_buffer(bpart->bdev,
-		size, _buf)) == NULL)
+		size, _buf)) == NULL) {
 		return ENOMEM;
+	}
 
 	status = uefi_call_wrapper(bpart->bdev->bio->ReadBlocks, 5,
 		bpart->bdev->bio, bpart->bdev->media_id, dblk, size, aligned_buf);



CVS commit: src/sys/stand/efiboot

2020-11-28 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Nov 28 15:24:05 UTC 2020

Modified Files:
src/sys/stand/efiboot: efiblock.c

Log Message:
Deal with devices that report either 512 or 2048 as logical block size
for CD9660 file-systems.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/stand/efiboot/efiblock.c

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



CVS commit: src/sys/stand/efiboot

2020-11-28 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Nov 28 14:02:09 UTC 2020

Modified Files:
src/sys/stand/efiboot: boot.c efiboot_machdep.h
src/sys/stand/efiboot/bootaa64: efibootaa64.c
src/sys/stand/efiboot/bootarm: efibootarm.c

Log Message:
Add a hook for MD specific info to print in the "ver" command. Use this
to print the value of the current execution level in bootaa64.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/stand/efiboot/boot.c
cvs rdiff -u -r1.2 -r1.3 src/sys/stand/efiboot/efiboot_machdep.h
cvs rdiff -u -r1.2 -r1.3 src/sys/stand/efiboot/bootaa64/efibootaa64.c
cvs rdiff -u -r1.2 -r1.3 src/sys/stand/efiboot/bootarm/efibootarm.c

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.28 src/sys/stand/efiboot/boot.c:1.29
--- src/sys/stand/efiboot/boot.c:1.28	Sun Oct 11 14:03:33 2020
+++ src/sys/stand/efiboot/boot.c	Sat Nov 28 14:02:09 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: boot.c,v 1.28 2020/10/11 14:03:33 jmcneill Exp $	*/
+/*	$NetBSD: boot.c,v 1.29 2020/11/28 14:02:09 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -347,6 +347,7 @@ command_version(char *arg)
 	efi_fdt_show();
 	efi_acpi_show();
 	efi_rng_show();
+	efi_md_show();
 }
 
 void

Index: src/sys/stand/efiboot/efiboot_machdep.h
diff -u src/sys/stand/efiboot/efiboot_machdep.h:1.2 src/sys/stand/efiboot/efiboot_machdep.h:1.3
--- src/sys/stand/efiboot/efiboot_machdep.h:1.2	Fri Sep  7 17:30:32 2018
+++ src/sys/stand/efiboot/efiboot_machdep.h	Sat Nov 28 14:02:09 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: efiboot_machdep.h,v 1.2 2018/09/07 17:30:32 jmcneill Exp $ */
+/* $NetBSD: efiboot_machdep.h,v 1.3 2020/11/28 14:02:09 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2018 Jared McNeill 
@@ -32,3 +32,4 @@
 
 void efi_dcache_flush(u_long, u_long);
 void efi_boot_kernel(u_long[]);
+void efi_md_show(void);

Index: src/sys/stand/efiboot/bootaa64/efibootaa64.c
diff -u src/sys/stand/efiboot/bootaa64/efibootaa64.c:1.2 src/sys/stand/efiboot/bootaa64/efibootaa64.c:1.3
--- src/sys/stand/efiboot/bootaa64/efibootaa64.c:1.2	Fri Sep  7 17:30:32 2018
+++ src/sys/stand/efiboot/bootaa64/efibootaa64.c	Sat Nov 28 14:02:09 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: efibootaa64.c,v 1.2 2018/09/07 17:30:32 jmcneill Exp $	*/
+/*	$NetBSD: efibootaa64.c,v 1.3 2020/11/28 14:02:09 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -60,3 +60,20 @@ efi_boot_kernel(u_long marks[MARK_MAX])
 
 	aarch64_exec_kernel((paddr_t)marks[MARK_ENTRY], (paddr_t)efi_fdt_data());
 }
+
+/*
+ * Returns the current exception level.
+ */
+static u_int
+efi_aarch64_current_el(void)
+{
+	uint64_t el;
+	__asm __volatile ("mrs %0, CurrentEL" : "=r" (el));
+	return (el >> 2) & 0x3;
+}
+
+void
+efi_md_show(void)
+{
+	printf("Current Exception Level: EL%u\n", efi_aarch64_current_el());
+}

Index: src/sys/stand/efiboot/bootarm/efibootarm.c
diff -u src/sys/stand/efiboot/bootarm/efibootarm.c:1.2 src/sys/stand/efiboot/bootarm/efibootarm.c:1.3
--- src/sys/stand/efiboot/bootarm/efibootarm.c:1.2	Sat Mar 30 17:41:13 2019
+++ src/sys/stand/efiboot/bootarm/efibootarm.c	Sat Nov 28 14:02:09 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: efibootarm.c,v 1.2 2019/03/30 17:41:13 jmcneill Exp $ */
+/* $NetBSD: efibootarm.c,v 1.3 2020/11/28 14:02:09 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2019 Jared McNeill 
@@ -58,3 +58,8 @@ efi_boot_kernel(u_long marks[MARK_MAX])
 
 	armv7_exec_kernel((register_t)marks[MARK_ENTRY], (register_t)efi_fdt_data());
 }
+
+void
+efi_md_show(void)
+{
+}



CVS commit: src/sys/stand/efiboot

2020-11-28 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Nov 28 14:02:09 UTC 2020

Modified Files:
src/sys/stand/efiboot: boot.c efiboot_machdep.h
src/sys/stand/efiboot/bootaa64: efibootaa64.c
src/sys/stand/efiboot/bootarm: efibootarm.c

Log Message:
Add a hook for MD specific info to print in the "ver" command. Use this
to print the value of the current execution level in bootaa64.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/stand/efiboot/boot.c
cvs rdiff -u -r1.2 -r1.3 src/sys/stand/efiboot/efiboot_machdep.h
cvs rdiff -u -r1.2 -r1.3 src/sys/stand/efiboot/bootaa64/efibootaa64.c
cvs rdiff -u -r1.2 -r1.3 src/sys/stand/efiboot/bootarm/efibootarm.c

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



CVS commit: src/sys/stand/efiboot

2020-10-22 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Oct 22 09:28:30 UTC 2020

Modified Files:
src/sys/stand/efiboot: efifdt.c

Log Message:
Fix previous.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/stand/efiboot/efifdt.c

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



CVS commit: src/sys/stand/efiboot

2020-10-22 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Oct 22 09:28:30 UTC 2020

Modified Files:
src/sys/stand/efiboot: efifdt.c

Log Message:
Fix previous.


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/stand/efiboot/efifdt.c

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/efifdt.c
diff -u src/sys/stand/efiboot/efifdt.c:1.26 src/sys/stand/efiboot/efifdt.c:1.27
--- src/sys/stand/efiboot/efifdt.c:1.26	Thu Oct 22 09:14:40 2020
+++ src/sys/stand/efiboot/efifdt.c	Thu Oct 22 09:28:30 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: efifdt.c,v 1.26 2020/10/22 09:14:40 jmcneill Exp $ */
+/* $NetBSD: efifdt.c,v 1.27 2020/10/22 09:28:30 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2019 Jason R. Thorpe
@@ -338,21 +338,17 @@ efi_fdt_gop(void)
 			continue;
 		}
 
-		snprintf(buf, sizeof(buf), "framebuffer@%" PRIx64, mode->FrameBufferBase);
-		fb = fdt_path_offset(fdt_data, buf);
-		if (fb >= 0) {
-			/* Framebuffer node already exists, no need to create one */
-			return;
-		}
-
 		chosen = efi_fdt_chosen();
 		fdt_setprop_u32(fdt_data, chosen, "#address-cells", 2);
 		fdt_setprop_u32(fdt_data, chosen, "#size-cells", 2);
 		fdt_setprop_empty(fdt_data, chosen, "ranges");
 
+		snprintf(buf, sizeof(buf), "framebuffer@%" PRIx64, mode->FrameBufferBase);
 		fb = fdt_add_subnode(fdt_data, chosen, buf);
-		if (fb < 0)
-			panic("FDT: Failed to create framebuffer node");
+		if (fb < 0) {
+			/* Framebuffer node already exists. No need to create a new one! */
+			return;
+		}
 
 		fdt_appendprop_string(fdt_data, fb, "compatible", "simple-framebuffer");
 		fdt_appendprop_string(fdt_data, fb, "status", "okay");



CVS commit: src/sys/stand/efiboot

2020-10-22 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Oct 22 09:14:41 UTC 2020

Modified Files:
src/sys/stand/efiboot: efifdt.c

Log Message:
If the framebuffer node already exists, we don't need to create one


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/stand/efiboot/efifdt.c

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/efifdt.c
diff -u src/sys/stand/efiboot/efifdt.c:1.25 src/sys/stand/efiboot/efifdt.c:1.26
--- src/sys/stand/efiboot/efifdt.c:1.25	Sat Oct 10 19:17:39 2020
+++ src/sys/stand/efiboot/efifdt.c	Thu Oct 22 09:14:40 2020
@@ -1,4 +1,4 @@
-/* $NetBSD: efifdt.c,v 1.25 2020/10/10 19:17:39 jmcneill Exp $ */
+/* $NetBSD: efifdt.c,v 1.26 2020/10/22 09:14:40 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2019 Jason R. Thorpe
@@ -338,12 +338,18 @@ efi_fdt_gop(void)
 			continue;
 		}
 
+		snprintf(buf, sizeof(buf), "framebuffer@%" PRIx64, mode->FrameBufferBase);
+		fb = fdt_path_offset(fdt_data, buf);
+		if (fb >= 0) {
+			/* Framebuffer node already exists, no need to create one */
+			return;
+		}
+
 		chosen = efi_fdt_chosen();
 		fdt_setprop_u32(fdt_data, chosen, "#address-cells", 2);
 		fdt_setprop_u32(fdt_data, chosen, "#size-cells", 2);
 		fdt_setprop_empty(fdt_data, chosen, "ranges");
 
-		snprintf(buf, sizeof(buf), "framebuffer@%" PRIx64, mode->FrameBufferBase);
 		fb = fdt_add_subnode(fdt_data, chosen, buf);
 		if (fb < 0)
 			panic("FDT: Failed to create framebuffer node");



CVS commit: src/sys/stand/efiboot

2020-10-22 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Thu Oct 22 09:14:41 UTC 2020

Modified Files:
src/sys/stand/efiboot: efifdt.c

Log Message:
If the framebuffer node already exists, we don't need to create one


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/stand/efiboot/efifdt.c

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



CVS commit: src/sys/stand/efiboot

2020-10-18 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sun Oct 18 18:09:32 UTC 2020

Modified Files:
src/sys/stand/efiboot: version

Log Message:
efiboot: bump version


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/stand/efiboot/version

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/version
diff -u src/sys/stand/efiboot/version:1.21 src/sys/stand/efiboot/version:1.22
--- src/sys/stand/efiboot/version:1.21	Sun Oct 11 14:03:33 2020
+++ src/sys/stand/efiboot/version	Sun Oct 18 18:09:32 2020
@@ -1,4 +1,4 @@
-$NetBSD: version,v 1.21 2020/10/11 14:03:33 jmcneill Exp $
+$NetBSD: version,v 1.22 2020/10/18 18:09:32 tnn 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
@@ -25,3 +25,4 @@ is taken as the current.
 2.2:	Remove support for storing settings in EFI env vars.
 2.3:	EFI RT and GOP support for devicetree mode.
 2.4:	Add ISO9660 support.
+2.5:	Recognize the EFI system partion as fstype MSDOS.



CVS commit: src/sys/stand/efiboot

2020-10-18 Thread Tobias Nygren
Module Name:src
Committed By:   tnn
Date:   Sun Oct 18 18:09:32 UTC 2020

Modified Files:
src/sys/stand/efiboot: version

Log Message:
efiboot: bump version


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/stand/efiboot/version

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



  1   2   3   >