diff options
Diffstat (limited to 'src/core/hle/kernel/kernel.cpp')
| -rw-r--r-- | src/core/hle/kernel/kernel.cpp | 52 |
1 files changed, 51 insertions, 1 deletions
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index 1d0783bd3..0cf3c8f70 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp | |||
| @@ -3,13 +3,15 @@ | |||
| 3 | // Refer to the license.txt file included. | 3 | // Refer to the license.txt file included. |
| 4 | 4 | ||
| 5 | #include <atomic> | 5 | #include <atomic> |
| 6 | #include <functional> | ||
| 6 | #include <memory> | 7 | #include <memory> |
| 7 | #include <mutex> | 8 | #include <mutex> |
| 8 | #include <utility> | 9 | #include <utility> |
| 9 | 10 | ||
| 10 | #include "common/assert.h" | 11 | #include "common/assert.h" |
| 11 | #include "common/logging/log.h" | 12 | #include "common/logging/log.h" |
| 12 | 13 | #include "core/arm/arm_interface.h" | |
| 14 | #include "core/arm/exclusive_monitor.h" | ||
| 13 | #include "core/core.h" | 15 | #include "core/core.h" |
| 14 | #include "core/core_timing.h" | 16 | #include "core/core_timing.h" |
| 15 | #include "core/core_timing_util.h" | 17 | #include "core/core_timing_util.h" |
| @@ -17,6 +19,7 @@ | |||
| 17 | #include "core/hle/kernel/errors.h" | 19 | #include "core/hle/kernel/errors.h" |
| 18 | #include "core/hle/kernel/handle_table.h" | 20 | #include "core/hle/kernel/handle_table.h" |
| 19 | #include "core/hle/kernel/kernel.h" | 21 | #include "core/hle/kernel/kernel.h" |
| 22 | #include "core/hle/kernel/physical_core.h" | ||
| 20 | #include "core/hle/kernel/process.h" | 23 | #include "core/hle/kernel/process.h" |
| 21 | #include "core/hle/kernel/resource_limit.h" | 24 | #include "core/hle/kernel/resource_limit.h" |
| 22 | #include "core/hle/kernel/scheduler.h" | 25 | #include "core/hle/kernel/scheduler.h" |
| @@ -98,6 +101,7 @@ struct KernelCore::Impl { | |||
| 98 | void Initialize(KernelCore& kernel) { | 101 | void Initialize(KernelCore& kernel) { |
| 99 | Shutdown(); | 102 | Shutdown(); |
| 100 | 103 | ||
| 104 | InitializePhysicalCores(kernel); | ||
| 101 | InitializeSystemResourceLimit(kernel); | 105 | InitializeSystemResourceLimit(kernel); |
| 102 | InitializeThreads(); | 106 | InitializeThreads(); |
| 103 | InitializePreemption(); | 107 | InitializePreemption(); |
| @@ -121,6 +125,21 @@ struct KernelCore::Impl { | |||
| 121 | global_scheduler.Shutdown(); | 125 | global_scheduler.Shutdown(); |
| 122 | 126 | ||
| 123 | named_ports.clear(); | 127 | named_ports.clear(); |
| 128 | |||
| 129 | for (auto& core : cores) { | ||
| 130 | core.Shutdown(); | ||
| 131 | } | ||
| 132 | cores.clear(); | ||
| 133 | |||
| 134 | exclusive_monitor.reset(nullptr); | ||
| 135 | } | ||
| 136 | |||
| 137 | void InitializePhysicalCores(KernelCore& kernel) { | ||
| 138 | exclusive_monitor = | ||
| 139 | Core::MakeExclusiveMonitor(system.Memory(), global_scheduler.CpuCoresCount()); | ||
| 140 | for (std::size_t i = 0; i < global_scheduler.CpuCoresCount(); i++) { | ||
| 141 | cores.emplace_back(system, kernel, i, *exclusive_monitor); | ||
| 142 | } | ||
| 124 | } | 143 | } |
| 125 | 144 | ||
| 126 | // Creates the default system resource limit | 145 | // Creates the default system resource limit |
| @@ -186,6 +205,9 @@ struct KernelCore::Impl { | |||
| 186 | /// the ConnectToPort SVC. | 205 | /// the ConnectToPort SVC. |
| 187 | NamedPortTable named_ports; | 206 | NamedPortTable named_ports; |
| 188 | 207 | ||
| 208 | std::unique_ptr<Core::ExclusiveMonitor> exclusive_monitor; | ||
| 209 | std::vector<Kernel::PhysicalCore> cores; | ||
| 210 | |||
| 189 | // System context | 211 | // System context |
| 190 | Core::System& system; | 212 | Core::System& system; |
| 191 | }; | 213 | }; |
| @@ -240,6 +262,34 @@ const Kernel::GlobalScheduler& KernelCore::GlobalScheduler() const { | |||
| 240 | return impl->global_scheduler; | 262 | return impl->global_scheduler; |
| 241 | } | 263 | } |
| 242 | 264 | ||
| 265 | Kernel::PhysicalCore& KernelCore::PhysicalCore(std::size_t id) { | ||
| 266 | return impl->cores[id]; | ||
| 267 | } | ||
| 268 | |||
| 269 | const Kernel::PhysicalCore& KernelCore::PhysicalCore(std::size_t id) const { | ||
| 270 | return impl->cores[id]; | ||
| 271 | } | ||
| 272 | |||
| 273 | Core::ExclusiveMonitor& KernelCore::GetExclusiveMonitor() { | ||
| 274 | return *impl->exclusive_monitor; | ||
| 275 | } | ||
| 276 | |||
| 277 | const Core::ExclusiveMonitor& KernelCore::GetExclusiveMonitor() const { | ||
| 278 | return *impl->exclusive_monitor; | ||
| 279 | } | ||
| 280 | |||
| 281 | void KernelCore::InvalidateAllInstructionCaches() { | ||
| 282 | for (std::size_t i = 0; i < impl->global_scheduler.CpuCoresCount(); i++) { | ||
| 283 | PhysicalCore(i).ArmInterface().ClearInstructionCache(); | ||
| 284 | } | ||
| 285 | } | ||
| 286 | |||
| 287 | void KernelCore::PrepareReschedule(std::size_t id) { | ||
| 288 | if (id < impl->global_scheduler.CpuCoresCount()) { | ||
| 289 | impl->cores[id].Stop(); | ||
| 290 | } | ||
| 291 | } | ||
| 292 | |||
| 243 | void KernelCore::AddNamedPort(std::string name, std::shared_ptr<ClientPort> port) { | 293 | void KernelCore::AddNamedPort(std::string name, std::shared_ptr<ClientPort> port) { |
| 244 | impl->named_ports.emplace(std::move(name), std::move(port)); | 294 | impl->named_ports.emplace(std::move(name), std::move(port)); |
| 245 | } | 295 | } |