Files
eden/src/core/arm/arm_interface.h
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

114 lines
3.4 KiB
C++
Raw Normal View History

2022-05-15 02:06:02 +02:00
// SPDX-FileCopyrightText: 2014 Citra Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
2014-04-04 22:26:06 -04:00
#pragma once
2018-01-09 21:33:46 +00:00
#include <array>
2022-06-06 12:56:01 -04:00
#include <span>
2023-02-05 14:22:02 -05:00
#include <string>
2019-05-17 21:43:26 -04:00
#include <vector>
#include "common/common_funcs.h"
#include "common/common_types.h"
2020-02-29 13:58:50 -04:00
#include "core/hardware_properties.h"
2023-11-28 14:30:39 -05:00
#include "core/hle/kernel/svc_types.h"
namespace Common {
struct PageTable;
}
namespace Kernel {
2022-06-06 12:56:01 -04:00
enum class DebugWatchpointType : u8;
struct DebugWatchpoint;
2023-11-28 14:30:39 -05:00
class KThread;
class KProcess;
2022-06-06 12:56:01 -04:00
} // namespace Kernel
2014-04-04 22:26:06 -04:00
namespace Core {
2022-06-06 12:56:01 -04:00
using WatchpointArray = std::array<Kernel::DebugWatchpoint, Core::Hardware::NUM_WATCHPOINTS>;
2020-02-29 13:58:50 -04:00
2023-06-12 21:34:25 -04:00
// NOTE: these values match the HaltReason enum in Dynarmic
enum class HaltReason : u64 {
StepThread = 0x00000001,
DataAbort = 0x00000004,
BreakLoop = 0x02000000,
SupervisorCall = 0x04000000,
InstructionBreakpoint = 0x08000000,
PrefetchAbort = 0x20000000,
};
DECLARE_ENUM_FLAG_OPERATORS(HaltReason);
enum class Architecture {
2023-11-28 14:30:39 -05:00
AArch64,
AArch32,
2023-06-12 21:34:25 -04:00
};
/// Generic ARMv8 CPU interface
2023-11-28 14:30:39 -05:00
class ArmInterface {
2014-04-04 22:26:06 -04:00
public:
2023-11-28 14:30:39 -05:00
YUZU_NON_COPYABLE(ArmInterface);
YUZU_NON_MOVEABLE(ArmInterface);
explicit ArmInterface(bool uses_wall_clock) : m_uses_wall_clock{uses_wall_clock} {}
virtual ~ArmInterface() = default;
// Perform any backend-specific initialization.
virtual void Initialize() {}
2023-11-28 14:30:39 -05:00
// Runs the CPU until an event happens.
virtual HaltReason RunThread(Kernel::KThread* thread) = 0;
2023-11-28 14:30:39 -05:00
// Runs the CPU for one instruction or until an event happens.
virtual HaltReason StepThread(Kernel::KThread* thread) = 0;
// Admits a backend-specific mechanism to lock the thread context.
virtual void LockThread(Kernel::KThread* thread) {}
virtual void UnlockThread(Kernel::KThread* thread) {}
// Clear the entire instruction cache for this CPU.
2016-06-27 21:38:49 +03:00
virtual void ClearInstructionCache() = 0;
2023-11-28 14:30:39 -05:00
// Clear a range of the instruction cache for this CPU.
2023-03-17 21:26:04 -04:00
virtual void InvalidateCacheRange(u64 addr, std::size_t size) = 0;
2023-11-28 14:30:39 -05:00
// Get the current architecture.
// This returns AArch64 when PSTATE.nRW == 0 and AArch32 when PSTATE.nRW == 1.
2023-06-12 21:34:25 -04:00
virtual Architecture GetArchitecture() const = 0;
2023-11-28 14:30:39 -05:00
// Context accessors.
// These should not be called if the CPU is running.
virtual void GetContext(Kernel::Svc::ThreadContext& ctx) const = 0;
virtual void SetContext(const Kernel::Svc::ThreadContext& ctx) = 0;
virtual void SetTpidrroEl0(u64 value) = 0;
2023-11-28 14:30:39 -05:00
virtual void GetSvcArguments(std::span<uint64_t, 8> args) const = 0;
virtual void SetSvcArguments(std::span<const uint64_t, 8> args) = 0;
virtual u32 GetSvcNumber() const = 0;
2022-04-03 16:29:05 +01:00
2023-11-28 14:30:39 -05:00
void SetWatchpointArray(const WatchpointArray* watchpoints) {
m_watchpoints = watchpoints;
}
2022-07-07 20:06:46 -04:00
2023-11-28 14:30:39 -05:00
// Signal an interrupt for execution to halt as soon as possible.
// It is safe to call this if the CPU is not running.
virtual void SignalInterrupt(Kernel::KThread* thread) = 0;
2019-05-17 21:43:26 -04:00
2023-11-28 14:30:39 -05:00
// Stack trace generation.
void LogBacktrace(Kernel::KProcess* process) const;
2023-11-28 14:30:39 -05:00
// Debug functionality.
virtual const Kernel::DebugWatchpoint* HaltedWatchpoint() const = 0;
virtual void RewindBreakpointInstruction() = 0;
protected:
2022-06-06 12:56:01 -04:00
const Kernel::DebugWatchpoint* MatchingWatchpoint(
2023-03-17 21:26:04 -04:00
u64 addr, u64 size, Kernel::DebugWatchpointType access_type) const;
2023-11-28 14:30:39 -05:00
protected:
const WatchpointArray* m_watchpoints{};
bool m_uses_wall_clock{};
2014-04-04 22:26:06 -04:00
};
} // namespace Core