summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancisco José García García2016-08-14 18:28:25 +0200
committerFrancisco José García García2016-08-14 18:28:25 +0200
commit44b63e7d280c9b6a2f1ca4aa908c31e27adeea01 (patch)
tree0914eeabcf96df2cbe8f1d33fe76819b2af26616
parent177abe6a22c1ad95305587256b6c39baf9a25168 (diff)
downloadpicogpsp-44b63e7d280c9b6a2f1ca4aa908c31e27adeea01.tar.gz
picogpsp-44b63e7d280c9b6a2f1ca4aa908c31e27adeea01.tar.bz2
picogpsp-44b63e7d280c9b6a2f1ca4aa908c31e27adeea01.zip
(VITA) Dynarec WIP
-rw-r--r--arm/arm_emit.h12
-rw-r--r--cpu_threaded.c41
-rw-r--r--libretro.c12
3 files changed, 30 insertions, 35 deletions
diff --git a/arm/arm_emit.h b/arm/arm_emit.h
index bfd1c49..185caef 100644
--- a/arm/arm_emit.h
+++ b/arm/arm_emit.h
@@ -49,10 +49,8 @@ void execute_swi_thumb(u32 pc);
void execute_store_u32_safe(u32 address, u32 source);
#define write32(value) \
- VITA_RW_INIT(); \
*((u32 *)translation_ptr) = value; \
- translation_ptr += 4; \
- VITA_RW_END() \
+ translation_ptr += 4 \
#define arm_relative_offset(source, offset) \
(((((u32)offset - (u32)source) - 8) >> 2) & 0xFFFFFF) \
@@ -409,17 +407,13 @@ u32 arm_disect_imm_32bit(u32 imm, u32 *stores, u32 *rotations)
cycle_count = 0 \
#define generate_branch_patch_conditional(dest, offset) \
- VITA_RW_INIT(); \
*((u32 *)(dest)) = (*((u32 *)dest) & 0xFF000000) | \
- arm_relative_offset(dest, offset); \
- VITA_RW_END(); \
+ arm_relative_offset(dest, offset) \
#define generate_branch_patch_unconditional(dest, offset) \
- VITA_RW_INIT(); \
*((u32 *)(dest)) = (*((u32 *)dest) & 0xFF000000) | \
- arm_relative_offset(dest, offset); \
- VITA_RW_END(); \
+ arm_relative_offset(dest, offset) \
// A different function is called for idle updates because of the relative
// location of the embedded PC. The idle version could be optimized to put
diff --git a/cpu_threaded.c b/cpu_threaded.c
index e3e1a14..ca5b99e 100644
--- a/cpu_threaded.c
+++ b/cpu_threaded.c
@@ -24,6 +24,7 @@
#include "common.h"
#if defined(VITA)
#include <psp2/kernel/sysmem.h>
+#include <stdio.h>
#endif
u8 *last_rom_translation_ptr = NULL;
@@ -251,7 +252,7 @@ extern u8 bit_count[256];
#define invalidate_icache_region(addr, size) \
{ \
- sceKernelSyncVMDomain(sceBlock, addr, size); \
+ int ret = sceKernelSyncVMDomain(sceBlock, addr, size); \
}
#elif defined(_3DS)
@@ -2837,8 +2838,10 @@ u8 *block_lookup_address_##type(u32 pc) \
u8 *block_address; \
\
/* Starting at the beginning, we allow for one translation cache flush. */ \
- if(translation_recursion_level == 0) \
+ if(translation_recursion_level == 0){ \
translation_flush_count = 0; \
+ RW_INIT(); \
+ } \
block_lookup_address_pc_##type(); \
\
switch(pc >> 24) \
@@ -2871,7 +2874,6 @@ u8 *block_lookup_address_##type(u32 pc) \
(ROM_BRANCH_HASH_SIZE - 1); \
u32 *block_ptr = rom_branch_hash[hash_target]; \
u32 **block_ptr_address = rom_branch_hash + hash_target; \
- RW_INIT(); \
while(block_ptr) \
{ \
if(block_ptr[0] == pc) \
@@ -2882,7 +2884,6 @@ u8 *block_lookup_address_##type(u32 pc) \
block_ptr_address = (u32 **)(block_ptr + 1); \
block_ptr = (u32 *)block_ptr[1]; \
} \
- RW_END(); \
if(!block_ptr) \
{ \
__label__ redo; \
@@ -2891,13 +2892,11 @@ u8 *block_lookup_address_##type(u32 pc) \
redo: \
\
translation_recursion_level++; \
- RW_INIT(); \
((u32 *)rom_translation_ptr)[0] = pc; \
((u32 **)rom_translation_ptr)[1] = NULL; \
*block_ptr_address = (u32 *)rom_translation_ptr; \
rom_translation_ptr += 8; \
block_address = rom_translation_ptr + block_prologue_size; \
- RW_END(); \
block_lookup_translate_##type(rom, 0); \
translation_recursion_level--; \
\
@@ -2937,7 +2936,9 @@ u8 *block_lookup_address_##type(u32 pc) \
block_address = (u8 *)(-1); \
break; \
} \
- \
+ if(translation_recursion_level == 0) \
+ RW_END(); \
+ \
return block_address; \
} \
@@ -3291,7 +3292,8 @@ s32 translate_block_arm(u32 pc, translation_region_type
u8 *translation_cache_limit = NULL;
s32 i;
u32 flag_status;
- block_exit_type external_block_exits[MAX_EXITS];
+ block_exit_type external_block_exits[MAX_EXITS];
+ RW_INIT();
generate_block_extra_vars_arm();
arm_fix_pc();
@@ -3399,7 +3401,7 @@ s32 translate_block_arm(u32 pc, translation_region_type
flush_translation_cache_bios();
break;
}
-
+ RW_END();
return -1;
}
@@ -3476,12 +3478,14 @@ s32 translate_block_arm(u32 pc, translation_region_type
{
branch_target = external_block_exits[i].branch_target;
arm_link_block();
- if(!translation_target)
- return -1;
+ if(!translation_target){
+ RW_END();
+ return -1;
+ }
generate_branch_patch_unconditional(
external_block_exits[i].branch_source, translation_target);
}
-
+ RW_END();
return 0;
}
@@ -3508,7 +3512,8 @@ s32 translate_block_thumb(u32 pc, translation_region_type
u8 *translation_cache_limit = NULL;
s32 i;
u32 flag_status;
- block_exit_type external_block_exits[MAX_EXITS];
+ block_exit_type external_block_exits[MAX_EXITS];
+ RW_INIT();
generate_block_extra_vars_thumb();
thumb_fix_pc();
@@ -3616,7 +3621,7 @@ s32 translate_block_thumb(u32 pc, translation_region_type
flush_translation_cache_bios();
break;
}
-
+ RW_END();
return -1;
}
@@ -3693,12 +3698,14 @@ s32 translate_block_thumb(u32 pc, translation_region_type
{
branch_target = external_block_exits[i].branch_target;
thumb_link_block();
- if(!translation_target)
- return -1;
+ if(!translation_target){
+ RW_END();
+ return -1;
+ }
generate_branch_patch_unconditional(
external_block_exits[i].branch_source, translation_target);
}
-
+ RW_END();
return 0;
}
diff --git a/libretro.c b/libretro.c
index b0fac00..00dfe55 100644
--- a/libretro.c
+++ b/libretro.c
@@ -9,7 +9,7 @@
#include "memmap.h"
-#if defined(VITA)
+#if defined(VITA) && defined(HAVE_DYNAREC)
#include <psp2/kernel/sysmem.h>
static int translation_caches_inited = 0;
static inline int align(int x, int n) {
@@ -159,15 +159,13 @@ void retro_init(void)
}
#endif
-#if defined(VITA)
+#if defined(VITA) && defined(HAVE_DYNAREC)
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)));
- FILE * fd = fopen("ux0:/temp/test.txt","w+");
- fprintf(fd,"%x\n",sceBlock);
if (sceBlock < 0)
{
return;
@@ -179,9 +177,6 @@ void retro_init(void)
{
return;
}
- fprintf(fd,"%x %x\n",currentHandle,ret);
-
- fclose(fd);
rom_translation_cache = (u8*)currentHandle;
ram_translation_cache = rom_translation_cache + ROM_TRANSLATION_CACHE_SIZE;
@@ -240,7 +235,7 @@ void retro_deinit(void)
}
#endif
-#if defined(VITA)
+#if defined(VITA) && defined(HAVE_DYNAREC)
if(translation_caches_inited){
sceKernelFreeMemBlock(sceBlock);
@@ -487,7 +482,6 @@ bool retro_load_game(const struct retro_game_info* info)
}
gamepak_filename[0] = 0;
-
if (load_gamepak(info, info->path) != 0)
{
error_msg("Could not load the game file.");