diff options
author | Kyösti Mälkki <kyosti.malkki@gmail.com> | 2019-03-20 19:53:44 +0200 |
---|---|---|
committer | Patrick Georgi <pgeorgi@google.com> | 2019-03-22 12:19:47 +0000 |
commit | 321bce4a3f472cfcd1f9af12e0204f6648ce499e (patch) | |
tree | 748ec4ac9ae5484fb006e87fd95c68e170fc1e6d /src | |
parent | a9506dbaf410d9b2d297661f51f0e0b9842170e1 (diff) | |
download | coreboot-321bce4a3f472cfcd1f9af12e0204f6648ce499e.tar.xz |
lib/ramtest.c: Make it a bit more arch-agnostic
Change-Id: I05734515c0bbd043d489c76cf9cf8b2dbe0ff515
Signed-off-by: Kyösti Mälkki <kyosti.malkki@gmail.com>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/31994
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Reviewed-by: Patrick Georgi <pgeorgi@google.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/lib/Makefile.inc | 2 | ||||
-rw-r--r-- | src/lib/ramtest.c | 49 |
2 files changed, 20 insertions, 31 deletions
diff --git a/src/lib/Makefile.inc b/src/lib/Makefile.inc index 70bbece49d..1350152a40 100644 --- a/src/lib/Makefile.inc +++ b/src/lib/Makefile.inc @@ -83,7 +83,7 @@ romstage-y += libgcc.c romstage-y += memrange.c romstage-$(CONFIG_PRIMITIVE_MEMTEST) += primitive_memtest.c ramstage-$(CONFIG_PRIMITIVE_MEMTEST) += primitive_memtest.c -romstage-$(CONFIG_CACHE_AS_RAM) += ramtest.c +romstage-y += ramtest.c romstage-$(CONFIG_GENERIC_GPIO_LIB) += gpio.c ramstage-y += region_file.c romstage-y += region_file.c diff --git a/src/lib/ramtest.c b/src/lib/ramtest.c index f0f5c556a6..eb58c30fe5 100644 --- a/src/lib/ramtest.c +++ b/src/lib/ramtest.c @@ -1,50 +1,39 @@ #include <stdint.h> #include <lib.h> /* Prototypes */ #include <console/console.h> +#include <device/mmio.h> -static void write_phys(unsigned long addr, u32 value) +#if CONFIG(ARCH_X86) && CONFIG(SSE2) +/* Assembler in lib/ is ugly. */ +static void write_phys(uintptr_t addr, u32 value) { - // Assembler in lib/ is very ugly. But we properly guarded - // it so let's obey this one for now -#if CONFIG(SSE2) - asm volatile( + asm volatile ( "movnti %1, (%0)" : /* outputs */ : "r" (addr), "r" (value) /* inputs */ -#ifndef __GNUC__ /* GCC does not like empty clobbers? */ - : /* clobbers */ -#endif - ); -#else - volatile unsigned long *ptr; - ptr = (void *)addr; - *ptr = value; -#endif + ); } -static u32 read_phys(unsigned long addr) +static void phys_memory_barrier(void) +{ + // Needed for movnti + asm volatile ("sfence" ::: "memory"); +} +#else +static void write_phys(uintptr_t addr, u32 value) { - volatile unsigned long *ptr; - ptr = (void *)addr; - return *ptr; + write32((void *)addr, value); } 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 u32 read_phys(uintptr_t addr) +{ + return read32((void *)addr); } /** |