Search
lxdream.org :: lxdream/src/sh4/sh4trans.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/sh4/sh4trans.c
changeset 596:dfc0c93d882e
prev593:6c710c7c6835
next600:3b0f94d0faed
author nkeynes
date Mon Jan 21 11:59:46 2008 +0000 (15 years ago)
permissions -rw-r--r--
last change Fix MAC.L/MAC.W stack issues
Fix various recovery-table issues
file annotate diff log raw
1.1 --- a/src/sh4/sh4trans.c Thu Jan 17 21:26:58 2008 +0000
1.2 +++ b/src/sh4/sh4trans.c Mon Jan 21 11:59:46 2008 +0000
1.3 @@ -88,9 +88,9 @@
1.4 code = xlat_get_code_by_vma( sh4r.pc );
1.5 if( code == NULL ) {
1.6 code = sh4_translate_basic_block( sh4r.pc );
1.7 -// xlat_check_integrity();
1.8 }
1.9 }
1.10 + uint32_t oldpc = sh4r.pc;
1.11 code = code();
1.12 }
1.13
1.14 @@ -105,9 +105,18 @@
1.15 }
1.16
1.17 uint8_t *xlat_output;
1.18 +xlat_cache_block_t xlat_current_block;
1.19 struct xlat_recovery_record xlat_recovery[MAX_RECOVERY_SIZE];
1.20 uint32_t xlat_recovery_posn;
1.21
1.22 +void sh4_translate_add_recovery( uint32_t icount )
1.23 +{
1.24 + xlat_recovery[xlat_recovery_posn].xlat_offset =
1.25 + ((uintptr_t)xlat_output) - ((uintptr_t)xlat_current_block->code);
1.26 + xlat_recovery[xlat_recovery_posn].sh4_icount = icount;
1.27 + xlat_recovery_posn++;
1.28 +}
1.29 +
1.30 /**
1.31 * Translate a linear basic block, ie all instructions from the start address
1.32 * (inclusive) until the next branch/jump instruction or the end of the page
1.33 @@ -120,10 +129,10 @@
1.34 sh4addr_t pc = start;
1.35 sh4addr_t lastpc = (pc&0xFFFFF000)+0x1000;
1.36 int done, i;
1.37 - xlat_cache_block_t block = xlat_start_block( start );
1.38 - xlat_output = (uint8_t *)block->code;
1.39 + xlat_current_block = xlat_start_block( start );
1.40 + xlat_output = (uint8_t *)xlat_current_block->code;
1.41 xlat_recovery_posn = 0;
1.42 - uint8_t *eob = xlat_output + block->size;
1.43 + uint8_t *eob = xlat_output + xlat_current_block->size;
1.44
1.45 if( GET_ICACHE_END() < lastpc ) {
1.46 lastpc = GET_ICACHE_END();
1.47 @@ -140,10 +149,10 @@
1.48 }
1.49 }
1.50 if( eob - xlat_output < MAX_INSTRUCTION_SIZE ) {
1.51 - uint8_t *oldstart = block->code;
1.52 - block = xlat_extend_block( xlat_output - oldstart + MAX_INSTRUCTION_SIZE );
1.53 - xlat_output = block->code + (xlat_output - oldstart);
1.54 - eob = block->code + block->size;
1.55 + uint8_t *oldstart = xlat_current_block->code;
1.56 + xlat_current_block = xlat_extend_block( xlat_output - oldstart + MAX_INSTRUCTION_SIZE );
1.57 + xlat_output = xlat_current_block->code + (xlat_output - oldstart);
1.58 + eob = xlat_current_block->code + xlat_current_block->size;
1.59 }
1.60 done = sh4_translate_instruction( pc );
1.61 assert( xlat_output <= eob );
1.62 @@ -155,20 +164,20 @@
1.63 pc += (done - 2);
1.64 int epilogue_size = sh4_translate_end_block_size();
1.65 uint32_t recovery_size = sizeof(struct xlat_recovery_record)*xlat_recovery_posn;
1.66 - uint32_t finalsize = xlat_output - block->code + epilogue_size + recovery_size;
1.67 + uint32_t finalsize = xlat_output - xlat_current_block->code + epilogue_size + recovery_size;
1.68 if( eob - xlat_output < finalsize ) {
1.69 - uint8_t *oldstart = block->code;
1.70 - block = xlat_extend_block( finalsize );
1.71 - xlat_output = block->code + (xlat_output - oldstart);
1.72 + uint8_t *oldstart = xlat_current_block->code;
1.73 + xlat_current_block = xlat_extend_block( finalsize );
1.74 + xlat_output = xlat_current_block->code + (xlat_output - oldstart);
1.75 }
1.76 sh4_translate_end_block(pc);
1.77
1.78 /* Write the recovery records onto the end of the code block */
1.79 memcpy( xlat_output, xlat_recovery, recovery_size);
1.80 - block->recover_table_offset = xlat_output - (uint8_t *)block->code;
1.81 - block->recover_table_size = xlat_recovery_posn;
1.82 + xlat_current_block->recover_table_offset = xlat_output - (uint8_t *)xlat_current_block->code;
1.83 + xlat_current_block->recover_table_size = xlat_recovery_posn;
1.84 xlat_commit_block( finalsize, pc-start );
1.85 - return block->code;
1.86 + return xlat_current_block->code;
1.87 }
1.88
1.89 /**
.