2022-04-23 08:59:50 +00:00
|
|
|
// SPDX-FileCopyrightText: Copyright 2020 yuzu Emulator Project
|
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2020-01-24 19:38:20 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2023-02-06 18:14:27 +00:00
|
|
|
#include <condition_variable>
|
2020-01-26 20:14:18 +00:00
|
|
|
#include <cstddef>
|
|
|
|
#include <memory>
|
2022-04-07 23:01:26 +00:00
|
|
|
#include <mutex>
|
2020-01-26 20:14:18 +00:00
|
|
|
|
2020-11-13 19:11:12 +00:00
|
|
|
#include "core/arm/arm_interface.h"
|
|
|
|
|
2020-01-24 19:38:20 +00:00
|
|
|
namespace Kernel {
|
2023-11-28 19:30:39 +00:00
|
|
|
class KernelCore;
|
2020-01-24 19:38:20 +00:00
|
|
|
} // namespace Kernel
|
|
|
|
|
2020-01-25 22:55:32 +00:00
|
|
|
namespace Core {
|
2020-01-24 19:38:20 +00:00
|
|
|
class ExclusiveMonitor;
|
2020-01-25 22:55:32 +00:00
|
|
|
class System;
|
|
|
|
} // namespace Core
|
2020-01-24 19:38:20 +00:00
|
|
|
|
|
|
|
namespace Kernel {
|
|
|
|
|
|
|
|
class PhysicalCore {
|
|
|
|
public:
|
2023-11-28 19:30:39 +00:00
|
|
|
PhysicalCore(KernelCore& kernel, std::size_t core_index);
|
2020-01-26 20:14:18 +00:00
|
|
|
~PhysicalCore();
|
2020-01-24 19:38:20 +00:00
|
|
|
|
2022-07-08 00:06:46 +00:00
|
|
|
YUZU_NON_COPYABLE(PhysicalCore);
|
|
|
|
YUZU_NON_MOVEABLE(PhysicalCore);
|
2020-01-30 23:38:28 +00:00
|
|
|
|
2023-11-28 19:30:39 +00:00
|
|
|
// Execute guest code running on the given thread.
|
|
|
|
void RunThread(KThread* thread);
|
2020-11-13 19:11:12 +00:00
|
|
|
|
2023-11-28 19:30:39 +00:00
|
|
|
// Copy context from thread to current core.
|
|
|
|
void LoadContext(const KThread* thread);
|
|
|
|
void LoadSvcArguments(const KProcess& process, std::span<const uint64_t, 8> args);
|
2020-11-13 19:11:12 +00:00
|
|
|
|
2023-11-28 19:30:39 +00:00
|
|
|
// Copy context from current core to thread.
|
|
|
|
void SaveContext(KThread* thread) const;
|
|
|
|
void SaveSvcArguments(KProcess& process, std::span<uint64_t, 8> args) const;
|
|
|
|
|
|
|
|
// Copy floating point status registers to the target thread.
|
|
|
|
void CloneFpuStatus(KThread* dst) const;
|
|
|
|
|
|
|
|
// Log backtrace of current processor state.
|
|
|
|
void LogBacktrace();
|
|
|
|
|
|
|
|
// Wait for an interrupt.
|
2020-02-25 02:04:12 +00:00
|
|
|
void Idle();
|
2020-11-13 19:11:12 +00:00
|
|
|
|
2023-11-28 19:30:39 +00:00
|
|
|
// Interrupt this core.
|
2020-02-25 02:04:12 +00:00
|
|
|
void Interrupt();
|
|
|
|
|
2023-11-28 19:30:39 +00:00
|
|
|
// Clear this core's interrupt.
|
2020-02-25 02:04:12 +00:00
|
|
|
void ClearInterrupt();
|
|
|
|
|
2023-11-28 19:30:39 +00:00
|
|
|
// Check if this core is interrupted.
|
2020-06-27 22:20:06 +00:00
|
|
|
bool IsInterrupted() const;
|
2020-02-25 02:04:12 +00:00
|
|
|
|
2020-01-24 19:38:20 +00:00
|
|
|
std::size_t CoreIndex() const {
|
2023-03-07 04:08:53 +00:00
|
|
|
return m_core_index;
|
2020-01-24 19:38:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2023-11-28 19:30:39 +00:00
|
|
|
KernelCore& m_kernel;
|
2023-03-07 04:08:53 +00:00
|
|
|
const std::size_t m_core_index;
|
|
|
|
|
|
|
|
std::mutex m_guard;
|
|
|
|
std::condition_variable m_on_interrupt;
|
2023-11-28 19:30:39 +00:00
|
|
|
Core::ArmInterface* m_arm_interface{};
|
|
|
|
KThread* m_current_thread{};
|
2023-03-07 04:08:53 +00:00
|
|
|
bool m_is_interrupted{};
|
2023-11-28 19:30:39 +00:00
|
|
|
bool m_is_single_core{};
|
2020-01-25 22:55:32 +00:00
|
|
|
};
|
2020-01-24 19:38:20 +00:00
|
|
|
|
|
|
|
} // namespace Kernel
|