OSDev.org

The Place to Start for Operating System Developers
It is currently Mon Aug 03, 2020 9:54 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 15 posts ] 
Author Message
 Post subject: Is the memory map static?
PostPosted: Sun Jun 07, 2020 5:54 am 
Offline
Member
Member
User avatar

Joined: Sun Jul 21, 2019 7:34 am
Posts: 200
Hi.
I use the memory map obtained from GRUB.
I write the free memory areas to my table. I'm wondering if these addresses and the sizes of these areas can change as the computer works. Do I need to update my previously obtained memory area data?

I think not, but it's better to know for sure.


Top
 Profile  
 
 Post subject: Re: Is the memory map static?
PostPosted: Sun Jun 07, 2020 6:06 am 
Offline
Member
Member
User avatar

Joined: Tue Feb 18, 2020 3:29 pm
Posts: 197
No, because that would be very hard to do right and to know when to re-obtain the map. As far as my knowledge goes, no.

_________________
Working on NexOS, a microkernel based OS.


Top
 Profile  
 
 Post subject: Re: Is the memory map static?
PostPosted: Sun Jun 07, 2020 7:49 am 
Offline
Member
Member
User avatar

Joined: Sun Jul 21, 2019 7:34 am
Posts: 200
nexos wrote:
No, because that would be very hard to do right and to know when to re-obtain the map. As far as my knowledge goes, no.

What should I do in this case? How do I track its changes? When should I update my data?


Top
 Profile  
 
 Post subject: Re: Is the memory map static?
PostPosted: Sun Jun 07, 2020 8:09 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 3881
Location: Chichester, UK
Not sure what you mean. Free memory only changes as you allocate pages; it's the reponsibility of the OS to keep track of which pages it has allocated (and therefore which are still free).


Top
 Profile  
 
 Post subject: Re: Is the memory map static?
PostPosted: Sun Jun 07, 2020 9:26 am 
Offline
Member
Member
User avatar

Joined: Sun Jul 21, 2019 7:34 am
Posts: 200
iansjack wrote:
Not sure what you mean. Free memory only changes as you allocate pages; it's the reponsibility of the OS to keep track of which pages it has allocated (and therefore which are still free).

I mean, can the memory map to change myself.
Can the data about RAM partitions received from grub change by itself? Or do they not change?


Top
 Profile  
 
 Post subject: Re: Is the memory map static?
PostPosted: Sun Jun 07, 2020 9:44 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 3881
Location: Chichester, UK
Why would they change?


Top
 Profile  
 
 Post subject: Re: Is the memory map static?
PostPosted: Sun Jun 07, 2020 9:58 am 
Offline
Member
Member
User avatar

Joined: Mon May 22, 2017 5:56 am
Posts: 315
There is such a thing as hot-pluggable RAM, but I think very few of us here have to worry about that particular craziness. Ditto hot-pluggable PCI. We don't have supercomputers.


Top
 Profile  
 
 Post subject: Re: Is the memory map static?
PostPosted: Sun Jun 07, 2020 10:37 am 
Offline
Member
Member
User avatar

Joined: Sun Jul 21, 2019 7:34 am
Posts: 200
Okay, thanks, I thought so. I just wanted to clarify.
Thanks.


Top
 Profile  
 
 Post subject: Re: Is the memory map static?
PostPosted: Sun Jun 07, 2020 10:55 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 2156
Hot-pluggable RAM and CPUs are very popular in enterprise virtual machines, where there's a pretty high demand for being able to scale resources up or down while the OS and applications are running.

PCI hotplug is working its way into consumer electronics in the form of Thunderbolt and SD Express.


Top
 Profile  
 
 Post subject: Re: Is the memory map static?
PostPosted: Mon Jun 08, 2020 5:08 am 
Offline
Member
Member
User avatar

Joined: Mon May 22, 2017 5:56 am
Posts: 315
Ah, thanks Octocontrabass. Well, I'm sure beginner OS devs are not expected to support hot-pluggable RAM. :) Interesting that Thunderbolt is so closely related to PCIe; it might be easy to support. I'm not so sure about the other parts of it, though.


Top
 Profile  
 
 Post subject: Re: Is the memory map static?
PostPosted: Tue Jun 09, 2020 1:11 am 
Offline
Member
Member

Joined: Sat Aug 18, 2018 8:44 pm
Posts: 56
I am looking for the definition fille (.h) for struct mboot or struct mboot_header...do you know where to get it?


Top
 Profile  
 
 Post subject: Re: Is the memory map static?
PostPosted: Tue Jun 09, 2020 1:34 am 
Offline
Member
Member

Joined: Mon Feb 02, 2015 7:11 pm
Posts: 384
https://github.com/kiznit/rainbow-os/tr ... /multiboot

_________________
https://github.com/kiznit/rainbow-os


Top
 Profile  
 
 Post subject: Re: Is the memory map static?
PostPosted: Tue Jun 09, 2020 1:40 am 
Offline
Member
Member

Joined: Mon Mar 25, 2013 7:01 pm
Posts: 2156
They can also be found in the Multiboot and Multiboot2 specifications.

The Multiboot specifications don't use the names "mboot" or "mboot_header" so that probably came from someone else's implementation of the header. (You can write your own header based on the spec instead of using the one in the spec.)


Top
 Profile  
 
 Post subject: Re: Is the memory map static?
PostPosted: Mon Jul 20, 2020 2:56 am 
Offline
Member
Member
User avatar

Joined: Sun Feb 20, 2011 2:01 pm
Posts: 69
Not in GRUB, but it's worth noting that something like this sort of is possible in UEFI.
It doesn't happen automagically, though. Calls to Boot Services can result in changes to the memory map.

When you call GetMemoryMap, UEFI gives you a mapKey.
When you call ExitBootServices, you need to pass that same mapKey, and an error will be returned if it has changed in the interim!

_________________
Whoever said you can't do OS development on Windows?
https://github.com/ChaiSoft/ChaiOS


Top
 Profile  
 
 Post subject: Re: Is the memory map static?
PostPosted: Mon Jul 20, 2020 4:19 am 
Offline
Member
Member
User avatar

Joined: Thu Oct 13, 2016 4:55 pm
Posts: 791
bellezzasolo wrote:
Not in GRUB, but it's worth noting that something like this sort of is possible in UEFI.
It doesn't happen automagically, though. Calls to Boot Services can result in changes to the memory map.

When you call GetMemoryMap, UEFI gives you a mapKey.
When you call ExitBootServices, you need to pass that same mapKey, and an error will be returned if it has changed in the interim!
EFI applications and drivers can allocate and free memory which changes the map. Calling ExitBootServices guarantees that all further memory allocation calls will result in an error code. Therefore RunTime Services must operate on static memory (allocated at initialization stage), and BootTime Services are not accessible at all after ExitBootServices call.

For BIOS, this can't happen as BIOS doesn't have memory allocation functions, so BIOS code can't allocate memory to change the map. E820 will remain static (this is what GRUB returns for you).

Cheers,
bzt


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

All times are UTC - 6 hours


Who is online

Users browsing this forum: AndrewAPrice and 3 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