From 820dcfceb3901dbb00bb90c876e374126ca14e20 Mon Sep 17 00:00:00 2001 From: Xiang Wang Date: Thu, 19 Jul 2018 17:35:39 +0800 Subject: riscv: Simplify payload handling 1. Simplify payload code and convert it to C 2. Save the FDT pointer to HLS (hart-local storage). 3. Don't use mscratch to pass FDT pointer as it is used for exception handling. Change-Id: I32bf2a99e07a65358a7f19b899259f0816eb45e8 Signed-off-by: Xiang Wang Signed-off-by: Philipp Hug Reviewed-on: https://review.coreboot.org/c/31179 Reviewed-by: ron minnich Tested-by: build bot (Jenkins) --- src/arch/riscv/boot.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) (limited to 'src/arch/riscv/boot.c') diff --git a/src/arch/riscv/boot.c b/src/arch/riscv/boot.c index 3d8d5d623e..29064b1dc1 100644 --- a/src/arch/riscv/boot.c +++ b/src/arch/riscv/boot.c @@ -19,6 +19,7 @@ #include #include #include +#include /* * A pointer to the Flattened Device Tree passed to coreboot by the boot ROM. @@ -26,27 +27,29 @@ * * This pointer is only used in ramstage! */ -const void *rom_fdt; static void do_arch_prog_run(struct prog *prog) { - void (*doit)(void *) = prog_entry(prog); - void riscvpayload(const void *fdt, void *payload); + void (*doit)(int hart_id, void *fdt); + int hart_id; + void *fdt = prog_entry_arg(prog); + + /* + * If prog_entry_arg is not set (e.g. by fit_payload), use fdt from HLS + * instead. + */ + if (fdt == NULL) + fdt = HLS()->fdt; if (ENV_RAMSTAGE && prog_type(prog) == PROG_PAYLOAD) { - /* - * FIXME: This is wrong and will crash. Linux can't (in early - * boot) access memory that's before its own loading address. - * We need to copy the FDT to a place where Linux can access it. - */ - const void *fdt = rom_fdt; - - printk(BIOS_SPEW, "FDT is at %p\n", fdt); - printk(BIOS_SPEW, "OK, let's go\n"); - riscvpayload(fdt, doit); + run_payload(prog, fdt, RISCV_PAYLOAD_MODE_S); + return; } - doit(prog_entry_arg(prog)); + doit = prog_entry(prog); + hart_id = HLS()->hart_id; + + doit(hart_id, fdt); } void arch_prog_run(struct prog *prog) -- cgit v1.2.3