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