up_boot源码分析
/* ================================ bootx.c ================================ */
void system_startup(void)
{
UINT32 ex_addr = OS_EX_ADDR;
if (ota_main(&ex_addr) == 0) //ota updata app process
{
os_printf("\r\n ota updata success!\r\n");
}
bk_printf("\r\n\r\ngo os_addr(0x%x)..........\r\n", ex_addr);
uart1_wait_tx_finish(); //为了把log发完
sys_forbidden_interrupts();
jump_pc_address(ex_addr); //指针跳转到app分区起始地址0x10000
while(1);
}
void system_timeout_startup(void)
{
system_startup();
}
/* ================================ main.c ================================ */
int boot_main(void)
{
__disable_irq();
__disable_fiq();
intc_forbidden_all(); //close all int opreate ICU regist
rt_hw_board_init(); //flash/uart init
heap_init(); //mem manager
system_timeout_startup(); //ota process
return 0;
}
/*============================boot_handlers.s==============================*/
/*
* 1)关中断;
* 2)初始化各运行模式下的数据栈指针;
* 3)拷贝image到ram;
* 4)初始化bss,清寄存器;
* 5)跳到boot_main执行
*/
boot_reset
; Disable IRQ and FIQ before starting anything
MRS R0, CPSR
ORR R0, R0, #0xC0
MSR CPSR_c, R0
; Setup all stacks, Note: Sys and Usr mode are not used
BOOT_CHANGE_MODE SYS
BOOT_SET_STACK UNUSED
BOOT_CHANGE_MODE ABT
BOOT_SET_STACK UNUSED
BOOT_CHANGE_MODE UND
BOOT_SET_STACK UNUSED
BOOT_CHANGE_MODE IRQ
BOOT_SET_STACK IRQ
BOOT_CHANGE_MODE FIQ
BOOT_SET_STACK FIQ
; Clear FIQ banked registers while in FIQ mode
MOV R8, #0
MOV R9, #0
MOV R10, #0
MOV R11, #0
MOV R12, #0
BOOT_CHANGE_MODE SVC
BOOT_SET_STACK SVC
; Stay in Supervisor Mode, copy data from binary to ram
BL _sysboot_copy_data_to_ram
; Init the BSS section
LDR R0, ram_bss_base
LDR R1, ram_bss_length
MOV R2, #0
MOV R3, #0
MOV R4, #0
MOV R5, #0
init_bss_loop
SUBS R1, R1, #16
STMCSIA R0!, {R2, R3, R4, R5}
BHI init_bss_loop
LSLS R1, R1, #29
STMCSIA R0!, {R4, R5}
STRMI R3, [R0]
; /* Clear Registers */
MOV R0, #0
MOV R1, #0
MOV R2, #0
MOV R3, #0
MOV R4, #0
MOV R5, #0
MOV R6, #0
MOV R7, #0
MOV R8, #0
MOV R9, #0
MOV R10, #0
MOV R11, #0
MOV R12, #0
B boot_main
InitStack
MOV R0, LR
BX R0 ; MOV PC, R0
STACK_BASE DCD ||Image$$RAM_STACK_FIQ$$Base||
/*============================boot_vectors.s==============================*/
/*
* 1)ENTRY 定义初始入口点,0x0存放复位异常中断向量;
* 2)vectors 设置中断向量表
*/
AREA SYS_BOOT, CODE, READONLY, ALIGN=4
ENTRY
vectors
b boot_reset