Search
lxdream.org :: lxdream/src/xlat/xltcache.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/xlat/xltcache.c
changeset 1188:1cc9bb0b3848
prev1186:2dc47c67bb93
next1189:1540105786c8
author Nathan Keynes <nkeynes@lxdream.org>
date Thu Dec 01 01:50:44 2011 +1000 (10 years ago)
permissions -rw-r--r--
last change Rearrange the profile dump code so as to avoid xlat => SH4 references
file annotate diff log raw
1.1 --- a/src/xlat/xltcache.c Tue Nov 29 17:11:40 2011 +1000
1.2 +++ b/src/xlat/xltcache.c Thu Dec 01 01:50:44 2011 +1000
1.3 @@ -583,11 +583,6 @@
1.4 #endif
1.5 }
1.6
1.7 -typedef struct {
1.8 - xlat_cache_block_t block;
1.9 - sh4addr_t sh4_pc;
1.10 -} block_sh4_entry;
1.11 -
1.12 unsigned int xlat_get_active_block_count()
1.13 {
1.14 unsigned int count = 0;
1.15 @@ -601,14 +596,14 @@
1.16 return count;
1.17 }
1.18
1.19 -unsigned int xlat_get_active_blocks( block_sh4_entry *blocks, unsigned int size )
1.20 +unsigned int xlat_get_active_blocks( struct xlat_block_ref *blocks, unsigned int size )
1.21 {
1.22 unsigned int count = 0;
1.23 xlat_cache_block_t ptr = xlat_new_cache;
1.24 while( ptr->size != 0 ) {
1.25 if( ptr->active != 0 ) {
1.26 blocks[count].block = ptr;
1.27 - blocks[count].sh4_pc = 0;
1.28 + blocks[count].pc = 0;
1.29 count++;
1.30 }
1.31 if( count >= size )
1.32 @@ -618,7 +613,7 @@
1.33 return count;
1.34 }
1.35
1.36 -void xlat_get_block_sh4addrs( block_sh4_entry *blocks, unsigned int size )
1.37 +void xlat_get_block_sh4addrs( struct xlat_block_ref *blocks, unsigned int size )
1.38 {
1.39 unsigned i;
1.40 for( i=0; i<XLAT_LUT_PAGES;i ++ ) {
1.41 @@ -631,7 +626,7 @@
1.42 sh4addr_t pc = XLAT_ADDR_FROM_ENTRY(i,j);
1.43 for( unsigned k=0; k<size; k++ ) {
1.44 if( blocks[k].block == ptr ) {
1.45 - blocks[k].sh4_pc = pc;
1.46 + blocks[k].pc = pc;
1.47 ptr = ptr->chain;
1.48 if( ptr == NULL )
1.49 break;
1.50 @@ -649,26 +644,23 @@
1.51
1.52 static int xlat_compare_active_field( const void *a, const void *b )
1.53 {
1.54 - const block_sh4_entry *ptra = (const block_sh4_entry *)a;
1.55 - const block_sh4_entry *ptrb = (const block_sh4_entry *)b;
1.56 + const struct xlat_block_ref *ptra = (const struct xlat_block_ref *)a;
1.57 + const struct xlat_block_ref *ptrb = (const struct xlat_block_ref *)b;
1.58 return ptrb->block->active - ptra->block->active;
1.59 }
1.60
1.61 -void xlat_dump_cache_by_activity( unsigned int topN )
1.62 +unsigned int xlat_get_cache_blocks_by_activity( xlat_block_ref_t outblocks, size_t topN )
1.63 {
1.64 int i=0;
1.65 int count = xlat_get_active_block_count();
1.66
1.67 - block_sh4_entry blocks[count];
1.68 + struct xlat_block_ref blocks[count];
1.69 xlat_get_active_blocks(blocks, count);
1.70 xlat_get_block_sh4addrs(blocks,count);
1.71 - qsort(blocks, count, sizeof(block_sh4_entry), xlat_compare_active_field);
1.72 + qsort(blocks, count, sizeof(struct xlat_block_ref), xlat_compare_active_field);
1.73
1.74 - if( topN == 0 || topN > count )
1.75 + if( topN > count )
1.76 topN = count;
1.77 - for( unsigned int i=0; i<topN; i++ ) {
1.78 - fprintf(stderr, "0x%08X (%p): %d\n", blocks[i].sh4_pc, blocks[i].block->code, blocks[i].block->active);
1.79 - sh4_translate_disasm_block( stderr, blocks[i].block->code, blocks[i].sh4_pc, NULL );
1.80 - fprintf(stderr, "\n");
1.81 - }
1.82 + memcpy(outblocks, blocks, topN*sizeof(struct xlat_block_ref));
1.83 + return topN;
1.84 }
.