wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 1 | /* |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 2 | * Copyright 2004, 2007 Freescale Semiconductor. |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 3 | * Copyright (C) 2003 Motorola,Inc. |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 4 | * |
| 5 | * See file CREDITS for list of people who contributed to this |
| 6 | * project. |
| 7 | * |
| 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. |
| 12 | * |
| 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. |
| 17 | * |
| 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, |
| 21 | * MA 02111-1307 USA |
| 22 | */ |
| 23 | |
| 24 | /* U-Boot Startup Code for Motorola 85xx PowerPC based Embedded Boards |
| 25 | * |
| 26 | * The processor starts at 0xfffffffc and the code is first executed in the |
| 27 | * last 4K page(0xfffff000-0xffffffff) in flash/rom. |
| 28 | * |
| 29 | */ |
| 30 | |
| 31 | #include <config.h> |
| 32 | #include <mpc85xx.h> |
| 33 | #include <version.h> |
| 34 | |
| 35 | #define _LINUX_CONFIG_H 1 /* avoid reading Linux autoconf.h file */ |
| 36 | |
| 37 | #include <ppc_asm.tmpl> |
| 38 | #include <ppc_defs.h> |
| 39 | |
| 40 | #include <asm/cache.h> |
| 41 | #include <asm/mmu.h> |
| 42 | |
| 43 | #ifndef CONFIG_IDENT_STRING |
| 44 | #define CONFIG_IDENT_STRING "" |
| 45 | #endif |
| 46 | |
| 47 | #undef MSR_KERNEL |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 48 | #define MSR_KERNEL ( MSR_ME ) /* Machine Check */ |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 49 | |
| 50 | /* |
| 51 | * Set up GOT: Global Offset Table |
| 52 | * |
| 53 | * Use r14 to access the GOT |
| 54 | */ |
| 55 | START_GOT |
| 56 | GOT_ENTRY(_GOT2_TABLE_) |
| 57 | GOT_ENTRY(_FIXUP_TABLE_) |
| 58 | |
| 59 | GOT_ENTRY(_start) |
| 60 | GOT_ENTRY(_start_of_vectors) |
| 61 | GOT_ENTRY(_end_of_vectors) |
| 62 | GOT_ENTRY(transfer_to_handler) |
| 63 | |
| 64 | GOT_ENTRY(__init_end) |
| 65 | GOT_ENTRY(_end) |
| 66 | GOT_ENTRY(__bss_start) |
| 67 | END_GOT |
| 68 | |
| 69 | /* |
| 70 | * e500 Startup -- after reset only the last 4KB of the effective |
| 71 | * address space is mapped in the MMU L2 TLB1 Entry0. The .bootpg |
| 72 | * section is located at THIS LAST page and basically does three |
| 73 | * things: clear some registers, set up exception tables and |
| 74 | * add more TLB entries for 'larger spaces'(e.g. the boot rom) to |
| 75 | * continue the boot procedure. |
| 76 | |
| 77 | * Once the boot rom is mapped by TLB entries we can proceed |
| 78 | * with normal startup. |
| 79 | * |
| 80 | */ |
| 81 | |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 82 | .section .bootpg,"ax" |
| 83 | .globl _start_e500 |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 84 | |
| 85 | _start_e500: |
wdenk | 97d80fc | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 86 | |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 87 | /* clear registers/arrays not reset by hardware */ |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 88 | |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 89 | /* L1 */ |
| 90 | li r0,2 |
| 91 | mtspr L1CSR0,r0 /* invalidate d-cache */ |
| 92 | mtspr L1CSR1,r0 /* invalidate i-cache */ |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 93 | |
| 94 | mfspr r1,DBSR |
| 95 | mtspr DBSR,r1 /* Clear all valid bits */ |
| 96 | |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 97 | /* |
| 98 | * Enable L1 Caches early |
| 99 | * |
| 100 | */ |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 101 | |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 102 | lis r2,L1CSR0_CPE@H /* enable parity */ |
| 103 | ori r2,r2,L1CSR0_DCE |
| 104 | mtspr L1CSR0,r2 /* enable L1 Dcache */ |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 105 | isync |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 106 | mtspr L1CSR1,r2 /* enable L1 Icache */ |
| 107 | isync |
| 108 | msync |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 109 | |
| 110 | /* Setup interrupt vectors */ |
wdenk | 343117b | 2005-05-13 22:49:36 +0000 | [diff] [blame] | 111 | lis r1,TEXT_BASE@h |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 112 | mtspr IVPR,r1 |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 113 | |
wdenk | 343117b | 2005-05-13 22:49:36 +0000 | [diff] [blame] | 114 | li r1,0x0100 |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 115 | mtspr IVOR0,r1 /* 0: Critical input */ |
wdenk | 343117b | 2005-05-13 22:49:36 +0000 | [diff] [blame] | 116 | li r1,0x0200 |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 117 | mtspr IVOR1,r1 /* 1: Machine check */ |
wdenk | 343117b | 2005-05-13 22:49:36 +0000 | [diff] [blame] | 118 | li r1,0x0300 |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 119 | mtspr IVOR2,r1 /* 2: Data storage */ |
wdenk | 343117b | 2005-05-13 22:49:36 +0000 | [diff] [blame] | 120 | li r1,0x0400 |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 121 | mtspr IVOR3,r1 /* 3: Instruction storage */ |
| 122 | li r1,0x0500 |
| 123 | mtspr IVOR4,r1 /* 4: External interrupt */ |
| 124 | li r1,0x0600 |
| 125 | mtspr IVOR5,r1 /* 5: Alignment */ |
| 126 | li r1,0x0700 |
| 127 | mtspr IVOR6,r1 /* 6: Program check */ |
| 128 | li r1,0x0800 |
| 129 | mtspr IVOR7,r1 /* 7: floating point unavailable */ |
wdenk | 343117b | 2005-05-13 22:49:36 +0000 | [diff] [blame] | 130 | li r1,0x0900 |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 131 | mtspr IVOR8,r1 /* 8: System call */ |
| 132 | /* 9: Auxiliary processor unavailable(unsupported) */ |
wdenk | 343117b | 2005-05-13 22:49:36 +0000 | [diff] [blame] | 133 | li r1,0x0a00 |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 134 | mtspr IVOR10,r1 /* 10: Decrementer */ |
wdenk | 343117b | 2005-05-13 22:49:36 +0000 | [diff] [blame] | 135 | li r1,0x0b00 |
| 136 | mtspr IVOR11,r1 /* 11: Interval timer */ |
| 137 | li r1,0x0c00 |
Wolfgang Denk | 3e0bc44 | 2005-08-04 01:24:19 +0200 | [diff] [blame] | 138 | mtspr IVOR12,r1 /* 12: Watchdog timer */ |
| 139 | li r1,0x0d00 |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 140 | mtspr IVOR13,r1 /* 13: Data TLB error */ |
wdenk | 343117b | 2005-05-13 22:49:36 +0000 | [diff] [blame] | 141 | li r1,0x0e00 |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 142 | mtspr IVOR14,r1 /* 14: Instruction TLB error */ |
wdenk | 343117b | 2005-05-13 22:49:36 +0000 | [diff] [blame] | 143 | li r1,0x0f00 |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 144 | mtspr IVOR15,r1 /* 15: Debug */ |
| 145 | |
wdenk | 9aea953 | 2004-08-01 23:02:45 +0000 | [diff] [blame] | 146 | |
| 147 | /* |
| 148 | * After reset, CCSRBAR is located at CFG_CCSRBAR_DEFAULT, i.e. |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 149 | * 0xff700000-0xff800000. We need add a TLB1 entry for this 1MB |
| 150 | * region before we can access any CCSR registers such as L2 |
| 151 | * registers, Local Access Registers,etc. We will also re-allocate |
| 152 | * CFG_CCSRBAR_DEFAULT to CFG_CCSRBAR immediately after TLB1 setup. |
| 153 | * |
| 154 | * Please refer to board-specif directory for TLB1 entry configuration. |
| 155 | * (e.g. board/<yourboard>/init.S) |
| 156 | * |
| 157 | */ |
wdenk | 343117b | 2005-05-13 22:49:36 +0000 | [diff] [blame] | 158 | bl tlb1_entry |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 159 | mr r5,r0 |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 160 | lwzu r4,0(r5) /* how many TLB1 entries we actually use */ |
Zang Roy-r61911 | 63247a5 | 2006-12-20 11:01:00 +0800 | [diff] [blame] | 161 | mtctr r4 |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 162 | |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 163 | 0: lwzu r6,4(r5) |
| 164 | lwzu r7,4(r5) |
| 165 | lwzu r8,4(r5) |
| 166 | lwzu r9,4(r5) |
| 167 | mtspr MAS0,r6 |
| 168 | mtspr MAS1,r7 |
| 169 | mtspr MAS2,r8 |
| 170 | mtspr MAS3,r9 |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 171 | isync |
| 172 | msync |
| 173 | tlbwe |
| 174 | isync |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 175 | bdnz 0b |
| 176 | |
| 177 | 1: |
| 178 | #if (CFG_CCSRBAR_DEFAULT != CFG_CCSRBAR) |
| 179 | /* Special sequence needed to update CCSRBAR itself */ |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 180 | lis r4,CFG_CCSRBAR_DEFAULT@h |
| 181 | ori r4,r4,CFG_CCSRBAR_DEFAULT@l |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 182 | |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 183 | lis r5,CFG_CCSRBAR@h |
| 184 | ori r5,r5,CFG_CCSRBAR@l |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 185 | srwi r6,r5,12 |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 186 | stw r6,0(r4) |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 187 | isync |
| 188 | |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 189 | lis r5,0xffff |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 190 | ori r5,r5,0xf000 |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 191 | lwz r5,0(r5) |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 192 | isync |
| 193 | |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 194 | lis r3,CFG_CCSRBAR@h |
| 195 | lwz r5,CFG_CCSRBAR@l(r3) |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 196 | isync |
| 197 | #endif |
| 198 | |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 199 | |
| 200 | /* set up local access windows, defined at board/<boardname>/init.S */ |
| 201 | lis r7,CFG_CCSRBAR@h |
| 202 | ori r7,r7,CFG_CCSRBAR@l |
| 203 | |
wdenk | 343117b | 2005-05-13 22:49:36 +0000 | [diff] [blame] | 204 | bl law_entry |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 205 | mr r6,r0 |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 206 | lwzu r5,0(r6) /* how many windows we actually use */ |
Zang Roy-r61911 | 63247a5 | 2006-12-20 11:01:00 +0800 | [diff] [blame] | 207 | mtctr r5 |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 208 | |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 209 | li r2,0x0c28 /* the first pair is reserved for */ |
| 210 | li r1,0x0c30 /* boot-over-rio-or-pci */ |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 211 | |
Zang Roy-r61911 | 63247a5 | 2006-12-20 11:01:00 +0800 | [diff] [blame] | 212 | 0: lwzu r4,4(r6) |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 213 | lwzu r3,4(r6) |
| 214 | stwx r4,r7,r2 |
| 215 | stwx r3,r7,r1 |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 216 | addi r2,r2,0x0020 |
| 217 | addi r1,r1,0x0020 |
| 218 | bdnz 0b |
| 219 | |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 220 | /* Clear and set up some registers. */ |
urwithsughosh@gmail.com | 1e701e7 | 2007-09-24 13:36:01 -0400 | [diff] [blame^] | 221 | li r0,0 |
| 222 | mtmsr r0 |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 223 | li r0,0x0000 |
| 224 | lis r1,0xffff |
| 225 | mtspr DEC,r0 /* prevent dec exceptions */ |
| 226 | mttbl r0 /* prevent fit & wdt exceptions */ |
| 227 | mttbu r0 |
| 228 | mtspr TSR,r1 /* clear all timer exception status */ |
| 229 | mtspr TCR,r0 /* disable all */ |
| 230 | mtspr ESR,r0 /* clear exception syndrome register */ |
| 231 | mtspr MCSR,r0 /* machine check syndrome register */ |
| 232 | mtxer r0 /* clear integer exception register */ |
| 233 | lis r1,0x0002 /* set CE bit (Critical Exceptions) */ |
| 234 | ori r1,r1,0x1200 /* set ME/DE bit */ |
| 235 | mtmsr r1 /* change MSR */ |
| 236 | isync |
| 237 | |
| 238 | /* Enable Time Base and Select Time Base Clock */ |
wdenk | 0ac6f8b | 2004-07-09 23:27:13 +0000 | [diff] [blame] | 239 | lis r0,HID0_EMCP@h /* Enable machine check */ |
Jon Loeliger | d9b94f2 | 2005-07-25 14:05:07 -0500 | [diff] [blame] | 240 | #if defined(CONFIG_ENABLE_36BIT_PHYS) |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 241 | ori r0,r0,(HID0_TBEN|HID0_ENMAS7)@l /* Enable Timebase & MAS7 */ |
| 242 | #else |
| 243 | ori r0,r0,HID0_TBEN@l /* enable Timebase */ |
Jon Loeliger | d9b94f2 | 2005-07-25 14:05:07 -0500 | [diff] [blame] | 244 | #endif |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 245 | mtspr HID0,r0 |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 246 | |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 247 | li r0,(HID1_ASTME|HID1_ABE)@l /* Addr streaming & broadcast */ |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 248 | mtspr HID1,r0 |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 249 | |
| 250 | /* Enable Branch Prediction */ |
| 251 | #if defined(CONFIG_BTB) |
| 252 | li r0,0x201 /* BBFI = 1, BPEN = 1 */ |
| 253 | mtspr BUCSR,r0 |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 254 | #endif |
| 255 | |
| 256 | #if defined(CFG_INIT_DBCR) |
| 257 | lis r1,0xffff |
| 258 | ori r1,r1,0xffff |
wdenk | 0ac6f8b | 2004-07-09 23:27:13 +0000 | [diff] [blame] | 259 | mtspr DBSR,r1 /* Clear all status bits */ |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 260 | lis r0,CFG_INIT_DBCR@h /* DBCR0[IDM] must be set */ |
| 261 | ori r0,r0,CFG_INIT_DBCR@l |
wdenk | 0ac6f8b | 2004-07-09 23:27:13 +0000 | [diff] [blame] | 262 | mtspr DBCR0,r0 |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 263 | #endif |
| 264 | |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 265 | /* L1 DCache is used for initial RAM */ |
| 266 | |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 267 | /* Allocate Initial RAM in data cache. |
| 268 | */ |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 269 | lis r3,CFG_INIT_RAM_ADDR@h |
| 270 | ori r3,r3,CFG_INIT_RAM_ADDR@l |
Kumar Gala | e1ce3cb | 2007-10-02 11:12:27 -0500 | [diff] [blame] | 271 | li r2,(CFG_DCACHE_SIZE / (2 * CFG_CACHELINE_SIZE)) |
wdenk | 343117b | 2005-05-13 22:49:36 +0000 | [diff] [blame] | 272 | mtctr r2 |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 273 | li r0,0 |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 274 | 1: |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 275 | dcbz r0,r3 |
| 276 | dcbtls 0,r0,r3 |
Kumar Gala | e1ce3cb | 2007-10-02 11:12:27 -0500 | [diff] [blame] | 277 | addi r3,r3,CFG_CACHELINE_SIZE |
wdenk | 343117b | 2005-05-13 22:49:36 +0000 | [diff] [blame] | 278 | bdnz 1b |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 279 | |
Kumar Gala | 3db0bef | 2007-08-07 18:07:27 -0500 | [diff] [blame] | 280 | /* Jump out the last 4K page and continue to 'normal' start */ |
| 281 | #ifdef CFG_RAMBOOT |
Kumar Gala | 3db0bef | 2007-08-07 18:07:27 -0500 | [diff] [blame] | 282 | b _start_cont |
| 283 | #else |
wdenk | 343117b | 2005-05-13 22:49:36 +0000 | [diff] [blame] | 284 | /* Calculate absolute address in FLASH and jump there */ |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 285 | /*--------------------------------------------------------------*/ |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 286 | lis r3,CFG_MONITOR_BASE@h |
| 287 | ori r3,r3,CFG_MONITOR_BASE@l |
Kumar Gala | 3db0bef | 2007-08-07 18:07:27 -0500 | [diff] [blame] | 288 | addi r3,r3,_start_cont - _start + _START_OFFSET |
wdenk | 343117b | 2005-05-13 22:49:36 +0000 | [diff] [blame] | 289 | mtlr r3 |
urwithsughosh@gmail.com | 1e701e7 | 2007-09-24 13:36:01 -0400 | [diff] [blame^] | 290 | blr |
Kumar Gala | 3db0bef | 2007-08-07 18:07:27 -0500 | [diff] [blame] | 291 | #endif |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 292 | |
Kumar Gala | 3db0bef | 2007-08-07 18:07:27 -0500 | [diff] [blame] | 293 | .text |
| 294 | .globl _start |
| 295 | _start: |
| 296 | .long 0x27051956 /* U-BOOT Magic Number */ |
| 297 | .globl version_string |
| 298 | version_string: |
| 299 | .ascii U_BOOT_VERSION |
| 300 | .ascii " (", __DATE__, " - ", __TIME__, ")" |
| 301 | .ascii CONFIG_IDENT_STRING, "\0" |
| 302 | |
| 303 | .align 4 |
| 304 | .globl _start_cont |
| 305 | _start_cont: |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 306 | /* Setup the stack in initial RAM,could be L2-as-SRAM or L1 dcache*/ |
| 307 | lis r1,CFG_INIT_RAM_ADDR@h |
| 308 | ori r1,r1,CFG_INIT_SP_OFFSET@l |
| 309 | |
| 310 | li r0,0 |
| 311 | stwu r0,-4(r1) |
| 312 | stwu r0,-4(r1) /* Terminate call chain */ |
| 313 | |
| 314 | stwu r1,-8(r1) /* Save back chain and move SP */ |
| 315 | lis r0,RESET_VECTOR@h /* Address of reset vector */ |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 316 | ori r0,r0,RESET_VECTOR@l |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 317 | stwu r1,-8(r1) /* Save back chain and move SP */ |
| 318 | stw r0,+12(r1) /* Save return addr (underflow vect) */ |
| 319 | |
| 320 | GET_GOT |
| 321 | bl cpu_init_f |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 322 | bl board_init_f |
wdenk | 0ac6f8b | 2004-07-09 23:27:13 +0000 | [diff] [blame] | 323 | isync |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 324 | |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 325 | . = EXC_OFF_SYS_RESET |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 326 | .globl _start_of_vectors |
| 327 | _start_of_vectors: |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 328 | |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 329 | /* Critical input. */ |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 330 | CRIT_EXCEPTION(0x0100, CriticalInput, CritcalInputException) |
| 331 | |
| 332 | /* Machine check */ |
| 333 | MCK_EXCEPTION(0x200, MachineCheck, MachineCheckException) |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 334 | |
| 335 | /* Data Storage exception. */ |
| 336 | STD_EXCEPTION(0x0300, DataStorage, UnknownException) |
| 337 | |
| 338 | /* Instruction Storage exception. */ |
| 339 | STD_EXCEPTION(0x0400, InstStorage, UnknownException) |
| 340 | |
| 341 | /* External Interrupt exception. */ |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 342 | STD_EXCEPTION(0x0500, ExtInterrupt, ExtIntException) |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 343 | |
| 344 | /* Alignment exception. */ |
| 345 | . = 0x0600 |
| 346 | Alignment: |
Rafal Jaworowski | 02032e8 | 2007-06-22 14:58:04 +0200 | [diff] [blame] | 347 | EXCEPTION_PROLOG(SRR0, SRR1) |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 348 | mfspr r4,DAR |
| 349 | stw r4,_DAR(r21) |
| 350 | mfspr r5,DSISR |
| 351 | stw r5,_DSISR(r21) |
| 352 | addi r3,r1,STACK_FRAME_OVERHEAD |
| 353 | li r20,MSR_KERNEL |
| 354 | rlwimi r20,r23,0,16,16 /* copy EE bit from saved MSR */ |
| 355 | lwz r6,GOT(transfer_to_handler) |
| 356 | mtlr r6 |
| 357 | blrl |
| 358 | .L_Alignment: |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 359 | .long AlignmentException - _start + _START_OFFSET |
| 360 | .long int_return - _start + _START_OFFSET |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 361 | |
| 362 | /* Program check exception */ |
| 363 | . = 0x0700 |
| 364 | ProgramCheck: |
Rafal Jaworowski | 02032e8 | 2007-06-22 14:58:04 +0200 | [diff] [blame] | 365 | EXCEPTION_PROLOG(SRR0, SRR1) |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 366 | addi r3,r1,STACK_FRAME_OVERHEAD |
| 367 | li r20,MSR_KERNEL |
| 368 | rlwimi r20,r23,0,16,16 /* copy EE bit from saved MSR */ |
| 369 | lwz r6,GOT(transfer_to_handler) |
| 370 | mtlr r6 |
| 371 | blrl |
| 372 | .L_ProgramCheck: |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 373 | .long ProgramCheckException - _start + _START_OFFSET |
| 374 | .long int_return - _start + _START_OFFSET |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 375 | |
| 376 | /* No FPU on MPC85xx. This exception is not supposed to happen. |
| 377 | */ |
| 378 | STD_EXCEPTION(0x0800, FPUnavailable, UnknownException) |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 379 | |
wdenk | 343117b | 2005-05-13 22:49:36 +0000 | [diff] [blame] | 380 | . = 0x0900 |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 381 | /* |
| 382 | * r0 - SYSCALL number |
| 383 | * r3-... arguments |
| 384 | */ |
| 385 | SystemCall: |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 386 | addis r11,r0,0 /* get functions table addr */ |
| 387 | ori r11,r11,0 /* Note: this code is patched in trap_init */ |
| 388 | addis r12,r0,0 /* get number of functions */ |
wdenk | 343117b | 2005-05-13 22:49:36 +0000 | [diff] [blame] | 389 | ori r12,r12,0 |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 390 | |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 391 | cmplw 0,r0,r12 |
wdenk | 343117b | 2005-05-13 22:49:36 +0000 | [diff] [blame] | 392 | bge 1f |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 393 | |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 394 | rlwinm r0,r0,2,0,31 /* fn_addr = fn_tbl[r0] */ |
wdenk | 343117b | 2005-05-13 22:49:36 +0000 | [diff] [blame] | 395 | add r11,r11,r0 |
| 396 | lwz r11,0(r11) |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 397 | |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 398 | li r20,0xd00-4 /* Get stack pointer */ |
wdenk | 343117b | 2005-05-13 22:49:36 +0000 | [diff] [blame] | 399 | lwz r12,0(r20) |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 400 | subi r12,r12,12 /* Adjust stack pointer */ |
wdenk | 343117b | 2005-05-13 22:49:36 +0000 | [diff] [blame] | 401 | li r0,0xc00+_end_back-SystemCall |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 402 | cmplw 0,r0,r12 /* Check stack overflow */ |
wdenk | 343117b | 2005-05-13 22:49:36 +0000 | [diff] [blame] | 403 | bgt 1f |
| 404 | stw r12,0(r20) |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 405 | |
wdenk | 343117b | 2005-05-13 22:49:36 +0000 | [diff] [blame] | 406 | mflr r0 |
| 407 | stw r0,0(r12) |
| 408 | mfspr r0,SRR0 |
| 409 | stw r0,4(r12) |
| 410 | mfspr r0,SRR1 |
| 411 | stw r0,8(r12) |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 412 | |
wdenk | 343117b | 2005-05-13 22:49:36 +0000 | [diff] [blame] | 413 | li r12,0xc00+_back-SystemCall |
| 414 | mtlr r12 |
| 415 | mtspr SRR0,r11 |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 416 | |
wdenk | 343117b | 2005-05-13 22:49:36 +0000 | [diff] [blame] | 417 | 1: SYNC |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 418 | rfi |
| 419 | _back: |
| 420 | |
wdenk | 343117b | 2005-05-13 22:49:36 +0000 | [diff] [blame] | 421 | mfmsr r11 /* Disable interrupts */ |
| 422 | li r12,0 |
| 423 | ori r12,r12,MSR_EE |
| 424 | andc r11,r11,r12 |
| 425 | SYNC /* Some chip revs need this... */ |
| 426 | mtmsr r11 |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 427 | SYNC |
| 428 | |
wdenk | 343117b | 2005-05-13 22:49:36 +0000 | [diff] [blame] | 429 | li r12,0xd00-4 /* restore regs */ |
| 430 | lwz r12,0(r12) |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 431 | |
wdenk | 343117b | 2005-05-13 22:49:36 +0000 | [diff] [blame] | 432 | lwz r11,0(r12) |
| 433 | mtlr r11 |
| 434 | lwz r11,4(r12) |
| 435 | mtspr SRR0,r11 |
| 436 | lwz r11,8(r12) |
| 437 | mtspr SRR1,r11 |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 438 | |
wdenk | 343117b | 2005-05-13 22:49:36 +0000 | [diff] [blame] | 439 | addi r12,r12,12 /* Adjust stack pointer */ |
| 440 | li r20,0xd00-4 |
| 441 | stw r12,0(r20) |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 442 | |
| 443 | SYNC |
| 444 | rfi |
| 445 | _end_back: |
| 446 | |
wdenk | 343117b | 2005-05-13 22:49:36 +0000 | [diff] [blame] | 447 | STD_EXCEPTION(0x0a00, Decrementer, timer_interrupt) |
| 448 | STD_EXCEPTION(0x0b00, IntervalTimer, UnknownException) |
| 449 | STD_EXCEPTION(0x0c00, WatchdogTimer, UnknownException) |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 450 | |
wdenk | 343117b | 2005-05-13 22:49:36 +0000 | [diff] [blame] | 451 | STD_EXCEPTION(0x0d00, DataTLBError, UnknownException) |
| 452 | STD_EXCEPTION(0x0e00, InstructionTLBError, UnknownException) |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 453 | |
wdenk | 343117b | 2005-05-13 22:49:36 +0000 | [diff] [blame] | 454 | CRIT_EXCEPTION(0x0f00, DebugBreakpoint, DebugException ) |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 455 | |
wdenk | 343117b | 2005-05-13 22:49:36 +0000 | [diff] [blame] | 456 | .globl _end_of_vectors |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 457 | _end_of_vectors: |
| 458 | |
| 459 | |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 460 | . = . + (0x100 - ( . & 0xff )) /* align for debug */ |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 461 | |
| 462 | /* |
| 463 | * This code finishes saving the registers to the exception frame |
| 464 | * and jumps to the appropriate handler for the exception. |
| 465 | * Register r21 is pointer into trap frame, r1 has new stack pointer. |
| 466 | */ |
| 467 | .globl transfer_to_handler |
| 468 | transfer_to_handler: |
| 469 | stw r22,_NIP(r21) |
| 470 | lis r22,MSR_POW@h |
| 471 | andc r23,r23,r22 |
| 472 | stw r23,_MSR(r21) |
| 473 | SAVE_GPR(7, r21) |
| 474 | SAVE_4GPRS(8, r21) |
| 475 | SAVE_8GPRS(12, r21) |
| 476 | SAVE_8GPRS(24, r21) |
| 477 | |
| 478 | mflr r23 |
| 479 | andi. r24,r23,0x3f00 /* get vector offset */ |
| 480 | stw r24,TRAP(r21) |
| 481 | li r22,0 |
| 482 | stw r22,RESULT(r21) |
| 483 | mtspr SPRG2,r22 /* r1 is now kernel sp */ |
| 484 | |
| 485 | lwz r24,0(r23) /* virtual address of handler */ |
| 486 | lwz r23,4(r23) /* where to go when done */ |
| 487 | mtspr SRR0,r24 |
| 488 | mtspr SRR1,r20 |
| 489 | mtlr r23 |
| 490 | SYNC |
| 491 | rfi /* jump to handler, enable MMU */ |
| 492 | |
| 493 | int_return: |
| 494 | mfmsr r28 /* Disable interrupts */ |
| 495 | li r4,0 |
| 496 | ori r4,r4,MSR_EE |
| 497 | andc r28,r28,r4 |
| 498 | SYNC /* Some chip revs need this... */ |
| 499 | mtmsr r28 |
| 500 | SYNC |
| 501 | lwz r2,_CTR(r1) |
| 502 | lwz r0,_LINK(r1) |
| 503 | mtctr r2 |
| 504 | mtlr r0 |
| 505 | lwz r2,_XER(r1) |
| 506 | lwz r0,_CCR(r1) |
| 507 | mtspr XER,r2 |
| 508 | mtcrf 0xFF,r0 |
| 509 | REST_10GPRS(3, r1) |
| 510 | REST_10GPRS(13, r1) |
| 511 | REST_8GPRS(23, r1) |
| 512 | REST_GPR(31, r1) |
| 513 | lwz r2,_NIP(r1) /* Restore environment */ |
| 514 | lwz r0,_MSR(r1) |
| 515 | mtspr SRR0,r2 |
| 516 | mtspr SRR1,r0 |
| 517 | lwz r0,GPR0(r1) |
| 518 | lwz r2,GPR2(r1) |
| 519 | lwz r1,GPR1(r1) |
| 520 | SYNC |
| 521 | rfi |
| 522 | |
| 523 | crit_return: |
| 524 | mfmsr r28 /* Disable interrupts */ |
| 525 | li r4,0 |
| 526 | ori r4,r4,MSR_EE |
| 527 | andc r28,r28,r4 |
| 528 | SYNC /* Some chip revs need this... */ |
| 529 | mtmsr r28 |
| 530 | SYNC |
| 531 | lwz r2,_CTR(r1) |
| 532 | lwz r0,_LINK(r1) |
| 533 | mtctr r2 |
| 534 | mtlr r0 |
| 535 | lwz r2,_XER(r1) |
| 536 | lwz r0,_CCR(r1) |
| 537 | mtspr XER,r2 |
| 538 | mtcrf 0xFF,r0 |
| 539 | REST_10GPRS(3, r1) |
| 540 | REST_10GPRS(13, r1) |
| 541 | REST_8GPRS(23, r1) |
| 542 | REST_GPR(31, r1) |
| 543 | lwz r2,_NIP(r1) /* Restore environment */ |
| 544 | lwz r0,_MSR(r1) |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 545 | mtspr SPRN_CSRR0,r2 |
| 546 | mtspr SPRN_CSRR1,r0 |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 547 | lwz r0,GPR0(r1) |
| 548 | lwz r2,GPR2(r1) |
| 549 | lwz r1,GPR1(r1) |
| 550 | SYNC |
| 551 | rfci |
| 552 | |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 553 | mck_return: |
| 554 | mfmsr r28 /* Disable interrupts */ |
| 555 | li r4,0 |
| 556 | ori r4,r4,MSR_EE |
| 557 | andc r28,r28,r4 |
| 558 | SYNC /* Some chip revs need this... */ |
| 559 | mtmsr r28 |
| 560 | SYNC |
| 561 | lwz r2,_CTR(r1) |
| 562 | lwz r0,_LINK(r1) |
| 563 | mtctr r2 |
| 564 | mtlr r0 |
| 565 | lwz r2,_XER(r1) |
| 566 | lwz r0,_CCR(r1) |
| 567 | mtspr XER,r2 |
| 568 | mtcrf 0xFF,r0 |
| 569 | REST_10GPRS(3, r1) |
| 570 | REST_10GPRS(13, r1) |
| 571 | REST_8GPRS(23, r1) |
| 572 | REST_GPR(31, r1) |
| 573 | lwz r2,_NIP(r1) /* Restore environment */ |
| 574 | lwz r0,_MSR(r1) |
| 575 | mtspr SPRN_MCSRR0,r2 |
| 576 | mtspr SPRN_MCSRR1,r0 |
| 577 | lwz r0,GPR0(r1) |
| 578 | lwz r2,GPR2(r1) |
| 579 | lwz r1,GPR1(r1) |
| 580 | SYNC |
| 581 | rfmci |
| 582 | |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 583 | /* Cache functions. |
| 584 | */ |
| 585 | invalidate_icache: |
| 586 | mfspr r0,L1CSR1 |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 587 | ori r0,r0,L1CSR1_ICFI |
| 588 | msync |
| 589 | isync |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 590 | mtspr L1CSR1,r0 |
| 591 | isync |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 592 | blr /* entire I cache */ |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 593 | |
| 594 | invalidate_dcache: |
| 595 | mfspr r0,L1CSR0 |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 596 | ori r0,r0,L1CSR0_DCFI |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 597 | msync |
| 598 | isync |
| 599 | mtspr L1CSR0,r0 |
| 600 | isync |
| 601 | blr |
| 602 | |
| 603 | .globl icache_enable |
| 604 | icache_enable: |
| 605 | mflr r8 |
| 606 | bl invalidate_icache |
| 607 | mtlr r8 |
| 608 | isync |
| 609 | mfspr r4,L1CSR1 |
| 610 | ori r4,r4,0x0001 |
| 611 | oris r4,r4,0x0001 |
| 612 | mtspr L1CSR1,r4 |
| 613 | isync |
| 614 | blr |
| 615 | |
| 616 | .globl icache_disable |
| 617 | icache_disable: |
| 618 | mfspr r0,L1CSR1 |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 619 | lis r3,0 |
| 620 | ori r3,r3,L1CSR1_ICE |
| 621 | andc r0,r0,r3 |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 622 | mtspr L1CSR1,r0 |
| 623 | isync |
| 624 | blr |
| 625 | |
| 626 | .globl icache_status |
| 627 | icache_status: |
| 628 | mfspr r3,L1CSR1 |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 629 | andi. r3,r3,L1CSR1_ICE |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 630 | blr |
| 631 | |
| 632 | .globl dcache_enable |
| 633 | dcache_enable: |
| 634 | mflr r8 |
| 635 | bl invalidate_dcache |
| 636 | mtlr r8 |
| 637 | isync |
| 638 | mfspr r0,L1CSR0 |
| 639 | ori r0,r0,0x0001 |
| 640 | oris r0,r0,0x0001 |
| 641 | msync |
| 642 | isync |
| 643 | mtspr L1CSR0,r0 |
| 644 | isync |
| 645 | blr |
| 646 | |
| 647 | .globl dcache_disable |
| 648 | dcache_disable: |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 649 | mfspr r3,L1CSR0 |
| 650 | lis r4,0 |
| 651 | ori r4,r4,L1CSR0_DCE |
| 652 | andc r3,r3,r4 |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 653 | mtspr L1CSR0,r0 |
| 654 | isync |
| 655 | blr |
| 656 | |
| 657 | .globl dcache_status |
| 658 | dcache_status: |
| 659 | mfspr r3,L1CSR0 |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 660 | andi. r3,r3,L1CSR0_DCE |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 661 | blr |
| 662 | |
| 663 | .globl get_pir |
| 664 | get_pir: |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 665 | mfspr r3,PIR |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 666 | blr |
| 667 | |
| 668 | .globl get_pvr |
| 669 | get_pvr: |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 670 | mfspr r3,PVR |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 671 | blr |
| 672 | |
wdenk | 97d80fc | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 673 | .globl get_svr |
| 674 | get_svr: |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 675 | mfspr r3,SVR |
wdenk | 97d80fc | 2004-06-09 00:34:46 +0000 | [diff] [blame] | 676 | blr |
| 677 | |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 678 | .globl wr_tcr |
| 679 | wr_tcr: |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 680 | mtspr TCR,r3 |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 681 | blr |
| 682 | |
| 683 | /*------------------------------------------------------------------------------- */ |
| 684 | /* Function: in8 */ |
| 685 | /* Description: Input 8 bits */ |
| 686 | /*------------------------------------------------------------------------------- */ |
| 687 | .globl in8 |
| 688 | in8: |
| 689 | lbz r3,0x0000(r3) |
| 690 | blr |
| 691 | |
| 692 | /*------------------------------------------------------------------------------- */ |
| 693 | /* Function: out8 */ |
| 694 | /* Description: Output 8 bits */ |
| 695 | /*------------------------------------------------------------------------------- */ |
| 696 | .globl out8 |
| 697 | out8: |
| 698 | stb r4,0x0000(r3) |
Ed Swarthout | 1487adb | 2007-09-26 16:35:54 -0500 | [diff] [blame] | 699 | sync |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 700 | blr |
| 701 | |
| 702 | /*------------------------------------------------------------------------------- */ |
| 703 | /* Function: out16 */ |
| 704 | /* Description: Output 16 bits */ |
| 705 | /*------------------------------------------------------------------------------- */ |
| 706 | .globl out16 |
| 707 | out16: |
| 708 | sth r4,0x0000(r3) |
Ed Swarthout | 1487adb | 2007-09-26 16:35:54 -0500 | [diff] [blame] | 709 | sync |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 710 | blr |
| 711 | |
| 712 | /*------------------------------------------------------------------------------- */ |
| 713 | /* Function: out16r */ |
| 714 | /* Description: Byte reverse and output 16 bits */ |
| 715 | /*------------------------------------------------------------------------------- */ |
| 716 | .globl out16r |
| 717 | out16r: |
| 718 | sthbrx r4,r0,r3 |
Ed Swarthout | 1487adb | 2007-09-26 16:35:54 -0500 | [diff] [blame] | 719 | sync |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 720 | blr |
| 721 | |
| 722 | /*------------------------------------------------------------------------------- */ |
| 723 | /* Function: out32 */ |
| 724 | /* Description: Output 32 bits */ |
| 725 | /*------------------------------------------------------------------------------- */ |
| 726 | .globl out32 |
| 727 | out32: |
| 728 | stw r4,0x0000(r3) |
Ed Swarthout | 1487adb | 2007-09-26 16:35:54 -0500 | [diff] [blame] | 729 | sync |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 730 | blr |
| 731 | |
| 732 | /*------------------------------------------------------------------------------- */ |
| 733 | /* Function: out32r */ |
| 734 | /* Description: Byte reverse and output 32 bits */ |
| 735 | /*------------------------------------------------------------------------------- */ |
| 736 | .globl out32r |
| 737 | out32r: |
| 738 | stwbrx r4,r0,r3 |
Ed Swarthout | 1487adb | 2007-09-26 16:35:54 -0500 | [diff] [blame] | 739 | sync |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 740 | blr |
| 741 | |
| 742 | /*------------------------------------------------------------------------------- */ |
| 743 | /* Function: in16 */ |
| 744 | /* Description: Input 16 bits */ |
| 745 | /*------------------------------------------------------------------------------- */ |
| 746 | .globl in16 |
| 747 | in16: |
| 748 | lhz r3,0x0000(r3) |
| 749 | blr |
| 750 | |
| 751 | /*------------------------------------------------------------------------------- */ |
| 752 | /* Function: in16r */ |
| 753 | /* Description: Input 16 bits and byte reverse */ |
| 754 | /*------------------------------------------------------------------------------- */ |
| 755 | .globl in16r |
| 756 | in16r: |
| 757 | lhbrx r3,r0,r3 |
| 758 | blr |
| 759 | |
| 760 | /*------------------------------------------------------------------------------- */ |
| 761 | /* Function: in32 */ |
| 762 | /* Description: Input 32 bits */ |
| 763 | /*------------------------------------------------------------------------------- */ |
| 764 | .globl in32 |
| 765 | in32: |
| 766 | lwz 3,0x0000(3) |
| 767 | blr |
| 768 | |
| 769 | /*------------------------------------------------------------------------------- */ |
| 770 | /* Function: in32r */ |
| 771 | /* Description: Input 32 bits and byte reverse */ |
| 772 | /*------------------------------------------------------------------------------- */ |
| 773 | .globl in32r |
| 774 | in32r: |
| 775 | lwbrx r3,r0,r3 |
| 776 | blr |
| 777 | |
| 778 | /*------------------------------------------------------------------------------- */ |
| 779 | /* Function: ppcDcbf */ |
| 780 | /* Description: Data Cache block flush */ |
| 781 | /* Input: r3 = effective address */ |
| 782 | /* Output: none. */ |
| 783 | /*------------------------------------------------------------------------------- */ |
| 784 | .globl ppcDcbf |
| 785 | ppcDcbf: |
| 786 | dcbf r0,r3 |
| 787 | blr |
| 788 | |
| 789 | /*------------------------------------------------------------------------------- */ |
| 790 | /* Function: ppcDcbi */ |
| 791 | /* Description: Data Cache block Invalidate */ |
| 792 | /* Input: r3 = effective address */ |
| 793 | /* Output: none. */ |
| 794 | /*------------------------------------------------------------------------------- */ |
| 795 | .globl ppcDcbi |
| 796 | ppcDcbi: |
| 797 | dcbi r0,r3 |
| 798 | blr |
| 799 | |
wdenk | 0ac6f8b | 2004-07-09 23:27:13 +0000 | [diff] [blame] | 800 | /*-------------------------------------------------------------------------- |
| 801 | * Function: ppcDcbz |
| 802 | * Description: Data Cache block zero. |
| 803 | * Input: r3 = effective address |
| 804 | * Output: none. |
| 805 | *-------------------------------------------------------------------------- */ |
| 806 | |
| 807 | .globl ppcDcbz |
| 808 | ppcDcbz: |
| 809 | dcbz r0,r3 |
| 810 | blr |
| 811 | |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 812 | /*------------------------------------------------------------------------------- */ |
| 813 | /* Function: ppcSync */ |
| 814 | /* Description: Processor Synchronize */ |
| 815 | /* Input: none. */ |
| 816 | /* Output: none. */ |
| 817 | /*------------------------------------------------------------------------------- */ |
| 818 | .globl ppcSync |
| 819 | ppcSync: |
| 820 | sync |
| 821 | blr |
| 822 | |
| 823 | /*------------------------------------------------------------------------------*/ |
| 824 | |
| 825 | /* |
| 826 | * void relocate_code (addr_sp, gd, addr_moni) |
| 827 | * |
| 828 | * This "function" does not return, instead it continues in RAM |
| 829 | * after relocating the monitor code. |
| 830 | * |
| 831 | * r3 = dest |
| 832 | * r4 = src |
| 833 | * r5 = length in bytes |
| 834 | * r6 = cachelinesize |
| 835 | */ |
| 836 | .globl relocate_code |
| 837 | relocate_code: |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 838 | mr r1,r3 /* Set new stack pointer */ |
| 839 | mr r9,r4 /* Save copy of Init Data pointer */ |
| 840 | mr r10,r5 /* Save copy of Destination Address */ |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 841 | |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 842 | mr r3,r5 /* Destination Address */ |
| 843 | lis r4,CFG_MONITOR_BASE@h /* Source Address */ |
| 844 | ori r4,r4,CFG_MONITOR_BASE@l |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 845 | lwz r5,GOT(__init_end) |
| 846 | sub r5,r5,r4 |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 847 | li r6,CFG_CACHELINE_SIZE /* Cache Line Size */ |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 848 | |
| 849 | /* |
| 850 | * Fix GOT pointer: |
| 851 | * |
| 852 | * New GOT-PTR = (old GOT-PTR - CFG_MONITOR_BASE) + Destination Address |
| 853 | * |
| 854 | * Offset: |
| 855 | */ |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 856 | sub r15,r10,r4 |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 857 | |
| 858 | /* First our own GOT */ |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 859 | add r14,r14,r15 |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 860 | /* the the one used by the C code */ |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 861 | add r30,r30,r15 |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 862 | |
| 863 | /* |
| 864 | * Now relocate code |
| 865 | */ |
| 866 | |
| 867 | cmplw cr1,r3,r4 |
| 868 | addi r0,r5,3 |
| 869 | srwi. r0,r0,2 |
| 870 | beq cr1,4f /* In place copy is not necessary */ |
| 871 | beq 7f /* Protect against 0 count */ |
| 872 | mtctr r0 |
| 873 | bge cr1,2f |
| 874 | |
| 875 | la r8,-4(r4) |
| 876 | la r7,-4(r3) |
| 877 | 1: lwzu r0,4(r8) |
| 878 | stwu r0,4(r7) |
| 879 | bdnz 1b |
| 880 | b 4f |
| 881 | |
| 882 | 2: slwi r0,r0,2 |
| 883 | add r8,r4,r0 |
| 884 | add r7,r3,r0 |
| 885 | 3: lwzu r0,-4(r8) |
| 886 | stwu r0,-4(r7) |
| 887 | bdnz 3b |
| 888 | |
| 889 | /* |
| 890 | * Now flush the cache: note that we must start from a cache aligned |
| 891 | * address. Otherwise we might miss one cache line. |
| 892 | */ |
| 893 | 4: cmpwi r6,0 |
| 894 | add r5,r3,r5 |
| 895 | beq 7f /* Always flush prefetch queue in any case */ |
| 896 | subi r0,r6,1 |
| 897 | andc r3,r3,r0 |
| 898 | mr r4,r3 |
| 899 | 5: dcbst 0,r4 |
| 900 | add r4,r4,r6 |
| 901 | cmplw r4,r5 |
| 902 | blt 5b |
| 903 | sync /* Wait for all dcbst to complete on bus */ |
| 904 | mr r4,r3 |
| 905 | 6: icbi 0,r4 |
| 906 | add r4,r4,r6 |
| 907 | cmplw r4,r5 |
| 908 | blt 6b |
| 909 | 7: sync /* Wait for all icbi to complete on bus */ |
| 910 | isync |
| 911 | |
Wolfgang Denk | 7d31499 | 2005-10-05 00:00:54 +0200 | [diff] [blame] | 912 | /* |
| 913 | * Re-point the IVPR at RAM |
| 914 | */ |
| 915 | mtspr IVPR,r10 |
Wolfgang Denk | 99b0d28 | 2005-10-05 00:19:34 +0200 | [diff] [blame] | 916 | |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 917 | /* |
| 918 | * We are done. Do not return, instead branch to second part of board |
| 919 | * initialization, now running from RAM. |
| 920 | */ |
| 921 | |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 922 | addi r0,r10,in_ram - _start + _START_OFFSET |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 923 | mtlr r0 |
| 924 | blr /* NEVER RETURNS! */ |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 925 | .globl in_ram |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 926 | in_ram: |
| 927 | |
| 928 | /* |
| 929 | * Relocation Function, r14 point to got2+0x8000 |
| 930 | * |
| 931 | * Adjust got2 pointers, no need to check for 0, this code |
| 932 | * already puts a few entries in the table. |
| 933 | */ |
| 934 | li r0,__got2_entries@sectoff@l |
| 935 | la r3,GOT(_GOT2_TABLE_) |
| 936 | lwz r11,GOT(_GOT2_TABLE_) |
| 937 | mtctr r0 |
| 938 | sub r11,r3,r11 |
| 939 | addi r3,r3,-4 |
| 940 | 1: lwzu r0,4(r3) |
| 941 | add r0,r0,r11 |
| 942 | stw r0,0(r3) |
| 943 | bdnz 1b |
| 944 | |
| 945 | /* |
| 946 | * Now adjust the fixups and the pointers to the fixups |
| 947 | * in case we need to move ourselves again. |
| 948 | */ |
| 949 | 2: li r0,__fixup_entries@sectoff@l |
| 950 | lwz r3,GOT(_FIXUP_TABLE_) |
| 951 | cmpwi r0,0 |
| 952 | mtctr r0 |
| 953 | addi r3,r3,-4 |
| 954 | beq 4f |
| 955 | 3: lwzu r4,4(r3) |
| 956 | lwzux r0,r4,r11 |
| 957 | add r0,r0,r11 |
| 958 | stw r10,0(r3) |
| 959 | stw r0,0(r4) |
| 960 | bdnz 3b |
| 961 | 4: |
| 962 | clear_bss: |
| 963 | /* |
| 964 | * Now clear BSS segment |
| 965 | */ |
| 966 | lwz r3,GOT(__bss_start) |
| 967 | lwz r4,GOT(_end) |
| 968 | |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 969 | cmplw 0,r3,r4 |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 970 | beq 6f |
| 971 | |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 972 | li r0,0 |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 973 | 5: |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 974 | stw r0,0(r3) |
| 975 | addi r3,r3,4 |
| 976 | cmplw 0,r3,r4 |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 977 | bne 5b |
| 978 | 6: |
| 979 | |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 980 | mr r3,r9 /* Init Data pointer */ |
| 981 | mr r4,r10 /* Destination Address */ |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 982 | bl board_init_r |
| 983 | |
| 984 | /* |
| 985 | * Copy exception vector code to low memory |
| 986 | * |
| 987 | * r3: dest_addr |
| 988 | * r7: source address, r8: end address, r9: target address |
| 989 | */ |
wdenk | 343117b | 2005-05-13 22:49:36 +0000 | [diff] [blame] | 990 | .globl trap_init |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 991 | trap_init: |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 992 | lwz r7,GOT(_start_of_vectors) |
| 993 | lwz r8,GOT(_end_of_vectors) |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 994 | |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 995 | li r9,0x100 /* reset vector always at 0x100 */ |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 996 | |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 997 | cmplw 0,r7,r8 |
wdenk | 343117b | 2005-05-13 22:49:36 +0000 | [diff] [blame] | 998 | bgelr /* return if r7>=r8 - just in case */ |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 999 | |
wdenk | 343117b | 2005-05-13 22:49:36 +0000 | [diff] [blame] | 1000 | mflr r4 /* save link register */ |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 1001 | 1: |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 1002 | lwz r0,0(r7) |
| 1003 | stw r0,0(r9) |
| 1004 | addi r7,r7,4 |
| 1005 | addi r9,r9,4 |
| 1006 | cmplw 0,r7,r8 |
wdenk | 343117b | 2005-05-13 22:49:36 +0000 | [diff] [blame] | 1007 | bne 1b |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 1008 | |
| 1009 | /* |
| 1010 | * relocate `hdlr' and `int_return' entries |
| 1011 | */ |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 1012 | li r7,.L_CriticalInput - _start + _START_OFFSET |
wdenk | 343117b | 2005-05-13 22:49:36 +0000 | [diff] [blame] | 1013 | bl trap_reloc |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 1014 | li r7,.L_MachineCheck - _start + _START_OFFSET |
wdenk | 343117b | 2005-05-13 22:49:36 +0000 | [diff] [blame] | 1015 | bl trap_reloc |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 1016 | li r7,.L_DataStorage - _start + _START_OFFSET |
wdenk | 343117b | 2005-05-13 22:49:36 +0000 | [diff] [blame] | 1017 | bl trap_reloc |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 1018 | li r7,.L_InstStorage - _start + _START_OFFSET |
wdenk | 343117b | 2005-05-13 22:49:36 +0000 | [diff] [blame] | 1019 | bl trap_reloc |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 1020 | li r7,.L_ExtInterrupt - _start + _START_OFFSET |
wdenk | 343117b | 2005-05-13 22:49:36 +0000 | [diff] [blame] | 1021 | bl trap_reloc |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 1022 | li r7,.L_Alignment - _start + _START_OFFSET |
wdenk | 343117b | 2005-05-13 22:49:36 +0000 | [diff] [blame] | 1023 | bl trap_reloc |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 1024 | li r7,.L_ProgramCheck - _start + _START_OFFSET |
wdenk | 343117b | 2005-05-13 22:49:36 +0000 | [diff] [blame] | 1025 | bl trap_reloc |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 1026 | li r7,.L_FPUnavailable - _start + _START_OFFSET |
wdenk | 343117b | 2005-05-13 22:49:36 +0000 | [diff] [blame] | 1027 | bl trap_reloc |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 1028 | li r7,.L_Decrementer - _start + _START_OFFSET |
| 1029 | bl trap_reloc |
| 1030 | li r7,.L_IntervalTimer - _start + _START_OFFSET |
| 1031 | li r8,_end_of_vectors - _start + _START_OFFSET |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 1032 | 2: |
wdenk | 343117b | 2005-05-13 22:49:36 +0000 | [diff] [blame] | 1033 | bl trap_reloc |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 1034 | addi r7,r7,0x100 /* next exception vector */ |
| 1035 | cmplw 0,r7,r8 |
wdenk | 343117b | 2005-05-13 22:49:36 +0000 | [diff] [blame] | 1036 | blt 2b |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 1037 | |
wdenk | 343117b | 2005-05-13 22:49:36 +0000 | [diff] [blame] | 1038 | lis r7,0x0 |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 1039 | mtspr IVPR,r7 |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 1040 | |
wdenk | 343117b | 2005-05-13 22:49:36 +0000 | [diff] [blame] | 1041 | mtlr r4 /* restore link register */ |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 1042 | blr |
| 1043 | |
| 1044 | /* |
| 1045 | * Function: relocate entries for one exception vector |
| 1046 | */ |
| 1047 | trap_reloc: |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 1048 | lwz r0,0(r7) /* hdlr ... */ |
| 1049 | add r0,r0,r3 /* ... += dest_addr */ |
| 1050 | stw r0,0(r7) |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 1051 | |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 1052 | lwz r0,4(r7) /* int_return ... */ |
| 1053 | add r0,r0,r3 /* ... += dest_addr */ |
| 1054 | stw r0,4(r7) |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 1055 | |
| 1056 | blr |
| 1057 | |
| 1058 | #ifdef CFG_INIT_RAM_LOCK |
| 1059 | .globl unlock_ram_in_cache |
| 1060 | unlock_ram_in_cache: |
| 1061 | /* invalidate the INIT_RAM section */ |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 1062 | lis r3,(CFG_INIT_RAM_ADDR & ~31)@h |
| 1063 | ori r3,r3,(CFG_INIT_RAM_ADDR & ~31)@l |
Kumar Gala | e1ce3cb | 2007-10-02 11:12:27 -0500 | [diff] [blame] | 1064 | li r4,(CFG_DCACHE_SIZE / (2 * CFG_CACHELINE_SIZE)) |
Andy Fleming | 61a21e9 | 2007-08-14 01:34:21 -0500 | [diff] [blame] | 1065 | mtctr r4 |
| 1066 | 1: icbi r0,r3 |
| 1067 | dcbi r0,r3 |
Kumar Gala | e1ce3cb | 2007-10-02 11:12:27 -0500 | [diff] [blame] | 1068 | addi r3,r3,CFG_CACHELINE_SIZE |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 1069 | bdnz 1b |
wdenk | 343117b | 2005-05-13 22:49:36 +0000 | [diff] [blame] | 1070 | sync /* Wait for all icbi to complete on bus */ |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 1071 | isync |
| 1072 | blr |
| 1073 | #endif |