Hi,
I call this a "physical address space manager".
The thing is, the physical address space doesn't change often, so performance doesn't matter too much. I use a sorted table of entries, which involves copying data when an entry is inserted or removed. A better idea would be a sorted linked list (to avoid the copying), but anything more complicated (or anything with better performance) isn't necessary.
Colonel Kernel wrote:A side question -- I'm using GRUB. Some physical address regions are not present in the Multiboot memory map (i.e. -- they are actually not there, as opposed to entries that are present but whose type indicates that they are not usable RAM). Are these regions that aren't in the map guaranteed to be utterly useless (i.e. -- not mapped to any I/O devices ever)? I suspect the answer is "no" because of something to do with PCI, which I know nothing about yet... have mercy.

AFAIK GRUB just returns whatever the BIOS told it (e.g. int 0x15, eax = 0xE820). This won't include memory mapped devices - you'd have to scan the PCI buses (and possibly detect ISA cards) to find out which areas they use.
If the computer doesn't support int 0x15, eax = 0xE820 then I think GRUB will only report RAM areas (from other BIOS functions), so you won't know which areas are "system areas".
I'd also be carefull with both Bochs and QEMU - the standard BIOS won't return "system areas" from int 0x15, eax = 0xE820 like it should, so if you're looking for an address range to map a PCI device you could overwrite something that should have been reported (e.g. ROMs or APICs just below 4 GB, or anything between 0x000A0000 to 0x000FFFFF).
To avoid these problems, I'd assume that everything below 16 MB is not unused, and everything above 0xFEC00000 is also not unused (regardless of what GRUB says). This would also mean that memory mapped ISA devices (which use the areas between 15 MB and 16 MB) aren't a problem.
Also, the "ACPI reclaimable" area normally reported by int 0x15, eax = 0xE820 can be "reclaimed" and used as normal RAM when you've finished using the ACPI tables (or if you never use the ACPI tables).
Cheers,
Brendan