Line 31... |
Line 31... |
|
|
unsigned long dmmu_translate(unsigned long virtaddr)
|
unsigned long dmmu_translate(unsigned long virtaddr)
|
{
|
{
|
unsigned long phyaddr = dmmu_simulate_tlb(virtaddr);
|
unsigned long phyaddr = dmmu_simulate_tlb(virtaddr);
|
|
|
printf("DMMU translate(%x) = %x\n", virtaddr, phyaddr);
|
/* printf("DMMU translate(%x) = %x\n", virtaddr, phyaddr);*/
|
return phyaddr;
|
return phyaddr;
|
}
|
}
|
|
|
/* Number of DTLB sets used (power of 2, max is 256) */
|
/* Number of DTLB sets used (power of 2, max is 256) */
|
#define DTLB_SETS 16
|
#define DTLB_SETS 16
|
Line 47... |
Line 47... |
#define DTLB_WAYS 2
|
#define DTLB_WAYS 2
|
|
|
/* Number of usage states (2, 3, 4 etc., max is 4). */
|
/* Number of usage states (2, 3, 4 etc., max is 4). */
|
#define DTLB_USTATES 2
|
#define DTLB_USTATES 2
|
|
|
/* Don't change. Defined by mask of PPN/VPN bits in TLB. */
|
|
#define MIN_PG_SIZE 1024
|
|
|
|
void dtlb_info()
|
void dtlb_info()
|
{
|
{
|
printf("Data MMU %dKB: ", DTLB_SETS * DTLB_ENTRY_SIZE * DTLB_WAYS / 1024);
|
printf("Data MMU %dKB: ", DTLB_SETS * DTLB_ENTRY_SIZE * DTLB_WAYS / 1024);
|
printf("%d ways, %d sets, entry size %d bytes\n", DTLB_WAYS, DTLB_SETS, DTLB_ENTRY_SIZE);
|
printf("%d ways, %d sets, entry size %d bytes\n", DTLB_WAYS, DTLB_SETS, DTLB_ENTRY_SIZE);
|
}
|
}
|
Line 80... |
Line 77... |
if ((start_set >= 0) && (start_set < end_set))
|
if ((start_set >= 0) && (start_set < end_set))
|
end_set = start_set + 1;
|
end_set = start_set + 1;
|
else
|
else
|
start_set = 0;
|
start_set = 0;
|
|
|
|
printf("\nDMMU: ");
|
/* Scan set(s) and way(s). */
|
/* Scan set(s) and way(s). */
|
for (set = start_set; set < end_set; set++) {
|
for (set = start_set; set < end_set; set++) {
|
printf("\nSet %x: ", set);
|
printf("\nSet %x: ", set);
|
for (way = 0; way < DTLB_WAYS; way++) {
|
for (way = 0; way < DTLB_WAYS; way++) {
|
printf(" way %d: ", way);
|
printf(" way %d: ", way);
|
printf("vpn %x ", getsprbits(SPR_DTLBMR_BASE(way) + set, SPR_DTLBMR_VPN));
|
printf("vpn=%x ", getsprbits(SPR_DTLBMR_BASE(way) + set, SPR_DTLBMR_VPN));
|
printf("lru %x ", getsprbits(SPR_DTLBMR_BASE(way) + set, SPR_DTLBMR_LRU));
|
printf("lru=%x ", getsprbits(SPR_DTLBMR_BASE(way) + set, SPR_DTLBMR_LRU));
|
printf("pl1 %x ", getsprbits(SPR_DTLBMR_BASE(way) + set, SPR_DTLBMR_PL1));
|
printf("pl1=%x ", getsprbits(SPR_DTLBMR_BASE(way) + set, SPR_DTLBMR_PL1));
|
printf("v %x ", getsprbits(SPR_DTLBMR_BASE(way) + set, SPR_DTLBMR_V));
|
printf("v=%x ", getsprbits(SPR_DTLBMR_BASE(way) + set, SPR_DTLBMR_V));
|
printf("a %x ", getsprbits(SPR_DTLBMR_BASE(way) + set, SPR_DTLBTR_A));
|
|
printf("d %x ", getsprbits(SPR_DTLBMR_BASE(way) + set, SPR_DTLBTR_D));
|
printf("a=%x ", getsprbits(SPR_DTLBTR_BASE(way) + set, SPR_DTLBTR_A));
|
printf("ure %x ", getsprbits(SPR_DTLBMR_BASE(way) + set, SPR_DTLBTR_URE));
|
printf("d=%x ", getsprbits(SPR_DTLBTR_BASE(way) + set, SPR_DTLBTR_D));
|
printf("uwe %x ", getsprbits(SPR_DTLBMR_BASE(way) + set, SPR_DTLBTR_UWE));
|
printf("ure=%x ", getsprbits(SPR_DTLBTR_BASE(way) + set, SPR_DTLBTR_URE));
|
printf("sre %x ", getsprbits(SPR_DTLBMR_BASE(way) + set, SPR_DTLBTR_SRE));
|
printf("uwe=%x ", getsprbits(SPR_DTLBTR_BASE(way) + set, SPR_DTLBTR_UWE));
|
printf("swe %x ", getsprbits(SPR_DTLBMR_BASE(way) + set, SPR_DTLBTR_SWE));
|
printf("sre=%x ", getsprbits(SPR_DTLBTR_BASE(way) + set, SPR_DTLBTR_SRE));
|
printf("ppn %x ", getsprbits(SPR_DTLBMR_BASE(way) + set, SPR_DTLBTR_PPN));
|
printf("swe=%x ", getsprbits(SPR_DTLBTR_BASE(way) + set, SPR_DTLBTR_SWE));
|
if (way > 0)
|
printf("ppn=%x ", getsprbits(SPR_DTLBTR_BASE(way) + set, SPR_DTLBTR_PPN));
|
printf("\n");
|
|
}
|
}
|
}
|
}
|
printf("\n");
|
printf("\n");
|
}
|
}
|
|
|
Line 116... |
Line 113... |
return virtaddr;
|
return virtaddr;
|
|
|
/* Which set to check out? */
|
/* Which set to check out? */
|
set = (virtaddr / PAGE_SIZE) % DTLB_SETS;
|
set = (virtaddr / PAGE_SIZE) % DTLB_SETS;
|
tagaddr = (virtaddr / PAGE_SIZE) / DTLB_SETS;
|
tagaddr = (virtaddr / PAGE_SIZE) / DTLB_SETS;
|
vpn = virtaddr / MIN_PG_SIZE;
|
vpn = virtaddr / PAGE_SIZE;
|
|
|
/* Scan all ways and try to find a matching way. */
|
/* Scan all ways and try to find a matching way. */
|
for (i = 0; i < DTLB_WAYS; i++)
|
for (i = 0; i < DTLB_WAYS; i++)
|
if ((getsprbits(SPR_DTLBMR_BASE(i) + set, SPR_DTLBMR_VPN) == vpn) &&
|
if ((getsprbits(SPR_DTLBMR_BASE(i) + set, SPR_DTLBMR_VPN) == vpn) &&
|
getsprbits(SPR_DTLBMR_BASE(i) + set, SPR_DTLBMR_V))
|
getsprbits(SPR_DTLBMR_BASE(i) + set, SPR_DTLBMR_V))
|
Line 135... |
Line 132... |
for (i = 0; i < DTLB_WAYS; i++)
|
for (i = 0; i < DTLB_WAYS; i++)
|
if (getsprbits(SPR_DTLBMR_BASE(i) + set, SPR_DTLBMR_LRU))
|
if (getsprbits(SPR_DTLBMR_BASE(i) + set, SPR_DTLBMR_LRU))
|
setsprbits(SPR_DTLBMR_BASE(i) + set, SPR_DTLBMR_LRU, getsprbits(SPR_DTLBMR_BASE(i) + set, SPR_DTLBMR_LRU) - 1);
|
setsprbits(SPR_DTLBMR_BASE(i) + set, SPR_DTLBMR_LRU, getsprbits(SPR_DTLBMR_BASE(i) + set, SPR_DTLBMR_LRU) - 1);
|
setsprbits(SPR_DTLBMR_BASE(way) + set, SPR_DTLBMR_LRU, DTLB_USTATES - 1);
|
setsprbits(SPR_DTLBMR_BASE(way) + set, SPR_DTLBMR_LRU, DTLB_USTATES - 1);
|
|
|
return getsprbits(SPR_DTLBTR_BASE(way) + set, SPR_DTLBTR_PPN) * MIN_PG_SIZE + (virtaddr % PAGE_SIZE);
|
return getsprbits(SPR_DTLBTR_BASE(way) + set, SPR_DTLBTR_PPN) * PAGE_SIZE + (virtaddr % PAGE_SIZE);
|
}
|
}
|
else { /* No, we didn't. */
|
else { /* No, we didn't. */
|
int minlru = DTLB_USTATES - 1;
|
int minlru = DTLB_USTATES - 1;
|
int minway = 0;
|
int minway = 0;
|
|
|
Line 157... |
Line 154... |
setsprbits(SPR_DTLBTR_BASE(minway) + set, SPR_DTLBTR_PPN, vpn); /* 1 to 1 */
|
setsprbits(SPR_DTLBTR_BASE(minway) + set, SPR_DTLBTR_PPN, vpn); /* 1 to 1 */
|
setsprbits(SPR_DTLBMR_BASE(minway) + set, SPR_DTLBMR_V, 1);
|
setsprbits(SPR_DTLBMR_BASE(minway) + set, SPR_DTLBMR_V, 1);
|
#endif
|
#endif
|
except_handle(EXCEPT_DTLBMISS, virtaddr);
|
except_handle(EXCEPT_DTLBMISS, virtaddr);
|
/* if tlb refill implemented in HW */
|
/* if tlb refill implemented in HW */
|
/* return getsprbits(SPR_DTLBTR_BASE(minway) + set, SPR_DTLBTR_PPN) * MIN_PG_SIZE + (virtaddr % PAGE_SIZE); */
|
/* return getsprbits(SPR_DTLBTR_BASE(minway) + set, SPR_DTLBTR_PPN) * PAGE_SIZE + (virtaddr % PAGE_SIZE); */
|
return 0;
|
return 0;
|
}
|
}
|
}
|
}
|
|
|
No newline at end of file
|
No newline at end of file
|