Higher Half Kernel Problems
Posted: Wed Aug 30, 2006 10:17 am
Hey,
I am trying to convert my current kernel into a higher half kernel, following the page from the OS-FAQ. Although when I try to use the multiboot info struct members, my kernel page faults. I think this could be a problem with my start.asm, but I am not sure. Below is a copy of my start.asm, any help would be appreciated.
Thanks, TomB
I am trying to convert my current kernel into a higher half kernel, following the page from the OS-FAQ. Although when I try to use the multiboot info struct members, my kernel page faults. I think this could be a problem with my start.asm, but I am not sure. Below is a copy of my start.asm, any help would be appreciated.
Code: Select all
[BITS 32]
global start
MULTIBOOT_PAGE_ALIGN equ 1 << 0
MULTIBOOT_MEMORY_INFO equ 1 << 1
MULTIBOOT_HEADER_FLAGS equ MULTIBOOT_PAGE_ALIGN | MULTIBOOT_MEMORY_INFO
MULTIBOOT_HEADER_MAGIC equ 0x1badb002
MULTIBOOT_CHECKSUM equ -(MULTIBOOT_HEADER_MAGIC + MULTIBOOT_HEADER_FLAGS)
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
align 0x1000
multibootheader:
dd MULTIBOOT_HEADER_MAGIC
dd MULTIBOOT_HEADER_FLAGS
dd MULTIBOOT_CHECKSUM
STACKSIZE equ 0x4000
start:
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, [startinhigherhalf]
jmp ecx
startinhigherhalf:
mov dword [bootpagedirectory], 0
invlpg [0]
mov esp, _sys_stack + STACKSIZE
push eax
push ebx
extern kernel_main
call kernel_main
hlt
section .bss
align 0x8000
resb STACKSIZE
_sys_stack: