Search
lxdream.org :: lxdream :: r583:ba995fadf173
lxdream 0.9.1
released Jun 29
Download Now
changeset583:ba995fadf173 lxdream-mmu
parent582:c89a69dc427d
child584:5c29dd7297df
authornkeynes
dateTue Jan 15 10:10:17 2008 +0000 (12 years ago)
branchlxdream-mmu
Fix assoc UTLB write
Fix ITLB updates
src/sh4/mmu.c
1.1 --- a/src/sh4/mmu.c Tue Jan 15 10:03:27 2008 +0000
1.2 +++ b/src/sh4/mmu.c Tue Jan 15 10:10:17 2008 +0000
1.3 @@ -184,6 +184,7 @@
1.4 void MMU_reset()
1.5 {
1.6 mmio_region_MMU_write( CCR, 0 );
1.7 + mmio_region_MMU_write( MMUCR, 0 );
1.8 }
1.9
1.10 void MMU_save_state( FILE *f )
1.11 @@ -331,9 +332,11 @@
1.12 int result = -1;
1.13 unsigned int i;
1.14 for( i = 0; i < UTLB_ENTRY_COUNT; i++ ) {
1.15 - if( ((mmu_utlb[i].flags & TLB_SHARE) || asid == mmu_utlb[i].asid) &&
1.16 + if( (mmu_utlb[i].flags & TLB_VALID) &&
1.17 + ((mmu_utlb[i].flags & TLB_SHARE) || asid == mmu_utlb[i].asid) &&
1.18 ((mmu_utlb[i].vpn ^ vpn) & mmu_utlb[i].mask) == 0 ) {
1.19 if( result != -1 ) {
1.20 + fprintf( stderr, "TLB Multi hit: %d %d\n", result, i );
1.21 return -2;
1.22 }
1.23 result = i;
1.24 @@ -351,7 +354,8 @@
1.25 int result = -1;
1.26 unsigned int i;
1.27 for( i = 0; i < ITLB_ENTRY_COUNT; i++ ) {
1.28 - if( ((mmu_itlb[i].flags & TLB_SHARE) || asid == mmu_itlb[i].asid) &&
1.29 + if( (mmu_itlb[i].flags & TLB_VALID) &&
1.30 + ((mmu_itlb[i].flags & TLB_SHARE) || asid == mmu_itlb[i].asid) &&
1.31 ((mmu_itlb[i].vpn ^ vpn) & mmu_itlb[i].mask) == 0 ) {
1.32 if( result != -1 ) {
1.33 return -2;
1.34 @@ -365,8 +369,7 @@
1.35 void mmu_utlb_addr_write( sh4addr_t addr, uint32_t val )
1.36 {
1.37 if( UTLB_ASSOC(addr) ) {
1.38 - uint32_t asid = MMIO_READ( MMU, PTEH ) & 0xFF;
1.39 - int utlb = mmu_utlb_lookup_assoc( val, asid );
1.40 + int utlb = mmu_utlb_lookup_assoc( val, mmu_asid );
1.41 if( utlb >= 0 ) {
1.42 struct utlb_entry *ent = &mmu_utlb[utlb];
1.43 ent->flags = ent->flags & ~(TLB_DIRTY|TLB_VALID);
1.44 @@ -374,7 +377,7 @@
1.45 ent->flags |= ((val & 0x200)>>7);
1.46 }
1.47
1.48 - int itlb = mmu_itlb_lookup_assoc( val, asid );
1.49 + int itlb = mmu_itlb_lookup_assoc( val, mmu_asid );
1.50 if( itlb >= 0 ) {
1.51 struct itlb_entry *ent = &mmu_itlb[itlb];
1.52 ent->flags = (ent->flags & (~TLB_VALID)) | (val & TLB_VALID);
1.53 @@ -522,7 +525,7 @@
1.54 {
1.55 int replace;
1.56 /* Determine entry to replace based on lrui */
1.57 - if( mmu_lrui & 0x38 == 0x38 ) {
1.58 + if( (mmu_lrui & 0x38) == 0x38 ) {
1.59 replace = 0;
1.60 mmu_lrui = mmu_lrui & 0x07;
1.61 } else if( (mmu_lrui & 0x26) == 0x06 ) {
1.62 @@ -570,9 +573,9 @@
1.63 }
1.64
1.65 if( result == -1 ) {
1.66 - int utlbEntry = mmu_utlb_lookup_vpn( vpn );
1.67 - if( utlbEntry == -1 ) {
1.68 - return -1;
1.69 + int utlbEntry = mmu_utlb_lookup_vpn_asid( vpn );
1.70 + if( utlbEntry < 0 ) {
1.71 + return utlbEntry;
1.72 } else {
1.73 return mmu_itlb_update_from_utlb( utlbEntry );
1.74 }
1.75 @@ -614,8 +617,8 @@
1.76
1.77 if( result == -1 ) {
1.78 int utlbEntry = mmu_utlb_lookup_vpn( vpn );
1.79 - if( utlbEntry == -1 ) {
1.80 - return -1;
1.81 + if( utlbEntry < 0 ) {
1.82 + return utlbEntry;
1.83 } else {
1.84 return mmu_itlb_update_from_utlb( utlbEntry );
1.85 }
.