summaryrefslogtreecommitdiff
path: root/src/core/core_manager.cpp
diff options
context:
space:
mode:
authorGravatar Fernando Sahmkow2020-01-26 14:07:22 -0400
committerGravatar Fernando Sahmkow2020-01-26 14:07:22 -0400
commite4a1ead897575ee9222b4fc1021aaa9cc58f12c8 (patch)
treeef544a51ba2480400df62d40706f68fa3ae62693 /src/core/core_manager.cpp
parentArmInterface: Delegate Exclusive monitor factory to exclusive monitor interfa... (diff)
downloadyuzu-e4a1ead897575ee9222b4fc1021aaa9cc58f12c8.tar.gz
yuzu-e4a1ead897575ee9222b4fc1021aaa9cc58f12c8.tar.xz
yuzu-e4a1ead897575ee9222b4fc1021aaa9cc58f12c8.zip
Core: Refactor CpuCoreManager to CpuManager and Cpu to Core Manager.
This commit instends on better naming the new purpose of this classes.
Diffstat (limited to 'src/core/core_manager.cpp')
-rw-r--r--src/core/core_manager.cpp71
1 files changed, 71 insertions, 0 deletions
diff --git a/src/core/core_manager.cpp b/src/core/core_manager.cpp
new file mode 100644
index 000000000..bb03857d5
--- /dev/null
+++ b/src/core/core_manager.cpp
@@ -0,0 +1,71 @@
1// Copyright 2018 yuzu emulator team
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#include <condition_variable>
6#include <mutex>
7
8#include "common/logging/log.h"
9#ifdef ARCHITECTURE_x86_64
10#include "core/arm/dynarmic/arm_dynarmic.h"
11#endif
12#include "core/arm/exclusive_monitor.h"
13#include "core/arm/unicorn/arm_unicorn.h"
14#include "core/core.h"
15#include "core/core_manager.h"
16#include "core/core_timing.h"
17#include "core/hle/kernel/kernel.h"
18#include "core/hle/kernel/physical_core.h"
19#include "core/hle/kernel/scheduler.h"
20#include "core/hle/kernel/thread.h"
21#include "core/hle/lock.h"
22#include "core/settings.h"
23
24namespace Core {
25
26CoreManager::CoreManager(System& system, std::size_t core_index)
27 : global_scheduler{system.GlobalScheduler()},
28 physical_core{system.Kernel().PhysicalCore(core_index)}, core_timing{system.CoreTiming()},
29 core_index{core_index} {
30}
31
32CoreManager::~CoreManager() = default;
33
34void CoreManager::RunLoop(bool tight_loop) {
35 Reschedule();
36
37 // If we don't have a currently active thread then don't execute instructions,
38 // instead advance to the next event and try to yield to the next thread
39 if (Kernel::GetCurrentThread() == nullptr) {
40 LOG_TRACE(Core, "Core-{} idling", core_index);
41 core_timing.Idle();
42 } else {
43 if (tight_loop) {
44 physical_core.Run();
45 } else {
46 physical_core.Step();
47 }
48 }
49 core_timing.Advance();
50
51 Reschedule();
52}
53
54void CoreManager::SingleStep() {
55 return RunLoop(false);
56}
57
58void CoreManager::PrepareReschedule() {
59 physical_core.Stop();
60}
61
62void CoreManager::Reschedule() {
63 // Lock the global kernel mutex when we manipulate the HLE state
64 std::lock_guard lock(HLE::g_hle_lock);
65
66 global_scheduler.SelectThread(core_index);
67
68 physical_core.Scheduler().TryDoContextSwitch();
69}
70
71} // namespace Core