下面是初始化部分(bootloader)
__reset_exception:
/* 开发板制锁*/
ldr r0, = 0xe010e81c
ldr r1, = 0x301
str r1, [r0]
/* 关闭看门狗 */
ldr r0, = 0xe2700000
mov r1, #0
str r1, [r0]
/* 下面有调用c函数设置SVC栈地址 */
ldr sp, = 0xd0037d80
/* 启动icache */
bl enable_icache
/* 设置时钟 */
bl init_clock
/* 初始化DDR */
bl sdram_init
/* 创建页表 */
bl create_page_table
/* 使能mmu */
bl enable_mmu
/* 代码重定位 */
bl copy2sdram
/* 清bss段 */
bl clear_bss
/* 从iram跳转到ddr */
ldr pc, = sdram
sdram:
bl uart0_init
/* 开irq中断 */
mrs r0, cpsr
bic r0, r0, #1<<7
msr cpsr, r0
ldr sp, = 0x45000000
/* 调用main函数 */
bl main
b .
enable_icache:
mrc p15, 0, r1, c1, c0, 0 @read Control Regist
orr r1, r1,#(1<<12) @ENABLE instructon cache
//bic r1, r1,#(1<<12)
mcr p15, 0, r1, c1, c0, 0
mov pc, lr
enable_mmu:
/* translation table base write cp5 */
ldr r1, = 0x4f000000
mrc p15, 0, r2, c2, c0, 0 @ Read Translation Table Base Register
orr r2, r2, r1
mcr p15, 0, r2, c2, c0, 0 @ Write Translation Table Base Register
/* set domain 0xffffffff */
ldr r0, = 0xffffffff
mcr p15, 0, r0, c3, c0, 0 @ Read Domain Access Control Register
/* enable i/d canche */
mrc p15, 0, r1, c1, c0, 0 @Read Control Regist
orr r1, r1,#(1<<12) @enable instructon cache
orr r1, r1,#(1<<2) @enable data cache
orr r1, r1,#(1<<0) @enable mmu
mcr p15, 0, r1, c1, c0, 0 @write Control Regist
mov pc, lr
|