1
0

start_rvds.S 53 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190
  1. ;/*****************************************************************************/
  2. ;/* S3C2440.S: Startup file for Samsung S3C440 */
  3. ;/*****************************************************************************/
  4. ;/* <<< Use Configuration Wizard in Context Menu >>> */
  5. ;/*****************************************************************************/
  6. ;/* This file is part of the uVision/ARM development tools. */
  7. ;/* Copyright (c) 2005-2008 Keil Software. All rights reserved. */
  8. ;/* This software may only be used under the terms of a valid, current, */
  9. ;/* end user licence from KEIL for a compatible version of KEIL software */
  10. ;/* development tools. Nothing else gives you the right to use this software. */
  11. ;/*****************************************************************************/
  12. ;/*
  13. ; * The S3C2440.S code is executed after CPU Reset. This file may be
  14. ; * translated with the following SET symbols. In uVision these SET
  15. ; * symbols are entered under Options - ASM - Define.
  16. ; *
  17. ; * NO_CLOCK_SETUP: when set the startup code will not initialize Clock
  18. ; * (used mostly when clock is already initialized from script .ini
  19. ; * file).
  20. ; *
  21. ; * NO_MC_SETUP: when set the startup code will not initialize Memory
  22. ; * Controller (used mostly when clock is already initialized from script
  23. ; * .ini file).
  24. ; *
  25. ; * NO_GP_SETUP: when set the startup code will not initialize General Ports
  26. ; * (used mostly when clock is already initialized from script .ini
  27. ; * file).
  28. ; *
  29. ; * RAM_INTVEC: when set the startup code copies exception vectors
  30. ; * from execution address to on-chip RAM.
  31. ; */
  32. ; Standard definitions of Mode bits and Interrupt (I & F) flags in PSRs
  33. Mode_USR EQU 0x10
  34. Mode_FIQ EQU 0x11
  35. Mode_IRQ EQU 0x12
  36. Mode_SVC EQU 0x13
  37. Mode_ABT EQU 0x17
  38. Mode_UND EQU 0x1B
  39. Mode_SYS EQU 0x1F
  40. I_Bit EQU 0x80 ; when I bit is set, IRQ is disabled
  41. F_Bit EQU 0x40 ; when F bit is set, FIQ is disabled
  42. ;----------------------- Stack and Heap Definitions ----------------------------
  43. ;// <h> Stack Configuration (Stack Sizes in Bytes)
  44. ;// <o0> Undefined Mode <0x0-0xFFFFFFFF:8>
  45. ;// <o1> Supervisor Mode <0x0-0xFFFFFFFF:8>
  46. ;// <o2> Abort Mode <0x0-0xFFFFFFFF:8>
  47. ;// <o3> Fast Interrupt Mode <0x0-0xFFFFFFFF:8>
  48. ;// <o4> Interrupt Mode <0x0-0xFFFFFFFF:8>
  49. ;// <o5> User/System Mode <0x0-0xFFFFFFFF:8>
  50. ;// </h>
  51. UND_Stack_Size EQU 0x00000000
  52. SVC_Stack_Size EQU 0x00000100
  53. ABT_Stack_Size EQU 0x00000000
  54. FIQ_Stack_Size EQU 0x00000000
  55. IRQ_Stack_Size EQU 0x00000100
  56. USR_Stack_Size EQU 0x00000100
  57. ISR_Stack_Size EQU (UND_Stack_Size + SVC_Stack_Size + ABT_Stack_Size + \
  58. FIQ_Stack_Size + IRQ_Stack_Size)
  59. AREA STACK, NOINIT, READWRITE, ALIGN=3
  60. Stack_Mem SPACE USR_Stack_Size
  61. __initial_sp SPACE ISR_Stack_Size
  62. Stack_Top
  63. ;// <h> Heap Configuration
  64. ;// <o> Heap Size (in Bytes) <0x0-0xFFFFFFFF>
  65. ;// </h>
  66. Heap_Size EQU 0x00000000
  67. AREA HEAP, NOINIT, READWRITE, ALIGN=3
  68. __heap_base
  69. Heap_Mem SPACE Heap_Size
  70. __heap_limit
  71. ;----------------------- Memory Definitions ------------------------------------
  72. ; Internal Memory Base Addresses
  73. IRAM_BASE EQU 0x40000000
  74. ;----------------------- Watchdog Timer Definitions ----------------------------
  75. WT_BASE EQU 0x53000000 ; Watchdog Timer Base Address
  76. WTCON_OFS EQU 0x00 ; Watchdog Timer Control Register Offset
  77. WTDAT_OFS EQU 0x04 ; Watchdog Timer Data Register Offset
  78. WTCNT_OFS EQU 0x08 ; Watchdog Timer Count Register Offset
  79. ;// <e> Watchdog Timer Setup
  80. ;// <h> Watchdog Timer Control Register (WTCON)
  81. ;// <o1.8..15> Prescaler Value <0-255>
  82. ;// <o1.5> Watchdog Timer Enable
  83. ;// <o1.3..4> Clock Division Factor
  84. ;// <0=> 16 <1=> 32 <2=> 64 <3=> 128
  85. ;// <o1.2> Interrupt Generation Enable
  86. ;// <o1.0> Reset Enable
  87. ;// </h>
  88. ;// <h> Watchdog Timer Data Register (WTDAT)
  89. ;// <o2.0..15> Count Reload Value <0-65535>
  90. ;// </h>
  91. ;// </e> Watchdog Timer Setup
  92. WT_SETUP EQU 1
  93. WTCON_Val EQU 0x00000000
  94. WTDAT_Val EQU 0x00008000
  95. ;----------------------- Clock and Power Management Definitions ----------------
  96. CLOCK_BASE EQU 0x4C000000 ; Clock Base Address
  97. LOCKTIME_OFS EQU 0x00 ; PLL Lock Time Count Register Offset
  98. MPLLCON_OFS EQU 0x04 ; MPLL Configuration Register Offset
  99. UPLLCON_OFS EQU 0x08 ; UPLL Configuration Register Offset
  100. CLKCON_OFS EQU 0x0C ; Clock Generator Control Reg Offset
  101. CLKSLOW_OFS EQU 0x10 ; Clock Slow Control Register Offset
  102. CLKDIVN_OFS EQU 0x14 ; Clock Divider Control Register Offset
  103. CAMDIVN_OFS EQU 0x18 ; Camera Clock Divider Register Offset
  104. ;// <e> Clock Setup
  105. ;// <h> PLL Lock Time Count Register (LOCKTIME)
  106. ;// <o1.16..31> U_LTIME: UPLL Lock Time Count Value for UCLK <0x0-0xFFFF>
  107. ;// <o1.0..15> M_LTIME: MPLL Lock Time Count Value for FCLK, HCLK and PCLK <0x0-0xFFFF>
  108. ;// </h>
  109. ;// <h> MPLL Configuration Register (MPLLCON)
  110. ;// <i> MPLL = (2 * m * Fin) / (p * 2^s)
  111. ;// <o2.12..19> m: Main Divider m Value <9-256><#-8>
  112. ;// <i> m = MDIV + 8
  113. ;// <o2.4..9> p: Pre-divider p Value <3-64><#-2>
  114. ;// <i> p = PDIV + 2
  115. ;// <o2.0..1> s: Post Divider s Value <0-3>
  116. ;// <i> s = SDIV
  117. ;// </h>
  118. ;// <h> UPLL Configuration Register (UPLLCON)
  119. ;// <i> UPLL = ( m * Fin) / (p * 2^s)
  120. ;// <o3.12..19> m: Main Divider m Value <8-263><#-8>
  121. ;// <i> m = MDIV + 8
  122. ;// <o3.4..9> p: Pre-divider p Value <2-65><#-2>
  123. ;// <i> p = PDIV + 2
  124. ;// <o3.0..1> s: Post Divider s Value <0-3>
  125. ;// <i> s = SDIV
  126. ;// </h>
  127. ;// <h> Clock Generation Control Register (CLKCON)
  128. ;// <o4.20> AC97 Enable
  129. ;// <o4.19> Camera Enable
  130. ;// <o4.18> SPI Enable
  131. ;// <o4.17> IIS Enable
  132. ;// <o4.16> IIC Enable
  133. ;// <o4.15> ADC + Touch Screen Enable
  134. ;// <o4.14> RTC Enable
  135. ;// <o4.13> GPIO Enable
  136. ;// <o4.12> UART2 Enable
  137. ;// <o4.11> UART1 Enable
  138. ;// <o4.10> UART0 Enable
  139. ;// <o4.9> SDI Enable
  140. ;// <o4.8> PWMTIMER Enable
  141. ;// <o4.7> USB Device Enable
  142. ;// <o4.6> USB Host Enable
  143. ;// <o4.5> LCDC Enable
  144. ;// <o4.4> NAND FLASH Controller Enable
  145. ;// <o4.3> SLEEP Enable
  146. ;// <o4.2> IDLE BIT Enable
  147. ;// </h>
  148. ;// <h> Clock Slow Control Register (CLKSLOW)
  149. ;// <o5.7> UCLK_ON: UCLK ON
  150. ;// <o5.5> MPLL_OFF: Turn off PLL
  151. ;// <o5.4> SLOW_BIT: Slow Mode Enable
  152. ;// <o5.0..2> SLOW_VAL: Slow Clock Divider <0-7>
  153. ;// </h>
  154. ;// <h> Clock Divider Control Register (CLKDIVN)
  155. ;// <o6.3> DIVN_UPLL: UCLK Select
  156. ;// <0=> UCLK = UPLL clock
  157. ;// <1=> UCLK = UPLL clock / 2
  158. ;// <o6.1..2> HDIVN: HCLK Select
  159. ;// <0=> HCLK = FCLK
  160. ;// <1=> HCLK = FCLK / 2
  161. ;// <2=> HCLK = FCLK / 4 if HCLK4_HALF = 0 in CAMDIVN, else HCLK = FCLK / 8
  162. ;// <3=> HCLK = FCLK / 3 if HCLK3_HALF = 0 in CAMDIVN, else HCLK = FCLK / 6
  163. ;// <o6.0> PDIVN: PCLK Select
  164. ;// <0=> PCLK = HCLK
  165. ;// <1=> PCLK = HCLK / 2
  166. ;// </h>
  167. ;// <h> Camera Clock Divider Control Register (CAMDIVN)
  168. ;// <o7.12> DVS_EN: ARM Core Clock Select
  169. ;// <0=> ARM core runs at FCLK
  170. ;// <1=> ARM core runs at HCLK
  171. ;// <o7.9> HCLK4_HALF: HDIVN Division Rate Change Bit
  172. ;// <0=> If HDIVN = 2 in CLKDIVN then HCLK = FCLK / 4
  173. ;// <1=> If HDIVN = 2 in CLKDIVN then HCLK = FCLK / 8
  174. ;// <o7.8> HCLK3_HALF: HDIVN Division Rate Change Bit
  175. ;// <0=> If HDIVN = 3 in CLKDIVN then HCLK = FCLK / 3
  176. ;// <1=> If HDIVN = 3 in CLKDIVN then HCLK = FCLK / 6
  177. ;// <o7.4> CAMCLK Select
  178. ;// <0=> CAMCLK = UPLL
  179. ;// <1=> CAMCLK = UPLL / CAMCLK_DIV
  180. ;// <o7.0..3> CAMCLK_DIV: CAMCLK Divider <0-15>
  181. ;// <i> Camera Clock = UPLL / (2 * (CAMCLK_DIV + 1))
  182. ;// <i> Divider is used only if CAMCLK_SEL = 1
  183. ;// </h>
  184. ;// </e> Clock Setup
  185. CLOCK_SETUP EQU 0
  186. LOCKTIME_Val EQU 0x0FFF0FFF
  187. MPLLCON_Val EQU 0x00043011
  188. UPLLCON_Val EQU 0x00038021
  189. CLKCON_Val EQU 0x001FFFF0
  190. CLKSLOW_Val EQU 0x00000004
  191. CLKDIVN_Val EQU 0x0000000F
  192. CAMDIVN_Val EQU 0x00000000
  193. ;----------------------- Memory Controller Definitions -------------------------
  194. MC_BASE EQU 0x48000000 ; Memory Controller Base Address
  195. BWSCON_OFS EQU 0x00 ; Bus Width and Wait Status Ctrl Offset
  196. BANKCON0_OFS EQU 0x04 ; Bank 0 Control Register Offset
  197. BANKCON1_OFS EQU 0x08 ; Bank 1 Control Register Offset
  198. BANKCON2_OFS EQU 0x0C ; Bank 2 Control Register Offset
  199. BANKCON3_OFS EQU 0x10 ; Bank 3 Control Register Offset
  200. BANKCON4_OFS EQU 0x14 ; Bank 4 Control Register Offset
  201. BANKCON5_OFS EQU 0x18 ; Bank 5 Control Register Offset
  202. BANKCON6_OFS EQU 0x1C ; Bank 6 Control Register Offset
  203. BANKCON7_OFS EQU 0x20 ; Bank 7 Control Register Offset
  204. REFRESH_OFS EQU 0x24 ; SDRAM Refresh Control Register Offset
  205. BANKSIZE_OFS EQU 0x28 ; Flexible Bank Size Register Offset
  206. MRSRB6_OFS EQU 0x2C ; Bank 6 Mode Register Offset
  207. MRSRB7_OFS EQU 0x30 ; Bank 7 Mode Register Offset
  208. ;// <e> Memory Controller Setup
  209. ;// <h> Bus Width and Wait Control Register (BWSCON)
  210. ;// <o1.31> ST7: Use UB/LB for Bank 7
  211. ;// <o1.30> WS7: Enable Wait Status for Bank 7
  212. ;// <o1.28..29> DW7: Data Bus Width for Bank 7
  213. ;// <0=> 8-bit <1=> 16-bit <2=> 32-bit <3=> Reserved
  214. ;// <o1.27> ST6: Use UB/LB for Bank 6
  215. ;// <o1.26> WS6: Enable Wait Status for Bank 6
  216. ;// <o1.24..25> DW6: Data Bus Width for Bank 6
  217. ;// <0=> 8-bit <1=> 16-bit <2=> 32-bit <3=> Reserved
  218. ;// <o1.23> ST5: Use UB/LB for Bank 5
  219. ;// <o1.22> WS5: Enable Wait Status for Bank 5
  220. ;// <o1.20..21> DW5: Data Bus Width for Bank 5
  221. ;// <0=> 8-bit <1=> 16-bit <2=> 32-bit <3=> Reserved
  222. ;// <o1.19> ST4: Use UB/LB for Bank 4
  223. ;// <o1.18> WS4: Enable Wait Status for Bank 4
  224. ;// <o1.16..17> DW4: Data Bus Width for Bank 4
  225. ;// <0=> 8-bit <1=> 16-bit <2=> 32-bit <3=> Reserved
  226. ;// <o1.15> ST3: Use UB/LB for Bank 3
  227. ;// <o1.14> WS3: Enable Wait Status for Bank 3
  228. ;// <o1.12..13> DW3: Data Bus Width for Bank 3
  229. ;// <0=> 8-bit <1=> 16-bit <2=> 32-bit <3=> Reserved
  230. ;// <o1.11> ST2: Use UB/LB for Bank 2
  231. ;// <o1.10> WS2: Enable Wait Status for Bank 2
  232. ;// <o1.8..9> DW2: Data Bus Width for Bank 2
  233. ;// <0=> 8-bit <1=> 16-bit <2=> 32-bit <3=> Reserved
  234. ;// <o1.7> ST1: Use UB/LB for Bank 1
  235. ;// <o1.6> WS1: Enable Wait Status for Bank 1
  236. ;// <o1.4..5> DW1: Data Bus Width for Bank 1
  237. ;// <0=> 8-bit <1=> 16-bit <2=> 32-bit <3=> Reserved
  238. ;// <o1.1..2> DW0: Indicate Data Bus Width for Bank 0
  239. ;// <1=> 16-bit <2=> 32-bit
  240. ;// </h>
  241. ;// <h> Bank 0 Control Register (BANKCON0)
  242. ;// <o2.13..14> Tacs: Address Set-up Time before nGCS
  243. ;// <0=> 0 clocks <1=> 1 clocks <2=> 2 clocks <3=> 4 clocks
  244. ;// <o2.11..12> Tcos: Chip Selection Set-up Time before nOE
  245. ;// <0=> 0 clocks <1=> 1 clocks <2=> 2 clocks <3=> 4 clocks
  246. ;// <o2.8..10> Tacc: Access Cycle
  247. ;// <0=> 1 clocks <1=> 2 clocks <2=> 3 clocks <3=> 4 clocks
  248. ;// <4=> 6 clocks <5=> 8 clocks <6=> 10 clocks <7=> 14 clocks
  249. ;// <o2.6..7> Tcoh: Chip Selection Hold Time after nOE
  250. ;// <0=> 0 clocks <1=> 1 clocks <2=> 2 clocks <3=> 4 clocks
  251. ;// <o2.4..5> Tcah: Address Hold Time after nGCS
  252. ;// <0=> 0 clocks <1=> 1 clocks <2=> 2 clocks <3=> 4 clocks
  253. ;// <o2.2..3> Tacp: Page Mode Access Cycle at Page Mode
  254. ;// <0=> 2 clocks <1=> 3 clocks <2=> 4 clocks <3=> 6 clocks
  255. ;// <o2.0..1> PMC: Page Mode Configuration
  256. ;// <0=> normal (1 data) <1=> 4 data <2=> 8 data <3=> 16 data
  257. ;// </h>
  258. ;// <h> Bank 1 Control Register (BANKCON1)
  259. ;// <o3.13..14> Tacs: Address Set-up Time before nGCS
  260. ;// <0=> 0 clocks <1=> 1 clocks <2=> 2 clocks <3=> 4 clocks
  261. ;// <o3.11..12> Tcos: Chip Selection Set-up Time before nOE
  262. ;// <0=> 0 clocks <1=> 1 clocks <2=> 2 clocks <3=> 4 clocks
  263. ;// <o3.8..10> Tacc: Access Cycle
  264. ;// <0=> 1 clocks <1=> 2 clocks <2=> 3 clocks <3=> 4 clocks
  265. ;// <4=> 6 clocks <5=> 8 clocks <6=> 10 clocks <7=> 14 clocks
  266. ;// <o3.6..7> Tcoh: Chip Selection Hold Time after nOE
  267. ;// <0=> 0 clocks <1=> 1 clocks <2=> 2 clocks <3=> 4 clocks
  268. ;// <o3.4..5> Tcah: Address Hold Time after nGCS
  269. ;// <0=> 0 clocks <1=> 1 clocks <2=> 2 clocks <3=> 4 clocks
  270. ;// <o3.2..3> Tacp: Page Mode Access Cycle at Page Mode
  271. ;// <0=> 2 clocks <1=> 3 clocks <2=> 4 clocks <3=> 6 clocks
  272. ;// <o3.0..1> PMC: Page Mode Configuration
  273. ;// <0=> normal (1 data) <1=> 4 data <2=> 8 data <3=> 16 data
  274. ;// </h>
  275. ;// <h> Bank 2 Control Register (BANKCON2)
  276. ;// <o4.13..14> Tacs: Address Set-up Time before nGCS
  277. ;// <0=> 0 clocks <1=> 1 clocks <2=> 2 clocks <3=> 4 clocks
  278. ;// <o4.11..12> Tcos: Chip Selection Set-up Time before nOE
  279. ;// <0=> 0 clocks <1=> 1 clocks <2=> 2 clocks <3=> 4 clocks
  280. ;// <o4.8..10> Tacc: Access Cycle
  281. ;// <0=> 1 clocks <1=> 2 clocks <2=> 3 clocks <3=> 4 clocks
  282. ;// <4=> 6 clocks <5=> 8 clocks <6=> 10 clocks <7=> 14 clocks
  283. ;// <o4.6..7> Tcoh: Chip Selection Hold Time after nOE
  284. ;// <0=> 0 clocks <1=> 1 clocks <2=> 2 clocks <3=> 4 clocks
  285. ;// <o4.4..5> Tcah: Address Hold Time after nGCS
  286. ;// <0=> 0 clocks <1=> 1 clocks <2=> 2 clocks <3=> 4 clocks
  287. ;// <o4.2..3> Tacp: Page Mode Access Cycle at Page Mode
  288. ;// <0=> 2 clocks <1=> 3 clocks <2=> 4 clocks <3=> 6 clocks
  289. ;// <o4.0..1> PMC: Page Mode Configuration
  290. ;// <0=> normal (1 data) <1=> 4 data <2=> 8 data <3=> 16 data
  291. ;// </h>
  292. ;// <h> Bank 3 Control Register (BANKCON3)
  293. ;// <o5.13..14> Tacs: Address Set-up Time before nGCS
  294. ;// <0=> 0 clocks <1=> 1 clocks <2=> 2 clocks <3=> 4 clocks
  295. ;// <o5.11..12> Tcos: Chip Selection Set-up Time before nOE
  296. ;// <0=> 0 clocks <1=> 1 clocks <2=> 2 clocks <3=> 4 clocks
  297. ;// <o5.8..10> Tacc: Access Cycle
  298. ;// <0=> 1 clocks <1=> 2 clocks <2=> 3 clocks <3=> 4 clocks
  299. ;// <4=> 6 clocks <5=> 8 clocks <6=> 10 clocks <7=> 14 clocks
  300. ;// <o5.6..7> Tcoh: Chip Selection Hold Time after nOE
  301. ;// <0=> 0 clocks <1=> 1 clocks <2=> 2 clocks <3=> 4 clocks
  302. ;// <o5.4..5> Tcah: Address Hold Time after nGCS
  303. ;// <0=> 0 clocks <1=> 1 clocks <2=> 2 clocks <3=> 4 clocks
  304. ;// <o5.2..3> Tacp: Page Mode Access Cycle at Page Mode
  305. ;// <0=> 2 clocks <1=> 3 clocks <2=> 4 clocks <3=> 6 clocks
  306. ;// <o5.0..1> PMC: Page Mode Configuration
  307. ;// <0=> normal (1 data) <1=> 4 data <2=> 8 data <3=> 16 data
  308. ;// </h>
  309. ;// <h> Bank 4 Control Register (BANKCON4)
  310. ;// <o6.13..14> Tacs: Address Set-up Time before nGCS
  311. ;// <0=> 0 clocks <1=> 1 clocks <2=> 2 clocks <3=> 4 clocks
  312. ;// <o6.11..12> Tcos: Chip Selection Set-up Time before nOE
  313. ;// <0=> 0 clocks <1=> 1 clocks <2=> 2 clocks <3=> 4 clocks
  314. ;// <o6.8..10> Tacc: Access Cycle
  315. ;// <0=> 1 clocks <1=> 2 clocks <2=> 3 clocks <3=> 4 clocks
  316. ;// <4=> 6 clocks <5=> 8 clocks <6=> 10 clocks <7=> 14 clocks
  317. ;// <o6.6..7> Tcoh: Chip Selection Hold Time after nOE
  318. ;// <0=> 0 clocks <1=> 1 clocks <2=> 2 clocks <3=> 4 clocks
  319. ;// <o6.4..5> Tcah: Address Hold Time after nGCS
  320. ;// <0=> 0 clocks <1=> 1 clocks <2=> 2 clocks <3=> 4 clocks
  321. ;// <o6.2..3> Tacp: Page Mode Access Cycle at Page Mode
  322. ;// <0=> 2 clocks <1=> 3 clocks <2=> 4 clocks <3=> 6 clocks
  323. ;// <o6.0..1> PMC: Page Mode Configuration
  324. ;// <0=> normal (1 data) <1=> 4 data <2=> 8 data <3=> 16 data
  325. ;// </h>
  326. ;// <h> Bank 5 Control Register (BANKCON5)
  327. ;// <o7.13..14> Tacs: Address Set-up Time before nGCS
  328. ;// <0=> 0 clocks <1=> 1 clocks <2=> 2 clocks <3=> 4 clocks
  329. ;// <o7.11..12> Tcos: Chip Selection Set-up Time before nOE
  330. ;// <0=> 0 clocks <1=> 1 clocks <2=> 2 clocks <3=> 4 clocks
  331. ;// <o7.8..10> Tacc: Access Cycle
  332. ;// <0=> 1 clocks <1=> 2 clocks <2=> 3 clocks <3=> 4 clocks
  333. ;// <4=> 6 clocks <5=> 8 clocks <6=> 10 clocks <7=> 14 clocks
  334. ;// <o7.6..7> Tcoh: Chip Selection Hold Time after nOE
  335. ;// <0=> 0 clocks <1=> 1 clocks <2=> 2 clocks <3=> 4 clocks
  336. ;// <o7.4..5> Tcah: Address Hold Time after nGCS
  337. ;// <0=> 0 clocks <1=> 1 clocks <2=> 2 clocks <3=> 4 clocks
  338. ;// <o7.2..3> Tacp: Page Mode Access Cycle at Page Mode
  339. ;// <0=> 2 clocks <1=> 3 clocks <2=> 4 clocks <3=> 6 clocks
  340. ;// <o7.0..1> PMC: Page Mode Configuration
  341. ;// <0=> normal (1 data) <1=> 4 data <2=> 8 data <3=> 16 data
  342. ;// </h>
  343. ;// <h> Bank 6 Control Register (BANKCON6)
  344. ;// <o8.15..16> Memory Type Selection
  345. ;// <0=> ROM or SRAM <3=> SDRAM
  346. ;// <o8.13..14> Tacs: Address Set-up Time before nGCS
  347. ;// <0=> 0 clocks <1=> 1 clocks <2=> 2 clocks <3=> 4 clocks
  348. ;// <o8.11..12> Tcos: Chip Selection Set-up Time before nOE
  349. ;// <0=> 0 clocks <1=> 1 clocks <2=> 2 clocks <3=> 4 clocks
  350. ;// <o8.8..10> Tacc: Access Cycle
  351. ;// <0=> 1 clocks <1=> 2 clocks <2=> 3 clocks <3=> 4 clocks
  352. ;// <4=> 6 clocks <5=> 8 clocks <6=> 10 clocks <7=> 14 clocks
  353. ;// <o8.6..7> Tcoh: Chip Selection Hold Time after nOE
  354. ;// <0=> 0 clocks <1=> 1 clocks <2=> 2 clocks <3=> 4 clocks
  355. ;// <o8.4..5> Tcah: Address Hold Time after nGCS
  356. ;// <0=> 0 clocks <1=> 1 clocks <2=> 2 clocks <3=> 4 clocks
  357. ;// <o8.2..3> Tacp/Trcd: Page Mode Access Cycle at Page Mode / RAS to CAS Delay
  358. ;// <i> Parameter depends on Memory Type: if type SRAM then parameter is Tacp,
  359. ;// <i> if type is SDRAM then parameter is Trcd
  360. ;// <i> For SDRAM 6 cycles setting is not allowed
  361. ;// <0=> 2 clocks <1=> 3 clocks <2=> 4 clocks <3=> 6 clocks
  362. ;// <o8.0..1> PMC/SCAN: Page Mode Configuration / Column Address Number <0-3>
  363. ;// <i> Parameter depends on Memory Type: if type SRAM then parameter is PMC,
  364. ;// <i> if type is SDRAM then parameter is SCAN
  365. ;// </h>
  366. ;// <h> Bank 7 Control Register (BANKCON7)
  367. ;// <o9.15..16> Memory Type Selection
  368. ;// <0=> ROM or SRAM <3=> SDRAM
  369. ;// <o9.13..14> Tacs: Address Set-up Time before nGCS
  370. ;// <0=> 0 clocks <1=> 1 clocks <2=> 2 clocks <3=> 4 clocks
  371. ;// <o9.11..12> Tcos: Chip Selection Set-up Time before nOE
  372. ;// <0=> 0 clocks <1=> 1 clocks <2=> 2 clocks <3=> 4 clocks
  373. ;// <o9.8..10> Tacc: Access Cycle
  374. ;// <0=> 1 clocks <1=> 2 clocks <2=> 3 clocks <3=> 4 clocks
  375. ;// <4=> 6 clocks <5=> 8 clocks <6=> 10 clocks <7=> 14 clocks
  376. ;// <o9.6..7> Tcoh: Chip Selection Hold Time after nOE
  377. ;// <0=> 0 clocks <1=> 1 clocks <2=> 2 clocks <3=> 4 clocks
  378. ;// <o9.4..5> Tcah: Address Hold Time after nGCS
  379. ;// <0=> 0 clocks <1=> 1 clocks <2=> 2 clocks <3=> 4 clocks
  380. ;// <o9.2..3> Tacp/Trcd: Page Mode Access Cycle at Page Mode / RAS to CAS Delay
  381. ;// <i> Parameter depends on Memory Type: if type SRAM then parameter is Tacp,
  382. ;// <i> if type is SDRAM then parameter is Trcd
  383. ;// <i> For SDRAM 6 cycles setting is not allowed
  384. ;// <0=> 2 clocks <1=> 3 clocks <2=> 4 clocks <3=> 6 clocks
  385. ;// <o9.0..1> PMC/SCAN: Page Mode Configuration / Column Address Number <0-3>
  386. ;// <i> Parameter depends on Memory Type: if type SRAM then parameter is PMC,
  387. ;// <i> if type is SDRAM then parameter is SCAN
  388. ;// </h>
  389. ;// <h> SDRAM Refresh Control Register (REFRESH)
  390. ;// <o10.23> REFEN: SDRAM Refresh Enable
  391. ;// <o10.22> TREFMD: SDRAM Refresh Mode
  392. ;// <0=> CBR/Auto Refresh <1=> Self Refresh
  393. ;// <o10.20..21> Trp: SDRAM RAS Pre-charge Time
  394. ;// <0=> 2 clocks <1=> 3 clocks <2=> 4 clocks <3=> Reserved
  395. ;// <o10.18..19> Tsrc: SDRAM Semi Row Cycle Time
  396. ;// <i> SDRAM Row cycle time: Trc = Tsrc + Trp
  397. ;// <0=> 4 clocks <1=> 5 clocks <2=> 6 clocks <3=> 7 clocks
  398. ;// <o10.0..10> Refresh Counter <0-1023>
  399. ;// <i> Refresh Period = (2048 - Refresh Count + 1) / HCLK
  400. ;// </h>
  401. ;// <h> Flexible Bank Size Register (BANKSIZE)
  402. ;// <o11.7> BURST_EN: ARM Core Burst Operation Enable
  403. ;// <o11.5> SCKE_EN: SDRAM Power Down Mode Enable
  404. ;// <o11.4> SCLK_EN: SCLK Enabled During SDRAM Access Cycle
  405. ;// <0=> SCLK is always active <1=> SCLK is active only during the access
  406. ;// <o11.0..2> BK76MAP: BANK6 and BANK7 Memory Map
  407. ;// <0=> 32MB / 32MB <1=> 64MB / 64MB <2=> 128MB / 128MB
  408. ;// <4=> 2MB / 2MB <5=> 4MB / 4MB <6=> 8MB / 8MB <7=> 16MB / 16MB
  409. ;// <o11.0..10> Refresh Counter <0-1023>
  410. ;// <i> Refresh Period = (2048 - Refresh Count + 1) / HCLK
  411. ;// </h>
  412. ;// <h> SDRAM Mode Register Set Register 6 (MRSRB6)
  413. ;// <o12.7> WBL: Write Burst Length
  414. ;// <0=> Burst (Fixed)
  415. ;// <o12.7..8> TM: Test Mode
  416. ;// <0=> Mode register set (Fixed)
  417. ;// <o12.4..6> CL: CAS Latency
  418. ;// <0=> 1 clocks <1=> 2 clocks <2=> 3 clocks
  419. ;// <o12.3> BT: Burst Type
  420. ;// <0=> Sequential (Fixed)
  421. ;// <o12.0..2> BL: Burst Length
  422. ;// <0=> 1 (Fixed)
  423. ;// </h>
  424. ;// <h> SDRAM Mode Register Set Register 7 (MRSRB7)
  425. ;// <o13.7> WBL: Write Burst Length
  426. ;// <0=> Burst (Fixed)
  427. ;// <o13.7..8> TM: Test Mode
  428. ;// <0=> Mode register set (Fixed)
  429. ;// <o13.4..6> CL: CAS Latency
  430. ;// <0=> 1 clocks <1=> 2 clocks <2=> 3 clocks
  431. ;// <o13.3> BT: Burst Type
  432. ;// <0=> Sequential (Fixed)
  433. ;// <o13.0..2> BL: Burst Length
  434. ;// <0=> 1 (Fixed)
  435. ;// </h>
  436. ;// </e> Memory Controller Setup
  437. MC_SETUP EQU 0
  438. BWSCON_Val EQU 0x22000000
  439. BANKCON0_Val EQU 0x00000700
  440. BANKCON1_Val EQU 0x00000700
  441. BANKCON2_Val EQU 0x00000700
  442. BANKCON3_Val EQU 0x00000700
  443. BANKCON4_Val EQU 0x00000700
  444. BANKCON5_Val EQU 0x00000700
  445. BANKCON6_Val EQU 0x00018005
  446. BANKCON7_Val EQU 0x00018005
  447. REFRESH_Val EQU 0x008404F3
  448. BANKSIZE_Val EQU 0x00000032
  449. MRSRB6_Val EQU 0x00000020
  450. MRSRB7_Val EQU 0x00000020
  451. ;----------------------- I/O Port Definitions ----------------------------------
  452. GPA_BASE EQU 0x56000000 ; GPA Base Address
  453. GPB_BASE EQU 0x56000010 ; GPB Base Address
  454. GPC_BASE EQU 0x56000020 ; GPC Base Address
  455. GPD_BASE EQU 0x56000030 ; GPD Base Address
  456. GPE_BASE EQU 0x56000040 ; GPE Base Address
  457. GPF_BASE EQU 0x56000050 ; GPF Base Address
  458. GPG_BASE EQU 0x56000060 ; GPG Base Address
  459. GPH_BASE EQU 0x56000070 ; GPH Base Address
  460. GPJ_BASE EQU 0x560000D0 ; GPJ Base Address
  461. GPCON_OFS EQU 0x00 ; Control Register Offset
  462. GPDAT_OFS EQU 0x04 ; Data Register Offset
  463. GPUP_OFS EQU 0x08 ; Pull-up Disable Register Offset
  464. ;// <e> I/O Setup
  465. GP_SETUP EQU 1
  466. ;// <e> Port A Settings
  467. ;// <h> Port A Control Register (GPACON)
  468. ;// <o1.22> GPA22 <0=> Output <1=> nFCE
  469. ;// <o1.21> GPA21 <0=> Output <1=> nRSTOUT
  470. ;// <o1.20> GPA20 <0=> Output <1=> nFRE
  471. ;// <o1.19> GPA19 <0=> Output <1=> nFWE
  472. ;// <o1.18> GPA18 <0=> Output <1=> ALE
  473. ;// <o1.17> GPA17 <0=> Output <1=> CLE
  474. ;// <o1.16> GPA16 <0=> Output <1=> nGCS[5]
  475. ;// <o1.15> GPA15 <0=> Output <1=> nGCS[4]
  476. ;// <o1.14> GPA14 <0=> Output <1=> nGCS[3]
  477. ;// <o1.13> GPA13 <0=> Output <1=> nGCS[2]
  478. ;// <o1.12> GPA12 <0=> Output <1=> nGCS[1]
  479. ;// <o1.11> GPA11 <0=> Output <1=> ADDR26
  480. ;// <o1.10> GPA10 <0=> Output <1=> ADDR25
  481. ;// <o1.9> GPA9 <0=> Output <1=> ADDR24
  482. ;// <o1.8> GPA8 <0=> Output <1=> ADDR23
  483. ;// <o1.7> GPA7 <0=> Output <1=> ADDR22
  484. ;// <o1.6> GPA6 <0=> Output <1=> ADDR21
  485. ;// <o1.5> GPA5 <0=> Output <1=> ADDR20
  486. ;// <o1.4> GPA4 <0=> Output <1=> ADDR19
  487. ;// <o1.3> GPA3 <0=> Output <1=> ADDR18
  488. ;// <o1.2> GPA2 <0=> Output <1=> ADDR17
  489. ;// <o1.1> GPA1 <0=> Output <1=> ADDR16
  490. ;// <o1.0> GPA0 <0=> Output <1=> ADDR0
  491. ;// </h>
  492. ;// </e>
  493. GPA_SETUP EQU 0
  494. GPACON_Val EQU 0x000003FF
  495. ;// <e> Port B Settings
  496. ;// <h> Port B Control Register (GPBCON)
  497. ;// <o1.20..21> GPB10 <0=> Input <1=> Output <2=> nXDREQ0 <3=> Reserved
  498. ;// <o1.18..19> GPB9 <0=> Input <1=> Output <2=> nXDACK0 <3=> Reserved
  499. ;// <o1.16..17> GPB8 <0=> Input <1=> Output <2=> nXDREQ1 <3=> Reserved
  500. ;// <o1.14..15> GPB7 <0=> Input <1=> Output <2=> nXDACK1 <3=> Reserved
  501. ;// <o1.12..13> GPB6 <0=> Input <1=> Output <2=> nXBREQ <3=> Reserved
  502. ;// <o1.10..11> GPB5 <0=> Input <1=> Output <2=> nXBACK <3=> Reserved
  503. ;// <o1.8..9> GPB4 <0=> Input <1=> Output <2=> TCLK[0] <3=> Reserved
  504. ;// <o1.6..7> GPB3 <0=> Input <1=> Output <2=> TOUT3 <3=> Reserved
  505. ;// <o1.4..5> GPB2 <0=> Input <1=> Output <2=> TOUT2 <3=> Reserved
  506. ;// <o1.2..3> GPB1 <0=> Input <1=> Output <2=> TOUT1 <3=> Reserved
  507. ;// <o1.0..1> GPB0 <0=> Input <1=> Output <2=> TOUT0 <3=> Reserved
  508. ;// </h>
  509. ;// <h> Port B Pull-up Settings Register (GPBUP)
  510. ;// <o2.10> GPB10 Pull-up Disable
  511. ;// <o2.9> GPB9 Pull-up Disable
  512. ;// <o2.8> GPB8 Pull-up Disable
  513. ;// <o2.7> GPB7 Pull-up Disable
  514. ;// <o2.6> GPB6 Pull-up Disable
  515. ;// <o2.5> GPB5 Pull-up Disable
  516. ;// <o2.4> GPB4 Pull-up Disable
  517. ;// <o2.3> GPB3 Pull-up Disable
  518. ;// <o2.2> GPB2 Pull-up Disable
  519. ;// <o2.1> GPB1 Pull-up Disable
  520. ;// <o2.0> GPB0 Pull-up Disable
  521. ;// </h>
  522. ;// </e>
  523. GPB_SETUP EQU 0
  524. GPBCON_Val EQU 0x00000000
  525. GPBUP_Val EQU 0x00000000
  526. ;// <e> Port C Settings
  527. ;// <h> Port C Control Register (GPCCON)
  528. ;// <o1.30..31> GPC15 <0=> Input <1=> Output <2=> VD[7] <3=> Reserved
  529. ;// <o1.28..29> GPC14 <0=> Input <1=> Output <2=> VD[6] <3=> Reserved
  530. ;// <o1.26..27> GPC13 <0=> Input <1=> Output <2=> VD[5] <3=> Reserved
  531. ;// <o1.24..25> GPC12 <0=> Input <1=> Output <2=> VD[4] <3=> Reserved
  532. ;// <o1.22..23> GPC11 <0=> Input <1=> Output <2=> VD[3] <3=> Reserved
  533. ;// <o1.20..21> GPC10 <0=> Input <1=> Output <2=> VD[2] <3=> Reserved
  534. ;// <o1.18..19> GPC9 <0=> Input <1=> Output <2=> VD[1] <3=> Reserved
  535. ;// <o1.16..17> GPC8 <0=> Input <1=> Output <2=> VD[0] <3=> Reserved
  536. ;// <o1.14..15> GPC7 <0=> Input <1=> Output <2=> LCD_LPCREVB <3=> Reserved
  537. ;// <o1.12..13> GPC6 <0=> Input <1=> Output <2=> LCD_LPCREV <3=> Reserved
  538. ;// <o1.10..11> GPC5 <0=> Input <1=> Output <2=> LCD_LPCOE <3=> Reserved
  539. ;// <o1.8..9> GPC4 <0=> Input <1=> Output <2=> VM <3=> I2SSDI
  540. ;// <o1.6..7> GPC3 <0=> Input <1=> Output <2=> VFRAME <3=> Reserved
  541. ;// <o1.4..5> GPC2 <0=> Input <1=> Output <2=> VLINE <3=> Reserved
  542. ;// <o1.2..3> GPC1 <0=> Input <1=> Output <2=> VCLK <3=> Reserved
  543. ;// <o1.0..1> GPC0 <0=> Input <1=> Output <2=> LEND <3=> Reserved
  544. ;// </h>
  545. ;// <h> Port C Pull-up Settings Register (GPCUP)
  546. ;// <o2.15> GPC15 Pull-up Disable
  547. ;// <o2.14> GPC14 Pull-up Disable
  548. ;// <o2.13> GPC13 Pull-up Disable
  549. ;// <o2.12> GPC12 Pull-up Disable
  550. ;// <o2.11> GPC11 Pull-up Disable
  551. ;// <o2.10> GPC10 Pull-up Disable
  552. ;// <o2.9> GPC9 Pull-up Disable
  553. ;// <o2.8> GPC8 Pull-up Disable
  554. ;// <o2.7> GPC7 Pull-up Disable
  555. ;// <o2.6> GPC6 Pull-up Disable
  556. ;// <o2.5> GPC5 Pull-up Disable
  557. ;// <o2.4> GPC4 Pull-up Disable
  558. ;// <o2.3> GPC3 Pull-up Disable
  559. ;// <o2.2> GPC2 Pull-up Disable
  560. ;// <o2.1> GPC1 Pull-up Disable
  561. ;// <o2.0> GPC0 Pull-up Disable
  562. ;// </h>
  563. ;// </e>
  564. GPC_SETUP EQU 0
  565. GPCCON_Val EQU 0x00000000
  566. GPCUP_Val EQU 0x00000000
  567. ;// <e> Port D Settings
  568. ;// <h> Port D Control Register (GPDCON)
  569. ;// <o1.30..31> GPD15 <0=> Input <1=> Output <2=> VD[23] <3=> nSS0
  570. ;// <o1.28..29> GPD14 <0=> Input <1=> Output <2=> VD[22] <3=> nSS1
  571. ;// <o1.26..27> GPD13 <0=> Input <1=> Output <2=> VD[21] <3=> Reserved
  572. ;// <o1.24..25> GPD12 <0=> Input <1=> Output <2=> VD[20] <3=> Reserved
  573. ;// <o1.22..23> GPD11 <0=> Input <1=> Output <2=> VD[19] <3=> Reserved
  574. ;// <o1.20..21> GPD10 <0=> Input <1=> Output <2=> VD[18] <3=> SPICLK1
  575. ;// <o1.18..19> GPD9 <0=> Input <1=> Output <2=> VD[17] <3=> SPIMOSI1
  576. ;// <o1.16..17> GPD8 <0=> Input <1=> Output <2=> VD[16] <3=> SPIMISO1
  577. ;// <o1.14..15> GPD7 <0=> Input <1=> Output <2=> VD[15] <3=> Reserved
  578. ;// <o1.12..13> GPD6 <0=> Input <1=> Output <2=> VD[14] <3=> Reserved
  579. ;// <o1.10..11> GPD5 <0=> Input <1=> Output <2=> VD[13] <3=> Reserved
  580. ;// <o1.8..9> GPD4 <0=> Input <1=> Output <2=> VD[12] <3=> Reserved
  581. ;// <o1.6..7> GPD3 <0=> Input <1=> Output <2=> VD[11] <3=> Reserved
  582. ;// <o1.4..5> GPD2 <0=> Input <1=> Output <2=> VD[10] <3=> Reserved
  583. ;// <o1.2..3> GPD1 <0=> Input <1=> Output <2=> VD[9] <3=> Reserved
  584. ;// <o1.0..1> GPD0 <0=> Input <1=> Output <2=> VD[8] <3=> Reserved
  585. ;// </h>
  586. ;// <h> Port D Pull-up Settings Register (GPDUP)
  587. ;// <o2.15> GPD15 Pull-up Disable
  588. ;// <o2.14> GPD14 Pull-up Disable
  589. ;// <o2.13> GPD13 Pull-up Disable
  590. ;// <o2.12> GPD12 Pull-up Disable
  591. ;// <o2.11> GPD11 Pull-up Disable
  592. ;// <o2.10> GPD10 Pull-up Disable
  593. ;// <o2.9> GPD9 Pull-up Disable
  594. ;// <o2.8> GPD8 Pull-up Disable
  595. ;// <o2.7> GPD7 Pull-up Disable
  596. ;// <o2.6> GPD6 Pull-up Disable
  597. ;// <o2.5> GPD5 Pull-up Disable
  598. ;// <o2.4> GPD4 Pull-up Disable
  599. ;// <o2.3> GPD3 Pull-up Disable
  600. ;// <o2.2> GPD2 Pull-up Disable
  601. ;// <o2.1> GPD1 Pull-up Disable
  602. ;// <o2.0> GPD0 Pull-up Disable
  603. ;// </h>
  604. ;// </e>
  605. GPD_SETUP EQU 0
  606. GPDCON_Val EQU 0x00000000
  607. GPDUP_Val EQU 0x00000000
  608. ;// <e> Port E Settings
  609. ;// <h> Port E Control Register (GPECON)
  610. ;// <o1.30..31> GPE15 <0=> Input <1=> Output <2=> IICSDA <3=> Reserved
  611. ;// <i> This pad is open-drain, and has no pull-up option.
  612. ;// <o1.28..29> GPE14 <0=> Input <1=> Output <2=> IICSCL <3=> Reserved
  613. ;// <i> This pad is open-drain, and has no pull-up option.
  614. ;// <o1.26..27> GPE13 <0=> Input <1=> Output <2=> SPICLK0 <3=> Reserved
  615. ;// <o1.24..25> GPE12 <0=> Input <1=> Output <2=> SPIMOSI0 <3=> Reserved
  616. ;// <o1.22..23> GPE11 <0=> Input <1=> Output <2=> SPIMISO0 <3=> Reserved
  617. ;// <o1.20..21> GPE10 <0=> Input <1=> Output <2=> SDDAT3 <3=> Reserved
  618. ;// <o1.18..19> GPE9 <0=> Input <1=> Output <2=> SDDAT2 <3=> Reserved
  619. ;// <o1.16..17> GPE8 <0=> Input <1=> Output <2=> SDDAT1 <3=> Reserved
  620. ;// <o1.14..15> GPE7 <0=> Input <1=> Output <2=> SDDAT0 <3=> Reserved
  621. ;// <o1.12..13> GPE6 <0=> Input <1=> Output <2=> SDCMD <3=> Reserved
  622. ;// <o1.10..11> GPE5 <0=> Input <1=> Output <2=> SDCLK <3=> Reserved
  623. ;// <o1.8..9> GPE4 <0=> Input <1=> Output <2=> I2SDO <3=> AC_SDATA_OUT
  624. ;// <o1.6..7> GPE3 <0=> Input <1=> Output <2=> I2SDI <3=> AC_SDATA_IN
  625. ;// <o1.4..5> GPE2 <0=> Input <1=> Output <2=> CDCLK <3=> AC_nRESET
  626. ;// <o1.2..3> GPE1 <0=> Input <1=> Output <2=> I2SSCLK <3=> AC_BIT_CLK
  627. ;// <o1.0..1> GPE0 <0=> Input <1=> Output <2=> I2SLRCK <3=> AC_SYNC
  628. ;// </h>
  629. ;// <h> Port E Pull-up Settings Register (GPEUP)
  630. ;// <o2.13> GPE13 Pull-up Disable
  631. ;// <o2.12> GPE12 Pull-up Disable
  632. ;// <o2.11> GPE11 Pull-up Disable
  633. ;// <o2.10> GPE10 Pull-up Disable
  634. ;// <o2.9> GPE9 Pull-up Disable
  635. ;// <o2.8> GPE8 Pull-up Disable
  636. ;// <o2.7> GPE7 Pull-up Disable
  637. ;// <o2.6> GPE6 Pull-up Disable
  638. ;// <o2.5> GPE5 Pull-up Disable
  639. ;// <o2.4> GPE4 Pull-up Disable
  640. ;// <o2.3> GPE3 Pull-up Disable
  641. ;// <o2.2> GPE2 Pull-up Disable
  642. ;// <o2.1> GPE1 Pull-up Disable
  643. ;// <o2.0> GPE0 Pull-up Disable
  644. ;// </h>
  645. ;// </e>
  646. GPE_SETUP EQU 0
  647. GPECON_Val EQU 0x00000000
  648. GPEUP_Val EQU 0x00000000
  649. ;// <e> Port F Settings
  650. ;// <h> Port F Control Register (GPFCON)
  651. ;// <o1.14..15> GPF7 <0=> Input <1=> Output <2=> EINT[7] <3=> Reserved
  652. ;// <o1.12..13> GPF6 <0=> Input <1=> Output <2=> EINT[6] <3=> Reserved
  653. ;// <o1.10..11> GPF5 <0=> Input <1=> Output <2=> EINT[5] <3=> Reserved
  654. ;// <o1.8..9> GPF4 <0=> Input <1=> Output <2=> EINT[4] <3=> Reserved
  655. ;// <o1.6..7> GPF3 <0=> Input <1=> Output <2=> EINT[3] <3=> Reserved
  656. ;// <o1.4..5> GPF2 <0=> Input <1=> Output <2=> EINT[2] <3=> Reserved
  657. ;// <o1.2..3> GPF1 <0=> Input <1=> Output <2=> EINT[1] <3=> Reserved
  658. ;// <o1.0..1> GPF0 <0=> Input <1=> Output <2=> EINT[0] <3=> Reserved
  659. ;// </h>
  660. ;// <h> Port F Pull-up Settings Register (GPFUP)
  661. ;// <o2.7> GPF7 Pull-up Disable
  662. ;// <o2.6> GPF6 Pull-up Disable
  663. ;// <o2.5> GPF5 Pull-up Disable
  664. ;// <o2.4> GPF4 Pull-up Disable
  665. ;// <o2.3> GPF3 Pull-up Disable
  666. ;// <o2.2> GPF2 Pull-up Disable
  667. ;// <o2.1> GPF1 Pull-up Disable
  668. ;// <o2.0> GPF0 Pull-up Disable
  669. ;// </h>
  670. ;// </e>
  671. GPF_SETUP EQU 1
  672. GPFCON_Val EQU 0x000000AA
  673. GPFUP_Val EQU 0x0000000F
  674. ;// <e> Port G Settings
  675. ;// <h> Port G Control Register (GPGCON)
  676. ;// <o1.30..31> GPG15 <0=> Input <1=> Output <2=> EINT[23] <3=> Reserved
  677. ;// <o1.28..29> GPG14 <0=> Input <1=> Output <2=> EINT[22] <3=> Reserved
  678. ;// <o1.26..27> GPG13 <0=> Input <1=> Output <2=> EINT[21] <3=> Reserved
  679. ;// <o1.24..25> GPG12 <0=> Input <1=> Output <2=> EINT[20] <3=> Reserved
  680. ;// <o1.22..23> GPG11 <0=> Input <1=> Output <2=> EINT[19] <3=> TCLK[1]
  681. ;// <o1.20..21> GPG10 <0=> Input <1=> Output <2=> EINT[18] <3=> nCTS1
  682. ;// <o1.18..19> GPG9 <0=> Input <1=> Output <2=> EINT[17] <3=> nRTS1
  683. ;// <o1.16..17> GPG8 <0=> Input <1=> Output <2=> EINT[16] <3=> Reserved
  684. ;// <o1.14..15> GPG7 <0=> Input <1=> Output <2=> EINT[15] <3=> SPICLK1
  685. ;// <o1.12..13> GPG6 <0=> Input <1=> Output <2=> EINT[14] <3=> SPIMOSI1
  686. ;// <o1.10..11> GPG5 <0=> Input <1=> Output <2=> EINT[13] <3=> SPIMISO1
  687. ;// <o1.8..9> GPG4 <0=> Input <1=> Output <2=> EINT[12] <3=> LCD_PWRDN
  688. ;// <o1.6..7> GPG3 <0=> Input <1=> Output <2=> EINT[11] <3=> nSS1
  689. ;// <o1.4..5> GPG2 <0=> Input <1=> Output <2=> EINT[10] <3=> nSS0
  690. ;// <o1.2..3> GPG1 <0=> Input <1=> Output <2=> EINT[9] <3=> Reserved
  691. ;// <o1.0..1> GPG0 <0=> Input <1=> Output <2=> EINT[8] <3=> Reserved
  692. ;// </h>
  693. ;// <h> Port G Pull-up Settings Register (GPGUP)
  694. ;// <o2.15> GPG15 Pull-up Disable
  695. ;// <o2.14> GPG14 Pull-up Disable
  696. ;// <o2.13> GPG13 Pull-up Disable
  697. ;// <o2.12> GPG12 Pull-up Disable
  698. ;// <o2.11> GPG11 Pull-up Disable
  699. ;// <o2.10> GPG10 Pull-up Disable
  700. ;// <o2.9> GPG9 Pull-up Disable
  701. ;// <o2.8> GPG8 Pull-up Disable
  702. ;// <o2.7> GPG7 Pull-up Disable
  703. ;// <o2.6> GPG6 Pull-up Disable
  704. ;// <o2.5> GPG5 Pull-up Disable
  705. ;// <o2.4> GPG4 Pull-up Disable
  706. ;// <o2.3> GPG3 Pull-up Disable
  707. ;// <o2.2> GPG2 Pull-up Disable
  708. ;// <o2.1> GPG1 Pull-up Disable
  709. ;// <o2.0> GPG0 Pull-up Disable
  710. ;// </h>
  711. ;// </e>
  712. GPG_SETUP EQU 0
  713. GPGCON_Val EQU 0x00000000
  714. GPGUP_Val EQU 0x00000000
  715. ;// <e> Port H Settings
  716. ;// <h> Port H Control Register (GPHCON)
  717. ;// <o1.20..21> GPH10 <0=> Input <1=> Output <2=> CLKOUT1 <3=> Reserved
  718. ;// <o1.18..19> GPH9 <0=> Input <1=> Output <2=> CLKOUT0 <3=> Reserved
  719. ;// <o1.16..17> GPH8 <0=> Input <1=> Output <2=> UEXTCLK <3=> Reserved
  720. ;// <o1.14..15> GPH7 <0=> Input <1=> Output <2=> RXD[2] <3=> nCTS1
  721. ;// <o1.12..13> GPH6 <0=> Input <1=> Output <2=> TXD[2] <3=> nRTS1
  722. ;// <o1.10..11> GPH5 <0=> Input <1=> Output <2=> RXD[1] <3=> Reserved
  723. ;// <o1.8..9> GPH4 <0=> Input <1=> Output <2=> TXD[1] <3=> Reserved
  724. ;// <o1.6..7> GPH3 <0=> Input <1=> Output <2=> RXD[0] <3=> Reserved
  725. ;// <o1.4..5> GPH2 <0=> Input <1=> Output <2=> TXD[0] <3=> Reserved
  726. ;// <o1.2..3> GPH1 <0=> Input <1=> Output <2=> nRTS0 <3=> Reserved
  727. ;// <o1.0..1> GPH0 <0=> Input <1=> Output <2=> nCTS0 <3=> Reserved
  728. ;// </h>
  729. ;// <h> Port H Pull-up Settings Register (GPHUP)
  730. ;// <o2.10> GPH10 Pull-up Disable
  731. ;// <o2.9> GPH9 Pull-up Disable
  732. ;// <o2.8> GPH8 Pull-up Disable
  733. ;// <o2.7> GPH7 Pull-up Disable
  734. ;// <o2.6> GPH6 Pull-up Disable
  735. ;// <o2.5> GPH5 Pull-up Disable
  736. ;// <o2.4> GPH4 Pull-up Disable
  737. ;// <o2.3> GPH3 Pull-up Disable
  738. ;// <o2.2> GPH2 Pull-up Disable
  739. ;// <o2.1> GPH1 Pull-up Disable
  740. ;// <o2.0> GPH0 Pull-up Disable
  741. ;// </h>
  742. ;// </e>
  743. GPH_SETUP EQU 0
  744. GPHCON_Val EQU 0x00000000
  745. GPHUP_Val EQU 0x00000000
  746. ;// <e> Port J Settings
  747. ;// <h> Port J Control Register (GPJCON)
  748. ;// <o1.24..25> GPJ12 <0=> Input <1=> Output <2=> CAMRESET <3=> Reserved
  749. ;// <o1.22..23> GPJ11 <0=> Input <1=> Output <2=> CAMCLKOUT <3=> Reserved
  750. ;// <o1.20..21> GPJ10 <0=> Input <1=> Output <2=> CAMHREF <3=> Reserved
  751. ;// <o1.18..19> GPJ9 <0=> Input <1=> Output <2=> CAMVSYNC <3=> Reserved
  752. ;// <o1.16..17> GPJ8 <0=> Input <1=> Output <2=> CAMPCLK <3=> Reserved
  753. ;// <o1.14..15> GPJ7 <0=> Input <1=> Output <2=> CAMDATA[7] <3=> Reserved
  754. ;// <o1.12..13> GPJ6 <0=> Input <1=> Output <2=> CAMDATA[6] <3=> Reserved
  755. ;// <o1.10..11> GPJ5 <0=> Input <1=> Output <2=> CAMDATA[5] <3=> Reserved
  756. ;// <o1.8..9> GPJ4 <0=> Input <1=> Output <2=> CAMDATA[4] <3=> Reserved
  757. ;// <o1.6..7> GPJ3 <0=> Input <1=> Output <2=> CAMDATA[3] <3=> Reserved
  758. ;// <o1.4..5> GPJ2 <0=> Input <1=> Output <2=> CAMDATA[2] <3=> Reserved
  759. ;// <o1.2..3> GPJ1 <0=> Input <1=> Output <2=> CAMDATA[1] <3=> Reserved
  760. ;// <o1.0..1> GPJ0 <0=> Input <1=> Output <2=> CAMDATA[0] <3=> Reserved
  761. ;// </h>
  762. ;// <h> Port J Pull-up Settings Register (GPJUP)
  763. ;// <o2.12> GPJ12 Pull-up Disable
  764. ;// <o2.11> GPJ11 Pull-up Disable
  765. ;// <o2.10> GPJ10 Pull-up Disable
  766. ;// <o2.9> GPJ9 Pull-up Disable
  767. ;// <o2.8> GPJ8 Pull-up Disable
  768. ;// <o2.7> GPJ7 Pull-up Disable
  769. ;// <o2.6> GPJ6 Pull-up Disable
  770. ;// <o2.5> GPJ5 Pull-up Disable
  771. ;// <o2.4> GPJ4 Pull-up Disable
  772. ;// <o2.3> GPJ3 Pull-up Disable
  773. ;// <o2.2> GPJ2 Pull-up Disable
  774. ;// <o2.1> GPJ1 Pull-up Disable
  775. ;// <o2.0> GPJ0 Pull-up Disable
  776. ;// </h>
  777. ;// </e>
  778. GPJ_SETUP EQU 0
  779. GPJCON_Val EQU 0x00000000
  780. GPJUP_Val EQU 0x00000000
  781. ;// </e> I/O Setup
  782. ;----------------------- CODE --------------------------------------------------
  783. PRESERVE8
  784. ; Area Definition and Entry Point
  785. ; Startup Code must be linked first at Address at which it expects to run.
  786. AREA RESET, CODE, READONLY
  787. ARM
  788. ; Exception Vectors
  789. ; Mapped to Address 0.
  790. ; Absolute addressing mode must be used.
  791. ; Dummy Handlers are implemented as infinite loops which can be modified.
  792. EXPORT Entry_Point
  793. Entry_Point
  794. Vectors LDR PC, Reset_Addr
  795. LDR PC, Undef_Addr
  796. LDR PC, SWI_Addr
  797. LDR PC, PAbt_Addr
  798. LDR PC, DAbt_Addr
  799. NOP
  800. LDR PC, IRQ_Addr
  801. LDR PC, FIQ_Addr
  802. Reset_Addr DCD Reset_Handler
  803. Undef_Addr DCD Undef_Handler
  804. SWI_Addr DCD SWI_Handler
  805. PAbt_Addr DCD PAbt_Handler
  806. DAbt_Addr DCD DAbt_Handler
  807. DCD 0 ; Reserved Address
  808. IRQ_Addr DCD IRQ_Handler
  809. FIQ_Addr DCD FIQ_Handler
  810. Undef_Handler B Undef_Handler
  811. SWI_Handler B SWI_Handler
  812. PAbt_Handler B PAbt_Handler
  813. ;DAbt_Handler B DAbt_Handler
  814. FIQ_Handler B FIQ_Handler
  815. ;*
  816. ;*************************************************************************
  817. ;*
  818. ;* Interrupt handling
  819. ;*
  820. ;*************************************************************************
  821. ;*
  822. ; DAbt Handler
  823. DAbt_Handler
  824. IMPORT rt_hw_trap_dabt
  825. sub sp, sp, #72
  826. stmia sp, {r0 - r12} ;/* Calling r0-r12 */
  827. add r8, sp, #60
  828. stmdb r8, {sp, lr} ;/* Calling SP, LR */
  829. str lr, [r8, #0] ;/* Save calling PC */
  830. mrs r6, spsr
  831. str r6, [r8, #4] ;/* Save CPSR */
  832. str r0, [r8, #8] ;/* Save OLD_R0 */
  833. mov r0, sp
  834. bl rt_hw_trap_dabt
  835. ;##########################################
  836. ; Reset Handler
  837. EXPORT Reset_Handler
  838. Reset_Handler
  839. ; Watchdog Setup ---------------------------------------------------------------
  840. IF WT_SETUP != 0
  841. LDR R0, =WT_BASE
  842. LDR R1, =WTCON_Val
  843. LDR R2, =WTDAT_Val
  844. STR R2, [R0, #WTCNT_OFS]
  845. STR R2, [R0, #WTDAT_OFS]
  846. STR R1, [R0, #WTCON_OFS]
  847. ENDIF
  848. ; Clock Setup ------------------------------------------------------------------
  849. IF (:LNOT:(:DEF:NO_CLOCK_SETUP)):LAND:(CLOCK_SETUP != 0)
  850. LDR R0, =CLOCK_BASE
  851. LDR R1, =LOCKTIME_Val
  852. STR R1, [R0, #LOCKTIME_OFS]
  853. MOV R1, #CLKDIVN_Val
  854. STR R1, [R0, #CLKDIVN_OFS]
  855. LDR R1, =CAMDIVN_Val
  856. STR R1, [R0, #CAMDIVN_OFS]
  857. LDR R1, =MPLLCON_Val
  858. STR R1, [R0, #MPLLCON_OFS]
  859. LDR R1, =UPLLCON_Val
  860. STR R1, [R0, #UPLLCON_OFS]
  861. MOV R1, #CLKSLOW_Val
  862. STR R1, [R0, #CLKSLOW_OFS]
  863. LDR R1, =CLKCON_Val
  864. STR R1, [R0, #CLKCON_OFS]
  865. ENDIF
  866. ; Memory Controller Setup ------------------------------------------------------
  867. IF (:LNOT:(:DEF:NO_MC_SETUP)):LAND:(CLOCK_SETUP != 0)
  868. LDR R0, =MC_BASE
  869. LDR R1, =BWSCON_Val
  870. STR R1, [R0, #BWSCON_OFS]
  871. LDR R1, =BANKCON0_Val
  872. STR R1, [R0, #BANKCON0_OFS]
  873. LDR R1, =BANKCON1_Val
  874. STR R1, [R0, #BANKCON1_OFS]
  875. LDR R1, =BANKCON2_Val
  876. STR R1, [R0, #BANKCON2_OFS]
  877. LDR R1, =BANKCON3_Val
  878. STR R1, [R0, #BANKCON3_OFS]
  879. LDR R1, =BANKCON4_Val
  880. STR R1, [R0, #BANKCON4_OFS]
  881. LDR R1, =BANKCON5_Val
  882. STR R1, [R0, #BANKCON5_OFS]
  883. LDR R1, =BANKCON6_Val
  884. STR R1, [R0, #BANKCON6_OFS]
  885. LDR R1, =BANKCON7_Val
  886. STR R1, [R0, #BANKCON7_OFS]
  887. LDR R1, =REFRESH_Val
  888. STR R1, [R0, #REFRESH_OFS]
  889. MOV R1, #BANKSIZE_Val
  890. STR R1, [R0, #BANKSIZE_OFS]
  891. MOV R1, #MRSRB6_Val
  892. STR R1, [R0, #MRSRB6_OFS]
  893. MOV R1, #MRSRB7_Val
  894. STR R1, [R0, #MRSRB7_OFS]
  895. ENDIF
  896. ; I/O Pins Setup ---------------------------------------------------------------
  897. IF (:LNOT:(:DEF:NO_GP_SETUP)):LAND:(GP_SETUP != 0)
  898. IF GPA_SETUP != 0
  899. LDR R0, =GPA_BASE
  900. LDR R1, =GPACON_Val
  901. STR R1, [R0, #GPCON_OFS]
  902. ENDIF
  903. IF GPB_SETUP != 0
  904. LDR R0, =GPB_BASE
  905. LDR R1, =GPBCON_Val
  906. STR R1, [R0, #GPCON_OFS]
  907. LDR R1, =GPBUP_Val
  908. STR R1, [R0, #GPUP_OFS]
  909. ENDIF
  910. IF GPC_SETUP != 0
  911. LDR R0, =GPC_BASE
  912. LDR R1, =GPCCON_Val
  913. STR R1, [R0, #GPCON_OFS]
  914. LDR R1, =GPCUP_Val
  915. STR R1, [R0, #GPUP_OFS]
  916. ENDIF
  917. IF GPD_SETUP != 0
  918. LDR R0, =GPD_BASE
  919. LDR R1, =GPDCON_Val
  920. STR R1, [R0, #GPCON_OFS]
  921. LDR R1, =GPDUP_Val
  922. STR R1, [R0, #GPUP_OFS]
  923. ENDIF
  924. IF GPE_SETUP != 0
  925. LDR R0, =GPE_BASE
  926. LDR R1, =GPECON_Val
  927. STR R1, [R0, #GPCON_OFS]
  928. LDR R1, =GPEUP_Val
  929. STR R1, [R0, #GPUP_OFS]
  930. ENDIF
  931. IF GPF_SETUP != 0
  932. LDR R0, =GPF_BASE
  933. LDR R1, =GPFCON_Val
  934. STR R1, [R0, #GPCON_OFS]
  935. LDR R1, =GPFUP_Val
  936. STR R1, [R0, #GPUP_OFS]
  937. ENDIF
  938. IF GPG_SETUP != 0
  939. LDR R0, =GPG_BASE
  940. LDR R1, =GPGCON_Val
  941. STR R1, [R0, #GPCON_OFS]
  942. LDR R1, =GPGUP_Val
  943. STR R1, [R0, #GPUP_OFS]
  944. ENDIF
  945. IF GPH_SETUP != 0
  946. LDR R0, =GPH_BASE
  947. LDR R1, =GPHCON_Val
  948. STR R1, [R0, #GPCON_OFS]
  949. LDR R1, =GPHUP_Val
  950. STR R1, [R0, #GPUP_OFS]
  951. ENDIF
  952. IF GPJ_SETUP != 0
  953. LDR R0, =GPJ_BASE
  954. LDR R1, =GPJCON_Val
  955. STR R1, [R0, #GPCON_OFS]
  956. LDR R1, =GPJUP_Val
  957. STR R1, [R0, #GPUP_OFS]
  958. ENDIF
  959. ENDIF
  960. ; Copy Exception Vectors to Internal RAM ---------------------------------------
  961. IF :DEF:RAM_INTVEC
  962. ADR R8, Vectors ; Source
  963. LDR R9, =IRAM_BASE ; Destination
  964. LDMIA R8!, {R0-R7} ; Load Vectors
  965. STMIA R9!, {R0-R7} ; Store Vectors
  966. LDMIA R8!, {R0-R7} ; Load Handler Addresses
  967. STMIA R9!, {R0-R7} ; Store Handler Addresses
  968. ENDIF
  969. ; Setup Stack for each mode ----------------------------------------------------
  970. LDR R0, =Stack_Top
  971. ; Enter Undefined Instruction Mode and set its Stack Pointer
  972. MSR CPSR_c, #Mode_UND:OR:I_Bit:OR:F_Bit
  973. MOV SP, R0
  974. SUB R0, R0, #UND_Stack_Size
  975. ; Enter Abort Mode and set its Stack Pointer
  976. MSR CPSR_c, #Mode_ABT:OR:I_Bit:OR:F_Bit
  977. MOV SP, R0
  978. SUB R0, R0, #ABT_Stack_Size
  979. ; Enter FIQ Mode and set its Stack Pointer
  980. MSR CPSR_c, #Mode_FIQ:OR:I_Bit:OR:F_Bit
  981. MOV SP, R0
  982. SUB R0, R0, #FIQ_Stack_Size
  983. ; Enter IRQ Mode and set its Stack Pointer
  984. MSR CPSR_c, #Mode_IRQ:OR:I_Bit:OR:F_Bit
  985. MOV SP, R0
  986. SUB R0, R0, #IRQ_Stack_Size
  987. ; Enter Supervisor Mode and set its Stack Pointer
  988. MSR CPSR_c, #Mode_SVC:OR:I_Bit:OR:F_Bit
  989. MOV SP, R0
  990. SUB R0, R0, #SVC_Stack_Size
  991. ; Enter User Mode and set its Stack Pointer
  992. ; MSR CPSR_c, #Mode_USR
  993. MOV SP, R0
  994. SUB SL, SP, #USR_Stack_Size
  995. ; Enter the C code -------------------------------------------------------------
  996. IMPORT __main
  997. LDR R0, =__main
  998. BX R0
  999. IMPORT rt_interrupt_enter
  1000. IMPORT rt_interrupt_leave
  1001. IMPORT rt_thread_switch_interrupt_flag
  1002. IMPORT rt_interrupt_from_thread
  1003. IMPORT rt_interrupt_to_thread
  1004. IMPORT rt_hw_trap_irq
  1005. IRQ_Handler PROC
  1006. EXPORT IRQ_Handler
  1007. STMFD sp!, {r0-r12,lr}
  1008. BL rt_interrupt_enter
  1009. BL rt_hw_trap_irq
  1010. BL rt_interrupt_leave
  1011. ; if rt_thread_switch_interrupt_flag set, jump to
  1012. ; rt_hw_context_switch_interrupt_do and don't return
  1013. LDR r0, =rt_thread_switch_interrupt_flag
  1014. LDR r1, [r0]
  1015. CMP r1, #1
  1016. BEQ rt_hw_context_switch_interrupt_do
  1017. LDMFD sp!, {r0-r12,lr}
  1018. SUBS pc, lr, #4
  1019. ENDP
  1020. ; /*
  1021. ; * void rt_hw_context_switch_interrupt_do(rt_base_t flag)
  1022. ; */
  1023. rt_hw_context_switch_interrupt_do PROC
  1024. EXPORT rt_hw_context_switch_interrupt_do
  1025. MOV r1, #0 ; clear flag
  1026. STR r1, [r0]
  1027. LDMFD sp!, {r0-r12,lr}; reload saved registers
  1028. STMFD sp!, {r0-r3} ; save r0-r3
  1029. MOV r1, sp
  1030. ADD sp, sp, #16 ; restore sp
  1031. SUB r2, lr, #4 ; save old task's pc to r2
  1032. MRS r3, spsr ; get cpsr of interrupt thread
  1033. ; switch to SVC mode and no interrupt
  1034. MSR cpsr_c, #I_Bit:OR:F_Bit:OR:Mode_SVC
  1035. STMFD sp!, {r2} ; push old task's pc
  1036. STMFD sp!, {r4-r12,lr}; push old task's lr,r12-r4
  1037. MOV r4, r1 ; Special optimised code below
  1038. MOV r5, r3
  1039. LDMFD r4!, {r0-r3}
  1040. STMFD sp!, {r0-r3} ; push old task's r3-r0
  1041. STMFD sp!, {r5} ; push old task's cpsr
  1042. MRS r4, spsr
  1043. STMFD sp!, {r4} ; push old task's spsr
  1044. LDR r4, =rt_interrupt_from_thread
  1045. LDR r5, [r4]
  1046. STR sp, [r5] ; store sp in preempted tasks's TCB
  1047. LDR r6, =rt_interrupt_to_thread
  1048. LDR r6, [r6]
  1049. LDR sp, [r6] ; get new task's stack pointer
  1050. LDMFD sp!, {r4} ; pop new task's spsr
  1051. MSR spsr_cxsf, r4
  1052. LDMFD sp!, {r4} ; pop new task's psr
  1053. MSR cpsr_cxsf, r4
  1054. LDMFD sp!, {r0-r12,lr,pc} ; pop new task's r0-r12,lr & pc
  1055. ENDP
  1056. IF :DEF:__MICROLIB
  1057. EXPORT __heap_base
  1058. EXPORT __heap_limit
  1059. ELSE
  1060. ; User Initial Stack & Heap
  1061. AREA |.text|, CODE, READONLY
  1062. IMPORT __use_two_region_memory
  1063. EXPORT __user_initial_stackheap
  1064. __user_initial_stackheap
  1065. LDR R0, = Heap_Mem
  1066. LDR R1, =(Stack_Mem + USR_Stack_Size)
  1067. LDR R2, = (Heap_Mem + Heap_Size)
  1068. LDR R3, = Stack_Mem
  1069. BX LR
  1070. ENDIF
  1071. END