Nightloader/i386/legacy-boot/src-asm/entry.asm

75 lines
1.2 KiB
NASM
Raw Normal View History

; entry.asm: Entrypoint for the loader partition of the Nightloader.
; WARNING: Never import at the top of this file!
; If something has to be included, include it at the bottom!
STACK_SIZE equ 32768
UPPER_STACK_POINTER equ 0x20000
LOWER_STACK_POINTER equ (UPPER_STACK_POINTER - STACK_SIZE)
bits 16
org 0xa000
stage_2_setup_entry:
mov ebx, LOWER_STACK_POINTER
mov ss, ebx
mov esp, STACK_SIZE
mov ebp, STACK_SIZE
push dx
cli
mov ah, 0x00
mov al, 0x03 ; 0x13 for graphics, 0x03 for text.
int 0x10
.check_a20:
push ebp
mov ebp, esp
call check_a20_wraparound
mov esp, ebp
pop ebp
cmp eax, 1
je .a20_is_enabled
hlt
.a20_is_enabled:
mov edi, ebp
mov esi, esp
push ebp
mov ebp, esp
; push dword after_gdt_loaded
call load_flat_gdt
mov esp, ebp
pop ebp
cli
hlt
; Utilities
; Memory Management
%include "memory/a20.asm"
%include "memory/gdt.asm"
bits 32
stage2_protected_entry:
push ebp
mov ebp, esp
call setup_drivers
mov esp, ebp
pop ebp
cli
hlt
.buffer:
dd 0
%include "utility/math.asm"
%include "utility/memory.asm"
%include "utility/display.asm"
; Driver Manager
%include "drivers/manager.asm"