2 * armboot - Startup Code for ARM926EJS CPU-core
4 * Copyright (c) 2003 Texas Instruments
6 * ----- Adapted for OMAP1610 OMAP730 from ARM925t code ------
8 * Copyright (c) 2001 Marius Gröger <mag@sysgo.de>
9 * Copyright (c) 2002 Alex Züpke <azu@sysgo.de>
10 * Copyright (c) 2002 Gary Jennejohn <garyj@denx.de>
11 * Copyright (c) 2003 Richard Woodruff <r-woodruff2@ti.com>
12 * Copyright (c) 2003 Kshitij <kshitij@ti.com>
14 * SPDX-License-Identifier: GPL-2.0+
17 #include <asm-offsets.h>
22 *************************************************************************
26 *************************************************************************
32 ldr pc, _undefined_instruction
33 ldr pc, _software_interrupt
34 ldr pc, _prefetch_abort
40 _undefined_instruction:
41 .word undefined_instruction
43 .word software_interrupt
55 .balignl 16,0xdeadbeef
58 *************************************************************************
60 * Startup Code (reset vector)
62 * do important init only if we don't start from memory!
63 * setup memory and board specific bits prior to relocation.
64 * relocate armboot to ram
67 *************************************************************************
71 /* IRQ stack memory (calculated at run-time) */
72 .globl IRQ_STACK_START
76 /* IRQ stack memory (calculated at run-time) */
77 .globl FIQ_STACK_START
82 /* IRQ stack memory (calculated at run-time) + 8 bytes */
83 .globl IRQ_STACK_START_IN
88 * the actual reset code
93 * set the cpu to SVC32 mode
101 * we do sys-critical inits only at reboot,
102 * not when booting from ram!
104 #ifndef CONFIG_SKIP_LOWLEVEL_INIT
110 /*------------------------------------------------------------------------------*/
112 .globl c_runtime_cpu_setup
118 *************************************************************************
120 * CPU_init_critical registers
122 * setup important registers
123 * setup memory timing
125 *************************************************************************
128 #ifndef CONFIG_SKIP_LOWLEVEL_INIT
130 /* arm_int_generic assumes the ARM boot monitor, or user software,
131 * has initialized the platform
133 mov pc, lr /* back to my caller */
136 *************************************************************************
140 *************************************************************************
146 #define S_FRAME_SIZE 72
168 #define MODE_SVC 0x13
172 * use bad_save_user_regs for abort/prefetch/undef/swi ...
173 * use irq_save_user_regs / irq_restore_user_regs for IRQ/FIQ handling
176 .macro bad_save_user_regs
177 @ carve out a frame on current user stack
178 sub sp, sp, #S_FRAME_SIZE
179 stmia sp, {r0 - r12} @ Save user registers (now in svc mode) r0-r12
181 ldr r2, IRQ_STACK_START_IN
182 @ get values for "aborted" pc and cpsr (into parm regs)
184 add r0, sp, #S_FRAME_SIZE @ grab pointer to old stack
187 stmia r5, {r0 - r3} @ save sp_SVC, lr_SVC, pc, cpsr
188 mov r0, sp @ save current stack into r0 (param register)
191 .macro irq_save_user_regs
192 sub sp, sp, #S_FRAME_SIZE
193 stmia sp, {r0 - r12} @ Calling r0-r12
194 @ !!!! R8 NEEDS to be saved !!!! a reserved stack spot would be good.
196 stmdb r8, {sp, lr}^ @ Calling SP, LR
197 str lr, [r8, #0] @ Save calling PC
199 str r6, [r8, #4] @ Save CPSR
200 str r0, [r8, #8] @ Save OLD_R0
204 .macro irq_restore_user_regs
205 ldmia sp, {r0 - lr}^ @ Calling r0 - lr
207 ldr lr, [sp, #S_PC] @ Get PC
208 add sp, sp, #S_FRAME_SIZE
209 subs pc, lr, #4 @ return & move spsr_svc into cpsr
213 ldr r13, IRQ_STACK_START_IN @ setup our mode stack
215 str lr, [r13] @ save caller lr in position 0 of saved stack
216 mrs lr, spsr @ get the spsr
217 str lr, [r13, #4] @ save spsr in position 1 of saved stack
218 mov r13, #MODE_SVC @ prepare SVC-Mode
220 msr spsr, r13 @ switch modes, make sure moves will execute
221 mov lr, pc @ capture return pc
222 movs pc, lr @ jump to next instruction & switch modes.
225 .macro get_irq_stack @ setup IRQ stack
226 ldr sp, IRQ_STACK_START
229 .macro get_fiq_stack @ setup FIQ stack
230 ldr sp, FIQ_STACK_START
237 .globl undefined_instruction
238 undefined_instruction:
241 bl do_undefined_instruction
244 .globl software_interrupt
248 bl do_software_interrupt
251 .globl prefetch_abort
271 #ifdef CONFIG_USE_IRQ
278 irq_restore_user_regs
284 /* someone ought to write a more effiction fiq_save_user_regs */
287 irq_restore_user_regs