Add in support for EDD to support large disks via LBA. This uses a

method similar to that of the loader to avoid potentially breaking older
drives in that we only use EDD if the desired cylinder is > 1023.
This commit is contained in:
John Baldwin 2000-06-26 22:57:16 +00:00
parent a585d13451
commit cbf3fb883e
4 changed files with 48 additions and 46 deletions

View File

@ -10,7 +10,7 @@ CLEANFILES+= boot1 boot1.out boot1.o \
sio.o
# A value of 0x80 enables LBA support.
B1FLAGS= 0
B1FLAGS= 0x80
BOOT_COMCONSOLE_PORT?= 0x3f8
BOOT_COMCONSOLE_SPEED?= 9600

View File

@ -23,6 +23,7 @@
.set MEM_BTX,0x9000 # BTX start
.set MEM_JMP,0x9010 # BTX entry point
.set MEM_USR,0xa000 # Client start
.set BDA_BOOT,0x472 # Boot howto flag
# Partition Constants
.set PRT_OFF,0x1be # Partition offset
@ -200,7 +201,8 @@ error: callw putstr # Display message
callw putstr # prompt
xorb %ah,%ah # BIOS: Get
int $0x16 # keypress
int $0x19 # BIOS: Reboot
movw $0x1234, BDA_BOOT # Do a warm boot
ljmp $0xffff,$0x0 # reboot the machine
#
# Display a null-terminated string using the BIOS output.
#
@ -228,25 +230,8 @@ return: retw # To caller
#
# %dl - byte - drive number
# stack - 10 bytes - EDD Packet
#
read: testb $FL_PACKET,%cs:MEM_REL+flags-start # LBA support enabled?
jz read.1 # No
mov $0x55aa,%bx # Magic
push %dx # Save
movb $0x41,%ah # BIOS: Check
int $0x13 # extensions present
pop %dx # Restore
jc read.1 # If error
cmp $0xaa55,%bx # Magic?
jne read.1 # No
testb $0x1,%cl # Packet interface?
jz read.1 # No
mov %bp,%si # Disk packet
movb $0x42,%ah # BIOS: Extended
int $0x13 # read
retw # To caller
read.1: push %dx # Save
#
read: push %dx # Save
movb $0x8,%ah # BIOS: Get drive
int $0x13 # parameters
movb %dh,%ch # Max head number
@ -269,7 +254,7 @@ read.1: push %dx # Save
pop %dx # Restore
cmpl $0x3ff,%eax # Cylinder number supportable?
sti # Enable interrupts
ja ereturn # No
ja read.7 # No, try EDD
xchgb %al,%ah # Set up cylinder
rorb $0x2,%al # number
orb %ch,%al # Merge
@ -301,8 +286,24 @@ read.4: movzbw %bl,%ax # Sectors read
read.5: shlb %bl # buffer
add %bl,0x5(%bp) # pointer,
sub %al,0x2(%bp) # block count
ja read.1 # If not done
ja read # If not done
read.6: retw # To caller
read.7: testb $FL_PACKET,%cs:MEM_REL+flags-start # LBA support enabled?
jz ereturn # No, so return an error
mov $0x55aa,%bx # Magic
push %dx # Save
movb $0x41,%ah # BIOS: Check
int $0x13 # extensions present
pop %dx # Restore
jc return # If error, return an error
cmp $0xaa55,%bx # Magic?
jne ereturn # No, so return an error
testb $0x1,%cl # Packet interface?
jz ereturn # No, so return an error
mov %bp,%si # Disk packet
movb $0x42,%ah # BIOS: Extended
int $0x13 # read
retw # To caller
# Messages

View File

@ -23,6 +23,7 @@
.set MEM_BTX,0x9000 # BTX start
.set MEM_JMP,0x9010 # BTX entry point
.set MEM_USR,0xa000 # Client start
.set BDA_BOOT,0x472 # Boot howto flag
# Partition Constants
.set PRT_OFF,0x1be # Partition offset
@ -200,7 +201,8 @@ error: callw putstr # Display message
callw putstr # prompt
xorb %ah,%ah # BIOS: Get
int $0x16 # keypress
int $0x19 # BIOS: Reboot
movw $0x1234, BDA_BOOT # Do a warm boot
ljmp $0xffff,$0x0 # reboot the machine
#
# Display a null-terminated string using the BIOS output.
#
@ -228,25 +230,8 @@ return: retw # To caller
#
# %dl - byte - drive number
# stack - 10 bytes - EDD Packet
#
read: testb $FL_PACKET,%cs:MEM_REL+flags-start # LBA support enabled?
jz read.1 # No
mov $0x55aa,%bx # Magic
push %dx # Save
movb $0x41,%ah # BIOS: Check
int $0x13 # extensions present
pop %dx # Restore
jc read.1 # If error
cmp $0xaa55,%bx # Magic?
jne read.1 # No
testb $0x1,%cl # Packet interface?
jz read.1 # No
mov %bp,%si # Disk packet
movb $0x42,%ah # BIOS: Extended
int $0x13 # read
retw # To caller
read.1: push %dx # Save
#
read: push %dx # Save
movb $0x8,%ah # BIOS: Get drive
int $0x13 # parameters
movb %dh,%ch # Max head number
@ -269,7 +254,7 @@ read.1: push %dx # Save
pop %dx # Restore
cmpl $0x3ff,%eax # Cylinder number supportable?
sti # Enable interrupts
ja ereturn # No
ja read.7 # No, try EDD
xchgb %al,%ah # Set up cylinder
rorb $0x2,%al # number
orb %ch,%al # Merge
@ -301,8 +286,24 @@ read.4: movzbw %bl,%ax # Sectors read
read.5: shlb %bl # buffer
add %bl,0x5(%bp) # pointer,
sub %al,0x2(%bp) # block count
ja read.1 # If not done
ja read # If not done
read.6: retw # To caller
read.7: testb $FL_PACKET,%cs:MEM_REL+flags-start # LBA support enabled?
jz ereturn # No, so return an error
mov $0x55aa,%bx # Magic
push %dx # Save
movb $0x41,%ah # BIOS: Check
int $0x13 # extensions present
pop %dx # Restore
jc return # If error, return an error
cmp $0xaa55,%bx # Magic?
jne ereturn # No, so return an error
testb $0x1,%cl # Packet interface?
jz ereturn # No, so return an error
mov %bp,%si # Disk packet
movb $0x42,%ah # BIOS: Extended
int $0x13 # read
retw # To caller
# Messages

View File

@ -10,7 +10,7 @@ CLEANFILES+= boot1 boot1.out boot1.o \
sio.o
# A value of 0x80 enables LBA support.
B1FLAGS= 0
B1FLAGS= 0x80
BOOT_COMCONSOLE_PORT?= 0x3f8
BOOT_COMCONSOLE_SPEED?= 9600