diff options
author | Dale Rahn <drahn@cvs.openbsd.org> | 2003-04-17 03:43:20 +0000 |
---|---|---|
committer | Dale Rahn <drahn@cvs.openbsd.org> | 2003-04-17 03:43:20 +0000 |
commit | 6bb480fd6df5d8e084142751e0b25183459561d6 (patch) | |
tree | baf77d01ee85f750e1cf66d7c3c5fd85b7b5bc07 /sys/arch/i386/stand/boot | |
parent | d36015cb7ad92f7024a5754fc18618f0b0e13139 (diff) |
i386 ELF bootloader. developed with weingart@
Diffstat (limited to 'sys/arch/i386/stand/boot')
-rw-r--r-- | sys/arch/i386/stand/boot/Makefile | 14 | ||||
-rw-r--r-- | sys/arch/i386/stand/boot/conf.c | 8 | ||||
-rw-r--r-- | sys/arch/i386/stand/boot/srt0.S | 44 |
3 files changed, 44 insertions, 22 deletions
diff --git a/sys/arch/i386/stand/boot/Makefile b/sys/arch/i386/stand/boot/Makefile index d306ee0f6f3..d3b62e77fb3 100644 --- a/sys/arch/i386/stand/boot/Makefile +++ b/sys/arch/i386/stand/boot/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.29 2000/10/19 17:14:01 fgsch Exp $ +# $OpenBSD: Makefile,v 1.30 2003/04/17 03:43:18 drahn Exp $ .include "${.CURDIR}/../Makefile.inc" @@ -15,12 +15,12 @@ LDFLAGS+=-nostdlib -Bstatic CLEANFILES+= srt0.o SRCS= crt0.c .else -LDFLAGS+=-Ttext $(LINKADDR) -z -x +LDFLAGS+=-Ttext $(LINKADDR) -N -x -noinhibit-exec CLEANFILES+= crt0.o SRCS= srt0.S .endif -SRCS+= boot.c cmd.c vars.c bootarg.c conf.c +SRCS+= boot_loadfile.c cmd.c vars.c bootarg.c conf.c S =${.CURDIR}/../../../.. SADIR= ${.CURDIR}/.. @@ -29,9 +29,12 @@ DPADD= ${LIBSA} ${LIBZ} .PATH: ${S}/stand/boot +boot.bin: boot + objcopy -v -O binary ${PROG} boot.bin + ${PROG}: $(OBJS) $(DPADD) - $(LD) $(LDFLAGS) -o $(PROG) $(OBJS) $(LDADD) - @$(SIZE) $(PROG) + $(LD) $(LDFLAGS) -o ${PROG} $(OBJS) $(LDADD) + @$(SIZE) ${PROG} .else NOPROG= @@ -40,6 +43,7 @@ NOPROG= .include <bsd.prog.mk> CPPFLAGS+=-DBOOTMAGIC=$(BOOTMAGIC) ${DEBUGFLAGS} +CPPFLAGS+=-DLINKADDR=${LINKADDR} CFLAGS+=$(SACFLAGS) #AFLAGS+=-Wa,-R # AFLAGS+=-Wa,-a diff --git a/sys/arch/i386/stand/boot/conf.c b/sys/arch/i386/stand/boot/conf.c index 4a55c8a80a5..3be0b2704cb 100644 --- a/sys/arch/i386/stand/boot/conf.c +++ b/sys/arch/i386/stand/boot/conf.c @@ -1,4 +1,4 @@ -/* $OpenBSD: conf.c,v 1.19 2002/06/21 21:02:57 weingart Exp $ */ +/* $OpenBSD: conf.c,v 1.20 2003/04/17 03:43:18 drahn Exp $ */ /* * Copyright (c) 1996 Michael Shalayeff @@ -48,13 +48,9 @@ #include <dev/cons.h> #include <lib/libsa/exec.h> -const char version[] = "1.29"; +const char version[] = "2.00"; int debug = 1; -const struct x_sw execsw[] = { - { "aout", aout_probe, aout_load, aout_ldsym }, - { "", NULL, NULL, NULL }, -}; struct fs_ops file_system[] = { { ufs_open, ufs_close, ufs_read, ufs_write, ufs_seek, diff --git a/sys/arch/i386/stand/boot/srt0.S b/sys/arch/i386/stand/boot/srt0.S index f8498632e56..b835bfa5e9a 100644 --- a/sys/arch/i386/stand/boot/srt0.S +++ b/sys/arch/i386/stand/boot/srt0.S @@ -1,4 +1,4 @@ -/* $OpenBSD: srt0.S,v 1.10 1998/05/14 20:59:12 mickey Exp $ */ +/* $OpenBSD: srt0.S,v 1.11 2003/04/17 03:43:18 drahn Exp $ */ /* * Copyright (c) 1997 Michael Shalayeff @@ -32,33 +32,55 @@ * */ #include <machine/asm.h> +#include <assym.h> + +#define BOOTSTACK 0xfffc .globl _C_LABEL(end) .globl _C_LABEL(edata) .globl _C_LABEL(boot) .globl _C_LABEL(_rtt) .globl _ASM_LABEL(pmm_init) + .globl Gdtr .text - .globl start -start: + .code16 + .globl _start +_start: + popl %eax + cmpl $BOOTMAGIC, %eax + je 1f #ifdef DEBUG movl $0xb80a0, %ebx movl $0x07420742, (%ebx) #endif +1: + popl %edx + cli + pushl %cs + popl %ds + addr32 data32 lgdt (Gdtr - LINKADDR) + movl %cr0, %eax + orl $CR0_PE, %eax + data32 movl %eax, %cr0 + data32 ljmp $8, $1f +1: + .code32 + movl $0x10,%eax + mov %ax,%ds + mov %ax,%ss + mov %ax,%es + mov %ax,%fs + mov %ax,%gs + movl $BOOTSTACK,%esp + pushl %edx + + /* Now do it all */ call _ASM_LABEL(pmm_init) #ifdef DEBUG movl $0xb80a4, %ebx movl $0x07520752, (%ebx) #endif - popl %eax - cmpl $BOOTMAGIC, %eax - je 1f -#ifdef DEBUG - movl $0xb80a8, %ebx - movl $0xcf41cf4d, (%ebx) -#endif -1: /* zero .bss */ xorl %eax, %eax movl $_C_LABEL(end), %ecx |