Skip to content
Snippets Groups Projects
Commit c3e72ab8 authored by Daniel Schwierzeck's avatar Daniel Schwierzeck
Browse files

MIPS: factor out code for initial stack and global data


Move the code for setting up the initial stack and global data
to a macro to be able to use it more than once.

Signed-off-by: default avatarDaniel Schwierzeck <daniel.schwierzeck@gmail.com>
parent 65d297af
No related branches found
No related tags found
No related merge requests found
...@@ -52,6 +52,34 @@ ...@@ -52,6 +52,34 @@
sdbbp 1 # Invoke UHI operation sdbbp 1 # Invoke UHI operation
.endm .endm
.macro setup_stack_gd
li t0, -16
PTR_LI t1, CONFIG_SYS_INIT_SP_ADDR
and sp, t1, t0 # force 16 byte alignment
PTR_SUBU \
sp, sp, GD_SIZE # reserve space for gd
and sp, sp, t0 # force 16 byte alignment
move k0, sp # save gd pointer
#ifdef CONFIG_SYS_MALLOC_F_LEN
li t2, CONFIG_SYS_MALLOC_F_LEN
PTR_SUBU \
sp, sp, t2 # reserve space for early malloc
and sp, sp, t0 # force 16 byte alignment
#endif
move fp, sp
/* Clear gd */
move t0, k0
1:
PTR_S zero, 0(t0)
blt t0, t1, 1b
PTR_ADDIU t0, PTRSIZE
#ifdef CONFIG_SYS_MALLOC_F_LEN
PTR_S sp, GD_MALLOC_BASE(k0) # gd->malloc_base offset
#endif
.endm
ENTRY(_start) ENTRY(_start)
/* U-Boot entry point */ /* U-Boot entry point */
b reset b reset
...@@ -227,32 +255,8 @@ wr_done: ...@@ -227,32 +255,8 @@ wr_done:
# endif # endif
#endif #endif
/* Set up temporary stack */ /* Set up initial stack and global data */
li t0, -16 setup_stack_gd
PTR_LI t1, CONFIG_SYS_INIT_SP_ADDR
and sp, t1, t0 # force 16 byte alignment
PTR_SUBU \
sp, sp, GD_SIZE # reserve space for gd
and sp, sp, t0 # force 16 byte alignment
move k0, sp # save gd pointer
#ifdef CONFIG_SYS_MALLOC_F_LEN
li t2, CONFIG_SYS_MALLOC_F_LEN
PTR_SUBU \
sp, sp, t2 # reserve space for early malloc
and sp, sp, t0 # force 16 byte alignment
#endif
move fp, sp
/* Clear gd */
move t0, k0
1:
PTR_S zero, 0(t0)
blt t0, t1, 1b
PTR_ADDIU t0, PTRSIZE
#ifdef CONFIG_SYS_MALLOC_F_LEN
PTR_S sp, GD_MALLOC_BASE(k0) # gd->malloc_base offset
#endif
move a0, zero # a0 <-- boot_flags = 0 move a0, zero # a0 <-- boot_flags = 0
PTR_LA t9, board_init_f PTR_LA t9, board_init_f
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment