wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 1 | /* |
Marek Vasut | 20f7b1b | 2011-10-31 14:12:39 +0100 | [diff] [blame] | 2 | * armboot - Startup Code for XScale CPU-core |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 3 | * |
| 4 | * Copyright (C) 1998 Dan Malek <dmalek@jlc.net> |
| 5 | * Copyright (C) 1999 Magnus Damm <kieraypc01.p.y.kie.era.ericsson.se> |
| 6 | * Copyright (C) 2000 Wolfgang Denk <wd@denx.de> |
wdenk | a8c7c70 | 2003-12-06 19:49:23 +0000 | [diff] [blame] | 7 | * Copyright (C) 2001 Alex Zuepke <azu@sysgo.de> |
Marek Vasut | 20f7b1b | 2011-10-31 14:12:39 +0100 | [diff] [blame] | 8 | * Copyright (C) 2001 Marius Groger <mag@sysgo.de> |
| 9 | * Copyright (C) 2002 Alex Zupke <azu@sysgo.de> |
| 10 | * Copyright (C) 2002 Gary Jennejohn <garyj@denx.de> |
wdenk | 1cb8e98 | 2003-03-06 21:55:29 +0000 | [diff] [blame] | 11 | * Copyright (C) 2002 Kyle Harris <kharris@nexus-tech.net> |
Wolfgang Denk | 951a954 | 2006-03-06 23:18:48 +0100 | [diff] [blame] | 12 | * Copyright (C) 2003 Kai-Uwe Bloem <kai-uwe.bloem@auerswald.de> |
Marek Vasut | 20f7b1b | 2011-10-31 14:12:39 +0100 | [diff] [blame] | 13 | * Copyright (C) 2003 Kshitij <kshitij@ti.com> |
| 14 | * Copyright (C) 2003 Richard Woodruff <r-woodruff2@ti.com> |
| 15 | * Copyright (C) 2003 Robert Schwebel <r.schwebel@pengutronix.de> |
| 16 | * Copyright (C) 2004 Texas Instruments <r-woodruff2@ti.com> |
| 17 | * Copyright (C) 2010 Marek Vasut <marek.vasut@gmail.com> |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 18 | * |
Wolfgang Denk | 3765b3e | 2013-10-07 13:07:26 +0200 | [diff] [blame^] | 19 | * SPDX-License-Identifier: GPL-2.0+ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 20 | */ |
| 21 | |
Wolfgang Denk | 25ddd1f | 2010-10-26 14:34:52 +0200 | [diff] [blame] | 22 | #include <asm-offsets.h> |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 23 | #include <config.h> |
| 24 | #include <version.h> |
Marek Vasut | 7f4cfcf | 2011-11-05 19:26:47 +0100 | [diff] [blame] | 25 | |
Marek Vasut | abc20ab | 2011-11-26 07:20:07 +0100 | [diff] [blame] | 26 | #ifdef CONFIG_CPU_PXA25X |
Marek Vasut | 7f4cfcf | 2011-11-05 19:26:47 +0100 | [diff] [blame] | 27 | #if ((CONFIG_SYS_INIT_SP_ADDR) != 0xfffff800) |
| 28 | #error "Init SP address must be set to 0xfffff800 for PXA250" |
| 29 | #endif |
| 30 | #endif |
| 31 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 32 | .globl _start |
wdenk | 384ae02 | 2002-11-05 00:17:55 +0000 | [diff] [blame] | 33 | _start: b reset |
Aneesh V | 401bb30 | 2011-07-13 05:11:07 +0000 | [diff] [blame] | 34 | #ifdef CONFIG_SPL_BUILD |
Marek Vasut | 5ab877b | 2010-07-06 02:48:35 +0200 | [diff] [blame] | 35 | ldr pc, _hang |
| 36 | ldr pc, _hang |
| 37 | ldr pc, _hang |
| 38 | ldr pc, _hang |
| 39 | ldr pc, _hang |
| 40 | ldr pc, _hang |
| 41 | ldr pc, _hang |
| 42 | |
| 43 | _hang: |
| 44 | .word do_hang |
| 45 | .word 0x12345678 |
| 46 | .word 0x12345678 |
| 47 | .word 0x12345678 |
| 48 | .word 0x12345678 |
| 49 | .word 0x12345678 |
| 50 | .word 0x12345678 |
| 51 | .word 0x12345678 /* now 16*4=64 */ |
| 52 | #else |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 53 | ldr pc, _undefined_instruction |
| 54 | ldr pc, _software_interrupt |
| 55 | ldr pc, _prefetch_abort |
| 56 | ldr pc, _data_abort |
| 57 | ldr pc, _not_used |
| 58 | ldr pc, _irq |
| 59 | ldr pc, _fiq |
| 60 | |
wdenk | 384ae02 | 2002-11-05 00:17:55 +0000 | [diff] [blame] | 61 | _undefined_instruction: .word undefined_instruction |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 62 | _software_interrupt: .word software_interrupt |
| 63 | _prefetch_abort: .word prefetch_abort |
| 64 | _data_abort: .word data_abort |
| 65 | _not_used: .word not_used |
| 66 | _irq: .word irq |
| 67 | _fiq: .word fiq |
Marek Vasut | 20f7b1b | 2011-10-31 14:12:39 +0100 | [diff] [blame] | 68 | _pad: .word 0x12345678 /* now 16*4=64 */ |
Aneesh V | 401bb30 | 2011-07-13 05:11:07 +0000 | [diff] [blame] | 69 | #endif /* CONFIG_SPL_BUILD */ |
Marek Vasut | 20f7b1b | 2011-10-31 14:12:39 +0100 | [diff] [blame] | 70 | .global _end_vect |
| 71 | _end_vect: |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 72 | |
| 73 | .balignl 16,0xdeadbeef |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 74 | /* |
Marek Vasut | 20f7b1b | 2011-10-31 14:12:39 +0100 | [diff] [blame] | 75 | ************************************************************************* |
| 76 | * |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 77 | * Startup Code (reset vector) |
| 78 | * |
Marek Vasut | 20f7b1b | 2011-10-31 14:12:39 +0100 | [diff] [blame] | 79 | * do important init only if we don't start from memory! |
| 80 | * setup Memory and board specific bits prior to relocation. |
| 81 | * relocate armboot to ram |
| 82 | * setup stack |
| 83 | * |
| 84 | ************************************************************************* |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 85 | */ |
| 86 | |
Heiko Schocher | 5347f68 | 2010-09-17 13:10:46 +0200 | [diff] [blame] | 87 | .globl _TEXT_BASE |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 88 | _TEXT_BASE: |
Benoît Thébaudeau | 508611b | 2013-04-11 09:35:42 +0000 | [diff] [blame] | 89 | #if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_TEXT_BASE) |
Marek Vasut | 20f7b1b | 2011-10-31 14:12:39 +0100 | [diff] [blame] | 90 | .word CONFIG_SPL_TEXT_BASE |
| 91 | #else |
Wolfgang Denk | 14d0a02 | 2010-10-07 21:51:12 +0200 | [diff] [blame] | 92 | .word CONFIG_SYS_TEXT_BASE |
Marek Vasut | 20f7b1b | 2011-10-31 14:12:39 +0100 | [diff] [blame] | 93 | #endif |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 94 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 95 | /* |
wdenk | f6e20fc | 2004-02-08 19:38:38 +0000 | [diff] [blame] | 96 | * These are defined in the board-specific linker script. |
Marek Vasut | 20f7b1b | 2011-10-31 14:12:39 +0100 | [diff] [blame] | 97 | * Subtracting _start from them lets the linker put their |
| 98 | * relative position in the executable instead of leaving |
| 99 | * them null. |
wdenk | 47cd00f | 2003-03-06 13:39:27 +0000 | [diff] [blame] | 100 | */ |
Marek Vasut | 6e96cf9 | 2010-10-20 19:36:39 +0200 | [diff] [blame] | 101 | .globl _bss_start_ofs |
| 102 | _bss_start_ofs: |
| 103 | .word __bss_start - _start |
wdenk | 47cd00f | 2003-03-06 13:39:27 +0000 | [diff] [blame] | 104 | |
Marek Vasut | 6e96cf9 | 2010-10-20 19:36:39 +0200 | [diff] [blame] | 105 | .globl _bss_end_ofs |
| 106 | _bss_end_ofs: |
Simon Glass | 3929fb0 | 2013-03-14 06:54:53 +0000 | [diff] [blame] | 107 | .word __bss_end - _start |
wdenk | 47cd00f | 2003-03-06 13:39:27 +0000 | [diff] [blame] | 108 | |
Po-Yu Chuang | f326cbb | 2011-03-01 23:02:04 +0000 | [diff] [blame] | 109 | .globl _end_ofs |
| 110 | _end_ofs: |
| 111 | .word _end - _start |
| 112 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 113 | #ifdef CONFIG_USE_IRQ |
| 114 | /* IRQ stack memory (calculated at run-time) */ |
| 115 | .globl IRQ_STACK_START |
| 116 | IRQ_STACK_START: |
| 117 | .word 0x0badc0de |
| 118 | |
| 119 | /* IRQ stack memory (calculated at run-time) */ |
| 120 | .globl FIQ_STACK_START |
| 121 | FIQ_STACK_START: |
| 122 | .word 0x0badc0de |
Marek Vasut | 20f7b1b | 2011-10-31 14:12:39 +0100 | [diff] [blame] | 123 | #endif |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 124 | |
Heiko Schocher | 5347f68 | 2010-09-17 13:10:46 +0200 | [diff] [blame] | 125 | /* IRQ stack memory (calculated at run-time) + 8 bytes */ |
| 126 | .globl IRQ_STACK_START_IN |
| 127 | IRQ_STACK_START_IN: |
| 128 | .word 0x0badc0de |
| 129 | |
Heiko Schocher | 5347f68 | 2010-09-17 13:10:46 +0200 | [diff] [blame] | 130 | /* |
| 131 | * the actual reset code |
| 132 | */ |
| 133 | |
| 134 | reset: |
| 135 | /* |
| 136 | * set the cpu to SVC32 mode |
| 137 | */ |
| 138 | mrs r0,cpsr |
| 139 | bic r0,r0,#0x1f |
| 140 | orr r0,r0,#0xd3 |
| 141 | msr cpsr,r0 |
| 142 | |
Marek Vasut | 20f7b1b | 2011-10-31 14:12:39 +0100 | [diff] [blame] | 143 | #ifndef CONFIG_SKIP_LOWLEVEL_INIT |
| 144 | bl cpu_init_crit |
| 145 | #endif |
Heiko Schocher | 5347f68 | 2010-09-17 13:10:46 +0200 | [diff] [blame] | 146 | |
Marek Vasut | abc20ab | 2011-11-26 07:20:07 +0100 | [diff] [blame] | 147 | #ifdef CONFIG_CPU_PXA25X |
Marek Vasut | 7f4cfcf | 2011-11-05 19:26:47 +0100 | [diff] [blame] | 148 | bl lock_cache_for_stack |
| 149 | #endif |
| 150 | |
Albert ARIBAUD | e05e5de | 2013-01-08 10:18:02 +0000 | [diff] [blame] | 151 | bl _main |
Heiko Schocher | 5347f68 | 2010-09-17 13:10:46 +0200 | [diff] [blame] | 152 | |
| 153 | /*------------------------------------------------------------------------------*/ |
Albert ARIBAUD | e05e5de | 2013-01-08 10:18:02 +0000 | [diff] [blame] | 154 | |
| 155 | .globl c_runtime_cpu_setup |
| 156 | c_runtime_cpu_setup: |
| 157 | |
Albert ARIBAUD | 3da0e57 | 2013-05-19 01:48:15 +0000 | [diff] [blame] | 158 | #ifdef CONFIG_CPU_PXA25X |
| 159 | /* |
| 160 | * Unlock (actually, disable) the cache now that board_init_f |
| 161 | * is done. We could do this earlier but we would need to add |
| 162 | * a new C runtime hook, whereas c_runtime_cpu_setup already |
| 163 | * exists. |
| 164 | * As this routine is just a call to cpu_init_crit, let us |
| 165 | * tail-optimize and do a simple branch here. |
| 166 | */ |
| 167 | b cpu_init_crit |
| 168 | #else |
Albert ARIBAUD | e05e5de | 2013-01-08 10:18:02 +0000 | [diff] [blame] | 169 | bx lr |
Albert ARIBAUD | 3da0e57 | 2013-05-19 01:48:15 +0000 | [diff] [blame] | 170 | #endif |
Albert ARIBAUD | e05e5de | 2013-01-08 10:18:02 +0000 | [diff] [blame] | 171 | |
Marek Vasut | 20f7b1b | 2011-10-31 14:12:39 +0100 | [diff] [blame] | 172 | /* |
| 173 | ************************************************************************* |
| 174 | * |
| 175 | * CPU_init_critical registers |
| 176 | * |
| 177 | * setup important registers |
| 178 | * setup memory timing |
| 179 | * |
| 180 | ************************************************************************* |
| 181 | */ |
Marek Vasut | abc20ab | 2011-11-26 07:20:07 +0100 | [diff] [blame] | 182 | #if !defined(CONFIG_SKIP_LOWLEVEL_INIT) || defined(CONFIG_CPU_PXA25X) |
Marek Vasut | 20f7b1b | 2011-10-31 14:12:39 +0100 | [diff] [blame] | 183 | cpu_init_crit: |
| 184 | /* |
| 185 | * flush v4 I/D caches |
| 186 | */ |
| 187 | mov r0, #0 |
| 188 | mcr p15, 0, r0, c7, c7, 0 /* Invalidate I+D+BTB caches */ |
| 189 | mcr p15, 0, r0, c8, c7, 0 /* Invalidate Unified TLB */ |
Marek Vasut | 2cad92f | 2010-09-28 15:44:10 +0200 | [diff] [blame] | 190 | |
Marek Vasut | 20f7b1b | 2011-10-31 14:12:39 +0100 | [diff] [blame] | 191 | /* |
| 192 | * disable MMU stuff and caches |
| 193 | */ |
| 194 | mrc p15, 0, r0, c1, c0, 0 |
Mike Dunn | 097d86d | 2013-06-17 10:47:28 -0700 | [diff] [blame] | 195 | bic r0, r0, #0x00003300 @ clear bits 13:12, 9:8 (--VI --RS) |
Marek Vasut | 20f7b1b | 2011-10-31 14:12:39 +0100 | [diff] [blame] | 196 | bic r0, r0, #0x00000087 @ clear bits 7, 2:0 (B--- -CAM) |
| 197 | orr r0, r0, #0x00000002 @ set bit 2 (A) Align |
Marek Vasut | 20f7b1b | 2011-10-31 14:12:39 +0100 | [diff] [blame] | 198 | mcr p15, 0, r0, c1, c0, 0 |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 199 | |
Marek Vasut | 20f7b1b | 2011-10-31 14:12:39 +0100 | [diff] [blame] | 200 | mov pc, lr /* back to my caller */ |
Marek Vasut | abc20ab | 2011-11-26 07:20:07 +0100 | [diff] [blame] | 201 | #endif /* !CONFIG_SKIP_LOWLEVEL_INIT || CONFIG_CPU_PXA25X */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 202 | |
Aneesh V | 401bb30 | 2011-07-13 05:11:07 +0000 | [diff] [blame] | 203 | #ifndef CONFIG_SPL_BUILD |
Marek Vasut | 20f7b1b | 2011-10-31 14:12:39 +0100 | [diff] [blame] | 204 | /* |
| 205 | ************************************************************************* |
| 206 | * |
| 207 | * Interrupt handling |
| 208 | * |
| 209 | ************************************************************************* |
| 210 | */ |
| 211 | @ |
| 212 | @ IRQ stack frame. |
| 213 | @ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 214 | #define S_FRAME_SIZE 72 |
| 215 | |
| 216 | #define S_OLD_R0 68 |
| 217 | #define S_PSR 64 |
| 218 | #define S_PC 60 |
| 219 | #define S_LR 56 |
| 220 | #define S_SP 52 |
| 221 | |
| 222 | #define S_IP 48 |
| 223 | #define S_FP 44 |
| 224 | #define S_R10 40 |
| 225 | #define S_R9 36 |
| 226 | #define S_R8 32 |
| 227 | #define S_R7 28 |
| 228 | #define S_R6 24 |
| 229 | #define S_R5 20 |
| 230 | #define S_R4 16 |
| 231 | #define S_R3 12 |
| 232 | #define S_R2 8 |
| 233 | #define S_R1 4 |
| 234 | #define S_R0 0 |
| 235 | |
| 236 | #define MODE_SVC 0x13 |
Marek Vasut | 20f7b1b | 2011-10-31 14:12:39 +0100 | [diff] [blame] | 237 | #define I_BIT 0x80 |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 238 | |
Marek Vasut | 20f7b1b | 2011-10-31 14:12:39 +0100 | [diff] [blame] | 239 | /* |
| 240 | * use bad_save_user_regs for abort/prefetch/undef/swi ... |
| 241 | * use irq_save_user_regs / irq_restore_user_regs for IRQ/FIQ handling |
| 242 | */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 243 | |
| 244 | .macro bad_save_user_regs |
Marek Vasut | 20f7b1b | 2011-10-31 14:12:39 +0100 | [diff] [blame] | 245 | sub sp, sp, #S_FRAME_SIZE @ carve out a frame on current user stack |
| 246 | stmia sp, {r0 - r12} @ Save user registers (now in svc mode) r0-r12 |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 247 | |
Marek Vasut | 20f7b1b | 2011-10-31 14:12:39 +0100 | [diff] [blame] | 248 | ldr r2, IRQ_STACK_START_IN @ set base 2 words into abort stack |
| 249 | ldmia r2, {r2 - r3} @ get values for "aborted" pc and cpsr (into parm regs) |
| 250 | add r0, sp, #S_FRAME_SIZE @ grab pointer to old stack |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 251 | |
| 252 | add r5, sp, #S_SP |
| 253 | mov r1, lr |
Marek Vasut | 20f7b1b | 2011-10-31 14:12:39 +0100 | [diff] [blame] | 254 | stmia r5, {r0 - r3} @ save sp_SVC, lr_SVC, pc, cpsr |
| 255 | mov r0, sp @ save current stack into r0 (param register) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 256 | .endm |
| 257 | |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 258 | .macro irq_save_user_regs |
| 259 | sub sp, sp, #S_FRAME_SIZE |
Marek Vasut | 20f7b1b | 2011-10-31 14:12:39 +0100 | [diff] [blame] | 260 | stmia sp, {r0 - r12} @ Calling r0-r12 |
| 261 | add r8, sp, #S_PC @ !!!! R8 NEEDS to be saved !!!! a reserved stack spot would be good. |
| 262 | stmdb r8, {sp, lr}^ @ Calling SP, LR |
| 263 | str lr, [r8, #0] @ Save calling PC |
wdenk | 384ae02 | 2002-11-05 00:17:55 +0000 | [diff] [blame] | 264 | mrs r6, spsr |
Marek Vasut | 20f7b1b | 2011-10-31 14:12:39 +0100 | [diff] [blame] | 265 | str r6, [r8, #4] @ Save CPSR |
| 266 | str r0, [r8, #8] @ Save OLD_R0 |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 267 | mov r0, sp |
| 268 | .endm |
| 269 | |
| 270 | .macro irq_restore_user_regs |
| 271 | ldmia sp, {r0 - lr}^ @ Calling r0 - lr |
| 272 | mov r0, r0 |
| 273 | ldr lr, [sp, #S_PC] @ Get PC |
| 274 | add sp, sp, #S_FRAME_SIZE |
| 275 | subs pc, lr, #4 @ return & move spsr_svc into cpsr |
| 276 | .endm |
| 277 | |
| 278 | .macro get_bad_stack |
Marek Vasut | 20f7b1b | 2011-10-31 14:12:39 +0100 | [diff] [blame] | 279 | ldr r13, IRQ_STACK_START_IN @ setup our mode stack (enter in banked mode) |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 280 | |
Marek Vasut | 20f7b1b | 2011-10-31 14:12:39 +0100 | [diff] [blame] | 281 | str lr, [r13] @ save caller lr in position 0 of saved stack |
| 282 | mrs lr, spsr @ get the spsr |
| 283 | str lr, [r13, #4] @ save spsr in position 1 of saved stack |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 284 | |
| 285 | mov r13, #MODE_SVC @ prepare SVC-Mode |
Marek Vasut | 20f7b1b | 2011-10-31 14:12:39 +0100 | [diff] [blame] | 286 | @ msr spsr_c, r13 |
| 287 | msr spsr, r13 @ switch modes, make sure moves will execute |
| 288 | mov lr, pc @ capture return pc |
| 289 | movs pc, lr @ jump to next instruction & switch modes. |
| 290 | .endm |
| 291 | |
| 292 | .macro get_bad_stack_swi |
| 293 | sub r13, r13, #4 @ space on current stack for scratch reg. |
| 294 | str r0, [r13] @ save R0's value. |
| 295 | ldr r0, IRQ_STACK_START_IN @ get data regions start |
| 296 | str lr, [r0] @ save caller lr in position 0 of saved stack |
Tetsuyuki Kobayashi | 4411b2a | 2013-04-05 00:12:51 +0000 | [diff] [blame] | 297 | mrs lr, spsr @ get the spsr |
Marek Vasut | 20f7b1b | 2011-10-31 14:12:39 +0100 | [diff] [blame] | 298 | str lr, [r0, #4] @ save spsr in position 1 of saved stack |
Tetsuyuki Kobayashi | 4411b2a | 2013-04-05 00:12:51 +0000 | [diff] [blame] | 299 | ldr lr, [r0] @ restore lr |
Marek Vasut | 20f7b1b | 2011-10-31 14:12:39 +0100 | [diff] [blame] | 300 | ldr r0, [r13] @ restore r0 |
| 301 | add r13, r13, #4 @ pop stack entry |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 302 | .endm |
| 303 | |
| 304 | .macro get_irq_stack @ setup IRQ stack |
| 305 | ldr sp, IRQ_STACK_START |
| 306 | .endm |
| 307 | |
| 308 | .macro get_fiq_stack @ setup FIQ stack |
| 309 | ldr sp, FIQ_STACK_START |
| 310 | .endm |
Marek Vasut | 20f7b1b | 2011-10-31 14:12:39 +0100 | [diff] [blame] | 311 | #endif /* CONFIG_SPL_BUILD */ |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 312 | |
Marek Vasut | 20f7b1b | 2011-10-31 14:12:39 +0100 | [diff] [blame] | 313 | /* |
| 314 | * exception handlers |
| 315 | */ |
Aneesh V | 401bb30 | 2011-07-13 05:11:07 +0000 | [diff] [blame] | 316 | #ifdef CONFIG_SPL_BUILD |
Marek Vasut | 5ab877b | 2010-07-06 02:48:35 +0200 | [diff] [blame] | 317 | .align 5 |
| 318 | do_hang: |
Marek Vasut | 20f7b1b | 2011-10-31 14:12:39 +0100 | [diff] [blame] | 319 | ldr sp, _TEXT_BASE /* use 32 words about stack */ |
Marek Vasut | 5ab877b | 2010-07-06 02:48:35 +0200 | [diff] [blame] | 320 | bl hang /* hang and never return */ |
Marek Vasut | 20f7b1b | 2011-10-31 14:12:39 +0100 | [diff] [blame] | 321 | #else /* !CONFIG_SPL_BUILD */ |
wdenk | 384ae02 | 2002-11-05 00:17:55 +0000 | [diff] [blame] | 322 | .align 5 |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 323 | undefined_instruction: |
| 324 | get_bad_stack |
| 325 | bad_save_user_regs |
wdenk | 384ae02 | 2002-11-05 00:17:55 +0000 | [diff] [blame] | 326 | bl do_undefined_instruction |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 327 | |
| 328 | .align 5 |
| 329 | software_interrupt: |
Marek Vasut | 20f7b1b | 2011-10-31 14:12:39 +0100 | [diff] [blame] | 330 | get_bad_stack_swi |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 331 | bad_save_user_regs |
wdenk | 384ae02 | 2002-11-05 00:17:55 +0000 | [diff] [blame] | 332 | bl do_software_interrupt |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 333 | |
| 334 | .align 5 |
| 335 | prefetch_abort: |
| 336 | get_bad_stack |
| 337 | bad_save_user_regs |
wdenk | 384ae02 | 2002-11-05 00:17:55 +0000 | [diff] [blame] | 338 | bl do_prefetch_abort |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 339 | |
| 340 | .align 5 |
| 341 | data_abort: |
| 342 | get_bad_stack |
| 343 | bad_save_user_regs |
wdenk | 384ae02 | 2002-11-05 00:17:55 +0000 | [diff] [blame] | 344 | bl do_data_abort |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 345 | |
| 346 | .align 5 |
| 347 | not_used: |
| 348 | get_bad_stack |
| 349 | bad_save_user_regs |
wdenk | 384ae02 | 2002-11-05 00:17:55 +0000 | [diff] [blame] | 350 | bl do_not_used |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 351 | |
| 352 | #ifdef CONFIG_USE_IRQ |
| 353 | |
| 354 | .align 5 |
| 355 | irq: |
| 356 | get_irq_stack |
| 357 | irq_save_user_regs |
wdenk | 384ae02 | 2002-11-05 00:17:55 +0000 | [diff] [blame] | 358 | bl do_irq |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 359 | irq_restore_user_regs |
| 360 | |
| 361 | .align 5 |
| 362 | fiq: |
| 363 | get_fiq_stack |
Marek Vasut | 20f7b1b | 2011-10-31 14:12:39 +0100 | [diff] [blame] | 364 | /* someone ought to write a more effiction fiq_save_user_regs */ |
| 365 | irq_save_user_regs |
| 366 | bl do_fiq |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 367 | irq_restore_user_regs |
| 368 | |
Marek Vasut | 20f7b1b | 2011-10-31 14:12:39 +0100 | [diff] [blame] | 369 | #else |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 370 | |
| 371 | .align 5 |
| 372 | irq: |
| 373 | get_bad_stack |
| 374 | bad_save_user_regs |
wdenk | 384ae02 | 2002-11-05 00:17:55 +0000 | [diff] [blame] | 375 | bl do_irq |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 376 | |
| 377 | .align 5 |
| 378 | fiq: |
| 379 | get_bad_stack |
| 380 | bad_save_user_regs |
wdenk | 384ae02 | 2002-11-05 00:17:55 +0000 | [diff] [blame] | 381 | bl do_fiq |
wdenk | c609719 | 2002-11-03 00:24:07 +0000 | [diff] [blame] | 382 | |
Marek Vasut | 20f7b1b | 2011-10-31 14:12:39 +0100 | [diff] [blame] | 383 | #endif |
| 384 | .align 5 |
Aneesh V | 401bb30 | 2011-07-13 05:11:07 +0000 | [diff] [blame] | 385 | #endif /* CONFIG_SPL_BUILD */ |
Marek Vasut | 7f4cfcf | 2011-11-05 19:26:47 +0100 | [diff] [blame] | 386 | |
| 387 | |
| 388 | /* |
| 389 | * Enable MMU to use DCache as DRAM. |
| 390 | * |
| 391 | * This is useful on PXA25x and PXA26x in early bootstages, where there is no |
| 392 | * other possible memory available to hold stack. |
| 393 | */ |
Marek Vasut | abc20ab | 2011-11-26 07:20:07 +0100 | [diff] [blame] | 394 | #ifdef CONFIG_CPU_PXA25X |
Marek Vasut | 7f4cfcf | 2011-11-05 19:26:47 +0100 | [diff] [blame] | 395 | .macro CPWAIT reg |
| 396 | mrc p15, 0, \reg, c2, c0, 0 |
| 397 | mov \reg, \reg |
| 398 | sub pc, pc, #4 |
| 399 | .endm |
| 400 | lock_cache_for_stack: |
| 401 | /* Domain access -- enable for all CPs */ |
| 402 | ldr r0, =0x0000ffff |
| 403 | mcr p15, 0, r0, c3, c0, 0 |
| 404 | |
| 405 | /* Point TTBR to MMU table */ |
| 406 | ldr r0, =mmutable |
| 407 | mcr p15, 0, r0, c2, c0, 0 |
| 408 | |
| 409 | /* Kick in MMU, ICache, DCache, BTB */ |
| 410 | mrc p15, 0, r0, c1, c0, 0 |
| 411 | bic r0, #0x1b00 |
| 412 | bic r0, #0x0087 |
| 413 | orr r0, #0x1800 |
| 414 | orr r0, #0x0005 |
| 415 | mcr p15, 0, r0, c1, c0, 0 |
| 416 | CPWAIT r0 |
| 417 | |
| 418 | /* Unlock Icache, Dcache */ |
| 419 | mcr p15, 0, r0, c9, c1, 1 |
| 420 | mcr p15, 0, r0, c9, c2, 1 |
| 421 | |
| 422 | /* Flush Icache, Dcache, BTB */ |
| 423 | mcr p15, 0, r0, c7, c7, 0 |
| 424 | |
| 425 | /* Unlock I-TLB, D-TLB */ |
| 426 | mcr p15, 0, r0, c10, c4, 1 |
| 427 | mcr p15, 0, r0, c10, c8, 1 |
| 428 | |
| 429 | /* Flush TLB */ |
| 430 | mcr p15, 0, r0, c8, c7, 0 |
| 431 | |
| 432 | /* Allocate 4096 bytes of Dcache as RAM */ |
| 433 | |
| 434 | /* Drain pending loads and stores */ |
| 435 | mcr p15, 0, r0, c7, c10, 4 |
| 436 | |
| 437 | mov r4, #0x00 |
| 438 | mov r5, #0x00 |
| 439 | mov r2, #0x01 |
| 440 | mcr p15, 0, r0, c9, c2, 0 |
| 441 | CPWAIT r0 |
| 442 | |
| 443 | /* 128 lines reserved (128 x 32bytes = 4096 bytes total) */ |
| 444 | mov r0, #128 |
| 445 | ldr r1, =0xfffff000 |
| 446 | |
| 447 | alloc: |
| 448 | mcr p15, 0, r1, c7, c2, 5 |
| 449 | /* Drain pending loads and stores */ |
| 450 | mcr p15, 0, r0, c7, c10, 4 |
| 451 | strd r4, [r1], #8 |
| 452 | strd r4, [r1], #8 |
| 453 | strd r4, [r1], #8 |
| 454 | strd r4, [r1], #8 |
| 455 | subs r0, #0x01 |
| 456 | bne alloc |
| 457 | /* Drain pending loads and stores */ |
| 458 | mcr p15, 0, r0, c7, c10, 4 |
| 459 | mov r2, #0x00 |
| 460 | mcr p15, 0, r2, c9, c2, 0 |
| 461 | CPWAIT r0 |
| 462 | |
| 463 | mov pc, lr |
| 464 | |
| 465 | .section .mmutable, "a" |
| 466 | mmutable: |
| 467 | .align 14 |
| 468 | /* 0x00000000 - 0xffe00000 : 1:1, uncached mapping */ |
| 469 | .set __base, 0 |
| 470 | .rept 0xfff |
| 471 | .word (__base << 20) | 0xc12 |
| 472 | .set __base, __base + 1 |
| 473 | .endr |
| 474 | |
| 475 | /* 0xfff00000 : 1:1, cached mapping */ |
| 476 | .word (0xfff << 20) | 0x1c1e |
Marek Vasut | abc20ab | 2011-11-26 07:20:07 +0100 | [diff] [blame] | 477 | #endif /* CONFIG_CPU_PXA25X */ |