Made Kernel 'Higher-Half' and enabled paging.
git-svn-id: https://spexeah.com:8443/svn/Asuro@85 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
This commit is contained in:
@ -10,12 +10,12 @@
|
||||
;
|
||||
; Export entrypoint
|
||||
;
|
||||
[global kstart]
|
||||
global _loader
|
||||
|
||||
;
|
||||
; Import kernel entrypoint
|
||||
;
|
||||
[extern kmain]
|
||||
extern kmain
|
||||
|
||||
;
|
||||
; Posible multiboot header flags
|
||||
@ -36,9 +36,18 @@ MULTIBOOT_HEADER_CHECKSUM equ -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEA
|
||||
; Kernel stack size
|
||||
;
|
||||
KERNEL_STACKSIZE equ 0x4000
|
||||
KERNEL_VIRTUAL_BASE equ 0xC0000000
|
||||
KERNEL_PAGE_NUMBER equ (KERNEL_VIRTUAL_BASE >> 22)
|
||||
|
||||
section .data
|
||||
align 0x1000
|
||||
BootPageDirectory:
|
||||
dd 0x00000083
|
||||
times (KERNEL_PAGE_NUMBER - 1) dd 0
|
||||
dd 0x00000083
|
||||
times (1024 - KERNEL_PAGE_NUMBER - 1) dd 0
|
||||
|
||||
section .text
|
||||
|
||||
;
|
||||
; Multiboot header
|
||||
;
|
||||
@ -50,16 +59,38 @@ dd MULTIBOOT_HEADER_CHECKSUM
|
||||
;
|
||||
; Entrypoint
|
||||
;
|
||||
loader equ _loader
|
||||
global loader
|
||||
|
||||
_loader:
|
||||
mov ecx, (BootPageDirectory - KERNEL_VIRTUAL_BASE)
|
||||
mov cr3, ecx
|
||||
|
||||
mov ecx, cr4
|
||||
or ecx, 0x00000010
|
||||
mov cr4, ecx
|
||||
|
||||
mov ecx, cr0
|
||||
or ecx, 0x80000000
|
||||
mov cr0, ecx
|
||||
|
||||
lea ecx, [kstart]
|
||||
jmp ecx
|
||||
|
||||
kstart:
|
||||
mov dword [BootPageDirectory], 0
|
||||
invlpg [0]
|
||||
|
||||
mov esp, KERNEL_STACK+KERNEL_STACKSIZE ;Create kernel stack
|
||||
push eax ;Multiboot magic number
|
||||
add ebx, KERNEL_VIRTUAL_BASE
|
||||
push ebx ;Multiboot info
|
||||
call kmain ;Call kernel entrypoint
|
||||
cli ;Clear interrupts
|
||||
hlt ;Halt machine
|
||||
|
||||
section .bss
|
||||
|
||||
|
||||
;
|
||||
; Kernel stack location
|
||||
;
|
||||
|
Reference in New Issue
Block a user