Search
lxdream.org :: lxdream/src/sh4/xltcache.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/sh4/xltcache.c
changeset 410:5f8413358e7f
prev407:d24ab36150c4
next422:61a0598e07ff
author nkeynes
date Thu Oct 04 08:47:52 2007 +0000 (16 years ago)
permissions -rw-r--r--
last change Add explicit branch cases for main ram - yes it's faster...
file annotate diff log raw
1.1 --- a/src/sh4/xltcache.c Fri Sep 28 07:26:35 2007 +0000
1.2 +++ b/src/sh4/xltcache.c Thu Oct 04 08:47:52 2007 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: xltcache.c,v 1.6 2007-09-28 07:26:35 nkeynes Exp $
1.6 + * $Id: xltcache.c,v 1.7 2007-09-29 11:06:40 nkeynes Exp $
1.7 *
1.8 * Translation cache management. This part is architecture independent.
1.9 *
1.10 @@ -53,7 +53,6 @@
1.11 xlat_cache_block_t xlat_old_cache;
1.12 xlat_cache_block_t xlat_old_cache_ptr;
1.13 static void ***xlat_lut;
1.14 -static void **xlat_lut2; /* second-tier page info */
1.15 static gboolean xlat_initialized = FALSE;
1.16
1.17 void xlat_cache_init()
1.18 @@ -197,10 +196,10 @@
1.19
1.20 void *xlat_get_code( sh4addr_t address )
1.21 {
1.22 - void *result;
1.23 + void *result = NULL;
1.24 void **page = xlat_lut[XLAT_LUT_PAGE(address)];
1.25 if( page != NULL ) {
1.26 - result = (void *)(((uint32_t)page[XLAT_LUT_ENTRY(address)]) & 0xFFFFFFFC);
1.27 + result = (void *)(((uint32_t)(page[XLAT_LUT_ENTRY(address)])) & 0xFFFFFFFC);
1.28 }
1.29 return result;
1.30 }
1.31 @@ -237,6 +236,7 @@
1.32 static inline xlat_cache_block_t xlat_cut_block( xlat_cache_block_t block, int cutsize )
1.33 {
1.34 cutsize = (cutsize + 3) & 0xFFFFFFFC; // force word alignment
1.35 + assert( cutsize <= block->size );
1.36 if( block->size > cutsize + MIN_TOTAL_SIZE ) {
1.37 int oldsize = block->size;
1.38 block->size = cutsize;
1.39 @@ -365,36 +365,38 @@
1.40 return xlat_new_create_ptr;
1.41 }
1.42
1.43 -xlat_cache_block_t xlat_extend_block()
1.44 +xlat_cache_block_t xlat_extend_block( uint32_t newSize )
1.45 {
1.46 - if( xlat_new_cache_ptr->size == 0 ) {
1.47 - /* Migrate to the front of the cache to keep it contiguous */
1.48 - xlat_new_create_ptr->active = 0;
1.49 - char *olddata = xlat_new_create_ptr->code;
1.50 - int oldsize = xlat_new_create_ptr->size;
1.51 - int size = oldsize + MIN_BLOCK_SIZE; /* minimum expansion */
1.52 - void **lut_entry = xlat_new_create_ptr->lut_entry;
1.53 - int allocation = -sizeof(struct xlat_cache_block);
1.54 - xlat_new_cache_ptr = xlat_new_cache;
1.55 - do {
1.56 + while( xlat_new_create_ptr->size < newSize ) {
1.57 + if( xlat_new_cache_ptr->size == 0 ) {
1.58 + /* Migrate to the front of the cache to keep it contiguous */
1.59 + xlat_new_create_ptr->active = 0;
1.60 + char *olddata = xlat_new_create_ptr->code;
1.61 + int oldsize = xlat_new_create_ptr->size;
1.62 + int size = oldsize + MIN_BLOCK_SIZE; /* minimum expansion */
1.63 + void **lut_entry = xlat_new_create_ptr->lut_entry;
1.64 + int allocation = -sizeof(struct xlat_cache_block);
1.65 + xlat_new_cache_ptr = xlat_new_cache;
1.66 + do {
1.67 + if( xlat_new_cache_ptr->active ) {
1.68 + xlat_promote_to_temp_space( xlat_new_cache_ptr );
1.69 + }
1.70 + allocation += xlat_new_cache_ptr->size + sizeof(struct xlat_cache_block);
1.71 + xlat_new_cache_ptr = NEXT(xlat_new_cache_ptr);
1.72 + } while( allocation < size );
1.73 + xlat_new_create_ptr = xlat_new_cache;
1.74 + xlat_new_create_ptr->active = 1;
1.75 + xlat_new_create_ptr->size = allocation;
1.76 + xlat_new_create_ptr->lut_entry = lut_entry;
1.77 + *lut_entry = &xlat_new_create_ptr->code;
1.78 + memmove( xlat_new_create_ptr->code, olddata, oldsize );
1.79 + } else {
1.80 if( xlat_new_cache_ptr->active ) {
1.81 xlat_promote_to_temp_space( xlat_new_cache_ptr );
1.82 }
1.83 - allocation += xlat_new_cache_ptr->size + sizeof(struct xlat_cache_block);
1.84 + xlat_new_create_ptr->size += xlat_new_cache_ptr->size + sizeof(struct xlat_cache_block);
1.85 xlat_new_cache_ptr = NEXT(xlat_new_cache_ptr);
1.86 - } while( allocation < size );
1.87 - xlat_new_create_ptr = xlat_new_cache;
1.88 - xlat_new_create_ptr->active = 1;
1.89 - xlat_new_create_ptr->size = allocation;
1.90 - xlat_new_create_ptr->lut_entry = lut_entry;
1.91 - *lut_entry = &xlat_new_create_ptr->code;
1.92 - memmove( xlat_new_create_ptr->code, olddata, oldsize );
1.93 - } else {
1.94 - if( xlat_new_cache_ptr->active ) {
1.95 - xlat_promote_to_temp_space( xlat_new_cache_ptr );
1.96 }
1.97 - xlat_new_create_ptr->size += xlat_new_cache_ptr->size + sizeof(struct xlat_cache_block);
1.98 - xlat_new_cache_ptr = NEXT(xlat_new_cache_ptr);
1.99 }
1.100 return xlat_new_create_ptr;
1.101
.