mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-03 13:31:27 +12:00
aarch64: Fix compilation for windows-on-arm
This commit is contained in:
parent
23f9eb57e5
commit
a60eab6e36
8 changed files with 64 additions and 9 deletions
|
@ -1840,10 +1840,18 @@ static LONG exception_filter(PEXCEPTION_POINTERS pExp) noexcept
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt::append(msg, "Instruction address: %p.\n", pExp->ContextRecord->Rip);
|
#if defined(ARCH_X64)
|
||||||
|
#define RIP(ctx) ctx->Rip
|
||||||
|
#elif defined(ARCH_ARM64)
|
||||||
|
#define RIP(ctx) ctx->Pc
|
||||||
|
#else
|
||||||
|
#error "Unimplemented exception handling for this architecture"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
fmt::append(msg, "Instruction address: %p.\n", RIP(pExp->ContextRecord));
|
||||||
|
|
||||||
DWORD64 unwind_base;
|
DWORD64 unwind_base;
|
||||||
if (const auto rtf = RtlLookupFunctionEntry(pExp->ContextRecord->Rip, &unwind_base, nullptr))
|
if (const auto rtf = RtlLookupFunctionEntry(RIP(pExp->ContextRecord), &unwind_base, nullptr))
|
||||||
{
|
{
|
||||||
// Get function address
|
// Get function address
|
||||||
const DWORD64 func_addr = rtf->BeginAddress + unwind_base;
|
const DWORD64 func_addr = rtf->BeginAddress + unwind_base;
|
||||||
|
@ -1860,7 +1868,7 @@ static LONG exception_filter(PEXCEPTION_POINTERS pExp) noexcept
|
||||||
{
|
{
|
||||||
const DWORD64 base = reinterpret_cast<DWORD64>(info.lpBaseOfDll);
|
const DWORD64 base = reinterpret_cast<DWORD64>(info.lpBaseOfDll);
|
||||||
|
|
||||||
if (pExp->ContextRecord->Rip >= base && pExp->ContextRecord->Rip < base + info.SizeOfImage)
|
if (RIP(pExp->ContextRecord) >= base && RIP(pExp->ContextRecord) < base + info.SizeOfImage)
|
||||||
{
|
{
|
||||||
std::string module_name;
|
std::string module_name;
|
||||||
for (DWORD size = 15; module_name.size() != size;)
|
for (DWORD size = 15; module_name.size() != size;)
|
||||||
|
|
|
@ -510,15 +510,19 @@ class named_thread final : public Context, result_storage<Context>, thread_base
|
||||||
|
|
||||||
#if defined(ARCH_X64)
|
#if defined(ARCH_X64)
|
||||||
static inline thread::native_entry trampoline = thread::make_trampoline(entry_point);
|
static inline thread::native_entry trampoline = thread::make_trampoline(entry_point);
|
||||||
|
#else
|
||||||
|
#ifdef _WIN32
|
||||||
|
static uint trampoline(void* arg)
|
||||||
#else
|
#else
|
||||||
static void* trampoline(void* arg)
|
static void* trampoline(void* arg)
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
if (const auto next = thread_base::finalize(entry_point(static_cast<thread_base*>(arg))))
|
if (const auto next = thread_base::finalize(entry_point(static_cast<thread_base*>(arg))))
|
||||||
{
|
{
|
||||||
return next(thread_ctrl::get_current());
|
return next(thread_ctrl::get_current());
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -41,12 +41,18 @@ namespace utils
|
||||||
RtlCaptureContext(&context);
|
RtlCaptureContext(&context);
|
||||||
|
|
||||||
STACKFRAME64 stack = {};
|
STACKFRAME64 stack = {};
|
||||||
stack.AddrPC.Offset = context.Rip;
|
|
||||||
stack.AddrPC.Mode = AddrModeFlat;
|
stack.AddrPC.Mode = AddrModeFlat;
|
||||||
stack.AddrStack.Offset = context.Rsp;
|
|
||||||
stack.AddrStack.Mode = AddrModeFlat;
|
stack.AddrStack.Mode = AddrModeFlat;
|
||||||
stack.AddrFrame.Offset = context.Rbp;
|
|
||||||
stack.AddrFrame.Mode = AddrModeFlat;
|
stack.AddrFrame.Mode = AddrModeFlat;
|
||||||
|
#if defined(ARCH_X64)
|
||||||
|
stack.AddrPC.Offset = context.Rip;
|
||||||
|
stack.AddrStack.Offset = context.Rsp;
|
||||||
|
stack.AddrFrame.Offset = context.Rbp;
|
||||||
|
#elif defined(ARCH_ARM64)
|
||||||
|
stack.AddrPC.Offset = context.Pc;
|
||||||
|
stack.AddrStack.Offset = context.Sp;
|
||||||
|
stack.AddrFrame.Offset = context.Fp;
|
||||||
|
#endif
|
||||||
|
|
||||||
while (max_depth--)
|
while (max_depth--)
|
||||||
{
|
{
|
||||||
|
|
|
@ -114,7 +114,7 @@ if(UNIX)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(WIN32)
|
if(WIN32)
|
||||||
target_link_libraries(rpcs3 PRIVATE ws2_32 Iphlpapi Winmm Psapi gdi32 setupapi pdh)
|
target_link_libraries(rpcs3 PRIVATE bcrypt ws2_32 Iphlpapi Winmm Psapi gdi32 setupapi pdh c++)
|
||||||
else()
|
else()
|
||||||
target_link_libraries(rpcs3 PRIVATE ${CMAKE_DL_LIBS})
|
target_link_libraries(rpcs3 PRIVATE ${CMAKE_DL_LIBS})
|
||||||
endif()
|
endif()
|
||||||
|
|
|
@ -389,7 +389,7 @@ target_sources(rpcs3_emu PRIVATE
|
||||||
CPU/CPUTranslator.cpp
|
CPU/CPUTranslator.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm64|aarch64")
|
if(CMAKE_SYSTEM_PROCESSOR MATCHES "ARM64|arm64|aarch64")
|
||||||
target_sources(rpcs3_emu PRIVATE
|
target_sources(rpcs3_emu PRIVATE
|
||||||
CPU/Backends/AArch64/AArch64ASM.cpp
|
CPU/Backends/AArch64/AArch64ASM.cpp
|
||||||
CPU/Backends/AArch64/AArch64Common.cpp
|
CPU/Backends/AArch64/AArch64Common.cpp
|
||||||
|
|
|
@ -1,7 +1,12 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <util/types.hpp>
|
#include <util/types.hpp>
|
||||||
|
|
||||||
|
#ifndef _WIN32
|
||||||
#include <sys/ucontext.h>
|
#include <sys/ucontext.h>
|
||||||
|
#else
|
||||||
|
using ucontext_t = void;
|
||||||
|
#endif
|
||||||
|
|
||||||
namespace aarch64
|
namespace aarch64
|
||||||
{
|
{
|
||||||
|
|
|
@ -132,6 +132,25 @@
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(_WIN32)
|
||||||
|
static inline int posix_memalign(void** memptr, size_t alignment, size_t size) {
|
||||||
|
// Check for valid alignment (must be a power of two and multiple of sizeof(void*))
|
||||||
|
if (alignment == 0 || (alignment & (alignment - 1)) != 0 || alignment % sizeof(void*) != 0) {
|
||||||
|
return EINVAL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Allocate memory using _aligned_malloc
|
||||||
|
void* ptr = _aligned_malloc(size, alignment);
|
||||||
|
if (ptr == NULL) {
|
||||||
|
return ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set the output pointer
|
||||||
|
*memptr = ptr;
|
||||||
|
return 0; // Success
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/* "__has_builtin" can be used to query support for built-in functions
|
/* "__has_builtin" can be used to query support for built-in functions
|
||||||
* provided by gcc/clang and other compilers that support it.
|
* provided by gcc/clang and other compilers that support it.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -68,6 +68,15 @@ namespace Darwin_ProcessInfo
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if defined(ARCH_ARM64) && defined (_WIN32) && !defined(_MSC_VER)
|
||||||
|
static inline u64 __readx18qword(int offset)
|
||||||
|
{
|
||||||
|
u64* peb = nullptr;
|
||||||
|
__asm__ volatile("mov %0, x18" : "=r"(peb));
|
||||||
|
return peb[offset];
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
bool utils::has_ssse3()
|
bool utils::has_ssse3()
|
||||||
{
|
{
|
||||||
#if defined(ARCH_X64)
|
#if defined(ARCH_X64)
|
||||||
|
@ -583,7 +592,11 @@ std::string utils::get_OS_version()
|
||||||
// So we're forced to read PEB instead to get Windows version info. It's ugly but works.
|
// So we're forced to read PEB instead to get Windows version info. It's ugly but works.
|
||||||
|
|
||||||
const DWORD peb_offset = 0x60;
|
const DWORD peb_offset = 0x60;
|
||||||
|
#if defined(ARCH_X64)
|
||||||
const INT_PTR peb = __readgsqword(peb_offset);
|
const INT_PTR peb = __readgsqword(peb_offset);
|
||||||
|
#elif defined(_M_ARM64)
|
||||||
|
const INT_PTR peb = __readx18qword(peb_offset);
|
||||||
|
#endif
|
||||||
|
|
||||||
const DWORD version_major = *reinterpret_cast<const DWORD*>(peb + 0x118);
|
const DWORD version_major = *reinterpret_cast<const DWORD*>(peb + 0x118);
|
||||||
const DWORD version_minor = *reinterpret_cast<const DWORD*>(peb + 0x11c);
|
const DWORD version_minor = *reinterpret_cast<const DWORD*>(peb + 0x11c);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue