diff options
author | Theo de Raadt <deraadt@cvs.openbsd.org> | 1998-04-03 19:09:19 +0000 |
---|---|---|
committer | Theo de Raadt <deraadt@cvs.openbsd.org> | 1998-04-03 19:09:19 +0000 |
commit | 234537e527e73a7398b289c222243f3233889556 (patch) | |
tree | 1fa29ce29fc6e4ddf17a5936878ad533f4c769f1 /sys/arch/i386/stand/biosboot | |
parent | d3c4b7110243603a323a397c0e39c4b347949a5d (diff) |
new changes from weingart: -DDEBUG not needed anymore
Diffstat (limited to 'sys/arch/i386/stand/biosboot')
-rw-r--r-- | sys/arch/i386/stand/biosboot/Makefile | 4 | ||||
-rw-r--r-- | sys/arch/i386/stand/biosboot/biosboot.S | 116 |
2 files changed, 55 insertions, 65 deletions
diff --git a/sys/arch/i386/stand/biosboot/Makefile b/sys/arch/i386/stand/biosboot/Makefile index 48881421d33..0dd1fd90b4a 100644 --- a/sys/arch/i386/stand/biosboot/Makefile +++ b/sys/arch/i386/stand/biosboot/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.12 1998/03/30 07:00:28 deraadt Exp $ +# $OpenBSD: Makefile,v 1.13 1998/04/03 19:09:16 deraadt Exp $ PROG= biosboot SRCS= biosboot.S @@ -23,5 +23,5 @@ ${PROG}: $(OBJS) $(DPADD) .include <bsd.prog.mk> CPPFLAGS+=-DLOADADDR=$(LOADADDR) -DBOOTMAGIC=$(BOOTMAGIC) -DBOOTREL=$(BOOTREL) -CPPFLAGS+=${DEBUGFLAGS} -DBEMBR -DDEBUG +CPPFLAGS+=${DEBUGFLAGS} -DBEMBR #AFLAGS+=-Wa,-a diff --git a/sys/arch/i386/stand/biosboot/biosboot.S b/sys/arch/i386/stand/biosboot/biosboot.S index 96eaa646fb3..cc998793057 100644 --- a/sys/arch/i386/stand/biosboot/biosboot.S +++ b/sys/arch/i386/stand/biosboot/biosboot.S @@ -1,7 +1,7 @@ -/* $OpenBSD: biosboot.S,v 1.23 1998/03/30 07:00:29 deraadt Exp $ */ +/* $OpenBSD: biosboot.S,v 1.24 1998/04/03 19:09:18 deraadt Exp $ */ /* - * Copyright (c) 1997 Michael Shalayeff + * Copyright (c) 1997 Michael Shalayeff, Tobias Weingartner * All rights reserved. * * Redistribution and use in source and binary forms, with or without @@ -39,31 +39,28 @@ #define addr32 .byte 0x67 #define data32 .byte 0x66 -#define BLKCNT 12 /* Max without colliding with the partition table */ +#define BLKCNT 14 /* Max without colliding with the partition table */ #define BOOTSEG 0x07c0 /* boot loaded here */ #define BOOTSTACK 0xfffc /* stack starts here */ #define ZMAGIC 0x0b01 /* ZMAGIC */ -#ifdef DEBUG -#define DBGMSG(msg) \ - movb $msg, %al; \ + +/* Clobbers %al - maybe more */ +#define putc(c) \ + movb $c, %al; \ .byte 0xe8; \ .word Lchr - . - 2 -#define GO_RELOC 'R' /* running relocated code */ -#define REAL2PROT 'P' /* switch to protected mode */ -#else /* !DEBUG */ -#define DBGMSG(msg) /* */ -#endif /* !DEBUG */ + +/* Clobbers %esi - maybe more */ #define puts(s) \ - data32; \ + data32; \ movl $s, %esi; \ - /* call Lmessage */; \ .byte 0xe8; \ .word Lmessage - . - 2 - .text + .text .globl start start: jmp 1f @@ -96,46 +93,31 @@ ebpb: .long 16 /* hidden sectors */ /* boot code */ . = start + 0x3e -1: /* set up stack (%ss:%esp) */ +1: + /* Fix up %cs just in case */ + data32 + ljmp $BOOTSEG, $1f + +load_msg: + .asciz "reading boot" + +1: + /* set up stack (%ss:%esp) */ cli /* disable interrupts w/o stack */ - # movw $(BOOTREL >> 4), %ax - .byte 0xb8 - .word BOOTREL >> 4 + xorl %ax, %ax movl %ax, %ss - movl %ax, %es /* relocate there */ data32 movl $BOOTSTACK, %esp sti /* we have stack, do ints */ - # movw $BOOTSEG, %ax /* we are here */ + /* Set up other segment regs */ + # movw $BOOTSEG, %ax .byte 0xb8 .word BOOTSEG movl %ax, %ds - xorl %si, %si - xorl %di, %di - # movw $0x100, %cx /* 512 bytes to move */ - .byte 0xb9 - .word 0x100 - cld - rep; movsl - - /* jump to relocated code */ - data32 - ljmp $(BOOTREL >> 4), $2f -1: .asciz "loading /boot" - -2: DBGMSG(GO_RELOC) - - nop - /* set up %ds */ - pushl %cs - popl %ds - - /* set up %es, (where we will load /boot to) */ - # movw $(LOADADDR >> 4), %ax - .byte 0xb8 - .word LOADADDR >> 4 movl %ax, %es + movl %ax, %fs + movl %ax, %gs #ifdef SERIAL # Initialize the serial port to 9600 baud, 8N1. @@ -149,7 +131,19 @@ ebpb: .long 16 /* hidden sectors */ int $0x14 popl %dx #endif - puts(1b) + +#ifdef DEBUG + putc('R') +#endif + + /* Print pretty message */ + puts(load_msg) + + /* set up %es, (where we will load /boot to) */ + # movw $(LOADADDR >> 4), %ax + .byte 0xb8 + .word LOADADDR >> 4 + movl %ax, %es data32 xorl %ebx, %ebx /* put it at %es:0 */ @@ -179,10 +173,7 @@ ebpb: .long 16 /* hidden sectors */ 2: .asciz "\r\nRead error\r\n" 3: /* read next block */ - movb $'.', %al - # call Lchr /* show progress indicator */ - .byte 0xe8 - .word Lchr - . - 2 + putc('.') /* show progress indicator */ popl %ax movzbl %al, %ax @@ -208,17 +199,16 @@ halt: hlt 1: .ascii "Bad magic" 2: .asciz "\r\n" -3: -#if notdef - data32;es;lodsl /* text size */ - data32;es;lodsl /* data size */ - data32;es;lodsl /* bss size */ - data32;es;lodsl /* syms size */ -#endif - data32 - addl 16(%esi), %edi /* entry */ - DBGMSG(REAL2PROT) +3: /* At this point we could try to use the entry point in + * the image we just loaded. But if we do that, we also + * have to potentially support loading that image where it + * is supposed to go. Screw it, just assume that the image + * is sane. + */ +#ifdef DEBUG + putc('P') +#endif /* change to protected mode */ /* guarantee that interrupts are disabled when in prot mode */ @@ -240,11 +230,11 @@ halt: * reload CS register */ data32 - ljmp $8, $1f+BOOTREL + ljmp $8, $(BOOTSEG << 4) + 1f 1: /* * 32bit mode - * set up %ds, %ss, %es + * set up %ds, %ss, %es, etc */ movw $0x10, %eax movl %ax, %ds @@ -332,7 +322,7 @@ Lchr: .byte 0xf | 0 | 0x40 | 0x80 # hilimit, xx, 32bit, 4k granularity .byte 0 # hibase Gdtr: .word . - 1b - .long BOOTREL + 1b + .long (BOOTSEG << 4) + 1b .globl _block_table, _block_count _block_count: @@ -341,7 +331,7 @@ _block_table: .word 0 /* cylinder/sector */ .byte 0 /* head */ .byte 0 /* nsect */ - # . = _block_table + BLKCNT*4 + . = _block_table + BLKCNT*4 #ifdef BEMBR . = 0x1b8 |