From 88f7643f70681d211c71a30d845592d48b1b9bea Mon Sep 17 00:00:00 2001 From: lentillog Date: Fri, 30 Sep 2016 23:44:49 -0700 Subject: [PATCH] (VITA) Dynarec working --- Makefile | 4 ++++ Makefile.libretro | 14 ++++++++------ cpu/drc/cmn.c | 10 ++++++++++ cpu/drc/cmn.h | 4 ++++ platform/libretro/libretro.c | 18 ++++++++++++++++-- 5 files changed, 42 insertions(+), 8 deletions(-) diff --git a/Makefile b/Makefile index c7fbe9ed..9b364dd9 100644 --- a/Makefile +++ b/Makefile @@ -2,7 +2,11 @@ TARGET ?= PicoDrive CFLAGS += -Wall CFLAGS += -I. -DINLINE=inline ifndef DEBUG +ifeq ($(platform), vita) +CFLAGS += -O3 -DNDEBUG +else CFLAGS += -O2 -DNDEBUG -ffunction-sections +endif ifneq ($(APPLE),1) LDFLAGS += -Wl,--gc-sections endif diff --git a/Makefile.libretro b/Makefile.libretro index 3b7c0fed..b2759d8e 100644 --- a/Makefile.libretro +++ b/Makefile.libretro @@ -263,8 +263,10 @@ else ifeq ($(platform), vita) CC = arm-vita-eabi-gcc$(EXE_EXT) AR = arm-vita-eabi-ar$(EXE_EXT) CFLAGS += -DVITA - CFLAGS += -mfloat-abi=hard -ffast-math -mword-relocations -fno-optimize-sibling-calls - CFLAGS += -marm -mfpu=neon -mcpu=cortex-a9 -march=armv7-a + CFLAGS += -marm -mfpu=neon -mcpu=cortex-a9 -march=armv7-a -mfloat-abi=hard -ffast-math + CFLAGS += -fno-asynchronous-unwind-tables -ftree-vectorize -funroll-loops + CFLAGS += -mword-relocations -fno-unwind-tables + CFLAGS += -fno-optimize-sibling-calls STATIC_LINKING = 1 NO_MMAP = 1 DONT_COMPILE_IN_ZLIB = 1 @@ -274,15 +276,15 @@ else ifeq ($(platform), vita) asm_render = 1 asm_ym2612 = 1 asm_misc = 1 - asm_cdpico = 0 - asm_cdmemory = 0 + asm_cdpico = 1 + asm_cdmemory = 1 asm_mix = 1 use_cyclone = 1 use_fame = 0 use_drz80 = 1 use_cz80 = 0 - use_sh2drc = 0 - use_svpdrc = 0 + use_sh2drc = 1 + use_svpdrc = 1 # Xbox 360 else ifeq ($(platform), xenon) diff --git a/cpu/drc/cmn.c b/cpu/drc/cmn.c index a07dcbdd..f788ecac 100644 --- a/cpu/drc/cmn.c +++ b/cpu/drc/cmn.c @@ -12,6 +12,11 @@ #ifdef _MSC_VER u8 tcache[DRC_TCACHE_SIZE]; +#elif defined(VITA) +#include +u8 *tcache; +static int sceBlock; +int getVMBlock(); #else u8 __attribute__((aligned(4096))) tcache[DRC_TCACHE_SIZE]; #endif @@ -19,6 +24,11 @@ u8 __attribute__((aligned(4096))) tcache[DRC_TCACHE_SIZE]; void drc_cmn_init(void) { +#ifdef VITA + sceBlock = getVMBlock(); + sceKernelGetMemBlockBase(sceBlock, (void **)&tcache); +#endif + int ret = plat_mem_set_exec(tcache, sizeof(tcache)); elprintf(EL_STATUS, "drc_cmn_init: %p, %zd bytes: %d", tcache, sizeof(tcache), ret); diff --git a/cpu/drc/cmn.h b/cpu/drc/cmn.h index 4737b74d..e6da6eac 100644 --- a/cpu/drc/cmn.h +++ b/cpu/drc/cmn.h @@ -5,7 +5,11 @@ typedef unsigned int u32; #define DRC_TCACHE_SIZE (2*1024*1024) +#ifdef VITA +extern u8 *tcache; +#else extern u8 tcache[DRC_TCACHE_SIZE]; +#endif void drc_cmn_init(void); void drc_cmn_cleanup(void); diff --git a/platform/libretro/libretro.c b/platform/libretro/libretro.c index 581702c9..46363618 100644 --- a/platform/libretro/libretro.c +++ b/platform/libretro/libretro.c @@ -38,6 +38,15 @@ void* linearMemAlign(size_t size, size_t alignment); void linearFree(void* mem); static int ctr_svchack_successful = 0; + +#elif defined(VITA) +#define TARGET_SIZE_2 24 // 2^24 = 16 megabytes + +#include +static int sceBlock; +int getVMBlock(); +int _newlib_vm_size_user = 1 << TARGET_SIZE_2; + #endif #include @@ -83,14 +92,16 @@ static void snd_write(int len); void cache_flush_d_inval_i(void *start, void *end) { #ifdef __arm__ + size_t len = (char *)end - (char *)start; #if defined(__BLACKBERRY_QNX__) msync(start, end - start, MS_SYNC | MS_CACHE_ONLY | MS_INVALIDATE_ICACHE); #elif defined(__MACH__) - size_t len = (char *)end - (char *)start; sys_dcache_flush(start, len); sys_icache_invalidate(start, len); #elif defined(_3DS) ctr_flush_invalidate_cache(); +#elif defined(VITA) + sceKernelSyncVMDomain(sceBlock, start, len); #else __clear_cache(start, end); #endif @@ -444,7 +455,8 @@ int plat_mem_set_exec(void *ptr, size_t size) exit(1); } - +#elif defined(VITA) + int ret = sceKernelOpenVMDomain(); #else int ret = mprotect(ptr, size, PROT_READ | PROT_WRITE | PROT_EXEC); if (ret != 0 && log_cb) @@ -1251,6 +1263,8 @@ void retro_init(void) #ifdef _3DS ctr_svchack_successful = ctr_svchack_init(); +#elif defined(VITA) + sceBlock = getVMBlock(); #endif PicoOpt = POPT_EN_STEREO|POPT_EN_FM|POPT_EN_PSG|POPT_EN_Z80 -- 2.39.5