reset
resetting …
cmd/boot.c
U_BOOT_CMD(
reset, 1, 0, do_reset,
"Perform RESET of the CPU",
""
);
----> arch/arm/lib/reset.c
puts ("resetting ...\n");
udelay (50000); /* wait 50 ms */
do_shutdown();
disable_interrupts();
reset_misc();
reset_cpu(0); // 关键性操作
/*NOTREACHED*/
分析一下 do_shutdown操作
arch/arm/lib/process.c
#include <common.h>
#define CFG_MAX_SHUTDOWN 10
static struct shutdown_ctrl {
int count;
void (*shutdown[CFG_MAX_SHUTDOWN])(void);
} shutdown_ctrl = {0, {0}, };
void add_shutdown(void (*shutdown)(void)) // 其他地方往数组集合里增加函数
{
if (shutdown_ctrl.count >= CFG_MAX_SHUTDOWN) {
printf("Can't add shutdown function,"
"Please increase CFG_MAX_SHUTDOWN count\n");
return;
}
shutdown_ctrl.shutdown[shutdown_ctrl.count++]
= shutdown;
}
void do_shutdown(void)
{
int ix;
for (ix = 0; ix < shutdown_ctrl.count; ix++) /// 循环运行数组循环里的函数
shutdown_ctrl.shutdown[ix]();
}
// add_shutdown(xxx_driver_shutdown); // spi nor flash 3字节地址使能
static void xxx_driver_shutdown(void)
{
}
分析一下:reset_cpu
arch/arm/cpu/armv8/xxx/reset.S
.global reset_cpu
reset_cpu:
ldr r1, rstctl @ get addr for global reset
@ reg
mov r3, #0x2 @ full reset pll + mpu
str r3, [r1] @ force reset // 往某个地址写值 类型*p = xxx;
mov r0, r0
_loop_forever:
b _loop_forever // 进入循环
.align 2
rstctl:
.word SYS_CTRL_REG_BASE + REG_SC_SYSRES // 0x11020000 +4