aboutsummaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorLukas Auer <lukas.auer@aisec.fraunhofer.de>2019-08-21 21:14:46 +0200
committerAndes <uboot@andestech.com>2019-08-26 16:07:42 +0800
commitc7e1effb965a3ec7e33d8e83925f04636771c91b (patch)
treee920dd7c9b36439ca6693967204d736040ac583b /arch
parent8c59f2023cc8d4ab32b3988193ff2eb116df5995 (diff)
downloadu-boot-c7e1effb965a3ec7e33d8e83925f04636771c91b.zip
u-boot-c7e1effb965a3ec7e33d8e83925f04636771c91b.tar.gz
u-boot-c7e1effb965a3ec7e33d8e83925f04636771c91b.tar.bz2
riscv: support SPL stack and global data relocation
To support relocation of the stack and global data on RISC-V, the secondary harts must be notified of the change using IPIs. We can reuse the hart relocation code for this purpose. It uses global data to store the new stack pointer and global data pointer for the secondary harts. This means that we cannot update the global data pointer of the main hart in spl_relocate_stack_gd(), because the secondary harts have not yet been relocated at this point. It is updated after the secondary harts have been notified. Signed-off-by: Lukas Auer <lukas.auer@aisec.fraunhofer.de> Reviewed-by: Bin Meng <bmeng.cn@gmail.com> Tested-by: Bin Meng <bmeng.cn@gmail.com> Reviewed-by: Anup Patel <anup.patel@wdc.com>
Diffstat (limited to 'arch')
-rw-r--r--arch/riscv/cpu/start.S35
1 files changed, 34 insertions, 1 deletions
diff --git a/arch/riscv/cpu/start.S b/arch/riscv/cpu/start.S
index 66c6039..b15209d 100644
--- a/arch/riscv/cpu/start.S
+++ b/arch/riscv/cpu/start.S
@@ -169,13 +169,46 @@ wait_for_gd_init:
spl_clear_bss:
la t0, __bss_start
la t1, __bss_end
- beq t0, t1, spl_call_board_init_r
+ beq t0, t1, spl_stack_gd_setup
spl_clear_bss_loop:
SREG zero, 0(t0)
addi t0, t0, REGBYTES
bne t0, t1, spl_clear_bss_loop
+spl_stack_gd_setup:
+ jal spl_relocate_stack_gd
+
+ /* skip setup if we did not relocate */
+ beqz a0, spl_call_board_init_r
+ mv s0, a0
+
+ /* setup stack on main hart */
+#ifdef CONFIG_SMP
+ /* tp: hart id */
+ slli t0, tp, CONFIG_STACK_SIZE_SHIFT
+ sub sp, s0, t0
+#else
+ mv sp, s0
+#endif
+
+ /* set new stack and global data pointer on secondary harts */
+spl_secondary_hart_stack_gd_setup:
+ la a0, secondary_hart_relocate
+ mv a1, s0
+ mv a2, s0
+ jal smp_call_function
+
+ /* hang if relocation of secondary harts has failed */
+ beqz a0, 1f
+ mv a1, a0
+ la a0, secondary_harts_relocation_error
+ jal printf
+ jal hang
+
+ /* set new global data pointer on main hart */
+1: mv gp, s0
+
spl_call_board_init_r:
mv a0, zero
mv a1, zero