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

S3C2440启动代码分析

时间:11-21 来源:互联网 点击:
  1. dian指令,只是由于总线不一样而取机器码的顺序不一样
  2. ]
  3. |
  4. bResetHandler;我们的程序由于ENDIAN_CHANGE设成FALSE就到这儿了,转跳到复位程序入口
  5. ]
  6. bHandlerUndef;handlerforUndefinedmode;0x04
  7. bHandlerSWI;handlerforSWIinterrupt;0x08
  8. bHandlerPabort;handlerforPAbort;0x0c
  9. bHandlerDabort;handlerforDAbort;0x10
  10. b.;reserved注意小圆点;0x14
  11. bHandlerIRQ;handlerforIRQinterrupt;0x18
  12. bHandlerFIQ;handlerforFIQinterrupt;0x1c
  13. ;@0x20
  14. bEnterPWDN;Mustbe@0x20.
  15. ;==================================================================================
  16. ;下面是改变大小端的程序,这里采用直接定义机器码的方式,至说为什么这么做就得问三星了
  17. ;反正我们程序里这段代码也不会去执行,不用去管它
  18. ;==================================================================================
  19. ;通过设置CP15的C1的位7,设置存储格式为Bigendian,三种总线方式
  20. ChangeBigEndian;//hereENTRY_BUS_WIDTH=16
  21. ;@0x24
  22. [ENTRY_BUS_WIDTH=32
  23. DCD0xee110f10;0xee110f10=>mrcp15,0,r0,c1,c0,0
  24. DCD0xe3800080;0xe3800080=>orrr0,r0,#0x80;//Big-endian
  25. DCD0xee010f10;0xee010f10=>mcrp15,0,r0,c1,c0,0
  26. ;对存储器控制寄存器操作,指定内存模式为Big-endian
  27. ;因为刚开始CPU都是按照32位总线的指令格式运行的,如果采用其他的话,CPU别不了,必须转化
  28. ;但当系统初始化好以后,则CPU能自动识别
  29. ]
  30. [ENTRY_BUS_WIDTH=16
  31. DCD0x0f10ee11
  32. DCD0x0080e380
  33. DCD0x0f10ee01
  34. ;因为采用Big-endian模式,采用16位总线时,物理地址的高位和数据的地位对应
  35. ;所以指令的机器码也相应的高低对调
  36. ]
  37. [ENTRY_BUS_WIDTH=8
  38. DCD0x100f11ee
  39. DCD0x800080e3
  40. DCD0x100f01ee
  41. ]
  42. DCD0xffffffff;swinv0xffffffissimilarwithNOPandrunwellinbothendianmode.
  43. DCD0xffffffff
  44. DCD0xffffffff
  45. DCD0xffffffff
  46. DCD0xffffffff
  47. bResetHandler
  48. ;=========================================================================================
  49. ;Functionforenteringpowerdownmode
  50. ;1.SDRAMshouldbeinself-refreshmode.
  51. ;2.AllinterruptshouldbemakskedforSDRAM/DRAMself-refresh.
  52. ;3.LCDcontrollershouldbedisabledforSDRAM/DRAMself-refresh.
  53. ;4.TheI-cachemayhavetobeturnedon.
  54. ;5.Thelocationofthefollowingcodemayhavenottobechanged.
  55. ;voidEnterPWDN(intCLKCON);
  56. EnterPWDN
  57. movr2,r0;r2=rCLKCON保存原始数据0x4c00000c使能各模块的时钟输入
  58. tstr0,#0x8;测试bit[3]SLEEPmode?1=>sleep
  59. bneENTER_SLEEP;C=0,即TST结果非0,bit[3]=1
  60. ;//进入PWDN后如果不是sleep则进入stop
  61. ;//进入Stopmode
  62. ENTER_STOP
  63. ldrr0,=REFRESH;0x48000024DRAM/SDRAMrefreshconfig
  64. ldrr3,[r0];r3=rREFRESH
  65. movr1,r3
  66. orrr1,r1,#BIT_SELFREFRESH;EnableSDRAMself-refresh
  67. strr1,[r0];EnableSDRAMself-refresh
  68. movr1,#16;waituntilself-refreshisissued.maynotbeneeded.
  69. 0
  70. subsr1,r1,#1
  71. bne%B0
  72. ;//wait16fclksforself-refresh
  73. ldrr0,=CLKCON;enterSTOPmode.
  74. strr2,[r0]
  75. movr1,#32
  76. 0
  77. subsr1,r1,#1;1)waituntiltheSTOPmodeisineffect.
  78. bne%B0;2)OrwaithereuntiltheCPU&Peripheralswillbeturned-off
  79. ;EnteringSLEEPmode,onlytheresetbywake-upisavailable.
  80. ldrr0,=REFRESH;exitfromSDRAMselfrefreshmode.
  81. strr3,[r0]
  82. MOV_PC_LR;backtomainprocess
  83. ENTER_SLEEP
  84. ;NOTE.
  85. ;1)rGSTATUS3shouldhavethereturnaddressafterwake-upfromSLEEPmode.
  86. ldrr0,=REFRESH
  87. ldrr1,[r0];r1=rREFRESH
  88. orrr1,r1,#BIT_SELFREFRESH
  89. strr1,[r0];EnableSDRAMself-refresh
  90. ;//EnableSDRAMself-refresh
  91. movr1,#16;Waituntilself-refreshisissued,whichmaynotbeneeded.
  92. 0
  93. subsr1,r1,#1
  94. bne%B0
  95. ;//Waituntilself-refreshisissued,whichmaynotbeneeded
  96. ldrr1,=MISCCR;IOregister
  97. ldrr0,[r1]
  98. orrr0,r0,#(7<17);SetSCLK0=1,SCLK1=1,SCKE=1.
  99. strr0,[r1]
  100. ldrr0,=CLKCON;Entersleepmode
  101. strr2,[r0]
  102. b.;CPUwilldiehere.
  103. ;//进入SleepMode,1)设置SDRAM为self-refresh
  104. ;//2)设置MISCCRbit[17]1:sclk0=sclk0:sclk0=0
  105. ;//bit[18]1:sclk1=sclk0:sclk1=0
  106. ;//bit[19]1:Selfrefreshretainenable
  107. ;//0:Selfrefreshretaindisable
  108. ;//When1,Afterwake-upfromsleep,Theself-refreshwillberetained.
  109. WAKEUP_SLEEP
  110. ;ReleaseSCLKnafterwake-upfromtheSLEEPmode.
  111. ldrr1,=MISCCR
  112. ldrr0,[r1]
  113. bicr0,r0,#(7<17);SCLK0:0->SCLK,SCLK1:0->SCLK,SCKE:0->=SCKE.
  114. strr0,[r1]
  115. ;//设置MISCCR
  116. ;Setmemorycontrolregisters
  117. ;ldrr0,=SMRDATA
  118. adrlr0,SMRDATA
  119. ldrr1,=BWSCON;BWSCONAddress;//总线宽度和等待控制寄存器
  120. addr2

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

网站地图

Top