firmware: Reset all registers and flush icache
authorAtish Patra <atish.patra@wdc.com>
Wed, 6 Mar 2019 23:18:29 +0000 (15:18 -0800)
committerAnup Patel <anup@brainfault.org>
Thu, 7 Mar 2019 02:37:18 +0000 (08:07 +0530)
A warm reset using reset button may put icache and registers
in non-coherent state.

Flush the icache and reset all registers for every hart.

Signed-off-by: Atish Patra <atish.patra@wdc.com>
firmware/fw_base.S

index dccaef1..cf2c6a0 100644 (file)
@@ -25,6 +25,8 @@ _start:
        csrr    a6, CSR_MHARTID
        blt     zero, a6, _wait_for_boot_hart
 
+       li      ra, 0
+       call    _reset_regs
        /* Zero-out BSS */
        la      a4, _bss_start
        la      a5, _bss_end
@@ -392,6 +394,8 @@ _trap_handler_all_mode:
        .globl _reset_regs
 _reset_regs:
 
+       /* flush the instruction cache */
+       fence.i
        /* Reset all registers except ra, a0,a1 */
        li sp, 0
        li gp, 0