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

96 lines
2.0 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 <mutex>
2020-01-26 21:14:18 +01:00
#include "core/arm/arm_interface.h"
2020-01-24 20:38:20 +01:00
namespace Kernel {
class KScheduler;
2020-01-24 20:38:20 +01:00
} // namespace Kernel
namespace Core {
2020-06-28 00:20:06 +02:00
class CPUInterruptHandler;
2020-01-24 20:38:20 +01:00
class ExclusiveMonitor;
class System;
} // namespace Core
2020-01-24 20:38:20 +01:00
namespace Kernel {
class PhysicalCore {
public:
PhysicalCore(std::size_t core_index_, Core::System& system_, KScheduler& scheduler_,
Core::CPUInterrupts& interrupts_);
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&&) = delete;
/// Initialize the core for the specified parameters.
void Initialize(bool is_64_bit);
/// Execute current jit state
void Run();
void Idle();
/// Interrupt this physical core.
void Interrupt();
/// Clear this core's interrupt
void ClearInterrupt();
/// Check if this core is interrupted
2020-06-28 00:20:06 +02:00
bool IsInterrupted() const;
bool IsInitialized() const {
return arm_interface != nullptr;
}
Core::ARM_Interface& ArmInterface() {
return *arm_interface;
}
const Core::ARM_Interface& ArmInterface() const {
return *arm_interface;
}
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::KScheduler& Scheduler() {
return scheduler;
2020-01-24 20:38:20 +01:00
}
const Kernel::KScheduler& Scheduler() const {
return scheduler;
2020-01-24 20:38:20 +01:00
}
private:
const std::size_t core_index;
Core::System& system;
Kernel::KScheduler& scheduler;
Core::CPUInterrupts& interrupts;
std::unique_ptr<std::mutex> guard;
std::unique_ptr<Core::ARM_Interface> arm_interface;
};
2020-01-24 20:38:20 +01:00
} // namespace Kernel