summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoursoir <chat@joursoir.net>2021-10-06 16:01:41 +0000
committerJoursoir <chat@joursoir.net>2021-10-06 16:26:33 +0000
commitb212476244fcdd1c0f49a5bd1fb8f3dc33194928 (patch)
tree7534de973562df8f6696148986ea9b519b7f4209
parente46551eebeeed2e79f1784f1c2b5f48c65d95b1d (diff)
downloadmfsos-b212476244fcdd1c0f49a5bd1fb8f3dc33194928.tar.gz
mfsos-b212476244fcdd1c0f49a5bd1fb8f3dc33194928.tar.bz2
mfsos-b212476244fcdd1c0f49a5bd1fb8f3dc33194928.zip
x86/boot/setup: get boot drive parameters
-rw-r--r--arch/x86/boot/setup.s28
1 files changed, 28 insertions, 0 deletions
diff --git a/arch/x86/boot/setup.s b/arch/x86/boot/setup.s
index a5c437c..41ba98c 100644
--- a/arch/x86/boot/setup.s
+++ b/arch/x86/boot/setup.s
@@ -31,6 +31,27 @@ _start:
mov %bp, %sp
BIOS_PRINT $get_data_msg
+
+ # Get disk drive parameters
+ xor %ax, %ax
+ mov %ax, %es # ES:DI = 0x0000:0x0000 to guard
+ mov %ax, %di # against BIOS bugs
+ mov (0), %dl # Set drive boot
+ mov $0x8, %ah
+ int $0x13
+ jc disk_error
+
+ # Interrupt return:
+ # - CH = low eight bits of maximum cylinder number
+ # - CL = maximum sector number (bits 5-0)
+ # high two bits of maximum cylinder number (bits 7-6)
+ # - DH = maximum head number
+ xor %ch, %ch
+ and $0b00111111, %cl
+ xor %dl, %dl
+ mov %dx, heads
+ mov %cx, sectors
+
# TODO: get memory size
# TODO: get video infos
@@ -131,6 +152,13 @@ gdt_data: # the data segment descriptor
gdt_end:
# Global variables
+
+# Total amount of HDD components:
+heads: # 8 significant bytes
+ .word 0x0
+sectors: # 6 significant bytes
+ .word 0x0
+
gdt_descriptor:
# The 6-byte GDT structure containing:
# - GDT size, 2 bytes (size always less one of the real size):