1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 13:07:46 +00:00

UserspaceEmulator: Enable splitting regions at arbitrary points

This is not yet useful in and of itself, but enables the feature in the next commit.
This commit is contained in:
Ben Wiederhake 2021-03-07 22:37:38 +01:00 committed by Andreas Kling
parent 7cc8f20a30
commit 45443f24ec
7 changed files with 66 additions and 2 deletions

View file

@ -67,7 +67,18 @@ public:
return contains(other.base(), other.size());
}
Vector<Range, 2> carve(const Range&);
Vector<Range, 2> carve(const Range&) const;
Range split_at(VirtualAddress address)
{
VERIFY(address.is_page_aligned());
VERIFY(m_base < address);
size_t new_size = (address - m_base).get();
VERIFY(new_size < m_size);
size_t other_size = m_size - new_size;
m_size = new_size;
return { address, other_size };
}
private:
VirtualAddress m_base;