u-boot部分:
normal_mode -> vlx_nand_boot -> vlx_entry
8f860134
8f860134: e92d4008 push {r3, lr}
8f860138: eb000869 bl 8f8622e4
8f86013c: e30017de movw r1, #2014 ; 0x7de
8f860140: e59f0018 ldr r0, [pc, #24] ; 8f860160
8f860144: ebfea515 bl 8f8095a0
8f860148: e3a00000 mov r0, #0
8f86014c: e30017de movw r1, #2014 ; 0x7de
将kernel启动需要的__machine_arch_type保存在r1寄存器中
8f860150: e59f200c ldr r2, [pc, #12] ; 8f860164
将“0x82000100”保存在r2寄存器中
8f860154: e59f300c ldr r3, [pc, #12] ; 8f860168
8f860158: e12fff33 blx r3
8f86015c: eafffffe b 8f86015c
8f860160: 8f87bf18 .word 0x8f87bf18
8f860164: 82000100 .word 0x82000100
8f860168: 80008000 .word 0x80008000
kernel部分:
c0008000
c0008000: eb003086 bl c0014220 <__hyp_stub_install>
c0008004: e10f9000 mrs r9, CPSR
c0008008: e229901a eor r9, r9, #26
c000800c: e319001f tst r9, #31
c0008010: e3c9901f bic r9, r9, #31
c0008014: e38990d3 orr r9, r9, #211 ; 0xd3
c0008018: 1a000004 bne c0008030
c000801c: e3899c01 orr r9, r9, #256 ; 0x100
c0008020: e28fe00c add lr, pc, #12
c0008024: e16ff009 msr SPSR_fsxc, r9
c0008028: e12ef30e .word 0xe12ef30e
c000802c: e160006e .word 0xe160006e
c0008030: e121f009 msr CPSR_c, r9
c0008034: ee109f10 mrc 15, 0, r9, cr0, cr0, {0}
c0008038: eb1cef41 bl c0743d44 <__lookup_processor_type>
c000803c: e1b0a005 movs sl, r5
c0008040: 0a1cef50 beq c0743d88 <__error>
c0008044: e28f3028 add r3, pc, #40 ; 0x28
c0008048: e8930110 ldm r3, {r4, r8}
c000804c: e0434004 sub r4, r3, r4
c0008050: e0888004 add r8, r8, r4
c0008054: eb000041 bl c0008160 <__vet_atags>
c0008058: eb000007 bl c000807c <__create_page_tables>
c000805c: e59fd00c ldr sp, [pc, #12] ; c0008070
该指令将“0xc0723260”加载到sp寄存器
c0008060: e28fe004 add lr, pc, #4
c0008064: e1a08004 mov r8, r4
c0008068: e28af010 add pc, sl, #16
c000806c: ea00002f b c0008130 <__enable_mmu>
本指令跳转到“__enable_mmu”
c0008070: c0723260 .word 0xc0723260
c0008074: c0008074 .word 0xc0008074
c0008078: c0000000 .word 0xc0000000
c0008130 <__enable_mmu>:
c0008130: e3c00002 bic r0, r0, #2
c0008134: e3a05015 mov r5, #21
c0008138: ee035f10 mcr 15, 0, r5, cr3, cr0, {0}
c000813c: ee024f10 mcr 15, 0, r4, cr2, cr0, {0}
c0008140: ea145c02 b c051f150 <__turn_mmu_on>
本指令跳转到“__turn_mmu_on”
c0008144: e320f000 nop {0}
c0008148: e320f000 nop {0}
c000814c: e320f000 nop {0}
c0008150: e320f000 nop {0}
c0008154: e320f000 nop {0}
c0008158: e320f000 nop {0}
c000815c: e320f000 nop {0}
c051f150 <__turn_mmu_on>:
c051f150: e1a00000 nop ; (mov r0, r0)
c051f154: f57ff06f isb sy
c051f158: ee010f10 mcr 15, 0, r0, cr1, cr0, {0}
c051f15c: ee103f10 mrc 15, 0, r3, cr0, cr0, {0}
c051f160: f57ff06f isb sy
c051f164: e1a03003 mov r3, r3
c051f168: e1a0300d mov r3, sp
将之前保存到sp寄存器的值放到r3寄存器
c051f16c: e1a0f003 mov pc, r3
本指令跳转到r3寄存器保存的函数地址,即开始时设定的“0xc0723260”,进入__mmap_switched
c0723260 <__mmap_switched>:
c0723260: e28f3044 add r3, pc, #68 ; 0x44
将“c07232ac”保存到r3寄存器
c0723264: e8b300f0 ldm r3!, {r4, r5, r6, r7}
将r3寄存器中保存的地址开始的值依次保存到r4/r5/r6/r7中,r3会依次增加。从原始的__mmap_switched_data中可以得知它们分别对应__data_loc/_sdata/__bss_start/_end
c0723268: e1540005 cmp r4, r5
c072326c: 11550006 cmpne r5, r6
c0723270: 1494b004 ldrne fp, [r4], #4
c0723274: 1485b004 strne fp, [r5], #4
c0723278: 1afffffb bne c072326c <__mmap_switched+0xc>
c072327c: e3a0b000 mov fp, #0
c0723280: e1560007 cmp r6, r7
c0723284: 3486b004 strcc fp, [r6], #4
c0723288: 3afffffc bcc c0723280 <__mmap_switched+0x20>
c072328c: e89320f0 ldm r3, {r4, r5, r6, r7, sp}
将r3寄存器中保存的地址开始的值依次保存到r4/r5/r6/r7/sp中。从原始的__mmap_switched_data中可以得知它们分别用于保存processor_id/__machine_arch_type/__atags_pointer/cr_alignment
c0723290: e5849000 str r9, [r4]
c0723294: e5851000 str r1, [r5]
将__machine_arch_type保存到[r5]对应的地址
c0723298: e5862000 str r2, [r6]
__atags_pointer[r6]对应的地址
c072329c: e3570000 cmp r7, #0
c07232a0: 13c04002 bicne r4, r0, #2
c07232a4: 18870011 stmne r7, {r0, r4}
c07232a8: ea000119 b c0723714
进入start_kernel,kernel开始启动
编译后:
c07232ac <__mmap_switched_data>:
c07232ac: c074e000 c074e000 c07ce7a0 c086c148 ..t...t...|.H...
c07232bc: c07ce9c0 c076a0e8 c0747ffc c07727ac ..|...v...t..'w.
c07232cc: c074fff8 ..t.
原始:
__mmap_switched_data:
.long __data_loc @ r4
.long _sdata @ r5
.long __bss_start @ r6
.long _end @ r7
.long processor_id @ r4
.long __machine_arch_type @ r5
.long __atags_pointer @ r6
#ifdef CONFIG_CPU_CP15
.long cr_alignment @ r7
#else
.long 0 @ r7
#endif
.long init_thread_union + THREAD_START_SP @ sp
.size __mmap_switched_data, . - __mmap_switched_data