head-rom.S 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413
  1. /*
  2. * head-rom.S - startup code for Motorola 68360
  3. *
  4. * Copyright (C) SED Systems, a Division of Calian Ltd.
  5. * Based on: arch/m68knommu/platform/68328/pilot/crt0_rom.S
  6. * Based on: arch/m68knommu/platform/68360/uCquicc/crt0_rom.S, 2.0.38.1.pre7
  7. * uClinux Kernel
  8. * Copyright (C) Michael Leslie <mleslie@lineo.com>
  9. * Based on: arch/m68knommu/platform/68EZ328/ucsimm/crt0_rom.S
  10. * Copyright (C) 1998 D. Jeff Dionne <jeff@uclinux.org>,
  11. *
  12. */
  13. .global _stext
  14. .global __bss_start
  15. .global _start
  16. .global _rambase
  17. .global _ramvec
  18. .global _ramstart
  19. .global _ramend
  20. .global _quicc_base
  21. .global _periph_base
  22. #define RAMEND (CONFIG_RAMBASE + CONFIG_RAMSIZE)
  23. #define REGB 0x1000
  24. #define PEPAR (_dprbase + REGB + 0x0016)
  25. #define GMR (_dprbase + REGB + 0x0040)
  26. #define OR0 (_dprbase + REGB + 0x0054)
  27. #define BR0 (_dprbase + REGB + 0x0050)
  28. #define OR1 (_dprbase + REGB + 0x0064)
  29. #define BR1 (_dprbase + REGB + 0x0060)
  30. #define OR2 (_dprbase + REGB + 0x0074)
  31. #define BR2 (_dprbase + REGB + 0x0070)
  32. #define OR3 (_dprbase + REGB + 0x0084)
  33. #define BR3 (_dprbase + REGB + 0x0080)
  34. #define OR4 (_dprbase + REGB + 0x0094)
  35. #define BR4 (_dprbase + REGB + 0x0090)
  36. #define OR5 (_dprbase + REGB + 0x00A4)
  37. #define BR5 (_dprbase + REGB + 0x00A0)
  38. #define OR6 (_dprbase + REGB + 0x00b4)
  39. #define BR6 (_dprbase + REGB + 0x00b0)
  40. #define OR7 (_dprbase + REGB + 0x00c4)
  41. #define BR7 (_dprbase + REGB + 0x00c0)
  42. #define MCR (_dprbase + REGB + 0x0000)
  43. #define AVR (_dprbase + REGB + 0x0008)
  44. #define SYPCR (_dprbase + REGB + 0x0022)
  45. #define PLLCR (_dprbase + REGB + 0x0010)
  46. #define CLKOCR (_dprbase + REGB + 0x000C)
  47. #define CDVCR (_dprbase + REGB + 0x0014)
  48. #define BKAR (_dprbase + REGB + 0x0030)
  49. #define BKCR (_dprbase + REGB + 0x0034)
  50. #define SWIV (_dprbase + REGB + 0x0023)
  51. #define PICR (_dprbase + REGB + 0x0026)
  52. #define PITR (_dprbase + REGB + 0x002A)
  53. /* Define for all memory configuration */
  54. #define MCU_SIM_GMR 0x00000000
  55. #define SIM_OR_MASK 0x0fffffff
  56. /* Defines for chip select zero - the flash */
  57. #define SIM_OR0_MASK 0x20000000
  58. #define SIM_BR0_MASK 0x00000001
  59. /* Defines for chip select one - the RAM */
  60. #define SIM_OR1_MASK 0x10000000
  61. #define SIM_BR1_MASK 0x00000001
  62. #define MCU_SIM_MBAR_ADRS 0x0003ff00
  63. #define MCU_SIM_MBAR_BA_MASK 0xfffff000
  64. #define MCU_SIM_MBAR_AS_MASK 0x00000001
  65. #define MCU_SIM_PEPAR 0x00B4
  66. #define MCU_DISABLE_INTRPTS 0x2700
  67. #define MCU_SIM_AVR 0x00
  68. #define MCU_SIM_MCR 0x00005cff
  69. #define MCU_SIM_CLKOCR 0x00
  70. #define MCU_SIM_PLLCR 0x8000
  71. #define MCU_SIM_CDVCR 0x0000
  72. #define MCU_SIM_SYPCR 0x0000
  73. #define MCU_SIM_SWIV 0x00
  74. #define MCU_SIM_PICR 0x0000
  75. #define MCU_SIM_PITR 0x0000
  76. #include <asm/m68360_regs.h>
  77. /*
  78. * By the time this RAM specific code begins to execute, DPRAM
  79. * and DRAM should already be mapped and accessible.
  80. */
  81. .text
  82. _start:
  83. _stext:
  84. nop
  85. ori.w #MCU_DISABLE_INTRPTS, %sr /* disable interrupts: */
  86. /* We should not need to setup the boot stack the reset should do it. */
  87. movea.l #RAMEND, %sp /* set up stack at the end of DRAM:*/
  88. set_mbar_register:
  89. moveq.l #0x07, %d1 /* Setup MBAR */
  90. movec %d1, %dfc
  91. lea.l MCU_SIM_MBAR_ADRS, %a0
  92. move.l #_dprbase, %d0
  93. andi.l #MCU_SIM_MBAR_BA_MASK, %d0
  94. ori.l #MCU_SIM_MBAR_AS_MASK, %d0
  95. moves.l %d0, %a0@
  96. moveq.l #0x05, %d1
  97. movec.l %d1, %dfc
  98. /* Now we can begin to access registers in DPRAM */
  99. set_sim_mcr:
  100. /* Set Module Configuration Register */
  101. move.l #MCU_SIM_MCR, MCR
  102. /* to do: Determine cause of reset */
  103. /*
  104. * configure system clock MC68360 p. 6-40
  105. * (value +1)*osc/128 = system clock
  106. * or
  107. * (value + 1)*osc = system clock
  108. * You do not need to divide the oscillator by 128 unless you want to.
  109. */
  110. set_sim_clock:
  111. move.w #MCU_SIM_PLLCR, PLLCR
  112. move.b #MCU_SIM_CLKOCR, CLKOCR
  113. move.w #MCU_SIM_CDVCR, CDVCR
  114. /* Wait for the PLL to settle */
  115. move.w #16384, %d0
  116. pll_settle_wait:
  117. subi.w #1, %d0
  118. bne pll_settle_wait
  119. /* Setup the system protection register, and watchdog timer register */
  120. move.b #MCU_SIM_SWIV, SWIV
  121. move.w #MCU_SIM_PICR, PICR
  122. move.w #MCU_SIM_PITR, PITR
  123. move.w #MCU_SIM_SYPCR, SYPCR
  124. /* Clear DPRAM - system + parameter */
  125. movea.l #_dprbase, %a0
  126. movea.l #_dprbase+0x2000, %a1
  127. /* Copy 0 to %a0 until %a0 == %a1 */
  128. clear_dpram:
  129. movel #0, %a0@+
  130. cmpal %a0, %a1
  131. bhi clear_dpram
  132. configure_memory_controller:
  133. /* Set up Global Memory Register (GMR) */
  134. move.l #MCU_SIM_GMR, %d0
  135. move.l %d0, GMR
  136. configure_chip_select_0:
  137. move.l #0x00400000, %d0
  138. subq.l #0x01, %d0
  139. eori.l #SIM_OR_MASK, %d0
  140. ori.l #SIM_OR0_MASK, %d0
  141. move.l %d0, OR0
  142. move.l #__rom_start, %d0
  143. ori.l #SIM_BR0_MASK, %d0
  144. move.l %d0, BR0
  145. move.l #0x0, BR1
  146. move.l #0x0, BR2
  147. move.l #0x0, BR3
  148. move.l #0x0, BR4
  149. move.l #0x0, BR5
  150. move.l #0x0, BR6
  151. move.l #0x0, BR7
  152. move.w #MCU_SIM_PEPAR, PEPAR
  153. /* point to vector table: */
  154. move.l #_romvec, %a0
  155. move.l #_ramvec, %a1
  156. copy_vectors:
  157. move.l %a0@, %d0
  158. move.l %d0, %a1@
  159. move.l %a0@, %a1@
  160. addq.l #0x04, %a0
  161. addq.l #0x04, %a1
  162. cmp.l #_start, %a0
  163. blt copy_vectors
  164. move.l #_ramvec, %a1
  165. movec %a1, %vbr
  166. /* Copy data segment from ROM to RAM */
  167. moveal #_etext, %a0
  168. moveal #_sdata, %a1
  169. moveal #_edata, %a2
  170. /* Copy %a0 to %a1 until %a1 == %a2 */
  171. LD1:
  172. move.l %a0@, %d0
  173. addq.l #0x04, %a0
  174. move.l %d0, %a1@
  175. addq.l #0x04, %a1
  176. cmp.l #_edata, %a1
  177. blt LD1
  178. moveal #__bss_start, %a0
  179. moveal #__bss_stop, %a1
  180. /* Copy 0 to %a0 until %a0 == %a1 */
  181. L1:
  182. movel #0, %a0@+
  183. cmpal %a0, %a1
  184. bhi L1
  185. load_quicc:
  186. move.l #_dprbase, _quicc_base
  187. store_ram_size:
  188. /* Set ram size information */
  189. move.l #_sdata, _rambase
  190. move.l #__bss_stop, _ramstart
  191. move.l #RAMEND, %d0
  192. sub.l #0x1000, %d0 /* Reserve 4K for stack space.*/
  193. move.l %d0, _ramend /* Different from RAMEND.*/
  194. pea 0
  195. pea env
  196. pea %sp@(4)
  197. pea 0
  198. lea init_thread_union, %a2
  199. lea 0x2000(%a2), %sp
  200. lp:
  201. jsr start_kernel
  202. _exit:
  203. jmp _exit
  204. .data
  205. .align 4
  206. env:
  207. .long 0
  208. _quicc_base:
  209. .long 0
  210. _periph_base:
  211. .long 0
  212. _ramvec:
  213. .long 0
  214. _rambase:
  215. .long 0
  216. _ramstart:
  217. .long 0
  218. _ramend:
  219. .long 0
  220. _dprbase:
  221. .long 0xffffe000
  222. .text
  223. /*
  224. * These are the exception vectors at boot up, they are copied into RAM
  225. * and then overwritten as needed.
  226. */
  227. .section ".data..initvect","awx"
  228. .long RAMEND /* Reset: Initial Stack Pointer - 0. */
  229. .long _start /* Reset: Initial Program Counter - 1. */
  230. .long buserr /* Bus Error - 2. */
  231. .long trap /* Address Error - 3. */
  232. .long trap /* Illegal Instruction - 4. */
  233. .long trap /* Divide by zero - 5. */
  234. .long trap /* CHK, CHK2 Instructions - 6. */
  235. .long trap /* TRAPcc, TRAPV Instructions - 7. */
  236. .long trap /* Privilege Violation - 8. */
  237. .long trap /* Trace - 9. */
  238. .long trap /* Line 1010 Emulator - 10. */
  239. .long trap /* Line 1111 Emualtor - 11. */
  240. .long trap /* Harware Breakpoint - 12. */
  241. .long trap /* (Reserved for Coprocessor Protocol Violation)- 13. */
  242. .long trap /* Format Error - 14. */
  243. .long trap /* Uninitialized Interrupt - 15. */
  244. .long trap /* (Unassigned, Reserver) - 16. */
  245. .long trap /* (Unassigned, Reserver) - 17. */
  246. .long trap /* (Unassigned, Reserver) - 18. */
  247. .long trap /* (Unassigned, Reserver) - 19. */
  248. .long trap /* (Unassigned, Reserver) - 20. */
  249. .long trap /* (Unassigned, Reserver) - 21. */
  250. .long trap /* (Unassigned, Reserver) - 22. */
  251. .long trap /* (Unassigned, Reserver) - 23. */
  252. .long trap /* Spurious Interrupt - 24. */
  253. .long trap /* Level 1 Interrupt Autovector - 25. */
  254. .long trap /* Level 2 Interrupt Autovector - 26. */
  255. .long trap /* Level 3 Interrupt Autovector - 27. */
  256. .long trap /* Level 4 Interrupt Autovector - 28. */
  257. .long trap /* Level 5 Interrupt Autovector - 29. */
  258. .long trap /* Level 6 Interrupt Autovector - 30. */
  259. .long trap /* Level 7 Interrupt Autovector - 31. */
  260. .long system_call /* Trap Instruction Vectors 0 - 32. */
  261. .long trap /* Trap Instruction Vectors 1 - 33. */
  262. .long trap /* Trap Instruction Vectors 2 - 34. */
  263. .long trap /* Trap Instruction Vectors 3 - 35. */
  264. .long trap /* Trap Instruction Vectors 4 - 36. */
  265. .long trap /* Trap Instruction Vectors 5 - 37. */
  266. .long trap /* Trap Instruction Vectors 6 - 38. */
  267. .long trap /* Trap Instruction Vectors 7 - 39. */
  268. .long trap /* Trap Instruction Vectors 8 - 40. */
  269. .long trap /* Trap Instruction Vectors 9 - 41. */
  270. .long trap /* Trap Instruction Vectors 10 - 42. */
  271. .long trap /* Trap Instruction Vectors 11 - 43. */
  272. .long trap /* Trap Instruction Vectors 12 - 44. */
  273. .long trap /* Trap Instruction Vectors 13 - 45. */
  274. .long trap /* Trap Instruction Vectors 14 - 46. */
  275. .long trap /* Trap Instruction Vectors 15 - 47. */
  276. .long 0 /* (Reserved for Coprocessor) - 48. */
  277. .long 0 /* (Reserved for Coprocessor) - 49. */
  278. .long 0 /* (Reserved for Coprocessor) - 50. */
  279. .long 0 /* (Reserved for Coprocessor) - 51. */
  280. .long 0 /* (Reserved for Coprocessor) - 52. */
  281. .long 0 /* (Reserved for Coprocessor) - 53. */
  282. .long 0 /* (Reserved for Coprocessor) - 54. */
  283. .long 0 /* (Reserved for Coprocessor) - 55. */
  284. .long 0 /* (Reserved for Coprocessor) - 56. */
  285. .long 0 /* (Reserved for Coprocessor) - 57. */
  286. .long 0 /* (Reserved for Coprocessor) - 58. */
  287. .long 0 /* (Unassigned, Reserved) - 59. */
  288. .long 0 /* (Unassigned, Reserved) - 60. */
  289. .long 0 /* (Unassigned, Reserved) - 61. */
  290. .long 0 /* (Unassigned, Reserved) - 62. */
  291. .long 0 /* (Unassigned, Reserved) - 63. */
  292. /* The assignment of these vectors to the CPM is */
  293. /* dependent on the configuration of the CPM vba */
  294. /* fields. */
  295. .long 0 /* (User-Defined Vectors 1) CPM Error - 64. */
  296. .long 0 /* (User-Defined Vectors 2) CPM Parallel IO PC11- 65. */
  297. .long 0 /* (User-Defined Vectors 3) CPM Parallel IO PC10- 66. */
  298. .long 0 /* (User-Defined Vectors 4) CPM SMC2 / PIP - 67. */
  299. .long 0 /* (User-Defined Vectors 5) CPM SMC1 - 68. */
  300. .long 0 /* (User-Defined Vectors 6) CPM SPI - 69. */
  301. .long 0 /* (User-Defined Vectors 7) CPM Parallel IO PC9 - 70. */
  302. .long 0 /* (User-Defined Vectors 8) CPM Timer 4 - 71. */
  303. .long 0 /* (User-Defined Vectors 9) CPM Reserved - 72. */
  304. .long 0 /* (User-Defined Vectors 10) CPM Parallel IO PC8- 73. */
  305. .long 0 /* (User-Defined Vectors 11) CPM Parallel IO PC7- 74. */
  306. .long 0 /* (User-Defined Vectors 12) CPM Parallel IO PC6- 75. */
  307. .long 0 /* (User-Defined Vectors 13) CPM Timer 3 - 76. */
  308. .long 0 /* (User-Defined Vectors 14) CPM Reserved - 77. */
  309. .long 0 /* (User-Defined Vectors 15) CPM Parallel IO PC5- 78. */
  310. .long 0 /* (User-Defined Vectors 16) CPM Parallel IO PC4- 79. */
  311. .long 0 /* (User-Defined Vectors 17) CPM Reserved - 80. */
  312. .long 0 /* (User-Defined Vectors 18) CPM RISC Timer Tbl - 81. */
  313. .long 0 /* (User-Defined Vectors 19) CPM Timer 2 - 82. */
  314. .long 0 /* (User-Defined Vectors 21) CPM Reserved - 83. */
  315. .long 0 /* (User-Defined Vectors 22) CPM IDMA2 - 84. */
  316. .long 0 /* (User-Defined Vectors 23) CPM IDMA1 - 85. */
  317. .long 0 /* (User-Defined Vectors 24) CPM SDMA Bus Err - 86. */
  318. .long 0 /* (User-Defined Vectors 25) CPM Parallel IO PC3- 87. */
  319. .long 0 /* (User-Defined Vectors 26) CPM Parallel IO PC2- 88. */
  320. .long 0 /* (User-Defined Vectors 27) CPM Timer 1 - 89. */
  321. .long 0 /* (User-Defined Vectors 28) CPM Parallel IO PC1- 90. */
  322. .long 0 /* (User-Defined Vectors 29) CPM SCC 4 - 91. */
  323. .long 0 /* (User-Defined Vectors 30) CPM SCC 3 - 92. */
  324. .long 0 /* (User-Defined Vectors 31) CPM SCC 2 - 93. */
  325. .long 0 /* (User-Defined Vectors 32) CPM SCC 1 - 94. */
  326. .long 0 /* (User-Defined Vectors 33) CPM Parallel IO PC0- 95. */
  327. /* I don't think anything uses the vectors after here. */
  328. .long 0 /* (User-Defined Vectors 34) - 96. */
  329. .long 0,0,0,0,0 /* (User-Defined Vectors 35 - 39). */
  330. .long 0,0,0,0,0,0,0,0,0,0 /* (User-Defined Vectors 40 - 49). */
  331. .long 0,0,0,0,0,0,0,0,0,0 /* (User-Defined Vectors 50 - 59). */
  332. .long 0,0,0,0,0,0,0,0,0,0 /* (User-Defined Vectors 60 - 69). */
  333. .long 0,0,0,0,0,0,0,0,0,0 /* (User-Defined Vectors 70 - 79). */
  334. .long 0,0,0,0,0,0,0,0,0,0 /* (User-Defined Vectors 80 - 89). */
  335. .long 0,0,0,0,0,0,0,0,0,0 /* (User-Defined Vectors 90 - 99). */
  336. .long 0,0,0,0,0,0,0,0,0,0 /* (User-Defined Vectors 100 - 109). */
  337. .long 0,0,0,0,0,0,0,0,0,0 /* (User-Defined Vectors 110 - 119). */
  338. .long 0,0,0,0,0,0,0,0,0,0 /* (User-Defined Vectors 120 - 129). */
  339. .long 0,0,0,0,0,0,0,0,0,0 /* (User-Defined Vectors 130 - 139). */
  340. .long 0,0,0,0,0,0,0,0,0,0 /* (User-Defined Vectors 140 - 149). */
  341. .long 0,0,0,0,0,0,0,0,0,0 /* (User-Defined Vectors 150 - 159). */
  342. .long 0,0,0,0,0,0,0,0,0,0 /* (User-Defined Vectors 160 - 169). */
  343. .long 0,0,0,0,0,0,0,0,0,0 /* (User-Defined Vectors 170 - 179). */
  344. .long 0,0,0,0,0,0,0,0,0,0 /* (User-Defined Vectors 180 - 189). */
  345. .long 0,0,0 /* (User-Defined Vectors 190 - 192). */
  346. .text
  347. ignore: rte