diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/core.cpp | 16 | ||||
| -rw-r--r-- | src/core/core.h | 10 | ||||
| -rw-r--r-- | src/core/memory.cpp | 12 | ||||
| -rw-r--r-- | src/core/memory.h | 21 |
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 @@ | |||
| 39 | #include "core/hle/service/service.h" | 39 | #include "core/hle/service/service.h" |
| 40 | #include "core/hle/service/sm/sm.h" | 40 | #include "core/hle/service/sm/sm.h" |
| 41 | #include "core/loader/loader.h" | 41 | #include "core/loader/loader.h" |
| 42 | #include "core/memory.h" | ||
| 42 | #include "core/memory/cheat_engine.h" | 43 | #include "core/memory/cheat_engine.h" |
| 43 | #include "core/perf_stats.h" | 44 | #include "core/perf_stats.h" |
| 44 | #include "core/reporter.h" | 45 | #include "core/reporter.h" |
| @@ -112,8 +113,8 @@ FileSys::VirtualFile GetGameFileFromPath(const FileSys::VirtualFilesystem& vfs, | |||
| 112 | } | 113 | } |
| 113 | struct System::Impl { | 114 | struct System::Impl { |
| 114 | explicit Impl(System& system) | 115 | explicit Impl(System& system) |
| 115 | : kernel{system}, fs_controller{system}, cpu_core_manager{system}, reporter{system}, | 116 | : kernel{system}, fs_controller{system}, memory{system}, |
| 116 | applet_manager{system} {} | 117 | cpu_core_manager{system}, reporter{system}, applet_manager{system} {} |
| 117 | 118 | ||
| 118 | Cpu& CurrentCpuCore() { | 119 | Cpu& CurrentCpuCore() { |
| 119 | return cpu_core_manager.GetCurrentCore(); | 120 | return cpu_core_manager.GetCurrentCore(); |
| @@ -341,7 +342,8 @@ struct System::Impl { | |||
| 341 | std::unique_ptr<VideoCore::RendererBase> renderer; | 342 | std::unique_ptr<VideoCore::RendererBase> renderer; |
| 342 | std::unique_ptr<Tegra::GPU> gpu_core; | 343 | std::unique_ptr<Tegra::GPU> gpu_core; |
| 343 | std::shared_ptr<Tegra::DebugContext> debug_context; | 344 | std::shared_ptr<Tegra::DebugContext> debug_context; |
| 344 | std::unique_ptr<Core::Hardware::InterruptManager> interrupt_manager; | 345 | std::unique_ptr<Hardware::InterruptManager> interrupt_manager; |
| 346 | Memory::Memory memory; | ||
| 345 | CpuCoreManager cpu_core_manager; | 347 | CpuCoreManager cpu_core_manager; |
| 346 | bool is_powered_on = false; | 348 | bool is_powered_on = false; |
| 347 | bool exit_lock = false; | 349 | bool exit_lock = false; |
| @@ -498,6 +500,14 @@ const ExclusiveMonitor& System::Monitor() const { | |||
| 498 | return impl->cpu_core_manager.GetExclusiveMonitor(); | 500 | return impl->cpu_core_manager.GetExclusiveMonitor(); |
| 499 | } | 501 | } |
| 500 | 502 | ||
| 503 | Memory::Memory& System::Memory() { | ||
| 504 | return impl->memory; | ||
| 505 | } | ||
| 506 | |||
| 507 | const Memory::Memory& System::Memory() const { | ||
| 508 | return impl->memory; | ||
| 509 | } | ||
| 510 | |||
| 501 | Tegra::GPU& System::GPU() { | 511 | Tegra::GPU& System::GPU() { |
| 502 | return *impl->gpu_core; | 512 | return *impl->gpu_core; |
| 503 | } | 513 | } |
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 { | |||
| 86 | class InterruptManager; | 86 | class InterruptManager; |
| 87 | } | 87 | } |
| 88 | 88 | ||
| 89 | namespace Memory { | ||
| 90 | class Memory; | ||
| 91 | } | ||
| 92 | |||
| 89 | namespace Core { | 93 | namespace Core { |
| 90 | 94 | ||
| 91 | class ARM_Interface; | 95 | class ARM_Interface; |
| @@ -225,6 +229,12 @@ public: | |||
| 225 | /// Gets a constant reference to the exclusive monitor | 229 | /// Gets a constant reference to the exclusive monitor |
| 226 | const ExclusiveMonitor& Monitor() const; | 230 | const ExclusiveMonitor& Monitor() const; |
| 227 | 231 | ||
| 232 | /// Gets a mutable reference to the system memory instance. | ||
| 233 | Memory::Memory& Memory(); | ||
| 234 | |||
| 235 | /// Gets a constant reference to the system memory instance. | ||
| 236 | const Memory::Memory& Memory() const; | ||
| 237 | |||
| 228 | /// Gets a mutable reference to the GPU interface | 238 | /// Gets a mutable reference to the GPU interface |
| 229 | Tegra::GPU& GPU(); | 239 | Tegra::GPU& GPU(); |
| 230 | 240 | ||
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 { | |||
| 24 | 24 | ||
| 25 | static Common::PageTable* current_page_table = nullptr; | 25 | static Common::PageTable* current_page_table = nullptr; |
| 26 | 26 | ||
| 27 | // Implementation class used to keep the specifics of the memory subsystem hidden | ||
| 28 | // from outside classes. This also allows modification to the internals of the memory | ||
| 29 | // subsystem without needing to rebuild all files that make use of the memory interface. | ||
| 30 | struct Memory::Impl { | ||
| 31 | explicit Impl(Core::System& system_) : system{system_} {} | ||
| 32 | |||
| 33 | Core::System& system; | ||
| 34 | }; | ||
| 35 | |||
| 36 | Memory::Memory(Core::System& system) : impl{std::make_unique<Impl>(system)} {} | ||
| 37 | Memory::~Memory() = default; | ||
| 38 | |||
| 27 | void SetCurrentPageTable(Kernel::Process& process) { | 39 | void SetCurrentPageTable(Kernel::Process& process) { |
| 28 | current_page_table = &process.VMManager().page_table; | 40 | current_page_table = &process.VMManager().page_table; |
| 29 | 41 | ||
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 @@ | |||
| 8 | #include <string> | 8 | #include <string> |
| 9 | #include "common/common_types.h" | 9 | #include "common/common_types.h" |
| 10 | 10 | ||
| 11 | namespace Core { | ||
| 12 | class System; | ||
| 13 | } | ||
| 14 | |||
| 11 | namespace Kernel { | 15 | namespace Kernel { |
| 12 | class Process; | 16 | class Process; |
| 13 | } | 17 | } |
| @@ -36,6 +40,23 @@ enum : VAddr { | |||
| 36 | KERNEL_REGION_END = KERNEL_REGION_VADDR + KERNEL_REGION_SIZE, | 40 | KERNEL_REGION_END = KERNEL_REGION_VADDR + KERNEL_REGION_SIZE, |
| 37 | }; | 41 | }; |
| 38 | 42 | ||
| 43 | /// Central class that handles all memory operations and state. | ||
| 44 | class Memory { | ||
| 45 | public: | ||
| 46 | explicit Memory(Core::System& system); | ||
| 47 | ~Memory(); | ||
| 48 | |||
| 49 | Memory(const Memory&) = delete; | ||
| 50 | Memory& operator=(const Memory&) = delete; | ||
| 51 | |||
| 52 | Memory(Memory&&) = default; | ||
| 53 | Memory& operator=(Memory&&) = default; | ||
| 54 | |||
| 55 | private: | ||
| 56 | struct Impl; | ||
| 57 | std::unique_ptr<Impl> impl; | ||
| 58 | }; | ||
| 59 | |||
| 39 | /// Changes the currently active page table to that of | 60 | /// Changes the currently active page table to that of |
| 40 | /// the given process instance. | 61 | /// the given process instance. |
| 41 | void SetCurrentPageTable(Kernel::Process& process); | 62 | void SetCurrentPageTable(Kernel::Process& process); |