First problem seemed to be lack of "OUTPUT_FORMAT(elf32-i386)" line at the beginning of the .ld script, because without it, the whole thing didn't agree to boot at all.
And now I'm stuck because when I enable paging I get triple fault and the VM reboots.
Here's the code:
Code: Select all
BootPageDirectory:
.byte 0x83
.byte 0
.byte 0
.byte 0
.fill (KERNEL_PAGE_NUMBER - 1), 4, 0x0
.byte 0x83
.byte 0
.byte 0
.byte 0
.fill (1024 - KERNEL_PAGE_NUMBER - 1), 4, 0x0
....
.global start
start:
mov %cr4,%ecx
or $0x10, %ecx # Set PSE bit in CR4 to enable 4MB pages.
mov %ecx,%cr4
mov $(BootPageDirectory - KERNEL_VIRTUAL_BASE),%ecx
# $(BootPageDirectory - KERNEL_VIRTUAL_BASE) == 0x00102004
mov %ecx,%cr3 # Load Page Directory Base Register.
mov %cr0,%ecx
or $0x80000000, %ecx # Set PG bit in CR0 to enable paging.
mov %ecx, %cr0
# triple fault here ^
lea (high_start), %ecx
jmp *%ecx
# Hang if kernel_main unexpectedly returns.
cli
hlt
In similair topics I read about setting the EIP properly, but it seems to be perfectly fine although I didn't set it up:
Code: Select all
<bochs:61> page cs:eip
linear page 0x0000000000100000 maps to physical page 0x000000100000