mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 11:58:12 +00:00
Kernel: Add RegionTree::find_region_containing(address or range)
Let's encapsulate looking up regions so clients don't have to dig into RegionTree internals.
This commit is contained in:
parent
da7ea2556e
commit
cfb61cbd54
4 changed files with 25 additions and 15 deletions
|
@ -170,4 +170,22 @@ bool RegionTree::remove(Region& region)
|
|||
return m_regions.remove(region.range().base().get());
|
||||
}
|
||||
|
||||
Region* RegionTree::find_region_containing(VirtualAddress address)
|
||||
{
|
||||
SpinlockLocker locker(m_lock);
|
||||
auto* region = m_regions.find_largest_not_above(address.get());
|
||||
if (!region || !region->contains(address))
|
||||
return nullptr;
|
||||
return region;
|
||||
}
|
||||
|
||||
Region* RegionTree::find_region_containing(VirtualRange range)
|
||||
{
|
||||
SpinlockLocker lock(m_lock);
|
||||
auto* region = m_regions.find_largest_not_above(range.base().get());
|
||||
if (!region || !region->contains(range))
|
||||
return nullptr;
|
||||
return region;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue