Search
lxdream.org :: lxdream/src/sh4/xltcache.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/sh4/xltcache.c
changeset 922:8a8361264b1e
prev905:4c17ebd9ef5e
next935:45246788ca00
next953:f4a156508ad1
author nkeynes
date Mon Dec 22 09:51:11 2008 +0000 (15 years ago)
branchlxdream-mem
permissions -rw-r--r--
last change Remove pointer cache and add full address-space map. Much better
file annotate diff log raw
1.1 --- a/src/sh4/xltcache.c Wed Oct 29 23:51:58 2008 +0000
1.2 +++ b/src/sh4/xltcache.c Mon Dec 22 09:51:11 2008 +0000
1.3 @@ -51,10 +51,14 @@
1.4 xlat_cache_block_t xlat_new_cache;
1.5 xlat_cache_block_t xlat_new_cache_ptr;
1.6 xlat_cache_block_t xlat_new_create_ptr;
1.7 +
1.8 +#ifdef XLAT_GENERATIONAL_CACHE
1.9 xlat_cache_block_t xlat_temp_cache;
1.10 xlat_cache_block_t xlat_temp_cache_ptr;
1.11 xlat_cache_block_t xlat_old_cache;
1.12 xlat_cache_block_t xlat_old_cache_ptr;
1.13 +#endif
1.14 +
1.15 static void ***xlat_lut;
1.16 static gboolean xlat_initialized = FALSE;
1.17
1.18 @@ -64,15 +68,16 @@
1.19 xlat_initialized = TRUE;
1.20 xlat_new_cache = mmap( NULL, XLAT_NEW_CACHE_SIZE, PROT_EXEC|PROT_READ|PROT_WRITE,
1.21 MAP_PRIVATE|MAP_ANON, -1, 0 );
1.22 + xlat_new_cache_ptr = xlat_new_cache;
1.23 + xlat_new_create_ptr = xlat_new_cache;
1.24 +#ifdef XLAT_GENERATIONAL_CACHE
1.25 xlat_temp_cache = mmap( NULL, XLAT_TEMP_CACHE_SIZE, PROT_EXEC|PROT_READ|PROT_WRITE,
1.26 MAP_PRIVATE|MAP_ANON, -1, 0 );
1.27 xlat_old_cache = mmap( NULL, XLAT_OLD_CACHE_SIZE, PROT_EXEC|PROT_READ|PROT_WRITE,
1.28 MAP_PRIVATE|MAP_ANON, -1, 0 );
1.29 - xlat_new_cache_ptr = xlat_new_cache;
1.30 xlat_temp_cache_ptr = xlat_temp_cache;
1.31 xlat_old_cache_ptr = xlat_old_cache;
1.32 - xlat_new_create_ptr = xlat_new_cache;
1.33 -
1.34 +#endif
1.35 xlat_lut = mmap( NULL, XLAT_LUT_PAGES*sizeof(void *), PROT_READ|PROT_WRITE,
1.36 MAP_PRIVATE|MAP_ANON, -1, 0);
1.37 memset( xlat_lut, 0, XLAT_LUT_PAGES*sizeof(void *) );
1.38 @@ -80,12 +85,6 @@
1.39 xlat_flush_cache();
1.40 }
1.41
1.42 -void xlat_print_free( FILE *out )
1.43 -{
1.44 - fprintf( out, "New space: %d\nTemp space: %d\nOld space: %d\n",
1.45 - xlat_new_cache_ptr->size, xlat_temp_cache_ptr->size, xlat_old_cache_ptr->size );
1.46 -}
1.47 -
1.48 /**
1.49 * Reset the cache structure to its default state
1.50 */
1.51 @@ -99,6 +98,7 @@
1.52 tmp = NEXT(xlat_new_cache_ptr);
1.53 tmp->active = 1;
1.54 tmp->size = 0;
1.55 +#ifdef XLAT_GENERATIONAL_CACHE
1.56 xlat_temp_cache_ptr = xlat_temp_cache;
1.57 xlat_temp_cache_ptr->active = 0;
1.58 xlat_temp_cache_ptr->size = XLAT_TEMP_CACHE_SIZE - 2*sizeof(struct xlat_cache_block);
1.59 @@ -111,6 +111,7 @@
1.60 tmp = NEXT(xlat_old_cache_ptr);
1.61 tmp->active = 1;
1.62 tmp->size = 0;
1.63 +#endif
1.64 for( i=0; i<XLAT_LUT_PAGES; i++ ) {
1.65 if( xlat_lut[i] != NULL ) {
1.66 memset( xlat_lut[i], 0, XLAT_LUT_PAGE_SIZE );
1.67 @@ -303,6 +304,7 @@
1.68 }
1.69 }
1.70
1.71 +#ifdef XLAT_GENERATIONAL_CACHE
1.72 /**
1.73 * Promote a block in temp space (or elsewhere for that matter) to old space.
1.74 *
1.75 @@ -392,6 +394,12 @@
1.76 }
1.77
1.78 }
1.79 +#else
1.80 +void xlat_promote_to_temp_space( xlat_cache_block_t block )
1.81 +{
1.82 + *block->lut_entry = 0;
1.83 +}
1.84 +#endif
1.85
1.86 /**
1.87 * Returns the next block in the new cache list that can be written to by the
1.88 @@ -510,7 +518,9 @@
1.89 void xlat_check_integrity( )
1.90 {
1.91 xlat_check_cache_integrity( xlat_new_cache, xlat_new_cache_ptr, XLAT_NEW_CACHE_SIZE );
1.92 +#ifdef XLAT_GENERATIONAL_CACHE
1.93 xlat_check_cache_integrity( xlat_temp_cache, xlat_temp_cache_ptr, XLAT_TEMP_CACHE_SIZE );
1.94 xlat_check_cache_integrity( xlat_old_cache, xlat_old_cache_ptr, XLAT_OLD_CACHE_SIZE );
1.95 +#endif
1.96 }
1.97
.