Line 49... |
Line 49... |
/* 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
|
|
|
void dtlb_info()
|
void dtlb_info()
|
{
|
{
|
|
if (!getsprbits(SPR_UPR, SPR_UPR_DMP)) {
|
|
printf("DMMU not implemented. Set UPR[DMP].\n");
|
|
return;
|
|
}
|
|
|
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);
|
}
|
}
|
|
|
/* First check if virtual address is covered by DTLB and if it is:
|
/* First check if virtual address is covered by DTLB and if it is:
|
Line 66... |
Line 71... |
- find lru way and entry and invoke DTLB miss exception handler
|
- find lru way and entry and invoke DTLB miss exception handler
|
- set 'lru' with DTLB_USTATES - 1 and decrement 'lru' of other
|
- set 'lru' with DTLB_USTATES - 1 and decrement 'lru' of other
|
ways unless they have reached 0
|
ways unless they have reached 0
|
*/
|
*/
|
|
|
unsigned long dtlb_status(int start_set)
|
void dtlb_status(int start_set)
|
{
|
{
|
int set;
|
int set;
|
int way;
|
int way;
|
int end_set = DTLB_SETS;
|
int end_set = DTLB_SETS;
|
|
|
|
if (!getsprbits(SPR_UPR, SPR_UPR_DMP)) {
|
|
printf("DMMU not implemented. Set UPR[DMP].\n");
|
|
return;
|
|
}
|
|
|
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;
|
|
|
Line 107... |
Line 117... |
int set, way = -1;
|
int set, way = -1;
|
int i;
|
int i;
|
unsigned long tagaddr;
|
unsigned long tagaddr;
|
unsigned long vpn;
|
unsigned long vpn;
|
|
|
if (! (mfspr(SPR_SR) & SPR_SR_DME))
|
if (!(mfspr(SPR_SR) & SPR_SR_DME) || (!getsprbits(SPR_SR, SPR_SR_DME)))
|
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;
|