1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:57:35 +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

@ -223,6 +223,19 @@ void MmapRegion::write64(u32 offset, ValueWithShadow<u64> value)
*reinterpret_cast<u64*>(m_shadow_data + offset) = value.shadow();
}
NonnullOwnPtr<MmapRegion> MmapRegion::split_at(VirtualAddress offset)
{
VERIFY(!m_malloc);
VERIFY(!m_malloc_metadata);
Range new_range = range();
Range other_range = new_range.split_at(offset);
auto other_region = adopt_own(*new MmapRegion(other_range.base().get(), other_range.size(), prot(), data() + new_range.size(), shadow_data() + new_range.size()));
other_region->m_file_backed = m_file_backed;
other_region->m_name = m_name;
set_range(new_range);
return other_region;
}
void MmapRegion::set_prot(int prot)
{
set_readable(prot & PROT_READ);