blob: 218cca3b40013a742658e282595e4a00a31d1ff3 [file] [log] [blame]
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +02001/*
2 * Copyright (c) 2018, Arm Limited. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <asm_macros.S>
8
9 .globl tftf_vector
10
Sandrine Bailleuxa43b0032019-01-14 14:04:32 +010011/*
12 * Exception vector code for unhandled exceptions.
13 * Print a crash dump on the UART and loops forever.
14 */
Sandrine Bailleuxe7604492019-01-14 09:37:28 +010015.macro unhandled_exception name
16 vector_entry \name
Sandrine Bailleuxa43b0032019-01-14 14:04:32 +010017 b crash_dump
Sandrine Bailleuxe7604492019-01-14 09:37:28 +010018 end_vector_entry \name
19.endm
20
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020021vector_base tftf_vector
Sandrine Bailleux8b170a22019-01-11 18:47:26 +010022
23 /*
24 * Current EL with SP0 : 0x0 - 0x200.
25 */
Daniel Boulby08798ac2021-04-06 14:30:19 +010026unhandled_exception sync_exception_sp_el0
27unhandled_exception irq_sp_el0
28unhandled_exception fiq_sp_el0
29unhandled_exception serror_sp_el0
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020030
Sandrine Bailleux8b170a22019-01-11 18:47:26 +010031 /*
32 * Current EL with SPx : 0x200 - 0x400.
33 */
Daniel Boulby08798ac2021-04-06 14:30:19 +010034unhandled_exception sync_exception_sp_elx
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020035
Daniel Boulby08798ac2021-04-06 14:30:19 +010036vector_entry irq_sp_elx
Sandrine Bailleuxd1019672019-01-11 18:39:24 +010037 b irq_vector_entry
Daniel Boulby08798ac2021-04-06 14:30:19 +010038end_vector_entry irq_sp_elx
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020039
Daniel Boulby08798ac2021-04-06 14:30:19 +010040unhandled_exception fiq_sp_elx
41unhandled_exception serror_sp_elx
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020042
Sandrine Bailleux8b170a22019-01-11 18:47:26 +010043 /*
44 * Lower EL using AArch64 : 0x400 - 0x600.
45 */
Daniel Boulby08798ac2021-04-06 14:30:19 +010046unhandled_exception sync_exception_aarch64
47unhandled_exception irq_aarch64
48unhandled_exception fiq_aarch64
49unhandled_exception serror_aarch64
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020050
Sandrine Bailleux8b170a22019-01-11 18:47:26 +010051 /*
52 * Lower EL using AArch32 : 0x600 - 0x800.
53 */
Daniel Boulby08798ac2021-04-06 14:30:19 +010054unhandled_exception sync_exception_aarch32
55unhandled_exception irq_aarch32
56unhandled_exception fiq_aarch32
57unhandled_exception serror_aarch32
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020058
Sandrine Bailleuxd1019672019-01-11 18:39:24 +010059.macro save_gp_regs
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020060 stp x0, x1, [sp, #0x0]
61 stp x2, x3, [sp, #0x10]
62 stp x4, x5, [sp, #0x20]
63 stp x6, x7, [sp, #0x30]
64 stp x8, x9, [sp, #0x40]
65 stp x10, x11, [sp, #0x50]
66 stp x12, x13, [sp, #0x60]
67 stp x14, x15, [sp, #0x70]
68 stp x16, x17, [sp, #0x80]
69 stp x18, x19, [sp, #0x90]
70 stp x20, x21, [sp, #0xa0]
71 stp x22, x23, [sp, #0xb0]
72 stp x24, x25, [sp, #0xc0]
73 stp x26, x27, [sp, #0xd0]
Sandrine Bailleuxd1019672019-01-11 18:39:24 +010074 stp x28, x29, [sp, #0xe0]
Sandrine Bailleuxa43b0032019-01-14 14:04:32 +010075 /* We push xzr simply to keep the stack 16-byte aligned. */
76 stp x30, xzr, [sp, #0xf0]
Sandrine Bailleuxd1019672019-01-11 18:39:24 +010077.endm
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020078
Sandrine Bailleuxd1019672019-01-11 18:39:24 +010079.macro restore_gp_regs
Sandrine Bailleuxa43b0032019-01-14 14:04:32 +010080 ldp x30, xzr, [sp, #0xf0]
Sandrine Bailleuxd1019672019-01-11 18:39:24 +010081 ldp x28, x29, [sp, #0xe0]
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020082 ldp x26, x27, [sp, #0xd0]
83 ldp x24, x25, [sp, #0xc0]
84 ldp x22, x23, [sp, #0xb0]
85 ldp x20, x21, [sp, #0xa0]
86 ldp x18, x19, [sp, #0x90]
87 ldp x16, x17, [sp, #0x80]
88 ldp x14, x15, [sp, #0x70]
89 ldp x12, x13, [sp, #0x60]
90 ldp x10, x11, [sp, #0x50]
91 ldp x8, x9, [sp, #0x40]
92 ldp x6, x7, [sp, #0x30]
93 ldp x4, x5, [sp, #0x20]
94 ldp x2, x3, [sp, #0x10]
95 ldp x0, x1, [sp, #0x0]
Sandrine Bailleuxd1019672019-01-11 18:39:24 +010096.endm
97
98func irq_vector_entry
99 sub sp, sp, #0x100
100 save_gp_regs
101 bl tftf_irq_handler_dispatcher
102 restore_gp_regs
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200103 add sp, sp, #0x100
Sandrine Bailleuxd1019672019-01-11 18:39:24 +0100104 eret
105endfunc irq_vector_entry
Sandrine Bailleuxa43b0032019-01-14 14:04:32 +0100106
107func crash_dump
108 /* Save general-purpose registers on the stack. */
109 sub sp, sp, #0x100
110 save_gp_regs
111
112 /* Save original stack pointer value on the stack. */
113 add x1, sp, #0x100
114 str x1, [sp, #0xf8]
115
116 /* Print the saved CPU context on the UART. */
117 mov x0, sp
118 b print_exception
119endfunc crash_dump