文章目录
2.6 清理bss和设置栈
- 设置寄存器为0,除了ra, a0, a1 和 a2
- 清零bss段
- 设置异常向量表处理函数为_start_hang
- 设置临时栈道_fw_end(opensbi代码结束地址)后8KB处
/* At this point we are running from link address */
/* Reset all registers for boot HART */
/*1. 设置寄存器为0*/
li ra, 0
call _reset_regs
/*2. 清零bss段*/
/* Zero-out BSS */
lla s4, _bss_start
lla s5, _bss_end
_bss_zero:
REG_S zero, (s4)
add s4, s4, __SIZEOF_POINTER__
blt s4, s5, _bss_zero
/* Setup temporary trap handler */
/*3. 设置异常向量表*/
lla s4, _start_hang
csrw CSR_MTVEC, s4
/* Setup temporary stack */
/*4. 设置临时栈道_fw_end后8处*/
lla s4, _fw_end
li s5, (SBI_SCRATCH_SIZE * 2)
add sp, s4, s5
2.7 保存fw_dynamic_info到sbi的变量中
调用fw_save_info前,先将a0、a1、a2、a3、a4分别备份到s0、s1、s2、s3、s4。调用后则恢复a0-a4寄存器
a0: hart id
a1: dtb地址
a2: 从spl传入的