start.S 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624
  1. /*
  2. * Copyright (C) 2003 Josef Baumgartner <josef.baumgartner@telex.de>
  3. * Based on code from Bernhard Kuhn <bkuhn@metrowerks.com>
  4. *
  5. * Copyright 2010-2012 Freescale Semiconductor, Inc.
  6. * TsiChung Liew (Tsi-Chung.Liew@freescale.com)
  7. *
  8. * SPDX-License-Identifier: GPL-2.0+
  9. */
  10. #include <common.h>
  11. #include <asm-offsets.h>
  12. #include <config.h>
  13. #include <timestamp.h>
  14. #include "version.h"
  15. #include <asm/cache.h>
  16. #define _START _start
  17. #define _FAULT _fault
  18. #define SAVE_ALL \
  19. move.w #0x2700,%sr; /* disable intrs */ \
  20. subl #60,%sp; /* space for 15 regs */ \
  21. moveml %d0-%d7/%a0-%a6,%sp@;
  22. #define RESTORE_ALL \
  23. moveml %sp@,%d0-%d7/%a0-%a6; \
  24. addl #60,%sp; /* space for 15 regs */ \
  25. rte;
  26. #if defined(CONFIG_SERIAL_BOOT)
  27. #define ASM_DRAMINIT (asm_dram_init - CONFIG_SYS_TEXT_BASE + \
  28. CONFIG_SYS_INIT_RAM_ADDR)
  29. #define ASM_DRAMINIT_N (asm_dram_init - CONFIG_SYS_TEXT_BASE)
  30. #define ASM_SBF_IMG_HDR (asm_sbf_img_hdr - CONFIG_SYS_TEXT_BASE + \
  31. CONFIG_SYS_INIT_RAM_ADDR)
  32. #endif
  33. .text
  34. /*
  35. * Vector table. This is used for initial platform startup.
  36. * These vectors are to catch any un-intended traps.
  37. */
  38. _vectors:
  39. #if defined(CONFIG_SERIAL_BOOT)
  40. INITSP: .long 0 /* Initial SP */
  41. #ifdef CONFIG_CF_SBF
  42. INITPC: .long ASM_DRAMINIT /* Initial PC */
  43. #endif
  44. #ifdef CONFIG_SYS_NAND_BOOT
  45. INITPC: .long ASM_DRAMINIT_N /* Initial PC */
  46. #endif
  47. #else
  48. INITSP: .long 0 /* Initial SP */
  49. INITPC: .long _START /* Initial PC */
  50. #endif
  51. vector02_0F:
  52. .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
  53. .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
  54. /* Reserved */
  55. vector10_17:
  56. .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
  57. vector18_1F:
  58. .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
  59. #if !defined(CONFIG_SERIAL_BOOT)
  60. /* TRAP #0 - #15 */
  61. vector20_2F:
  62. .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
  63. .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
  64. /* Reserved */
  65. vector30_3F:
  66. .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
  67. .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
  68. vector64_127:
  69. .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
  70. .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
  71. .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
  72. .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
  73. .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
  74. .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
  75. .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
  76. .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
  77. vector128_191:
  78. .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
  79. .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
  80. .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
  81. .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
  82. .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
  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. vector192_255:
  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. .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
  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. #endif
  96. #if defined(CONFIG_SERIAL_BOOT)
  97. /* Image header: chksum 4 bytes, len 4 bytes, img dest 4 bytes */
  98. asm_sbf_img_hdr:
  99. .long 0x00000000 /* checksum, not yet implemented */
  100. .long 0x00040000 /* image length */
  101. .long CONFIG_SYS_TEXT_BASE /* image to be relocated at */
  102. asm_dram_init:
  103. move.w #0x2700,%sr /* Mask off Interrupt */
  104. #ifdef CONFIG_SYS_NAND_BOOT
  105. /* for assembly stack */
  106. move.l #(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_RAM_CTRL), %d0
  107. movec %d0, %RAMBAR1
  108. move.l #(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_SP_OFFSET), %sp
  109. clr.l %sp@-
  110. #endif
  111. #ifdef CONFIG_CF_SBF
  112. move.l #CONFIG_SYS_INIT_RAM_ADDR, %d0
  113. movec %d0, %VBR
  114. move.l #(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_RAM_CTRL), %d0
  115. movec %d0, %RAMBAR1
  116. /* initialize general use internal ram */
  117. move.l #0, %d0
  118. move.l #(ICACHE_STATUS), %a1 /* icache */
  119. move.l #(DCACHE_STATUS), %a2 /* dcache */
  120. move.l %d0, (%a1)
  121. move.l %d0, (%a2)
  122. /* invalidate and disable cache */
  123. move.l #(CONFIG_SYS_ICACHE_INV + CONFIG_SYS_DCACHE_INV), %d0
  124. movec %d0, %CACR /* Invalidate cache */
  125. move.l #0, %d0
  126. movec %d0, %ACR0
  127. movec %d0, %ACR1
  128. movec %d0, %ACR2
  129. movec %d0, %ACR3
  130. move.l #(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_SP_OFFSET), %sp
  131. clr.l %sp@-
  132. #ifdef CONFIG_SYS_CS0_BASE
  133. /* Must disable global address */
  134. move.l #0xFC008000, %a1
  135. move.l #(CONFIG_SYS_CS0_BASE), (%a1)
  136. move.l #0xFC008008, %a1
  137. move.l #(CONFIG_SYS_CS0_CTRL), (%a1)
  138. move.l #0xFC008004, %a1
  139. move.l #(CONFIG_SYS_CS0_MASK), (%a1)
  140. #endif
  141. #endif /* CONFIG_CF_SBF */
  142. #ifdef CONFIG_MCF5441x
  143. /* TC: enable all peripherals,
  144. in the future only enable certain peripherals */
  145. move.l #0xFC04002D, %a1
  146. #if defined(CONFIG_CF_SBF)
  147. move.b #23, (%a1) /* dspi */
  148. #endif
  149. #endif /* CONFIG_MCF5441x */
  150. /* mandatory board level ddr-sdram init,
  151. * for both 5441x and 5445x
  152. */
  153. bsr sbf_dram_init
  154. #ifdef CONFIG_CF_SBF
  155. /*
  156. * DSPI Initialization
  157. * a0 - general, sram - 0x80008000 - 32, see M54455EVB.h
  158. * a1 - dspi status
  159. * a2 - dtfr
  160. * a3 - drfr
  161. * a4 - Dst addr
  162. */
  163. /* Enable pins for DSPI mode - chip-selects are enabled later */
  164. asm_dspi_init:
  165. #ifdef CONFIG_MCF5441x
  166. move.l #0xEC09404E, %a1
  167. move.l #0xEC09404F, %a2
  168. move.b #0xFF, (%a1)
  169. move.b #0x80, (%a2)
  170. #endif
  171. #ifdef CONFIG_MCF5445x
  172. move.l #0xFC0A4063, %a0
  173. move.b #0x7F, (%a0)
  174. #endif
  175. /* Configure DSPI module */
  176. move.l #0xFC05C000, %a0
  177. move.l #0x80FF0C00, (%a0) /* Master, clear TX/RX FIFO */
  178. move.l #0xFC05C00C, %a0
  179. #ifdef CONFIG_MCF5441x
  180. move.l #0x3E000016, (%a0)
  181. #endif
  182. #ifdef CONFIG_MCF5445x
  183. move.l #0x3E000011, (%a0)
  184. #endif
  185. move.l #0xFC05C034, %a2 /* dtfr */
  186. move.l #0xFC05C03B, %a3 /* drfr */
  187. move.l #(ASM_SBF_IMG_HDR + 4), %a1
  188. move.l (%a1)+, %d5
  189. move.l (%a1), %a4
  190. move.l #(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_SBFHDR_DATA_OFFSET), %a0
  191. move.l #(CONFIG_SYS_SBFHDR_SIZE), %d4
  192. move.l #0xFC05C02C, %a1 /* dspi status */
  193. /* Issue commands and address */
  194. move.l #0x8002000B, %d2 /* Fast Read Cmd */
  195. jsr asm_dspi_wr_status
  196. jsr asm_dspi_rd_status
  197. move.l #0x80020000, %d2 /* Address byte 2 */
  198. jsr asm_dspi_wr_status
  199. jsr asm_dspi_rd_status
  200. move.l #0x80020000, %d2 /* Address byte 1 */
  201. jsr asm_dspi_wr_status
  202. jsr asm_dspi_rd_status
  203. move.l #0x80020000, %d2 /* Address byte 0 */
  204. jsr asm_dspi_wr_status
  205. jsr asm_dspi_rd_status
  206. move.l #0x80020000, %d2 /* Dummy Wr and Rd */
  207. jsr asm_dspi_wr_status
  208. jsr asm_dspi_rd_status
  209. /* Transfer serial boot header to sram */
  210. asm_dspi_rd_loop1:
  211. move.l #0x80020000, %d2
  212. jsr asm_dspi_wr_status
  213. jsr asm_dspi_rd_status
  214. move.b %d1, (%a0) /* read, copy to dst */
  215. add.l #1, %a0 /* inc dst by 1 */
  216. sub.l #1, %d4 /* dec cnt by 1 */
  217. bne asm_dspi_rd_loop1
  218. /* Transfer u-boot from serial flash to memory */
  219. asm_dspi_rd_loop2:
  220. move.l #0x80020000, %d2
  221. jsr asm_dspi_wr_status
  222. jsr asm_dspi_rd_status
  223. move.b %d1, (%a4) /* read, copy to dst */
  224. add.l #1, %a4 /* inc dst by 1 */
  225. sub.l #1, %d5 /* dec cnt by 1 */
  226. bne asm_dspi_rd_loop2
  227. move.l #0x00020000, %d2 /* Terminate */
  228. jsr asm_dspi_wr_status
  229. jsr asm_dspi_rd_status
  230. /* jump to memory and execute */
  231. move.l #(CONFIG_SYS_TEXT_BASE + 0x400), %a0
  232. jmp (%a0)
  233. asm_dspi_wr_status:
  234. move.l (%a1), %d0 /* status */
  235. and.l #0x0000F000, %d0
  236. cmp.l #0x00003000, %d0
  237. bgt asm_dspi_wr_status
  238. move.l %d2, (%a2)
  239. rts
  240. asm_dspi_rd_status:
  241. move.l (%a1), %d0 /* status */
  242. and.l #0x000000F0, %d0
  243. lsr.l #4, %d0
  244. cmp.l #0, %d0
  245. beq asm_dspi_rd_status
  246. move.b (%a3), %d1
  247. rts
  248. #endif /* CONFIG_CF_SBF */
  249. #ifdef CONFIG_SYS_NAND_BOOT
  250. /* copy 4 boot pages to dram as soon as possible */
  251. /* each page is 996 bytes (1056 total with 60 ECC bytes */
  252. move.l #0x00000000, %a1 /* src */
  253. move.l #CONFIG_SYS_TEXT_BASE, %a2 /* dst */
  254. move.l #0x3E0, %d0 /* sz in long */
  255. asm_boot_nand_copy:
  256. move.l (%a1)+, (%a2)+
  257. subq.l #1, %d0
  258. bne asm_boot_nand_copy
  259. /* jump to memory and execute */
  260. move.l #(asm_nand_init), %a0
  261. jmp (%a0)
  262. asm_nand_init:
  263. /* exit nand boot-mode */
  264. move.l #0xFC0FFF30, %a1
  265. or.l #0x00000040, %d1
  266. move.l %d1, (%a1)
  267. /* initialize general use internal ram */
  268. move.l #0, %d0
  269. move.l #(CACR_STATUS), %a1 /* CACR */
  270. move.l #(ICACHE_STATUS), %a2 /* icache */
  271. move.l #(DCACHE_STATUS), %a3 /* dcache */
  272. move.l %d0, (%a1)
  273. move.l %d0, (%a2)
  274. move.l %d0, (%a3)
  275. /* invalidate and disable cache */
  276. move.l #0x01004100, %d0 /* Invalidate cache cmd */
  277. movec %d0, %CACR /* Invalidate cache */
  278. move.l #0, %d0
  279. movec %d0, %ACR0
  280. movec %d0, %ACR1
  281. movec %d0, %ACR2
  282. movec %d0, %ACR3
  283. #ifdef CONFIG_SYS_CS0_BASE
  284. /* Must disable global address */
  285. move.l #0xFC008000, %a1
  286. move.l #(CONFIG_SYS_CS0_BASE), (%a1)
  287. move.l #0xFC008008, %a1
  288. move.l #(CONFIG_SYS_CS0_CTRL), (%a1)
  289. move.l #0xFC008004, %a1
  290. move.l #(CONFIG_SYS_CS0_MASK), (%a1)
  291. #endif
  292. /* NAND port configuration */
  293. move.l #0xEC094048, %a1
  294. move.b #0xFD, (%a1)+
  295. move.b #0x5F, (%a1)+
  296. move.b #0x04, (%a1)+
  297. /* reset nand */
  298. move.l #0xFC0FFF38, %a1 /* isr */
  299. move.l #0x000e0000, (%a1)
  300. move.l #0xFC0FFF08, %a2
  301. move.l #0x00000000, (%a2)+ /* car */
  302. move.l #0x11000000, (%a2)+ /* rar */
  303. move.l #0x00000000, (%a2)+ /* rpt */
  304. move.l #0x00000000, (%a2)+ /* rai */
  305. move.l #0xFC0FFF2c, %a2 /* cfg */
  306. move.l #0x00000000, (%a2)+ /* secsz */
  307. move.l #0x000e0681, (%a2)+
  308. move.l #0xFC0FFF04, %a2 /* cmd2 */
  309. move.l #0xFF404001, (%a2)
  310. move.l #0x000e0000, (%a1)
  311. move.l #0x2000, %d1
  312. bsr asm_delay
  313. /* setup nand */
  314. move.l #0xFC0FFF00, %a1
  315. move.l #0x30700000, (%a1)+ /* cmd1 */
  316. move.l #0x007EF000, (%a1)+ /* cmd2 */
  317. move.l #0xFC0FFF2C, %a1
  318. move.l #0x00000841, (%a1)+ /* secsz */
  319. move.l #0x000e0681, (%a1)+ /* cfg */
  320. move.l #100, %d4 /* 100 pages ~200KB */
  321. move.l #4, %d2 /* start at 4 */
  322. move.l #0xFC0FFF04, %a0 /* cmd2 */
  323. move.l #0xFC0FFF0C, %a1 /* rar */
  324. move.l #(CONFIG_SYS_TEXT_BASE + 0xF80), %a2
  325. asm_nand_read:
  326. move.l #0x11000000, %d0 /* rar */
  327. or.l %d2, %d0
  328. move.l %d0, (%a1)
  329. add.l #1, %d2
  330. move.l (%a0), %d0 /* cmd2 */
  331. or.l #1, %d0
  332. move.l %d0, (%a0)
  333. move.l #0x200, %d1
  334. bsr asm_delay
  335. asm_nand_chk_status:
  336. move.l #0xFC0FFF38, %a4 /* isr */
  337. move.l (%a4), %d0
  338. and.l #0x40000000, %d0
  339. tst.l %d0
  340. beq asm_nand_chk_status
  341. move.l #0xFC0FFF38, %a4 /* isr */
  342. move.l (%a4), %d0
  343. or.l #0x000E0000, %d0
  344. move.l %d0, (%a4)
  345. move.l #0x200, %d3
  346. move.l #0xFC0FC000, %a3 /* buf 1 */
  347. asm_nand_copy:
  348. move.l (%a3)+, (%a2)+
  349. subq.l #1, %d3
  350. bgt asm_nand_copy
  351. subq.l #1, %d4
  352. bgt asm_nand_read
  353. /* jump to memory and execute */
  354. move.l #(CONFIG_SYS_TEXT_BASE + 0x400), %a0
  355. jmp (%a0)
  356. #endif /* CONFIG_SYS_NAND_BOOT */
  357. .globl asm_delay
  358. asm_delay:
  359. nop
  360. subq.l #1, %d1
  361. bne asm_delay
  362. rts
  363. #endif /* CONFIG_CF_SBF || CONFIG_NAND_U_BOOT */
  364. .text
  365. . = 0x400
  366. .globl _start
  367. _start:
  368. #if !defined(CONFIG_SERIAL_BOOT)
  369. nop
  370. nop
  371. move.w #0x2700,%sr /* Mask off Interrupt */
  372. /* Set vector base register at the beginning of the Flash */
  373. move.l #CONFIG_SYS_FLASH_BASE, %d0
  374. movec %d0, %VBR
  375. move.l #(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_RAM_CTRL), %d0
  376. movec %d0, %RAMBAR1
  377. /* initialize general use internal ram */
  378. move.l #0, %d0
  379. move.l #(ICACHE_STATUS), %a1 /* icache */
  380. move.l #(DCACHE_STATUS), %a2 /* dcache */
  381. move.l %d0, (%a1)
  382. move.l %d0, (%a2)
  383. /* invalidate and disable cache */
  384. move.l #(CONFIG_SYS_ICACHE_INV + CONFIG_SYS_DCACHE_INV), %d0
  385. movec %d0, %CACR /* Invalidate cache */
  386. move.l #0, %d0
  387. movec %d0, %ACR0
  388. movec %d0, %ACR1
  389. movec %d0, %ACR2
  390. movec %d0, %ACR3
  391. #else
  392. move.l #(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_RAM_CTRL), %d0
  393. movec %d0, %RAMBAR1
  394. #endif
  395. /* put relocation table address to a5 */
  396. move.l #__got_start, %a5
  397. /* setup stack initially on top of internal static ram */
  398. move.l #(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_RAM_SIZE), %sp
  399. /*
  400. * if configured, malloc_f arena will be reserved first,
  401. * then (and always) gd struct space will be reserved
  402. */
  403. move.l %sp, -(%sp)
  404. move.l #board_init_f_alloc_reserve, %a1
  405. jsr (%a1)
  406. /* update stack and frame-pointers */
  407. move.l %d0, %sp
  408. move.l %sp, %fp
  409. /* initialize reserved area */
  410. move.l %d0, -(%sp)
  411. move.l #board_init_f_init_reserve, %a1
  412. jsr (%a1)
  413. /* run low-level CPU init code (from flash) */
  414. move.l #cpu_init_f, %a1
  415. jsr (%a1)
  416. /* run low-level board init code (from flash) */
  417. clr.l %sp@-
  418. move.l #board_init_f, %a1
  419. jsr (%a1)
  420. /* board_init_f() does not return */
  421. /******************************************************************************/
  422. /*
  423. * void relocate_code (addr_sp, gd, addr_moni)
  424. *
  425. * This "function" does not return, instead it continues in RAM
  426. * after relocating the monitor code.
  427. *
  428. * r3 = dest
  429. * r4 = src
  430. * r5 = length in bytes
  431. * r6 = cachelinesize
  432. */
  433. .globl relocate_code
  434. relocate_code:
  435. link.w %a6,#0
  436. move.l 8(%a6), %sp /* set new stack pointer */
  437. move.l 12(%a6), %d0 /* Save copy of Global Data pointer */
  438. move.l 16(%a6), %a0 /* Save copy of Destination Address */
  439. move.l #CONFIG_SYS_MONITOR_BASE, %a1
  440. move.l #__init_end, %a2
  441. move.l %a0, %a3
  442. /* copy the code to RAM */
  443. 1:
  444. move.l (%a1)+, (%a3)+
  445. cmp.l %a1,%a2
  446. bgt.s 1b
  447. /*
  448. * We are done. Do not return, instead branch to second part of board
  449. * initialization, now running from RAM.
  450. */
  451. move.l %a0, %a1
  452. add.l #(in_ram - CONFIG_SYS_MONITOR_BASE), %a1
  453. jmp (%a1)
  454. in_ram:
  455. clear_bss:
  456. /*
  457. * Now clear BSS segment
  458. */
  459. move.l %a0, %a1
  460. add.l #(_sbss - CONFIG_SYS_MONITOR_BASE),%a1
  461. move.l %a0, %d1
  462. add.l #(_ebss - CONFIG_SYS_MONITOR_BASE),%d1
  463. 6:
  464. clr.l (%a1)+
  465. cmp.l %a1,%d1
  466. bgt.s 6b
  467. /*
  468. * fix got table in RAM
  469. */
  470. move.l %a0, %a1
  471. add.l #(__got_start - CONFIG_SYS_MONITOR_BASE),%a1
  472. move.l %a1,%a5 /* fix got pointer register a5 */
  473. move.l %a0, %a2
  474. add.l #(__got_end - CONFIG_SYS_MONITOR_BASE),%a2
  475. 7:
  476. move.l (%a1),%d1
  477. sub.l #_start,%d1
  478. add.l %a0,%d1
  479. move.l %d1,(%a1)+
  480. cmp.l %a2, %a1
  481. bne 7b
  482. /* calculate relative jump to board_init_r in ram */
  483. move.l %a0, %a1
  484. add.l #(board_init_r - CONFIG_SYS_MONITOR_BASE), %a1
  485. /* set parameters for board_init_r */
  486. move.l %a0,-(%sp) /* dest_addr */
  487. move.l %d0,-(%sp) /* gd */
  488. jsr (%a1)
  489. /******************************************************************************/
  490. /* exception code */
  491. .globl _fault
  492. _fault:
  493. bra _fault
  494. .globl _exc_handler
  495. _exc_handler:
  496. SAVE_ALL
  497. movel %sp,%sp@-
  498. bsr exc_handler
  499. addql #4,%sp
  500. RESTORE_ALL
  501. .globl _int_handler
  502. _int_handler:
  503. SAVE_ALL
  504. movel %sp,%sp@-
  505. bsr int_handler
  506. addql #4,%sp
  507. RESTORE_ALL
  508. /******************************************************************************/
  509. .globl version_string
  510. version_string:
  511. .ascii U_BOOT_VERSION_STRING, "\0"
  512. .align 4