summaryrefslogtreecommitdiff
path: root/src/core/core_cpu.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/core/core_cpu.h')
-rw-r--r--src/core/core_cpu.h120
1 files changed, 0 insertions, 120 deletions
diff --git a/src/core/core_cpu.h b/src/core/core_cpu.h
deleted file mode 100644
index 78f5021a2..000000000
--- a/src/core/core_cpu.h
+++ /dev/null
@@ -1,120 +0,0 @@
1// Copyright 2018 yuzu emulator team
2// Licensed under GPLv2 or any later version
3// Refer to the license.txt file included.
4
5#pragma once
6
7#include <atomic>
8#include <condition_variable>
9#include <cstddef>
10#include <memory>
11#include <mutex>
12#include "common/common_types.h"
13
14namespace Kernel {
15class GlobalScheduler;
16class Scheduler;
17} // namespace Kernel
18
19namespace Core {
20class System;
21}
22
23namespace Core::Timing {
24class CoreTiming;
25}
26
27namespace Memory {
28class Memory;
29}
30
31namespace Core {
32
33class ARM_Interface;
34class ExclusiveMonitor;
35
36constexpr unsigned NUM_CPU_CORES{4};
37
38class CpuBarrier {
39public:
40 bool IsAlive() const {
41 return !end;
42 }
43
44 void NotifyEnd();
45
46 bool Rendezvous();
47
48private:
49 unsigned cores_waiting{NUM_CPU_CORES};
50 std::mutex mutex;
51 std::condition_variable condition;
52 std::atomic<bool> end{};
53};
54
55class Cpu {
56public:
57 Cpu(System& system, ExclusiveMonitor& exclusive_monitor, CpuBarrier& cpu_barrier,
58 std::size_t core_index);
59 ~Cpu();
60
61 void RunLoop(bool tight_loop = true);
62
63 void SingleStep();
64
65 void PrepareReschedule();
66
67 ARM_Interface& ArmInterface() {
68 return *arm_interface;
69 }
70
71 const ARM_Interface& ArmInterface() const {
72 return *arm_interface;
73 }
74
75 Kernel::Scheduler& Scheduler() {
76 return *scheduler;
77 }
78
79 const Kernel::Scheduler& Scheduler() const {
80 return *scheduler;
81 }
82
83 bool IsMainCore() const {
84 return core_index == 0;
85 }
86
87 std::size_t CoreIndex() const {
88 return core_index;
89 }
90
91 void Shutdown();
92
93 /**
94 * Creates an exclusive monitor to handle exclusive reads/writes.
95 *
96 * @param memory The current memory subsystem that the monitor may wish
97 * to keep track of.
98 *
99 * @param num_cores The number of cores to assume about the CPU.
100 *
101 * @returns The constructed exclusive monitor instance, or nullptr if the current
102 * CPU backend is unable to use an exclusive monitor.
103 */
104 static std::unique_ptr<ExclusiveMonitor> MakeExclusiveMonitor(Memory::Memory& memory,
105 std::size_t num_cores);
106
107private:
108 void Reschedule();
109
110 std::unique_ptr<ARM_Interface> arm_interface;
111 CpuBarrier& cpu_barrier;
112 Kernel::GlobalScheduler& global_scheduler;
113 std::unique_ptr<Kernel::Scheduler> scheduler;
114 Timing::CoreTiming& core_timing;
115
116 std::atomic<bool> reschedule_pending = false;
117 std::size_t core_index;
118};
119
120} // namespace Core