mirror of
https://github.com/RGBCube/serenity
synced 2025-05-16 17:45:07 +00:00
UserspaceEmulator: Make mmap'ed memory track read/write protection
Here's the first time we get a taste of better information than the real hardware can give us: unlike x86 CPUs, we can actually support write-only memory, so now we do! While this isn't immediately useful, it's still pretty cool. :^)
This commit is contained in:
parent
27c1690504
commit
f6ad5edab0
5 changed files with 190 additions and 1 deletions
|
@ -25,6 +25,7 @@
|
|||
*/
|
||||
|
||||
#include "Emulator.h"
|
||||
#include "MmapRegion.h"
|
||||
#include "SimpleRegion.h"
|
||||
#include "SoftCPU.h"
|
||||
#include <AK/LexicalPath.h>
|
||||
|
@ -44,10 +45,20 @@ namespace UserspaceEmulator {
|
|||
static constexpr u32 stack_location = 0x10000000;
|
||||
static constexpr size_t stack_size = 64 * KB;
|
||||
|
||||
static Emulator* s_the;
|
||||
|
||||
Emulator& Emulator::the()
|
||||
{
|
||||
ASSERT(s_the);
|
||||
return *s_the;
|
||||
}
|
||||
|
||||
Emulator::Emulator(const Vector<String>& arguments, NonnullRefPtr<ELF::Loader> elf)
|
||||
: m_elf(move(elf))
|
||||
, m_cpu(*this)
|
||||
{
|
||||
ASSERT(!s_the);
|
||||
s_the = this;
|
||||
setup_stack(arguments);
|
||||
}
|
||||
|
||||
|
@ -315,7 +326,7 @@ u32 Emulator::virt$mmap(u32 params_addr)
|
|||
|
||||
next_address = final_address + final_size;
|
||||
|
||||
mmu().add_region(make<SimpleRegion>(final_address, final_size));
|
||||
mmu().add_region(make<MmapRegion>(final_address, final_size, params.prot));
|
||||
|
||||
return final_address;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue