atspeed_ddr.c
2.24 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
#include "cpusim.h"
#include "test_vector.h"
#define TEST_JUMP_ADDR (K0BASE | 0x201000)
#define TEST_JUMP_STACK (K0BASE | 0x2f8000)
int main()
{
int x;
void (*f0)(void);
static void run(void);
vu32 *p0, *p1;
test_preamble();
initICache();
initDCache();
init_ddr();
setcp0reg(C0_SR, SR_CU0|SR_CU1|SR_BEV);
setcp0reg(C0_CONFIG, CONFIG_BE|CONFIG_NONCOHRNT);
#ifndef NO_DDR_TEST
p0 = (vu32*)run;
p1 = (vu32*)PHYS_TO_K1(INTERNAL_RAM_START);
f0 = (void(*))K1_TO_K0(p1);
for(x = 0; x < 128; x++) *p1++ = *p0++;
(*f0)();
#endif
/* swicth stack to ddr and jump to other test */
/* Please make sure code is already loaded to ddr */
__asm__ __volatile__ ("li $29, %0\n" : : "M"(TEST_JUMP_STACK));
f0 = (void(*))K1_TO_K0(TEST_JUMP_ADDR);
(*f0)();
test_postamble();
return 0;
}
#ifndef NO_DDR_TEST
#define DDR_X64_START (K1BASE | 0x01000000)
#define DDR_X64_END (K1BASE | 0x02000000)
#define DDR_ADDR_LINE 24
#define DDR_MASK (((1<<DDR_ADDR_LINE) - 1) & 0xFFFFFFFC)
static void run(void)
{
int i, addr[(DDR_ADDR_LINE-2)*2], *paddr;
unsigned int *p, *e, data;
for (i=2, paddr=addr; i < DDR_ADDR_LINE; i++) {
*paddr++ = (1<<i) | DDR_X64_START;
*paddr++ = ((~(1<<i)) & DDR_MASK) | DDR_X64_START;
}
/* Output */
p=(unsigned int *) addr;
e=p + (DDR_ADDR_LINE-2)*2;
while (p < e) {
*((unsigned int *) p[0]) = p[0];
p++;
}
/* Input and compare*/
p=(unsigned int *) addr;
e=p + (DDR_ADDR_LINE-2)*2;
while (p < e) {
if (*((unsigned int *) p[0]) != p[0]) {
TEST_ERROR;
}
p++;
}
/* Output and input */
p=(unsigned int *) addr;
e=p + (DDR_ADDR_LINE-2)*2;
while (p < e) {
* ((unsigned int *) p[0]) = p[0];
if (*((unsigned int *) p[0]) != p[0]) {
TEST_ERROR;
}
p++;
}
for (i=0; i<32; i++) {
data = 1<<i;
IO_WRITE(0, data);
if (IO_READ(0) != data) {
TEST_ERROR;
}
}
for (i=0; i<32; i++) {
data = ~(1<<i);
IO_WRITE(0, data);
if (IO_READ(0) != data) {
TEST_ERROR;
}
}
return ;
}
#endif