summaryrefslogtreecommitdiff
path: root/src/core/memory.h
diff options
context:
space:
mode:
authorGravatar Lioncash2019-11-26 13:09:12 -0500
committerGravatar Lioncash2019-11-26 21:53:34 -0500
commit323680e5ad3ca0e27f2dd1de26816741b3243bed (patch)
treeac7a9e683831493f0f14c8b9566c0d570807ad62 /src/core/memory.h
parentcore/memory: Introduce skeleton of Memory class (diff)
downloadyuzu-323680e5ad3ca0e27f2dd1de26816741b3243bed.tar.gz
yuzu-323680e5ad3ca0e27f2dd1de26816741b3243bed.tar.xz
yuzu-323680e5ad3ca0e27f2dd1de26816741b3243bed.zip
core/memory: Migrate over memory mapping functions to the new Memory class
Migrates all of the direct mapping facilities over to the new memory class. In the process, this also obsoletes the need for memory_setup.h, so we can remove it entirely from the project.
Diffstat (limited to 'src/core/memory.h')
-rw-r--r--src/core/memory.h59
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
13namespace Common {
14struct PageTable;
15}
10 16
11namespace Core { 17namespace Core {
12class System; 18class 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
55private: 114private:
56 struct Impl; 115 struct Impl;
57 std::unique_ptr<Impl> impl; 116 std::unique_ptr<Impl> impl;