summaryrefslogtreecommitdiff
path: root/sys/arch/i386/boot
diff options
context:
space:
mode:
authorMichael Shalayeff <mickey@cvs.openbsd.org>1996-05-18 10:33:15 +0000
committerMichael Shalayeff <mickey@cvs.openbsd.org>1996-05-18 10:33:15 +0000
commite98b0cfc0036ca76305a467161b62514314f509c (patch)
tree85b1209567c8f43b6b420bbf55b0f79fd47c74cb /sys/arch/i386/boot
parent8f3378dcaa59f27b8b82e9f992609d74c940a7c7 (diff)
do boot from active partition.
this tested w/ DOS(win95), and BSD.
Diffstat (limited to 'sys/arch/i386/boot')
-rw-r--r--sys/arch/i386/boot/Makefile5
-rw-r--r--sys/arch/i386/boot/start.S110
2 files changed, 85 insertions, 30 deletions
diff --git a/sys/arch/i386/boot/Makefile b/sys/arch/i386/boot/Makefile
index 0ccde521bb7..e272ec29953 100644
--- a/sys/arch/i386/boot/Makefile
+++ b/sys/arch/i386/boot/Makefile
@@ -49,6 +49,11 @@ OBJS= start.o table.o boot.o asm.o bios.o io.o disk.o sys.o version.o
boot: ${OBJS}
${LD} -Bstatic -e start -N -T 0 -o boot ${OBJS}
cp boot boot.sym
+ @if [ `size boot | awk 'BEGIN {getline} {print $$1+$$2}'` -gt 7680 ];\
+ then \
+ echo BOOT BLOCKS ARE TOO BIG;\
+ fail;\
+ fi
@strip boot
@sh ${.CURDIR}/rmaouthdr boot boot.tmp
@mv -f boot.tmp boot
diff --git a/sys/arch/i386/boot/start.S b/sys/arch/i386/boot/start.S
index 288c75326ad..5efeafc340e 100644
--- a/sys/arch/i386/boot/start.S
+++ b/sys/arch/i386/boot/start.S
@@ -1,6 +1,9 @@
+/* $OpenBSD: start.S,v 1.3 1996/05/18 10:33:14 mickey Exp $ */
/* $NetBSD: start.S,v 1.12 1995/01/18 17:34:18 mycroft Exp $ */
-/*
+/*-
+ *
+ * Changes by Michael Shalayeff May 1996
* Ported to boot 386BSD by Julian Elischer (julian@tfs.com) Sept 1992
*
* Mach Operating System
@@ -55,7 +58,7 @@ WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
#define addr32 .byte 0x67
#define data32 .byte 0x66
-BOOTSEG = 0x0100 # boot will be loaded here (below 640K)
+BOOTSEG = 0x1000 # boot will be loaded here (below 640K)
BOOTSTACK = 0xfffc # boot stack
SIGNATURE = 0xaa55
LOADSZ = 15 # size of unix boot
@@ -103,21 +106,22 @@ start1:
popl %edx
#endif
-#ifdef DEBUG
+#ifdef FDDEBUG
data32
movl $one, %esi
data32
call message
#endif
-
+#if !defined(NOFD) && !defined(NOHD)
# bootstrap passes us drive number in %dl
cmpb $0x80, %dl
data32
jae hd
-
+#endif
+#ifndef NOFD
fd:
# reset the disk system
-#ifdef DEBUG
+#ifdef FDDEBUG
data32
movl $two, %esi
data32
@@ -125,7 +129,7 @@ fd:
#endif
movb $0x00, %ah
int $0x13
-#ifdef DEBUG
+#ifdef FDDEBUG
data32
movl $three, %esi
data32
@@ -138,7 +142,8 @@ fd:
movb $0x00, %dl
data32
jmp load
-
+#endif
+#ifndef NOHD
hd: /**** load sector 0 into the BOOTSEG ****/
#ifdef DEBUG
data32
@@ -151,28 +156,20 @@ hd: /**** load sector 0 into the BOOTSEG ****/
xorl %ebx, %ebx # %bx = 0
data32
movl $0x0001, %ecx
-#ifdef DEBUG
- data32
- movl $five, %esi
- data32
- call message
-#endif
data32
andl $0xff, %edx
- /*mov $0x0080, %edx*/
int $0x13
data32
jb read_error
- /***# find the first 386BSD partition *****/
+ /***# find the first active partition *****/
data32
movl $PARTSTART, %ebx
data32
movl $NUMPART, %ecx
again:
addr32
- movb %es:4(%ebx), %al
- cmpb $BSDPART, %al
+ cmpb $BOOTABLE, %es:(%ebx)
data32
je found
data32
@@ -183,13 +180,13 @@ again:
movl $enoboot, %esi
data32
jmp err_stop
+#endif
#else /* !DOSREAD */
- movb $0xff, %dl
- jmp _C_LABEL(boot2)
-#endif /* DOSREAD */
+ movb $0xff, %dl
+ jmp _C_LABEL(boot2)
+#endif /* DOSREAD */
-#ifndef DOSREAD
/*
# BIOS call "INT 0x13 Function 0x2" to read sectors from disk into memory
# Call with %ah = 0x2
@@ -202,25 +199,74 @@ again:
# Return:
# %al = 0x0 on success; err code on failure
*/
-
+#ifndef NOHD
found:
addr32
movb %es:1(%ebx), %dh /* head */
addr32
movl %es:2(%ebx), %ecx /*sect, cyl (+ 2 bytes junk in top word) */
+ data32
+ pushl %ecx
+
+ addr32
+ movb %es:4(%ebx), %al
+ cmpb $BSDPART, %al
+ je loadbsd
+
+ # set up %ds
+ movl %cs, %ax
+ movl %ax, %ds
+
+ # relocate the code to leave the space for next stage
+ movl $0x5c0, %ax
+ movl %ax, %es
+ data32
+ xorl %esi, %esi
+ data32
+ xorl %edi, %edi
+ data32
+ movl $0x100, %ecx
+ cld
+ rep
+ movsl
+ # jump to the new code
+ data32
+ ljmp $0x5c0, $start2
+
+start2:
+ movl $0x7c0, %ax
+ movl %ax, %es
+loadbsd:
+ data32
+ popl %ecx
+#endif
load:
+ data32
+ pushl %ebx
movb $0x2, %ah /* function 2 */
movb $LOADSZ, %al /* number of blocks */
xorl %ebx, %ebx /* %bx = 0, put it at 0 in the BOOTSEG */
int $0x13
data32
+ popl %ebx
+ data32
jb read_error
- # ljmp to the second stage boot loader (boot2).
- # After ljmp, %cs is BOOTSEG and boot1 (512 bytes) will be used
- # as an internal buffer "intbuf".
+#ifndef NOHD
+ cmpb $0x80, %dl /* no concurent dos on floppy */
+ data32
+ jl dobsd
+
+ addr32
+ movb %es:4(%ebx), %al
+ cmpb $BSDPART, %al
+ je dobsd
+
+ ljmp $0, $0x7c00
+dobsd:
+#endif
#ifdef DEBUG
data32
movl $six, %esi
@@ -228,6 +274,10 @@ load:
call message
#endif
+ # ljmp to the second stage boot loader (boot2).
+ # After ljmp, %cs is BOOTSEG and boot1 (512 bytes) will be used
+ # as an internal buffer "intbuf".
+
data32
ljmp $BOOTSEG, $_C_LABEL(boot2)
@@ -270,7 +320,6 @@ message:
data32
pushl %edx
-#endif
nextb:
cld
lodsb # load a byte into %al
@@ -302,7 +351,6 @@ done:
data32
ret
-
/* Conventional GDT indexes. */
BOOT_CS_INDEX = 3
BOOT_CS16_INDEX = 5
@@ -323,7 +371,7 @@ ENTRY(boot2)
/* fix up GDT entries for bootstrap */
#define FIXUP(gdt_index) \
addr32; \
- movl %eax, _C_LABEL(Gdt)+(8*gdt_index)+2; /* actually movw %ax */ \
+ movl %eax, _C_LABEL(Gdt)+(8*gdt_index)+2; /* actually movw %ax */ \
addr32; \
movb %bl, _C_LABEL(Gdt)+(8*gdt_index)+4
@@ -364,14 +412,16 @@ stop:
/* error messages */
#ifdef DEBUG
+#ifdef FDDEBUG
one: .asciz "1\r\n"
two: .asciz "2\r\n"
three: .asciz "3\r\n"
+#endif /* FDDEBUG */
four: .asciz "4\r\n"
five: .asciz "5\r\n"
six: .asciz "6\r\n"
seven: .asciz "7\r\n"
-#endif DEBUG
+#endif /* DEBUG */
eread: .asciz "Read error\r\n"
enoboot: .asciz "No bootable partition\r\n"
endofcode: