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>
16 move.w #0x2700,%sr; /* disable intrs */
17 subl #60,%sp; /* space for 15 regs */
18 moveml %d0-%d7/%a0-%a6,%sp@
22 moveml %sp@,%d0-%d7/%a0-%a6;
23 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 /* Flash offset is 0 until we setup CS0 */
41 #if defined(CONFIG_M5307) && \
42 (CONFIG_TEXT_BASE == CONFIG_SYS_INT_FLASH_BASE)
43 .long _start - CONFIG_TEXT_BASE
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, _FAULT, _FAULT
54 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
55 .long _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
63 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
64 .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
72 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
73 .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
81 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
82 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
94 /* set MBAR address + valid flag */
95 move.l #(CONFIG_SYS_MBAR + 1), %d0
98 move.l #(CONFIG_SYS_INIT_RAM_ADDR + 1), %d0
101 /* DS 4.8.2 (Cache Organization) invalidate and disable cache */
102 move.l #CF_CACR_CINVA, %d0
109 * if we come from a pre-loader we have no exception table and
110 * therefore no VBR to set
112 #if !defined(CONFIG_MONITOR_IS_IN_RAM)
113 move.l #CONFIG_SYS_FLASH_BASE, %d0
117 /* initialize general use internal ram */
119 move.l #(ICACHE_STATUS), %a1 /* icache */
120 move.l #(DCACHE_STATUS), %a2 /* dcache */
124 /* put relocation table address to a5 */
125 move.l #__got_start, %a5
127 /* setup stack initially on top of internal static ram */
128 move.l #(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_RAM_SIZE), %sp
131 * if configured, malloc_f arena will be reserved first,
132 * then (and always) gd struct space will be reserved
135 bsr board_init_f_alloc_reserve
137 /* update stack and frame-pointers */
141 /* initialize reserved area */
143 bsr board_init_f_init_reserve
145 /* run low-level CPU init code (from flash) */
148 /* run low-level board init code (from flash) */
152 /* board_init_f() does not return */
154 /******************************************************************************/
157 * void relocate_code(addr_sp, gd, addr_moni)
159 * This "function" does not return, instead it continues in RAM
160 * after relocating the monitor code.
166 move.l 8(%a6), %sp /* set new stack pointer */
167 move.l 12(%a6), %d0 /* Save copy of Global Data pointer */
168 move.l 16(%a6), %a0 /* Save copy of Destination Address */
170 move.l #CONFIG_SYS_MONITOR_BASE, %a1
171 move.l #__init_end, %a2
173 /* copy the code to RAM */
175 move.l (%a1)+, (%a3)+
180 * We are done. Do not return, instead branch to second part of board
181 * initialization, now running from RAM.
184 add.l #(in_ram - CONFIG_SYS_MONITOR_BASE), %a1
191 * Now clear BSS segment
194 add.l #(_sbss - CONFIG_SYS_MONITOR_BASE), %a1
196 add.l #(_ebss - CONFIG_SYS_MONITOR_BASE), %d1
203 * fix got table in RAM
206 add.l #(__got_start - CONFIG_SYS_MONITOR_BASE), %a1
208 /* fix got pointer register a5 */
212 add.l #(__got_end - CONFIG_SYS_MONITOR_BASE), %a2
222 /* calculate relative jump to board_init_r in ram */
224 add.l #(board_init_r - CONFIG_SYS_MONITOR_BASE), %a1
226 /* set parameters for board_init_r */
227 move.l %a0,-(%sp) /* dest_addr */
228 move.l %d0,-(%sp) /* gd */
231 /******************************************************************************/
254 /******************************************************************************/