OSDev.org

The Place to Start for Operating System Developers
It is currently Sat Apr 27, 2024 9:16 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: The main piece of memory after the 0x100000
PostPosted: Tue Mar 19, 2024 4:20 pm 
Offline
Member
Member
User avatar

Joined: Sun Jul 21, 2019 7:34 am
Posts: 300
Some memory is required to initialize my buddy allocator, I am looking for a way to find this memory for initialization.
I want to use this method: just allocate memory after the end of the kernel.
I will need about a few kilobytes to 24 megabytes depending on the size of the total RAM.
Is it possible to use this method? On the memory maps that I have met, it is indicated that the main piece of memory will be located from 0x100000 and it will probably be large enough to meet my needs, is that so?


Top
 Profile  
 
 Post subject: Re: The main piece of memory after the 0x100000
PostPosted: Tue Mar 19, 2024 5:44 pm 
Offline
Member
Member

Joined: Tue Apr 03, 2018 2:44 am
Posts: 403
mrjbom wrote:
Some memory is required to initialize my buddy allocator, I am looking for a way to find this memory for initialization.
I want to use this method: just allocate memory after the end of the kernel.
I will need about a few kilobytes to 24 megabytes depending on the size of the total RAM.
Is it possible to use this method? On the memory maps that I have met, it is indicated that the main piece of memory will be located from 0x100000 and it will probably be large enough to meet my needs, is that so?


If you're using multiboot, you'll get the address map, which on a PC, will generally include extended memory from 1MB up to the amount of RAM installed or about 3.5GB, whichever is lower. Any memory beyond the 3.5GB is mapped beyond the 32-bit physical memory address, and so needs PAE to access.

So, from the memory map, you'll know how much memory you have to play with for the region starting at 1MB. Once your kernel is loaded, you'll also want to check for any modules loaded along with your kernel, which will most likely be loaded after your kernel.

So, you can set a pointer to the end of your BSS section, then for each loaded module, advance the pointer over the module. At the end of that, your pointer will point to unallocated physical memory, which you can co-opt as a bootstrap bump allocator to make the basis of your buddy allocator to manage the remaining memory.


Top
 Profile  
 
 Post subject: Re: The main piece of memory after the 0x100000
PostPosted: Tue Mar 19, 2024 8:55 pm 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 5146
mrjbom wrote:
On the memory maps that I have met, it is indicated that the main piece of memory will be located from 0x100000 and it will probably be large enough to meet my needs, is that so?

I don't think that's guaranteed. You should always check the memory map to make sure there's enough memory.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 30 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group