summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2019-11-26 18:33:20 +0100
committerLioncash <mathew1800@gmail.com>2019-11-27 03:53:34 +0100
commit4c2ed2706e3579ec1304907dad0d45673768e1fc (patch)
tree89f72c13ad6ab374a4e2d2d475b1e03320de7066 /src
parentMerge pull request #3143 from ReinUsesLisp/indexing-bug (diff)
downloadyuzu-4c2ed2706e3579ec1304907dad0d45673768e1fc.tar
yuzu-4c2ed2706e3579ec1304907dad0d45673768e1fc.tar.gz
yuzu-4c2ed2706e3579ec1304907dad0d45673768e1fc.tar.bz2
yuzu-4c2ed2706e3579ec1304907dad0d45673768e1fc.tar.lz
yuzu-4c2ed2706e3579ec1304907dad0d45673768e1fc.tar.xz
yuzu-4c2ed2706e3579ec1304907dad0d45673768e1fc.tar.zst
yuzu-4c2ed2706e3579ec1304907dad0d45673768e1fc.zip
Diffstat (limited to 'src')
-rw-r--r--src/core/core.cpp16
-rw-r--r--src/core/core.h10
-rw-r--r--src/core/memory.cpp12
-rw-r--r--src/core/memory.h21
4 files changed, 56 insertions, 3 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp
index eba17218a..c45fb960c 100644
--- a/src/core/core.cpp
+++ b/src/core/core.cpp
@@ -39,6 +39,7 @@
#include "core/hle/service/service.h"
#include "core/hle/service/sm/sm.h"
#include "core/loader/loader.h"
+#include "core/memory.h"
#include "core/memory/cheat_engine.h"
#include "core/perf_stats.h"
#include "core/reporter.h"
@@ -112,8 +113,8 @@ FileSys::VirtualFile GetGameFileFromPath(const FileSys::VirtualFilesystem& vfs,
}
struct System::Impl {
explicit Impl(System& system)
- : kernel{system}, fs_controller{system}, cpu_core_manager{system}, reporter{system},
- applet_manager{system} {}
+ : kernel{system}, fs_controller{system}, memory{system},
+ cpu_core_manager{system}, reporter{system}, applet_manager{system} {}
Cpu& CurrentCpuCore() {
return cpu_core_manager.GetCurrentCore();
@@ -341,7 +342,8 @@ struct System::Impl {
std::unique_ptr<VideoCore::RendererBase> renderer;
std::unique_ptr<Tegra::GPU> gpu_core;
std::shared_ptr<Tegra::DebugContext> debug_context;
- std::unique_ptr<Core::Hardware::InterruptManager> interrupt_manager;
+ std::unique_ptr<Hardware::InterruptManager> interrupt_manager;
+ Memory::Memory memory;
CpuCoreManager cpu_core_manager;
bool is_powered_on = false;
bool exit_lock = false;
@@ -498,6 +500,14 @@ const ExclusiveMonitor& System::Monitor() const {
return impl->cpu_core_manager.GetExclusiveMonitor();
}
+Memory::Memory& System::Memory() {
+ return impl->memory;
+}
+
+const Memory::Memory& System::Memory() const {
+ return impl->memory;
+}
+
Tegra::GPU& System::GPU() {
return *impl->gpu_core;
}
diff --git a/src/core/core.h b/src/core/core.h
index f9b1a2866..91184e433 100644
--- a/src/core/core.h
+++ b/src/core/core.h
@@ -86,6 +86,10 @@ namespace Core::Hardware {
class InterruptManager;
}
+namespace Memory {
+class Memory;
+}
+
namespace Core {
class ARM_Interface;
@@ -225,6 +229,12 @@ public:
/// Gets a constant reference to the exclusive monitor
const ExclusiveMonitor& Monitor() const;
+ /// Gets a mutable reference to the system memory instance.
+ Memory::Memory& Memory();
+
+ /// Gets a constant reference to the system memory instance.
+ const Memory::Memory& Memory() const;
+
/// Gets a mutable reference to the GPU interface
Tegra::GPU& GPU();
diff --git a/src/core/memory.cpp b/src/core/memory.cpp
index fa49f3dd0..2098f13f7 100644
--- a/src/core/memory.cpp
+++ b/src/core/memory.cpp
@@ -24,6 +24,18 @@ namespace Memory {
static Common::PageTable* current_page_table = nullptr;
+// Implementation class used to keep the specifics of the memory subsystem hidden
+// from outside classes. This also allows modification to the internals of the memory
+// subsystem without needing to rebuild all files that make use of the memory interface.
+struct Memory::Impl {
+ explicit Impl(Core::System& system_) : system{system_} {}
+
+ Core::System& system;
+};
+
+Memory::Memory(Core::System& system) : impl{std::make_unique<Impl>(system)} {}
+Memory::~Memory() = default;
+
void SetCurrentPageTable(Kernel::Process& process) {
current_page_table = &process.VMManager().page_table;
diff --git a/src/core/memory.h b/src/core/memory.h
index 09008e1dd..c690df3c3 100644
--- a/src/core/memory.h
+++ b/src/core/memory.h
@@ -8,6 +8,10 @@
#include <string>
#include "common/common_types.h"
+namespace Core {
+class System;
+}
+
namespace Kernel {
class Process;
}
@@ -36,6 +40,23 @@ enum : VAddr {
KERNEL_REGION_END = KERNEL_REGION_VADDR + KERNEL_REGION_SIZE,
};
+/// Central class that handles all memory operations and state.
+class Memory {
+public:
+ explicit Memory(Core::System& system);
+ ~Memory();
+
+ Memory(const Memory&) = delete;
+ Memory& operator=(const Memory&) = delete;
+
+ Memory(Memory&&) = default;
+ Memory& operator=(Memory&&) = default;
+
+private:
+ struct Impl;
+ std::unique_ptr<Impl> impl;
+};
+
/// Changes the currently active page table to that of
/// the given process instance.
void SetCurrentPageTable(Kernel::Process& process);