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:
parent
7cc8f20a30
commit
45443f24ec
7 changed files with 66 additions and 2 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue