tlbmod.c
1.37 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
#include <R4300.h>
#include <ultra64.h>
/*
#include "setjmp.h"
*/
#include "cpu.h"
static jmp_buf faultbuf;
s32
tlbMod(s32 *pt)
{
int error = 0;
int i;
u32 tlb_attrib = TLBLO_V | TLBLO_UNCACHED;
XDEBUG(PRINTF("TLB mod bit test\n"));
for (i = 0; i < NTLBENTRIES; i++) {
tlbwired(i, 0, 0,
(pt[i * 2] >> 6) | tlb_attrib,
(pt[i * 2 + 1] >> 6) | tlb_attrib);
if (__osSetJmp((u32 *)faultbuf)) {
if (_badvaddr != 1) {
XDEBUG(PRINTF (
"ERR: BadVaddr, Exp: 0x00000001, Act: 0x%08x, #%d\n",
_badvaddr, i));
error++;
}
} else {
RegisterNoFault((u32 *)faultbuf);
*(volatile u8 *)1 = i * 2;
ClearNoFault();
XDEBUG(PRINTF (
"ERR: Did not receive expected exception\n"));
error++;
}
osUnmapTLB(i);
}
for (i = 0; i < NTLBENTRIES; i++) {
tlbwired(i, 0, 0,
(pt[i * 2] >> 6) | tlb_attrib | TLBLO_D,
(pt[i * 2 + 1] >> 6) | tlb_attrib | TLBLO_D);
if (__osSetJmp((u32 *)faultbuf)) {
XDEBUG(PRINTF("ERR: Test failed %d\n", i));
return ++error;
} else {
RegisterNoFault((u32 *)faultbuf);
*(volatile u8 *)1 = i * 2;
ClearNoFault();
if (*(u8 *)1 != *(u8 *)0) {
XDEBUG(PRINTF (
"ERR: Bad data, Exp: 0x%02x, Act: 0x%02x, #%d\n",
*(u8 *)0, *(u8 *)1, i));
error++;
}
}
osUnmapTLB(i);
}
XDEBUG(PRINTF("******** Test DONE with %d errors ********\n",
error));
return error;
}