summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Documentation/arch/riscv/index.md3
-rw-r--r--src/arch/riscv/Kconfig1
-rw-r--r--src/arch/riscv/boot.c9
-rw-r--r--src/arch/riscv/ramstage.S7
4 files changed, 14 insertions, 6 deletions
diff --git a/Documentation/arch/riscv/index.md b/Documentation/arch/riscv/index.md
index ea6a5cd47e07..e0d37f591c0d 100644
--- a/Documentation/arch/riscv/index.md
+++ b/Documentation/arch/riscv/index.md
@@ -19,6 +19,9 @@ On entry to a stage or payload (including SELF payloads),
* all harts are running.
* A0 is the hart ID.
* A1 is the pointer to the Flattened Device Tree (FDT).
+* A2 contains the additional program calling argument:
+ - cbmem_top for ramstage
+ - the address of the payload for opensbi
## Additional payload handoff requirements
The location of cbmem should be placed in a node in the FDT.
diff --git a/src/arch/riscv/Kconfig b/src/arch/riscv/Kconfig
index f2ca571c97ca..9ee781b4f07d 100644
--- a/src/arch/riscv/Kconfig
+++ b/src/arch/riscv/Kconfig
@@ -90,6 +90,7 @@ config ARCH_ROMSTAGE_RISCV
config ARCH_RAMSTAGE_RISCV
bool
default n
+ select RAMSTAGE_CBMEM_TOP_ARG
config RISCV_USE_ARCH_TIMER
bool
diff --git a/src/arch/riscv/boot.c b/src/arch/riscv/boot.c
index d3ae693376aa..aaaac485ead8 100644
--- a/src/arch/riscv/boot.c
+++ b/src/arch/riscv/boot.c
@@ -36,7 +36,7 @@ struct arch_prog_run_args {
static void do_arch_prog_run(struct arch_prog_run_args *args)
{
- int hart_id;
+ int hart_id = HLS()->hart_id;
struct prog *prog = args->prog;
void *fdt = HLS()->fdt;
@@ -49,11 +49,8 @@ static void do_arch_prog_run(struct arch_prog_run_args *args)
else
run_payload(prog, fdt, RISCV_PAYLOAD_MODE_S);
} else {
- void (*doit)(int hart_id, void *fdt) = prog_entry(prog);
-
- hart_id = HLS()->hart_id;
-
- doit(hart_id, fdt);
+ void (*doit)(int hart_id, void *fdt, void *arg) = prog_entry(prog);
+ doit(hart_id, fdt, prog_entry_arg(prog));
}
die("Failed to run stage");
diff --git a/src/arch/riscv/ramstage.S b/src/arch/riscv/ramstage.S
index 28183e50e0dd..2468c231bcb3 100644
--- a/src/arch/riscv/ramstage.S
+++ b/src/arch/riscv/ramstage.S
@@ -20,6 +20,13 @@
.section ".text._start", "ax", %progbits
.globl _start
_start:
+ /* cbmem_top is passed via a2 */
+ la t0, _cbmem_top_ptr
+#if __riscv_xlen == 32
+ sw a2, (t0)
+#elif __riscv_xlen == 64
+ sd a2, (t0)
+#endif
# initialize stack point for each hart
# and the stack must be page-aligned.
# 0xDEADBEEF used to check stack overflow