summaryrefslogtreecommitdiff
path: root/sys/arch/i386/stand/boot
diff options
context:
space:
mode:
Diffstat (limited to 'sys/arch/i386/stand/boot')
-rw-r--r--sys/arch/i386/stand/boot/Makefile19
-rw-r--r--sys/arch/i386/stand/boot/boot.80
-rw-r--r--sys/arch/i386/stand/boot/boot.c130
-rw-r--r--sys/arch/i386/stand/boot/cmd.c325
-rw-r--r--sys/arch/i386/stand/boot/cmd.h53
-rw-r--r--sys/arch/i386/stand/boot/conf.c92
-rw-r--r--sys/arch/i386/stand/boot/crt0.c115
-rw-r--r--sys/arch/i386/stand/boot/srt0.S258
-rw-r--r--sys/arch/i386/stand/boot/version.c2
9 files changed, 994 insertions, 0 deletions
diff --git a/sys/arch/i386/stand/boot/Makefile b/sys/arch/i386/stand/boot/Makefile
new file mode 100644
index 00000000000..3b3532fc083
--- /dev/null
+++ b/sys/arch/i386/stand/boot/Makefile
@@ -0,0 +1,19 @@
+# $OpenBSD: Makefile,v 1.2 1997/03/31 03:12:02 weingart Exp $
+
+PROG= boot
+SRCS= srt0.S boot.c cmd.c conf.c version.c
+CFLAGS=-I${.CURDIR}/../../../../lib/libsa -I${.CURDIR}/../libsa
+AFLAGS+=-DREL=$(REL) #-Wa,-a
+CFLAGS+=-Wall -O
+LDFLAGS=-Wl,-T$(REL),-x,-z -e start_boot
+LDFLAGS+=-static -nostdlib
+MAN= boot.8
+
+LDADD= -L../libsa -lsa -L../libz -lz
+DPADD= ../libsa/libsa.a ../libz/libz.a
+
+.include <bsd.prog.mk>
+
+.ifdef NO_NET
+CPPFLAGS+=-DNO_NET
+.endif
diff --git a/sys/arch/i386/stand/boot/boot.8 b/sys/arch/i386/stand/boot/boot.8
new file mode 100644
index 00000000000..e69de29bb2d
--- /dev/null
+++ b/sys/arch/i386/stand/boot/boot.8
diff --git a/sys/arch/i386/stand/boot/boot.c b/sys/arch/i386/stand/boot/boot.c
new file mode 100644
index 00000000000..5770f608d53
--- /dev/null
+++ b/sys/arch/i386/stand/boot/boot.c
@@ -0,0 +1,130 @@
+/* $OpenBSD: boot.c,v 1.2 1997/03/31 03:12:03 weingart Exp $ */
+/*
+ * Copyright (c) 1997 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 <sys/param.h>
+#include <sys/reboot.h>
+#include <sys/stat.h>
+#include <a.out.h>
+#include <sys/disklabel.h>
+#include <libsa.h>
+#include "cmd.h"
+
+/*
+ * Boot program, loaded by boot block from remaing 7.5K of boot area.
+ * Sifts through disklabel and attempts to load an program image of
+ * a standalone program off the disk. If keyboard is hit during load,
+ * or if an error is encounter, try alternate files.
+ */
+
+char *kernels[] = {
+ "bsd", "bsd.gz",
+ "obsd", "obsd.gz",
+ "bsd.old", "bsd.old.gz",
+ NULL
+};
+
+int retry = 0;
+extern char version[];
+extern dev_t bootdev;
+extern int boothowto;
+int cnvmem, extmem, probemem;
+
+void boot ();
+struct cmd_state cmd;
+
+/*
+ * Boot program... loads /boot out of filesystem indicated by arguements.
+ * We assume an autoboot unless we detect a misconfiguration.
+ */
+void
+boot()
+{
+ register char *bootfile = kernels[0];
+ register int i;
+
+
+ /* Get memory size */
+ cnvmem = memsize(0);
+ extmem = memsize(1);
+ gateA20(1);
+ probemem = memprobe();
+
+
+ /* XXX init cmd here to cut on .data !!! */
+ strncpy(cmd.bootdev,
+#ifdef _TEST
+ "/dev/rfd0a",
+#else
+ "fd(0,a)",
+#endif
+ sizeof(cmd.bootdev));
+ cmd.image[0] = '\0';
+ cmd.cwd[0] = '/';
+ cmd.cwd[1] = '\0';
+ cmd.addr = (void *)0x100000;
+ cmd.timeout = 50000;
+
+ printf("\n>> OpenBSD BOOT: %d/%d (%d) k [%s]\n",
+ cnvmem, extmem, probemem, version);
+
+ for (i = 0;;) {
+
+ strncpy(cmd.image, bootfile, sizeof(cmd.image));
+
+ do {
+ printf("boot> ");
+ } while(!getcmd(&cmd) && !execmd(&cmd));
+
+ sprintf(cmd.path, "%s%s%s", cmd.bootdev, cmd.cwd, bootfile);
+ printf("\nbooting %s: ", cmd.path);
+ exec (cmd.path, cmd.addr, boothowto);
+
+ if(kernels[++i] == NULL)
+ bootfile = kernels[i=0];
+ else
+ bootfile = kernels[i];
+
+ cmd.timeout += 20;
+
+ printf(" failed(%d)\nwill try %s\n", errno, bootfile);
+ }
+}
+
+#ifdef _TEST
+int
+main()
+{
+ boot();
+ return 0;
+}
+#endif
diff --git a/sys/arch/i386/stand/boot/cmd.c b/sys/arch/i386/stand/boot/cmd.c
new file mode 100644
index 00000000000..f6d2aa39a9f
--- /dev/null
+++ b/sys/arch/i386/stand/boot/cmd.c
@@ -0,0 +1,325 @@
+/* $OpenBSD: cmd.c,v 1.1 1997/03/31 03:12:03 weingart Exp $ */
+
+/*
+ * Copyright (c) 1997 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 <sys/param.h>
+#include <string.h>
+#include <libsa.h>
+#include "cmd.h"
+
+static struct cmd_table {
+ char *cmd_name;
+ int cmd_id;
+} cmd_table[] = {
+ {"addr", CMD_ADDR},
+ {"boot", CMD_BOOT},
+ {"cd", CMD_CD},
+ {"device", CMD_DEVICE},
+ {"help", CMD_HELP},
+ {"image", CMD_IMAGE},
+ {"ls", CMD_LS},
+ {"nope", CMD_NOPE},
+ {"reboot", CMD_REBOOT},
+ {"set", CMD_SET},
+ {NULL, 0},
+};
+
+extern char version[];
+void ls __P((char *, register struct stat *));
+char skipblnk __P((void));
+
+char cmd_buf[133];
+
+int
+getcmd(cmd)
+ register struct cmd_state *cmd;
+{
+ register struct cmd_table *ct = cmd_table;
+ register char *p = cmd_buf; /* input */
+ register char ch;
+ int len;
+
+ cmd->rc = 0;
+ cmd->argc = 1;
+
+ for (len = cmd->timeout; len-- && !ischar(); );
+
+ if (len < 0) {
+ cmd->cmd = CMD_BOOT;
+ cmd->argv[0] = cmd_table[CMD_BOOT].cmd_name;
+ cmd->argv[1] = NULL;
+ return 0;
+ }
+
+ ch = skipblnk();
+
+ for (len = 0; ch != '\n' &&
+ ch != ' ' && ch != '\t'; len++, ch = getchar())
+ *p++ = ch;
+ *p = '\0';
+
+ if (len == 0 && ch == '\n') {
+ cmd->cmd = CMD_NOPE;
+ return 0;
+ }
+
+ while (ct->cmd_name != NULL &&
+ strncmp(cmd_buf, ct->cmd_name, len))
+ ct++;
+
+ if (ct->cmd_name == NULL) {
+ cmd->cmd = CMD_ERROR;
+ cmd->argv[0] = ct->cmd_name;
+ return 0;
+ }
+
+ cmd->cmd = ct->cmd_id;
+ cmd->argv[0] = ct->cmd_name;
+ if (ct->cmd_name != NULL) {
+ while (ch != '\n') {
+
+ ch = skipblnk();
+
+ if (ch != '\n') {
+ cmd->argv[cmd->argc] = p;
+ *p++ = ch;
+ for (len = 0; (ch = getchar()) != '\n' &&
+ ch != ' ' && ch != '\t'; len++)
+ *p++ = ch;
+ *p++ = '\0';
+ if (len != 0)
+ cmd->argc++;
+ }
+ }
+ cmd->argv[cmd->argc] = NULL;
+ }
+
+ return cmd->rc;
+}
+
+char
+skipblnk()
+{
+ register char ch;
+
+ /* skip blanks */
+ while ((ch = getchar()) != '\n' &&
+ (ch == ' ' || ch == '\t'));
+
+ return ch;
+}
+
+int
+execmd(cmd)
+ register struct cmd_state *cmd;
+{
+ struct stat sb;
+ int fd;
+ register char *p, *q;
+ register struct cmd_table *ct;
+
+ cmd->rc = 0;
+
+ switch (cmd->cmd) {
+
+ case CMD_HELP:
+ printf("commands: ");
+ for (ct = cmd_table; ct->cmd_name != NULL; ct++)
+ printf(" %s", ct->cmd_name);
+ putchar('\n');
+ break;
+
+ case CMD_DEVICE:
+ if (cmd->argc != 2)
+ printf("device: device name required\n");
+ else {
+ strncpy(cmd->bootdev, cmd->argv[1],
+ sizeof(cmd->bootdev));
+ }
+ break;
+
+ case CMD_IMAGE:
+ if (cmd->argc != 2)
+ printf("image: pathname required\n");
+ else {
+ strncpy(cmd->image, cmd->argv[1],
+ sizeof(cmd->image));
+ }
+ break;
+
+ case CMD_ADDR:
+ if (cmd->argc != 2)
+ printf("addr: address required\n");
+ else {
+ register u_long a;
+
+ p = cmd->argv[1];
+ if (p[0] == '0' && p[1] == 'x')
+ p += 2;
+ for (a = 0; *p != '\0'; p++) {
+ a <<= 4;
+ a |= (isdigit(*p)? *p - '0':
+ 10 + tolower(*p) - 'a') & 0xf;
+ }
+
+ cmd->addr = (void *)a;
+ }
+ break;
+
+ case CMD_LS:
+ {
+ q = cmd->argv[1] == NULL? "." : cmd->argv[1];
+ sprintf(cmd->path, "%s%s%s",
+ cmd->bootdev, cmd->cwd, q);
+
+ if (stat(cmd->path, &sb) < 0) {
+ printf("stat(%s): %d\n", cmd->path, errno);
+ break;
+ }
+
+ if ((sb.st_mode & S_IFMT) != S_IFDIR)
+ ls(q, &sb);
+ else {
+ if ((fd = opendir(cmd->path)) < 0) {
+ printf ("opendir(%s): %d\n",
+ cmd->path, errno);
+ break;
+ }
+
+ p = cmd->path + strlen(cmd->path);
+ *p++ = '/';
+ *p = '\0';
+
+ while(readdir(fd, p) >= 0 && *p != '\0') {
+
+ if (stat(cmd->path, &sb) < 0) {
+ printf("stat(%s): %d\n",
+ cmd->path, errno);
+ break;
+ }
+ ls(p, &sb);
+ }
+
+ closedir (fd);
+ }
+ }
+ break;
+
+ case CMD_CD:
+ if (cmd->argc == 1) {
+ cmd->cwd[0] = '/';
+ cmd->cwd[1] = '\0';
+ break;
+ }
+
+ if (cmd->argv[1][0] == '.' && cmd->argv[1][1] == '\0')
+ break;
+
+ if (cmd->argv[1][0] == '.' && cmd->argv[1][1] == '.'
+ && cmd->argv[1][2] == '\0') {
+ /* strrchr(cmd->cwd, '/'); */
+ for (p = cmd->cwd; *++p;);
+ for (p--; *--p != '/';);
+ p[1] = '\0';
+ break;
+ }
+
+ sprintf(cmd->path, "%s%s%s",
+ cmd->bootdev, cmd->cwd, cmd->argv[1]);
+ if (stat(cmd->path, &sb) < 0) {
+ printf("stat(%s): %d\n", cmd->argv[1], errno);
+ break;
+ }
+
+ if (!S_ISDIR(sb.st_mode)) {
+ printf("boot: %s: not a dir\n", cmd->argv[1]);
+ break;
+ }
+
+ /* change dir */
+ for (p = cmd->cwd; *p; p++);
+ for (q = cmd->argv[1]; (*p++ = *q++) != '\0';);
+ if (p[-2] != '/') {
+ p[-1] = '/';
+ p[0] = '\0';
+ }
+ break;
+
+ case CMD_SET:
+ printf("OpenBSD boot version %s\n"
+ "device:\t%s\n"
+ "cwd:\t%s\n"
+ "image:\t%s\n"
+ "load at:\t%p\n"
+ "timeout:\t%d\n",
+ version, cmd->bootdev, cmd->cwd, cmd->image,
+ cmd->addr, cmd->timeout);
+ break;
+
+ case CMD_REBOOT:
+ exit(1);
+ break;
+
+ case CMD_BOOT:
+ return 1;
+ break;
+
+ case CMD_ERROR:
+ default:
+ printf ("%s: invalid command\n", cmd->argv[0]);
+ case CMD_NOPE:
+ break;
+ }
+
+ return cmd->rc;
+}
+
+#define lsrwx(mode,s) \
+ putchar ((mode) & S_IROTH? 'r' : '-'); \
+ putchar ((mode) & S_IWOTH? 'w' : '-'); \
+ putchar ((mode) & S_IXOTH? *(s): (s)[1]);
+
+void
+ls(name, sb)
+ char *name;
+ register struct stat *sb;
+{
+ putchar("-fc-d-b---l-s-w-"[(sb->st_mode & S_IFMT) >> 12]);
+ lsrwx(sb->st_mode >> 6, (sb->st_mode & S_ISUID? "sS" : "x-"));
+ lsrwx(sb->st_mode >> 3, (sb->st_mode & S_ISUID? "sS" : "x-"));
+ lsrwx(sb->st_mode , (sb->st_mode & S_ISTXT? "tT" : "x-"));
+
+ printf (" %s\tuid=%u\tgid=%u\t%lu\n", name, sb->st_uid, sb->st_gid,
+ (u_long)sb->st_size);
+}
+
diff --git a/sys/arch/i386/stand/boot/cmd.h b/sys/arch/i386/stand/boot/cmd.h
new file mode 100644
index 00000000000..35f3d58348a
--- /dev/null
+++ b/sys/arch/i386/stand/boot/cmd.h
@@ -0,0 +1,53 @@
+/* $OpenBSD: cmd.h,v 1.1 1997/03/31 03:12:03 weingart Exp $ */
+
+/*
+ * Copyright (c) 1997 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.
+ *
+ */
+
+struct cmd_state {
+ char bootdev[16]; /* device */
+ char image[32]; /* image */
+ char cwd[MAXPATHLEN - 32 - 32];
+ void *addr; /* load here */
+ int timeout;
+ char path[MAXPATHLEN]; /* buffer for pathname compose */
+
+ enum { CMD_ADDR, CMD_BOOT, CMD_CD, CMD_DEVICE, CMD_HELP,
+ CMD_IMAGE, CMD_LS, CMD_NOPE, CMD_REBOOT, CMD_SET,
+ CMD_ERROR /* last !!! */ };
+ int cmd;
+ int argc;
+ char *argv[8]; /* XXX i hope this is enough */
+ int rc;
+};
+
+int getcmd __P((register struct cmd_state *));
+int execmd __P((register struct cmd_state *));
diff --git a/sys/arch/i386/stand/boot/conf.c b/sys/arch/i386/stand/boot/conf.c
new file mode 100644
index 00000000000..70a07c6494b
--- /dev/null
+++ b/sys/arch/i386/stand/boot/conf.c
@@ -0,0 +1,92 @@
+/* $OpenBSD: conf.c,v 1.2 1997/03/31 03:12:04 weingart Exp $ */
+
+/*
+ * Copyright (c) 1996 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 <sys/types.h>
+#include <netinet/in.h>
+#include <libsa.h>
+#include <ufs.h>
+#include <nfs.h>
+#include <cd9660.h>
+#include <netif.h>
+#include "biosdev.h"
+#include "unixdev.h"
+
+int debug = 1;
+
+struct fs_ops file_system[] = {
+ { ufs_open, ufs_close, ufs_read, ufs_write, ufs_seek,
+ ufs_stat, ufs_readdir },
+#ifdef notdef
+ { fat_open, fat_close, fat_read, fat_write, fat_seek,
+ fat_stat, fat_readdir },
+ { cd9660_open, cd9660_close, cd9660_read, cd9660_write, cd9660_seek,
+ cd9660_stat, cd9660_readdir },
+#endif
+#ifndef NO_NET
+ { nfs_open, nfs_close, nfs_read, nfs_write, nfs_seek,
+ nfs_stat, nfs_readdir },
+#endif
+#ifdef _TEST
+ { null_open, null_close, null_read, null_write, null_seek,
+ null_stat, null_readdir }
+#endif
+};
+int nfsys = NENTS(file_system);
+
+struct devsw devsw[] = {
+#ifdef _TEST
+ { "UNIX", unixstrategy, unixopen, unixclose, unixioctl },
+#else
+ { "BIOS", biosstrategy, biosopen, biosclose, biosioctl },
+#endif
+};
+int ndevs = NENTS(devsw);
+
+#ifndef NO_NET
+struct netif_driver *netif_drivers[] = {
+ NULL
+};
+int n_netif_drivers = NENTS(netif_drivers);
+#endif
+
+struct consw consw[] = {
+#ifdef _TEST
+ { "unix",unix_probe,unix_putc,unix_getc,unix_ischar},
+#else
+ { "kbd", kbd_probe, kbd_putc, kbd_getc, kbd_ischar },
+ { "com", com_probe, com_putc, com_getc, com_ischar },
+#endif
+};
+int ncons = NENTS(consw);
+
diff --git a/sys/arch/i386/stand/boot/crt0.c b/sys/arch/i386/stand/boot/crt0.c
new file mode 100644
index 00000000000..14802aeb187
--- /dev/null
+++ b/sys/arch/i386/stand/boot/crt0.c
@@ -0,0 +1,115 @@
+/* $OpenBSD: crt0.c,v 1.1 1997/03/31 03:12:04 weingart Exp $ */
+
+/*
+ * Copyright (c) 1997 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 <sys/param.h>
+#include <sys/types.h>
+#include <sys/mman.h>
+#include <sys/syscall.h>
+#include <termios.h>
+#include "libsa.h"
+#include "unixdev.h"
+
+extern void start __P((void)) asm("start");
+extern int main __P((int, char **, char **));
+static void domap __P((void));
+static void seterm __P((void));
+
+void
+start()
+{
+ domap();
+ seterm();
+ uexit(main(0, NULL, NULL));
+}
+
+#define ummap(a,l,p,f,fd,o) (caddr_t)syscall((quad_t)SYS_mmap,a,l,p,f,fd,0,o)
+
+static void
+domap()
+{
+ extern char end[];
+ register caddr_t p = (caddr_t)(((u_long)end + PGOFSET) & ~PGOFSET);
+ register size_t sz = 0x10000 - (u_long)p - NBPG;
+
+#ifdef DEBUG
+ /* we are low on memory w/ the DEBUG defined ); */
+ sz = 40 * NBPG;
+#endif
+
+ /* map heap */
+ if ( (p = ummap(p, sz, PROT_READ|PROT_WRITE,
+ MAP_FIXED|MAP_ANON, -1, 0)) == (caddr_t)-1) {
+ printf("mmap failed: %d\n", errno);
+ uexit(1);
+ }
+#ifdef DEBUG
+ else
+ printf("mmap==%p\n", p);
+#endif
+
+ /* map kernel */
+ if ( (p = ummap(0x100000, 0xf00000, PROT_READ|PROT_WRITE,
+ MAP_FIXED|MAP_ANON, -1, 0)) == (caddr_t)-1) {
+ printf("mmap failed: %d\n", errno);
+ uexit(1);
+ }
+#ifdef DEBUG
+ else
+ printf("mmap==%p\n", p);
+#endif
+
+}
+
+void
+seterm()
+{
+ struct termios tc;
+
+ if (uioctl(0, TIOCGETA, (char *)&tc) < 0) {
+ printf("cannot get tty\n");
+ uexit(1);
+ }
+
+ tc.c_iflag &= ~(IGNBRK|BRKINT|PARMRK|ISTRIP|INLCR|IGNCR|ICRNL|IXON);
+ tc.c_oflag &= ~OPOST;
+ tc.c_lflag &= ~(ECHO|ECHONL|ICANON|ISIG|IEXTEN);
+ tc.c_cflag &= ~(CSIZE|PARENB);
+ tc.c_cflag |= CS8;
+
+ if (uioctl(0, TIOCSETA, (char *)&tc) < 0) {
+ printf("cannot set tty\n");
+ uexit(1);
+ }
+}
diff --git a/sys/arch/i386/stand/boot/srt0.S b/sys/arch/i386/stand/boot/srt0.S
new file mode 100644
index 00000000000..923a47aeecf
--- /dev/null
+++ b/sys/arch/i386/stand/boot/srt0.S
@@ -0,0 +1,258 @@
+/* $OpenBSD: srt0.S,v 1.1 1997/03/31 03:12:05 weingart Exp $ */
+/* $NetBSD: srt0.c,v 1.3 1994/10/27 04:21:59 cgd Exp $ */
+
+/*-
+ * Copyright (c) 1990 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * William Jolitz.
+ *
+ * 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 the University of
+ * California, Berkeley and its contributors.
+ * 4. Neither the name of the University nor the names of its contributors
+ * may be used to endorse or promote products derived from this software
+ * without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+ * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * 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.
+ *
+ * @(#)srt0.c 5.3 (Berkeley) 4/28/91
+ */
+
+/*
+ * Startup code for standalone system
+ * Non-relocating version -- for programs which are loaded by boot
+ * Relocating version for boot
+ * Small relocating version for "micro" boot
+ */
+
+#include <machine/psl.h>
+#define _LOCORE
+#include <machine/segments.h>
+#undef _LOCORE
+
+ .globl _end
+ .globl _edata
+ .globl _boot
+ .globl __rtt
+
+ .data
+ .globl _Gdtr
+ .align 2
+_Gdtr: .word 4 * 8 - 1
+ .long 2f
+ .align 3
+2: /* 0x00 : null */
+ .long 0, 0
+ /* 0x08 : flat code */
+ .word 0xFFFF # lolimit
+ .word 0 # lobase
+ .byte 0 # midbase
+ .byte SDT_MEMERAC | 0 | 0x80 # RWXAC, dpl = 0, present
+ .byte 0xf | 0 | 0x40 | 0x80 # hilimit, xx, 32bit, 4k granularity
+ .byte 0 # hibase
+ /* 0x10 : flat data */
+ .word 0xFFFF # lolimit
+ .word 0 # lobase
+ .byte 0 # midbase
+ .byte SDT_MEMRWA | 0 | 0x80 # RWA, dpl = 0, present
+ .byte 0xf | 0 | 0x40 | 0x80 # hilimit, xx, 32bit, 4k granularity
+ .byte 0 # hibase
+ /* 0x18 : 16 bit code */
+ .word 0xFFFF # lolimit
+ .word 0 # lobase
+ .byte 0 # midbase
+ .byte SDT_MEMERC | 0 | 0x80 # RWXAC, dpl = 0, present
+ .byte 0x0 | 0 | 0 | 0 # hilimit, xx, 16bit, byte granularity
+ .byte 0 # hibase
+
+ .globl _codeseg
+ .globl _bootdev
+ .globl _boothowto
+ .globl _cyloffset
+_codeseg: .long 0
+_bootdev: .long 0
+_boothowto: .long 0
+_cyloffset: .long 0
+_esym: .long 0
+
+ .text
+text_start:
+
+#define NOP inb $0x84,%al ; inb $0x84,%al
+
+ .globl start_boot
+
+start_boot:
+ pushl %ebp
+ movl %esp, %ebp
+
+#ifdef REL
+ /* relocate code+data */
+ call 1f
+1: popl %esi
+ subl $1b, %esi
+ addl $text_start, %esi /* %esi = %eip - (1b - text_start) */
+ subl $0x20, %esi /* XXX - Fudge factor for header */
+ movl $REL, %edi
+ movl $_edata, %ecx
+ subl $text_start, %ecx
+ shrl $2, %ecx
+ incl %ecx
+ cld
+ rep
+ movsl
+#endif /* REL */
+
+ lgdt _Gdtr
+
+ /* The following should *not* be moved before the lgdt.
+ * Trust me, bad things will happen!
+ * Start executing from relocated code
+ */
+ movl $0x10, %eax
+ movl %eax, %ds
+ movl %eax, %es
+ movl %eax, %fs
+ movl %eax, %gs
+ movl %eax, %ss
+ ljmp $0x8,$docs
+docs:
+ nop
+
+ /* XXX - I don't know if the following is right */
+ movl 8(%ebp), %eax
+ movl %eax, _boothowto
+ movl 12(%ebp),%eax
+ movl %eax, _bootdev
+ movl 16(%ebp),%eax
+ movl %eax, _cyloffset
+ movl 20(%ebp),%eax
+ movl %eax, _esym
+
+ /* save old stack state */
+ movl %esp,savearea
+ movl %ebp,savearea+4
+
+ /* setup stack pointer */
+#ifdef REL
+ movl $0xfffc, %esp
+#else
+ movl $_end, %eax
+ addl $10000, %eax
+ movl %eax, %esp
+#endif
+
+ /* clear memory as needed */
+ movl %esp,%esi
+ movl $_end, %eax
+ subl $_edata,%eax
+ pushl %eax
+ pushl $0
+ pushl $_edata
+ call _memset
+ #call _kbdreset /* resets keyboard and gatea20 brain damage */
+ movl %esi,%esp
+
+ pushl __rtt
+ ljmp $0x8, $_boot /* Jmp to boot code */
+
+ .data
+
+savearea: .long 0,0 # sp & bp to return to
+
+ .text
+
+__rtt:
+ movl $-7,%eax
+#ifdef REL
+ movw $0x1234,%ax
+ movw %ax,0x472 # warm boot
+ movl $0,%esp # segment violation
+ ret
+#else
+ movl savearea,%esp
+ movl savearea+4,%ebp
+ ret
+#endif
+
+ .globl _inb
+_inb: movl 4(%esp),%edx
+ subl %eax,%eax # clr eax
+ NOP
+ inb %dx,%al
+ ret
+
+ .globl _outb
+_outb: movl 4(%esp),%edx
+ NOP
+ movl 8(%esp),%eax
+ outb %al,%dx
+ ret
+
+ .globl ___udivsi3
+___udivsi3:
+ movl 4(%esp),%eax
+ xorl %edx,%edx
+ divl 8(%esp)
+ ret
+
+ .globl ___divsi3
+___divsi3:
+ movl 4(%esp),%eax
+ xorl %edx,%edx
+ cltd
+ idivl 8(%esp)
+ ret
+
+ .globl _insw
+_insw:
+ pushl %edi
+ movw 8(%esp),%dx
+ movl 12(%esp),%edi
+ movl 16(%esp),%ecx
+ NOP
+ cld
+ nop
+ .byte 0x66,0xf2,0x6d # rep insw
+ nop
+ movl %edi,%eax
+ popl %edi
+ ret
+
+ # outsw(port,addr,cnt)
+ .globl _outsw
+_outsw:
+ pushl %esi
+ movw 8(%esp),%dx
+ movl 12(%esp),%esi
+ movl 16(%esp),%ecx
+ NOP
+ cld
+ nop
+ .byte 0x66,0xf2,0x6f # rep outsw
+ nop
+ movl %esi,%eax
+ popl %esi
+ ret
+
diff --git a/sys/arch/i386/stand/boot/version.c b/sys/arch/i386/stand/boot/version.c
new file mode 100644
index 00000000000..78ecc804998
--- /dev/null
+++ b/sys/arch/i386/stand/boot/version.c
@@ -0,0 +1,2 @@
+
+char version[] = "1.0";