From 09bf8a5f890130ef5d8775c0c65f9709466ad9fa Mon Sep 17 00:00:00 2001 From: Eero Nurkkala Date: Fri, 14 Jan 2022 09:38:16 +0200 Subject: [PATCH] risc-v/mpfs: mpfs_opensbi: fix fw_size calculation fw_start and fw_size were miscalculated. What was needed was the pointed values of the offsets __mpfs_nuttx_start and __mpfs_nuttx_end, not the values they had in place. Also add the next_arg1 initialization. Signed-off-by: Eero Nurkkala --- arch/risc-v/src/mpfs/mpfs_opensbi.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/arch/risc-v/src/mpfs/mpfs_opensbi.c b/arch/risc-v/src/mpfs/mpfs_opensbi.c index ba874f4452d..bbd6a6aa7f0 100644 --- a/arch/risc-v/src/mpfs/mpfs_opensbi.c +++ b/arch/risc-v/src/mpfs/mpfs_opensbi.c @@ -453,8 +453,11 @@ static void mpfs_opensbi_scratch_setup(uint32_t hartid) * them so that OpenSBI has no chance override then. */ - g_scratches[hartid].scratch.fw_start = __mpfs_nuttx_start; - g_scratches[hartid].scratch.fw_size = __mpfs_nuttx_end; + g_scratches[hartid].scratch.fw_start = (unsigned long)&__mpfs_nuttx_start; + g_scratches[hartid].scratch.fw_size = (unsigned long)&__mpfs_nuttx_end - + (unsigned long)&__mpfs_nuttx_start; + + DEBUGASSERT(g_scratches[hartid].scratch.fw_size > 0); } /**************************************************************************** @@ -516,6 +519,7 @@ void __attribute__((noreturn)) mpfs_opensbi_setup(void) csr_write(mscratch, &g_scratches[hartid].scratch); g_scratches[hartid].scratch.next_mode = PRV_S; g_scratches[hartid].scratch.next_addr = UBOOT_LOAD_ADDR; + g_scratches[hartid].scratch.next_arg1 = 0; sbi_init(&g_scratches[hartid].scratch);