Search
lxdream.org :: lxdream/src/sh4/mmu.c :: diff
lxdream 0.9.1
released Jun 29
Download Now
filename src/sh4/mmu.c
changeset 955:e289b49c28f1
prev953:f4a156508ad1
next960:2f0819278fdb
author nkeynes
date Tue Jan 13 23:58:36 2009 +0000 (11 years ago)
permissions -rw-r--r--
last change Replace mmu_fix_urc with mmu_read_urc (slightly cleaner)
file annotate diff log raw
1.1 --- a/src/sh4/mmu.c Tue Jan 13 11:56:28 2009 +0000
1.2 +++ b/src/sh4/mmu.c Tue Jan 13 23:58:36 2009 +0000
1.3 @@ -77,7 +77,7 @@
1.4 static void mmu_utlb_1k_init();
1.5 static struct utlb_1k_entry *mmu_utlb_1k_alloc();
1.6 static void mmu_utlb_1k_free( struct utlb_1k_entry *entry );
1.7 -static void mmu_fix_urc();
1.8 +static int mmu_read_urc();
1.9
1.10 static void FASTCALL tlb_miss_read( sh4addr_t addr, void *exc );
1.11 static int32_t FASTCALL tlb_protected_read( sh4addr_t addr, void *exc );
1.12 @@ -158,7 +158,7 @@
1.13
1.14 void MMU_save_state( FILE *f )
1.15 {
1.16 - mmu_fix_urc();
1.17 + mmu_read_urc();
1.18 fwrite( &mmu_itlb, sizeof(mmu_itlb), 1, f );
1.19 fwrite( &mmu_utlb, sizeof(mmu_utlb), 1, f );
1.20 fwrite( &mmu_urc, sizeof(mmu_urc), 1, f );
1.21 @@ -201,17 +201,17 @@
1.22 */
1.23 void MMU_ldtlb()
1.24 {
1.25 - mmu_fix_urc();
1.26 - if( mmu_utlb[mmu_urc].flags & TLB_VALID )
1.27 - mmu_utlb_remove_entry( mmu_urc );
1.28 - mmu_utlb[mmu_urc].vpn = MMIO_READ(MMU, PTEH) & 0xFFFFFC00;
1.29 - mmu_utlb[mmu_urc].asid = MMIO_READ(MMU, PTEH) & 0x000000FF;
1.30 - mmu_utlb[mmu_urc].ppn = MMIO_READ(MMU, PTEL) & 0x1FFFFC00;
1.31 - mmu_utlb[mmu_urc].flags = MMIO_READ(MMU, PTEL) & 0x00001FF;
1.32 - mmu_utlb[mmu_urc].pcmcia = MMIO_READ(MMU, PTEA);
1.33 - mmu_utlb[mmu_urc].mask = get_tlb_size_mask(mmu_utlb[mmu_urc].flags);
1.34 - if( mmu_utlb[mmu_urc].flags & TLB_VALID )
1.35 - mmu_utlb_insert_entry( mmu_urc );
1.36 + int urc = mmu_read_urc();
1.37 + if( mmu_utlb[urc].flags & TLB_VALID )
1.38 + mmu_utlb_remove_entry( urc );
1.39 + mmu_utlb[urc].vpn = MMIO_READ(MMU, PTEH) & 0xFFFFFC00;
1.40 + mmu_utlb[urc].asid = MMIO_READ(MMU, PTEH) & 0x000000FF;
1.41 + mmu_utlb[urc].ppn = MMIO_READ(MMU, PTEL) & 0x1FFFFC00;
1.42 + mmu_utlb[urc].flags = MMIO_READ(MMU, PTEL) & 0x00001FF;
1.43 + mmu_utlb[urc].pcmcia = MMIO_READ(MMU, PTEA);
1.44 + mmu_utlb[urc].mask = get_tlb_size_mask(mmu_utlb[urc].flags);
1.45 + if( mmu_utlb[urc].flags & TLB_VALID )
1.46 + mmu_utlb_insert_entry( urc );
1.47 }
1.48
1.49
1.50 @@ -220,8 +220,7 @@
1.51 reg &= 0xFFF;
1.52 switch( reg ) {
1.53 case MMUCR:
1.54 - mmu_fix_urc();
1.55 - return MMIO_READ( MMU, MMUCR) | (mmu_urc<<10) | ((mmu_urb&0x3F)<<18) | (mmu_lrui<<26);
1.56 + return MMIO_READ( MMU, MMUCR) | (mmu_read_urc()<<10) | ((mmu_urb&0x3F)<<18) | (mmu_lrui<<26);
1.57 default:
1.58 return MMIO_READ( MMU, reg );
1.59 }
1.60 @@ -349,7 +348,7 @@
1.61 /**
1.62 * MMU accessor functions just increment URC - fixup here if necessary
1.63 */
1.64 -static inline void mmu_fix_urc()
1.65 +static int mmu_read_urc()
1.66 {
1.67 if( mmu_urc_overflow ) {
1.68 if( mmu_urc >= 0x40 ) {
1.69 @@ -360,6 +359,7 @@
1.70 } else {
1.71 mmu_urc %= mmu_urb;
1.72 }
1.73 + return mmu_urc;
1.74 }
1.75
1.76 static void mmu_register_mem_region( uint32_t start, uint32_t end, mem_region_fn_t fn )
.