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

UserspaceEmulator: Add basic support for memory-mapped files

MmapRegion now supports using an mmap'ed file descriptor as backing.
This commit is contained in:
Andreas Kling 2020-07-13 11:58:58 +02:00
parent 63d3f5d19b
commit 9b6464010f
3 changed files with 30 additions and 5 deletions

View file

@ -33,7 +33,8 @@ namespace UserspaceEmulator {
class MmapRegion final : public SoftMMU::Region {
public:
MmapRegion(u32 base, u32 size, int prot);
static NonnullOwnPtr<MmapRegion> create_anonymous(u32 base, u32 size, u32 prot);
static NonnullOwnPtr<MmapRegion> create_file_backed(u32 base, u32 size, u32 prot, int flags, int fd, off_t offset);
virtual ~MmapRegion() override;
virtual u8 read8(u32 offset) override;
@ -51,8 +52,11 @@ public:
bool is_executable() const { return m_prot & PROT_EXEC; }
private:
MmapRegion(u32 base, u32 size, int prot);
u8* m_data { nullptr };
int m_prot { 0 };
bool m_file_backed { false };
};
}