diff options
| author | Chloe M. <chloe@aptel.org> | 2026-08-20 07:51:06 +0000 |
|---|---|---|
| committer | Chloe M. <chloe@aptel.org> | 2026-08-20 07:52:09 +0000 |
| commit | 2c5b32f34deacf2f832e091e6546a27a87967627 (patch) | |
| tree | 2ff99b574e379207f8f00482079e54e6b0c8ceee /boot | |
| parent | 597268957f475c2880b8cfba48b4c23807d8277d (diff) | |
boot/amd64: mbr: Load two sectors from disk
Signed-off-by: Chloe M. <chloe@aptel.org>
Diffstat (limited to 'boot')
| -rw-r--r-- | boot/arch/amd64/mbr/mbr.S | 45 |
1 files changed, 42 insertions, 3 deletions
diff --git a/boot/arch/amd64/mbr/mbr.S b/boot/arch/amd64/mbr/mbr.S index a548ce7..18740d6 100644 --- a/boot/arch/amd64/mbr/mbr.S +++ b/boot/arch/amd64/mbr/mbr.S @@ -39,9 +39,33 @@ reloc: mov $boot_msg, %si call putstr - cli + /* Load two sectors */ + movw $2, dap_blkcnt + movl $1, dap_lba_low + call disk_read_lba + +1: cli + hlt + jmp 1b + +/* + * Read sectors from the disk + */ +disk_read_lba: + pusha + mov $dap, %si + mov $0x42, %ah + mov drive_num, %dl + int $0x13 + jc .error + popa + ret +.error: + mov $disk_err_msg, %si + call putstr +1: cli hlt - jmp reloc + jmp 1b /* * Write a string to the console @@ -70,8 +94,23 @@ putchr: pop %dx ret +dap: + .byte 0x10 + .byte 0x00 +dap_blkcnt: + .word 0 +dap_destptr: + .word 0x7C00 +dap_destseg: + .word 0x0000 +dap_lba_low: + .long 0 +dap_lba_high: + .long 0 + drive_num: .byte 0x00 -boot_msg: .ascii "booting\0" +boot_msg: .ascii "booting\r\n\0" +disk_err_msg: .ascii "\r\n!!!disk error!!!\r\n\0" .org 510 .byte 0x55 |
