summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoryar <yar@FreeBSD.org>2004-08-28 08:32:23 +0000
committeryar <yar@FreeBSD.org>2004-08-28 08:32:23 +0000
commit736cef795a523fe14c86bce1f473da19ff9b4988 (patch)
tree2ebfadb60c7268d19d0271b676b7865b4a8ffd77
parent2032b765e70bf2638c33fea6437540f26aa24e2a (diff)
downloadFreeBSD-src-736cef795a523fe14c86bce1f473da19ff9b4988.zip
FreeBSD-src-736cef795a523fe14c86bce1f473da19ff9b4988.tar.gz
Try packet mode of INT13 on a hard disk first if not prohibited by
the flag, fall back to the old INT13/AH=02 function if that fails. This way of operation is less likely to fail with modern BIOSes and large disks of strange geometries. 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
-rw-r--r--sys/boot/i386/boot2/boot1.S40
1 files changed, 21 insertions, 19 deletions
diff --git a/sys/boot/i386/boot2/boot1.S b/sys/boot/i386/boot2/boot1.S
index 5b0f6f7..909cdf2 100644
--- a/sys/boot/i386/boot2/boot1.S
+++ b/sys/boot/i386/boot2/boot1.S
@@ -269,7 +269,25 @@ return: retw # To caller
* %dl - byte - drive number
* stack - 10 bytes - EDD Packet
*/
-read: push %dx # Save
+read: testb $FL_PACKET,%cs:MEM_REL+flags-start # LBA support enabled?
+ jz read.1 # No, use CHS
+ cmpb $0x80,%dl # Hard drive?
+ jb read.1 # No, use CHS
+ mov $0x55aa,%bx # Magic
+ push %dx # Save
+ movb $0x41,%ah # BIOS: Check
+ int $0x13 # extensions present
+ pop %dx # Restore
+ jc read.1 # If error, use CHS
+ cmp $0xaa55,%bx # Magic?
+ jne read.1 # No, so use CHS
+ testb $0x1,%cl # Packet interface?
+ jz read.1 # No, so use CHS
+ mov %bp,%si # Disk packet
+ movb $0x42,%ah # BIOS: Extended
+ int $0x13 # read
+ retw # To caller
+read.1: push %dx # Save
movb $0x8,%ah # BIOS: Get drive
int $0x13 # parameters
movb %dh,%ch # Max head number
@@ -292,7 +310,7 @@ read: push %dx # Save
pop %dx # Restore
cmpl $0x3ff,%eax # Cylinder number supportable?
sti # Enable interrupts
- ja read.7 # No, try EDD
+ ja ereturn # No, return an error
xchgb %al,%ah # Set up cylinder
rorb $0x2,%al # number
orb %ch,%al # Merge
@@ -328,24 +346,8 @@ 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 # If not done
+ ja read.1 # 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 */
OpenPOWER on IntegriCloud