blob: e7c58b3a292707cc3257a8c3fa95dbbcb8247a54 [file] [log] [blame]
wdenkfe8c2802002-11-03 00:38:21 +00001#ifdef ECC_TEST
2static inline void ecc_off(void)
3{
4 *(volatile int *)(INTERNAL_REG_BASE_ADDR+0x4b4) &= ~0x00200000;
5}
6
7static inline void ecc_on(void)
8{
9 *(volatile int *)(INTERNAL_REG_BASE_ADDR+0x4b4) |= 0x00200000;
10}
11
12static int putshex(const char *buf, int len)
13{
14 int i;
15 for (i=0;i<len;i++) {
16 printf("%02x", buf[i]);
17 }
18 return 0;
19}
20
21static int char_memcpy(void *d, const void *s, int len)
22{
23 int i;
24 char *cd=d;
25 const char *cs=s;
26 for(i=0;i<len;i++) {
27 *(cd++)=*(cs++);
28 }
29 return 0;
30}
31
32static int memory_test(char *buf)
33{
34 const char src[][16]={
35 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
36 {0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01,0x01},
37 {0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02,0x02},
38 {0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04,0x04},
39 {0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08,0x08},
40 {0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10,0x10},
41 {0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20},
42 {0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40,0x40},
43 {0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80,0x80},
44 {0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55,0x55},
45 {0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa,0xaa},
46 {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff}
47 };
48 const int foo[] = {0};
49 int i,j,a;
50
51 printf("\ntest @ %d %p\n", foo[0], buf);
52 for(i=0;i<12;i++) {
53 for(a=0;a<8;a++) {
54 const char *s=src[i]+a;
55 int align=(unsigned)(s)&0x7;
56 /* ecc_off(); */
57 memcpy(buf,s,8);
58 /* ecc_on(); */
59 putshex(s,8);
60 if(memcmp(buf,s,8)) {
61 putc('\n');
62 putshex(buf,8);
63 printf(" [FAIL] (%p) align=%d\n", s, align);
64 for(j=0;j<8;j++) {
65 s[j]==buf[j]?puts(" "):printf("%02x", (s[j])^(buf[j]));
66 }
67 putc('\n');
68 } else {
69 printf(" [PASS] (%p) align=%d\n", s, align);
70 }
71 /* ecc_off(); */
72 char_memcpy(buf,s,8);
73 /* ecc_on(); */
74 putshex(s,8);
75 if(memcmp(buf,s,8)) {
76 putc('\n');
77 putshex(buf,8);
78 printf(" [FAIL] (%p) align=%d\n", s, align);
79 for(j=0;j<8;j++) {
80 s[j]==buf[j]?puts(" "):printf("%02x", (s[j])^(buf[j]));
81 }
82 putc('\n');
83 } else {
84 printf(" [PASS] (%p) align=%d\n", s, align);
85 }
86 }
87 }
88
89 return 0;
90}
91#endif