After many headaches, I managed to make the paging to work partially. I have only one problem, when I access uninitialized global variables I receive triple fault, but if I used only initialized global variables then everything is good. I think I could initialize all the global variables, but I want to know the cause of the problem. Partially, I know the problem, the global variables which are put into .data segment are loaded correct while those from the bss segment are not.
Note that the kernel is mapped in higher half (3GiB). I disassembled the .elf file and the code is:
Code: Select all
mov (%esp),%ecx
add $0x6167,%ecx
lea 0x4dc4(%ecx),%eax // here it's loaded the initialized global variable
movl $0x0,(%eax)
mov -0x38(%ecx),%eax // here it's loaded the UNinitialized global variable
movl $0x5,(%eax)
here it's the code where are accessing the global variables: https://github.com/EnachescuAlin/PhiOS/ ... main.c#L27
here it's entry function: https://github.com/EnachescuAlin/PhiOS/ ... ot32.s#L29
here it's linker.ld: https://github.com/EnachescuAlin/PhiOS/ ... inker32.ld