From 4d6a86b03fe6ae0d98838a21613b66d5196150af Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Sat, 25 Jan 2020 18:55:32 -0400 Subject: Core: Refactor CPU Management. This commit moves ARM Interface and Scheduler handling into the kernel. --- src/core/core_cpu.h | 61 +++-------------------------------------------------- 1 file changed, 3 insertions(+), 58 deletions(-) (limited to 'src/core/core_cpu.h') diff --git a/src/core/core_cpu.h b/src/core/core_cpu.h index 78f5021a2..6f7aec8f9 100644 --- a/src/core/core_cpu.h +++ b/src/core/core_cpu.h @@ -13,7 +13,7 @@ namespace Kernel { class GlobalScheduler; -class Scheduler; +class PhysicalCore; } // namespace Kernel namespace Core { @@ -30,32 +30,11 @@ class Memory; namespace Core { -class ARM_Interface; -class ExclusiveMonitor; - constexpr unsigned NUM_CPU_CORES{4}; -class CpuBarrier { -public: - bool IsAlive() const { - return !end; - } - - void NotifyEnd(); - - bool Rendezvous(); - -private: - unsigned cores_waiting{NUM_CPU_CORES}; - std::mutex mutex; - std::condition_variable condition; - std::atomic end{}; -}; - class Cpu { public: - Cpu(System& system, ExclusiveMonitor& exclusive_monitor, CpuBarrier& cpu_barrier, - std::size_t core_index); + Cpu(System& system, std::size_t core_index); ~Cpu(); void RunLoop(bool tight_loop = true); @@ -64,22 +43,6 @@ public: void PrepareReschedule(); - ARM_Interface& ArmInterface() { - return *arm_interface; - } - - const ARM_Interface& ArmInterface() const { - return *arm_interface; - } - - Kernel::Scheduler& Scheduler() { - return *scheduler; - } - - const Kernel::Scheduler& Scheduler() const { - return *scheduler; - } - bool IsMainCore() const { return core_index == 0; } @@ -88,29 +51,11 @@ public: return core_index; } - void Shutdown(); - - /** - * Creates an exclusive monitor to handle exclusive reads/writes. - * - * @param memory The current memory subsystem that the monitor may wish - * to keep track of. - * - * @param num_cores The number of cores to assume about the CPU. - * - * @returns The constructed exclusive monitor instance, or nullptr if the current - * CPU backend is unable to use an exclusive monitor. - */ - static std::unique_ptr MakeExclusiveMonitor(Memory::Memory& memory, - std::size_t num_cores); - private: void Reschedule(); - std::unique_ptr arm_interface; - CpuBarrier& cpu_barrier; Kernel::GlobalScheduler& global_scheduler; - std::unique_ptr scheduler; + Kernel::PhysicalCore& physical_core; Timing::CoreTiming& core_timing; std::atomic reschedule_pending = false; -- cgit v1.2.3 From e4a1ead897575ee9222b4fc1021aaa9cc58f12c8 Mon Sep 17 00:00:00 2001 From: Fernando Sahmkow Date: Sun, 26 Jan 2020 14:07:22 -0400 Subject: Core: Refactor CpuCoreManager to CpuManager and Cpu to Core Manager. This commit instends on better naming the new purpose of this classes. --- src/core/core_cpu.h | 65 ----------------------------------------------------- 1 file changed, 65 deletions(-) delete mode 100644 src/core/core_cpu.h (limited to 'src/core/core_cpu.h') diff --git a/src/core/core_cpu.h b/src/core/core_cpu.h deleted file mode 100644 index 6f7aec8f9..000000000 --- a/src/core/core_cpu.h +++ /dev/null @@ -1,65 +0,0 @@ -// Copyright 2018 yuzu emulator team -// Licensed under GPLv2 or any later version -// Refer to the license.txt file included. - -#pragma once - -#include -#include -#include -#include -#include -#include "common/common_types.h" - -namespace Kernel { -class GlobalScheduler; -class PhysicalCore; -} // namespace Kernel - -namespace Core { -class System; -} - -namespace Core::Timing { -class CoreTiming; -} - -namespace Memory { -class Memory; -} - -namespace Core { - -constexpr unsigned NUM_CPU_CORES{4}; - -class Cpu { -public: - Cpu(System& system, std::size_t core_index); - ~Cpu(); - - void RunLoop(bool tight_loop = true); - - void SingleStep(); - - void PrepareReschedule(); - - bool IsMainCore() const { - return core_index == 0; - } - - std::size_t CoreIndex() const { - return core_index; - } - -private: - void Reschedule(); - - Kernel::GlobalScheduler& global_scheduler; - Kernel::PhysicalCore& physical_core; - Timing::CoreTiming& core_timing; - - std::atomic reschedule_pending = false; - std::size_t core_index; -}; - -} // namespace Core -- cgit v1.2.3