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

83 lines
1.7 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.
#pragma once
2020-01-26 21:14:18 +01:00
#include <cstddef>
#include <memory>
#include "core/arm/cpu_interrupt_handler.h"
namespace Common {
2020-05-09 00:53:13 +02:00
class SpinLock;
}
2020-01-24 20:38:20 +01:00
namespace Kernel {
class Scheduler;
} // namespace Kernel
namespace Core {
2020-01-24 20:38:20 +01:00
class ARM_Interface;
class ExclusiveMonitor;
class System;
} // namespace Core
2020-01-24 20:38:20 +01:00
namespace Kernel {
class PhysicalCore {
public:
2020-05-09 00:53:13 +02:00
PhysicalCore(Core::System& system, std::size_t id, Kernel::Scheduler& scheduler,
Core::CPUInterruptHandler& interrupt_handler);
2020-01-26 21:14:18 +01:00
~PhysicalCore();
2020-01-24 20:38:20 +01:00
PhysicalCore(const PhysicalCore&) = delete;
PhysicalCore& operator=(const PhysicalCore&) = delete;
PhysicalCore(PhysicalCore&&) = default;
PhysicalCore& operator=(PhysicalCore&&) = default;
void Idle();
/// Interrupt this physical core.
void Interrupt();
/// Clear this core's interrupt
void ClearInterrupt();
/// Check if this core is interrupted
bool IsInterrupted() const {
return interrupt_handler.IsInterrupted();
}
// Shutdown this physical core.
void Shutdown();
2020-01-24 20:38:20 +01:00
bool IsMainCore() const {
return core_index == 0;
}
bool IsSystemCore() const {
return core_index == 3;
}
std::size_t CoreIndex() const {
return core_index;
}
Kernel::Scheduler& Scheduler() {
return scheduler;
2020-01-24 20:38:20 +01:00
}
const Kernel::Scheduler& Scheduler() const {
return scheduler;
2020-01-24 20:38:20 +01:00
}
private:
2020-02-29 18:58:50 +01:00
Core::CPUInterruptHandler& interrupt_handler;
2020-01-24 20:38:20 +01:00
std::size_t core_index;
Kernel::Scheduler& scheduler;
2020-02-29 18:58:50 +01:00
std::unique_ptr<Common::SpinLock> guard;
};
2020-01-24 20:38:20 +01:00
} // namespace Kernel