Search
lxdream.org :: lxdream/src/xlat/xltcache.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/xlat/xltcache.c
changeset 1186:2dc47c67bb93
prev1182:b38a327ad8fa
next1188:1cc9bb0b3848
author nkeynes
date Tue Nov 29 17:11:40 2011 +1000 (10 years ago)
permissions -rw-r--r--
last change Add support for block linking when the block target is fixed. Only a small
(~3% improvement) so far.
file annotate diff log raw
1.1 --- a/src/xlat/xltcache.c Sun Nov 27 18:20:21 2011 +1000
1.2 +++ b/src/xlat/xltcache.c Tue Nov 29 17:11:40 2011 +1000
1.3 @@ -22,6 +22,7 @@
1.4
1.5 #include "dreamcast.h"
1.6 #include "sh4/sh4core.h"
1.7 +#include "sh4/sh4trans.h"
1.8 #include "xlat/xltcache.h"
1.9 #include "x86dasm/x86dasm.h"
1.10
1.11 @@ -121,6 +122,13 @@
1.12 }
1.13 }
1.14
1.15 +void xlat_delete_block( xlat_cache_block_t block )
1.16 +{
1.17 + block->active = 0;
1.18 + *block->lut_entry = block->chain;
1.19 + sh4_translate_unlink_block( block->use_list );
1.20 +}
1.21 +
1.22 static void xlat_flush_page_by_lut( void **page )
1.23 {
1.24 int i;
1.25 @@ -129,7 +137,7 @@
1.26 void *p = page[i];
1.27 do {
1.28 xlat_cache_block_t block = XLAT_BLOCK_FOR_CODE(p);
1.29 - block->active = 0;
1.30 + xlat_delete_block(block);
1.31 p = block->chain;
1.32 } while( p != NULL );
1.33 }
1.34 @@ -377,7 +385,8 @@
1.35 #else
1.36 void xlat_promote_to_temp_space( xlat_cache_block_t block )
1.37 {
1.38 - *block->lut_entry = 0;
1.39 + *block->lut_entry = block->chain;
1.40 + xlat_delete_block(block);
1.41 }
1.42 #endif
1.43
1.44 @@ -414,6 +423,7 @@
1.45 } else {
1.46 xlat_new_create_ptr->chain = NULL;
1.47 }
1.48 + xlat_new_create_ptr->use_list = NULL;
1.49
1.50 xlat_lut[XLAT_LUT_PAGE(address)][XLAT_LUT_ENTRY(address)] =
1.51 &xlat_new_create_ptr->code;
1.52 @@ -424,6 +434,7 @@
1.53
1.54 xlat_cache_block_t xlat_extend_block( uint32_t newSize )
1.55 {
1.56 + assert( xlat_new_create_ptr->use_list == NULL );
1.57 while( xlat_new_create_ptr->size < newSize ) {
1.58 if( xlat_new_cache_ptr->size == 0 ) {
1.59 /* Migrate to the front of the cache to keep it contiguous */
1.60 @@ -447,6 +458,7 @@
1.61 xlat_new_create_ptr->size = allocation;
1.62 xlat_new_create_ptr->lut_entry = lut_entry;
1.63 xlat_new_create_ptr->chain = chain;
1.64 + xlat_new_create_ptr->use_list = NULL;
1.65 *lut_entry = &xlat_new_create_ptr->code;
1.66 memmove( xlat_new_create_ptr->code, olddata, oldsize );
1.67 } else {
1.68 @@ -475,12 +487,6 @@
1.69 xlat_new_cache_ptr = xlat_cut_block( xlat_new_create_ptr, destsize );
1.70 }
1.71
1.72 -void xlat_delete_block( xlat_cache_block_t block )
1.73 -{
1.74 - block->active = 0;
1.75 - *block->lut_entry = NULL;
1.76 -}
1.77 -
1.78 void xlat_check_cache_integrity( xlat_cache_block_t cache, xlat_cache_block_t ptr, int size )
1.79 {
1.80 int foundptr = 0;
1.81 @@ -517,7 +523,7 @@
1.82 if( page != NULL ) {
1.83 for( j=0; j<XLAT_LUT_PAGE_ENTRIES; j++ ) {
1.84 void *entry = page[j];
1.85 - if( ((uintptr_t)entry) > XLAT_LUT_ENTRY_USED ) {
1.86 + if( ((uintptr_t)entry) > (uintptr_t)XLAT_LUT_ENTRY_USED ) {
1.87 xlat_cache_block_t block = XLAT_BLOCK_FOR_CODE(entry);
1.88 if( ptr >= block->code && ptr < block->code + block->size) {
1.89 /* Found it */
.