mirror of
https://github.com/RGBCube/serenity
synced 2025-07-24 21:37:34 +00:00
UserspaceEmulator: Add ways to check if a Region is stack/mmap
This commit is contained in:
parent
9f1221c785
commit
7e13244238
3 changed files with 8 additions and 0 deletions
|
@ -75,6 +75,7 @@ Emulator::Emulator(const Vector<String>& arguments, NonnullRefPtr<ELF::Loader> e
|
||||||
void Emulator::setup_stack(const Vector<String>& arguments)
|
void Emulator::setup_stack(const Vector<String>& arguments)
|
||||||
{
|
{
|
||||||
auto stack_region = make<SimpleRegion>(stack_location, stack_size);
|
auto stack_region = make<SimpleRegion>(stack_location, stack_size);
|
||||||
|
stack_region->set_stack(true);
|
||||||
m_mmu.add_region(move(stack_region));
|
m_mmu.add_region(move(stack_region));
|
||||||
m_cpu.set_esp(stack_location + stack_size);
|
m_cpu.set_esp(stack_location + stack_size);
|
||||||
|
|
||||||
|
|
|
@ -55,6 +55,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
MmapRegion(u32 base, u32 size, int prot);
|
MmapRegion(u32 base, u32 size, int prot);
|
||||||
|
virtual bool is_mmap() const override { return true; }
|
||||||
|
|
||||||
u8* m_data { nullptr };
|
u8* m_data { nullptr };
|
||||||
int m_prot { 0 };
|
int m_prot { 0 };
|
||||||
|
|
|
@ -58,6 +58,10 @@ public:
|
||||||
|
|
||||||
virtual u8* cacheable_ptr([[maybe_unused]] u32 offset) { return nullptr; }
|
virtual u8* cacheable_ptr([[maybe_unused]] u32 offset) { return nullptr; }
|
||||||
virtual bool is_shared_buffer() const { return false; }
|
virtual bool is_shared_buffer() const { return false; }
|
||||||
|
virtual bool is_mmap() const { return false; }
|
||||||
|
|
||||||
|
bool is_stack() const { return m_stack; }
|
||||||
|
void set_stack(bool b) { m_stack = b; }
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Region(u32 base, u32 size)
|
Region(u32 base, u32 size)
|
||||||
|
@ -69,6 +73,8 @@ public:
|
||||||
private:
|
private:
|
||||||
u32 m_base { 0 };
|
u32 m_base { 0 };
|
||||||
u32 m_size { 0 };
|
u32 m_size { 0 };
|
||||||
|
|
||||||
|
bool m_stack { false };
|
||||||
};
|
};
|
||||||
|
|
||||||
u8 read8(X86::LogicalAddress);
|
u8 read8(X86::LogicalAddress);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue