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

2019-12-14 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Dec 15 03:38:17 UTC 2019

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

Log Message:
PR/54767: elo: fix incorrect test (mlelstv)
Add symbolic constants and reference to the standard.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/i386/stand/lib/vbe.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/vbe.c
diff -u src/sys/arch/i386/stand/lib/vbe.c:1.9 src/sys/arch/i386/stand/lib/vbe.c:1.10
--- src/sys/arch/i386/stand/lib/vbe.c:1.9	Tue Jan 24 06:09:14 2017
+++ src/sys/arch/i386/stand/lib/vbe.c	Sat Dec 14 22:38:17 2019
@@ -1,4 +1,4 @@
-/* $NetBSD: vbe.c,v 1.9 2017/01/24 11:09:14 nonaka Exp $ */
+/* $NetBSD: vbe.c,v 1.10 2019/12/15 03:38:17 christos Exp $ */
 
 /*-
  * Copyright (c) 2009 Jared D. McNeill 
@@ -45,19 +45,57 @@ static struct _vbestate {
 	int		modenum;
 } vbestate;
 
+/*
+ * https://pdos.csail.mit.edu/6.828/2018/readings/hardware/vbe3.pdf
+ * p32
+ */
+#define	VBE_MODEATTR_MODE_HARDWARE_SUPPORTED		0x0001u
+#define	VBE_MODEATTR_RESERVED_10x0002u
+#define	VBE_MODEATTR_TTY_OUTPUT_FUNCTIONS_SUPPORTED	0x0004u
+#define	VBE_MODEATTR_COLOR_MODE0x0008u
+#define	VBE_MODEATTR_GRAPHICS_MODE			0x0010u
+#define	VBE_MODEATTR_VGA_COMPATIBLE_MODE		0x0020u
+#define	VBE_MODEATTR_VGA_COMPATIBLE_WINDOWD_MEMORY_MODE	0x0040u
+#define	VBE_MODEATTR_LINEAR_FRAME_BUFFER_MODE		0x0080u
+#define	VBE_MODEATTR_DOUBLE_SCAN_MODE			0x0100u
+#define	VBE_MODEATTR_INTERLACED_MODE			0x0200u
+#define	VBE_MODEATTR_HARDWARE_TRIPPLE_BUFFERING_SUPPORT	0x0400u
+#define	VBE_MODEATTR_HARDWARE_STEREOSCOPIC_SUPPORT	0x0800u
+#define	VBE_MODEATTR_DUAL_DISPLAY_START_ADDRESS_SUPPORT	0x1000u
+#define	VBE_MODEATTR_RESERVED_20x2000u
+#define	VBE_MODEATTR_RESERVED_30x4000u
+#define	VBE_MODEATTR_RESERVED_40x8000u
+
+/*
+ * p36
+ */
+#define VBE_MEMMODEL_TEXT		0x00u
+#define	VBE_MEMMODEL_CGA		0x01u
+#define	VBE_MEMMODEL_HERCULES		0x02u
+#define	VBE_MEMMODEL_PLANAR		0x03u
+#define	VBE_MEMMODEL_PACKED_PIXEL	0x04u
+#define	VBE_MEMMODEL_NON_CHAIN_4_256	0x05u
+#define	VBE_MEMMODEL_DIRECT_COLOR	0x06u
+#define	VBE_MEMMODEL_YUV		0x07u
+/* VESA Reserved 			0x08u-0x0fu */
+/* OEM Reserved0x10u-0xffU */
+
+
 static int
 vbe_mode_is_supported(struct modeinfoblock *mi)
 {
-	if ((mi->ModeAttributes & 0x01) == 0)
+	if ((mi->ModeAttributes & VBE_MODEATTR_MODE_HARDWARE_SUPPORTED) == 0)
 		return 0;	/* mode not supported by hardware */
-	if ((mi->ModeAttributes & 0x08) == 0)
-		return 0;	/* linear fb not available */
-	if ((mi->ModeAttributes & 0x10) == 0)
+	if ((mi->ModeAttributes & VBE_MODEATTR_COLOR_MODE) == 0)
+		return 0;	/* only color modes are supported */
+	if ((mi->ModeAttributes & VBE_MODEATTR_GRAPHICS_MODE) == 0)
 		return 0;	/* text mode */
+	if ((mi->ModeAttributes & VBE_MODEATTR_LINEAR_FRAME_BUFFER_MODE) == 0)
+		return 0;	/* linear fb not available */
 	if (mi->NumberOfPlanes != 1)
 		return 0;	/* planar mode not supported */
-	if (mi->MemoryModel != 0x04 /* Packed pixel */ &&
-	mi->MemoryModel != 0x06 /* Direct Color */)
+	if (mi->MemoryModel != VBE_MEMMODEL_PACKED_PIXEL /* Packed pixel */ &&
+	mi->MemoryModel != VBE_MEMMODEL_DIRECT_COLOR /* Direct Color */)
 		return 0;	/* unsupported pixel format */
 	return 1;
 }



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

2019-12-06 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sat Dec  7 02:29:03 UTC 2019

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

Log Message:
loadfile sets errno, return the correct error, not EIO.


To generate a diff of this commit:
cvs rdiff -u -r1.74 -r1.75 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.74 src/sys/arch/i386/stand/lib/exec.c:1.75
--- src/sys/arch/i386/stand/lib/exec.c:1.74	Thu Sep 12 22:19:46 2019
+++ src/sys/arch/i386/stand/lib/exec.c	Fri Dec  6 21:29:03 2019
@@ -1,4 +1,4 @@
-/*	$NetBSD: exec.c,v 1.74 2019/09/13 02:19:46 manu Exp $	 */
+/*	$NetBSD: exec.c,v 1.75 2019/12/07 02:29:03 christos Exp $	 */
 
 /*
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -321,7 +321,7 @@ common_load_prekern(const char *file, u_
 	/* Load the prekern (static) */
 	flags = LOAD_KERNEL & ~(LOAD_HDR|LOAD_SYM);
 	if ((fd = loadfile(prekernpath, marks, flags)) == -1)
-		return EIO;
+		return errno;
 	close(fd);
 
 	prekern_start = marks[MARK_START];
@@ -334,7 +334,7 @@ common_load_prekern(const char *file, u_
 	/* Load the kernel (dynamic) */
 	flags = (LOAD_KERNEL | LOAD_DYN) & ~(floppy ? LOAD_BACKWARDS : 0);
 	if ((fd = loadfile(file, marks, flags)) == -1)
-		return EIO;
+		return errno;
 	close(fd);
 
 	kernpa_end = marks[MARK_END] - loadaddr;
@@ -399,7 +399,7 @@ common_load_kernel(const char *file, u_l
 		 */
 		marks[MARK_START] = loadaddr;
 		if ((fd = loadfile(file, marks, COUNT_KERNEL)) == -1)
-			return EIO;
+			return errno;
 		close(fd);
 
 		kernsize = marks[MARK_END];
@@ -413,7 +413,7 @@ common_load_kernel(const char *file, u_l
 	marks[MARK_START] = loadaddr;
 	if ((fd = loadfile(file, marks,
 	LOAD_KERNEL & ~(floppy ? LOAD_BACKWARDS : 0))) == -1)
-		return EIO;
+		return errno;
 
 	close(fd);
 



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

2018-06-13 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Jun 13 16:03:10 UTC 2018

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

Log Message:
revert previous MAKEOBJDIRPREFIX massaging


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 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.18 src/sys/arch/i386/stand/lib/Makefile.inc:1.19
--- src/sys/arch/i386/stand/lib/Makefile.inc:1.18	Mon Jun 11 17:35:13 2018
+++ src/sys/arch/i386/stand/lib/Makefile.inc	Wed Jun 13 12:03:10 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.inc,v 1.18 2018/06/11 21:35:13 christos Exp $
+#	$NetBSD: Makefile.inc,v 1.19 2018/06/13 16:03:10 christos Exp $
 #
 #	Configuration variables (default values are below):
 #
@@ -24,7 +24,7 @@ CWARNFLAGS.clang+=	-Wno-tautological-com
 I386MAKE= \
 	cd ${I386DIR} && MAKEOBJDIRPREFIX= && unset MAKEOBJDIRPREFIX && \
 	MAKEOBJDIR=${I386DST} ${MAKE} \
-	CC=${CC:q} CFLAGS=${CFLAGS:S/MAKEOBJDIRPREFIX/MAKEOBJDIR/:q} \
+	CC=${CC:q} CFLAGS=${CFLAGS:q} \
 	AS=${AS:q} AFLAGS=${AFLAGS:q} \
 	LD=${LD:q} STRIP=${STRIP:q} \
 	MACHINE=${MACHINE} MACHINE_ARCH=${MACHINE_ARCH:q} \



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

2018-06-11 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Jun 11 21:35:13 UTC 2018

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

Log Message:
switch CFLAGS from using MAKEOBJDIRPREFIX to MAKEOBJDIR. This whole thing
is disgusting, but fixing it properly. requires restructuring


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 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.17 src/sys/arch/i386/stand/lib/Makefile.inc:1.18
--- src/sys/arch/i386/stand/lib/Makefile.inc:1.17	Sat May 26 21:14:50 2018
+++ src/sys/arch/i386/stand/lib/Makefile.inc	Mon Jun 11 17:35:13 2018
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile.inc,v 1.17 2018/05/27 01:14:50 christos Exp $
+#	$NetBSD: Makefile.inc,v 1.18 2018/06/11 21:35:13 christos Exp $
 #
 #	Configuration variables (default values are below):
 #
@@ -24,7 +24,7 @@ CWARNFLAGS.clang+=	-Wno-tautological-com
 I386MAKE= \
 	cd ${I386DIR} && MAKEOBJDIRPREFIX= && unset MAKEOBJDIRPREFIX && \
 	MAKEOBJDIR=${I386DST} ${MAKE} \
-	CC=${CC:q} CFLAGS=${CFLAGS:q} \
+	CC=${CC:q} CFLAGS=${CFLAGS:S/MAKEOBJDIRPREFIX/MAKEOBJDIR/:q} \
 	AS=${AS:q} AFLAGS=${AFLAGS:q} \
 	LD=${LD:q} STRIP=${STRIP:q} \
 	MACHINE=${MACHINE} MACHINE_ARCH=${MACHINE_ARCH:q} \



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

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

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

Log Message:
efiboot: fix to find boot partition process.

NetBSD related partitions with no bootme flag set are also candidates
for boot partition.


To generate a diff of this commit:
cvs rdiff -u -r1.47 -r1.48 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.47 src/sys/arch/i386/stand/lib/biosdisk.c:1.48
--- src/sys/arch/i386/stand/lib/biosdisk.c:1.47	Thu Mar  8 10:34:33 2018
+++ src/sys/arch/i386/stand/lib/biosdisk.c	Tue Mar 20 10:21:01 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: biosdisk.c,v 1.47 2018/03/08 10:34:33 nonaka Exp $	*/
+/*	$NetBSD: biosdisk.c,v 1.48 2018/03/20 10:21:01 nonaka Exp $	*/
 
 /*
  * Copyright (c) 1996, 1998
@@ -802,20 +802,21 @@ biosdisk_findpartition(int biosdev, dadd
 			if (d->part[partition].fstype == FS_UNUSED)
 continue;
 #ifdef EFIBOOT
-			if (d->part[partition].attr & GPT_ENT_ATTR_BOOTME) {
-switch (d->part[partition].fstype) {
-case FS_BSDFFS:
-case FS_BSDLFS:
-case FS_RAID:
-case FS_CCD:
-case FS_CGD:
-case FS_ISO9660:
-	break;
+			switch (d->part[partition].fstype) {
+			case FS_BSDFFS:
+			case FS_BSDLFS:
+			case FS_RAID:
+			case FS_CCD:
+			case FS_CGD:
+			case FS_ISO9660:
+if (d->part[partition].attr & GPT_ENT_ATTR_BOOTME)
+	goto found;
+candidate = partition;
+break;
 
-default:
+			default:
+if (d->part[partition].attr & GPT_ENT_ATTR_BOOTME)
 	candidate = partition;
-	continue;
-}
 break;
 			}
 #else
@@ -824,6 +825,7 @@ biosdisk_findpartition(int biosdev, dadd
 #endif
 		}
 #ifdef EFIBOOT
+found:
 		if (partition == 0 && candidate != 0)
 			partition = candidate;
 #endif



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

2018-01-27 Thread Paul Goyette
Module Name:src
Committed By:   pgoyette
Date:   Sat Jan 27 22:25:23 UTC 2018

Modified Files:
src/sys/arch/i386/stand/lib: bootinfo.h

Log Message:
Recent changes have increased the number of "things" the bootloader
needs to deal with.  Increase the table size so we don't overflow.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/i386/stand/lib/bootinfo.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/lib/bootinfo.h
diff -u src/sys/arch/i386/stand/lib/bootinfo.h:1.11 src/sys/arch/i386/stand/lib/bootinfo.h:1.12
--- src/sys/arch/i386/stand/lib/bootinfo.h:1.11	Sun Jun  5 14:13:57 2016
+++ src/sys/arch/i386/stand/lib/bootinfo.h	Sat Jan 27 22:25:23 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: bootinfo.h,v 1.11 2016/06/05 14:13:57 maxv Exp $	*/
+/*	$NetBSD: bootinfo.h,v 1.12 2018/01/27 22:25:23 pgoyette Exp $	*/
 
 /*
  * Copyright (c) 1997
@@ -35,7 +35,7 @@ struct bootinfo {
 
 extern struct bootinfo *bootinfo;
 
-#define BTINFO_MAX	32
+#define BTINFO_MAX	64
 
 #define BI_ALLOC(max) (bootinfo = alloc(sizeof(struct bootinfo) \
 + ((max) - 1) * sizeof(uint32_t))) \



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

2017-03-24 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Fri Mar 24 08:50:17 UTC 2017

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

Log Message:
efiboot: fix calculation of the kernel size when loading modules.


To generate a diff of this commit:
cvs rdiff -u -r1.67 -r1.68 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.67 src/sys/arch/i386/stand/lib/exec.c:1.68
--- src/sys/arch/i386/stand/lib/exec.c:1.67	Sun Mar 12 05:33:48 2017
+++ src/sys/arch/i386/stand/lib/exec.c	Fri Mar 24 08:50:17 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: exec.c,v 1.67 2017/03/12 05:33:48 nonaka Exp $	 */
+/*	$NetBSD: exec.c,v 1.68 2017/03/24 08:50:17 nonaka Exp $	 */
 
 /*
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -469,14 +469,16 @@ count_netbsd(const char *file, u_long *r
 {
 	u_long marks[MARK_MAX];
 	char kdev[64];
-	char base_path[64];
+	char base_path[64] = "/";
 	struct stat st;
 	boot_module_t *bm;
 	u_long sz;
 	int err, fd;
 
+	howto = AB_SILENT;
+
 	memset(marks, 0, sizeof(marks));
-	if ((fd = loadfile(file, marks, COUNT_KERNEL)) == -1)
+	if ((fd = loadfile(file, marks, COUNT_KERNEL | LOAD_NOTE)) == -1)
 		return -1;
 	close(fd);
 	marks[MARK_END] = (((u_long) marks[MARK_END] + sizeof(int) - 1)) &
@@ -490,13 +492,13 @@ count_netbsd(const char *file, u_long *r
 
 		/* If the root fs type is unusual, load its module. */
 		if (fsmod != NULL)
-			module_add(__UNCONST(fsmod));
+			module_add_common(fsmod, BM_TYPE_KMOD);
 
 		for (bm = boot_modules; bm; bm = bm->bm_next) {
 			fd = module_open(bm, 0, kdev, base_path, false);
 			if (fd == -1)
 continue;
-			sz = (image_end + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1);
+			sz = (sz + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1);
 			err = fstat(fd, &st);
 			if (err == -1 || st.st_size == -1) {
 close(fd);



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

2017-02-23 Thread NONAKA Kimihiro
Module Name:src
Committed By:   nonaka
Date:   Thu Feb 23 12:14:53 UTC 2017

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

Log Message:
no need COUNT_KERNEL hack.


To generate a diff of this commit:
cvs rdiff -u -r1.65 -r1.66 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.65 src/sys/arch/i386/stand/lib/exec.c:1.66
--- src/sys/arch/i386/stand/lib/exec.c:1.65	Sat Feb 11 10:23:39 2017
+++ src/sys/arch/i386/stand/lib/exec.c	Thu Feb 23 12:14:53 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: exec.c,v 1.65 2017/02/11 10:23:39 nonaka Exp $	 */
+/*	$NetBSD: exec.c,v 1.66 2017/02/23 12:14:53 nonaka Exp $	 */
 
 /*
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -313,7 +313,6 @@ common_load_kernel(const char *file, u_l
 		/* Allocate temporary arena. */
 		addr = EFI_ALLOCATE_MAX_ADDRESS;
 		kernsize = marks[MARK_END] - loadaddr;
-		kernsize += 1 * 1024 * 1024;	/* XXX: kernel size COUNT_KERNEL vs LOAD_KERNL (lacked some SYMTAB?) */
 		kernsize = EFI_SIZE_TO_PAGES(kernsize);
 		status = uefi_call_wrapper(BS->AllocatePages, 4,
 		AllocateMaxAddress, EfiLoaderData, kernsize, &addr);



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

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

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

Log Message:
efiboot: Copy bootinfo to safe arena.


To generate a diff of this commit:
cvs rdiff -u -r1.63 -r1.64 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.63 src/sys/arch/i386/stand/lib/exec.c:1.64
--- src/sys/arch/i386/stand/lib/exec.c:1.63	Tue Jan 24 11:09:14 2017
+++ src/sys/arch/i386/stand/lib/exec.c	Sat Feb 11 10:18:10 2017
@@ -1,4 +1,4 @@
-/*	$NetBSD: exec.c,v 1.63 2017/01/24 11:09:14 nonaka Exp $	 */
+/*	$NetBSD: exec.c,v 1.64 2017/02/11 10:18:10 nonaka Exp $	 */
 
 /*
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -389,6 +389,9 @@ exec_netbsd(const char *file, physaddr_t
 	u_long extmem;
 	u_long basemem;
 	int error;
+#ifdef EFIBOOT
+	int i;
+#endif
 
 #ifdef	DEBUG
 	printf("exec: file=%s loadaddr=0x%lx\n", file ? file : "NULL",
@@ -449,6 +452,14 @@ exec_netbsd(const char *file, physaddr_t
 	if (callback != NULL)
 		(*callback)();
 #ifdef EFIBOOT
+	/* Copy bootinfo to safe arena. */
+	for (i = 0; i < bootinfo->nentries; i++) {
+		struct btinfo_common *bi = (void *)(u_long)bootinfo->entry[i];
+		char *p = alloc(bi->len);
+		memcpy(p, bi, bi->len);
+		bootinfo->entry[i] = vtophys(p);
+	}
+
 	/* Copy the kernel to original load address. */
 	memmove((void *)marks[MARK_START],
 	(void *)(efi_loadaddr + marks[MARK_START]),



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

2016-12-04 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sun Dec  4 08:21:08 UTC 2016

Modified Files:
src/sys/arch/i386/stand/lib: biosmem.S biosmemps2.S biosmemx.S exec.c
multiboot.S startprog.S

Log Message:
KNF and explain a few things


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/i386/stand/lib/biosmem.S \
src/sys/arch/i386/stand/lib/biosmemx.S
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/i386/stand/lib/biosmemps2.S
cvs rdiff -u -r1.61 -r1.62 src/sys/arch/i386/stand/lib/exec.c
cvs rdiff -u -r1.1 -r1.2 src/sys/arch/i386/stand/lib/multiboot.S
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/i386/stand/lib/startprog.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/biosmem.S
diff -u src/sys/arch/i386/stand/lib/biosmem.S:1.9 src/sys/arch/i386/stand/lib/biosmem.S:1.10
--- src/sys/arch/i386/stand/lib/biosmem.S:1.9	Thu Jun 16 13:27:59 2011
+++ src/sys/arch/i386/stand/lib/biosmem.S	Sun Dec  4 08:21:08 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: biosmem.S,v 1.9 2011/06/16 13:27:59 joerg Exp $	*/
+/*	$NetBSD: biosmem.S,v 1.10 2016/12/04 08:21:08 maxv Exp $	*/
 
 /*
  * Copyright (c) 1996
@@ -36,8 +36,9 @@
 
 	.text
 
-/* get mem below 1M, in kByte */
-
+/*
+ * Get mem below 1M, in kByte.
+ */
 ENTRY(getbasemem)
 	pusha
 
@@ -45,18 +46,19 @@ ENTRY(getbasemem)
 	.code16
 
 	int	$0x12
-	# zero-extend 16-bit result to 32 bits.
-	movzwl	%ax, %eax
+	/* Zero-extend 16-bit result to 32 bits */
+	movzwl	%ax,%eax
 
 	calll	_C_LABEL(real_to_prot)
 	.code32
 
-	movl	%eax, 28(%esp)
+	movl	%eax,28(%esp)
 	popa
 	ret
 
-/* get mem above 1M, in kByte */
-
+/*
+ * Get mem above 1M, in kByte.
+ */
 ENTRY(getextmem1)
 	pusha
 
@@ -66,13 +68,13 @@ ENTRY(getextmem1)
 	movb	$0x88,%ah
 	int	$0x15
 
-	# zero-extend 16-bit result to 32 bits.
-	movzwl	%ax, %eax
+	/* Zero-extend 16-bit result to 32 bits */
+	movzwl	%ax,%eax
 
 	calll	_C_LABEL(real_to_prot)
 	.code32
 
-	movl	%eax, 28(%esp)
+	movl	%eax,28(%esp)
 	popa
 	ret
 
Index: src/sys/arch/i386/stand/lib/biosmemx.S
diff -u src/sys/arch/i386/stand/lib/biosmemx.S:1.9 src/sys/arch/i386/stand/lib/biosmemx.S:1.10
--- src/sys/arch/i386/stand/lib/biosmemx.S:1.9	Tue Oct 14 14:18:11 2008
+++ src/sys/arch/i386/stand/lib/biosmemx.S	Sun Dec  4 08:21:08 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: biosmemx.S,v 1.9 2008/10/14 14:18:11 ad Exp $	*/
+/*	$NetBSD: biosmemx.S,v 1.10 2016/12/04 08:21:08 maxv Exp $	*/
 
 /*
  * Copyright (c) 1997, 1999
@@ -30,11 +30,13 @@
 
 	.text
 
-/* int getextmem2(int buffer[2])
-   return: 0=OK, -1=error
-   buffer[0]: extmem kBytes below 16M (max 15M/1024)
-   buffer[1]: extmem above 16M, in 64k units
-*/
+/*
+ * int getextmem2(int buffer[2])
+ *
+ * return: 0=OK, -1=error
+ * buffer[0]: extmem kBytes below 16M (max 15M/1024)
+ * buffer[1]: extmem above 16M, in 64k units
+ */
 ENTRY(getextmem2)
 	pushl	%ebp
 	movl	%esp,%ebp
@@ -47,16 +49,16 @@ ENTRY(getextmem2)
 	call	_C_LABEL(prot_to_real)
 	.code16
 
-	xorl	%ebx, %ebx
-	movl	$0xe801, %eax
+	xorl	%ebx,%ebx
+	movl	$0xe801,%eax
 	int	$0x15
 	pushf
 
-	movw	%si, %ax
-	orw	%si, %bx
+	movw	%si,%ax
+	orw	%si,%bx
 	jz	1f		/* if zero use configured values */
-	movw	%cx, %ax	/* k below 16M (max 0x3c00 = 15MB) */
-	movw	%dx, %bx	/* 64k above 16M */
+	movw	%cx,%ax		/* k below 16M (max 0x3c00 = 15MB) */
+	movw	%dx,%bx		/* 64k above 16M */
 1:
 	popf
 	setc	%bl
@@ -64,13 +66,13 @@ ENTRY(getextmem2)
 	calll	_C_LABEL(real_to_prot)
 	.code32
 
-	movl	8(%ebp), %edi
-	xorl	%eax, %eax
-	movw	%cx, %ax
+	movl	8(%ebp),%edi
+	xorl	%eax,%eax
+	movw	%cx,%ax
 	stosl
-	movw	%dx, %ax
+	movw	%dx,%ax
 	stosl
-	movb	%bl, %al
+	movb	%bl,%al
 	cbw
 
 	pop	%edi
@@ -81,12 +83,14 @@ ENTRY(getextmem2)
 	popl	%ebp
 	ret
 
-/* int getmementry(int *iterator, buffer[5])
-   return: 0=ok, else error
-   buffer[0]: start of memory chunk
-   buffer[2]: length (bytes)
-   buffer[4]: type
-*/
+/*
+ * int getmementry(int *iterator, int buffer[5])
+ *
+ * return: 0=ok, else error
+ * buffer[0]: start of memory chunk
+ * buffer[2]: length (bytes)
+ * buffer[4]: type
+ */
 ENTRY(getmementry)
 	pushl	%ebp
 	movl	%esp,%ebp
@@ -96,24 +100,24 @@ ENTRY(getmementry)
 	push	%esi
 	push	%edi
 
-	movl	8(%ebp), %eax
-	movl	0(%eax), %ebx		/* index */
-	movl	$20, %ecx		/* Buffer size */
-	movl	$0x534d4150, %edx	/* "SMAP" */
-	movl	12(%ebp), %edi		/* buffer address */
+	movl	8(%ebp),%eax
+	movl	0(%eax),%ebx		/* index */
+	movl	$20,%ecx		/* Buffer size */
+	movl	$0x534d4150,%edx	/* "SMAP" */
+	movl	12(%ebp),%edi		/* buffer address */
 
 	call	_C_LABEL(prot_to_real)
 	.code16
 
 	push	%di
-	shrl	$4, %edi
-	mov	%ds, %ax
-	add	%di, %ax
-	mov	%ax, %es
+	shrl	$4,%edi
+	mov	%ds,%ax
+	add	%di,%ax
+	mov	%ax,%es
 	pop	%di
-	and	$0xf, %di		/* buffer addres now in ES:DI */
+	and	$0xf,%di		/* buffer addres now in ES:DI */
 
-	movl	$0xe820, %eax		/* Some BIOS check EAX value */
+	movl	$0xe820,%eax		/* Some BIOS check EAX value */
 	int	$0x15
 
 	setc	%cl
@@ -

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

2016-06-05 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sun Jun  5 14:13:57 UTC 2016

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

Log Message:
Don't use a magic value. Define a limit, and enforce it.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/i386/stand/lib/bootinfo.c
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/i386/stand/lib/bootinfo.h
cvs rdiff -u -r1.60 -r1.61 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/bootinfo.c
diff -u src/sys/arch/i386/stand/lib/bootinfo.c:1.5 src/sys/arch/i386/stand/lib/bootinfo.c:1.6
--- src/sys/arch/i386/stand/lib/bootinfo.c:1.5	Sun Dec 14 18:46:33 2008
+++ src/sys/arch/i386/stand/lib/bootinfo.c	Sun Jun  5 14:13:57 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: bootinfo.c,v 1.5 2008/12/14 18:46:33 christos Exp $	*/
+/*	$NetBSD: bootinfo.c,v 1.6 2016/06/05 14:13:57 maxv Exp $	*/
 
 /*
  * Copyright (c) 1997
@@ -40,6 +40,11 @@ bi_add(struct btinfo_common *what, int t
 	what->len = size;
 	what->type = type;
 
-	if (bootinfo)
-		bootinfo->entry[bootinfo->nentries++] = vtophys(what);
+	if (bootinfo == NULL) {
+		return;
+	}
+	if (bootinfo->nentries >= BTINFO_MAX) {
+		panic("bootinfo too big");
+	}
+	bootinfo->entry[bootinfo->nentries++] = vtophys(what);
 }

Index: src/sys/arch/i386/stand/lib/bootinfo.h
diff -u src/sys/arch/i386/stand/lib/bootinfo.h:1.10 src/sys/arch/i386/stand/lib/bootinfo.h:1.11
--- src/sys/arch/i386/stand/lib/bootinfo.h:1.10	Mon Nov 18 03:52:45 2013
+++ src/sys/arch/i386/stand/lib/bootinfo.h	Sun Jun  5 14:13:57 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: bootinfo.h,v 1.10 2013/11/18 03:52:45 jakllsch Exp $	*/
+/*	$NetBSD: bootinfo.h,v 1.11 2016/06/05 14:13:57 maxv Exp $	*/
 
 /*
  * Copyright (c) 1997
@@ -35,6 +35,8 @@ struct bootinfo {
 
 extern struct bootinfo *bootinfo;
 
+#define BTINFO_MAX	32
+
 #define BI_ALLOC(max) (bootinfo = alloc(sizeof(struct bootinfo) \
 + ((max) - 1) * sizeof(uint32_t))) \
   ->nentries = 0

Index: src/sys/arch/i386/stand/lib/exec.c
diff -u src/sys/arch/i386/stand/lib/exec.c:1.60 src/sys/arch/i386/stand/lib/exec.c:1.61
--- src/sys/arch/i386/stand/lib/exec.c:1.60	Sun Jun  5 14:06:31 2016
+++ src/sys/arch/i386/stand/lib/exec.c	Sun Jun  5 14:13:57 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: exec.c,v 1.60 2016/06/05 14:06:31 maxv Exp $	 */
+/*	$NetBSD: exec.c,v 1.61 2016/06/05 14:13:57 maxv Exp $	 */
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -356,7 +356,7 @@ exec_netbsd(const char *file, physaddr_t
 	   file ? file : "NULL", loadaddr);
 #endif
 
-	BI_ALLOC(32); /* ??? */
+	BI_ALLOC(BTINFO_MAX);
 
 	BI_ADD(&btinfo_console, BTINFO_CONSOLE, sizeof(struct btinfo_console));
 



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

2016-06-05 Thread Maxime Villard
Module Name:src
Committed By:   maxv
Date:   Sun Jun  5 14:06:31 UTC 2016

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

Log Message:
The bootinfo is refreshed each time the bootloader tries to execute a
kernel, so there's no point in using this global variable. Because of
this variable, only one "boot" command can be issued in the prompt, and
you have to reboot the machine if you mistyped the kernel name.


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 src/sys/arch/i386/stand/lib/biosdisk.c
cvs rdiff -u -r1.59 -r1.60 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/biosdisk.c
diff -u src/sys/arch/i386/stand/lib/biosdisk.c:1.44 src/sys/arch/i386/stand/lib/biosdisk.c:1.45
--- src/sys/arch/i386/stand/lib/biosdisk.c:1.44	Sun Jan 18 20:18:07 2015
+++ src/sys/arch/i386/stand/lib/biosdisk.c	Sun Jun  5 14:06:31 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: biosdisk.c,v 1.44 2015/01/18 20:18:07 jakllsch Exp $	*/
+/*	$NetBSD: biosdisk.c,v 1.45 2016/06/05 14:06:31 maxv Exp $	*/
 
 /*
  * Copyright (c) 1996, 1998
@@ -701,24 +701,13 @@ biosdisk_findpartition(int biosdev, dadd
 static void
 add_biosdisk_bootinfo(void)
 {
-	static bool done;
-
 	if (bootinfo == NULL) {
-		done = false;
 		return;
 	}
-	
-	if (done)
-		return;
-
 	BI_ADD(&bi_disk, BTINFO_BOOTDISK, sizeof(bi_disk));
 	BI_ADD(&bi_wedge, BTINFO_BOOTWEDGE, sizeof(bi_wedge));
-
-	done = true;
-
 	return;
 }
-
 #endif
 
 int

Index: src/sys/arch/i386/stand/lib/exec.c
diff -u src/sys/arch/i386/stand/lib/exec.c:1.59 src/sys/arch/i386/stand/lib/exec.c:1.60
--- src/sys/arch/i386/stand/lib/exec.c:1.59	Sun Apr  6 19:18:00 2014
+++ src/sys/arch/i386/stand/lib/exec.c	Sun Jun  5 14:06:31 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: exec.c,v 1.59 2014/04/06 19:18:00 jakllsch Exp $	 */
+/*	$NetBSD: exec.c,v 1.60 2016/06/05 14:06:31 maxv Exp $	 */
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -411,7 +411,7 @@ exec_netbsd(const char *file, physaddr_t
 
 out:
 	BI_FREE();
-	bootinfo = 0;
+	bootinfo = NULL;
 	return -1;
 }
 



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

2016-01-17 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Jan 17 14:57:18 UTC 2016

Modified Files:
src/sys/arch/i386/stand/lib/netif: 3c90xb.c etherdrv.h

Log Message:
PR/50668: David Binderman: Don't compare unsigned to -1


To generate a diff of this commit:
cvs rdiff -u -r1.14 -r1.15 src/sys/arch/i386/stand/lib/netif/3c90xb.c
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/i386/stand/lib/netif/etherdrv.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/lib/netif/3c90xb.c
diff -u src/sys/arch/i386/stand/lib/netif/3c90xb.c:1.14 src/sys/arch/i386/stand/lib/netif/3c90xb.c:1.15
--- src/sys/arch/i386/stand/lib/netif/3c90xb.c:1.14	Sun Dec 14 13:46:33 2008
+++ src/sys/arch/i386/stand/lib/netif/3c90xb.c	Sun Jan 17 09:57:18 2016
@@ -1,4 +1,4 @@
-/* $NetBSD: 3c90xb.c,v 1.14 2008/12/14 18:46:33 christos Exp $ */
+/* $NetBSD: 3c90xb.c,v 1.15 2016/01/17 14:57:18 christos Exp $ */
 
 /*
  * Copyright (c) 1999
@@ -291,7 +291,7 @@ ex_probemedia(void)
 	}
 	printf("unknown connector\n");
 bad:
-	ether_medium = -1;
+	ether_medium = ETHERMEDIUM_BAD;
 }
 
 int
@@ -346,7 +346,7 @@ found:
 		ether_medium = ETHERMEDIUM_MII;
 	else {
 		ex_probemedia();
-		if (ether_medium < 0)
+		if (ether_medium == ETHERMEDIUM_BAD)
 			return 0;
 	}
 

Index: src/sys/arch/i386/stand/lib/netif/etherdrv.h
diff -u src/sys/arch/i386/stand/lib/netif/etherdrv.h:1.9 src/sys/arch/i386/stand/lib/netif/etherdrv.h:1.10
--- src/sys/arch/i386/stand/lib/netif/etherdrv.h:1.9	Sun Dec 14 13:46:33 2008
+++ src/sys/arch/i386/stand/lib/netif/etherdrv.h	Sun Jan 17 09:57:18 2016
@@ -1,4 +1,4 @@
-/*	$NetBSD: etherdrv.h,v 1.9 2008/12/14 18:46:33 christos Exp $	*/
+/*	$NetBSD: etherdrv.h,v 1.10 2016/01/17 14:57:18 christos Exp $	*/
 
 /*
  * Copyright (c) 1996
@@ -32,6 +32,7 @@ int EtherReceive(char *, int);
 void EtherStop(void);
 
 extern unsigned ether_medium;
+#define ETHERMEDIUM_BAD ((unsigned)-1)
 #define ETHERMEDIUM_BNC 0
 #define ETHERMEDIUM_UTP 1
 #define ETHERMEDIUM_AUI 2



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

2015-12-13 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Dec 13 21:03:31 UTC 2015

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

Log Message:
one default is better than two


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/i386/stand/lib/dosfile.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/dosfile.c
diff -u src/sys/arch/i386/stand/lib/dosfile.c:1.18 src/sys/arch/i386/stand/lib/dosfile.c:1.19
--- src/sys/arch/i386/stand/lib/dosfile.c:1.18	Sun Dec 13 14:51:53 2015
+++ src/sys/arch/i386/stand/lib/dosfile.c	Sun Dec 13 16:03:31 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: dosfile.c,v 1.18 2015/12/13 19:51:53 christos Exp $	 */
+/*	$NetBSD: dosfile.c,v 1.19 2015/12/13 21:03:31 christos Exp $	 */
 
 /*
  * Copyright (c) 1996
@@ -70,7 +70,6 @@ dos2errno(void)
 		err = EPERM;
 		break;
 	case 6: /* invalid handle */
-	default:
 		err = EINVAL;
 		break;
 	}



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

2015-12-13 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Dec 13 19:51:53 UTC 2015

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

Log Message:
better than returning random errors.


To generate a diff of this commit:
cvs rdiff -u -r1.17 -r1.18 src/sys/arch/i386/stand/lib/dosfile.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/dosfile.c
diff -u src/sys/arch/i386/stand/lib/dosfile.c:1.17 src/sys/arch/i386/stand/lib/dosfile.c:1.18
--- src/sys/arch/i386/stand/lib/dosfile.c:1.17	Fri Dec 11 03:04:20 2015
+++ src/sys/arch/i386/stand/lib/dosfile.c	Sun Dec 13 14:51:53 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: dosfile.c,v 1.17 2015/12/11 08:04:20 mlelstv Exp $	 */
+/*	$NetBSD: dosfile.c,v 1.18 2015/12/13 19:51:53 christos Exp $	 */
 
 /*
  * Copyright (c) 1996
@@ -70,6 +70,7 @@ dos2errno(void)
 		err = EPERM;
 		break;
 	case 6: /* invalid handle */
+	default:
 		err = EINVAL;
 		break;
 	}



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

2015-12-11 Thread Michael van Elst
Module Name:src
Committed By:   mlelstv
Date:   Fri Dec 11 08:04:20 UTC 2015

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

Log Message:
PR 50516 bad switch statement.
Adding some comments.


To generate a diff of this commit:
cvs rdiff -u -r1.16 -r1.17 src/sys/arch/i386/stand/lib/dosfile.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/dosfile.c
diff -u src/sys/arch/i386/stand/lib/dosfile.c:1.16 src/sys/arch/i386/stand/lib/dosfile.c:1.17
--- src/sys/arch/i386/stand/lib/dosfile.c:1.16	Sun Oct 20 21:06:37 2013
+++ src/sys/arch/i386/stand/lib/dosfile.c	Fri Dec 11 08:04:20 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: dosfile.c,v 1.16 2013/10/20 21:06:37 christos Exp $	 */
+/*	$NetBSD: dosfile.c,v 1.17 2015/12/11 08:04:20 mlelstv Exp $	 */
 
 /*
  * Copyright (c) 1996
@@ -56,18 +56,22 @@ dos2errno(void)
 	int err;
 
 	switch (doserrno) {
-	case 1:
-	case 4:
-	case 12:
+	case 1: /* invalid function number */
+	case 4: /* too many open files */
+	case 12: /* invalid access mode */
 	default:
 		err = EIO;
-	case 2:
-	case 3:
+		break;
+	case 2: /* file not found */
+	case 3: /* path not found */
 		err = ENOENT;
-	case 5:
+		break;
+	case 5: /* access denied */
 		err = EPERM;
-	case 6:
+		break;
+	case 6: /* invalid handle */
 		err = EINVAL;
+		break;
 	}
 	return err;
 }



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

2015-04-16 Thread matthew green
Module Name:src
Committed By:   mrg
Date:   Thu Apr 16 08:38:36 UTC 2015

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

Log Message:
remove HAVE_GCC=45 fragment.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 src/sys/arch/i386/stand/lib/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/lib/Makefile
diff -u src/sys/arch/i386/stand/lib/Makefile:1.40 src/sys/arch/i386/stand/lib/Makefile:1.41
--- src/sys/arch/i386/stand/lib/Makefile:1.40	Tue Apr  8 15:34:18 2014
+++ src/sys/arch/i386/stand/lib/Makefile	Thu Apr 16 08:38:36 2015
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.40 2014/04/08 15:34:18 christos Exp $
+#	$NetBSD: Makefile,v 1.41 2015/04/16 08:38:36 mrg Exp $
 
 S?=	${.CURDIR}/../../../..
 
@@ -54,9 +54,6 @@ lib${LIB}.o:: ${OBJS}
 	@${LD} -r -o lib${LIB}.o `lorder ${OBJS} | tsort`
 
 # XXX
-.if ${HAVE_GCC:U} == 45
-COPTS.biosdisk.c+=	-fno-strict-aliasing
-.endif
 .if ${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U} == 48
 COPTS.biosdisk_ll.c+=	-O0
 .endif



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

2015-01-18 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sun Jan 18 20:18:07 UTC 2015

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

Log Message:
While the old gpt.S mbr code looks at both primary and alternate GPT
partition tables, mbrgpt.S and DKWEDGE_METHOD_GPT only look in the
primary.  Align the bootxx/boot2 biosdisk code with this so as to avoid
situations where the disk becomes unbootable when it has an undestroyed
secondary GPT.


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 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.43 src/sys/arch/i386/stand/lib/biosdisk.c:1.44
--- src/sys/arch/i386/stand/lib/biosdisk.c:1.43	Thu Oct 31 20:31:04 2013
+++ src/sys/arch/i386/stand/lib/biosdisk.c	Sun Jan 18 20:18:07 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: biosdisk.c,v 1.43 2013/10/31 20:31:04 christos Exp $	*/
+/*	$NetBSD: biosdisk.c,v 1.44 2015/01/18 20:18:07 jakllsch Exp $	*/
 
 /*
  * Copyright (c) 1996, 1998
@@ -330,9 +330,6 @@ read_gpt(struct biosdisk *d)
 		gptsector[1] = d->ll.chs_sectors - 1;
 	}
 
-	/*
-	 * Use any valid GPT available, do not require both GPTs to be valid
-	 */
 	for (i = 0; i < __arraycount(gptsector); i++) {
 		error = check_gpt(d, gptsector[i]);
 		if (error == 0)
@@ -344,6 +341,15 @@ read_gpt(struct biosdisk *d)
 		return -1;
 	}
 
+#ifndef USE_SECONDARY_GPT
+	if (i > 0) {
+#ifdef DISK_DEBUG
+		printf("ignoring valid secondary GPT\n");
+#endif
+		return -1;
+	}
+#endif
+
 #ifdef DISK_DEBUG
 	printf("using %s GPT\n", (i == 0) ? "primary" : "secondary");
 #endif



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

2014-07-19 Thread Eric Haszlakiewicz
Module Name:src
Committed By:   erh
Date:   Sat Jul 19 14:50:21 UTC 2014

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

Log Message:
Fix bootxx_* and boot on machines where the bios sets high bits of %eax on 
success.


To generate a diff of this commit:
cvs rdiff -u -r1.21 -r1.22 src/sys/arch/i386/stand/lib/bios_disk.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/bios_disk.S
diff -u src/sys/arch/i386/stand/lib/bios_disk.S:1.21 src/sys/arch/i386/stand/lib/bios_disk.S:1.22
--- src/sys/arch/i386/stand/lib/bios_disk.S:1.21	Thu Jun 16 13:27:59 2011
+++ src/sys/arch/i386/stand/lib/bios_disk.S	Sat Jul 19 14:50:21 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: bios_disk.S,v 1.21 2011/06/16 13:27:59 joerg Exp $	*/
+/*	$NetBSD: bios_disk.S,v 1.22 2014/07/19 14:50:21 erh Exp $	*/
 
 /*
  * Ported to boot 386BSD by Julian Elischer (jul...@tfs.com) Sept 1992
@@ -133,6 +133,9 @@ ENTRY(biosdisk_read)
 	calll	_C_LABEL(real_to_prot) # back to protected mode
 	.code32
 
+	andl$0x, %eax  # Some bioses set high bits in %eax
+	   #  on success, interfering with our
+	   #  return value.  Clear those out.
 	movl	%eax, 28(%esp)
 
 	popa



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

2014-04-08 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Tue Apr  8 15:34:18 UTC 2014

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

Log Message:
make this more attractive (to me).


To generate a diff of this commit:
cvs rdiff -u -r1.39 -r1.40 src/sys/arch/i386/stand/lib/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/lib/Makefile
diff -u src/sys/arch/i386/stand/lib/Makefile:1.39 src/sys/arch/i386/stand/lib/Makefile:1.40
--- src/sys/arch/i386/stand/lib/Makefile:1.39	Tue Apr  8 09:56:04 2014
+++ src/sys/arch/i386/stand/lib/Makefile	Tue Apr  8 11:34:18 2014
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.39 2014/04/08 13:56:04 joerg Exp $
+#	$NetBSD: Makefile,v 1.40 2014/04/08 15:34:18 christos Exp $
 
 S?=	${.CURDIR}/../../../..
 
@@ -57,6 +57,6 @@ lib${LIB}.o:: ${OBJS}
 .if ${HAVE_GCC:U} == 45
 COPTS.biosdisk.c+=	-fno-strict-aliasing
 .endif
-.if ${HAVE_GCC:U} == 48
-COPTS.biosdisk_ll.c+=	${${ACTIVE_CC} == "gcc":?-O0:}
+.if ${ACTIVE_CC} == "gcc" && ${HAVE_GCC:U} == 48
+COPTS.biosdisk_ll.c+=	-O0
 .endif



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

2014-04-08 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Tue Apr  8 13:56:04 UTC 2014

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

Log Message:
Unbreak clang build by restricting -O0 hack to gcc.


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 src/sys/arch/i386/stand/lib/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/lib/Makefile
diff -u src/sys/arch/i386/stand/lib/Makefile:1.38 src/sys/arch/i386/stand/lib/Makefile:1.39
--- src/sys/arch/i386/stand/lib/Makefile:1.38	Mon Apr  7 21:09:55 2014
+++ src/sys/arch/i386/stand/lib/Makefile	Tue Apr  8 13:56:04 2014
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.38 2014/04/07 21:09:55 christos Exp $
+#	$NetBSD: Makefile,v 1.39 2014/04/08 13:56:04 joerg Exp $
 
 S?=	${.CURDIR}/../../../..
 
@@ -58,5 +58,5 @@ lib${LIB}.o:: ${OBJS}
 COPTS.biosdisk.c+=	-fno-strict-aliasing
 .endif
 .if ${HAVE_GCC:U} == 48
-COPTS.biosdisk_ll.c+=	-O0
+COPTS.biosdisk_ll.c+=	${${ACTIVE_CC} == "gcc":?-O0:}
 .endif



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

2014-04-07 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Mon Apr  7 21:09:55 UTC 2014

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

Log Message:
XXX: gcc-4.8 bug. Passes wrong arguments to biosdisk_read(). Turn optimization
off.


To generate a diff of this commit:
cvs rdiff -u -r1.37 -r1.38 src/sys/arch/i386/stand/lib/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/lib/Makefile
diff -u src/sys/arch/i386/stand/lib/Makefile:1.37 src/sys/arch/i386/stand/lib/Makefile:1.38
--- src/sys/arch/i386/stand/lib/Makefile:1.37	Fri Feb 14 15:34:27 2014
+++ src/sys/arch/i386/stand/lib/Makefile	Mon Apr  7 17:09:55 2014
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.37 2014/02/14 20:34:27 joerg Exp $
+#	$NetBSD: Makefile,v 1.38 2014/04/07 21:09:55 christos Exp $
 
 S?=	${.CURDIR}/../../../..
 
@@ -57,3 +57,6 @@ lib${LIB}.o:: ${OBJS}
 .if ${HAVE_GCC:U} == 45
 COPTS.biosdisk.c+=	-fno-strict-aliasing
 .endif
+.if ${HAVE_GCC:U} == 48
+COPTS.biosdisk_ll.c+=	-O0
+.endif



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

2014-04-06 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sun Apr  6 19:18:00 UTC 2014

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

Log Message:
Misc WARNS=4 fixes.


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 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.58 src/sys/arch/i386/stand/lib/exec.c:1.59
--- src/sys/arch/i386/stand/lib/exec.c:1.58	Fri Jan 10 17:40:51 2014
+++ src/sys/arch/i386/stand/lib/exec.c	Sun Apr  6 19:18:00 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: exec.c,v 1.58 2014/01/10 17:40:51 jakllsch Exp $	 */
+/*	$NetBSD: exec.c,v 1.59 2014/04/06 19:18:00 jakllsch Exp $	 */
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -418,7 +418,7 @@ out:
 static void
 extract_device(const char *path, char *buf, size_t buflen)
 {
-	int i;
+	size_t i;
 
 	if (strchr(path, ':') != NULL) {
 		for (i = 0; i < buflen - 2 && path[i] != ':'; i++)
@@ -440,7 +440,7 @@ module_path(boot_module_t *bm, const cha
 	for (name2 = name; *name2; ++name2) {
 		if (*name2 == ' ' || *name2 == '\t') {
 			strlcpy(name_buf, name, sizeof(name_buf));
-			if (name2 - name < sizeof(name_buf))
+			if ((uintptr_t)name2 - (uintptr_t)name < sizeof(name_buf))
 name_buf[name2 - name] = '\0';
 			name = name_buf;
 			break;
@@ -504,7 +504,7 @@ module_init(const char *kernel_path)
 	char kdev[64];
 	char *buf;
 	boot_module_t *bm;
-	size_t len;
+	ssize_t len;
 	off_t off;
 	int err, fd, nfail = 0;
 



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

2014-04-06 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sun Apr  6 19:11:26 UTC 2014

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

Log Message:
Use __dead.


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/i386/stand/lib/bootmenu.c
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/i386/stand/lib/menuutils.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/bootmenu.c
diff -u src/sys/arch/i386/stand/lib/bootmenu.c:1.11 src/sys/arch/i386/stand/lib/bootmenu.c:1.12
--- src/sys/arch/i386/stand/lib/bootmenu.c:1.11	Sun Jul 28 08:50:09 2013
+++ src/sys/arch/i386/stand/lib/bootmenu.c	Sun Apr  6 19:11:26 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: bootmenu.c,v 1.11 2013/07/28 08:50:09 he Exp $	*/
+/*	$NetBSD: bootmenu.c,v 1.12 2014/04/06 19:11:26 jakllsch Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -345,7 +345,7 @@ bootdefault(void)
 	}
 }
 
-void
+__dead void
 doboottypemenu(void)
 {
 	int choice;

Index: src/sys/arch/i386/stand/lib/menuutils.c
diff -u src/sys/arch/i386/stand/lib/menuutils.c:1.3 src/sys/arch/i386/stand/lib/menuutils.c:1.4
--- src/sys/arch/i386/stand/lib/menuutils.c:1.3	Sun Dec 14 18:46:33 2008
+++ src/sys/arch/i386/stand/lib/menuutils.c	Sun Apr  6 19:11:26 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: menuutils.c,v 1.3 2008/12/14 18:46:33 christos Exp $	*/
+/*	$NetBSD: menuutils.c,v 1.4 2014/04/06 19:11:26 jakllsch Exp $	*/
 
 /*
  * Copyright (c) 1996, 1997
@@ -61,7 +61,7 @@ docommand(char *arg)
 	command_help(NULL);
 }
 
-void
+__dead void
 bootmenu(void)
 {
 	char input[80];



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

2014-02-14 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Fri Feb 14 20:34:28 UTC 2014

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

Log Message:
Only realprot.S still needs to be built with GNU as.


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 src/sys/arch/i386/stand/lib/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/lib/Makefile
diff -u src/sys/arch/i386/stand/lib/Makefile:1.36 src/sys/arch/i386/stand/lib/Makefile:1.37
--- src/sys/arch/i386/stand/lib/Makefile:1.36	Fri Aug 10 12:18:15 2012
+++ src/sys/arch/i386/stand/lib/Makefile	Fri Feb 14 20:34:27 2014
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.36 2012/08/10 12:18:15 joerg Exp $
+#	$NetBSD: Makefile,v 1.37 2014/02/14 20:34:27 joerg Exp $
 
 S?=	${.CURDIR}/../../../..
 
@@ -11,27 +11,6 @@ I386_INCLUDE_DOS?= no
 I386_INCLUDE_BUS?= no
 I386_INCLUDE_PS2?= yes
 
-AFLAGS.biosdelay.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:}
-AFLAGS.biosgetrtc.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:}
-AFLAGS.biosgetsystime.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:}
-AFLAGS.biosmca.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:}
-AFLAGS.biosmemps2.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:}
-AFLAGS.biosmem.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:}
-AFLAGS.biosmemx.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:}
-AFLAGS.biosreboot.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:}
-AFLAGS.biosvbe.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:}
-AFLAGS.biosvideomode.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:}
-AFLAGS.bios_disk.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:}
-AFLAGS.bios_pci.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:}
-AFLAGS.comio.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:}
-AFLAGS.conio.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:}
-AFLAGS.dos_file.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:}
-AFLAGS.dump_eax.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:}
-AFLAGS.message.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:}
-AFLAGS.message32.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:}
-AFLAGS.pvcopy.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:}
-AFLAGS.putstr.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:}
-AFLAGS.putstr32.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:}
 AFLAGS.realprot.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:}
 
 CPPFLAGS= -I$S/lib/libsa ${I386CPPFLAGS} ${I386MISCCPPFLAGS}



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

2014-01-10 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Fri Jan 10 17:40:51 UTC 2014

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

Log Message:
fix style and whitespace nits


To generate a diff of this commit:
cvs rdiff -u -r1.57 -r1.58 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.57 src/sys/arch/i386/stand/lib/exec.c:1.58
--- src/sys/arch/i386/stand/lib/exec.c:1.57	Sun Jan  5 21:36:50 2014
+++ src/sys/arch/i386/stand/lib/exec.c	Fri Jan 10 17:40:51 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: exec.c,v 1.57 2014/01/05 21:36:50 jakllsch Exp $	 */
+/*	$NetBSD: exec.c,v 1.58 2014/01/10 17:40:51 jakllsch Exp $	 */
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -386,7 +386,7 @@ exec_netbsd(const char *file, physaddr_t
 	userconf_init();
 	if (btinfo_userconfcommands != NULL)
 		BI_ADD(btinfo_userconfcommands, BTINFO_USERCONFCOMMANDS,
-	btinfo_userconfcommands_size);
+		btinfo_userconfcommands_size);
 
 #ifdef DEBUG
 	printf("Start @ 0x%lx [%ld=0x%lx-0x%lx]...\n", marks[MARK_ENTRY],
@@ -458,7 +458,7 @@ module_path(boot_module_t *bm, const cha
 		}
 	} else {
 		/* device not specified; load from kernel device if known */
- 		if (name[0] == '/')
+		if (name[0] == '/')
 			snprintf(buf, sizeof(buf), "%s%s", kdev, name);
 		else
 			snprintf(buf, sizeof(buf), "%s%s/%s/%s.kmod",



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

2014-01-05 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sun Jan  5 21:36:50 UTC 2014

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

Log Message:
Make name argument to module_add_common const; use this to allow the libsa
fsmod string to soon become const.


To generate a diff of this commit:
cvs rdiff -u -r1.56 -r1.57 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.56 src/sys/arch/i386/stand/lib/exec.c:1.57
--- src/sys/arch/i386/stand/lib/exec.c:1.56	Mon Dec 30 21:45:51 2013
+++ src/sys/arch/i386/stand/lib/exec.c	Sun Jan  5 21:36:50 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: exec.c,v 1.56 2013/12/30 21:45:51 jakllsch Exp $	 */
+/*	$NetBSD: exec.c,v 1.57 2014/01/05 21:36:50 jakllsch Exp $	 */
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -144,7 +144,7 @@ static struct btinfo_userconfcommands *b
 static size_t btinfo_userconfcommands_size = 0;
 
 static void	module_init(const char *);
-static void	module_add_common(char *, uint8_t);
+static void	module_add_common(const char *, uint8_t);
 
 static void	userconf_init(void);
 
@@ -184,7 +184,7 @@ fs_add(char *name)
 }
 
 static void
-module_add_common(char *name, uint8_t type)
+module_add_common(const char *name, uint8_t type)
 {
 	boot_module_t *bm, *bmp;
 	size_t len;
@@ -305,7 +305,7 @@ common_load_kernel(const char *file, u_l
 
 	/* If the root fs type is unusual, load its module. */
 	if (fsmod != NULL)
-		module_add(fsmod);
+		module_add_common(fsmod, BM_TYPE_KMOD);
 
 	/*
 	 * Gather some information for the kernel. Do this after the



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

2014-01-05 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sun Jan  5 20:52:57 UTC 2014

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

Log Message:
No need to return a empty string literal of the wrong const-ness when we
already have a empty string of the correct const-ness.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/i386/stand/lib/parseutils.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/parseutils.c
diff -u src/sys/arch/i386/stand/lib/parseutils.c:1.6 src/sys/arch/i386/stand/lib/parseutils.c:1.7
--- src/sys/arch/i386/stand/lib/parseutils.c:1.6	Thu Aug 18 13:20:04 2011
+++ src/sys/arch/i386/stand/lib/parseutils.c	Sun Jan  5 20:52:57 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: parseutils.c,v 1.6 2011/08/18 13:20:04 christos Exp $	*/
+/*	$NetBSD: parseutils.c,v 1.7 2014/01/05 20:52:57 jakllsch Exp $	*/
 
 /*
  * Copyright (c) 1996, 1997
@@ -64,7 +64,7 @@ gettrailer(char *arg)
 		break;
 	}
 	if (*options == '\0')
-		return "";
+		return options;
 
 	/* trim leading blanks/tabs */
 	while (*options == ' ' || *options == '\t')



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

2014-01-05 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sun Jan  5 20:49:20 UTC 2014

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

Log Message:
don't shadow local variable


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 src/sys/arch/i386/stand/lib/comio_direct.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/comio_direct.c
diff -u src/sys/arch/i386/stand/lib/comio_direct.c:1.10 src/sys/arch/i386/stand/lib/comio_direct.c:1.11
--- src/sys/arch/i386/stand/lib/comio_direct.c:1.10	Sun Dec 14 18:46:33 2008
+++ src/sys/arch/i386/stand/lib/comio_direct.c	Sun Jan  5 20:49:20 2014
@@ -1,4 +1,4 @@
-/*	$NetBSD: comio_direct.c,v 1.10 2008/12/14 18:46:33 christos Exp $	*/
+/*	$NetBSD: comio_direct.c,v 1.11 2014/01/05 20:49:20 jakllsch Exp $	*/
 
 /*-
  * Copyright (c) 1993, 1994, 1995, 1996, 1997
@@ -150,9 +150,9 @@ computc_d(int c, int combase)
 
 	/* check for new XOFF */
 	if (comstatus_d(combase)) {
-		int c = comgetc_d(combase);	/* XOFF handled in comgetc_d */
+		int x = comgetc_d(combase);	/* XOFF handled in comgetc_d */
 		/* stuff char into preread buffer */
-		serbuf[serbuf_write++] = c;
+		serbuf[serbuf_write++] = x;
 		if (serbuf_write >= SERBUFSIZE)
 			serbuf_write = 0;
 	}



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

2013-12-30 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Mon Dec 30 21:45:51 UTC 2013

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

Log Message:
Zero out on-stack 'marks' array before first use.
This is needed so the MARK_DATA index is properly filled in.


To generate a diff of this commit:
cvs rdiff -u -r1.55 -r1.56 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.55 src/sys/arch/i386/stand/lib/exec.c:1.56
--- src/sys/arch/i386/stand/lib/exec.c:1.55	Wed Nov 27 18:29:45 2013
+++ src/sys/arch/i386/stand/lib/exec.c	Mon Dec 30 21:45:51 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: exec.c,v 1.55 2013/11/27 18:29:45 jakllsch Exp $	 */
+/*	$NetBSD: exec.c,v 1.56 2013/12/30 21:45:51 jakllsch Exp $	 */
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -362,6 +362,8 @@ exec_netbsd(const char *file, physaddr_t
 
 	howto = boothowto;
 
+	memset(marks, 0, sizeof(marks));
+
 	if (common_load_kernel(file, &basemem, &extmem, loadaddr, floppy, marks))
 		goto out;
 



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

2013-12-24 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Tue Dec 24 19:00:56 UTC 2013

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

Log Message:
Obtain CR0_PE constant from  rather than a local #define.


To generate a diff of this commit:
cvs rdiff -u -r1.10 -r1.11 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.10 src/sys/arch/i386/stand/lib/realprot.S:1.11
--- src/sys/arch/i386/stand/lib/realprot.S:1.10	Sun Dec 19 17:18:23 2010
+++ src/sys/arch/i386/stand/lib/realprot.S	Tue Dec 24 19:00:56 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: realprot.S,v 1.10 2010/12/19 17:18:23 jakllsch Exp $	*/
+/*	$NetBSD: realprot.S,v 1.11 2013/12/24 19:00:56 jakllsch Exp $	*/
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -34,8 +34,7 @@
  */
 
 #include 
-
-#define	CR0_PE		1
+#include 
 
 	.text
 	.align  16



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

2013-11-27 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Wed Nov 27 18:29:45 UTC 2013

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

Log Message:
Use the size of what's at the bootinfo_userconf pointer, not the size
of the pointer itself.


To generate a diff of this commit:
cvs rdiff -u -r1.54 -r1.55 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.54 src/sys/arch/i386/stand/lib/exec.c:1.55
--- src/sys/arch/i386/stand/lib/exec.c:1.54	Sun Nov 24 17:20:00 2013
+++ src/sys/arch/i386/stand/lib/exec.c	Wed Nov 27 18:29:45 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: exec.c,v 1.54 2013/11/24 17:20:00 jakllsch Exp $	 */
+/*	$NetBSD: exec.c,v 1.55 2013/11/27 18:29:45 jakllsch Exp $	 */
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -636,7 +636,7 @@ userconf_init(void)
 	count = 0;
 	for (uc = userconf_commands; uc != NULL; uc = uc->uc_next)
 		count++;
-	len = sizeof(btinfo_userconfcommands) +
+	len = sizeof(*btinfo_userconfcommands) +
 	  count * sizeof(struct bi_userconfcommand);
 
 	/* Allocate the userconf commands list */



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

2013-11-24 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sun Nov 24 17:20:01 UTC 2013

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

Log Message:
The x86 kernel entry point stack arguments are always 32-bit, even on amd64.


To generate a diff of this commit:
cvs rdiff -u -r1.53 -r1.54 src/sys/arch/i386/stand/lib/exec.c
cvs rdiff -u -r1.39 -r1.40 src/sys/arch/i386/stand/lib/libi386.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/lib/exec.c
diff -u src/sys/arch/i386/stand/lib/exec.c:1.53 src/sys/arch/i386/stand/lib/exec.c:1.54
--- src/sys/arch/i386/stand/lib/exec.c:1.53	Sun Nov 24 17:17:48 2013
+++ src/sys/arch/i386/stand/lib/exec.c	Sun Nov 24 17:20:00 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: exec.c,v 1.53 2013/11/24 17:17:48 jakllsch Exp $	 */
+/*	$NetBSD: exec.c,v 1.54 2013/11/24 17:20:00 jakllsch Exp $	 */
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -345,7 +345,7 @@ int
 exec_netbsd(const char *file, physaddr_t loadaddr, int boothowto, int floppy,
 	void (*callback)(void))
 {
-	u_long  boot_argv[BOOT_NARGS];
+	uint32_t	boot_argv[BOOT_NARGS];
 	u_long		marks[MARK_MAX];
 	struct btinfo_symtab btinfo_symtab;
 	u_long		extmem;

Index: src/sys/arch/i386/stand/lib/libi386.h
diff -u src/sys/arch/i386/stand/lib/libi386.h:1.39 src/sys/arch/i386/stand/lib/libi386.h:1.40
--- src/sys/arch/i386/stand/lib/libi386.h:1.39	Fri Aug 30 16:42:17 2013
+++ src/sys/arch/i386/stand/lib/libi386.h	Sun Nov 24 17:20:00 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: libi386.h,v 1.39 2013/08/30 16:42:17 jmcneill Exp $	*/
+/*	$NetBSD: libi386.h,v 1.40 2013/11/24 17:20:00 jakllsch Exp $	*/
 
 /*
  * Copyright (c) 1996
@@ -35,7 +35,7 @@ void pbzero(void *, size_t);
 physaddr_t vtophys(void *);
 
 ssize_t pread(int, void *, size_t);
-void startprog(physaddr_t, int, unsigned long *, physaddr_t);
+void startprog(physaddr_t, uint32_t, uint32_t *, physaddr_t);
 void multiboot(physaddr_t, physaddr_t, physaddr_t);
 
 int exec_netbsd(const char *, physaddr_t, int, int, void (*)(void));



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

2013-11-24 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sun Nov 24 17:17:48 UTC 2013

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

Log Message:
use  instead of  so this can be
compiled for amd64


To generate a diff of this commit:
cvs rdiff -u -r1.52 -r1.53 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.52 src/sys/arch/i386/stand/lib/exec.c:1.53
--- src/sys/arch/i386/stand/lib/exec.c:1.52	Sun Nov 24 17:16:29 2013
+++ src/sys/arch/i386/stand/lib/exec.c	Sun Nov 24 17:17:48 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: exec.c,v 1.52 2013/11/24 17:16:29 jakllsch Exp $	 */
+/*	$NetBSD: exec.c,v 1.53 2013/11/24 17:17:48 jakllsch Exp $	 */
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -97,7 +97,7 @@
 #include 
 #include 
 
-#include 
+#include 
 
 #include 
 #include 



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

2013-11-24 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sun Nov 24 17:16:30 UTC 2013

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

Log Message:
cast from 32-bit integer to void * though uintptr_t to avoid warnings
when compiling for x86_64.


To generate a diff of this commit:
cvs rdiff -u -r1.51 -r1.52 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.51 src/sys/arch/i386/stand/lib/exec.c:1.52
--- src/sys/arch/i386/stand/lib/exec.c:1.51	Fri Aug 30 16:42:17 2013
+++ src/sys/arch/i386/stand/lib/exec.c	Sun Nov 24 17:16:29 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: exec.c,v 1.51 2013/08/30 16:42:17 jmcneill Exp $	 */
+/*	$NetBSD: exec.c,v 1.52 2013/11/24 17:16:29 jakllsch Exp $	 */
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -578,7 +578,7 @@ module_init(const char *kernel_path)
 		if (fd == -1)
 			continue;
 		image_end = (image_end + PAGE_SIZE - 1) & ~(PAGE_SIZE - 1);
-		len = pread(fd, (void *)image_end, SSIZE_MAX);
+		len = pread(fd, (void *)(uintptr_t)image_end, SSIZE_MAX);
 		if (len < bm->bm_len) {
 			if ((howto & AB_SILENT) != 0)
 printf("Loading %s ", bm->bm_path);



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

2013-11-17 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Mon Nov 18 03:52:45 UTC 2013

Modified Files:
src/sys/arch/i386/stand/lib: bootinfo.h

Log Message:
Bring arch/i386/stand bootinfo structure in line with the kernel's
fixed-layout understanding of it.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/i386/stand/lib/bootinfo.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/lib/bootinfo.h
diff -u src/sys/arch/i386/stand/lib/bootinfo.h:1.9 src/sys/arch/i386/stand/lib/bootinfo.h:1.10
--- src/sys/arch/i386/stand/lib/bootinfo.h:1.9	Wed Jan 25 18:28:26 2006
+++ src/sys/arch/i386/stand/lib/bootinfo.h	Mon Nov 18 03:52:45 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: bootinfo.h,v 1.9 2006/01/25 18:28:26 christos Exp $	*/
+/*	$NetBSD: bootinfo.h,v 1.10 2013/11/18 03:52:45 jakllsch Exp $	*/
 
 /*
  * Copyright (c) 1997
@@ -29,14 +29,14 @@
 #include 
 
 struct bootinfo {
-	int nentries;
-	physaddr_t entry[1];
+	uint32_t nentries;
+	uint32_t entry[1];
 };
 
 extern struct bootinfo *bootinfo;
 
 #define BI_ALLOC(max) (bootinfo = alloc(sizeof(struct bootinfo) \
-+ ((max) - 1) * sizeof(physaddr_t))) \
++ ((max) - 1) * sizeof(uint32_t))) \
   ->nentries = 0
 
 #define BI_FREE() dealloc(bootinfo, 0)



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

2013-10-31 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Oct 31 20:31:04 UTC 2013

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

Log Message:
avoid pointer aliasing problems.


To generate a diff of this commit:
cvs rdiff -u -r1.42 -r1.43 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.42 src/sys/arch/i386/stand/lib/biosdisk.c:1.43
--- src/sys/arch/i386/stand/lib/biosdisk.c:1.42	Tue Jul  3 11:24:37 2012
+++ src/sys/arch/i386/stand/lib/biosdisk.c	Thu Oct 31 16:31:04 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: biosdisk.c,v 1.42 2012/07/03 15:24:37 tsutsui Exp $	*/
+/*	$NetBSD: biosdisk.c,v 1.43 2013/10/31 20:31:04 christos Exp $	*/
 
 /*
  * Copyright (c) 1996, 1998
@@ -118,6 +118,8 @@ static struct btinfo_bootdisk bi_disk;
 static struct btinfo_bootwedge bi_wedge;
 #endif
 
+#define MBR_PARTS(buf) ((char *)(buf) + offsetof(struct mbr_sector, mbr_parts))
+
 #define	RF_PROTECTED_SECTORS	64	/* XXX refer to <.../rf_optnames.h> */
 
 int
@@ -231,7 +233,7 @@ check_gpt(struct biosdisk *d, daddr_t se
 		return EIO;
 	}
 
-	gpth = *(const struct gpt_hdr *)d->buf;
+	memcpy(&gpth, d->buf, sizeof(gpth));
 
 	if (memcmp(GPT_HDR_SIG, gpth.hdr_sig, sizeof(gpth.hdr_sig)))
 		return -1;
@@ -423,7 +425,7 @@ read_minix_subp(struct biosdisk *d, stru
 	if ((uint8_t)d->buf[510] != 0x55 || (uint8_t)d->buf[511] != 0xAA) {
 		return -1;
 	}
-	memcpy(&mbr, ((struct mbr_sector *)d->buf)->mbr_parts, sizeof(mbr));
+	memcpy(&mbr, MBR_PARTS(d->buf), sizeof(mbr));
 	for (i = 0; i < MBR_PART_COUNT; i++) {
 		typ = mbr[i].mbrp_type;
 		if (typ == 0)
@@ -478,8 +480,7 @@ read_label(struct biosdisk *d)
 #endif
 			return EIO;
 		}
-		memcpy(&mbr, ((struct mbr_sector *)d->buf)->mbr_parts,
-		   sizeof(mbr));
+		memcpy(&mbr, MBR_PARTS(d->buf), sizeof(mbr));
 		/* Look for NetBSD partition ID */
 		for (i = 0; i < MBR_PART_COUNT; i++) {
 			typ = mbr[i].mbrp_type;



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

2013-10-20 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Sun Oct 20 21:06:37 UTC 2013

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

Log Message:
remove unused variable


To generate a diff of this commit:
cvs rdiff -u -r1.15 -r1.16 src/sys/arch/i386/stand/lib/dosfile.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/dosfile.c
diff -u src/sys/arch/i386/stand/lib/dosfile.c:1.15 src/sys/arch/i386/stand/lib/dosfile.c:1.16
--- src/sys/arch/i386/stand/lib/dosfile.c:1.15	Thu Jun 16 09:27:59 2011
+++ src/sys/arch/i386/stand/lib/dosfile.c	Sun Oct 20 17:06:37 2013
@@ -1,4 +1,4 @@
-/*	$NetBSD: dosfile.c,v 1.15 2011/06/16 13:27:59 joerg Exp $	 */
+/*	$NetBSD: dosfile.c,v 1.16 2013/10/20 21:06:37 christos Exp $	 */
 
 /*
  * Copyright (c) 1996
@@ -178,9 +178,6 @@ dos_write(struct open_file *f, void *sta
 __compactcall int
 dos_stat(struct open_file *f, struct stat *sb)
 {
-	struct dosfile *df;
-	df = (struct dosfile *) f->f_fsdata;
-
 	sb->st_mode = 0444;
 	sb->st_nlink = 1;
 	sb->st_uid = 0;



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

2013-05-31 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Fri May 31 15:11:07 UTC 2013

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

Log Message:
The 'vesa' command can take 'list' flag so mention it in an error message.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/i386/stand/lib/vbe.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/vbe.c
diff -u src/sys/arch/i386/stand/lib/vbe.c:1.7 src/sys/arch/i386/stand/lib/vbe.c:1.8
--- src/sys/arch/i386/stand/lib/vbe.c:1.7	Wed Feb  9 04:37:54 2011
+++ src/sys/arch/i386/stand/lib/vbe.c	Fri May 31 15:11:07 2013
@@ -1,4 +1,4 @@
-/* $NetBSD: vbe.c,v 1.7 2011/02/09 04:37:54 jmcneill Exp $ */
+/* $NetBSD: vbe.c,v 1.8 2013/05/31 15:11:07 tsutsui Exp $ */
 
 /*-
  * Copyright (c) 2009 Jared D. McNeill 
@@ -414,6 +414,6 @@ command_vesa(char *cmd)
 		return;
 	}
 
-	printf("invalid flag, must be 'on', 'off', "
+	printf("invalid flag, must be 'on', 'off', 'list', "
 	"a display mode, or a VBE mode number\n");
 }



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

2012-07-03 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Tue Jul  3 15:24:37 UTC 2012

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

Log Message:
Apply patch:
 PR/46583: BIOS bootloader problems with partitions that start above 1TB

Should be pulled up to netbsd-6.


To generate a diff of this commit:
cvs rdiff -u -r1.41 -r1.42 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.41 src/sys/arch/i386/stand/lib/biosdisk.c:1.42
--- src/sys/arch/i386/stand/lib/biosdisk.c:1.41	Wed Jun 13 18:34:20 2012
+++ src/sys/arch/i386/stand/lib/biosdisk.c	Tue Jul  3 15:24:37 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: biosdisk.c,v 1.41 2012/06/13 18:34:20 perseant Exp $	*/
+/*	$NetBSD: biosdisk.c,v 1.42 2012/07/03 15:24:37 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 1996, 1998
@@ -416,7 +416,7 @@ read_minix_subp(struct biosdisk *d, stru
 
 	if (readsects(&d->ll, sector, 1, d->buf, 0)) {
 #ifdef DISK_DEBUG
-		printf("Error reading MFS sector %d\n", sector);
+		printf("Error reading MFS sector %"PRId64"\n", sector);
 #endif
 		return EIO;
 	}
@@ -445,10 +445,11 @@ read_label(struct biosdisk *d)
 	struct disklabel dflt_lbl;
 	struct mbr_partition mbr[MBR_PART_COUNT];
 	struct partition *p;
-	int sector, i;
+	uint32_t sector;
+	int i;
 	int error;
 	int typ;
-	int ext_base, this_ext, next_ext;
+	uint32_t ext_base, this_ext, next_ext;
 #ifdef COMPAT_386BSD_MBRPART
 	int sector_386bsd = -1;
 #endif
@@ -473,7 +474,7 @@ read_label(struct biosdisk *d)
 		next_ext = 0;
 		if (readsects(&d->ll, this_ext, 1, d->buf, 0)) {
 #ifdef DISK_DEBUG
-			printf("error reading MBR sector %d\n", this_ext);
+			printf("error reading MBR sector %u\n", this_ext);
 #endif
 			return EIO;
 		}
@@ -486,7 +487,7 @@ read_label(struct biosdisk *d)
 continue;
 			sector = this_ext + mbr[i].mbrp_start;
 #ifdef DISK_DEBUG
-			printf("ptn type %d in sector %d\n", typ, sector);
+			printf("ptn type %d in sector %u\n", typ, sector);
 #endif
 if (typ == MBR_PTYPE_MINIX_14B) {
 if (!read_minix_subp(d, &dflt_lbl,



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

2012-06-13 Thread Konrad Schroder
Module Name:src
Committed By:   perseant
Date:   Wed Jun 13 18:34:20 UTC 2012

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

Log Message:
Sanity check the values coming back from the int13 extensions of the bios,
so we can catch impossible return values.  Allows the bootloader to work
again on the Soekris net4501.

Fixes PR kern/46027.


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 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.40 src/sys/arch/i386/stand/lib/biosdisk.c:1.41
--- src/sys/arch/i386/stand/lib/biosdisk.c:1.40	Mon Jan 16 18:47:57 2012
+++ src/sys/arch/i386/stand/lib/biosdisk.c	Wed Jun 13 18:34:20 2012
@@ -1,4 +1,4 @@
-/*	$NetBSD: biosdisk.c,v 1.40 2012/01/16 18:47:57 christos Exp $	*/
+/*	$NetBSD: biosdisk.c,v 1.41 2012/06/13 18:34:20 perseant Exp $	*/
 
 /*
  * Copyright (c) 1996, 1998
@@ -316,7 +316,9 @@ read_gpt(struct biosdisk *d)
 	gptsector[0] = GPT_HDR_BLKNO;
 	if (set_geometry(&d->ll, &ed) == 0 && d->ll.flags & BIOSDISK_INT13EXT) {
 		gptsector[1] = ed.totsec - 1;
-		d->ll.secsize = ed.sbytes;
+		/* Sanity check values returned from BIOS */
+		if (ed.sbytes >= 512 && (ed.sbytes & (ed.sbytes - 1)) == 0)
+			d->ll.secsize = ed.sbytes;
 	} else {
 #ifdef DISK_DEBUG
 		printf("Unable to determine extended disk geometry - "



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

2011-09-21 Thread Grégoire Sutre
Module Name:src
Committed By:   gsutre
Date:   Wed Sep 21 08:57:12 UTC 2011

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

Log Message:
Fix btinfo_bootdisk's labelsector and btinfo_bootwedge's startblk for
the non-GPT case.

ok jakllsch@


To generate a diff of this commit:
cvs rdiff -u -r1.38 -r1.39 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.38 src/sys/arch/i386/stand/lib/biosdisk.c:1.39
--- src/sys/arch/i386/stand/lib/biosdisk.c:1.38	Sun Jul 17 20:54:41 2011
+++ src/sys/arch/i386/stand/lib/biosdisk.c	Wed Sep 21 08:57:12 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: biosdisk.c,v 1.38 2011/07/17 20:54:41 joerg Exp $	*/
+/*	$NetBSD: biosdisk.c,v 1.39 2011/09/21 08:57:12 gsutre Exp $	*/
 
 /*
  * Copyright (c) 1996, 1998
@@ -389,12 +389,12 @@
 	ingest_label(d, lp);
 
 #ifdef _STANDALONE
-	bi_disk.labelsector = d->boff + LABELSECTOR;
+	bi_disk.labelsector = sector + LABELSECTOR;
 	bi_disk.label.type = lp->d_type;
 	memcpy(bi_disk.label.packname, lp->d_packname, 16);
 	bi_disk.label.checksum = lp->d_checksum;
 
-	bi_wedge.matchblk = d->boff + LABELSECTOR;
+	bi_wedge.matchblk = sector + LABELSECTOR;
 	bi_wedge.matchnblks = 1;
 
 	md5(bi_wedge.matchhash, d->buf, d->ll.secsize);



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

2011-08-18 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Thu Aug 18 13:20:04 UTC 2011

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

Log Message:
PR/43563: Wolfgang Solfrank: boot.cfg doesn't support comments
Fix makes it support # comments and treat spaces and tabs the same way.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 src/sys/arch/i386/stand/lib/bootmenu.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/i386/stand/lib/parseutils.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/bootmenu.c
diff -u src/sys/arch/i386/stand/lib/bootmenu.c:1.9 src/sys/arch/i386/stand/lib/bootmenu.c:1.10
--- src/sys/arch/i386/stand/lib/bootmenu.c:1.9	Thu May 26 00:25:27 2011
+++ src/sys/arch/i386/stand/lib/bootmenu.c	Thu Aug 18 09:20:04 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: bootmenu.c,v 1.9 2011/05/26 04:25:27 uebayasi Exp $	*/
+/*	$NetBSD: bootmenu.c,v 1.10 2011/08/18 13:20:04 christos Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -101,7 +101,7 @@
 	int cmenu, cbanner, len;
 	int fd, err, off;
 	struct stat st;
-	char *key, *value, *v2;
+	char *next, *key, *value, *v2;
 
 	/* Clear bootconf structure */
 	memset((void *)&bootconf, 0, sizeof(bootconf));
@@ -157,13 +157,22 @@
 
 	cmenu = 0;
 	cbanner = 0;
-	for (c = bc; *c; c++) {
+	for (c = bc; *c; c = next) {
 		key = c;
+		/* find end of line */
+		for (; *c && *c != '\n'; c++)
+			/* zero terminate line on start of comment */
+			if (*c == '#')
+*c = 0;
+		/* zero terminate line */
+		if (*(next = c))
+			*next++ = 0;
 		/* Look for = separator between key and value */
-		for (; *c && *c != '='; c++)
+		for (c = key; *c && *c != '='; c++)
 			continue;
+		/* Ignore lines with no key=value pair */
 		if (*c == '\0')
-			break; /* break if at end of data */
+			continue;
 
 		/* zero terminate key which points to keyword */
 		*c++ = 0;

Index: src/sys/arch/i386/stand/lib/parseutils.c
diff -u src/sys/arch/i386/stand/lib/parseutils.c:1.5 src/sys/arch/i386/stand/lib/parseutils.c:1.6
--- src/sys/arch/i386/stand/lib/parseutils.c:1.5	Sun Dec 14 12:03:43 2008
+++ src/sys/arch/i386/stand/lib/parseutils.c	Thu Aug 18 09:20:04 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: parseutils.c,v 1.5 2008/12/14 17:03:43 christos Exp $	*/
+/*	$NetBSD: parseutils.c,v 1.6 2011/08/18 13:20:04 christos Exp $	*/
 
 /*
  * Copyright (c) 1996, 1997
@@ -52,13 +52,22 @@
 {
 	char *options;
 
-	if ((options = strchr(arg, ' ')) == NULL)
+	for (options = arg; *options; options++) {
+		switch (*options) {
+		case ' ':
+		case '\t':
+			*options++ = '\0';
+			break;
+		default:
+			continue;
+		}
+		break;
+	}
+	if (*options == '\0')
 		return "";
-	else
-		*options++ = '\0';
 
-	/* trim leading blanks */
-	while (*options && *options == ' ')
+	/* trim leading blanks/tabs */
+	while (*options == ' ' || *options == '\t')
 		options++;
 
 	return options;



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

2011-06-08 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Wed Jun  8 16:04:40 UTC 2011

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

Log Message:
Use prototypes from libi386.h.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/arch/i386/stand/lib/pcio.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/pcio.c
diff -u src/sys/arch/i386/stand/lib/pcio.c:1.29 src/sys/arch/i386/stand/lib/pcio.c:1.30
--- src/sys/arch/i386/stand/lib/pcio.c:1.29	Mon Feb 14 23:47:11 2011
+++ src/sys/arch/i386/stand/lib/pcio.c	Wed Jun  8 16:04:40 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: pcio.c,v 1.29 2011/02/14 23:47:11 jmcneill Exp $	 */
+/*	$NetBSD: pcio.c,v 1.30 2011/06/08 16:04:40 joerg Exp $	 */
 
 /*
  * Copyright (c) 1996, 1997
@@ -38,10 +38,6 @@
 #include "libi386.h"
 #include "bootinfo.h"
 
-extern void conputc(int);
-extern int congetc(void);
-extern int conisshift(void);
-extern int coniskey(void);
 extern struct x86_boot_params boot_params;
 
 struct btinfo_console btinfo_console;



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

2011-06-08 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Wed Jun  8 16:03:42 UTC 2011

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

Log Message:
G/C wbinvd


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/i386/stand/lib/cpufunc.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/cpufunc.S
diff -u src/sys/arch/i386/stand/lib/cpufunc.S:1.3 src/sys/arch/i386/stand/lib/cpufunc.S:1.4
--- src/sys/arch/i386/stand/lib/cpufunc.S:1.3	Wed Oct 22 08:42:38 2008
+++ src/sys/arch/i386/stand/lib/cpufunc.S	Wed Jun  8 16:03:42 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: cpufunc.S,v 1.3 2008/10/22 08:42:38 ad Exp $	*/
+/*	$NetBSD: cpufunc.S,v 1.4 2011/06/08 16:03:42 joerg Exp $	*/
 
 /*-
  * Copyright (c) 2007 The NetBSD Foundation, Inc.
@@ -150,7 +150,3 @@
 	outsl
 	popl	%esi
 	ret
-
-NENTRY(wbinvd)
-	wbinvd
-	ret



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

2011-06-07 Thread Joerg Sonnenberger
Module Name:src
Committed By:   joerg
Date:   Tue Jun  7 20:05:46 UTC 2011

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

Log Message:
Catch up with addition of putstr32.S.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 src/sys/arch/i386/stand/lib/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/lib/Makefile
diff -u src/sys/arch/i386/stand/lib/Makefile:1.33 src/sys/arch/i386/stand/lib/Makefile:1.34
--- src/sys/arch/i386/stand/lib/Makefile:1.33	Thu Jun  2 18:53:00 2011
+++ src/sys/arch/i386/stand/lib/Makefile	Tue Jun  7 20:05:46 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.33 2011/06/02 18:53:00 dsl Exp $
+#	$NetBSD: Makefile,v 1.34 2011/06/07 20:05:46 joerg Exp $
 
 S?=	${.CURDIR}/../../../..
 
@@ -31,6 +31,7 @@
 AFLAGS.message32.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:}
 AFLAGS.pvcopy.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:}
 AFLAGS.putstr.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:}
+AFLAGS.putstr32.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:}
 AFLAGS.realprot.S= ${${ACTIVE_CC} == "clang":?-no-integrated-as:}
 
 CPPFLAGS= -I$S/lib/libsa ${I386CPPFLAGS} ${I386MISCCPPFLAGS}



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

2011-06-02 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Thu Jun  2 18:53:01 UTC 2011

Modified Files:
src/sys/arch/i386/stand/lib: Makefile
Added Files:
src/sys/arch/i386/stand/lib: putstr32.S

Log Message:
Add C stubs to allow prints early in the boot code.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/arch/i386/stand/lib/Makefile
cvs rdiff -u -r0 -r1.1 src/sys/arch/i386/stand/lib/putstr32.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/Makefile
diff -u src/sys/arch/i386/stand/lib/Makefile:1.32 src/sys/arch/i386/stand/lib/Makefile:1.33
--- src/sys/arch/i386/stand/lib/Makefile:1.32	Fri May 20 22:29:56 2011
+++ src/sys/arch/i386/stand/lib/Makefile	Thu Jun  2 18:53:00 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.32 2011/05/20 22:29:56 joerg Exp $
+#	$NetBSD: Makefile,v 1.33 2011/06/02 18:53:00 dsl Exp $
 
 S?=	${.CURDIR}/../../../..
 
@@ -46,7 +46,7 @@
 SRCS+= bootinfo.c bootinfo_biosgeom.c bootinfo_memmap.c
 SRCS+= startprog.S multiboot.S
 SRCS+= biosgetsystime.S cpufunc.S bootmenu.c
-SRCS+= realprot.S message.S message32.S dump_eax.S pvcopy.S putstr.S
+SRCS+= realprot.S message.S message32.S dump_eax.S pvcopy.S putstr.S putstr32.S
 SRCS+= rasops.c vbe.c biosvbe.S
 .if (${I386_INCLUDE_DISK} == "yes")
 SRCS+= biosdisk.c biosdisk_ll.c bios_disk.S

Added files:

Index: src/sys/arch/i386/stand/lib/putstr32.S
diff -u /dev/null src/sys/arch/i386/stand/lib/putstr32.S:1.1
--- /dev/null	Thu Jun  2 18:53:01 2011
+++ src/sys/arch/i386/stand/lib/putstr32.S	Thu Jun  2 18:53:00 2011
@@ -0,0 +1,69 @@
+/*	$NetBSD: putstr32.S,v 1.1 2011/06/02 18:53:00 dsl Exp $	*/
+
+/*-
+ * Copyright (c) 20011 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by David Laight.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+
+/*
+ * Diagnostic print routines callable from 32bit C code during early
+ * parts of the boot process.
+ */
+
+/*
+ * void putstr(const char *)
+ *
+ * display message on serial port
+ */
+
+	.globl	_C_LABEL(putstr32)
+_C_LABEL(putstr32):
+	.code32
+	push	%esi
+	movl	8(%esp), %esi
+
+	call	message32
+
+	pop	%esi
+	ret
+
+/*
+ * void putint(int)
+ *
+ * display value on serial port as 8 hex digits followed by a space
+ */
+
+	.globl	_C_LABEL(putint32)
+_C_LABEL(putint32):
+	.code32
+	movl	4(%esp), %eax
+
+	call	dump_eax32
+
+	ret



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

2011-02-20 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Mon Feb 21 02:58:03 UTC 2011

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

Log Message:
Rework previous commit.  Return non-zero instead of turning off
BIOSDISK_INT13EXT.  BIOSDISK_INT13EXT also enables LBA access mechanisms
that we really want to be using if at all possible.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/arch/i386/stand/lib/biosdisk_ll.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_ll.c
diff -u src/sys/arch/i386/stand/lib/biosdisk_ll.c:1.30 src/sys/arch/i386/stand/lib/biosdisk_ll.c:1.31
--- src/sys/arch/i386/stand/lib/biosdisk_ll.c:1.30	Mon Feb 21 00:43:19 2011
+++ src/sys/arch/i386/stand/lib/biosdisk_ll.c	Mon Feb 21 02:58:02 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: biosdisk_ll.c,v 1.30 2011/02/21 00:43:19 dyoung Exp $	 */
+/*	$NetBSD: biosdisk_ll.c,v 1.31 2011/02/21 02:58:02 jakllsch Exp $	 */
 
 /*-
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -129,7 +129,7 @@
 		if (ed != NULL) {
 			ed->size = sizeof(*ed);
 			if (biosdisk_getextinfo(d->dev, ed) != 0)
-d->flags &= ~BIOSDISK_INT13EXT;
+return -1;
 		}
 	}
 



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

2011-02-20 Thread David Young
Module Name:src
Committed By:   dyoung
Date:   Mon Feb 21 00:43:20 UTC 2011

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

Log Message:
biosdisk_getextinfo() can fail.  If it does fail in set_geometry(),
clear the flag BIOSDISK_INT13EXT so that a caller such as read_gpt()
will not try to rely on the gibberish in the biosdisk_extinfo.


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 src/sys/arch/i386/stand/lib/biosdisk_ll.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_ll.c
diff -u src/sys/arch/i386/stand/lib/biosdisk_ll.c:1.29 src/sys/arch/i386/stand/lib/biosdisk_ll.c:1.30
--- src/sys/arch/i386/stand/lib/biosdisk_ll.c:1.29	Thu Dec 30 22:27:43 2010
+++ src/sys/arch/i386/stand/lib/biosdisk_ll.c	Mon Feb 21 00:43:19 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: biosdisk_ll.c,v 1.29 2010/12/30 22:27:43 jakllsch Exp $	 */
+/*	$NetBSD: biosdisk_ll.c,v 1.30 2011/02/21 00:43:19 dyoung Exp $	 */
 
 /*-
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -128,7 +128,8 @@
 		d->flags |= BIOSDISK_INT13EXT;
 		if (ed != NULL) {
 			ed->size = sizeof(*ed);
-			biosdisk_getextinfo(d->dev, ed);
+			if (biosdisk_getextinfo(d->dev, ed) != 0)
+d->flags &= ~BIOSDISK_INT13EXT;
 		}
 	}
 



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

2011-02-20 Thread David Young
Module Name:src
Committed By:   dyoung
Date:   Mon Feb 21 00:39:54 UTC 2011

Modified Files:
src/sys/arch/i386/stand/lib: libi386.h

Log Message:
biosdisk_getextinfo() returns 0 on success, non-zero on failure, so
change its return type from void to int.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 src/sys/arch/i386/stand/lib/libi386.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/lib/libi386.h
diff -u src/sys/arch/i386/stand/lib/libi386.h:1.34 src/sys/arch/i386/stand/lib/libi386.h:1.35
--- src/sys/arch/i386/stand/lib/libi386.h:1.34	Sun Feb  6 23:16:05 2011
+++ src/sys/arch/i386/stand/lib/libi386.h	Mon Feb 21 00:39:54 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: libi386.h,v 1.34 2011/02/06 23:16:05 jmcneill Exp $	*/
+/*	$NetBSD: libi386.h,v 1.35 2011/02/21 00:39:54 dyoung Exp $	*/
 
 /*
  * Copyright (c) 1996
@@ -121,7 +121,7 @@
 int biosdisk_int13ext(int);
 int biosdisk_getinfo(int);
 struct biosdisk_extinfo;
-void biosdisk_getextinfo(int, struct biosdisk_extinfo *);
+int biosdisk_getextinfo(int, struct biosdisk_extinfo *);
 int get_harddrives(void);
 void biosdisk_probe(void);
 



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

2011-02-20 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sun Feb 20 22:03:13 UTC 2011

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

Log Message:
Follow a minor detail in the spec a bit more closely.


To generate a diff of this commit:
cvs rdiff -u -r1.2 -r1.3 src/sys/arch/i386/stand/lib/biosvbe.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/biosvbe.S
diff -u src/sys/arch/i386/stand/lib/biosvbe.S:1.2 src/sys/arch/i386/stand/lib/biosvbe.S:1.3
--- src/sys/arch/i386/stand/lib/biosvbe.S:1.2	Wed Feb  9 04:37:54 2011
+++ src/sys/arch/i386/stand/lib/biosvbe.S	Sun Feb 20 22:03:13 2011
@@ -1,4 +1,4 @@
-/* $NetBSD: biosvbe.S,v 1.2 2011/02/09 04:37:54 jmcneill Exp $ */
+/* $NetBSD: biosvbe.S,v 1.3 2011/02/20 22:03:13 jakllsch Exp $ */
 
 /*-
  * Copyright (c) 2009 Jared D. McNeill 
@@ -273,14 +273,18 @@
 	call	_C_LABEL(prot_to_real)
 	.code16
 
+	pushw	%es
+
+	xorw	%di, %di
+	movw	%di, %es	/* es:di == 0:0 */
+
 	movw	$0x4f15, %ax	/* display identification extensions */
 	mov	$0x00, %bx	/* report DDC capabilities */
-
-	movl	$0x, %esi	/* ES:DI == 0:0 */
-	movl	$0x, %edi
 	mov	$0x00, %cx	/* controller unit number (00h = primary) */
 	int	$0x10
 
+	popw	%es
+
 	calll	_C_LABEL(real_to_prot)
 	.code32
 



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

2011-02-19 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sun Feb 20 05:45:48 UTC 2011

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

Log Message:
%bl is part of %bx, %bx contains the address we requested from the BIOS.
Thus, use %cl instead of %bl for return value storage.


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/i386/stand/lib/biosmemps2.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/biosmemps2.S
diff -u src/sys/arch/i386/stand/lib/biosmemps2.S:1.4 src/sys/arch/i386/stand/lib/biosmemps2.S:1.5
--- src/sys/arch/i386/stand/lib/biosmemps2.S:1.4	Sat Nov 21 11:52:57 2009
+++ src/sys/arch/i386/stand/lib/biosmemps2.S	Sun Feb 20 05:45:48 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: biosmemps2.S,v 1.4 2009/11/21 11:52:57 dsl Exp $	*/
+/*	$NetBSD: biosmemps2.S,v 1.5 2011/02/20 05:45:48 jakllsch Exp $	*/
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -56,7 +56,7 @@
 	# do int15, function 0xc0 call to discover if C7h is supported
 	movb	$0xc0, %ah
 	int	$0x15
-	setc	%bl
+	setc	%cl
 	jc	out		# 0xc0 not supported if carry set
 
 	# check feature byte 2, bit 4 to see if return memory map is supported
@@ -64,8 +64,8 @@
 	andb	$0x10, %al
 	jnz	getmem		# 0xc7 supported
 	
-	# set %bl to indicate failure, and exit
-	movb	$2, %bl
+	# set %cl to indicate failure, and exit
+	movb	$2, %cl
 	jmp	out
 
 getmem:
@@ -81,15 +81,14 @@
 	# actually call int15, function 0xc7 now
 	movb	$0xc7, %ah
 	int	$0x15
-	setc	%bl		# save carry
+	setc	%cl		# save carry
 	pop	%ds
 
 out:
 	calll	_C_LABEL(real_to_prot)
 	.code32
 
-	xorl	%eax, %eax
-	movb	%bl, %al	# return value in %ax
+	movzbl	%cl, %eax	# return value in %eax
 
 	pop	%edi
 	pop	%esi



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

2011-02-14 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Feb 14 23:47:11 UTC 2011

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

Log Message:
port-i386/44563: boot loader prompt doesn't read keyboard input on a MacBook1,1

check for keystroke (int 16h, AH=01h) before getting keystroke (int 16h,
AH=00h), fixes bootloader keyboard input with Apple firmware, from Taylor R
Campbell


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/i386/stand/lib/pcio.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/pcio.c
diff -u src/sys/arch/i386/stand/lib/pcio.c:1.28 src/sys/arch/i386/stand/lib/pcio.c:1.29
--- src/sys/arch/i386/stand/lib/pcio.c:1.28	Fri Jun 25 15:35:08 2010
+++ src/sys/arch/i386/stand/lib/pcio.c	Mon Feb 14 23:47:11 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: pcio.c,v 1.28 2010/06/25 15:35:08 tsutsui Exp $	 */
+/*	$NetBSD: pcio.c,v 1.29 2011/02/14 23:47:11 jmcneill Exp $	 */
 
 /*
  * Copyright (c) 1996, 1997
@@ -271,6 +271,8 @@
 	default: /* to make gcc -Wall happy... */
 	case CONSDEV_PC:
 #endif
+		while (!coniskey())
+			;
 		c = congetc();
 #ifdef CONSOLE_KEYMAP
 		{



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

2011-01-26 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Wed Jan 26 20:59:49 UTC 2011

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

Log Message:
Attempt to correct two regressions.
 - avoid Virtualbox's BIOS panicing on 64-bit LBAs
 - MBR-without-disklabel was ignored


To generate a diff of this commit:
cvs rdiff -u -r1.36 -r1.37 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.36 src/sys/arch/i386/stand/lib/biosdisk.c:1.37
--- src/sys/arch/i386/stand/lib/biosdisk.c:1.36	Wed Jan  5 22:06:59 2011
+++ src/sys/arch/i386/stand/lib/biosdisk.c	Wed Jan 26 20:59:48 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: biosdisk.c,v 1.36 2011/01/05 22:06:59 jakllsch Exp $	*/
+/*	$NetBSD: biosdisk.c,v 1.37 2011/01/26 20:59:48 jakllsch Exp $	*/
 
 /*
  * Copyright (c) 1996, 1998
@@ -310,6 +310,10 @@
 	daddr_t gptsector[2];
 	int i, error;
 
+	if (d->ll.type != BIOSDISK_TYPE_HD)
+		/* No GPT on floppy and CD */
+		return -1;
+
 	gptsector[0] = GPT_HDR_BLKNO;
 	if (set_geometry(&d->ll, &ed) == 0 && d->ll.flags & BIOSDISK_INT13EXT) {
 		gptsector[1] = ed.totsec - 1;
@@ -345,11 +349,28 @@
 #endif	/* !NO_GPT */
 
 #ifndef NO_DISKLABEL
+static void
+ingest_label(struct biosdisk *d, struct disklabel *lp)
+{
+	int part;
+
+	memset(d->part, 0, sizeof(d->part));
+
+	for (part = 0; part < lp->d_npartitions; part++) {
+		if (lp->d_partitions[part].p_size == 0)
+			continue;
+		if (lp->d_partitions[part].p_fstype == FS_UNUSED)
+			continue;
+		d->part[part].fstype = lp->d_partitions[part].p_fstype;
+		d->part[part].offset = lp->d_partitions[part].p_offset;
+		d->part[part].size = lp->d_partitions[part].p_size;
+	}
+}
+	
 static int
 check_label(struct biosdisk *d, daddr_t sector)
 {
 	struct disklabel *lp;
-	int part;
 
 	/* find partition in NetBSD disklabel */
 	if (readsects(&d->ll, sector + LABELSECTOR, 1, d->buf, 0)) {
@@ -366,18 +387,7 @@
 		return -1;
 	}
 
-	memset(d->part, 0, sizeof(d->part));
-	for (part = 0; part < lp->d_npartitions; part++) {
-		if (lp->d_partitions[part].p_size == 0)
-			continue;
-		if (lp->d_partitions[part].p_fstype == FS_UNUSED)
-			continue;
-		d->part[part].fstype = lp->d_partitions[part].p_fstype;
-		d->part[part].offset = lp->d_partitions[part].p_offset;
-		d->part[part].size = lp->d_partitions[part].p_size;
-	}
-	
-	d->boff = sector;
+	ingest_label(d, lp);
 
 #ifdef _STANDALONE
 	bi_disk.labelsector = d->boff + LABELSECTOR;
@@ -499,7 +509,7 @@
 	 */
 	/* XXX fill it to make checksum match kernel one */
 	dflt_lbl.d_checksum = dkcksum(&dflt_lbl);
-	memcpy(d->buf, &dflt_lbl, sizeof(dflt_lbl));
+	ingest_label(d, &dflt_lbl);
 	return 0;
 }
 #endif /* NO_DISKLABEL */



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

2011-01-05 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Wed Jan  5 22:06:59 UTC 2011

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

Log Message:
Teach BIOS disk driver about GPT partition tables.
Inspired by Mike Volokhov's GPT booting GSoC project.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/arch/i386/stand/lib/Makefile
cvs rdiff -u -r1.35 -r1.36 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/Makefile
diff -u src/sys/arch/i386/stand/lib/Makefile:1.30 src/sys/arch/i386/stand/lib/Makefile:1.31
--- src/sys/arch/i386/stand/lib/Makefile:1.30	Mon Dec 20 01:12:44 2010
+++ src/sys/arch/i386/stand/lib/Makefile	Wed Jan  5 22:06:59 2011
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.30 2010/12/20 01:12:44 jakllsch Exp $
+#	$NetBSD: Makefile,v 1.31 2011/01/05 22:06:59 jakllsch Exp $
 
 S?=	${.CURDIR}/../../../..
 
@@ -14,6 +14,7 @@
 CPPFLAGS= -I$S/lib/libsa ${I386CPPFLAGS} ${I386MISCCPPFLAGS}
 #CPPFLAGS+= -DDISK_DEBUG
 #CPPFLAGS+= -DNO_DISKLABEL
+#CPPFLAGS+= -DNO_GPT
 #CPPFLAGS+= -DSAVE_MEMORY
 
 SRCS= pcio.c conio.S comio.S comio_direct.c biosvideomode.S

Index: src/sys/arch/i386/stand/lib/biosdisk.c
diff -u src/sys/arch/i386/stand/lib/biosdisk.c:1.35 src/sys/arch/i386/stand/lib/biosdisk.c:1.36
--- src/sys/arch/i386/stand/lib/biosdisk.c:1.35	Wed Jan  5 21:44:23 2011
+++ src/sys/arch/i386/stand/lib/biosdisk.c	Wed Jan  5 22:06:59 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: biosdisk.c,v 1.35 2011/01/05 21:44:23 jakllsch Exp $	*/
+/*	$NetBSD: biosdisk.c,v 1.36 2011/01/05 22:06:59 jakllsch Exp $	*/
 
 /*
  * Copyright (c) 1996, 1998
@@ -63,18 +63,22 @@
  * the rights to redistribute these changes.
  */
 
-#ifndef NO_DISKLABEL
+#if !defined(NO_DISKLABEL) || !defined(NO_GPT)
 #define FSTYPENAMES
 #endif
 
+#include 
+#include 
+
 #include 
 #include 
 #include 
 #include 
+#include 
+#include 
 
 #include 
 
-#include 
 #include 
 #include 
 #include 
@@ -88,12 +92,28 @@
 
 #define BUFSIZE	2048	/* must be large enough for a CD sector */
 
+#define BIOSDISKNPART 26
+
 struct biosdisk {
 	struct biosdisk_ll ll;
 	daddr_t boff;
 	charbuf[BUFSIZE];
+#if !defined(NO_DISKLABEL) || !defined(NO_GPT)
+	struct {
+		daddr_t offset;
+		daddr_t size;
+		int fstype;
+	} part[BIOSDISKNPART];
+#endif
 };
 
+#ifndef NO_GPT
+const struct uuid GET_nbsd_raid = GPT_ENT_TYPE_NETBSD_RAIDFRAME;
+const struct uuid GET_nbsd_ffs = GPT_ENT_TYPE_NETBSD_FFS;
+const struct uuid GET_nbsd_lfs = GPT_ENT_TYPE_NETBSD_LFS;
+const struct uuid GET_nbsd_swap = GPT_ENT_TYPE_NETBSD_SWAP;
+#endif /* NO_GPT */
+
 #ifdef _STANDALONE
 static struct btinfo_bootdisk bi_disk;
 static struct btinfo_bootwedge bi_wedge;
@@ -162,11 +182,174 @@
 	return d;
 }
 
+#if !defined(NO_DISKLABEL) || !defined(NO_GPT)
+static void
+md5(void *hash, const void *data, size_t len)
+{
+	MD5_CTX ctx;
+
+	MD5Init(&ctx);
+	MD5Update(&ctx, data, len);
+	MD5Final(hash, &ctx);
+
+	return;
+}
+#endif
+
+#ifndef NO_GPT
+static bool
+guid_is_nil(const struct uuid *u)
+{
+	static const struct uuid nil = { .time_low = 0 };
+	return (memcmp(u, &nil, sizeof(*u)) == 0 ? true : false);
+}
+
+static bool
+guid_is_equal(const struct uuid *a, const struct uuid *b)
+{
+	return (memcmp(a, b, sizeof(*a)) == 0 ? true : false);
+}
+
+static int
+check_gpt(struct biosdisk *d, daddr_t sector)
+{
+	struct gpt_hdr gpth;
+	const struct gpt_ent *ep;
+	const struct uuid *u;
+	daddr_t entblk;
+	size_t size;
+	uint32_t crc;
+	int sectors;
+	int entries;
+	int entry;
+	int i, j;
+
+	/* read in gpt_hdr sector */
+	if (readsects(&d->ll, sector, 1, d->buf, 1)) {
+#ifdef DISK_DEBUG
+		printf("Error reading GPT header at %"PRId64"\n", sector);
+#endif
+		return EIO;
+	}
+
+	gpth = *(const struct gpt_hdr *)d->buf;
+
+	if (memcmp(GPT_HDR_SIG, gpth.hdr_sig, sizeof(gpth.hdr_sig)))
+		return -1;
+
+	crc = gpth.hdr_crc_self;
+	gpth.hdr_crc_self = 0;
+	gpth.hdr_crc_self = crc32(0, (const void *)&gpth, GPT_HDR_SIZE);
+	if (gpth.hdr_crc_self != crc) {
+		return -1;
+	}
+
+	if (gpth.hdr_lba_self != sector)
+		return -1;
+
+#ifdef _STANDALONE
+	bi_wedge.matchblk = sector;
+	bi_wedge.matchnblks = 1;
+
+	md5(bi_wedge.matchhash, d->buf, d->ll.secsize);
+#endif
+
+	sectors = sizeof(d->buf)/d->ll.secsize; /* sectors per buffer */
+	entries = sizeof(d->buf)/gpth.hdr_entsz; /* entries per buffer */
+	entblk = gpth.hdr_lba_table;
+	crc = crc32(0, NULL, 0);
+
+	j = 0;
+	ep = (const struct gpt_ent *)d->buf;
+
+	for (entry = 0; entry < gpth.hdr_entries; entry += entries) {
+		size = MIN(sizeof(d->buf),
+		(gpth.hdr_entries - entry) * gpth.hdr_entsz);
+		entries = size / gpth.hdr_entsz;
+		sectors = roundup(size, d->ll.secsize) / d->ll.secsize;
+		if (readsects(&d->ll, entblk, sectors, d->buf, 1))
+			return -1;
+		entblk += sectors;
+		crc = crc32(crc, (const void *)d->buf, size);
+
+		for (i = 0; j < BIOSDISKNPART && i < e

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

2011-01-05 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Wed Jan  5 21:44:23 UTC 2011

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

Log Message:
Let the compiler determine the correct type for sizeof().
>From Mike Volokhov's GPT booting GSoC.


To generate a diff of this commit:
cvs rdiff -u -r1.34 -r1.35 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.34 src/sys/arch/i386/stand/lib/biosdisk.c:1.35
--- src/sys/arch/i386/stand/lib/biosdisk.c:1.34	Thu Dec 30 22:28:53 2010
+++ src/sys/arch/i386/stand/lib/biosdisk.c	Wed Jan  5 21:44:23 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: biosdisk.c,v 1.34 2010/12/30 22:28:53 jakllsch Exp $	*/
+/*	$NetBSD: biosdisk.c,v 1.35 2011/01/05 21:44:23 jakllsch Exp $	*/
 
 /*
  * Copyright (c) 1996, 1998
@@ -497,7 +497,7 @@
 out:
 va_end(ap);
 	if (error)
-		dealloc(d, sizeof(struct biosdisk));
+		dealloc(d, sizeof(*d));
 	return error;
 }
 
@@ -511,7 +511,7 @@
 	if (d->ll.type == BIOSDISK_TYPE_FD)
 		wait_sec(3);	/* 2s is enough on all PCs I found */
 
-	dealloc(d, sizeof(struct biosdisk));
+	dealloc(d, sizeof(*d));
 	f->f_devdata = NULL;
 	return 0;
 }



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

2010-12-30 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Thu Dec 30 22:28:53 UTC 2010

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

Log Message:
Fix DISK_DEBUG build.


To generate a diff of this commit:
cvs rdiff -u -r1.33 -r1.34 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.33 src/sys/arch/i386/stand/lib/biosdisk.c:1.34
--- src/sys/arch/i386/stand/lib/biosdisk.c:1.33	Sat Dec 25 01:19:33 2010
+++ src/sys/arch/i386/stand/lib/biosdisk.c	Thu Dec 30 22:28:53 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: biosdisk.c,v 1.33 2010/12/25 01:19:33 jakllsch Exp $	*/
+/*	$NetBSD: biosdisk.c,v 1.34 2010/12/30 22:28:53 jakllsch Exp $	*/
 
 /*
  * Copyright (c) 1996, 1998
@@ -234,7 +234,7 @@
 continue;
 			sector = this_ext + mbr[i].mbrp_start;
 #ifdef DISK_DEBUG
-			printf("ptn type %d in sector %"PRId64"\n", typ, sector);
+			printf("ptn type %d in sector %d\n", typ, sector);
 #endif
 			if (typ == MBR_PTYPE_NETBSD) {
 error = check_label(d, sector);
@@ -485,7 +485,7 @@
 #endif /* NO_DISKLABEL */
 
 #ifdef DISK_DEBUG
-	printf("partition @%d\n", d->boff);
+	printf("partition @%"PRId64"\n", d->boff);
 #endif
 
 #ifdef _STANDALONE



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

2010-12-30 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Thu Dec 30 22:27:43 UTC 2010

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

Log Message:
Make this actually build with DISK_DEBUG.


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/i386/stand/lib/biosdisk_ll.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_ll.c
diff -u src/sys/arch/i386/stand/lib/biosdisk_ll.c:1.28 src/sys/arch/i386/stand/lib/biosdisk_ll.c:1.29
--- src/sys/arch/i386/stand/lib/biosdisk_ll.c:1.28	Sat Dec 25 01:19:33 2010
+++ src/sys/arch/i386/stand/lib/biosdisk_ll.c	Thu Dec 30 22:27:43 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: biosdisk_ll.c,v 1.28 2010/12/25 01:19:33 jakllsch Exp $	 */
+/*	$NetBSD: biosdisk_ll.c,v 1.29 2010/12/30 22:27:43 jakllsch Exp $	 */
 
 /*-
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -69,6 +69,7 @@
  * needs lowlevel parts from bios_disk.S
  */
 
+#include 
 #include 
 
 #include "biosdisk_ll.h"
@@ -264,7 +265,7 @@
 			while ((nsec = do_read(d, dblk, maxsecs, trbuf)) < 0) {
 #ifdef DISK_DEBUG
 if (!cold)
-	printf("read error dblk %"PRId64"-%PRId64\n",
+	printf("read error dblk %"PRId64"-%"PRId64"\n",
 	dblk, (dblk + maxsecs - 1));
 #endif
 if (--retries >= 0)



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

2010-12-29 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Wed Dec 29 22:40:46 UTC 2010

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

Log Message:
Utilize movz[bw]l to save a few instrutions and bytes of .text.


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/i386/stand/lib/bios_disk.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/bios_disk.S
diff -u src/sys/arch/i386/stand/lib/bios_disk.S:1.19 src/sys/arch/i386/stand/lib/bios_disk.S:1.20
--- src/sys/arch/i386/stand/lib/bios_disk.S:1.19	Sat Nov 21 11:52:57 2009
+++ src/sys/arch/i386/stand/lib/bios_disk.S	Wed Dec 29 22:40:46 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: bios_disk.S,v 1.19 2009/11/21 11:52:57 dsl Exp $	*/
+/*	$NetBSD: bios_disk.S,v 1.20 2010/12/29 22:40:46 jakllsch Exp $	*/
 
 /*
  * Ported to boot 386BSD by Julian Elischer (jul...@tfs.com) Sept 1992
@@ -82,8 +82,7 @@
 	calll	_C_LABEL(real_to_prot) # back to protected mode
 	.code32
 
-	xorl	%eax, %eax
-	movw	%bx, %ax	# return value in %ax
+	movzwl	%bx, %eax	# return value in %eax
 
 	pop	%edi
 	pop	%edx
@@ -146,7 +145,7 @@
 	calll	_C_LABEL(real_to_prot) # back to protected mode
 	.code32
 
-	andl	$0x, %eax
+	movzwl	%ax, %eax	# return value in %eax
 
 	pop	%edi
 	pop	%esi
@@ -246,8 +245,7 @@
 	calll	_C_LABEL(real_to_prot)	# switch back
 	.code32
 
-	xorl	%eax, %eax
-	movb	%dl, %al	# return value in %ax
+	movzbl	%dl, %eax		# return value in %eax
 
 	cmpw	$0xaa55, %bx
 	sete	%dl
@@ -304,8 +302,7 @@
 	calll	_C_LABEL(real_to_prot) # back to protected mode
 	.code32
 
-	xorl	%eax, %eax
-	movw	%bx, %ax	# return value in %ax
+	movzwl	%bx, %eax	# return value in %eax
 
 	pop	%edi
 	pop	%esi
@@ -346,8 +343,7 @@
 	calll	_C_LABEL(real_to_prot) # back to protected mode
 	.code32
 
-	xorl	%eax, %eax
-	movb	%bl, %al	# return value in %ax
+	movzbl	%bl, %eax	# return value in %eax
 
 	pop	%edi
 	pop	%esi



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

2010-12-24 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sat Dec 25 01:19:34 UTC 2010

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

Log Message:
Use printf format macros for long longs.


To generate a diff of this commit:
cvs rdiff -u -r1.32 -r1.33 src/sys/arch/i386/stand/lib/biosdisk.c
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/i386/stand/lib/biosdisk_ll.c
cvs rdiff -u -r1.20 -r1.21 src/sys/arch/i386/stand/lib/bootinfo_biosgeom.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.32 src/sys/arch/i386/stand/lib/biosdisk.c:1.33
--- src/sys/arch/i386/stand/lib/biosdisk.c:1.32	Fri Dec 24 20:36:51 2010
+++ src/sys/arch/i386/stand/lib/biosdisk.c	Sat Dec 25 01:19:33 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: biosdisk.c,v 1.32 2010/12/24 20:36:51 jakllsch Exp $	*/
+/*	$NetBSD: biosdisk.c,v 1.33 2010/12/25 01:19:33 jakllsch Exp $	*/
 
 /*
  * Copyright (c) 1996, 1998
@@ -178,7 +178,7 @@
 	lp = (struct disklabel *) (d->buf + LABELOFFSET);
 	if (lp->d_magic != DISKMAGIC || dkcksum(lp)) {
 #ifdef DISK_DEBUG
-		printf("warning: no disklabel in sector %lld\n", sector);
+		printf("warning: no disklabel in sector %"PRId64"\n", sector);
 #endif
 		return -1;
 	}
@@ -234,7 +234,7 @@
 continue;
 			sector = this_ext + mbr[i].mbrp_start;
 #ifdef DISK_DEBUG
-			printf("ptn type %d in sector %lld\n", typ, sector);
+			printf("ptn type %d in sector %"PRId64"\n", typ, sector);
 #endif
 			if (typ == MBR_PTYPE_NETBSD) {
 error = check_label(d, sector);
@@ -334,10 +334,10 @@
 printf(" size ");
 size = ed.totsec * ed.sbytes;
 if (size >= (10ULL * 1024 * 1024 * 1024))
-	printf("%llu GB",
+	printf("%"PRIu64" GB",
 	size / (1024 * 1024 * 1024));
 else
-	printf("%llu MB",
+	printf("%"PRIu64" MB",
 	size / (1024 * 1024));
 			}
 			printf("\n");
@@ -386,7 +386,7 @@
 	int partition = 0;
 	struct disklabel *lp;
 #ifdef DISK_DEBUG
-	printf("looking for partition device %x, sector %lld\n", biosdev, sector);
+	printf("looking for partition device %x, sector %"PRId64"\n", biosdev, sector);
 #endif
 
 	/* Look for netbsd partition that is the dos boot one */

Index: src/sys/arch/i386/stand/lib/biosdisk_ll.c
diff -u src/sys/arch/i386/stand/lib/biosdisk_ll.c:1.27 src/sys/arch/i386/stand/lib/biosdisk_ll.c:1.28
--- src/sys/arch/i386/stand/lib/biosdisk_ll.c:1.27	Fri Dec 24 20:36:51 2010
+++ src/sys/arch/i386/stand/lib/biosdisk_ll.c	Sat Dec 25 01:19:33 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: biosdisk_ll.c,v 1.27 2010/12/24 20:36:51 jakllsch Exp $	 */
+/*	$NetBSD: biosdisk_ll.c,v 1.28 2010/12/25 01:19:33 jakllsch Exp $	 */
 
 /*-
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -264,7 +264,7 @@
 			while ((nsec = do_read(d, dblk, maxsecs, trbuf)) < 0) {
 #ifdef DISK_DEBUG
 if (!cold)
-	printf("read error dblk %lld-%lld\n",
+	printf("read error dblk %"PRId64"-%PRId64\n",
 	dblk, (dblk + maxsecs - 1));
 #endif
 if (--retries >= 0)

Index: src/sys/arch/i386/stand/lib/bootinfo_biosgeom.c
diff -u src/sys/arch/i386/stand/lib/bootinfo_biosgeom.c:1.20 src/sys/arch/i386/stand/lib/bootinfo_biosgeom.c:1.21
--- src/sys/arch/i386/stand/lib/bootinfo_biosgeom.c:1.20	Fri Nov 20 19:25:37 2009
+++ src/sys/arch/i386/stand/lib/bootinfo_biosgeom.c	Sat Dec 25 01:19:33 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: bootinfo_biosgeom.c,v 1.20 2009/11/20 19:25:37 dsl Exp $	*/
+/*	$NetBSD: bootinfo_biosgeom.c,v 1.21 2010/12/25 01:19:33 jakllsch Exp $	*/
 
 /*
  * Copyright (c) 1997
@@ -99,7 +99,7 @@
 #ifdef GEOM_DEBUG
 		printf("#%d: %x: C %d H %d S %d\n", nvalid,
 		   d.dev, d.cyl, d.head, d.sec);
-		printf("   sz %d fl %x cyl %d head %d sec %d totsec %lld sbytes %d\n",
+		printf("   sz %d fl %x cyl %d head %d sec %d totsec %"PRId64" sbytes %d\n",
 		   ed.size, ed.flags, ed.cyl, ed.head, ed.sec,
 		   ed.totsec, ed.sbytes);
 #endif



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

2010-12-24 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Fri Dec 24 20:36:51 UTC 2010

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

Log Message:
Sprinkle daddr_t.
Adjust DISK_DEBUG printf formats to match.


To generate a diff of this commit:
cvs rdiff -u -r1.31 -r1.32 src/sys/arch/i386/stand/lib/biosdisk.c
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/i386/stand/lib/biosdisk.h
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/i386/stand/lib/biosdisk_ll.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.31 src/sys/arch/i386/stand/lib/biosdisk.c:1.32
--- src/sys/arch/i386/stand/lib/biosdisk.c:1.31	Fri Jun 25 15:35:08 2010
+++ src/sys/arch/i386/stand/lib/biosdisk.c	Fri Dec 24 20:36:51 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: biosdisk.c,v 1.31 2010/06/25 15:35:08 tsutsui Exp $	*/
+/*	$NetBSD: biosdisk.c,v 1.32 2010/12/24 20:36:51 jakllsch Exp $	*/
 
 /*
  * Copyright (c) 1996, 1998
@@ -90,7 +90,7 @@
 
 struct biosdisk {
 	struct biosdisk_ll ll;
-	int boff;
+	daddr_t boff;
 	charbuf[BUFSIZE];
 };
 
@@ -164,7 +164,7 @@
 
 #ifndef NO_DISKLABEL
 static int
-check_label(struct biosdisk *d, int sector)
+check_label(struct biosdisk *d, daddr_t sector)
 {
 	struct disklabel *lp;
 
@@ -178,7 +178,7 @@
 	lp = (struct disklabel *) (d->buf + LABELOFFSET);
 	if (lp->d_magic != DISKMAGIC || dkcksum(lp)) {
 #ifdef DISK_DEBUG
-		printf("warning: no disklabel in sector %u\n", sector);
+		printf("warning: no disklabel in sector %lld\n", sector);
 #endif
 		return -1;
 	}
@@ -234,7 +234,7 @@
 continue;
 			sector = this_ext + mbr[i].mbrp_start;
 #ifdef DISK_DEBUG
-			printf("ptn type %d in sector %u\n", typ, sector);
+			printf("ptn type %d in sector %lld\n", typ, sector);
 #endif
 			if (typ == MBR_PTYPE_NETBSD) {
 error = check_label(d, sector);
@@ -377,7 +377,7 @@
  */
 
 int
-biosdisk_findpartition(int biosdev, u_int sector)
+biosdisk_findpartition(int biosdev, daddr_t sector)
 {
 #ifdef NO_DISKLABEL
 	return 0;
@@ -386,7 +386,7 @@
 	int partition = 0;
 	struct disklabel *lp;
 #ifdef DISK_DEBUG
-	printf("looking for partition device %x, sector %u\n", biosdev, sector);
+	printf("looking for partition device %x, sector %lld\n", biosdev, sector);
 #endif
 
 	/* Look for netbsd partition that is the dos boot one */

Index: src/sys/arch/i386/stand/lib/biosdisk.h
diff -u src/sys/arch/i386/stand/lib/biosdisk.h:1.7 src/sys/arch/i386/stand/lib/biosdisk.h:1.8
--- src/sys/arch/i386/stand/lib/biosdisk.h:1.7	Sun Dec 14 17:03:43 2008
+++ src/sys/arch/i386/stand/lib/biosdisk.h	Fri Dec 24 20:36:51 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: biosdisk.h,v 1.7 2008/12/14 17:03:43 christos Exp $	*/
+/*	$NetBSD: biosdisk.h,v 1.8 2010/12/24 20:36:51 jakllsch Exp $	*/
 
 /*
  * Copyright (c) 1996
@@ -29,4 +29,4 @@
 int biosdisk_open(struct open_file *, ...);
 int biosdisk_close(struct open_file *);
 int biosdisk_ioctl(struct open_file *, u_long, void *);
-int biosdisk_findpartition(int, u_int);
+int biosdisk_findpartition(int, daddr_t);

Index: src/sys/arch/i386/stand/lib/biosdisk_ll.c
diff -u src/sys/arch/i386/stand/lib/biosdisk_ll.c:1.26 src/sys/arch/i386/stand/lib/biosdisk_ll.c:1.27
--- src/sys/arch/i386/stand/lib/biosdisk_ll.c:1.26	Mon Apr 28 20:23:25 2008
+++ src/sys/arch/i386/stand/lib/biosdisk_ll.c	Fri Dec 24 20:36:51 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: biosdisk_ll.c,v 1.26 2008/04/28 20:23:25 martin Exp $	 */
+/*	$NetBSD: biosdisk_ll.c,v 1.27 2010/12/24 20:36:51 jakllsch Exp $	 */
 
 /*-
  * Copyright (c) 2005 The NetBSD Foundation, Inc.
@@ -153,8 +153,8 @@
  * this buffer doesn't cross a 64K DMA boundary.
  */
 static int  ra_dev;
-static int  ra_end;
-static int  ra_first;
+static daddr_t  ra_end;
+static daddr_t  ra_first;
 
 /*
  * Because some older BIOSes have bugs in their int13 extensions, we
@@ -264,8 +264,8 @@
 			while ((nsec = do_read(d, dblk, maxsecs, trbuf)) < 0) {
 #ifdef DISK_DEBUG
 if (!cold)
-	printf("read error dblk %d-%d\n", (int)dblk,
-	   (int)(dblk + maxsecs - 1));
+	printf("read error dblk %lld-%lld\n",
+	dblk, (dblk + maxsecs - 1));
 #endif
 if (--retries >= 0)
 	continue;



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

2010-12-19 Thread Jonathan A. Kollasch
Module Name:src
Committed By:   jakllsch
Date:   Sun Dec 19 17:18:23 UTC 2010

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

Log Message:
Compute real/protected %sp/%esp offset in 'gdt_fixup' using all 32-bits.
Allows the case of %ss being less than %cs to work.
Also, completely save and restore the general-purpose registers we use.


To generate a diff of this commit:
cvs rdiff -u -r1.9 -r1.10 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.9 src/sys/arch/i386/stand/lib/realprot.S:1.10
--- src/sys/arch/i386/stand/lib/realprot.S:1.9	Sat Nov 21 11:54:47 2009
+++ src/sys/arch/i386/stand/lib/realprot.S	Sun Dec 19 17:18:23 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: realprot.S,v 1.9 2009/11/21 11:54:47 dsl Exp $	*/
+/*	$NetBSD: realprot.S,v 1.10 2010/12/19 17:18:23 jakllsch Exp $	*/
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -90,18 +90,18 @@
 	.global	gdt_fixup
 gdt_fixup:
 	.code16
-	push	%ax
-	push	%dx
+	pushl	%eax
+	pushl	%edx
 
 	xorl	%eax, %eax
 	mov	%cs, %ax
 	mov	%ax, ourseg
 	/* sort out stuff for %ss != %ds */
+	xorl	%edx, %edx
 	movw	%ss, %dx
 	movw	%dx, stkseg
-	subw	%ax, %dx
-	shll	$16, %edx
-	shrl	$12, %edx
+	subl	%eax, %edx
+	shll	$4, %edx
 	movl	%edx, stkdif
 
 	/* fix up GDT entries for bootstrap */
@@ -121,8 +121,8 @@
 	addl	$gdt, %eax
 	movl	%eax, gdtarg+2
 
-	pop	%dx
-	pop	%ax
+	popl	%edx
+	popl	%eax
 	ret
 
 /*



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

2010-10-30 Thread John Nemeth
Module Name:src
Committed By:   jnemeth
Date:   Sat Oct 30 08:12:43 UTC 2010

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

Log Message:
Reduce licence with copyright Perry E. Metzger and Matthias Drochner
to two clauses.

On Thu, 21 Oct 2010 22:42:00 -0700 jnem...@xxx
(John Nemeth) wrote:
> The file src/sys/arch/i386/stand/lib/exec.c has a licence
> section that starts off saying copyright by each of you.  That is
> then followed by a standard four claus UCB licence.  Would it be
> okay to reduce that to the two claus licence that is now standard
> for NetBSD?

I have no particular objections.

--
Perry E. Metzgerpe...@xxx

jnem...@xxx said:
> Would it be okay to reduce that to the two claus licence

Yes of course, this is OK.

best regards
Matthias


To generate a diff of this commit:
cvs rdiff -u -r1.44 -r1.45 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.44 src/sys/arch/i386/stand/lib/exec.c:1.45
--- src/sys/arch/i386/stand/lib/exec.c:1.44	Wed Aug 25 16:32:51 2010
+++ src/sys/arch/i386/stand/lib/exec.c	Sat Oct 30 08:12:43 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: exec.c,v 1.44 2010/08/25 16:32:51 christos Exp $	 */
+/*	$NetBSD: exec.c,v 1.45 2010/10/30 08:12:43 jnemeth Exp $	 */
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -71,13 +71,6 @@
  * 2. Redistributions in binary form must reproduce the above copyright
  *notice, this list of conditions and the following disclaimer in the
  *documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- *must display the following acknowledgement:
- *	This product includes software developed by the University of
- *	California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- *may be used to endorse or promote products derived from this software
- *without specific prior written permission.
  *
  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE



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

2010-08-25 Thread Christos Zoulas
Module Name:src
Committed By:   christos
Date:   Wed Aug 25 16:32:51 UTC 2010

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

Log Message:
use LOAD_BACKWARDS instead of LOAD_NOTE for floppy book.


To generate a diff of this commit:
cvs rdiff -u -r1.43 -r1.44 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.43 src/sys/arch/i386/stand/lib/exec.c:1.44
--- src/sys/arch/i386/stand/lib/exec.c:1.43	Fri Jun 25 11:35:08 2010
+++ src/sys/arch/i386/stand/lib/exec.c	Wed Aug 25 12:32:51 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: exec.c,v 1.43 2010/06/25 15:35:08 tsutsui Exp $	 */
+/*	$NetBSD: exec.c,v 1.44 2010/08/25 16:32:51 christos Exp $	 */
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -228,7 +228,7 @@
 #endif
 	marks[MARK_START] = loadaddr;
 	if ((fd = loadfile(file, marks,
-	LOAD_KERNEL & ~(floppy ? LOAD_NOTE : 0))) == -1)
+	LOAD_KERNEL & ~(floppy ? LOAD_BACKWARDS : 0))) == -1)
 		return EIO;
 
 	close(fd);



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

2010-06-25 Thread Izumi Tsutsui
Module Name:src
Committed By:   tsutsui
Date:   Fri Jun 25 15:35:08 UTC 2010

Modified Files:
src/sys/arch/i386/stand/lib: biosdisk.c exec.c libi386.h pcio.c vbe.c

Log Message:
Add wait_sec() which uses BIOS function call INT 1Ah/AH=00h (GET SYSTEMTIME)
and use it for large delays (in seconds) instead of delay() that uses
INT 15h/AH=86h (WAIT) in microsecond because the latter one can't provide
precise delays on emulators.
Fixes PR port-i386/43156 (NetBSD bootloader countdown runs at 1/20 speed
in qemu 0.12).

No particular comments on the PR and port-i...@.


To generate a diff of this commit:
cvs rdiff -u -r1.30 -r1.31 src/sys/arch/i386/stand/lib/biosdisk.c
cvs rdiff -u -r1.42 -r1.43 src/sys/arch/i386/stand/lib/exec.c
cvs rdiff -u -r1.32 -r1.33 src/sys/arch/i386/stand/lib/libi386.h
cvs rdiff -u -r1.27 -r1.28 src/sys/arch/i386/stand/lib/pcio.c
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/i386/stand/lib/vbe.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.30 src/sys/arch/i386/stand/lib/biosdisk.c:1.31
--- src/sys/arch/i386/stand/lib/biosdisk.c:1.30	Tue Oct 20 14:49:03 2009
+++ src/sys/arch/i386/stand/lib/biosdisk.c	Fri Jun 25 15:35:08 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: biosdisk.c,v 1.30 2009/10/20 14:49:03 jmcneill Exp $	*/
+/*	$NetBSD: biosdisk.c,v 1.31 2010/06/25 15:35:08 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 1996, 1998
@@ -509,7 +509,7 @@
 
 	/* let the floppy drive go off */
 	if (d->ll.type == BIOSDISK_TYPE_FD)
-		delay(300);	/* 2s is enough on all PCs I found */
+		wait_sec(3);	/* 2s is enough on all PCs I found */
 
 	dealloc(d, sizeof(struct biosdisk));
 	f->f_devdata = NULL;

Index: src/sys/arch/i386/stand/lib/exec.c
diff -u src/sys/arch/i386/stand/lib/exec.c:1.42 src/sys/arch/i386/stand/lib/exec.c:1.43
--- src/sys/arch/i386/stand/lib/exec.c:1.42	Mon Sep 14 11:56:27 2009
+++ src/sys/arch/i386/stand/lib/exec.c	Fri Jun 25 15:35:08 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: exec.c,v 1.42 2009/09/14 11:56:27 jmcneill Exp $	 */
+/*	$NetBSD: exec.c,v 1.43 2010/06/25 15:35:08 tsutsui Exp $	 */
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -125,7 +125,7 @@
 #define	PAGE_SIZE	4096
 #endif
 
-#define MODULE_WARNING_DELAY	500
+#define MODULE_WARNING_SEC	5
 
 extern struct btinfo_console btinfo_console;
 
@@ -486,7 +486,7 @@
 	btinfo_modulelist = alloc(len);
 	if (btinfo_modulelist == NULL) {
 		printf("WARNING: couldn't allocate module list\n");
-		delay(MODULE_WARNING_DELAY);
+		wait_sec(MODULE_WARNING_SEC);
 		return;
 	}
 	memset(btinfo_modulelist, 0, len);
@@ -530,7 +530,7 @@
 		printf("WARNING: %d module%s failed to load\n",
 		nfail, nfail == 1 ? "" : "s");
 #if notyet
-		delay(MODULE_WARNING_DELAY);
+		wait_sec(MODULE_WARNING_SEC);
 #endif
 	}
 }

Index: src/sys/arch/i386/stand/lib/libi386.h
diff -u src/sys/arch/i386/stand/lib/libi386.h:1.32 src/sys/arch/i386/stand/lib/libi386.h:1.33
--- src/sys/arch/i386/stand/lib/libi386.h:1.32	Sun Sep 13 22:45:27 2009
+++ src/sys/arch/i386/stand/lib/libi386.h	Fri Jun 25 15:35:08 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: libi386.h,v 1.32 2009/09/13 22:45:27 jmcneill Exp $	*/
+/*	$NetBSD: libi386.h,v 1.33 2010/06/25 15:35:08 tsutsui Exp $	*/
 
 /*
  * Copyright (c) 1996
@@ -69,6 +69,7 @@
 #define CONSDEV_AUTO (-1)
 int iskey(int);
 char awaitkey(int, int);
+void wait_sec(int);
 
 /* this is in "user code"! */
 int parsebootfile(const char *, char **, char **, int *, int *, const char **);

Index: src/sys/arch/i386/stand/lib/pcio.c
diff -u src/sys/arch/i386/stand/lib/pcio.c:1.27 src/sys/arch/i386/stand/lib/pcio.c:1.28
--- src/sys/arch/i386/stand/lib/pcio.c:1.27	Wed Aug 26 13:28:48 2009
+++ src/sys/arch/i386/stand/lib/pcio.c	Fri Jun 25 15:35:08 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: pcio.c,v 1.27 2009/08/26 13:28:48 jmcneill Exp $	 */
+/*	$NetBSD: pcio.c,v 1.28 2010/06/25 15:35:08 tsutsui Exp $	 */
 
 /*
  * Copyright (c) 1996, 1997
@@ -371,3 +371,10 @@
 
 	return c;
 }
+
+void
+wait_sec(int sec)
+{
+
+	wait(sec * 100);
+}

Index: src/sys/arch/i386/stand/lib/vbe.c
diff -u src/sys/arch/i386/stand/lib/vbe.c:1.5 src/sys/arch/i386/stand/lib/vbe.c:1.6
--- src/sys/arch/i386/stand/lib/vbe.c:1.5	Tue Oct 20 14:47:33 2009
+++ src/sys/arch/i386/stand/lib/vbe.c	Fri Jun 25 15:35:08 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: vbe.c,v 1.5 2009/10/20 14:47:33 jmcneill Exp $ */
+/* $NetBSD: vbe.c,v 1.6 2010/06/25 15:35:08 tsutsui Exp $ */
 
 /*-
  * Copyright (c) 2009 Jared D. McNeill 
@@ -172,7 +172,7 @@
 		if (ret) {
 			printf("WARNING: failed to set VBE mode 0x%x\n",
 			vbestate.modenum);
-			delay(500);
+			wait_sec(5);
 		}
 	}
 	return ret;



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

2009-11-21 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Sat Nov 21 11:54:47 UTC 2009

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

Log Message:
Replace EPIA_HACK code with a version that 'just' trashes any return
address cache.  This seems to be rather more effective!
This seems to be adequate and is more justifyable than the previous hack.


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 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.8 src/sys/arch/i386/stand/lib/realprot.S:1.9
--- src/sys/arch/i386/stand/lib/realprot.S:1.8	Mon Feb 16 22:39:30 2009
+++ src/sys/arch/i386/stand/lib/realprot.S	Sat Nov 21 11:54:47 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: realprot.S,v 1.8 2009/02/16 22:39:30 jmcneill Exp $	*/
+/*	$NetBSD: realprot.S,v 1.9 2009/11/21 11:54:47 dsl Exp $	*/
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -184,33 +184,31 @@
 /*
  * EPIA_HACK
  *
- * VIA C3 processors don't seem to correctly switch back to executing
- * 16 bit code after the switch to real mode and subsequent jump.
+ * VIA C3 processors (Eden, Samuel 2) don't seem to correctly switch back to
+ * executing 16 bit code after the switch to real mode and subsequent jump.
  *
  * 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
+ * is most likely the problem.
  *
- * The precise reason for this hack working is still unknown, but
- * it was determined experimentally on two theories:
- * 1) Flush the pipeline with NOPs
- * 2) call/ret after the return from prot_to_real seems to improve matters,
- *perhaps by making more work for the branch prediction/prefetch logic.
+ * Previous versions just used some extra call/ret and a few NOPs, these
+ * only helped a bit, but booting compressed kernels would still fail.
  *
- * Neither of these individually are effective, but this combination is
- * determined experimentally to be sufficient.
+ * Trashing the return address stack (by doing 'call' without matched 'ret')
+ * Seems to fix things completely. 1 iteration isn't enough, 16 is plenty.
  */
 ENTRY(prot_to_real)
-#ifdef EPIA_HACK
-	.code32
-	call prot_to_real_main
-	.code16
-	call epia_nops
-	retl
-
-prot_to_real_main:
-#endif
 	.code32
 	pushl	%eax
+#ifdef EPIA_HACK
+	push	%ecx
+	push	$0x10
+	pop	%ecx
+1:	call	trash_return_cache
+	loop	1b
+	pop	%ecx
+#endif
 
 	/*
 	 * Load the segment registers while still in protected mode.
@@ -260,10 +258,6 @@
 	jne	1f
 	pop	%bp
 
-#ifdef EPIA_HACK
-	call epia_nops
-#endif
-
 	sti
 	popl	%eax
 	retl
@@ -283,15 +277,10 @@
 	. = . + 16
 
 #ifdef EPIA_HACK
-epia_nops:
-	.code16
-	nop
-	nop
-	nop
-	nop
-	nop
-	nop
-	ret
+trash_return_cache:
+	.code32
+	pop	%eax
+	jmp	*%eax
 #endif
 
 /* vtophys(void *)



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

2009-11-21 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Sat Nov 21 11:52:57 UTC 2009

Modified Files:
src/sys/arch/i386/stand/lib: bios_disk.S biosmemps2.S dos_file.S

Log Message:
Preserve %ds over bios calls.
Not strickly necessary because real_to_prot doesn't normally rely on in.
However it caused much confusion while debugging, and does no harm.


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sys/arch/i386/stand/lib/bios_disk.S
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/i386/stand/lib/biosmemps2.S
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/i386/stand/lib/dos_file.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/bios_disk.S
diff -u src/sys/arch/i386/stand/lib/bios_disk.S:1.18 src/sys/arch/i386/stand/lib/bios_disk.S:1.19
--- src/sys/arch/i386/stand/lib/bios_disk.S:1.18	Sun Dec 11 12:17:48 2005
+++ src/sys/arch/i386/stand/lib/bios_disk.S	Sat Nov 21 11:52:57 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: bios_disk.S,v 1.18 2005/12/11 12:17:48 christos Exp $	*/
+/*	$NetBSD: bios_disk.S,v 1.19 2009/11/21 11:52:57 dsl Exp $	*/
 
 /*
  * Ported to boot 386BSD by Julian Elischer (jul...@tfs.com) Sept 1992
@@ -287,6 +287,7 @@
 	call	_C_LABEL(prot_to_real)	# enter real mode
 	.code16
 
+	push	%ds
 	movl	%esi, %eax
 	shrl	$4, %eax
 	movw	%ds, %bx
@@ -298,6 +299,7 @@
 	int	$0x13
 	setc	%bl
 	movb	%ah, %bh	# save error code
+	pop	%ds
 
 	calll	_C_LABEL(real_to_prot) # back to protected mode
 	.code32
@@ -328,6 +330,7 @@
 	call	_C_LABEL(prot_to_real)	# enter real mode
 	.code16
 
+	push	%ds
 	movl	%esi, %eax
 	shrl	$4, %eax
 	andw	$0xf, %si
@@ -338,6 +341,7 @@
 	movb	$0x48, %ah	# subfunction
 	int	$0x13
 	setc	%bl
+	pop	%ds
 
 	calll	_C_LABEL(real_to_prot) # back to protected mode
 	.code32

Index: src/sys/arch/i386/stand/lib/biosmemps2.S
diff -u src/sys/arch/i386/stand/lib/biosmemps2.S:1.3 src/sys/arch/i386/stand/lib/biosmemps2.S:1.4
--- src/sys/arch/i386/stand/lib/biosmemps2.S:1.3	Mon Apr 28 20:23:25 2008
+++ src/sys/arch/i386/stand/lib/biosmemps2.S	Sat Nov 21 11:52:57 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: biosmemps2.S,v 1.3 2008/04/28 20:23:25 martin Exp $	*/
+/*	$NetBSD: biosmemps2.S,v 1.4 2009/11/21 11:52:57 dsl Exp $	*/
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -70,6 +70,7 @@
 
 getmem:
 	# move the parameter to right register
+	push	%ds
 	movl	%edx, %esi
 	andl	$0xf, %esi
 	shrl	$4, %edx
@@ -81,6 +82,7 @@
 	movb	$0xc7, %ah
 	int	$0x15
 	setc	%bl		# save carry
+	pop	%ds
 
 out:
 	calll	_C_LABEL(real_to_prot)

Index: src/sys/arch/i386/stand/lib/dos_file.S
diff -u src/sys/arch/i386/stand/lib/dos_file.S:1.5 src/sys/arch/i386/stand/lib/dos_file.S:1.6
--- src/sys/arch/i386/stand/lib/dos_file.S:1.5	Sat Feb  1 14:48:18 2003
+++ src/sys/arch/i386/stand/lib/dos_file.S	Sat Nov 21 11:52:57 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: dos_file.S,v 1.5 2003/02/01 14:48:18 dsl Exp $	*/
+/*	$NetBSD: dos_file.S,v 1.6 2009/11/21 11:52:57 dsl Exp $	*/
 	
 /* extracted from Tor Egge's patches for NetBSD boot */
 
@@ -29,6 +29,7 @@
 	call	_C_LABEL(prot_to_real)	# enter real mode
 	.code16
 
+	push	%ds
 	movl	%edx, %eax
 	shrl	$4, %eax
 	mov	%ds, %si
@@ -42,6 +43,7 @@
 	sti
 	int	$0x21
 	cli
+	pop	%ds
 
 	jnc	ok1
 	mov	%ax, _C_LABEL(doserrno)
@@ -80,6 +82,7 @@
 	call	_C_LABEL(prot_to_real)	# enter real mode
 	.code16
 
+	push	%ds
 	movl	%edx, %eax
 	shrl	$4, %eax
 	mov	%ds, %si
@@ -92,6 +95,7 @@
 	sti
 	int	$0x21
 	cli
+	pop	%ds
 
 	jnc	ok2
 	mov	%ax, _C_LABEL(doserrno)



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

2009-11-20 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Fri Nov 20 19:25:38 UTC 2009

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

Log Message:
EXT13_DEVPATH_SIGNATURE should be EXTINFO_DEVPATH_SIGNATURE


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sys/arch/i386/stand/lib/bootinfo_biosgeom.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/bootinfo_biosgeom.c
diff -u src/sys/arch/i386/stand/lib/bootinfo_biosgeom.c:1.19 src/sys/arch/i386/stand/lib/bootinfo_biosgeom.c:1.20
--- src/sys/arch/i386/stand/lib/bootinfo_biosgeom.c:1.19	Sun Dec 11 12:17:48 2005
+++ src/sys/arch/i386/stand/lib/bootinfo_biosgeom.c	Fri Nov 20 19:25:37 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: bootinfo_biosgeom.c,v 1.19 2005/12/11 12:17:48 christos Exp $	*/
+/*	$NetBSD: bootinfo_biosgeom.c,v 1.20 2009/11/20 19:25:37 dsl Exp $	*/
 
 /*
  * Copyright (c) 1997
@@ -117,7 +117,7 @@
 
 		/* The v3.0 stuff will help identify the disks */
 		if (ed.size >= offsetof(struct biosdisk_ext13info, checksum)
-		&& ed.devpath_sig == EXT13_DEVPATH_SIGNATURE) {
+		&& ed.devpath_sig == EXTINFO_DEVPATH_SIGNATURE) {
 			char *cp;
 
 			for (cp = (void *)&ed.devpath_sig, cksum = 0;



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

2009-11-19 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Thu Nov 19 22:13:17 UTC 2009

Modified Files:
src/sys/arch/i386/stand/lib: Makefile
Added Files:
src/sys/arch/i386/stand/lib: message32.S

Log Message:
Add 32 bit versions of message and dump_eax that write directly to
the serial port. Useful for debugging - especially real_to_prot!


To generate a diff of this commit:
cvs rdiff -u -r1.28 -r1.29 src/sys/arch/i386/stand/lib/Makefile
cvs rdiff -u -r0 -r1.1 src/sys/arch/i386/stand/lib/message32.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/Makefile
diff -u src/sys/arch/i386/stand/lib/Makefile:1.28 src/sys/arch/i386/stand/lib/Makefile:1.29
--- src/sys/arch/i386/stand/lib/Makefile:1.28	Mon Mar 30 09:22:52 2009
+++ src/sys/arch/i386/stand/lib/Makefile	Thu Nov 19 22:13:17 2009
@@ -1,4 +1,4 @@
-#	$NetBSD: Makefile,v 1.28 2009/03/30 09:22:52 tsutsui Exp $
+#	$NetBSD: Makefile,v 1.29 2009/11/19 22:13:17 dsl Exp $
 
 S?=	${.CURDIR}/../../../..
 
@@ -23,7 +23,7 @@
 SRCS+= bootinfo.c bootinfo_biosgeom.c bootinfo_memmap.c
 SRCS+= startprog.S multiboot.S panic.c
 SRCS+= biosgetsystime.S cpufunc.S bootmenu.c
-SRCS+= realprot.S message.S dump_eax.S pvcopy.S putstr.S
+SRCS+= realprot.S message.S message32.S dump_eax.S pvcopy.S putstr.S
 SRCS+= rasops.c vbe.c biosvbe.S
 .if (${I386_INCLUDE_DISK} == "yes")
 SRCS+= biosdisk.c biosdisk_ll.c bios_disk.S

Added files:

Index: src/sys/arch/i386/stand/lib/message32.S
diff -u /dev/null src/sys/arch/i386/stand/lib/message32.S:1.1
--- /dev/null	Thu Nov 19 22:13:17 2009
+++ src/sys/arch/i386/stand/lib/message32.S	Thu Nov 19 22:13:17 2009
@@ -0,0 +1,87 @@
+/*	$NetBSD: message32.S,v 1.1 2009/11/19 22:13:17 dsl Exp $	*/
+
+/*-
+ * Copyright (c) 2003 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by David Laight.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *notice, this list of conditions and the following disclaimer in the
+ *documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include 
+
+/* 
+ * Output messages directly to serial port from 32bit mode.
+ * Useful for debugging when the real-prot is suspect.
+ *
+ * %ds:dump_eax_buff must be somewhere it is safe to write 12 bytes.
+ */
+
+#ifndef COM_PORT_VAL
+#define COM_PORT_VAL $0x3f8	/* Standard address COM1 (dty0) */
+#endif
+
+	.globl	message32
+	.code32
+message32:
+	pusha   
+message32_1:
+	lodsb   
+2:
+	mov COM_PORT_VAL, %dx
+	outb%al, %dx
+	add $5, %dl
+3:  inb %dx
+	test$0x40, %al
+	jz  3b
+
+	lodsb
+	test%al, %al
+	jnz 2b
+	popa
+	ret 
+
+	.globl	dump_eax32
+dump_eax32:
+	pusha
+	movl	$dump_eax_buff, %esi
+	mov	%esi, %edi
+	push	$8
+	pop	%ecx
+1:	roll	$4, %eax
+	push	%eax
+	andb	$0x0f, %al
+	addb	$0x30, %al			/* 30..3f - clear AF */
+#if 1 /* 5 bytes to generate real hex... */
+	daa	/* 30..39, 40..45 */
+	addb	$0xc0, %al			/* f0..f9, 00..05 */
+	adcb	$0x40, %al			/* 30..39, 41..46 */
+#endif
+	movb	%al,(%edi)
+	inc	%edi
+	pop	%eax
+	loop	1b
+	push	$0x20/* space + 3 NULs */
+	pop	(%edi)
+	jmp	message32_1



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

2009-11-19 Thread David Laight
Module Name:src
Committed By:   dsl
Date:   Thu Nov 19 22:08:14 UTC 2009

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

Log Message:
Shorten slightly


To generate a diff of this commit:
cvs rdiff -u -r1.3 -r1.4 src/sys/arch/i386/stand/lib/dump_eax.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/dump_eax.S
diff -u src/sys/arch/i386/stand/lib/dump_eax.S:1.3 src/sys/arch/i386/stand/lib/dump_eax.S:1.4
--- src/sys/arch/i386/stand/lib/dump_eax.S:1.3	Wed Feb 11 07:24:40 2009
+++ src/sys/arch/i386/stand/lib/dump_eax.S	Thu Nov 19 22:08:14 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: dump_eax.S,v 1.3 2009/02/11 07:24:40 jnemeth Exp $	*/
+/*	$NetBSD: dump_eax.S,v 1.4 2009/11/19 22:08:14 dsl Exp $	*/
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -39,9 +39,6 @@
 ENTRY(dump_eax)
 	.code16
 	pusha	/* saves bottom 16 bits only! */
-	push	%es/* allow for %es != %ds */
-	push	%ds
-	pop	%es
 	movw	$dump_eax_buff, %si
 	mov	%si, %di
 	movw	$8, %cx
@@ -54,10 +51,9 @@
 	addb	$0xc0, %al			/* f0..f9, 00..05 */
 	adcb	$0x40, %al			/* 30..39, 41..46 */
 #endif
-	stosb
+	mov	%al,(%di)
+	inc	%di
 	pop	%ax
 	loop	1b
-	movw	$0x20, %ax			/* space + null */
-	stosw
-	pop	%es
+	movw	$0x20,(%di)			/* space + NIL */
 	jmp	message_1



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

2009-10-20 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Oct 20 14:49:03 UTC 2009

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

Log Message:
trim some fat, don't scan disklabels on non-HD disks


To generate a diff of this commit:
cvs rdiff -u -r1.29 -r1.30 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.29 src/sys/arch/i386/stand/lib/biosdisk.c:1.30
--- src/sys/arch/i386/stand/lib/biosdisk.c:1.29	Sun Sep 13 22:45:27 2009
+++ src/sys/arch/i386/stand/lib/biosdisk.c	Tue Oct 20 14:49:03 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: biosdisk.c,v 1.29 2009/09/13 22:45:27 jmcneill Exp $	*/
+/*	$NetBSD: biosdisk.c,v 1.30 2009/10/20 14:49:03 jmcneill Exp $	*/
 
 /*
  * Copyright (c) 1996, 1998
@@ -319,17 +319,17 @@
 			d.ll.dev = 0x80 + i;			/* hd/cd */
 		if (set_geometry(&d.ll, &ed))
 			continue;
+		printf("disk ");
 		switch (d.ll.type) {
 		case BIOSDISK_TYPE_CD:
-			printf("disk cd0\n");
-			printf("  cd0a(unknown)\n");
+			printf("cd0\n  cd0a\n");
 			break;
 		case BIOSDISK_TYPE_FD:
-			printf("disk fd%d\n", d.ll.dev & 0x7f);
-			printf("  fd%da(unknown)\n", d.ll.dev & 0x7f);
+			printf("fd%d\n", d.ll.dev & 0x7f);
+			printf("  fd%da\n", d.ll.dev & 0x7f);
 			break;
 		case BIOSDISK_TYPE_HD:
-			printf("disk hd%d", d.ll.dev & 0x7f);
+			printf("hd%d", d.ll.dev & 0x7f);
 			if (d.ll.flags & BIOSDISK_INT13EXT) {
 printf(" size ");
 size = ed.totsec * ed.sbytes;
@@ -344,6 +344,8 @@
 			break;
 		}
 #ifndef NO_DISKLABEL
+		if (d.ll.type != BIOSDISK_TYPE_HD)
+			continue;
 		if (read_label(&d) == -1)
 			break;
 		lp = (struct disklabel *)(d.buf + LABELOFFSET);



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

2009-10-20 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Tue Oct 20 14:47:33 UTC 2009

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

Log Message:
trim some fat


To generate a diff of this commit:
cvs rdiff -u -r1.4 -r1.5 src/sys/arch/i386/stand/lib/vbe.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/vbe.c
diff -u src/sys/arch/i386/stand/lib/vbe.c:1.4 src/sys/arch/i386/stand/lib/vbe.c:1.5
--- src/sys/arch/i386/stand/lib/vbe.c:1.4	Mon Sep 14 11:56:27 2009
+++ src/sys/arch/i386/stand/lib/vbe.c	Tue Oct 20 14:47:33 2009
@@ -1,4 +1,4 @@
-/* $NetBSD: vbe.c,v 1.4 2009/09/14 11:56:27 jmcneill Exp $ */
+/* $NetBSD: vbe.c,v 1.5 2009/10/20 14:47:33 jmcneill Exp $ */
 
 /*-
  * Copyright (c) 2009 Jared D. McNeill 
@@ -38,25 +38,11 @@
 
 extern const uint8_t rasops_cmap[];
 
-static int vbeverbose = 1;
-
 static struct _vbestate {
 	int		available;
 	int		modenum;
 } vbestate;
 
-static void
-vbe_dump(struct vbeinfoblock *vbe)
-{
-	int mem = (int)vbe->TotalMemory * 64;
-
-	if (!vbeverbose)
-		return;
-
-	printf(">> VESA VBE Version %d.%d %d k\n",
-	vbe->VbeVersion >> 8, vbe->VbeVersion & 0xff, mem);
-}
-
 static int
 vbe_mode_is_supported(struct modeinfoblock *mi)
 {
@@ -74,6 +60,16 @@
 	return 1;
 }
 
+static bool
+vbe_check(void)
+{
+	if (!vbestate.available) {
+		printf("VBE not available\n");
+		return false;
+	}
+	return true;
+}
+
 void
 vbe_init(void)
 {
@@ -83,14 +79,9 @@
 	memcpy(vbe.VbeSignature, "VBE2", 4);
 	if (biosvbe_info(&vbe) != 0x004f)
 		return;
-	if (memcmp(vbe.VbeSignature, "VESA", 4) != 0) {
-		printf("VESA VBE: bad signature %c%c%c%c\n",
-		vbe.VbeSignature[0], vbe.VbeSignature[1],
-		vbe.VbeSignature[2], vbe.VbeSignature[3]);
+	if (memcmp(vbe.VbeSignature, "VESA", 4) != 0)
 		return;
-	}
 
-	vbe_dump(&vbe);
 	vbestate.available = 1;
 	vbestate.modenum = 0;
 }
@@ -107,10 +98,8 @@
 	struct paletteentry pe;
 	int ret;
 
-	if (!vbestate.available) {
-		printf("VESA BIOS extensions not available\n");
+	if (!vbe_check())
 		return 1;
-	}
 
 	pe.Blue = cmap[2] >> 2;
 	pe.Green = cmap[1] >> 2;
@@ -129,25 +118,23 @@
 	struct btinfo_framebuffer fb;
 	int ret, i;
 
-	if (!vbestate.available) {
-		printf("VESA BIOS extensions not available\n");
+	if (!vbe_check())
 		return 1;
-	}
 
 	ret = biosvbe_get_mode_info(modenum, &mi);
 	if (ret != 0x004f) {
-		printf("VESA VBE mode 0x%x is invalid.\n", modenum);
+		printf("mode 0x%x invalid\n", modenum);
 		return 1;
 	}
 
 	if (!vbe_mode_is_supported(&mi)) {
-		printf("VESA VBE mode 0x%x is not supported.\n", modenum);
+		printf("mode 0x%x not supported\n", modenum);
 		return 1;
 	}
 
 	ret = biosvbe_set_mode(modenum);
 	if (ret != 0x004f) {
-		printf("VESA VBE mode 0x%x could not be set.\n", modenum);
+		printf("mode 0x%x could not be set\n", modenum);
 		return 1;
 	}
 
@@ -183,7 +170,7 @@
 	if (vbestate.modenum > 0) {
 		ret = vbe_set_mode(vbestate.modenum);
 		if (ret) {
-			printf("WARNING: failed to set VESA VBE mode 0x%x\n",
+			printf("WARNING: failed to set VBE mode 0x%x\n",
 			vbestate.modenum);
 			delay(500);
 		}
@@ -266,7 +253,6 @@
 			return mode;
 	}
 
-	printf("VESA VBE BIOS does not support %s\n", str);
 	return 0;
 }
 
@@ -286,10 +272,8 @@
 	uint16_t mode;
 	int nmodes = 0, safety = 0;
 
-	if (!vbestate.available) {
-		printf("VESA BIOS extensions not available\n");
+	if (!vbe_check())
 		return;
-	}
 
 	printf("Modes: ");
 	memset(&vbe, 0, sizeof(vbe));
@@ -306,7 +290,7 @@
 		safety++;
 		farptr += 2;
 		if (safety == 100) {
-			printf("[garbage] ");
+			printf("[?] ");
 			break;
 		}
 		if (biosvbe_get_mode_info(mode, &mi) != 0x004f)
@@ -335,10 +319,8 @@
 	char arg[20];
 	int modenum;
 
-	if (!vbe_available()) {
-		printf("VESA VBE not available\n");
+	if (!vbe_check())
 		return;
-	}
 
 	strlcpy(arg, cmd, sizeof(arg));
 
@@ -370,6 +352,6 @@
 		return;
 	}
 
-	printf("invalid flag, must be 'enabled', 'disabled', "
-	"a display mode, or a valid VESA VBE mode number.\n");
+	printf("invalid flag, must be 'on', 'off', "
+	"a display mode, or a VBE mode number\n");
 }



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

2009-09-14 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Mon Sep 14 10:42:43 UTC 2009

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

Log Message:
Don't treat timeouts or the return key as an invalid choice; spotted by
Andreas Gustafsson.


To generate a diff of this commit:
cvs rdiff -u -r1.7 -r1.8 src/sys/arch/i386/stand/lib/bootmenu.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/bootmenu.c
diff -u src/sys/arch/i386/stand/lib/bootmenu.c:1.7 src/sys/arch/i386/stand/lib/bootmenu.c:1.8
--- src/sys/arch/i386/stand/lib/bootmenu.c:1.7	Sun Sep 13 23:53:36 2009
+++ src/sys/arch/i386/stand/lib/bootmenu.c	Mon Sep 14 10:42:42 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: bootmenu.c,v 1.7 2009/09/13 23:53:36 jmcneill Exp $	*/
+/*	$NetBSD: bootmenu.c,v 1.8 2009/09/14 10:42:42 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -261,11 +261,15 @@
 static int
 getchoicefrominput(char *input, int def)
 {
-	int choice;
+	int choice, usedef;
+
 	choice = -1;
-	if (*input == '\0' || *input == '\r' || *input == '\n')
+	usedef = 0;
+
+	if (*input == '\0' || *input == '\r' || *input == '\n') {
 		choice = def;
-	else if (*input >= 'A' && *input < bootconf.nummenu + 'A')
+		usedef = 1;
+	} else if (*input >= 'A' && *input < bootconf.nummenu + 'A')
 		choice = (*input) - 'A';
 	else if (*input >= 'a' && *input < bootconf.nummenu + 'a')
 		choice = (*input) - 'a';
@@ -275,7 +279,8 @@
 			choice = -1;
 	}
 
-	if (bootconf.menuformat != MENUFORMAT_LETTER && !isnum(*input))
+	if (bootconf.menuformat != MENUFORMAT_LETTER &&
+	!isnum(*input) && !usedef)
 		choice = -1;
 
 	return choice;



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

2009-09-13 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Sep 13 23:53:36 UTC 2009

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

Log Message:
If the menuformat is not letter, do not allow letter keys to be aliases
for number keys. snj@ often overshoots the spacebar in a panic and
accidentally hits 'b' instead, which makes the loader boot item '2'.
Can't fix snj@, so fix the boot loader instead.


To generate a diff of this commit:
cvs rdiff -u -r1.6 -r1.7 src/sys/arch/i386/stand/lib/bootmenu.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/bootmenu.c
diff -u src/sys/arch/i386/stand/lib/bootmenu.c:1.6 src/sys/arch/i386/stand/lib/bootmenu.c:1.7
--- src/sys/arch/i386/stand/lib/bootmenu.c:1.6	Fri Apr 10 19:41:41 2009
+++ src/sys/arch/i386/stand/lib/bootmenu.c	Sun Sep 13 23:53:36 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: bootmenu.c,v 1.6 2009/04/10 19:41:41 perry Exp $	*/
+/*	$NetBSD: bootmenu.c,v 1.7 2009/09/13 23:53:36 jmcneill Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -274,6 +274,10 @@
 		if (choice < 0 || choice >= bootconf.nummenu)
 			choice = -1;
 	}
+
+	if (bootconf.menuformat != MENUFORMAT_LETTER && !isnum(*input))
+		choice = -1;
+
 	return choice;
 }
 



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

2009-09-13 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Sep 13 18:13:37 UTC 2009

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

Log Message:
kmod improvements
 - unless otherwise specified, modules are now loaded from the same device
   as the kernel ('load miniroot' now implies 'load tftp:miniroot' if the
   boot command is 'boot tftp:netbsd')
 - the module name -> path expansion now works when a device prefix: is
   specified ('load tftp:miniroot' now works)
 - if the module name has been expanded to a path, print that path when
   loading the module rather than the symbolic name
 - only print an error in module_open if both the expanded path and the
   raw path fail to open


To generate a diff of this commit:
cvs rdiff -u -r1.40 -r1.41 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.40 src/sys/arch/i386/stand/lib/exec.c:1.41
--- src/sys/arch/i386/stand/lib/exec.c:1.40	Sat Mar 21 15:01:56 2009
+++ src/sys/arch/i386/stand/lib/exec.c	Sun Sep 13 18:13:37 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: exec.c,v 1.40 2009/03/21 15:01:56 ad Exp $	 */
+/*	$NetBSD: exec.c,v 1.41 2009/09/13 18:13:37 jmcneill Exp $	 */
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -124,6 +124,8 @@
 #define	PAGE_SIZE	4096
 #endif
 
+#define MODULE_WARNING_DELAY	500
+
 extern struct btinfo_console btinfo_console;
 
 boot_module_t *boot_modules;
@@ -138,7 +140,7 @@
 static char module_base[64] = "/";
 static int howto;
 
-static void	module_init(void);
+static void	module_init(const char *);
 
 void
 framebuffer_configure(struct btinfo_framebuffer *fb)
@@ -304,7 +306,7 @@
 
 	/* pull in any modules if necessary */
 	if (boot_modules_enabled) {
-		module_init();
+		module_init(file);
 		if (btinfo_modulelist) {
 			BI_ADD(btinfo_modulelist, BTINFO_MODULELIST,
 			btinfo_modulelist_size);
@@ -333,12 +335,26 @@
 	return -1;
 }
 
+static void
+extract_device(const char *path, char *buf, size_t buflen)
+{
+	int i;
+
+	if (strchr(path, ':') != NULL) {
+		for (i = 0; i < buflen - 2 && path[i] != ':'; i++)
+			buf[i] = path[i];
+		buf[i++] = ':';
+		buf[i] = '\0';
+	} else
+		buf[0] = '\0';
+}
+
 static const char *
-module_path(boot_module_t *bm)
+module_path(boot_module_t *bm, const char *kdev)
 {
 	static char buf[256];
-	char name_buf[256];
-	const char *name, *name2;
+	char name_buf[256], dev_buf[64];
+	const char *name, *name2, *p;
 
 	name = bm->bm_path;
 	for (name2 = name; *name2; ++name2) {
@@ -350,45 +366,69 @@
 			break;
 		}
 	}
- 	if (name[0] == '/')
-		snprintf(buf, sizeof(buf), "%s", name);
-	else
-		snprintf(buf, sizeof(buf), "%s/%s/%s.kmod",
-		module_base, name, name);
+	if ((p = strchr(name, ':')) != NULL) {
+		/* device specified, use it */
+		if (p[1] == '/')
+			snprintf(buf, sizeof(buf), "%s", name);
+		else {
+			p++;
+			extract_device(name, dev_buf, sizeof(dev_buf));
+			snprintf(buf, sizeof(buf), "%s%s/%s/%s.kmod",
+			dev_buf, module_base, p, p);
+		}
+	} else {
+		/* device not specified; load from kernel device if known */
+ 		if (name[0] == '/')
+			snprintf(buf, sizeof(buf), "%s%s", kdev, name);
+		else
+			snprintf(buf, sizeof(buf), "%s%s/%s/%s.kmod",
+			kdev, module_base, name, name);
+	}
 
 	return buf;
 }
 
 static int
-module_open(boot_module_t *bm, int mode)
+module_open(boot_module_t *bm, int mode, const char *kdev, bool doload)
 {
 	int fd;
 	const char *path;
 
 	/* check the expanded path first */
-	path = module_path(bm);
+	path = module_path(bm, kdev);
 	fd = open(path, mode);
-	if (fd == -1) {
-		printf("WARNING: couldn't open %s\n", path);
+	if (fd != -1) {
+		if ((howto & AB_SILENT) == 0 && doload)
+			printf("Loading %s ", path);
+	} else {
 		/* now attempt the raw path provided */
 		fd = open(bm->bm_path, mode);
-		if (fd == -1)
-			printf("WARNING: couldn't open %s\n", bm->bm_path);
+		if (fd != -1 && (howto & AB_SILENT) == 0 && doload)
+			printf("Loading %s ", bm->bm_path);
+	}
+	if (!doload && fd == -1) {
+		printf("WARNING: couldn't open %s", bm->bm_path);
+		if (strcmp(bm->bm_path, path) != 0)
+			printf(" (%s)", path);
+		printf("\n");
 	}
 	return fd;
 }
 
 static void
-module_init(void)
+module_init(const char *kernel_path)
 {
 	struct bi_modulelist_entry *bi;
 	struct stat st;
 	const char *machine;
+	char kdev[64];
 	char *buf;
 	boot_module_t *bm;
 	size_t len;
 	off_t off;
-	int err, fd;
+	int err, fd, nfail = 0;
+
+	extract_device(kernel_path, kdev, sizeof(kdev));
 
 	switch (netbsd_elf_class) {
 	case ELFCLASS32:
@@ -419,9 +459,10 @@
 	/* First, see which modules are valid and calculate btinfo size */
 	len = sizeof(struct btinfo_modulelist);
 	for (bm = boot_modules; bm; bm = bm->bm_next) {
-		fd = module_open(bm, 0);
+		fd = module_open(bm, 0, kdev, false);
 		if (fd == -1) {
 			bm->bm_len = -1;
+			++nfail;
 			continue

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

2009-08-26 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Wed Aug 26 13:28:48 UTC 2009

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

Log Message:
int 15h/AH=86h (WAIT) doesn't work properly on all hardware and emulators, so
for the countdown use the more coarsely grained sleep implementation based
on int 1ah/AH=00h (GET SYSTEM TIME).

ok ad@


To generate a diff of this commit:
cvs rdiff -u -r1.26 -r1.27 src/sys/arch/i386/stand/lib/pcio.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/pcio.c
diff -u src/sys/arch/i386/stand/lib/pcio.c:1.26 src/sys/arch/i386/stand/lib/pcio.c:1.27
--- src/sys/arch/i386/stand/lib/pcio.c:1.26	Mon Jun 29 09:23:16 2009
+++ src/sys/arch/i386/stand/lib/pcio.c	Wed Aug 26 13:28:48 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: pcio.c,v 1.26 2009/06/29 09:23:16 mbalmer Exp $	 */
+/*	$NetBSD: pcio.c,v 1.27 2009/08/26 13:28:48 jmcneill Exp $	 */
 
 /*
  * Copyright (c) 1996, 1997
@@ -71,6 +71,20 @@
 
 #define POLL_FREQ 10
 
+static void
+wait(int us)
+{
+	int prev = biosgetsystime();
+	int tgt = prev + (20 * us) / 100;
+	int new;
+
+	while ((new = biosgetsystime()) < tgt) {
+		if (new < prev) /* XXX timer wrapped */
+			break;
+		prev = new;
+	}
+}
+
 #ifdef SUPPORT_SERIAL
 static int
 getcomaddr(int idx)
@@ -346,7 +360,7 @@
 			goto out;
 		}
 		if (i--)
-			delay(100 / POLL_FREQ);
+			wait(100 / POLL_FREQ);
 		else
 			break;
 	}



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

2009-08-23 Thread Jared D. McNeill
Module Name:src
Committed By:   jmcneill
Date:   Sun Aug 23 12:31:05 UTC 2009

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

Log Message:
PR# kern/39726: Soekris 5501-60 boot/bootxx 120 second delay
PR# port-i386/41162: A20 gate legacy hook cause long pxeboot delay on Soekris 
net5501

Remove calls to delay() before polling KBD registers in gateA20().


To generate a diff of this commit:
cvs rdiff -u -r1.11 -r1.12 src/sys/arch/i386/stand/lib/gatea20.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/gatea20.c
diff -u src/sys/arch/i386/stand/lib/gatea20.c:1.11 src/sys/arch/i386/stand/lib/gatea20.c:1.12
--- src/sys/arch/i386/stand/lib/gatea20.c:1.11	Tue Oct 14 14:18:11 2008
+++ src/sys/arch/i386/stand/lib/gatea20.c	Sun Aug 23 12:31:05 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: gatea20.c,v 1.11 2008/10/14 14:18:11 ad Exp $	*/
+/*	$NetBSD: gatea20.c,v 1.12 2009/08/23 12:31:05 jmcneill Exp $	*/
 
 /* extracted from freebsd:sys/i386/boot/biosboot/io.c */
 
@@ -67,12 +67,10 @@
 
 		outb(K_CMD, KC_CMD_WOUT);
 
-		delay(100);
 		while (inb(K_STATUS) & K_IBUF_FUL);
 
 		outb(K_RDWR, x_20);
 
-		delay(100);
 		while (inb(K_STATUS) & K_IBUF_FUL);
 
 		while (inb(K_STATUS) & K_OBUF_FUL)



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

2009-06-29 Thread Marc Balmer
Module Name:src
Committed By:   mbalmer
Date:   Mon Jun 29 09:23:16 UTC 2009

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

Log Message:
Have the boot countdown on i386 display "starting in N seconds." instead
of "starting in N" and eliminate a use of sprintf.  Note that on
some rare machines it can be that the BIOS does not provide the delay
function.  On such machines the countdown will almost immediately count down
to zero display "starting in 0 seconds."; apparently the net4801 is such a
machine.
Feedback, ideas, and inspiration from tron, ok tron/tonnerre


To generate a diff of this commit:
cvs rdiff -u -r1.25 -r1.26 src/sys/arch/i386/stand/lib/pcio.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/pcio.c
diff -u src/sys/arch/i386/stand/lib/pcio.c:1.25 src/sys/arch/i386/stand/lib/pcio.c:1.26
--- src/sys/arch/i386/stand/lib/pcio.c:1.25	Sun Dec 14 18:46:33 2008
+++ src/sys/arch/i386/stand/lib/pcio.c	Mon Jun 29 09:23:16 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: pcio.c,v 1.25 2008/12/14 18:46:33 christos Exp $	 */
+/*	$NetBSD: pcio.c,v 1.26 2009/06/29 09:23:16 mbalmer Exp $	 */
 
 /*
  * Copyright (c) 1996, 1997
@@ -323,15 +323,19 @@
 
 	for (;;) {
 		if (tell && (i % POLL_FREQ) == 0) {
-			char numbuf[20];
-			int len, j;
+			char numbuf[32];
+			int len;
 
-			sprintf(numbuf, "%d ", i/POLL_FREQ);
-			len = strlen(numbuf);
-			for (j = 0; j < len; j++)
-numbuf[len + j] = '\b';
-			numbuf[len + j] = '\0';
-			printf(numbuf);
+			len = snprintf(numbuf, sizeof(numbuf), "%d seconds. ",
+			i/POLL_FREQ);
+			if (len > 0 && len < sizeof(numbuf)) {
+char *p = numbuf;
+
+printf("%s", numbuf);
+while (*p)
+	*p++ = '\b';
+printf("%s", numbuf);
+			}
 		}
 		if (iskey(1)) {
 			/* flush input buffer */
@@ -349,7 +353,7 @@
 
 out:
 	if (tell)
-		printf("0 \n");
+		printf("0 seconds. \n");
 
 	return c;
 }



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

2009-04-10 Thread Perry E. Metzger
Module Name:src
Committed By:   perry
Date:   Fri Apr 10 19:41:41 UTC 2009

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

Log Message:
Check the size of the offered boot.cfg file. Bail out if it is larger
than 32k.

A bootconf file is normally only a few hundred bytes long. If it is
much bigger than expected, we can't load it into an 8086 real mode
segment anyway.

Much more to the point, in the pxeboot case, someone may have
configured their dhcpd to return the filename for the kernel, not
realizing that the filename is now for boot.cfg which didn't used to
be the case. If we try to load the kernel here, thinking it is
boot.cfg by accident, the boot loader will die ignominiously and
without much of an error message, so we don't want to do that.

This needs to be pulled up to 5.0 if 5.0 has all this machinery
-- I'm not sure whether it does.


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/sys/arch/i386/stand/lib/bootmenu.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/bootmenu.c
diff -u src/sys/arch/i386/stand/lib/bootmenu.c:1.5 src/sys/arch/i386/stand/lib/bootmenu.c:1.6
--- src/sys/arch/i386/stand/lib/bootmenu.c:1.5	Wed Mar 18 16:00:12 2009
+++ src/sys/arch/i386/stand/lib/bootmenu.c	Fri Apr 10 19:41:41 2009
@@ -1,4 +1,4 @@
-/*	$NetBSD: bootmenu.c,v 1.5 2009/03/18 16:00:12 cegger Exp $	*/
+/*	$NetBSD: bootmenu.c,v 1.6 2009/04/10 19:41:41 perry Exp $	*/
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -122,6 +122,21 @@
 		return;
 	}
 
+	/*
+	 * Check the size. A bootconf file is normally only a few
+	 * hundred bytes long. If it is much bigger than expected,
+	 * don't try to load it. We can't load something big into
+	 * an 8086 real mode segment anyway, and in pxeboot this is
+	 * probably a case of the loader getting a filename for the
+	 * kernel and thinking it is boot.cfg by accident. (The 32k
+	 * number is arbitrary but 8086 real mode data segments max
+	 * out at 64k.)
+	 */
+	if (st.st_size > 32768) {
+		close(fd);
+		return;
+	}
+
 	bc = alloc(st.st_size + 1);
 	if (bc == NULL) {
 		printf("Could not allocate memory for boot configuration\n");