tlbmem.c
1.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#include <R4300.h>
#include <ultra64.h>
#include <os_internal.h>
/*
#include "setjmp.h"
*/
#include "cpu.h"
#define TLBLO_PFN2MASK 0x03ffffc0 /* Bit 26-35 are 0s */
/*
* Test the tlb as a small memory array. Just see if all the read/write
* bits can be toggled and that all undefined bit read back zero.
*/
s32
tlbMem(void)
{
s32 error = 0;
u32 expected_pat;
s32 i;
s32 j;
u32 rpat;
/*
u32 tlbhi_mask = TLBHI_VPNMASK | TLBHI_PIDMASK;
*/
u32 tlbhi_mask = TLBHI_VPN2MASK | TLBHI_PIDMASK;
u32 tlblo_mask = TLBLO_PFN2MASK | TLBLO_CACHMASK | TLBLO_D | TLBLO_V;
u32 wpat;
XDEBUG(PRINTF("TLB data test, himask=0x%08x, lomask=0x%08x\n",
tlbhi_mask, tlblo_mask));
wpat = 0xa5a5a5a5;
for (i = 0; i < NTLBENTRIES; i++) {
for (j = 0; j < 2; j++) {
tlbwired(i, 0, 0, wpat, ~wpat);
rpat = __osGetTLBLo0(i);
expected_pat = wpat & tlblo_mask;
if (rpat != expected_pat) {
XDEBUG(PRINTF(
"ERR: entry %2d LO 0: Exp:0x%08x, Act:0x%08x\n",
i, expected_pat, rpat));
error++;
}
wpat = ~wpat;
rpat = __osGetTLBLo1(i);
expected_pat = wpat & tlblo_mask;
if (rpat != expected_pat) {
XDEBUG(PRINTF(
"ERR: entry %2d LO 1: Exp:0x%08x, Act:0x%08x\n",
i, expected_pat, rpat));
error++;
}
}
osUnmapTLB(i);
}
for (i = 0; i < NTLBENTRIES; i++) {
for (j = 0; j < 2; j++) {
tlbwired(i, wpat & 0xff, wpat, 0, 0);
rpat = __osGetTLBHi(i);
expected_pat = wpat & tlbhi_mask;
if (rpat != expected_pat) {
XDEBUG(PRINTF(
"ERR: entry %2d HI: Exp:0x%08x, Act:0x%08x\n",
i, expected_pat, rpat));
error++;
}
wpat = ~wpat;
}
osUnmapTLB(i);
}
XDEBUG(PRINTF("******** Test DONE with %d errors ********\n",
error));
return error;
}