[Midnightbsd-cvs] src [10194] U trunk/sys/boot/i386: sync with freebsd

laffer1 at midnightbsd.org laffer1 at midnightbsd.org
Fri Jun 1 19:44:38 EDT 2018


Revision: 10194
          http://svnweb.midnightbsd.org/src/?rev=10194
Author:   laffer1
Date:     2018-06-01 19:44:37 -0400 (Fri, 01 Jun 2018)
Log Message:
-----------
sync with freebsd

Modified Paths:
--------------
    trunk/sys/boot/i386/boot0/Makefile
    trunk/sys/boot/i386/boot2/Makefile
    trunk/sys/boot/i386/boot2/boot1.S
    trunk/sys/boot/i386/boot2/boot2.c
    trunk/sys/boot/i386/boot2/lib.h
    trunk/sys/boot/i386/boot2/sio.S
    trunk/sys/boot/i386/btx/Makefile
    trunk/sys/boot/i386/btx/Makefile.inc
    trunk/sys/boot/i386/btx/btx/Makefile
    trunk/sys/boot/i386/btx/btx/btx.S
    trunk/sys/boot/i386/btx/btxldr/Makefile
    trunk/sys/boot/i386/btx/btxldr/btxldr.S
    trunk/sys/boot/i386/btx/lib/Makefile
    trunk/sys/boot/i386/btx/lib/btxcsu.S
    trunk/sys/boot/i386/btx/lib/btxsys.s
    trunk/sys/boot/i386/btx/lib/btxv86.h
    trunk/sys/boot/i386/btx/lib/btxv86.s
    trunk/sys/boot/i386/cdboot/Makefile
    trunk/sys/boot/i386/cdboot/cdboot.S
    trunk/sys/boot/i386/common/bootargs.h
    trunk/sys/boot/i386/common/cons.c
    trunk/sys/boot/i386/common/cons.h
    trunk/sys/boot/i386/common/drv.c
    trunk/sys/boot/i386/common/drv.h
    trunk/sys/boot/i386/common/edd.h
    trunk/sys/boot/i386/gptboot/Makefile
    trunk/sys/boot/i386/gptboot/gptboot.8
    trunk/sys/boot/i386/gptboot/gptboot.c
    trunk/sys/boot/i386/gptboot/gptldr.S
    trunk/sys/boot/i386/gptzfsboot/Makefile
    trunk/sys/boot/i386/gptzfsboot/gptzfsboot.8
    trunk/sys/boot/i386/kgzldr/Makefile
    trunk/sys/boot/i386/kgzldr/boot.c
    trunk/sys/boot/i386/kgzldr/crt.s
    trunk/sys/boot/i386/kgzldr/kgzldr.h
    trunk/sys/boot/i386/kgzldr/lib.c
    trunk/sys/boot/i386/kgzldr/sio.s
    trunk/sys/boot/i386/kgzldr/start.s
    trunk/sys/boot/i386/libfirewire/Makefile
    trunk/sys/boot/i386/libfirewire/dconsole.c
    trunk/sys/boot/i386/libfirewire/fwohci.c
    trunk/sys/boot/i386/libfirewire/fwohci.h
    trunk/sys/boot/i386/libfirewire/fwohcireg.h
    trunk/sys/boot/i386/libi386/Makefile
    trunk/sys/boot/i386/libi386/amd64_tramp.S
    trunk/sys/boot/i386/libi386/biosacpi.c
    trunk/sys/boot/i386/libi386/bioscd.c
    trunk/sys/boot/i386/libi386/biosdisk.c
    trunk/sys/boot/i386/libi386/biosmem.c
    trunk/sys/boot/i386/libi386/biospci.c
    trunk/sys/boot/i386/libi386/biospnp.c
    trunk/sys/boot/i386/libi386/biossmap.c
    trunk/sys/boot/i386/libi386/bootinfo.c
    trunk/sys/boot/i386/libi386/bootinfo32.c
    trunk/sys/boot/i386/libi386/bootinfo64.c
    trunk/sys/boot/i386/libi386/comconsole.c
    trunk/sys/boot/i386/libi386/devicename.c
    trunk/sys/boot/i386/libi386/elf32_freebsd.c
    trunk/sys/boot/i386/libi386/elf64_freebsd.c
    trunk/sys/boot/i386/libi386/i386_copy.c
    trunk/sys/boot/i386/libi386/i386_module.c
    trunk/sys/boot/i386/libi386/libi386.h
    trunk/sys/boot/i386/libi386/pxe.c
    trunk/sys/boot/i386/libi386/pxe.h
    trunk/sys/boot/i386/libi386/smbios.c
    trunk/sys/boot/i386/libi386/time.c
    trunk/sys/boot/i386/pmbr/pmbr.s

Added Paths:
-----------
    trunk/sys/boot/i386/libi386/multiboot.c
    trunk/sys/boot/i386/libi386/multiboot.h
    trunk/sys/boot/i386/libi386/multiboot_tramp.S
    trunk/sys/boot/i386/libi386/smbios.h

Property Changed:
----------------
    trunk/sys/boot/i386/boot0/boot0.S
    trunk/sys/boot/i386/boot0/boot0ext.S
    trunk/sys/boot/i386/boot2/boot1.S
    trunk/sys/boot/i386/boot2/sio.S
    trunk/sys/boot/i386/btx/Makefile.inc
    trunk/sys/boot/i386/btx/btxldr/btxldr.S
    trunk/sys/boot/i386/btx/lib/btxcsu.S
    trunk/sys/boot/i386/btx/lib/btxsys.s
    trunk/sys/boot/i386/btx/lib/btxv86.s
    trunk/sys/boot/i386/cdboot/cdboot.S
    trunk/sys/boot/i386/efi/start.S
    trunk/sys/boot/i386/gptboot/gptldr.S
    trunk/sys/boot/i386/mbr/mbr.s
    trunk/sys/boot/i386/pmbr/pmbr.s
    trunk/sys/boot/i386/pxeldr/pxeldr.S
    trunk/sys/boot/i386/zfsboot/zfsldr.S

Modified: trunk/sys/boot/i386/boot0/Makefile
===================================================================
--- trunk/sys/boot/i386/boot0/Makefile	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/boot0/Makefile	2018-06-01 23:44:37 UTC (rev 10194)
@@ -1,9 +1,10 @@
-# $FreeBSD$
+# $MidnightBSD$
+# $FreeBSD: stable/10/sys/boot/i386/boot0/Makefile 276486 2014-12-31 23:25:37Z ngie $
 
 PROG?=	boot0
 STRIP=
 BINMODE=${NOBINMODE}
-NO_MAN=
+MAN=
 SRCS=	${PROG}.S
 
 # Additional options that you can specify with make OPTS="..."

Index: trunk/sys/boot/i386/boot0/boot0.S
===================================================================
--- trunk/sys/boot/i386/boot0/boot0.S	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/boot0/boot0.S	2018-06-01 23:44:37 UTC (rev 10194)

Property changes on: trunk/sys/boot/i386/boot0/boot0.S
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Index: trunk/sys/boot/i386/boot0/boot0ext.S
===================================================================
--- trunk/sys/boot/i386/boot0/boot0ext.S	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/boot0/boot0ext.S	2018-06-01 23:44:37 UTC (rev 10194)

Property changes on: trunk/sys/boot/i386/boot0/boot0ext.S
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/sys/boot/i386/boot2/Makefile
===================================================================
--- trunk/sys/boot/i386/boot2/Makefile	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/boot2/Makefile	2018-06-01 23:44:37 UTC (rev 10194)
@@ -1,5 +1,5 @@
 # $MidnightBSD$
-# $FreeBSD: stable/9/sys/boot/i386/boot2/Makefile 279796 2015-03-08 22:50:45Z dim $
+# $FreeBSD: stable/10/sys/boot/i386/boot2/Makefile 319025 2017-05-28 01:14:59Z ngie $
 
 .include <bsd.own.mk>
 
@@ -61,7 +61,7 @@
 CLEANFILES+=	boot1 boot1.out boot1.o
 
 boot1: boot1.out
-	objcopy -S -O binary boot1.out ${.TARGET}
+	${OBJCOPY} -S -O binary boot1.out ${.TARGET}
 
 boot1.out: boot1.o
 	${LD} ${LD_FLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} boot1.o
@@ -69,10 +69,12 @@
 CLEANFILES+=	boot2 boot2.ld boot2.ldr boot2.bin boot2.out boot2.o \
 		boot2.s boot2.s.tmp boot2.h sio.o
 
+BOOT2SIZE=	7680
+
 boot2: boot2.ld
-	@set -- `ls -l boot2.ld`; x=$$((7680-$$5)); \
+	@set -- `ls -l ${.ALLSRC}`; x=$$((${BOOT2SIZE}-$$5)); \
 	    echo "$$x bytes available"; test $$x -ge 0
-	dd if=boot2.ld of=${.TARGET} obs=7680 conv=osync
+	${DD} if=${.ALLSRC} of=${.TARGET} obs=${BOOT2SIZE} conv=osync
 
 boot2.ld: boot2.ldr boot2.bin ${BTXKERN}
 	btxld -v -E ${ORG2} -f bin -b ${BTXKERN} -l boot2.ldr \
@@ -79,10 +81,10 @@
 	    -o ${.TARGET} -P 1 boot2.bin
 
 boot2.ldr:
-	dd if=/dev/zero of=${.TARGET} bs=512 count=1
+	${DD} if=/dev/zero of=${.TARGET} bs=512 count=1
 
 boot2.bin: boot2.out
-	objcopy -S -O binary boot2.out ${.TARGET}
+	${OBJCOPY} -S -O binary boot2.out ${.TARGET}
 
 boot2.out: ${BTXCRT} boot2.o sio.o
 	${LD} ${LD_FLAGS} -Ttext ${ORG2} -o ${.TARGET} ${.ALLSRC}

Modified: trunk/sys/boot/i386/boot2/boot1.S
===================================================================
--- trunk/sys/boot/i386/boot2/boot1.S	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/boot2/boot1.S	2018-06-01 23:44:37 UTC (rev 10194)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 1998 Robert Nordier
  * All rights reserved.
@@ -12,7 +13,7 @@
  * warranties of merchantability and fitness for a particular
  * purpose.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/boot/i386/boot2/boot1.S 232623 2012-03-06 20:45:13Z jhb $
  */
 
 /* Memory Locations */
@@ -125,7 +126,10 @@
 		mov $start,%sp			#  stack
 /*
  * Relocate ourself to MEM_REL.  Since %cx == 0, the inc %ch sets
- * %cx == 0x100.
+ * %cx == 0x100.  Note that boot1 does not use this relocated copy
+ * of itself while loading boot2; however, BTX reclaims the memory
+ * used by boot1 during its initialization.  As a result, boot2 uses
+ * xread from the relocated copy.
  */
 		mov %sp,%si			# Source
 		mov $MEM_REL,%di		# Destination


Property changes on: trunk/sys/boot/i386/boot2/boot1.S
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/sys/boot/i386/boot2/boot2.c
===================================================================
--- trunk/sys/boot/i386/boot2/boot2.c	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/boot2/boot2.c	2018-06-01 23:44:37 UTC (rev 10194)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1998 Robert Nordier
  * All rights reserved.
@@ -14,8 +15,6 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
-/* $FreeBSD: src/sys/boot/i386/boot2/boot2.c,v 1.83.2.5.2.1 2008/11/25 02:59:29 kensmith Exp $ */
 
 #include <sys/param.h>
 #include <sys/disklabel.h>
@@ -34,52 +33,27 @@
 
 #include "boot2.h"
 #include "lib.h"
+#include "paths.h"
+#include "rbx.h"
 
+/* Define to 0 to omit serial support */
+#ifndef SERIAL
+#define SERIAL 1
+#endif
+
 #define IO_KEYBOARD	1
 #define IO_SERIAL	2
 
+#if SERIAL
+#define DO_KBD (ioctrl & IO_KEYBOARD)
+#define DO_SIO (ioctrl & IO_SERIAL)
+#else
+#define DO_KBD (1)
+#define DO_SIO (0)
+#endif
+
 #define SECOND		18	/* Circa that many ticks in a second. */
 
-#define RBX_ASKNAME	0x0	/* -a */
-#define RBX_SINGLE	0x1	/* -s */
-/* 0x2 is reserved for log2(RB_NOSYNC). */
-/* 0x3 is reserved for log2(RB_HALT). */
-/* 0x4 is reserved for log2(RB_INITNAME). */
-#define RBX_DFLTROOT	0x5	/* -r */
-#define RBX_KDB 	0x6	/* -d */
-/* 0x7 is reserved for log2(RB_RDONLY). */
-/* 0x8 is reserved for log2(RB_DUMP). */
-/* 0x9 is reserved for log2(RB_MINIROOT). */
-#define RBX_CONFIG	0xa	/* -c */
-#define RBX_VERBOSE	0xb	/* -v */
-#define RBX_SERIAL	0xc	/* -h */
-#define RBX_CDROM	0xd	/* -C */
-/* 0xe is reserved for log2(RB_POWEROFF). */
-#define RBX_GDB 	0xf	/* -g */
-#define RBX_MUTE	0x10	/* -m */
-/* 0x11 is reserved for log2(RB_SELFTEST). */
-/* 0x12 is reserved for boot programs. */
-/* 0x13 is reserved for boot programs. */
-#define RBX_PAUSE	0x14	/* -p */
-#define RBX_QUIET	0x15	/* -q */
-#define RBX_NOINTR	0x1c	/* -n */
-/* 0x1d is reserved for log2(RB_MULTIPLE) and is just misnamed here. */
-#define RBX_DUAL	0x1d	/* -D */
-/* 0x1f is reserved for log2(RB_BOOTINFO). */
-
-/* pass: -a, -s, -r, -d, -c, -v, -h, -C, -g, -m, -p, -D */
-#define RBX_MASK	(OPT_SET(RBX_ASKNAME) | OPT_SET(RBX_SINGLE) | \
-			OPT_SET(RBX_DFLTROOT) | OPT_SET(RBX_KDB ) | \
-			OPT_SET(RBX_CONFIG) | OPT_SET(RBX_VERBOSE) | \
-			OPT_SET(RBX_SERIAL) | OPT_SET(RBX_CDROM) | \
-			OPT_SET(RBX_GDB ) | OPT_SET(RBX_MUTE) | \
-			OPT_SET(RBX_PAUSE) | OPT_SET(RBX_DUAL))
-
-#define PATH_DOTCONFIG	"/boot.config"
-#define PATH_CONFIG	"/boot/config"
-#define PATH_BOOT3	"/boot/loader"
-#define PATH_KERNEL	"/boot/kernel/kernel"
-
 #define ARGS		0x900
 #define NOPT		14
 #define NDEV		3
@@ -94,9 +68,6 @@
 #define TYPE_MAXHARD	TYPE_DA
 #define TYPE_FD		2
 
-#define OPT_SET(opt)	(1 << (opt))
-#define OPT_CHECK(opt)	((opts) & OPT_SET(opt))
-
 extern uint32_t _end;
 
 static const char optstr[NOPT] = "DhaCcdgmnpqrsv"; /* Also 'P', 'S' */
@@ -131,15 +102,16 @@
 } dsk;
 static char cmd[512], cmddup[512], knamebuf[1024];
 static const char *kname;
-static uint32_t opts;
+uint32_t opts;
+static struct bootinfo bootinfo;
+#if SERIAL
 static int comspeed = SIOSPD;
-static struct bootinfo bootinfo;
 static uint8_t ioctrl = IO_KEYBOARD;
+#endif
 
 void exit(int);
 static void load(void);
 static int parse(void);
-static int xfsread(ino_t, void *, size_t);
 static int dskread(void *, unsigned, unsigned);
 static void printf(const char *,...);
 static void putchar(int);
@@ -171,7 +143,7 @@
 #include "ufsread.c"
 
 static inline int
-xfsread(ino_t inode, void *buf, size_t nbyte)
+xfsread(ufs_ino_t inode, void *buf, size_t nbyte)
 {
     if ((size_t)fsread(inode, buf, nbyte) != nbyte) {
 	printf("Invalid %s\n", "format");
@@ -223,7 +195,7 @@
 main(void)
 {
     uint8_t autoboot;
-    ino_t ino;
+    ufs_ino_t ino;
     size_t nbyte;
 
     dmadat = (void *)(roundup2(__base + (int32_t)&_end, 0x10000) - __base);
@@ -262,7 +234,7 @@
      */
 
     if (!kname) {
-	kname = PATH_BOOT3;
+	kname = PATH_LOADER;
 	if (autoboot && !keyhit(3*SECOND)) {
 	    load();
 	    kname = PATH_KERNEL;
@@ -278,7 +250,7 @@
 		   "boot: ",
 		   dsk.drive & DRV_MASK, dev_nm[dsk.type], dsk.unit,
 		   'a' + dsk.part, kname);
-	if (ioctrl & IO_SERIAL)
+	if (DO_SIO)
 	    sio_flush();
 	if (!autoboot || keyhit(3*SECOND))
 	    getstr();
@@ -308,7 +280,7 @@
     static Elf32_Phdr ep[2];
     static Elf32_Shdr es[2];
     caddr_t p;
-    ino_t ino;
+    ufs_ino_t ino;
     uint32_t addr;
     int i, j;
 
@@ -400,6 +372,7 @@
 		    }
 		    printf("Keyboard: %s\n", cp);
 		    continue;
+#if SERIAL
 		} else if (c == 'S') {
 		    j = 0;
 		    while ((unsigned int)(i = *arg++ - '0') <= 9)
@@ -409,6 +382,7 @@
 			break;
 		    }
 		    /* Fall through to error below ('S' not in optstr[]). */
+#endif
 		}
 		for (i = 0; c != optstr[i]; i++)
 		    if (i == NOPT - 1)
@@ -415,12 +389,14 @@
 			return -1;
 		opts ^= OPT_SET(flags[i]);
 	    }
+#if SERIAL
 	    ioctrl = OPT_CHECK(RBX_DUAL) ? (IO_SERIAL|IO_KEYBOARD) :
 		     OPT_CHECK(RBX_SERIAL) ? IO_SERIAL : IO_KEYBOARD;
-	    if (ioctrl & IO_SERIAL) {
+	    if (DO_SIO) {
 	        if (sio_init(115200 / comspeed) != 0)
 		    ioctrl &= ~IO_SERIAL;
 	    }
+#endif
 	} else {
 	    for (q = arg--; *q && *q != '('; q++);
 	    if (*q) {
@@ -628,9 +604,9 @@
 static int
 xputc(int c)
 {
-    if (ioctrl & IO_KEYBOARD)
+    if (DO_KBD)
 	putc(c);
-    if (ioctrl & IO_SERIAL)
+    if (DO_SIO)
 	sio_putc(c);
     return c;
 }
@@ -650,9 +626,9 @@
     if (OPT_CHECK(RBX_NOINTR))
 	return 0;
     for (;;) {
-	if (ioctrl & IO_KEYBOARD && getc(1))
+	if (DO_KBD && getc(1))
 	    return fn ? 1 : getc(0);
-	if (ioctrl & IO_SERIAL && sio_ischar())
+	if (DO_SIO && sio_ischar())
 	    return fn ? 1 : sio_getc();
 	if (fn)
 	    return 0;

Modified: trunk/sys/boot/i386/boot2/lib.h
===================================================================
--- trunk/sys/boot/i386/boot2/lib.h	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/boot2/lib.h	2018-06-01 23:44:37 UTC (rev 10194)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 1998 Robert Nordier
  * All rights reserved.
@@ -14,7 +15,7 @@
  */
 
 /*
- * $FreeBSD$
+ * $FreeBSD: stable/10/sys/boot/i386/boot2/lib.h 241301 2012-10-06 20:08:29Z avg $
  */
 
 int sio_init(int) __attribute__((regparm (3)));

Modified: trunk/sys/boot/i386/boot2/sio.S
===================================================================
--- trunk/sys/boot/i386/boot2/sio.S	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/boot2/sio.S	2018-06-01 23:44:37 UTC (rev 10194)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 1998 Robert Nordier
  * All rights reserved.
@@ -12,7 +13,7 @@
  * warranties of merchantability and fitness for a particular
  * purpose.
  *
- * $FreeBSD$
+ * $FreeBSD: stable/10/sys/boot/i386/boot2/sio.S 242804 2012-11-08 23:21:02Z dim $
  */
 
 		.set SIO_PRT,SIOPRT		# Base port


Property changes on: trunk/sys/boot/i386/boot2/sio.S
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/sys/boot/i386/btx/Makefile
===================================================================
--- trunk/sys/boot/i386/btx/Makefile	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/btx/Makefile	2018-06-01 23:44:37 UTC (rev 10194)
@@ -1,4 +1,5 @@
 # $MidnightBSD$
+# $FreeBSD: stable/10/sys/boot/i386/btx/Makefile 50477 1999-08-28 01:08:13Z peter $
 
 SUBDIR=	btx btxldr lib
 

Modified: trunk/sys/boot/i386/btx/Makefile.inc
===================================================================
--- trunk/sys/boot/i386/btx/Makefile.inc	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/btx/Makefile.inc	2018-06-01 23:44:37 UTC (rev 10194)
@@ -1,3 +1,4 @@
 # $MidnightBSD$
+# $FreeBSD: stable/10/sys/boot/i386/btx/Makefile.inc 125537 2004-02-06 21:58:32Z ru $
 
 .include "../Makefile.inc"


Property changes on: trunk/sys/boot/i386/btx/Makefile.inc
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/sys/boot/i386/btx/btx/Makefile
===================================================================
--- trunk/sys/boot/i386/btx/btx/Makefile	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/btx/btx/Makefile	2018-06-01 23:44:37 UTC (rev 10194)
@@ -1,9 +1,9 @@
-# $MidnightBSD: src/sys/boot/i386/btx/btx/Makefile,v 1.2 2011/10/16 21:11:08 laffer1 Exp $
-# $FreeBSD: src/sys/boot/i386/btx/btx/Makefile,v 1.19.10.1.2.1 2008/11/25 02:59:29 kensmith Exp $
+# $MidnightBSD$
+# $FreeBSD: stable/10/sys/boot/i386/btx/btx/Makefile 276486 2014-12-31 23:25:37Z ngie $
 
 PROG=	btx
 INTERNALPROG=
-NO_MAN=
+MAN=
 SRCS=	btx.S
 
 .if defined(BOOT_BTX_NOHANG)

Modified: trunk/sys/boot/i386/btx/btx/btx.S
===================================================================
--- trunk/sys/boot/i386/btx/btx/btx.S	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/btx/btx/btx.S	2018-06-01 23:44:37 UTC (rev 10194)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 1998 Robert Nordier
  * All rights reserved.
@@ -12,7 +13,7 @@
  * warranties of merchantability and fitness for a particular
  * purpose.
  *
- * $FreeBSD: stable/9/sys/boot/i386/btx/btx/btx.S 258171 2013-11-15 15:08:53Z jhb $
+ * $FreeBSD: stable/10/sys/boot/i386/btx/btx/btx.S 256562 2013-10-15 21:08:37Z jhb $
  */
 
 #include <bootargs.h>

Modified: trunk/sys/boot/i386/btx/btxldr/Makefile
===================================================================
--- trunk/sys/boot/i386/btx/btxldr/Makefile	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/btx/btxldr/Makefile	2018-06-01 23:44:37 UTC (rev 10194)
@@ -1,9 +1,9 @@
-# $MidnightBSD: src/sys/boot/i386/btx/btxldr/Makefile,v 1.2 2011/10/16 21:11:08 laffer1 Exp $
-# $FreeBSD: src/sys/boot/i386/btx/btxldr/Makefile,v 1.18 2004/12/21 08:47:13 ru Exp $
+# $MidnightBSD$
+# $FreeBSD: stable/10/sys/boot/i386/btx/btxldr/Makefile 276486 2014-12-31 23:25:37Z ngie $
 
 PROG=	btxldr
 INTERNALPROG=
-NO_MAN=
+MAN=
 SRCS=	btxldr.S
 
 CFLAGS+=-DLOADER_ADDRESS=${LOADER_ADDRESS}

Modified: trunk/sys/boot/i386/btx/btxldr/btxldr.S
===================================================================
--- trunk/sys/boot/i386/btx/btxldr/btxldr.S	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/btx/btxldr/btxldr.S	2018-06-01 23:44:37 UTC (rev 10194)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 1998 Robert Nordier
  * All rights reserved.
@@ -12,8 +13,7 @@
  * warranties of merchantability and fitness for a particular
  * purpose.
  *
- * $MidnightBSD: src/sys/boot/i386/btx/btxldr/btxldr.S,v 1.2 2011/10/16 21:11:08 laffer1 Exp $
- * $FreeBSD: src/sys/boot/i386/btx/btxldr/btxldr.S,v 1.17 2004/05/14 20:29:30 ru Exp $
+ * $FreeBSD: stable/10/sys/boot/i386/btx/btxldr/btxldr.S 235154 2012-05-09 08:04:29Z avg $
  */
 
 #include <bootargs.h>


Property changes on: trunk/sys/boot/i386/btx/btxldr/btxldr.S
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/sys/boot/i386/btx/lib/Makefile
===================================================================
--- trunk/sys/boot/i386/btx/lib/Makefile	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/btx/lib/Makefile	2018-06-01 23:44:37 UTC (rev 10194)
@@ -1,9 +1,9 @@
-# $MidnightBSD: src/sys/boot/i386/btx/lib/Makefile,v 1.2 2011/10/16 21:11:08 laffer1 Exp $
-# $FreeBSD: src/sys/boot/i386/btx/lib/Makefile,v 1.13.18.1 2008/11/25 02:59:29 kensmith Exp $
+# $MidnightBSD$
+# $FreeBSD: stable/10/sys/boot/i386/btx/lib/Makefile 276486 2014-12-31 23:25:37Z ngie $
 
 PROG=	crt0.o
 INTERNALPROG=
-NO_MAN=
+MAN=
 SRCS=	btxcsu.S btxsys.s btxv86.s
 CFLAGS+=-I${.CURDIR}/../../common
 LDFLAGS=-Wl,-r

Modified: trunk/sys/boot/i386/btx/lib/btxcsu.S
===================================================================
--- trunk/sys/boot/i386/btx/lib/btxcsu.S	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/btx/lib/btxcsu.S	2018-06-01 23:44:37 UTC (rev 10194)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 #
 # Copyright (c) 1998 Robert Nordier
 # All rights reserved.
@@ -13,7 +14,7 @@
 # purpose.
 #
 
-# $MidnightBSD$
+# $FreeBSD: stable/10/sys/boot/i386/btx/lib/btxcsu.S 235154 2012-05-09 08:04:29Z avg $
 
 #include <bootargs.h>
 


Property changes on: trunk/sys/boot/i386/btx/lib/btxcsu.S
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/sys/boot/i386/btx/lib/btxsys.s
===================================================================
--- trunk/sys/boot/i386/btx/lib/btxsys.s	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/btx/lib/btxsys.s	2018-06-01 23:44:37 UTC (rev 10194)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 #
 # Copyright (c) 1998 Robert Nordier
 # All rights reserved.
@@ -13,8 +14,7 @@
 # purpose.
 #
 
-# $MidnightBSD$
-# $FreeBSD: src/sys/boot/i386/btx/lib/btxsys.s,v 1.2.52.1 2008/11/25 02:59:29 kensmith Exp $
+# $FreeBSD: stable/10/sys/boot/i386/btx/lib/btxsys.s 50477 1999-08-28 01:08:13Z peter $
 
 #
 # BTX system calls.


Property changes on: trunk/sys/boot/i386/btx/lib/btxsys.s
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/sys/boot/i386/btx/lib/btxv86.h
===================================================================
--- trunk/sys/boot/i386/btx/lib/btxv86.h	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/btx/lib/btxv86.h	2018-06-01 23:44:37 UTC (rev 10194)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 1998 Robert Nordier
  * All rights reserved.
@@ -13,8 +14,8 @@
  * purpose.
  */
 
-/* $MidnightBSD: src/sys/boot/i386/btx/lib/btxv86.h,v 1.2 2011/10/16 21:11:08 laffer1 Exp $
- * $FreeBSD: src/sys/boot/i386/btx/lib/btxv86.h,v 1.5.52.1 2008/11/25 02:59:29 kensmith Exp $
+/*
+ * $FreeBSD: stable/10/sys/boot/i386/btx/lib/btxv86.h 226746 2011-10-25 19:45:12Z jhb $
  */
 
 #ifndef _BTXV86_H_

Modified: trunk/sys/boot/i386/btx/lib/btxv86.s
===================================================================
--- trunk/sys/boot/i386/btx/lib/btxv86.s	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/btx/lib/btxv86.s	2018-06-01 23:44:37 UTC (rev 10194)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 #
 # Copyright (c) 1998 Robert Nordier
 # All rights reserved.
@@ -13,8 +14,7 @@
 # purpose.
 #
 
-# $MidnightBSD$
-# $FreeBSD: src/sys/boot/i386/btx/lib/btxv86.s,v 1.3.52.1 2008/11/25 02:59:29 kensmith Exp $
+# $FreeBSD: stable/10/sys/boot/i386/btx/lib/btxv86.s 50477 1999-08-28 01:08:13Z peter $
 
 #
 # BTX V86 interface.


Property changes on: trunk/sys/boot/i386/btx/lib/btxv86.s
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/sys/boot/i386/cdboot/Makefile
===================================================================
--- trunk/sys/boot/i386/cdboot/Makefile	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/cdboot/Makefile	2018-06-01 23:44:37 UTC (rev 10194)
@@ -1,9 +1,10 @@
-# $FreeBSD$
+# $MidnightBSD$
+# $FreeBSD: stable/10/sys/boot/i386/cdboot/Makefile 276486 2014-12-31 23:25:37Z ngie $
 
 PROG=	cdboot
 STRIP=
 BINMODE=${NOBINMODE}
-NO_MAN=
+MAN=
 SRCS=	${PROG}.S
 
 CFLAGS+=-I${.CURDIR}/../common

Modified: trunk/sys/boot/i386/cdboot/cdboot.S
===================================================================
--- trunk/sys/boot/i386/cdboot/cdboot.S	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/cdboot/cdboot.S	2018-06-01 23:44:37 UTC (rev 10194)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 #
 # Copyright (c) 2001 John Baldwin <jhb at FreeBSD.org>
 # All rights reserved.
@@ -10,9 +11,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. Neither the name of the author nor the names of any co-contributors
-#    may be used to endorse or promote products derived from this software
-#    without specific prior written permission.
 #
 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
@@ -27,7 +25,7 @@
 # SUCH DAMAGE.
 #
 
-# $FreeBSD$
+# $FreeBSD: stable/10/sys/boot/i386/cdboot/cdboot.S 262192 2014-02-18 20:27:17Z jhb $
 
 #
 # This program is a freestanding boot program to load an a.out binary


Property changes on: trunk/sys/boot/i386/cdboot/cdboot.S
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/sys/boot/i386/common/bootargs.h
===================================================================
--- trunk/sys/boot/i386/common/bootargs.h	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/common/bootargs.h	2018-06-01 23:44:37 UTC (rev 10194)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2012 Andriy Gapon <avg at FreeBSD.org>
  * All rights reserved.
@@ -12,7 +13,7 @@
  * warranties of merchantability and fitness for a particular
  * purpose.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/boot/i386/common/bootargs.h 235154 2012-05-09 08:04:29Z avg $
  */
 
 #ifndef _BOOT_I386_ARGS_H_

Modified: trunk/sys/boot/i386/common/cons.c
===================================================================
--- trunk/sys/boot/i386/common/cons.c	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/common/cons.c	2018-06-01 23:44:37 UTC (rev 10194)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1998 Robert Nordier
  * All rights reserved.
@@ -14,7 +15,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/boot/i386/common/cons.c 226746 2011-10-25 19:45:12Z jhb $");
 
 #include <sys/param.h>
 

Modified: trunk/sys/boot/i386/common/cons.h
===================================================================
--- trunk/sys/boot/i386/common/cons.h	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/common/cons.h	2018-06-01 23:44:37 UTC (rev 10194)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1998 Robert Nordier
  * All rights reserved.
@@ -12,8 +13,7 @@
  * warranties of merchantability and fitness for a particular
  * purpose.
  *
- * $MidnightBSD$
- * $FreeBSD: stable/9/sys/boot/i386/common/cons.h 300462 2016-05-23 05:25:34Z ngie $
+ * $FreeBSD: stable/10/sys/boot/i386/common/cons.h 300460 2016-05-23 05:23:53Z ngie $
  */
 
 #ifndef _CONS_H_

Modified: trunk/sys/boot/i386/common/drv.c
===================================================================
--- trunk/sys/boot/i386/common/drv.c	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/common/drv.c	2018-06-01 23:44:37 UTC (rev 10194)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1998 Robert Nordier
  * Copyright (c) 2010 Pawel Jakub Dawidek <pjd at FreeBSD.org>
@@ -15,7 +16,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/boot/i386/common/drv.c 308915 2016-11-21 10:14:36Z avg $");
 
 #include <sys/param.h>
 
@@ -93,7 +94,7 @@
 	return (0);
 }
 
-#ifdef GPT
+#if defined(GPT) || defined(ZFS)
 int
 drvwrite(struct dsk *dskp, void *buf, daddr_t lba, unsigned nblk)
 {
@@ -116,4 +117,4 @@
 	}
 	return (0);
 }
-#endif	/* GPT */
+#endif	/* GPT || ZFS */

Modified: trunk/sys/boot/i386/common/drv.h
===================================================================
--- trunk/sys/boot/i386/common/drv.h	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/common/drv.h	2018-06-01 23:44:37 UTC (rev 10194)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2010 Pawel Jakub Dawidek <pjd at FreeBSD.org>
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/boot/i386/common/drv.h 308915 2016-11-21 10:14:36Z avg $
  */
 
 #ifndef _DRV_H_
@@ -40,9 +41,9 @@
 };
 
 int drvread(struct dsk *dskp, void *buf, daddr_t lba, unsigned nblk);
-#ifdef GPT
+#if defined(GPT) || defined(ZFS)
 int drvwrite(struct dsk *dskp, void *buf, daddr_t lba, unsigned nblk);
 uint64_t drvsize(struct dsk *dskp);
-#endif	/* GPT */
+#endif	/* GPT || ZFS */
 
 #endif	/* !_DRV_H_ */

Modified: trunk/sys/boot/i386/common/edd.h
===================================================================
--- trunk/sys/boot/i386/common/edd.h	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/common/edd.h	2018-06-01 23:44:37 UTC (rev 10194)
@@ -1,5 +1,6 @@
+/* $MidnightBSD$ */
 /*-
- * Copyright (c) 2011 Advanced Computing Technologies LLC
+ * Copyright (c) 2011 Hudson River Trading LLC
  * Written by: John H. Baldwin <jhb at FreeBSD.org>
  * All rights reserved.
  *
@@ -24,7 +25,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/boot/i386/common/edd.h 283927 2015-06-02 19:20:39Z jhb $
  */
 
 #ifndef	_EDD_H_

Index: trunk/sys/boot/i386/efi/start.S
===================================================================
--- trunk/sys/boot/i386/efi/start.S	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/efi/start.S	2018-06-01 23:44:37 UTC (rev 10194)

Property changes on: trunk/sys/boot/i386/efi/start.S
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/sys/boot/i386/gptboot/Makefile
===================================================================
--- trunk/sys/boot/i386/gptboot/Makefile	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/gptboot/Makefile	2018-06-01 23:44:37 UTC (rev 10194)
@@ -1,5 +1,5 @@
 # $MidnightBSD$
-# $FreeBSD: stable/9/sys/boot/i386/gptboot/Makefile 260497 2014-01-09 23:08:56Z dim $
+# $FreeBSD: stable/10/sys/boot/i386/gptboot/Makefile 281289 2015-04-09 06:38:32Z dim $
 
 .PATH:		${.CURDIR}/../boot2 ${.CURDIR}/../common ${.CURDIR}/../../common
 
@@ -42,6 +42,8 @@
 
 LD_FLAGS=-static -N --gc-sections
 
+LIBSTAND=	${.OBJDIR}/../../libstand32/libstand.a
+
 # Pick up ../Makefile.inc early.
 .include <bsd.init.mk>
 
@@ -54,7 +56,7 @@
 CLEANFILES+=	gptldr.bin gptldr.out gptldr.o
 
 gptldr.bin: gptldr.out
-	objcopy -S -O binary gptldr.out ${.TARGET}
+	${OBJCOPY} -S -O binary gptldr.out ${.TARGET}
 
 gptldr.out: gptldr.o
 	${LD} ${LD_FLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} gptldr.o
@@ -63,7 +65,7 @@
 		cons.o util.o
 
 gptboot.bin: gptboot.out
-	objcopy -S -O binary gptboot.out ${.TARGET}
+	${OBJCOPY} -S -O binary gptboot.out ${.TARGET}
 
 gptboot.out: ${BTXCRT} gptboot.o sio.o gpt.o crc32.o drv.o cons.o util.o
 	${LD} ${LD_FLAGS} -Ttext ${ORG2} -o ${.TARGET} ${.ALLSRC} ${LIBSTAND}

Modified: trunk/sys/boot/i386/gptboot/gptboot.8
===================================================================
--- trunk/sys/boot/i386/gptboot/gptboot.8	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/gptboot/gptboot.8	2018-06-01 23:44:37 UTC (rev 10194)
@@ -23,7 +23,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\" $FreeBSD: stable/9/sys/boot/i386/gptboot/gptboot.8 261721 2014-02-10 17:41:40Z wblock $
+.\" $FreeBSD: stable/10/sys/boot/i386/gptboot/gptboot.8 261720 2014-02-10 17:37:34Z wblock $
 .\"
 .Dd February 5, 2014
 .Dt GPTBOOT 8

Modified: trunk/sys/boot/i386/gptboot/gptboot.c
===================================================================
--- trunk/sys/boot/i386/gptboot/gptboot.c	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/gptboot/gptboot.c	2018-06-01 23:44:37 UTC (rev 10194)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1998 Robert Nordier
  * All rights reserved.
@@ -14,7 +15,6 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
 
 #include <sys/param.h>
 #include <sys/gpt.h>
@@ -37,12 +37,8 @@
 #include "util.h"
 #include "cons.h"
 #include "gpt.h"
+#include "paths.h"
 
-#define PATH_DOTCONFIG  "/boot.config"
-#define PATH_CONFIG	"/boot/config"
-#define PATH_BOOT3	"/boot/loader"
-#define PATH_KERNEL	"/boot/kernel/kernel"
-
 #define ARGS		0x900
 #define NOPT		14
 #define NDEV		3
@@ -90,7 +86,6 @@
 void exit(int);
 static void load(void);
 static int parse(char *, int *);
-static int xfsread(ino_t, void *, size_t);
 static int dskread(void *, daddr_t, unsigned);
 static uint32_t memsize(void);
 
@@ -97,7 +92,7 @@
 #include "ufsread.c"
 
 static inline int
-xfsread(ino_t inode, void *buf, size_t nbyte)
+xfsread(ufs_ino_t inode, void *buf, size_t nbyte)
 {
 
 	if ((size_t)fsread(inode, buf, nbyte) != nbyte) {
@@ -137,8 +132,9 @@
 main(void)
 {
 	char cmd[512], cmdtmp[512];
+	ssize_t sz;
 	int autoboot, dskupdated;
-	ino_t ino;
+	ufs_ino_t ino;
 
 	dmadat = (void *)(roundup2(__base + (int32_t)&_end, 0x10000) - __base);
 	v86.ctl = V86_FLAGS;
@@ -165,9 +161,10 @@
 	for (;;) {
 		*kname = '\0';
 		if ((ino = lookup(PATH_CONFIG)) ||
-		    (ino = lookup(PATH_DOTCONFIG)))
-			fsread(ino, cmd, sizeof(cmd));
-
+		    (ino = lookup(PATH_DOTCONFIG))) {
+			sz = fsread(ino, cmd, sizeof(cmd) - 1);
+			cmd[(sz < 0) ? 0 : sz] = '\0';
+		}
 		if (*cmd != '\0') {
 			memcpy(cmdtmp, cmd, sizeof(cmdtmp));
 			if (parse(cmdtmp, &dskupdated))
@@ -181,7 +178,7 @@
 
 		if (autoboot && keyhit(3)) {
 			if (*kname == '\0')
-				memcpy(kname, PATH_BOOT3, sizeof(PATH_BOOT3));
+				memcpy(kname, PATH_LOADER, sizeof(PATH_LOADER));
 			break;
 		}
 		autoboot = 0;
@@ -193,7 +190,7 @@
 		 */
 		if (*kname != '\0')
 			load();
-		memcpy(kname, PATH_BOOT3, sizeof(PATH_BOOT3));
+		memcpy(kname, PATH_LOADER, sizeof(PATH_LOADER));
 		load();
 		memcpy(kname, PATH_KERNEL, sizeof(PATH_KERNEL));
 		load();
@@ -207,7 +204,7 @@
 
 	for (;;) {
 		if (!OPT_CHECK(RBX_QUIET)) {
-			printf("\nMidnightBSD/x86 boot\n"
+			printf("\nFreeBSD/x86 boot\n"
 			    "Default: %u:%s(%up%u)%s\n"
 			    "boot: ",
 			    dsk.drive & DRV_MASK, dev_nm[dsk.type], dsk.unit,
@@ -247,7 +244,7 @@
     static Elf32_Phdr ep[2];
     static Elf32_Shdr es[2];
     caddr_t p;
-    ino_t ino;
+    ufs_ino_t ino;
     uint32_t addr, x;
     int fmt, i, j;
 

Modified: trunk/sys/boot/i386/gptboot/gptldr.S
===================================================================
--- trunk/sys/boot/i386/gptboot/gptldr.S	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/gptboot/gptldr.S	2018-06-01 23:44:37 UTC (rev 10194)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2007 Yahoo!, Inc.
  * All rights reserved.
@@ -27,8 +28,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $MidnightBSD$
- * $FreeBSD: src/sys/boot/i386/gptboot/gptldr.S,v 1.2.2.1.2.1 2008/11/25 02:59:29 kensmith Exp $
+ * $FreeBSD: stable/10/sys/boot/i386/gptboot/gptldr.S 289358 2015-10-15 03:48:03Z cperciva $
  *
  * Partly from: src/sys/boot/i386/boot2/boot1.S 1.31
  */
@@ -46,6 +46,10 @@
 /* Misc. Constants */
 		.set SIZ_PAG,0x1000		# Page size
 		.set SIZ_SEC,0x200		# Sector size
+		.set COPY_BLKS,0x4		# Number of blocks
+						# to copy for boot2
+		.set COPY_BLK_SZ,0x8000		# Copy in 32k blocks; must be
+						# a multiple of 16 bytes
 
 		.globl start
 		.code16
@@ -69,26 +73,39 @@
  * its header to find boot2.  We need to copy boot2 to MEM_USR and BTX
  * to MEM_BTX.  Since those might overlap, we have to copy boot2
  * backwards first and then copy BTX.  We aren't sure exactly how long
- * boot2 is, but we assume it can't be longer than 64k, so we just always
- * copy 64k.
+ * boot2 is, but it's currently under 128kB so we'll copy 4 blocks of 32kB
+ * each; this can be adjusted via COPY_BLK and COPY_BLK_SZ above.
  */
 		mov $end,%bx			# BTX
 		mov 0xa(%bx),%si		# Get BTX length and set
 		add %bx,%si			#  %si to start of boot2
-		mov %si,%ax			# Align %ds:%si on a
-		shr $4,%ax			#  paragraph boundary
-		and $0xf,%si			#  with the smallest
-		mov %ax,%ds			#  possible %si
-		add $(64 * 1024 - 16),%si
-		mov $MEM_USR/16,%ax		# Point %es:%di at end of
-		mov $(64 * 1024 - 16),%di	#  largest boot2 range
+		dec %si				# Set %ds:%si to point at the
+		mov %si,%ax			# last byte we want to copy
+		shr $4,%ax			# from boot2, with %si made as
+		add $(COPY_BLKS*COPY_BLK_SZ/16),%ax	# small as possible.
+		and $0xf,%si			# 
+		mov %ax,%ds			#
+		mov $MEM_USR/16,%ax		# Set %es:(-1) to point at
+		add $(COPY_BLKS*COPY_BLK_SZ/16),%ax	# the last byte we
+		mov %ax,%es			# want to copy boot2 into.
+		mov $COPY_BLKS,%bx		# Copy COPY_BLKS 32k blocks
+copyloop:
+		add $COPY_BLK_SZ,%si		# Adjust %ds:%si to point at
+		mov %ds,%ax			# the end of the next 32k to
+		sub $COPY_BLK_SZ/16,%ax		# copy from boot2
+		mov %ax,%ds
+		mov $COPY_BLK_SZ-1,%di		# Adjust %es:%di to point at
+		mov %es,%ax			# the end of the next 32k into
+		sub $COPY_BLK_SZ/16,%ax		# which we want boot2 copied
 		mov %ax,%es
+		mov $COPY_BLK_SZ,%cx		# Copy 32k
 		std
-		mov %di,%cx			# Copy 64k - paragraph + 1 
-		inc %cx				#  bytes
 		rep movsb
+		dec %bx
+		jnz copyloop
 		mov %cx,%ds			# Reset %ds and %es
 		mov %cx,%es
+		mov $end,%bx			# BTX
 		mov 0xa(%bx),%cx		# Get BTX length and set
 		mov %bx,%si			#  %si to end of BTX
 		mov $MEM_BTX,%di		# %di -> end of BTX at


Property changes on: trunk/sys/boot/i386/gptboot/gptldr.S
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/sys/boot/i386/gptzfsboot/Makefile
===================================================================
--- trunk/sys/boot/i386/gptzfsboot/Makefile	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/gptzfsboot/Makefile	2018-06-01 23:44:37 UTC (rev 10194)
@@ -1,5 +1,5 @@
 # $MidnightBSD$
-# $FreeBSD: stable/9/sys/boot/i386/gptzfsboot/Makefile 272697 2014-10-07 13:37:10Z avg $
+# $FreeBSD: stable/10/sys/boot/i386/gptzfsboot/Makefile 308915 2016-11-21 10:14:36Z avg $
 
 .PATH:		${.CURDIR}/../boot2 ${.CURDIR}/../gptboot \
 		${.CURDIR}/../zfsboot ${.CURDIR}/../common \
@@ -20,7 +20,7 @@
 
 CFLAGS=	-DBOOTPROG=\"gptzfsboot\" \
 	-O1 \
-	-DGPT -DBOOT2 \
+	-DGPT -DZFS -DBOOT2 \
 	-DSIOPRT=${BOOT_COMCONSOLE_PORT} \
 	-DSIOFMT=${B2SIOFMT} \
 	-DSIOSPD=${BOOT_COMCONSOLE_SPEED} \
@@ -40,6 +40,8 @@
 
 LD_FLAGS=-static -N --gc-sections
 
+LIBSTAND=	${.OBJDIR}/../../libstand32/libstand.a
+
 # Pick up ../Makefile.inc early.
 .include <bsd.init.mk>
 
@@ -52,7 +54,7 @@
 CLEANFILES+=	gptldr.bin gptldr.out gptldr.o
 
 gptldr.bin: gptldr.out
-	objcopy -S -O binary gptldr.out ${.TARGET}
+	${OBJCOPY} -S -O binary gptldr.out ${.TARGET}
 
 gptldr.out: gptldr.o
 	${LD} ${LD_FLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} gptldr.o
@@ -61,7 +63,7 @@
 		drv.o gpt.o util.o
 
 gptzfsboot.bin: gptzfsboot.out
-	objcopy -S -O binary gptzfsboot.out ${.TARGET}
+	${OBJCOPY} -S -O binary gptzfsboot.out ${.TARGET}
 
 gptzfsboot.out: ${BTXCRT} zfsboot.o sio.o gpt.o drv.o cons.o util.o
 	${LD} ${LD_FLAGS} -Ttext ${ORG2} -o ${.TARGET} ${.ALLSRC} ${LIBSTAND}

Modified: trunk/sys/boot/i386/gptzfsboot/gptzfsboot.8
===================================================================
--- trunk/sys/boot/i386/gptzfsboot/gptzfsboot.8	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/gptzfsboot/gptzfsboot.8	2018-06-01 23:44:37 UTC (rev 10194)
@@ -23,7 +23,7 @@
 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 .\" SUCH DAMAGE.
 .\"
-.\" $FreeBSD: stable/9/sys/boot/i386/gptzfsboot/gptzfsboot.8 272697 2014-10-07 13:37:10Z avg $
+.\" $FreeBSD: stable/10/sys/boot/i386/gptzfsboot/gptzfsboot.8 306378 2016-09-27 19:00:22Z pluknet $
 .\"
 .Dd September 15, 2014
 .Dt GPTZFSBOOT 8
@@ -177,6 +177,9 @@
 .Sh HISTORY
 .Nm
 appeared in FreeBSD 7.3.
+.Sh AUTHORS
+This manual page was written by
+.An Andriy Gapon Aq avg at FreeBSD.org .
 .Sh BUGS
 .Nm
 looks for ZFS meta-data only in MBR partitions
@@ -189,6 +192,3 @@
 .Nm
 will recognize the partition as a part of a ZFS pool,
 but this is not guaranteed to happen.
-.Sh AUTHORS
-This manual page was written by
-.An Andriy Gapon Aq avg at FreeBSD.org .

Modified: trunk/sys/boot/i386/kgzldr/Makefile
===================================================================
--- trunk/sys/boot/i386/kgzldr/Makefile	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/kgzldr/Makefile	2018-06-01 23:44:37 UTC (rev 10194)
@@ -1,10 +1,11 @@
 # $MidnightBSD$
+# $FreeBSD: stable/10/sys/boot/i386/kgzldr/Makefile 276486 2014-12-31 23:25:37Z ngie $
 
 PROG=	kgzldr.o
 STRIP=
 BINMODE=${LIBMODE}
 BINDIR=	${LIBDIR}
-NO_MAN=
+MAN=
 
 SRCS=	start.s boot.c inflate.c lib.c crt.s sio.s
 CFLAGS=	-Os

Modified: trunk/sys/boot/i386/kgzldr/boot.c
===================================================================
--- trunk/sys/boot/i386/kgzldr/boot.c	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/kgzldr/boot.c	2018-06-01 23:44:37 UTC (rev 10194)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1999 Global Technology Associates, Inc.
  * All rights reserved.
@@ -25,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/boot/i386/kgzldr/boot.c 119482 2003-08-25 23:28:32Z obrien $");
 
 #include <sys/types.h>
 #include <sys/reboot.h>

Modified: trunk/sys/boot/i386/kgzldr/crt.s
===================================================================
--- trunk/sys/boot/i386/kgzldr/crt.s	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/kgzldr/crt.s	2018-06-01 23:44:37 UTC (rev 10194)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 #
 # Copyright (c) 1999 Global Technology Associates, Inc.
 # All rights reserved.
@@ -24,7 +25,7 @@
 # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #
 #	From: btx.s 1.10 1999/02/25 16:27:41 rnordier
-# $MidnightBSD$
+# $FreeBSD: stable/10/sys/boot/i386/kgzldr/crt.s 103436 2002-09-17 01:49:00Z peter $
 #
 
 # Screen defaults and assumptions.

Modified: trunk/sys/boot/i386/kgzldr/kgzldr.h
===================================================================
--- trunk/sys/boot/i386/kgzldr/kgzldr.h	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/kgzldr/kgzldr.h	2018-06-01 23:44:37 UTC (rev 10194)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 1999 Global Technology Associates, Inc.
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
- * $MidnightBSD$
+ * $FreeBSD: stable/10/sys/boot/i386/kgzldr/kgzldr.h 50477 1999-08-28 01:08:13Z peter $
  */
 
 #define KGZ_CRT	 0x1		/* Video console */

Modified: trunk/sys/boot/i386/kgzldr/lib.c
===================================================================
--- trunk/sys/boot/i386/kgzldr/lib.c	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/kgzldr/lib.c	2018-06-01 23:44:37 UTC (rev 10194)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1999 Global Technology Associates, Inc.
  * All rights reserved.
@@ -25,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/boot/i386/kgzldr/lib.c 119482 2003-08-25 23:28:32Z obrien $");
 
 #include <sys/types.h>
 #include <stddef.h>

Modified: trunk/sys/boot/i386/kgzldr/sio.s
===================================================================
--- trunk/sys/boot/i386/kgzldr/sio.s	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/kgzldr/sio.s	2018-06-01 23:44:37 UTC (rev 10194)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 #
 # Copyright (c) 1999 Global Technology Associates, Inc.
 # All rights reserved.
@@ -24,7 +25,7 @@
 # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #
 #	From: sio.s 1.3 1999/01/10 14:48:03 rnordier
-# $MidnightBSD$
+# $FreeBSD: stable/10/sys/boot/i386/kgzldr/sio.s 104234 2002-09-30 20:37:58Z peter $
 #
 
 		.globl sio_putchr

Modified: trunk/sys/boot/i386/kgzldr/start.s
===================================================================
--- trunk/sys/boot/i386/kgzldr/start.s	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/kgzldr/start.s	2018-06-01 23:44:37 UTC (rev 10194)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 #
 # Copyright (c) 1999 Global Technology Associates, Inc.
 # All rights reserved.
@@ -23,7 +24,7 @@
 # OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
 # EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #
-# $MidnightBSD$
+# $FreeBSD: stable/10/sys/boot/i386/kgzldr/start.s 103436 2002-09-17 01:49:00Z peter $
 #
 
 		.set entry,0x10			# kgz.entry

Modified: trunk/sys/boot/i386/libfirewire/Makefile
===================================================================
--- trunk/sys/boot/i386/libfirewire/Makefile	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/libfirewire/Makefile	2018-06-01 23:44:37 UTC (rev 10194)
@@ -1,4 +1,5 @@
-# $FreeBSD$
+# $MidnightBSD$
+# $FreeBSD: stable/10/sys/boot/i386/libfirewire/Makefile 211677 2010-08-23 01:42:09Z imp $
 
 LIB=		firewire
 INTERNALLIB=

Modified: trunk/sys/boot/i386/libfirewire/dconsole.c
===================================================================
--- trunk/sys/boot/i386/libfirewire/dconsole.c	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/libfirewire/dconsole.c	2018-06-01 23:44:37 UTC (rev 10194)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2004 Hidetoshi Shimokawa
  *
@@ -24,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/boot/i386/libfirewire/dconsole.c 170101 2007-05-29 14:35:57Z simokawa $");
 
 #include <stand.h>
 #include <bootstrap.h>

Modified: trunk/sys/boot/i386/libfirewire/fwohci.c
===================================================================
--- trunk/sys/boot/i386/libfirewire/fwohci.c	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/libfirewire/fwohci.c	2018-06-01 23:44:37 UTC (rev 10194)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2003 Hidetoshi Shimokawa
  * Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa
@@ -31,7 +32,7 @@
  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  * 
- * $FreeBSD$
+ * $FreeBSD: stable/10/sys/boot/i386/libfirewire/fwohci.c 170101 2007-05-29 14:35:57Z simokawa $
  *
  */
 

Modified: trunk/sys/boot/i386/libfirewire/fwohci.h
===================================================================
--- trunk/sys/boot/i386/libfirewire/fwohci.h	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/libfirewire/fwohci.h	2018-06-01 23:44:37 UTC (rev 10194)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2007 Hidetoshi Shimokawa
  * All rights reserved.
@@ -30,7 +31,7 @@
  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  * 
- * $FreeBSD$
+ * $FreeBSD: stable/10/sys/boot/i386/libfirewire/fwohci.h 261455 2014-02-04 03:36:42Z eadler $
  *
  */
 
@@ -76,7 +77,7 @@
 #define	OHCI_CROMHDR		0x18
 #define OHCI_BUS_ID		0x1c
 #define	OHCI_BUS_OPT		0x20
-#define	OHCI_BUSIRMC		(1 << 31)
+#define	OHCI_BUSIRMC		(1U << 31)
 #define	OHCI_BUSCMC		(1 << 30)
 #define	OHCI_BUSISC		(1 << 29)
 #define	OHCI_BUSBMC		(1 << 28)
@@ -102,7 +103,7 @@
 
 #define	OHCI_SID_BUF		0x64
 #define	OHCI_SID_CNT		0x68
-#define OHCI_SID_ERR		(1 << 31)
+#define OHCI_SID_ERR		(1U << 31)
 #define OHCI_SID_CNT_MASK	0xffc
 
 #define	OHCI_IT_STAT		0x90

Modified: trunk/sys/boot/i386/libfirewire/fwohcireg.h
===================================================================
--- trunk/sys/boot/i386/libfirewire/fwohcireg.h	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/libfirewire/fwohcireg.h	2018-06-01 23:44:37 UTC (rev 10194)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*
  * Copyright (c) 2003 Hidetoshi Shimokawa
  * Copyright (c) 1998-2002 Katsushi Kobayashi and Hidetoshi Shimokawa
@@ -31,7 +32,7 @@
  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  * POSSIBILITY OF SUCH DAMAGE.
  * 
- * $FreeBSD$
+ * $FreeBSD: stable/10/sys/boot/i386/libfirewire/fwohcireg.h 261455 2014-02-04 03:36:42Z eadler $
  *
  */
 #define		PCI_CBMEM		PCIR_BAR(0)
@@ -239,7 +240,7 @@
 	fwohcireg_t	dummy1[3];	/* dummy 0x44-0x4c */
 	fwohcireg_t	hcc_cntl_set;	/* HCC control set 0x50 */
 	fwohcireg_t	hcc_cntl_clr;	/* HCC control clr 0x54 */
-#define	OHCI_HCC_BIBIV	(1 << 31)	/* BIBimage Valid */
+#define	OHCI_HCC_BIBIV	(1U << 31)	/* BIBimage Valid */
 #define	OHCI_HCC_BIGEND	(1 << 30)	/* noByteSwapData */
 #define	OHCI_HCC_PRPHY	(1 << 23)	/* programPhyEnable */
 #define	OHCI_HCC_PHYEN	(1 << 22)	/* aPhyEnhanceEnable */
@@ -278,7 +279,7 @@
 	fwohcireg_t	link_cntl_clr;	/* Chip control clear 0xe4*/
 #define FWOHCI_NODEID	0xe8
 	fwohcireg_t	node;		/* Node ID 0xe8 */
-#define	OHCI_NODE_VALID	(1 << 31)
+#define	OHCI_NODE_VALID	(1U << 31)
 #define	OHCI_NODE_ROOT	(1 << 30)
 
 #define	OHCI_ASYSRCBUS	1

Modified: trunk/sys/boot/i386/libi386/Makefile
===================================================================
--- trunk/sys/boot/i386/libi386/Makefile	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/libi386/Makefile	2018-06-01 23:44:37 UTC (rev 10194)
@@ -1,5 +1,5 @@
 # $MidnightBSD$
-# $FreeBSD: stable/9/sys/boot/i386/libi386/Makefile 294852 2016-01-26 21:35:47Z jkim $
+# $FreeBSD: stable/10/sys/boot/i386/libi386/Makefile 294852 2016-01-26 21:35:47Z jkim $
 #
 LIB=			i386
 INTERNALLIB=
@@ -7,7 +7,7 @@
 SRCS=	biosacpi.c bioscd.c biosdisk.c biosmem.c biospnp.c \
 	biospci.c biossmap.c bootinfo.c bootinfo32.c bootinfo64.c \
 	comconsole.c devicename.c elf32_freebsd.c \
-	elf64_freebsd.c \
+	elf64_freebsd.c multiboot.c multiboot_tramp.S \
 	i386_copy.c i386_module.c nullconsole.c pxe.c pxetramp.s \
 	smbios.c time.c vidconsole.c amd64_tramp.S spinconsole.c
 .PATH:	${.CURDIR}/../../zfs
@@ -56,6 +56,9 @@
 # the location of libstand
 CFLAGS+=	-I${.CURDIR}/../../../../lib/libstand/
 
+# Suppress warning from clang for FreeBSD %b and %D formats
+CFLAGS+= -fformat-extensions
+
 .if ${MACHINE_CPUARCH} == "amd64"
 CLEANFILES+=	machine
 machine:
@@ -66,6 +69,7 @@
 
 # XXX: clang integrated-as doesn't grok .codeNN directives yet
 CFLAGS.amd64_tramp.S=	${CLANG_NO_IAS}
+CFLAGS.multiboot_tramp.S=	${CLANG_NO_IAS}
 CFLAGS+=		${CFLAGS.${.IMPSRC:T}}
 
 .if ${MACHINE_CPUARCH} == "amd64"

Modified: trunk/sys/boot/i386/libi386/amd64_tramp.S
===================================================================
--- trunk/sys/boot/i386/libi386/amd64_tramp.S	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/libi386/amd64_tramp.S	2018-06-01 23:44:37 UTC (rev 10194)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 2003  Peter Wemm <peter at FreeBSD.org>
  * All rights reserved.
@@ -23,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/boot/i386/libi386/amd64_tramp.S,v 1.4.26.1 2008/11/25 02:59:29 kensmith Exp $
+ * $FreeBSD: stable/10/sys/boot/i386/libi386/amd64_tramp.S 129240 2004-05-14 20:29:30Z ru $
  */
 
 /*

Modified: trunk/sys/boot/i386/libi386/biosacpi.c
===================================================================
--- trunk/sys/boot/i386/libi386/biosacpi.c	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/libi386/biosacpi.c	2018-06-01 23:44:37 UTC (rev 10194)
@@ -26,6 +26,7 @@
  */
 
 #include <sys/cdefs.h>
+__FBSDID("$FreeBSD: stable/10/sys/boot/i386/libi386/biosacpi.c 254733 2013-08-23 18:52:36Z jkim $");
 
 #include <stand.h>
 #include <machine/stdarg.h>
@@ -61,7 +62,7 @@
 	return;
 
     /* export values from the RSDP */
-    sprintf(buf, "%u", VTOP(rsdp));
+    sprintf(buf, "0x%08x", VTOP(rsdp));
     setenv("hint.acpi.0.rsdp", buf, 1);
     revision = rsdp->Revision;
     if (revision == 0)

Modified: trunk/sys/boot/i386/libi386/bioscd.c
===================================================================
--- trunk/sys/boot/i386/libi386/bioscd.c	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/libi386/bioscd.c	2018-06-01 23:44:37 UTC (rev 10194)
@@ -27,6 +27,7 @@
  */
 
 #include <sys/cdefs.h>
+__FBSDID("$FreeBSD: stable/10/sys/boot/i386/libi386/bioscd.c 227389 2011-11-09 14:37:47Z jhb $");
 
 /*
  * BIOS CD device handling for CD's that have been booted off of via no

Modified: trunk/sys/boot/i386/libi386/biosdisk.c
===================================================================
--- trunk/sys/boot/i386/libi386/biosdisk.c	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/libi386/biosdisk.c	2018-06-01 23:44:37 UTC (rev 10194)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
 /*-
  * Copyright (c) 1998 Michael Smith <msmith at freebsd.org>
  * Copyright (c) 2012 Andrey V. Elsukov <ae at FreeBSD.org>
@@ -26,7 +27,7 @@
  */
 
 #include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/boot/i386/libi386/biosdisk.c 305458 2016-09-06 06:13:47Z avg $");
 
 /*
  * BIOS disk device handling.
@@ -42,7 +43,6 @@
 #include <stand.h>
 #include <machine/bootinfo.h>
 #include <stdarg.h>
-#include <stdint.h>
 
 #include <bootstrap.h>
 #include <btxv86.h>

Modified: trunk/sys/boot/i386/libi386/biosmem.c
===================================================================
--- trunk/sys/boot/i386/libi386/biosmem.c	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/libi386/biosmem.c	2018-06-01 23:44:37 UTC (rev 10194)
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/boot/i386/libi386/biosmem.c,v 1.8.2.1.2.1 2008/11/25 02:59:29 kensmith Exp $");
+__FBSDID("$FreeBSD: stable/10/sys/boot/i386/libi386/biosmem.c 226746 2011-10-25 19:45:12Z jhb $");
 
 /*
  * Obtain memory configuration information from the BIOS

Modified: trunk/sys/boot/i386/libi386/biospci.c
===================================================================
--- trunk/sys/boot/i386/libi386/biospci.c	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/libi386/biospci.c	2018-06-01 23:44:37 UTC (rev 10194)
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/boot/i386/libi386/biospci.c,v 1.6.6.1 2008/11/25 02:59:29 kensmith Exp $");
+__FBSDID("$FreeBSD: stable/10/sys/boot/i386/libi386/biospci.c 229435 2012-01-03 22:36:12Z kib $");
 
 /*
  * PnP enumerator using the PCI BIOS.

Modified: trunk/sys/boot/i386/libi386/biospnp.c
===================================================================
--- trunk/sys/boot/i386/libi386/biospnp.c	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/libi386/biospnp.c	2018-06-01 23:44:37 UTC (rev 10194)
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/boot/i386/libi386/biospnp.c,v 1.10.6.1 2008/11/25 02:59:29 kensmith Exp $");
+__FBSDID("$FreeBSD: stable/10/sys/boot/i386/libi386/biospnp.c 236213 2012-05-29 01:48:06Z kevlo $");
 
 /*
  * PnP BIOS enumerator.
@@ -277,6 +277,7 @@
 	    break;
 	}
     }
+    va_end(ap);
 
     /* BIOS segment last */
     *(u_int16_t *)argp = pnp_Icheck->pnp_rmds;

Modified: trunk/sys/boot/i386/libi386/biossmap.c
===================================================================
--- trunk/sys/boot/i386/libi386/biossmap.c	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/libi386/biossmap.c	2018-06-01 23:44:37 UTC (rev 10194)
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/boot/i386/libi386/biossmap.c,v 1.6.2.2.2.1 2008/11/25 02:59:29 kensmith Exp $");
+__FBSDID("$FreeBSD: stable/10/sys/boot/i386/libi386/biossmap.c 226746 2011-10-25 19:45:12Z jhb $");
 
 /*
  * Obtain memory configuration information from the BIOS

Modified: trunk/sys/boot/i386/libi386/bootinfo.c
===================================================================
--- trunk/sys/boot/i386/libi386/bootinfo.c	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/libi386/bootinfo.c	2018-06-01 23:44:37 UTC (rev 10194)
@@ -26,39 +26,17 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/boot/i386/libi386/bootinfo.c 271132 2014-09-04 20:47:14Z emaste $");
 
 #include <stand.h>
 #include <sys/param.h>
 #include <sys/reboot.h>
 #include <sys/linker.h>
+#include <sys/boot.h>
 #include "bootstrap.h"
 #include "libi386.h"
 #include "btxv86.h"
 
-/*
- * Return a 'boothowto' value corresponding to the kernel arguments in
- * (kargs) and any relevant environment variables.
- */
-static struct 
-{
-    const char	*ev;
-    int		mask;
-} howto_names[] = {
-    {"boot_askname",	RB_ASKNAME},
-    {"boot_cdrom",	RB_CDROM},
-    {"boot_ddb",	RB_KDB},
-    {"boot_dfltroot",	RB_DFLTROOT},
-    {"boot_gdb",	RB_GDB},
-    {"boot_multicons",	RB_MULTIPLE},
-    {"boot_mute",	RB_MUTE},
-    {"boot_pause",	RB_PAUSE},
-    {"boot_serial",	RB_SERIAL},
-    {"boot_single",	RB_SINGLE},
-    {"boot_verbose",	RB_VERBOSE},
-    {NULL,	0}
-};
-
 int
 bi_getboothowto(char *kargs)
 {

Modified: trunk/sys/boot/i386/libi386/bootinfo32.c
===================================================================
--- trunk/sys/boot/i386/libi386/bootinfo32.c	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/libi386/bootinfo32.c	2018-06-01 23:44:37 UTC (rev 10194)
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/boot/i386/libi386/bootinfo32.c,v 1.37.6.1 2008/11/25 02:59:29 kensmith Exp $");
+__FBSDID("$FreeBSD: stable/10/sys/boot/i386/libi386/bootinfo32.c 185029 2008-11-17 20:49:29Z pjd $");
 
 #include <stand.h>
 #include <sys/param.h>

Modified: trunk/sys/boot/i386/libi386/bootinfo64.c
===================================================================
--- trunk/sys/boot/i386/libi386/bootinfo64.c	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/libi386/bootinfo64.c	2018-06-01 23:44:37 UTC (rev 10194)
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/boot/i386/libi386/bootinfo64.c,v 1.37.2.1.2.1 2008/11/25 02:59:29 kensmith Exp $");
+__FBSDID("$FreeBSD: stable/10/sys/boot/i386/libi386/bootinfo64.c 294417 2016-01-20 13:23:02Z royger $");
 
 #include <stand.h>
 #include <sys/param.h>
@@ -34,6 +34,7 @@
 #include <sys/linker.h>
 #include <machine/bootinfo.h>
 #include <machine/cpufunc.h>
+#include <machine/metadata.h>
 #include <machine/psl.h>
 #include <machine/specialreg.h>
 #include "bootstrap.h"
@@ -135,7 +136,8 @@
 {
     char *cpu_vendor;
     int vendor[3];
-    int eflags, regs[4];
+    int eflags;
+    unsigned int regs[4];
 
     /* Check for presence of "cpuid". */
     eflags = read_eflags();
@@ -176,14 +178,15 @@
  * - Module metadata are formatted and placed in kernel space.
  */
 int
-bi_load64(char *args, vm_offset_t *modulep, vm_offset_t *kernendp)
+bi_load64(char *args, vm_offset_t addr, vm_offset_t *modulep,
+    vm_offset_t *kernendp, int add_smap)
 {
     struct preloaded_file	*xp, *kfp;
     struct i386_devdesc		*rootdev;
     struct file_metadata	*md;
-    vm_offset_t			addr;
     u_int64_t			kernend;
     u_int64_t			envp;
+    u_int64_t			module;
     vm_offset_t			size;
     char			*rootdevname;
     int				howto;
@@ -210,22 +213,19 @@
     /* Try reading the /etc/fstab file to select the root device */
     getrootmount(i386_fmtdev((void *)rootdev));
 
-    /* find the last module in the chain */
-    addr = 0;
-    for (xp = file_findfile(NULL, NULL); xp != NULL; xp = xp->f_next) {
-	if (addr < (xp->f_addr + xp->f_size))
-	    addr = xp->f_addr + xp->f_size;
+    if (addr == 0) {
+        /* find the last module in the chain */
+        for (xp = file_findfile(NULL, NULL); xp != NULL; xp = xp->f_next) {
+            if (addr < (xp->f_addr + xp->f_size))
+                addr = xp->f_addr + xp->f_size;
+        }
     }
     /* pad to a page boundary */
     addr = roundup(addr, PAGE_SIZE);
 
-    /* copy our environment */
-    envp = addr;
-    addr = bi_copyenv(addr);
+    /* place the metadata before anything */
+    module = *modulep = addr;
 
-    /* pad to a page boundary */
-    addr = roundup(addr, PAGE_SIZE);
-
     kfp = file_findfile(NULL, "elf kernel");
     if (kfp == NULL)
       kfp = file_findfile(NULL, "elf64 kernel");
@@ -235,12 +235,18 @@
     file_addmetadata(kfp, MODINFOMD_HOWTO, sizeof howto, &howto);
     file_addmetadata(kfp, MODINFOMD_ENVP, sizeof envp, &envp);
     file_addmetadata(kfp, MODINFOMD_KERNEND, sizeof kernend, &kernend);
-    bios_addsmapdata(kfp);
+    file_addmetadata(kfp, MODINFOMD_MODULEP, sizeof module, &module);
+    if (add_smap != 0)
+        bios_addsmapdata(kfp);
 
-    /* Figure out the size and location of the metadata */
-    *modulep = addr;
     size = bi_copymodules64(0);
-    kernend = roundup(addr + size, PAGE_SIZE);
+
+    /* copy our environment */
+    envp = roundup(addr + size, PAGE_SIZE);
+    addr = bi_copyenv(envp);
+
+    /* set kernend */
+    kernend = roundup(addr, PAGE_SIZE);
     *kernendp = kernend;
 
     /* patch MODINFOMD_KERNEND */
@@ -247,8 +253,12 @@
     md = file_findmetadata(kfp, MODINFOMD_KERNEND);
     bcopy(&kernend, md->md_data, sizeof kernend);
 
+    /* patch MODINFOMD_ENVP */
+    md = file_findmetadata(kfp, MODINFOMD_ENVP);
+    bcopy(&envp, md->md_data, sizeof envp);
+
     /* copy module list and metadata */
-    (void)bi_copymodules64(addr);
+    (void)bi_copymodules64(*modulep);
 
     return(0);
 }

Modified: trunk/sys/boot/i386/libi386/comconsole.c
===================================================================
--- trunk/sys/boot/i386/libi386/comconsole.c	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/libi386/comconsole.c	2018-06-01 23:44:37 UTC (rev 10194)
@@ -25,7 +25,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: stable/9/sys/boot/i386/libi386/comconsole.c 261574 2014-02-07 04:10:30Z mav $");
+__FBSDID("$FreeBSD: stable/10/sys/boot/i386/libi386/comconsole.c 271880 2014-09-19 21:30:45Z emaste $");
 
 #include <stand.h>
 #include <bootstrap.h>
@@ -215,6 +215,9 @@
 static uint32_t
 comc_parse_pcidev(const char *string)
 {
+#ifdef NO_PCI
+	return (0);
+#else
 	char *p, *p1;
 	uint8_t bus, dev, func, bar;
 	uint32_t locator;
@@ -248,11 +251,15 @@
 
 	locator = (bar << 16) | biospci_locator(bus, dev, func);
 	return (locator);
+#endif
 }
 
 static int
 comc_pcidev_handle(uint32_t locator)
 {
+#ifdef NO_PCI
+	return (CMD_ERROR);
+#else
 	char intbuf[64];
 	uint32_t port;
 
@@ -276,6 +283,7 @@
 	comc_locator = locator;
 
 	return (CMD_OK);
+#endif
 }
 
 static int

Modified: trunk/sys/boot/i386/libi386/devicename.c
===================================================================
--- trunk/sys/boot/i386/libi386/devicename.c	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/libi386/devicename.c	2018-06-01 23:44:37 UTC (rev 10194)
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/boot/i386/libi386/devicename.c,v 1.8.2.1.2.1 2008/11/25 02:59:29 kensmith Exp $");
+__FBSDID("$FreeBSD: stable/10/sys/boot/i386/libi386/devicename.c 245424 2013-01-14 15:05:22Z sbruno $");
 
 #include <stand.h>
 #include <string.h>
@@ -129,7 +129,7 @@
 		goto fail;
 	    }
 	} else {
-		cp = np;
+		cp = (char *)np;
 	}
 	if (*cp && (*cp != ':')) {
 	    err = EINVAL;

Modified: trunk/sys/boot/i386/libi386/elf32_freebsd.c
===================================================================
--- trunk/sys/boot/i386/libi386/elf32_freebsd.c	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/libi386/elf32_freebsd.c	2018-06-01 23:44:37 UTC (rev 10194)
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/boot/i386/libi386/elf32_freebsd.c,v 1.17.6.1 2008/11/25 02:59:29 kensmith Exp $");
+__FBSDID("$FreeBSD: stable/10/sys/boot/i386/libi386/elf32_freebsd.c 199806 2009-11-25 16:36:07Z trasz $");
 
 #include <sys/param.h>
 #include <sys/exec.h>

Modified: trunk/sys/boot/i386/libi386/elf64_freebsd.c
===================================================================
--- trunk/sys/boot/i386/libi386/elf64_freebsd.c	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/libi386/elf64_freebsd.c	2018-06-01 23:44:37 UTC (rev 10194)
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/boot/i386/libi386/elf64_freebsd.c,v 1.17.6.1 2008/11/25 02:59:29 kensmith Exp $");
+__FBSDID("$FreeBSD: stable/10/sys/boot/i386/libi386/elf64_freebsd.c 294417 2016-01-20 13:23:02Z royger $");
 
 #define __ELF_WORD_SIZE 64
 #include <sys/param.h>
@@ -82,7 +82,7 @@
 	return(EFTYPE);
     ehdr = (Elf_Ehdr *)&(md->md_data);
 
-    err = bi_load64(fp->f_args, &modulep, &kernend);
+    err = bi_load64(fp->f_args, 0, &modulep, &kernend, 1);
     if (err != 0)
 	return(err);
 

Modified: trunk/sys/boot/i386/libi386/i386_copy.c
===================================================================
--- trunk/sys/boot/i386/libi386/i386_copy.c	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/libi386/i386_copy.c	2018-06-01 23:44:37 UTC (rev 10194)
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
+__FBSDID("$FreeBSD: stable/10/sys/boot/i386/libi386/i386_copy.c 153589 2005-12-21 02:17:58Z sobomax $");
 
 /*
  * MD primitives supporting placement of module data 

Modified: trunk/sys/boot/i386/libi386/i386_module.c
===================================================================
--- trunk/sys/boot/i386/libi386/i386_module.c	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/libi386/i386_module.c	2018-06-01 23:44:37 UTC (rev 10194)
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/boot/i386/libi386/i386_module.c,v 1.12.28.1 2008/11/25 02:59:29 kensmith Exp $");
+__FBSDID("$FreeBSD: stable/10/sys/boot/i386/libi386/i386_module.c 215245 2010-11-13 15:23:20Z nyan $");
 
 /*
  * i386-specific module functionality.

Modified: trunk/sys/boot/i386/libi386/libi386.h
===================================================================
--- trunk/sys/boot/i386/libi386/libi386.h	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/libi386/libi386.h	2018-06-01 23:44:37 UTC (rev 10194)
@@ -24,7 +24,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/boot/i386/libi386/libi386.h,v 1.27.6.1 2008/11/25 02:59:29 kensmith Exp $
+ * $FreeBSD: stable/10/sys/boot/i386/libi386/libi386.h 294417 2016-01-20 13:23:02Z royger $
  */
 
 
@@ -111,8 +111,6 @@
 
 void	biosacpi_detect(void);
 
-void	smbios_detect(void);
-
 int	i386_autoload(void);
 
 int	bi_getboothowto(char *kargs);
@@ -120,6 +118,7 @@
 vm_offset_t	bi_copyenv(vm_offset_t addr);
 int	bi_load32(char *args, int *howtop, int *bootdevp, vm_offset_t *bip,
 	    vm_offset_t *modulep, vm_offset_t *kernend);
-int	bi_load64(char *args, vm_offset_t *modulep, vm_offset_t *kernend);
+int	bi_load64(char *args, vm_offset_t addr, vm_offset_t *modulep,
+	    vm_offset_t *kernend, int add_smap);
 
 void	pxe_enable(void *pxeinfo);

Added: trunk/sys/boot/i386/libi386/multiboot.c
===================================================================
--- trunk/sys/boot/i386/libi386/multiboot.c	                        (rev 0)
+++ trunk/sys/boot/i386/libi386/multiboot.c	2018-06-01 23:44:37 UTC (rev 10194)
@@ -0,0 +1,426 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2014 Roger Pau Monné <royger at FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ */
+
+/*
+ * This multiboot implementation only implements a subset of the full
+ * multiboot specification in order to be able to boot Xen and a
+ * FreeBSD Dom0. Trying to use it to boot other multiboot compliant
+ * kernels will most surely fail.
+ *
+ * The full multiboot specification can be found here:
+ * http://www.gnu.org/software/grub/manual/multiboot/multiboot.html
+ */
+
+#include <sys/cdefs.h>
+__FBSDID("$FreeBSD: stable/10/sys/boot/i386/libi386/multiboot.c 294417 2016-01-20 13:23:02Z royger $");
+
+#include <sys/param.h>
+#include <sys/exec.h>
+#include <sys/linker.h>
+#include <sys/module.h>
+#include <sys/stdint.h>
+#define _MACHINE_ELF_WANT_32BIT
+#include <machine/elf.h>
+#include <string.h>
+#include <stand.h>
+
+#include "bootstrap.h"
+#include "multiboot.h"
+#include "../i386/libi386/libi386.h"
+#include "../i386/btx/lib/btxv86.h"
+
+#define MULTIBOOT_SUPPORTED_FLAGS \
+				(MULTIBOOT_PAGE_ALIGN|MULTIBOOT_MEMORY_INFO)
+#define NUM_MODULES		2
+#define METADATA_FIXED_SIZE	(PAGE_SIZE*4)
+#define METADATA_MODULE_SIZE	PAGE_SIZE
+
+#define METADATA_RESV_SIZE(mod_num) \
+	roundup(METADATA_FIXED_SIZE + METADATA_MODULE_SIZE * mod_num, PAGE_SIZE)
+
+extern int elf32_loadfile_raw(char *filename, u_int64_t dest,
+    struct preloaded_file **result, int multiboot);
+extern int elf64_load_modmetadata(struct preloaded_file *fp, u_int64_t dest);
+extern int elf64_obj_loadfile(char *filename, u_int64_t dest,
+    struct preloaded_file **result);
+
+static int multiboot_loadfile(char *, u_int64_t, struct preloaded_file **);
+static int multiboot_exec(struct preloaded_file *);
+
+static int multiboot_obj_loadfile(char *, u_int64_t, struct preloaded_file **);
+static int multiboot_obj_exec(struct preloaded_file *fp);
+
+struct file_format multiboot = { multiboot_loadfile, multiboot_exec };
+struct file_format multiboot_obj =
+    { multiboot_obj_loadfile, multiboot_obj_exec };
+
+extern void multiboot_tramp();
+
+static const char mbl_name[] = "FreeBSD Loader";
+
+static int
+num_modules(struct preloaded_file *kfp)
+{
+	struct kernel_module	*kmp;
+	int			 mod_num = 0;
+
+	for (kmp = kfp->f_modules; kmp != NULL; kmp = kmp->m_next)
+		mod_num++;
+
+	return (mod_num);
+}
+
+static vm_offset_t
+max_addr(void)
+{
+	struct preloaded_file	*fp;
+	vm_offset_t		 addr = 0;
+
+	for (fp = file_findfile(NULL, NULL); fp != NULL; fp = fp->f_next) {
+		if (addr < (fp->f_addr + fp->f_size))
+			addr = fp->f_addr + fp->f_size;
+	}
+
+	return (addr);
+}
+
+static int
+multiboot_loadfile(char *filename, u_int64_t dest,
+    struct preloaded_file **result)
+{
+	uint32_t		*magic;
+	int			 i, error;
+	caddr_t			 header_search;
+	ssize_t			 search_size;
+	int			 fd;
+	struct multiboot_header	*header;
+	char			*cmdline;
+
+	/*
+	 * Read MULTIBOOT_SEARCH size in order to search for the
+	 * multiboot magic header.
+	 */
+	if (filename == NULL)
+		return (EFTYPE);
+	if ((fd = open(filename, O_RDONLY)) == -1)
+		return (errno);
+	header_search = malloc(MULTIBOOT_SEARCH);
+	if (header_search == NULL) {
+		close(fd);
+		return (ENOMEM);
+	}
+	search_size = read(fd, header_search, MULTIBOOT_SEARCH);
+	magic = (uint32_t *)header_search;
+
+	header = NULL;
+	for (i = 0; i < (search_size / sizeof(uint32_t)); i++) {
+		if (magic[i] == MULTIBOOT_HEADER_MAGIC) {
+			header = (struct multiboot_header *)&magic[i];
+			break;
+		}
+	}
+
+	if (header == NULL) {
+		error = EFTYPE;
+		goto out;
+	}
+
+	/* Valid multiboot header has been found, validate checksum */
+	if (header->magic + header->flags + header->checksum != 0) {
+		printf(
+	"Multiboot checksum failed, magic: 0x%x flags: 0x%x checksum: 0x%x\n",
+	header->magic, header->flags, header->checksum);
+		error = EFTYPE;
+		goto out;
+	}
+
+	if ((header->flags & ~MULTIBOOT_SUPPORTED_FLAGS) != 0) {
+		printf("Unsupported multiboot flags found: 0x%x\n",
+		    header->flags);
+		error = EFTYPE;
+		goto out;
+	}
+
+	error = elf32_loadfile_raw(filename, dest, result, 1);
+	if (error != 0) {
+		printf(
+	"elf32_loadfile_raw failed: %d unable to load multiboot kernel\n",
+	error);
+		goto out;
+	}
+
+	/*
+	 * f_addr is already aligned to PAGE_SIZE, make sure
+	 * f_size it's also aligned so when the modules are loaded
+	 * they are aligned to PAGE_SIZE.
+	 */
+	(*result)->f_size = roundup((*result)->f_size, PAGE_SIZE);
+
+out:
+	free(header_search);
+	close(fd);
+	return (error);
+}
+
+static int
+multiboot_exec(struct preloaded_file *fp)
+{
+	vm_offset_t			 module_start, last_addr, metadata_size;
+	vm_offset_t			 modulep, kernend, entry;
+	struct file_metadata		*md;
+	Elf_Ehdr			*ehdr;
+	struct multiboot_info		*mb_info = NULL;
+	struct multiboot_mod_list	*mb_mod = NULL;
+	char				*cmdline = NULL;
+	size_t				 len;
+	int				 error, mod_num;
+
+	/*
+	 * Don't pass the memory size found by the bootloader, the memory
+	 * available to Dom0 will be lower than that.
+	 */
+	unsetenv("smbios.memory.enabled");
+
+	/* Allocate the multiboot struct and fill the basic details. */
+	mb_info = malloc(sizeof(struct multiboot_info));
+	if (mb_info == NULL) {
+		error = ENOMEM;
+		goto error;
+	}
+	bzero(mb_info, sizeof(struct multiboot_info));
+	mb_info->flags = MULTIBOOT_INFO_MEMORY|MULTIBOOT_INFO_BOOT_LOADER_NAME;
+	mb_info->mem_lower = bios_basemem / 1024;
+	mb_info->mem_upper = bios_extmem / 1024;
+	mb_info->boot_loader_name = VTOP(mbl_name);
+
+	/* Set the Xen command line. */
+	if (fp->f_args == NULL) {
+		/* Add the Xen command line if it is set. */
+		cmdline = getenv("xen_cmdline");
+		if (cmdline != NULL) {
+			fp->f_args = strdup(cmdline);
+			if (fp->f_args == NULL) {
+				error = ENOMEM;
+				goto error;
+			}
+		}
+	}
+	if (fp->f_args != NULL) {
+		len = strlen(fp->f_name) + 1 + strlen(fp->f_args) + 1;
+		cmdline = malloc(len);
+		if (cmdline == NULL) {
+			error = ENOMEM;
+			goto error;
+		}
+		snprintf(cmdline, len, "%s %s", fp->f_name, fp->f_args);
+		mb_info->cmdline = VTOP(cmdline);
+		mb_info->flags |= MULTIBOOT_INFO_CMDLINE;
+	}
+
+	/* Find the entry point of the Xen kernel and save it for later */
+	if ((md = file_findmetadata(fp, MODINFOMD_ELFHDR)) == NULL) {
+		printf("Unable to find %s entry point\n", fp->f_name);
+		error = EINVAL;
+		goto error;
+	}
+	ehdr = (Elf_Ehdr *)&(md->md_data);
+	entry = ehdr->e_entry & 0xffffff;
+
+	/*
+	 * Prepare the multiboot module list, Xen assumes the first
+	 * module is the Dom0 kernel, and the second one is the initramfs.
+	 * This is not optimal for FreeBSD, that doesn't have a initramfs
+	 * but instead loads modules dynamically and creates the metadata
+	 * info on-the-fly.
+	 *
+	 * As expected, the first multiboot module is going to be the
+	 * FreeBSD kernel loaded as a raw file. The second module is going
+	 * to contain the metadata info and the loaded modules.
+	 *
+	 * On native FreeBSD loads all the modules and then places the
+	 * metadata info at the end, but this is painful when running on Xen,
+	 * because it relocates the second multiboot module wherever it
+	 * likes. In order to workaround this limitation the metadata
+	 * information is placed at the start of the second module and
+	 * the original modulep value is saved together with the other
+	 * metadata, so we can relocate everything.
+	 */
+	fp = file_findfile(NULL, "elf kernel");
+	if (fp == NULL) {
+		printf("No FreeBSD kernel provided, aborting\n");
+		error = EINVAL;
+		goto error;
+	}
+
+	mb_mod = malloc(sizeof(struct multiboot_mod_list) * NUM_MODULES);
+	if (mb_mod == NULL) {
+		error = ENOMEM;
+		goto error;
+	}
+
+	bzero(mb_mod, sizeof(struct multiboot_mod_list) * NUM_MODULES);
+
+	/*
+	 * Calculate how much memory is needed for the metatdata. We did
+	 * an approximation of the maximum size when loading the kernel,
+	 * but now we know the exact size, so we can release some of this
+	 * preallocated memory if not needed.
+	 */
+	last_addr = roundup(max_addr(), PAGE_SIZE);
+	mod_num = num_modules(fp);
+
+	/*
+	 * Place the metadata after the last used address in order to
+	 * calculate it's size, this will not be used.
+	 */
+	error = bi_load64(fp->f_args, last_addr, &modulep, &kernend, 0);
+	if (error != 0) {
+		printf("bi_load64 failed: %d\n", error);
+		goto error;
+	}
+	metadata_size = roundup(kernend - last_addr, PAGE_SIZE);
+
+	/* Check that the size is not greater than what we have reserved */
+	if (metadata_size > METADATA_RESV_SIZE(mod_num)) {
+		printf("Required memory for metadata is greater than reserved "
+		    "space, please increase METADATA_FIXED_SIZE and "
+		    "METADATA_MODULE_SIZE and rebuild the loader\n");
+		error = ENOMEM;
+		goto error;
+	}
+
+	/*
+	 * This is the position where the second multiboot module
+	 * will be placed.
+	 */
+	module_start = fp->f_addr + fp->f_size - metadata_size;
+
+	error = bi_load64(fp->f_args, module_start, &modulep, &kernend, 0);
+	if (error != 0) {
+		printf("bi_load64 failed: %d\n", error);
+		goto error;
+	}
+
+	mb_mod[0].mod_start = fp->f_addr;
+	mb_mod[0].mod_end = fp->f_addr + fp->f_size;
+	mb_mod[0].mod_end -= METADATA_RESV_SIZE(mod_num);
+
+	mb_mod[1].mod_start = module_start;
+	mb_mod[1].mod_end = last_addr;
+
+	mb_info->mods_count = NUM_MODULES;
+	mb_info->mods_addr = VTOP(mb_mod);
+	mb_info->flags |= MULTIBOOT_INFO_MODS;
+
+	dev_cleanup();
+	__exec((void *)VTOP(multiboot_tramp), (void *)entry,
+	    (void *)VTOP(mb_info));
+
+	panic("exec returned");
+
+error:
+	if (mb_mod)
+		free(mb_mod);
+	if (mb_info)
+		free(mb_info);
+	if (cmdline)
+		free(cmdline);
+	return (error);
+}
+
+static int
+multiboot_obj_loadfile(char *filename, u_int64_t dest,
+    struct preloaded_file **result)
+{
+	struct preloaded_file	*mfp, *kfp, *rfp;
+	struct kernel_module	*kmp;
+	int			 error, mod_num;
+
+	/* See if there's a multiboot kernel loaded */
+	mfp = file_findfile(NULL, "elf multiboot kernel");
+	if (mfp == NULL)
+		return (EFTYPE);
+
+	/*
+	 * We have a multiboot kernel loaded, see if there's a FreeBSD
+	 * kernel loaded also.
+	 */
+	kfp = file_findfile(NULL, "elf kernel");
+	if (kfp == NULL) {
+		/*
+		 * No kernel loaded, this must be it. The kernel has to
+		 * be loaded as a raw file, it will be processed by
+		 * Xen and correctly loaded as an ELF file.
+		 */
+		rfp = file_loadraw(filename, "elf kernel", 0);
+		if (rfp == NULL) {
+			printf(
+			"Unable to load %s as a multiboot payload kernel\n",
+			filename);
+			return (EINVAL);
+		}
+
+		/* Load kernel metadata... */
+		setenv("kernelname", filename, 1);
+		error = elf64_load_modmetadata(rfp, rfp->f_addr + rfp->f_size);
+		if (error) {
+			printf("Unable to load kernel %s metadata error: %d\n",
+			    rfp->f_name, error);
+			return (EINVAL);
+		}
+
+		/*
+		 * Save space at the end of the kernel in order to place
+		 * the metadata information. We do an approximation of the
+		 * max metadata size, this is not optimal but it's probably
+		 * the best we can do at this point. Once all modules are
+		 * loaded and the size of the metadata is known this
+		 * space will be recovered if not used.
+		 */
+		mod_num = num_modules(rfp);
+		rfp->f_size = roundup(rfp->f_size, PAGE_SIZE);
+		rfp->f_size += METADATA_RESV_SIZE(mod_num);
+		*result = rfp;
+	} else {
+		/* The rest should be loaded as regular modules */
+		error = elf64_obj_loadfile(filename, dest, result);
+		if (error != 0) {
+			printf("Unable to load %s as an object file, error: %d",
+			    filename, error);
+			return (error);
+		}
+	}
+
+	return (0);
+}
+
+static int
+multiboot_obj_exec(struct preloaded_file *fp)
+{
+
+	return (EFTYPE);
+}


Property changes on: trunk/sys/boot/i386/libi386/multiboot.c
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/sys/boot/i386/libi386/multiboot.h
===================================================================
--- trunk/sys/boot/i386/libi386/multiboot.h	                        (rev 0)
+++ trunk/sys/boot/i386/libi386/multiboot.h	2018-06-01 23:44:37 UTC (rev 10194)
@@ -0,0 +1,226 @@
+/* $MidnightBSD$ */
+/* multiboot.h - Multiboot header file. */
+/* Copyright (C) 1999,2003,2007,2008,2009  Free Software Foundation, Inc.
+*
+*  Permission is hereby granted, free of charge, to any person obtaining a copy
+*  of this software and associated documentation files (the "Software"), to
+*  deal in the Software without restriction, including without limitation the
+*  rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+*  sell copies of the Software, and to permit persons to whom the Software is
+*  furnished to do so, subject to the following conditions:
+*
+*  The above copyright notice and this permission notice shall be included in
+*  all copies or substantial portions of the Software.
+*
+*  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+*  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+*  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL ANY
+*  DEVELOPER OR DISTRIBUTOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
+*  WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
+*  IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+*
+* $FreeBSD: stable/10/sys/boot/i386/libi386/multiboot.h 294417 2016-01-20 13:23:02Z royger $
+*/
+
+#ifndef MULTIBOOT_HEADER
+#define MULTIBOOT_HEADER 1
+
+/* How many bytes from the start of the file we search for the header. */
+#define MULTIBOOT_SEARCH                        8192
+
+/* The magic field should contain this. */
+#define MULTIBOOT_HEADER_MAGIC                  0x1BADB002
+
+/* This should be in %eax. */
+#define MULTIBOOT_BOOTLOADER_MAGIC              0x2BADB002
+
+/* The bits in the required part of flags field we don't support. */
+#define MULTIBOOT_UNSUPPORTED                   0x0000fffc
+
+/* Alignment of multiboot modules. */
+#define MULTIBOOT_MOD_ALIGN                     0x00001000
+
+/* Alignment of the multiboot info structure. */
+#define MULTIBOOT_INFO_ALIGN                    0x00000004
+
+/* Flags set in the 'flags' member of the multiboot header. */
+
+/* Align all boot modules on i386 page (4KB) boundaries. */
+#define MULTIBOOT_PAGE_ALIGN                    0x00000001
+
+/* Must pass memory information to OS. */
+#define MULTIBOOT_MEMORY_INFO                   0x00000002
+
+/* Must pass video information to OS. */
+#define MULTIBOOT_VIDEO_MODE                    0x00000004
+
+/* This flag indicates the use of the address fields in the header. */
+#define MULTIBOOT_AOUT_KLUDGE                   0x00010000
+
+/* Flags to be set in the 'flags' member of the multiboot info structure. */
+
+/* is there basic lower/upper memory information? */
+#define MULTIBOOT_INFO_MEMORY                   0x00000001
+/* is there a boot device set? */
+#define MULTIBOOT_INFO_BOOTDEV                  0x00000002
+/* is the command-line defined? */
+#define MULTIBOOT_INFO_CMDLINE                  0x00000004
+/* are there modules to do something with? */
+#define MULTIBOOT_INFO_MODS                     0x00000008
+
+/* These next two are mutually exclusive */
+
+/* is there a symbol table loaded? */
+#define MULTIBOOT_INFO_AOUT_SYMS                0x00000010
+/* is there an ELF section header table? */
+#define MULTIBOOT_INFO_ELF_SHDR                 0X00000020
+
+/* is there a full memory map? */
+#define MULTIBOOT_INFO_MEM_MAP                  0x00000040
+
+/* Is there drive info? */
+#define MULTIBOOT_INFO_DRIVE_INFO               0x00000080
+
+/* Is there a config table? */
+#define MULTIBOOT_INFO_CONFIG_TABLE             0x00000100
+
+/* Is there a boot loader name? */
+#define MULTIBOOT_INFO_BOOT_LOADER_NAME         0x00000200
+
+/* Is there a APM table? */
+#define MULTIBOOT_INFO_APM_TABLE                0x00000400
+
+/* Is there video information? */
+#define MULTIBOOT_INFO_VIDEO_INFO               0x00000800
+
+#ifndef ASM_FILE
+
+typedef unsigned short          multiboot_uint16_t;
+typedef unsigned int            multiboot_uint32_t;
+typedef unsigned long long      multiboot_uint64_t;
+
+struct multiboot_header
+{
+/* Must be MULTIBOOT_MAGIC - see above. */
+	multiboot_uint32_t magic;
+
+/* Feature flags. */
+	multiboot_uint32_t flags;
+
+/* The above fields plus this one must equal 0 mod 2^32. */
+	multiboot_uint32_t checksum;
+
+/* These are only valid if MULTIBOOT_AOUT_KLUDGE is set. */
+	multiboot_uint32_t header_addr;
+	multiboot_uint32_t load_addr;
+	multiboot_uint32_t load_end_addr;
+	multiboot_uint32_t bss_end_addr;
+	multiboot_uint32_t entry_addr;
+
+/* These are only valid if MULTIBOOT_VIDEO_MODE is set. */
+	multiboot_uint32_t mode_type;
+	multiboot_uint32_t width;
+	multiboot_uint32_t height;
+	multiboot_uint32_t depth;
+};
+
+/* The symbol table for a.out. */
+struct multiboot_aout_symbol_table
+{
+	multiboot_uint32_t tabsize;
+	multiboot_uint32_t strsize;
+	multiboot_uint32_t addr;
+	multiboot_uint32_t reserved;
+};
+typedef struct multiboot_aout_symbol_table multiboot_aout_symbol_table_t;
+
+/* The section header table for ELF. */
+struct multiboot_elf_section_header_table
+{
+	multiboot_uint32_t num;
+	multiboot_uint32_t size;
+	multiboot_uint32_t addr;
+	multiboot_uint32_t shndx;
+};
+typedef struct multiboot_elf_section_header_table multiboot_elf_section_header_table_t;
+
+struct multiboot_info
+{
+/* Multiboot info version number */
+	multiboot_uint32_t flags;
+
+/* Available memory from BIOS */
+	multiboot_uint32_t mem_lower;
+	multiboot_uint32_t mem_upper;
+
+/* "root" partition */
+	multiboot_uint32_t boot_device;
+
+/* Kernel command line */
+	multiboot_uint32_t cmdline;
+
+/* Boot-Module list */
+	multiboot_uint32_t mods_count;
+	multiboot_uint32_t mods_addr;
+
+	union
+	{
+		multiboot_aout_symbol_table_t aout_sym;
+		multiboot_elf_section_header_table_t elf_sec;
+	} u;
+
+/* Memory Mapping buffer */
+	multiboot_uint32_t mmap_length;
+	multiboot_uint32_t mmap_addr;
+
+/* Drive Info buffer */
+	multiboot_uint32_t drives_length;
+	multiboot_uint32_t drives_addr;
+
+/* ROM configuration table */
+	multiboot_uint32_t config_table;
+
+/* Boot Loader Name */
+	multiboot_uint32_t boot_loader_name;
+
+/* APM table */
+	multiboot_uint32_t apm_table;
+
+/* Video */
+	multiboot_uint32_t vbe_control_info;
+	multiboot_uint32_t vbe_mode_info;
+	multiboot_uint16_t vbe_mode;
+	multiboot_uint16_t vbe_interface_seg;
+	multiboot_uint16_t vbe_interface_off;
+	multiboot_uint16_t vbe_interface_len;
+};
+typedef struct multiboot_info multiboot_info_t;
+
+struct multiboot_mmap_entry
+{
+	multiboot_uint32_t size;
+	multiboot_uint64_t addr;
+	multiboot_uint64_t len;
+#define MULTIBOOT_MEMORY_AVAILABLE              1
+#define MULTIBOOT_MEMORY_RESERVED               2
+	multiboot_uint32_t type;
+} __attribute__((packed));
+typedef struct multiboot_mmap_entry multiboot_memory_map_t;
+
+struct multiboot_mod_list
+{
+/* the memory used goes from bytes 'mod_start' to 'mod_end-1' inclusive */
+	multiboot_uint32_t mod_start;
+	multiboot_uint32_t mod_end;
+
+/* Module command line */
+	multiboot_uint32_t cmdline;
+
+/* padding to take it to 16 bytes (must be zero) */
+	multiboot_uint32_t pad;
+};
+typedef struct multiboot_mod_list multiboot_module_t;
+
+#endif /* ! ASM_FILE */
+
+#endif /* ! MULTIBOOT_HEADER */


Property changes on: trunk/sys/boot/i386/libi386/multiboot.h
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Added: trunk/sys/boot/i386/libi386/multiboot_tramp.S
===================================================================
--- trunk/sys/boot/i386/libi386/multiboot_tramp.S	                        (rev 0)
+++ trunk/sys/boot/i386/libi386/multiboot_tramp.S	2018-06-01 23:44:37 UTC (rev 10194)
@@ -0,0 +1,52 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2014  Roger Pau Monné <royger at FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR 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 AUTHOR 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.
+ *
+ * $FreeBSD: stable/10/sys/boot/i386/libi386/multiboot_tramp.S 294417 2016-01-20 13:23:02Z royger $
+ */
+
+#define ASM_FILE
+#include "multiboot.h"
+
+/*
+ * The multiboot specification requires the executable to be launched
+ * with %cs set to a flat read/execute segment with offset 0 and limit
+ * 0xFFFFFFFF, and the rest of the segment registers (%ds, %es, %fs,
+ * %gs, %ss) to flat read/write segments with the same offset and limit.
+ * This is already done by the BTX code before calling multiboot_tramp,
+ * so there is no need to do anything here.
+ */
+
+	.globl	multiboot_tramp
+multiboot_tramp:
+	/* Be sure that interrupts are disabled. */
+	cli
+
+	movl    $MULTIBOOT_BOOTLOADER_MAGIC, %eax
+	/* Get the entry point and address of the multiboot_info parameter. */
+	movl	8(%esp), %ebx
+	movl	4(%esp), %ecx
+
+	call    *%ecx


Property changes on: trunk/sys/boot/i386/libi386/multiboot_tramp.S
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: trunk/sys/boot/i386/libi386/pxe.c
===================================================================
--- trunk/sys/boot/i386/libi386/pxe.c	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/libi386/pxe.c	2018-06-01 23:44:37 UTC (rev 10194)
@@ -28,7 +28,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/boot/i386/libi386/pxe.c,v 1.22.18.1 2008/11/25 02:59:29 kensmith Exp $");
+__FBSDID("$FreeBSD: stable/10/sys/boot/i386/libi386/pxe.c 301056 2016-05-31 17:01:54Z ian $");
 
 #include <stand.h>
 #include <string.h>
@@ -89,6 +89,12 @@
 static int	pxe_netif_put(struct iodesc *desc, void *pkt, size_t len);
 static void	pxe_netif_end(struct netif *nif);
 
+#ifdef OLD_NFSV2
+int nfs_getrootfh(struct iodesc*, char*, u_char*);
+#else
+int nfs_getrootfh(struct iodesc*, char*, uint32_t*, u_char*);
+#endif
+
 extern struct netif_stats	pxe_st[];
 extern u_int16_t		__bangpxeseg;
 extern u_int16_t		__bangpxeoff;
@@ -307,6 +313,11 @@
 		    sprintf(temp, "%6D", bootplayer.CAddr, ":");
 		    setenv("boot.netif.hwaddr", temp, 1);
 		}
+		if (intf_mtu != 0) {
+			char mtu[16];
+			sprintf(mtu, "%u", intf_mtu);
+			setenv("boot.netif.mtu", mtu, 1);
+		}
 		setenv("boot.nfsroot.server", inet_ntoa(rootip), 1);
 		setenv("boot.nfsroot.path", rootpath, 1);
 		setenv("dhcp.host-name", hostname, 1);
@@ -356,18 +367,11 @@
 static void
 pxe_print(int verbose)
 {
-	if (pxe_call != NULL) {
-		if (*bootplayer.Sname == '\0') {
-			printf("      "IP_STR":%s\n",
-			       IP_ARGS(htonl(bootplayer.sip)),
-			       bootplayer.bootfile);
-		} else {
-			printf("      %s:%s\n", bootplayer.Sname,
-			       bootplayer.bootfile);
-		}
-	}
 
-	return;
+	if (pxe_call == NULL)
+		return;
+
+	printf("    pxe0:    %s:%s\n", inet_ntoa(rootip), rootpath);
 }
 
 static void

Modified: trunk/sys/boot/i386/libi386/pxe.h
===================================================================
--- trunk/sys/boot/i386/libi386/pxe.h	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/libi386/pxe.h	2018-06-01 23:44:37 UTC (rev 10194)
@@ -28,7 +28,7 @@
  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  * SUCH DAMAGE.
  *
- * $FreeBSD: src/sys/boot/i386/libi386/pxe.h,v 1.6.32.1 2008/11/25 02:59:29 kensmith Exp $
+ * $FreeBSD: stable/10/sys/boot/i386/libi386/pxe.h 240421 2012-09-12 21:00:37Z mav $
  */
 
 /*
@@ -53,15 +53,6 @@
 
 #define	S_SIZE(s)	s, sizeof(s) - 1
 
-#define	IP_STR		"%d.%d.%d.%d"
-#define	IP_ARGS(ip)					\
-	(int)(ip >> 24) & 0xff, (int)(ip >> 16) & 0xff, \
-	(int)(ip >> 8) & 0xff, (int)ip & 0xff
-
-#define	MAC_STR		"%02x:%02x:%02x:%02x:%02x:%02x"
-#define	MAC_ARGS(mac)					\
-	mac[0], mac[1], mac[2], mac[3], mac[4], mac[5] 
-
 #define	PXENFSROOTPATH	"/pxeroot"
 
 typedef struct {

Modified: trunk/sys/boot/i386/libi386/smbios.c
===================================================================
--- trunk/sys/boot/i386/libi386/smbios.c	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/libi386/smbios.c	2018-06-01 23:44:37 UTC (rev 10194)
@@ -26,14 +26,19 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: stable/9/sys/boot/i386/libi386/smbios.c 294852 2016-01-26 21:35:47Z jkim $");
+__FBSDID("$FreeBSD: stable/10/sys/boot/i386/libi386/smbios.c 294981 2016-01-28 12:11:42Z smh $");
 
 #include <stand.h>
 #include <bootstrap.h>
 #include <sys/endian.h>
 
+#ifdef EFI
+/* In EFI, we don't need PTOV(). */
+#define PTOV(x)		(caddr_t)(x)
+#else
 #include "btxv86.h"
-#include "libi386.h"
+#endif
+#include "smbios.h"
 
 /*
  * Detect SMBIOS and export information about the SMBIOS into the
@@ -65,11 +70,25 @@
 #define	SMBIOS_GETLEN(base)	SMBIOS_GET8(base, 0x01)
 #define	SMBIOS_GETSTR(base)	((base) + SMBIOS_GETLEN(base))
 
-static uint32_t	smbios_enabled_memory = 0;
-static uint32_t	smbios_old_enabled_memory = 0;
-static uint8_t	smbios_enabled_sockets = 0;
-static uint8_t	smbios_populated_sockets = 0;
+struct smbios_attr {
+	int		probed;
+	caddr_t 	addr;
+	size_t		length;
+	size_t		count;
+	int		major;
+	int		minor;
+	int		ver;
+	const char*	bios_vendor;
+	const char*	maker;
+	const char*	product;
+	uint32_t	enabled_memory;
+	uint32_t	old_enabled_memory;
+	uint8_t		enabled_sockets;
+	uint8_t		populated_sockets;
+};
 
+static struct smbios_attr smbios;
+
 static uint8_t
 smbios_checksum(const caddr_t addr, const uint8_t len)
 {
@@ -96,8 +115,8 @@
 	return (NULL);
 }
 
-static void
-smbios_setenv(const char *name, caddr_t addr, const int offset)
+static const char*
+smbios_getstring(caddr_t addr, const int offset)
 {
 	caddr_t		cp;
 	int		i, idx;
@@ -107,10 +126,21 @@
 		cp = SMBIOS_GETSTR(addr);
 		for (i = 1; i < idx; i++)
 			cp += strlen(cp) + 1;
-		setenv(name, cp, 1);
+		return cp;
 	}
+	return (NULL);
 }
 
+static void
+smbios_setenv(const char *name, caddr_t addr, const int offset)
+{
+	const char*	val;
+
+	val = smbios_getstring(addr, offset);
+	if (val != NULL)
+		setenv(name, val, 1);
+}
+
 #ifdef SMBIOS_SERIAL_NUMBERS
 
 #define	UUID_SIZE		16
@@ -188,7 +218,7 @@
 #endif
 
 static caddr_t
-smbios_parse_table(const caddr_t addr, const int ver)
+smbios_parse_table(const caddr_t addr)
 {
 	caddr_t		cp;
 	int		proc, size, osize, type;
@@ -207,7 +237,7 @@
 		smbios_setenv("smbios.system.version", addr, 0x06);
 #ifdef SMBIOS_SERIAL_NUMBERS
 		smbios_setenv("smbios.system.serial", addr, 0x07);
-		smbios_setuuid("smbios.system.uuid", addr + 0x08, ver);
+		smbios_setuuid("smbios.system.uuid", addr + 0x08, smbios.ver);
 #endif
 		break;
 
@@ -249,9 +279,9 @@
 		 */
 		proc = SMBIOS_GET8(addr, 0x18);
 		if ((proc & 0x07) == 1)
-			smbios_enabled_sockets++;
+			smbios.enabled_sockets++;
 		if ((proc & 0x40) != 0)
-			smbios_populated_sockets++;
+			smbios.populated_sockets++;
 		break;
 
 	case 6:		/* 3.3.7 Memory Module Information (Type 6, Obsolete) */
@@ -269,7 +299,7 @@
 		 */
 		osize = SMBIOS_GET8(addr, 0x0a) & 0x7f;
 		if (osize > 0 && osize < 22)
-			smbios_old_enabled_memory += 1 << (osize + 10);
+			smbios.old_enabled_memory += 1 << (osize + 10);
 		break;
 
 	case 17:	/* 3.3.18 Memory Device (Type 17) */
@@ -283,7 +313,7 @@
 		 */
 		size = SMBIOS_GET16(addr, 0x0c);
 		if (size != 0 && size != 0xffff)
-			smbios_enabled_memory += (size & 0x8000) != 0 ?
+			smbios.enabled_memory += (size & 0x8000) != 0 ?
 			    (size & 0x7fff) : (size << 10);
 		break;
 
@@ -299,54 +329,120 @@
 	return (cp + 2);
 }
 
-void
-smbios_detect(void)
+static caddr_t
+smbios_find_struct(int type)
 {
-	char		buf[16];
-	caddr_t		addr, dmi, smbios;
-	size_t		count, length;
-	uint32_t	paddr;
-	int		i, major, minor, ver;
+	caddr_t		dmi;
+	size_t		i;
 
+	if (smbios.addr == NULL)
+		return (NULL);
+
+	for (dmi = smbios.addr, i = 0;
+	     dmi < smbios.addr + smbios.length && i < smbios.count; i++) {
+		if (SMBIOS_GET8(dmi, 0) == type)
+			return dmi;
+		/* Find structure terminator. */
+		dmi = SMBIOS_GETSTR(dmi);
+		while (SMBIOS_GET16(dmi, 0) != 0)
+			dmi++;
+		dmi += 2;
+	}
+
+	return (NULL);
+}
+
+static void
+smbios_probe(const caddr_t addr)
+{
+	caddr_t		saddr, info;
+	uintptr_t	paddr;
+
+	if (smbios.probed)
+		return;
+	smbios.probed = 1;
+
 	/* Search signatures and validate checksums. */
-	smbios = smbios_sigsearch(PTOV(SMBIOS_START), SMBIOS_LENGTH);
-	if (smbios == NULL)
+	saddr = smbios_sigsearch(addr ? addr : PTOV(SMBIOS_START),
+	    SMBIOS_LENGTH);
+	if (saddr == NULL)
 		return;
 
-	length = SMBIOS_GET16(smbios, 0x16);	/* Structure Table Length */
-	paddr = SMBIOS_GET32(smbios, 0x18);	/* Structure Table Address */
-	count = SMBIOS_GET16(smbios, 0x1c);	/* No of SMBIOS Structures */
-	ver = SMBIOS_GET8(smbios, 0x1e);	/* SMBIOS BCD Revision */
+	smbios.length = SMBIOS_GET16(saddr, 0x16);	/* Structure Table Length */
+	paddr = SMBIOS_GET32(saddr, 0x18);		/* Structure Table Address */
+	smbios.count = SMBIOS_GET16(saddr, 0x1c);	/* No of SMBIOS Structures */
+	smbios.ver = SMBIOS_GET8(saddr, 0x1e);		/* SMBIOS BCD Revision */
 
-	if (ver != 0) {
-		major = ver >> 4;
-		minor = ver & 0x0f;
-		if (major > 9 || minor > 9)
-			ver = 0;
+	if (smbios.ver != 0) {
+		smbios.major = smbios.ver >> 4;
+		smbios.minor = smbios.ver & 0x0f;
+		if (smbios.major > 9 || smbios.minor > 9)
+			smbios.ver = 0;
 	}
-	if (ver == 0) {
-		major = SMBIOS_GET8(smbios, 0x06); /* SMBIOS Major Version */
-		minor = SMBIOS_GET8(smbios, 0x07); /* SMBIOS Minor Version */
+	if (smbios.ver == 0) {
+		smbios.major = SMBIOS_GET8(saddr, 0x06);/* SMBIOS Major Version */
+		smbios.minor = SMBIOS_GET8(saddr, 0x07);/* SMBIOS Minor Version */
 	}
-	ver = (major << 8) | minor;
+	smbios.ver = (smbios.major << 8) | smbios.minor;
+	smbios.addr = PTOV(paddr);
 
-	addr = PTOV(paddr);
-	for (dmi = addr, i = 0; dmi < addr + length && i < count; i++)
-		dmi = smbios_parse_table(dmi, ver);
+	/* Get system information from SMBIOS */
+	info = smbios_find_struct(0x00);
+	if (info != NULL) {
+		smbios.bios_vendor = smbios_getstring(info, 0x04);
+	}
+	info = smbios_find_struct(0x01);
+	if (info != NULL) {
+		smbios.maker = smbios_getstring(info, 0x04);
+		smbios.product = smbios_getstring(info, 0x05);
+	}
+}
 
-	sprintf(buf, "%d.%d", major, minor);
+void
+smbios_detect(const caddr_t addr)
+{
+	char		buf[16];
+	caddr_t		dmi;
+	size_t		i;
+
+	smbios_probe(addr);
+	if (smbios.addr == NULL)
+		return;
+
+	for (dmi = smbios.addr, i = 0;
+	     dmi < smbios.addr + smbios.length && i < smbios.count; i++)
+		dmi = smbios_parse_table(dmi);
+
+	sprintf(buf, "%d.%d", smbios.major, smbios.minor);
 	setenv("smbios.version", buf, 1);
-	if (smbios_enabled_memory > 0 || smbios_old_enabled_memory > 0) {
-		sprintf(buf, "%u", smbios_enabled_memory > 0 ?
-		    smbios_enabled_memory : smbios_old_enabled_memory);
+	if (smbios.enabled_memory > 0 || smbios.old_enabled_memory > 0) {
+		sprintf(buf, "%u", smbios.enabled_memory > 0 ?
+		    smbios.enabled_memory : smbios.old_enabled_memory);
 		setenv("smbios.memory.enabled", buf, 1);
 	}
-	if (smbios_enabled_sockets > 0) {
-		sprintf(buf, "%u", smbios_enabled_sockets);
+	if (smbios.enabled_sockets > 0) {
+		sprintf(buf, "%u", smbios.enabled_sockets);
 		setenv("smbios.socket.enabled", buf, 1);
 	}
-	if (smbios_populated_sockets > 0) {
-		sprintf(buf, "%u", smbios_populated_sockets);
+	if (smbios.populated_sockets > 0) {
+		sprintf(buf, "%u", smbios.populated_sockets);
 		setenv("smbios.socket.populated", buf, 1);
 	}
 }
+
+static int
+smbios_match_str(const char* s1, const char* s2)
+{
+	return (s1 == NULL || (s2 != NULL && !strcmp(s1, s2)));
+}
+
+int
+smbios_match(const char* bios_vendor, const char* maker,
+    const char* product)
+{
+	/* XXXRP currently, only called from non-EFI. */
+	smbios_probe(NULL);
+	return (smbios_match_str(bios_vendor, smbios.bios_vendor) &&
+	    smbios_match_str(maker, smbios.maker) &&
+	    smbios_match_str(product, smbios.product));
+}

Added: trunk/sys/boot/i386/libi386/smbios.h
===================================================================
--- trunk/sys/boot/i386/libi386/smbios.h	                        (rev 0)
+++ trunk/sys/boot/i386/libi386/smbios.h	2018-06-01 23:44:37 UTC (rev 10194)
@@ -0,0 +1,35 @@
+/* $MidnightBSD$ */
+/*-
+ * Copyright (c) 2015 Rui Paulo <rpaulo at FreeBSD.org>
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
+ *
+ * $FreeBSD: stable/10/sys/boot/i386/libi386/smbios.h 285726 2015-07-20 22:14:55Z allanjude $
+ */
+#ifndef _SMBIOS_H_
+#define	_SMBIOS_H_
+
+void	smbios_detect(const caddr_t);
+int	smbios_match(const char *, const char *, const char *);
+
+#endif /* _SMBIOS_H_ */


Property changes on: trunk/sys/boot/i386/libi386/smbios.h
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: trunk/sys/boot/i386/libi386/time.c
===================================================================
--- trunk/sys/boot/i386/libi386/time.c	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/libi386/time.c	2018-06-01 23:44:37 UTC (rev 10194)
@@ -26,7 +26,7 @@
  */
 
 #include <sys/cdefs.h>
-__FBSDID("$FreeBSD: src/sys/boot/i386/libi386/time.c,v 1.5.28.1 2008/11/25 02:59:29 kensmith Exp $");
+__FBSDID("$FreeBSD: stable/10/sys/boot/i386/libi386/time.c 228782 2011-12-21 16:47:01Z ed $");
 
 #include <stand.h>
 #include <btxv86.h>
@@ -63,7 +63,7 @@
  * Some BIOSes (notably qemu) don't correctly read the RTC
  * registers in an atomic way, sometimes returning bogus values.
  * Therefore we "debounce" the reading by accepting it only when
- * we got two identical values in succession.
+ * we got 8 identical values in succession.
  *
  * If we pass midnight, don't wrap back to 0.
  */
@@ -72,14 +72,16 @@
 {
     static time_t lasttime;
     time_t now, check;
-    int try;
+    int same, try;
 
-    try = 0;
+    same = try = 0;
     check = bios_seconds();
     do {
 	now = check;
 	check = bios_seconds();
-    } while (now != check && ++try < 1000);
+	if (check != now)
+	    same = 0;
+    } while (++same < 8 && ++try < 1000);
 
     if (now < lasttime)
 	now += 24 * 3600;

Index: trunk/sys/boot/i386/mbr/mbr.s
===================================================================
--- trunk/sys/boot/i386/mbr/mbr.s	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/mbr/mbr.s	2018-06-01 23:44:37 UTC (rev 10194)

Property changes on: trunk/sys/boot/i386/mbr/mbr.s
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/sys/boot/i386/pmbr/pmbr.s
===================================================================
--- trunk/sys/boot/i386/pmbr/pmbr.s	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/pmbr/pmbr.s	2018-06-01 23:44:37 UTC (rev 10194)
@@ -28,7 +28,7 @@
 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
 # SUCH DAMAGE.
 #
-# $MidnightBSD: src/sys/boot/i386/pmbr/pmbr.s,v 1.1 2011/10/16 21:11:09 laffer1 Exp $
+# $MidnightBSD$
 # $FreeBSD: src/sys/boot/i386/pmbr/pmbr.s,v 1.2.2.1.2.1 2008/11/25 02:59:29 kensmith Exp $
 #
 # Partly from: src/sys/boot/i386/mbr/mbr.s 1.7


Property changes on: trunk/sys/boot/i386/pmbr/pmbr.s
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Index: trunk/sys/boot/i386/pxeldr/pxeldr.S
===================================================================
--- trunk/sys/boot/i386/pxeldr/pxeldr.S	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/pxeldr/pxeldr.S	2018-06-01 23:44:37 UTC (rev 10194)

Property changes on: trunk/sys/boot/i386/pxeldr/pxeldr.S
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Index: trunk/sys/boot/i386/zfsboot/zfsldr.S
===================================================================
--- trunk/sys/boot/i386/zfsboot/zfsldr.S	2018-06-01 23:38:08 UTC (rev 10193)
+++ trunk/sys/boot/i386/zfsboot/zfsldr.S	2018-06-01 23:44:37 UTC (rev 10194)

Property changes on: trunk/sys/boot/i386/zfsboot/zfsldr.S
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property


More information about the Midnightbsd-cvs mailing list