Search
lxdream.org :: lxdream/src/sh4/xltcache.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/sh4/xltcache.c
changeset 935:45246788ca00
prev922:8a8361264b1e
next938:e377bd827c54
author nkeynes
date Sat Dec 27 02:18:17 2008 +0000 (11 years ago)
branchlxdream-mem
permissions -rw-r--r--
last change Simplify xlat_lut slightly (cache now always initialized even if we're not
translating, just for efficiency)
file annotate diff log raw
1.1 --- a/src/sh4/xltcache.c Thu Dec 11 23:26:03 2008 +0000
1.2 +++ b/src/sh4/xltcache.c Sat Dec 27 02:18:17 2008 +0000
1.3 @@ -59,7 +59,7 @@
1.4 xlat_cache_block_t xlat_old_cache_ptr;
1.5 #endif
1.6
1.7 -static void ***xlat_lut;
1.8 +static void **xlat_lut[XLAT_LUT_PAGES];
1.9 static gboolean xlat_initialized = FALSE;
1.10
1.11 void xlat_cache_init(void)
1.12 @@ -78,8 +78,8 @@
1.13 xlat_temp_cache_ptr = xlat_temp_cache;
1.14 xlat_old_cache_ptr = xlat_old_cache;
1.15 #endif
1.16 - xlat_lut = mmap( NULL, XLAT_LUT_PAGES*sizeof(void *), PROT_READ|PROT_WRITE,
1.17 - MAP_PRIVATE|MAP_ANON, -1, 0);
1.18 +// xlat_lut = mmap( NULL, XLAT_LUT_PAGES*sizeof(void *), PROT_READ|PROT_WRITE,
1.19 +// MAP_PRIVATE|MAP_ANON, -1, 0);
1.20 memset( xlat_lut, 0, XLAT_LUT_PAGES*sizeof(void *) );
1.21 }
1.22 xlat_flush_cache();
1.23 @@ -132,26 +132,22 @@
1.24
1.25 void FASTCALL xlat_invalidate_word( sh4addr_t addr )
1.26 {
1.27 - if( xlat_lut ) {
1.28 - void **page = xlat_lut[XLAT_LUT_PAGE(addr)];
1.29 - if( page != NULL ) {
1.30 - int entry = XLAT_LUT_ENTRY(addr);
1.31 - if( page[entry] != NULL ) {
1.32 - xlat_flush_page_by_lut(page);
1.33 - }
1.34 + void **page = xlat_lut[XLAT_LUT_PAGE(addr)];
1.35 + if( page != NULL ) {
1.36 + int entry = XLAT_LUT_ENTRY(addr);
1.37 + if( page[entry] != NULL ) {
1.38 + xlat_flush_page_by_lut(page);
1.39 }
1.40 }
1.41 }
1.42
1.43 void FASTCALL xlat_invalidate_long( sh4addr_t addr )
1.44 {
1.45 - if( xlat_lut ) {
1.46 - void **page = xlat_lut[XLAT_LUT_PAGE(addr)];
1.47 - if( page != NULL ) {
1.48 - int entry = XLAT_LUT_ENTRY(addr);
1.49 - if( page[entry] != NULL || page[entry+1] != NULL ) {
1.50 - xlat_flush_page_by_lut(page);
1.51 - }
1.52 + void **page = xlat_lut[XLAT_LUT_PAGE(addr)];
1.53 + if( page != NULL ) {
1.54 + int entry = XLAT_LUT_ENTRY(addr);
1.55 + if( page[entry] != NULL || page[entry+1] != NULL ) {
1.56 + xlat_flush_page_by_lut(page);
1.57 }
1.58 }
1.59 }
1.60 @@ -162,32 +158,30 @@
1.61 int entry_count = size >> 1; // words;
1.62 uint32_t page_no = XLAT_LUT_PAGE(address);
1.63 int entry = XLAT_LUT_ENTRY(address);
1.64 - if( xlat_lut ) {
1.65 - do {
1.66 - void **page = xlat_lut[page_no];
1.67 - int page_entries = XLAT_LUT_PAGE_ENTRIES - entry;
1.68 - if( entry_count < page_entries ) {
1.69 - page_entries = entry_count;
1.70 - }
1.71 - if( page != NULL ) {
1.72 - if( page_entries == XLAT_LUT_PAGE_ENTRIES ) {
1.73 - /* Overwriting the entire page anyway */
1.74 - xlat_flush_page_by_lut(page);
1.75 - } else {
1.76 - for( i=entry; i<entry+page_entries; i++ ) {
1.77 - if( page[i] != NULL ) {
1.78 - xlat_flush_page_by_lut(page);
1.79 - break;
1.80 - }
1.81 + do {
1.82 + void **page = xlat_lut[page_no];
1.83 + int page_entries = XLAT_LUT_PAGE_ENTRIES - entry;
1.84 + if( entry_count < page_entries ) {
1.85 + page_entries = entry_count;
1.86 + }
1.87 + if( page != NULL ) {
1.88 + if( page_entries == XLAT_LUT_PAGE_ENTRIES ) {
1.89 + /* Overwriting the entire page anyway */
1.90 + xlat_flush_page_by_lut(page);
1.91 + } else {
1.92 + for( i=entry; i<entry+page_entries; i++ ) {
1.93 + if( page[i] != NULL ) {
1.94 + xlat_flush_page_by_lut(page);
1.95 + break;
1.96 }
1.97 }
1.98 - entry_count -= page_entries;
1.99 }
1.100 - page_no ++;
1.101 entry_count -= page_entries;
1.102 - entry = 0;
1.103 - } while( entry_count > 0 );
1.104 - }
1.105 + }
1.106 + page_no ++;
1.107 + entry_count -= page_entries;
1.108 + entry = 0;
1.109 + } while( entry_count > 0 );
1.110 }
1.111
1.112 void FASTCALL xlat_flush_page( sh4addr_t address )
.