blob: 37c5218b7eafe8909ff107dcbef28c47699145ce [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 Bailleuxe7604492019-01-14 09:37:28 +010011/* Exception vector code for unhandled exceptions. Loops forever. */
12.macro unhandled_exception name
13 vector_entry \name
14 b \name
15 end_vector_entry \name
16.endm
17
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020018vector_base tftf_vector
Sandrine Bailleux8b170a22019-01-11 18:47:26 +010019
20 /*
21 * Current EL with SP0 : 0x0 - 0x200.
22 */
Sandrine Bailleuxe7604492019-01-14 09:37:28 +010023unhandled_exception SynchronousExceptionSP0
24unhandled_exception IrqSP0
25unhandled_exception FiqSP0
26unhandled_exception SErrorSP0
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020027
Sandrine Bailleux8b170a22019-01-11 18:47:26 +010028 /*
29 * Current EL with SPx : 0x200 - 0x400.
30 */
Sandrine Bailleuxe7604492019-01-14 09:37:28 +010031unhandled_exception SynchronousExceptionSPx
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020032
33vector_entry IrqSPx
Sandrine Bailleuxd1019672019-01-11 18:39:24 +010034 b irq_vector_entry
Sandrine Bailleux452f3602019-01-14 13:49:22 +010035end_vector_entry IrqSPx
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020036
Sandrine Bailleuxe7604492019-01-14 09:37:28 +010037unhandled_exception FiqSPx
38unhandled_exception SErrorSPx
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020039
Sandrine Bailleux8b170a22019-01-11 18:47:26 +010040 /*
41 * Lower EL using AArch64 : 0x400 - 0x600.
42 */
Sandrine Bailleuxe7604492019-01-14 09:37:28 +010043unhandled_exception SynchronousExceptionA64
44unhandled_exception IrqA64
45unhandled_exception FiqA64
46unhandled_exception SErrorA64
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020047
Sandrine Bailleux8b170a22019-01-11 18:47:26 +010048 /*
49 * Lower EL using AArch32 : 0x600 - 0x800.
50 */
Sandrine Bailleuxe7604492019-01-14 09:37:28 +010051unhandled_exception SynchronousExceptionA32
52unhandled_exception IrqA32
53unhandled_exception FiqA32
54unhandled_exception SErrorA32
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020055
Sandrine Bailleuxd1019672019-01-11 18:39:24 +010056/*
57 * Exceptions will always be from the same exception level so no need to save
58 * and restore SPSR.
59 */
60.macro save_gp_regs
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020061 stp x0, x1, [sp, #0x0]
62 stp x2, x3, [sp, #0x10]
63 stp x4, x5, [sp, #0x20]
64 stp x6, x7, [sp, #0x30]
65 stp x8, x9, [sp, #0x40]
66 stp x10, x11, [sp, #0x50]
67 stp x12, x13, [sp, #0x60]
68 stp x14, x15, [sp, #0x70]
69 stp x16, x17, [sp, #0x80]
70 stp x18, x19, [sp, #0x90]
71 stp x20, x21, [sp, #0xa0]
72 stp x22, x23, [sp, #0xb0]
73 stp x24, x25, [sp, #0xc0]
74 stp x26, x27, [sp, #0xd0]
Sandrine Bailleuxd1019672019-01-11 18:39:24 +010075 stp x28, x29, [sp, #0xe0]
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020076 mrs x0, sp_el0
Sandrine Bailleuxd1019672019-01-11 18:39:24 +010077 stp x30, x0, [sp, #0xf0]
78.endm
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020079
Sandrine Bailleuxd1019672019-01-11 18:39:24 +010080.macro restore_gp_regs
81 ldp x30, x0, [sp, #0xf0]
82 msr sp_el0, x0
83 ldp x28, x29, [sp, #0xe0]
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020084 ldp x26, x27, [sp, #0xd0]
85 ldp x24, x25, [sp, #0xc0]
86 ldp x22, x23, [sp, #0xb0]
87 ldp x20, x21, [sp, #0xa0]
88 ldp x18, x19, [sp, #0x90]
89 ldp x16, x17, [sp, #0x80]
90 ldp x14, x15, [sp, #0x70]
91 ldp x12, x13, [sp, #0x60]
92 ldp x10, x11, [sp, #0x50]
93 ldp x8, x9, [sp, #0x40]
94 ldp x6, x7, [sp, #0x30]
95 ldp x4, x5, [sp, #0x20]
96 ldp x2, x3, [sp, #0x10]
97 ldp x0, x1, [sp, #0x0]
Sandrine Bailleuxd1019672019-01-11 18:39:24 +010098.endm
99
100func irq_vector_entry
101 sub sp, sp, #0x100
102 save_gp_regs
103 bl tftf_irq_handler_dispatcher
104 restore_gp_regs
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +0200105 add sp, sp, #0x100
Sandrine Bailleuxd1019672019-01-11 18:39:24 +0100106 eret
107endfunc irq_vector_entry