标签:default col not The bic tlb set 硬件 arm9
1.UBOOT 运行的第一个文件是:cpu/arm920t/start.S(从程序的链接脚本中知道)
1 .globl _start // .globl定义一个全局符号"_start" 2 _start: b reset // 系统复位设置 3 ldr pc, _undefined_instruction //未定义异常 4 ldr pc, _software_interrupt //软件中断异常 5 ldr pc, _prefetch_abort //内存操作异常 6 ldr pc, _data_abort //数据异常 7 ldr pc, _not_used //未使用 8 ldr pc, _irq //中断异常(中断属于异常的一种) 9 ldr pc, _fiq //快速中断异常 10 11 _undefined_instruction: .word undefined_instruction //异常处理函数 12 _software_interrupt: .word software_interrupt 13 _prefetch_abort: .word prefetch_abort 14 _data_abort: .word data_abort 15 _not_used: .word not_used 16 _irq: .word irq 17 _fiq: .word fiq
1 reset: 2 /* 3 * set the cpu to SVC32 mode 将 CPU 设置为 SVC32 管理模式
1 #ifndef CONFIG_SKIP_LOWLEVEL_INIT 2 adr r0, _start /* r0 <- current position of code */ 3 ldr r1, _TEXT_BASE /* test if we run from flash or RAM */ 4 cmp r0, r1 /* don‘t reloc during debug */ 5 blne cpu_init_crit 6 #endif
1 /* turn off the watchdog 关闭 看门狗*/ 2 #if defined(CONFIG_S3C2400) || defined(CONFIG_S3C2410) 3 ldr r0, =pWTCON 4 mov r1, #0x0 5 str r1, [r0]
1 /* 2 * mask all IRQs by setting all bits in the INTMR - default 屏蔽所有中断 3 */ 4 mov r1, #0xffffffff 5 ldr r0, =INTMSK 6 str r1, [r0] 7 # if defined(CONFIG_S3C2410) 8 ldr r1, =0x3ff 9 ldr r0, =INTSUBMSK 10 str r1, [r0] 11 # endif
/* 判断系统是从nand启动的还是直接将程序下载到SDRAM中运行, 若系统从nand启动,这里得到r0和r1值是不一样的,r1=0x33f80000, 而r0=0x00000000。说明没初始化SDRAM,ne(no equal)标识符为真,所以bl cpu_init_crit执行跳转. */
1 #ifndef CONFIG_SKIP_LOWLEVEL_INIT 2 adr r0, _start /* r0 <- current position of code adr 是读地址指令,当前 _start 这段代码位于哪里 */ 3 ldr r1, _TEXT_BASE /* test if we run from flash or RAM */ 4 cmp r0, r1 /* don‘t reloc during debug */ 5 blne cpu_init_crit 6 #endif
1 #ifndef CONFIG_SKIP_LOWLEVEL_INIT 2 cpu_init_crit: 3 /* 4 * flush v4 I/D caches 先关 flush 清 caches 5 */ 6 mov r0, #0 7 mcr p15, 0, r0, c7, c7, 0 /* flush v3/v4 cache */ 8 mcr p15, 0, r0, c8, c7, 0 /* flush v4 TLB */ 9 10 /* 11 * disable MMU stuff and caches 关闭MMU 12 */ 13 mrc p15, 0, r0, c1, c0, 0 14 bic r0, r0, #0x00002300 @ clear bits 13, 9:8 (--V- --RS) 15 bic r0, r0, #0x00000087 @ clear bits 7, 2:0 (B--- -CAM) 16 orr r0, r0, #0x00000002 @ set bit 2 (A) Align 17 orr r0, r0, #0x00001000 @ set bit 12 (I) I-Cache 18 mcr p15, 0, r0, c1, c0, 0 19 20 /* 21 * before relocating, we have to setup RAM timing 22 * because memory timing is board-dependend, you will 23 * find a lowlevel_init.S in your board directory. 24 */ 25 mov ip, lr 26 bl lowlevel_init //进入lowlevel_init初始化13个BANK寄存器来初始化SDRAM 27 mov lr, ip 28 mov pc, lr 29 #endif /* CONFIG_SKIP_LOWLEVEL_INIT */
1 /* Set up the stack 栈的设置 */ 2 stack_setup: 3 ldr r0, _TEXT_BASE /* upper 128 KiB: relocated uboot */ 4 sub r0, r0, #CFG_MALLOC_LEN /* malloc area */ 5 sub r0, r0, #CFG_GBL_DATA_SIZE /* bdinfo */ 6 7 #ifdef CONFIG_USE_IRQ 8 sub r0, r0, #(CONFIG_STACKSIZE_IRQ+CONFIG_STACKSIZE_FIQ) 9 #endif 10 sub sp, r0, #12 /* leave 3 words for abort-stack */ 11 12 #ifndef CONFIG_SKIP_LOWLEVEL_INIT 13 bl clock_init //进入 clock_init 函数 14 #endif
1 relocate: /* relocate U-Boot to RAM 重定位代码 拷贝u-boot到SDRAM */ 2 adr r0, _start /* r0 <- current position of code */ 3 ldr r1, _TEXT_BASE /* test if we run from flash or RAM */ 4 cmp r0, r1 /* don‘t reloc during debug */ 5 beq clear_bss 6 7 ldr r2, _armboot_start 8 ldr r3, _bss_start 9 sub r2, r3, r2 /* r2 <- size of armboot */
1 clear_bss: /*清除BSS段*/ 2 ldr r0, _bss_start /* find start of bss segment */ 3 ldr r1, _bss_end /* stop here */ 4 mov r2, #0x00000000 /* clear */
clbss_l:str r2, [r0] /* clear loop... */
add r0, r0, #4
cmp r0, r1
ble clbss_l
1 ldr pc, _start_armboot 2 3 _start_armboot: .word start_armboot /*最后调用 C 函数 start_armboo 用来实现第2阶段硬件相关的初始化*/
标签:default col not The bic tlb set 硬件 arm9
原文地址:https://www.cnblogs.com/imunrobot/p/12437270.html