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

2024-01-06 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Jan  6 21:26:43 UTC 2024

Modified Files:
src/sys/arch/i386/stand/efiboot: efidisk.c efidisk.h
src/sys/arch/i386/stand/lib: biosdisk.c exec.c

Log Message:
In efiboot
- create bootinfo information only once.
- add fake biosgeom entries so that the kernel can distinguish between
  hard drives (with geom) and CD-ROM (without).


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/i386/stand/efiboot/efidisk.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/i386/stand/efiboot/efidisk.h
cvs rdiff -u -r1.60 -r1.61 src/sys/arch/i386/stand/lib/biosdisk.c
cvs rdiff -u -r1.79 -r1.80 src/sys/arch/i386/stand/lib/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/arch/i386/stand/efiboot/efidisk.c
diff -u src/sys/arch/i386/stand/efiboot/efidisk.c:1.10 src/sys/arch/i386/stand/efiboot/efidisk.c:1.11
--- src/sys/arch/i386/stand/efiboot/efidisk.c:1.10	Sun May 14 09:07:54 2023
+++ src/sys/arch/i386/stand/efiboot/efidisk.c	Sat Jan  6 21:26:43 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: efidisk.c,v 1.10 2023/05/14 09:07:54 riastradh Exp $	*/
+/*	$NetBSD: efidisk.c,v 1.11 2024/01/06 21:26:43 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -38,9 +38,12 @@
 #include "biosdisk_ll.h"
 #include "devopen.h"
 #include "efidisk.h"
+#include "bootinfo.h"
 
 static struct efidiskinfo_lh efi_disklist;
 static int nefidisks;
+static struct btinfo_biosgeom *bibg;
+static size_t bibg_len;
 
 #define MAXDEVNAME 39 /* "NAME=" + 34 char part_name */
 
@@ -158,6 +161,23 @@ next:
 		if (edi->bootdev)
 			boot_biosdev = edi->dev;
 	}
+
+	bibg_len = sizeof(*bibg) + nefidisks * sizeof(struct bi_biosgeom_entry);
+	bibg = alloc(bibg_len);
+	if (bibg == NULL)
+		return;
+
+	bibg->num = nefidisks;
+
+	i = 0;
+	TAILQ_FOREACH(edi, _disklist, list) {
+		if (edi->type == BIOSDISK_TYPE_HD) {
+			memset(>disk[i], 0, sizeof(bibg->disk[i]));
+			bibg->disk[i].dev = edi->dev;
+			bibg->disk[i].flags = BI_GEOM_INVALID;
+		}
+		++i;
+	}
 }
 
 static void
@@ -383,3 +403,10 @@ efidisk_get_efi_system_partition(int dev
 	*partition = i;
 	return 0;
 }
+
+void
+efidisk_getbiosgeom()
+{
+	BI_ADD(bibg, BTINFO_BIOSGEOM, bibg_len);
+}
+

Index: src/sys/arch/i386/stand/efiboot/efidisk.h
diff -u src/sys/arch/i386/stand/efiboot/efidisk.h:1.3 src/sys/arch/i386/stand/efiboot/efidisk.h:1.4
--- src/sys/arch/i386/stand/efiboot/efidisk.h:1.3	Mon Apr  2 09:44:18 2018
+++ src/sys/arch/i386/stand/efiboot/efidisk.h	Sat Jan  6 21:26:43 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: efidisk.h,v 1.3 2018/04/02 09:44:18 nonaka Exp $	*/
+/*	$NetBSD: efidisk.h,v 1.4 2024/01/06 21:26:43 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -41,3 +41,4 @@ TAILQ_HEAD(efidiskinfo_lh, efidiskinfo);
 
 const struct efidiskinfo *efidisk_getinfo(int);
 int efidisk_get_efi_system_partition(int, int *);
+void efidisk_getbiosgeom(void);

Index: src/sys/arch/i386/stand/lib/biosdisk.c
diff -u src/sys/arch/i386/stand/lib/biosdisk.c:1.60 src/sys/arch/i386/stand/lib/biosdisk.c:1.61
--- src/sys/arch/i386/stand/lib/biosdisk.c:1.60	Mon Oct  2 00:02:33 2023
+++ src/sys/arch/i386/stand/lib/biosdisk.c	Sat Jan  6 21:26:43 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: biosdisk.c,v 1.60 2023/10/02 00:02:33 manu Exp $	*/
+/*	$NetBSD: biosdisk.c,v 1.61 2024/01/06 21:26:43 mlelstv Exp $	*/
 
 /*
  * Copyright (c) 1996, 1998
@@ -1198,11 +1198,13 @@ out:
 static void
 add_biosdisk_bootinfo(void)
 {
+#ifndef EFIBOOT
 	if (bootinfo == NULL) {
 		return;
 	}
 	BI_ADD(_disk, BTINFO_BOOTDISK, sizeof(bi_disk));
 	BI_ADD(_wedge, BTINFO_BOOTWEDGE, sizeof(bi_wedge));
+#endif
 	return;
 }
 #endif

Index: src/sys/arch/i386/stand/lib/exec.c
diff -u src/sys/arch/i386/stand/lib/exec.c:1.79 src/sys/arch/i386/stand/lib/exec.c:1.80
--- src/sys/arch/i386/stand/lib/exec.c:1.79	Thu Apr 20 00:42:24 2023
+++ src/sys/arch/i386/stand/lib/exec.c	Sat Jan  6 21:26:43 2024
@@ -1,4 +1,4 @@
-/*	$NetBSD: exec.c,v 1.79 2023/04/20 00:42:24 manu Exp $	 */
+/*	$NetBSD: exec.c,v 1.80 2024/01/06 21:26:43 mlelstv Exp $	 */
 
 /*
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -108,6 +108,8 @@
 #endif
 #ifdef EFIBOOT
 #include "efiboot.h"
+#include "biosdisk.h"
+#include "efidisk.h"
 #undef DEBUG	/* XXX */
 #endif
 
@@ -498,6 +500,10 @@ exec_netbsd(const char *file, physaddr_t
 		goto out;
 	}
 #ifdef EFIBOOT
+	BI_ADD(_disk, BTINFO_BOOTDISK, sizeof(bi_disk));
+	BI_ADD(_wedge, BTINFO_BOOTWEDGE, sizeof(bi_wedge));
+	efidisk_getbiosgeom();
+
 	efi_load_start = marks[MARK_START];
 
 	/* adjust to the real load address */



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

2024-01-06 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sat Jan  6 21:26:43 UTC 2024

Modified Files:
src/sys/arch/i386/stand/efiboot: efidisk.c efidisk.h
src/sys/arch/i386/stand/lib: biosdisk.c exec.c

Log Message:
In efiboot
- create bootinfo information only once.
- add fake biosgeom entries so that the kernel can distinguish between
  hard drives (with geom) and CD-ROM (without).


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/i386/stand/efiboot/efidisk.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/i386/stand/efiboot/efidisk.h
cvs rdiff -u -r1.60 -r1.61 src/sys/arch/i386/stand/lib/biosdisk.c
cvs rdiff -u -r1.79 -r1.80 src/sys/arch/i386/stand/lib/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/arch/i386/stand/libsa

2023-12-14 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Thu Dec 14 08:06:23 UTC 2023

Modified Files:
src/sys/arch/i386/stand/libsa: nfs.c

Log Message:
Align again with libsa (NFS_NOSYMLINK fix).


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/i386/stand/libsa/nfs.c

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



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

2023-12-14 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Thu Dec 14 08:06:23 UTC 2023

Modified Files:
src/sys/arch/i386/stand/libsa: nfs.c

Log Message:
Align again with libsa (NFS_NOSYMLINK fix).


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/i386/stand/libsa/nfs.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/libsa/nfs.c
diff -u src/sys/arch/i386/stand/libsa/nfs.c:1.20 src/sys/arch/i386/stand/libsa/nfs.c:1.21
--- src/sys/arch/i386/stand/libsa/nfs.c:1.20	Tue Dec 12 09:16:17 2023
+++ src/sys/arch/i386/stand/libsa/nfs.c	Thu Dec 14 08:06:23 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs.c,v 1.20 2023/12/12 09:16:17 mlelstv Exp $	*/
+/*	$NetBSD: nfs.c,v 1.21 2023/12/14 08:06:23 mlelstv Exp $	*/
 
 /*-
  *  Copyright (c) 1993 John Brezak
@@ -597,9 +597,9 @@ nfs_open(const char *path, struct open_f
 	char namebuf[NFS_MAXPATHLEN + 1];
 	char linkbuf[NFS_MAXPATHLEN + 1];
 	int nlinks = 0;
+	n_long fa_type;
 #endif
 	int error = 0;
-	n_long fa_type;
 
 #ifdef NFS_DEBUG
  	if (debug)



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

2023-12-12 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Tue Dec 12 09:16:17 UTC 2023

Modified Files:
src/sys/arch/i386/stand/libsa: nfs.c

Log Message:
Merge with generic libsa NFS code to minimize differences and to learn NFSv3.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/i386/stand/libsa/nfs.c

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



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

2023-12-12 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Tue Dec 12 09:16:17 UTC 2023

Modified Files:
src/sys/arch/i386/stand/libsa: nfs.c

Log Message:
Merge with generic libsa NFS code to minimize differences and to learn NFSv3.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/i386/stand/libsa/nfs.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/libsa/nfs.c
diff -u src/sys/arch/i386/stand/libsa/nfs.c:1.19 src/sys/arch/i386/stand/libsa/nfs.c:1.20
--- src/sys/arch/i386/stand/libsa/nfs.c:1.19	Sun Dec 25 06:09:09 2011
+++ src/sys/arch/i386/stand/libsa/nfs.c	Tue Dec 12 09:16:17 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: nfs.c,v 1.19 2011/12/25 06:09:09 tsutsui Exp $	*/
+/*	$NetBSD: nfs.c,v 1.20 2023/12/12 09:16:17 mlelstv Exp $	*/
 
 /*-
  *  Copyright (c) 1993 John Brezak
@@ -28,6 +28,16 @@
  * POSSIBILITY OF SUCH DAMAGE.
  */
 
+/*
+ * XXX Does not currently implement:
+ * XXX
+ * XXX LIBSA_NO_FS_CLOSE
+ * XXX LIBSA_NO_FS_SEEK
+ * XXX LIBSA_NO_FS_WRITE
+ * XXX LIBSA_NO_FS_SYMLINK (does this even make sense?)
+ * XXX LIBSA_FS_SINGLECOMPONENT (does this even make sense?)
+ */
+
 #include 
 #include 
 #include 
@@ -43,6 +53,7 @@
 
 #include "rpcv2.h"
 #include "nfsv2.h"
+#include "nfsv3.h"
 
 #include 
 #include "net.h"
@@ -50,40 +61,11 @@
 #include "nfs.h"
 #include "rpc.h"
 
-/* Define our own NFS attributes. */
-struct nfsv2_fattrs {
-	n_long	fa_type;
-	n_long	fa_mode;
-	n_long	fa_nlink;
-	n_long	fa_uid;
-	n_long	fa_gid;
-	n_long	fa_size;
-	n_long	fa_blocksize;
-	n_long	fa_rdev;
-	n_long	fa_blocks;
-	n_long	fa_fsid;
-	n_long	fa_fileid;
-	struct nfsv2_time fa_atime;
-	struct nfsv2_time fa_mtime;
-	struct nfsv2_time fa_ctime;
-};
-
-
-struct nfs_read_args {
-	u_char	fh[NFS_FHSIZE];
-	n_long	off;
-	n_long	len;
-	n_long	xxx;			/* XXX what's this for? */
-};
+/* Storage for any filehandle (including length for V3) */
+#define NFS_FHSTORE (NFS_FHSIZE < NFS_V3FHSIZE ? NFS_V3FHSIZE + 4: NFS_FHSIZE)
 
 /* Data part of nfs rpc reply (also the largest thing we receive) */
 #define NFSREAD_SIZE 1024
-struct nfs_read_repl {
-	n_long	errno;
-	struct	nfsv2_fattrs fa;
-	n_long	count;
-	u_char	data[NFSREAD_SIZE];
-};
 
 #ifndef NFS_NOSYMLINK
 struct nfs_readlnk_repl {
@@ -93,36 +75,88 @@ struct nfs_readlnk_repl {
 };
 #endif
 
+static inline uint64_t
+getnquad(n_long x[2]) {
+	return (uint64_t)ntohl(x[0]) << 32 | ntohl(x[1]);
+}
+
+static inline void
+setnquad(n_long x[2], uint64_t v)
+{
+	x[0] = htonl((n_long)(v >> 32));
+	x[1] = htonl((n_long)(v & 0x));
+}
+
 struct nfs_iodesc {
 	struct	iodesc	*iodesc;
 	off_t	off;
-	u_char	fh[NFS_FHSIZE];
-	struct nfsv2_fattrs fa;	/* all in network order */
+	int	version;
+	u_char	fh[NFS_FHSTORE];
+	union {
+		/* all in network order */
+		struct nfsv2_fattr v2;
+		struct nfsv3_fattr v3;
+	} u_fa;
 };
 
-int	nfs_getrootfh(struct iodesc *, char *, u_char *);
+static inline size_t
+fhstore(int version, u_char *fh)
+{
+	size_t len;
+
+	switch (version) {
+	case NFS_VER2:
+		len = NFS_FHSIZE;
+		break;
+	case NFS_VER3:
+		len = fh[0] << 24 | fh[1] << 16 | fh[2] << 8 | fh[3];
+		if (len > NFS_V3FHSIZE)
+			len = NFS_V3FHSIZE;
+		len = 4 + roundup(len, 4);
+		break;
+	default:
+		len = 0;
+		break;
+	}
+
+	return len;
+}
+
+static inline size_t
+fhcopy(int version, u_char *src, u_char *dst)
+{
+	size_t len = fhstore(version, src);
+	memcpy(dst, src, len);
+	return len;
+}
+
+#define setfh(d, s) fhcopy((d)->version, (s), (d)->fh)
+#define getfh(d, s) fhcopy((d)->version, (d)->fh, (s))
+
+
+struct nfs_iodesc nfs_root_node;
+
+int	nfs_getrootfh(struct iodesc *, char *, u_char *, int *);
 int	nfs_lookupfh(struct nfs_iodesc *, const char *, int,
 	struct nfs_iodesc *);
-#ifndef NFS_NOSYMLINK
 int	nfs_readlink(struct nfs_iodesc *, char *);
-#endif
 ssize_t	nfs_readdata(struct nfs_iodesc *, off_t, void *, size_t);
 
 /*
  * Fetch the root file handle (call mount daemon)
- * Return zero or error number.
+ * On error, return non-zero and set errno.
  */
 int
-nfs_getrootfh(struct iodesc *d, char *path, u_char *fhp)
+nfs_getrootfh(struct iodesc *d, char *path, u_char *fhp, int *versionp)
 {
-	size_t len;
+	int len;
 	struct args {
 		n_long	len;
 		char	path[FNAME_SIZE];
 	} *args;
 	struct repl {
 		n_long	errno;
-		u_char	fh[NFS_FHSIZE];
+		u_char	fh[NFS_FHSTORE];
 	} *repl;
 	struct {
 		n_long	h[RPC_HEADER_WORDS];
@@ -136,32 +170,42 @@ nfs_getrootfh(struct iodesc *d, char *pa
 
 #ifdef NFS_DEBUG
 	if (debug)
-		printf("nfs_getrootfh: %s\n", path);
+		printf("%s: %s\n", __func__, path);
 #endif
 
 	args = 
 	repl = 
 
-	memset(args, 0, sizeof(*args));
+	(void)memset(args, 0, sizeof(*args));
 	len = strlen(path);
-	if (len > sizeof(args->path))
+	if ((size_t)len > sizeof(args->path))
 		len = sizeof(args->path);
 	args->len = htonl(len);
-	memcpy(args->path, path, len);
+	(void)memcpy(args->path, path, len);
 	len = 4 + roundup(len, 4);
 
-	cc = 

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

2023-12-08 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Fri Dec  8 16:29:04 UTC 2023

Modified Files:
src/sys/arch/i386/stand/bootxx: pbr.S

Log Message:
Replace several magic numbers with macro to describe GPT's hybrid MBR boot.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/i386/stand/bootxx/pbr.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/bootxx/pbr.S
diff -u src/sys/arch/i386/stand/bootxx/pbr.S:1.23 src/sys/arch/i386/stand/bootxx/pbr.S:1.24
--- src/sys/arch/i386/stand/bootxx/pbr.S:1.23	Wed May 11 14:58:00 2022
+++ src/sys/arch/i386/stand/bootxx/pbr.S	Fri Dec  8 16:29:04 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: pbr.S,v 1.23 2022/05/11 14:58:00 andvar Exp $	*/
+/*	$NetBSD: pbr.S,v 1.24 2023/12/08 16:29:04 tsutsui Exp $	*/
 
 /*-
  * Copyright (c) 2003,2004 The NetBSD Foundation, Inc.
@@ -71,6 +71,10 @@
 #define MBR_AFTERBPB	62		/* BPB size in floppy master BR */
 #endif
 
+#define GPT_MAGIC	0x54504721	/* '!GPT' magic on hybrid MBR boot */
+#define GPT_ENTRY_OFF	20		/* GPT part entry in handover struct */
+#define GPT_ENT_LBA_OFF	32		/* ent_lba_start in struct gpt_ent */
+
 #ifdef TERSE_ERROR
 /*
  * Error codes. Done this way to save space.
@@ -127,7 +131,7 @@ start0:
 	mov	%cx, %sp
 	mov	%cx, %es
 #ifndef BOOT_FROM_FAT
-	cmpl	$0x54504721, %eax	/* did a GPT hybrid MBR start us? */
+	cmpl	$GPT_MAGIC, %eax	/* did a GPT hybrid MBR start us? */
 	je	boot_gpt
 #endif
 	mov	%cx, %ds
@@ -366,8 +370,9 @@ chs_read:
 
 #ifndef BOOT_FROM_FAT
 boot_gpt:
-	movl	(20+32+0)(%si), %ebp
-	movl	(20+32+4)(%si), %edi
+	/* DS:SI has a pointer to the hybrid MBR handover structure */
+	movl	(GPT_ENTRY_OFF+GPT_ENT_LBA_OFF+0)(%si), %ebp
+	movl	(GPT_ENTRY_OFF+GPT_ENT_LBA_OFF+4)(%si), %edi
 	movw	%cx, %ds
 	movl	%ebp, lba_sector + 0
 	movl	%edi, lba_sector + 4



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

2023-12-08 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Fri Dec  8 16:29:04 UTC 2023

Modified Files:
src/sys/arch/i386/stand/bootxx: pbr.S

Log Message:
Replace several magic numbers with macro to describe GPT's hybrid MBR boot.


To generate a diff of this commit:
cvs rdiff -u -r1.23 -r1.24 src/sys/arch/i386/stand/bootxx/pbr.S

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



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

2023-11-05 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Nov  6 07:09:08 UTC 2023

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

Log Message:
x86/dosboot: Drop no-longer-available -DSLOW for libz

It should be lost during merge from upstream.

We may introduce a similar hack again, if it is *really* required;
inflate_fast() may be dropped by using slow path unconditionally.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/arch/i386/stand/dosboot/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/dosboot/Makefile
diff -u src/sys/arch/i386/stand/dosboot/Makefile:1.35 src/sys/arch/i386/stand/dosboot/Makefile:1.36
--- src/sys/arch/i386/stand/dosboot/Makefile:1.35	Mon Nov  6 07:02:17 2023
+++ src/sys/arch/i386/stand/dosboot/Makefile	Mon Nov  6 07:09:08 2023
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.35 2023/11/06 07:02:17 rin Exp $
+#	$NetBSD: Makefile,v 1.36 2023/11/06 07:09:08 rin Exp $
 
 S=	${.CURDIR}/../../../..
 
@@ -10,7 +10,7 @@ RELOC=		0x100
 
 SRCS= main.c devopen.c exec.c exec_multiboot1.c exec_multiboot2.c
 
-CPPFLAGS+= -DSLOW	# for libz
+#CPPFLAGS+= -DSLOW	# for libz; no longer available
 CPPFLAGS+= -DCOMPAT_386BSD_MBRPART
 CPPFLAGS+= -DXMS
 CPPFLAGS+= -DLIBSA_ENABLE_LS_OP



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

2023-11-05 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Nov  6 07:09:08 UTC 2023

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

Log Message:
x86/dosboot: Drop no-longer-available -DSLOW for libz

It should be lost during merge from upstream.

We may introduce a similar hack again, if it is *really* required;
inflate_fast() may be dropped by using slow path unconditionally.


To generate a diff of this commit:
cvs rdiff -u -r1.35 -r1.36 src/sys/arch/i386/stand/dosboot/Makefile

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



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

2023-11-05 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Nov  6 07:02:17 UTC 2023

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

Log Message:
x86/dosboot: Do not page-align data segment

4K alignment is too heavy burden for COM executable with 64K limit :)

Fix binary size overflow for clang/amd64.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/arch/i386/stand/dosboot/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/dosboot/Makefile
diff -u src/sys/arch/i386/stand/dosboot/Makefile:1.34 src/sys/arch/i386/stand/dosboot/Makefile:1.35
--- src/sys/arch/i386/stand/dosboot/Makefile:1.34	Mon Nov  6 06:53:52 2023
+++ src/sys/arch/i386/stand/dosboot/Makefile	Mon Nov  6 07:02:17 2023
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.34 2023/11/06 06:53:52 rin Exp $
+#	$NetBSD: Makefile,v 1.35 2023/11/06 07:02:17 rin Exp $
 
 S=	${.CURDIR}/../../../..
 
@@ -34,6 +34,9 @@ I386MISCMAKEFLAGS= I386_INCLUDE_DOS=yes
 # DOS command line arguments are located at 0x.
 COPTS.doscommain.c+= -fno-delete-null-pointer-checks
 
+# Do not page-align data segment.
+LDFLAGS+= -Wl,-N
+
 VERSIONFILE= ${.CURDIR}/version
 
 .include 



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

2023-11-05 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Nov  6 07:02:17 UTC 2023

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

Log Message:
x86/dosboot: Do not page-align data segment

4K alignment is too heavy burden for COM executable with 64K limit :)

Fix binary size overflow for clang/amd64.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/arch/i386/stand/dosboot/Makefile

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



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

2023-11-05 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Nov  6 06:53:52 UTC 2023

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

Log Message:
x86/dosboot: Allow NULL dereference to fetch command line arguments

DOS command line arguments are provided as struct psp at 0x;
see doscommain.c.

Recent versions of gcc and clang are clever enough to optimize code
block involving NULL dereference into ud2 insn.

Sprinkle -fno-delete-null-pointer-checks to doscommain.c to
prevent this behavior.

Note that dosboot.com for netbsd-9 and later was broken due to
this ``over optimization''. gcc 5.5.0 and clang 4.0.0 in netbsd-8
generate correct codes without this workaround.

XXX
Are there still use cases for dosboot.com? Does anyone want to
boot NetBSD from real-mode DOS in 2023?


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/i386/stand/dosboot/Makefile

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



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

2023-11-05 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Nov  6 06:53:52 UTC 2023

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

Log Message:
x86/dosboot: Allow NULL dereference to fetch command line arguments

DOS command line arguments are provided as struct psp at 0x;
see doscommain.c.

Recent versions of gcc and clang are clever enough to optimize code
block involving NULL dereference into ud2 insn.

Sprinkle -fno-delete-null-pointer-checks to doscommain.c to
prevent this behavior.

Note that dosboot.com for netbsd-9 and later was broken due to
this ``over optimization''. gcc 5.5.0 and clang 4.0.0 in netbsd-8
generate correct codes without this workaround.

XXX
Are there still use cases for dosboot.com? Does anyone want to
boot NetBSD from real-mode DOS in 2023?


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/i386/stand/dosboot/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/dosboot/Makefile
diff -u src/sys/arch/i386/stand/dosboot/Makefile:1.33 src/sys/arch/i386/stand/dosboot/Makefile:1.34
--- src/sys/arch/i386/stand/dosboot/Makefile:1.33	Mon Sep 23 13:42:36 2019
+++ src/sys/arch/i386/stand/dosboot/Makefile	Mon Nov  6 06:53:52 2023
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.33 2019/09/23 13:42:36 christos Exp $
+#	$NetBSD: Makefile,v 1.34 2023/11/06 06:53:52 rin Exp $
 
 S=	${.CURDIR}/../../../..
 
@@ -31,6 +31,9 @@ SAMISCCPPFLAGS+= -DHEAP_START=0x2 -D
 SAMISCMAKEFLAGS= SA_USE_CREAD=yes SA_INCLUDE_NET=no SA_ENABLE_LS_OP=yes
 I386MISCMAKEFLAGS= I386_INCLUDE_DOS=yes
 
+# DOS command line arguments are located at 0x.
+COPTS.doscommain.c+= -fno-delete-null-pointer-checks
+
 VERSIONFILE= ${.CURDIR}/version
 
 .include 



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

2023-10-01 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Mon Oct  2 00:02:34 UTC 2023

Modified Files:
src/sys/arch/i386/stand/lib: biosdisk.c

Log Message:
Fix build with -DNO_GPT


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/sys/arch/i386/stand/lib/biosdisk.c

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



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

2023-10-01 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Mon Oct  2 00:02:34 UTC 2023

Modified Files:
src/sys/arch/i386/stand/lib: biosdisk.c

Log Message:
Fix build with -DNO_GPT


To generate a diff of this commit:
cvs rdiff -u -r1.59 -r1.60 src/sys/arch/i386/stand/lib/biosdisk.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/lib/biosdisk.c
diff -u src/sys/arch/i386/stand/lib/biosdisk.c:1.59 src/sys/arch/i386/stand/lib/biosdisk.c:1.60
--- src/sys/arch/i386/stand/lib/biosdisk.c:1.59	Thu Sep 28 15:46:55 2023
+++ src/sys/arch/i386/stand/lib/biosdisk.c	Mon Oct  2 00:02:33 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: biosdisk.c,v 1.59 2023/09/28 15:46:55 manu Exp $	*/
+/*	$NetBSD: biosdisk.c,v 1.60 2023/10/02 00:02:33 manu Exp $	*/
 
 /*
  * Copyright (c) 1996, 1998
@@ -328,7 +328,6 @@ guid_is_equal(const struct uuid *a, cons
 	return (memcmp(a, b, sizeof(*a)) == 0 ? true : false);
 }
 
-#ifndef NO_GPT
 static void
 part_name_utf8(const uint16_t *utf16_src, size_t utf16_srclen,
 	   char *utf8_dst, size_t utf8_dstlen)
@@ -351,7 +350,6 @@ part_name_utf8(const uint16_t *utf16_src
 
 	return;
 }
-#endif
 
 static int
 check_gpt(struct biosdisk *d, daddr_t rf_offset, daddr_t sector)
@@ -1562,14 +1560,17 @@ next_disk:
 			if (d->part[part].fstype == FS_UNUSED)
 continue;
 
+#ifndef NO_GPT
 			if (first_bootme == -1 &&
 			d->part[part].attr & GPT_ENT_ATTR_BOOTME)
 first_bootme = part;
+#endif
 
 			if (first_ffs == -1 &&
 			(d->part[part].fstype == FS_BSDFFS ||
 			 d->part[part].fstype == FS_BSDLFS))
 first_ffs = part;
+
 			if (part == target_part) {
 *biosdev = raidframe[i].biosdev;
 *offset = raidframe[i].offset



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

2023-09-28 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Thu Sep 28 15:46:55 UTC 2023

Modified Files:
src/sys/arch/i386/stand/lib: biosdisk.c

Log Message:
Align the behavior of different boot methods in RAIDframe

We enforce the documented and paritally implemented behavior when
looking for the kernel in RAID 1 sets without a partition name given.
We search for:
- A GPT partition with bootme attribute set
- A FFS or LFS patititon
- The first partition


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/sys/arch/i386/stand/lib/biosdisk.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/lib/biosdisk.c
diff -u src/sys/arch/i386/stand/lib/biosdisk.c:1.58 src/sys/arch/i386/stand/lib/biosdisk.c:1.59
--- src/sys/arch/i386/stand/lib/biosdisk.c:1.58	Tue May  3 10:09:40 2022
+++ src/sys/arch/i386/stand/lib/biosdisk.c	Thu Sep 28 15:46:55 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: biosdisk.c,v 1.58 2022/05/03 10:09:40 jmcneill Exp $	*/
+/*	$NetBSD: biosdisk.c,v 1.59 2023/09/28 15:46:55 manu Exp $	*/
 
 /*
  * Copyright (c) 1996, 1998
@@ -105,6 +105,7 @@
 struct biosdisk {
 	struct biosdisk_ll ll;
 	daddr_t boff;
+	daddr_t size;
 	charbuf[BIOSDISK_BUFSIZE];
 #if !defined(NO_DISKLABEL) || !defined(NO_GPT)
 	struct biosdisk_partition part[BIOSDISKNPART];
@@ -666,6 +667,7 @@ read_label(struct biosdisk *d, daddr_t o
 	dflt_lbl.d_npartitions = 8;
 
 	d->boff = 0;
+	d->size = 0;
 
 	if (d->ll.type != BIOSDISK_TYPE_HD)
 		/* No label on floppy and CD */
@@ -1208,7 +1210,7 @@ add_biosdisk_bootinfo(void)
 #endif
 
 #ifndef NO_GPT
-static daddr_t
+static void
 raidframe_part_offset(struct biosdisk *d, int part)
 {
 	struct biosdisk raidframe;
@@ -1221,8 +1223,10 @@ raidframe_part_offset(struct biosdisk *d
 
 	rf_offset = d->part[part].offset + RF_PROTECTED_SECTORS;
 	rf_size = d->part[part].size;
-	if (read_gpt(, rf_offset, rf_size) != 0)
-		return RF_PROTECTED_SECTORS;
+	if (read_gpt(, rf_offset, rf_size) != 0) {
+		d->boff += RF_PROTECTED_SECTORS;
+		return;
+	}
 
 	candidate = 0;
 	for (i = 0; i < BIOSDISKNPART; i++) {
@@ -1231,12 +1235,20 @@ raidframe_part_offset(struct biosdisk *d
 		if (raidframe.part[i].fstype == FS_UNUSED)
 			continue;
 #ifndef NO_GPT
-		if (raidframe.part[i].attr & GPT_ENT_ATTR_BOOTME)
+		if (raidframe.part[i].attr & GPT_ENT_ATTR_BOOTME) {
 			candidate = i;
+			break;
+		}
 #endif
+		if (raidframe.part[i].fstype == FS_BSDFFS ||
+		raidframe.part[i].fstype == FS_BSDLFS) {
+			if (candidate == 0)
+candidate = i;
+		}
 	}
 
-	return RF_PROTECTED_SECTORS + raidframe.part[candidate].offset;
+	d->boff += RF_PROTECTED_SECTORS + raidframe.part[candidate].offset;
+	d->size = raidframe.part[candidate].size;
 }
 #endif
 
@@ -1285,17 +1297,18 @@ biosdisk_open(struct open_file *f, ...)
 	}
 
 	d->boff = d->part[partition].offset;
+	d->size = d->part[partition].size;
 
 	if (d->part[partition].fstype == FS_RAID)
 #ifndef NO_GPT
-		d->boff += raidframe_part_offset(d, partition);
+		raidframe_part_offset(d, partition);
 #else
 		d->boff += RF_PROTECTED_SECTORS;
 #endif
 
 #ifdef _STANDALONE
-	bi_wedge.startblk = d->part[partition].offset;
-	bi_wedge.nblks = d->part[partition].size;
+	bi_wedge.startblk = d->boff;
+	bi_wedge.nblks = d->size;
 #endif
 
 nolabel:
@@ -1389,6 +1402,8 @@ next_disk:
 
 #ifndef NO_RAIDFRAME
 	for (i = 0; i < raidframe_count; i++) {
+		int first_bootme = -1;
+		int first_ffs = -1;
 		int candidate = -1;
 
 		if ((d = alloc_biosdisk(raidframe[i].biosdev)) == NULL) {
@@ -1402,12 +1417,20 @@ next_disk:
 			goto next_raidframe;
 
 		for (part = 0; part < BIOSDISKNPART; part++) {
-			bool bootme = d->part[part].attr & GPT_ENT_ATTR_BOOTME;
 			if (d->part[part].size == 0)
 continue;
 			if (d->part[part].fstype == FS_UNUSED)
 continue;
 
+			if (first_bootme == -1 && 
+			d->part[part].attr & GPT_ENT_ATTR_BOOTME)
+first_bootme = part;
+
+			if (first_ffs == -1 && 
+			(d->part[part].fstype == FS_BSDFFS ||
+			 d->part[part].fstype == FS_BSDLFS))
+first_ffs = part;
+
 			if (d->part[part].part_name != NULL &&
 			strcmp(d->part[part].part_name, name) == 0) {
 *biosdev = raidframe[i].biosdev;
@@ -1418,11 +1441,13 @@ next_disk:
 ret = 0;
 goto out;
 			}
-			if (strcmp(raidframe[i].parent_name, name) == 0) {
-if (candidate == -1 || bootme)
-	candidate = part;
-continue;
-			}
+		}
+
+		if (strcmp(raidframe[i].parent_name, name) == 0) {
+			if (first_bootme != -1)
+candidate = first_bootme;
+			else if (first_ffs != -1)
+candidate = first_ffs;
 		}
 
 		if (candidate != -1) {
@@ -1514,6 +1539,10 @@ next_disk:
 	}
 
 	for (i = 0; i < raidframe_count; i++) {
+		int first_bootme = -1;
+		int first_ffs = -1;
+		int candidate = -1;
+
 		if (raidframe[i].last_unit != target_unit)
 			continue;
 
@@ -1532,6 +1561,15 @@ next_disk:
 continue;
 			if (d->part[part].fstype == 

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

2023-09-28 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Thu Sep 28 15:46:55 UTC 2023

Modified Files:
src/sys/arch/i386/stand/lib: biosdisk.c

Log Message:
Align the behavior of different boot methods in RAIDframe

We enforce the documented and paritally implemented behavior when
looking for the kernel in RAID 1 sets without a partition name given.
We search for:
- A GPT partition with bootme attribute set
- A FFS or LFS patititon
- The first partition


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/sys/arch/i386/stand/lib/biosdisk.c

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



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

2023-09-13 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Sep 14 03:05:15 UTC 2023

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

Log Message:
efiboot/x86: eficons.c: Explicitly include params.h for howmany()

NFC for -current and netbsd-10, but necessary for netbsd-[89] to
pull up raw IO serial port support (PR port-amd64/57523).


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 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.



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

2023-09-13 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Thu Sep 14 03:05:15 UTC 2023

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

Log Message:
efiboot/x86: eficons.c: Explicitly include params.h for howmany()

NFC for -current and netbsd-10, but necessary for netbsd-[89] to
pull up raw IO serial port support (PR port-amd64/57523).


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 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.13 src/sys/arch/i386/stand/efiboot/eficons.c:1.14
--- src/sys/arch/i386/stand/efiboot/eficons.c:1.13	Mon Jul 24 01:56:59 2023
+++ src/sys/arch/i386/stand/efiboot/eficons.c	Thu Sep 14 03:05:15 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: eficons.c,v 1.13 2023/07/24 01:56:59 rin Exp $	*/
+/*	$NetBSD: eficons.c,v 1.14 2023/09/14 03:05:15 rin Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -26,6 +26,7 @@
  * SUCH DAMAGE.
  */
 
+#include 
 #include 
 #include 
 



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

2023-08-30 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Aug 30 18:46:52 UTC 2023

Modified Files:
src/sys/arch/i386/stand/bootxx/bootxx_msdos: Makefile
src/sys/arch/i386/stand/bootxx/bootxx_ustarfs: Makefile

Log Message:
Override these two booters with -Oz for clang since it produces smaller code
here.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/i386/stand/bootxx/bootxx_msdos/Makefile
cvs rdiff -u -r1.3 -r1.4 \
src/sys/arch/i386/stand/bootxx/bootxx_ustarfs/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/bootxx/bootxx_msdos/Makefile
diff -u src/sys/arch/i386/stand/bootxx/bootxx_msdos/Makefile:1.4 src/sys/arch/i386/stand/bootxx/bootxx_msdos/Makefile:1.5
--- src/sys/arch/i386/stand/bootxx/bootxx_msdos/Makefile:1.4	Wed Jan 22 01:13:18 2020
+++ src/sys/arch/i386/stand/bootxx/bootxx_msdos/Makefile	Wed Aug 30 14:46:51 2023
@@ -1,7 +1,11 @@
-# $NetBSD: Makefile,v 1.4 2020/01/22 06:13:18 martin Exp $
+# $NetBSD: Makefile,v 1.5 2023/08/30 18:46:51 christos Exp $
+
+NOMAN=yes
+.include 
 
 PROG=	bootxx_msdos
 FS=	dosfs
 CPPFLAGS=-DBOOT_FROM_FAT -DTERSE_ERROR -DSA_DOSFS_NO_BIG_PART_SUPPORT
 
 .include <../Makefile.bootxx>
+OPT_SIZE.clang += -Oz

Index: src/sys/arch/i386/stand/bootxx/bootxx_ustarfs/Makefile
diff -u src/sys/arch/i386/stand/bootxx/bootxx_ustarfs/Makefile:1.3 src/sys/arch/i386/stand/bootxx/bootxx_ustarfs/Makefile:1.4
--- src/sys/arch/i386/stand/bootxx/bootxx_ustarfs/Makefile:1.3	Wed Nov 18 16:02:16 2009
+++ src/sys/arch/i386/stand/bootxx/bootxx_ustarfs/Makefile	Wed Aug 30 14:46:52 2023
@@ -1,7 +1,11 @@
-# $NetBSD: Makefile,v 1.3 2009/11/18 21:02:16 dsl Exp $
+# $NetBSD: Makefile,v 1.4 2023/08/30 18:46:52 christos Exp $
+
+NOMAN=yes
+.include 
 
 FS=ustarfs
 
 BOOTXX_SECTORS=16
 
 .include <../Makefile.bootxx>
+OPT_SIZE.clang += -Oz



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

2023-08-30 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Aug 30 18:46:52 UTC 2023

Modified Files:
src/sys/arch/i386/stand/bootxx/bootxx_msdos: Makefile
src/sys/arch/i386/stand/bootxx/bootxx_ustarfs: Makefile

Log Message:
Override these two booters with -Oz for clang since it produces smaller code
here.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/i386/stand/bootxx/bootxx_msdos/Makefile
cvs rdiff -u -r1.3 -r1.4 \
src/sys/arch/i386/stand/bootxx/bootxx_ustarfs/Makefile

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



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

2023-08-30 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Aug 30 18:45:46 UTC 2023

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

Log Message:
Merge the OPT_SIZE flags. -Oz is not always producing smaller code that -Os,
so default to -Os for both, and we'll override where needed.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/i386/stand/Makefile.inc

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/Makefile.inc
diff -u src/sys/arch/i386/stand/Makefile.inc:1.18 src/sys/arch/i386/stand/Makefile.inc:1.19
--- src/sys/arch/i386/stand/Makefile.inc:1.18	Sat Jan 26 23:56:46 2019
+++ src/sys/arch/i386/stand/Makefile.inc	Wed Aug 30 14:45:46 2023
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.inc,v 1.18 2019/01/27 04:56:46 dholland Exp $
+#	$NetBSD: Makefile.inc,v 1.19 2023/08/30 18:45:46 christos Exp $
 
 NOLIBCSANITIZER=
 NOSANITIZER=
@@ -10,8 +10,6 @@ NOMAN=
 BINDIR=	/usr/mdec
 
 OPT_SIZE.gcc=	-Os -ffreestanding -fomit-frame-pointer -fno-unwind-tables \
-		-fno-asynchronous-unwind-tables -fno-exceptions -mno-sse
-OPT_SIZE.clang=	-Oz -ffreestanding -fomit-frame-pointer -DNDEBUG \
-		-fno-stack-protector -mno-sse \
-		-mstack-alignment=4 \
-		-fno-unwind-tables
+		-fno-asynchronous-unwind-tables -fno-exceptions -mno-sse \
+		-fno-stack-protector
+OPT_SIZE.clang=	${OPT_SIZE.gcc} -mstack-alignment=4  -DNDEBUG



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

2023-08-30 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Aug 30 18:45:46 UTC 2023

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

Log Message:
Merge the OPT_SIZE flags. -Oz is not always producing smaller code that -Os,
so default to -Os for both, and we'll override where needed.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/i386/stand/Makefile.inc

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



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

2023-08-30 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Aug 30 18:44:48 UTC 2023

Modified Files:
src/sys/arch/i386/stand/lib: Makefile.inc

Log Message:
Explicitly pass COPTS


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

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/lib/Makefile.inc
diff -u src/sys/arch/i386/stand/lib/Makefile.inc:1.19 src/sys/arch/i386/stand/lib/Makefile.inc:1.20
--- src/sys/arch/i386/stand/lib/Makefile.inc:1.19	Wed Jun 13 12:03:10 2018
+++ src/sys/arch/i386/stand/lib/Makefile.inc	Wed Aug 30 14:44:48 2023
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.inc,v 1.19 2018/06/13 16:03:10 christos Exp $
+#	$NetBSD: Makefile.inc,v 1.20 2023/08/30 18:44:48 christos Exp $
 #
 #	Configuration variables (default values are below):
 #
@@ -26,6 +26,7 @@ I386MAKE= \
 	MAKEOBJDIR=${I386DST} ${MAKE} \
 	CC=${CC:q} CFLAGS=${CFLAGS:q} \
 	AS=${AS:q} AFLAGS=${AFLAGS:q} \
+	COPTS=${COPTS:q} \
 	LD=${LD:q} STRIP=${STRIP:q} \
 	MACHINE=${MACHINE} MACHINE_ARCH=${MACHINE_ARCH:q} \
 	I386CPPFLAGS=${CPPFLAGS:S@^-I.@-I../../.@g:q} \



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

2023-08-30 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Aug 30 18:44:48 UTC 2023

Modified Files:
src/sys/arch/i386/stand/lib: Makefile.inc

Log Message:
Explicitly pass COPTS


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

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



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

2023-08-04 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Aug  4 07:21:57 UTC 2023

Modified Files:
src/sys/arch/i386/stand/lib: exec_multiboot2.c

Log Message:
x86/multiboot2: Fix short read for 64-bit ELF headers

XXX document this
At the moment, this cannot affect NetBSD/amd64, as we have not
supported multiboot for kernel side.

Found by GCC12.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/i386/stand/lib/exec_multiboot2.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/lib/exec_multiboot2.c
diff -u src/sys/arch/i386/stand/lib/exec_multiboot2.c:1.5 src/sys/arch/i386/stand/lib/exec_multiboot2.c:1.6
--- src/sys/arch/i386/stand/lib/exec_multiboot2.c:1.5	Wed Jul 21 23:16:08 2021
+++ src/sys/arch/i386/stand/lib/exec_multiboot2.c	Fri Aug  4 07:21:57 2023
@@ -1,4 +1,4 @@
-/* $NetBSD: exec_multiboot2.c,v 1.5 2021/07/21 23:16:08 jmcneill Exp $ */
+/* $NetBSD: exec_multiboot2.c,v 1.6 2023/08/04 07:21:57 rin Exp $ */
 
 /*
  * Copyright (c) 2019 The NetBSD Foundation, Inc.
@@ -976,7 +976,10 @@ mbi_elf_sections(struct multiboot_packag
 {
 	size_t len = 0;
 	struct multiboot_tag_elf_sections *mbt = buf;
-	Elf_Ehdr ehdr;
+	union {
+		Elf32_Ehdr e32;
+		Elf64_Ehdr e64;
+	} ehdr;
 	int class;
 	Elf32_Ehdr *ehdr32 = NULL;
 	Elf64_Ehdr *ehdr64 = NULL;
@@ -991,21 +994,21 @@ mbi_elf_sections(struct multiboot_packag
 	/*
 	 * Check this is a ELF header
 	 */
-	if (memcmp(_ident, ELFMAG, SELFMAG) != 0)
+	if (memcmp(_ident, ELFMAG, SELFMAG) != 0)
 		goto out;
 
-	class = ehdr.e_ident[EI_CLASS];
+	class = ehdr.e32.e_ident[EI_CLASS];
 
 	switch (class) {
 	case ELFCLASS32:
-		ehdr32 = (Elf32_Ehdr *)
+		ehdr32 = 
 		shnum = ehdr32->e_shnum;
 		shentsize = ehdr32->e_shentsize;
 		shstrndx = ehdr32->e_shstrndx;
 		shoff = ehdr32->e_shoff;
 		break;
 	case ELFCLASS64:
-		ehdr64 = (Elf64_Ehdr *)
+		ehdr64 = 
 		shnum = ehdr64->e_shnum;
 		shentsize = ehdr64->e_shentsize;
 		shstrndx = ehdr64->e_shstrndx;



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

2023-08-04 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Fri Aug  4 07:21:57 UTC 2023

Modified Files:
src/sys/arch/i386/stand/lib: exec_multiboot2.c

Log Message:
x86/multiboot2: Fix short read for 64-bit ELF headers

XXX document this
At the moment, this cannot affect NetBSD/amd64, as we have not
supported multiboot for kernel side.

Found by GCC12.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/i386/stand/lib/exec_multiboot2.c

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



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

2023-07-24 Thread Rin Okuyama

On 2023/07/24 16:14, matthew green wrote:

"Rin Okuyama" writes:

Module Name:src
Committed By:   rin
Date:   Mon Jul 24 01:56:59 UTC 2023

Modified Files:
src/sys/arch/i386/stand/efiboot: Makefile.efiboot eficons.c
Added Files:
src/sys/arch/i386/stand/efiboot: eficpufunc.c eficpufunc.h

Log Message:
efiboot/x86: Add serial console support via raw I/O port access


thanks!  this makes efiboot capable of replacing bios on many
of my test systems that can use serial console (and often do.)


Thank you too for your feedback! I'm glad to hear that :)

rin


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

2023-07-24 Thread matthew green
"Rin Okuyama" writes:
> Module Name:  src
> Committed By: rin
> Date: Mon Jul 24 01:56:59 UTC 2023
>
> Modified Files:
>   src/sys/arch/i386/stand/efiboot: Makefile.efiboot eficons.c
> Added Files:
>   src/sys/arch/i386/stand/efiboot: eficpufunc.c eficpufunc.h
>
> Log Message:
> efiboot/x86: Add serial console support via raw I/O port access

thanks!  this makes efiboot capable of replacing bios on many
of my test systems that can use serial console (and often do.)


.mrg.


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

2023-07-23 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Jul 24 01:56:59 UTC 2023

Modified Files:
src/sys/arch/i386/stand/efiboot: Makefile.efiboot eficons.c
Added Files:
src/sys/arch/i386/stand/efiboot: eficpufunc.c eficpufunc.h

Log Message:
efiboot/x86: Add serial console support via raw I/O port access

Unfortunately, some (most?) UEFI implementations do not support
com ports by ``Serial I/O Protocol''.

``PNP0501-0'' and friends are not recognized also.

In this case, if user explicitly requires to switch to serial
console by ``consdev'' command, try to use raw I/O port access.

Ugly, but what FreeBSD does, at least.

Proposed as PR port-amd64/57523


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/i386/stand/efiboot/Makefile.efiboot
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/i386/stand/efiboot/eficons.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/i386/stand/efiboot/eficpufunc.c \
src/sys/arch/i386/stand/efiboot/eficpufunc.h

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



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

2023-07-23 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Jul 24 01:56:59 UTC 2023

Modified Files:
src/sys/arch/i386/stand/efiboot: Makefile.efiboot eficons.c
Added Files:
src/sys/arch/i386/stand/efiboot: eficpufunc.c eficpufunc.h

Log Message:
efiboot/x86: Add serial console support via raw I/O port access

Unfortunately, some (most?) UEFI implementations do not support
com ports by ``Serial I/O Protocol''.

``PNP0501-0'' and friends are not recognized also.

In this case, if user explicitly requires to switch to serial
console by ``consdev'' command, try to use raw I/O port access.

Ugly, but what FreeBSD does, at least.

Proposed as PR port-amd64/57523


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/i386/stand/efiboot/Makefile.efiboot
cvs rdiff -u -r1.12 -r1.13 src/sys/arch/i386/stand/efiboot/eficons.c
cvs rdiff -u -r0 -r1.1 src/sys/arch/i386/stand/efiboot/eficpufunc.c \
src/sys/arch/i386/stand/efiboot/eficpufunc.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/arch/i386/stand/efiboot/Makefile.efiboot
diff -u src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.21 src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.22
--- src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.21	Sat Jun  3 08:52:56 2023
+++ src/sys/arch/i386/stand/efiboot/Makefile.efiboot	Mon Jul 24 01:56:59 2023
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.efiboot,v 1.21 2023/06/03 08:52:56 lukem Exp $
+# $NetBSD: Makefile.efiboot,v 1.22 2023/07/24 01:56:59 rin Exp $
 
 S=		${.CURDIR}/../../../../..
 
@@ -14,9 +14,11 @@ AFLAGS.start.S= ${${ACTIVE_CC} == "clang
 
 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+= eficpufunc.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+= comio_direct.c
 LIBI386SRCS+= diskbuf.c exec.c menuutils.c parseutils.c pread.c
 LIBI386SRCS+= exec_multiboot1.c exec_multiboot2.c
 # use our own nfs implementation

Index: src/sys/arch/i386/stand/efiboot/eficons.c
diff -u src/sys/arch/i386/stand/efiboot/eficons.c:1.12 src/sys/arch/i386/stand/efiboot/eficons.c:1.13
--- src/sys/arch/i386/stand/efiboot/eficons.c:1.12	Thu Oct 28 06:13:13 2021
+++ src/sys/arch/i386/stand/efiboot/eficons.c	Mon Jul 24 01:56:59 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: eficons.c,v 1.12 2021/10/28 06:13:13 kim Exp $	*/
+/*	$NetBSD: eficons.c,v 1.13 2023/07/24 01:56:59 rin Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -29,6 +29,8 @@
 #include 
 #include 
 
+#include 
+
 #include "efiboot.h"
 
 #include "bootinfo.h"
@@ -60,6 +62,8 @@ static u_char serbuf[16];
 static int serbuf_read = 0;
 static int serbuf_write = 0;
 
+static int raw_com_addr = 0;
+
 static void eficons_init_video(void);
 static void efi_switch_video_to_text_mode(void);
 
@@ -76,6 +80,12 @@ static int efi_com_putc(int);
 static int efi_com_status(int);
 static int efi_com_waitforinputevent(uint64_t);
 
+static int raw_com_init(int, int);
+static int raw_com_getc(void);
+static int raw_com_putc(int);
+static int raw_com_status(int);
+static int raw_com_waitforinputevent(uint64_t);
+
 static int efi_find_gop_mode(char *);
 
 static int iodev;
@@ -134,11 +144,8 @@ ok:
 	case CONSDEV_COM3:
 		iodev = dev;
 		btinfo_console.addr = ioport;
-		if (btinfo_console.addr == 0) {
-			if (!efi_valid_com(iodev))
-goto nocom;
+		if (btinfo_console.addr == 0)
 			btinfo_console.addr = getcomaddr(iodev - CONSDEV_COM0);
-		}
 		if (speed != 0)
 			btinfo_console.speed = speed;
 		efi_com_init(btinfo_console.addr, btinfo_console.speed);
@@ -149,8 +156,6 @@ ok:
 	case CONSDEV_COM2KBD:
 	case CONSDEV_COM3KBD:
 		iodev = dev - CONSDEV_COM0KBD + CONSDEV_COM0;
-		if (!efi_valid_com(iodev))
-			goto nocom;
 		btinfo_console.addr = getcomaddr(iodev - CONSDEV_COM0);
 
 		efi_cons_putc('0' + iodev - CONSDEV_COM0);
@@ -869,7 +874,7 @@ efi_com_init(int addr, int speed)
 		return 0;
 
 	if (!efi_valid_com(iodev))
-		return 0;
+		return raw_com_init(addr, speed);
 
 	serio = serios[iodev - CONSDEV_COM0];
 
@@ -885,6 +890,7 @@ efi_com_init(int addr, int speed)
 		}
 	}
 
+	raw_com_addr = 0;
 	default_comspeed = speed;
 	internal_getchar = efi_com_getc;
 	internal_putchar = efi_com_putc;
@@ -1019,3 +1025,65 @@ efi_com_waitforinputevent(uint64_t timeo
 		return ETIMEDOUT;
 	return EINVAL;
 }
+
+static int
+raw_com_init(int addr, int speed)
+{
+
+	if (addr == 0 || speed <= 0)
+		return 0;
+
+	speed = cominit_d(addr, speed);
+
+	raw_com_addr = addr;
+	default_comspeed = speed;
+	internal_getchar = raw_com_getc;
+	internal_putchar = raw_com_putc;
+	internal_iskey = raw_com_status;
+	internal_waitforinputevent = raw_com_waitforinputevent;
+
+	return speed;
+}
+
+static int
+raw_com_getc(void)
+{
+
+	if (raw_com_addr == 0)
+		panic("%s: Invalid serial port", 

Re: CVS commit: src/sys/arch/i386/stand/bootxx

2023-06-29 Thread Greg Troxel
Emmanuel Dreyfus  writes:

> On Thu, Jun 29, 2023 at 08:43:36PM -0400, Greg Troxel wrote:
>> > Primary bootstrap is now able to read a GPT inside RAIDframe.
>> did you also update documentation?
>
> We do not have any documentation specific to primary bootstrap. 
> x86/boot(8) domuent the behavior with no detail about primary
> and secondary bootstrap distinct roles.
>
> The change makes primary bootstrap behavior in line with secondary
> bootstrap and with what is already documented in x86/boot(8). Hence
> there is no documentation update, we could consider it as a bug fix, 
> since the previosu behavior did not match x86/boot(8) documentation.

Thank you for explaining.  That sounds fine then.


Re: CVS commit: src/sys/arch/i386/stand/bootxx

2023-06-29 Thread Emmanuel Dreyfus
On Thu, Jun 29, 2023 at 08:43:36PM -0400, Greg Troxel wrote:
> > Primary bootstrap is now able to read a GPT inside RAIDframe.
> did you also update documentation?

We do not have any documentation specific to primary bootstrap. 
x86/boot(8) domuent the behavior with no detail about primary
and secondary bootstrap distinct roles.

The change makes primary bootstrap behavior in line with secondary
bootstrap and with what is already documented in x86/boot(8). Hence
there is no documentation update, we could consider it as a bug fix, 
since the previosu behavior did not match x86/boot(8) documentation.

-- 
Emmanuel Dreyfus
m...@netbsd.org


Re: CVS commit: src/sys/arch/i386/stand/bootxx

2023-06-29 Thread Greg Troxel
"Emmanuel Dreyfus"  writes:

> Log Message:
> Primary bootstrap is now able to read a GPT inside RAIDframe.

did you also update documentation?


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

2023-06-29 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Thu Jun 29 14:18:58 UTC 2023

Modified Files:
src/sys/arch/i386/stand/bootxx: boot1.c

Log Message:
Primary bootstrap is now able to read a GPT inside RAIDframe.

Previously, primary bootstrap was able to boot on RAID-1 RAIDframe set
with the limitation that the FFS filesystem had to start at bloc 0 in the
RAID. That allowed inner RAID partitionning with a disklabel, but not with
a GPT.

When booting on a RAID-1 RAIDframe, primary bootstrap now first try a
filesystem at bloc 0 of the RAID as before. On failure, it tries to
read a GPT and load secondary bootstrap from, by priority;
1) the first partition with the bootme attribute set
2) the first partition of type FFS, LFS, CCD or CGD
3) the first partition present in the GPT


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/i386/stand/bootxx/boot1.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/bootxx/boot1.c
diff -u src/sys/arch/i386/stand/bootxx/boot1.c:1.21 src/sys/arch/i386/stand/bootxx/boot1.c:1.22
--- src/sys/arch/i386/stand/bootxx/boot1.c:1.21	Thu Jun 24 01:23:16 2021
+++ src/sys/arch/i386/stand/bootxx/boot1.c	Thu Jun 29 14:18:58 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: boot1.c,v 1.21 2021/06/24 01:23:16 gutteridge Exp $	*/
+/*	$NetBSD: boot1.c,v 1.22 2023/06/29 14:18:58 manu Exp $	*/
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -30,15 +30,17 @@
  */
 
 #include 
-__RCSID("$NetBSD: boot1.c,v 1.21 2021/06/24 01:23:16 gutteridge Exp $");
+__RCSID("$NetBSD: boot1.c,v 1.22 2023/06/29 14:18:58 manu Exp $");
 
 #include 
 #include 
 #include 
 
 #include 
+#include 
 #include 
 #include 
+#include 
 #include 	/* For RF_PROTECTED_SECTORS */
 
 #define XSTR(x) #x
@@ -49,6 +51,9 @@ static daddr_t bios_sector;
 static struct biosdisk_ll d;
 
 const char *boot1(uint32_t, uint64_t *);
+#ifndef NO_GPT
+static daddr_t gpt_lookup(daddr_t);
+#endif
 extern void putstr(const char *);
 
 extern struct disklabel ptn_disklabel;
@@ -90,6 +95,17 @@ boot1(uint32_t biosdev, uint64_t *sector
 	fd = ob();
 	if (fd != -1)
 		goto done;
+
+#ifndef NO_GPT
+	/*
+	 * Test for a GPT inside the RAID
+	 */
+	bios_sector += gpt_lookup(bios_sector);
+	fd = ob();
+	if (fd != -1)
+		goto done;
+#endif
+
 	/*
 	 * Nothing at the start of the MBR partition, fallback on
 	 * partition 'a' from the disklabel in this MBR partition.
@@ -144,3 +160,146 @@ blkdevstrategy(void *devdata, int flag, 
 
 	return 0;
 }
+
+#ifndef NO_GPT
+static int
+is_unused(struct gpt_ent *ent)
+{
+	const struct uuid unused = GPT_ENT_TYPE_UNUSED;
+
+	return (memcmp(ent->ent_type, , sizeof(unused)) == 0);
+}
+
+static int
+is_bootable(struct gpt_ent *ent)
+{
+	/* GPT_ENT_TYPE_NETBSD_RAID omitted as we are already in a RAID */
+	const struct uuid bootable[] = {
+		GPT_ENT_TYPE_NETBSD_FFS,
+		GPT_ENT_TYPE_NETBSD_LFS,
+		GPT_ENT_TYPE_NETBSD_CCD,
+		GPT_ENT_TYPE_NETBSD_CGD,
+	};
+	int i;
+
+	for (i = 0; i < sizeof(bootable) / sizeof(*bootable); i++) {
+		if (memcmp(ent->ent_type, [i],
+		sizeof(struct uuid)) == 0)
+			return 1;
+	}
+
+	return 0;
+}
+
+static daddr_t
+gpt_lookup(daddr_t sector)
+{
+	char buf[BIOSDISK_DEFAULT_SECSIZE];
+	struct mbr_sector *pmbr;	
+	const char gpt_hdr_sig[] = GPT_HDR_SIG;
+	struct gpt_hdr *hdr;
+	struct gpt_ent *ent;
+	uint32_t nents;
+	uint32_t entsz;
+	uint32_t entries_per_sector;
+	uint32_t sectors_per_entry;
+	uint64_t firstpart_lba = 0;
+	uint64_t bootable_lba = 0;
+	uint64_t bootme_lba = 0;
+	int i, j;
+
+	/*
+	 * Look for a PMBR
+	 */
+	if (readsects(, sector, 1, buf, 1) != 0)
+		return 0;
+
+	pmbr = (struct mbr_sector *)buf;
+
+	if (pmbr->mbr_magic != htole16(MBR_MAGIC))
+		return 0;
+
+	if (pmbr->mbr_parts[0].mbrp_type != MBR_PTYPE_PMBR)
+		return 0;
+
+	sector++; /* skip PMBR */
+
+	/*
+	 * Look for a GPT header
+	 * Space is scarce, we do not check CRC.
+	 */
+	if (readsects(, sector, 1, buf, 1) != 0)
+		return 0;
+
+	hdr = (struct gpt_hdr *)buf;
+
+	if (memcmp(gpt_hdr_sig, hdr->hdr_sig, sizeof(hdr->hdr_sig)) != 0)
+		return 0;
+
+	if (hdr->hdr_revision != htole32(GPT_HDR_REVISION))
+		return 0;
+
+	if (le32toh(hdr->hdr_size) > BIOSDISK_DEFAULT_SECSIZE)
+		return 0;
+
+	nents = le32toh(hdr->hdr_entries);
+	entsz = le32toh(hdr->hdr_entsz);
+
+	sector++; /* skip GPT header */
+
+	/*
+	 * Read partition table
+	 *
+	 * According to UEFI specification section 5.3.2, entries
+	 * are 128 * (2^n) bytes long. The most common scenario is
+	 * 128 bytes (n = 0) where there are 4 entries per sector.
+	 * If n > 2, then entries spans multiple sectors, but they
+	 * remain sector-aligned.
+	 */
+	entries_per_sector = BIOSDISK_DEFAULT_SECSIZE / entsz;
+	if (entries_per_sector == 0)
+		entries_per_sector = 1;
+
+	sectors_per_entry = entsz / BIOSDISK_DEFAULT_SECSIZE;
+	if (sectors_per_entry == 0)
+		sectors_per_entry = 1;
+
+	for (i = 0; i < nents; i += entries_per_sector) {
+	

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

2023-06-29 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Thu Jun 29 14:18:58 UTC 2023

Modified Files:
src/sys/arch/i386/stand/bootxx: boot1.c

Log Message:
Primary bootstrap is now able to read a GPT inside RAIDframe.

Previously, primary bootstrap was able to boot on RAID-1 RAIDframe set
with the limitation that the FFS filesystem had to start at bloc 0 in the
RAID. That allowed inner RAID partitionning with a disklabel, but not with
a GPT.

When booting on a RAID-1 RAIDframe, primary bootstrap now first try a
filesystem at bloc 0 of the RAID as before. On failure, it tries to
read a GPT and load secondary bootstrap from, by priority;
1) the first partition with the bootme attribute set
2) the first partition of type FFS, LFS, CCD or CGD
3) the first partition present in the GPT


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/i386/stand/bootxx/boot1.c

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



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

2023-06-20 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Tue Jun 20 07:46:03 UTC 2023

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

Log Message:
``int i'' is used only for SUPPORT_NFS || SUPPORT_TFTP.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 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.



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

2023-06-20 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Tue Jun 20 07:46:03 UTC 2023

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

Log Message:
``int i'' is used only for SUPPORT_NFS || SUPPORT_TFTP.


To generate a diff of this commit:
cvs rdiff -u -r1.13 -r1.14 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.13 src/sys/arch/i386/stand/efiboot/devopen.c:1.14
--- src/sys/arch/i386/stand/efiboot/devopen.c:1.13	Mon Dec 27 12:19:27 2021
+++ src/sys/arch/i386/stand/efiboot/devopen.c	Tue Jun 20 07:46:03 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: devopen.c,v 1.13 2021/12/27 12:19:27 simonb Exp $	 */
+/*	$NetBSD: devopen.c,v 1.14 2023/06/20 07:46:03 rin Exp $	 */
 
 /*-
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -154,13 +154,13 @@ devopen(struct open_file *f, const char 
 	const char *xname = NULL;
 	int unit, partition;
 	int biosdev;
-	int i, error;
+	int error;
 #if defined(SUPPORT_NFS) || defined(SUPPORT_TFTP)
 	struct devdesc desc;
 	const struct netboot_fstab *nf;
 	char *filename;
 	size_t fsnamelen;
-	int n;
+	int i, n;
 #endif
 
 	error = parsebootfile(fname, , , , ,



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

2023-06-18 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Jun 19 04:30:27 UTC 2023

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

Log Message:
whitespace -> tab, blank line, no binary changes.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 \
src/sys/arch/i386/stand/efiboot/bootia32/efibootia32.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/bootia32/efibootia32.c
diff -u src/sys/arch/i386/stand/efiboot/bootia32/efibootia32.c:1.7 src/sys/arch/i386/stand/efiboot/bootia32/efibootia32.c:1.8
--- src/sys/arch/i386/stand/efiboot/bootia32/efibootia32.c:1.7	Sun May 14 09:07:54 2023
+++ src/sys/arch/i386/stand/efiboot/bootia32/efibootia32.c	Mon Jun 19 04:30:27 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: efibootia32.c,v 1.7 2023/05/14 09:07:54 riastradh Exp $	*/
+/*	$NetBSD: efibootia32.c,v 1.8 2023/06/19 04:30:27 rin Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -57,16 +57,15 @@ efi_md_init(void)
 	startprog32 = (void *)(u_long)addr;
 	CopyMem(startprog32, startprog32_start, startprog32_size);
 
-addr = EFI_ALLOCATE_MAX_ADDRESS;
-sz = EFI_SIZE_TO_PAGES(multiboot32_size);
-status = uefi_call_wrapper(BS->AllocatePages, 4, AllocateMaxAddress,
-EfiLoaderData, sz, );
-if (EFI_ERROR(status))
-panic("%s: AllocatePages() failed: %d page(s): %" PRIxMAX,
-__func__, sz, (uintmax_t)status);
-multiboot32 = (void *)(u_long)addr;
-CopyMem(multiboot32, multiboot32_start, multiboot32_size);
-
+	addr = EFI_ALLOCATE_MAX_ADDRESS;
+	sz = EFI_SIZE_TO_PAGES(multiboot32_size);
+	status = uefi_call_wrapper(BS->AllocatePages, 4, AllocateMaxAddress,
+	EfiLoaderData, sz, );
+	if (EFI_ERROR(status))
+		panic("%s: AllocatePages() failed: %d page(s): %" PRIxMAX,
+		__func__, sz, (uintmax_t)status);
+	multiboot32 = (void *)(u_long)addr;
+	CopyMem(multiboot32, multiboot32_start, multiboot32_size);
 }
 
 /* ARGSUSED */



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

2023-06-18 Thread Rin Okuyama
Module Name:src
Committed By:   rin
Date:   Mon Jun 19 04:30:27 UTC 2023

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

Log Message:
whitespace -> tab, blank line, no binary changes.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 \
src/sys/arch/i386/stand/efiboot/bootia32/efibootia32.c

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



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

2023-05-14 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 14 09:07:54 UTC 2023

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

Log Message:
x86/efiboot: Nix trailing whitespace.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/i386/stand/efiboot/boot.c
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/i386/stand/efiboot/efidisk.c \
src/sys/arch/i386/stand/efiboot/efimemory.c
cvs rdiff -u -r1.6 -r1.7 \
src/sys/arch/i386/stand/efiboot/bootia32/efibootia32.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.22 src/sys/arch/i386/stand/efiboot/boot.c:1.23
--- src/sys/arch/i386/stand/efiboot/boot.c:1.22	Thu Apr 20 00:42:24 2023
+++ src/sys/arch/i386/stand/efiboot/boot.c	Sun May 14 09:07:54 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: boot.c,v 1.22 2023/04/20 00:42:24 manu Exp $	*/
+/*	$NetBSD: boot.c,v 1.23 2023/05/14 09:07:54 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -483,7 +483,7 @@ command_dev(char *arg)
 	if (*arg == '\0') {
 		efi_disk_show();
 		efi_net_show();
-	
+
 		if (default_part_name != NULL)
 			printf("default NAME=%s\n", default_part_name);
 		else
@@ -647,7 +647,7 @@ void
 command_reloc(char *arg)
 {
 	char *ep;
-	
+
 	if (*arg == '\0') {
 		switch (efi_reloc_type) {
 		case RELOC_NONE:

Index: src/sys/arch/i386/stand/efiboot/efidisk.c
diff -u src/sys/arch/i386/stand/efiboot/efidisk.c:1.9 src/sys/arch/i386/stand/efiboot/efidisk.c:1.10
--- src/sys/arch/i386/stand/efiboot/efidisk.c:1.9	Tue Dec 17 01:37:52 2019
+++ src/sys/arch/i386/stand/efiboot/efidisk.c	Sun May 14 09:07:54 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: efidisk.c,v 1.9 2019/12/17 01:37:52 manu Exp $	*/
+/*	$NetBSD: efidisk.c,v 1.10 2023/05/14 09:07:54 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -70,9 +70,9 @@ dealloc_biosdisk_part(struct biosdisk_pa
 			part[i].part_name = NULL;
 		}
 	}
-	
+
 	dealloc(part, sizeof(*part) * nparts);
-	
+
 	return;
 }
 
@@ -194,7 +194,6 @@ efi_raidframe_probe(struct efi_raidframe
 	return;
 }
 
-
 void
 efi_disk_show(void)
 {
@@ -293,7 +292,7 @@ efi_disk_show(void)
 		raidframe[i].size,
 		, ))
 			continue;
-			
+
 		first = 1;
 		for (j = 0; j < nparts; j++) {
 			bool bootme = part[j].attr & GPT_ENT_ATTR_BOOTME;
Index: src/sys/arch/i386/stand/efiboot/efimemory.c
diff -u src/sys/arch/i386/stand/efiboot/efimemory.c:1.9 src/sys/arch/i386/stand/efiboot/efimemory.c:1.10
--- src/sys/arch/i386/stand/efiboot/efimemory.c:1.9	Fri Sep 13 02:19:45 2019
+++ src/sys/arch/i386/stand/efiboot/efimemory.c	Sun May 14 09:07:54 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: efimemory.c,v 1.9 2019/09/13 02:19:45 manu Exp $	*/
+/*	$NetBSD: efimemory.c,v 1.10 2023/05/14 09:07:54 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -221,7 +221,7 @@ efi_memory_get_memmap(struct bi_memmap_e
 
 		next = NextMemoryDescriptor(md, DescriptorSize);
 	}
-	
+
 	*memmapp = memmap;
 	*num = NoEntries;
 	return 0;

Index: src/sys/arch/i386/stand/efiboot/bootia32/efibootia32.c
diff -u src/sys/arch/i386/stand/efiboot/bootia32/efibootia32.c:1.6 src/sys/arch/i386/stand/efiboot/bootia32/efibootia32.c:1.7
--- src/sys/arch/i386/stand/efiboot/bootia32/efibootia32.c:1.6	Thu Apr 20 00:42:24 2023
+++ src/sys/arch/i386/stand/efiboot/bootia32/efibootia32.c	Sun May 14 09:07:54 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: efibootia32.c,v 1.6 2023/04/20 00:42:24 manu Exp $	*/
+/*	$NetBSD: efibootia32.c,v 1.7 2023/05/14 09:07:54 riastradh Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -60,7 +60,7 @@ efi_md_init(void)
 addr = EFI_ALLOCATE_MAX_ADDRESS;
 sz = EFI_SIZE_TO_PAGES(multiboot32_size);
 status = uefi_call_wrapper(BS->AllocatePages, 4, AllocateMaxAddress,
-EfiLoaderData, sz, ); 
+EfiLoaderData, sz, );
 if (EFI_ERROR(status))
 panic("%s: AllocatePages() failed: %d page(s): %" PRIxMAX,
 __func__, sz, (uintmax_t)status);



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

2023-05-14 Thread Taylor R Campbell
Module Name:src
Committed By:   riastradh
Date:   Sun May 14 09:07:54 UTC 2023

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

Log Message:
x86/efiboot: Nix trailing whitespace.


To generate a diff of this commit:
cvs rdiff -u -r1.22 -r1.23 src/sys/arch/i386/stand/efiboot/boot.c
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/i386/stand/efiboot/efidisk.c \
src/sys/arch/i386/stand/efiboot/efimemory.c
cvs rdiff -u -r1.6 -r1.7 \
src/sys/arch/i386/stand/efiboot/bootia32/efibootia32.c

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



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

2023-05-09 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Wed May 10 00:49:17 UTC 2023

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

Log Message:
Raise the version for new feature (here reloc command)
Suggested by Masanobu SAITOH


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/i386/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/arch/i386/stand/efiboot/version
diff -u src/sys/arch/i386/stand/efiboot/version:1.2 src/sys/arch/i386/stand/efiboot/version:1.3
--- src/sys/arch/i386/stand/efiboot/version:1.2	Sat Aug  3 08:13:36 2019
+++ src/sys/arch/i386/stand/efiboot/version	Wed May 10 00:49:17 2023
@@ -1,4 +1,4 @@
-$NetBSD: version,v 1.2 2019/08/03 08:13:36 nonaka Exp $
+$NetBSD: version,v 1.3 2023/05/10 00:49:17 manu 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
@@ -6,3 +6,4 @@ is taken as the current.
 
 1.0:	Initial version.
 1.1:	Add CD/DVD-ROM, serial, PXE boot and UEFI memory map compaction support.
+1.2:	Add reloc command



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

2023-05-09 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Wed May 10 00:49:17 UTC 2023

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

Log Message:
Raise the version for new feature (here reloc command)
Suggested by Masanobu SAITOH


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/i386/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/arch/i386/stand

2023-01-18 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Jan 18 12:28:55 UTC 2023

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

Log Message:
Fix the clang build by setting -z noseparate-code


To generate a diff of this commit:
cvs rdiff -u -r1.94 -r1.95 src/sys/arch/i386/stand/Makefile.booters

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/Makefile.booters
diff -u src/sys/arch/i386/stand/Makefile.booters:1.94 src/sys/arch/i386/stand/Makefile.booters:1.95
--- src/sys/arch/i386/stand/Makefile.booters:1.94	Sun Sep  6 03:20:28 2020
+++ src/sys/arch/i386/stand/Makefile.booters	Wed Jan 18 07:28:54 2023
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.booters,v 1.94 2020/09/06 07:20:28 mrg Exp $
+#	$NetBSD: Makefile.booters,v 1.95 2023/01/18 12:28:54 christos Exp $
 
 NOLIBCSANITIZER=
 NOSANITIZER=
@@ -77,7 +77,7 @@ cleandir distclean: .WAIT cleanlibdir
 cleanlibdir:
 	-rm -rf lib
 
-LDFLAGS+=-Wl,-M -Wl,-e,start 	# -N does not work properly.
+LDFLAGS+=-Wl,-z,noseparate-code -Wl,-M -Wl,-e,start 	# -N does not work properly.
 
 LIBLIST=${LIBI386} ${LIBSA} ${LIBZ} ${LIBSA} ${LIBKERN} ${LIBI386} ${LIBSA}
 



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

2023-01-18 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Jan 18 12:28:55 UTC 2023

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

Log Message:
Fix the clang build by setting -z noseparate-code


To generate a diff of this commit:
cvs rdiff -u -r1.94 -r1.95 src/sys/arch/i386/stand/Makefile.booters

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



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

2022-12-25 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Dec 25 22:14:05 UTC 2022

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

Log Message:
Fix broken flag -nocombreloc, 2.34 did not complain for not understanding it,
but 2.39 wants -z nocombreloc. Is it really needed?


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 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.



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

2022-12-25 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Dec 25 22:14:05 UTC 2022

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

Log Message:
Fix broken flag -nocombreloc, 2.34 did not complain for not understanding it,
but 2.39 wants -z nocombreloc. Is it really needed?


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 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.19 src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.20
--- src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.19	Thu Nov 18 11:17:40 2021
+++ src/sys/arch/i386/stand/efiboot/Makefile.efiboot	Sun Dec 25 17:14:05 2022
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.efiboot,v 1.19 2021/11/18 16:17:40 manu Exp $
+# $NetBSD: Makefile.efiboot,v 1.20 2022/12/25 22:14:05 christos Exp $
 
 S=		${.CURDIR}/../../../../..
 
@@ -41,8 +41,8 @@ BINMODE=444
 .PATH:	${.CURDIR}/../../libsa
 
 LDSCRIPT?= ${.CURDIR}/ldscript
-LDFLAGS+= --no-dynamic-linker --noinhibit-exec
-LDFLAGS+= -nostdlib -T${LDSCRIPT} -Bsymbolic -shared -nocombreloc
+LDFLAGS+= --no-dynamic-linker --noinhibit-exec -z nocombreloc
+LDFLAGS+= -nostdlib -T${LDSCRIPT} -Bsymbolic -shared
 CPPFLAGS+= -I$S -I${.CURDIR} -I${.CURDIR}/.. -I$S/lib/libsa
 CPPFLAGS+= -I${.OBJDIR}
 CPPFLAGS+= -I${.CURDIR}/../../lib



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

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

Modified Files:
src/sys/arch/i386/stand/lib: exec.c

Log Message:
i386/stand: 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.77 -r1.78 src/sys/arch/i386/stand/lib/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/arch/i386/stand/lib/exec.c
diff -u src/sys/arch/i386/stand/lib/exec.c:1.77 src/sys/arch/i386/stand/lib/exec.c:1.78
--- src/sys/arch/i386/stand/lib/exec.c:1.77	Sun May 30 05:59:23 2021
+++ src/sys/arch/i386/stand/lib/exec.c	Wed Sep 21 14:29:45 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: exec.c,v 1.77 2021/05/30 05:59:23 mlelstv Exp $	 */
+/*	$NetBSD: exec.c,v 1.78 2022/09/21 14:29:45 riastradh Exp $	 */
 
 /*
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -684,7 +684,7 @@ module_base_path(char *buf, size_t bufsi
 		"/stand/%s/%d.%d.%d/modules", machine,
 		netbsd_version / 1,
 		netbsd_version / 100 % 100,
-		netbsd_version / 100 % 100);
+		netbsd_version / 100 % 1);
 	} else if (netbsd_version != 0) {
 		/* release */
 		snprintf(buf, bufsize,



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

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

Modified Files:
src/sys/arch/i386/stand/lib: exec.c

Log Message:
i386/stand: 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.77 -r1.78 src/sys/arch/i386/stand/lib/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/arch/i386/stand

2022-06-08 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Wed Jun  8 21:43:45 UTC 2022

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

Log Message:
Do not use default entry's parameters for for plain "boot" command

Go back to the "menu" instead of you want that.

Patch from RVP in PR 56862, ok uwe@


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.79 src/sys/arch/i386/stand/boot/boot2.c
cvs rdiff -u -r1.20 -r1.21 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/boot/boot2.c
diff -u src/sys/arch/i386/stand/boot/boot2.c:1.78 src/sys/arch/i386/stand/boot/boot2.c:1.79
--- src/sys/arch/i386/stand/boot/boot2.c:1.78	Tue Sep  7 11:41:31 2021
+++ src/sys/arch/i386/stand/boot/boot2.c	Wed Jun  8 21:43:45 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: boot2.c,v 1.78 2021/09/07 11:41:31 nia Exp $	*/
+/*	$NetBSD: boot2.c,v 1.79 2022/06/08 21:43:45 wiz Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -488,10 +488,6 @@ command_boot(char *arg)
 	} else {
 		int i;
 
-#ifndef SMALL
-		if (howto == 0)
-			bootdefault();
-#endif
 		for (i = 0; i < NUMNAMES; i++) {
 			bootit(names[i][0], howto);
 			bootit(names[i][1], howto);

Index: src/sys/arch/i386/stand/efiboot/boot.c
diff -u src/sys/arch/i386/stand/efiboot/boot.c:1.20 src/sys/arch/i386/stand/efiboot/boot.c:1.21
--- src/sys/arch/i386/stand/efiboot/boot.c:1.20	Tue Sep  7 11:41:31 2021
+++ src/sys/arch/i386/stand/efiboot/boot.c	Wed Jun  8 21:43:45 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: boot.c,v 1.20 2021/09/07 11:41:31 nia Exp $	*/
+/*	$NetBSD: boot.c,v 1.21 2022/06/08 21:43:45 wiz Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -453,8 +453,6 @@ command_boot(char *arg)
 	} else {
 		int i;
 
-		if (howto == 0)
-			bootdefault();
 		for (i = 0; i < NUMNAMES; i++) {
 			bootit(names[i][0], howto);
 			bootit(names[i][1], howto);



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

2022-06-08 Thread Thomas Klausner
Module Name:src
Committed By:   wiz
Date:   Wed Jun  8 21:43:45 UTC 2022

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

Log Message:
Do not use default entry's parameters for for plain "boot" command

Go back to the "menu" instead of you want that.

Patch from RVP in PR 56862, ok uwe@


To generate a diff of this commit:
cvs rdiff -u -r1.78 -r1.79 src/sys/arch/i386/stand/boot/boot2.c
cvs rdiff -u -r1.20 -r1.21 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.



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

2022-05-03 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue May  3 10:09:40 UTC 2022

Modified Files:
src/sys/arch/i386/stand/lib: biosdisk.c

Log Message:
Trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/sys/arch/i386/stand/lib/biosdisk.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/lib/biosdisk.c
diff -u src/sys/arch/i386/stand/lib/biosdisk.c:1.57 src/sys/arch/i386/stand/lib/biosdisk.c:1.58
--- src/sys/arch/i386/stand/lib/biosdisk.c:1.57	Tue Dec 28 00:37:16 2021
+++ src/sys/arch/i386/stand/lib/biosdisk.c	Tue May  3 10:09:40 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: biosdisk.c,v 1.57 2021/12/28 00:37:16 simonb Exp $	*/
+/*	$NetBSD: biosdisk.c,v 1.58 2022/05/03 10:09:40 jmcneill Exp $	*/
 
 /*
  * Copyright (c) 1996, 1998
@@ -544,7 +544,7 @@ ingest_label(struct biosdisk *d, struct 
 		d->part[part].size = lp->d_partitions[part].p_size;
 	}
 }
-	
+
 static int
 check_label(struct biosdisk *d, daddr_t sector)
 {
@@ -787,7 +787,6 @@ read_partitions(struct biosdisk *d, dadd
 #endif
 #ifndef NO_DISKLABEL
 	error = read_label(d, offset);
-	
 #endif
 	return error;
 }
@@ -893,7 +892,7 @@ biosdisk_probe(void)
 
 		if (read_partitions(d, 0, 0) != 0)
 			goto next_disk;
-			
+
 		for (part = 0; part < BIOSDISKNPART; part++) {
 			if (d->part[part].size == 0)
 continue;
@@ -969,7 +968,7 @@ next_disk:
 		raidframe[i].offset + RF_PROTECTED_SECTORS,
 		raidframe[i].size) != 0)
 			goto next_raidrame;
-			
+
 		first = 1;
 		for (part = 0; part < BIOSDISKNPART; part++) {
 #ifndef NO_GPT
@@ -1240,7 +1239,7 @@ raidframe_part_offset(struct biosdisk *d
 	return RF_PROTECTED_SECTORS + raidframe.part[candidate].offset;
 }
 #endif
-	
+
 int
 biosdisk_open(struct open_file *f, ...)
 /* struct open_file *f, int biosdev, int partition */
@@ -1356,7 +1355,7 @@ biosdisk_find_name(const char *fname, in
 
 		if (read_partitions(d, 0, 0) != 0)
 			goto next_disk;
-			
+
 		for (part = 0; part < BIOSDISKNPART; part++) {
 			if (d->part[part].size == 0)
 continue;
@@ -1401,7 +1400,7 @@ next_disk:
 		raidframe[i].offset + RF_PROTECTED_SECTORS,
 		raidframe[i].size) != 0)
 			goto next_raidframe;
-			
+
 		for (part = 0; part < BIOSDISKNPART; part++) {
 			bool bootme = d->part[part].attr & GPT_ENT_ATTR_BOOTME;
 			if (d->part[part].size == 0)
@@ -1499,7 +1498,7 @@ biosdisk_find_raid(const char *name, int
 
 		if (read_partitions(d, 0, 0) != 0)
 			goto next_disk;
-			
+
 		for (part = 0; part < BIOSDISKNPART; part++) {
 			if (d->part[part].size == 0)
 continue;
@@ -1527,7 +1526,7 @@ next_disk:
 		raidframe[i].offset + RF_PROTECTED_SECTORS,
 		raidframe[i].size) != 0)
 			goto next_raidframe;
-			
+
 		for (part = 0; part < BIOSDISKNPART; part++) {
 			if (d->part[part].size == 0)
 continue;



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

2022-05-03 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue May  3 10:09:40 UTC 2022

Modified Files:
src/sys/arch/i386/stand/lib: biosdisk.c

Log Message:
Trailing whitespace


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 src/sys/arch/i386/stand/lib/biosdisk.c

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



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

2022-04-01 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Fri Apr  1 19:02:12 UTC 2022

Modified Files:
src/sys/arch/i386/stand/lib: realprot.S

Log Message:
s/potected/protected and s/investication/investigation/ in comments.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/i386/stand/lib/realprot.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/lib/realprot.S
diff -u src/sys/arch/i386/stand/lib/realprot.S:1.11 src/sys/arch/i386/stand/lib/realprot.S:1.12
--- src/sys/arch/i386/stand/lib/realprot.S:1.11	Tue Dec 24 19:00:56 2013
+++ src/sys/arch/i386/stand/lib/realprot.S	Fri Apr  1 19:02:12 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: realprot.S,v 1.11 2013/12/24 19:00:56 jakllsch Exp $	*/
+/*	$NetBSD: realprot.S,v 1.12 2022/04/01 19:02:12 andvar Exp $	*/
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -188,7 +188,7 @@ ENTRY(real_to_prot)
  *
  * It is speculated that the CPU is prefetching and decoding branch
  * targets and not invalidating this buffer on the long jump.
- * Further investication indicates that the caching of return addresses
+ * Further investigation indicates that the caching of return addresses
  * is most likely the problem.
  *
  * Previous versions just used some extra call/ret and a few NOPs, these
@@ -229,7 +229,7 @@ ENTRY(prot_to_real)
 	.code16
 	movl	%cr0, %eax
 	and 	$~CR0_PE, %eax
-	movl	%eax, %cr0		/* Disable potected mode */
+	movl	%eax, %cr0		/* Disable protected mode */
 
 	/* Jump far indirect to load real mode %cs */
 	ljmp	*%cs:toreal



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

2022-04-01 Thread Andrius Varanavicius
Module Name:src
Committed By:   andvar
Date:   Fri Apr  1 19:02:12 UTC 2022

Modified Files:
src/sys/arch/i386/stand/lib: realprot.S

Log Message:
s/potected/protected and s/investication/investigation/ in comments.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/i386/stand/lib/realprot.S

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



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

2022-03-06 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Mar  6 18:35:43 UTC 2022

Modified Files:
src/sys/arch/i386/stand/bootxx: bootxx.S

Log Message:
pass errno through switch to protected mode.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/i386/stand/bootxx/bootxx.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/bootxx/bootxx.S
diff -u src/sys/arch/i386/stand/bootxx/bootxx.S:1.11 src/sys/arch/i386/stand/bootxx/bootxx.S:1.12
--- src/sys/arch/i386/stand/bootxx/bootxx.S:1.11	Thu Jul 11 03:49:51 2019
+++ src/sys/arch/i386/stand/bootxx/bootxx.S	Sun Mar  6 18:35:43 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: bootxx.S,v 1.11 2019/07/11 03:49:51 msaitoh Exp $	*/
+/*	$NetBSD: bootxx.S,v 1.12 2022/03/06 18:35:43 mlelstv Exp $	*/
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -79,6 +79,7 @@ boot_params:/* space for patchable v
 	push	%edx
 	call	_C_LABEL(boot1)		/* C code to load /boot */
 	add	$8, %esp
+	movw	errno, %dx
 	call	prot_to_real
 	.code16
 
@@ -94,7 +95,7 @@ boot_params:/* space for patchable v
 
 boot_fail:
 	push	%ax			/* error string from boot1 */
-	movw	errno, %ax
+	movw	%dx, %ax
 	aam/* largest errno is < 100 */
 	addw	$('0' << 8) | '0', %ax	/* to ascii */
 	rorw	$8, %ax



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

2022-03-06 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Sun Mar  6 18:35:43 UTC 2022

Modified Files:
src/sys/arch/i386/stand/bootxx: bootxx.S

Log Message:
pass errno through switch to protected mode.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/i386/stand/bootxx/bootxx.S

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



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

2021-12-27 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Tue Dec 28 00:37:16 UTC 2021

Modified Files:
src/sys/arch/i386/stand/lib: biosdisk.c

Log Message:
In biosdisk_findpartition() check if part_name isn't NULL before
assigning *part_name.

Thanks to manu@ for the pointer.


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/sys/arch/i386/stand/lib/biosdisk.c

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



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

2021-12-27 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Tue Dec 28 00:37:16 UTC 2021

Modified Files:
src/sys/arch/i386/stand/lib: biosdisk.c

Log Message:
In biosdisk_findpartition() check if part_name isn't NULL before
assigning *part_name.

Thanks to manu@ for the pointer.


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 src/sys/arch/i386/stand/lib/biosdisk.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/lib/biosdisk.c
diff -u src/sys/arch/i386/stand/lib/biosdisk.c:1.56 src/sys/arch/i386/stand/lib/biosdisk.c:1.57
--- src/sys/arch/i386/stand/lib/biosdisk.c:1.56	Tue Dec 28 00:34:30 2021
+++ src/sys/arch/i386/stand/lib/biosdisk.c	Tue Dec 28 00:37:16 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: biosdisk.c,v 1.56 2021/12/28 00:34:30 simonb Exp $	*/
+/*	$NetBSD: biosdisk.c,v 1.57 2021/12/28 00:37:16 simonb Exp $	*/
 
 /*
  * Copyright (c) 1996, 1998
@@ -1028,7 +1028,8 @@ biosdisk_findpartition(int biosdev, dadd
 {
 #if defined(NO_DISKLABEL) && defined(NO_GPT)
 	*partition = 0;
-	*part_name = NULL;
+	if (part_name)
+		*part_name = NULL;
 	return 0;
 #else
 	int i;
@@ -1047,7 +1048,8 @@ biosdisk_findpartition(int biosdev, dadd
 
 	/* default to first partition */
 	*partition = 0;
-	*part_name = NULL;
+	if (part_name)
+		*part_name = NULL;
 
 	/* Look for netbsd partition that is the dos boot one */
 	d = alloc_biosdisk(biosdev);



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

2021-12-27 Thread Simon Burge
Emmanuel Dreyfus wrote:

> In src/sys/arch/i386/stand/lib/biosdisk.c
> int
> biosdisk_findpartition(int biosdev, daddr_t sector,
>int *partition, const char **part_name)
> {
> (...)
> /* default ot first partition */
> *partition = 0;
> *part_name = NULL;
>
> part_name is NULL, *part_name crashes. How do you avoid that?

Aha, I have this elsewhere in my zfs tree:

*partition = 0;
-   *part_name = NULL;
+   if (part_name)
+   *part_name = NULL;

I'll commit that now (as well as the same check for the
NO_DISKLABEL && NO_GPT case.  Thanks for the digging!

Cheers,
Simon.


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

2021-12-27 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Tue Dec 28 00:34:30 UTC 2021

Modified Files:
src/sys/arch/i386/stand/lib: biosdisk.c

Log Message:
Fix a tyop.


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/sys/arch/i386/stand/lib/biosdisk.c

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



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

2021-12-27 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Tue Dec 28 00:34:30 UTC 2021

Modified Files:
src/sys/arch/i386/stand/lib: biosdisk.c

Log Message:
Fix a tyop.


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 src/sys/arch/i386/stand/lib/biosdisk.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/lib/biosdisk.c
diff -u src/sys/arch/i386/stand/lib/biosdisk.c:1.55 src/sys/arch/i386/stand/lib/biosdisk.c:1.56
--- src/sys/arch/i386/stand/lib/biosdisk.c:1.55	Sun May 30 05:59:23 2021
+++ src/sys/arch/i386/stand/lib/biosdisk.c	Tue Dec 28 00:34:30 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: biosdisk.c,v 1.55 2021/05/30 05:59:23 mlelstv Exp $	*/
+/*	$NetBSD: biosdisk.c,v 1.56 2021/12/28 00:34:30 simonb Exp $	*/
 
 /*
  * Copyright (c) 1996, 1998
@@ -1045,7 +1045,7 @@ biosdisk_findpartition(int biosdev, dadd
 	printf("looking for partition device %x, sector %"PRId64"\n", biosdev, sector);
 #endif
 
-	/* default ot first partition */
+	/* default to first partition */
 	*partition = 0;
 	*part_name = NULL;
 



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

2021-12-27 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Mon Dec 27 12:19:27 UTC 2021

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

Log Message:
Revert rev 1.12 of devopen.c.  This had the unintented side effect
of breaking opens on non-root filesystems (eg trying to open/read
"esp:/EFI/NetBSD/boot.cfg" on the EFI system partition).

Ok manu@.  Original problem to be re-addressed.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 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.12 src/sys/arch/i386/stand/efiboot/devopen.c:1.13
--- src/sys/arch/i386/stand/efiboot/devopen.c:1.12	Thu Nov 18 16:18:13 2021
+++ src/sys/arch/i386/stand/efiboot/devopen.c	Mon Dec 27 12:19:27 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: devopen.c,v 1.12 2021/11/18 16:18:13 manu Exp $	 */
+/*	$NetBSD: devopen.c,v 1.13 2021/12/27 12:19:27 simonb Exp $	 */
 
 /*-
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -288,9 +288,8 @@ neterr:
 	 * biosdisk
 	 */
 	if (strcmp(devname, "esp") == 0) {
-		const char *part_name = NULL;
 		bios2dev(boot_biosdev, boot_biossector, , ,
-		, _name);
+		, NULL);
 		if (efidisk_get_efi_system_partition(boot_biosdev, ))
 			return ENXIO;
 	}



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

2021-12-27 Thread Simon Burge
Module Name:src
Committed By:   simonb
Date:   Mon Dec 27 12:19:27 UTC 2021

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

Log Message:
Revert rev 1.12 of devopen.c.  This had the unintented side effect
of breaking opens on non-root filesystems (eg trying to open/read
"esp:/EFI/NetBSD/boot.cfg" on the EFI system partition).

Ok manu@.  Original problem to be re-addressed.


To generate a diff of this commit:
cvs rdiff -u -r1.12 -r1.13 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.



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

2021-12-27 Thread Simon Burge
Emmanuel Dreyfus wrote:

> On Mon, Dec 27, 2021 at 01:08:15PM +1100, Simon Burge wrote:
> > What crash did this fix?  All the use of part_name by the
> > called functions should check if it is NULL before trying
> > to assign anything to *part_name.
>
> I do not recall the details now, but I had a crash because
> of this. Please revert my change, I will get back to it when
> I find some time.

Thanks.  I'll revert that now.

If you have a way of preproducing this, I'm happy to have a look.

Cheers,
Simon.


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

2021-12-26 Thread Emmanuel Dreyfus
On Mon, Dec 27, 2021 at 01:08:15PM +1100, Simon Burge wrote:
> What crash did this fix?  All the use of part_name by the
> called functions should check if it is NULL before trying
> to assign anything to *part_name.

I do not recall the details now, but I had a crash because
of this. Please revert my change, I will get back to it when
I find some time.

-- 
Emmanuel Dreyfus
m...@netbsd.org


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

2021-12-26 Thread Simon Burge
Hi Emmanuel,

"Emmanuel Dreyfus" wrote:

> Module Name:  src
> Committed By: manu
> Date: Thu Nov 18 16:18:13 UTC 2021
>
> Modified Files:
>
>   src/sys/arch/i386/stand/efiboot: devopen.c
>
> Log Message:
>
> Fix crash because of NULL pointer reference

What crash did this fix?  All the use of part_name by the
called functions should check if it is NULL before trying
to assign anything to *part_name.

This change has broken loading boot.cfg via the EFI path
"esp:/EFI/NetBSD/boot.cfg" since the call to bios_boot() at
https://nxr.netbsd.org/xref/src/sys/arch/i386/stand/efiboot/devopen.c#292
with a non-NULL last argument means devname gets updated and
now points to the partition with a root filesystem rather
than the EFI system partition.

Cheers,
Simon.


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

2021-11-18 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Thu Nov 18 16:18:13 UTC 2021

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

Log Message:
Fix crash because of NULL pointer reference


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 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.11 src/sys/arch/i386/stand/efiboot/devopen.c:1.12
--- src/sys/arch/i386/stand/efiboot/devopen.c:1.11	Sat Jan 18 19:25:58 2020
+++ src/sys/arch/i386/stand/efiboot/devopen.c	Thu Nov 18 16:18:13 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: devopen.c,v 1.11 2020/01/18 19:25:58 nonaka Exp $	 */
+/*	$NetBSD: devopen.c,v 1.12 2021/11/18 16:18:13 manu Exp $	 */
 
 /*-
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -288,8 +288,9 @@ neterr:
 	 * biosdisk
 	 */
 	if (strcmp(devname, "esp") == 0) {
+		const char *part_name = NULL;
 		bios2dev(boot_biosdev, boot_biossector, , ,
-		, NULL);
+		, _name);
 		if (efidisk_get_efi_system_partition(boot_biosdev, ))
 			return ENXIO;
 	}



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

2021-11-18 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Thu Nov 18 16:18:13 UTC 2021

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

Log Message:
Fix crash because of NULL pointer reference


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 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.



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

2021-11-18 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Thu Nov 18 16:17:41 UTC 2021

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

Log Message:
Do not pass BIOS geometry when booting using EFI

Recent Mac return garbage data that will crash the code handling it,
and EFI boot does not need it anyway.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 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.



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

2021-11-18 Thread Emmanuel Dreyfus
Module Name:src
Committed By:   manu
Date:   Thu Nov 18 16:17:41 UTC 2021

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

Log Message:
Do not pass BIOS geometry when booting using EFI

Recent Mac return garbage data that will crash the code handling it,
and EFI boot does not need it anyway.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 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.18 src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.19
--- src/sys/arch/i386/stand/efiboot/Makefile.efiboot:1.18	Sun Sep  6 07:20:29 2020
+++ src/sys/arch/i386/stand/efiboot/Makefile.efiboot	Thu Nov 18 16:17:40 2021
@@ -1,4 +1,4 @@
-# $NetBSD: Makefile.efiboot,v 1.18 2020/09/06 07:20:29 mrg Exp $
+# $NetBSD: Makefile.efiboot,v 1.19 2021/11/18 16:17:40 manu Exp $
 
 S=		${.CURDIR}/../../../../..
 
@@ -66,7 +66,8 @@ CPPFLAGS+= -DSUPPORT_BOOTP
 CPPFLAGS+= -DSUPPORT_DHCP
 CPPFLAGS+= -DSUPPORT_NFS
 CPPFLAGS+= -DSUPPORT_TFTP
-CPPFLAGS+= -DPASS_BIOSGEOM
+# Recent macs report garbage geometry
+#CPPFLAGS+= -DPASS_BIOSGEOM
 CPPFLAGS+= -DBIOSDISK_DEFAULT_SECSIZE=2048	# for bootinfo_biosgeom.c
 CPPFLAGS+= -DLIBSA_ENABLE_LS_OP
 



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

2021-10-28 Thread Kimmo Suominen
Module Name:src
Committed By:   kim
Date:   Thu Oct 28 06:13:13 UTC 2021

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

Log Message:
Make "0 seconds" overwrite the countdown also when enter is pressed

Fixes PR misc/56486.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 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.11 src/sys/arch/i386/stand/efiboot/eficons.c:1.12
--- src/sys/arch/i386/stand/efiboot/eficons.c:1.11	Sat Feb 22 10:30:37 2020
+++ src/sys/arch/i386/stand/efiboot/eficons.c	Thu Oct 28 06:13:13 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: eficons.c,v 1.11 2020/02/22 10:30:37 jmcneill Exp $	*/
+/*	$NetBSD: eficons.c,v 1.12 2021/10/28 06:13:13 kim Exp $	*/
 
 /*-
  * Copyright (c) 2016 Kimihiro Nonaka 
@@ -355,7 +355,9 @@ awaitkey(int timeout, int tell)
 c = getchar();
 			if (c == 0)
 c = -1;
-			goto out;
+			if (tell && timeout)
+printf("%s", numbuf);
+			break;
 		}
 		if (timeout--)
 			internal_waitforinputevent(1000);
@@ -365,7 +367,6 @@ awaitkey(int timeout, int tell)
 			printf("%s", numbuf);
 	}
 
-out:
 	if (tell)
 		printf("0 seconds. \n");
 



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

2021-10-28 Thread Kimmo Suominen
Module Name:src
Committed By:   kim
Date:   Thu Oct 28 06:13:13 UTC 2021

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

Log Message:
Make "0 seconds" overwrite the countdown also when enter is pressed

Fixes PR misc/56486.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 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.



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

2021-06-23 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Thu Jun 24 01:23:17 UTC 2021

Modified Files:
src/sys/arch/i386/stand/bootxx: boot1.c

Log Message:
boot1.c: remove a comment that's no longer relevant/correct

In r. 1.13, a check of the return value in fd was removed, and a comment
about this ("...so keep going") added. Then in r. 1.19, the fd return
value check was reinstated (as the true underlying errno could be masked
by the fstat() call), so there is no "keep going" happening anymore.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/i386/stand/bootxx/boot1.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/bootxx/boot1.c
diff -u src/sys/arch/i386/stand/bootxx/boot1.c:1.20 src/sys/arch/i386/stand/bootxx/boot1.c:1.21
--- src/sys/arch/i386/stand/bootxx/boot1.c:1.20	Thu Jan  6 01:08:48 2011
+++ src/sys/arch/i386/stand/bootxx/boot1.c	Thu Jun 24 01:23:16 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: boot1.c,v 1.20 2011/01/06 01:08:48 jakllsch Exp $	*/
+/*	$NetBSD: boot1.c,v 1.21 2021/06/24 01:23:16 gutteridge Exp $	*/
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
  */
 
 #include 
-__RCSID("$NetBSD: boot1.c,v 1.20 2011/01/06 01:08:48 jakllsch Exp $");
+__RCSID("$NetBSD: boot1.c,v 1.21 2021/06/24 01:23:16 gutteridge Exp $");
 
 #include 
 #include 
@@ -106,7 +106,6 @@ boot1(uint32_t biosdev, uint64_t *sector
 	fd = ob();
 
 done:
-	/* if we fail here, so will fstat, so keep going */
 	if (fd == -1 || fstat(fd, ) == -1)
 		return "Can't open /boot\r\n";
 



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

2021-06-23 Thread David H. Gutteridge
Module Name:src
Committed By:   gutteridge
Date:   Thu Jun 24 01:23:17 UTC 2021

Modified Files:
src/sys/arch/i386/stand/bootxx: boot1.c

Log Message:
boot1.c: remove a comment that's no longer relevant/correct

In r. 1.13, a check of the return value in fd was removed, and a comment
about this ("...so keep going") added. Then in r. 1.19, the fd return
value check was reinstated (as the true underlying errno could be masked
by the fstat() call), so there is no "keep going" happening anymore.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/i386/stand/bootxx/boot1.c

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



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

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.



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

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

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

Log Message:
use a single printf call for readability


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/sys/arch/i386/stand/boot/boot2.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/boot/boot2.c
diff -u src/sys/arch/i386/stand/boot/boot2.c:1.76 src/sys/arch/i386/stand/boot/boot2.c:1.77
--- src/sys/arch/i386/stand/boot/boot2.c:1.76	Mon Jun 21 19:43:17 2021
+++ src/sys/arch/i386/stand/boot/boot2.c	Mon Jun 21 19:52:17 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: boot2.c,v 1.76 2021/06/21 19:43:17 nia Exp $	*/
+/*	$NetBSD: boot2.c,v 1.77 2021/06/21 19:52:17 nia Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -311,16 +311,17 @@ print_banner(void)
 			printf("%s\n", bootcfg_info.banner[n]);
 	} else {
 #endif /* !SMALL */
-		printf("\n");
-		printf("  \\-__,--,___.\n");
-		printf("   \\__,---`  %s (from NetBSD %s)\n",
-		bootprog_name, bootprog_kernrev);
-		printf("\\   `---,_.  Revision %s\n", bootprog_rev);
-		printf(" \\-,_,.---`  Memory: %d/%d k\n",
-		getbasemem(), getextmem());
-		printf("  \\\n");
-		printf("   \\\n");
-		printf("\\\n");
+		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());
 #ifndef SMALL
 	}
 #endif /* !SMALL */



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

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

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

Log Message:
use a single printf call for readability


To generate a diff of this commit:
cvs rdiff -u -r1.76 -r1.77 src/sys/arch/i386/stand/boot/boot2.c

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



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

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

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

Log Message:
biosboot: Add ASCII art.


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/sys/arch/i386/stand/boot/boot2.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/boot/boot2.c
diff -u src/sys/arch/i386/stand/boot/boot2.c:1.75 src/sys/arch/i386/stand/boot/boot2.c:1.76
--- src/sys/arch/i386/stand/boot/boot2.c:1.75	Sun May 30 05:59:22 2021
+++ src/sys/arch/i386/stand/boot/boot2.c	Mon Jun 21 19:43:17 2021
@@ -1,4 +1,4 @@
-/*	$NetBSD: boot2.c,v 1.75 2021/05/30 05:59:22 mlelstv Exp $	*/
+/*	$NetBSD: boot2.c,v 1.76 2021/06/21 19:43:17 nia Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -311,12 +311,16 @@ print_banner(void)
 			printf("%s\n", bootcfg_info.banner[n]);
 	} else {
 #endif /* !SMALL */
-		printf("\n"
-		   ">> %s, Revision %s (from NetBSD %s)\n"
-		   ">> Memory: %d/%d k\n",
-		   bootprog_name, bootprog_rev, bootprog_kernrev,
-		   getbasemem(), getextmem());
-
+		printf("\n");
+		printf("  \\-__,--,___.\n");
+		printf("   \\__,---`  %s (from NetBSD %s)\n",
+		bootprog_name, bootprog_kernrev);
+		printf("\\   `---,_.  Revision %s\n", bootprog_rev);
+		printf(" \\-,_,.---`  Memory: %d/%d k\n",
+		getbasemem(), getextmem());
+		printf("  \\\n");
+		printf("   \\\n");
+		printf("\\\n");
 #ifndef SMALL
 	}
 #endif /* !SMALL */



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

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

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

Log Message:
biosboot: Add ASCII art.


To generate a diff of this commit:
cvs rdiff -u -r1.75 -r1.76 src/sys/arch/i386/stand/boot/boot2.c

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



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

2020-07-15 Thread Kimmo Suominen
Module Name:src
Committed By:   kim
Date:   Wed Jul 15 12:36:30 UTC 2020

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

Log Message:
Let consdev command also set speed

Adapted from PR install/55490 by Sunil Nimmagadda


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 src/sys/arch/i386/stand/boot/boot2.c

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



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

2020-07-15 Thread Kimmo Suominen
Module Name:src
Committed By:   kim
Date:   Wed Jul 15 12:36:30 UTC 2020

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

Log Message:
Let consdev command also set speed

Adapted from PR install/55490 by Sunil Nimmagadda


To generate a diff of this commit:
cvs rdiff -u -r1.73 -r1.74 src/sys/arch/i386/stand/boot/boot2.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/boot/boot2.c
diff -u src/sys/arch/i386/stand/boot/boot2.c:1.73 src/sys/arch/i386/stand/boot/boot2.c:1.74
--- src/sys/arch/i386/stand/boot/boot2.c:1.73	Sat Apr  4 19:50:54 2020
+++ src/sys/arch/i386/stand/boot/boot2.c	Wed Jul 15 12:36:30 2020
@@ -1,4 +1,4 @@
-/*	$NetBSD: boot2.c,v 1.73 2020/04/04 19:50:54 christos Exp $	*/
+/*	$NetBSD: boot2.c,v 1.74 2020/07/15 12:36:30 kim Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -449,7 +449,7 @@ command_help(char *arg)
 	   "ls [dev:][path]\n"
 #endif
 	   "dev [dev:]\n"
-	   "consdev {pc|com[0123]|com[0123]kbd|auto}\n"
+	   "consdev {pc|{com[0123]|com[0123]kbd|auto}[,{speed}]}\n"
 	   "vesa {modenum|on|off|enabled|disabled|list}\n"
 #ifndef SMALL
 	   "menu (reenters boot menu, if defined in boot.cfg)\n"
@@ -581,14 +581,32 @@ void
 command_consdev(char *arg)
 {
 	const struct cons_devs *cdp;
+	char *sep;
+	int speed;
+
+	sep = strchr(arg, ',');
+	if (sep != NULL)
+		*sep++ = '\0';
 
 	for (cdp = cons_devs; cdp->name; cdp++) {
-		if (strcmp(arg, cdp->name) == 0) {
-			initio(cdp->tag);
-			print_banner();
-			return;
+		if (strcmp(arg, cdp->name) != 0)
+			continue;
+
+		if (sep != NULL) {
+			if (cdp->tag == CONSDEV_PC)
+goto error;
+
+			speed = atoi(sep);
+			if (speed < 0)
+goto error;
+			boot_params.bp_conspeed = speed;
 		}
+
+		initio(cdp->tag);
+		print_banner();
+		return;
 	}
+error:
 	printf("invalid console device.\n");
 }
 



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

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.



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.



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 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.



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.



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-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.



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

2020-02-10 Thread Kimihiro Nonaka
Hi,

Hyper-V Gen.2 VM has only 1024x768 GOP entry.
https://twitter.com/nonakap/status/1227076603470942208

kernel will be booted in text mode. no output to the console.
If execute "gop 0" command before booting a kernel, it works fine.

On Sat, Feb 8, 2020 at 11:35 PM Jared D. McNeill  wrote:
>
> 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.
>


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-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.



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.



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;
 }



  1   2   3   4   5   6   >