[coreboot] [commit] r5309 - in trunk/src: lib mainboard/kontron/986lcd-m

repository service svn at coreboot.org
Sun Mar 28 23:31:31 CEST 2010


Author: stepan
Date: Sun Mar 28 23:31:30 2010
New Revision: 5309
URL: https://tracker.coreboot.org/trac/coreboot/changeset/5309

Log:
Add a non-time consuming version of ram check so we can print a decent error
rather than looping on non-working ram.

Signed-off-by: Stefan Reinauer <stepan at coresystems.de>
Acked-by: Stefan Reinauer <stepan at coresystems.de>

Modified:
   trunk/src/lib/ramtest.c
   trunk/src/mainboard/kontron/986lcd-m/romstage.c

Modified: trunk/src/lib/ramtest.c
==============================================================================
--- trunk/src/lib/ramtest.c	Sun Mar 28 23:30:23 2010	(r5308)
+++ trunk/src/lib/ramtest.c	Sun Mar 28 23:31:30 2010	(r5309)
@@ -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 @@
 		"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 @@
 #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 @@
 			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 @@
 	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 @@
 #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();
+}
+

Modified: trunk/src/mainboard/kontron/986lcd-m/romstage.c
==============================================================================
--- trunk/src/mainboard/kontron/986lcd-m/romstage.c	Sun Mar 28 23:30:23 2010	(r5308)
+++ trunk/src/mainboard/kontron/986lcd-m/romstage.c	Sun Mar 28 23:31:30 2010	(r5309)
@@ -455,6 +455,8 @@
 #endif
 #endif
 
+	quick_ram_check();
+
 	MCHBAR16(SSKPD) = 0xCAFE;
 
 #if CONFIG_HAVE_ACPI_RESUME




More information about the coreboot mailing list