Search
lxdream.org :: lxdream :: r935:45246788ca00
lxdream 0.9.1
released Jun 29
Download Now
changeset935:45246788ca00 lxdream-mem
parent934:3acd3b3ee6d1
child936:f394309c399a
authornkeynes
dateSat Dec 27 02:18:17 2008 +0000 (11 years ago)
branchlxdream-mem
Simplify xlat_lut slightly (cache now always initialized even if we're not
translating, just for efficiency)
src/sh4/sh4.c
src/sh4/xltcache.c
1.1 --- a/src/sh4/sh4.c Fri Dec 26 14:25:23 2008 +0000
1.2 +++ b/src/sh4/sh4.c Sat Dec 27 02:18:17 2008 +0000
1.3 @@ -63,7 +63,6 @@
1.4 {
1.5 // No-op if the translator was not built
1.6 #ifdef SH4_TRANSLATOR
1.7 - xlat_cache_init();
1.8 if( use ) {
1.9 sh4_translate_init();
1.10 }
1.11 @@ -80,6 +79,7 @@
1.12 {
1.13 register_io_regions( mmio_list_sh4mmio );
1.14 TMU_init();
1.15 + xlat_cache_init();
1.16 sh4_mem_init();
1.17 sh4_reset();
1.18 #ifdef ENABLE_SH4STATS
2.1 --- a/src/sh4/xltcache.c Fri Dec 26 14:25:23 2008 +0000
2.2 +++ b/src/sh4/xltcache.c Sat Dec 27 02:18:17 2008 +0000
2.3 @@ -59,7 +59,7 @@
2.4 xlat_cache_block_t xlat_old_cache_ptr;
2.5 #endif
2.6
2.7 -static void ***xlat_lut;
2.8 +static void **xlat_lut[XLAT_LUT_PAGES];
2.9 static gboolean xlat_initialized = FALSE;
2.10
2.11 void xlat_cache_init(void)
2.12 @@ -78,8 +78,8 @@
2.13 xlat_temp_cache_ptr = xlat_temp_cache;
2.14 xlat_old_cache_ptr = xlat_old_cache;
2.15 #endif
2.16 - xlat_lut = mmap( NULL, XLAT_LUT_PAGES*sizeof(void *), PROT_READ|PROT_WRITE,
2.17 - MAP_PRIVATE|MAP_ANON, -1, 0);
2.18 +// xlat_lut = mmap( NULL, XLAT_LUT_PAGES*sizeof(void *), PROT_READ|PROT_WRITE,
2.19 +// MAP_PRIVATE|MAP_ANON, -1, 0);
2.20 memset( xlat_lut, 0, XLAT_LUT_PAGES*sizeof(void *) );
2.21 }
2.22 xlat_flush_cache();
2.23 @@ -132,26 +132,22 @@
2.24
2.25 void FASTCALL xlat_invalidate_word( sh4addr_t addr )
2.26 {
2.27 - if( xlat_lut ) {
2.28 - void **page = xlat_lut[XLAT_LUT_PAGE(addr)];
2.29 - if( page != NULL ) {
2.30 - int entry = XLAT_LUT_ENTRY(addr);
2.31 - if( page[entry] != NULL ) {
2.32 - xlat_flush_page_by_lut(page);
2.33 - }
2.34 + void **page = xlat_lut[XLAT_LUT_PAGE(addr)];
2.35 + if( page != NULL ) {
2.36 + int entry = XLAT_LUT_ENTRY(addr);
2.37 + if( page[entry] != NULL ) {
2.38 + xlat_flush_page_by_lut(page);
2.39 }
2.40 }
2.41 }
2.42
2.43 void FASTCALL xlat_invalidate_long( sh4addr_t addr )
2.44 {
2.45 - if( xlat_lut ) {
2.46 - void **page = xlat_lut[XLAT_LUT_PAGE(addr)];
2.47 - if( page != NULL ) {
2.48 - int entry = XLAT_LUT_ENTRY(addr);
2.49 - if( page[entry] != NULL || page[entry+1] != NULL ) {
2.50 - xlat_flush_page_by_lut(page);
2.51 - }
2.52 + void **page = xlat_lut[XLAT_LUT_PAGE(addr)];
2.53 + if( page != NULL ) {
2.54 + int entry = XLAT_LUT_ENTRY(addr);
2.55 + if( page[entry] != NULL || page[entry+1] != NULL ) {
2.56 + xlat_flush_page_by_lut(page);
2.57 }
2.58 }
2.59 }
2.60 @@ -162,32 +158,30 @@
2.61 int entry_count = size >> 1; // words;
2.62 uint32_t page_no = XLAT_LUT_PAGE(address);
2.63 int entry = XLAT_LUT_ENTRY(address);
2.64 - if( xlat_lut ) {
2.65 - do {
2.66 - void **page = xlat_lut[page_no];
2.67 - int page_entries = XLAT_LUT_PAGE_ENTRIES - entry;
2.68 - if( entry_count < page_entries ) {
2.69 - page_entries = entry_count;
2.70 - }
2.71 - if( page != NULL ) {
2.72 - if( page_entries == XLAT_LUT_PAGE_ENTRIES ) {
2.73 - /* Overwriting the entire page anyway */
2.74 - xlat_flush_page_by_lut(page);
2.75 - } else {
2.76 - for( i=entry; i<entry+page_entries; i++ ) {
2.77 - if( page[i] != NULL ) {
2.78 - xlat_flush_page_by_lut(page);
2.79 - break;
2.80 - }
2.81 + do {
2.82 + void **page = xlat_lut[page_no];
2.83 + int page_entries = XLAT_LUT_PAGE_ENTRIES - entry;
2.84 + if( entry_count < page_entries ) {
2.85 + page_entries = entry_count;
2.86 + }
2.87 + if( page != NULL ) {
2.88 + if( page_entries == XLAT_LUT_PAGE_ENTRIES ) {
2.89 + /* Overwriting the entire page anyway */
2.90 + xlat_flush_page_by_lut(page);
2.91 + } else {
2.92 + for( i=entry; i<entry+page_entries; i++ ) {
2.93 + if( page[i] != NULL ) {
2.94 + xlat_flush_page_by_lut(page);
2.95 + break;
2.96 }
2.97 }
2.98 - entry_count -= page_entries;
2.99 }
2.100 - page_no ++;
2.101 entry_count -= page_entries;
2.102 - entry = 0;
2.103 - } while( entry_count > 0 );
2.104 - }
2.105 + }
2.106 + page_no ++;
2.107 + entry_count -= page_entries;
2.108 + entry = 0;
2.109 + } while( entry_count > 0 );
2.110 }
2.111
2.112 void FASTCALL xlat_flush_page( sh4addr_t address )
.