1 #include <lib.h> /* Prototypes */
3 static void write_phys(unsigned long addr, unsigned long value)
5 // Assembler in lib/ is very ugly. But we properly guarded
6 // it so let's obey this one for now
11 : "r" (addr), "r" (value) /* inputs */
17 volatile unsigned long *ptr;
23 static unsigned long read_phys(unsigned long addr)
25 volatile unsigned long *ptr;
30 static void ram_fill(unsigned long start, unsigned long stop)
36 #if CONFIG_USE_PRINTK_IN_CAR
37 printk(BIOS_DEBUG, "DRAM fill: 0x%08lx-0x%08lx\r\n", start, stop);
39 print_debug("DRAM fill: ");
40 print_debug_hex32(start);
42 print_debug_hex32(stop);
45 for(addr = start; addr < stop ; addr += 4) {
46 /* Display address being filled */
47 if (!(addr & 0xfffff)) {
48 #if CONFIG_USE_PRINTK_IN_CAR
49 printk(BIOS_DEBUG, "%08lx \r", addr);
51 print_debug_hex32(addr);
55 write_phys(addr, addr);
59 asm volatile ("sfence" ::: "memory");
61 /* Display final address */
62 #if CONFIG_USE_PRINTK_IN_CAR
63 printk(BIOS_DEBUG, "%08lx\r\nDRAM filled\r\n", addr);
65 print_debug_hex32(addr);
66 print_debug("\r\nDRAM filled\r\n");
70 static void ram_verify(unsigned long start, unsigned long stop)
77 #if CONFIG_USE_PRINTK_IN_CAR
78 printk(BIOS_DEBUG, "DRAM verify: 0x%08lx-0x%08lx\r\n", start, stop);
80 print_debug("DRAM verify: ");
81 print_debug_hex32(start);
82 print_debug_char('-');
83 print_debug_hex32(stop);
86 for(addr = start; addr < stop ; addr += 4) {
88 /* Display address being tested */
89 if (!(addr & 0xfffff)) {
90 #if CONFIG_USE_PRINTK_IN_CAR
91 printk(BIOS_DEBUG, "%08lx \r", addr);
93 print_debug_hex32(addr);
97 value = read_phys(addr);
99 /* Display address with error */
100 #if CONFIG_USE_PRINTK_IN_CAR
101 printk(BIOS_ERR, "Fail: @0x%08lx Read value=0x%08lx\r\n", addr, value);
103 print_err("Fail: @0x");
104 print_err_hex32(addr);
105 print_err(" Read value=0x");
106 print_err_hex32(value);
111 #if CONFIG_USE_PRINTK_IN_CAR
112 printk(BIOS_DEBUG, "Aborting.\n\r");
114 print_debug("Aborting.\n\r");
120 /* Display final address */
121 #if CONFIG_USE_PRINTK_IN_CAR
122 printk(BIOS_DEBUG, "%08lx", addr);
124 print_debug_hex32(addr);
128 #if CONFIG_USE_PRINTK_IN_CAR
129 printk(BIOS_DEBUG, "\r\nDRAM did _NOT_ verify!\r\n");
131 print_debug("\r\nDRAM did _NOT_ verify!\r\n");
136 #if CONFIG_USE_PRINTK_IN_CAR
137 printk(BIOS_DEBUG, "\r\nDRAM range verified.\r\n");
139 print_debug("\r\nDRAM range verified.\r\n");
145 void ram_check(unsigned long start, unsigned long stop)
148 * This is much more of a "Is my DRAM properly configured?"
149 * test than a "Is my DRAM faulty?" test. Not all bits
152 #if CONFIG_USE_PRINTK_IN_CAR
153 printk(BIOS_DEBUG, "Testing DRAM : %08lx - %08lx\r\n", start, stop);
155 print_debug("Testing DRAM : ");
156 print_debug_hex32(start);
158 print_debug_hex32(stop);
161 ram_fill(start, stop);
162 ram_verify(start, stop);
163 #if CONFIG_USE_PRINTK_IN_CAR
164 printk(BIOS_DEBUG, "Done.\r\n");
166 print_debug("Done.\r\n");