1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Copyright (C) 2003 Josef Baumgartner <josef.baumgartner@telex.de>
4 * Based on code from Bernhard Kuhn <bkuhn@metrowerks.com>
7 #include <asm-offsets.h>
16 move.w #0x2700,%sr; /* disable intrs */ \
17 subl #60,%sp; /* space for 15 regs */ \
18 moveml %d0-%d7/%a0-%a6,%sp@; \
21 moveml %sp@,%d0-%d7/%a0-%a6; \
22 addl #60,%sp; /* space for 15 regs */ \
25 /* If we come from a pre-loader we don't need an initial exception
28 #if !defined(CONFIG_MONITOR_IS_IN_RAM)
33 * Vector table. This is used for initial platform startup.
34 * These vectors are to catch any un-intended traps.
37 .long 0x00000000 /* Flash offset is 0 until we setup CS0 */
38 #if defined(CONFIG_M5282) && (CONFIG_TEXT_BASE == CONFIG_SYS_INT_FLASH_BASE)
39 .long _start - CONFIG_TEXT_BASE
44 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
45 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
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
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, _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
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
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
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 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
78 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
84 #if defined(CONFIG_SYS_INT_FLASH_BASE) && \
85 (defined(CONFIG_M5282) || defined(CONFIG_M5281))
86 #if (CONFIG_TEXT_BASE == CONFIG_SYS_INT_FLASH_BASE)
87 .long 0x55AA55AA,0xAA55AA55 /* CFM Backdoorkey */
88 .long 0xFFFFFFFF /* all sectors protected */
89 .long 0x00000000 /* supervisor/User restriction */
90 .long 0x00000000 /* programm/data space restriction */
91 .long 0x00000000 /* Flash security */
101 #if defined(CONFIG_M5208)
102 /* Initialize RAMBAR: locate SRAM and validate it */
103 move.l #(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_RAM_CTRL), %d0
107 #if defined(CONFIG_M5272) || defined(CONFIG_M5249) || defined(CONFIG_M5253)
108 /* set MBAR address + valid flag */
109 move.l #(CONFIG_SYS_MBAR + 1), %d0
112 /*** The 5249 has MBAR2 as well ***/
113 #ifdef CONFIG_SYS_MBAR2
114 /* Get MBAR2 address */
115 move.l #(CONFIG_SYS_MBAR2 + 1), %d0
119 move.l #(CONFIG_SYS_INIT_RAM_ADDR + 1), %d0
121 #endif /* CONFIG_M5272 || CONFIG_M5249 || CONFIG_M5253 */
123 #if defined(CONFIG_M5282) || defined(CONFIG_M5271)
124 /* set MBAR address + valid flag */
125 move.l #(CONFIG_SYS_MBAR + 1), %d0
126 move.l %d0, 0x40000000
128 /* Initialize RAMBAR1: locate SRAM and validate it */
129 move.l #(CONFIG_SYS_INIT_RAM_ADDR + 0x21), %d0
132 #if defined(CONFIG_M5282)
133 #if (CONFIG_TEXT_BASE == CONFIG_SYS_INT_FLASH_BASE)
135 * Setup code in SRAM to initialize FLASHBAR,
136 * if start from internal Flash
138 move.l #(_flashbar_setup-CONFIG_SYS_INT_FLASH_BASE), %a0
139 move.l #(_flashbar_setup_end-CONFIG_SYS_INT_FLASH_BASE), %a1
140 move.l #(CONFIG_SYS_INIT_RAM_ADDR), %a2
142 move.l (%a0)+, (%a2)+
145 jmp CONFIG_SYS_INIT_RAM_ADDR
148 /* Initialize FLASHBAR: locate internal Flash and validate it */
149 move.l #(CONFIG_SYS_INT_FLASH_BASE + CONFIG_SYS_INT_FLASH_ENABLE), %d0
151 jmp _after_flashbar_copy.L /* Force jump to absolute address */
154 _after_flashbar_copy:
156 /* Setup code to initialize FLASHBAR, if start from external Memory */
157 move.l #(CONFIG_SYS_INT_FLASH_BASE + CONFIG_SYS_INT_FLASH_ENABLE), %d0
159 #endif /* (CONFIG_TEXT_BASE == CONFIG_SYS_INT_FLASH_BASE) */
164 * if we come from a pre-loader we have no exception table and
165 * therefore no VBR to set
167 #if !defined(CONFIG_MONITOR_IS_IN_RAM)
168 #if defined(CONFIG_M5282) && (CONFIG_TEXT_BASE == CONFIG_SYS_INT_FLASH_BASE)
169 move.l #CONFIG_SYS_INT_FLASH_BASE, %d0
171 move.l #CONFIG_SYS_FLASH_BASE, %d0
177 /* set MBAR address + valid flag */
178 move.l #(CONFIG_SYS_MBAR + 1), %d0
179 move.l %d0, 0x40000000
180 /* movec %d0, %MBAR */
182 /* Initialize RAMBAR: locate SRAM and validate it */
183 move.l #(CONFIG_SYS_INIT_RAM_ADDR + 0x21), %d0
187 /* initialize general use internal ram */
189 move.l #(ICACHE_STATUS), %a1 /* icache */
190 move.l #(DCACHE_STATUS), %a2 /* icache */
194 /* put relocation table address to a5 */
195 move.l #__got_start, %a5
197 /* setup stack initially on top of internal static ram */
198 move.l #(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_RAM_SIZE), %sp
201 * if configured, malloc_f arena will be reserved first,
202 * then (and always) gd struct space will be reserved
205 move.l #board_init_f_alloc_reserve, %a1
208 /* update stack and frame-pointers */
212 /* initialize reserved area */
214 move.l #board_init_f_init_reserve, %a1
217 /* run low-level CPU init code (from flash) */
218 move.l #cpu_init_f, %a1
221 /* run low-level board init code (from flash) */
223 move.l #board_init_f, %a1
226 /* board_init_f() does not return */
228 /******************************************************************************/
231 * void relocate_code(addr_sp, gd, addr_moni)
233 * This "function" does not return, instead it continues in RAM
234 * after relocating the monitor code.
238 * r5 = length in bytes
244 move.l 8(%a6), %sp /* set new stack pointer */
246 move.l 12(%a6), %d0 /* Save copy of Global Data pointer */
247 move.l 16(%a6), %a0 /* Save copy of Destination Address */
249 move.l #CONFIG_SYS_MONITOR_BASE, %a1
250 move.l #__init_end, %a2
252 /* copy the code to RAM */
254 move.l (%a1)+, (%a3)+
259 * We are done. Do not return, instead branch to second part of board
260 * initialization, now running from RAM.
263 add.l #(in_ram - CONFIG_SYS_MONITOR_BASE), %a1
270 * Now clear BSS segment
273 add.l #(_sbss - CONFIG_SYS_MONITOR_BASE),%a1
275 add.l #(_ebss - CONFIG_SYS_MONITOR_BASE),%d1
282 * fix got table in RAM
285 add.l #(__got_start - CONFIG_SYS_MONITOR_BASE),%a1
286 move.l %a1,%a5 /* fix got pointer register a5 */
289 add.l #(__got_end - CONFIG_SYS_MONITOR_BASE),%a2
299 /* calculate relative jump to board_init_r in ram */
301 add.l #(board_init_r - CONFIG_SYS_MONITOR_BASE), %a1
303 /* set parameters for board_init_r */
304 move.l %a0,-(%sp) /* dest_addr */
305 move.l %d0,-(%sp) /* gd */
308 /******************************************************************************/
331 /******************************************************************************/