From: notaz Date: Tue, 20 Sep 2016 23:07:16 +0000 (+0300) Subject: drc: some vita and 3ds support X-Git-Tag: r23~165 X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1e212a25c55c298490867c2ded029c82db1d2b9d;p=pcsx_rearmed.git drc: some vita and 3ds support not tested, mostly just guesswork --- diff --git a/Makefile.libretro b/Makefile.libretro index cbebc5df..223ba9f9 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -128,7 +128,7 @@ else ifeq ($(platform), qnx) DRC_CACHE_BASE = 0 BUILTIN_GPU = neon ARCH = arm - CFLAGS += -DBASE_ADDR_FIXED=0 -D__BLACKBERRY_QNX__ -marm -mcpu=cortex-a9 -mtune=cortex-a9 -mfpu=neon -mfloat-abi=softfp + CFLAGS += -D__BLACKBERRY_QNX__ -marm -mcpu=cortex-a9 -mtune=cortex-a9 -mfpu=neon -mfloat-abi=softfp ASFLAGS += -mcpu=cortex-a9 -mfpu=neon -mfloat-abi=softfp # ARM diff --git a/libpcsxcore/new_dynarec/assem_arm.c b/libpcsxcore/new_dynarec/assem_arm.c index 6c3826c0..21640f84 100644 --- a/libpcsxcore/new_dynarec/assem_arm.c +++ b/libpcsxcore/new_dynarec/assem_arm.c @@ -28,7 +28,10 @@ #include "pcnt.h" #include "arm_features.h" -#if !BASE_ADDR_FIXED +#if defined(BASE_ADDR_FIXED) +#elif defined(BASE_ADDR_DYNAMIC) +char *translation_cache; +#else char translation_cache[1 << TARGET_SIZE_2] __attribute__((aligned(4096))); #endif diff --git a/libpcsxcore/new_dynarec/assem_arm.h b/libpcsxcore/new_dynarec/assem_arm.h index acf65bd7..bb6114c8 100644 --- a/libpcsxcore/new_dynarec/assem_arm.h +++ b/libpcsxcore/new_dynarec/assem_arm.h @@ -39,10 +39,19 @@ extern char *invc_ptr; #define TARGET_SIZE_2 24 // 2^24 = 16 megabytes // Code generator target address -#if BASE_ADDR_FIXED -// "round" address helpful for debug -#define BASE_ADDR 0x1000000 +#if defined(BASE_ADDR_FIXED) + // "round" address helpful for debug + // this produces best code, but not many platforms allow it, + // only use if you are sure this range is always free + #define BASE_ADDR 0x1000000 + #define translation_cache (char *)BASE_ADDR +#elif defined(BASE_ADDR_DYNAMIC) + // for platforms that can't just use .bss buffer, like vita + // otherwise better to use the next option for closer branches + extern char *translation_cache; + #define BASE_ADDR (u_int)translation_cache #else -extern char translation_cache[1 << TARGET_SIZE_2]; -#define BASE_ADDR (u_int)translation_cache + // using a static buffer in .bss + extern char translation_cache[1 << TARGET_SIZE_2]; + #define BASE_ADDR (u_int)translation_cache #endif diff --git a/libpcsxcore/new_dynarec/new_dynarec.c b/libpcsxcore/new_dynarec/new_dynarec.c index b0bfb239..1618b0fa 100644 --- a/libpcsxcore/new_dynarec/new_dynarec.c +++ b/libpcsxcore/new_dynarec/new_dynarec.c @@ -26,6 +26,13 @@ #ifdef __MACH__ #include #endif +#ifdef _3DS +#include <3ds_utils.h> +#endif +#ifdef VITA +#include +static int sceBlock; +#endif #include "new_dynarec_config.h" #include "emu_if.h" //emulator interface @@ -265,11 +272,20 @@ static int tracedebug=0; static void mprotect_w_x(void *start, void *end, int is_x) { #ifdef NO_WRITE_EXEC + #if defined(VITA) + // *Open* enables write on all memory that was + // allocated by sceKernelAllocMemBlockForVM()? + if (is_x) + sceKernelCloseVMDomain(); + else + sceKernelOpenVMDomain(); + #else u_long mstart = (u_long)start & ~4095ul; u_long mend = (u_long)end; if (mprotect((void *)mstart, mend - mstart, PROT_READ | (is_x ? PROT_EXEC : PROT_WRITE)) != 0) SysPrintf("mprotect(%c) failed: %s\n", is_x ? 'x' : 'w', strerror(errno)); + #endif #endif } @@ -287,8 +303,9 @@ static void end_tcache_write(void *start, void *end) #elif defined(__MACH__) sys_cache_control(kCacheFunctionPrepareForExecution, start, len); #elif defined(VITA) - int block = sceKernelFindMemBlockByAddr(start, len); - sceKernelSyncVMDomain(block, start, len); + sceKernelSyncVMDomain(sceBlock, start, len); + #elif defined(_3DS) + ctr_flush_invalidate_cache(); #else __clear_cache(start, end); #endif @@ -7023,19 +7040,43 @@ void new_dynarec_clear_full() void new_dynarec_init() { SysPrintf("Init new dynarec\n"); - out=(u_char *)BASE_ADDR; -#if BASE_ADDR_FIXED - if (mmap (out, 1<