summaryrefslogtreecommitdiff
path: root/cpu_threaded.c
diff options
context:
space:
mode:
authorDavid Guillen Fandos2021-03-23 19:05:35 +0100
committerDavid Guillen Fandos2021-03-23 19:09:56 +0100
commit11ec213c99d5d22905ff82cf3fb26ba6a8adf290 (patch)
tree0af3ed99246d3bdb2d2b22f1420bddf2fafba507 /cpu_threaded.c
parent7e27010a3c08811e4ed04097e1961009c3fef8d7 (diff)
downloadpicogpsp-11ec213c99d5d22905ff82cf3fb26ba6a8adf290.tar.gz
picogpsp-11ec213c99d5d22905ff82cf3fb26ba6a8adf290.tar.bz2
picogpsp-11ec213c99d5d22905ff82cf3fb26ba6a8adf290.zip
Make ewram memory lineal
This saves a few cycles in MIPS and simplifies a bit the core. Removed the write map, only affects interpreter performance very minimally. Rewired ARM and x86 handlers to support direct access to I/EWRAM (and VRAM on ARM) to compensate. Overall performance is slightly better but code is cleaner and allows for further improvements in the dynarecs.
Diffstat (limited to 'cpu_threaded.c')
-rw-r--r--cpu_threaded.c60
1 files changed, 17 insertions, 43 deletions
diff --git a/cpu_threaded.c b/cpu_threaded.c
index 519d7f0..555b9c6 100644
--- a/cpu_threaded.c
+++ b/cpu_threaded.c
@@ -76,12 +76,6 @@ u32 ewram_code_max = 0xFFFFFFFF;
u32 *rom_branch_hash[ROM_BRANCH_HASH_SIZE];
-// Default
-u32 force_pc_update_target = 0xFFFFFFFF;
-u32 allow_smc_ram_u8 = 1;
-u32 allow_smc_ram_u16 = 1;
-u32 allow_smc_ram_u32 = 1;
-
typedef struct
{
u8 *block_offset;
@@ -2813,7 +2807,7 @@ u8 function_cc *block_lookup_address_##type(u32 pc) \
switch(pc >> 24) \
{ \
case 0x2: \
- location = (u16 *)(ewram + (pc & 0x7FFF) + ((pc & 0x38000) * 2)); \
+ location = (u16 *)(ewram + (pc & 0x3FFFF) + 0x40000); \
block_lookup_translate(type, ram, 1); \
break; \
\
@@ -3119,18 +3113,22 @@ block_lookup_address_builder(dual);
block_data_type block_data[MAX_BLOCK_SIZE];
block_exit_type block_exits[MAX_EXITS];
-#define smc_write_arm_yes() \
- if(address32(pc_address_block, (block_end_pc & 0x7FFF) - 0x8000) == 0x0000) \
+#define smc_write_arm_yes() { \
+ int offset = (pc < 0x03000000) ? 0x40000 : -0x8000; \
+ if(address32(pc_address_block, (block_end_pc & 0x7FFF) + offset) == 0) \
{ \
- address32(pc_address_block, (block_end_pc & 0x7FFF) - 0x8000) = \
+ address32(pc_address_block, (block_end_pc & 0x7FFF) + offset) = \
0xFFFFFFFF; \
} \
+}
-#define smc_write_thumb_yes() \
- if(address16(pc_address_block, (block_end_pc & 0x7FFF) - 0x8000) == 0x0000) \
+#define smc_write_thumb_yes() { \
+ int offset = (pc < 0x03000000) ? 0x40000 : -0x8000; \
+ if(address16(pc_address_block, (block_end_pc & 0x7FFF) + offset) == 0) \
{ \
- address16(pc_address_block, (block_end_pc & 0x7FFF) - 0x8000) = 0xFFFF; \
+ address16(pc_address_block, (block_end_pc & 0x7FFF) + offset) = 0xFFFF; \
} \
+}
#define smc_write_arm_no() \
@@ -3428,7 +3426,6 @@ s32 translate_block_thumb(u32 pc, translation_region_type
u32 opcode = 0;
u32 last_opcode;
u32 condition;
- u32 last_condition;
u32 pc_region = (pc >> 15);
u32 new_pc_region;
u8 *pc_address_block = memory_map_read[pc_region];
@@ -3514,8 +3511,6 @@ s32 translate_block_thumb(u32 pc, translation_region_type
block_exit_position = 0;
block_data_position = 0;
- last_condition = 0x0E;
-
while(pc != block_end_pc)
{
block_data[block_data_position].block_offset = translation_ptr;
@@ -3627,13 +3622,16 @@ s32 translate_block_thumb(u32 pc, translation_region_type
void flush_translation_cache_ram(void)
{
flush_ram_count++;
-/* printf("ram flush %d (pc %x), %x to %x, %x to %x\n",
+ /*printf("ram flush %d (pc %x), %x to %x, %x to %x\n",
flush_ram_count, reg[REG_PC], iwram_code_min, iwram_code_max,
- ewram_code_min, ewram_code_max); */
+ ewram_code_min, ewram_code_max);*/
last_ram_translation_ptr = ram_translation_cache;
ram_translation_ptr = ram_translation_cache;
ram_block_tag_top = 0x0101;
+
+ // Proceed to clean the SMC area if needed
+ // (also try to memset as little as possible for performance)
if(iwram_code_min != 0xFFFFFFFF)
{
iwram_code_min &= 0x7FFF;
@@ -3643,33 +3641,9 @@ void flush_translation_cache_ram(void)
if(ewram_code_min != 0xFFFFFFFF)
{
- u32 ewram_code_min_page;
- u32 ewram_code_max_page;
- u32 ewram_code_min_offset;
- u32 ewram_code_max_offset;
- u32 i;
-
ewram_code_min &= 0x3FFFF;
ewram_code_max &= 0x3FFFF;
-
- ewram_code_min_page = ewram_code_min >> 15;
- ewram_code_max_page = ewram_code_max >> 15;
- ewram_code_min_offset = ewram_code_min & 0x7FFF;
- ewram_code_max_offset = ewram_code_max & 0x7FFF;
-
- if(ewram_code_min_page == ewram_code_max_page)
- {
- memset(ewram + (ewram_code_min_page * 0x10000) +
- ewram_code_min_offset, 0,
- ewram_code_max_offset - ewram_code_min_offset);
- }
- else
- {
- for(i = ewram_code_min_page + 1; i < ewram_code_max_page; i++)
- memset(ewram + (i * 0x10000), 0, 0x8000);
-
- memset(ewram, 0, ewram_code_max_offset);
- }
+ memset(&ewram[0x40000 + ewram_code_min], 0, ewram_code_max - ewram_code_min);
}
iwram_code_min = 0xFFFFFFFF;