[U-Boot] [PATCH 4/5] nios2: initialize stack earlier in startup
Thomas Chou
thomas at wytron.com.tw
Fri Sep 4 05:15:25 CEST 2015
This patch reorders the startup sequence, and initializes stack
earlier. So that we can call external functions after stack
initialized.
We will add OF control and use separated dtb. As dtb is located at
the end of u-boot-dtb.bin image, we will need to relocate it before
zeroing the bss. It will be easier to handle fdt in C than ASM.
Signed-off-by: Thomas Chou <thomas at wytron.com.tw>
---
arch/nios2/cpu/start.S | 45 ++++++++++++++++++++++-----------------------
1 file changed, 22 insertions(+), 23 deletions(-)
diff --git a/arch/nios2/cpu/start.S b/arch/nios2/cpu/start.S
index 6af9b4e..dde80f7 100644
--- a/arch/nios2/cpu/start.S
+++ b/arch/nios2/cpu/start.S
@@ -68,7 +68,7 @@ _except_end:
_cur: movhi r5, %hi(_cur - _start)
ori r5, r5, %lo(_cur - _start)
sub r4, r4, r5 /* r4 <- cur _start */
- mov r8, r4
+ mov r8, r4 /* r8 <- cur _start */
movhi r5, %hi(_start)
ori r5, r5, %lo(_start) /* r5 <- linked _start */
beq r4, r5, 3f
@@ -82,26 +82,34 @@ _cur: movhi r5, %hi(_cur - _start)
bne r5, r6, 2b
3:
+ /* JUMP TO RELOC ADDR */
+ movhi r4, %hi(_reloc)
+ ori r4, r4, %lo(_reloc)
+ jmp r4
+_reloc:
+
+ /* STACK INIT -- zero top two words for call back chain. */
+ movhi sp, %hi(CONFIG_SYS_INIT_SP)
+ ori sp, sp, %lo(CONFIG_SYS_INIT_SP)
+ addi sp, sp, -8
+ stw r0, 0(sp)
+ stw r0, 4(sp)
+ mov fp, sp
+
/* ZERO BSS/SBSS -- bss and sbss are assumed to be adjacent
* and between __bss_start and __bss_end.
*/
- movhi r5, %hi(__bss_start)
- ori r5, r5, %lo(__bss_start)
- movhi r6, %hi(__bss_end)
- ori r6, r6, %lo(__bss_end)
- beq r5, r6, 5f
+ movhi r5, %hi(__bss_start)
+ ori r5, r5, %lo(__bss_start)
+ movhi r6, %hi(__bss_end)
+ ori r6, r6, %lo(__bss_end)
+ beq r5, r6, 5f
4: stwio r0, 0(r5)
- addi r5, r5, 4
- bne r5, r6, 4b
+ addi r5, r5, 4
+ bne r5, r6, 4b
5:
- /* JUMP TO RELOC ADDR */
- movhi r4, %hi(_reloc)
- ori r4, r4, %lo(_reloc)
- jmp r4
-_reloc:
-
/* COPY EXCEPTION TRAMPOLINE -- copy the tramp to the
* exception address. Define CONFIG_ROM_STUBS to prevent
* the copy (e.g. exception in flash or in other
@@ -124,15 +132,6 @@ _reloc:
7:
#endif
- /* STACK INIT -- zero top two words for call back chain.
- */
- movhi sp, %hi(CONFIG_SYS_INIT_SP)
- ori sp, sp, %lo(CONFIG_SYS_INIT_SP)
- addi sp, sp, -8
- stw r0, 0(sp)
- stw r0, 4(sp)
- mov fp, sp
-
/*
* Call board_init_f -- never returns
*/
--
2.1.4
More information about the U-Boot
mailing list