Search
lxdream.org :: lxdream :: r376:8c7587af5a5d
lxdream 0.9.1
released Jun 29
Download Now
changeset376:8c7587af5a5d
parent375:4627600f7f8e
child377:fa18743f6905
authornkeynes
dateWed Sep 12 09:16:47 2007 +0000 (12 years ago)
Add disassembly dump function to xltcache
src/sh4/xltcache.c
src/sh4/xltcache.h
src/x86dasm/x86dasm.c
src/x86dasm/x86dasm.h
1.1 --- a/src/sh4/xltcache.c Tue Sep 11 21:23:48 2007 +0000
1.2 +++ b/src/sh4/xltcache.c Wed Sep 12 09:16:47 2007 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: xltcache.c,v 1.2 2007-09-04 08:32:44 nkeynes Exp $
1.6 + * $Id: xltcache.c,v 1.3 2007-09-12 09:16:47 nkeynes Exp $
1.7 *
1.8 * Translation cache management. This part is architecture independent.
1.9 *
1.10 @@ -54,24 +54,27 @@
1.11 xlat_cache_block_t xlat_old_cache_ptr;
1.12 static void ***xlat_lut;
1.13 static void **xlat_lut2; /* second-tier page info */
1.14 +static gboolean xlat_initialized = FALSE;
1.15
1.16 void xlat_cache_init()
1.17 {
1.18 - xlat_new_cache = mmap( NULL, XLAT_NEW_CACHE_SIZE, PROT_EXEC|PROT_READ|PROT_WRITE,
1.19 - MAP_PRIVATE|MAP_ANONYMOUS, -1, 0 );
1.20 - xlat_temp_cache = mmap( NULL, XLAT_TEMP_CACHE_SIZE, PROT_EXEC|PROT_READ|PROT_WRITE,
1.21 - MAP_PRIVATE|MAP_ANONYMOUS, -1, 0 );
1.22 - xlat_old_cache = mmap( NULL, XLAT_OLD_CACHE_SIZE, PROT_EXEC|PROT_READ|PROT_WRITE,
1.23 - MAP_PRIVATE|MAP_ANONYMOUS, -1, 0 );
1.24 - xlat_new_cache_ptr = xlat_new_cache;
1.25 - xlat_temp_cache_ptr = xlat_temp_cache;
1.26 - xlat_old_cache_ptr = xlat_old_cache;
1.27 - xlat_new_create_ptr = xlat_new_cache;
1.28 -
1.29 - xlat_lut = mmap( NULL, XLAT_LUT_PAGES*sizeof(void *), PROT_READ|PROT_WRITE,
1.30 - MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
1.31 - memset( xlat_lut, 0, XLAT_LUT_PAGES*sizeof(void *) );
1.32 -
1.33 + if( !xlat_initialized ) {
1.34 + xlat_initialized = TRUE;
1.35 + xlat_new_cache = mmap( NULL, XLAT_NEW_CACHE_SIZE, PROT_EXEC|PROT_READ|PROT_WRITE,
1.36 + MAP_PRIVATE|MAP_ANONYMOUS, -1, 0 );
1.37 + xlat_temp_cache = mmap( NULL, XLAT_TEMP_CACHE_SIZE, PROT_EXEC|PROT_READ|PROT_WRITE,
1.38 + MAP_PRIVATE|MAP_ANONYMOUS, -1, 0 );
1.39 + xlat_old_cache = mmap( NULL, XLAT_OLD_CACHE_SIZE, PROT_EXEC|PROT_READ|PROT_WRITE,
1.40 + MAP_PRIVATE|MAP_ANONYMOUS, -1, 0 );
1.41 + xlat_new_cache_ptr = xlat_new_cache;
1.42 + xlat_temp_cache_ptr = xlat_temp_cache;
1.43 + xlat_old_cache_ptr = xlat_old_cache;
1.44 + xlat_new_create_ptr = xlat_new_cache;
1.45 +
1.46 + xlat_lut = mmap( NULL, XLAT_LUT_PAGES*sizeof(void *), PROT_READ|PROT_WRITE,
1.47 + MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
1.48 + memset( xlat_lut, 0, XLAT_LUT_PAGES*sizeof(void *) );
1.49 + }
1.50 xlat_flush_cache();
1.51 }
1.52
1.53 @@ -351,3 +354,11 @@
1.54 xlat_check_cache_integrity( xlat_temp_cache, xlat_temp_cache_ptr, XLAT_TEMP_CACHE_SIZE );
1.55 xlat_check_cache_integrity( xlat_old_cache, xlat_old_cache_ptr, XLAT_OLD_CACHE_SIZE );
1.56 }
1.57 +
1.58 +
1.59 +void xlat_disasm_block( FILE *out, void *block )
1.60 +{
1.61 + uint32_t buflen = xlat_get_block_size(block);
1.62 + x86_set_symtab( NULL, 0 );
1.63 + x86_disasm_block( out, block, buflen );
1.64 +}
2.1 --- a/src/sh4/xltcache.h Tue Sep 11 21:23:48 2007 +0000
2.2 +++ b/src/sh4/xltcache.h Wed Sep 12 09:16:47 2007 +0000
2.3 @@ -1,5 +1,5 @@
2.4 /**
2.5 - * $Id: xltcache.h,v 1.2 2007-09-04 08:32:44 nkeynes Exp $
2.6 + * $Id: xltcache.h,v 1.3 2007-09-12 09:16:47 nkeynes Exp $
2.7 *
2.8 * Translation cache support (architecture independent)
2.9 *
2.10 @@ -48,6 +48,15 @@
2.11 void xlat_commit_block( uint32_t destsize, uint32_t srcsize );
2.12
2.13 /**
2.14 + * Dump the disassembly of the specified code block to a stream
2.15 + * (primarily for debugging purposes)
2.16 + * @param out The stream to write the output to
2.17 + * @param code a translated block
2.18 + */
2.19 +void xlat_disasm_block( FILE *out, void *code );
2.20 +
2.21 +
2.22 +/**
2.23 * Delete (deactivate) the specified block from the cache. Caller is responsible
2.24 * for ensuring that there really is a block there.
2.25 */
3.1 --- a/src/x86dasm/x86dasm.c Tue Sep 11 21:23:48 2007 +0000
3.2 +++ b/src/x86dasm/x86dasm.c Wed Sep 12 09:16:47 2007 +0000
3.3 @@ -1,5 +1,5 @@
3.4 /**
3.5 - * $Id: x86dasm.c,v 1.2 2007-09-04 08:32:10 nkeynes Exp $
3.6 + * $Id: x86dasm.c,v 1.3 2007-09-12 09:16:47 nkeynes Exp $
3.7 *
3.8 * Wrapper around i386-dis to supply the same behaviour as the other
3.9 * disassembly functions.
3.10 @@ -40,6 +40,20 @@
3.11 static x86_symbol *x86_symtab;
3.12 static int x86_num_symbols = 0;
3.13
3.14 +void x86_disasm_block(FILE *out, void *start, uint32_t len)
3.15 +{
3.16 + uint32_t start_addr = (uint32_t)start;
3.17 + uint32_t pc;
3.18 + x86_disasm_init( start, start_addr, len );
3.19 + for( pc = start_addr; pc < start_addr + len; ) {
3.20 + char buf[256];
3.21 + char op[256];
3.22 + uint32_t pc2 = x86_disasm_instruction( pc, buf, sizeof(buf), op );
3.23 + fprintf( out, "%08X: %-20s %s\n", pc, op, buf );
3.24 + pc = pc2;
3.25 + }
3.26 +}
3.27 +
3.28 void x86_disasm_init(char *buf, uint32_t vma, int buflen)
3.29 {
3.30 init_disassemble_info( &x86_disasm_info, NULL, x86_disasm_output );
4.1 --- a/src/x86dasm/x86dasm.h Tue Sep 11 21:23:48 2007 +0000
4.2 +++ b/src/x86dasm/x86dasm.h Wed Sep 12 09:16:47 2007 +0000
4.3 @@ -1,5 +1,5 @@
4.4 /**
4.5 - * $Id: x86dasm.h,v 1.2 2007-09-04 08:32:10 nkeynes Exp $
4.6 + * $Id: x86dasm.h,v 1.3 2007-09-12 09:16:47 nkeynes Exp $
4.7 *
4.8 * Wrapper around i386-dis to supply the same behaviour as the other
4.9 * disassembly functions.
4.10 @@ -26,6 +26,7 @@
4.11 void *ptr;
4.12 } x86_symbol;
4.13
4.14 +void x86_disasm_block( FILE *out, void *block, uint32_t len );
4.15 void x86_set_symtab( x86_symbol *symtab, int num_symbols );
4.16 void x86_disasm_init(char *buf, uint32_t vma, int buflen);
4.17 uint32_t x86_disasm_instruction( uint32_t pc, char *buf, int len, char *opcode );
.