S3C2440启动代码分析
时间:11-21
来源:互联网
点击:
- ,BaseOfROM
- ;旨在计算出正确的RW区起始位置
- ;下面2行目的是为了计算正确的r0(必须使之指向code区中的rw域开始处)
- subr2,r2,r3;r2=BaseOfROM-TopOfROM=(-)代码长度
- subr0,r0,r2;r0=ResetEntry-(-)代码长度=ResetEntry+代码长度
- InitRam
- ;复制代码加载位置中的RM区到|Image
Base|RW - ldrr2,BaseOfBSS;BaseOfBSS->r2,BaseOfBSS=|Image
Base|RW - ldrr3,BaseOfZero;BaseOfZero->r3,BaseOfZero=|Image
Base|ZI - 0
- cmpr2,r3;比较BaseOfBSS和BaseOfZero
- ldrccr1,[r0],#4;当代码在内存中运行时,r0(初始值)=TopOfROM.这之后的BaseOfZero-BaseOfBSS仍属于code,需拷贝到BaseOfBSS
- strccr1,[r2],#4
- bcc%B0
- ;用0初始化ZI区
- movr0,#0
- ldrr3,EndOfBSS;EndOfBSS=|Image
Limit|ZI - 1
- cmpr2,r3
- strccr0,[r2],#4
- bcc%B1
- ;要是r21;meansFclk:Hclkisnot1:1.
- ;blMMU_SetAsyncBusMode
- ;|
- ;blMMU_SetFastBusMode;defaultvalue.
- ;]
- ;blLed_Test
- ;===========================================================
- ;进入C语言前的最后一步了,就是把我们用说查二级向量表
- ;的中断例程安装到一级向量表(异常向量表)里.
- ;//5.设置缺省中断处理函数
- ;SetupIRQhandler
- ldrr0,=HandleIRQ;Thisroutineisneeded
- ldrr1,=IsrIRQ;ifthereisntsubspc,lr,#4at0x18,0x1c
- strr1,[r0]
- ;//initializetheIRQ将普通中断判断程序的入口地址给HandleIRQ
- ;//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- ;注意,以下这段可能不需要!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- ;//6.将数据段拷贝到ram中将零初始化数据段清零跳入C语言的main函数执行到这步结束bootloader初步引导结束
- ;Ifmain()isused,thevariableinitializationwillbedonein__main().
- [{FALSE};bytinko--最外面的条件由tinko添加,实际上不再执行这段
- [:LNOT:USE_MAIN;initialized{FALSE}
- ;CopyandpasteRWdata/zeroinitializeddata
- LDRr0,=|Image
Limit|;GetpointertoROMdataRO - LDRr1,=|Image
Base|;andRAMcopyRW - LDRr3,=|Image
Base|ZI - ;Zeroinitbase=>topofinitialiseddata
- CMPr0,r1;Checkthattheyaredifferentjustfordebug??????????????????????????
- BEQ%F2
- 1
- CMPr1,r3;Copyinitdata
- LDRCCr2,[r0],#4;-->LDRCCr2,[r0]+ADDr0,r0,#4
- STRCCr2,[r1],#4;-->STRCCr2,[r1]+ADDr1,r1,#4
- BCC%B1
- 2
- LDRr1,=|Image
Limit|;TopofzeroinitsegmentZI - MOVr2,#0
- 3
- CMPr3,r1;Zeroinit
- STRCCr2,[r3],#4
- BCC%B3
- ]
- ]
- ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- ;***************************************
- ;bytinko
- [{TRUE};得有些表示了,该点点LED灯了
- ;rGPFDAT=(rGPFDAT&~(0xf<4))|((~data&0xf)<4);
- ;Led_Display
- ldrr0,=GPFCON
- ldrr1,=0x5500
- strr1,[r0]
- ldrr0,=GPFDAT
- ldrr1,=0xe0
- strr1,[r0]
- ldrr2,=0xffffffff;
- 1
- subr2,r2,#1
- bne%b1
- ldrr0,=GPFDAT
- ldrr1,=0xe0
- ;b.;diehere
- ]
- ;*****************************************
- ;*****************************************************************************
- ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- ;妈呀,终说见到艳阳天了!!!!!!!!!!
- ;跳到C语言的main函数处了.
- ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
- ;*****************************************************************************
- [:LNOT:THUMBCODE;ifthumbcode={false}blmainL代表logic变量
- blMain;Dontusemain()because......
- b.;注意小圆点
- ]
- ;//ifthumbcod={ture}
- [THUMBCODE;forstart-upcodeforThumbmode
- orrlr,pc,#1
- bxlr
- CODE16
- blMain;Dontusemain()because......
- b.;注意小圆点
- CODE32
- ]
- ;functioninitializingstacks
- InitStacks
- ;DontuseDRAM,suchasstmfd,ldmfd......
- ;SVCstackisinitializedbefore
- ;Undertoolkitver2.5,msrcpsr,r1canbeusedinsteadofmsrcpsr_cxsf,r1
- mrsr0,cpsr
- bicr0,r0,#MODEMASK
- orrr1,r0,#UNDEFMODE|NOINT
- msrcpsr_cxsf,r1;UndefMode
- ldrsp,=UndefStack;UndefStack=0x33FF_5C00
- orrr1,r0,#ABORTMODE|NOINT
- msrcpsr_cxsf,r1;AbortMode
- ldrsp,=AbortStack;AbortStack=0x33FF_6000
- orrr1,r0,#IRQMODE|NOINT
- msrcpsr_cxsf,r1;IRQMode
- ldrsp,=IRQStack;IRQStack=0x33FF_7000
- orrr1,r0,#FIQMODE|NOINT
- msrcpsr_cxsf,r1;FIQMode
- ldrsp,=FIQStack;FIQStack=0x33FF_8000
- bicr0,r0,#MODEMASK|
S3C2440启动代 相关文章:
- 深入分析S3C2440启动代码中大小端问题(11-22)
- S3C2440启动代码中应用程序执行环境的初始化(11-22)
- S3C2440启动代码 中断分析(11-22)
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)