diff options
Diffstat (limited to 'src/boot.asm')
-rw-r--r-- | src/boot.asm | 51 |
1 files changed, 30 insertions, 21 deletions
diff --git a/src/boot.asm b/src/boot.asm index 631a99a..9b130a2 100644 --- a/src/boot.asm +++ b/src/boot.asm @@ -5,7 +5,10 @@ ; 16-bit real-mode [bits 16] - + +; export a map of kernel symbols for debugging + [map symbols kernel.map] + ; initialize segment registers mov ax, 0 mov ds, ax @@ -18,6 +21,8 @@ mov [BOOT_DRIVE], dl ; make sure we know the location of the stack by setting it on our own +; this stack is only used in real mode in stage 1, so it's growing from +; 0xffff down mov bp, 0xFFFF mov sp, bp @@ -34,10 +39,13 @@ ; print we are going to load stage 2 of the boot blocks mov si, MESSAGE_LOADING_STAGE_2 call print_string - + +; load stage 2 and the kernel together to 0x7e00 (directly +; after the boot sector) mov dl, [BOOT_DRIVE] call read_from_disk - + +; jump over variables and subroutines of stage 1 and execute stage 2 jmp stage2 %include "stage1_functions.asm" @@ -67,13 +75,16 @@ times 510-($-$$) db 0 dw 0xaa55 stage2: +; print a message that we are indeed in stage 2 now mov si, MESSAGE_STAGE_2_LOADED call print_string -; remember current position on screen +; remember current position on screen, otherwise we loose this +; information after switching to protected mode call current_row mov [CURSOR_Y], dh +; enter protected mode call switch_to_protected_mode ; we should never get here, but just in case @@ -88,43 +99,39 @@ MESSAGE_STAGE_2_LOADED: BEGIN_PROTECTED_MODE: - mov edx, 1 -_loop_test: - mov si, MESSAGE_INITIALIZING - call pm_print_string - call pm_print_newline - dec edx - cmp edx, 0 - jnz _loop_test -_end_of_test: - +; we switched to protected mode mov si, MESSAGE_PROTECTED_MODE call pm_print_string call pm_print_newline - + +; check sanity of kernel by searching for MAGIC string at a given +; position + call check_magic + +; print a message before we call the C level kernel mov si, MESSAGE_CALL_C_ENTRY call pm_print_string call pm_print_newline ; call our kernel call c_entry - + +; "kernel halted" message, when we terminate the C kernel mov si, MESSAGE_HALTED call pm_print_string call pm_print_newline ; end of C, disable interupts again, NMIs can still happen +; make sure we loop endlessly here but without burning too +; much CPU cli _halt_loop: hlt jmp _halt_loop - + MESSAGE_PROTECTED_MODE: db "Switched to 32-bit Protected Mode", 0 -MESSAGE_INITIALIZING: - db "Initializing the Foo machine..", 0 - MESSAGE_CALL_C_ENTRY: db "Calling C entry function", 0 @@ -133,7 +140,9 @@ MESSAGE_HALTED: %include "stage2_functions.asm" -; make sure we have full sectors +; make sure we have full sectors, stage one is 512 bytes, so we +; have to will up 3 sectors times 2048-($-$$) db 0 +; position is 0x8400 now for the C entry c_entry: |