From cf55ba84f46ddbf3fb7385a1233f26cb39a26fb8 Mon Sep 17 00:00:00 2001 From: jhb Date: Mon, 26 Jun 2000 22:57:16 +0000 Subject: 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. --- sys/boot/i386/boot2/Makefile | 2 +- sys/boot/i386/boot2/boot1.S | 45 +++++++++++++++++++++--------------------- sys/boot/i386/boot2/boot1.s | 45 +++++++++++++++++++++--------------------- sys/boot/i386/gptboot/Makefile | 2 +- 4 files changed, 48 insertions(+), 46 deletions(-) diff --git a/sys/boot/i386/boot2/Makefile b/sys/boot/i386/boot2/Makefile index 0ccf65d..35e7d89 100644 --- a/sys/boot/i386/boot2/Makefile +++ b/sys/boot/i386/boot2/Makefile @@ -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 diff --git a/sys/boot/i386/boot2/boot1.S b/sys/boot/i386/boot2/boot1.S index da238b1..0f15897 100644 --- a/sys/boot/i386/boot2/boot1.S +++ b/sys/boot/i386/boot2/boot1.S @@ -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 diff --git a/sys/boot/i386/boot2/boot1.s b/sys/boot/i386/boot2/boot1.s index da238b1..0f15897 100644 --- a/sys/boot/i386/boot2/boot1.s +++ b/sys/boot/i386/boot2/boot1.s @@ -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 diff --git a/sys/boot/i386/gptboot/Makefile b/sys/boot/i386/gptboot/Makefile index 0ccf65d..35e7d89 100644 --- a/sys/boot/i386/gptboot/Makefile +++ b/sys/boot/i386/gptboot/Makefile @@ -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 -- cgit v1.1