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