blob: 0e5e6982a36a55dfb23d87be52b555a0cece673f [file] [log] [blame]
Eric Biederman8ca8d762003-04-22 19:02:15 +00001static void write_phys(unsigned long addr, unsigned long value)
2{
3 unsigned long *ptr;
4 ptr = (void *)addr;
5 *ptr = value;
6}
7
8static unsigned long read_phys(unsigned long addr)
9{
10 unsigned long *ptr;
11 ptr = (void *)addr;
12 return *ptr;
13}
14
15void 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
39void 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
72void 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