Initial xloong code
[xloong.git] / sys / arch / mips / include / newtest / writesome-testsome-ram.S
blobd4ab47fde67625e50ac3b4553b56967259a38b1c
1 #undef STEPS
2 #undef STARTADDR
3 #undef MAXSIZE
4 #undef STARTDATA
5 #undef DECDATA
6 #undef ADDRMASK
7 #undef tmp
8 #undef curaddr
9 #undef writedata
10 #undef readdata
11 #undef count
12 #undef errorall
13 #undef TESTONCE
15 #define STEPS 0x100000
16 #define STARTADDR (0x80000000+STEPS*4)
17 #define MAXSIZE (256*1024*1024-STEPS*4)
18 #define STARTDATA 0xffffffff
19 #define DECDATA 1
20 #define ADDRMASK (8*1024*1024-1)
21 #define tmp t0
22 #define curaddr t1
23 #define writedata t2
24 #define readdata t3
25 #define count t4
26 #define errorall t5
29 #define TESTONCE \
30         li count,STEPS;\
31 1: \
32         sw      writedata, 0(curaddr); \
33         subu    writedata,DECDATA; \
34         addu    curaddr, 4; \
35         subu count,1; \
36         bnez count,1b; \
37         nop; \
38         \
39         addu writedata,STEPS*DECDATA; \
40     subu curaddr,STEPS*4;       \
41         li count,STEPS;\
42 1: \
43         lw      readdata, 0(curaddr); \
44         beq readdata, writedata,11f; \
45         nop; \
46         bal 111f; \
47         nop; \
48 11: \
49         subu    writedata, DECDATA; \
50         addu    curaddr, 4; \
51         subu count,1;\
52         bnez count, 1b;\
53         nop;
54         
56 #define MYDBG(x) \
57         .rdata;98: .asciz x; .text; la a0, 98b; la v0, stringserial; addu v0,s0;jalr v0; nop    
58 #define NEWADDR 0x80000000
60         move a0,s0
61         bal hexserial
62         nop
63         PRINTSTR("\r\n");
64         la v0,_start
65         li v1,0xbfc00000
66         subu a0,v1,v0
67         bal hexserial
68         nop
69         PRINTSTR("\r\n");
71         la t0,testmem0_start
72         addu t0,s0
73         la t1,testmem0_end
74         addu t1,s0
75         li t2,NEWADDR
76         or t2,0xa0000000
78         lw v0,(t0)
79         nop
80         nop
81         sw v0,(t2)
82         addu t0,4
83         addu t2,4
84         bne t0,t1,1b
85         nop
86 #       bal godson2_cache_flush
87 #       nop
88         li t0,NEWADDR
89         jr t0   
90         nop             
92 testmem0_start: 
93         MYDBG("Testing memory now\r\n")
94         
95         move errorall,zero
96         li writedata,STARTDATA
97         li curaddr,STARTADDR
98 21:
99     TESTONCE;
100         addu writedata,STEPS*DECDATA; 
101     subu curaddr,STEPS*4;       
102     not writedata
103         TESTONCE;
104     
105     li  tmp,ADDRMASK
106         and tmp,curaddr
107         bnez tmp,22f
108         nop;
109         li      a0, '.'; 
110         la  v0,tgt_putchar
111         add v0,s0
112         jalr v0; 
113         nop; 
115     li tmp,MAXSIZE+STARTADDR
116         subu tmp,curaddr
117         bgtz tmp,21b
118         nop
119         MYDBG("\r\nTesting ok\r\n");
120 1:      
121         b       1b
122         nop
124 111:
125         move t6,ra
126         MYDBG("\r\nMemory test failed at ");
127         move    a0,     curaddr
128         la v0,hexserial
129         add v0,s0
130         jalr v0
131         nop
132         MYDBG("\r\nWrite=");
133         move    a0, writedata
134         la v0,hexserial
135         add v0,s0
136         jalr v0
137         nop
138         MYDBG("\r\nRead =");
139         move    a0, readdata
140         la v0,hexserial
141         add v0,s0
142         jalr v0
143         nop
144         MYDBG("\r\nxor =");
145         xor a0,writedata,readdata
146         or errorall,a0
147         la v0,hexserial
148         add v0,s0
149         jalr v0
150         nop
151         MYDBG("\r\nallerror =");
152         move a0,errorall
153         la v0,hexserial
154         add v0,s0
155         jalr v0
156         nop
157         jr t6
158         nop
159 testmem0_end:
165 #undef STARTADDR 
166 #undef MAXSIZE
167 #undef STARTDATA 
168 #undef DECDATA 
169 #undef ADDRMASK 
170 #undef STEPS 
171 #undef tmp 
172 #undef curaddr 
173 #undef writedata 
174 #undef readdata 
175 #undef count 
176 #undef errorall