bandwidth.c
1.85 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
#include "cpusim.h"
#define CMEM_WORD (*(vu32*)K0BASE)
#define UMEM_WORD (*(vu32*)K1BASE)
#define CMEM64_WORD (*(vu32*)PHYS_TO_K0(DDRRAM64_START))
#define UMEM64_WORD (*(vu32*)PHYS_TO_K1(DDRRAM64_START))
#define CNONMEM_WORD (*(vu32*)PHYS_TO_K0(PI_BUFFER_BASE_REG))
#define UNONMEM_WORD (*(vu32*)PHYS_TO_K1(PI_BUFFER_BASE_REG))
void
failed(const char* code) {
message("bandwidth test failed (");
message(code);
message(")\n");
DBG_JTAG_FAIL(code);
test_postamble();
}
int
main() {
int x;
vu32 *p0, *p1;
void (*f0)(void);
static void run(void);
if (((getcp0reg(C0_CONFIG)&CONFIG_EC) >> 28) != 1)
IO_WRITE(MI_CTRL_REG, MI_CTRL_HARD_RESET|MI_CTRL_DIV_MODE_1_5);
test_preamble();
initICache();
initDCache();
init_ddr();
setcp0reg(C0_SR, SR_CU0|SR_CU1|SR_BEV);
setcp0reg(C0_CONFIG, CONFIG_BE|CONFIG_NONCOHRNT);
p0 = (vu32*)run;
p1 = (vu32*)PHYS_TO_K1(INTERNAL_RAM_START);
f0 = (void(*))K1_TO_K0(p1);
for(x = 0; x < 256; x++) *p1++ = *p0++;
(*f0)();
message("bandwidth test\n");
DBG_JTAG_PASS("Bandwidth test Passed\n");
test_postamble();
return 0;
}
#define STRIDE (1*1024)
static void
run(void) {
int i, pass = 0;
u32* x = (u32*)&UMEM_WORD;
u32* y = (u32*)&UMEM_WORD+STRIDE;
unsigned z;
again:
i = STRIDE;
z = getcp0reg(C0_COUNT);
do {
*x++ = 0;
} while(i-- >= 0);
IO_WRITE(PI_IDE3_BASE_REG, getcp0reg(C0_COUNT)-z);
i = STRIDE; x = y - STRIDE;
z = getcp0reg(C0_COUNT);
do {
*(volatile unsigned *)x++;
} while(i-- >= 0);
IO_WRITE(PI_IDE3_BASE_REG, getcp0reg(C0_COUNT)-z);
i = STRIDE; x = y - STRIDE;
z = getcp0reg(C0_COUNT);
do {
*y++ = *x++;
} while(i-- > 0);
IO_WRITE(PI_IDE3_BASE_REG, getcp0reg(C0_COUNT)-z);
if (pass++ == 0) {
x = (u32*)&CMEM_WORD;
y = (u32*)&CMEM_WORD+STRIDE;
goto again;
}
}