Page Frame Bitmap - Reserved Areas

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Page Frame Bitmap - Reserved Areas

Post by AJ »

Hi,

I implemented my page allocation system ages ago and it all works very nicely. I just had a bit of a worry about PCI configuration spaces etc... which I haven't really dealt with yet.

At the moment, I build my RAM bitmap from the system memory map provided by GRUB / the BIOS. Every area marked as 'available' is added to the physical memory bitmap as free (this happens in my boot loader which later builds a stack-based system for the kernel.

Supposing I am later using PCI memory mapped devices. Will the system RAM map take this in to account, or do I have to scan the PCI bus and manually ensure that memory mapped areas are not assigned as RAM?

Also, supposing VESA resides at 0xE0000000 and I had a system with 4GB RAM, will this area already have been marked as unavailable by the BIOS? At present, My system only has 2GB, so it doesn't really matter as VESA space is outside the physical RAM space.

The main reason for my concern is that I prefer the stack allocation method. Obviously this makes it difficult to remove pages later on if they are found to be within some device's configuration space.

Cheers,
Adam
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

Post by Combuster »

Just assume that the bios map is safe - i.e. it does not give you RAM where there isn't any.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
User avatar
Brendan
Member
Member
Posts: 8561
Joined: Sat Jan 15, 2005 12:00 am
Location: At his keyboard!
Contact:

Re: Page Frame Bitmap - Reserved Areas

Post by Brendan »

Hi,
AJ wrote:Supposing I am later using PCI memory mapped devices. Will the system RAM map take this in to account, or do I have to scan the PCI bus and manually ensure that memory mapped areas are not assigned as RAM?

Also, supposing VESA resides at 0xE0000000 and I had a system with 4GB RAM, will this area already have been marked as unavailable by the BIOS? At present, My system only has 2GB, so it doesn't really matter as VESA space is outside the physical RAM space.
You shouldn't need to scan the PCI bus and manually ensure that memory mapped areas are not assigned as RAM.

If you've got 4 GB of RAM, then part of the physical address space will be reserved for PCI devices (e.g. from 0xC0000000 to 0xFFFFFFFF). For cheap motherboards this might mean you can only use 3 GB of RAM and the rest is wasted. For better motherboards the RAM will be remapped, so that (for e.g.) the fourth GB of RAM is from 0x0000000100000000 to 0x000000013FFFFFFF. In this case your OS will need to use PAE or PSE36 (or long mode) to access it.


Cheers,

Brendan
For all things; perfection is, and will always remain, impossible to achieve in practice. However; by striving for perfection we create things that are as perfect as practically possible. Let the pursuit of perfection be our guide.
User avatar
AJ
Member
Member
Posts: 2646
Joined: Sun Oct 22, 2006 7:01 am
Location: Devon, UK
Contact:

Post by AJ »

Thanks - that means I can stop worrying about having to remove pages from my page frame stack after boot-time!

Cheers,
Adam
Post Reply