Retrieve kernel adress and size

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
kutkloon7
Member
Member
Posts: 98
Joined: Fri Jan 04, 2013 6:56 pm

Retrieve kernel adress and size

Post by kutkloon7 »

I'm currently working on a physical memory manager for my kernel. I'd like to know at which adress my kernel image is loaded, and how big it is. I use an ELF-executable, so one way would just be to check for the lowest adress for a loadable section, mark that as the base adress, and do something similar for the biggest adress. However, it would be nice to actually use a multiboot structure (following the specification) to pass the information (since I already use the same structure for the memory map).

However, it seems like the multiboot structure doesn't have a field for this, so the kernel 'know' how big it is (it is always loaded at 1MB, so that isn't a big problem). What is an elegant way to do this?
FallenAvatar
Member
Member
Posts: 283
Joined: Mon Jan 03, 2011 6:58 pm

Re: Retrieve kernel adress and size

Post by FallenAvatar »

Linker Variables should work correctly.

- Monk
kutkloon7
Member
Member
Posts: 98
Joined: Fri Jan 04, 2013 6:56 pm

Re: Retrieve kernel adress and size

Post by kutkloon7 »

Great, thanks! Never heard of em before.
Post Reply