diff options
| author | bunnei <bunneidev@gmail.com> | 2018-01-27 15:20:53 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-01-27 15:20:53 -0500 |
| commit | c1a8e4bfe46255e850129b00c01e818b479fce8f (patch) | |
| tree | b26f2b8ce9725ff02a5cd1067fe237dc6f066a89 /src/core/memory_hook.h | |
| parent | 81be2027ad3b3b134092478d12c32d361dde46fd (diff) | |
| parent | 738f91a57da7c129d1ee85b7abbf6858f8669ee3 (diff) | |
Merge pull request #148 from MerryMage/feature/special-memory
memory: Replace all memory hooking with Special regions
Diffstat (limited to 'src/core/memory_hook.h')
| -rw-r--r-- | src/core/memory_hook.h | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/core/memory_hook.h b/src/core/memory_hook.h new file mode 100644 index 000000000..feebd850a --- /dev/null +++ b/src/core/memory_hook.h @@ -0,0 +1,46 @@ +// Copyright 2016 Citra Emulator Project +// Licensed under GPLv2 or any later version +// Refer to the license.txt file included. + +#pragma once + +#include <memory> +#include <boost/optional.hpp> +#include "common/common_types.h" + +namespace Memory { + +/** + * Memory hooks have two purposes: + * 1. To allow reads and writes to a region of memory to be intercepted. This is used to implement + * texture forwarding and memory breakpoints for debugging. + * 2. To allow for the implementation of MMIO devices. + * + * A hook may be mapped to multiple regions of memory. + * + * If a boost::none or false is returned from a function, the read/write request is passed through + * to the underlying memory region. + */ +class MemoryHook { +public: + virtual ~MemoryHook() = default; + + virtual boost::optional<bool> IsValidAddress(VAddr addr) = 0; + + virtual boost::optional<u8> Read8(VAddr addr) = 0; + virtual boost::optional<u16> Read16(VAddr addr) = 0; + virtual boost::optional<u32> Read32(VAddr addr) = 0; + virtual boost::optional<u64> Read64(VAddr addr) = 0; + + virtual bool ReadBlock(VAddr src_addr, void* dest_buffer, size_t size) = 0; + + virtual bool Write8(VAddr addr, u8 data) = 0; + virtual bool Write16(VAddr addr, u16 data) = 0; + virtual bool Write32(VAddr addr, u32 data) = 0; + virtual bool Write64(VAddr addr, u64 data) = 0; + + virtual bool WriteBlock(VAddr dest_addr, const void* src_buffer, size_t size) = 0; +}; + +using MemoryHookPointer = std::shared_ptr<MemoryHook>; +} // namespace Memory |
