微波EDA网,见证研发工程师的成长!
首页 > 硬件设计 > 嵌入式设计 > S3C2440启动代码分析

S3C2440启动代码分析

时间:11-21 来源:互联网 点击:
  1. ,BaseOfROM
  2. ;旨在计算出正确的RW区起始位置
  3. ;下面2行目的是为了计算正确的r0(必须使之指向code区中的rw域开始处)
  4. subr2,r2,r3;r2=BaseOfROM-TopOfROM=(-)代码长度
  5. subr0,r0,r2;r0=ResetEntry-(-)代码长度=ResetEntry+代码长度
  6. InitRam
  7. ;复制代码加载位置中的RM区到|Image

    RW

    Base|
  8. ldrr2,BaseOfBSS;BaseOfBSS->r2,BaseOfBSS=|Image

    RW

    Base|
  9. ldrr3,BaseOfZero;BaseOfZero->r3,BaseOfZero=|Image

    ZI

    Base|
  10. 0
  11. cmpr2,r3;比较BaseOfBSS和BaseOfZero
  12. ldrccr1,[r0],#4;当代码在内存中运行时,r0(初始值)=TopOfROM.这之后的BaseOfZero-BaseOfBSS仍属于code,需拷贝到BaseOfBSS
  13. strccr1,[r2],#4
  14. bcc%B0
  15. ;用0初始化ZI区
  16. movr0,#0
  17. ldrr3,EndOfBSS;EndOfBSS=|Image

    ZI

    Limit|
  18. 1
  19. cmpr2,r3
  20. strccr0,[r2],#4
  21. bcc%B1
  22. ;要是r21;meansFclk:Hclkisnot1:1.
  23. ;blMMU_SetAsyncBusMode
  24. ;|
  25. ;blMMU_SetFastBusMode;defaultvalue.
  26. ;]
  27. ;blLed_Test
  28. ;===========================================================
  29. ;进入C语言前的最后一步了,就是把我们用说查二级向量表
  30. ;的中断例程安装到一级向量表(异常向量表)里.
  31. ;//5.设置缺省中断处理函数
  32. ;SetupIRQhandler
  33. ldrr0,=HandleIRQ;Thisroutineisneeded
  34. ldrr1,=IsrIRQ;ifthereisntsubspc,lr,#4at0x18,0x1c
  35. strr1,[r0]
  36. ;//initializetheIRQ将普通中断判断程序的入口地址给HandleIRQ
  37. ;//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  38. ;注意,以下这段可能不需要!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  39. ;//6.将数据段拷贝到ram中将零初始化数据段清零跳入C语言的main函数执行到这步结束bootloader初步引导结束
  40. ;Ifmain()isused,thevariableinitializationwillbedonein__main().
  41. [{FALSE};bytinko--最外面的条件由tinko添加,实际上不再执行这段
  42. [:LNOT:USE_MAIN;initialized{FALSE}
  43. ;CopyandpasteRWdata/zeroinitializeddata
  44. LDRr0,=|Image

    RO

    Limit|;GetpointertoROMdata
  45. LDRr1,=|Image

    RW

    Base|;andRAMcopy
  46. LDRr3,=|Image

    ZI

    Base|
  47. ;Zeroinitbase=>topofinitialiseddata
  48. CMPr0,r1;Checkthattheyaredifferentjustfordebug??????????????????????????
  49. BEQ%F2
  50. 1
  51. CMPr1,r3;Copyinitdata
  52. LDRCCr2,[r0],#4;-->LDRCCr2,[r0]+ADDr0,r0,#4
  53. STRCCr2,[r1],#4;-->STRCCr2,[r1]+ADDr1,r1,#4
  54. BCC%B1
  55. 2
  56. LDRr1,=|Image

    ZI

    Limit|;Topofzeroinitsegment
  57. MOVr2,#0
  58. 3
  59. CMPr3,r1;Zeroinit
  60. STRCCr2,[r3],#4
  61. BCC%B3
  62. ]
  63. ]
  64. ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  65. ;***************************************
  66. ;bytinko
  67. [{TRUE};得有些表示了,该点点LED灯了
  68. ;rGPFDAT=(rGPFDAT&~(0xf<4))|((~data&0xf)<4);
  69. ;Led_Display
  70. ldrr0,=GPFCON
  71. ldrr1,=0x5500
  72. strr1,[r0]
  73. ldrr0,=GPFDAT
  74. ldrr1,=0xe0
  75. strr1,[r0]
  76. ldrr2,=0xffffffff;
  77. 1
  78. subr2,r2,#1
  79. bne%b1
  80. ldrr0,=GPFDAT
  81. ldrr1,=0xe0
  82. ;b.;diehere
  83. ]
  84. ;*****************************************
  85. ;*****************************************************************************
  86. ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  87. ;妈呀,终说见到艳阳天了!!!!!!!!!!
  88. ;跳到C语言的main函数处了.
  89. ;!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
  90. ;*****************************************************************************
  91. [:LNOT:THUMBCODE;ifthumbcode={false}blmainL代表logic变量
  92. blMain;Dontusemain()because......
  93. b.;注意小圆点
  94. ]
  95. ;//ifthumbcod={ture}
  96. [THUMBCODE;forstart-upcodeforThumbmode
  97. orrlr,pc,#1
  98. bxlr
  99. CODE16
  100. blMain;Dontusemain()because......
  101. b.;注意小圆点
  102. CODE32
  103. ]
  104. ;functioninitializingstacks
  105. InitStacks
  106. ;DontuseDRAM,suchasstmfd,ldmfd......
  107. ;SVCstackisinitializedbefore
  108. ;Undertoolkitver2.5,msrcpsr,r1canbeusedinsteadofmsrcpsr_cxsf,r1
  109. mrsr0,cpsr
  110. bicr0,r0,#MODEMASK
  111. orrr1,r0,#UNDEFMODE|NOINT
  112. msrcpsr_cxsf,r1;UndefMode
  113. ldrsp,=UndefStack;UndefStack=0x33FF_5C00
  114. orrr1,r0,#ABORTMODE|NOINT
  115. msrcpsr_cxsf,r1;AbortMode
  116. ldrsp,=AbortStack;AbortStack=0x33FF_6000
  117. orrr1,r0,#IRQMODE|NOINT
  118. msrcpsr_cxsf,r1;IRQMode
  119. ldrsp,=IRQStack;IRQStack=0x33FF_7000
  120. orrr1,r0,#FIQMODE|NOINT
  121. msrcpsr_cxsf,r1;FIQMode
  122. ldrsp,=FIQStack;FIQStack=0x33FF_8000
  123. bicr0,r0,#MODEMASK|

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

网站地图

Top