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>
18 move.w #0x2700,%sr; /* disable intrs */ \
19 subl #60,%sp; /* space for 15 regs */ \
20 moveml %d0-%d7/%a0-%a6,%sp@; \
23 moveml %sp@,%d0-%d7/%a0-%a6; \
24 addl #60,%sp; /* space for 15 regs */ \
27 /* If we come from a pre-loader we don't need an initial exception
30 #if !defined(CONFIG_MONITOR_IS_IN_RAM)
35 * Vector table. This is used for initial platform startup.
36 * These vectors are to catch any un-intended traps.
39 .long 0x00000000 /* Flash offset is 0 until we setup CS0 */
40 #if defined(CONFIG_M5282) && (CONFIG_SYS_TEXT_BASE == CONFIG_SYS_INT_FLASH_BASE)
41 .long _start - CONFIG_SYS_TEXT_BASE
46 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
47 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
48 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
49 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
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
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, _FAULT, _FAULT
58 .long _FAULT, _FAULT, _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
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
67 .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
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 .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
86 #if defined(CONFIG_SYS_INT_FLASH_BASE) && \
87 (defined(CONFIG_M5282) || defined(CONFIG_M5281))
88 #if (CONFIG_SYS_TEXT_BASE == CONFIG_SYS_INT_FLASH_BASE)
89 .long 0x55AA55AA,0xAA55AA55 /* CFM Backdoorkey */
90 .long 0xFFFFFFFF /* all sectors protected */
91 .long 0x00000000 /* supervisor/User restriction */
92 .long 0x00000000 /* programm/data space restriction */
93 .long 0x00000000 /* Flash security */
103 #if defined(CONFIG_M5208)
104 /* Initialize RAMBAR: locate SRAM and validate it */
105 move.l #(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_RAM_CTRL), %d0
109 #if defined(CONFIG_M5272) || defined(CONFIG_M5249) || defined(CONFIG_M5253)
110 /* set MBAR address + valid flag */
111 move.l #(CONFIG_SYS_MBAR + 1), %d0
114 /*** The 5249 has MBAR2 as well ***/
115 #ifdef CONFIG_SYS_MBAR2
116 /* Get MBAR2 address */
117 move.l #(CONFIG_SYS_MBAR2 + 1), %d0
121 move.l #(CONFIG_SYS_INIT_RAM_ADDR + 1), %d0
123 #endif /* CONFIG_M5272 || CONFIG_M5249 || CONFIG_M5253 */
125 #if defined(CONFIG_M5282) || defined(CONFIG_M5271)
126 /* set MBAR address + valid flag */
127 move.l #(CONFIG_SYS_MBAR + 1), %d0
128 move.l %d0, 0x40000000
130 /* Initialize RAMBAR1: locate SRAM and validate it */
131 move.l #(CONFIG_SYS_INIT_RAM_ADDR + 0x21), %d0
134 #if defined(CONFIG_M5282)
135 #if (CONFIG_SYS_TEXT_BASE == CONFIG_SYS_INT_FLASH_BASE)
137 * Setup code in SRAM to initialize FLASHBAR,
138 * if start from internal Flash
140 move.l #(_flashbar_setup-CONFIG_SYS_INT_FLASH_BASE), %a0
141 move.l #(_flashbar_setup_end-CONFIG_SYS_INT_FLASH_BASE), %a1
142 move.l #(CONFIG_SYS_INIT_RAM_ADDR), %a2
144 move.l (%a0)+, (%a2)+
147 jmp CONFIG_SYS_INIT_RAM_ADDR
150 /* Initialize FLASHBAR: locate internal Flash and validate it */
151 move.l #(CONFIG_SYS_INT_FLASH_BASE + CONFIG_SYS_INT_FLASH_ENABLE), %d0
153 jmp _after_flashbar_copy.L /* Force jump to absolute address */
156 _after_flashbar_copy:
158 /* Setup code to initialize FLASHBAR, if start from external Memory */
159 move.l #(CONFIG_SYS_INT_FLASH_BASE + CONFIG_SYS_INT_FLASH_ENABLE), %d0
161 #endif /* (CONFIG_SYS_TEXT_BASE == CONFIG_SYS_INT_FLASH_BASE) */
166 * if we come from a pre-loader we have no exception table and
167 * therefore no VBR to set
169 #if !defined(CONFIG_MONITOR_IS_IN_RAM)
170 #if defined(CONFIG_M5282) && (CONFIG_SYS_TEXT_BASE == CONFIG_SYS_INT_FLASH_BASE)
171 move.l #CONFIG_SYS_INT_FLASH_BASE, %d0
173 move.l #CONFIG_SYS_FLASH_BASE, %d0
179 /* set MBAR address + valid flag */
180 move.l #(CONFIG_SYS_MBAR + 1), %d0
181 move.l %d0, 0x40000000
182 /* movec %d0, %MBAR */
184 /* Initialize RAMBAR: locate SRAM and validate it */
185 move.l #(CONFIG_SYS_INIT_RAM_ADDR + 0x21), %d0
189 /* initialize general use internal ram */
191 move.l #(ICACHE_STATUS), %a1 /* icache */
192 move.l #(DCACHE_STATUS), %a2 /* icache */
196 /* put relocation table address to a5 */
197 move.l #__got_start, %a5
199 /* setup stack initially on top of internal static ram */
200 move.l #(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_RAM_SIZE), %sp
203 * if configured, malloc_f arena will be reserved first,
204 * then (and always) gd struct space will be reserved
207 move.l #board_init_f_alloc_reserve, %a1
210 /* update stack and frame-pointers */
214 /* initialize reserved area */
216 move.l #board_init_f_init_reserve, %a1
219 /* run low-level CPU init code (from flash) */
220 move.l #cpu_init_f, %a1
223 /* run low-level board init code (from flash) */
225 move.l #board_init_f, %a1
228 /* board_init_f() does not return */
230 /******************************************************************************/
233 * void relocate_code (addr_sp, gd, addr_moni)
235 * This "function" does not return, instead it continues in RAM
236 * after relocating the monitor code.
240 * r5 = length in bytes
246 move.l 8(%a6), %sp /* set new stack pointer */
248 move.l 12(%a6), %d0 /* Save copy of Global Data pointer */
249 move.l 16(%a6), %a0 /* Save copy of Destination Address */
251 move.l #CONFIG_SYS_MONITOR_BASE, %a1
252 move.l #__init_end, %a2
254 /* copy the code to RAM */
256 move.l (%a1)+, (%a3)+
261 * We are done. Do not return, instead branch to second part of board
262 * initialization, now running from RAM.
265 add.l #(in_ram - CONFIG_SYS_MONITOR_BASE), %a1
272 * Now clear BSS segment
275 add.l #(_sbss - CONFIG_SYS_MONITOR_BASE),%a1
277 add.l #(_ebss - CONFIG_SYS_MONITOR_BASE),%d1
284 * fix got table in RAM
287 add.l #(__got_start - CONFIG_SYS_MONITOR_BASE),%a1
288 move.l %a1,%a5 /* fix got pointer register a5 */
291 add.l #(__got_end - CONFIG_SYS_MONITOR_BASE),%a2
301 /* calculate relative jump to board_init_r in ram */
303 add.l #(board_init_r - CONFIG_SYS_MONITOR_BASE), %a1
305 /* set parameters for board_init_r */
306 move.l %a0,-(%sp) /* dest_addr */
307 move.l %d0,-(%sp) /* gd */
308 #if defined(DEBUG) && (CONFIG_SYS_TEXT_BASE != CONFIG_SYS_INT_FLASH_BASE) && \
309 defined(CONFIG_SYS_HALT_BEFOR_RAM_JUMP)
314 /******************************************************************************/
337 /******************************************************************************/
339 .globl version_string
341 .ascii U_BOOT_VERSION_STRING, "\0"