Search
lxdream.org :: lxdream/src/sh4/xltcache.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/sh4/xltcache.c
changeset 400:049d72a7a229
prev383:f597b73474cb
next407:d24ab36150c4
author nkeynes
date Thu Sep 20 08:35:04 2007 +0000 (13 years ago)
permissions -rw-r--r--
last change Add translation cache invalidation
file annotate diff log raw
1.1 --- a/src/sh4/xltcache.c Sun Sep 16 06:59:47 2007 +0000
1.2 +++ b/src/sh4/xltcache.c Thu Sep 20 08:35:04 2007 +0000
1.3 @@ -1,5 +1,5 @@
1.4 /**
1.5 - * $Id: xltcache.c,v 1.4 2007-09-16 06:59:47 nkeynes Exp $
1.6 + * $Id: xltcache.c,v 1.5 2007-09-20 08:35:04 nkeynes Exp $
1.7 *
1.8 * Translation cache management. This part is architecture independent.
1.9 *
1.10 @@ -78,6 +78,12 @@
1.11 xlat_flush_cache();
1.12 }
1.13
1.14 +void xlat_print_free( FILE *out )
1.15 +{
1.16 + fprintf( out, "New space: %d\nTemp space: %d\nOld space: %d\n",
1.17 + xlat_new_cache_ptr->size, xlat_temp_cache_ptr->size, xlat_old_cache_ptr->size );
1.18 +}
1.19 +
1.20 /**
1.21 * Reset the cache structure to its default state
1.22 */
1.23 @@ -110,10 +116,9 @@
1.24 }
1.25 }
1.26
1.27 -void xlat_flush_page( sh4addr_t address )
1.28 +static void xlat_flush_page_by_lut( void **page )
1.29 {
1.30 int i;
1.31 - void **page = xlat_lut[XLAT_LUT_PAGE(address)];
1.32 for( i=0; i<XLAT_LUT_PAGE_ENTRIES; i++ ) {
1.33 if( IS_ENTRY_POINT(page[i]) ) {
1.34 BLOCK_FOR_CODE(page[i])->active = 0;
1.35 @@ -122,6 +127,74 @@
1.36 }
1.37 }
1.38
1.39 +void xlat_invalidate_word( sh4addr_t addr )
1.40 +{
1.41 + if( xlat_lut ) {
1.42 + void **page = xlat_lut[XLAT_LUT_PAGE(addr)];
1.43 + if( page != NULL ) {
1.44 + int entry = XLAT_LUT_ENTRY(addr);
1.45 + if( page[entry] != NULL ) {
1.46 + xlat_flush_page_by_lut(page);
1.47 + }
1.48 + }
1.49 + }
1.50 +}
1.51 +
1.52 +void xlat_invalidate_long( sh4addr_t addr )
1.53 +{
1.54 + if( xlat_lut ) {
1.55 + void **page = xlat_lut[XLAT_LUT_PAGE(addr)];
1.56 + if( page != NULL ) {
1.57 + int entry = XLAT_LUT_ENTRY(addr);
1.58 + if( page[entry] != NULL || page[entry+1] != NULL ) {
1.59 + xlat_flush_page_by_lut(page);
1.60 + }
1.61 + }
1.62 + }
1.63 +}
1.64 +
1.65 +void xlat_invalidate_block( sh4addr_t address, size_t size )
1.66 +{
1.67 + int i;
1.68 + int entry_count = size >> 1; // words;
1.69 + uint32_t page_no = XLAT_LUT_PAGE(address);
1.70 + int entry = XLAT_LUT_ENTRY(address);
1.71 + if( xlat_lut ) {
1.72 + do {
1.73 + void **page = xlat_lut[page_no];
1.74 + int page_entries = XLAT_LUT_PAGE_ENTRIES - entry;
1.75 + if( entry_count < page_entries ) {
1.76 + page_entries = entry_count;
1.77 + }
1.78 + if( page != NULL ) {
1.79 + if( page_entries == XLAT_LUT_PAGE_ENTRIES ) {
1.80 + /* Overwriting the entire page anyway */
1.81 + xlat_flush_page_by_lut(page);
1.82 + } else {
1.83 + for( i=entry; i<entry+page_entries; i++ ) {
1.84 + if( page[i] != NULL ) {
1.85 + xlat_flush_page_by_lut(page);
1.86 + break;
1.87 + }
1.88 + }
1.89 + }
1.90 + entry_count -= page_entries;
1.91 + }
1.92 + page_no ++;
1.93 + entry_count -= page_entries;
1.94 + entry = 0;
1.95 + } while( entry_count > 0 );
1.96 + }
1.97 +}
1.98 +
1.99 +void xlat_flush_page( sh4addr_t address )
1.100 +{
1.101 + void **page = xlat_lut[XLAT_LUT_PAGE(address)];
1.102 + if( page != NULL ) {
1.103 + xlat_flush_page_by_lut(page);
1.104 + }
1.105 +}
1.106 +
1.107 void *xlat_get_code( sh4addr_t address )
1.108 {
1.109 void **page = xlat_lut[XLAT_LUT_PAGE(address)];
.