Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 1 | static void write_phys(unsigned long addr, unsigned long value) |
| 2 | { |
Eric Biederman | 8d9c123 | 2003-06-17 08:42:17 +0000 | [diff] [blame] | 3 | #if HAVE_MOVNTI |
| 4 | asm volatile( |
| 5 | "movnti %1, (%0)" |
| 6 | : /* outputs */ |
| 7 | : "r" (addr), "r" (value) /* inputs */ |
Stefan Reinauer | 7671293 | 2004-05-27 11:13:24 +0000 | [diff] [blame] | 8 | #ifndef __GNUC__ |
Eric Biederman | 8d9c123 | 2003-06-17 08:42:17 +0000 | [diff] [blame] | 9 | : /* clobbers */ |
Stefan Reinauer | 7671293 | 2004-05-27 11:13:24 +0000 | [diff] [blame] | 10 | #endif |
Eric Biederman | 8d9c123 | 2003-06-17 08:42:17 +0000 | [diff] [blame] | 11 | ); |
| 12 | #else |
Eric Biederman | 5268557 | 2003-05-19 19:16:21 +0000 | [diff] [blame] | 13 | volatile unsigned long *ptr; |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 14 | ptr = (void *)addr; |
| 15 | *ptr = value; |
Eric Biederman | 8d9c123 | 2003-06-17 08:42:17 +0000 | [diff] [blame] | 16 | #endif |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 17 | } |
| 18 | |
| 19 | static unsigned long read_phys(unsigned long addr) |
| 20 | { |
Eric Biederman | 5268557 | 2003-05-19 19:16:21 +0000 | [diff] [blame] | 21 | volatile unsigned long *ptr; |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 22 | ptr = (void *)addr; |
| 23 | return *ptr; |
| 24 | } |
| 25 | |
Eric Biederman | 8d9c123 | 2003-06-17 08:42:17 +0000 | [diff] [blame] | 26 | static void ram_fill(unsigned long start, unsigned long stop) |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 27 | { |
| 28 | unsigned long addr; |
| 29 | /* |
| 30 | * Fill. |
| 31 | */ |
| 32 | print_debug("DRAM fill: "); |
| 33 | print_debug_hex32(start); |
| 34 | print_debug("-"); |
| 35 | print_debug_hex32(stop); |
| 36 | print_debug("\r\n"); |
| 37 | for(addr = start; addr < stop ; addr += 4) { |
| 38 | /* Display address being filled */ |
Eric Biederman | 8d9c123 | 2003-06-17 08:42:17 +0000 | [diff] [blame] | 39 | if (!(addr & 0xffff)) { |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 40 | print_debug_hex32(addr); |
Eric Biederman | 69afe28 | 2004-11-11 06:53:24 +0000 | [diff] [blame] | 41 | print_debug(" \r"); |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 42 | } |
| 43 | write_phys(addr, addr); |
| 44 | }; |
| 45 | /* Display final address */ |
| 46 | print_debug_hex32(addr); |
| 47 | print_debug("\r\nDRAM filled\r\n"); |
| 48 | } |
| 49 | |
Eric Biederman | 8d9c123 | 2003-06-17 08:42:17 +0000 | [diff] [blame] | 50 | static void ram_verify(unsigned long start, unsigned long stop) |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 51 | { |
| 52 | unsigned long addr; |
Eric Biederman | 69afe28 | 2004-11-11 06:53:24 +0000 | [diff] [blame] | 53 | int i = 0; |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 54 | /* |
| 55 | * Verify. |
| 56 | */ |
| 57 | print_debug("DRAM verify: "); |
| 58 | print_debug_hex32(start); |
| 59 | print_debug_char('-'); |
| 60 | print_debug_hex32(stop); |
| 61 | print_debug("\r\n"); |
| 62 | for(addr = start; addr < stop ; addr += 4) { |
| 63 | unsigned long value; |
| 64 | /* Display address being tested */ |
Eric Biederman | 8d9c123 | 2003-06-17 08:42:17 +0000 | [diff] [blame] | 65 | if (!(addr & 0xffff)) { |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 66 | print_debug_hex32(addr); |
Eric Biederman | 69afe28 | 2004-11-11 06:53:24 +0000 | [diff] [blame] | 67 | print_debug(" \r"); |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 68 | } |
| 69 | value = read_phys(addr); |
| 70 | if (value != addr) { |
| 71 | /* Display address with error */ |
| 72 | print_err_hex32(addr); |
| 73 | print_err_char(':'); |
| 74 | print_err_hex32(value); |
| 75 | print_err("\r\n"); |
Eric Biederman | 69afe28 | 2004-11-11 06:53:24 +0000 | [diff] [blame] | 76 | i++; |
| 77 | if(i>256) break; |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 78 | } |
| 79 | } |
| 80 | /* Display final address */ |
| 81 | print_debug_hex32(addr); |
| 82 | print_debug("\r\nDRAM verified\r\n"); |
| 83 | } |
| 84 | |
| 85 | |
Eric Biederman | 8d9c123 | 2003-06-17 08:42:17 +0000 | [diff] [blame] | 86 | void ram_check(unsigned long start, unsigned long stop) |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 87 | { |
| 88 | int result; |
| 89 | /* |
| 90 | * This is much more of a "Is my DRAM properly configured?" |
| 91 | * test than a "Is my DRAM faulty?" test. Not all bits |
| 92 | * are tested. -Tyson |
| 93 | */ |
Ronald G. Minnich | bfdc562 | 2004-03-22 04:24:29 +0000 | [diff] [blame] | 94 | print_debug("Testing DRAM : "); |
| 95 | print_debug_hex32(start); |
| 96 | print_debug("-"); |
| 97 | print_debug_hex32(stop); |
| 98 | print_debug("\r\n"); |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 99 | ram_fill(start, stop); |
| 100 | ram_verify(start, stop); |
Ronald G. Minnich | bfdc562 | 2004-03-22 04:24:29 +0000 | [diff] [blame] | 101 | print_debug("Done.\r\n"); |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 102 | } |
| 103 | |