lib: add ram_check_nodie

The current implementation calls die() if memory checking fails.
This isn't always what we want: one might want to print error registers,
or do some other error handling. Introduce ram_check_nodie() for that
reason. It returns 0 if ram check succeeded, otherwise 1.

Change-Id: Ib9a9279120755cf63b5b3ba5e0646492c3c29ac2
Signed-off-by: Sven Schnelle <svens@stackframe.org>
Reviewed-on: http://review.coreboot.org/532
Tested-by: build bot (Jenkins)
Reviewed-by: Ronald G. Minnich <rminnich@gmail.com>
This commit is contained in:
Sven Schnelle 2011-12-02 16:23:06 +01:00
parent 5db45b4d4a
commit 3ad8c54c01
2 changed files with 38 additions and 3 deletions

View File

@ -37,6 +37,7 @@ void move_gdt(void);
/* Defined in src/lib/ramtest.c */ /* Defined in src/lib/ramtest.c */
void ram_check(unsigned long start, unsigned long stop); void ram_check(unsigned long start, unsigned long stop);
int ram_check_nodie(unsigned long start, unsigned long stop);
void quick_ram_check(void); void quick_ram_check(void);
/* Defined in romstage.c */ /* Defined in romstage.c */

View File

@ -83,7 +83,7 @@ static void ram_fill(unsigned long start, unsigned long stop)
#endif #endif
} }
static void ram_verify(unsigned long start, unsigned long stop) static int ram_verify_nodie(unsigned long start, unsigned long stop)
{ {
unsigned long addr; unsigned long addr;
int i = 0; int i = 0;
@ -146,15 +146,17 @@ static void ram_verify(unsigned long start, unsigned long stop)
#else #else
print_debug("\nDRAM did _NOT_ verify!\n"); print_debug("\nDRAM did _NOT_ verify!\n");
#endif #endif
die("DRAM ERROR"); return 1;
} }
else { else {
#if !defined(__ROMCC__) #if !defined(__ROMCC__)
printk(BIOS_DEBUG, "\nDRAM range verified.\n"); printk(BIOS_DEBUG, "\nDRAM range verified.\n");
#else #else
print_debug("\nDRAM range verified.\n"); print_debug("\nDRAM range verified.\n");
return 0;
#endif #endif
} }
return 0;
} }
@ -177,7 +179,8 @@ void ram_check(unsigned long start, unsigned long stop)
ram_fill(start, stop); ram_fill(start, stop);
/* Make sure we don't read before we wrote */ /* Make sure we don't read before we wrote */
phys_memory_barrier(); phys_memory_barrier();
ram_verify(start, stop); if (ram_verify_nodie(start, stop))
die("DRAM ERROR");
#if !defined(__ROMCC__) #if !defined(__ROMCC__)
printk(BIOS_DEBUG, "Done.\n"); printk(BIOS_DEBUG, "Done.\n");
#else #else
@ -185,6 +188,37 @@ void ram_check(unsigned long start, unsigned long stop)
#endif #endif
} }
int ram_check_nodie(unsigned long start, unsigned long stop)
{
int ret;
/*
* This is much more of a "Is my DRAM properly configured?"
* test than a "Is my DRAM faulty?" test. Not all bits
* are tested. -Tyson
*/
#if !defined(__ROMCC__)
printk(BIOS_DEBUG, "Testing DRAM : %08lx - %08lx\n", start, stop);
#else
print_debug("Testing DRAM : ");
print_debug_hex32(start);
print_debug("-");
print_debug_hex32(stop);
print_debug("\n");
#endif
ram_fill(start, stop);
/* Make sure we don't read before we wrote */
phys_memory_barrier();
ret = ram_verify_nodie(start, stop);
#if !defined(__ROMCC__)
printk(BIOS_DEBUG, "Done.\n");
#else
print_debug("Done.\n");
#endif
return ret;
}
void quick_ram_check(void) void quick_ram_check(void)
{ {
int fail = 0; int fail = 0;