]>
Commit | Line | Data |
---|---|---|
8e585f02 TL |
1 | /* |
2 | * Copyright (C) 2003 Josef Baumgartner <[email protected]> | |
3 | * Based on code from Bernhard Kuhn <[email protected]> | |
4 | * | |
536e7dac TL |
5 | * (C) Copyright 2004-2008 Freescale Semiconductor, Inc. |
6 | * TsiChung Liew ([email protected]) | |
7 | * | |
3765b3e7 | 8 | * SPDX-License-Identifier: GPL-2.0+ |
8e585f02 TL |
9 | */ |
10 | ||
25ddd1fb | 11 | #include <asm-offsets.h> |
8e585f02 TL |
12 | #include <config.h> |
13 | #include "version.h" | |
dd9f054e | 14 | #include <asm/cache.h> |
8e585f02 | 15 | |
8e585f02 TL |
16 | #define _START _start |
17 | #define _FAULT _fault | |
18 | ||
8e585f02 TL |
19 | #define SAVE_ALL \ |
20 | move.w #0x2700,%sr; /* disable intrs */ \ | |
21 | subl #60,%sp; /* space for 15 regs */ \ | |
22 | moveml %d0-%d7/%a0-%a6,%sp@; | |
23 | ||
24 | #define RESTORE_ALL \ | |
25 | moveml %sp@,%d0-%d7/%a0-%a6; \ | |
26 | addl #60,%sp; /* space for 15 regs */ \ | |
27 | rte; | |
28 | ||
c7de810c | 29 | #if !defined(CONFIG_MONITOR_IS_IN_RAM) |
5c928d02 | 30 | |
8e585f02 | 31 | .text |
5c928d02 | 32 | |
8e585f02 | 33 | /* |
5c928d02 AD |
34 | * Vector table. This is used for initial platform startup. |
35 | * These vectors are to catch any un-intended traps. | |
8e585f02 TL |
36 | */ |
37 | _vectors: | |
5c928d02 AD |
38 | INITSP: .long 0x00000000 /* Initial SP */ |
39 | INITPC: .long _START /* Initial PC */ | |
8e585f02 | 40 | |
5c928d02 AD |
41 | vector02_0F: |
42 | .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT | |
43 | .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT | |
ddd104f1 TL |
44 | |
45 | /* Reserved */ | |
8e585f02 TL |
46 | vector10_17: |
47 | .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT | |
48 | ||
5c928d02 AD |
49 | vector18_1F: |
50 | .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT | |
8e585f02 TL |
51 | |
52 | /* TRAP #0 - #15 */ | |
53 | vector20_2F: | |
54 | .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT | |
55 | .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT | |
56 | ||
57 | /* Reserved */ | |
58 | vector30_3F: | |
59 | .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT | |
60 | .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT | |
61 | ||
62 | vector64_127: | |
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 | |
71 | ||
72 | vector128_191: | |
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 | |
80 | .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT | |
81 | ||
82 | vector192_255: | |
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 | .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT | |
90 | .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT | |
c7de810c | 91 | #endif /* !defined(CONFIG_MONITOR_IS_IN_RAM) */ |
8e585f02 | 92 | |
5c928d02 | 93 | .text |
8e585f02 | 94 | |
5c928d02 | 95 | .globl _start |
8e585f02 TL |
96 | _start: |
97 | nop | |
98 | nop | |
5c928d02 | 99 | move.w #0x2700,%sr /* Mask off Interrupt */ |
8e585f02 | 100 | |
c7de810c | 101 | #if !defined(CONFIG_MONITOR_IS_IN_RAM) |
ddd104f1 | 102 | /* Set vector base register at the beginning of the Flash */ |
6d0f6bcf | 103 | move.l #CONFIG_SYS_FLASH_BASE, %d0 |
8e585f02 | 104 | movec %d0, %VBR |
c7de810c | 105 | #endif |
8e585f02 | 106 | |
6d0f6bcf | 107 | move.l #(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_RAM_CTRL), %d0 |
c67e12e7 | 108 | movec %d0, %RAMBAR1 |
8e585f02 TL |
109 | |
110 | /* invalidate and disable cache */ | |
dd9f054e | 111 | move.l #CF_CACR_CINVA, %d0 /* Invalidate cache cmd */ |
8e585f02 TL |
112 | movec %d0, %CACR /* Invalidate cache */ |
113 | move.l #0, %d0 | |
114 | movec %d0, %ACR0 | |
115 | movec %d0, %ACR1 | |
116 | ||
536e7dac TL |
117 | #ifdef CONFIG_MCF5301x |
118 | move.l #(0xFC0a0010), %a0 | |
119 | move.w (%a0), %d0 | |
120 | and.l %d0, 0xEFFF | |
121 | ||
122 | move.w %d0, (%a0) | |
123 | #endif | |
124 | ||
8e585f02 | 125 | /* initialize general use internal ram */ |
5c928d02 AD |
126 | move.l #0, %d0 |
127 | move.l #(ICACHE_STATUS), %a1 /* icache */ | |
128 | move.l #(DCACHE_STATUS), %a2 /* icache */ | |
129 | move.l %d0, (%a1) | |
130 | move.l %d0, (%a2) | |
8e585f02 | 131 | |
5044c9cc | 132 | /* put relocation table address to a5 */ |
5c928d02 | 133 | move.l #__got_start, %a5 |
8e585f02 | 134 | |
5044c9cc | 135 | /* setup stack initially on top of internal static ram */ |
136 | move.l #(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_RAM_SIZE), %sp | |
137 | ||
138 | /* | |
139 | * if configured, malloc_f arena will be reserved first, | |
140 | * then (and always) gd struct space will be reserved | |
141 | */ | |
142 | move.l %sp, -(%sp) | |
143 | move.l #board_init_f_alloc_reserve, %a1 | |
144 | jsr (%a1) | |
145 | ||
146 | /* update stack and frame-pointers */ | |
147 | move.l %d0, %sp | |
148 | move.l %sp, %fp | |
149 | ||
150 | /* initialize reserved area */ | |
5c928d02 | 151 | move.l %d0, -(%sp) |
5044c9cc | 152 | move.l #board_init_f_init_reserve, %a1 |
153 | jsr (%a1) | |
8e585f02 | 154 | |
55ac54c4 | 155 | /* run low-level CPU init code (from flash) */ |
5c928d02 AD |
156 | move.l #cpu_init_f, %a1 |
157 | jsr (%a1) | |
158 | ||
55ac54c4 | 159 | /* run low-level board init code (from flash) */ |
5044c9cc | 160 | clr.l %sp@- |
55ac54c4 | 161 | move.l #board_init_f, %a1 |
162 | jsr (%a1) | |
8e585f02 TL |
163 | |
164 | /* board_init_f() does not return */ | |
165 | ||
5c928d02 | 166 | /******************************************************************************/ |
8e585f02 TL |
167 | |
168 | /* | |
169 | * void relocate_code (addr_sp, gd, addr_moni) | |
170 | * | |
171 | * This "function" does not return, instead it continues in RAM | |
172 | * after relocating the monitor code. | |
173 | * | |
174 | * r3 = dest | |
175 | * r4 = src | |
176 | * r5 = length in bytes | |
177 | * r6 = cachelinesize | |
178 | */ | |
5c928d02 | 179 | .globl relocate_code |
8e585f02 | 180 | relocate_code: |
5c928d02 AD |
181 | link.w %a6,#0 |
182 | move.l 8(%a6), %sp /* set new stack pointer */ | |
8e585f02 | 183 | |
5c928d02 AD |
184 | move.l 12(%a6), %d0 /* Save copy of Global Data pointer */ |
185 | move.l 16(%a6), %a0 /* Save copy of Destination Address */ | |
8e585f02 | 186 | |
5c928d02 AD |
187 | move.l #CONFIG_SYS_MONITOR_BASE, %a1 |
188 | move.l #__init_end, %a2 | |
189 | move.l %a0, %a3 | |
8e585f02 TL |
190 | |
191 | /* copy the code to RAM */ | |
192 | 1: | |
5c928d02 AD |
193 | move.l (%a1)+, (%a3)+ |
194 | cmp.l %a1,%a2 | |
195 | bgt.s 1b | |
8e585f02 TL |
196 | |
197 | /* | |
198 | * We are done. Do not return, instead branch to second part of board | |
199 | * initialization, now running from RAM. | |
200 | */ | |
201 | move.l %a0, %a1 | |
6d0f6bcf | 202 | add.l #(in_ram - CONFIG_SYS_MONITOR_BASE), %a1 |
8e585f02 TL |
203 | jmp (%a1) |
204 | ||
205 | in_ram: | |
206 | ||
207 | clear_bss: | |
208 | /* | |
209 | * Now clear BSS segment | |
210 | */ | |
211 | move.l %a0, %a1 | |
6d0f6bcf | 212 | add.l #(_sbss - CONFIG_SYS_MONITOR_BASE),%a1 |
8e585f02 | 213 | move.l %a0, %d1 |
6d0f6bcf | 214 | add.l #(_ebss - CONFIG_SYS_MONITOR_BASE),%d1 |
8e585f02 TL |
215 | 6: |
216 | clr.l (%a1)+ | |
217 | cmp.l %a1,%d1 | |
218 | bgt.s 6b | |
219 | ||
220 | /* | |
221 | * fix got table in RAM | |
222 | */ | |
223 | move.l %a0, %a1 | |
6d0f6bcf | 224 | add.l #(__got_start - CONFIG_SYS_MONITOR_BASE),%a1 |
5c928d02 | 225 | move.l %a1,%a5 /* fix got pointer register a5 */ |
8e585f02 TL |
226 | |
227 | move.l %a0, %a2 | |
6d0f6bcf | 228 | add.l #(__got_end - CONFIG_SYS_MONITOR_BASE),%a2 |
8e585f02 TL |
229 | |
230 | 7: | |
231 | move.l (%a1),%d1 | |
232 | sub.l #_start,%d1 | |
233 | add.l %a0,%d1 | |
234 | move.l %d1,(%a1)+ | |
235 | cmp.l %a2, %a1 | |
236 | bne 7b | |
237 | ||
238 | /* calculate relative jump to board_init_r in ram */ | |
5c928d02 AD |
239 | move.l %a0, %a1 |
240 | add.l #(board_init_r - CONFIG_SYS_MONITOR_BASE), %a1 | |
8e585f02 TL |
241 | |
242 | /* set parameters for board_init_r */ | |
5c928d02 AD |
243 | move.l %a0,-(%sp) /* dest_addr */ |
244 | move.l %d0,-(%sp) /* gd */ | |
8e585f02 TL |
245 | jsr (%a1) |
246 | ||
5c928d02 AD |
247 | /******************************************************************************/ |
248 | ||
8e585f02 | 249 | /* exception code */ |
5c928d02 | 250 | .globl _fault |
8e585f02 | 251 | _fault: |
37d6cc31 | 252 | bra _fault |
8e585f02 | 253 | |
5c928d02 | 254 | .globl _exc_handler |
8e585f02 TL |
255 | _exc_handler: |
256 | SAVE_ALL | |
257 | movel %sp,%sp@- | |
5c928d02 | 258 | bsr exc_handler |
8e585f02 TL |
259 | addql #4,%sp |
260 | RESTORE_ALL | |
261 | ||
5c928d02 | 262 | .globl _int_handler |
8e585f02 TL |
263 | _int_handler: |
264 | SAVE_ALL | |
265 | movel %sp,%sp@- | |
5c928d02 | 266 | bsr int_handler |
8e585f02 TL |
267 | addql #4,%sp |
268 | RESTORE_ALL | |
269 | ||
5c928d02 AD |
270 | /******************************************************************************/ |
271 | ||
272 | .globl version_string | |
8e585f02 | 273 | version_string: |
5c928d02 AD |
274 | .ascii U_BOOT_VERSION_STRING, "\0" |
275 | .align 4 |