I'm currently setting up page frame allocation. For that purpose i got a memory map from grub.
It gave me 2 usable chunks of memory
base 0x0 length 0x9fc00
base 0x100000 length 0x7efe000
but my kernel's code & data is inside of the second chunk.
My question is: how do i know which space is "occupied"? So how to find out how much memory my kernels code&data use?
Of course i could reserve an arbitrary amount of memory "just to be sure" but what if my kernel ever exceeds this point?
To solve this i would need a pointer to "the end" of my kernel. How to do this?
Thanks in advance. Every advice is welcome
Page Frame Allocation - where does my kernel reside?
Re: Page Frame Allocation - where does my kernel reside?
Your elf files tell you how big the various sections are, so you know how much memory the kernel uses.
Re: Page Frame Allocation - where does my kernel reside?
Thank you, i haven't thought about this.
I'll have a look inside the specification
Does GRUB load my ELF directly at 0x100000?
I'll have a look inside the specification
Does GRUB load my ELF directly at 0x100000?
Re: Page Frame Allocation - where does my kernel reside?
For a pointer to the end of your code placeat the end of the .bss section of your linker script. If you then useyou get a pointer to the end of your kernel.
P.S.
This is explained in more detail at the wiki (http://wiki.osdev.org/Writing_A_Page_Frame_Allocator).
P.P.S.
Don't use the article for your actual allocator, it is basically a stub.
Code: Select all
endkernel = .;
Code: Select all
extern uint32_t endkernel;
uint32_t end_pointer = &endkernel
P.S.
This is explained in more detail at the wiki (http://wiki.osdev.org/Writing_A_Page_Frame_Allocator).
P.P.S.
Don't use the article for your actual allocator, it is basically a stub.
Re: Page Frame Allocation - where does my kernel reside?
Thank you. You really helped me alot!