My bootloader loads the kernel to the address 0x100,
after enable protection it jumps to it (address 0x1000).
in the start asm code it try to enable paging but bochs mean that there is a triple fault 14 (page fault). before this i had load my kernel at 0x300 and jumped to 0x3000 then bochs said oh triple fault 13. i think i map all 1:1 if it isn't say it, and say how to map addresses.
My enable_paging function:
Code: Select all
enable_paging:
cli
page_dir equ 0x9C000
page_table equ 0x9D000
xor eax, eax
xor ebx, ebx
mov ecx, 1024
loop1:
or eax, 3
mov [page_table + ebx], eax
xor eax, 3
add ebx, 32
add eax, 4096
loop loop1
mov eax, page_table
or eax, 3
mov[page_dir + 0x00], eax
xor eax, eax
or eax, 2
mov ebx, 32
mov ecx, 1023
loop2:
mov [page_dir + ebx], eax
add ebx, 32
loop loop2
mov eax, page_dir
mov cr3, eax
mov eax, cr0
or eax, 0x80000000
mov cr0, eax ; after this the cpu crashes
ret
Code: Select all
/* Link.ld */
OUTPUT_FORMAT("binary")
ENTRY(start)
SECTIONS
{
.text 0x100000 :
{
code = .; _code = .; __code = .;
*(.text)
. = ALIGN(4096);
}
.data :
{
__CTOR_LIST__ = .; LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2) *(.ctors) LONG(0) __CTOR_END__ = .;
__DTOR_LIST__ = .; LONG((__DTOR_END__ - __DTOR_LIST__) / 4 - 2) *(.dtors) LONG(0) __DTOR_END__ = .;
data = .; _data = .; __data = .;
*(.data)
. = ALIGN(4096);
}
.bss :
{
bss = .; _bss = .; __bss = .;
*(.bss)
. = ALIGN(4096);
}
end = .; _end = .; __end = .;
}