yuzu/src/core/hle/kernel/physical_core.cpp

67 lines
1.9 KiB
C++
Raw Normal View History

2020-01-24 20:38:20 +01:00
// Copyright 2020 yuzu Emulator Project
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
#include "common/spin_lock.h"
#include "core/arm/cpu_interrupt_handler.h"
#include "core/arm/dynarmic/arm_dynarmic_32.h"
#include "core/arm/dynarmic/arm_dynarmic_64.h"
#include "core/core.h"
#include "core/hle/kernel/kernel.h"
#include "core/hle/kernel/physical_core.h"
#include "core/hle/kernel/scheduler.h"
2020-01-24 20:38:20 +01:00
namespace Kernel {
PhysicalCore::PhysicalCore(std::size_t core_index, Core::System& system,
Kernel::Scheduler& scheduler, Core::CPUInterrupts& interrupts)
: core_index{core_index}, system{system}, scheduler{scheduler},
interrupts{interrupts}, guard{std::make_unique<Common::SpinLock>()} {}
2020-01-24 20:38:20 +01:00
2020-01-26 21:14:18 +01:00
PhysicalCore::~PhysicalCore() = default;
void PhysicalCore::Initialize([[maybe_unused]] bool is_64_bit) {
#ifdef ARCHITECTURE_x86_64
auto& kernel = system.Kernel();
if (is_64_bit) {
arm_interface = std::make_unique<Core::ARM_Dynarmic_64>(
system, interrupts, kernel.IsMulticore(), kernel.GetExclusiveMonitor(), core_index);
} else {
arm_interface = std::make_unique<Core::ARM_Dynarmic_32>(
system, interrupts, kernel.IsMulticore(), kernel.GetExclusiveMonitor(), core_index);
}
#else
#error Platform not supported yet.
#endif
}
void PhysicalCore::Run() {
arm_interface->Run();
}
void PhysicalCore::Idle() {
interrupts[core_index].AwaitInterrupt();
}
void PhysicalCore::Shutdown() {
scheduler.Shutdown();
}
2020-06-28 00:20:06 +02:00
bool PhysicalCore::IsInterrupted() const {
return interrupts[core_index].IsInterrupted();
2020-06-28 00:20:06 +02:00
}
void PhysicalCore::Interrupt() {
guard->lock();
interrupts[core_index].SetInterrupt(true);
guard->unlock();
}
void PhysicalCore::ClearInterrupt() {
guard->lock();
interrupts[core_index].SetInterrupt(false);
guard->unlock();
}
2020-01-24 20:38:20 +01:00
} // namespace Kernel