1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23#ifdef ECC_TEST
24static inline void ecc_off (void)
25{
26 *(volatile int *) (INTERNAL_REG_BASE_ADDR + 0x4b4) &= ~0x00200000;
27}
28
29static inline void ecc_on (void)
30{
31 *(volatile int *) (INTERNAL_REG_BASE_ADDR + 0x4b4) |= 0x00200000;
32}
33
34static int putshex (const char *buf, int len)
35{
36 int i;
37
38 for (i = 0; i < len; i++) {
39 printf ("%02x", buf[i]);
40 }
41 return 0;
42}
43
44static int char_memcpy (void *d, const void *s, int len)
45{
46 int i;
47 char *cd = d;
48 const char *cs = s;
49
50 for (i = 0; i < len; i++) {
51 *(cd++) = *(cs++);
52 }
53 return 0;
54}
55
56static int memory_test (char *buf)
57{
58 const char src[][16] = {
59 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
60 {0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
61 0x01, 0x01, 0x01, 0x01, 0x01, 0x01},
62 {0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
63 0x02, 0x02, 0x02, 0x02, 0x02, 0x02},
64 {0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
65 0x04, 0x04, 0x04, 0x04, 0x04, 0x04},
66 {0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
67 0x08, 0x08, 0x08, 0x08, 0x08, 0x08},
68 {0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
69 0x10, 0x10, 0x10, 0x10, 0x10, 0x10},
70 {0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
71 0x20, 0x20, 0x20, 0x20, 0x20, 0x20},
72 {0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
73 0x40, 0x40, 0x40, 0x40, 0x40, 0x40},
74 {0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
75 0x80, 0x80, 0x80, 0x80, 0x80, 0x80},
76 {0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
77 0x55, 0x55, 0x55, 0x55, 0x55, 0x55},
78 {0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
79 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa},
80 {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
81 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}
82 };
83 const int foo[] = { 0 };
84 int i, j, a;
85
86 printf ("\ntest @ %d %p\n", foo[0], buf);
87 for (i = 0; i < 12; i++) {
88 for (a = 0; a < 8; a++) {
89 const char *s = src[i] + a;
90 int align = (unsigned) (s) & 0x7;
91
92
93 memcpy (buf, s, 8);
94
95 putshex (s, 8);
96 if (memcmp (buf, s, 8)) {
97 putc ('\n');
98 putshex (buf, 8);
99 printf (" [FAIL] (%p) align=%d\n", s, align);
100 for (j = 0; j < 8; j++) {
101 s[j] == buf[j] ? puts (" ") :
102 printf ("%02x",
103 (s[j]) ^ (buf[j]));
104 }
105 putc ('\n');
106 } else {
107 printf (" [PASS] (%p) align=%d\n", s, align);
108 }
109
110 char_memcpy (buf, s, 8);
111
112 putshex (s, 8);
113 if (memcmp (buf, s, 8)) {
114 putc ('\n');
115 putshex (buf, 8);
116 printf (" [FAIL] (%p) align=%d\n", s, align);
117 for (j = 0; j < 8; j++) {
118 s[j] == buf[j] ? puts (" ") :
119 printf ("%02x",
120 (s[j]) ^ (buf[j]));
121 }
122 putc ('\n');
123 } else {
124 printf (" [PASS] (%p) align=%d\n", s, align);
125 }
126 }
127 }
128
129 return 0;
130}
131#endif
132