]> git.karo-electronics.de Git - karo-tx-uboot.git/blob - arch/m68k/cpu/mcf530x/start.S
Kconfig: Move config IDENT_STRING to Kconfig
[karo-tx-uboot.git] / arch / m68k / cpu / mcf530x / start.S
1 /*
2  * (C) Copyright 2015  Angelo Dureghello <angelo@sysam.it>
3  * Based on code from Bernhard Kuhn <bkuhn@metrowerks.com>
4  *
5  * SPDX-License-Identifier:     GPL-2.0+
6  */
7
8 #include <asm-offsets.h>
9 #include <config.h>
10 #include "version.h"
11 #include <asm/cache.h>
12
13 #define _START  _start
14 #define _FAULT  _fault
15
16
17 .macro  SAVE_ALL
18         move.w  #0x2700,%sr;            /* disable intrs */
19         subl    #60,%sp;                /* space for 15 regs */
20         moveml  %d0-%d7/%a0-%a6,%sp@
21 .endm
22
23 .macro  RESTORE_ALL
24         moveml  %sp@,%d0-%d7/%a0-%a6;
25         addl    #60,%sp;                /* space for 15 regs */
26         rte
27 .endm
28
29 /* If we come from a pre-loader we don't need an initial exception
30  * table.
31  */
32 #if !defined(CONFIG_MONITOR_IS_IN_RAM)
33
34 .text
35
36 /*
37  * Vector table. This is used for initial platform startup.
38  * These vectors are to catch any un-intended traps.
39  */
40 _vectors:
41 /* Flash offset is 0 until we setup CS0 */
42 .long   0x00000000
43 #if defined(CONFIG_M5307) && \
44            (CONFIG_SYS_TEXT_BASE == CONFIG_SYS_INT_FLASH_BASE)
45 .long   _start - CONFIG_SYS_TEXT_BASE
46 #else
47 .long   _START
48 #endif
49
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, _FAULT, _FAULT
57 .long   _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
58
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
66 .long   _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
67
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
75 .long   _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
76
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
84 .long   _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
85
86 #endif
87
88 .text
89
90 .globl _start
91 _start:
92         nop
93         nop
94         move.w  #0x2700,%sr
95
96         /* set MBAR address + valid flag */
97         move.l  #(CONFIG_SYS_MBAR + 1), %d0
98         move.c  %d0, %MBAR
99
100         move.l  #(CONFIG_SYS_INIT_RAM_ADDR + 1), %d0
101         move.c  %d0, %RAMBAR
102
103         /* DS 4.8.2 (Cache Organization) invalidate and disable cache */
104         move.l  #CF_CACR_CINVA, %d0
105         movec   %d0, %CACR
106         move.l  #0, %d0
107         movec   %d0, %ACR0
108         movec   %d0, %ACR1
109
110         /*
111          * if we come from a pre-loader we have no exception table and
112          * therefore no VBR to set
113          */
114 #if !defined(CONFIG_MONITOR_IS_IN_RAM)
115         move.l  #CONFIG_SYS_FLASH_BASE, %d0
116         movec   %d0, %VBR
117 #endif
118
119         /* initialize general use internal ram */
120         move.l  #0, %d0
121         move.l  #(ICACHE_STATUS), %a1   /* icache */
122         move.l  #(DCACHE_STATUS), %a2   /* dcache */
123         move.l  %d0, (%a1)
124         move.l  %d0, (%a2)
125
126         /* put relocation table address to a5 */
127         move.l  #__got_start, %a5
128
129         /* setup stack initially on top of internal static ram  */
130         move.l  #(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_RAM_SIZE), %sp
131
132         /*
133          * if configured, malloc_f arena will be reserved first,
134          * then (and always) gd struct space will be reserved
135          */
136         move.l  %sp, -(%sp)
137         bsr     board_init_f_alloc_reserve
138
139         /* update stack and frame-pointers */
140         move.l  %d0, %sp
141         move.l  %sp, %fp
142
143         /* initialize reserved area */
144         move.l  %d0, -(%sp)
145         bsr     board_init_f_init_reserve
146
147         /* run low-level CPU init code (from flash) */
148         bsr     cpu_init_f
149
150         /* run low-level board init code (from flash) */
151         clr.l   %sp@-
152         bsr     board_init_f
153
154         /* board_init_f() does not return */
155
156 /******************************************************************************/
157
158 /*
159  * void relocate_code (addr_sp, gd, addr_moni)
160  *
161  * This "function" does not return, instead it continues in RAM
162  * after relocating the monitor code.
163  *
164  */
165 .globl relocate_code
166 relocate_code:
167         link.w  %a6,#0
168         move.l  8(%a6), %sp     /* set new stack pointer */
169         move.l  12(%a6), %d0    /* Save copy of Global Data pointer */
170         move.l  16(%a6), %a0    /* Save copy of Destination Address */
171
172         move.l  #CONFIG_SYS_MONITOR_BASE, %a1
173         move.l  #__init_end, %a2
174         move.l  %a0, %a3
175         /* copy the code to RAM */
176 1:
177         move.l  (%a1)+, (%a3)+
178         cmp.l   %a1,%a2
179         bgt.s   1b
180
181 /*
182  * We are done. Do not return, instead branch to second part of board
183  * initialization, now running from RAM.
184  */
185         move.l  %a0, %a1
186         add.l   #(in_ram - CONFIG_SYS_MONITOR_BASE), %a1
187         jmp     (%a1)
188
189 in_ram:
190
191 clear_bss:
192         /*
193          * Now clear BSS segment
194          */
195         move.l  %a0, %a1
196         add.l   #(_sbss - CONFIG_SYS_MONITOR_BASE), %a1
197         move.l  %a0, %d1
198         add.l   #(_ebss - CONFIG_SYS_MONITOR_BASE), %d1
199 6:
200         clr.l   (%a1)+
201         cmp.l   %a1,%d1
202         bgt.s   6b
203
204         /*
205          * fix got table in RAM
206          */
207         move.l  %a0, %a1
208         add.l   #(__got_start - CONFIG_SYS_MONITOR_BASE), %a1
209
210         /* fix got pointer register a5 */
211         move.l  %a1,%a5
212
213         move.l  %a0, %a2
214         add.l   #(__got_end - CONFIG_SYS_MONITOR_BASE), %a2
215
216 7:
217         move.l  (%a1),%d1
218         sub.l   #_start, %d1
219         add.l   %a0,%d1
220         move.l  %d1,(%a1)+
221         cmp.l   %a2, %a1
222         bne     7b
223
224         /* calculate relative jump to board_init_r in ram */
225         move.l  %a0, %a1
226         add.l   #(board_init_r - CONFIG_SYS_MONITOR_BASE), %a1
227
228         /* set parameters for board_init_r */
229         move.l  %a0,-(%sp)      /* dest_addr */
230         move.l  %d0,-(%sp)      /* gd */
231 #if defined(DEBUG) && (CONFIG_SYS_TEXT_BASE!=CONFIG_SYS_INT_FLASH_BASE) && \
232     defined(CONFIG_SYS_HALT_BEFOR_RAM_JUMP)
233         halt
234 #endif
235         jsr     (%a1)
236
237 /******************************************************************************/
238
239 /* exception code */
240 .globl _fault
241 _fault:
242         bra     _fault
243
244 .globl _exc_handler
245 _exc_handler:
246         SAVE_ALL
247         movel   %sp,%sp@-
248         bsr     exc_handler
249         addql   #4,%sp
250         RESTORE_ALL
251
252 .globl _int_handler
253 _int_handler:
254         SAVE_ALL
255         movel   %sp,%sp@-
256         bsr     int_handler
257         addql   #4,%sp
258         RESTORE_ALL
259
260 /******************************************************************************/
261
262 .globl version_string
263 version_string:
264 .ascii  U_BOOT_VERSION
265 .ascii  " (", U_BOOT_DATE, " - ", U_BOOT_TIME, ")"
266 .ascii  CONFIG_IDENT_STRING, "\0"
267 .align  4