I was trying to enable paging the other day, but i just got stuck at one place. The whole paging thing is OK with me, i get the structures and all the bit twidles you gotta do but what about the linker script?
So currently I don't have paging enabled.. and my linker script looks like the following
Code: Select all
OUTPUT_FORMAT("binary");
ENTRY(_boot_entry);
codestart = 0x100000;
virtual = 0xC0000000; /* I want to use a higher half kernel but can't seem to get it right*/
. = codestart; /* you need to set this up to the kernel text. */
SECTIONS
{
.text : {
code = . ;
*(.text);
. = ALIGN(4096);
codeend = ABSOLUTE(.); /* make sure you use absolute otherwise it'll be relative to current section which is text section */
}
/*. = codeend ; you need to set the current location couter to the absolute value of location counter where the code ended */
.data : { /* ADDR returns the absolute Virtual Memory Address (VMA) of a named section*/
data = ABSOLUTE(.);
*(.data);
. = ALIGN(4096);
dataend = ABSOLUTE(.);
_dataend = dataend;
}
/*. = dataend ; same way setup location counter for the bss segment */
.bss :
{ bss = ABSOLUTE(.);
*(.bss);
. = ALIGN(4096);
bssend = ABSOLUTE(.);
}
}
I'm using the AOUT kludge / grub specification for loading my kernel so i need to know the start and end address of my sections. Probably need them anyway so i can move to user land correctly.
Problems i'm facing...
---->the kernel according to this script is made to be executed starting 1MB. But i want it to appear at 3Gigs so what i want is code instructions to have addresses starting from that location correct?
---->if i make the VMA to be virtual(variable in my script above), then i believe the code emitted will be having that instruction address right? however i don't have that much memory so that thing is gonna give me a triple correct?
---->Now since initially the kernel will need to be able to work with physical memory, how can i make sure the switch occurs after i've initialized my pgd and pgt for the kernel? I read Tim Robinson's GDT trick, so do i have to use it. I don't want to introduce another section in linker script, but if that's the only way then i'll have to.
---->What is the purpose of LMA then in the linker script? Really really confused...on VMA and LMA part. Read online docs from redhat on the linker scripts but this thing doesn't make any sense to me.
Please help...