mirror of https://github.com/E-Almqvist/eOS
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.0 KiB
56 lines
1.0 KiB
4 years ago
|
[org 0x7c00] ; bootsector
|
||
3 years ago
|
KERNEL_OFFSET equ 0x1000
|
||
|
|
||
3 years ago
|
; Save the boot drive index
|
||
|
mov [BOOT_DRIVE], dl
|
||
|
|
||
|
; Move the stack pointer somewhere safe
|
||
3 years ago
|
mov bp, 0x9000 ; move it to 0x8000
|
||
3 years ago
|
mov sp, bp
|
||
4 years ago
|
|
||
3 years ago
|
; Load kernel into memory
|
||
3 years ago
|
mov bx, stat_kernel_load
|
||
|
call println
|
||
3 years ago
|
call load_kernel
|
||
|
|
||
3 years ago
|
; Switching to PM
|
||
3 years ago
|
mov bx, stat_pm_init
|
||
|
call println
|
||
3 years ago
|
call pm_preinit
|
||
3 years ago
|
|
||
4 years ago
|
jmp $ ; inf loop
|
||
4 years ago
|
|
||
3 years ago
|
%include "bootloader/equ/ascii.asm"
|
||
|
%include "bootloader/bios.asm"
|
||
|
%include "bootloader/pm.asm"
|
||
4 years ago
|
|
||
3 years ago
|
BEGIN_PM:
|
||
3 years ago
|
; Inform of mode switch
|
||
|
mov ebx, stat_boot_success
|
||
3 years ago
|
call vga_print
|
||
4 years ago
|
|
||
3 years ago
|
; Execute kernel code
|
||
|
call KERNEL_OFFSET
|
||
|
|
||
3 years ago
|
jmp $
|
||
|
|
||
3 years ago
|
[bits 16]
|
||
3 years ago
|
|
||
3 years ago
|
load_kernel:
|
||
|
mov bx, KERNEL_OFFSET ; Load kernel at the kernel offset
|
||
3 years ago
|
mov dh, 9 ; Read 15 sectors
|
||
3 years ago
|
mov dl, [BOOT_DRIVE] ; Drive index
|
||
|
call disk_read ; Load the kernel
|
||
|
|
||
|
ret
|
||
|
|
||
|
stat_pm_init: db "Entering 32bit Protected Mode...", ASCII_END
|
||
3 years ago
|
stat_kernel_load: db "Loading kernel into memory...", ASCII_END
|
||
|
stat_boot_success: db "Booting complete!", ASCII_END
|
||
3 years ago
|
|
||
3 years ago
|
BOOT_DRIVE: db 0
|
||
3 years ago
|
|
||
3 years ago
|
; Bootsector
|
||
4 years ago
|
times 510-($-$$) db 0
|
||
3 years ago
|
dw 0xaa55 ; magic BIOS numbers
|