微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > ARM启动文件2440init.s分析

ARM启动文件2440init.s分析

时间:11-23 来源:互联网 点击:

ldr r0,=0x30000000

0

stmia r0!,{r1-r8}

subs r9,r9,#32

bne ?% B0?

;Clear SDRAM End

1

;Initializestacks

bl InitStacks

;------------------------------------------------------------------------------------------------

;===========================================================

;OM0是flash选择开关,OM0接地时从nand 启动,悬空时(核心板上有上拉电阻)从nor启动

;OM1在核心板上,始终是接地,为0

;OM1:OM0取值:00 nandflash mode

; 01 16bit nor

; 10 32bit nor

; 11 test mode

;详见:s3c2440 用户手册 5.memory controller 一节

;ands指令,加s表示结果影响cpsr寄存器的值

ldr r0, =BWSCON ;BWSCON总线宽度&等待控制寄存器

ldr r0, [r0]

ands r0, r0, #6 ;OM[1:0]!= 0, NOR FLash boot

bne copy_proc_beg ;do not read nand flash

adr r0, ResetEntry ;OM[1:0] == 0, NAND FLash boot

cmp r0, #0 ;ifuse Multi-ice,

bne copy_proc_beg ;donot read nand flash for boot

;nop

;===========================================================

;把nand中的数据,拷贝到ram中

nand_boot_beg

[ {TRUE}

bl RdNF2SDRAM

]

ldr pc, =copy_proc_beg

;===========================================================

;这里的一段代码时对内存数据的初始化,涉及代码段,数据段,bss段等

;因对这里的变量设置等有异议,暂时未全面分析,但是基本原理想通,就是一个比较地址,复制数据的过程

copy_proc_beg

adr r0, ResetEntry

ldr r2, BaseOfROM

cmp r0, r2

ldreq r0, TopOfROM

beq InitRam

ldrr3, TopOfROM

0

ldmia r0!, {r4-r7}

stmia r2!, {r4-r7}

cmp r2, r3

bcc % B0???

sub r2, r2, r3

sub r0, r0, r2

InitRam

ldr r2, BaseOfBSS

ldr r3, BaseOfZero

0

cmp r2, r3

ldrcc r1, [r0], #4

strcc r1, [r2], #4

bcc % B0???

mov r0, #0

ldr r3, EndOfBSS

1

cmp r2, r3

strcc r0, [r2], #4

bcc % B1???

ldr pc, = % F2 ;gotocompiler address

2

; [CLKdiv_VAL>1 ; meansFclk:Hclk is not 1:1.

; bl MMU_SetAsyncBusMode

; |

; blMMU_SetFastBusMode ; default value.

; ]

;===========================================================

; Setup IRQ handler

; 把中断服务函数的总入口地址,赋给HandleIRQ地址(文件最低端定义)

ldr r0,=HandleIRQ ;Thisroutine is needed

ldr r1,=IsrIRQ ;ifthere is not subs pc,lr,#4 at 0x18, 0x1c

str r1,[r0]

[ :LNOT:THUMBCODE

bl Main ;Do not use main() because ......

b .

]

[ THUMBCODE ;for start-up code for Thumbmode

orr lr,pc,#1

bx lr

CODE16

bl Main ;Do not use main() because ......

b .

CODE32

]

;------------------------------------------------------------------------------------------------

;function initializing stacks

; 初始化栈空间(各个模式下的),为c函数运行做准备

InitStacks

;Donot use DRAM,such as stmfd,ldmfd......

;SVCstackis initialized before

;Undertoolkit ver 2.5, msr cpsr,r1 can be used instead of msr cpsr_cxsf,r1

mrs r0,cpsr

bic r0,r0,#MODEMASK

orr r1,r0,#UNDEFMODE|NOINT

msr cpsr_cxsf,r1 ;UndefMode

ldr sp,=UndefStack ; UndefStack=0x33FF_5C00

orr r1,r0,#ABORTMODE|NOINT

msr cpsr_cxsf,r1 ;AbortMode

ldr sp,=AbortStack ; AbortStack=0x33FF_6000

orr r1,r0,#IRQMODE|NOINT

msr cpsr_cxsf,r1 ;IRQMode

ldr sp,=IRQStack ;IRQStack=0x33FF_7000

orr r1,r0,#FIQMODE|NOINT

msr cpsr_cxsf,r1 ;FIQMode

ldr sp,=FIQStack ;FIQStack=0x33FF_8000

bic r0,r0,#MODEMASK|NOINT

orr r1,r0,#SVCMODE

msr cpsr_cxsf,r1 ;SVCMode

ldr sp,=SVCStack ;SVCStack=0x33FF_5800

;USERmode has not be initialized.

mov pc,lr

;TheLR register will not be valid if the current mode is not SVC mode.

LTORG

;------------------------------------------

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top