OSDev.org

The Place to Start for Operating System Developers
It is currently Thu May 23, 2019 1:22 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: I need help with memory management
PostPosted: Sun May 12, 2019 6:41 am 
Offline

Joined: Thu Feb 28, 2019 6:50 am
Posts: 11
I was reading this entry on the wiki and I'm struggling a little bit. My os uses grub to get all the information he may need and I got some information that looks like this :
Code:
// Available memory from BIOS
uint32_t mem_lower;
uint32_t mem_upper;
// Memory Mapping buffer
uint32_t mmap_length;
uint32_t mmap_addr;


First, mem_lower equals to 639 and mem_upper (approximately) equals the amount of ram I gave qemu / 1000. And I'd like to know why is this like that, is the size in blocks ?
Then, I can't really understand what to do with those headers. What I thought is that you have a header at the beginning of each block that describes it, but I'm not sure.

Can somebody help me with that ?
Thanks in advance :) !


Top
 Profile  
 
 Post subject: Re: I need help with memory management
PostPosted: Sun May 12, 2019 6:53 am 
Offline
Member
Member
User avatar

Joined: Mon Jul 13, 2009 5:52 am
Posts: 93
Location: Rome
The answer to your question can be found in the multiboot specs: https://www.gnu.org/software/grub/manua ... iboot.html

The two fields mem_lower and mem_upper is the memory in KBs.

The variable mmap_addr points to an array of "structs" of the form:
Code:
             +-------------------+
     -4      | size              |
             +-------------------+
     0       | base_addr         |
     8       | length            |
     16      | type              |
             +-------------------+


Top
 Profile  
 
 Post subject: Re: I need help with memory management
PostPosted: Sun May 12, 2019 7:01 am 
Offline

Joined: Thu Feb 28, 2019 6:50 am
Posts: 11
but why isn't mem_lower equals to zero and mem_upper to the memory if mem_upper - mem_lower = to the size of the ram in kb ?
And what do I do with those headers ?
Edit : just checked I apparently has nothing to do with this thanks for answering !


Top
 Profile  
 
 Post subject: Re: I need help with memory management
PostPosted: Sun May 12, 2019 1:55 pm 
Offline
Member
Member

Joined: Fri Aug 26, 2016 1:41 pm
Posts: 417
In Multiboot Upper memory is the memory above 1mb (>= 0x100000) and historically Lower memory was the region between 0x00000-0xA0000. mem_lower and mem_upper represent the SIZE (not the starting address of these regions of memory). There is 640KiB (655360 bytes) between 0x00000 and 0xA0000. Why then is 639KiB reported? The Extended BIOS Data Area (EBDA) should be considered unusable ram since System Management Mode (SMM) can overwrite it at any time (or may rely on the data there). The EBDA area sits just below the video memory at 0xA0000. On many systems it is 1KiB (640-639) however it is possible to be larger than that. The memory area between 640-mem_lower and mem_lower should not be overwritten.


Last edited by MichaelPetch on Mon May 13, 2019 2:12 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: I need help with memory management
PostPosted: Mon May 13, 2019 12:19 pm 
Offline

Joined: Thu Feb 28, 2019 6:50 am
Posts: 11
Alight, thanks !


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot] and 16 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