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 | 5268557 | 2003-05-19 19:16:21 +0000 | [diff] [blame] | 3 | volatile unsigned long *ptr; |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 4 | ptr = (void *)addr; |
| 5 | *ptr = value; |
| 6 | } |
| 7 | |
| 8 | static unsigned long read_phys(unsigned long addr) |
| 9 | { |
Eric Biederman | 5268557 | 2003-05-19 19:16:21 +0000 | [diff] [blame] | 10 | volatile unsigned long *ptr; |
Eric Biederman | 8ca8d76 | 2003-04-22 19:02:15 +0000 | [diff] [blame] | 11 | ptr = (void *)addr; |
| 12 | return *ptr; |
| 13 | } |
| 14 | |
| 15 | void ram_fill(unsigned long start, unsigned long stop) |
| 16 | { |
| 17 | unsigned long addr; |
| 18 | /* |
| 19 | * Fill. |
| 20 | */ |
| 21 | print_debug("DRAM fill: "); |
| 22 | print_debug_hex32(start); |
| 23 | print_debug("-"); |
| 24 | print_debug_hex32(stop); |
| 25 | print_debug("\r\n"); |
| 26 | for(addr = start; addr < stop ; addr += 4) { |
| 27 | /* Display address being filled */ |
| 28 | if ((addr & 0xffff) == 0) { |
| 29 | print_debug_hex32(addr); |
| 30 | print_debug("\r"); |
| 31 | } |
| 32 | write_phys(addr, addr); |
| 33 | }; |
| 34 | /* Display final address */ |
| 35 | print_debug_hex32(addr); |
| 36 | print_debug("\r\nDRAM filled\r\n"); |
| 37 | } |
| 38 | |
| 39 | void ram_verify(unsigned long start, unsigned long stop) |
| 40 | { |
| 41 | unsigned long addr; |
| 42 | /* |
| 43 | * Verify. |
| 44 | */ |
| 45 | print_debug("DRAM verify: "); |
| 46 | print_debug_hex32(start); |
| 47 | print_debug_char('-'); |
| 48 | print_debug_hex32(stop); |
| 49 | print_debug("\r\n"); |
| 50 | for(addr = start; addr < stop ; addr += 4) { |
| 51 | unsigned long value; |
| 52 | /* Display address being tested */ |
| 53 | if ((addr & 0xffff) == 0) { |
| 54 | print_debug_hex32(addr); |
| 55 | print_debug("\r"); |
| 56 | } |
| 57 | value = read_phys(addr); |
| 58 | if (value != addr) { |
| 59 | /* Display address with error */ |
| 60 | print_err_hex32(addr); |
| 61 | print_err_char(':'); |
| 62 | print_err_hex32(value); |
| 63 | print_err("\r\n"); |
| 64 | } |
| 65 | } |
| 66 | /* Display final address */ |
| 67 | print_debug_hex32(addr); |
| 68 | print_debug("\r\nDRAM verified\r\n"); |
| 69 | } |
| 70 | |
| 71 | |
| 72 | void ramcheck(unsigned long start, unsigned long stop) |
| 73 | { |
| 74 | int result; |
| 75 | /* |
| 76 | * This is much more of a "Is my DRAM properly configured?" |
| 77 | * test than a "Is my DRAM faulty?" test. Not all bits |
| 78 | * are tested. -Tyson |
| 79 | */ |
| 80 | print_debug("Testing DRAM : "); |
| 81 | print_debug_hex32(start); |
| 82 | print_debug("-"); |
| 83 | print_debug_hex32(stop); |
| 84 | print_debug("\r\n"); |
| 85 | ram_fill(start, stop); |
| 86 | ram_verify(start, stop); |
| 87 | print_debug("Done.\n"); |
| 88 | } |
| 89 | |