summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorTobias Weingartner <weingart@cvs.openbsd.org>1997-04-04 17:23:32 +0000
committerTobias Weingartner <weingart@cvs.openbsd.org>1997-04-04 17:23:32 +0000
commit7d0780fa95d78e4f0a3a01bd1a9bf5745a0fe5dd (patch)
treedecaa805cdbb4a67e774b96643eed57edacd436d /sys
parent0e9e1f1e991347ffd7894188634d9ebe8a6004db (diff)
Replace exec_i386.S with these two files. Startprog.S is a
stopgap measure, to be removed once I get locore.s done.
Diffstat (limited to 'sys')
-rw-r--r--sys/arch/i386/stand/libsa/exec_i386.c79
-rw-r--r--sys/arch/i386/stand/libsa/startprog.S48
2 files changed, 127 insertions, 0 deletions
diff --git a/sys/arch/i386/stand/libsa/exec_i386.c b/sys/arch/i386/stand/libsa/exec_i386.c
new file mode 100644
index 00000000000..0cf8f40987a
--- /dev/null
+++ b/sys/arch/i386/stand/libsa/exec_i386.c
@@ -0,0 +1,79 @@
+
+/* $OpenBSD: exec_i386.c,v 1.4 1997/04/04 17:23:29 weingart Exp $ */
+
+#include <sys/param.h>
+#include <sys/exec.h>
+#include <sys/reboot.h>
+#include <libsa.h>
+
+#include <biosdev.h>
+int startprog(void *, void *);
+static int bootdev;
+
+void
+machdep_start(startaddr, howto, loadaddr, ssym, esym)
+ char *startaddr, *loadaddr, *ssym, *esym;
+ int howto;
+{
+ static int argv[9];
+ struct exec *x;
+
+
+#ifdef DEBUG
+ x = (void *)loadaddr;
+ printf("exec {\n");
+ printf(" a_midmag = %lx\n", x->a_midmag);
+ printf(" a_text = %lx\n", x->a_text);
+ printf(" a_data = %lx\n", x->a_data);
+ printf(" a_bss = %lx\n", x->a_bss);
+ printf(" a_syms = %lx\n", x->a_syms);
+ printf(" a_entry = %lx\n", x->a_entry);
+ printf(" a_trsize = %lx\n", x->a_trsize);
+ printf(" a_drsize = %lx\n", x->a_drsize);
+ printf("}\n");
+
+ getchar();
+#endif
+
+ (int)startaddr &= 0xffffff;
+
+ /*
+ * We now pass the various bootstrap parameters to the loaded
+ * image via the argument list
+ *
+ * arg0 = 8 (magic)
+ * arg1 = boot flags
+ * arg2 = boot device
+ * arg3 = start of symbol table (0 if not loaded)
+ * arg4 = end of symbol table (0 if not loaded)
+ * arg5 = transfer address from image
+ * arg6 = transfer address for next image pointer
+ * arg7 = conventional memory size (640)
+ * arg8 = extended memory size (8196)
+ */
+ argv[0] = 8;
+ argv[1] = howto;
+ argv[2] = bootdev;
+ argv[3] = (int)ssym;
+ argv[4] = (int)esym;
+ argv[5] = (int)startaddr;
+ argv[6] = 0;
+ argv[7] = biosmem(0);
+ argv[8] = biosmem(1);
+
+#ifdef DEBUG
+ { int i;
+ for(i = 0; i <= argv[0]; i++)
+ printf("argv[%d] = %x\n", i, argv[i]);
+
+ getchar();
+ }
+#endif
+
+ /****************************************************************/
+ /* copy that first page and overwrite any BIOS variables */
+ /****************************************************************/
+ printf("entry point at 0x%x\n", (int)startaddr);
+ startprog(startaddr, argv);
+}
+
diff --git a/sys/arch/i386/stand/libsa/startprog.S b/sys/arch/i386/stand/libsa/startprog.S
new file mode 100644
index 00000000000..b8e248f561f
--- /dev/null
+++ b/sys/arch/i386/stand/libsa/startprog.S
@@ -0,0 +1,48 @@
+/* $OpenBSD: startprog.S,v 1.4 1997/04/04 17:23:31 weingart Exp $ */
+
+#include <machine/asm.h>
+
+
+/*
+ * startprog(phyaddr, argv)
+ * start the program on protected mode where phyaddr is the entry point
+ */
+ENTRY(startprog)
+ pushl %ebp
+ movl %esp, %ebp
+
+ # get things we need into registers
+ movl 8(%ebp), %ecx # entry offset
+ movl 12(%ebp), %eax # &argv
+
+ # make a new stack at 0:0x90000 (big segs)
+ movl $0x10, %ebx
+ movw %bx, %ss
+ movl $0x90000, %ebx
+ movl %ebx, %esp
+
+ # push some number of args onto the stack
+ pushl 28(%eax) # argv[7] = cnvmem
+ pushl 32(%eax) # argv[8] = extmem
+ pushl 16(%eax) # argv[4] = esym
+ pushl 12(%eax) # argv[3] = cyl offset
+ pushl 8(%eax) # argv[2] = bootdev
+ pushl 4(%eax) # argv[1] = howto
+ pushl $0 # dummy 'return' address
+
+ # push on our entry address
+ movl $0x8, %ebx # segment
+ pushl %ebx
+ pushl %ecx
+
+ # convert over the other data segs
+ movl $0x10, %ebx
+ movl %bx, %ds
+ movl %bx, %es
+ movl %bx, %ss
+ movl %bx, %fs
+ movl %bx, %gs
+
+ # convert the PC (and code seg)
+ lret
+