2024-06-16 21:07:51 +00:00
|
|
|
; 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
|
2024-07-02 10:16:25 +00:00
|
|
|
UPPER_STACK_POINTER equ 0x20000
|
2024-06-16 21:07:51 +00:00
|
|
|
LOWER_STACK_POINTER equ (UPPER_STACK_POINTER - STACK_SIZE)
|
|
|
|
|
|
|
|
bits 16
|
2024-07-02 10:16:25 +00:00
|
|
|
org 0xa000
|
|
|
|
stage_2_setup_entry:
|
2024-06-16 21:07:51 +00:00
|
|
|
mov ebx, LOWER_STACK_POINTER
|
|
|
|
mov ss, ebx
|
|
|
|
mov esp, STACK_SIZE
|
|
|
|
mov ebp, STACK_SIZE
|
|
|
|
push dx
|
2024-06-18 13:41:54 +00:00
|
|
|
cli
|
2024-06-16 21:07:51 +00:00
|
|
|
|
2024-07-02 10:16:25 +00:00
|
|
|
mov ah, 0x00
|
2024-08-07 08:06:18 +00:00
|
|
|
mov al, 0x03 ; 0x13 for graphics, 0x03 for text.
|
2024-07-02 10:16:25 +00:00
|
|
|
int 0x10
|
|
|
|
|
2024-06-16 21:07:51 +00:00
|
|
|
.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
|
2024-07-02 10:16:25 +00:00
|
|
|
; push dword after_gdt_loaded
|
2024-06-16 21:07:51 +00:00
|
|
|
call load_flat_gdt
|
|
|
|
mov esp, ebp
|
|
|
|
pop ebp
|
|
|
|
|
|
|
|
cli
|
|
|
|
hlt
|
2024-07-02 10:16:25 +00:00
|
|
|
|
2024-06-16 21:07:51 +00:00
|
|
|
; Utilities
|
|
|
|
; Memory Management
|
|
|
|
%include "memory/a20.asm"
|
|
|
|
%include "memory/gdt.asm"
|
|
|
|
|
2024-07-02 10:16:25 +00:00
|
|
|
bits 32
|
2024-08-07 08:06:18 +00:00
|
|
|
stage2_protected_entry:
|
2024-07-23 21:57:58 +00:00
|
|
|
|
2024-08-17 16:57:49 +00:00
|
|
|
push ebp
|
|
|
|
mov ebp, esp
|
|
|
|
call setup_drivers
|
|
|
|
mov esp, ebp
|
|
|
|
pop ebp
|
|
|
|
|
2024-07-02 10:16:25 +00:00
|
|
|
cli
|
|
|
|
hlt
|
|
|
|
|
2024-08-07 08:06:18 +00:00
|
|
|
.buffer:
|
|
|
|
dd 0
|
|
|
|
|
2024-07-02 10:16:25 +00:00
|
|
|
%include "utility/math.asm"
|
|
|
|
%include "utility/memory.asm"
|
2024-07-23 21:57:58 +00:00
|
|
|
%include "utility/display.asm"
|
2024-07-02 10:16:25 +00:00
|
|
|
|
2024-06-16 21:07:51 +00:00
|
|
|
; Driver Manager
|
2024-07-23 21:57:58 +00:00
|
|
|
%include "drivers/manager.asm"
|