tlbtrans.c
1.25 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
#include <R4300.h>
#include <ultra64.h>
/*
#include "setjmp.h"
*/
#include "cpu.h"
static jmp_buf faultbuf;
s32
tlbTranslate(s32 *pt, u32 *uncachedp)
{
s32 error = 0;
s32 i;
u32 tlblo_attrib = TLBLO_V | TLBLO_UNCACHED;
XDEBUG(PRINTF("TLB translation test\n"));
for (i = 0; i < NTLBENTRIES; i++) {
u32 addr;
for (addr = 0; addr < K0BASE; addr = (addr << 1) + PAGESIZE) {
u32 _addr = addr & ~PAGESIZE;
u8 bucket;
u8 *ptr = (u8 *)uncachedp;
tlbwired(i, 0, _addr,
(pt[i * 2] >> 6) | tlblo_attrib,
(pt[i * 2 + 1] >> 6) | tlblo_attrib);
if (__osSetJmp((u32 *)faultbuf)) {
return ++error;
}
RegisterNoFault((u32 *)faultbuf);
bucket = *(u8 *)_addr;
ClearNoFault();
if (bucket != *ptr) {
XDEBUG(PRINTF (
"ERR: Data, Exp: 0x%x, Act: 0x%x\n",
*ptr, bucket));
error++;
}
_addr |= PAGESIZE;
RegisterNoFault((u32 *)faultbuf);
bucket = *(u8 *)_addr;
ClearNoFault();
ptr += PAGESIZE;
if (bucket != *ptr) {
XDEBUG(PRINTF (
"ERR: Data, Exp: 0x%x, Act: 0x%x\n",
*ptr, bucket));
error++;
}
osUnmapTLB(i);
}
uncachedp += PAGESIZE * 2 / sizeof(*uncachedp);
}
XDEBUG(PRINTF("******** Test DONE with %d errors ********\n",
error));
return error;
}