riscv/mb/qemu: fix DRAM probing

Current version of qemu raise an exception when accessing invalid
memory.  Modify the probing code to temporary redirect the exception
handler like on ARM platform.
Also move saving of the stack frame out to trap_util.S to have all at
the same place for a future rewrite.

TEST=boots to ramstage
Change-Id: I25860f688c7546714f6fdbce8c8f96da6400813c
Signed-off-by: Philipp Hug <philipp@hug.cx>
Signed-off-by: Arthur Heymans <arthur@aheymans.xyz>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/36486
Reviewed-by: ron minnich <rminnich@gmail.com>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Philipp Hug
2024-03-01 10:59:56 +00:00
committed by ron minnich
parent f3ae0f0cfb
commit 8e365396d4
7 changed files with 93 additions and 23 deletions

View File

@@ -11,15 +11,12 @@
int __weak probe_mb(const uintptr_t dram_start, const uintptr_t size)
{
uintptr_t addr = dram_start + (size * MiB) - sizeof(uint32_t);
static const uint32_t patterns[] = {
0x55aa55aa,
0x12345678
};
void *ptr = (void *) addr;
static const uint32_t patterns[] = {0x55aa55aa, 0x12345678};
void *ptr = (void *)addr;
size_t i;
/* Don't accidentally clobber oneself. */
if (OVERLAP(addr, addr + sizeof(uint32_t), (uintptr_t)_program, (uintptr_t) _eprogram))
if (OVERLAP(addr, addr + sizeof(uint32_t), (uintptr_t)_program, (uintptr_t)_eprogram))
return 1;
uint32_t old = read32(ptr);