Physical memory management?
Posted: Thu Mar 05, 2015 4:57 pm
Hello.
My OS uses a very simple physical memory allocator: basically, it has a "placement frame", which is the lowest unsued frame, and is initialized at the 2MB mark. When a frame is freed, it pushes it onto a stack; and frames from the stacked are all popped on requests before the next placement frame is returned.
My problem is this: how do I know I don't accidentally allocate a frame which belongs to some memory-mapped device? Obviously I can't rely on drivers to tell me that, because to load them, I need to allocate memory in the first place.
I've heard that GRUB (or other multiboot-compliant bootloaders) can give me a 'memory map'. Is this what gives me all the necessary information to ensure I don't allocate a frame that belongs to a device? If not, how does your OS do it?
Thank you for help.
My OS uses a very simple physical memory allocator: basically, it has a "placement frame", which is the lowest unsued frame, and is initialized at the 2MB mark. When a frame is freed, it pushes it onto a stack; and frames from the stacked are all popped on requests before the next placement frame is returned.
My problem is this: how do I know I don't accidentally allocate a frame which belongs to some memory-mapped device? Obviously I can't rely on drivers to tell me that, because to load them, I need to allocate memory in the first place.
I've heard that GRUB (or other multiboot-compliant bootloaders) can give me a 'memory map'. Is this what gives me all the necessary information to ensure I don't allocate a frame that belongs to a device? If not, how does your OS do it?
Thank you for help.