summaryrefslogtreecommitdiff
path: root/Userland/DevTools/UserspaceEmulator/SimpleRegion.h
blob: adad49dc65fd5de743d57737b5ae906d621bd826 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
 * Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#pragma once

#include "SoftMMU.h"

namespace UserspaceEmulator {

class SimpleRegion final : public Region {
public:
    SimpleRegion(u32 base, u32 size);
    virtual ~SimpleRegion() override;

    virtual ValueWithShadow<u8> read8(u32 offset) override;
    virtual ValueWithShadow<u16> read16(u32 offset) override;
    virtual ValueWithShadow<u32> read32(u32 offset) override;
    virtual ValueWithShadow<u64> read64(u32 offset) override;

    virtual void write8(u32 offset, ValueWithShadow<u8>) override;
    virtual void write16(u32 offset, ValueWithShadow<u16>) override;
    virtual void write32(u32 offset, ValueWithShadow<u32>) override;
    virtual void write64(u32 offset, ValueWithShadow<u64>) override;

    virtual u8* data() override { return m_data; }
    virtual u8* shadow_data() override { return m_shadow_data; }

    virtual u8* cacheable_ptr(u32 offset) override;

private:
    u8* m_data { nullptr };
    u8* m_shadow_data { nullptr };
};

}