arch/riscv: Pass cbmem_top to ramstage via calling argument

Tested on the Qemu-Virt target both 32 and 64 bit.

Change-Id: I5c74cd5d3ee292931c5bbd2e4075f88381429f72
Signed-off-by: Arthur Heymans <arthur@aheymans.xyz>
Reviewed-on: https://review.coreboot.org/c/coreboot/+/36558
Reviewed-by: Nico Huber <nico.h@gmx.de>
Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
Arthur Heymans 2019-11-01 21:53:36 +01:00 committed by Nico Huber
parent 7f22933e98
commit 55069d15d8
4 changed files with 14 additions and 6 deletions

View File

@ -19,6 +19,9 @@ On entry to a stage or payload (including SELF payloads),
* all harts are running. * all harts are running.
* A0 is the hart ID. * A0 is the hart ID.
* A1 is the pointer to the Flattened Device Tree (FDT). * 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 ## Additional payload handoff requirements
The location of cbmem should be placed in a node in the FDT. The location of cbmem should be placed in a node in the FDT.

View File

@ -90,6 +90,7 @@ config ARCH_ROMSTAGE_RISCV
config ARCH_RAMSTAGE_RISCV config ARCH_RAMSTAGE_RISCV
bool bool
default n default n
select RAMSTAGE_CBMEM_TOP_ARG
config RISCV_USE_ARCH_TIMER config RISCV_USE_ARCH_TIMER
bool bool

View File

@ -36,7 +36,7 @@ struct arch_prog_run_args {
static void do_arch_prog_run(struct arch_prog_run_args *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; struct prog *prog = args->prog;
void *fdt = HLS()->fdt; void *fdt = HLS()->fdt;
@ -49,11 +49,8 @@ static void do_arch_prog_run(struct arch_prog_run_args *args)
else else
run_payload(prog, fdt, RISCV_PAYLOAD_MODE_S); run_payload(prog, fdt, RISCV_PAYLOAD_MODE_S);
} else { } else {
void (*doit)(int hart_id, void *fdt) = prog_entry(prog); void (*doit)(int hart_id, void *fdt, void *arg) = prog_entry(prog);
doit(hart_id, fdt, prog_entry_arg(prog));
hart_id = HLS()->hart_id;
doit(hart_id, fdt);
} }
die("Failed to run stage"); die("Failed to run stage");

View File

@ -20,6 +20,13 @@
.section ".text._start", "ax", %progbits .section ".text._start", "ax", %progbits
.globl _start .globl _start
_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 # initialize stack point for each hart
# and the stack must be page-aligned. # and the stack must be page-aligned.
# 0xDEADBEEF used to check stack overflow # 0xDEADBEEF used to check stack overflow