Uboot的進入點:
從u-boot.lds中得知, 程式進入點從_start開始
_start被定義在start.s中, 在u-boot的資料夾裡, 不同類型的CPU會有各自的start.s
_start中所做的第一條指令是去做reset
.globl _start
... |
reset中所做的第一件事情, 是將CPSR讀出, 並且設定其中的
1. mode 設成 System mode --> 將CPU工作模式切成system mode
2. set IRQ, FIQ bit --> Disable IRQ 與 FIQ 防止任何interrupt 發生
reset: /* * set the cpu to SVC32 mode */ mrs r0,cpsr bic r0,r0,#0x1f orr r0,r0,#0xd3 msr cpsr,r0 |
之後會去做cpu_init_crit
這裡最主要都對ARM的coprocessor 15作設定
1. Flushing I/D-cache
2. 設定control register
a) Bit 13
ARM 會將exception vector 放在起始位址前幾個byte,
Bit 13是決定起始位址是從0x00000000或0xFFFF0000
起始位址的也可以經由VINITHI ping腳在系統通電後決定
軟體通電後若要再變更就可以經由設定Bit 13來達到
b) Bit 9 -- Rom protection bit --> 設成 0 : no access
Bit 8 -- System protection bit --> 設成 0: no access
Bit 7 -- Endian selection --> 0:little-endian, 1:big-endian
c) Bit 2 -- Data cache enable --> 0: disabled, 1: enabled.
Bit 12 -- Instruction cache enable --> 0: disabled, 1: enabled.
3. 呼叫 lowlevel_init進一步設定memory (lowlevel_init.S)
cpu_init_crit: /* * flush v4 I/D caches */ mov r0, #0 mcr p15, 0, r0, c7, c5, 0 /* flush v4 I-cache */ mcr p15, 0, r0, c7, c6, 0 /* flush v4 D-cache */ /* * disable MMU stuff and caches */ mrc p15, 0, r0, c1, c0, 0 bic r0, r0, #0x00002300 /* clear bits 13, 9:8 (--V- --RS) */ bic r0, r0, #0x00000087 /* clear bits 7, 2:0 (B--- -CAM) */ orr r0, r0, #0x00000002 /* set bit 2 (A) Align */ orr r0, r0, #0x00001000 /* set bit 12 (I) I-Cache */ mcr p15, 0, r0, c1, c0, 0 /* * Go setup Memory and board specific bits prior to relocation. */ mov ip, lr /* perserve link reg across call */ bl lowlevel_init /* go setup memory */ mov lr, ip /* restore link */ mov pc, lr /* back to my caller */ |