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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541 | #define MM_SDRAM_BASE 0x00000000
#define MM_SDRAM_SIZE 0x01000000
#define SDRAM_LOW MM_SDRAM_BASE
#define SDRAM_HIGH (MM_SDRAM_BASE+MM_SDRAM_SIZE)
#define SDRAM_PAGE 512 /* 128, 32 bit words */
#define SDRAM_RNDP_SHFT 8
#define SDRAM_RNDP_MASK 0xFFFE00
#define SST_LOOPS 10240
/* Linear congruential generator parameters */
/* Vj+1 = (A * Vj + B) mod 2^32 */
#define LCG_V0 0x55555555 /* default seed */
#define LCG_A 0x0019660D
#define LCG_B 0x3C6EF35F
.global quick_sdram_cycle
.global quick_sdram_test
.global deep_sdram_cycle
.global deep_sdram_test
.extern dst_cb
.data
memory_test_patern:
.long 0x00000000
.long 0x55555555
.long 0xFFFFFFFF
.long 0xAAAAAAAA
.long 0x33333333
.long 0x66666666
.long 0xF0F0F0F0
.long 0xCCCCCCCC
.long 0x99999999
.long 0x3C3C3C3C
.long 0x0F0F0F0F
.long 0xC3C3C3C3
.long 0x00FF00FF
.long 0xFF00FF00
.long 0xF00FF00F
.long 0x0FF00FF0
memory_test_patern_end:
memory_test_patern_size:
.long 0x00000040
.text
/**************************************************************\
Implements a single pass, word-oriented March-Y, with
memory retention test.
in %d0 = background
out %d0 = result code
\**************************************************************/
quick_sdram_cycle:
lea (-28,%sp), %sp
moveml %d1/%a0-%a5, (%sp)
moveal #SDRAM_LOW, %a0
moveal #SDRAM_HIGH, %a1
moveal #SDRAM_PAGE, %a2
movel %d0, %d1
notl %d1
/* Initialize background, ascending X */
moveal %a0, %a3
quick_sdram_cycle_1:
movel %d0, (%a3)+
cmpal %a1, %a3
jlt quick_sdram_cycle_1
/* Flush row */
moveal %a0, %a3
tstl (%a3)
/* Write foreground, descending Y */
moveal #(SDRAM_HIGH - SDRAM_PAGE), %a3
moveal %a1, %a4
quick_sdram_cycle_2_1:
subql #4, %a4
moveal %a4, %a5
quick_sdram_cycle_2_2:
cmpl (%a5), %d0
jne sdram_cycle_e1 /* Error 1 */
movel %d1, (%a5)
cmpl (%a5), %d1
jne sdram_cycle_e2 /* Error 2 */
subal %a2, %a5
cmpal %a0, %a5
jge quick_sdram_cycle_2_2
cmpal %a3, %a4
jgt quick_sdram_cycle_2_1
/* Sleeping sickness check, descending Y */
moveal #(SDRAM_HIGH - SDRAM_PAGE), %a3
moveal %a1, %a4
quick_sdram_cycle_3_1:
subql #4, %a4
moveal %a4, %a5
quick_sdram_cycle_3_2:
cmpl (%a5), %d1
jne sdram_cycle_e3 /* Error 3 */
subal %a2, %a5
cmpal %a0, %a5
jge quick_sdram_cycle_3_2
cmpal %a3, %a4
jgt quick_sdram_cycle_3_1
/* Flush row */
moveal %a1, %a3
tstl -(%a3)
/* Write background, ascending Y */
moveal #(SDRAM_LOW + SDRAM_PAGE), %a3
moveal %a0, %a4
quick_sdram_cycle_4_1:
moveal %a4, %a5
quick_sdram_cycle_4_2:
cmpl (%a5), %d1
jne sdram_cycle_e4 /* Error 4 */
movel %d0, (%a5)
cmpl (%a5), %d0
jne sdram_cycle_e5 /* Error 5 */
addal %a2, %a5
cmpal %a1, %a5
jlt quick_sdram_cycle_4_2
addql #4, %a4
cmpal %a3, %a4
jlt quick_sdram_cycle_4_1
/* Sleeping sickness check, ascending Y */
moveal #(SDRAM_LOW + SDRAM_PAGE), %a3
moveal %a0, %a4
quick_sdram_cycle_5_1:
moveal %a4, %a5
quick_sdram_cycle_5_2:
cmpl (%a5), %d0
jne sdram_cycle_e6 /* Error 6 */
addal %a2, %a5
cmpal %a1, %a5
jlt quick_sdram_cycle_5_2
addql #4, %a4
cmpal %a3, %a4
jlt quick_sdram_cycle_5_1
movel #0, %d0
jra quick_sdram_cycle_done
sdram_cycle_e1:
movel #1, %d0
jra quick_sdram_cycle_done
sdram_cycle_e2:
movel #2, %d0
jra quick_sdram_cycle_done
sdram_cycle_e3:
movel #3, %d0
jra quick_sdram_cycle_done
sdram_cycle_e4:
movel #4, %d0
jra quick_sdram_cycle_done
sdram_cycle_e5:
movel #5, %d0
jra quick_sdram_cycle_done
sdram_cycle_e6:
movel #6, %d0
quick_sdram_cycle_done:
moveml (%sp), %d1/%a0-%a5
lea (28,%sp), %sp
rts
/**************************************************************\
Implements a 16 pass, word-oriented March-Y, with
memory retention test.
out %d0 = result code
\**************************************************************/
quick_sdram_test:
lea (-8,%sp), %sp
moveml %a0-%a1, (%sp)
moveal #memory_test_patern, %a0
moveal #memory_test_patern_end, %a1
quick_sdram_test_loop:
movel -(%a1), %d0
jbsr quick_sdram_cycle
tstl %d0
jne quick_sdram_test_error
cmpal %a0, %a1
jgt quick_sdram_test_loop
quick_sdram_test_error:
moveml (%sp), %a0-%a1
lea (8,%sp), %sp
rts
/**************************************************************\
Implements a single deep sdram test cycle.
in %d0 = background
out %d0 = result code
\**************************************************************/
deep_sdram_cycle:
lea (-36,%sp), %sp
moveml %d1-%d3/%a0-%a5, (%sp)
moveal #SDRAM_LOW, %a0
moveal #SDRAM_HIGH, %a1
moveal #SDRAM_PAGE, %a2
movel %d0, %d1
notl %d1
/* Initialize background, ascending X */
moveal %a0, %a3
deep_sdram_cycle_1:
movel %d0, (%a3)+
cmpal %a1, %a3
jlt deep_sdram_cycle_1
/* Flush row */
moveal %a0, %a3
tstl (%a3)
/* Write foreground, descending Y */
moveal #(SDRAM_HIGH - SDRAM_PAGE), %a3
moveal %a1, %a4
deep_sdram_cycle_2_1:
subql #4, %a4
moveal %a4, %a5
deep_sdram_cycle_2_2:
cmpl (%a5), %d0
jne deep_sdram_cycle_e1 /* Error 1 */
movel %d1, (%a5)
cmpl (%a5), %d1
jne deep_sdram_cycle_e2 /* Error 2 */
subal %a2, %a5
cmpal %a0, %a5
jge deep_sdram_cycle_2_2
cmpal %a3, %a4
jgt deep_sdram_cycle_2_1
/* Simultaneous-switching test */
moveal #memory_test_patern, %a3
moveal #memory_test_patern_end, %a4
movel %d0, %d2
deep_sdram_cycle_3:
movel (%a3)+, %d3
eorl %d3, %d2
jbsr deep_sdram_switching_test
tstl %d2
jne deep_sdram_cycle_esst /* Error SST */
cmpal %a3, %a4
jgt deep_sdram_cycle_3
/* Flush row */
moveal %a1, %a3
tstl -(%a3)
/* Write background, ascending Y */
moveal #(SDRAM_LOW + SDRAM_PAGE), %a3
moveal %a0, %a4
deep_sdram_cycle_4_1:
moveal %a4, %a5
deep_sdram_cycle_4_2:
cmpl (%a5), %d1
jne deep_sdram_cycle_e3 /* Error 3 */
movel %d0, (%a5)
cmpl (%a5), %d0
jne deep_sdram_cycle_e4 /* Error 4 */
addal %a2, %a5
cmpal %a1, %a5
jlt deep_sdram_cycle_4_2
addql #4, %a4
cmpal %a3, %a4
jlt deep_sdram_cycle_4_1
/* Simultaneous-switching test */
moveal #memory_test_patern, %a3
moveal #memory_test_patern_end, %a4
movel %d0, %d2
negl %d2
deep_sdram_cycle_5:
movel (%a3)+, %d3
eorl %d3, %d2
jbsr deep_sdram_switching_test
tstl %d2
jne deep_sdram_cycle_esst /* Error SST */
cmpal %a3, %a4
jgt deep_sdram_cycle_5
/* Flush row */
moveal %a1, %a3
tstl -(%a3)
/* Sleeping sickness check, ascending Y */
moveal #(SDRAM_LOW + SDRAM_PAGE), %a3
moveal %a0, %a4
deep_sdram_cycle_6_1:
moveal %a4, %a5
deep_sdram_cycle_6_2:
cmpl (%a5), %d0
jne deep_sdram_cycle_e5 /* Error 5 */
addal %a2, %a5
cmpal %a1, %a5
jlt deep_sdram_cycle_6_2
addql #4, %a4
cmpal %a3, %a4
jlt deep_sdram_cycle_6_1
/* Address test */
moveal %a0, %a3
deep_sdram_cycle_7_1:
movel %a3, %d2
notl %d2
movel %d2, (%a3)+
cmpal %a1, %a3
jlt deep_sdram_cycle_7_1
moveal %a0, %a3
deep_sdram_cycle_7_2:
movel %a3, %d2
notl %d2
cmpl (%a3)+, %d2
jne deep_sdram_cycle_e6 /* Error 6 */
cmpal %a1, %a3
jlt deep_sdram_cycle_7_2
movel #0, %d0
jra deep_sdram_cycle_done
deep_sdram_cycle_e1:
movel #1, %d0
jra deep_sdram_cycle_done
deep_sdram_cycle_e2:
movel #2, %d0
jra deep_sdram_cycle_done
deep_sdram_cycle_e3:
movel #3, %d0
jra deep_sdram_cycle_done
deep_sdram_cycle_e4:
movel #4, %d0
jra deep_sdram_cycle_done
deep_sdram_cycle_e5:
movel #5, %d0
jra deep_sdram_cycle_done
deep_sdram_cycle_e6:
movel #6, %d0
jra deep_sdram_cycle_done
deep_sdram_cycle_esst:
movel %d2, %d0
deep_sdram_cycle_done:
moveml (%sp), %d1-%d3/%a0-%a5
lea (36,%sp), %sp
rts
/**************************************************************\
Implements a word-oriented March-Y, with simultaneous-
switching test. Uses a callback function for feedback
after every cycle.
in %d0 = random number seed, set to zero to use the
default
\**************************************************************/
deep_sdram_test:
lea (-4,%sp), %sp
movel %d1, (%sp)
tstl %d0
jne deep_sdram_test_loop
movel #LCG_V0, %d0
deep_sdram_test_loop:
movel %d0, %d1
jbsr deep_sdram_cycle
jbsr dst_cb
tstl %d0
jeq deep_sdram_test_continue /* %d0 = 0 : continue */
jpl deep_sdram_test_done /* %d0 > 0 : break */
movel %d1, %d0
jra deep_sdram_test_loop /* %d0 < 0 : retry */
deep_sdram_test_continue:
movel %d1, %d0
movel #LCG_A, %d1
mulul %d1, %d0
addil #LCG_B, %d0
jra deep_sdram_test_loop
deep_sdram_test_done:
movel (%sp), %d1
lea (4,%sp), %sp
rts
/**************************************************************\
This function implements a simultaneous-switching test.
in %d2 = random number
out %d2 = result code
\**************************************************************/
deep_sdram_switching_test:
lea (-40,%sp), %sp
moveml %d0-%d1/%d3-%d6/%a0-%a3, (%sp)
/* Select a test page */
lsrl #SDRAM_RNDP_SHFT, %d2
andl #SDRAM_RNDP_MASK, %d2
moveal %d2, %a0
addal #MM_SDRAM_BASE, %a0
/* Save the test page */
moveal %a0, %a1
addal #SDRAM_PAGE, %a1
movel (%a0), %d6
moveal %a0, %a2
dsst_stp:
cmpl (%a2)+, %d6
jne dsst_e1 /* Error 7 */
cmpal %a1, %a2
jlt dsst_stp
movel #0, %d4
movel #SST_LOOPS, %d5
dsst_0:
addql #1, %d4
movel #0, %d0 /* fg */
movel %d0, %d1
notl %d1 /* bg */
moveal %a0, %a1
addal #(SDRAM_PAGE/2), %a1
moveal %a1, %a2 /* p */
moveal %a1, %a3 /* q */
dsst_1:
movel %d0, -(%a2) /* *--p = fg */
movel %d1, (%a3)+ /* *q++ = bg */
cmpal %a0, %a2
jgt dsst_1
moveal %a1, %a2
moveal %a1, %a3
dsst_2:
orl -(%a2), %d0 /* fg |= *--p */
andl (%a3)+, %d1 /* bg &= *q++ */
cmpal %a0, %a2
jgt dsst_2
movel %d1, %d3 /* fg == ~bg == 0 */
notl %d3
orl %d0, %d3
tstl %d3
jne dsst_e2 /* Error 8 */
dsst_3:
movel %d0, (%a2)+ /* *p++ = fg */
movel %d1, -(%a3) /* *--q = bg */
movel %d0, -(%a3) /* *--q = fg */
movel %d1, (%a2)+ /* *p++ = bg */
cmpal %a1, %a3
jgt dsst_3
dsst_4:
orl (%a3)+, %d0 /* fg |= *q++ */
andl -(%a2), %d1 /* bg &= *--p */
orl -(%a2), %d0 /* fg |= *--p */
andl (%a3)+, %d1 /* bg &= *q++ */
cmpal %a0, %a2
jgt dsst_4
movel %d1, %d3 /* fg == ~bg == 0 */
notl %d3
orl %d0, %d3
tstl %d3
jne dsst_e3 /* error 9 */
dsst_5:
movel %d1, (%a2)+ /* *p++ = bg */
movel %d0, -(%a3) /* *--q = fg */
movel %d1, -(%a3) /* *--q = bg */
movel %d0, (%a2)+ /* *p++ = fg */
cmpal %a1, %a3
jgt dsst_5
dsst_6:
andl (%a3)+, %d1 /* bg |= *q++ */
orl -(%a2), %d0 /* fg &= *--p */
andl -(%a2), %d1 /* bg |= *--p */
orl (%a3)+, %d0 /* fg &= *q++ */
cmpal %a0, %a2
jgt dsst_6
movel %d1, %d3 /* fg == ~bg == 0 */
notl %d3
orl %d0, %d3
tstl %d3
jne dsst_e4 /* error 10 */
cmpl %d4, %d5
jge dsst_0
/* Restore the test page */
moveal %a0, %a1
addal #SDRAM_PAGE, %a1
moveal %a0, %a2
dsst_rtp:
movel %d6, (%a2)+
cmpal %a1, %a2
jlt dsst_rtp
movel #0, %d2
jra dsst_done
dsst_e1:
movel #7, %d2
jra dsst_done
dsst_e2:
movel #8, %d2
jra dsst_done
dsst_e3:
movel #9, %d2
jra dsst_done
dsst_e4:
movel #10, %d2
dsst_done:
moveml (%sp), %d0-%d1/%d3-%d6/%a0-%a3
lea (40,%sp), %sp
rts
|