uboot的代码,第一部分是汇编写的,第二部分是C语言写的。
在从汇编进入C语言过程中,先要设置好堆栈。
我的问题是:
1.为什么在arm平台上运行的uboot设置的堆栈只设定了一个堆栈的指针,
却没有指定堆栈的大小。如果设置了,在什么地方设置的?
2.即使设置了堆栈的大小,可是C语言运行过程中,堆栈的使用仍有可能
超过设定的范围。这也是一个问题
arm平台uboot设置的堆栈例子:
1./* Set initial stackpointer in SDRAM to call board_init_f */
call_board_init_f:
ldr sp, =(CONFIG_SYS_INIT_SP_ADDR)
bic sp, sp, #7 /* 8-byte alignment for ABI compliance */
ldr r0,=0x00000000
bl board_init_f
2. /* Set up the stack */
stack_setup:
mov sp, r4
adr r0, _start
cmp r0, r6
beq clear_bss /* skip relocation */
mov r1, r6 /* r1 <- scratch for copy_loop */
ldr r3, _bss_start_ofs
add r2, r0, r3 /* r2 <- source end address */
copy_loop:
ldmia r0!, {r9-r10} /* copy from source address [r0] */
stmia r1!, {r9-r10} /* copy to target address [r1] */
cmp r0, r2 /* until source end address [r2] */
blo copy_loop
------解决方案--------------------------------------------------------
1.为什么在arm平台上运行的uboot设置的堆栈只设定了一个堆栈的指针,
却没有指定堆栈的大小。如果设置了,在什么地方设置的?
lz的uboot代码对吗?我看的uboot是有设定大小的
copy_loop:
ldmia r0!, {r3-r10} /* copy from source address [r0] */
stmia r1!, {r3-r10} /* copy to target address [r1] */
cmp r0, r2 /* until source end addreee [r2] */
ble copy_loop
/* Set up the stack */
stack_setup:
ldr r0, _uboot_reloc /* upper 128 KiB: relocated uboot */
sub r0, r0, #CFG_MALLOC_LEN /* malloc area */
/* FIXME: bdinfo should be here */
sub sp, r0, #12 /* leave 3 words for abort-stack */
clear_bss:
ldr r0, _bss_start /* find start of bss segment */
add r0, r0, #4 /* start at first byte of bss */