bits 16
cpu 686
-org 0x1800
+extern enable_paging
+extern map_range
+extern set_up_page_directory
+
+section .text
%include "../fat32/fat32-structs.s"
%macro print 1
pop si
%endmacro
+extern __STACK_BOTTOM__
+
+global _start
_start:
+ mov sp, __STACK_BOTTOM__
mov [BOOT_DRIVE], dl
call enable_unreal
print begin
print kernel_loaded
call get_e820_map
+ mov ebx, ecx
+ mov eax, 24
+ mul ecx
+ add eax, 20
+ sub sp, ax
cli
lgdt [gdt]
pop esi
ret
-
%include "unreal.s"
%include "a20.s"
%include "../fat32/fat32.s"
%include "print.s"
%include "e820.s"
-in_protected:
bits 32
+section .text
+in_protected:
mov ax, 0x10
mov ds, ax
mov es, ax
mov fs, ax
mov gs, ax
- call load_paging_structs
+ push dword 0
+ push 0xc0003000
+ push 0xc0000000
+ push 0x103000
+ push 0x100000
+ call map_range
+ cmp eax, 0
+ jne .error
+ add esp, 20
+ push dword 2
+ push 0xc0009000
+ push 0xc0003000
+ push 0x109000
+ push 0x103000
+ call map_range
+ cmp eax, 0
+ jne .error
+ add esp, 20
+ push dword 2
+ push 0x100000
+ push dword 0
+ push 0x100000
+ push dword 0
+ call map_range
+ cmp eax, 0
+ jne .error
+ add esp, 20
+
+ call set_up_page_directory
call enable_paging
- jmp 0x8:0xc0000000
+ jmp 0xc0000000
nop
+.error:
+ mov dword [0xb8000], 0xcf28cf3a
+ hlt
+ jmp $-1
+
+section .rodata
kernel_name: db "KERNEL BIN"
begin: db "Nameless Bootloader revision ", GIT_REVISION, 0xd, 0xa, 0
space: db " ", 0
hex_delm: db "0x", 0
newline: db 0xd, 0xa, 0
-
-%include "paging.s"