Blame view
arch/arm/cpu/arm926ejs/start.S
7.58 KB
6f21347d4 * Patch by George... |
1 2 3 4 5 |
/* * armboot - Startup Code for ARM926EJS CPU-core * * Copyright (c) 2003 Texas Instruments * |
a56bd9228 * Patch by Dave P... |
6 |
* ----- Adapted for OMAP1610 OMAP730 from ARM925t code ------ |
6f21347d4 * Patch by George... |
7 |
* |
fa82f871c Convert ISO-8859 ... |
8 9 |
* Copyright (c) 2001 Marius Gröger <mag@sysgo.de> * Copyright (c) 2002 Alex Züpke <azu@sysgo.de> |
792a09eb9 Fix e-mail addres... |
10 |
* Copyright (c) 2002 Gary Jennejohn <garyj@denx.de> |
6f21347d4 * Patch by George... |
11 12 |
* Copyright (c) 2003 Richard Woodruff <r-woodruff2@ti.com> * Copyright (c) 2003 Kshitij <kshitij@ti.com> |
57b4bce99 Replace obsolete ... |
13 |
* Copyright (c) 2010 Albert Aribaud <albert.u.boot@aribaud.net> |
6f21347d4 * Patch by George... |
14 |
* |
1a4596601 Add GPL-2.0+ SPDX... |
15 |
* SPDX-License-Identifier: GPL-2.0+ |
6f21347d4 * Patch by George... |
16 |
*/ |
25ddd1fb0 Replace CONFIG_SY... |
17 |
#include <asm-offsets.h> |
6f21347d4 * Patch by George... |
18 |
#include <config.h> |
fcd3c87e4 Make include/comm... |
19 |
#include <common.h> |
6f21347d4 * Patch by George... |
20 |
#include <version.h> |
6f21347d4 * Patch by George... |
21 22 23 24 25 26 27 |
/* ************************************************************************* * * Jump vector table as in table 3.1 in [1] * ************************************************************************* */ |
337c43338 arm, davinci: add... |
28 |
#ifdef CONFIG_SYS_DV_NOR_BOOT_CFG |
6f21347d4 * Patch by George... |
29 30 |
.globl _start _start: |
337c43338 arm, davinci: add... |
31 32 33 |
.globl _NOR_BOOT_CFG _NOR_BOOT_CFG: .word CONFIG_SYS_DV_NOR_BOOT_CFG |
6f21347d4 * Patch by George... |
34 |
b reset |
337c43338 arm, davinci: add... |
35 36 37 38 39 |
#else .globl _start _start: b reset #endif |
401bb30b6 replace CONFIG_PR... |
40 |
#ifdef CONFIG_SPL_BUILD |
ef22b5037 arm926ejs: add na... |
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
/* No exception handlers in preloader */ ldr pc, _hang ldr pc, _hang ldr pc, _hang ldr pc, _hang ldr pc, _hang ldr pc, _hang ldr pc, _hang _hang: .word do_hang /* pad to 64 byte boundary */ .word 0x12345678 .word 0x12345678 .word 0x12345678 .word 0x12345678 .word 0x12345678 .word 0x12345678 .word 0x12345678 #else |
6f21347d4 * Patch by George... |
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
ldr pc, _undefined_instruction ldr pc, _software_interrupt ldr pc, _prefetch_abort ldr pc, _data_abort ldr pc, _not_used ldr pc, _irq ldr pc, _fiq _undefined_instruction: .word undefined_instruction _software_interrupt: .word software_interrupt _prefetch_abort: .word prefetch_abort _data_abort: .word data_abort _not_used: .word not_used _irq: .word irq _fiq: .word fiq |
401bb30b6 replace CONFIG_PR... |
83 |
#endif /* CONFIG_SPL_BUILD */ |
6f21347d4 * Patch by George... |
84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
.balignl 16,0xdeadbeef /* ************************************************************************* * * Startup Code (reset vector) * * do important init only if we don't start from memory! * setup Memory and board specific bits prior to relocation. * relocate armboot to ram * setup stack * ************************************************************************* */ |
6f21347d4 * Patch by George... |
99 100 101 102 103 104 105 106 107 108 109 |
#ifdef CONFIG_USE_IRQ /* IRQ stack memory (calculated at run-time) */ .globl IRQ_STACK_START IRQ_STACK_START: .word 0x0badc0de /* IRQ stack memory (calculated at run-time) */ .globl FIQ_STACK_START FIQ_STACK_START: .word 0x0badc0de #endif |
ab86f72c3 ARM: implement re... |
110 111 112 113 |
/* IRQ stack memory (calculated at run-time) + 8 bytes */ .globl IRQ_STACK_START_IN IRQ_STACK_START_IN: .word 0x0badc0de |
6f21347d4 * Patch by George... |
114 115 116 117 118 119 120 121 122 123 124 125 |
/* * the actual reset code */ reset: /* * set the cpu to SVC32 mode */ mrs r0,cpsr bic r0,r0,#0x1f orr r0,r0,#0xd3 msr cpsr,r0 |
6f21347d4 * Patch by George... |
126 |
/* |
a8c7c708a * Patch by Gleb N... |
127 128 |
* we do sys-critical inits only at reboot, * not when booting from ram! |
6f21347d4 * Patch by George... |
129 |
*/ |
27b66622b arm, arm926ejs: D... |
130 |
#ifndef CONFIG_SKIP_LOWLEVEL_INIT |
a8c7c708a * Patch by Gleb N... |
131 |
bl cpu_init_crit |
27b66622b arm, arm926ejs: D... |
132 |
#endif |
a8c7c708a * Patch by Gleb N... |
133 |
|
e05e5de7f arm: move C runti... |
134 |
bl _main |
ab86f72c3 ARM: implement re... |
135 136 |
/*------------------------------------------------------------------------------*/ |
e05e5de7f arm: move C runti... |
137 138 139 140 |
.globl c_runtime_cpu_setup c_runtime_cpu_setup: bx lr |
6f21347d4 * Patch by George... |
141 142 143 144 145 146 147 148 149 150 |
/* ************************************************************************* * * CPU_init_critical registers * * setup important registers * setup memory timing * ************************************************************************* */ |
27b66622b arm, arm926ejs: D... |
151 |
#ifndef CONFIG_SKIP_LOWLEVEL_INIT |
6f21347d4 * Patch by George... |
152 153 |
cpu_init_crit: /* |
da104e04e arm, arm926ejs: F... |
154 |
* flush D cache before disabling it |
6f21347d4 * Patch by George... |
155 156 |
*/ mov r0, #0 |
da104e04e arm, arm926ejs: F... |
157 158 159 160 161 162 |
flush_dcache: mrc p15, 0, r15, c7, c10, 3 bne flush_dcache mcr p15, 0, r0, c8, c7, 0 /* invalidate TLB */ mcr p15, 0, r0, c7, c5, 0 /* invalidate I Cache */ |
6f21347d4 * Patch by George... |
163 164 |
/* |
d735a99d3 arm, arm926ejs: E... |
165 166 |
* disable MMU and D cache * enable I cache if CONFIG_SYS_ICACHE_OFF is not defined |
6f21347d4 * Patch by George... |
167 168 |
*/ mrc p15, 0, r0, c1, c0, 0 |
b67d8816f arm, arm926ejs: A... |
169 |
bic r0, r0, #0x00000300 /* clear bits 9:8 (---- --RS) */ |
6f21347d4 * Patch by George... |
170 |
bic r0, r0, #0x00000087 /* clear bits 7, 2:0 (B--- -CAM) */ |
b67d8816f arm, arm926ejs: A... |
171 172 173 174 175 |
#ifdef CONFIG_SYS_EXCEPTION_VECTORS_HIGH orr r0, r0, #0x00002000 /* set bit 13 (--V- ----) */ #else bic r0, r0, #0x00002000 /* clear bit 13 (--V- ----) */ #endif |
6f21347d4 * Patch by George... |
176 |
orr r0, r0, #0x00000002 /* set bit 2 (A) Align */ |
d735a99d3 arm, arm926ejs: E... |
177 |
#ifndef CONFIG_SYS_ICACHE_OFF |
6f21347d4 * Patch by George... |
178 |
orr r0, r0, #0x00001000 /* set bit 12 (I) I-Cache */ |
d735a99d3 arm, arm926ejs: E... |
179 |
#endif |
6f21347d4 * Patch by George... |
180 181 182 183 184 185 |
mcr p15, 0, r0, c1, c0, 0 /* * Go setup Memory and board specific bits prior to relocation. */ mov ip, lr /* perserve link reg across call */ |
87cb6862b Update make targe... |
186 |
bl lowlevel_init /* go setup pll,mux,memory */ |
6f21347d4 * Patch by George... |
187 |
mov lr, ip /* restore link */ |
ca4b55800 arm, arm926ejs: a... |
188 |
mov pc, lr /* back to my caller */ |
27b66622b arm, arm926ejs: D... |
189 |
#endif /* CONFIG_SKIP_LOWLEVEL_INIT */ |
a6cdd21b5 Fix arm926ejs com... |
190 |
|
401bb30b6 replace CONFIG_PR... |
191 |
#ifndef CONFIG_SPL_BUILD |
6f21347d4 * Patch by George... |
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 |
/* ************************************************************************* * * Interrupt handling * ************************************************************************* */ @ @ IRQ stack frame. @ #define S_FRAME_SIZE 72 #define S_OLD_R0 68 #define S_PSR 64 #define S_PC 60 #define S_LR 56 #define S_SP 52 #define S_IP 48 #define S_FP 44 #define S_R10 40 #define S_R9 36 #define S_R8 32 #define S_R7 28 #define S_R6 24 #define S_R5 20 #define S_R4 16 #define S_R3 12 #define S_R2 8 #define S_R1 4 #define S_R0 0 #define MODE_SVC 0x13 #define I_BIT 0x80 /* * use bad_save_user_regs for abort/prefetch/undef/swi ... * use irq_save_user_regs / irq_restore_user_regs for IRQ/FIQ handling */ .macro bad_save_user_regs @ carve out a frame on current user stack sub sp, sp, #S_FRAME_SIZE stmia sp, {r0 - r12} @ Save user registers (now in svc mode) r0-r12 |
ab86f72c3 ARM: implement re... |
237 |
ldr r2, IRQ_STACK_START_IN |
6f21347d4 * Patch by George... |
238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 |
@ get values for "aborted" pc and cpsr (into parm regs) ldmia r2, {r2 - r3} add r0, sp, #S_FRAME_SIZE @ grab pointer to old stack add r5, sp, #S_SP mov r1, lr stmia r5, {r0 - r3} @ save sp_SVC, lr_SVC, pc, cpsr mov r0, sp @ save current stack into r0 (param register) .endm .macro irq_save_user_regs sub sp, sp, #S_FRAME_SIZE stmia sp, {r0 - r12} @ Calling r0-r12 @ !!!! R8 NEEDS to be saved !!!! a reserved stack spot would be good. add r8, sp, #S_PC stmdb r8, {sp, lr}^ @ Calling SP, LR str lr, [r8, #0] @ Save calling PC mrs r6, spsr str r6, [r8, #4] @ Save CPSR str r0, [r8, #8] @ Save OLD_R0 mov r0, sp .endm .macro irq_restore_user_regs ldmia sp, {r0 - lr}^ @ Calling r0 - lr mov r0, r0 ldr lr, [sp, #S_PC] @ Get PC add sp, sp, #S_FRAME_SIZE subs pc, lr, #4 @ return & move spsr_svc into cpsr .endm .macro get_bad_stack |
ab86f72c3 ARM: implement re... |
269 |
ldr r13, IRQ_STACK_START_IN @ setup our mode stack |
6f21347d4 * Patch by George... |
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 |
str lr, [r13] @ save caller lr in position 0 of saved stack mrs lr, spsr @ get the spsr str lr, [r13, #4] @ save spsr in position 1 of saved stack mov r13, #MODE_SVC @ prepare SVC-Mode @ msr spsr_c, r13 msr spsr, r13 @ switch modes, make sure moves will execute mov lr, pc @ capture return pc movs pc, lr @ jump to next instruction & switch modes. .endm .macro get_irq_stack @ setup IRQ stack ldr sp, IRQ_STACK_START .endm .macro get_fiq_stack @ setup FIQ stack ldr sp, FIQ_STACK_START .endm |
401bb30b6 replace CONFIG_PR... |
288 |
#endif /* CONFIG_SPL_BUILD */ |
6f21347d4 * Patch by George... |
289 290 291 292 |
/* * exception handlers */ |
401bb30b6 replace CONFIG_PR... |
293 |
#ifdef CONFIG_SPL_BUILD |
ef22b5037 arm926ejs: add na... |
294 295 |
.align 5 do_hang: |
ef22b5037 arm926ejs: add na... |
296 297 |
1: bl 1b /* hang and never return */ |
401bb30b6 replace CONFIG_PR... |
298 |
#else /* !CONFIG_SPL_BUILD */ |
6f21347d4 * Patch by George... |
299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 |
.align 5 undefined_instruction: get_bad_stack bad_save_user_regs bl do_undefined_instruction .align 5 software_interrupt: get_bad_stack bad_save_user_regs bl do_software_interrupt .align 5 prefetch_abort: get_bad_stack bad_save_user_regs bl do_prefetch_abort .align 5 data_abort: get_bad_stack bad_save_user_regs bl do_data_abort .align 5 not_used: get_bad_stack bad_save_user_regs bl do_not_used #ifdef CONFIG_USE_IRQ .align 5 irq: get_irq_stack irq_save_user_regs |
53677ef18 Big white-space c... |
335 |
bl do_irq |
6f21347d4 * Patch by George... |
336 337 338 339 340 341 342 |
irq_restore_user_regs .align 5 fiq: get_fiq_stack /* someone ought to write a more effiction fiq_save_user_regs */ irq_save_user_regs |
53677ef18 Big white-space c... |
343 |
bl do_fiq |
6f21347d4 * Patch by George... |
344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 |
irq_restore_user_regs #else .align 5 irq: get_bad_stack bad_save_user_regs bl do_irq .align 5 fiq: get_bad_stack bad_save_user_regs bl do_fiq #endif |
401bb30b6 replace CONFIG_PR... |
361 |
#endif /* CONFIG_SPL_BUILD */ |