blob: 5d3679aa9396e64635dee9384c5f5e7bf0ba4019 [file] [log] [blame]
wdenkbf9e3b32004-02-12 00:47:09 +00001indent: Standard input:27: Warning:old style assignment ambiguity in "=*". Assuming "= *"
2
wdenkfe8c2802002-11-03 00:38:21 +00003#ifdef ECC_TEST
wdenkbf9e3b32004-02-12 00:47:09 +00004static inline void ecc_off (void)
wdenkfe8c2802002-11-03 00:38:21 +00005{
wdenkbf9e3b32004-02-12 00:47:09 +00006 *(volatile int *) (INTERNAL_REG_BASE_ADDR + 0x4b4) &= ~0x00200000;
wdenkfe8c2802002-11-03 00:38:21 +00007}
8
wdenkbf9e3b32004-02-12 00:47:09 +00009static inline void ecc_on (void)
wdenkfe8c2802002-11-03 00:38:21 +000010{
wdenkbf9e3b32004-02-12 00:47:09 +000011 *(volatile int *) (INTERNAL_REG_BASE_ADDR + 0x4b4) |= 0x00200000;
wdenkfe8c2802002-11-03 00:38:21 +000012}
13
wdenkbf9e3b32004-02-12 00:47:09 +000014static int putshex (const char *buf, int len)
wdenkfe8c2802002-11-03 00:38:21 +000015{
wdenkbf9e3b32004-02-12 00:47:09 +000016 int i;
wdenkfe8c2802002-11-03 00:38:21 +000017
wdenkbf9e3b32004-02-12 00:47:09 +000018 for (i = 0; i < len; i++) {
19 printf ("%02x", buf[i]);
wdenkfe8c2802002-11-03 00:38:21 +000020 }
wdenkbf9e3b32004-02-12 00:47:09 +000021 return 0;
22}
wdenkfe8c2802002-11-03 00:38:21 +000023
wdenkbf9e3b32004-02-12 00:47:09 +000024static int char_memcpy (void *d, const void *s, int len)
25{
26 int i;
27 char *cd = d;
28 const char *cs = s;
29
30 for (i = 0; i < len; i++) {
31 *(cd++) = *(cs++);
32 }
33 return 0;
34}
35
36static int memory_test (char *buf)
37{
38 const char src[][16] = {
39 {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
40 {0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01, 0x01,
41 0x01, 0x01, 0x01, 0x01, 0x01, 0x01},
42 {0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02, 0x02,
43 0x02, 0x02, 0x02, 0x02, 0x02, 0x02},
44 {0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04, 0x04,
45 0x04, 0x04, 0x04, 0x04, 0x04, 0x04},
46 {0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08, 0x08,
47 0x08, 0x08, 0x08, 0x08, 0x08, 0x08},
48 {0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10, 0x10,
49 0x10, 0x10, 0x10, 0x10, 0x10, 0x10},
50 {0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20, 0x20,
51 0x20, 0x20, 0x20, 0x20, 0x20, 0x20},
52 {0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40, 0x40,
53 0x40, 0x40, 0x40, 0x40, 0x40, 0x40},
54 {0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80,
55 0x80, 0x80, 0x80, 0x80, 0x80, 0x80},
56 {0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55, 0x55,
57 0x55, 0x55, 0x55, 0x55, 0x55, 0x55},
58 {0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
59 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa},
60 {0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
61 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}
62 };
63 const int foo[] = { 0 };
64 int i, j, a;
65
66 printf ("\ntest @ %d %p\n", foo[0], buf);
67 for (i = 0; i < 12; i++) {
68 for (a = 0; a < 8; a++) {
69 const char *s = src[i] + a;
70 int align = (unsigned) (s) & 0x7;
71
72 /* ecc_off(); */
73 memcpy (buf, s, 8);
74 /* ecc_on(); */
75 putshex (s, 8);
76 if (memcmp (buf, s, 8)) {
77 putc ('\n');
78 putshex (buf, 8);
79 printf (" [FAIL] (%p) align=%d\n", s, align);
80 for (j = 0; j < 8; j++) {
81 s[j] == buf[j] ? puts (" ") :
82 printf ("%02x",
83 (s[j]) ^ (buf[j]));
84 }
85 putc ('\n');
86 } else {
87 printf (" [PASS] (%p) align=%d\n", s, align);
88 }
89 /* ecc_off(); */
90 char_memcpy (buf, s, 8);
91 /* ecc_on(); */
92 putshex (s, 8);
93 if (memcmp (buf, s, 8)) {
94 putc ('\n');
95 putshex (buf, 8);
96 printf (" [FAIL] (%p) align=%d\n", s, align);
97 for (j = 0; j < 8; j++) {
98 s[j] == buf[j] ? puts (" ") :
99 printf ("%02x",
100 (s[j]) ^ (buf[j]));
101 }
102 putc ('\n');
103 } else {
104 printf (" [PASS] (%p) align=%d\n", s, align);
105 }
106 }
107 }
108
109 return 0;
wdenkfe8c2802002-11-03 00:38:21 +0000110}
111#endif