--- ./usr/src/sys/arch/i386/stand/dosboot/Makefile-dist	Sat Feb 13 11:54:46 1999
+++ ./usr/src/sys/arch/i386/stand/dosboot/Makefile	Tue Jul 20 17:27:47 1999
@@ -1,17 +1,25 @@
 #	$NetBSD: Makefile,v 1.11 1999/02/13 02:54:46 lukem Exp $
 
+# specify default kernel from following
+# FREEBSD, NETBSD, OPENBSD
+KERNEL=FREEBSD
+
 S=	${.CURDIR}/../../../../
 
-BASE= dosboot
+BASE= bsdboot
 PROG= ${BASE}.com
 MKMAN=	no
-NEWVERSWHAT=	"DOS Boot"
+NEWVERSWHAT=	"DOS Boot for *BSD"
+VERSIONFILE=	version
 
-SRCS= main.c devopen.c exec.c
+SRCS= main.c devopen.c exec.c ob_bootarg.c
+# k_exec.c
 
 CLEANFILES+= ${DOSSTART} ${BASE}.sym
 
-CPPFLAGS+= -DCOMPAT_OLDBOOT -DXMS
+CPPFLAGS+= -DCOMPAT_OLDBOOT -DXMS -DANYBSD -DDEFAULT_$(KERNEL)
+CPPFLAGS+= -D__NetBSD__ -D_STANDALONE
+
 #uncomment if there are problems with memory detection
 #CPPFLAGS+= -DCONSERVATIVE_MEMDETECT
 
@@ -20,10 +28,10 @@
 
 # XXX should go into library
 SRCS+= getopt.c ls.c
-.PATH: ${.CURDIR}/../libsa
+.PATH: ${S}arch/i386/stand/libsa
 
 SAMISCCPPFLAGS+= -DHEAP_START=0x10000 -DHEAP_LIMIT=0x40000
 SAMISCMAKEFLAGS= SA_USE_CREAD=yes SA_INCLUDE_NET=no
 I386MISCMAKEFLAGS= I386_INCLUDE_DOS=yes
 
-.include "../Makefile.booters"
+.include "${S}arch/i386/stand/Makefile.booters"
--- ./usr/src/sys/arch/i386/stand/dosboot/main.c-dist	Fri Feb 12 14:14:23 1999
+++ ./usr/src/sys/arch/i386/stand/dosboot/main.c	Tue Jul 20 17:44:41 1999
@@ -43,6 +43,84 @@
 
 #include <libi386.h>
 
+#ifdef ANYBSD
+#include "k_vars.h"
+
+#ifndef DEFAULT_BOOT_KERNEL
+#  if defined(DEFAULT_FREEBSD)
+#    define DEFAULT_BOOT_KERNEL K_FREEBSD
+#  elif defined(DEFAULT_OPENBSD)
+#    define DEFAULT_BOOT_KERNEL K_OPENBSD
+#  else
+#    define DEFAULT_BOOT_KERNEL K_NETBSD
+#  endif
+#endif
+
+#define RBX_MASK	0xffff
+
+/* FreeBSD options */
+#define RBF_ASKNAME	0x0	/* -a */
+#define RBF_SINGLE	0x1	/* -s */
+#define RBF_DFLTROOT	0x5	/* -r */
+#define RBF_KDB 	0x6	/* -d */
+#define RBF_CONFIG	0xa	/* -c */
+#define RBF_VERBOSE	0xb	/* -v */
+#define RBF_SERIAL	0xc	/* -h */
+#define RBF_CDROM	0xd	/* -C */
+#define RBF_GDB 	0xf	/* -g */
+#define RBF_DUAL	0x1d	/* -D */
+#define RBF_PROBEKBD	0x1e	/* -P */
+
+#define NOPTS_FREEBSD		11
+static const char *optstr_freebsd = "DhaCcdgPrsv";
+static const unsigned char flags_freebsd[NOPTS_FREEBSD] = {
+    RBF_DUAL,
+    RBF_SERIAL,
+    RBF_ASKNAME,
+    RBF_CDROM,
+    RBF_CONFIG,
+    RBF_KDB,
+    RBF_GDB,
+    RBF_PROBEKBD,
+    RBF_DFLTROOT,
+    RBF_SINGLE,
+    RBF_VERBOSE
+};
+
+/* NetBSD options */
+#define RBN_ASKNAME	0x0	/* -a */
+#define RBN_SINGLE	0x1	/* -s */
+#define RBN_DFLTROOT	0x5	/* -r */
+#define RBN_KDB 	0x6	/* -d */
+
+#define NOPTS_NETBSD		4
+static const char *optstr_netbsd = "asrd";
+static const unsigned char flags_netbsd[NOPTS_NETBSD] = {
+    RBN_ASKNAME,
+    RBN_SINGLE,
+    RBN_DFLTROOT,
+    RBN_KDB,
+};
+
+/* OpenBSD options */
+#define RBO_ASKNAME	0x0	/* -a */
+#define RBO_HALT	0x3	/* -b */
+#define RBO_CONFIG	0xa	/* -c */
+#define RBO_SINGLE	0x1	/* -s */
+#define RBO_KDB 	0x6	/* -d */
+
+#define NOPTS_OPENBSD		5
+static const char *optstr_openbsd = "abcsd";
+static const unsigned char flags_openbsd[NOPTS_OPENBSD] = {
+    RBO_ASKNAME,
+    RBO_HALT,
+    RBO_CONFIG,
+    RBO_SINGLE,
+    RBO_KDB,
+};
+
+#endif
+
 extern void ls  __P((char *));
 extern int getopt __P((int, char **, const char *));
 
@@ -236,8 +314,68 @@
 void 
 usage()
 {
-	printf("dosboot [-u] [-c <commands>] [-i] [filename [-bootopts]]\n");
+	printf("bsdboot [-u][-c <commands>][-i][-f][-n][-o]
+\t[filename [-bootopts]]\n");
+}
+
+#ifdef ANYBSD
+int anybsd_opts(arg, howto)
+     char *arg;
+     int *howto;
+{
+   int i;
+   char c;
+   int nopts;
+   const char *optstr;
+   const unsigned char *optflags;
+
+   /* skip '-' */
+   while ((c = *++arg) != 0){
+      switch(boot_kernel){
+       case K_OPENBSD:
+	  optstr = optstr_openbsd;
+	  nopts = NOPTS_OPENBSD;
+	  optflags = flags_openbsd;
+	  break;
+       case K_NETBSD:
+	  optstr = optstr_netbsd;
+	  nopts = NOPTS_NETBSD;
+	  optflags = flags_netbsd;
+	  break;
+       case K_FREEBSD:
+       default:
+	  optstr = optstr_freebsd;
+	  nopts = NOPTS_FREEBSD;
+	  optflags = flags_freebsd;
+	  break;
+      }
+      for (i = 0; c != optstr[i]; i++)
+	 if (i == nopts - 1) {
+	    printf("-%c: unknown kernel option\n", c);
+	    printf("valid options are : %s\n", optstr);
+	    return 0;
+	 }
+
+      *howto |= 1 << optflags[i];
+   }
+
+   *howto &= RBX_MASK;
+
+#if 0
+   switch(boot_kernel){
+    case K_FREEBSD:
+       *howto |= RB_BOOTINFO;
+       break;
+    case K_OPENBSD:
+    case K_NETBSD:
+    default:
+       break;
+   }
+#endif
+
+   return 1;
 }
+#endif
 
 int 
 main(argc, argv)
@@ -259,9 +397,20 @@
 	default_devname = "hd";
 	default_unit = 0;
 	default_partition = 0;
+#if DEFAULT_BOOT_KERNEL == K_FREEBSD
+	default_filename = "kernel";
+#elif DEFAULT_BOOT_KERNEL == K_NETBSD
 	default_filename = "netbsd";
+#else
+	default_filename = "bsd";
+#endif
 
+#ifdef ANYBSD
+	boot_kernel = DEFAULT_BOOT_KERNEL;
+	while ((ch = getopt(argc, argv, "c:iufno")) != -1) {
+#else
 	while ((ch = getopt(argc, argv, "c:iu")) != -1) {
+#endif
 		switch (ch) {
 		case 'c':
 			docommand(optarg);
@@ -273,6 +422,17 @@
 		case 'u':
 			current_fsmode = "ufs";
 			break;
+#ifdef ANYBSD
+		case 'f':
+			boot_kernel = K_FREEBSD;
+			break;
+		case 'n':
+			boot_kernel = K_NETBSD;
+			break;
+		case 'o':
+			boot_kernel = K_OPENBSD;
+			break;
+#endif
 		default:
 			usage();
 			return (1);
@@ -292,10 +452,15 @@
 		return (1);
 	}
 	howto = 0;
+#ifdef ANYBSD
+	if (argc > 1 && !anybsd_opts(argv[1], &howto))
+	    return 1;
+#else
 	if (argc > 1 && !parseopts(argv[1], &howto))
 		return (1);
+#endif
 
-	bootit((argc > 0 ? argv[0] : "netbsd"), howto, 1);
+	bootit((argc > 0 ? argv[0] : default_filename), howto, 1);
 	return (1);
 }
 
--- ./usr/src/sys/arch/i386/stand/dosboot/ob_bootarg.c-dist	Sun Jul 18 02:11:15 1999
+++ ./usr/src/sys/arch/i386/stand/dosboot/ob_bootarg.c	Sun Jul 18 02:11:10 1999
@@ -0,0 +1,87 @@
+/*	$OpenBSD: bootarg.c,v 1.5 1998/05/25 19:17:38 mickey Exp $	*/
+
+/*
+ * Copyright (c) 1997,1998 Michael Shalayeff
+ * 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.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by Michael Shalayeff.
+ * 4. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * 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 REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+
+#include <lib/libsa/stand.h>
+#include "ob_bootarg.h"
+
+bootarg_t *bootarg_list;
+
+void
+addbootarg(t, l, p)
+	int t;
+	size_t l;
+	void *p;
+{
+	bootarg_t *q = alloc(sizeof(*q) + l - sizeof(q->ba_arg));
+
+	q->ba_type = t;
+	q->ba_size = sizeof(*q) + l - sizeof(q->ba_arg);
+	bcopy(p, q->ba_arg, l);
+	q->ba_next = bootarg_list;
+	bootarg_list = q;
+}
+
+void
+makebootargs(v, lenp)
+	caddr_t v;
+	size_t *lenp;
+{
+	register bootarg_t *p;
+	register u_char *q;
+	register size_t l;
+
+	/* get total size */
+	l = sizeof(*p);
+	for (p = bootarg_list; p != NULL; p = p->ba_next)
+		l += p->ba_size;
+	if (*lenp < l) {
+#ifdef DEBUG
+		printf("makebootargs: too much args\n");
+#endif
+		l = *lenp;
+	}
+	*lenp = l;
+	/* copy them out */
+	for (p = bootarg_list, q = v;
+	     p != NULL && ((q + p->ba_size) - (u_char*)v) < l;
+	     q += p->ba_size, p = p->ba_next) {
+#ifdef DEBUG
+		printf("%d,%d ", p->ba_type, p->ba_size);
+#endif
+		bcopy(p, q, p->ba_size);
+	}
+	p = (bootarg_t *)q;
+	p->ba_type = BOOTARG_END;
+}
+
--- ./usr/src/sys/arch/i386/stand/dosboot/ob_bootarg.h-dist	Sun Jul 18 02:12:12 1999
+++ ./usr/src/sys/arch/i386/stand/dosboot/ob_bootarg.h	Sun Jul 18 02:12:08 1999
@@ -0,0 +1,61 @@
+/*	$OpenBSD: bootarg.h,v 1.7 1998/12/19 11:35:48 mickey Exp $	*/
+
+/*
+ * Copyright (c) 1996-1998 Michael Shalayeff
+ * 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.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by Michael Shalayeff.
+ * 4. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * 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 REGENTS OR CONTRIBUTORS BE LIABLE
+ * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+ * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+ * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+ * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+ * SUCH DAMAGE.
+ *
+ */
+
+#define	BOOTARG_APIVER	(BAPIV_VECTOR|BAPIV_ENV)
+#define	BAPIV_ANCIENT	0x00000000	/* MD old i386 bootblocks */
+#define	BAPIV_VARS	0x00000001	/* MD structure w/ add info passed */
+#define	BAPIV_VECTOR	0x00000002	/* MI vector of MD structures passed */
+#define	BAPIV_ENV	0x00000004	/* MI environment vars vector */
+#define	BAPIV_BMEMMAP	0x00000008	/* MI memory map passed is in bytes */
+
+typedef struct _boot_args {
+	int ba_type;
+	size_t ba_size;
+	struct _boot_args *ba_next;
+	int ba_arg[1];
+} bootarg_t;
+
+#define	BOOTARG_ENV	0x1000
+#define	BOOTARG_END	-1
+
+#if defined(_KERNEL) || defined(_STANDALONE)
+extern void *bootargv;
+extern int bootargc;                                                     
+extern bootarg_t *bootargp;
+#endif
+
+#ifdef _STANDALONE
+void addbootarg __P((int, size_t, void *));
+void makebootargs __P((caddr_t, size_t *));
+#endif /* _STANDALONE */
--- ./usr/src/sys/arch/i386/stand/dosboot/ob_exec.h-dist	Sun Jul 18 02:12:51 1999
+++ ./usr/src/sys/arch/i386/stand/dosboot/ob_exec.h	Sun Jul 18 02:13:18 1999
@@ -0,0 +1,98 @@
+/*	$OpenBSD: exec.h,v 1.2 1998/07/14 17:21:44 mickey Exp $	*/
+
+/*
+ * Copyright (c) 1998 Michael Shalayeff
+ * 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.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *	This product includes software developed by Michael Shalayeff.
+ * 4. The name of the author may not be used to endorse or promote products
+ *    derived from this software without specific prior written permission.
+ *
+ * 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.
+ */
+
+#ifndef _SA_EXEC_H_
+#define _SA_EXEC_H_
+
+#define	MAX_EXEC_NAME	8
+
+#ifdef	EXEC_AOUT
+#include <sys/exec_aout.h>
+#endif
+#ifdef	EXEC_ECOFF
+#include <sys/exec_ecoff.h>
+#endif
+#ifdef	EXEC_ELF
+#include <sys/exec_elf.h>
+#endif
+#ifdef	EXEC_SOM
+#include <sys/exec_som.h>
+#endif
+
+union x_header {
+#ifdef	EXEC_AOUT
+	struct exec		x_aout;
+#endif
+#ifdef	EXEC_ECOFF
+	struct ecoff_exechdr	x_ecoff;
+#endif
+#ifdef	EXEC_ELF
+	struct elfhdr		x_elf;
+#endif
+#ifdef	EXEC_SOM
+	struct som_filehdr	x_som;
+#endif
+};
+
+struct x_param;
+struct x_sw {
+	char name[MAX_EXEC_NAME];
+	/* returns file position to lseek to */
+	int (*probe) __P((int, union x_header *));
+	/* zero on success */
+	int (*load) __P((int, struct x_param *));
+};
+
+struct x_param {
+	union x_header *xp_hdr;
+	const struct x_sw *xp_execsw;
+	u_int xp_entry, xp_end;
+
+	struct { u_int addr, size, foff; } text, data, bss, sym, str;
+};
+
+extern const struct x_sw execsw[];
+void machdep_exec __P((struct x_param *, int, void *));
+
+int aout_probe __P((int, union x_header *));
+int aout_load __P((int, struct x_param *));
+
+int elf_probe __P((int, union x_header *));
+int elf_load __P((int, struct x_param *));
+
+int ecoff_probe __P((int, union x_header *));
+int ecoff_load __P((int, struct x_param *));
+
+int som_probe __P((int, union x_header *));
+int som_load __P((int, struct x_param *));
+
+#endif /* _SA_EXEC_H_ */
--- ./usr/src/sys/arch/i386/stand/lib/exec.c-dist	Sat Apr 10 02:11:29 1999
+++ ./usr/src/sys/arch/i386/stand/lib/exec.c	Sun Jul 18 16:42:38 1999
@@ -59,6 +59,38 @@
 #include "libi386.h"
 #include "bootinfo.h"
 
+#ifdef ANYBSD
+#include "ob_exec.h"
+#include "ob_bootarg.h"
+#include "k_vars.h"
+
+/*
+ * A zero bootinfo field often means that there is no info available.
+ * Flags are used to indicate the validity of fields where zero is a
+ * normal value.
+ */
+#define	N_BIOS_GEOM		8
+#define	BOOTINFO_VERSION	1
+
+struct fbsd_bootinfo {
+	unsigned long		bi_version;
+	unsigned char		*bi_kernelname;
+	void				*bi_nfs_diskless;
+				/* End of fields that are always present. */
+#define	bi_endcommon		bi_n_bios_used
+	unsigned long		bi_n_bios_used;
+	unsigned long		bi_bios_geom[N_BIOS_GEOM];
+	unsigned long		bi_size;
+	unsigned char		bi_memsizes_valid;
+	unsigned char		bi_pad[3];
+	unsigned long		bi_basemem;
+	unsigned long		bi_extmem;
+	unsigned long		bi_symtab;
+	unsigned long		bi_esymtab;
+};
+struct fbsd_bootinfo	fbsd_bootinfo;
+#endif
+
 #ifdef COMPAT_OLDBOOT
 static int
 dev2major(devname, major)
@@ -77,7 +109,13 @@
 	return (-1);
 }
 #endif
+#ifdef ANYBSD
+#define BOOT_NARGS	8
+#else
 #define BOOT_NARGS	6
+#endif
+
+
 
 extern struct btinfo_console btinfo_console;
 
@@ -189,8 +227,21 @@
 #else
 	boot_argv[1] = 0;
 #endif
-	boot_argv[2] = vtophys(bootinfo);	/* old cyl offset */
-	/* argv[3] below */
+#ifdef ANYBSD
+	switch (boot_kernel) {
+	 case K_OPENBSD:
+		 boot_argv[2] = BOOTARG_APIVER;
+		 /* argv[3] below */
+		 break;
+	 case K_NETBSD:
+		 boot_argv[2] = vtophys(bootinfo);	/* old cyl offset */
+		 /* argv[3] below */
+		 break;
+	}
+#else
+	 boot_argv[2] = vtophys(bootinfo);	/* old cyl offset */
+	 /* argv[3] below */
+#endif
 	boot_argv[4] = extmem;
 	boot_argv[5] = getbasemem();
 
@@ -203,6 +254,29 @@
 	 */
 #ifdef PASS_BIOSGEOM
 	bi_getbiosgeom();
+#ifdef ANYBSD
+	/* for FreeBSD */
+	{
+	   int ret;
+	   struct btinfo_biosgeom *bibg =
+	      (struct btinfo_biosgeom *) bootinfo->entry[bootinfo->nentries -1];
+
+	/* 
+	 * form a longword representing all this gunk:
+	 *       6 bit zero
+	 *	10 bit max cylinder (0 based)
+	 *	 8 bit max head (0 based)
+	 *	 2 bit zero
+	 *	 6 bit max sector (1 based) = # sectors
+	 */
+	   for(ret = 0; ret < N_BIOS_GEOM; ret ++){
+	      fbsd_bootinfo.bi_bios_geom[ret] =
+		 ((bibg->disk[ret].cyl & 0x3ff) << 16) |
+		 ((bibg->disk[ret].head & 0xff) << 8) |
+		 (bibg->disk[ret].sec & 0x3f);
+	   }
+	}
+#endif
 #endif
 #ifdef PASS_MEMMAP
 	bi_getmemmap();
@@ -238,6 +312,44 @@
 	btinfo_symtab.esym = marks[MARK_END];
 	BI_ADD(&btinfo_symtab, BTINFO_SYMTAB, sizeof(struct btinfo_symtab));
 
+#ifdef ANYBSD
+	switch (boot_kernel) {
+	 case K_OPENBSD:
+	    {
+#define	BOOTARG_LEN	(NBPG*1)
+#define	BOOTARG_OFF	(NBPG)
+		 size_t ac = BOOTARG_LEN;
+		 caddr_t av = (caddr_t)BOOTARG_OFF;
+
+		 makebootargs(av, &ac);
+		 boot_argv[6] = ac;
+		 boot_argv[7] = (int) av;
+	    }
+		 break;
+
+	 case K_FREEBSD:
+		 {
+			 char *name = "kernel";
+
+		 fbsd_bootinfo.bi_basemem = getbasemem();
+		 fbsd_bootinfo.bi_extmem = extmem;
+		 fbsd_bootinfo.bi_memsizes_valid = 1;
+		 fbsd_bootinfo.bi_symtab = marks[MARK_SYM];
+		 fbsd_bootinfo.bi_esymtab = marks[MARK_END];
+
+		 fbsd_bootinfo.bi_version = BOOTINFO_VERSION;
+		 fbsd_bootinfo.bi_kernelname = (unsigned char *) vtophys(name);
+		 fbsd_bootinfo.bi_nfs_diskless = 0;
+		 fbsd_bootinfo.bi_size = sizeof(fbsd_bootinfo);
+
+		 boot_argv[2] = 0; 
+		 boot_argv[3] = 0; 
+		 boot_argv[4] = 0; 
+		 boot_argv[5] = vtophys(&fbsd_bootinfo);
+		 }
+		 break;
+	}
+#endif
 	startprog(marks[MARK_ENTRY], BOOT_NARGS, boot_argv, 0x90000);
 	panic("exec returned");
 
--- ./usr/src/sys/arch/i386/stand/lib/loadfile.c-dist	Tue Apr 20 00:30:25 1999
+++ ./usr/src/sys/arch/i386/stand/lib/loadfile.c	Tue Jul 20 21:07:23 1999
@@ -274,8 +274,8 @@
 	size_t sz;
 	int first;
 	int havesyms;
-	paddr_t minp = ~0, maxp = 0, pos;
-	paddr_t offset = marks[MARK_START], shpp, elfp;
+	paddr_t minp = ~0, maxp = 0, pos = 0;
+	paddr_t offset = marks[MARK_START], shpp, elfp = 0;
 
 	for (first = 1, i = 0; i < elf->e_phnum; i++) {
 		Elf_Phdr phdr;
--- ./usr/src/sys/arch/i386/stand/newvers.sh-dist	Sat Jul 26 10:50:38 1997
+++ ./usr/src/sys/arch/i386/stand/newvers.sh	Sun Jul 18 02:47:54 1999
@@ -38,7 +38,7 @@
 u=${USER-root} h=`hostname` t=`date`
 r=`head -n 6 $1 | tail -n 1 | awk -F: ' { print $1 } '`
 
-echo "char bootprog_name[] = \"NetBSD/i386 ${2}\";" > vers.c
+echo "char bootprog_name[] = \"`uname`/i386 ${2}\";" > vers.c
 echo "char bootprog_rev[] = \"${r}\";" >> vers.c
 echo "char bootprog_date[] = \"${t}\";" >> vers.c
 echo "char bootprog_maker[] = \"${u}@${h}\";" >> vers.c
