1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * (C) Copyright 2015 Angelo Dureghello <angelo@sysam.it>
4 * Based on code from Bernhard Kuhn <bkuhn@metrowerks.com>
7 #include <asm-offsets.h>
10 #include <asm/cache.h>
17 move.w #0x2700,%sr; /* disable intrs */
18 subl #60,%sp; /* space for 15 regs */
19 moveml %d0-%d7/%a0-%a6,%sp@
23 moveml %sp@,%d0-%d7/%a0-%a6;
24 addl #60,%sp; /* space for 15 regs */
28 /* If we come from a pre-loader we don't need an initial exception
31 #if !defined(CONFIG_MONITOR_IS_IN_RAM)
36 * Vector table. This is used for initial platform startup.
37 * These vectors are to catch any un-intended traps.
40 /* Flash offset is 0 until we setup CS0 */
42 #if defined(CONFIG_M5307) && \
43 (CONFIG_SYS_TEXT_BASE == CONFIG_SYS_INT_FLASH_BASE)
44 .long _start - CONFIG_SYS_TEXT_BASE
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, _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
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
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
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
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
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
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
95 /* set MBAR address + valid flag */
96 move.l #(CONFIG_SYS_MBAR + 1), %d0
99 move.l #(CONFIG_SYS_INIT_RAM_ADDR + 1), %d0
102 /* DS 4.8.2 (Cache Organization) invalidate and disable cache */
103 move.l #CF_CACR_CINVA, %d0
110 * if we come from a pre-loader we have no exception table and
111 * therefore no VBR to set
113 #if !defined(CONFIG_MONITOR_IS_IN_RAM)
114 move.l #CONFIG_SYS_FLASH_BASE, %d0
118 /* initialize general use internal ram */
120 move.l #(ICACHE_STATUS), %a1 /* icache */
121 move.l #(DCACHE_STATUS), %a2 /* dcache */
125 /* put relocation table address to a5 */
126 move.l #__got_start, %a5
128 /* setup stack initially on top of internal static ram */
129 move.l #(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_RAM_SIZE), %sp
132 * if configured, malloc_f arena will be reserved first,
133 * then (and always) gd struct space will be reserved
136 bsr board_init_f_alloc_reserve
138 /* update stack and frame-pointers */
142 /* initialize reserved area */
144 bsr board_init_f_init_reserve
146 /* run low-level CPU init code (from flash) */
149 /* run low-level board init code (from flash) */
153 /* board_init_f() does not return */
155 /******************************************************************************/
158 * void relocate_code(addr_sp, gd, addr_moni)
160 * This "function" does not return, instead it continues in RAM
161 * after relocating the monitor code.
167 move.l 8(%a6), %sp /* set new stack pointer */
168 move.l 12(%a6), %d0 /* Save copy of Global Data pointer */
169 move.l 16(%a6), %a0 /* Save copy of Destination Address */
171 move.l #CONFIG_SYS_MONITOR_BASE, %a1
172 move.l #__init_end, %a2
174 /* copy the code to RAM */
176 move.l (%a1)+, (%a3)+
181 * We are done. Do not return, instead branch to second part of board
182 * initialization, now running from RAM.
185 add.l #(in_ram - CONFIG_SYS_MONITOR_BASE), %a1
192 * Now clear BSS segment
195 add.l #(_sbss - CONFIG_SYS_MONITOR_BASE), %a1
197 add.l #(_ebss - CONFIG_SYS_MONITOR_BASE), %d1
204 * fix got table in RAM
207 add.l #(__got_start - CONFIG_SYS_MONITOR_BASE), %a1
209 /* fix got pointer register a5 */
213 add.l #(__got_end - CONFIG_SYS_MONITOR_BASE), %a2
223 /* calculate relative jump to board_init_r in ram */
225 add.l #(board_init_r - CONFIG_SYS_MONITOR_BASE), %a1
227 /* set parameters for board_init_r */
228 move.l %a0,-(%sp) /* dest_addr */
229 move.l %d0,-(%sp) /* gd */
230 #if defined(DEBUG) && (CONFIG_SYS_TEXT_BASE!=CONFIG_SYS_INT_FLASH_BASE) && \
231 defined(CONFIG_SYS_HALT_BEFOR_RAM_JUMP)
236 /******************************************************************************/
259 /******************************************************************************/
261 .globl version_string
263 .ascii U_BOOT_VERSION
264 .ascii " (", U_BOOT_DATE, " - ", U_BOOT_TIME, ")"
265 .ascii CONFIG_IDENT_STRING, "\0"