diff options
Diffstat (limited to 'src/core/memory.h')
| -rw-r--r-- | src/core/memory.h | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/src/core/memory.h b/src/core/memory.h index c690df3c3..87ed3b696 100644 --- a/src/core/memory.h +++ b/src/core/memory.h | |||
| @@ -5,8 +5,14 @@ | |||
| 5 | #pragma once | 5 | #pragma once |
| 6 | 6 | ||
| 7 | #include <cstddef> | 7 | #include <cstddef> |
| 8 | #include <memory> | ||
| 8 | #include <string> | 9 | #include <string> |
| 9 | #include "common/common_types.h" | 10 | #include "common/common_types.h" |
| 11 | #include "common/memory_hook.h" | ||
| 12 | |||
| 13 | namespace Common { | ||
| 14 | struct PageTable; | ||
| 15 | } | ||
| 10 | 16 | ||
| 11 | namespace Core { | 17 | namespace Core { |
| 12 | class System; | 18 | class System; |
| @@ -52,6 +58,59 @@ public: | |||
| 52 | Memory(Memory&&) = default; | 58 | Memory(Memory&&) = default; |
| 53 | Memory& operator=(Memory&&) = default; | 59 | Memory& operator=(Memory&&) = default; |
| 54 | 60 | ||
| 61 | /** | ||
| 62 | * Maps an allocated buffer onto a region of the emulated process address space. | ||
| 63 | * | ||
| 64 | * @param page_table The page table of the emulated process. | ||
| 65 | * @param base The address to start mapping at. Must be page-aligned. | ||
| 66 | * @param size The amount of bytes to map. Must be page-aligned. | ||
| 67 | * @param target Buffer with the memory backing the mapping. Must be of length at least | ||
| 68 | * `size`. | ||
| 69 | */ | ||
| 70 | void MapMemoryRegion(Common::PageTable& page_table, VAddr base, u64 size, u8* target); | ||
| 71 | |||
| 72 | /** | ||
| 73 | * Maps a region of the emulated process address space as a IO region. | ||
| 74 | * | ||
| 75 | * @param page_table The page table of the emulated process. | ||
| 76 | * @param base The address to start mapping at. Must be page-aligned. | ||
| 77 | * @param size The amount of bytes to map. Must be page-aligned. | ||
| 78 | * @param mmio_handler The handler that backs the mapping. | ||
| 79 | */ | ||
| 80 | void MapIoRegion(Common::PageTable& page_table, VAddr base, u64 size, | ||
| 81 | Common::MemoryHookPointer mmio_handler); | ||
| 82 | |||
| 83 | /** | ||
| 84 | * Unmaps a region of the emulated process address space. | ||
| 85 | * | ||
| 86 | * @param page_table The page table of the emulated process. | ||
| 87 | * @param base The address to begin unmapping at. | ||
| 88 | * @param size The amount of bytes to unmap. | ||
| 89 | */ | ||
| 90 | void UnmapRegion(Common::PageTable& page_table, VAddr base, u64 size); | ||
| 91 | |||
| 92 | /** | ||
| 93 | * Adds a memory hook to intercept reads and writes to given region of memory. | ||
| 94 | * | ||
| 95 | * @param page_table The page table of the emulated process | ||
| 96 | * @param base The starting address to apply the hook to. | ||
| 97 | * @param size The size of the memory region to apply the hook to, in bytes. | ||
| 98 | * @param hook The hook to apply to the region of memory. | ||
| 99 | */ | ||
| 100 | void AddDebugHook(Common::PageTable& page_table, VAddr base, u64 size, | ||
| 101 | Common::MemoryHookPointer hook); | ||
| 102 | |||
| 103 | /** | ||
| 104 | * Removes a memory hook from a given range of memory. | ||
| 105 | * | ||
| 106 | * @param page_table The page table of the emulated process. | ||
| 107 | * @param base The starting address to remove the hook from. | ||
| 108 | * @param size The size of the memory region to remove the hook from, in bytes. | ||
| 109 | * @param hook The hook to remove from the specified region of memory. | ||
| 110 | */ | ||
| 111 | void RemoveDebugHook(Common::PageTable& page_table, VAddr base, u64 size, | ||
| 112 | Common::MemoryHookPointer hook); | ||
| 113 | |||
| 55 | private: | 114 | private: |
| 56 | struct Impl; | 115 | struct Impl; |
| 57 | std::unique_ptr<Impl> impl; | 116 | std::unique_ptr<Impl> impl; |