aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRSDuck <rsduck@users.noreply.github.com>2020-12-09 18:58:51 +0100
committerRSDuck <rsduck@users.noreply.github.com>2020-12-09 18:58:51 +0100
commit49b5860f0f3345362ef0e86621443d006e1e3cad (patch)
tree5b43351b4e0dcff6cfcac5a7e0f700a240bf2ec3
parentd2cfd71c32b9b8d7b52249270ea124235d02de79 (diff)
aligned_alloc instead of memalign
also carry over new Switch changes
-rw-r--r--src/ARMJIT_A64/ARMJIT_Compiler.cpp18
-rw-r--r--src/ARMJIT_Memory.cpp25
2 files changed, 17 insertions, 26 deletions
diff --git a/src/ARMJIT_A64/ARMJIT_Compiler.cpp b/src/ARMJIT_A64/ARMJIT_Compiler.cpp
index 93563b9..5fe3fe7 100644
--- a/src/ARMJIT_A64/ARMJIT_Compiler.cpp
+++ b/src/ARMJIT_A64/ARMJIT_Compiler.cpp
@@ -1,5 +1,11 @@
+#include "ARMJIT_Compiler.h"
+
+#include "../ARMJIT_Internal.h"
+#include "../ARMInterpreter.h"
+#include "../Config.h"
+
#ifdef __SWITCH__
-#include "../switch/compat_switch.h"
+#include <switch.h>
extern char __start__;
#else
@@ -7,13 +13,7 @@ extern char __start__;
#include <unistd.h>
#endif
-#include "ARMJIT_Compiler.h"
-
-#include "../ARMJIT_Internal.h"
-#include "../ARMInterpreter.h"
-#include "../Config.h"
-
-#include <malloc.h>
+#include <stdlib.h>
using namespace Arm64Gen;
@@ -184,7 +184,7 @@ void Compiler::PopRegs(bool saveHiRegs)
Compiler::Compiler()
{
#ifdef __SWITCH__
- JitRWBase = memalign(0x1000, JitMemSize);
+ JitRWBase = aligned_alloc(0x1000, JitMemSize);
JitRXStart = (u8*)&__start__ - JitMemSize - 0x1000;
JitRWStart = virtmemReserve(JitMemSize);
diff --git a/src/ARMJIT_Memory.cpp b/src/ARMJIT_Memory.cpp
index f9f82aa..ffc294f 100644
--- a/src/ARMJIT_Memory.cpp
+++ b/src/ARMJIT_Memory.cpp
@@ -1,5 +1,6 @@
#if defined(__SWITCH__)
-#include "switch/compat_switch.h"
+#include <switch.h>
+#include "frontend/switch/FaultHandler.h"
#elif defined(_WIN32)
#include <windows.h>
#else
@@ -28,9 +29,7 @@
#include "NDSCart.h"
#include "SPU.h"
-#ifndef __APPLE__
-#include <malloc.h>
-#endif
+#include <stdlib.h>
/*
We're handling fastmem here.
@@ -97,22 +96,14 @@ void __libnx_exception_handler(ThreadExceptionDump* ctx)
integerRegisters[31] = ctx->sp.x;
integerRegisters[32] = ctx->pc.x;
- if (ARMJIT_Memory::FaultHandler(desc, offset))
+ if (ARMJIT_Memory::FaultHandler(desc))
{
integerRegisters[32] = (u64)desc.FaultPC;
ARM_RestoreContext(integerRegisters);
}
- if (ctx->pc.x >= (u64)&__start__ && ctx->pc.x < (u64)&__rodata_start)
- {
- printf("unintentional fault in .text at 0x%x (type %d) (trying to access 0x%x?)\n",
- ctx->pc.x - (u64)&__start__, ctx->error_desc, ctx->far.x);
- }
- else
- {
- printf("unintentional fault somewhere in deep (address) space at %x (type %d)\n", ctx->pc.x, ctx->error_desc);
- }
+ HandleFault(ctx->pc.x, ctx->lr.x, ctx->fp.x, ctx->far.x, ctx->error_desc);
}
}
@@ -670,12 +661,12 @@ bool FaultHandler(FaultDescription& faultDesc)
return false;
}
+const u64 AddrSpaceSize = 0x100000000;
+
void Init()
{
- const u64 AddrSpaceSize = 0x100000000;
-
#if defined(__SWITCH__)
- MemoryBase = (u8*)memalign(0x1000, MemoryTotalSize);
+ MemoryBase = (u8*)aligned_alloc(0x1000, MemoryTotalSize);
MemoryBaseCodeMem = (u8*)virtmemReserve(MemoryTotalSize);
bool succeded = R_SUCCEEDED(svcMapProcessCodeMemory(envGetOwnProcessHandle(), (u64)MemoryBaseCodeMem,