Afternoon osdevers,
A problem I've been having now that I've managed to get my head around interrupt servicing:
If I compile and link my kernel to be loaded to 1MiB, it is loaded at 1MiB in RAM. How then do I relocate it to the higher half of the virtual address space without having to recompute every symbol offset within? Even if I save myself some difficulty and build the image as an elf32 or similar, what is the proper method to do this? Do I need to write my own linker/loader routines already before I can move?
Or am I looking at this wrong, and all I need to do is memcpy the kernel image to the higher half and remap the page table to suit?
Linking, loading, and the higher half kernel
Re: Linking, loading, and the higher half kernel
Hi,
Some people also use the GDT trick, which is explained at http://wiki.osdev.org/Higher_Half_With_GDT
Regards,
Shikhin
The simplest option would be to compile and link the kernel to be loaded at whatever higher half address you chose (let's assume 0xC0000000). Then, ask GRUB (I assume you are using GRUB) to load your kernel at the 1MiB mark. There, a position independent assembly stub could enable paging to make 0xC0000000 point to the 1MiB mark, and jump to the real kernel.duran wrote:If I compile and link my kernel to be loaded to 1MiB, it is loaded at 1MiB in RAM. How then do I relocate it to the higher half of the virtual address space without having to recompute every symbol offset within? Even if I save myself some difficulty and build the image as an elf32 or similar, what is the proper method to do this?
Some people also use the GDT trick, which is explained at http://wiki.osdev.org/Higher_Half_With_GDT
Regards,
Shikhin
Re: Linking, loading, and the higher half kernel
Another way is to use a multistage loader. The loader is starts at 1MB and it loads the kernel at the correct higher half address.
If a trainstation is where trains stop, what is a workstation ?