wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2003 Josef Baumgartner <josef.baumgartner@telex.de> |
| 3 | * Based on code from Bernhard Kuhn <bkuhn@metrowerks.com> |
| 4 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 5 | * SPDX-License-Identifier: GPL-2.0+ |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
Wolfgang Denk | 0191e47 | 2010-10-26 14:34:52 +0200 | [diff] [blame] | 8 | #include <asm-offsets.h> |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 9 | #include <config.h> |
| 10 | #include "version.h" |
TsiChung Liew | 0ee47d4 | 2010-03-11 22:12:53 -0600 | [diff] [blame] | 11 | #include <asm/cache.h> |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 12 | |
| 13 | #ifndef CONFIG_IDENT_STRING |
| 14 | #define CONFIG_IDENT_STRING "" |
| 15 | #endif |
| 16 | |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 17 | #define _START _start |
| 18 | #define _FAULT _fault |
| 19 | |
| 20 | |
| 21 | #define SAVE_ALL \ |
| 22 | move.w #0x2700,%sr; /* disable intrs */ \ |
| 23 | subl #60,%sp; /* space for 15 regs */ \ |
| 24 | moveml %d0-%d7/%a0-%a6,%sp@; \ |
| 25 | |
| 26 | #define RESTORE_ALL \ |
| 27 | moveml %sp@,%d0-%d7/%a0-%a6; \ |
| 28 | addl #60,%sp; /* space for 15 regs */ \ |
| 29 | rte |
| 30 | |
| 31 | /* If we come from a pre-loader we don't need an initial exception |
| 32 | * table. |
| 33 | */ |
| 34 | #if !defined(CONFIG_MONITOR_IS_IN_RAM) |
| 35 | |
| 36 | .text |
Angelo Dureghello | 65d5991 | 2016-05-22 00:14:29 +0200 | [diff] [blame] | 37 | |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 38 | /* |
Angelo Dureghello | 65d5991 | 2016-05-22 00:14:29 +0200 | [diff] [blame] | 39 | * Vector table. This is used for initial platform startup. |
| 40 | * These vectors are to catch any un-intended traps. |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 41 | */ |
| 42 | _vectors: |
Wolfgang Denk | b4b1c46 | 2006-06-10 19:27:47 +0200 | [diff] [blame] | 43 | .long 0x00000000 /* Flash offset is 0 until we setup CS0 */ |
Wolfgang Denk | 0708bc6 | 2010-10-07 21:51:12 +0200 | [diff] [blame] | 44 | #if defined(CONFIG_M5282) && (CONFIG_SYS_TEXT_BASE == CONFIG_SYS_INT_FLASH_BASE) |
| 45 | .long _start - CONFIG_SYS_TEXT_BASE |
Zachary P. Landau | 0bba862 | 2006-01-26 17:35:56 -0500 | [diff] [blame] | 46 | #else |
Wolfgang Denk | b4b1c46 | 2006-06-10 19:27:47 +0200 | [diff] [blame] | 47 | .long _START |
Zachary P. Landau | 0bba862 | 2006-01-26 17:35:56 -0500 | [diff] [blame] | 48 | #endif |
Wolfgang Denk | b4b1c46 | 2006-06-10 19:27:47 +0200 | [diff] [blame] | 49 | |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 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 | |
Angelo Dureghello | 65d5991 | 2016-05-22 00:14:29 +0200 | [diff] [blame] | 88 | .text |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 89 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 90 | #if defined(CONFIG_SYS_INT_FLASH_BASE) && \ |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 91 | (defined(CONFIG_M5282) || defined(CONFIG_M5281)) |
Angelo Dureghello | 65d5991 | 2016-05-22 00:14:29 +0200 | [diff] [blame] | 92 | #if (CONFIG_SYS_TEXT_BASE == CONFIG_SYS_INT_FLASH_BASE) |
| 93 | .long 0x55AA55AA,0xAA55AA55 /* CFM Backdoorkey */ |
| 94 | .long 0xFFFFFFFF /* all sectors protected */ |
| 95 | .long 0x00000000 /* supervisor/User restriction */ |
| 96 | .long 0x00000000 /* programm/data space restriction */ |
| 97 | .long 0x00000000 /* Flash security */ |
| 98 | #endif |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 99 | #endif |
Angelo Dureghello | 65d5991 | 2016-05-22 00:14:29 +0200 | [diff] [blame] | 100 | |
| 101 | .globl _start |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 102 | _start: |
| 103 | nop |
| 104 | nop |
Angelo Dureghello | 65d5991 | 2016-05-22 00:14:29 +0200 | [diff] [blame] | 105 | move.w #0x2700,%sr |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 106 | |
TsiChung Liew | b354aef | 2009-06-12 11:29:00 +0000 | [diff] [blame] | 107 | #if defined(CONFIG_M5208) |
| 108 | /* Initialize RAMBAR: locate SRAM and validate it */ |
| 109 | move.l #(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_RAM_CTRL), %d0 |
| 110 | movec %d0, %RAMBAR1 |
| 111 | #endif |
| 112 | |
TsiChungLiew | 3467469 | 2007-08-16 13:20:50 -0500 | [diff] [blame] | 113 | #if defined(CONFIG_M5272) || defined(CONFIG_M5249) || defined(CONFIG_M5253) |
Angelo Dureghello | 65d5991 | 2016-05-22 00:14:29 +0200 | [diff] [blame] | 114 | /* set MBAR address + valid flag */ |
| 115 | move.l #(CONFIG_SYS_MBAR + 1), %d0 |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 116 | move.c %d0, %MBAR |
| 117 | |
stroese | 53395a2 | 2004-12-16 18:09:49 +0000 | [diff] [blame] | 118 | /*** The 5249 has MBAR2 as well ***/ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 119 | #ifdef CONFIG_SYS_MBAR2 |
Angelo Dureghello | 65d5991 | 2016-05-22 00:14:29 +0200 | [diff] [blame] | 120 | /* Get MBAR2 address */ |
| 121 | move.l #(CONFIG_SYS_MBAR2 + 1), %d0 |
| 122 | /* Set MBAR2 */ |
| 123 | movec %d0, #0xc0e |
stroese | 53395a2 | 2004-12-16 18:09:49 +0000 | [diff] [blame] | 124 | #endif |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 125 | move.l #(CONFIG_SYS_INIT_RAM_ADDR + 1), %d0 |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 126 | movec %d0, %RAMBAR0 |
TsiChungLiew | 3467469 | 2007-08-16 13:20:50 -0500 | [diff] [blame] | 127 | #endif /* CONFIG_M5272 || CONFIG_M5249 || CONFIG_M5253 */ |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 128 | |
Wolfgang Denk | b4b1c46 | 2006-06-10 19:27:47 +0200 | [diff] [blame] | 129 | #if defined(CONFIG_M5282) || defined(CONFIG_M5271) |
Angelo Dureghello | 65d5991 | 2016-05-22 00:14:29 +0200 | [diff] [blame] | 130 | /* set MBAR address + valid flag */ |
| 131 | move.l #(CONFIG_SYS_MBAR + 1), %d0 |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 132 | move.l %d0, 0x40000000 |
| 133 | |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 134 | /* Initialize RAMBAR1: locate SRAM and validate it */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 135 | move.l #(CONFIG_SYS_INIT_RAM_ADDR + 0x21), %d0 |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 136 | movec %d0, %RAMBAR1 |
| 137 | |
Bartlomiej Sieka | 8ff81c6 | 2006-12-20 00:27:32 +0100 | [diff] [blame] | 138 | #if defined(CONFIG_M5282) |
Wolfgang Denk | 0708bc6 | 2010-10-07 21:51:12 +0200 | [diff] [blame] | 139 | #if (CONFIG_SYS_TEXT_BASE == CONFIG_SYS_INT_FLASH_BASE) |
Angelo Dureghello | 65d5991 | 2016-05-22 00:14:29 +0200 | [diff] [blame] | 140 | /* |
| 141 | * Setup code in SRAM to initialize FLASHBAR, |
| 142 | * if start from internal Flash |
| 143 | */ |
| 144 | move.l #(_flashbar_setup-CONFIG_SYS_INT_FLASH_BASE), %a0 |
| 145 | move.l #(_flashbar_setup_end-CONFIG_SYS_INT_FLASH_BASE), %a1 |
| 146 | move.l #(CONFIG_SYS_INIT_RAM_ADDR), %a2 |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 147 | _copy_flash: |
Angelo Dureghello | 65d5991 | 2016-05-22 00:14:29 +0200 | [diff] [blame] | 148 | move.l (%a0)+, (%a2)+ |
| 149 | cmp.l %a0, %a1 |
| 150 | bgt.s _copy_flash |
| 151 | jmp CONFIG_SYS_INIT_RAM_ADDR |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 152 | |
| 153 | _flashbar_setup: |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 154 | /* Initialize FLASHBAR: locate internal Flash and validate it */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 155 | move.l #(CONFIG_SYS_INT_FLASH_BASE + CONFIG_SYS_INT_FLASH_ENABLE), %d0 |
TsiChung Liew | 7e5ae27 | 2008-03-13 14:26:32 -0500 | [diff] [blame] | 156 | movec %d0, %FLASHBAR |
Angelo Dureghello | 65d5991 | 2016-05-22 00:14:29 +0200 | [diff] [blame] | 157 | jmp _after_flashbar_copy.L /* Force jump to absolute address */ |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 158 | _flashbar_setup_end: |
| 159 | nop |
| 160 | _after_flashbar_copy: |
| 161 | #else |
| 162 | /* Setup code to initialize FLASHBAR, if start from external Memory */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 163 | move.l #(CONFIG_SYS_INT_FLASH_BASE + CONFIG_SYS_INT_FLASH_ENABLE), %d0 |
TsiChung Liew | fcd4aac | 2008-08-11 15:54:25 +0000 | [diff] [blame] | 164 | movec %d0, %FLASHBAR |
Wolfgang Denk | 0708bc6 | 2010-10-07 21:51:12 +0200 | [diff] [blame] | 165 | #endif /* (CONFIG_SYS_TEXT_BASE == CONFIG_SYS_INT_FLASH_BASE) */ |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 166 | |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 167 | #endif |
Wolfgang Denk | 5b1657d | 2006-09-04 01:03:57 +0200 | [diff] [blame] | 168 | #endif |
Angelo Dureghello | 65d5991 | 2016-05-22 00:14:29 +0200 | [diff] [blame] | 169 | /* |
| 170 | * if we come from a pre-loader we have no exception table and |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 171 | * therefore no VBR to set |
| 172 | */ |
| 173 | #if !defined(CONFIG_MONITOR_IS_IN_RAM) |
Wolfgang Denk | 0708bc6 | 2010-10-07 21:51:12 +0200 | [diff] [blame] | 174 | #if defined(CONFIG_M5282) && (CONFIG_SYS_TEXT_BASE == CONFIG_SYS_INT_FLASH_BASE) |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 175 | move.l #CONFIG_SYS_INT_FLASH_BASE, %d0 |
TsiChungLiew | 5bffcad | 2007-10-25 17:09:17 -0500 | [diff] [blame] | 176 | #else |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 177 | move.l #CONFIG_SYS_FLASH_BASE, %d0 |
TsiChungLiew | 5bffcad | 2007-10-25 17:09:17 -0500 | [diff] [blame] | 178 | #endif |
Heiko Schocher | ac1956e | 2006-04-20 08:42:42 +0200 | [diff] [blame] | 179 | movec %d0, %VBR |
Marian Balakowicz | c20d87d | 2006-05-09 11:51:51 +0200 | [diff] [blame] | 180 | #endif |
| 181 | |
Matthew Fettke | 761e2e9 | 2008-02-04 15:38:20 -0600 | [diff] [blame] | 182 | #ifdef CONFIG_M5275 |
Angelo Dureghello | 65d5991 | 2016-05-22 00:14:29 +0200 | [diff] [blame] | 183 | /* set MBAR address + valid flag */ |
| 184 | move.l #(CONFIG_SYS_MBAR + 1), %d0 |
Matthew Fettke | 761e2e9 | 2008-02-04 15:38:20 -0600 | [diff] [blame] | 185 | move.l %d0, 0x40000000 |
| 186 | /* movec %d0, %MBAR */ |
| 187 | |
| 188 | /* Initialize RAMBAR: locate SRAM and validate it */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 189 | move.l #(CONFIG_SYS_INIT_RAM_ADDR + 0x21), %d0 |
Matthew Fettke | 761e2e9 | 2008-02-04 15:38:20 -0600 | [diff] [blame] | 190 | movec %d0, %RAMBAR1 |
| 191 | #endif |
| 192 | |
TsiChung Liew | 0ee47d4 | 2010-03-11 22:12:53 -0600 | [diff] [blame] | 193 | /* initialize general use internal ram */ |
Angelo Dureghello | 65d5991 | 2016-05-22 00:14:29 +0200 | [diff] [blame] | 194 | move.l #0, %d0 |
| 195 | move.l #(ICACHE_STATUS), %a1 /* icache */ |
| 196 | move.l #(DCACHE_STATUS), %a2 /* icache */ |
| 197 | move.l %d0, (%a1) |
| 198 | move.l %d0, (%a2) |
TsiChung Liew | 0ee47d4 | 2010-03-11 22:12:53 -0600 | [diff] [blame] | 199 | |
angelo@sysam.it | ef9707c | 2016-04-27 21:50:44 +0200 | [diff] [blame] | 200 | /* put relocation table address to a5 */ |
Angelo Dureghello | 65d5991 | 2016-05-22 00:14:29 +0200 | [diff] [blame] | 201 | move.l #__got_start, %a5 |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 202 | |
angelo@sysam.it | ef9707c | 2016-04-27 21:50:44 +0200 | [diff] [blame] | 203 | /* setup stack initially on top of internal static ram */ |
Angelo Dureghello | 65d5991 | 2016-05-22 00:14:29 +0200 | [diff] [blame] | 204 | move.l #(CONFIG_SYS_INIT_RAM_ADDR + CONFIG_SYS_INIT_RAM_SIZE), %sp |
angelo@sysam.it | ef9707c | 2016-04-27 21:50:44 +0200 | [diff] [blame] | 205 | |
| 206 | /* |
| 207 | * if configured, malloc_f arena will be reserved first, |
| 208 | * then (and always) gd struct space will be reserved |
| 209 | */ |
| 210 | move.l %sp, -(%sp) |
| 211 | move.l #board_init_f_alloc_reserve, %a1 |
Angelo Dureghello | 65d5991 | 2016-05-22 00:14:29 +0200 | [diff] [blame] | 212 | jsr (%a1) |
angelo@sysam.it | ef9707c | 2016-04-27 21:50:44 +0200 | [diff] [blame] | 213 | |
| 214 | /* update stack and frame-pointers */ |
Angelo Dureghello | 65d5991 | 2016-05-22 00:14:29 +0200 | [diff] [blame] | 215 | move.l %d0, %sp |
| 216 | move.l %sp, %fp |
angelo@sysam.it | ef9707c | 2016-04-27 21:50:44 +0200 | [diff] [blame] | 217 | |
| 218 | /* initialize reserved area */ |
Angelo Dureghello | 65d5991 | 2016-05-22 00:14:29 +0200 | [diff] [blame] | 219 | move.l %d0, -(%sp) |
angelo@sysam.it | ef9707c | 2016-04-27 21:50:44 +0200 | [diff] [blame] | 220 | move.l #board_init_f_init_reserve, %a1 |
Angelo Dureghello | 65d5991 | 2016-05-22 00:14:29 +0200 | [diff] [blame] | 221 | jsr (%a1) |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 222 | |
angelo@sysam.it | b8cd132 | 2016-04-12 00:30:59 +0200 | [diff] [blame] | 223 | /* run low-level CPU init code (from flash) */ |
Angelo Dureghello | 65d5991 | 2016-05-22 00:14:29 +0200 | [diff] [blame] | 224 | move.l #cpu_init_f, %a1 |
| 225 | jsr (%a1) |
| 226 | |
angelo@sysam.it | b8cd132 | 2016-04-12 00:30:59 +0200 | [diff] [blame] | 227 | /* run low-level board init code (from flash) */ |
Angelo Dureghello | 65d5991 | 2016-05-22 00:14:29 +0200 | [diff] [blame] | 228 | clr.l %sp@- |
| 229 | move.l #board_init_f, %a1 |
| 230 | jsr (%a1) |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 231 | |
Marian Balakowicz | c20d87d | 2006-05-09 11:51:51 +0200 | [diff] [blame] | 232 | /* board_init_f() does not return */ |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 233 | |
Angelo Dureghello | 65d5991 | 2016-05-22 00:14:29 +0200 | [diff] [blame] | 234 | /******************************************************************************/ |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 235 | |
| 236 | /* |
| 237 | * void relocate_code (addr_sp, gd, addr_moni) |
| 238 | * |
| 239 | * This "function" does not return, instead it continues in RAM |
| 240 | * after relocating the monitor code. |
| 241 | * |
| 242 | * r3 = dest |
| 243 | * r4 = src |
| 244 | * r5 = length in bytes |
| 245 | * r6 = cachelinesize |
| 246 | */ |
Angelo Dureghello | 65d5991 | 2016-05-22 00:14:29 +0200 | [diff] [blame] | 247 | .globl relocate_code |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 248 | relocate_code: |
Angelo Dureghello | 65d5991 | 2016-05-22 00:14:29 +0200 | [diff] [blame] | 249 | link.w %a6,#0 |
| 250 | move.l 8(%a6), %sp /* set new stack pointer */ |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 251 | |
Angelo Dureghello | 65d5991 | 2016-05-22 00:14:29 +0200 | [diff] [blame] | 252 | move.l 12(%a6), %d0 /* Save copy of Global Data pointer */ |
| 253 | move.l 16(%a6), %a0 /* Save copy of Destination Address */ |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 254 | |
Angelo Dureghello | 65d5991 | 2016-05-22 00:14:29 +0200 | [diff] [blame] | 255 | move.l #CONFIG_SYS_MONITOR_BASE, %a1 |
| 256 | move.l #__init_end, %a2 |
| 257 | move.l %a0, %a3 |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 258 | /* copy the code to RAM */ |
| 259 | 1: |
Angelo Dureghello | 65d5991 | 2016-05-22 00:14:29 +0200 | [diff] [blame] | 260 | move.l (%a1)+, (%a3)+ |
| 261 | cmp.l %a1,%a2 |
| 262 | bgt.s 1b |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 263 | |
| 264 | /* |
| 265 | * We are done. Do not return, instead branch to second part of board |
| 266 | * initialization, now running from RAM. |
| 267 | */ |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 268 | move.l %a0, %a1 |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 269 | add.l #(in_ram - CONFIG_SYS_MONITOR_BASE), %a1 |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 270 | jmp (%a1) |
| 271 | |
| 272 | in_ram: |
| 273 | |
| 274 | clear_bss: |
Wolfgang Denk | a1be476 | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 275 | /* |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 276 | * Now clear BSS segment |
| 277 | */ |
| 278 | move.l %a0, %a1 |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 279 | add.l #(_sbss - CONFIG_SYS_MONITOR_BASE),%a1 |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 280 | move.l %a0, %d1 |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 281 | add.l #(_ebss - CONFIG_SYS_MONITOR_BASE),%d1 |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 282 | 6: |
| 283 | clr.l (%a1)+ |
| 284 | cmp.l %a1,%d1 |
| 285 | bgt.s 6b |
| 286 | |
| 287 | /* |
| 288 | * fix got table in RAM |
| 289 | */ |
| 290 | move.l %a0, %a1 |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 291 | add.l #(__got_start - CONFIG_SYS_MONITOR_BASE),%a1 |
Angelo Dureghello | 65d5991 | 2016-05-22 00:14:29 +0200 | [diff] [blame] | 292 | move.l %a1,%a5 /* fix got pointer register a5 */ |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 293 | |
| 294 | move.l %a0, %a2 |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 295 | add.l #(__got_end - CONFIG_SYS_MONITOR_BASE),%a2 |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 296 | |
| 297 | 7: |
| 298 | move.l (%a1),%d1 |
| 299 | sub.l #_start,%d1 |
| 300 | add.l %a0,%d1 |
| 301 | move.l %d1,(%a1)+ |
| 302 | cmp.l %a2, %a1 |
| 303 | bne 7b |
| 304 | |
| 305 | /* calculate relative jump to board_init_r in ram */ |
Angelo Dureghello | 65d5991 | 2016-05-22 00:14:29 +0200 | [diff] [blame] | 306 | move.l %a0, %a1 |
| 307 | add.l #(board_init_r - CONFIG_SYS_MONITOR_BASE), %a1 |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 308 | |
| 309 | /* set parameters for board_init_r */ |
Angelo Dureghello | 65d5991 | 2016-05-22 00:14:29 +0200 | [diff] [blame] | 310 | move.l %a0,-(%sp) /* dest_addr */ |
| 311 | move.l %d0,-(%sp) /* gd */ |
Wolfgang Denk | 0708bc6 | 2010-10-07 21:51:12 +0200 | [diff] [blame] | 312 | #if defined(DEBUG) && (CONFIG_SYS_TEXT_BASE != CONFIG_SYS_INT_FLASH_BASE) && \ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 313 | defined(CONFIG_SYS_HALT_BEFOR_RAM_JUMP) |
TsiChungLiew | 8cd73be | 2007-08-15 19:21:21 -0500 | [diff] [blame] | 314 | halt |
| 315 | #endif |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 316 | jsr (%a1) |
| 317 | |
Angelo Dureghello | 65d5991 | 2016-05-22 00:14:29 +0200 | [diff] [blame] | 318 | /******************************************************************************/ |
| 319 | |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 320 | /* exception code */ |
Angelo Dureghello | 65d5991 | 2016-05-22 00:14:29 +0200 | [diff] [blame] | 321 | .globl _fault |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 322 | _fault: |
Angelo Dureghello | 65d5991 | 2016-05-22 00:14:29 +0200 | [diff] [blame] | 323 | bra _fault |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 324 | |
Angelo Dureghello | 65d5991 | 2016-05-22 00:14:29 +0200 | [diff] [blame] | 325 | .globl _exc_handler |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 326 | _exc_handler: |
| 327 | SAVE_ALL |
| 328 | movel %sp,%sp@- |
Angelo Dureghello | 65d5991 | 2016-05-22 00:14:29 +0200 | [diff] [blame] | 329 | bsr exc_handler |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 330 | addql #4,%sp |
| 331 | RESTORE_ALL |
| 332 | |
Angelo Dureghello | 65d5991 | 2016-05-22 00:14:29 +0200 | [diff] [blame] | 333 | .globl _int_handler |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 334 | _int_handler: |
| 335 | SAVE_ALL |
| 336 | movel %sp,%sp@- |
Angelo Dureghello | 65d5991 | 2016-05-22 00:14:29 +0200 | [diff] [blame] | 337 | bsr int_handler |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 338 | addql #4,%sp |
| 339 | RESTORE_ALL |
| 340 | |
Angelo Dureghello | 65d5991 | 2016-05-22 00:14:29 +0200 | [diff] [blame] | 341 | /******************************************************************************/ |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 342 | |
Angelo Dureghello | 65d5991 | 2016-05-22 00:14:29 +0200 | [diff] [blame] | 343 | .globl version_string |
wdenk | e65527f | 2004-02-12 00:47:09 +0000 | [diff] [blame] | 344 | version_string: |
Angelo Dureghello | 65d5991 | 2016-05-22 00:14:29 +0200 | [diff] [blame] | 345 | .ascii U_BOOT_VERSION_STRING, "\0" |
| 346 | .align 4 |