ferros
ferros copied to clipboard
VSpace: Unify the uses of ScratchRegion, ReservedRegion, and MappedRegion
These three types grew at distinct times in the development of VSpace 2: The Address Space Odyssey and they could be contracted into a single type which serves the needs of each use case.
This is a follow up to #9.
If MemoryRegion
learns how to unmap itself, we can replace the current uses of ScratchRegion
with an exclusive MemoryRegion
which gets unmapped after it's been used locally. ELF setup, however, has a special case—it needs pages. Therefore we create a ScratchRegion
-like type which aliases the VSpace capability and has ownership of a single page's worth of address space. It uses the ReservedRegion
mechanics to set up the intermediate paging structures, then takes MemoryRegion
s of size PageBits
into a temporarily_map
function a lá ScratchRegion::temporarily_map_region
.