Page 1 of 1
I need help with memory management
Posted: Sun May 12, 2019 6:41 am
by Teln0
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: Select all
// 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
!
Re: I need help with memory management
Posted: Sun May 12, 2019 6:53 am
by zity
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: Select all
+-------------------+
-4 | size |
+-------------------+
0 | base_addr |
8 | length |
16 | type |
+-------------------+
Re: I need help with memory management
Posted: Sun May 12, 2019 7:01 am
by Teln0
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 !
Re: I need help with memory management
Posted: Sun May 12, 2019 1:55 pm
by MichaelPetch
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.
Re: I need help with memory management
Posted: Mon May 13, 2019 12:19 pm
by Teln0
Alight, thanks !