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

S3C2440启动代码分析

时间:11-21 来源:互联网 点击:
  1. NOINT
  2. orrr1,r0,#SVCMODE
  3. msrcpsr_cxsf,r1;SVCMode
  4. ldrsp,=SVCStack;SVCStack=0x33FF_5800
  5. ;USERmodehasnotbeinitialized.
  6. ;//为什么不用初始化user的stacks,系统刚启动的时候运行在哪个模式下?
  7. movpc,lr
  8. ;TheLRregisterwontbevalidifthecurrentmodeisnotSVCmode.?
  9. ;//系统一开始运行就是SVCmode?
  10. ;===========================================================
  11. ReadNandID
  12. movr7,#NFCONF
  13. ldrr0,[r7,#4];NFChipEn();
  14. bicr0,r0,#2
  15. strr0,[r7,#4]
  16. movr0,#0x90;WrNFCmd(RdIDCMD);
  17. strbr0,[r7,#8]
  18. movr4,#0;WrNFAddr(0);
  19. strbr4,[r7,#0xc]
  20. 1;while(NFIsBusy());
  21. ldrr0,[r7,#0x20]
  22. tstr0,#1
  23. beq%B1
  24. ldrbr0,[r7,#0x10];id=RdNFDat()<8;
  25. movr0,r0,lsl#8
  26. ldrbr1,[r7,#0x10];id|=RdNFDat();
  27. orrr5,r1,r0
  28. ldrr0,[r7,#4];NFChipDs();
  29. orrr0,r0,#2
  30. strr0,[r7,#4]
  31. movpc,lr
  32. ReadNandStatus
  33. movr7,#NFCONF
  34. ldrr0,[r7,#4];NFChipEn();
  35. bicr0,r0,#2
  36. strr0,[r7,#4]
  37. movr0,#0x70;WrNFCmd(QUERYCMD);
  38. strbr0,[r7,#8]
  39. ldrbr1,[r7,#0x10];r1=RdNFDat();
  40. ldrr0,[r7,#4];NFChipDs();
  41. orrr0,r0,#2
  42. strr0,[r7,#4]
  43. movpc,lr
  44. WaitNandBusy
  45. movr0,#0x70;WrNFCmd(QUERYCMD);
  46. movr1,#NFCONF
  47. strbr0,[r1,#8]
  48. 1;while(!(RdNFDat()&0x40));
  49. ldrbr0,[r1,#0x10]
  50. tstr0,#0x40
  51. beq%B1
  52. movr0,#0;WrNFCmd(READCMD0);
  53. strbr0,[r1,#8]
  54. movpc,lr
  55. CheckBadBlk
  56. movr7,lr
  57. movr5,#NFCONF
  58. bicr0,r0,#0x1f;addr&=~0x1f;
  59. ldrr1,[r5,#4];NFChipEn()
  60. bicr1,r1,#2
  61. strr1,[r5,#4]
  62. movr1,#0x50;WrNFCmd(READCMD2)
  63. strbr1,[r5,#8]
  64. movr1,#5;6;6->5
  65. strbr1,[r5,#0xc];WrNFAddr(5);(6)6->5
  66. strbr0,[r5,#0xc];WrNFAddr(addr)
  67. movr1,r0,lsr#8;WrNFAddr(addr>>8)
  68. strbr1,[r5,#0xc]
  69. cmpr6,#0;if(NandAddr)
  70. movner0,r0,lsr#16;WrNFAddr(addr>>16)
  71. strnebr0,[r5,#0xc]
  72. ;blWaitNandBusy;WaitNFBusy()
  73. ;donotuseWaitNandBusy,afterWaitNandBusywillreadpartA!
  74. movr0,#100
  75. 1
  76. subsr0,r0,#1
  77. bne%B1
  78. 2
  79. ldrr0,[r5,#0x20]
  80. tstr0,#1
  81. beq%B2
  82. ldrbr0,[r5,#0x10];RdNFDat()
  83. subr0,r0,#0xff
  84. movr1,#0;WrNFCmd(READCMD0)
  85. strbr1,[r5,#8]
  86. ldrr1,[r5,#4];NFChipDs()
  87. orrr1,r1,#2
  88. strr1,[r5,#4]
  89. movpc,r7
  90. ReadNandPage
  91. movr7,lr
  92. movr4,r1
  93. movr5,#NFCONF
  94. ldrr1,[r5,#4];NFChipEn()
  95. bicr1,r1,#2
  96. strr1,[r5,#4]
  97. movr1,#0;WrNFCmd(READCMD0)
  98. strbr1,[r5,#8]
  99. strbr1,[r5,#0xc];WrNFAddr(0)
  100. strbr0,[r5,#0xc];WrNFAddr(addr)
  101. movr1,r0,lsr#8;WrNFAddr(addr>>8)
  102. strbr1,[r5,#0xc]
  103. cmpr6,#0;if(NandAddr)
  104. movner0,r0,lsr#16;WrNFAddr(addr>>16)
  105. strnebr0,[r5,#0xc]
  106. ldrr0,[r5,#4];InitEcc()
  107. orrr0,r0,#0x10
  108. strr0,[r5,#4]
  109. blWaitNandBusy;WaitNFBusy()
  110. movr0,#0;for(i=0;i<512;i++)
  111. 1
  112. ldrbr1,[r5,#0x10];buf[i]=RdNFDat()
  113. strbr1,[r4,r0]
  114. addr0,r0,#1
  115. bicr0,r0,#0x10000
  116. cmpr0,#0x200
  117. bcc%B1
  118. ldrr0,[r5,#4];NFChipDs()
  119. orrr0,r0,#2
  120. strr0,[r5,#4]
  121. movpc,r7
  122. ;--------------------LEDtest
  123. EXPORTLed_Test
  124. Led_Test
  125. movr0,#0x56000000
  126. movr1,#0x5500
  127. strr1,[r0,#0x50]
  128. 0
  129. movr1,#0x50
  130. strr1,[r0,#0x54]
  131. movr2,#0x100000
  132. 1
  133. subsr2,r2,#1
  134. bne%B1
  135. movr1,#0xa0
  136. strr1,[r0,#0x54]
  137. movr2,#0x100000
  138. 2
  139. subsr2,r2,#1
  140. bne%B2
  141. b%B0
  142. movpc,lr
  143. ;===========================================================
  144. ;=====================================================================
  145. ;Clockdivisiontest
  146. ;Assemblecode,becauseVSYNCtimeisveryshort
  147. ;=====================================================================
  148. EXPORTCLKdiv124
  149. EXPORTCLKdiv144
  150. CLKdiv124
  151. ldrr0,=CLKdivN
  152. ldrr1,=0x3;0x3=1:2:4
  153. strr1,[r0]
  154. ;waituntilclockisstable
  155. nop
  156. nop
  157. nop
  158. nop
  159. nop
  160. ldrr0,=REFRESH
  161. ldrr1,[r0]
  162. bicr1,r1,#0xff
  163. bicr1,r1,#(0x7<8)
  164. orrr1,r1,#0x470;REFCNT135
  165. strr1,[r0]
  166. nop
  167. nop
  168. nop
  169. nop
  170. nop
  171. movpc,lr
  172. CLKdiv144
  173. ldrr0,=CLKdivN
  174. ldrr1,=0x4;0x4=1:4:4
  175. strr1,[r0]
  176. ;waituntilclockisstable
  177. nop
  178. nop
  179. nop
  180. nop
  181. nop
  182. ldrr0,=REFRESH
  183. ldrr1,[r0]
  184. bicr1,r1,#0xff
  185. bicr1,r1,#(0x7<8)
  186. orrr1,r1,#0x630;REFCNT675-1520
  187. strr1,[r0]
  188. nop
  189. nop
  190. nop
  191. nop
  192. nop
  193. movpc,lr
  194. ;存储器控制寄存器的定义区
  195. LTORG
  196. SMRDATADATA
  197. ;Memoryconfigurationshouldbeoptimizedforbestperformance
  198. ;Thefollowingparameterisnotoptimized.
  199. ;Memoryaccesscycleparameterstrategy
  200. ;1)ThememorysettingsissafeparametersevenatHCLK=75Mhz.
  201. ;2)SDRAMrefreshperiodisforHCLK<=75Mhz.
  202. DCD(0+(B1_BWSCON<4)+(B2_BWSCON<8)+(B3_BWSCON<12)+(B4_BWSCON<16)+(B5_BWSCON<20)+(B6_BWSCON<24)+(B7_BWSCON<28));各bank的buswidth;没有B0,因为由OM[1:0]pins确定
  203. DCD((B0_Tacs<13)+(B0_Tcos<11)+(B0_Tacc<8)+(B0_Tcoh<6)+(B0_Tah<4)+(B0_Tacp<2)+(B0_PMC));GCS0
  204. DCD((B1_Tacs<13)+(B1_Tcos<11)+(B1_Tacc<8)+(B1_Tcoh<6)+(B1_Tah<4)+(B1_Tacp<2)+(B1_PMC));GCS1
  205. DCD((B2_Tacs<13)+(B2_Tcos<11)+(B2_Tacc<8)+(B2_Tcoh<6)+(B2_Tah<4)+(B2_Tacp<2)+(B2_PMC));GCS2
  206. DCD((B3_Tacs<13)+(B3_Tcos<11)+(B3_Tacc<8)+(B3_Tcoh<6)+(B3_Tah<4)+(B3_Tacp<2)+(B3_PMC));GCS3
  207. DCD((B4_Tacs<13)+(B4_Tcos<11)+(B4_Tacc<8)+(B4_Tcoh<6)+(B4_Tah<4)+(B4_Tacp<2)+(B4_PMC));GCS4
  208. DCD((B5_Tacs<13)+(B5_Tcos<11)+(B5_Tacc<8)+(B5_Tcoh<6)+(B5_Tah<4)+(B5_Tacp<2)+(B5_PMC));GCS5
  209. DCD((B6_MT<15)+(B6_Trcd<2)+(B6_SCAN));GCS6B6_MT定义在memcfg.inc中,11-->SDRAM;B6_SCAN-非reset默认值
  210. DCD((B7_MT<15)+(B7_Trcd<2)+(B7_SCAN));GCS7
  211. DCD((REFEN<23)+(TREFMD<22)+(Trp<20)+(Trc<18)+(Tchr<16)+REFCNT);Tchr-notused
  212. ;DCD0x32;SCLKpowersavin

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

网站地图

Top