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.
|
|
|
|
|
2020-02-25 03:04:12 +01:00
|
|
|
#include "common/spin_lock.h"
|
|
|
|
#include "core/arm/cpu_interrupt_handler.h"
|
2020-01-25 23:55:32 +01:00
|
|
|
#include "core/core.h"
|
|
|
|
#include "core/hle/kernel/physical_core.h"
|
|
|
|
#include "core/hle/kernel/scheduler.h"
|
|
|
|
|
2020-01-24 20:38:20 +01:00
|
|
|
namespace Kernel {
|
|
|
|
|
2020-03-01 17:14:17 +01:00
|
|
|
PhysicalCore::PhysicalCore(Core::System& system, std::size_t id, Kernel::Scheduler& scheduler,
|
|
|
|
Core::CPUInterruptHandler& interrupt_handler)
|
2020-11-04 01:54:53 +01:00
|
|
|
: interrupt_handler{interrupt_handler},
|
|
|
|
core_index{id}, scheduler{scheduler}, 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;
|
|
|
|
|
2020-02-25 03:04:12 +01:00
|
|
|
void PhysicalCore::Idle() {
|
|
|
|
interrupt_handler.AwaitInterrupt();
|
|
|
|
}
|
|
|
|
|
2020-01-25 23:55:32 +01:00
|
|
|
void PhysicalCore::Shutdown() {
|
2020-03-01 17:14:17 +01:00
|
|
|
scheduler.Shutdown();
|
2020-03-02 05:46:10 +01:00
|
|
|
}
|
|
|
|
|
2020-06-28 00:20:06 +02:00
|
|
|
bool PhysicalCore::IsInterrupted() const {
|
|
|
|
return interrupt_handler.IsInterrupted();
|
|
|
|
}
|
|
|
|
|
2020-02-25 03:04:12 +01:00
|
|
|
void PhysicalCore::Interrupt() {
|
|
|
|
guard->lock();
|
|
|
|
interrupt_handler.SetInterrupt(true);
|
|
|
|
guard->unlock();
|
|
|
|
}
|
|
|
|
|
|
|
|
void PhysicalCore::ClearInterrupt() {
|
|
|
|
guard->lock();
|
|
|
|
interrupt_handler.SetInterrupt(false);
|
|
|
|
guard->unlock();
|
|
|
|
}
|
|
|
|
|
2020-01-24 20:38:20 +01:00
|
|
|
} // namespace Kernel
|