2 * (C) Copyright 2015 Angelo Dureghello <angelo@sysam.it>
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@
28 moveml %sp@,%d0-%d7/%a0-%a6;
29 addl #60,%sp; /* space for 15 regs */
33 /* If we come from a pre-loader we don't need an initial exception
36 #if !defined(CONFIG_MONITOR_IS_IN_RAM)
40 * Vector table. This is used for initial platform startup.
41 * These vectors are to catch any un-intended traps.
45 /* Flash offset is 0 until we setup CS0 */
47 #if defined(CONFIG_M5307) && \
48 (CONFIG_SYS_TEXT_BASE == CONFIG_SYS_INT_FLASH_BASE)
49 .long _start - CONFIG_SYS_TEXT_BASE
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
61 .long _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
70 .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
79 .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
99 /* set MBAR address + valid flag */
100 move.l #(CONFIG_SYS_MBAR + 1), %d0
103 move.l #(CONFIG_SYS_INIT_RAM_ADDR + 1), %d0
106 /* DS 4.8.2 (Cache Organization) invalidate and disable cache */
107 move.l #CF_CACR_CINVA, %d0
114 * if we come from a pre-loader we have no exception table and
115 * therefore no VBR to set
117 #if !defined(CONFIG_MONITOR_IS_IN_RAM)
118 move.l #CONFIG_SYS_FLASH_BASE, %d0
122 /* initialize general use internal ram */
124 move.l #(ICACHE_STATUS), %a1 /* icache */
125 move.l #(DCACHE_STATUS), %a2 /* dcache */
130 * set stackpointer to internal sram end - 80
131 * (global data struct size + some bytes)
132 * get some stackspace for the first c-code,
134 move.l #(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_SP_OFFSET), %sp
137 /* put relocation table address to a5 */
138 move.l #__got_start, %a5
140 /* run low-level CPU init code (from flash) */
143 /* run low-level board init code (from flash) */
146 /* board_init_f() does not return */
148 /*--------------------------------------------------------------------------*/
151 * void relocate_code (addr_sp, gd, addr_moni)
153 * This "function" does not return, instead it continues in RAM
154 * after relocating the monitor code.
160 move.l 8(%a6), %sp /* set new stack pointer */
161 move.l 12(%a6), %d0 /* Save copy of Global Data pointer */
162 move.l 16(%a6), %a0 /* Save copy of Destination Address */
164 move.l #CONFIG_SYS_MONITOR_BASE, %a1
165 move.l #__init_end, %a2
167 /* copy the code to RAM */
169 move.l (%a1)+, (%a3)+
174 * We are done. Do not return, instead branch to second part of board
175 * initialization, now running from RAM.
178 add.l #(in_ram - CONFIG_SYS_MONITOR_BASE), %a1
185 * Now clear BSS segment
188 add.l #(_sbss - CONFIG_SYS_MONITOR_BASE), %a1
190 add.l #(_ebss - CONFIG_SYS_MONITOR_BASE), %d1
197 * fix got table in RAM
200 add.l #(__got_start - CONFIG_SYS_MONITOR_BASE), %a1
201 /* * fix got pointer register a5 */
205 add.l #(__got_end - CONFIG_SYS_MONITOR_BASE), %a2
215 /* calculate relative jump to board_init_r in ram */
217 add.l #(board_init_r - CONFIG_SYS_MONITOR_BASE), %a1
219 /* set parameters for board_init_r */
220 move.l %a0,-(%sp) /* dest_addr */
221 move.l %d0,-(%sp) /* gd */
222 #if defined(DEBUG) && (CONFIG_SYS_TEXT_BASE!=CONFIG_SYS_INT_FLASH_BASE) && \
223 defined(CONFIG_SYS_HALT_BEFOR_RAM_JUMP)
228 /*--------------------------------------------------------------------------*/
250 /*--------------------------------------------------------------------------*/
252 .globl version_string
254 .ascii U_BOOT_VERSION
255 .ascii " (", U_BOOT_DATE, " - ", U_BOOT_TIME, ")"
256 .ascii CONFIG_IDENT_STRING, "\0"