2 * Copyright (C) 2003 Josef Baumgartner <josef.baumgartner@telex.de>
3 * Based on code from Bernhard Kuhn <bkuhn@metrowerks.com>
5 * See file CREDITS for list of people who contributed to this
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License as
10 * published by the Free Software Foundation; either version 2 of
11 * the License, or (at your option) any later version.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
24 #include <asm-offsets.h>
26 #include <timestamp.h>
28 #include <asm/cache.h>
30 #ifndef CONFIG_IDENT_STRING
31 #define CONFIG_IDENT_STRING ""
39 move.w #0x2700,%sr; /* disable intrs */ \
40 subl #60,%sp; /* space for 15 regs */ \
41 moveml %d0-%d7/%a0-%a6,%sp@; \
44 moveml %sp@,%d0-%d7/%a0-%a6; \
45 addl #60,%sp; /* space for 15 regs */ \
48 /* If we come from a pre-loader we don't need an initial exception
51 #if !defined(CONFIG_MONITOR_IS_IN_RAM)
55 * Vector table. This is used for initial platform startup.
56 * These vectors are to catch any un-intended traps.
60 .long 0x00000000 /* Flash offset is 0 until we setup CS0 */
61 #if defined(CONFIG_M5282) && (CONFIG_SYS_TEXT_BASE == CONFIG_SYS_INT_FLASH_BASE)
62 .long _start - CONFIG_SYS_TEXT_BASE
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
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
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
91 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
92 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
94 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
95 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
96 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
97 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
98 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
99 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
100 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
101 .long _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT, _FAULT
108 #if defined(CONFIG_SYS_INT_FLASH_BASE) && \
109 (defined(CONFIG_M5282) || defined(CONFIG_M5281))
110 #if (CONFIG_SYS_TEXT_BASE == CONFIG_SYS_INT_FLASH_BASE)
111 .long 0x55AA55AA,0xAA55AA55 /* CFM Backdoorkey */
112 .long 0xFFFFFFFF /* all sectors protected */
113 .long 0x00000000 /* supervisor/User restriction */
114 .long 0x00000000 /* programm/data space restriction */
115 .long 0x00000000 /* Flash security */
124 #if defined(CONFIG_M5208)
125 /* Initialize RAMBAR: locate SRAM and validate it */
126 move.l #(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_RAM_CTRL), %d0
130 #if defined(CONFIG_M5272) || defined(CONFIG_M5249) || defined(CONFIG_M5253)
131 move.l #(CONFIG_SYS_MBAR + 1), %d0 /* set MBAR address + valid flag */
134 /*** The 5249 has MBAR2 as well ***/
135 #ifdef CONFIG_SYS_MBAR2
136 move.l #(CONFIG_SYS_MBAR2 + 1), %d0 /* Get MBAR2 address */
137 movec %d0, #0xc0e /* Set MBAR2 */
140 move.l #(CONFIG_SYS_INIT_RAM_ADDR + 1), %d0
142 #endif /* CONFIG_M5272 || CONFIG_M5249 || CONFIG_M5253 */
144 #if defined(CONFIG_M5282) || defined(CONFIG_M5271)
145 /* Initialize IPSBAR */
146 move.l #(CONFIG_SYS_MBAR + 1), %d0 /* set IPSBAR address + valid flag */
147 move.l %d0, 0x40000000
149 /* Initialize RAMBAR1: locate SRAM and validate it */
150 move.l #(CONFIG_SYS_INIT_RAM_ADDR + 0x21), %d0
153 #if defined(CONFIG_M5282)
154 #if (CONFIG_SYS_TEXT_BASE == CONFIG_SYS_INT_FLASH_BASE)
155 /* Setup code in SRAM to initialize FLASHBAR, if start from internal Flash */
157 move.l #(_flashbar_setup-CONFIG_SYS_INT_FLASH_BASE), %a0
158 move.l #(_flashbar_setup_end-CONFIG_SYS_INT_FLASH_BASE), %a1
159 move.l #(CONFIG_SYS_INIT_RAM_ADDR), %a2
161 move.l (%a0)+, (%a2)+
164 jmp CONFIG_SYS_INIT_RAM_ADDR
167 /* Initialize FLASHBAR: locate internal Flash and validate it */
168 move.l #(CONFIG_SYS_INT_FLASH_BASE + CONFIG_SYS_INT_FLASH_ENABLE), %d0
170 jmp _after_flashbar_copy.L /* Force jump to absolute address */
173 _after_flashbar_copy:
175 /* Setup code to initialize FLASHBAR, if start from external Memory */
176 move.l #(CONFIG_SYS_INT_FLASH_BASE + CONFIG_SYS_INT_FLASH_ENABLE), %d0
178 #endif /* (CONFIG_SYS_TEXT_BASE == CONFIG_SYS_INT_FLASH_BASE) */
182 /* if we come from a pre-loader we have no exception table and
183 * therefore no VBR to set
185 #if !defined(CONFIG_MONITOR_IS_IN_RAM)
186 #if defined(CONFIG_M5282) && (CONFIG_SYS_TEXT_BASE == CONFIG_SYS_INT_FLASH_BASE)
187 move.l #CONFIG_SYS_INT_FLASH_BASE, %d0
189 move.l #CONFIG_SYS_FLASH_BASE, %d0
195 /* Initialize IPSBAR */
196 move.l #(CONFIG_SYS_MBAR + 1), %d0 /* set IPSBAR address + valid flag */
197 move.l %d0, 0x40000000
198 /* movec %d0, %MBAR */
200 /* Initialize RAMBAR: locate SRAM and validate it */
201 move.l #(CONFIG_SYS_INIT_RAM_ADDR + 0x21), %d0
205 /* initialize general use internal ram */
207 move.l #(ICACHE_STATUS), %a1 /* icache */
208 move.l #(DCACHE_STATUS), %a2 /* icache */
212 /* set stackpointer to end of internal ram to get some stackspace for the first c-code */
213 move.l #(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_SP_OFFSET), %sp
216 move.l #__got_start, %a5 /* put relocation table address to a5 */
218 bsr cpu_init_f /* run low-level CPU init code (from flash) */
219 bsr board_init_f /* run low-level board init code (from flash) */
221 /* board_init_f() does not return */
223 /*------------------------------------------------------------------------------*/
226 * void relocate_code (addr_sp, gd, addr_moni)
228 * This "function" does not return, instead it continues in RAM
229 * after relocating the monitor code.
233 * r5 = length in bytes
239 move.l 8(%a6), %sp /* set new stack pointer */
241 move.l 12(%a6), %d0 /* Save copy of Global Data pointer */
242 move.l 16(%a6), %a0 /* Save copy of Destination Address */
244 move.l #CONFIG_SYS_MONITOR_BASE, %a1
245 move.l #__init_end, %a2
247 /* copy the code to RAM */
249 move.l (%a1)+, (%a3)+
254 * We are done. Do not return, instead branch to second part of board
255 * initialization, now running from RAM.
258 add.l #(in_ram - CONFIG_SYS_MONITOR_BASE), %a1
265 * Now clear BSS segment
268 add.l #(_sbss - CONFIG_SYS_MONITOR_BASE),%a1
270 add.l #(_ebss - CONFIG_SYS_MONITOR_BASE),%d1
277 * fix got table in RAM
280 add.l #(__got_start - CONFIG_SYS_MONITOR_BASE),%a1
281 move.l %a1,%a5 /* * fix got pointer register a5 */
284 add.l #(__got_end - CONFIG_SYS_MONITOR_BASE),%a2
294 /* calculate relative jump to board_init_r in ram */
296 add.l #(board_init_r - CONFIG_SYS_MONITOR_BASE), %a1
298 /* set parameters for board_init_r */
299 move.l %a0,-(%sp) /* dest_addr */
300 move.l %d0,-(%sp) /* gd */
301 #if defined(DEBUG) && (CONFIG_SYS_TEXT_BASE != CONFIG_SYS_INT_FLASH_BASE) && \
302 defined(CONFIG_SYS_HALT_BEFOR_RAM_JUMP)
307 /*------------------------------------------------------------------------------*/
329 /*------------------------------------------------------------------------------*/
331 .globl version_string
333 .ascii U_BOOT_VERSION
334 .ascii " (", U_BOOT_DATE, " - ", U_BOOT_TIME, ")"
335 .ascii CONFIG_IDENT_STRING, "\0"