Don't be too smart, just try packet mode of INT13 first.
This way of operation is more robust than the "AI" used before. Add flags to mbr accessible from make.conf as BOOT_MBR_FLAGS. Only one flag is defined now, "allow using packet mode", which is 0x80 in accord with the rest of i386 boot code. The "packet" flag is on by default. PR: i386/70241 Submitted by: Valentin Nechayev <netch <@> netch.kiev.ua> (inital version) Discussed with: jhb (by Valentin Nechayev) Tested on: bochs (with EDD turned on or off by patching the BIOS), PCs
This commit is contained in:
parent
57888b4c83
commit
a30e1135b4
@ -6,8 +6,12 @@ BINMODE=${NOBINMODE}
|
||||
NOMAN=
|
||||
SRCS= ${PROG}.s
|
||||
|
||||
# MBR flags: 0x80 -- try packet interface (also known as EDD or LBA)
|
||||
BOOT_MBR_FLAGS?= 0x80
|
||||
|
||||
ORG= 0x600
|
||||
|
||||
AFLAGS+=--defsym FLAGS=${BOOT_MBR_FLAGS}
|
||||
LDFLAGS=-N -e start -Ttext ${ORG} -Wl,-S,--oformat,binary
|
||||
|
||||
.include <bsd.prog.mk>
|
||||
|
@ -21,6 +21,7 @@
|
||||
.set EXEC,0x600 # Execution address
|
||||
.set PT_OFF,0x1be # Partition table
|
||||
.set MAGIC,0xaa55 # Magic: bootable
|
||||
.set FL_PACKET,0x80 # Flag: try EDD
|
||||
|
||||
.set NHRDRV,0x475 # Number of hard drives
|
||||
|
||||
@ -88,10 +89,8 @@ main.5: movw %sp,%di # Save stack pointer
|
||||
movb 0x1(%si),%dh # Load head
|
||||
movw 0x2(%si),%cx # Load cylinder:sector
|
||||
movw $LOAD,%bx # Transfer buffer
|
||||
cmpb $0xff,%dh # Might we need to use LBA?
|
||||
jnz main.7 # No.
|
||||
cmpw $0xffff,%cx # Do we need to use LBA?
|
||||
jnz main.7 # No.
|
||||
testb $FL_PACKET,flags # Try EDD?
|
||||
jz main.7 # No.
|
||||
pushw %cx # Save %cx
|
||||
pushw %bx # Save %bx
|
||||
movw $0x55aa,%bx # Magic
|
||||
@ -151,7 +150,8 @@ msg_pt: .asciz "Invalid partition table"
|
||||
msg_rd: .asciz "Error loading operating system"
|
||||
msg_os: .asciz "Missing operating system"
|
||||
|
||||
.org PT_OFF
|
||||
.org PT_OFF-1,0x90
|
||||
flags: .byte FLAGS # Flags
|
||||
|
||||
partbl: .fill 0x10,0x4,0x0 # Partition table
|
||||
.word MAGIC # Magic number
|
||||
|
Loading…
x
Reference in New Issue
Block a user