Fixed tools/env utilities
[u-boot-openmoko/mini2440.git] / board / evb64260 / ecctest.c
blob5d3679aa9396e64635dee9384c5f5e7bf0ba4019
1 indent: Standard input:27: Warning:old style assignment ambiguity in "=*". Assuming "= *"
3 #ifdef ECC_TEST
4 static inline void ecc_off (void)
6 *(volatile int *) (INTERNAL_REG_BASE_ADDR + 0x4b4) &= ~0x00200000;
9 static inline void ecc_on (void)
11 *(volatile int *) (INTERNAL_REG_BASE_ADDR + 0x4b4) |= 0x00200000;
14 static int putshex (const char *buf, int len)
16 int i;
18 for (i = 0; i < len; i++) {
19 printf ("%02x", buf[i]);
21 return 0;
24 static int char_memcpy (void *d, const void *s, int len)
26 int i;
27 char *cd = d;
28 const char *cs = s;
30 for (i = 0; i < len; i++) {
31 *(cd++) = *(cs++);
33 return 0;
36 static int memory_test (char *buf)
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}
63 const int foo[] = { 0 };
64 int i, j, a;
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;
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]));
85 putc ('\n');
86 } else {
87 printf (" [PASS] (%p) align=%d\n", s, align);
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]));
102 putc ('\n');
103 } else {
104 printf (" [PASS] (%p) align=%d\n", s, align);
109 return 0;
111 #endif