2 * armboot - Startup Code for ARM720 CPU-core
4 * Copyright (c) 2001 Marius Gröger <mag@sysgo.de>
5 * Copyright (c) 2002 Alex Züpke <azu@sysgo.de>
7 * SPDX-License-Identifier: GPL-2.0+
10 #include <asm-offsets.h>
13 #include <asm/hardware.h>
16 *************************************************************************
18 * Jump vector table as in table 3.1 in [1]
20 *************************************************************************
26 ldr pc, _undefined_instruction
27 ldr pc, _software_interrupt
28 ldr pc, _prefetch_abort
34 #ifdef CONFIG_SPL_BUILD
35 _undefined_instruction: .word _undefined_instruction
36 _software_interrupt: .word _software_interrupt
37 _prefetch_abort: .word _prefetch_abort
38 _data_abort: .word _data_abort
39 _not_used: .word _not_used
42 _pad: .word 0x12345678 /* now 16*4=64 */
44 _undefined_instruction: .word undefined_instruction
45 _software_interrupt: .word software_interrupt
46 _prefetch_abort: .word prefetch_abort
47 _data_abort: .word data_abort
48 _not_used: .word not_used
51 _pad: .word 0x12345678 /* now 16*4=64 */
52 #endif /* CONFIG_SPL_BUILD */
54 .balignl 16,0xdeadbeef
58 *************************************************************************
60 * Startup Code (reset vector)
62 * do important init only if we don't start from RAM!
63 * relocate armboot to ram
65 * jump to second stage
67 *************************************************************************
72 #if defined(CONFIG_SPL_BUILD) && defined(CONFIG_SPL_TEXT_BASE)
73 .word CONFIG_SPL_TEXT_BASE
75 .word CONFIG_SYS_TEXT_BASE
79 * These are defined in the board-specific linker script.
80 * Subtracting _start from them lets the linker put their
81 * relative position in the executable instead of leaving
86 .word __bss_start - _start
90 .word __bss_end - _start
97 /* IRQ stack memory (calculated at run-time) */
98 .globl IRQ_STACK_START
102 /* IRQ stack memory (calculated at run-time) */
103 .globl FIQ_STACK_START
108 /* IRQ stack memory (calculated at run-time) + 8 bytes */
109 .globl IRQ_STACK_START_IN
114 * the actual reset code
119 * set the cpu to SVC32 mode
127 * we do sys-critical inits only at reboot,
128 * not when booting from ram!
130 #ifndef CONFIG_SKIP_LOWLEVEL_INIT
136 /*------------------------------------------------------------------------------*/
138 .globl c_runtime_cpu_setup
144 *************************************************************************
146 * CPU_init_critical registers
148 * setup important registers
149 * setup memory timing
151 *************************************************************************
154 #ifndef CONFIG_SKIP_LOWLEVEL_INIT
159 * before relocating, we have to setup RAM timing
160 * because memory timing is board-dependent, you will
161 * find a lowlevel_init.S in your board directory.
167 #endif /* CONFIG_SKIP_LOWLEVEL_INIT */
170 #ifndef CONFIG_SPL_BUILD
172 *************************************************************************
176 *************************************************************************
182 #define S_FRAME_SIZE 72
204 #define MODE_SVC 0x13
208 * use bad_save_user_regs for abort/prefetch/undef/swi ...
209 * use irq_save_user_regs / irq_restore_user_regs for IRQ/FIQ handling
212 .macro bad_save_user_regs
213 sub sp, sp, #S_FRAME_SIZE
214 stmia sp, {r0 - r12} @ Calling r0-r12
217 ldr r2, IRQ_STACK_START_IN
218 ldmia r2, {r2 - r4} @ get pc, cpsr, old_r0
219 add r0, sp, #S_FRAME_SIZE @ restore sp_SVC
223 stmia r5, {r0 - r4} @ save sp_SVC, lr_SVC, pc, cpsr, old_r
227 .macro irq_save_user_regs
228 sub sp, sp, #S_FRAME_SIZE
229 stmia sp, {r0 - r12} @ Calling r0-r12
231 stmdb r8, {sp, lr}^ @ Calling SP, LR
232 str lr, [r8, #0] @ Save calling PC
234 str r6, [r8, #4] @ Save CPSR
235 str r0, [r8, #8] @ Save OLD_R0
239 .macro irq_restore_user_regs
240 ldmia sp, {r0 - lr}^ @ Calling r0 - lr
242 ldr lr, [sp, #S_PC] @ Get PC
243 add sp, sp, #S_FRAME_SIZE
244 subs pc, lr, #4 @ return & move spsr_svc into cpsr
248 ldr r13, IRQ_STACK_START_IN @ setup our mode stack
250 str lr, [r13] @ save caller lr / spsr
254 mov r13, #MODE_SVC @ prepare SVC-Mode
260 .macro get_irq_stack @ setup IRQ stack
261 ldr sp, IRQ_STACK_START
264 .macro get_fiq_stack @ setup FIQ stack
265 ldr sp, FIQ_STACK_START
272 undefined_instruction:
275 bl do_undefined_instruction
281 bl do_software_interrupt
301 #ifdef CONFIG_USE_IRQ
308 irq_restore_user_regs
313 /* someone ought to write a more effiction fiq_save_user_regs */
316 irq_restore_user_regs
333 #endif /* CONFIG_SPL_BUILD */