summaryrefslogtreecommitdiff
path: root/src/core/cpu_manager.h
diff options
context:
space:
mode:
authorGravatar Fernando Sahmkow2020-02-24 22:04:12 -0400
committerGravatar Fernando Sahmkow2020-06-27 11:35:06 -0400
commite31425df3877636c098ec7426ebd2067920715cb (patch)
tree5c0fc518a4ebb8413c491b43a9fdd99450c7bd80 /src/core/cpu_manager.h
parentMerge pull request #3396 from FernandoS27/prometheus-1 (diff)
downloadyuzu-e31425df3877636c098ec7426ebd2067920715cb.tar.gz
yuzu-e31425df3877636c098ec7426ebd2067920715cb.tar.xz
yuzu-e31425df3877636c098ec7426ebd2067920715cb.zip
General: Recover Prometheus project from harddrive failure
This commit: Implements CPU Interrupts, Replaces Cycle Timing for Host Timing, Reworks the Kernel's Scheduler, Introduce Idle State and Suspended State, Recreates the bootmanager, Initializes Multicore system.
Diffstat (limited to 'src/core/cpu_manager.h')
-rw-r--r--src/core/cpu_manager.h49
1 files changed, 37 insertions, 12 deletions
diff --git a/src/core/cpu_manager.h b/src/core/cpu_manager.h
index 97554d1bb..8103ae857 100644
--- a/src/core/cpu_manager.h
+++ b/src/core/cpu_manager.h
@@ -5,12 +5,18 @@
5#pragma once 5#pragma once
6 6
7#include <array> 7#include <array>
8#include <functional>
8#include <memory> 9#include <memory>
10#include <thread>
9#include "core/hardware_properties.h" 11#include "core/hardware_properties.h"
10 12
13namespace Common {
14class Event;
15class Fiber;
16} // namespace Common
17
11namespace Core { 18namespace Core {
12 19
13class CoreManager;
14class System; 20class System;
15 21
16class CpuManager { 22class CpuManager {
@@ -27,21 +33,40 @@ public:
27 void Initialize(); 33 void Initialize();
28 void Shutdown(); 34 void Shutdown();
29 35
30 CoreManager& GetCoreManager(std::size_t index); 36 void Pause(bool paused);
31 const CoreManager& GetCoreManager(std::size_t index) const; 37
38 std::function<void(void*)> GetGuestThreadStartFunc();
39 std::function<void(void*)> GetIdleThreadStartFunc();
40 std::function<void(void*)> GetSuspendThreadStartFunc();
41 void* GetStartFuncParamater();
32 42
33 CoreManager& GetCurrentCoreManager(); 43private:
34 const CoreManager& GetCurrentCoreManager() const; 44 static void GuestThreadFunction(void* cpu_manager);
45 static void IdleThreadFunction(void* cpu_manager);
46 static void SuspendThreadFunction(void* cpu_manager);
35 47
36 std::size_t GetActiveCoreIndex() const { 48 void RunGuestThread();
37 return active_core; 49 void RunIdleThread();
38 } 50 void RunSuspendThread();
39 51
40 void RunLoop(bool tight_loop); 52 static void ThreadStart(CpuManager& cpu_manager, std::size_t core);
41 53
42private: 54 void RunThread(std::size_t core);
43 std::array<std::unique_ptr<CoreManager>, Hardware::NUM_CPU_CORES> core_managers; 55
44 std::size_t active_core{}; ///< Active core, only used in single thread mode 56 struct CoreData {
57 std::shared_ptr<Common::Fiber> host_context;
58 std::unique_ptr<Common::Event> enter_barrier;
59 std::unique_ptr<Common::Event> exit_barrier;
60 std::atomic<bool> is_running;
61 std::atomic<bool> is_paused;
62 std::atomic<bool> initialized;
63 std::unique_ptr<std::thread> host_thread;
64 };
65
66 std::atomic<bool> running_mode{};
67 std::atomic<bool> paused_state{};
68
69 std::array<CoreData, Core::Hardware::NUM_CPU_CORES> core_data{};
45 70
46 System& system; 71 System& system;
47}; 72};