Browse Source

Fix compile errors and finish up Windows NCE

remotes/1785372757367212240/tmp_refs/heads/variable-page-size
Exverge 4 weeks ago
parent
commit
c2bc7d92ce
No known key found for this signature in database GPG Key ID: DAD399BCC5FB77E4
  1. 2
      src/common/vector_math.h
  2. 24
      src/core/arm/nce/arm_nce.cpp
  3. 7
      src/core/arm/nce/arm_nce.h
  4. 2
      src/core/arm/nce/guest_context.h
  5. 3
      src/core/arm/nce/patcher.cpp
  6. 1
      src/core/arm/nce/win/exceptions.h
  7. 1582
      src/core/arm/nce/win/platform_visitor.h

2
src/common/vector_math.h

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: 2014 Tony Wasserka

24
src/core/arm/nce/arm_nce.cpp

@ -106,6 +106,7 @@ void ArmNce::UnlockThreadParameters(void* tpidr) {
static_cast<NativeExecutionParameters*>(tpidr)->lock.store(SpinLockUnlocked, std::memory_order_release);
}
#ifndef __WIN32
YUZU_NAKED
YUZU_NO_INLINE
HaltReason ArmNce::ReturnToRunCodeByExceptionLevelChange(int tid, void *tpidr) {
@ -141,6 +142,14 @@ HaltReason ArmNce::ReturnToRunCodeByExceptionLevelChange(int tid, void *tpidr) {
);
}
YUZU_NAKED_END
#else
HaltReason ArmNce::ReturnToRunCodeByExceptionLevelChange(int tid, void *tpidr) {
DEBUG_ASSERT(os::TlsGetValue(ContextKey) == tpidr);
os::RaiseException(SIGUSR2, 0, 0, nullptr); // TODO: pass tpidr through arguments?
__builtin_unreachable();
}
#endif
void ArmNce::ReturnToRunCodeByExceptionLevelChangeSignalHandler(int sig, void *info, void *raw_context) {
auto tpidr = static_cast<NativeExecutionParameters*>(RestoreGuestContext(raw_context));
@ -224,9 +233,11 @@ YUZU_NAKED_END
static_assert(offsetof(HostContext, host_sp) == 0xE0); // TODO: don't use magic number
#ifndef __WIN32
void ArmNce::BreakFromRunCodeSignalHandler(int sig, void *info, void *raw_context) {
NativeExecutionParameters* tpidr = reinterpret_cast<NativeExecutionParameters *>(GetGuestParameters());
#if defined(__APPLE__) || defined(__WIN32)
NativeExecutionParameters* tpidr = static_cast<NativeExecutionParameters *>(GetGuestParameters());
#if defined(__APPLE__)
if (tpidr->is_actually_running) {
tpidr->is_actually_running = false;
#else
@ -242,6 +253,8 @@ void ArmNce::BreakFromRunCodeSignalHandler(int sig, void *info, void *raw_contex
}
}
#endif
void ArmNce::GuestMemoryFaultSignalHandler(int sig, void* raw_info, void* raw_context) {
DEBUG_ASSERT(sig == SIGSEGV || sig == SIGBUS);
@ -326,8 +339,12 @@ void* ArmNce::RestoreGuestContext(void* raw_context) {
// Retrieve the host context.
auto host_ctx = KernelContext(raw_context);
#ifndef __WIN32
// Thread-local parameters will be located in x9.
auto* tpidr = reinterpret_cast<NativeExecutionParameters*>(host_ctx.regs()[9]);
#else
auto* tpidr = static_cast<NativeExecutionParameters*>(GetGuestParameters());
#endif
auto* guest_ctx = static_cast<GuestContext*>(tpidr->native_context);
// Save host callee-saved registers.
@ -647,7 +664,8 @@ void ArmNce::SignalInterrupt(Kernel::KThread* thread) {
"svc #0x80\n"
:: "r"(static_cast<u64>(m_thread_id)), "r"(static_cast<u64>(SIGURG))
: "x0", "x1", "x16", "memory", "cc");
#elif
#elif defined(__WIN32)
// TODO: use SetThreadState to emulate BreakFromRunCodeSignalHandler
SuspendThread(m_thread_id);
UnlockThreadParameters(params);
#endif

7
src/core/arm/nce/arm_nce.h

@ -33,12 +33,13 @@ constexpr pthread_key_t ContextKey = 210;
namespace os {
extern "C" {
#include <winternl.h>
#include <processthreadsapi.h>
#include <errhandlingapi.h>
}
}
static const u32 ContextKey = TlsAlloc();
static const u32 NCEStorage = TlsAlloc();
static const u32 ContextKey = os::TlsAlloc();
static const u32 NCEStorage = os::TlsAlloc();
static const u64 TlsSlots = offsetof(os::TEB, TlsSlots);
#endif

2
src/core/arm/nce/guest_context.h

@ -162,7 +162,7 @@ private:
return reinterpret_cast<fpsimd_context*>(header);
}
#elif defined(__WIN32)
ARM64_NT_CONTEXT* ptr;
CONTEXT* ptr;
#endif
};

3
src/core/arm/nce/patcher.cpp

@ -17,7 +17,10 @@
#include "core/hle/kernel/svc.h"
#include "core/memory.h"
#include "core/hle/kernel/k_thread.h"
#ifdef __WIN32
#include "win/platform_visitor.h"
#endif
namespace Core::NCE {

1
src/core/arm/nce/win/exceptions.h

@ -8,7 +8,6 @@
#define SIGBUS EXCEPTION_DATATYPE_MISALIGNMENT
#define SIGSEGV EXCEPTION_ACCESS_VIOLATION
#define SIGUSR2 0xE0000001
#define SIGURG 0xE0000002
namespace Core {

1582
src/core/arm/nce/win/platform_visitor.h
File diff suppressed because it is too large
View File

Loading…
Cancel
Save