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>
|
|
|
|
|
2020-02-25 03:04:12 +01:00
|
|
|
#include "core/arm/cpu_interrupt_handler.h"
|
|
|
|
|
|
|
|
namespace Common {
|
|
|
|
class SpinLock;
|
|
|
|
}
|
|
|
|
|
2020-01-24 20:38:20 +01:00
|
|
|
namespace Kernel {
|
|
|
|
class Scheduler;
|
|
|
|
} // namespace Kernel
|
|
|
|
|
2020-01-25 23:55:32 +01:00
|
|
|
namespace Core {
|
2020-01-24 20:38:20 +01:00
|
|
|
class ARM_Interface;
|
|
|
|
class ExclusiveMonitor;
|
2020-01-25 23:55:32 +01:00
|
|
|
class System;
|
|
|
|
} // namespace Core
|
2020-01-24 20:38:20 +01:00
|
|
|
|
|
|
|
namespace Kernel {
|
|
|
|
|
|
|
|
class PhysicalCore {
|
|
|
|
public:
|
2020-01-31 00:19:21 +01:00
|
|
|
PhysicalCore(Core::System& system, std::size_t id, Core::ExclusiveMonitor& exclusive_monitor);
|
2020-01-26 21:14:18 +01:00
|
|
|
~PhysicalCore();
|
2020-01-24 20:38:20 +01:00
|
|
|
|
2020-01-31 00:38:28 +01:00
|
|
|
PhysicalCore(const PhysicalCore&) = delete;
|
|
|
|
PhysicalCore& operator=(const PhysicalCore&) = delete;
|
|
|
|
|
|
|
|
PhysicalCore(PhysicalCore&&) = default;
|
|
|
|
PhysicalCore& operator=(PhysicalCore&&) = default;
|
|
|
|
|
2020-01-24 20:38:20 +01:00
|
|
|
/// Execute current jit state
|
|
|
|
void Run();
|
2020-02-26 15:44:21 +01:00
|
|
|
/// Clear Exclusive state.
|
|
|
|
void ClearExclusive();
|
2020-02-25 03:04:12 +01:00
|
|
|
/// Set this core in IdleState.
|
|
|
|
void Idle();
|
2020-01-24 20:38:20 +01:00
|
|
|
/// Execute a single instruction in current jit.
|
|
|
|
void Step();
|
|
|
|
/// Stop JIT execution/exit
|
|
|
|
void Stop();
|
|
|
|
|
2020-02-25 03:04:12 +01:00
|
|
|
/// 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();
|
|
|
|
}
|
|
|
|
|
2020-01-25 23:55:32 +01:00
|
|
|
// Shutdown this physical core.
|
|
|
|
void Shutdown();
|
|
|
|
|
|
|
|
Core::ARM_Interface& ArmInterface() {
|
2020-01-24 20:38:20 +01:00
|
|
|
return *arm_interface;
|
|
|
|
}
|
|
|
|
|
2020-01-25 23:55:32 +01:00
|
|
|
const Core::ARM_Interface& ArmInterface() const {
|
2020-01-24 20:38:20 +01:00
|
|
|
return *arm_interface;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool IsMainCore() const {
|
|
|
|
return core_index == 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool IsSystemCore() const {
|
|
|
|
return core_index == 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::size_t CoreIndex() const {
|
|
|
|
return core_index;
|
|
|
|
}
|
|
|
|
|
2020-01-25 23:55:32 +01:00
|
|
|
Kernel::Scheduler& Scheduler() {
|
2020-01-24 20:38:20 +01:00
|
|
|
return *scheduler;
|
|
|
|
}
|
|
|
|
|
2020-01-25 23:55:32 +01:00
|
|
|
const Kernel::Scheduler& Scheduler() const {
|
2020-01-24 20:38:20 +01:00
|
|
|
return *scheduler;
|
|
|
|
}
|
|
|
|
|
2020-03-02 05:46:10 +01:00
|
|
|
void SetIs64Bit(bool is_64_bit);
|
|
|
|
|
2020-01-24 20:38:20 +01:00
|
|
|
private:
|
2020-02-25 03:04:12 +01:00
|
|
|
Core::CPUInterruptHandler interrupt_handler;
|
2020-01-24 20:38:20 +01:00
|
|
|
std::size_t core_index;
|
2020-03-02 05:46:10 +01:00
|
|
|
std::unique_ptr<Core::ARM_Interface> arm_interface_32;
|
|
|
|
std::unique_ptr<Core::ARM_Interface> arm_interface_64;
|
2020-01-31 00:38:28 +01:00
|
|
|
std::unique_ptr<Kernel::Scheduler> scheduler;
|
2020-03-02 05:46:10 +01:00
|
|
|
Core::ARM_Interface* arm_interface{};
|
2020-02-25 03:04:12 +01:00
|
|
|
std::unique_ptr<Common::SpinLock> guard;
|
2020-01-25 23:55:32 +01:00
|
|
|
};
|
2020-01-24 20:38:20 +01:00
|
|
|
|
|
|
|
} // namespace Kernel
|