Reintroduce LBA (cyl > 1023) support in the bootblocks, enabled by

means of a build option.
This commit is contained in:
Robert Nordier 1999-07-20 01:19:23 +00:00
parent 7e08426441
commit 50d57a133e
5 changed files with 111 additions and 57 deletions

View File

@ -1,4 +1,4 @@
# $Id: Makefile,v 1.11 1999/01/10 14:48:03 rnordier Exp $
# $Id: Makefile,v 1.12 1999/04/05 07:24:51 rnordier Exp $
PROG= boot2
NOMAN=
@ -11,6 +11,9 @@ CLEANFILES+= boot1 boot1.out boot1.o \
M4?= m4
# A value of 0x80 enables LBA support.
B1FLAGS= 0
BOOT_COMCONSOLE_PORT?= 0x3f8
BOOT_COMCONSOLE_SPEED?= 9600
B2SIOFMT?= 0x3
@ -41,7 +44,7 @@ boot1.out: boot1.o
${LD} ${LDFLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} boot1.o
boot1.o: boot1.m4 boot1.s
(cd ${.CURDIR}; ${M4} boot1.m4 boot1.s) | \
(cd ${.CURDIR}; ${M4} -DFLAGS=${B1FLAGS} boot1.m4 boot1.s) | \
${AS} ${AFLAGS} -o ${.TARGET}
boot2: boot2.ldr boot2.bin

View File

@ -13,7 +13,7 @@
# purpose.
#
# $Id: boot1.s,v 1.7 1999/01/10 13:29:51 peter Exp $
# $Id: boot1.s,v 1.8 1999/01/13 23:30:07 rnordier Exp $
.set MEM_REL,0x700 # Relocation address
.set MEM_ARG,0x900 # Arguments
@ -39,17 +39,21 @@ start: jmp main # Start recognizably
# External read from disk
xread: pushl %ecx # Set
pushl %eax # LBA
pushl %es # Set transfer
pushl %ebx # buffer
pushl %edx # Set count:drive
xread: pushl %ss # Address
popl %ds # data
xread.1: o16 # Starting
pushb $0x0 # absolute
pushl %ecx # block
pushl %eax # number
pushl %es # Address of
pushl %ebx # transfer buffer
xorl %eax,%eax # Number of
movb %dh,%al # blocks to
pushl %eax # transfer
pushb $0x10 # Size of packet
movl %esp,%ebp # Packet pointer
callwi(read) # Read from disk
popl %edx # Pop all
popl %ebx # registers
popl %es # pushed, but
popl %ecx # preserve
popl %ecx # AX
leaw1r(0x10,_bp_,_sp) # Clear stack
lret # To far caller
# Bootstrap
@ -127,7 +131,7 @@ nread: movwir(MEM_BUF,_bx) # Transfer buffer
movw1r(0x8,_si_,_ax) # Get
movw1r(0xa,_si_,_cx) # LBA
pushl %cs # Read from
callwi(xread) # disk
callwi(xread.1) # disk
jnc return # If success
movwir(msg_read,_si) # Message
@ -155,8 +159,25 @@ return: ret # To caller
# Read from disk
read: movl %esp,%ebp # Address stack frame
read: cs_ # LBA support
tstbim(0x80,MEM_REL+flags-start)# enabled?
jz read.1 # No
movwir(0x55aa,_bx) # Magic
pushl %edx # Save
movb $0x41,%ah # BIOS: Check
int $0x13 # extensions present
popl %edx # Restore
jc read.1 # If error
cmpwir(0xaa55,_bx) # Magic?
jne read.1 # No
testb $0x1,%cl # Packet interface?
jz read.1 # No
movl %ebp,%esi # Disk packet
movb $0x42,%ah # BIOS: Extended
int $0x13 # read
ret # To caller
read.1: pushl %edx # Save
movb $0x8,%ah # BIOS: Get drive
int $0x13 # parameters
movb %dh,%ch # Max head number
@ -189,32 +210,32 @@ read: movl %esp,%ebp # Address stack frame
xchgl %eax,%ecx # number
movb %bh,%dh # Head number
subb %ah,%al # Sectors this track
movb1r(0x3,_bp_,_ah) # Blocks to read
movb1r(0x2,_bp_,_ah) # Blocks to read
cmpb %ah,%al # To read
jb read.1 # this
jb read.2 # this
movb %ah,%al # track
read.1: movwir(0x5,_di) # Try count
read.2: lesw1r(0x4,_bp_,_bx) # Transfer buffer
read.2: movwir(0x5,_di) # Try count
read.3: lesw1r(0x4,_bp_,_bx) # Transfer buffer
pushl %eax # Save
movb $0x2,%ah # BIOS: Read
int $0x13 # from disk
popl %ebx # Restore
jnc read.3 # If success
jnc read.4 # If success
decl %edi # Retry?
jz read.5 # No
jz read.6 # No
xorb %ah,%ah # BIOS: Reset
int $0x13 # disk system
xchgl %ebx,%eax # Block count
jmp read.2 # Continue
read.3: movzbl %bl,%eax # Sectors read
jmp read.3 # Continue
read.4: movzbl %bl,%eax # Sectors read
addwr1(_ax,0x8,_bp_) # Adjust
jnc read.4 # LBA,
jnc read.5 # LBA,
incw1(0xa,_bp_) # transfer
read.4: shlb %bl # buffer
read.5: shlb %bl # buffer
addbr1(_bl,0x5,_bp_) # pointer,
subbr1(_al,0x3,_bp_) # block count
ja read # If not done
read.5: ret # To caller
subbr1(_al,0x2,_bp_) # block count
ja read.1 # If not done
read.6: ret # To caller
# Messages
@ -223,6 +244,8 @@ msg_part: .asciz "Boot"
prompt: .asciz " error\r\n"
flags: .byte FLAGS # Flags
.org PRT_OFF,0x90
# Partition table

View File

@ -13,7 +13,7 @@
# purpose.
#
# $Id: boot1.m4,v 1.2 1998/11/05 20:52:25 rnordier Exp $
# $Id: boot1.m4,v 1.3 1998/11/08 15:36:35 rnordier Exp $
define(_al,0x0)dnl
define(_cl,0x1)dnl
@ -42,6 +42,7 @@ define(_di_,0x5)dnl
define(_bp_,0x6)dnl
define(_bx_,0x7)dnl
define(cs_,`.byte 0x2e')dnl
define(o16,`.byte 0x66')dnl
define(addbr1,`.byte 0x0; .byte 0x40 | ($1 << 0x3) | $3; .byte $2')dnl
@ -54,6 +55,7 @@ define(movwr1,`.byte 0x89; .byte 0x40 | ($1 << 0x3) | $3; .byte $2')dnl
define(movwrm,`.byte 0x89; .byte 0x6 | ($1 << 0x3); .word $2')dnl
define(movb1r,`.byte 0x8a; .byte 0x40 | ($3 << 0x3) | $2; .byte $1')dnl
define(movw1r,`.byte 0x8b; .byte 0x40 | ($3 << 0x3) | $2; .byte $1')dnl
define(leaw1r,`.byte 0x8d; .byte 0x40 | ($3 << 0x3) | $2; .byte $1')dnl
define(movwir,`.byte 0xb8 | $2; .word $1')dnl
define(lesw1r,`.byte 0xc4; .byte 0x40 | ($3 << 0x3) | $2; .byte $1')dnl
define(movbi1,`.byte 0xc6; .byte 0x40 | $3; .byte $2; .byte $1')dnl

View File

@ -13,7 +13,7 @@
# purpose.
#
# $Id: boot1.s,v 1.7 1999/01/10 13:29:51 peter Exp $
# $Id: boot1.s,v 1.8 1999/01/13 23:30:07 rnordier Exp $
.set MEM_REL,0x700 # Relocation address
.set MEM_ARG,0x900 # Arguments
@ -39,17 +39,21 @@ start: jmp main # Start recognizably
# External read from disk
xread: pushl %ecx # Set
pushl %eax # LBA
pushl %es # Set transfer
pushl %ebx # buffer
pushl %edx # Set count:drive
xread: pushl %ss # Address
popl %ds # data
xread.1: o16 # Starting
pushb $0x0 # absolute
pushl %ecx # block
pushl %eax # number
pushl %es # Address of
pushl %ebx # transfer buffer
xorl %eax,%eax # Number of
movb %dh,%al # blocks to
pushl %eax # transfer
pushb $0x10 # Size of packet
movl %esp,%ebp # Packet pointer
callwi(read) # Read from disk
popl %edx # Pop all
popl %ebx # registers
popl %es # pushed, but
popl %ecx # preserve
popl %ecx # AX
leaw1r(0x10,_bp_,_sp) # Clear stack
lret # To far caller
# Bootstrap
@ -127,7 +131,7 @@ nread: movwir(MEM_BUF,_bx) # Transfer buffer
movw1r(0x8,_si_,_ax) # Get
movw1r(0xa,_si_,_cx) # LBA
pushl %cs # Read from
callwi(xread) # disk
callwi(xread.1) # disk
jnc return # If success
movwir(msg_read,_si) # Message
@ -155,8 +159,25 @@ return: ret # To caller
# Read from disk
read: movl %esp,%ebp # Address stack frame
read: cs_ # LBA support
tstbim(0x80,MEM_REL+flags-start)# enabled?
jz read.1 # No
movwir(0x55aa,_bx) # Magic
pushl %edx # Save
movb $0x41,%ah # BIOS: Check
int $0x13 # extensions present
popl %edx # Restore
jc read.1 # If error
cmpwir(0xaa55,_bx) # Magic?
jne read.1 # No
testb $0x1,%cl # Packet interface?
jz read.1 # No
movl %ebp,%esi # Disk packet
movb $0x42,%ah # BIOS: Extended
int $0x13 # read
ret # To caller
read.1: pushl %edx # Save
movb $0x8,%ah # BIOS: Get drive
int $0x13 # parameters
movb %dh,%ch # Max head number
@ -189,32 +210,32 @@ read: movl %esp,%ebp # Address stack frame
xchgl %eax,%ecx # number
movb %bh,%dh # Head number
subb %ah,%al # Sectors this track
movb1r(0x3,_bp_,_ah) # Blocks to read
movb1r(0x2,_bp_,_ah) # Blocks to read
cmpb %ah,%al # To read
jb read.1 # this
jb read.2 # this
movb %ah,%al # track
read.1: movwir(0x5,_di) # Try count
read.2: lesw1r(0x4,_bp_,_bx) # Transfer buffer
read.2: movwir(0x5,_di) # Try count
read.3: lesw1r(0x4,_bp_,_bx) # Transfer buffer
pushl %eax # Save
movb $0x2,%ah # BIOS: Read
int $0x13 # from disk
popl %ebx # Restore
jnc read.3 # If success
jnc read.4 # If success
decl %edi # Retry?
jz read.5 # No
jz read.6 # No
xorb %ah,%ah # BIOS: Reset
int $0x13 # disk system
xchgl %ebx,%eax # Block count
jmp read.2 # Continue
read.3: movzbl %bl,%eax # Sectors read
jmp read.3 # Continue
read.4: movzbl %bl,%eax # Sectors read
addwr1(_ax,0x8,_bp_) # Adjust
jnc read.4 # LBA,
jnc read.5 # LBA,
incw1(0xa,_bp_) # transfer
read.4: shlb %bl # buffer
read.5: shlb %bl # buffer
addbr1(_bl,0x5,_bp_) # pointer,
subbr1(_al,0x3,_bp_) # block count
ja read # If not done
read.5: ret # To caller
subbr1(_al,0x2,_bp_) # block count
ja read.1 # If not done
read.6: ret # To caller
# Messages
@ -223,6 +244,8 @@ msg_part: .asciz "Boot"
prompt: .asciz " error\r\n"
flags: .byte FLAGS # Flags
.org PRT_OFF,0x90
# Partition table

View File

@ -1,4 +1,4 @@
# $Id: Makefile,v 1.11 1999/01/10 14:48:03 rnordier Exp $
# $Id: Makefile,v 1.12 1999/04/05 07:24:51 rnordier Exp $
PROG= boot2
NOMAN=
@ -11,6 +11,9 @@ CLEANFILES+= boot1 boot1.out boot1.o \
M4?= m4
# A value of 0x80 enables LBA support.
B1FLAGS= 0
BOOT_COMCONSOLE_PORT?= 0x3f8
BOOT_COMCONSOLE_SPEED?= 9600
B2SIOFMT?= 0x3
@ -41,7 +44,7 @@ boot1.out: boot1.o
${LD} ${LDFLAGS} -e start -Ttext ${ORG1} -o ${.TARGET} boot1.o
boot1.o: boot1.m4 boot1.s
(cd ${.CURDIR}; ${M4} boot1.m4 boot1.s) | \
(cd ${.CURDIR}; ${M4} -DFLAGS=${B1FLAGS} boot1.m4 boot1.s) | \
${AS} ${AFLAGS} -o ${.TARGET}
boot2: boot2.ldr boot2.bin