Line 33... |
Line 33... |
inline unsigned long immu_simulate_tlb(unsigned long virtaddr)
|
inline unsigned long immu_simulate_tlb(unsigned long virtaddr)
|
{
|
{
|
int set, way = -1;
|
int set, way = -1;
|
int i;
|
int i;
|
unsigned long tagaddr;
|
unsigned long tagaddr;
|
unsigned long vpn;
|
unsigned long vpn, ppn;
|
|
|
if (!(mfspr(SPR_SR) & SPR_SR_IME) || !(testsprbits(SPR_UPR, SPR_UPR_IMP)))
|
if (!(mfspr(SPR_SR) & SPR_SR_IME) || !(testsprbits(SPR_UPR, SPR_UPR_IMP)))
|
return virtaddr;
|
return virtaddr;
|
|
|
/* Which set to check out? */
|
/* Which set to check out? */
|
set = (virtaddr / config.immu.pagesize) % config.immu.nsets;
|
set = (virtaddr / config.immu.pagesize) % config.immu.nsets;
|
tagaddr = (virtaddr / config.immu.pagesize) / config.immu.nsets;
|
tagaddr = (virtaddr / config.immu.pagesize) / config.immu.nsets;
|
vpn = virtaddr / config.immu.pagesize;
|
vpn = virtaddr / (config.immu.pagesize * config.immu.nsets);
|
|
|
/* Scan all ways and try to find a matching way. */
|
/* Scan all ways and try to find a matching way. */
|
for (i = 0; i < config.immu.nways; i++)
|
for (i = 0; i < config.immu.nways; i++)
|
if ((getsprbits(SPR_ITLBMR_BASE(i) + set, SPR_ITLBMR_VPN) == vpn) &&
|
if (((mfspr(SPR_ITLBMR_BASE(i) + set) / (config.immu.pagesize * config.immu.nsets)) == vpn) &&
|
testsprbits(SPR_ITLBMR_BASE(i) + set, SPR_ITLBMR_V))
|
testsprbits(SPR_ITLBMR_BASE(i) + set, SPR_ITLBMR_V))
|
way = i;
|
way = i;
|
|
|
/* Did we find our tlb entry? */
|
/* Did we find our tlb entry? */
|
if (way >= 0) { /* Yes, we did. */
|
if (way >= 0) { /* Yes, we did. */
|
Line 69... |
Line 69... |
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.ustates - 1);
|
setsprbits(SPR_ITLBMR_BASE(way) + set, SPR_ITLBMR_LRU, config.immu.ustates - 1);
|
|
|
return getsprbits(SPR_ITLBTR_BASE(way) + set, SPR_ITLBTR_PPN) * config.immu.pagesize + (virtaddr % config.immu.pagesize);
|
ppn = mfspr(SPR_ITLBTR_BASE(way) + set) / config.immu.pagesize;
|
|
return (ppn * config.immu.pagesize) + (virtaddr % config.immu.pagesize);
|
}
|
}
|
else { /* No, we didn't. */
|
else { /* No, we didn't. */
|
int minlru = config.immu.ustates - 1;
|
int minlru = config.immu.ustates - 1;
|
int minway = 0;
|
int minway = 0;
|
|
|