CVS commit: src/sys/arch/i386/stand/efiboot

2021-06-22 Thread Nia Alarie
Module Name:src
Committed By:   nia
Date:   Tue Jun 22 19:53:58 UTC 2021

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

Log Message:
efiboot (x86): add ASCII art


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/i386/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/arch/i386/stand/efiboot/boot.c
diff -u src/sys/arch/i386/stand/efiboot/boot.c:1.18 src/sys/arch/i386/stand/efiboot/boot.c:1.19
--- src/sys/arch/i386/stand/efiboot/boot.c:1.18	Sun May 30 05:59:22 2021
+++ src/sys/arch/i386/stand/efiboot/boot.c	Tue Jun 22 19:53:58 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: boot.c,v 1.18 2021/05/30 05:59:22 mlelstv Exp $	*/
+/*	$NetBSD: boot.c,v 1.19 2021/06/22 19:53:58 nia Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -287,8 +287,19 @@ print_banner(void)
 		for (n = 0; n < BOOTCFG_MAXBANNER && bootcfg_info.banner[n];
 		n++)
 			printf("%s\n", bootcfg_info.banner[n]);
-	} else
-		command_version("short");
+	} else {
+		printf("\n"
+		   "  \\-__,--,___.\n"
+		   "   \\__,---`  %s (from NetBSD %s)\n"
+		   "\\   `---,_.  Revision %s\n"
+		   " \\-,_,.---`  Memory: %d/%d k\n"
+		   "  \\\n"  
+		   "   \\\n"
+		   "\\\n",
+		   bootprog_name, bootprog_kernrev,
+		   bootprog_rev,   
+		   getbasemem(), getextmem());
+	}
 }
 
 void



CVS commit: src/sys/arch/i386/stand/efiboot

2020-04-04 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Apr  4 15:30:46 UTC 2020

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

Log Message:
Add --noinhibit-exec and --no-dynamic-linker


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/i386/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/arch/i386/stand/efiboot/Makefile.efiboot
diff -u src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.16 src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.17
--- src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.16	Thu Sep 12 22:19:45 2019
+++ src/sys/arch/i386/stand/efiboot/Makefile.efiboot	Sat Apr  4 11:30:46 2020
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.efiboot,v 1.16 2019/09/13 02:19:45 manu Exp $
+# $NetBSD: Makefile.efiboot,v 1.17 2020/04/04 15:30:46 christos Exp $
 
 S=		${.CURDIR}/../../../../..
 
@@ -41,6 +41,7 @@ BINMODE=444
 .PATH:	${.CURDIR}/../../libsa
 
 LDSCRIPT?= ${.CURDIR}/ldscript
+LDFLAGS+= --no-dynamic-linker --noinhibit-exec
 LDFLAGS+= -nostdlib -T${LDSCRIPT} -Bsymbolic -shared -nocombreloc
 CPPFLAGS+= -I$S -I${.CURDIR} -I${.CURDIR}/.. -I$S/lib/libsa
 CPPFLAGS+= -I${.OBJDIR}



CVS commit: src/sys/arch/i386/stand/efiboot/bootx64

2020-03-21 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sat Mar 21 18:43:47 UTC 2020

Modified Files:
src/sys/arch/i386/stand/efiboot/bootx64: Makefile

Log Message:
Fix clang build after packed lfs64 accessor change.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/i386/stand/efiboot/bootx64/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/arch/i386/stand/efiboot/bootx64/Makefile
diff -u src/sys/arch/i386/stand/efiboot/bootx64/Makefile:1.2 src/sys/arch/i386/stand/efiboot/bootx64/Makefile:1.3
--- src/sys/arch/i386/stand/efiboot/bootx64/Makefile:1.2	Fri Sep 13 02:19:46 2019
+++ src/sys/arch/i386/stand/efiboot/bootx64/Makefile	Sat Mar 21 18:43:47 2020
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.2 2019/09/13 02:19:46 manu Exp $
+#	$NetBSD: Makefile,v 1.3 2020/03/21 18:43:47 riastradh Exp $
 
 PROG=		bootx64.efi
 OBJFMT=		pei-x86-64
@@ -9,4 +9,9 @@ EXTRA_SOURCES=	efibootx64.c startprog64.
 COPTS+=		-mno-red-zone
 CPPFLAGS+=	-DEFI_FUNCTION_WRAPPER
 
+# Follow the suit of Makefile.kern.inc; needed for the lfs64 union
+# accessors -- they don't actually dereference the resulting pointer,
+# just use it for type-checking.
+CWARNFLAGS.clang+=	-Wno-error=address-of-packed-member
+
 .include "${.CURDIR}/../Makefile.efiboot"



CVS commit: src/sys/arch/i386/stand/efiboot

2020-02-22 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Feb 22 10:30:37 UTC 2020

Modified Files:
src/sys/arch/i386/stand/efiboot: eficons.c

Log Message:
Remove check for bestmode==-1 (shouldn't happen)


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/i386/stand/efiboot/eficons.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/arch/i386/stand/efiboot/eficons.c
diff -u src/sys/arch/i386/stand/efiboot/eficons.c:1.10 src/sys/arch/i386/stand/efiboot/eficons.c:1.11
--- src/sys/arch/i386/stand/efiboot/eficons.c:1.10	Sat Feb 22 09:34:26 2020
+++ src/sys/arch/i386/stand/efiboot/eficons.c	Sat Feb 22 10:30:37 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: eficons.c,v 1.10 2020/02/22 09:34:26 jmcneill Exp $	*/
+/*	$NetBSD: eficons.c,v 1.11 2020/02/22 10:30:37 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -421,7 +421,7 @@ bi_framebuffer(void)
 	EFI_STATUS status;
 	EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *info;
 	struct btinfo_framebuffer fb;
-	INT32 bestmode = -1;
+	INT32 bestmode;
 	UINTN sz;
 
 	if (efi_gop == NULL)
@@ -435,8 +435,6 @@ bi_framebuffer(void)
 		if (bestmode == -1)
 			bestmode = FALLBACK_GOP_MODE;
 	}
-	if (bestmode == -1)
-		goto nofb;
 
 	status = uefi_call_wrapper(efi_gop->SetMode, 2, efi_gop,
 	bestmode);



CVS commit: src/sys/arch/i386/stand/efiboot

2020-02-22 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Feb 22 09:34:26 UTC 2020

Modified Files:
src/sys/arch/i386/stand/efiboot: eficons.c

Log Message:
If the default GOP mode is unavailable, fallback to the first mode defined.
PR# port-amd64/55000


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/i386/stand/efiboot/eficons.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/arch/i386/stand/efiboot/eficons.c
diff -u src/sys/arch/i386/stand/efiboot/eficons.c:1.9 src/sys/arch/i386/stand/efiboot/eficons.c:1.10
--- src/sys/arch/i386/stand/efiboot/eficons.c:1.9	Tue Feb 11 11:01:10 2020
+++ src/sys/arch/i386/stand/efiboot/eficons.c	Sat Feb 22 09:34:26 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: eficons.c,v 1.9 2020/02/11 11:01:10 jmcneill Exp $	*/
+/*	$NetBSD: eficons.c,v 1.10 2020/02/22 09:34:26 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -37,6 +37,7 @@
 #ifndef DEFAULT_GOP_MODE
 #define DEFAULT_GOP_MODE	"1024x768"
 #endif
+#define FALLBACK_GOP_MODE	0
 
 extern struct x86_boot_params boot_params;
 
@@ -431,6 +432,8 @@ bi_framebuffer(void)
 	} else {
 		/* If a mode has not been selected, choose a default */
 		bestmode = efi_find_gop_mode(DEFAULT_GOP_MODE);
+		if (bestmode == -1)
+			bestmode = FALLBACK_GOP_MODE;
 	}
 	if (bestmode == -1)
 		goto nofb;



CVS commit: src/sys/arch/i386/stand/efiboot

2020-02-11 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Feb 11 11:01:10 UTC 2020

Modified Files:
src/sys/arch/i386/stand/efiboot: eficons.c

Log Message:
Use 1024x768 as the default GOP mode. It is the only option available for
Hyper-V Gen.2 VMs and it seems to be the de facto standard and part of
WHQL requirements.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/sys/arch/i386/stand/efiboot/eficons.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/arch/i386/stand/efiboot/eficons.c
diff -u src/sys/arch/i386/stand/efiboot/eficons.c:1.8 src/sys/arch/i386/stand/efiboot/eficons.c:1.9
--- src/sys/arch/i386/stand/efiboot/eficons.c:1.8	Sat Feb  8 14:35:47 2020
+++ src/sys/arch/i386/stand/efiboot/eficons.c	Tue Feb 11 11:01:10 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: eficons.c,v 1.8 2020/02/08 14:35:47 jmcneill Exp $	*/
+/*	$NetBSD: eficons.c,v 1.9 2020/02/11 11:01:10 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -35,7 +35,7 @@
 #include "vbe.h"
 
 #ifndef DEFAULT_GOP_MODE
-#define DEFAULT_GOP_MODE	"800x600"
+#define DEFAULT_GOP_MODE	"1024x768"
 #endif
 
 extern struct x86_boot_params boot_params;



CVS commit: src/sys/arch/i386/stand/efiboot

2020-02-09 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Feb  9 12:13:39 UTC 2020

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

Log Message:
Do not clear the screen before exiting boot services as this may cause an
undesired display mode switch. PR# 54615


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/i386/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/arch/i386/stand/efiboot/efiboot.c
diff -u src/sys/arch/i386/stand/efiboot/efiboot.c:1.11 src/sys/arch/i386/stand/efiboot/efiboot.c:1.12
--- src/sys/arch/i386/stand/efiboot/efiboot.c:1.11	Fri Sep 13 02:19:45 2019
+++ src/sys/arch/i386/stand/efiboot/efiboot.c	Sun Feb  9 12:13:39 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: efiboot.c,v 1.11 2019/09/13 02:19:45 manu Exp $	*/
+/*	$NetBSD: efiboot.c,v 1.12 2020/02/09 12:13:39 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -112,8 +112,6 @@ efi_cleanup(void)
 	UINT32 DescriptorVersion;
 	size_t allocsz;
 
-	clearit();
-
 	memset(_efi, 0, sizeof(btinfo_efi));
 	btinfo_efi.systblpa = (intptr_t)ST;
 #ifdef	__i386__	/* bootia32.efi */



CVS commit: src/sys/arch/i386/stand/efiboot

2020-02-08 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sat Feb  8 14:35:47 UTC 2020

Modified Files:
src/sys/arch/i386/stand/efiboot: eficons.c

Log Message:
Fix a few bugs related to the framebuffer:
 - If a GOP mode wasn't explicitly requested, the bootloader was passing
   fb info to the kernel even if the console was in text mode! This
   results in garbled console output on at least ThinkPad T420 and
   likely many others. If a mode isn't specified, default to 800x600.
 - The "gop" command was incorrectly parsing video modes in the form
   WxHxD as WxWxD.
 - Allow a short form WxH for the "gop" command to select any mode with
   the target dimensions.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/i386/stand/efiboot/eficons.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/arch/i386/stand/efiboot/eficons.c
diff -u src/sys/arch/i386/stand/efiboot/eficons.c:1.7 src/sys/arch/i386/stand/efiboot/eficons.c:1.8
--- src/sys/arch/i386/stand/efiboot/eficons.c:1.7	Fri Sep 13 02:19:45 2019
+++ src/sys/arch/i386/stand/efiboot/eficons.c	Sat Feb  8 14:35:47 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: eficons.c,v 1.7 2019/09/13 02:19:45 manu Exp $	*/
+/*	$NetBSD: eficons.c,v 1.8 2020/02/08 14:35:47 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -34,6 +34,10 @@
 #include "bootinfo.h"
 #include "vbe.h"
 
+#ifndef DEFAULT_GOP_MODE
+#define DEFAULT_GOP_MODE	"800x600"
+#endif
+
 extern struct x86_boot_params boot_params;
 
 struct btinfo_console btinfo_console;
@@ -71,6 +75,8 @@ static int efi_com_putc(int);
 static int efi_com_status(int);
 static int efi_com_waitforinputevent(uint64_t);
 
+static int efi_find_gop_mode(char *);
+
 static int iodev;
 static int (*internal_getchar)(void) = efi_cons_getc;
 static int (*internal_putchar)(int) = efi_cons_putc;
@@ -415,46 +421,36 @@ bi_framebuffer(void)
 	EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *info;
 	struct btinfo_framebuffer fb;
 	INT32 bestmode = -1;
+	UINTN sz;
 
-	if (efi_gop == NULL) {
-		framebuffer_configure(NULL);
-		return;
-	}
+	if (efi_gop == NULL)
+		goto nofb;
 
 	if (efi_gop_mode >= 0) {
 		bestmode = efi_gop_mode;
 	} else {
-#if 0
-		UINT64 res, bestres = 0;
-		UINTN sz;
-		UINT32 i;
-
-		/* XXX EDID? EFI_EDID_DISCOVERED_PROTOCOL */
-		for (i = 0; i < efi_gop->Mode->MaxMode; i++) {
-			status = uefi_call_wrapper(efi_gop->QueryMode, 4,
-			efi_gop, i, , );
-			if (EFI_ERROR(status))
-continue;
+		/* If a mode has not been selected, choose a default */
+		bestmode = efi_find_gop_mode(DEFAULT_GOP_MODE);
+	}
+	if (bestmode == -1)
+		goto nofb;
 
-			res = (UINT64)info->HorizontalResolution *
-			(UINT64)info->VerticalResolution *
-			(UINT64)getdepth(info);
-			if (res > bestres) {
-bestmode = i;
-bestres = res;
-			}
-		}
-#endif
+	status = uefi_call_wrapper(efi_gop->SetMode, 2, efi_gop,
+	bestmode);
+	if (EFI_ERROR(status) || efi_gop->Mode->Mode != bestmode) {
+		printf("GOP setmode failed: %" PRIxMAX "\n",
+		(uintmax_t)status);
+		goto nofb;
 	}
-	if (bestmode >= 0) {
-		status = uefi_call_wrapper(efi_gop->SetMode, 2, efi_gop,
-		bestmode);
-		if (EFI_ERROR(status) || efi_gop->Mode->Mode != bestmode)
-			printf("GOP setmode failed: %" PRIxMAX "\n",
-			(uintmax_t)status);
+
+	status = uefi_call_wrapper(efi_gop->QueryMode, 4,
+	efi_gop, bestmode, , );
+	if (EFI_ERROR(status)) {
+		printf("GOP querymode failed: %" PRIxMAX "\n",
+		(uintmax_t)status);
+		goto nofb;
 	}
 
-	info = efi_gop->Mode->Info;
 	memset(, 0, sizeof(fb));
 	fb.physaddr = efi_gop->Mode->FrameBufferBase;
 	fb.flags = 0;
@@ -499,6 +495,10 @@ bi_framebuffer(void)
 	}
 
 	framebuffer_configure();
+	return;
+
+nofb:
+	framebuffer_configure(NULL);
 }
 
 int
@@ -658,10 +658,16 @@ efi_find_gop_mode(char *arg)
 
 		snprintf(mode, sizeof(mode), "%lux%lux%u",
 		(long)info->HorizontalResolution,
-		(long)info->HorizontalResolution,
+		(long)info->VerticalResolution,
 		depth);
 		if (strcmp(arg, mode) == 0)
 			return i;
+
+		snprintf(mode, sizeof(mode), "%lux%lu",
+		(long)info->HorizontalResolution,
+		(long)info->VerticalResolution);
+		if (strcmp(arg, mode) == 0)
+			return i;
 	}
 	return -1;
 }



CVS commit: src/sys/arch/i386/stand/efiboot

2020-01-18 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Sat Jan 18 19:25:58 UTC 2020

Modified Files:
src/sys/arch/i386/stand/efiboot: devopen.c

Log Message:
x86 efiboot: Fixed the problem that /EFI/NetBSD/boot.cfg could not be loaded.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/i386/stand/efiboot/devopen.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/arch/i386/stand/efiboot/devopen.c
diff -u src/sys/arch/i386/stand/efiboot/devopen.c:1.10 src/sys/arch/i386/stand/efiboot/devopen.c:1.11
--- src/sys/arch/i386/stand/efiboot/devopen.c:1.10	Sat Jan 18 19:20:23 2020
+++ src/sys/arch/i386/stand/efiboot/devopen.c	Sat Jan 18 19:25:58 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: devopen.c,v 1.10 2020/01/18 19:20:23 nonaka Exp $	 */
+/*	$NetBSD: devopen.c,v 1.11 2020/01/18 19:25:58 nonaka Exp $	 */
 
 /*-
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -100,7 +100,7 @@ bios2dev(int biosdev, daddr_t sector, ch
 		*devname = "hd";
 
 	(void)biosdisk_findpartition(biosdev, sector, partition, part_name);
-	if (*part_name != NULL) {
+	if (part_name != NULL && *part_name != NULL) {
 		snprintf(savedevname, sizeof(savedevname),
 		"NAME=%s", *part_name);
 		*devname = savedevname;



CVS commit: src/sys/arch/i386/stand/efiboot

2020-01-18 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Sat Jan 18 19:20:23 UTC 2020

Modified Files:
src/sys/arch/i386/stand/efiboot: devopen.c

Log Message:
fix indent.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/i386/stand/efiboot/devopen.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/arch/i386/stand/efiboot/devopen.c
diff -u src/sys/arch/i386/stand/efiboot/devopen.c:1.9 src/sys/arch/i386/stand/efiboot/devopen.c:1.10
--- src/sys/arch/i386/stand/efiboot/devopen.c:1.9	Tue Dec 10 02:02:47 2019
+++ src/sys/arch/i386/stand/efiboot/devopen.c	Sat Jan 18 19:20:23 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: devopen.c,v 1.9 2019/12/10 02:02:47 manu Exp $	 */
+/*	$NetBSD: devopen.c,v 1.10 2020/01/18 19:20:23 nonaka Exp $	 */
 
 /*-
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -103,7 +103,7 @@ bios2dev(int biosdev, daddr_t sector, ch
 	if (*part_name != NULL) {
 		snprintf(savedevname, sizeof(savedevname),
 		"NAME=%s", *part_name);
-			*devname = savedevname;
+		*devname = savedevname;
 	}
 }
 



CVS commit: src/sys/arch/i386/stand/efiboot

2019-04-17 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Wed Apr 17 06:50:34 UTC 2019

Modified Files:
src/sys/arch/i386/stand/efiboot: efidisk.c

Log Message:
efiboot: Don't panic when BLOCK_IO_PROTOCOL is not found.

It has been reported that there is a machine where BLOCK_IO_PROTOCOL
can not be found when network boot without disk.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/i386/stand/efiboot/efidisk.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/arch/i386/stand/efiboot/efidisk.c
diff -u src/sys/arch/i386/stand/efiboot/efidisk.c:1.6 src/sys/arch/i386/stand/efiboot/efidisk.c:1.7
--- src/sys/arch/i386/stand/efiboot/efidisk.c:1.6	Wed Apr 11 10:32:09 2018
+++ src/sys/arch/i386/stand/efiboot/efidisk.c	Wed Apr 17 06:50:34 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: efidisk.c,v 1.6 2018/04/11 10:32:09 nonaka Exp $	*/
+/*	$NetBSD: efidisk.c,v 1.7 2019/04/17 06:50:34 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -57,8 +57,7 @@ efi_disk_probe(void)
 	status = LibLocateHandle(ByProtocol, , NULL,
 	, );
 	if (EFI_ERROR(status))
-		panic("LocateHandle(BlockIoProtocol): %" PRIxMAX,
-		(uintmax_t)status);
+		return;
 
 	if (efi_bootdp != NULL)
 		depth = efi_device_path_depth(efi_bootdp, MEDIA_DEVICE_PATH);
@@ -76,8 +75,7 @@ efi_disk_probe(void)
 		status = uefi_call_wrapper(BS->HandleProtocol, 3, handles[i],
 		, (void **));
 		if (EFI_ERROR(status))
-			panic("HandleProtocol(BlockIoProtocol): %" PRIxMAX,
-			(uintmax_t)status);
+			continue;
 
 		media = bio->Media;
 		if (media->LogicalPartition || !media->MediaPresent)



CVS commit: src/sys/arch/i386/stand/efiboot

2018-12-24 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Dec 24 18:21:50 UTC 2018

Modified Files:
src/sys/arch/i386/stand/efiboot/bootia32: ldscript
src/sys/arch/i386/stand/efiboot/bootx64: ldscript

Log Message:
Avoid error with new binutils:
error: PHDR segment not covered by LOAD segment


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/i386/stand/efiboot/bootia32/ldscript
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/i386/stand/efiboot/bootx64/ldscript

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

Modified files:

Index: src/sys/arch/i386/stand/efiboot/bootia32/ldscript
diff -u src/sys/arch/i386/stand/efiboot/bootia32/ldscript:1.1 src/sys/arch/i386/stand/efiboot/bootia32/ldscript:1.2
--- src/sys/arch/i386/stand/efiboot/bootia32/ldscript:1.1	Tue Jan 24 06:09:14 2017
+++ src/sys/arch/i386/stand/efiboot/bootia32/ldscript	Mon Dec 24 13:21:50 2018
@@ -1,7 +1,14 @@
-/*	$NetBSD: ldscript,v 1.1 2017/01/24 11:09:14 nonaka Exp $	*/
+/*	$NetBSD: ldscript,v 1.2 2018/12/24 18:21:50 christos Exp $	*/
 OUTPUT_FORMAT("elf32-i386", "elf32-i386", "elf32-i386")
 OUTPUT_ARCH(i386)
 ENTRY(_start)
+
+PHDRS
+{
+  text PT_LOAD;
+  headers PT_PHDR FILEHDR PHDRS;
+}
+
 SECTIONS
 {
   . = 0;
@@ -13,7 +20,7 @@ SECTIONS
*(.text)
*(.text.*)
*(.gnu.linkonce.t.*)
-  }
+  } :text
   . = ALIGN(4096);
   .sdata :
   {

Index: src/sys/arch/i386/stand/efiboot/bootx64/ldscript
diff -u src/sys/arch/i386/stand/efiboot/bootx64/ldscript:1.1 src/sys/arch/i386/stand/efiboot/bootx64/ldscript:1.2
--- src/sys/arch/i386/stand/efiboot/bootx64/ldscript:1.1	Tue Jan 24 06:09:14 2017
+++ src/sys/arch/i386/stand/efiboot/bootx64/ldscript	Mon Dec 24 13:21:50 2018
@@ -1,8 +1,15 @@
-/*	$NetBSD: ldscript,v 1.1 2017/01/24 11:09:14 nonaka Exp $	*/
+/*	$NetBSD: ldscript,v 1.2 2018/12/24 18:21:50 christos Exp $	*/
 /* Same as elf_x86_64_fbsd_efi.lds, except for OUTPUT_FORMAT below - KEEP IN SYNC */
 OUTPUT_FORMAT("elf64-x86-64", "elf64-x86-64", "elf64-x86-64")
 OUTPUT_ARCH(i386:x86-64)
 ENTRY(_start)
+
+PHDRS
+{
+  text PT_LOAD;
+  headers PT_PHDR FILEHDR PHDRS;
+}
+
 SECTIONS
 {
   . = 0;
@@ -19,7 +26,7 @@ SECTIONS
*(.text)
*(.text.*)
*(.gnu.linkonce.t.*)
-  }
+  } :text
   . = ALIGN(4096);
   .reloc :
   {



CVS commit: src/sys/arch/i386/stand/efiboot

2018-11-08 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Nov  8 23:20:52 UTC 2018

Modified Files:
src/sys/arch/i386/stand/efiboot: Makefile

Log Message:
revert previous; does not fix the issue


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/i386/stand/efiboot/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/arch/i386/stand/efiboot/Makefile
diff -u src/sys/arch/i386/stand/efiboot/Makefile:1.4 src/sys/arch/i386/stand/efiboot/Makefile:1.5
--- src/sys/arch/i386/stand/efiboot/Makefile:1.4	Thu Nov  8 16:47:04 2018
+++ src/sys/arch/i386/stand/efiboot/Makefile	Thu Nov  8 18:20:52 2018
@@ -1,6 +1,4 @@
-#	$NetBSD: Makefile,v 1.4 2018/11/08 21:47:04 christos Exp $
-
-.include 
+#	$NetBSD: Makefile,v 1.5 2018/11/08 23:20:52 christos Exp $
 
 SUBDIR=	bootia32
 .if ${MACHINE} == "amd64"



CVS commit: src/sys/arch/i386/stand/efiboot

2018-11-08 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Nov  8 21:47:04 UTC 2018

Modified Files:
src/sys/arch/i386/stand/efiboot: Makefile

Log Message:
Don't build this as a PIE binary, PIE binaries need PHDR and this barfs
under the new binutils: error: PHDR segment not covered by LOAD segment
[including bsd.init.mk includes ../Makefile.inc which disables PIE like
 all the other bootloaders do]


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/i386/stand/efiboot/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/arch/i386/stand/efiboot/Makefile
diff -u src/sys/arch/i386/stand/efiboot/Makefile:1.3 src/sys/arch/i386/stand/efiboot/Makefile:1.4
--- src/sys/arch/i386/stand/efiboot/Makefile:1.3	Sun Jul  8 13:01:02 2018
+++ src/sys/arch/i386/stand/efiboot/Makefile	Thu Nov  8 16:47:04 2018
@@ -1,4 +1,6 @@
-#	$NetBSD: Makefile,v 1.3 2018/07/08 17:01:02 christos Exp $
+#	$NetBSD: Makefile,v 1.4 2018/11/08 21:47:04 christos Exp $
+
+.include 
 
 SUBDIR=	bootia32
 .if ${MACHINE} == "amd64"



CVS commit: src/sys/arch/i386/stand/efiboot

2018-08-16 Thread Robert Elz
Module Name:src
Committed By:   kre
Date:   Fri Aug 17 04:59:34 UTC 2018

Modified Files:
src/sys/arch/i386/stand/efiboot: panic.c

Log Message:
Deal with gnu-efi upgrade - "efilib.h" now provides a prototype
for VPrint() so it is no longer needed here, particularly not a
slightly different prototype.   Fixes the amd64 i386 & ia64 builds.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/i386/stand/efiboot/panic.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/arch/i386/stand/efiboot/panic.c
diff -u src/sys/arch/i386/stand/efiboot/panic.c:1.4 src/sys/arch/i386/stand/efiboot/panic.c:1.5
--- src/sys/arch/i386/stand/efiboot/panic.c:1.4	Sat Feb 11 10:15:55 2017
+++ src/sys/arch/i386/stand/efiboot/panic.c	Fri Aug 17 04:59:34 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: panic.c,v 1.4 2017/02/11 10:15:55 nonaka Exp $	*/
+/*	$NetBSD: panic.c,v 1.5 2018/08/17 04:59:34 kre Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -30,9 +30,6 @@
 
 #include 
 
-/* from sys/external/bsd/gnu-efi/dist/lib/print.c */
-UINTN VPrint (IN CHAR16 *, va_list);
-
 __dead VOID
 Panic(
 IN CHAR16 *fmt,



CVS commit: src/sys/arch/i386/stand/efiboot

2018-07-08 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Jul  8 17:01:02 UTC 2018

Modified Files:
src/sys/arch/i386/stand/efiboot: Makefile

Log Message:
use += :-)


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/i386/stand/efiboot/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/arch/i386/stand/efiboot/Makefile
diff -u src/sys/arch/i386/stand/efiboot/Makefile:1.2 src/sys/arch/i386/stand/efiboot/Makefile:1.3
--- src/sys/arch/i386/stand/efiboot/Makefile:1.2	Sun Jul  8 12:50:28 2018
+++ src/sys/arch/i386/stand/efiboot/Makefile	Sun Jul  8 13:01:02 2018
@@ -1,8 +1,8 @@
-#	$NetBSD: Makefile,v 1.2 2018/07/08 16:50:28 christos Exp $
+#	$NetBSD: Makefile,v 1.3 2018/07/08 17:01:02 christos Exp $
 
 SUBDIR=	bootia32
 .if ${MACHINE} == "amd64"
-SUBDIR=		bootx64
+SUBDIR+=	bootx64
 .endif
 
 .include 



CVS commit: src/sys/arch/i386/stand/efiboot

2018-06-08 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Fri Jun  8 11:52:30 UTC 2018

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

Log Message:
Remove unused include.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/i386/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/arch/i386/stand/efiboot/efiboot.c
diff -u src/sys/arch/i386/stand/efiboot/efiboot.c:1.7 src/sys/arch/i386/stand/efiboot/efiboot.c:1.8
--- src/sys/arch/i386/stand/efiboot/efiboot.c:1.7	Wed Apr 11 10:32:09 2018
+++ src/sys/arch/i386/stand/efiboot/efiboot.c	Fri Jun  8 11:52:30 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: efiboot.c,v 1.7 2018/04/11 10:32:09 nonaka Exp $	*/
+/*	$NetBSD: efiboot.c,v 1.8 2018/06/08 11:52:30 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -28,7 +28,6 @@
 
 #include "efiboot.h"
 
-#include "biosdisk_ll.h"
 #include "bootinfo.h"
 #include "devopen.h"
 



CVS commit: src/sys/arch/i386/stand/efiboot

2018-05-16 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Wed May 16 19:53:54 UTC 2018

Modified Files:
src/sys/arch/i386/stand/efiboot: eficons.c

Log Message:
During awaitkey(), move the cursor back to the beginning of the
countdown with '\b' only after waiting.

Some UEFI implementations have a destructive/erasing backspace,
and will not show the countdown if we move the cursor back before the
wait.

My ThinkPad T430 w/ Lenovo's UEFI exhibited this whiteout-backspace,
while my Gigabyte Brix GB-BXBT-2807 did not.

Should fix PR #53292.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/i386/stand/efiboot/eficons.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/arch/i386/stand/efiboot/eficons.c
diff -u src/sys/arch/i386/stand/efiboot/eficons.c:1.5 src/sys/arch/i386/stand/efiboot/eficons.c:1.6
--- src/sys/arch/i386/stand/efiboot/eficons.c:1.5	Tue Mar 27 14:15:05 2018
+++ src/sys/arch/i386/stand/efiboot/eficons.c	Wed May 16 19:53:54 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: eficons.c,v 1.5 2018/03/27 14:15:05 nonaka Exp $	*/
+/*	$NetBSD: eficons.c,v 1.6 2018/05/16 19:53:54 jakllsch Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -328,10 +328,10 @@ awaitkey(int timeout, int tell)
 	char c = 0;
 
 	for (;;) {
-		if (tell && timeout) {
-			char numbuf[32];
-			int len;
+		char numbuf[32];
+		int len;
 
+		if (tell && timeout) {
 			len = snprintf(numbuf, sizeof(numbuf), "%d seconds. ",
 			timeout);
 			if (len > 0 && len < sizeof(numbuf)) {
@@ -340,7 +340,6 @@ awaitkey(int timeout, int tell)
 printf("%s", numbuf);
 while (*p)
 	*p++ = '\b';
-printf("%s", numbuf);
 			}
 		}
 		if (iskey(1)) {
@@ -355,6 +354,8 @@ awaitkey(int timeout, int tell)
 			internal_waitforinputevent(1000);
 		else
 			break;
+		if (tell)
+			printf("%s", numbuf);
 	}
 
 out:



CVS commit: src/sys/arch/i386/stand/efiboot

2018-04-11 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Wed Apr 11 10:32:10 UTC 2018

Modified Files:
src/sys/arch/i386/stand/efiboot: Makefile.efiboot boot.c conf.c
devopen.c devopen.h efiboot.c efiboot.h efidisk.c
Added Files:
src/sys/arch/i386/stand/efiboot: dev_net.c efinet.c efinet.h efipxe.c

Log Message:
efiboot: Added network boot support.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/i386/stand/efiboot/Makefile.efiboot
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/i386/stand/efiboot/boot.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/i386/stand/efiboot/conf.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/i386/stand/efiboot/dev_net.c \
src/sys/arch/i386/stand/efiboot/efinet.c \
src/sys/arch/i386/stand/efiboot/efinet.h \
src/sys/arch/i386/stand/efiboot/efipxe.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/i386/stand/efiboot/devopen.c
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/i386/stand/efiboot/devopen.h
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/i386/stand/efiboot/efiboot.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/i386/stand/efiboot/efiboot.h
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/i386/stand/efiboot/efidisk.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/arch/i386/stand/efiboot/Makefile.efiboot
diff -u src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.11 src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.12
--- src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.11	Tue Mar 27 14:15:05 2018
+++ src/sys/arch/i386/stand/efiboot/Makefile.efiboot	Wed Apr 11 10:32:09 2018
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.efiboot,v 1.11 2018/03/27 14:15:05 nonaka Exp $
+# $NetBSD: Makefile.efiboot,v 1.12 2018/04/11 10:32:09 nonaka Exp $
 
 S=		${.CURDIR}/../../../../..
 
@@ -8,12 +8,12 @@ NEWVERSWHAT?=	"EFI Boot"
 
 AFLAGS.start.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:}
 
-SOURCES?= start.S conf.c devopen.c efiboot.c self_reloc.c
-LIBI386SRCS= boot.c biosdisk.c bootinfo.c bootinfo_biosgeom.c
-LIBI386SRCS+= bootmenu.c diskbuf.c exec.c menuutils.c
-LIBI386SRCS+= panic.c parseutils.c pread.c
-LIBI386SRCS+= efichar.c eficons.c efidelay.c efidev.c efidisk.c efidisk_ll.c
-LIBI386SRCS+= efigetsecs.c efimemory.c
+SOURCES= start.S boot.c conf.c devopen.c dev_net.c self_reloc.c panic.c
+SOURCES+= efiboot.c efichar.c eficons.c efidelay.c efidev.c
+SOURCES+= efidisk.c efidisk_ll.c efigetsecs.c efimemory.c
+SOURCES+= efinet.c efipxe.c
+LIBI386SRCS= biosdisk.c bootinfo.c bootinfo_biosgeom.c bootmenu.c
+LIBI386SRCS+= diskbuf.c exec.c menuutils.c parseutils.c pread.c
 SRCS= ${SOURCES} ${EXTRA_SOURCES} ${LIBI386SRCS}
 
 PIE_CFLAGS=
@@ -57,10 +57,22 @@ CPPFLAGS+= -DSUPPORT_CD9660
 CPPFLAGS+= -D"devb2cdb(bno)=(bno)"
 CPPFLAGS+= -DSUPPORT_DOSFS
 CPPFLAGS+= -DSUPPORT_EXT2FS
+CPPFLAGS+= -DSUPPORT_BOOTP
+CPPFLAGS+= -DSUPPORT_DHCP
+CPPFLAGS+= -DSUPPORT_NFS
+#CPPFLAGS+= -DSUPPORT_TFTP
 CPPFLAGS+= -DPASS_BIOSGEOM
 CPPFLAGS+= -DBIOSDISK_DEFAULT_SECSIZE=2048	# for bootinfo_biosgeom.c
 CPPFLAGS+= -DLIBSA_ENABLE_LS_OP
 
+#CPPFLAGS+= -DARP_DEBUG
+#CPPFLAGS+= -DBOOTP_DEBUG
+#CPPFLAGS+= -DNET_DEBUG
+#CPPFLAGS+= -DNETIF_DEBUG
+#CPPFLAGS+= -DNFS_DEBUG
+#CPPFLAGS+= -DRARP_DEBUG
+#CPPFLAGS+= -DRPC_DEBUG
+
 EFIDIR= ${S}/external/bsd/gnu-efi/dist
 GNUEFIARCH?= ${MACHINE_CPU}
 CPPFLAGS+= -I${EFIDIR}/inc -I${EFIDIR}/inc/${GNUEFIARCH}
@@ -69,12 +81,12 @@ CPPFLAGS+= -I${EFIDIR}/inc/protocol
 SAMISCCPPFLAGS+= -DLIBSA_PRINTF_LONGLONG_SUPPORT
 SAMISCCPPFLAGS+= -DLIBSA_PRINTF_WIDTH_SUPPORT
 SAMISCCPPFLAGS+= -D"cdb2devb(bno)=(bno)"
-SAMISCMAKEFLAGS+= SA_USE_CREAD=yes  # Read compressed kernels
-SAMISCMAKEFLAGS+= SA_INCLUDE_NET=no # Netboot via TFTP, NFS
 
 ### find out what to use for libsa
 SA_AS= library
 SAMISCMAKEFLAGS+="SA_USE_LOADFILE=yes"
+SAMISCMAKEFLAGS+="SA_USE_CREAD=yes"
+SAMISCMAKEFLAGS+="SA_INCLUDE_NET=yes"
 SAMISCMAKEFLAGS+="SA_ENABLE_LS_OP=yes"
 .include "${S}/lib/libsa/Makefile.inc"
 LIBSA= ${SALIB}

Index: src/sys/arch/i386/stand/efiboot/boot.c
diff -u src/sys/arch/i386/stand/efiboot/boot.c:1.9 src/sys/arch/i386/stand/efiboot/boot.c:1.10
--- src/sys/arch/i386/stand/efiboot/boot.c:1.9	Mon Apr  2 09:44:18 2018
+++ src/sys/arch/i386/stand/efiboot/boot.c	Wed Apr 11 10:32:09 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: boot.c,v 1.9 2018/04/02 09:44:18 nonaka Exp $	*/
+/*	$NetBSD: boot.c,v 1.10 2018/04/11 10:32:09 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -182,6 +182,21 @@ parsebootfile(const char *fname, char **
 }
 
 static char *
+snprint_bootdev(char *buf, size_t bufsize, const char *devname, int unit,
+int partition)
+{
+	static const char *no_partition_devs[] = { "esp", "net", "nfs", "tftp" };
+	int i;
+
+	for (i = 0; i < __arraycount(no_partition_devs); i++)
+		if (strcmp(devname, no_partition_devs[i]) == 0)
+			break;
+	snprintf(buf, bufsize, "%s%d%c", devname, unit,
+	i < __arraycount(no_partition_devs) ? '\0' : 'a' + partition);
+	return buf;
+}
+
+static char *
 

CVS commit: src/sys/arch/i386/stand/efiboot

2018-03-27 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Tue Mar 27 14:15:05 UTC 2018

Modified Files:
src/sys/arch/i386/stand/efiboot: Makefile.efiboot boot.c efiboot.c
efiboot.h eficons.c efidelay.c efidisk.c efimemory.c
src/sys/arch/i386/stand/efiboot/bootia32: efibootia32.c
src/sys/arch/i386/stand/efiboot/bootx64: efibootx64.c
Added Files:
src/sys/arch/i386/stand/efiboot: efichar.c

Log Message:
efiboot: Added serial console support.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/i386/stand/efiboot/Makefile.efiboot
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/i386/stand/efiboot/boot.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/i386/stand/efiboot/efiboot.c
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/i386/stand/efiboot/efiboot.h
cvs rdiff -u -r0 -r1.1 src/sys/arch/i386/stand/efiboot/efichar.c
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/i386/stand/efiboot/eficons.c \
src/sys/arch/i386/stand/efiboot/efimemory.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/i386/stand/efiboot/efidelay.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/i386/stand/efiboot/efidisk.c
cvs rdiff -u -r1.3 -r1.4 \
src/sys/arch/i386/stand/efiboot/bootia32/efibootia32.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/i386/stand/efiboot/bootx64/efibootx64.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/arch/i386/stand/efiboot/Makefile.efiboot
diff -u src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.10 src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.11
--- src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.10	Thu Mar  8 10:34:33 2018
+++ src/sys/arch/i386/stand/efiboot/Makefile.efiboot	Tue Mar 27 14:15:05 2018
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.efiboot,v 1.10 2018/03/08 10:34:33 nonaka Exp $
+# $NetBSD: Makefile.efiboot,v 1.11 2018/03/27 14:15:05 nonaka Exp $
 
 S=		${.CURDIR}/../../../../..
 
@@ -12,7 +12,7 @@ SOURCES?= start.S conf.c devopen.c efibo
 LIBI386SRCS= boot.c biosdisk.c bootinfo.c bootinfo_biosgeom.c
 LIBI386SRCS+= bootmenu.c diskbuf.c exec.c menuutils.c
 LIBI386SRCS+= panic.c parseutils.c pread.c
-LIBI386SRCS+= eficons.c efidelay.c efidev.c efidisk.c efidisk_ll.c
+LIBI386SRCS+= efichar.c eficons.c efidelay.c efidev.c efidisk.c efidisk_ll.c
 LIBI386SRCS+= efigetsecs.c efimemory.c
 SRCS= ${SOURCES} ${EXTRA_SOURCES} ${LIBI386SRCS}
 

Index: src/sys/arch/i386/stand/efiboot/boot.c
diff -u src/sys/arch/i386/stand/efiboot/boot.c:1.7 src/sys/arch/i386/stand/efiboot/boot.c:1.8
--- src/sys/arch/i386/stand/efiboot/boot.c:1.7	Tue Mar 20 10:18:10 2018
+++ src/sys/arch/i386/stand/efiboot/boot.c	Tue Mar 27 14:15:05 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: boot.c,v 1.7 2018/03/20 10:18:10 nonaka Exp $	*/
+/*	$NetBSD: boot.c,v 1.8 2018/03/27 14:15:05 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -463,11 +463,16 @@ command_consdev(char *arg)
 	char *sep, *sep2 = NULL;
 	int ioport, speed = 0;
 
+	if (*arg == '\0') {
+		efi_cons_show();
+		return;
+	}
+
 	sep = strchr(arg, ',');
 	if (sep != NULL) {
 		*sep++ = '\0';
 		sep2 = strchr(sep, ',');
-		if (sep != NULL)
+		if (sep2 != NULL)
 			*sep2++ = '\0';
 	}
 
@@ -555,6 +560,8 @@ void
 command_version(char *arg)
 {
 	CHAR16 *path;
+	char *upath, *ufirmware;
+	int rv;
 
 	if (strcmp(arg, "full") == 0) {
 		printf("ImageBase: 0x%" PRIxPTR "\n",
@@ -562,12 +569,24 @@ command_version(char *arg)
 		printf("Stack: 0x%" PRIxPTR "\n", efi_main_sp);
 		printf("EFI version: %d.%02d\n",
 		ST->Hdr.Revision >> 16, ST->Hdr.Revision & 0x);
-		Print(L"EFI Firmware: %s (rev %d.%02d)\n", ST->FirmwareVendor,
-		ST->FirmwareRevision >> 16, ST->FirmwareRevision & 0x);
+		ufirmware = NULL;
+		rv = ucs2_to_utf8(ST->FirmwareVendor, );
+		if (rv == 0) {
+			printf("EFI Firmware: %s (rev %d.%02d)\n", ufirmware,
+			ST->FirmwareRevision >> 16,
+			ST->FirmwareRevision & 0x);
+			FreePool(ufirmware);
+		}
 		path = DevicePathToStr(efi_bootdp);
-		Print(L"Boot DevicePath: %d:%d:%s\n", DevicePathType(efi_bootdp),
-		DevicePathSubType(efi_bootdp), path);
+		upath = NULL;
+		rv = ucs2_to_utf8(path, );
 		FreePool(path);
+		if (rv == 0) {
+			printf("Boot DevicePath: %d:%d:%s\n",
+			DevicePathType(efi_bootdp),
+			DevicePathSubType(efi_bootdp), upath);
+			FreePool(upath);
+		}
 	}
 
 	printf("\n"
@@ -603,7 +622,9 @@ command_devpath(char *arg)
 	EFI_HANDLE *handles;
 	EFI_DEVICE_PATH *dp0, *dp;
 	CHAR16 *path;
+	char *upath;
 	UINTN cols, rows, row = 0;
+	int rv;
 
 	status = uefi_call_wrapper(ST->ConOut->QueryMode, 4, ST->ConOut,
 	ST->ConOut->Mode->Mode, , );
@@ -626,41 +647,54 @@ command_devpath(char *arg)
 		if (EFI_ERROR(status))
 			break;
 
-		Print(L"DevicePathType %d\n", DevicePathType(dp0));
+		printf("DevicePathType %d\n", DevicePathType(dp0));
 		if (++row >= rows) {
 			row = 0;
-			Print(L"Press Any Key to continue :");
+			printf("Press Any Key to continue :");
 			(void) awaitkey(-1, 0);
-			

CVS commit: src/sys/arch/i386/stand/efiboot

2018-03-20 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Tue Mar 20 10:19:33 UTC 2018

Modified Files:
src/sys/arch/i386/stand/efiboot: efidisk.c

Log Message:
efiboot: boot device is always efi_distlist first element.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/i386/stand/efiboot/efidisk.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/arch/i386/stand/efiboot/efidisk.c
diff -u src/sys/arch/i386/stand/efiboot/efidisk.c:1.2 src/sys/arch/i386/stand/efiboot/efidisk.c:1.3
--- src/sys/arch/i386/stand/efiboot/efidisk.c:1.2	Thu Mar  8 10:34:33 2018
+++ src/sys/arch/i386/stand/efiboot/efidisk.c	Tue Mar 20 10:19:33 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: efidisk.c,v 1.2 2018/03/08 10:34:33 nonaka Exp $	*/
+/*	$NetBSD: efidisk.c,v 1.3 2018/03/20 10:19:33 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -106,14 +106,11 @@ next:
 	FreePool(handles);
 
 	if (efi_bootdp_type == BIOSDISK_TYPE_CD) {
-		TAILQ_FOREACH(edi, _disklist, list) {
-			if (edi->bootdev) {
-edi = TAILQ_FIRST(_disklist);
-edi->type = BIOSDISK_TYPE_CD;
-TAILQ_REMOVE(_disklist, edi, list);
-TAILQ_INSERT_TAIL(_disklist, edi, list);
-break;
-			}
+		edi = TAILQ_FIRST(_disklist);
+		if (edi != NULL && edi->bootdev) {
+			edi->type = BIOSDISK_TYPE_CD;
+			TAILQ_REMOVE(_disklist, edi, list);
+			TAILQ_INSERT_TAIL(_disklist, edi, list);
 		}
 	}
 



CVS commit: src/sys/arch/i386/stand/efiboot

2018-03-20 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Tue Mar 20 10:18:10 UTC 2018

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

Log Message:
efiboot: more pager.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/i386/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/arch/i386/stand/efiboot/boot.c
diff -u src/sys/arch/i386/stand/efiboot/boot.c:1.6 src/sys/arch/i386/stand/efiboot/boot.c:1.7
--- src/sys/arch/i386/stand/efiboot/boot.c:1.6	Thu Mar  8 10:34:33 2018
+++ src/sys/arch/i386/stand/efiboot/boot.c	Tue Mar 20 10:18:10 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: boot.c,v 1.6 2018/03/08 10:34:33 nonaka Exp $	*/
+/*	$NetBSD: boot.c,v 1.7 2018/03/20 10:18:10 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -627,6 +627,12 @@ command_devpath(char *arg)
 			break;
 
 		Print(L"DevicePathType %d\n", DevicePathType(dp0));
+		if (++row >= rows) {
+			row = 0;
+			Print(L"Press Any Key to continue :");
+			(void) awaitkey(-1, 0);
+			Print(L"\n");
+		}
 		for (dp = dp0;
 		 !IsDevicePathEnd(dp);
 		 dp = NextDevicePathNode(dp)) {



CVS commit: src/sys/arch/i386/stand/efiboot

2018-03-20 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Tue Mar 20 10:16:18 UTC 2018

Modified Files:
src/sys/arch/i386/stand/efiboot: devopen.c

Log Message:
efiboot: fix it can't boot from HDD.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/i386/stand/efiboot/devopen.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/arch/i386/stand/efiboot/devopen.c
diff -u src/sys/arch/i386/stand/efiboot/devopen.c:1.2 src/sys/arch/i386/stand/efiboot/devopen.c:1.3
--- src/sys/arch/i386/stand/efiboot/devopen.c:1.2	Thu Mar  8 10:34:33 2018
+++ src/sys/arch/i386/stand/efiboot/devopen.c	Tue Mar 20 10:16:17 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: devopen.c,v 1.2 2018/03/08 10:34:33 nonaka Exp $	 */
+/*	$NetBSD: devopen.c,v 1.3 2018/03/20 10:16:17 nonaka Exp $	 */
 
 /*-
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -66,7 +66,7 @@ dev2bios(char *devname, int unit, int *b
 
 	if (strcmp(devname, "hd") == 0)
 		*biosdev = 0x80 + unit;
-	if (strcmp(devname, "cd") == 0)
+	else if (strcmp(devname, "cd") == 0)
 		*biosdev = 0x80 + get_harddrives() + unit;
 	else
 		return ENXIO;



CVS commit: src/sys/arch/i386/stand/efiboot

2017-05-01 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Mon May  1 13:03:02 UTC 2017

Modified Files:
src/sys/arch/i386/stand/efiboot: boot.c efiboot.h eficons.c

Log Message:
efiboot: implement consdev command.

no support to change console device for efiboot yet.
only pass console parameters to kernel.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/i386/stand/efiboot/boot.c \
src/sys/arch/i386/stand/efiboot/efiboot.h
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/i386/stand/efiboot/eficons.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/arch/i386/stand/efiboot/boot.c
diff -u src/sys/arch/i386/stand/efiboot/boot.c:1.4 src/sys/arch/i386/stand/efiboot/boot.c:1.5
--- src/sys/arch/i386/stand/efiboot/boot.c:1.4	Sun Mar 12 05:33:48 2017
+++ src/sys/arch/i386/stand/efiboot/boot.c	Mon May  1 13:03:01 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: boot.c,v 1.4 2017/03/12 05:33:48 nonaka Exp $	*/
+/*	$NetBSD: boot.c,v 1.5 2017/05/01 13:03:01 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -30,6 +30,7 @@
 
 #include 
 #include 
+#include 
 
 #include "bootcfg.h"
 #include "bootmod.h"
@@ -340,7 +341,7 @@ command_help(char *arg)
 	   "boot [xdNx:][filename] [-12acdqsvxz]\n"
 	   " (ex. \"hd0a:netbsd.old -s\"\n"
 	   "dev [xd[N[x]]:]\n"
-	   "consdev {pc|com[0123]|com[0123]kbd|auto}\n"
+	   "consdev {pc|com[0123][,{speed}]|com,{ioport}[,{speed}]}\n"
 	   "devpath\n"
 	   "efivar\n"
 	   "gop [{modenum|list}]\n"
@@ -436,12 +437,77 @@ command_dev(char *arg)
 	default_devname = savedevname;
 }
 
-/* ARGSUSED */
+static const struct cons_devs {
+	const char	*name;
+	u_int		tag;
+	int		ioport;
+} cons_devs[] = {
+	{ "pc",		CONSDEV_PC,   0 },
+	{ "com0",	CONSDEV_COM0, 0 },
+	{ "com1",	CONSDEV_COM1, 0 },
+	{ "com2",	CONSDEV_COM2, 0 },
+	{ "com3",	CONSDEV_COM3, 0 },
+	{ "com0kbd",	CONSDEV_COM0KBD, 0 },
+	{ "com1kbd",	CONSDEV_COM1KBD, 0 },
+	{ "com2kbd",	CONSDEV_COM2KBD, 0 },
+	{ "com3kbd",	CONSDEV_COM3KBD, 0 },
+	{ "com",	CONSDEV_COM0, -1 },
+	{ "auto",	CONSDEV_AUTO, 0 },
+	{ NULL,		0 }
+};
+
 void
 command_consdev(char *arg)
 {
-
-	/* XXX not implemented yet */
+	const struct cons_devs *cdp;
+	char *sep, *sep2 = NULL;
+	int ioport, speed = 0;
+
+	sep = strchr(arg, ',');
+	if (sep != NULL) {
+		*sep++ = '\0';
+		sep2 = strchr(sep, ',');
+		if (sep != NULL)
+			*sep2++ = '\0';
+	}
+
+	for (cdp = cons_devs; cdp->name; cdp++) {
+		if (strcmp(arg, cdp->name) == 0) {
+			ioport = cdp->ioport;
+			if (cdp->tag == CONSDEV_PC || cdp->tag == CONSDEV_AUTO) {
+if (sep != NULL || sep2 != NULL)
+	goto error;
+			} else {
+/* com? */
+if (ioport == -1) {
+	if (sep != NULL) {
+		u_long t = strtoul(sep, NULL, 0);
+		if (t > INT_MAX)
+			goto error;
+		ioport = (int)t;
+	}
+	if (sep2 != NULL) {
+		speed = atoi(sep2);
+		if (speed < 0)
+			goto error;
+	}
+} else {
+	if (sep != NULL) {
+		speed = atoi(sep);
+		if (speed < 0)
+			goto error;
+	}
+	if (sep2 != NULL)
+		goto error;
+}
+			}
+			consinit(cdp->tag, ioport, speed);
+			print_banner();
+			return;
+		}
+	}
+error:
+	printf("invalid console device.\n");
 }
 
 #ifndef SMALL
Index: src/sys/arch/i386/stand/efiboot/efiboot.h
diff -u src/sys/arch/i386/stand/efiboot/efiboot.h:1.4 src/sys/arch/i386/stand/efiboot/efiboot.h:1.5
--- src/sys/arch/i386/stand/efiboot/efiboot.h:1.4	Sat Feb 11 10:23:39 2017
+++ src/sys/arch/i386/stand/efiboot/efiboot.h	Mon May  1 13:03:01 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: efiboot.h,v 1.4 2017/02/11 10:23:39 nonaka Exp $	*/
+/*	$NetBSD: efiboot.h,v 1.5 2017/05/01 13:03:01 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -55,6 +55,7 @@ void efi_cleanup(void);
 
 /* eficons.c */
 int cninit(void);
+void consinit(int, int, int);
 void command_text(char *);
 void command_gop(char *);
 

Index: src/sys/arch/i386/stand/efiboot/eficons.c
diff -u src/sys/arch/i386/stand/efiboot/eficons.c:1.3 src/sys/arch/i386/stand/efiboot/eficons.c:1.4
--- src/sys/arch/i386/stand/efiboot/eficons.c:1.3	Fri Mar 24 01:25:36 2017
+++ src/sys/arch/i386/stand/efiboot/eficons.c	Mon May  1 13:03:01 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: eficons.c,v 1.3 2017/03/24 01:25:36 nonaka Exp $	*/
+/*	$NetBSD: eficons.c,v 1.4 2017/05/01 13:03:01 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -34,6 +34,8 @@
 #include "bootinfo.h"
 #include "vbe.h"
 
+extern struct x86_boot_params boot_params;
+
 struct btinfo_console btinfo_console;
 
 static EFI_GRAPHICS_OUTPUT_PROTOCOL *efi_gop;
@@ -46,6 +48,68 @@ static int keybuf_write = 0;
 static void eficons_init_video(void);
 static void efi_switch_video_to_text_mode(void);
 
+static int
+getcomaddr(int idx)
+{
+	static const short comioport[4] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8 };
+
+	if (idx < __arraycount(comioport))

CVS commit: src/sys/arch/i386/stand/efiboot

2017-03-23 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Fri Mar 24 01:25:36 UTC 2017

Modified Files:
src/sys/arch/i386/stand/efiboot: eficons.c

Log Message:
Don't maximize the text columns and rows. only use 100x31 or 80x25.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/i386/stand/efiboot/eficons.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/arch/i386/stand/efiboot/eficons.c
diff -u src/sys/arch/i386/stand/efiboot/eficons.c:1.2 src/sys/arch/i386/stand/efiboot/eficons.c:1.3
--- src/sys/arch/i386/stand/efiboot/eficons.c:1.2	Fri Mar 24 01:00:47 2017
+++ src/sys/arch/i386/stand/efiboot/eficons.c	Fri Mar 24 01:25:36 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: eficons.c,v 1.2 2017/03/24 01:00:47 nonaka Exp $	*/
+/*	$NetBSD: eficons.c,v 1.3 2017/03/24 01:25:36 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -499,24 +499,27 @@ static void
 eficons_init_video(void)
 {
 	EFI_STATUS status;
-	UINTN cols, rows, dim = 0;
-	INT32 i, best = -1;
+	UINTN cols, rows;
+	INT32 i, best, mode80x25, mode100x31;
 
 	/*
 	 * Setup text mode
 	 */
 	uefi_call_wrapper(ST->ConOut->Reset, 2, ST->ConOut, TRUE);
 
+	mode80x25 = mode100x31 = -1;
 	for (i = 0; i < ST->ConOut->Mode->MaxMode; i++) {
 		status = uefi_call_wrapper(ST->ConOut->QueryMode, 4,
 		ST->ConOut, i, , );
 		if (EFI_ERROR(status))
 			continue;
-		if (dim < cols * rows) {
-			dim = cols * rows;
-			best = i;
-		}
+
+		if (mode80x25 < 0 && cols == 80 && rows == 25)
+			mode80x25 = i;
+		else if (mode100x31 < 0 && cols == 100 && rows == 31)
+			mode100x31 = i;
 	}
+	best = mode100x31 >= 0 ? mode100x31 : mode80x25 >= 0 ? mode80x25 : -1;
 	if (best >= 0)
 		uefi_call_wrapper(ST->ConOut->SetMode, 2, ST->ConOut, best);
 	uefi_call_wrapper(ST->ConOut->EnableCursor, 2, ST->ConOut, TRUE);



CVS commit: src/sys/arch/i386/stand/efiboot

2017-03-23 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Fri Mar 24 01:00:47 UTC 2017

Modified Files:
src/sys/arch/i386/stand/efiboot: eficons.c

Log Message:
Don't maximize the screen size when gop is not specified.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/i386/stand/efiboot/eficons.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/arch/i386/stand/efiboot/eficons.c
diff -u src/sys/arch/i386/stand/efiboot/eficons.c:1.1 src/sys/arch/i386/stand/efiboot/eficons.c:1.2
--- src/sys/arch/i386/stand/efiboot/eficons.c:1.1	Tue Jan 24 11:09:14 2017
+++ src/sys/arch/i386/stand/efiboot/eficons.c	Fri Mar 24 01:00:47 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: eficons.c,v 1.1 2017/01/24 11:09:14 nonaka Exp $	*/
+/*	$NetBSD: eficons.c,v 1.2 2017/03/24 01:00:47 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -209,9 +209,6 @@ bi_framebuffer(void)
 	EFI_STATUS status;
 	EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *info;
 	struct btinfo_framebuffer fb;
-	UINT64 res, bestres = 0;
-	UINTN sz;
-	UINT32 i;
 	INT32 bestmode = -1;
 
 	if (efi_gop == NULL) {
@@ -222,7 +219,12 @@ bi_framebuffer(void)
 	if (efi_gop_mode >= 0) {
 		bestmode = efi_gop_mode;
 	} else {
-		/* XXX EDID? EFI_EDID_DISCOVERD_PROTOCOL */
+#if 0
+		UINT64 res, bestres = 0;
+		UINTN sz;
+		UINT32 i;
+
+		/* XXX EDID? EFI_EDID_DISCOVERED_PROTOCOL */
 		for (i = 0; i < efi_gop->Mode->MaxMode; i++) {
 			status = uefi_call_wrapper(efi_gop->QueryMode, 4,
 			efi_gop, i, , );
@@ -237,6 +239,7 @@ bi_framebuffer(void)
 bestres = res;
 			}
 		}
+#endif
 	}
 	if (bestmode >= 0) {
 		status = uefi_call_wrapper(efi_gop->SetMode, 2, efi_gop,



CVS commit: src/sys/arch/i386/stand/efiboot

2017-03-11 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Sun Mar 12 06:37:41 UTC 2017

Modified Files:
src/sys/arch/i386/stand/efiboot: TODO.efiboot

Log Message:
Remove `fix module_init()' entry.

I've been committed.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/i386/stand/efiboot/TODO.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/arch/i386/stand/efiboot/TODO.efiboot
diff -u src/sys/arch/i386/stand/efiboot/TODO.efiboot:1.2 src/sys/arch/i386/stand/efiboot/TODO.efiboot:1.3
--- src/sys/arch/i386/stand/efiboot/TODO.efiboot:1.2	Tue Feb 21 10:53:37 2017
+++ src/sys/arch/i386/stand/efiboot/TODO.efiboot	Sun Mar 12 06:37:41 2017
@@ -2,7 +2,6 @@
  * handle UEFI variables
  * boot from CD/DVD (bootable from CD/DVD, but root fs not found.)
  * load boot.cfg from EFI system partition (FAT32)
- * fix module_init(). need to allocate memory for modules.
 
 - kernel
  * handle UEFI variables (/dev/efivar)



CVS commit: src/sys/arch/i386/stand/efiboot

2017-03-03 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Fri Mar  3 09:29:57 UTC 2017

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

Log Message:
efiboot: fix efivar command.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/i386/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/arch/i386/stand/efiboot/boot.c
diff -u src/sys/arch/i386/stand/efiboot/boot.c:1.2 src/sys/arch/i386/stand/efiboot/boot.c:1.3
--- src/sys/arch/i386/stand/efiboot/boot.c:1.2	Fri Feb  3 16:42:26 2017
+++ src/sys/arch/i386/stand/efiboot/boot.c	Fri Mar  3 09:29:57 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: boot.c,v 1.2 2017/02/03 16:42:26 roy Exp $	*/
+/*	$NetBSD: boot.c,v 1.3 2017/03/03 09:29:57 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -557,7 +557,7 @@ command_efivar(char *arg)
 	 L"GUIDVariable NameValue\n"
 	 L"===  \n";
 	EFI_STATUS status;
-	UINTN sz = 64;
+	UINTN sz = 64, osz;
 	CHAR16 *name = NULL, *tmp, *val;
 	EFI_GUID vendor;
 	UINTN cols, rows, row = 0;
@@ -576,11 +576,12 @@ command_efivar(char *arg)
 		return;
 	}
 
-	name[0] = 0;
+	SetMem(name, sz, 0);
 	vendor = NullGuid;
 
 	Print(L"%s", header);
 	for (;;) {
+		osz = sz;
 		status = uefi_call_wrapper(RT->GetNextVariableName, 3,
 		, name, );
 		if (EFI_ERROR(status)) {
@@ -598,8 +599,11 @@ command_efivar(char *arg)
 (UINT64)sz);
 break;
 			}
+			SetMem(tmp, sz, 0);
+			CopyMem(tmp, name, osz);
 			FreePool(name);
 			name = tmp;
+			continue;
 		}
 
 		val = LibGetVariable(name, );



CVS commit: src/sys/arch/i386/stand/efiboot/bootia32

2017-02-24 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Fri Feb 24 12:24:25 UTC 2017

Modified Files:
src/sys/arch/i386/stand/efiboot/bootia32: startprog32.S

Log Message:
efiboot: Don't access old stack after copying a kernel.

It's possible that the old stack is overwritten by the kernel.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 \
src/sys/arch/i386/stand/efiboot/bootia32/startprog32.S

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

Modified files:

Index: src/sys/arch/i386/stand/efiboot/bootia32/startprog32.S
diff -u src/sys/arch/i386/stand/efiboot/bootia32/startprog32.S:1.1 src/sys/arch/i386/stand/efiboot/bootia32/startprog32.S:1.2
--- src/sys/arch/i386/stand/efiboot/bootia32/startprog32.S:1.1	Tue Feb 21 10:53:37 2017
+++ src/sys/arch/i386/stand/efiboot/bootia32/startprog32.S	Fri Feb 24 12:24:25 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: startprog32.S,v 1.1 2017/02/21 10:53:37 nonaka Exp $	*/
+/*	$NetBSD: startprog32.S,v 1.2 2017/02/24 12:24:25 nonaka Exp $	*/
 /*	NetBSD: startprog.S,v 1.4 2016/12/04 08:21:08 maxv Exp	*/
 
 /*
@@ -91,6 +91,9 @@ start:
 
 	cli
 
+	movl	8(%ebp), %ebx	/* %ebx: entry address */
+	movl	36(%ebp), %edx	/* %edx: loaded start address */
+
 	/* Prepare a new stack */
 	movl	20(%ebp), %eax	/* stack */
 	subl	$4, %eax
@@ -108,12 +111,12 @@ start:
 	rep
 	movsl			/* copy %ds:(%esi) -> %es:(%edi) */
 	cld
-	mov	%edi, %edx	/* %edx: new stack pointer */
+	mov	%edi, %esp	/* set new stack pointer */
 
 	/* Copy kernel */
-	movl	24(%esp), %edi	/* dest */
-	movl	28(%esp), %esi	/* src */
-	movl	32(%esp), %ecx	/* size */
+	movl	24(%ebp), %edi	/* dest */
+	movl	28(%ebp), %esi	/* src */
+	movl	32(%ebp), %ecx	/* size */
 #if defined(NO_OVERLAP)
 	movl	%ecx, %eax
 #else
@@ -179,20 +182,17 @@ start:
 .Lcopy_done:
 	cld			/* LynxOS depends on it */
 
-	movl	8(%ebp), %esi	/* %esi: entry address */
-	movl	36(%ebp), %edi	/* %edi: loaded start address */
-
 	/* Prepare jump address */
-	lea	(start32a - start)(%edi), %eax
-	movl	%eax, (start32r - start)(%edi)
+	lea	(start32a - start)(%edx), %eax
+	movl	%eax, (start32r - start)(%edx)
 
 	/* Setup GDT */
-	lea	(gdt - start)(%edi), %eax
-	movl	%eax, (gdtrr - start)(%edi)
-	lgdt	(gdtr - start)(%edi)
+	lea	(gdt - start)(%edx), %eax
+	movl	%eax, (gdtrr - start)(%edx)
+	lgdt	(gdtr - start)(%edx)
 
 	/* Jump to set %cs */
-	ljmp	*(start32r - start)(%edi)
+	ljmp	*(start32r - start)(%edx)
 
 	.align	4
 start32a:
@@ -203,7 +203,8 @@ start32a:
 	movw	%ax, %gs
 	movw	%ax, %ss
 
-	movl	%edx, %esp
+	/* Already set new stack pointer */
+	movl	%esp, %ebp
 
 	/* Disable Paging in CR0 */
 	movl	%cr0, %eax
@@ -220,8 +221,8 @@ start32a:
 	.align	4
 start32b:
 	xor	%eax, %eax
-	movl	%esi, (start32r - start)(%edi)
-	ljmp	*(start32r - start)(%edi)
+	movl	%ebx, (start32r - start)(%edx)
+	ljmp	*(start32r - start)(%edx)
 
 	.align	16
 start32r:



CVS commit: src/sys/arch/i386/stand/efiboot

2017-02-21 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Tue Feb 21 10:53:37 UTC 2017

Modified Files:
src/sys/arch/i386/stand/efiboot: TODO.efiboot
src/sys/arch/i386/stand/efiboot/bootia32: Makefile efibootia32.c
Added Files:
src/sys/arch/i386/stand/efiboot/bootia32: startprog32.S

Log Message:
fix to be able to boot amd64 kernel from 32bit efiboot (booia32.efi).


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/i386/stand/efiboot/TODO.efiboot
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/i386/stand/efiboot/bootia32/Makefile \
src/sys/arch/i386/stand/efiboot/bootia32/efibootia32.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/i386/stand/efiboot/bootia32/startprog32.S

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

Modified files:

Index: src/sys/arch/i386/stand/efiboot/TODO.efiboot
diff -u src/sys/arch/i386/stand/efiboot/TODO.efiboot:1.1 src/sys/arch/i386/stand/efiboot/TODO.efiboot:1.2
--- src/sys/arch/i386/stand/efiboot/TODO.efiboot:1.1	Sat Feb 11 10:33:44 2017
+++ src/sys/arch/i386/stand/efiboot/TODO.efiboot	Tue Feb 21 10:53:37 2017
@@ -3,7 +3,6 @@
  * boot from CD/DVD (bootable from CD/DVD, but root fs not found.)
  * load boot.cfg from EFI system partition (FAT32)
  * fix module_init(). need to allocate memory for modules.
- * bootia32.efi can load kernel, but can't start kernel
 
 - kernel
  * handle UEFI variables (/dev/efivar)

Index: src/sys/arch/i386/stand/efiboot/bootia32/Makefile
diff -u src/sys/arch/i386/stand/efiboot/bootia32/Makefile:1.1 src/sys/arch/i386/stand/efiboot/bootia32/Makefile:1.2
--- src/sys/arch/i386/stand/efiboot/bootia32/Makefile:1.1	Tue Jan 24 11:09:14 2017
+++ src/sys/arch/i386/stand/efiboot/bootia32/Makefile	Tue Feb 21 10:53:37 2017
@@ -1,9 +1,9 @@
-#	$NetBSD: Makefile,v 1.1 2017/01/24 11:09:14 nonaka Exp $
+#	$NetBSD: Makefile,v 1.2 2017/02/21 10:53:37 nonaka Exp $
 
 PROG=		bootia32.efi
 OBJFMT=		pei-i386
 
-EXTRA_SOURCES=	efibootia32.c
+EXTRA_SOURCES=	efibootia32.c startprog32.S
 
 CPUFLAGS=	-march=i686 -mtune=i686
 GNUEFIARCH=	ia32
Index: src/sys/arch/i386/stand/efiboot/bootia32/efibootia32.c
diff -u src/sys/arch/i386/stand/efiboot/bootia32/efibootia32.c:1.1 src/sys/arch/i386/stand/efiboot/bootia32/efibootia32.c:1.2
--- src/sys/arch/i386/stand/efiboot/bootia32/efibootia32.c:1.1	Tue Jan 24 11:09:14 2017
+++ src/sys/arch/i386/stand/efiboot/bootia32/efibootia32.c	Tue Feb 21 10:53:37 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: efibootia32.c,v 1.1 2017/01/24 11:09:14 nonaka Exp $	*/
+/*	$NetBSD: efibootia32.c,v 1.2 2017/02/21 10:53:37 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -32,18 +32,40 @@
 
 struct x86_boot_params boot_params;
 
+void startprog32_start(physaddr_t, uint32_t, uint32_t *, physaddr_t,
+physaddr_t, physaddr_t, u_long, void *);
+extern void (*startprog32)(physaddr_t, uint32_t, uint32_t *, physaddr_t,
+physaddr_t, physaddr_t, u_long, void *);
+extern u_int startprog32_size;
+
 void
 efi_md_init(void)
 {
-	/* Nothing to do */
+	EFI_STATUS status;
+	EFI_PHYSICAL_ADDRESS addr = EFI_ALLOCATE_MAX_ADDRESS;
+	u_int sz = EFI_SIZE_TO_PAGES(startprog32_size);
+
+	status = uefi_call_wrapper(BS->AllocatePages, 4, AllocateMaxAddress,
+	EfiLoaderData, sz, );
+	if (EFI_ERROR(status))
+		Panic(L"%a: AllocatePages() failed: %d page(s): %r",
+		__func__, sz, status);
+	startprog32 = (void *)(u_long)addr;
+	CopyMem(startprog32, startprog32_start, startprog32_size);
 }
 
+/* ARGSUSED */
 void
 startprog(physaddr_t entry, uint32_t argc, uint32_t *argv, physaddr_t sp)
 {
-	Panic(L"%a: not implemented", __func__);
+
+	(*startprog32)(entry, argc, argv,
+	(physaddr_t)startprog32 + startprog32_size,
+	efi_kernel_start, efi_kernel_start + efi_loadaddr,
+	efi_kernel_size, startprog32);
 }
 
+/* ARGSUSED */
 void
 multiboot(physaddr_t entry, physaddr_t header, physaddr_t sp)
 {

Added files:

Index: src/sys/arch/i386/stand/efiboot/bootia32/startprog32.S
diff -u /dev/null src/sys/arch/i386/stand/efiboot/bootia32/startprog32.S:1.1
--- /dev/null	Tue Feb 21 10:53:37 2017
+++ src/sys/arch/i386/stand/efiboot/bootia32/startprog32.S	Tue Feb 21 10:53:37 2017
@@ -0,0 +1,243 @@
+/*	$NetBSD: startprog32.S,v 1.1 2017/02/21 10:53:37 nonaka Exp $	*/
+/*	NetBSD: startprog.S,v 1.4 2016/12/04 08:21:08 maxv Exp	*/
+
+/*
+ * Ported to boot 386BSD by Julian Elischer (jul...@tfs.com) Sept 1992
+ *
+ * Mach Operating System
+ * Copyright (c) 1992, 1991 Carnegie Mellon University
+ * All Rights Reserved.
+ *
+ * Permission to use, copy, modify and distribute this software and its
+ * documentation is hereby granted, provided that both the copyright
+ * notice and this permission notice appear in all copies of the
+ * software, derivative works or modified versions, and any portions
+ * thereof, and that both notices appear in supporting documentation.
+ *
+ * CARNEGIE MELLON ALLOWS FREE USE OF THIS SOFTWARE IN ITS "AS IS"
+ * CONDITION.  CARNEGIE MELLON 

CVS commit: src/sys/arch/i386/stand/efiboot

2017-02-11 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Sat Feb 11 10:33:44 UTC 2017

Added Files:
src/sys/arch/i386/stand/efiboot: TODO.efiboot

Log Message:
Added efiboot TODO.


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

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

Added files:

Index: src/sys/arch/i386/stand/efiboot/TODO.efiboot
diff -u /dev/null src/sys/arch/i386/stand/efiboot/TODO.efiboot:1.1
--- /dev/null	Sat Feb 11 10:33:44 2017
+++ src/sys/arch/i386/stand/efiboot/TODO.efiboot	Sat Feb 11 10:33:44 2017
@@ -0,0 +1,18 @@
+- efiboot
+ * handle UEFI variables
+ * boot from CD/DVD (bootable from CD/DVD, but root fs not found.)
+ * load boot.cfg from EFI system partition (FAT32)
+ * fix module_init(). need to allocate memory for modules.
+ * bootia32.efi can load kernel, but can't start kernel
+
+- kernel
+ * handle UEFI variables (/dev/efivar)
+ * accelerated console
+
+- userland
+ * efibootmgr like utility
+ * merge distrib/amd64/uefi-installimage to distrib/amd64/install-image
+ * merge distrib/amd64/uefi-installimage/Makefile.* to distrib/common/Makefile.*
+
+- installer
+ * sysinst(8): handle dk(4) for install disk



CVS commit: src/sys/arch/i386/stand/efiboot

2017-02-11 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Sat Feb 11 10:15:55 UTC 2017

Modified Files:
src/sys/arch/i386/stand/efiboot: efiboot.c efiboot.h panic.c

Log Message:
efiboot: don't call WaitForSingleEvent after ExitBootServices is called.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/i386/stand/efiboot/efiboot.c \
src/sys/arch/i386/stand/efiboot/efiboot.h
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/i386/stand/efiboot/panic.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/arch/i386/stand/efiboot/efiboot.c
diff -u src/sys/arch/i386/stand/efiboot/efiboot.c:1.2 src/sys/arch/i386/stand/efiboot/efiboot.c:1.3
--- src/sys/arch/i386/stand/efiboot/efiboot.c:1.2	Sat Feb 11 10:13:46 2017
+++ src/sys/arch/i386/stand/efiboot/efiboot.c	Sat Feb 11 10:15:55 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: efiboot.c,v 1.2 2017/02/11 10:13:46 nonaka Exp $	*/
+/*	$NetBSD: efiboot.c,v 1.3 2017/02/11 10:15:55 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -35,6 +35,7 @@ EFI_HANDLE IH;
 EFI_DEVICE_PATH *efi_bootdp;
 EFI_LOADED_IMAGE *efi_li;
 uintptr_t efi_main_sp;
+bool efi_cleanuped;
 
 static EFI_PHYSICAL_ADDRESS heap_start = EFI_ALLOCATE_MAX_ADDRESS;
 static UINTN heap_size = 1 * 1024 * 1024;			/* 1MB */
@@ -121,6 +122,7 @@ efi_cleanup(void)
 		if (EFI_ERROR(status))
 			Panic(L"ExitBootServices failed");
 	}
+	efi_cleanuped = true;
 
 	allocsz = sizeof(struct btinfo_efimemmap) - 1
 	+ NoEntries * DescriptorSize;
Index: src/sys/arch/i386/stand/efiboot/efiboot.h
diff -u src/sys/arch/i386/stand/efiboot/efiboot.h:1.2 src/sys/arch/i386/stand/efiboot/efiboot.h:1.3
--- src/sys/arch/i386/stand/efiboot/efiboot.h:1.2	Sat Feb 11 10:13:46 2017
+++ src/sys/arch/i386/stand/efiboot/efiboot.h	Sat Feb 11 10:15:55 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: efiboot.h,v 1.2 2017/02/11 10:13:46 nonaka Exp $	*/
+/*	$NetBSD: efiboot.h,v 1.3 2017/02/11 10:15:55 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -48,6 +48,7 @@ extern EFI_HANDLE IH;
 extern EFI_DEVICE_PATH *efi_bootdp;
 extern EFI_LOADED_IMAGE *efi_li;
 extern uintptr_t efi_main_sp;
+extern bool efi_cleanuped;
 void efi_cleanup(void);
 
 /* eficons.c */

Index: src/sys/arch/i386/stand/efiboot/panic.c
diff -u src/sys/arch/i386/stand/efiboot/panic.c:1.3 src/sys/arch/i386/stand/efiboot/panic.c:1.4
--- src/sys/arch/i386/stand/efiboot/panic.c:1.3	Sun Feb  5 10:13:43 2017
+++ src/sys/arch/i386/stand/efiboot/panic.c	Sat Feb 11 10:15:55 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: panic.c,v 1.3 2017/02/05 10:13:43 joerg Exp $	*/
+/*	$NetBSD: panic.c,v 1.4 2017/02/11 10:15:55 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -54,7 +54,8 @@ __dead void
 reboot(void)
 {
 
-	WaitForSingleEvent(ST->ConIn->WaitForKey, 0);
+	if (!efi_cleanuped)
+		WaitForSingleEvent(ST->ConIn->WaitForKey, 0);
 
 	uefi_call_wrapper(RT->ResetSystem, 4, EfiResetCold, EFI_SUCCESS,
 	0, NULL);



CVS commit: src/sys/arch/i386/stand/efiboot

2017-02-11 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Sat Feb 11 10:13:46 UTC 2017

Modified Files:
src/sys/arch/i386/stand/efiboot: Makefile.efiboot efiboot.c efiboot.h
efimemory.c

Log Message:
efiboot: pass memory map after ExitBootService is called to kernel.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/i386/stand/efiboot/Makefile.efiboot
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/i386/stand/efiboot/efiboot.c \
src/sys/arch/i386/stand/efiboot/efiboot.h
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/i386/stand/efiboot/efimemory.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/arch/i386/stand/efiboot/Makefile.efiboot
diff -u src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.6 src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.7
--- src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.6	Mon Feb  6 10:32:35 2017
+++ src/sys/arch/i386/stand/efiboot/Makefile.efiboot	Sat Feb 11 10:13:46 2017
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.efiboot,v 1.6 2017/02/06 10:32:35 nonaka Exp $
+# $NetBSD: Makefile.efiboot,v 1.7 2017/02/11 10:13:46 nonaka Exp $
 
 S=		${.CURDIR}/../../../../..
 
@@ -61,7 +61,6 @@ CPPFLAGS+= -DSUPPORT_CD9660
 CPPFLAGS+= -DSUPPORT_DOSFS
 CPPFLAGS+= -DSUPPORT_EXT2FS
 CPPFLAGS+= -DPASS_BIOSGEOM
-CPPFLAGS+= -DPASS_MEMMAP
 CPPFLAGS+= -DLIBSA_ENABLE_LS_OP
 
 EFIDIR= ${S}/external/bsd/gnu-efi/dist

Index: src/sys/arch/i386/stand/efiboot/efiboot.c
diff -u src/sys/arch/i386/stand/efiboot/efiboot.c:1.1 src/sys/arch/i386/stand/efiboot/efiboot.c:1.2
--- src/sys/arch/i386/stand/efiboot/efiboot.c:1.1	Tue Jan 24 11:09:14 2017
+++ src/sys/arch/i386/stand/efiboot/efiboot.c	Sat Feb 11 10:13:46 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: efiboot.c,v 1.1 2017/01/24 11:09:14 nonaka Exp $	*/
+/*	$NetBSD: efiboot.c,v 1.2 2017/02/11 10:13:46 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -97,6 +97,8 @@ efi_cleanup(void)
 	EFI_MEMORY_DESCRIPTOR *desc;
 	UINTN NoEntries, MapKey, DescriptorSize;
 	UINT32 DescriptorVersion;
+	struct btinfo_efimemmap *bim;
+	size_t allocsz;
 
 	clearit();
 
@@ -108,17 +110,26 @@ efi_cleanup(void)
 	BI_ADD(_efi, BTINFO_EFI, sizeof(btinfo_efi));
 
 	NoEntries = 0;
-	desc = LibMemoryMap(, , ,
-	);
+	desc = efi_memory_get_map(, , ,
+	, true);
 	status = uefi_call_wrapper(BS->ExitBootServices, 2, IH, MapKey);
 	if (EFI_ERROR(status)) {
 		FreePool(desc);
-		desc = LibMemoryMap(, , ,
-		);
+		desc = efi_memory_get_map(, , ,
+		, true);
 		status = uefi_call_wrapper(BS->ExitBootServices, 2, IH, MapKey);
 		if (EFI_ERROR(status))
 			Panic(L"ExitBootServices failed");
 	}
+
+	allocsz = sizeof(struct btinfo_efimemmap) - 1
+	+ NoEntries * DescriptorSize;
+	bim = alloc(allocsz);
+	bim->num = NoEntries;
+	bim->version = DescriptorVersion;
+	bim->size = DescriptorSize;
+	memcpy(bim->memmap, desc, NoEntries * DescriptorSize);
+	BI_ADD(bim, BTINFO_EFIMEMMAP, allocsz);
 }
 
 static void
Index: src/sys/arch/i386/stand/efiboot/efiboot.h
diff -u src/sys/arch/i386/stand/efiboot/efiboot.h:1.1 src/sys/arch/i386/stand/efiboot/efiboot.h:1.2
--- src/sys/arch/i386/stand/efiboot/efiboot.h:1.1	Tue Jan 24 11:09:14 2017
+++ src/sys/arch/i386/stand/efiboot/efiboot.h	Sat Feb 11 10:13:46 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: efiboot.h,v 1.1 2017/01/24 11:09:14 nonaka Exp $	*/
+/*	$NetBSD: efiboot.h,v 1.2 2017/02/11 10:13:46 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -61,6 +61,8 @@ void efi_disk_probe(void);
 /* efimemory.c */
 void efi_memory_probe(void);
 void efi_memory_show_map(bool);
+EFI_MEMORY_DESCRIPTOR *efi_memory_get_map(UINTN *, UINTN *, UINTN *, UINT32 *,
+bool);
 
 /* panic.c */
 __dead VOID Panic(IN CHAR16 *, ...);

Index: src/sys/arch/i386/stand/efiboot/efimemory.c
diff -u src/sys/arch/i386/stand/efiboot/efimemory.c:1.2 src/sys/arch/i386/stand/efiboot/efimemory.c:1.3
--- src/sys/arch/i386/stand/efiboot/efimemory.c:1.2	Fri Feb  3 16:42:26 2017
+++ src/sys/arch/i386/stand/efiboot/efimemory.c	Sat Feb 11 10:13:46 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: efimemory.c,v 1.2 2017/02/03 16:42:26 roy Exp $	*/
+/*	$NetBSD: efimemory.c,v 1.3 2017/02/11 10:13:46 nonaka Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -87,9 +87,9 @@ getmemtype(EFI_MEMORY_DESCRIPTOR *md)
 	return BIM_Reserved;
 }
 
-static EFI_MEMORY_DESCRIPTOR *
-GetMemoryMap(OUT UINTN *NoEntries, OUT UINTN *MapKey, OUT UINTN *DescriptorSize,
-OUT UINT32 *DescriptorVersion, bool sorted)
+EFI_MEMORY_DESCRIPTOR *
+efi_memory_get_map(UINTN *NoEntries, UINTN *MapKey, UINTN *DescriptorSize,
+UINT32 *DescriptorVersion, bool sorted)
 {
 	EFI_MEMORY_DESCRIPTOR *desc, *md, *next, *target, tmp;
 	UINTN i, j;
@@ -98,7 +98,7 @@ GetMemoryMap(OUT UINTN *NoEntries, OUT U
 	desc = LibMemoryMap(NoEntries, MapKey, DescriptorSize,
 	DescriptorVersion);
 	if (desc == NULL)
-		Panic(L"LibMemoryMap failed");
+		

CVS commit: src/sys/arch/i386/stand/efiboot

2017-02-05 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Sun Feb  5 10:13:43 UTC 2017

Modified Files:
src/sys/arch/i386/stand/efiboot: panic.c

Log Message:
Be a bit nicer to outdated compilers and use __unreachable().


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/i386/stand/efiboot/panic.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/arch/i386/stand/efiboot/panic.c
diff -u src/sys/arch/i386/stand/efiboot/panic.c:1.2 src/sys/arch/i386/stand/efiboot/panic.c:1.3
--- src/sys/arch/i386/stand/efiboot/panic.c:1.2	Sat Feb  4 13:36:07 2017
+++ src/sys/arch/i386/stand/efiboot/panic.c	Sun Feb  5 10:13:43 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: panic.c,v 1.2 2017/02/04 13:36:07 roy Exp $	*/
+/*	$NetBSD: panic.c,v 1.3 2017/02/05 10:13:43 joerg Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -47,7 +47,7 @@ Panic(
 	va_end(args);
 	reboot();
 	/*NOTREACHED*/
-	__builtin_unreachable();
+	__unreachable();
 }
 
 __dead void



CVS commit: src/sys/arch/i386/stand/efiboot

2017-02-05 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Sun Feb  5 10:13:18 UTC 2017

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

Log Message:
Unbreak clang again.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/i386/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/arch/i386/stand/efiboot/Makefile.efiboot
diff -u src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.4 src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.5
--- src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.4	Sat Feb  4 16:14:04 2017
+++ src/sys/arch/i386/stand/efiboot/Makefile.efiboot	Sun Feb  5 10:13:18 2017
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.efiboot,v 1.4 2017/02/04 16:14:04 christos Exp $
+# $NetBSD: Makefile.efiboot,v 1.5 2017/02/05 10:13:18 joerg Exp $
 
 S=		${.CURDIR}/../../../../..
 
@@ -48,7 +48,7 @@ CPPFLAGS+= -I${.CURDIR}/../../lib
 
 COPTS+= -ffreestanding -fPIC -fshort-wchar -fno-strict-aliasing -fno-builtin
 COPTS+= -fno-stack-protector
-COPTS+= -Wno-error=unused-but-set-variable
+COPTS+= ${${ACTIVE_CC} == "gcc":? -Wno-error=unused-but-set-variable :}
 COPTS+= ${${ACTIVE_CC} == "gcc":? -falign-functions=16 :}
 CPPFLAGS+= -nostdinc -D_STANDALONE
 CPPFLAGS+= -DEFIBOOT



CVS commit: src/sys/arch/i386/stand/efiboot/bootx64

2017-02-04 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Feb  4 16:14:28 UTC 2017

Modified Files:
src/sys/arch/i386/stand/efiboot/bootx64: startprog64.S

Log Message:
Fix operand width


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 \
src/sys/arch/i386/stand/efiboot/bootx64/startprog64.S

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

Modified files:

Index: src/sys/arch/i386/stand/efiboot/bootx64/startprog64.S
diff -u src/sys/arch/i386/stand/efiboot/bootx64/startprog64.S:1.1 src/sys/arch/i386/stand/efiboot/bootx64/startprog64.S:1.2
--- src/sys/arch/i386/stand/efiboot/bootx64/startprog64.S:1.1	Tue Jan 24 06:09:14 2017
+++ src/sys/arch/i386/stand/efiboot/bootx64/startprog64.S	Sat Feb  4 11:14:27 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: startprog64.S,v 1.1 2017/01/24 11:09:14 nonaka Exp $	*/
+/*	$NetBSD: startprog64.S,v 1.2 2017/02/04 16:14:27 christos Exp $	*/
 /*	NetBSD: startprog.S,v 1.3 2003/02/01 14:48:18 dsl Exp	*/
 
 /* starts program in protected mode / flat space
@@ -110,11 +110,11 @@ start:
 	.code32
 start32a:
 	movl	$DATA_SEGMENT, %eax
-	movw	%eax, %ds
-	movw	%eax, %es
-	movw	%eax, %fs
-	movw	%eax, %gs
-	movw	%eax, %ss
+	movw	%ax, %ds
+	movw	%ax, %es
+	movw	%ax, %fs
+	movw	%ax, %gs
+	movw	%ax, %ss
 
 	movl	%edx, %esp
 



CVS commit: src/sys/arch/i386/stand/efiboot

2017-02-04 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Feb  4 16:14:04 UTC 2017

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

Log Message:
Don't error out for set but unused variables for now.


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/i386/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/arch/i386/stand/efiboot/Makefile.efiboot
diff -u src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.3 src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.4
--- src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.3	Sat Feb  4 08:36:07 2017
+++ src/sys/arch/i386/stand/efiboot/Makefile.efiboot	Sat Feb  4 11:14:04 2017
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.efiboot,v 1.3 2017/02/04 13:36:07 roy Exp $
+# $NetBSD: Makefile.efiboot,v 1.4 2017/02/04 16:14:04 christos Exp $
 
 S=		${.CURDIR}/../../../../..
 
@@ -48,6 +48,7 @@ CPPFLAGS+= -I${.CURDIR}/../../lib
 
 COPTS+= -ffreestanding -fPIC -fshort-wchar -fno-strict-aliasing -fno-builtin
 COPTS+= -fno-stack-protector
+COPTS+= -Wno-error=unused-but-set-variable
 COPTS+= ${${ACTIVE_CC} == "gcc":? -falign-functions=16 :}
 CPPFLAGS+= -nostdinc -D_STANDALONE
 CPPFLAGS+= -DEFIBOOT



CVS commit: src/sys/arch/i386/stand/efiboot

2017-02-04 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Sat Feb  4 13:36:07 UTC 2017

Modified Files:
src/sys/arch/i386/stand/efiboot: Makefile.efiboot panic.c

Log Message:
Mark reboot() and _rtt() as __dead.
Use __builtin_unreachable() to ensure Panic really is marked dead.

Thanks to joerg@


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/i386/stand/efiboot/Makefile.efiboot
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/i386/stand/efiboot/panic.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/arch/i386/stand/efiboot/Makefile.efiboot
diff -u src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.2 src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.3
--- src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.2	Fri Feb  3 17:24:43 2017
+++ src/sys/arch/i386/stand/efiboot/Makefile.efiboot	Sat Feb  4 13:36:07 2017
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.efiboot,v 1.2 2017/02/03 17:24:43 roy Exp $
+# $NetBSD: Makefile.efiboot,v 1.3 2017/02/04 13:36:07 roy Exp $
 
 S=		${.CURDIR}/../../../../..
 
@@ -46,7 +46,6 @@ CPPFLAGS+= -I$S -I${.CURDIR} -I${.CURDIR
 CPPFLAGS+= -I${.OBJDIR}
 CPPFLAGS+= -I${.CURDIR}/../../lib
 
-CWARNFLAGS.clang+= -Wno-invalid-noreturn #panic.c
 COPTS+= -ffreestanding -fPIC -fshort-wchar -fno-strict-aliasing -fno-builtin
 COPTS+= -fno-stack-protector
 COPTS+= ${${ACTIVE_CC} == "gcc":? -falign-functions=16 :}

Index: src/sys/arch/i386/stand/efiboot/panic.c
diff -u src/sys/arch/i386/stand/efiboot/panic.c:1.1 src/sys/arch/i386/stand/efiboot/panic.c:1.2
--- src/sys/arch/i386/stand/efiboot/panic.c:1.1	Tue Jan 24 11:09:14 2017
+++ src/sys/arch/i386/stand/efiboot/panic.c	Sat Feb  4 13:36:07 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: panic.c,v 1.1 2017/01/24 11:09:14 nonaka Exp $	*/
+/*	$NetBSD: panic.c,v 1.2 2017/02/04 13:36:07 roy Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -47,9 +47,10 @@ Panic(
 	va_end(args);
 	reboot();
 	/*NOTREACHED*/
+	__builtin_unreachable();
 }
 
-void
+__dead void
 reboot(void)
 {
 
@@ -61,7 +62,7 @@ reboot(void)
 		continue;
 }
 
-void
+__dead void
 _rtt(void)
 {
 



CVS commit: src/sys/arch/i386/stand/efiboot

2017-02-03 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Feb  3 17:24:43 UTC 2017

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

Log Message:
Fix build with clang.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/i386/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/arch/i386/stand/efiboot/Makefile.efiboot
diff -u src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.1 src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.2
--- src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.1	Tue Jan 24 11:09:14 2017
+++ src/sys/arch/i386/stand/efiboot/Makefile.efiboot	Fri Feb  3 17:24:43 2017
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.efiboot,v 1.1 2017/01/24 11:09:14 nonaka Exp $
+# $NetBSD: Makefile.efiboot,v 1.2 2017/02/03 17:24:43 roy Exp $
 
 S=		${.CURDIR}/../../../../..
 
@@ -46,8 +46,10 @@ CPPFLAGS+= -I$S -I${.CURDIR} -I${.CURDIR
 CPPFLAGS+= -I${.OBJDIR}
 CPPFLAGS+= -I${.CURDIR}/../../lib
 
+CWARNFLAGS.clang+= -Wno-invalid-noreturn #panic.c
 COPTS+= -ffreestanding -fPIC -fshort-wchar -fno-strict-aliasing -fno-builtin
-COPTS+= -fno-stack-protector -falign-functions=16
+COPTS+= -fno-stack-protector
+COPTS+= ${${ACTIVE_CC} == "gcc":? -falign-functions=16 :}
 CPPFLAGS+= -nostdinc -D_STANDALONE
 CPPFLAGS+= -DEFIBOOT
 



CVS commit: src/sys/arch/i386/stand/efiboot

2017-02-03 Thread Roy Marples
Module Name:src
Committed By:   roy
Date:   Fri Feb  3 16:42:26 UTC 2017

Modified Files:
src/sys/arch/i386/stand/efiboot: boot.c efimemory.c

Log Message:
rows is a uint ... it will always be greater than or equal to 0.


To generate a diff of this commit:
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/i386/stand/efiboot/boot.c \
src/sys/arch/i386/stand/efiboot/efimemory.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/arch/i386/stand/efiboot/boot.c
diff -u src/sys/arch/i386/stand/efiboot/boot.c:1.1 src/sys/arch/i386/stand/efiboot/boot.c:1.2
--- src/sys/arch/i386/stand/efiboot/boot.c:1.1	Tue Jan 24 11:09:14 2017
+++ src/sys/arch/i386/stand/efiboot/boot.c	Fri Feb  3 16:42:26 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: boot.c,v 1.1 2017/01/24 11:09:14 nonaka Exp $	*/
+/*	$NetBSD: boot.c,v 1.2 2017/02/03 16:42:26 roy Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -540,7 +540,7 @@ command_devpath(char *arg)
 			Print(L"%d:%d:%s\n", DevicePathType(dp), DevicePathSubType(dp), path);
 			FreePool(path);
 
-			if (rows >= 0 && ++row >= rows) {
+			if (++row >= rows) {
 row = 0;
 Print(L"Press Any Key to continue :");
 (void) awaitkey(-1, 0);
@@ -607,7 +607,7 @@ command_efivar(char *arg)
 		val ? val : L"(null)");
 		FreePool(val);
 
-		if (rows >= 0 && ++row >= rows) {
+		if (++row >= rows) {
 			row = 0;
 			Print(L"Press Any Key to continue :");
 			(void) awaitkey(-1, 0);
Index: src/sys/arch/i386/stand/efiboot/efimemory.c
diff -u src/sys/arch/i386/stand/efiboot/efimemory.c:1.1 src/sys/arch/i386/stand/efiboot/efimemory.c:1.2
--- src/sys/arch/i386/stand/efiboot/efimemory.c:1.1	Tue Jan 24 11:09:14 2017
+++ src/sys/arch/i386/stand/efiboot/efimemory.c	Fri Feb  3 16:42:26 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: efimemory.c,v 1.1 2017/01/24 11:09:14 nonaka Exp $	*/
+/*	$NetBSD: efimemory.c,v 1.2 2017/02/03 16:42:26 roy Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -288,7 +288,7 @@ efi_memory_show_map(bool sorted)
 		md->Type >= __arraycount(efimemtypes) ?
 		  efimemstr : efimemtypes[md->Type]);
 
-		if (rows >= 0 && ++row >= rows) {
+		if (++row >= rows) {
 			row = 0;
 			Print(L"Press Any Key to continue :");
 			(void) awaitkey(-1, 0);