mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-05-31 07:43:16 +00:00
Initial support for compiling on ARM64. (#788)
This commit is contained in:
parent
adfb3af95f
commit
411449cd51
12 changed files with 166 additions and 25 deletions
10
src/common/arch.h
Normal file
10
src/common/arch.h
Normal file
|
@ -0,0 +1,10 @@
|
|||
// SPDX-FileCopyrightText: Copyright 2024 shadPS4 Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#pragma once
|
||||
|
||||
#if defined(__x86_64__) || defined(_M_X64)
|
||||
#define ARCH_X86_64 1
|
||||
#elif defined(__aarch64__) || defined(_M_ARM64)
|
||||
#define ARCH_ARM64 1
|
||||
#endif
|
|
@ -1,10 +1,17 @@
|
|||
// SPDX-FileCopyrightText: Copyright 2021 yuzu Emulator Project
|
||||
// SPDX-License-Identifier: GPL-2.0-or-later
|
||||
|
||||
#include "common/arch.h"
|
||||
#include "common/assert.h"
|
||||
#include "common/logging/backend.h"
|
||||
|
||||
#if defined(ARCH_X86_64)
|
||||
#define Crash() __asm__ __volatile__("int $3")
|
||||
#elif defined(ARCH_ARM64)
|
||||
#define Crash() __asm__ __volatile__("brk 0")
|
||||
#else
|
||||
#error "Missing Crash() implementation for target CPU architecture."
|
||||
#endif
|
||||
|
||||
void assert_fail_impl() {
|
||||
Common::Log::Stop();
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "common/arch.h"
|
||||
|
||||
#ifdef _MSC_VER
|
||||
#include <intrin.h>
|
||||
#endif
|
||||
|
@ -13,15 +15,20 @@ namespace Common {
|
|||
|
||||
#ifdef _MSC_VER
|
||||
__forceinline static u64 FencedRDTSC() {
|
||||
#ifdef ARCH_X86_64
|
||||
_mm_lfence();
|
||||
_ReadWriteBarrier();
|
||||
const u64 result = __rdtsc();
|
||||
_mm_lfence();
|
||||
_ReadWriteBarrier();
|
||||
return result;
|
||||
#else
|
||||
#error "Missing FencedRDTSC() implementation for target CPU architecture."
|
||||
#endif
|
||||
}
|
||||
#else
|
||||
static inline u64 FencedRDTSC() {
|
||||
#ifdef ARCH_X86_64
|
||||
u64 eax;
|
||||
u64 edx;
|
||||
asm volatile("lfence\n\t"
|
||||
|
@ -29,6 +36,16 @@ static inline u64 FencedRDTSC() {
|
|||
"lfence\n\t"
|
||||
: "=a"(eax), "=d"(edx));
|
||||
return (edx << 32) | eax;
|
||||
#elif defined(ARCH_ARM64)
|
||||
u64 ret;
|
||||
asm volatile("isb\n\t"
|
||||
"mrs %0, cntvct_el0\n\t"
|
||||
"isb\n\t"
|
||||
: "=r"(ret)::"memory");
|
||||
return ret;
|
||||
#else
|
||||
#error "Missing FencedRDTSC() implementation for target CPU architecture."
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue