summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/lib/ramtest.c62
-rw-r--r--src/mainboard/kontron/986lcd-m/romstage.c2
2 files changed, 56 insertions, 8 deletions
diff --git a/src/lib/ramtest.c b/src/lib/ramtest.c
index 5f24bc1c7d..a43101235b 100644
--- a/src/lib/ramtest.c
+++ b/src/lib/ramtest.c
@@ -1,6 +1,6 @@
#include <lib.h> /* Prototypes */
-static void write_phys(unsigned long addr, unsigned long value)
+static void write_phys(unsigned long addr, u32 value)
{
// Assembler in lib/ is very ugly. But we properly guarded
// it so let's obey this one for now
@@ -9,7 +9,7 @@ static void write_phys(unsigned long addr, unsigned long value)
"movnti %1, (%0)"
: /* outputs */
: "r" (addr), "r" (value) /* inputs */
-#ifndef __GNUC__
+#ifndef __GNUC__ /* GCC does not like empty clobbers? */
: /* clobbers */
#endif
);
@@ -20,13 +20,31 @@ static void write_phys(unsigned long addr, unsigned long value)
#endif
}
-static unsigned long read_phys(unsigned long addr)
+static u32 read_phys(unsigned long addr)
{
volatile unsigned long *ptr;
ptr = (void *)addr;
return *ptr;
}
+static void phys_memory_barrier(void)
+{
+#if CONFIG_SSE2
+ // Needed for movnti
+ asm volatile (
+ "sfence"
+ ::
+#ifdef __GNUC__ /* ROMCC does not like memory clobbers */
+ : "memory"
+#endif
+ );
+#else
+#ifdef __GNUC__ /* ROMCC does not like empty asm statements */
+ asm volatile ("" ::: "memory");
+#endif
+#endif
+}
+
static void ram_fill(unsigned long start, unsigned long stop)
{
unsigned long addr;
@@ -52,12 +70,8 @@ static void ram_fill(unsigned long start, unsigned long stop)
print_debug(" \r");
#endif
}
- write_phys(addr, addr);
+ write_phys(addr, (u32)addr);
};
-#if CONFIG_SSE2
- // Needed for movnti
- asm volatile ("sfence" ::: "memory");
-#endif
/* Display final address */
#if CONFIG_USE_PRINTK_IN_CAR
printk(BIOS_DEBUG, "%08lx\r\nDRAM filled\r\n", addr);
@@ -159,6 +173,8 @@ void ram_check(unsigned long start, unsigned long stop)
print_debug("\r\n");
#endif
ram_fill(start, stop);
+ /* Make sure we don't read before we wrote */
+ phys_memory_barrier();
ram_verify(start, stop);
#if CONFIG_USE_PRINTK_IN_CAR
printk(BIOS_DEBUG, "Done.\r\n");
@@ -167,3 +183,33 @@ void ram_check(unsigned long start, unsigned long stop)
#endif
}
+void quick_ram_check(void)
+{
+ int fail = 0;
+ u32 backup;
+ backup = read_phys(CONFIG_RAMBASE);
+ write_phys(CONFIG_RAMBASE, 0x55555555);
+ phys_memory_barrier();
+ if (read_phys(CONFIG_RAMBASE) != 0x55555555)
+ fail=1;
+ write_phys(CONFIG_RAMBASE, 0xaaaaaaaa);
+ phys_memory_barrier();
+ if (read_phys(CONFIG_RAMBASE) != 0xaaaaaaaa)
+ fail=1;
+ write_phys(CONFIG_RAMBASE, 0x00000000);
+ phys_memory_barrier();
+ if (read_phys(CONFIG_RAMBASE) != 0x00000000)
+ fail=1;
+ write_phys(CONFIG_RAMBASE, 0xffffffff);
+ phys_memory_barrier();
+ if (read_phys(CONFIG_RAMBASE) != 0xffffffff)
+ fail=1;
+
+ write_phys(CONFIG_RAMBASE, backup);
+ if (fail) {
+ post_code(0xea);
+ die("RAM INIT FAILURE!\n");
+ }
+ phys_memory_barrier();
+}
+
diff --git a/src/mainboard/kontron/986lcd-m/romstage.c b/src/mainboard/kontron/986lcd-m/romstage.c
index 939862a3ee..f5e9f6e55c 100644
--- a/src/mainboard/kontron/986lcd-m/romstage.c
+++ b/src/mainboard/kontron/986lcd-m/romstage.c
@@ -455,6 +455,8 @@ void real_main(unsigned long bist)
#endif
#endif
+ quick_ram_check();
+
MCHBAR16(SSKPD) = 0xCAFE;
#if CONFIG_HAVE_ACPI_RESUME