summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndreas Baumann <mail@andreasbaumann.cc>2017-06-10 12:43:16 +0200
committerAndreas Baumann <mail@andreasbaumann.cc>2017-06-10 12:43:16 +0200
commitc79bbf47202f14af01a339dfb5a4250f8e06e15e (patch)
treee3116979468992a7ab9a975a235daa5c3b4cf3b4 /src
parent4415816330813292de36803086fd3a8417a3514c (diff)
downloadabaos-c79bbf47202f14af01a339dfb5a4250f8e06e15e.tar.gz
abaos-c79bbf47202f14af01a339dfb5a4250f8e06e15e.tar.bz2
trying to fix up disk geometry
Diffstat (limited to 'src')
-rw-r--r--src/boot.asm2
-rw-r--r--src/stage2_real_functions.asm28
2 files changed, 30 insertions, 0 deletions
diff --git a/src/boot.asm b/src/boot.asm
index b5febd7..73f1214 100644
--- a/src/boot.asm
+++ b/src/boot.asm
@@ -92,6 +92,8 @@ stage2:
call print_string
mov dl, [BOOT_DRIVE]
call detect_disk_geometry
+ mov dl, [BOOT_DRIVE]
+ call probe_and_fix_disk_geometry
call print_newline
; print a message we are now loading the kernel
diff --git a/src/stage2_real_functions.asm b/src/stage2_real_functions.asm
index 273d790..f173ca3 100644
--- a/src/stage2_real_functions.asm
+++ b/src/stage2_real_functions.asm
@@ -48,6 +48,34 @@ detect_disk_geometry:
mov [SECTORS_PER_CYLINDER], BYTE cl
ret
+probe_and_fix_disk_geometry:
+ mov cl, 0xff ; from 63 down to 0
+
+.loop:
+ mov ah, 0x02 ; read sectors from drive
+ mov al, 1 ; read 1 sector
+ mov ch, BYTE 0
+ mov dh, BYTE 0
+
+ int 0x13
+
+ jc .next_try
+ ; no errors anymore, so it must be the correct sector
+ inc cl
+ mov [SECTORS_PER_CYLINDER], BYTE cl
+
+ mov al, '>'
+ call print_char
+ movzx dx, byte [SECTORS_PER_CYLINDER]
+ call print_hex
+
+ ret
+
+.next_try:
+ dec cl ; next sector
+ jnz .loop
+ ret
+
; read the whole stage2 and kernel from the disk
; IN dl: drive to read from
read_from_disk: