From ab51e9e285c805e74fe7b8ae0a934cb6a6679ebb Mon Sep 17 00:00:00 2001 From: notaz Date: Mon, 24 Jan 2022 20:49:04 +0200 Subject: [PATCH] drc: another hack to try to get Vita to work --- libpcsxcore/new_dynarec/assem_arm.c | 5 ++--- libpcsxcore/new_dynarec/new_dynarec.c | 19 ++++++++++++++----- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/libpcsxcore/new_dynarec/assem_arm.c b/libpcsxcore/new_dynarec/assem_arm.c index 381a5419..ef3219f4 100644 --- a/libpcsxcore/new_dynarec/assem_arm.c +++ b/libpcsxcore/new_dynarec/assem_arm.c @@ -101,8 +101,6 @@ const u_int invalidate_addr_reg[16] = { 0, 0}; -static u_int needs_clear_cache[1<<(TARGET_SIZE_2-17)]; - /* Linker */ static void set_jump_target(void *addr, void *target_) @@ -1642,7 +1640,8 @@ static void emit_extjump2(u_char *addr, u_int target, void *linker) emit_loadlp(target,0); emit_loadlp((u_int)addr,1); - assert(addr>=ndrc->translation_cache&&addr<(ndrc->translation_cache+(1<translation_cache <= addr && + addr < ndrc->translation_cache + sizeof(ndrc->translation_cache)); //assert((target>=0x80000000&&target<0x80800000)||(target>0xA4000000&&target<0xA4001000)); //DEBUG > #ifdef DEBUG_CYCLE_COUNT diff --git a/libpcsxcore/new_dynarec/new_dynarec.c b/libpcsxcore/new_dynarec/new_dynarec.c index 0900736d..107a6304 100644 --- a/libpcsxcore/new_dynarec/new_dynarec.c +++ b/libpcsxcore/new_dynarec/new_dynarec.c @@ -75,9 +75,17 @@ #define MAXBLOCK 4096 #define MAX_OUTPUT_BLOCK_SIZE 262144 +#ifdef VITA +// apparently Vita has a 16MB limit, so either we cut tc in half, +// or use this hack (it's a hack because tc size was designed to be power-of-2) +#define TC_REDUCE_BYTES 4096 +#else +#define TC_REDUCE_BYTES 0 +#endif + struct ndrc_mem { - u_char translation_cache[1 << TARGET_SIZE_2]; + u_char translation_cache[(1 << TARGET_SIZE_2) - TC_REDUCE_BYTES]; struct { struct tramp_insns ops[2048 / sizeof(struct tramp_insns)]; @@ -6844,7 +6852,7 @@ void new_dynarec_clear_full(void) void new_dynarec_init(void) { - SysPrintf("Init new dynarec\n"); + SysPrintf("Init new dynarec, ndrc size %x\n", (int)sizeof(*ndrc)); #ifdef _3DS check_rosalina(); @@ -6852,11 +6860,11 @@ void new_dynarec_init(void) #ifdef BASE_ADDR_DYNAMIC #ifdef VITA sceBlock = getVMBlock(); //sceKernelAllocMemBlockForVM("code", sizeof(*ndrc)); - if (sceBlock < 0) - SysPrintf("sceKernelAllocMemBlockForVM failed\n"); + if (sceBlock <= 0) + SysPrintf("sceKernelAllocMemBlockForVM failed: %x\n", sceBlock); int ret = sceKernelGetMemBlockBase(sceBlock, (void **)&ndrc); if (ret < 0) - SysPrintf("sceKernelGetMemBlockBase failed\n"); + SysPrintf("sceKernelGetMemBlockBase failed: %x\n", ret); sceKernelOpenVMDomain(); sceClibPrintf("translation_cache = 0x%08lx\n ", (long)ndrc->translation_cache); #elif defined(_MSC_VER) @@ -6904,6 +6912,7 @@ void new_dynarec_cleanup(void) int n; #ifdef BASE_ADDR_DYNAMIC #ifdef VITA + // sceBlock is managed by retroarch's bootstrap code //sceKernelFreeMemBlock(sceBlock); //sceBlock = -1; #else -- 2.39.5