Merge pull request #31 from frangarcj/master

(VITA) Dynarec working
This commit is contained in:
Francisco José García García 2016-10-03 19:21:32 +01:00 committed by GitHub
commit 57998622ac
4 changed files with 32 additions and 25 deletions

View File

@ -196,13 +196,14 @@ else ifeq ($(platform), vita)
CC = arm-vita-eabi-gcc$(EXE_EXT)
AR = arm-vita-eabi-ar$(EXE_EXT)
CFLAGS += -DVITA
CFLAGS += -mcpu=cortex-a9 -mfloat-abi=hard
CFLAGS += -marm -mcpu=cortex-a9 -mfloat-abi=hard
CFLAGS += -Wall -mword-relocations
CFLAGS += -fomit-frame-pointer -ffast-math
CFLAGS += -mword-relocations -fno-unwind-tables -fno-asynchronous-unwind-tables
CFLAGS += -ftree-vectorize -fno-optimize-sibling-calls
ASFLAGS += -mcpu=cortex-a9
STATIC_LINKING = 1
HAVE_DYNAREC = 1
CPU_ARCH := arm
# CTR(3DS)

View File

@ -21,10 +21,7 @@
#define ARM_EMIT_H
#include "arm_codegen.h"
#if defined(VITA)
#define VITA_RW_INIT sceKernelOpenVMDomain
#define VITA_RW_END sceKernelCloseVMDomain
#endif
u32 arm_update_gba_arm(u32 pc);
u32 arm_update_gba_thumb(u32 pc);
u32 arm_update_gba_idle_arm(u32 pc);

View File

@ -260,12 +260,21 @@ static INLINE void RW_END(void)
#if defined(PSP_BUILD)
#define translate_invalidate_dcache() sceKernelDcacheWritebackAll()
#elif defined(VITA)
#define translate_invalidate_dcache() (void)0
#define translate_invalidate_dcache_one(which) \
if (which##_translation_ptr > last_##which##_translation_ptr) \
{ \
sceKernelSyncVMDomain(sceBlock,last_##which##_translation_ptr, \
which##_translation_ptr - last_##which##_translation_ptr); \
}
#define invalidate_icache_region(addr, size) \
{ \
int ret = sceKernelSyncVMDomain(sceBlock, addr, size); \
}
#define translate_invalidate_dcache() \
{ \
translate_invalidate_dcache_one(rom) \
translate_invalidate_dcache_one(ram) \
translate_invalidate_dcache_one(bios) \
}
#define invalidate_icache_region(addr, size) (void)0
#elif defined(_3DS)
#include "3ds/3ds_utils.h"
@ -2854,7 +2863,7 @@ u8 *block_lookup_address_##type(u32 pc) \
/* Starting at the beginning, we allow for one translation cache flush. */ \
if(translation_recursion_level == 0){ \
translation_flush_count = 0; \
RW_INIT(); \
RW_INIT(); \
} \
block_lookup_address_pc_##type(); \
\
@ -2950,8 +2959,6 @@ u8 *block_lookup_address_##type(u32 pc) \
block_address = (u8 *)(-1); \
break; \
} \
if(translation_recursion_level == 0) \
RW_END(); \
\
return block_address; \
} \
@ -3415,7 +3422,6 @@ s32 translate_block_arm(u32 pc, translation_region_type
flush_translation_cache_bios();
break;
}
RW_END();
return -1;
}
@ -3493,13 +3499,11 @@ s32 translate_block_arm(u32 pc, translation_region_type
branch_target = external_block_exits[i].branch_target;
arm_link_block();
if(!translation_target){
RW_END();
return -1;
}
generate_branch_patch_unconditional(
external_block_exits[i].branch_source, translation_target);
}
RW_END();
return 0;
}
@ -3635,7 +3639,6 @@ s32 translate_block_thumb(u32 pc, translation_region_type
flush_translation_cache_bios();
break;
}
RW_END();
return -1;
}
@ -3713,13 +3716,11 @@ s32 translate_block_thumb(u32 pc, translation_region_type
branch_target = external_block_exits[i].branch_target;
thumb_link_block();
if(!translation_target){
RW_END();
return -1;
}
generate_branch_patch_unconditional(
external_block_exits[i].branch_source, translation_target);
}
RW_END();
return 0;
}

View File

@ -19,6 +19,12 @@ static inline int align(int x, int n) {
#define FOUR_KB_ALIGN(x) align(x, 12)
#define MB_ALIGN(x) align(x, 20)
int _newlib_vm_size_user = ROM_TRANSLATION_CACHE_SIZE +
RAM_TRANSLATION_CACHE_SIZE +
BIOS_TRANSLATION_CACHE_SIZE;
int getVMBlock();
#endif
#if defined(_3DS)
@ -163,9 +169,8 @@ void retro_init(void)
if(!translation_caches_inited){
void* currentHandle;
sceBlock = sceKernelAllocMemBlockForVM("code", MB_ALIGN(FOUR_KB_ALIGN(ROM_TRANSLATION_CACHE_SIZE +
RAM_TRANSLATION_CACHE_SIZE +
BIOS_TRANSLATION_CACHE_SIZE)));
sceBlock = getVMBlock();
if (sceBlock < 0)
{
return;
@ -237,9 +242,7 @@ void retro_deinit(void)
#if defined(VITA) && defined(HAVE_DYNAREC)
if(translation_caches_inited){
sceKernelFreeMemBlock(sceBlock);
translation_caches_inited = 0;
translation_caches_inited = 0;
}
#endif
@ -438,6 +441,11 @@ bool retro_load_game(const struct retro_game_info* info)
rom_translation_ptr = rom_translation_cache;
ram_translation_ptr = ram_translation_cache;
bios_translation_ptr = bios_translation_cache;
#elif defined(VITA)
dynarec_enable = 1;
rom_translation_ptr = rom_translation_cache;
ram_translation_ptr = ram_translation_cache;
bios_translation_ptr = bios_translation_cache;
#endif
}
else