printk_foo -> printk(BIOS_FOO, ...)
[coreboot.git] / src / lib / ramtest.c
index 4f00030b893fbc018d6b2dd67da912ae1ca32181..5f24bc1c7d7fadf9c93c0af2a6c10b5a67844ee6 100644 (file)
@@ -1,6 +1,10 @@
+#include <lib.h> /* Prototypes */
+
 static void write_phys(unsigned long addr, unsigned long value)
 {
-#if CONFIG_HAVE_MOVNTI
+       // Assembler in lib/ is very ugly. But we properly guarded
+       // it so let's obey this one for now
+#if CONFIG_SSE2
        asm volatile(
                "movnti %1, (%0)"
                : /* outputs */
@@ -30,7 +34,7 @@ static void ram_fill(unsigned long start, unsigned long stop)
         * Fill.
         */
 #if CONFIG_USE_PRINTK_IN_CAR
-       printk_debug("DRAM fill: 0x%08lx-0x%08lx\r\n", start, stop);
+       printk(BIOS_DEBUG, "DRAM fill: 0x%08lx-0x%08lx\r\n", start, stop);
 #else
        print_debug("DRAM fill: ");
        print_debug_hex32(start);
@@ -42,7 +46,7 @@ static void ram_fill(unsigned long start, unsigned long stop)
                /* Display address being filled */
                if (!(addr & 0xfffff)) {
 #if CONFIG_USE_PRINTK_IN_CAR
-                       printk_debug("%08lx \r", addr);
+                       printk(BIOS_DEBUG, "%08lx \r", addr);
 #else
                        print_debug_hex32(addr);
                        print_debug(" \r");
@@ -50,9 +54,13 @@ static void ram_fill(unsigned long start, unsigned long stop)
                }
                write_phys(addr, addr);
        };
+#if CONFIG_SSE2
+       // Needed for movnti
+       asm volatile ("sfence" ::: "memory");
+#endif
        /* Display final address */
 #if CONFIG_USE_PRINTK_IN_CAR
-       printk_debug("%08lx\r\nDRAM filled\r\n", addr);
+       printk(BIOS_DEBUG, "%08lx\r\nDRAM filled\r\n", addr);
 #else
        print_debug_hex32(addr);
        print_debug("\r\nDRAM filled\r\n");
@@ -67,7 +75,7 @@ static void ram_verify(unsigned long start, unsigned long stop)
         * Verify.
         */
 #if CONFIG_USE_PRINTK_IN_CAR
-       printk_debug("DRAM verify: 0x%08lx-0x%08lx\r\n", start, stop);
+       printk(BIOS_DEBUG, "DRAM verify: 0x%08lx-0x%08lx\r\n", start, stop);
 #else
        print_debug("DRAM verify: ");
        print_debug_hex32(start);
@@ -80,7 +88,7 @@ static void ram_verify(unsigned long start, unsigned long stop)
                /* Display address being tested */
                if (!(addr & 0xfffff)) {
 #if CONFIG_USE_PRINTK_IN_CAR
-                       printk_debug("%08lx \r", addr);
+                       printk(BIOS_DEBUG, "%08lx \r", addr);
 #else
                        print_debug_hex32(addr);
                        print_debug(" \r");
@@ -90,7 +98,7 @@ static void ram_verify(unsigned long start, unsigned long stop)
                if (value != addr) {
                        /* Display address with error */
 #if CONFIG_USE_PRINTK_IN_CAR
-                       printk_err("Fail: @0x%08lx Read value=0x%08lx\r\n", addr, value);
+                       printk(BIOS_ERR, "Fail: @0x%08lx Read value=0x%08lx\r\n", addr, value);
 #else
                        print_err("Fail: @0x");
                        print_err_hex32(addr);
@@ -101,7 +109,7 @@ static void ram_verify(unsigned long start, unsigned long stop)
                        i++;
                        if(i>256) {
 #if CONFIG_USE_PRINTK_IN_CAR
-                               printk_debug("Aborting.\n\r");
+                               printk(BIOS_DEBUG, "Aborting.\n\r");
 #else
                                print_debug("Aborting.\n\r");
 #endif
@@ -111,14 +119,14 @@ static void ram_verify(unsigned long start, unsigned long stop)
        }
        /* Display final address */
 #if CONFIG_USE_PRINTK_IN_CAR
-       printk_debug("%08lx", addr);
+       printk(BIOS_DEBUG, "%08lx", addr);
 #else
        print_debug_hex32(addr);
 #endif
 
        if (i) {
 #if CONFIG_USE_PRINTK_IN_CAR
-               printk_debug("\r\nDRAM did _NOT_ verify!\r\n");
+               printk(BIOS_DEBUG, "\r\nDRAM did _NOT_ verify!\r\n");
 #else
                print_debug("\r\nDRAM did _NOT_ verify!\r\n");
 #endif
@@ -126,7 +134,7 @@ static void ram_verify(unsigned long start, unsigned long stop)
        }
        else {
 #if CONFIG_USE_PRINTK_IN_CAR
-               printk_debug("\r\nDRAM range verified.\r\n");
+               printk(BIOS_DEBUG, "\r\nDRAM range verified.\r\n");
 #else
                print_debug("\r\nDRAM range verified.\r\n");
 #endif
@@ -142,7 +150,7 @@ void ram_check(unsigned long start, unsigned long stop)
         * are tested.   -Tyson
         */
 #if CONFIG_USE_PRINTK_IN_CAR
-       printk_debug("Testing DRAM : %08lx - %08lx\r\n", start, stop);
+       printk(BIOS_DEBUG, "Testing DRAM : %08lx - %08lx\r\n", start, stop);
 #else
        print_debug("Testing DRAM : ");
        print_debug_hex32(start);
@@ -153,7 +161,7 @@ void ram_check(unsigned long start, unsigned long stop)
        ram_fill(start, stop);
        ram_verify(start, stop);
 #if CONFIG_USE_PRINTK_IN_CAR
-       printk_debug("Done.\r\n");
+       printk(BIOS_DEBUG, "Done.\r\n");
 #else
        print_debug("Done.\r\n");
 #endif