Search
lxdream.org :: lxdream/src/sh4/sh4trans.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/sh4/sh4trans.c
changeset 1263:b3de98d19faf
prev1195:072131b61d2a
next1292:799fdd4f704a
author nkeynes
date Tue Mar 06 09:04:34 2012 +1000 (8 years ago)
permissions -rw-r--r--
last change Break host disassembly bits out of sh4x86.in, and move the generic disasm
bits from x86dasm to xlat.
file annotate diff log raw
1.1 --- a/src/sh4/sh4trans.c Mon Dec 12 21:15:44 2011 +1000
1.2 +++ b/src/sh4/sh4trans.c Tue Mar 06 09:04:34 2012 +1000
1.3 @@ -24,8 +24,10 @@
1.4 #include "sh4/sh4core.h"
1.5 #include "sh4/sh4trans.h"
1.6 #include "sh4/sh4mmio.h"
1.7 +#include "sh4/sh4dasm.h"
1.8 #include "sh4/mmu.h"
1.9 #include "xlat/xltcache.h"
1.10 +#include "xlat/xlatdasm.h"
1.11
1.12 //#define SINGLESTEP 1
1.13
1.14 @@ -292,6 +294,83 @@
1.15 sh4_translate_disasm_block( stderr, code, sh4_pc, NULL );
1.16 }
1.17
1.18 +
1.19 +static struct xlat_symbol xlat_symbol_table[] = {
1.20 + { "sh4r+128", ((char *)&sh4r)+128 },
1.21 + { "sh4_cpu_period", &sh4_cpu_period },
1.22 + { "sh4_address_space", NULL },
1.23 + { "sh4_user_address_space", NULL },
1.24 + { "sh4_translate_breakpoint_hit", sh4_translate_breakpoint_hit },
1.25 + { "sh4_translate_link_block", sh4_translate_link_block },
1.26 + { "sh4_write_fpscr", sh4_write_fpscr },
1.27 + { "sh4_write_sr", sh4_write_sr },
1.28 + { "sh4_read_sr", sh4_read_sr },
1.29 + { "sh4_raise_exception", sh4_raise_exception },
1.30 + { "sh4_sleep", sh4_sleep },
1.31 + { "sh4_fsca", sh4_fsca },
1.32 + { "sh4_ftrv", sh4_ftrv },
1.33 + { "sh4_switch_fr_banks", sh4_switch_fr_banks },
1.34 + { "sh4_execute_instruction", sh4_execute_instruction },
1.35 + { "signsat48", signsat48 },
1.36 + { "xlat_get_code_by_vma", xlat_get_code_by_vma },
1.37 + { "xlat_get_code", xlat_get_code }
1.38 +};
1.39 +
1.40 +/**
1.41 + * Disassemble the given translated code block, and it's source code block
1.42 + * side-by-side. The current native pc will be marked if non-null.
1.43 + */
1.44 +void sh4_translate_disasm_block( FILE *out, void *code, sh4addr_t source_start, void *native_pc )
1.45 +{
1.46 + char buf[256];
1.47 + char op[256];
1.48 +
1.49 + xlat_symbol_table[2].ptr = sh4_address_space;
1.50 + xlat_symbol_table[3].ptr = sh4_user_address_space;
1.51 + xlat_disasm_init( xlat_symbol_table, sizeof(xlat_symbol_table)/sizeof(struct xlat_symbol) );
1.52 +
1.53 + uintptr_t target_start = (uintptr_t)code, target_pc;
1.54 + uintptr_t target_end = target_start + xlat_get_code_size(code);
1.55 + uint32_t source_pc = source_start;
1.56 + uint32_t source_end = source_pc;
1.57 + xlat_recovery_record_t source_recov_table = XLAT_RECOVERY_TABLE(code);
1.58 + xlat_recovery_record_t source_recov_end = source_recov_table + XLAT_BLOCK_FOR_CODE(code)->recover_table_size - 1;
1.59 +
1.60 + for( target_pc = target_start; target_pc < target_end; ) {
1.61 + uintptr_t pc2 = xlat_disasm_instruction( target_pc, buf, sizeof(buf), op );
1.62 +#if SIZEOF_VOID_P == 8
1.63 + fprintf( out, "%c%016lx: %-30s %-40s", (target_pc == (uintptr_t)native_pc ? '*' : ' '),
1.64 + target_pc, op, buf );
1.65 +#else
1.66 + fprintf( out, "%c%08lx: %-30s %-40s", (target_pc == (uintptr_t)native_pc ? '*' : ' '),
1.67 + target_pc, op, buf );
1.68 +#endif
1.69 + if( source_recov_table < source_recov_end &&
1.70 + target_pc >= (target_start + source_recov_table->xlat_offset) ) {
1.71 + source_recov_table++;
1.72 + if( source_end < (source_start + (source_recov_table->sh4_icount)*2) )
1.73 + source_end = source_start + (source_recov_table->sh4_icount)*2;
1.74 + }
1.75 +
1.76 + if( source_pc < source_end ) {
1.77 + uint32_t source_pc2 = sh4_disasm_instruction( source_pc, buf, sizeof(buf), op );
1.78 + fprintf( out, " %08X: %s %s\n", source_pc, op, buf );
1.79 + source_pc = source_pc2;
1.80 + } else {
1.81 + fprintf( out, "\n" );
1.82 + }
1.83 +
1.84 + target_pc = pc2;
1.85 + }
1.86 +
1.87 + while( source_pc < source_end ) {
1.88 + uint32_t source_pc2 = sh4_disasm_instruction( source_pc, buf, sizeof(buf), op );
1.89 + fprintf( out, "%*c %08X: %s %s\n", 72,' ', source_pc, op, buf );
1.90 + source_pc = source_pc2;
1.91 + }
1.92 +}
1.93 +
1.94 +
1.95 void sh4_translate_dump_cache_by_activity( unsigned int topN )
1.96 {
1.97 struct xlat_block_ref blocks[topN];
.