2022-04-23 10:59:50 +02:00
|
|
|
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2020-01-24 20:38:20 +01:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2020-01-26 21:14:18 +01:00
|
|
|
#include <cstddef>
|
|
|
|
#include <memory>
|
2022-04-08 01:01:26 +02:00
|
|
|
#include <mutex>
|
2020-01-26 21:14:18 +01:00
|
|
|
|
2020-11-13 20:11:12 +01:00
|
|
|
#include "core/arm/arm_interface.h"
|
|
|
|
|
2020-01-24 20:38:20 +01:00
|
|
|
namespace Kernel {
|
2020-12-03 03:08:35 +01:00
|
|
|
class KScheduler;
|
2020-01-24 20:38:20 +01:00
|
|
|
} // namespace Kernel
|
|
|
|
|
2020-01-25 23:55:32 +01:00
|
|
|
namespace Core {
|
2020-01-24 20:38:20 +01:00
|
|
|
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:
|
2022-07-08 02:06:46 +02:00
|
|
|
PhysicalCore(std::size_t core_index_, Core::System& system_, KScheduler& scheduler_);
|
2020-01-26 21:14:18 +01:00
|
|
|
~PhysicalCore();
|
2020-01-24 20:38:20 +01:00
|
|
|
|
2022-07-08 02:06:46 +02:00
|
|
|
YUZU_NON_COPYABLE(PhysicalCore);
|
|
|
|
YUZU_NON_MOVEABLE(PhysicalCore);
|
2020-01-31 00:38:28 +01:00
|
|
|
|
2020-11-13 20:11:12 +01:00
|
|
|
/// Initialize the core for the specified parameters.
|
|
|
|
void Initialize(bool is_64_bit);
|
|
|
|
|
|
|
|
/// Execute current jit state
|
|
|
|
void Run();
|
|
|
|
|
2020-02-25 03:04:12 +01:00
|
|
|
void Idle();
|
2020-11-13 20:11:12 +01:00
|
|
|
|
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
|
2020-06-28 00:20:06 +02:00
|
|
|
bool IsInterrupted() const;
|
2020-02-25 03:04:12 +01:00
|
|
|
|
2020-11-14 08:20:32 +01:00
|
|
|
bool IsInitialized() const {
|
|
|
|
return arm_interface != nullptr;
|
|
|
|
}
|
|
|
|
|
2020-11-13 20:11:12 +01:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2020-12-03 03:08:35 +01:00
|
|
|
Kernel::KScheduler& Scheduler() {
|
2020-03-01 17:14:17 +01:00
|
|
|
return scheduler;
|
2020-01-24 20:38:20 +01:00
|
|
|
}
|
|
|
|
|
2020-12-03 03:08:35 +01:00
|
|
|
const Kernel::KScheduler& Scheduler() const {
|
2020-03-01 17:14:17 +01:00
|
|
|
return scheduler;
|
2020-01-24 20:38:20 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2020-11-13 20:11:12 +01:00
|
|
|
const std::size_t core_index;
|
|
|
|
Core::System& system;
|
2020-12-03 03:08:35 +01:00
|
|
|
Kernel::KScheduler& scheduler;
|
2022-07-08 02:06:46 +02:00
|
|
|
|
|
|
|
std::mutex guard;
|
|
|
|
std::condition_variable on_interrupt;
|
2020-11-13 20:11:12 +01:00
|
|
|
std::unique_ptr<Core::ARM_Interface> arm_interface;
|
2022-07-08 02:06:46 +02:00
|
|
|
bool is_interrupted;
|
2020-01-25 23:55:32 +01:00
|
|
|
};
|
2020-01-24 20:38:20 +01:00
|
|
|
|
|
|
|
} // namespace Kernel
|