summaryrefslogtreecommitdiff
path: root/firmware
diff options
context:
space:
mode:
authorAnup Patel <anup.patel@wdc.com>2020-04-26 12:01:28 +0300
committerAnup Patel <anup@brainfault.org>2020-05-01 08:03:02 +0300
commit4d063538f0493916dc6263276c4c84f31446db41 (patch)
treeb5dfda0139ca79e3da7b16e84100e8ad74352f01 /firmware
parent7cc6fa4d8a65e08048e1dd469087805ce89bf306 (diff)
downloadopensbi-4d063538f0493916dc6263276c4c84f31446db41.tar.xz
firmware: fw_base: Introduce optional fw_platform_init()
We add optional fw_platform_init() function which will allow platform specific code to update "struct sbi_platform platform" before it is used. The fw_platform_init() can be a regular C function so before callint it we: 1. zero-out BSS section 2. Setup temporary trap handler to catch bugs 3. Setup temporary stack pointer Signed-off-by: Anup Patel <anup.patel@wdc.com> Reviewed-by: Atish Patra <atish.patra@wdc.com>
Diffstat (limited to 'firmware')
-rw-r--r--firmware/fw_base.S41
1 files changed, 33 insertions, 8 deletions
diff --git a/firmware/fw_base.S b/firmware/fw_base.S
index 07edc74..5cb0dfa 100644
--- a/firmware/fw_base.S
+++ b/firmware/fw_base.S
@@ -160,6 +160,32 @@ _relocate_done:
li ra, 0
call _reset_regs
+ /* Zero-out BSS */
+ la s4, _bss_start
+ la s5, _bss_end
+_bss_zero:
+ REG_S zero, (s4)
+ add s4, s4, __SIZEOF_POINTER__
+ blt s4, s5, _bss_zero
+
+ /* Setup temporary trap handler */
+ la s4, _start_hang
+ csrw CSR_MTVEC, s4
+
+ /* Setup temporary stack */
+ la s4, _fw_end
+ li s5, (SBI_SCRATCH_SIZE * 2)
+ add sp, s4, s5
+
+ /*
+ * Initialize platform
+ * Note: The a0 to a4 registers passed to the
+ * firmware are parameters to this function.
+ */
+ MOV_5R s0, a0, s1, a1, s2, a2, s3, a3, s4, a4
+ call fw_platform_init
+ MOV_5R a0, s0, a1, s1, a2, s2, a3, s3, a4, s4
+
/* Allow main firmware to save info */
MOV_5R s0, a0, s1, a1, s2, a2, s3, a3, s4, a4
call fw_save_info
@@ -245,14 +271,6 @@ _scratch_init:
add t1, t1, t2
blt t1, s7, _scratch_init
- /* Zero-out BSS */
- la a4, _bss_start
- la a5, _bss_end
-_bss_zero:
- REG_S zero, (a4)
- add a4, a4, __SIZEOF_POINTER__
- blt a4, a5, _bss_zero
-
/* Override pervious arg1 */
MOV_3R s0, a0, s1, a1, s2, a2
call fw_prev_arg1
@@ -456,6 +474,13 @@ _start_hang:
.section .entry, "ax", %progbits
.align 3
+ .globl fw_platform_init
+ .weak fw_platform_init
+fw_platform_init:
+ ret
+
+ .section .entry, "ax", %progbits
+ .align 3
.globl _trap_handler
_trap_handler:
/* Swap TP and MSCRATCH */