start.S 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276
  1. /*
  2. * Copyright (C) 2003 Josef Baumgartner <josef.baumgartner@telex.de>
  3. * Based on code from Bernhard Kuhn <bkuhn@metrowerks.com>
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. #include <asm-offsets.h>
  24. #include <config.h>
  25. #include <timestamp.h>
  26. #include "version.h"
  27. #include <asm/cache.h>
  28. #ifndef CONFIG_IDENT_STRING
  29. #define CONFIG_IDENT_STRING ""
  30. #endif
  31. #define _START _start
  32. #define _FAULT _fault
  33. #define SAVE_ALL \
  34. move.w #0x2700,%sr; /* disable intrs */ \
  35. subl #60,%sp; /* space for 15 regs */ \
  36. moveml %d0-%d7/%a0-%a6,%sp@;
  37. #define RESTORE_ALL \
  38. moveml %sp@,%d0-%d7/%a0-%a6; \
  39. addl #60,%sp; /* space for 15 regs */ \
  40. rte;
  41. .text
  42. /*
  43. * Vector table. This is used for initial platform startup.
  44. * These vectors are to catch any un-intended traps.
  45. */
  46. _vectors:
  47. INITSP: .long 0x00000000 /* Initial SP */
  48. INITPC: .long _START /* Initial PC */
  49. vector02: .long _FAULT /* Access Error */
  50. vector03: .long _FAULT /* Address Error */
  51. vector04: .long _FAULT /* Illegal Instruction */
  52. vector05: .long _FAULT /* Reserved */
  53. vector06: .long _FAULT /* Reserved */
  54. vector07: .long _FAULT /* Reserved */
  55. vector08: .long _FAULT /* Privilege Violation */
  56. vector09: .long _FAULT /* Trace */
  57. vector0A: .long _FAULT /* Unimplemented A-Line */
  58. vector0B: .long _FAULT /* Unimplemented F-Line */
  59. vector0C: .long _FAULT /* Debug Interrupt */
  60. vector0D: .long _FAULT /* Reserved */
  61. vector0E: .long _FAULT /* Format Error */
  62. vector0F: .long _FAULT /* Unitialized Int. */
  63. /* Reserved */
  64. vector10_17:
  65. .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
  66. vector18: .long _FAULT /* Spurious Interrupt */
  67. vector19: .long _FAULT /* Autovector Level 1 */
  68. vector1A: .long _FAULT /* Autovector Level 2 */
  69. vector1B: .long _FAULT /* Autovector Level 3 */
  70. vector1C: .long _FAULT /* Autovector Level 4 */
  71. vector1D: .long _FAULT /* Autovector Level 5 */
  72. vector1E: .long _FAULT /* Autovector Level 6 */
  73. vector1F: .long _FAULT /* Autovector Level 7 */
  74. /* TRAP #0 - #15 */
  75. vector20_2F:
  76. .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
  77. .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
  78. /* Reserved */
  79. vector30_3F:
  80. .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
  81. .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
  82. vector64_127:
  83. .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
  84. .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
  85. .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
  86. .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
  87. .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
  88. .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
  89. .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
  90. .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
  91. vector128_191:
  92. .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
  93. .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
  94. .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
  95. .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
  96. .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
  97. .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
  98. .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
  99. .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
  100. vector192_255:
  101. .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
  102. .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
  103. .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
  104. .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
  105. .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
  106. .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
  107. .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
  108. .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
  109. .text
  110. .globl _start
  111. _start:
  112. nop
  113. nop
  114. move.w #0x2700,%sr /* Mask off Interrupt */
  115. /* Set vector base register at the beginning of the Flash */
  116. move.l #CONFIG_SYS_FLASH_BASE, %d0
  117. movec %d0, %VBR
  118. move.l #(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_RAM_CTRL), %d0
  119. movec %d0, %RAMBAR1
  120. /* invalidate and disable cache */
  121. move.l #CF_CACR_CINV, %d0 /* Invalidate cache cmd */
  122. movec %d0, %CACR /* Invalidate cache */
  123. nop
  124. move.l #0, %d0
  125. movec %d0, %ACR0
  126. movec %d0, %ACR1
  127. /* initialize general use internal ram */
  128. move.l #0, %d0
  129. move.l #(ICACHE_STATUS), %a1 /* icache */
  130. move.l #(DCACHE_STATUS), %a2 /* icache */
  131. move.l %d0, (%a1)
  132. move.l %d0, (%a2)
  133. /* set stackpointer to end of internal ram to get some stackspace for the
  134. first c-code */
  135. move.l #(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_SP_OFFSET), %sp
  136. clr.l %sp@-
  137. move.l #__got_start, %a5 /* put relocation table address to a5 */
  138. bsr cpu_init_f /* run low-level CPU init code (from flash) */
  139. bsr board_init_f /* run low-level board init code (from flash) */
  140. /* board_init_f() does not return */
  141. /*------------------------------------------------------------------------------*/
  142. /*
  143. * void relocate_code (addr_sp, gd, addr_moni)
  144. *
  145. * This "function" does not return, instead it continues in RAM
  146. * after relocating the monitor code.
  147. *
  148. * r3 = dest
  149. * r4 = src
  150. * r5 = length in bytes
  151. * r6 = cachelinesize
  152. */
  153. .globl relocate_code
  154. relocate_code:
  155. link.w %a6,#0
  156. move.l 8(%a6), %sp /* set new stack pointer */
  157. move.l 12(%a6), %d0 /* Save copy of Global Data pointer */
  158. move.l 16(%a6), %a0 /* Save copy of Destination Address */
  159. move.l #CONFIG_SYS_MONITOR_BASE, %a1
  160. move.l #__init_end, %a2
  161. move.l %a0, %a3
  162. /* copy the code to RAM */
  163. 1:
  164. move.l (%a1)+, (%a3)+
  165. cmp.l %a1,%a2
  166. bgt.s 1b
  167. /*
  168. * We are done. Do not return, instead branch to second part of board
  169. * initialization, now running from RAM.
  170. */
  171. move.l %a0, %a1
  172. add.l #(in_ram - CONFIG_SYS_MONITOR_BASE), %a1
  173. jmp (%a1)
  174. in_ram:
  175. clear_bss:
  176. /*
  177. * Now clear BSS segment
  178. */
  179. move.l %a0, %a1
  180. add.l #(_sbss - CONFIG_SYS_MONITOR_BASE),%a1
  181. move.l %a0, %d1
  182. add.l #(_ebss - CONFIG_SYS_MONITOR_BASE),%d1
  183. 6:
  184. clr.l (%a1)+
  185. cmp.l %a1,%d1
  186. bgt.s 6b
  187. /*
  188. * fix got table in RAM
  189. */
  190. move.l %a0, %a1
  191. add.l #(__got_start - CONFIG_SYS_MONITOR_BASE),%a1
  192. move.l %a1,%a5 /* * fix got pointer register a5 */
  193. move.l %a0, %a2
  194. add.l #(__got_end - CONFIG_SYS_MONITOR_BASE),%a2
  195. 7:
  196. move.l (%a1),%d1
  197. sub.l #_start,%d1
  198. add.l %a0,%d1
  199. move.l %d1,(%a1)+
  200. cmp.l %a2, %a1
  201. bne 7b
  202. /* calculate relative jump to board_init_r in ram */
  203. move.l %a0, %a1
  204. add.l #(board_init_r - CONFIG_SYS_MONITOR_BASE), %a1
  205. /* set parameters for board_init_r */
  206. move.l %a0,-(%sp) /* dest_addr */
  207. move.l %d0,-(%sp) /* gd */
  208. jsr (%a1)
  209. /*------------------------------------------------------------------------------*/
  210. /* exception code */
  211. .globl _fault
  212. _fault:
  213. jmp _fault
  214. .globl _exc_handler
  215. _exc_handler:
  216. SAVE_ALL
  217. movel %sp,%sp@-
  218. bsr exc_handler
  219. addql #4,%sp
  220. RESTORE_ALL
  221. .globl _int_handler
  222. _int_handler:
  223. SAVE_ALL
  224. movel %sp,%sp@-
  225. bsr int_handler
  226. addql #4,%sp
  227. RESTORE_ALL
  228. /*------------------------------------------------------------------------------*/
  229. .globl version_string
  230. version_string:
  231. .ascii U_BOOT_VERSION
  232. .ascii " (", U_BOOT_DATE, " - ", U_BOOT_TIME, ")"
  233. .ascii CONFIG_IDENT_STRING, "\0"
  234. .align 4