diff options
| author | 2018-09-06 20:34:51 -0400 | |
|---|---|---|
| committer | 2018-09-06 20:52:58 -0400 | |
| commit | 3f17fe71334a27a60bf54adc55eabe2356ed31f5 (patch) | |
| tree | 11fd2e48608908feb95c9024e3bd8e1267ec538a /src/core/core.cpp | |
| parent | Merge pull request #1250 from lioncash/file-sys (diff) | |
| download | yuzu-3f17fe71334a27a60bf54adc55eabe2356ed31f5.tar.gz yuzu-3f17fe71334a27a60bf54adc55eabe2356ed31f5.tar.xz yuzu-3f17fe71334a27a60bf54adc55eabe2356ed31f5.zip | |
core: Migrate current_process pointer to the kernel
Given we now have the kernel as a class, it doesn't make sense to keep
the current process pointer within the System class, as processes are
related to the kernel.
This also gets rid of a subtle case where memory wouldn't be freed on
core shutdown, as the current_process pointer would never be reset,
causing the pointed to contents to continue to live.
Diffstat (limited to 'src/core/core.cpp')
| -rw-r--r-- | src/core/core.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/src/core/core.cpp b/src/core/core.cpp index bf39ad689..713ee17c1 100644 --- a/src/core/core.cpp +++ b/src/core/core.cpp | |||
| @@ -136,7 +136,7 @@ struct System::Impl { | |||
| 136 | if (virtual_filesystem == nullptr) | 136 | if (virtual_filesystem == nullptr) |
| 137 | virtual_filesystem = std::make_shared<FileSys::RealVfsFilesystem>(); | 137 | virtual_filesystem = std::make_shared<FileSys::RealVfsFilesystem>(); |
| 138 | 138 | ||
| 139 | current_process = Kernel::Process::Create(kernel, "main"); | 139 | kernel.MakeCurrentProcess(Kernel::Process::Create(kernel, "main")); |
| 140 | 140 | ||
| 141 | cpu_barrier = std::make_shared<CpuBarrier>(); | 141 | cpu_barrier = std::make_shared<CpuBarrier>(); |
| 142 | cpu_exclusive_monitor = Cpu::MakeExclusiveMonitor(cpu_cores.size()); | 142 | cpu_exclusive_monitor = Cpu::MakeExclusiveMonitor(cpu_cores.size()); |
| @@ -202,7 +202,7 @@ struct System::Impl { | |||
| 202 | return init_result; | 202 | return init_result; |
| 203 | } | 203 | } |
| 204 | 204 | ||
| 205 | const Loader::ResultStatus load_result{app_loader->Load(current_process)}; | 205 | const Loader::ResultStatus load_result{app_loader->Load(kernel.CurrentProcess())}; |
| 206 | if (load_result != Loader::ResultStatus::Success) { | 206 | if (load_result != Loader::ResultStatus::Success) { |
| 207 | LOG_CRITICAL(Core, "Failed to load ROM (Error {})!", static_cast<int>(load_result)); | 207 | LOG_CRITICAL(Core, "Failed to load ROM (Error {})!", static_cast<int>(load_result)); |
| 208 | Shutdown(); | 208 | Shutdown(); |
| @@ -281,7 +281,6 @@ struct System::Impl { | |||
| 281 | std::unique_ptr<VideoCore::RendererBase> renderer; | 281 | std::unique_ptr<VideoCore::RendererBase> renderer; |
| 282 | std::unique_ptr<Tegra::GPU> gpu_core; | 282 | std::unique_ptr<Tegra::GPU> gpu_core; |
| 283 | std::shared_ptr<Tegra::DebugContext> debug_context; | 283 | std::shared_ptr<Tegra::DebugContext> debug_context; |
| 284 | Kernel::SharedPtr<Kernel::Process> current_process; | ||
| 285 | std::shared_ptr<ExclusiveMonitor> cpu_exclusive_monitor; | 284 | std::shared_ptr<ExclusiveMonitor> cpu_exclusive_monitor; |
| 286 | std::shared_ptr<CpuBarrier> cpu_barrier; | 285 | std::shared_ptr<CpuBarrier> cpu_barrier; |
| 287 | std::array<std::shared_ptr<Cpu>, NUM_CPU_CORES> cpu_cores; | 286 | std::array<std::shared_ptr<Cpu>, NUM_CPU_CORES> cpu_cores; |
| @@ -363,7 +362,11 @@ const std::shared_ptr<Kernel::Scheduler>& System::Scheduler(size_t core_index) { | |||
| 363 | } | 362 | } |
| 364 | 363 | ||
| 365 | Kernel::SharedPtr<Kernel::Process>& System::CurrentProcess() { | 364 | Kernel::SharedPtr<Kernel::Process>& System::CurrentProcess() { |
| 366 | return impl->current_process; | 365 | return impl->kernel.CurrentProcess(); |
| 366 | } | ||
| 367 | |||
| 368 | const Kernel::SharedPtr<Kernel::Process>& System::CurrentProcess() const { | ||
| 369 | return impl->kernel.CurrentProcess(); | ||
| 367 | } | 370 | } |
| 368 | 371 | ||
| 369 | ARM_Interface& System::ArmInterface(size_t core_index) { | 372 | ARM_Interface& System::ArmInterface(size_t core_index) { |