Line 70... |
Line 70... |
/* Did we find our tlb entry? */
|
/* Did we find our tlb entry? */
|
if (way >= 0) { /* Yes, we did. */
|
if (way >= 0) { /* Yes, we did. */
|
immu_stats.fetch_tlbhit++;
|
immu_stats.fetch_tlbhit++;
|
TRACE("ITLB hit (virtaddr=%"PRIxADDR").\n", virtaddr);
|
TRACE("ITLB hit (virtaddr=%"PRIxADDR").\n", virtaddr);
|
|
|
/* Test for page fault */
|
|
if (mfspr (SPR_SR) & SPR_SR_SM) {
|
|
if (!(mfspr (SPR_ITLBTR_BASE(way) + set) & SPR_ITLBTR_SXE))
|
|
except_handle(EXCEPT_IPF, virtaddr);
|
|
} else {
|
|
if (!(mfspr (SPR_ITLBTR_BASE(way) + set) & SPR_ITLBTR_UXE))
|
|
except_handle(EXCEPT_IPF, virtaddr);
|
|
}
|
|
|
|
/* Set LRUs */
|
/* Set LRUs */
|
for (i = 0; i < config.immu.nways; i++)
|
for (i = 0; i < config.immu.nways; i++)
|
if (testsprbits(SPR_ITLBMR_BASE(i) + set, SPR_ITLBMR_LRU))
|
if (testsprbits(SPR_ITLBMR_BASE(i) + set, SPR_ITLBMR_LRU))
|
setsprbits(SPR_ITLBMR_BASE(i) + set, SPR_ITLBMR_LRU, getsprbits(SPR_ITLBMR_BASE(i) + set, SPR_ITLBMR_LRU) - 1);
|
setsprbits(SPR_ITLBMR_BASE(i) + set, SPR_ITLBMR_LRU, getsprbits(SPR_ITLBMR_BASE(i) + set, SPR_ITLBMR_LRU) - 1);
|
setsprbits(SPR_ITLBMR_BASE(way) + set, SPR_ITLBMR_LRU, config.immu.nsets - 1);
|
setsprbits(SPR_ITLBMR_BASE(way) + set, SPR_ITLBMR_LRU, config.immu.nsets - 1);
|
|
|
/* Check if page is cache inhibited */
|
/* Check if page is cache inhibited */
|
insn_ci = (mfspr(SPR_ITLBTR_BASE(way) + set) & SPR_ITLBTR_CI) == SPR_ITLBTR_CI;
|
insn_ci = (mfspr(SPR_ITLBTR_BASE(way) + set) & SPR_ITLBTR_CI) == SPR_ITLBTR_CI;
|
|
|
runtime.sim.mem_cycles += config.immu.hitdelay;
|
runtime.sim.mem_cycles += config.immu.hitdelay;
|
|
|
|
/* Test for page fault */
|
|
if (mfspr (SPR_SR) & SPR_SR_SM) {
|
|
if (!(mfspr (SPR_ITLBTR_BASE(way) + set) & SPR_ITLBTR_SXE))
|
|
except_handle(EXCEPT_IPF, virtaddr);
|
|
} else {
|
|
if (!(mfspr (SPR_ITLBTR_BASE(way) + set) & SPR_ITLBTR_UXE))
|
|
except_handle(EXCEPT_IPF, virtaddr);
|
|
}
|
|
|
ppn = mfspr(SPR_ITLBTR_BASE(way) + set) / config.immu.pagesize;
|
ppn = mfspr(SPR_ITLBTR_BASE(way) + set) / config.immu.pagesize;
|
return (ppn * config.immu.pagesize) + (virtaddr % config.immu.pagesize);
|
return (ppn * config.immu.pagesize) + (virtaddr % config.immu.pagesize);
|
}
|
}
|
else { /* No, we didn't. */
|
else { /* No, we didn't. */
|
immu_stats.fetch_tlbmiss++;
|
immu_stats.fetch_tlbmiss++;
|
Line 107... |
Line 108... |
setsprbits(SPR_ITLBMR_BASE(i) + set, SPR_ITLBMR_LRU, getsprbits(SPR_ITLBMR_BASE(i) + set, SPR_ITLBMR_LRU) - 1);
|
setsprbits(SPR_ITLBMR_BASE(i) + set, SPR_ITLBMR_LRU, getsprbits(SPR_ITLBMR_BASE(i) + set, SPR_ITLBMR_LRU) - 1);
|
setsprbits(SPR_ITLBMR_BASE(minway) + set, SPR_ITLBMR_LRU, config.immu.ustates - 1);
|
setsprbits(SPR_ITLBMR_BASE(minway) + set, SPR_ITLBMR_LRU, config.immu.ustates - 1);
|
setsprbits(SPR_ITLBTR_BASE(minway) + set, SPR_ITLBTR_PPN, vpn); /* 1 to 1 */
|
setsprbits(SPR_ITLBTR_BASE(minway) + set, SPR_ITLBTR_PPN, vpn); /* 1 to 1 */
|
setsprbits(SPR_ITLBMR_BASE(minway) + set, SPR_ITLBMR_V, 1);
|
setsprbits(SPR_ITLBMR_BASE(minway) + set, SPR_ITLBMR_V, 1);
|
#endif
|
#endif
|
except_handle(EXCEPT_ITLBMISS, virtaddr);
|
|
/* if tlb refill implemented in HW */
|
/* if tlb refill implemented in HW */
|
/* return getsprbits(SPR_ITLBTR_BASE(minway) + set, SPR_ITLBTR_PPN) * config.immu.pagesize + (virtaddr % config.immu.pagesize); */
|
/* return getsprbits(SPR_ITLBTR_BASE(minway) + set, SPR_ITLBTR_PPN) * config.immu.pagesize + (virtaddr % config.immu.pagesize); */
|
runtime.sim.mem_cycles += config.immu.missdelay;
|
runtime.sim.mem_cycles += config.immu.missdelay;
|
|
|
|
except_handle(EXCEPT_ITLBMISS, virtaddr);
|
return 0;
|
return 0;
|
}
|
}
|
}
|
}
|
|
|
/* DESC: try to find EA -> PA transaltion without changing
|
/* DESC: try to find EA -> PA transaltion without changing
|