Pantek Library
Hosting Provided By
CybrHost
High Speed Hosting

Next x86 biosboot/boot diff

From: Tobias Weingartner <weingart(at)natasha.tepid.org>
Date: Tue Jan 28 2003 - 05:07:14 EST


This is the next step in the move to an LBA enabled /boot system. These diffs are to move the real->prot switch into /boot (from biosboot), saving us some very much needed bytes within biosboot. Note, the biosboot and /boot image always go together in lockstep. IE: an old /boot and a newer biosboot will not play nice (especially after you apply these patches). The same is true for an old biosboot, and new /boot.

I need people to test this. So far I've tested on 4 different machines, and they all work. However, daemons lurk in these waters... the more people that can apply this diff, build, install, and then copy a new /boot, and installboot this, the better.

Basic steps:

Apply diff.
cd /sys/arch/i386/stand
make obj && make && make install
cp /usr/mdec/boot /boot
/usr/mdec/installboot -v /boot /usr/mdec/biosboot wd0

Adjust as necessary to your configuration.

Please send results, comments, flames, whatever my way.

--Toby.
PS: Diff also available at
http://www.tepid.org/~weingart/OpenBSD/i386-next.diff PPS: You may wish to have a boot floppy handy, just in case.

Index: biosboot/biosboot.S



RCS file: /cvs/src/sys/arch/i386/stand/biosboot/biosboot.S,v retrieving revision 1.32
diff -u -r1.32 biosboot.S
--- biosboot/biosboot.S	28 Aug 2002 20:15:34 -0000	1.32
+++ biosboot/biosboot.S	28 Jan 2003 09:50:40 -0000
@@ -39,7 +39,7 @@
#define addr32 .byte 0x67
#define data32 .byte 0x66
 
-#define	BLKCNT	12
+#define	BLKCNT	55
 

#define BOOTSEG 0x07c0 /* boot loaded here */
#define BOOTSTACK 0xfffc /* stack starts here */
@@ -212,52 +212,16 @@ putc('P')

#endif
 
  • /* change to protected mode */
  • /* guarantee that interrupts are disabled when in prot mode */
  • cli -
  • /* load the gdtr */
  • addr32 + /* Push disk #, and magic */ + movzbl %dl, %eax /* drive number is in the lowest byte */ data32
  • lgdt Gdtr -
  • /* set the PE bit of CR0 */
  • movl %cr0, %eax + pushl %eax data32
  • orl $CR0_PE, %eax
  • movl %eax, %cr0 + pushl $BOOTMAGIC /* use some magic */
  • /*
  • * make intrasegment jump to flush the processor pipeline and
  • * reload CS register
  • */ + /* jmp to /boot */ data32
  • ljmp $8, $(BOOTSEG << 4) + 1f - -1: /*
  • * 32bit mode
  • * set up %ds, %ss, %es, etc
  • */
  • movl $0x10, %eax
  • movl %ax, %ds
  • movl %ax, %ss
  • movl %ax, %es
  • movl %ax, %fs
  • movl %ax, %gs
  • movl $BOOTSTACK, %esp - -#ifdef BDEBUG
  • movl $0xb8004, %ebx
  • movl $0x074f0747, (%ebx) -#endif -
  • movzbl %dl, %eax /* drive number is in the lowest byte */
  • pushl %eax
  • pushl $BOOTMAGIC /* use some magic */ -
  • /* jmp /boot */
  • ljmp $8, $(LOADADDR + 0x20)
  • /* not reached */ + ljmp $(LOADADDR >> 4), $0x20
Do you need help?X

 /*

  • Display string @@ -305,26 +269,6 @@ data32 popl %eax ret - - .align 3 -1: /* 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 -Gdtr: .word . - 1b - .long (BOOTSEG << 4) + 1b

         .globl _block_table, _block_count
 _block_count:
Index: boot/Makefile



RCS file: /cvs/src/sys/arch/i386/stand/boot/Makefile,v retrieving revision 1.29
diff -u -r1.29 Makefile
--- boot/Makefile	19 Oct 2000 17:14:01 -0000	1.29
+++ boot/Makefile	28 Jan 2003 09:50:40 -0000
@@ -40,6 +40,7 @@
 .include <bsd.prog.mk>  

 CPPFLAGS+=-DBOOTMAGIC=$(BOOTMAGIC) ${DEBUGFLAGS} +CPPFLAGS+=-DLINKADDR=${LINKADDR}
 CFLAGS+=$(SACFLAGS)
#AFLAGS+=-Wa,-R
# AFLAGS+=-Wa,-a

Index: boot/srt0.S



RCS file: /cvs/src/sys/arch/i386/stand/boot/srt0.S,v retrieving revision 1.10
diff -u -r1.10 srt0.S
--- boot/srt0.S	14 May 1998 20:59:12 -0000	1.10
+++ boot/srt0.S	28 Jan 2003 09:50:40 -0000
@@ -32,33 +32,92 @@
  *
  */
#include <machine/asm.h>
+#include 
+
+#define addr32	.byte 0x67
+#define data32	.byte 0x66
+#define BOOTSTACK	0xfffc	/* stack starts here */
 
 	.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:
+	data32
+	popl	%eax
+	data32
+	cmpl	$BOOTMAGIC, %eax
+	je	1f
+#ifdef DEBUG
+	movl	$0xb80a8, %ebx
+	movl	$0xcf41cf4d, (%ebx)

+#endif
+1:
#ifdef DEBUG
 	movl	$0xb80a0, %ebx
 	movl	$0x07420742, (%ebx)

#endif
+ /* Save disk while we switch */ + data32 + popl %edx + + /* guarantee that interrupts are disabled when in prot mode */ + cli + + /* Setup ds == cs, such that lgdt will work */ + pushl %cs + popl %ds + + /* change to protected mode */ + /* load the gdtr */ + addr32 + data32 + lgdt (Gdtr - LINKADDR) + + /* set the PE bit of CR0 */ + movl %cr0, %eax + data32 + orl $CR0_PE, %eax + movl %eax, %cr0 + + /* + * make intrasegment jump to flush the processor pipeline and + * reload CS register + */ + data32 + ljmp $8, $1f + +1: /* + * 32bit mode + * set up %ds, %ss, %es, etc + */ + movl $0x10, %eax + movl %ax, %ds + movl %ax, %ss + movl %ax, %es + movl %ax, %fs + movl %ax, %gs + movl $BOOTSTACK, %esp + +#ifdef BDEBUG + movl $0xb8004, %ebx + movl $0x074f0747, (%ebx) +#endif + + /* Restore disk # on stack */ + pushl %edx + + /* Now do the real thing */ call _ASM_LABEL(pmm_init)
Do you need more help?X

#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

Index: libsa/gidt.S

RCS file: /cvs/src/sys/arch/i386/stand/libsa/gidt.S,v retrieving revision 1.24
diff -u -r1.24 gidt.S
--- libsa/gidt.S	17 Sep 2001 13:10:09 -0000	1.24
+++ libsa/gidt.S	28 Jan 2003 09:50:40 -0000
@@ -276,7 +276,8 @@
 	.byte	0xf | 0 | 0 | 0		# hilimit, xx, 16bit, byte granularity
 	.byte	(LINKADDR >> 20) & 0xff	# hibase
 
-Gdtr:	.word	. - gdt - 1
+	.globl	Gdtr
+Gdtr:	.word	. - gdt
 	.long	gdt
 	.word	0
Received on Tue Jan 28 05:08:28 2003

This archive was generated by hypermail 2.1.8 : Wed Aug 23 2006 - 13:48:29 EDT


Contact Us  Legal Notices  Order Services Online 
Pantek Home  Privacy Policy  IT news  Site Map  Pantek Library