由于steppingstone因素,保存在nand flash的执行指令的前4k会搬到SRAM上执行。此时CPU是从SRAM取指令执行。
但是由于整个执行指令的代码会大于4k,因此前4k执行指令的部分功能是把所有代码搬到内存中,再由CPU从内存中读取指令。
-
.text
-
.global _start
-
_start:
-
-
bl disable_watch_dog
-
bl memsetup
-
bl copy_to_sdram
-
ldr pc, =on_sdram
-
-
on_sdram:
-
ldr sp, =0x34000000
-
bl main
-
-
halt_loop:
-
b halt_loop
第9行就是跳转取指令的地方。由从SRAM取指令转为从内存取指令。
-
sdram_elf: file format elf32-littlearm
-
-
Disassembly of section .text:
-
-
30000000 <_start>:
-
30000000: eb000005 bl 3000001c <disable_watch_dog>
-
30000004: eb000008 bl 3000002c <memsetup>
-
30000008: eb000010 bl 30000050 <copy_to_sdram>
-
3000000c: e59ff090 ldr pc, [pc, #144] ; 300000a4 <mem_cfg_val+0x34>
-
-
30000010 <on_sdram>:
-
30000010: e3a0d30d mov sp, #872415232 ; 0x34000000
-
30000014: eb000032 bl 300000e4 <main>
-
-
30000018 <halt_loop>:
-
30000018: eafffffe b 30000018 <halt_loop>
-
-
3000001c <disable_watch_dog>:
-
3000001c: e3a01453 mov r1, #1392508928 ; 0x53000000
-
30000020: e3a02000 mov r2, #0 ; 0x0
-
30000024: e5812000 str r2, [r1]
-
30000028: e1a0f00e mov pc, lr
-
-
3000002c <memsetup>:
-
3000002c: e3a01312 mov r1, #1207959552 ; 0x48000000
-
30000030: e28f2038 add r2, pc, #56 ; 0x38
-
30000034: e1a00000 nop (mov r0,r0)
-
30000038: e2813034 add r3, r1, #52 ; 0x34
-
3000003c: e4924004 ldr r4, [r2], #4
-
30000040: e4814004 str r4, [r1], #4
-
30000044: e1510003 cmp r1, r3
-
30000048: 1afffffb bne 3000003c <memsetup+0x10>
-
3000004c: e1a0f00e mov pc, lr
-
-
30000050 <copy_to_sdram>:
-
30000050: e3a01000 mov r1, #0 ; 0x0
-
30000054: e3a02203 mov r2, #805306368 ; 0x30000000
-
30000058: e3a03a01 mov r3, #4096 ; 0x1000
-
3000005c: e4914004 ldr r4, [r1], #4
-
30000060: e4824004 str r4, [r2], #4
-
30000064: e1510003 cmp r1, r3
-
30000068: 1afffffb bne 3000005c <copy_to_sdram+0xc>
-
3000006c: e1a0f00e mov pc, lr
-
-
30000070 <mem_cfg_val>:
-
30000070: 22011110 andcs r1, r1, #4 ; 0x4
-
30000074: 00000700 andeq r0, r0, r0, lsl #14
-
30000078: 00000700 andeq r0, r0, r0, lsl #14
-
3000007c: 00000700 andeq r0, r0, r0, lsl #14
-
30000080: 00000700 andeq r0, r0, r0, lsl #14
-
30000084: 00000700 andeq r0, r0, r0, lsl #14
-
30000088: 00000700 andeq r0, r0, r0, lsl #14
-
3000008c: 00018005 andeq r8, r1, r5
-
30000090: 00018005 andeq r8, r1, r5
-
30000094: 008c07a3 addeq r0, ip, r3, lsr #15
-
30000098: 000000b1 streqh r0, [r0], -r1
-
3000009c: 00000030 andeq r0, r0, r0, lsr r0
-
300000a0: 00000030 andeq r0, r0, r0, lsr r0
-
300000a4: 30000010 andcc r0, r0, r0, lsl r0
-
300000a8: e1a00000 nop (mov r0,r0)
-
300000ac: e1a00000 nop (mov r0,r0)
第9行ldr pc, =on_sdram 对应的反汇编是:
3000000c: e59ff090 ldr pc, [pc, #144] ; 300000a4
最左边是链接地址,pc=3000000c+8,[pc, #144]=[3000000c+4+144]=[300000a4],取300000a4地址的值复制给PC
300000a4: 30000010 andcc r0, r0, r0, lsl r0
PC=[300000a4]=30000010,就是标记on_sdram开始的地址
注意:链接地址从30000000是有在链接时候决定的:
arm-linux-ld -Ttext 0x30000000 sdram.o leds.o -o sdram_elf
阅读(1721) | 评论(0) | 转发(0) |