wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 1 | indent: Standard input:27: Warning:old style assignment ambiguity in "=*". Assuming "= *" |
| 2 | |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 3 | #ifdef ECC_TEST |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 4 | static inline void ecc_off (void) |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 5 | { |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 6 | *(volatile int *) (INTERNAL_REG_BASE_ADDR + 0x4b4) &= ~0x00200000; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 7 | } |
| 8 | |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 9 | static inline void ecc_on (void) |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 10 | { |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 11 | *(volatile int *) (INTERNAL_REG_BASE_ADDR + 0x4b4) |= 0x00200000; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 12 | } |
| 13 | |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 14 | static int putshex (const char *buf, int len) |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 15 | { |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 16 | int i; |
| 17 | |
| 18 | for (i = 0; i < len; i++) { |
| 19 | printf ("%02x", buf[i]); |
| 20 | } |
| 21 | return 0; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 22 | } |
| 23 | |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 24 | static int char_memcpy (void *d, const void *s, int len) |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 25 | { |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 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; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 34 | } |
| 35 | |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 36 | static int memory_test (char *buf) |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 37 | { |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 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; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 65 | |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 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 | } |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 106 | } |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 107 | } |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 108 | |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 109 | return 0; |
wdenk | fe8c280 | 2002-11-03 00:38:21 +0000 | [diff] [blame] | 110 | } |
| 111 | #endif |