diff options
| author | kotorifan <kotorifan05@gmail.com> | 2026-03-07 17:14:14 +0100 |
|---|---|---|
| committer | kotorifan <kotorifan05@gmail.com> | 2026-03-07 17:14:14 +0100 |
| commit | f81dee10ef19f0c82eb89d0e528bcbfb7a38b016 (patch) | |
| tree | 32e733d4ad2471419bdc9e1dd112d1d6a5b90958 /src/boot/boot.stage2.asm | |
| parent | 857f2d6fe4a77a485d9ed46c0c80eecf61142607 (diff) | |
| download | kotori-os-f81dee10ef19f0c82eb89d0e528bcbfb7a38b016.tar.gz | |
Kernel loads now, bootloader works kind of
Diffstat (limited to 'src/boot/boot.stage2.asm')
| -rw-r--r-- | src/boot/boot.stage2.asm | 40 |
1 files changed, 34 insertions, 6 deletions
diff --git a/src/boot/boot.stage2.asm b/src/boot/boot.stage2.asm index 52c73e5..968bedc 100644 --- a/src/boot/boot.stage2.asm +++ b/src/boot/boot.stage2.asm @@ -3,6 +3,8 @@ [bits 16] [org 0x7e00] + %include "common.asm" + jmp 0x0000:_s2_entry _s2_entry: @@ -10,6 +12,19 @@ _s2_entry: xor ax, ax mov ds, ax + mov si, DAP_kernel + mov ah, 0x42 + int 0x13 + jc _kernel_load_err + jmp _kernel_loaded + +_kernel_load_err: + mov si, boot_kernel_err + call _print_string + + jmp $ + +_kernel_loaded: mov si, boot_s2_msg call _print_string @@ -27,21 +42,34 @@ _s2_entry: _protected_mode: mov ax, DATA_SEG32 mov ds, ax + mov ss, ax mov esp, 0x90000 + and esp, 0xFFFFFFF0 ; Align to 16-byte boundary mov esi, boot_protmode_msg call _print_string_pm_vga call 0x10000 - - jmp $ +boot_s2_msg: + db "Entering Stage 2", 13, 10, 0 +boot_protmode_msg: + db "Enabling Protected Mode", 13, 10, 0 +boot_kernel_err: + db "Error loading kernel from disk", 13, 10, 0 + + + align 16 +DAP_kernel: + db 0x10 + db 0 + dw 1 ; Number of sectors + dw 0x0000 + dw 0x1000 ; Offset + dq 66 ; Starting sector + %include "boot.stage1.print.asm" %include "boot.stage2.a20.asm" %include "boot.stage2.gdt32.asm" %include "boot.stage2.print.asm" -boot_s2_msg: - db "Entering Stage 2", 13, 10, 0 -boot_protmode_msg: - db "Enabling Protected Mode", 13, 10, 0 |
