A poorly written OS for the x86 arch. (WIP)
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.
eOS/bootloader/bootloader.asm

56 lines
1.0 KiB

[org 0x7c00] ; bootsector
3 years ago
KERNEL_OFFSET equ 0x1000
; 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
mov sp, bp
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
jmp $ ; inf loop
%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
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
times 510-($-$$) db 0
3 years ago
dw 0xaa55 ; magic BIOS numbers