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>
6 * (C) Copyright 2004-2008 Freescale Semiconductor, Inc.
7 * TsiChung Liew (Tsi-Chung.Liew@freescale.com)
10 #include <asm-offsets.h>
12 #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 !defined(CONFIG_MONITOR_IS_IN_RAM)
32 * Vector table. This is used for initial platform startup.
33 * These vectors are to catch any un-intended traps.
36 INITSP: .long 0x00000000 /* Initial SP */
37 INITPC: .long _START /* Initial PC */
40 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
41 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
45 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
48 .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
57 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
58 .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
67 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
68 .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
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 .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 #endif /* !defined(CONFIG_MONITOR_IS_IN_RAM) */
97 move.w #0x2700,%sr /* Mask off Interrupt */
99 #if !defined(CONFIG_MONITOR_IS_IN_RAM)
100 /* Set vector base register at the beginning of the Flash */
101 move.l #CFG_SYS_FLASH_BASE, %d0
105 move.l #(CFG_SYS_INIT_RAM_ADDR + CFG_SYS_INIT_RAM_CTRL), %d0
108 /* invalidate and disable cache */
109 move.l #CF_CACR_CINVA, %d0 /* Invalidate cache cmd */
110 movec %d0, %CACR /* Invalidate cache */
115 #ifdef CONFIG_MCF5301x
116 move.l #(0xFC0a0010), %a0
123 /* initialize general use internal ram */
125 move.l #(ICACHE_STATUS), %a1 /* icache */
126 move.l #(DCACHE_STATUS), %a2 /* icache */
130 /* put relocation table address to a5 */
131 move.l #__got_start, %a5
133 /* setup stack initially on top of internal static ram */
134 move.l #(CFG_SYS_INIT_RAM_ADDR + CFG_SYS_INIT_RAM_SIZE), %sp
137 * if configured, malloc_f arena will be reserved first,
138 * then (and always) gd struct space will be reserved
141 move.l #board_init_f_alloc_reserve, %a1
144 /* update stack and frame-pointers */
148 /* initialize reserved area */
150 move.l #board_init_f_init_reserve, %a1
153 /* run low-level CPU init code (from flash) */
154 move.l #cpu_init_f, %a1
157 /* run low-level board init code (from flash) */
159 move.l #board_init_f, %a1
162 /* board_init_f() does not return */
164 /******************************************************************************/
167 * void relocate_code(addr_sp, gd, addr_moni)
169 * This "function" does not return, instead it continues in RAM
170 * after relocating the monitor code.
174 * r5 = length in bytes
180 move.l 8(%a6), %sp /* set new stack pointer */
182 move.l 12(%a6), %d0 /* Save copy of Global Data pointer */
183 move.l 16(%a6), %a0 /* Save copy of Destination Address */
185 move.l #CONFIG_SYS_MONITOR_BASE, %a1
186 move.l #__init_end, %a2
189 /* copy the code to RAM */
191 move.l (%a1)+, (%a3)+
196 * We are done. Do not return, instead branch to second part of board
197 * initialization, now running from RAM.
200 add.l #(in_ram - CONFIG_SYS_MONITOR_BASE), %a1
207 * Now clear BSS segment
210 add.l #(_sbss - CONFIG_SYS_MONITOR_BASE),%a1
212 add.l #(_ebss - CONFIG_SYS_MONITOR_BASE),%d1
219 * fix got table in RAM
222 add.l #(__got_start - CONFIG_SYS_MONITOR_BASE),%a1
223 move.l %a1,%a5 /* fix got pointer register a5 */
226 add.l #(__got_end - CONFIG_SYS_MONITOR_BASE),%a2
236 /* calculate relative jump to board_init_r in ram */
238 add.l #(board_init_r - CONFIG_SYS_MONITOR_BASE), %a1
240 /* set parameters for board_init_r */
241 move.l %a0,-(%sp) /* dest_addr */
242 move.l %d0,-(%sp) /* gd */
245 /******************************************************************************/
268 /******************************************************************************/