summaryrefslogtreecommitdiffstats
path: root/src/core/cpu_core_manager.h
diff options
context:
space:
mode:
authorLioncash <mathew1800@gmail.com>2018-11-22 07:27:23 +0100
committerLioncash <mathew1800@gmail.com>2018-11-22 10:28:19 +0100
commit232d95b56e4d634e21bc6d496cff6b3dae32dc14 (patch)
tree388c419ff948b26298c057991a049c271f7b31c7 /src/core/cpu_core_manager.h
parentMerge pull request #1737 from FernandoS27/layer-copy (diff)
downloadyuzu-232d95b56e4d634e21bc6d496cff6b3dae32dc14.tar
yuzu-232d95b56e4d634e21bc6d496cff6b3dae32dc14.tar.gz
yuzu-232d95b56e4d634e21bc6d496cff6b3dae32dc14.tar.bz2
yuzu-232d95b56e4d634e21bc6d496cff6b3dae32dc14.tar.lz
yuzu-232d95b56e4d634e21bc6d496cff6b3dae32dc14.tar.xz
yuzu-232d95b56e4d634e21bc6d496cff6b3dae32dc14.tar.zst
yuzu-232d95b56e4d634e21bc6d496cff6b3dae32dc14.zip
Diffstat (limited to 'src/core/cpu_core_manager.h')
-rw-r--r--src/core/cpu_core_manager.h59
1 files changed, 59 insertions, 0 deletions
diff --git a/src/core/cpu_core_manager.h b/src/core/cpu_core_manager.h
new file mode 100644
index 000000000..a4d70ec56
--- /dev/null
+++ b/src/core/cpu_core_manager.h
@@ -0,0 +1,59 @@
+// Copyright 2018 yuzu emulator team
+// Licensed under GPLv2 or any later version
+// Refer to the license.txt file included.
+
+#pragma once
+
+#include <array>
+#include <map>
+#include <memory>
+#include <thread>
+
+namespace Core {
+
+class Cpu;
+class CpuBarrier;
+class ExclusiveMonitor;
+class System;
+
+class CpuCoreManager {
+public:
+ CpuCoreManager();
+ CpuCoreManager(const CpuCoreManager&) = delete;
+ CpuCoreManager(CpuCoreManager&&) = delete;
+
+ ~CpuCoreManager();
+
+ CpuCoreManager& operator=(const CpuCoreManager&) = delete;
+ CpuCoreManager& operator=(CpuCoreManager&&) = delete;
+
+ void Initialize(System& system);
+ void Shutdown();
+
+ Cpu& GetCore(std::size_t index);
+ const Cpu& GetCore(std::size_t index) const;
+
+ Cpu& GetCurrentCore();
+ const Cpu& GetCurrentCore() const;
+
+ ExclusiveMonitor& GetExclusiveMonitor();
+ const ExclusiveMonitor& GetExclusiveMonitor() const;
+
+ void RunLoop(bool tight_loop);
+
+ void InvalidateAllInstructionCaches();
+
+private:
+ static constexpr std::size_t NUM_CPU_CORES = 4;
+
+ std::unique_ptr<ExclusiveMonitor> exclusive_monitor;
+ std::unique_ptr<CpuBarrier> barrier;
+ std::array<std::unique_ptr<Cpu>, NUM_CPU_CORES> cores;
+ std::array<std::unique_ptr<std::thread>, NUM_CPU_CORES - 1> core_threads;
+ std::size_t active_core{}; ///< Active core, only used in single thread mode
+
+ /// Map of guest threads to CPU cores
+ std::map<std::thread::id, Cpu*> thread_to_cpu;
+};
+
+} // namespace Core