aboutsummaryrefslogtreecommitdiff
path: root/src/arch/riscv/boot.c
diff options
context:
space:
mode:
authorXiang Wang <wxjstz@126.com>2018-07-19 17:35:39 +0800
committerron minnich <rminnich@gmail.com>2019-02-02 16:53:21 +0000
commit820dcfceb3901dbb00bb90c876e374126ca14e20 (patch)
tree2f0ba3f1038291f9dda7755680551cbe425f7922 /src/arch/riscv/boot.c
parentc47d43a8af5dfdbdb7afebb39f999f18f36c9d23 (diff)
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 <wxjstz@126.com> Signed-off-by: Philipp Hug <philipp@hug.cx> Reviewed-on: https://review.coreboot.org/c/31179 Reviewed-by: ron minnich <rminnich@gmail.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Diffstat (limited to 'src/arch/riscv/boot.c')
-rw-r--r--src/arch/riscv/boot.c31
1 files changed, 17 insertions, 14 deletions
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 <arch/encoding.h>
#include <console/console.h>
#include <arch/smp/smp.h>
+#include <mcall.h>
/*
* 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)