2 * Copyright (C) 2003 Josef Baumgartner <josef.baumgartner@telex.de>
3 * Based on code from Bernhard Kuhn <bkuhn@metrowerks.com>
5 * SPDX-License-Identifier: GPL-2.0+
8 #include <asm-offsets.h>
11 #include <asm/cache.h>
13 #ifndef CONFIG_IDENT_STRING
14 #define CONFIG_IDENT_STRING ""
22 move.w #0x2700,%sr; /* disable intrs */ \
23 subl #60,%sp; /* space for 15 regs */ \
24 moveml %d0-%d7/%a0-%a6,%sp@; \
27 moveml %sp@,%d0-%d7/%a0-%a6; \
28 addl #60,%sp; /* space for 15 regs */ \
31 /* If we come from a pre-loader we don't need an initial exception
34 #if !defined(CONFIG_MONITOR_IS_IN_RAM)
39 * Vector table. This is used for initial platform startup.
40 * These vectors are to catch any un-intended traps.
43 .long 0x00000000 /* Flash offset is 0 until we setup CS0 */
44 #if defined(CONFIG_M5282) && (CONFIG_SYS_TEXT_BASE == CONFIG_SYS_INT_FLASH_BASE)
45 .long _start - CONFIG_SYS_TEXT_BASE
50 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
51 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
52 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
53 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
54 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
55 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
56 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
57 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
59 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
60 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
61 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
62 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
63 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
64 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
65 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
66 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
68 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
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
77 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
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
90 #if defined(CONFIG_SYS_INT_FLASH_BASE) && \
91 (defined(CONFIG_M5282) || defined(CONFIG_M5281))
92 #if (CONFIG_SYS_TEXT_BASE == CONFIG_SYS_INT_FLASH_BASE)
93 .long 0x55AA55AA,0xAA55AA55 /* CFM Backdoorkey */
94 .long 0xFFFFFFFF /* all sectors protected */
95 .long 0x00000000 /* supervisor/User restriction */
96 .long 0x00000000 /* programm/data space restriction */
97 .long 0x00000000 /* Flash security */
107 #if defined(CONFIG_M5208)
108 /* Initialize RAMBAR: locate SRAM and validate it */
109 move.l #(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_RAM_CTRL), %d0
113 #if defined(CONFIG_M5272) || defined(CONFIG_M5249) || defined(CONFIG_M5253)
114 /* set MBAR address + valid flag */
115 move.l #(CONFIG_SYS_MBAR + 1), %d0
118 /*** The 5249 has MBAR2 as well ***/
119 #ifdef CONFIG_SYS_MBAR2
120 /* Get MBAR2 address */
121 move.l #(CONFIG_SYS_MBAR2 + 1), %d0
125 move.l #(CONFIG_SYS_INIT_RAM_ADDR + 1), %d0
127 #endif /* CONFIG_M5272 || CONFIG_M5249 || CONFIG_M5253 */
129 #if defined(CONFIG_M5282) || defined(CONFIG_M5271)
130 /* set MBAR address + valid flag */
131 move.l #(CONFIG_SYS_MBAR + 1), %d0
132 move.l %d0, 0x40000000
134 /* Initialize RAMBAR1: locate SRAM and validate it */
135 move.l #(CONFIG_SYS_INIT_RAM_ADDR + 0x21), %d0
138 #if defined(CONFIG_M5282)
139 #if (CONFIG_SYS_TEXT_BASE == CONFIG_SYS_INT_FLASH_BASE)
141 * Setup code in SRAM to initialize FLASHBAR,
142 * if start from internal Flash
144 move.l #(_flashbar_setup-CONFIG_SYS_INT_FLASH_BASE), %a0
145 move.l #(_flashbar_setup_end-CONFIG_SYS_INT_FLASH_BASE), %a1
146 move.l #(CONFIG_SYS_INIT_RAM_ADDR), %a2
148 move.l (%a0)+, (%a2)+
151 jmp CONFIG_SYS_INIT_RAM_ADDR
154 /* Initialize FLASHBAR: locate internal Flash and validate it */
155 move.l #(CONFIG_SYS_INT_FLASH_BASE + CONFIG_SYS_INT_FLASH_ENABLE), %d0
157 jmp _after_flashbar_copy.L /* Force jump to absolute address */
160 _after_flashbar_copy:
162 /* Setup code to initialize FLASHBAR, if start from external Memory */
163 move.l #(CONFIG_SYS_INT_FLASH_BASE + CONFIG_SYS_INT_FLASH_ENABLE), %d0
165 #endif /* (CONFIG_SYS_TEXT_BASE == CONFIG_SYS_INT_FLASH_BASE) */
170 * if we come from a pre-loader we have no exception table and
171 * therefore no VBR to set
173 #if !defined(CONFIG_MONITOR_IS_IN_RAM)
174 #if defined(CONFIG_M5282) && (CONFIG_SYS_TEXT_BASE == CONFIG_SYS_INT_FLASH_BASE)
175 move.l #CONFIG_SYS_INT_FLASH_BASE, %d0
177 move.l #CONFIG_SYS_FLASH_BASE, %d0
183 /* set MBAR address + valid flag */
184 move.l #(CONFIG_SYS_MBAR + 1), %d0
185 move.l %d0, 0x40000000
186 /* movec %d0, %MBAR */
188 /* Initialize RAMBAR: locate SRAM and validate it */
189 move.l #(CONFIG_SYS_INIT_RAM_ADDR + 0x21), %d0
193 /* initialize general use internal ram */
195 move.l #(ICACHE_STATUS), %a1 /* icache */
196 move.l #(DCACHE_STATUS), %a2 /* icache */
200 /* put relocation table address to a5 */
201 move.l #__got_start, %a5
203 /* setup stack initially on top of internal static ram */
204 move.l #(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_RAM_SIZE), %sp
207 * if configured, malloc_f arena will be reserved first,
208 * then (and always) gd struct space will be reserved
211 move.l #board_init_f_alloc_reserve, %a1
214 /* update stack and frame-pointers */
218 /* initialize reserved area */
220 move.l #board_init_f_init_reserve, %a1
223 /* run low-level CPU init code (from flash) */
224 move.l #cpu_init_f, %a1
227 /* run low-level board init code (from flash) */
229 move.l #board_init_f, %a1
232 /* board_init_f() does not return */
234 /******************************************************************************/
237 * void relocate_code (addr_sp, gd, addr_moni)
239 * This "function" does not return, instead it continues in RAM
240 * after relocating the monitor code.
244 * r5 = length in bytes
250 move.l 8(%a6), %sp /* set new stack pointer */
252 move.l 12(%a6), %d0 /* Save copy of Global Data pointer */
253 move.l 16(%a6), %a0 /* Save copy of Destination Address */
255 move.l #CONFIG_SYS_MONITOR_BASE, %a1
256 move.l #__init_end, %a2
258 /* copy the code to RAM */
260 move.l (%a1)+, (%a3)+
265 * We are done. Do not return, instead branch to second part of board
266 * initialization, now running from RAM.
269 add.l #(in_ram - CONFIG_SYS_MONITOR_BASE), %a1
276 * Now clear BSS segment
279 add.l #(_sbss - CONFIG_SYS_MONITOR_BASE),%a1
281 add.l #(_ebss - CONFIG_SYS_MONITOR_BASE),%d1
288 * fix got table in RAM
291 add.l #(__got_start - CONFIG_SYS_MONITOR_BASE),%a1
292 move.l %a1,%a5 /* fix got pointer register a5 */
295 add.l #(__got_end - CONFIG_SYS_MONITOR_BASE),%a2
305 /* calculate relative jump to board_init_r in ram */
307 add.l #(board_init_r - CONFIG_SYS_MONITOR_BASE), %a1
309 /* set parameters for board_init_r */
310 move.l %a0,-(%sp) /* dest_addr */
311 move.l %d0,-(%sp) /* gd */
312 #if defined(DEBUG) && (CONFIG_SYS_TEXT_BASE != CONFIG_SYS_INT_FLASH_BASE) && \
313 defined(CONFIG_SYS_HALT_BEFOR_RAM_JUMP)
318 /******************************************************************************/
341 /******************************************************************************/
343 .globl version_string
345 .ascii U_BOOT_VERSION_STRING, "\0"