summaryrefslogtreecommitdiff
path: root/src/core/core_manager.cpp
diff options
context:
space:
mode:
authorGravatar bunnei2020-01-30 18:13:59 -0500
committerGravatar GitHub2020-01-30 18:13:59 -0500
commit985d0f35e55f0752c6e147d0140b367708499cb4 (patch)
tree119249aee3acc2cc2ee6a5d391288b52c126765b /src/core/core_manager.cpp
parentMerge pull request #3151 from FearlessTobi/fix-korean (diff)
parentSystem: Address Feedback (diff)
downloadyuzu-985d0f35e55f0752c6e147d0140b367708499cb4.tar.gz
yuzu-985d0f35e55f0752c6e147d0140b367708499cb4.tar.xz
yuzu-985d0f35e55f0752c6e147d0140b367708499cb4.zip
Merge pull request #3353 from FernandoS27/aries
System: Refactor CPU Core management and move ARMInterface and Schedulers to Kernel
Diffstat (limited to 'src/core/core_manager.cpp')
-rw-r--r--src/core/core_manager.cpp70
1 files changed, 70 insertions, 0 deletions
diff --git a/src/core/core_manager.cpp b/src/core/core_manager.cpp
new file mode 100644
index 000000000..8eacf92dd
--- /dev/null
+++ b/src/core/core_manager.cpp
@@ -0,0 +1,70 @@
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()}, physical_core{system.Kernel().PhysicalCore(
28 core_index)},
29 core_timing{system.CoreTiming()}, core_index{core_index} {}
30
31CoreManager::~CoreManager() = default;
32
33void CoreManager::RunLoop(bool tight_loop) {
34 Reschedule();
35
36 // If we don't have a currently active thread then don't execute instructions,
37 // instead advance to the next event and try to yield to the next thread
38 if (Kernel::GetCurrentThread() == nullptr) {
39 LOG_TRACE(Core, "Core-{} idling", core_index);
40 core_timing.Idle();
41 } else {
42 if (tight_loop) {
43 physical_core.Run();
44 } else {
45 physical_core.Step();
46 }
47 }
48 core_timing.Advance();
49
50 Reschedule();
51}
52
53void CoreManager::SingleStep() {
54 return RunLoop(false);
55}
56
57void CoreManager::PrepareReschedule() {
58 physical_core.Stop();
59}
60
61void CoreManager::Reschedule() {
62 // Lock the global kernel mutex when we manipulate the HLE state
63 std::lock_guard lock(HLE::g_hle_lock);
64
65 global_scheduler.SelectThread(core_index);
66
67 physical_core.Scheduler().TryDoContextSwitch();
68}
69
70} // namespace Core