general: remove references to single core mode
This commit is contained in:
@@ -42,11 +42,6 @@ void GlobalSchedulerContext::PreemptThreads() {
|
||||
for (u32 core_id = 0; core_id < Core::Hardware::NUM_CPU_CORES; core_id++) {
|
||||
const u32 priority = preemption_priorities[core_id];
|
||||
KScheduler::RotateScheduledQueue(kernel, core_id, priority);
|
||||
|
||||
// Signal an interrupt occurred. For core 3, this is a certainty, as preemption will result
|
||||
// in the rotator thread being scheduled. For cores 0-2, this is to simulate or system
|
||||
// interrupts that may have occurred.
|
||||
kernel.PhysicalCore(core_id).Interrupt();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -125,9 +125,9 @@ void KScheduler::RescheduleCurrentCoreImpl() {
|
||||
}
|
||||
}
|
||||
|
||||
void KScheduler::Initialize(KThread* idle_thread) {
|
||||
void KScheduler::Initialize(KThread* main_thread, KThread* idle_thread, s32 core_id) {
|
||||
// Set core ID/idle thread/interrupt task manager.
|
||||
m_core_id = GetCurrentCoreId(kernel);
|
||||
m_core_id = core_id;
|
||||
m_idle_thread = idle_thread;
|
||||
// m_state.idle_thread_stack = m_idle_thread->GetStackTop();
|
||||
// m_state.interrupt_task_manager = &kernel.GetInterruptTaskManager();
|
||||
@@ -145,7 +145,7 @@ void KScheduler::Initialize(KThread* idle_thread) {
|
||||
// KInterruptController::PriorityLevel_Scheduler, false, false);
|
||||
|
||||
// Set the current thread.
|
||||
m_current_thread = GetCurrentThreadPointer(kernel);
|
||||
m_current_thread = main_thread;
|
||||
}
|
||||
|
||||
void KScheduler::Activate() {
|
||||
@@ -389,8 +389,7 @@ void KScheduler::ScheduleImplOffStack() {
|
||||
|
||||
// Save the original thread context.
|
||||
{
|
||||
auto& physical_core = kernel.System().CurrentPhysicalCore();
|
||||
auto& cpu_core = physical_core.ArmInterface();
|
||||
auto& cpu_core = kernel.System().CurrentArmInterface();
|
||||
cpu_core.SaveContext(cur_thread->GetContext32());
|
||||
cpu_core.SaveContext(cur_thread->GetContext64());
|
||||
// Save the TPIDR_EL0 system register in case it was modified.
|
||||
|
||||
@@ -41,12 +41,16 @@ public:
|
||||
explicit KScheduler(KernelCore& kernel);
|
||||
~KScheduler();
|
||||
|
||||
void Initialize(KThread* idle_thread);
|
||||
void Initialize(KThread* main_thread, KThread* idle_thread, s32 core_id);
|
||||
void Activate();
|
||||
|
||||
void SetInterruptTaskRunnable();
|
||||
void RequestScheduleOnInterrupt();
|
||||
|
||||
void ScheduleOnPreemption() {
|
||||
ScheduleOnInterrupt();
|
||||
}
|
||||
|
||||
u64 GetIdleCount() {
|
||||
return m_state.idle_count;
|
||||
}
|
||||
|
||||
@@ -252,7 +252,6 @@ Result KThread::InitializeThread(KThread* thread, KThreadFunction func, uintptr_
|
||||
|
||||
// Initialize emulation parameters.
|
||||
thread->host_context = std::make_shared<Common::Fiber>(std::move(init_func));
|
||||
thread->is_single_core = !Settings::values.use_multi_core.GetValue();
|
||||
|
||||
return ResultSuccess;
|
||||
}
|
||||
@@ -1189,7 +1188,7 @@ KThread& GetCurrentThread(KernelCore& kernel) {
|
||||
}
|
||||
|
||||
s32 GetCurrentCoreId(KernelCore& kernel) {
|
||||
return GetCurrentThread(kernel).GetCurrentCore();
|
||||
return static_cast<s32>(kernel.CurrentPhysicalCoreIndex());
|
||||
}
|
||||
|
||||
KScopedDisableDispatch::~KScopedDisableDispatch() {
|
||||
@@ -1198,11 +1197,6 @@ KScopedDisableDispatch::~KScopedDisableDispatch() {
|
||||
return;
|
||||
}
|
||||
|
||||
// Skip the reschedule if single-core, as dispatch tracking is disabled here.
|
||||
if (!Settings::values.use_multi_core.GetValue()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (GetCurrentThread(kernel).GetDisableDispatchCount() <= 1) {
|
||||
auto scheduler = kernel.CurrentScheduler();
|
||||
|
||||
|
||||
@@ -490,7 +490,7 @@ public:
|
||||
}
|
||||
|
||||
[[nodiscard]] bool IsDispatchTrackingDisabled() const {
|
||||
return is_single_core || IsKernelThread();
|
||||
return IsKernelThread();
|
||||
}
|
||||
|
||||
[[nodiscard]] s32 GetDisableDispatchCount() const {
|
||||
@@ -795,7 +795,6 @@ private:
|
||||
|
||||
// For emulation
|
||||
std::shared_ptr<Common::Fiber> host_context{};
|
||||
bool is_single_core{};
|
||||
ThreadType thread_type{};
|
||||
StepState step_state{};
|
||||
std::mutex dummy_wait_lock;
|
||||
|
||||
@@ -51,10 +51,6 @@ struct KernelCore::Impl {
|
||||
: time_manager{system_},
|
||||
service_threads_manager{1, "yuzu:ServiceThreadsManager"}, system{system_} {}
|
||||
|
||||
void SetMulticore(bool is_multi) {
|
||||
is_multicore = is_multi;
|
||||
}
|
||||
|
||||
void Initialize(KernelCore& kernel) {
|
||||
global_object_list_container = std::make_unique<KAutoObjectWithListContainer>(kernel);
|
||||
global_scheduler_context = std::make_unique<Kernel::GlobalSchedulerContext>(kernel);
|
||||
@@ -62,10 +58,6 @@ struct KernelCore::Impl {
|
||||
global_handle_table->Initialize(KHandleTable::MaxTableSize);
|
||||
default_service_thread = CreateServiceThread(kernel, "DefaultServiceThread");
|
||||
|
||||
is_phantom_mode_for_singlecore = false;
|
||||
|
||||
InitializePhysicalCores();
|
||||
|
||||
// Derive the initial memory layout from the emulated board
|
||||
Init::InitializeSlabResourceCounts(kernel);
|
||||
DeriveInitialMemoryLayout();
|
||||
@@ -76,6 +68,7 @@ struct KernelCore::Impl {
|
||||
InitializeMemoryLayout();
|
||||
Init::InitializeKPageBufferSlabHeap(system);
|
||||
InitializeShutdownThreads();
|
||||
InitializePhysicalCores();
|
||||
InitializePreemption(kernel);
|
||||
|
||||
RegisterHostThread();
|
||||
@@ -195,6 +188,18 @@ struct KernelCore::Impl {
|
||||
for (u32 i = 0; i < Core::Hardware::NUM_CPU_CORES; i++) {
|
||||
schedulers[i] = std::make_unique<Kernel::KScheduler>(system.Kernel());
|
||||
cores.emplace_back(i, system, *schedulers[i], interrupts);
|
||||
|
||||
auto* main_thread = KThread::Create(system.Kernel());
|
||||
main_thread->SetName(fmt::format("MainThread:{}", i));
|
||||
main_thread->SetCurrentCore(static_cast<s32>(i));
|
||||
ASSERT(KThread::InitializeMainThread(system, main_thread, static_cast<s32>(i))
|
||||
.IsSuccess());
|
||||
|
||||
auto* idle_thread = KThread::Create(system.Kernel());
|
||||
ASSERT(Kernel::KThread::InitializeIdleThread(system, idle_thread, static_cast<s32>(i))
|
||||
.IsSuccess());
|
||||
|
||||
schedulers[i]->Initialize(main_thread, idle_thread, i);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -290,10 +295,7 @@ struct KernelCore::Impl {
|
||||
/// Registers a CPU core thread by allocating a host thread ID for it
|
||||
void RegisterCoreThread(std::size_t core_id) {
|
||||
ASSERT(core_id < Core::Hardware::NUM_CPU_CORES);
|
||||
const auto this_id = GetHostThreadId(core_id);
|
||||
if (!is_multicore) {
|
||||
single_core_thread_id = this_id;
|
||||
}
|
||||
[[maybe_unused]] const auto this_id = GetHostThreadId(core_id);
|
||||
}
|
||||
|
||||
/// Registers a new host thread by allocating a host thread ID for it
|
||||
@@ -303,20 +305,7 @@ struct KernelCore::Impl {
|
||||
}
|
||||
|
||||
[[nodiscard]] u32 GetCurrentHostThreadID() {
|
||||
const auto this_id = GetHostThreadId();
|
||||
if (!is_multicore && single_core_thread_id == this_id) {
|
||||
return static_cast<u32>(system.GetCpuManager().CurrentCore());
|
||||
}
|
||||
return this_id;
|
||||
}
|
||||
|
||||
bool IsPhantomModeForSingleCore() const {
|
||||
return is_phantom_mode_for_singlecore;
|
||||
}
|
||||
|
||||
void SetIsPhantomModeForSingleCore(bool value) {
|
||||
ASSERT(!is_multicore);
|
||||
is_phantom_mode_for_singlecore = value;
|
||||
return GetHostThreadId();
|
||||
}
|
||||
|
||||
bool IsShuttingDown() const {
|
||||
@@ -771,10 +760,7 @@ struct KernelCore::Impl {
|
||||
std::array<Core::CPUInterruptHandler, Core::Hardware::NUM_CPU_CORES> interrupts{};
|
||||
std::array<std::unique_ptr<Kernel::KScheduler>, Core::Hardware::NUM_CPU_CORES> schedulers{};
|
||||
|
||||
bool is_multicore{};
|
||||
std::atomic_bool is_shutting_down{};
|
||||
bool is_phantom_mode_for_singlecore{};
|
||||
u32 single_core_thread_id{};
|
||||
|
||||
std::array<u64, Core::Hardware::NUM_CPU_CORES> svc_ticks{};
|
||||
|
||||
@@ -787,10 +773,6 @@ struct KernelCore::Impl {
|
||||
KernelCore::KernelCore(Core::System& system) : impl{std::make_unique<Impl>(system, *this)} {}
|
||||
KernelCore::~KernelCore() = default;
|
||||
|
||||
void KernelCore::SetMulticore(bool is_multicore) {
|
||||
impl->SetMulticore(is_multicore);
|
||||
}
|
||||
|
||||
void KernelCore::Initialize() {
|
||||
slab_heap_container = std::make_unique<SlabHeapContainer>();
|
||||
impl->Initialize(*this);
|
||||
@@ -1098,10 +1080,6 @@ void KernelCore::ShutdownCores() {
|
||||
InterruptAllPhysicalCores();
|
||||
}
|
||||
|
||||
bool KernelCore::IsMulticore() const {
|
||||
return impl->is_multicore;
|
||||
}
|
||||
|
||||
bool KernelCore::IsShuttingDown() const {
|
||||
return impl->IsShuttingDown();
|
||||
}
|
||||
@@ -1151,14 +1129,6 @@ const KMemoryLayout& KernelCore::MemoryLayout() const {
|
||||
return *impl->memory_layout;
|
||||
}
|
||||
|
||||
bool KernelCore::IsPhantomModeForSingleCore() const {
|
||||
return impl->IsPhantomModeForSingleCore();
|
||||
}
|
||||
|
||||
void KernelCore::SetIsPhantomModeForSingleCore(bool value) {
|
||||
impl->SetIsPhantomModeForSingleCore(value);
|
||||
}
|
||||
|
||||
Core::System& KernelCore::System() {
|
||||
return impl->system;
|
||||
}
|
||||
|
||||
@@ -97,9 +97,6 @@ public:
|
||||
KernelCore(KernelCore&&) = delete;
|
||||
KernelCore& operator=(KernelCore&&) = delete;
|
||||
|
||||
/// Sets if emulation is multicore or single core, must be set before Initialize
|
||||
void SetMulticore(bool is_multicore);
|
||||
|
||||
/// Resets the kernel to a clean slate for use.
|
||||
void Initialize();
|
||||
|
||||
@@ -283,8 +280,6 @@ public:
|
||||
/// Notify emulated CPU cores to shut down.
|
||||
void ShutdownCores();
|
||||
|
||||
bool IsMulticore() const;
|
||||
|
||||
bool IsShuttingDown() const;
|
||||
|
||||
void EnterSVCProfile();
|
||||
@@ -318,10 +313,6 @@ public:
|
||||
*/
|
||||
void ReleaseServiceThread(std::weak_ptr<Kernel::ServiceThread> service_thread);
|
||||
|
||||
/// Workaround for single-core mode when preempting threads while idle.
|
||||
bool IsPhantomModeForSingleCore() const;
|
||||
void SetIsPhantomModeForSingleCore(bool value);
|
||||
|
||||
Core::System& System();
|
||||
const Core::System& System() const;
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ PhysicalCore::PhysicalCore(std::size_t core_index_, Core::System& system_, KSche
|
||||
// a 32-bit instance of Dynarmic. This should be abstracted out to a CPU manager.
|
||||
auto& kernel = system.Kernel();
|
||||
arm_interface = std::make_unique<Core::ARM_Dynarmic_64>(
|
||||
system, interrupts, kernel.IsMulticore(), kernel.GetExclusiveMonitor(), core_index);
|
||||
system, interrupts, kernel.GetExclusiveMonitor(), core_index);
|
||||
#else
|
||||
#error Platform not supported yet.
|
||||
#endif
|
||||
@@ -34,7 +34,7 @@ void PhysicalCore::Initialize([[maybe_unused]] bool is_64_bit) {
|
||||
if (!is_64_bit) {
|
||||
// We already initialized a 64-bit core, replace with a 32-bit one.
|
||||
arm_interface = std::make_unique<Core::ARM_Dynarmic_32>(
|
||||
system, interrupts, kernel.IsMulticore(), kernel.GetExclusiveMonitor(), core_index);
|
||||
system, interrupts, kernel.GetExclusiveMonitor(), core_index);
|
||||
}
|
||||
#else
|
||||
#error Platform not supported yet.
|
||||
|
||||
@@ -2102,16 +2102,8 @@ static void ChangeKernelTraceState([[maybe_unused]] Core::System& system,
|
||||
static u64 GetSystemTick(Core::System& system) {
|
||||
LOG_TRACE(Kernel_SVC, "called");
|
||||
|
||||
auto& core_timing = system.CoreTiming();
|
||||
|
||||
// Returns the value of cntpct_el0 (https://switchbrew.org/wiki/SVC#svcGetSystemTick)
|
||||
const u64 result{system.CoreTiming().GetClockTicks()};
|
||||
|
||||
if (!system.Kernel().IsMulticore()) {
|
||||
core_timing.AddTicks(400U);
|
||||
}
|
||||
|
||||
return result;
|
||||
return system.CoreTiming().GetClockTicks();
|
||||
}
|
||||
|
||||
static void GetSystemTick32(Core::System& system, u32* time_low, u32* time_high) {
|
||||
|
||||
Reference in New Issue
Block a user