save_boot_params( u-boot )

reset:  
    bl  save_boot_params  
    /* 
     * disable interrupts (FIQ and IRQ), also set the cpu to SVC32 mode, 
     * except if in HYP mode already 
     */  
    mrs r0, cpsr  
    and r1, r0, #0x1f       @ mask mode bits  
    teq r1, #0x1a       @ test for HYP mode  
    bicne   r0, r0, #0x1f       @ clear all mode bits  
    orrne   r0, r0, #0x13       @ set SVC mode  
    orr r0, r0, #0xc0       @ disable FIQ and IRQ  
    msr cpsr,r0  

 

在上电或者重启后,处理器取得第一条指令就是b reset,所以会直接跳转到reset函数处。reset首先是跳转到save_boot_params中,如下:

/************************************************************************* 
 * 
 * void save_boot_params(u32 r0, u32 r1, u32 r2, u32 r3) 
 *  __attribute__((weak)); 
 * 
 * Stack pointer is not yet initialized at this moment 
 * Don't save anything to stack even if compiled with -O0 
 * 
 *************************************************************************/  
ENTRY(save_boot_params)  
    bx  lr          @ back to my caller  
ENDPROC(save_boot_params)  
    .weak   save_boot_params  

这里值得注意的是.weak关键字,在网上找了到的解释,我的理解是.weak相当于声明一个函数,如果该函数在其他地方没有定义,则为空函数,有定义则调用该定义的函数。

具体解释可以看这位大神的详解:

http://blog.csdn.NET/norains/article/details/5954459

接下来reset执行7条指令,修改cpsr寄存器,设置处理器进入svc模式,并且关掉irq和fiq。

 

转载于:https://www.cnblogs.com/tureno/articles/6532761.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值