Search
lxdream.org :: lxdream/src/sh4/sh4x86.in :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/sh4/sh4x86.in
changeset 1263:b3de98d19faf
prev1218:be02e87f9f87
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/sh4x86.in Mon Feb 13 21:02:42 2012 +1000
1.2 +++ b/src/sh4/sh4x86.in Tue Mar 06 09:04:34 2012 +1000
1.3 @@ -34,7 +34,7 @@
1.4 #include "sh4/mmu.h"
1.5 #include "xlat/xltcache.h"
1.6 #include "xlat/x86/x86op.h"
1.7 -#include "x86dasm/x86dasm.h"
1.8 +#include "xlat/xlatdasm.h"
1.9 #include "clock.h"
1.10
1.11 #define DEFAULT_BACKPATCH_SIZE 4096
1.12 @@ -120,30 +120,8 @@
1.13 static uint32_t save_fcw; /* save value for fpu control word */
1.14 static uint32_t trunc_fcw = 0x0F7F; /* fcw value for truncation mode */
1.15
1.16 -static void FASTCALL sh4_translate_get_code_and_backpatch( uint32_t pc );
1.17 static void sh4_x86_translate_unlink_block( void *use_list );
1.18
1.19 -static struct x86_symbol x86_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_get_code_and_backpatch", sh4_translate_get_code_and_backpatch },
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 static struct xlat_target_fns x86_target_fns = {
1.41 sh4_x86_translate_unlink_block
1.42 };
1.43 @@ -163,8 +141,6 @@
1.44 {
1.45 sh4_x86.priv_address_space = priv;
1.46 sh4_x86.user_address_space = user;
1.47 - x86_symbol_table[2].ptr = priv;
1.48 - x86_symbol_table[3].ptr = user;
1.49 }
1.50
1.51 void sh4_translate_init(void)
1.52 @@ -176,8 +152,6 @@
1.53 sh4_translate_set_address_space( sh4_address_space, sh4_user_address_space );
1.54 sh4_x86.fastmem = TRUE;
1.55 sh4_x86.sse3_enabled = is_sse3_supported();
1.56 - x86_disasm_init();
1.57 - x86_set_symtab( x86_symbol_table, sizeof(x86_symbol_table)/sizeof(struct x86_symbol) );
1.58 xlat_set_target_fns(&x86_target_fns);
1.59 }
1.60
1.61 @@ -192,56 +166,6 @@
1.62 sh4_x86.fastmem = flag;
1.63 }
1.64
1.65 -/**
1.66 - * Disassemble the given translated code block, and it's source SH4 code block
1.67 - * side-by-side. The current native pc will be marked if non-null.
1.68 - */
1.69 -void sh4_translate_disasm_block( FILE *out, void *code, sh4addr_t source_start, void *native_pc )
1.70 -{
1.71 - char buf[256];
1.72 - char op[256];
1.73 -
1.74 - uintptr_t target_start = (uintptr_t)code, target_pc;
1.75 - uintptr_t target_end = target_start + xlat_get_code_size(code);
1.76 - uint32_t source_pc = source_start;
1.77 - uint32_t source_end = source_pc;
1.78 - xlat_recovery_record_t source_recov_table = XLAT_RECOVERY_TABLE(code);
1.79 - xlat_recovery_record_t source_recov_end = source_recov_table + XLAT_BLOCK_FOR_CODE(code)->recover_table_size - 1;
1.80 -
1.81 - for( target_pc = target_start; target_pc < target_end; ) {
1.82 - uintptr_t pc2 = x86_disasm_instruction( target_pc, buf, sizeof(buf), op );
1.83 -#if SIZEOF_VOID_P == 8
1.84 - fprintf( out, "%c%016lx: %-30s %-40s", (target_pc == (uintptr_t)native_pc ? '*' : ' '),
1.85 - target_pc, op, buf );
1.86 -#else
1.87 - fprintf( out, "%c%08lx: %-30s %-40s", (target_pc == (uintptr_t)native_pc ? '*' : ' '),
1.88 - target_pc, op, buf );
1.89 -#endif
1.90 - if( source_recov_table < source_recov_end &&
1.91 - target_pc >= (target_start + source_recov_table->xlat_offset) ) {
1.92 - source_recov_table++;
1.93 - if( source_end < (source_start + (source_recov_table->sh4_icount)*2) )
1.94 - source_end = source_start + (source_recov_table->sh4_icount)*2;
1.95 - }
1.96 -
1.97 - if( source_pc < source_end ) {
1.98 - uint32_t source_pc2 = sh4_disasm_instruction( source_pc, buf, sizeof(buf), op );
1.99 - fprintf( out, " %08X: %s %s\n", source_pc, op, buf );
1.100 - source_pc = source_pc2;
1.101 - } else {
1.102 - fprintf( out, "\n" );
1.103 - }
1.104 -
1.105 - target_pc = pc2;
1.106 - }
1.107 -
1.108 - while( source_pc < source_end ) {
1.109 - uint32_t source_pc2 = sh4_disasm_instruction( source_pc, buf, sizeof(buf), op );
1.110 - fprintf( out, "%*c %08X: %s %s\n", 72,' ', source_pc, op, buf );
1.111 - source_pc = source_pc2;
1.112 - }
1.113 -}
1.114 -
1.115 static void sh4_x86_add_backpatch( uint8_t *fixup_addr, uint32_t fixup_pc, uint32_t exc_code )
1.116 {
1.117 int reloc_size = 4;
1.118 @@ -583,7 +507,7 @@
1.119 /**
1.120 *
1.121 */
1.122 -static void FASTCALL sh4_translate_get_code_and_backpatch( uint32_t pc )
1.123 +void FASTCALL sh4_translate_link_block( uint32_t pc )
1.124 {
1.125 uint8_t *target = (uint8_t *)xlat_get_code_by_vma(pc);
1.126 while( target != NULL && sh4r.xlat_sh4_mode != XLAT_BLOCK_MODE(target) ) {
1.127 @@ -606,7 +530,7 @@
1.128 static void emit_translate_and_backpatch()
1.129 {
1.130 /* NB: this is either 7 bytes (i386) or 12 bytes (x86-64) */
1.131 - CALL1_ptr_r32(sh4_translate_get_code_and_backpatch, REG_ARG1);
1.132 + CALL1_ptr_r32(sh4_translate_link_block, REG_ARG1);
1.133
1.134 /* When patched, the jmp instruction will be 5 bytes (either platform) -
1.135 * we need to reserve sizeof(void*) bytes for the use-list
.