mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 07:07:34 +00:00
Kernel: Add Region helpers for accessing underlying physical pages
Since a Region is basically a view into a potentially larger VMObject, it was always necessary to include the Region starting offset when accessing its underlying physical pages. Until now, you had to do that manually, but this patch adds a simple Region::physical_page() for read-only access and a physical_page_slot() when you want a mutable reference to the RefPtr<PhysicalPage> itself. A lot of code is simplified by making use of this.
This commit is contained in:
parent
8a417c311f
commit
9c856811b2
8 changed files with 64 additions and 48 deletions
|
@ -128,6 +128,18 @@ public:
|
|||
return size() / PAGE_SIZE;
|
||||
}
|
||||
|
||||
const PhysicalPage* physical_page(size_t index) const
|
||||
{
|
||||
ASSERT(index < page_count());
|
||||
return vmobject().physical_pages()[first_page_index() + index];
|
||||
}
|
||||
|
||||
RefPtr<PhysicalPage>& physical_page_slot(size_t index)
|
||||
{
|
||||
ASSERT(index < page_count());
|
||||
return vmobject().physical_pages()[first_page_index() + index];
|
||||
}
|
||||
|
||||
size_t offset_in_vmobject() const
|
||||
{
|
||||
return m_offset_in_vmobject;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue