blob: 41be653a462b2c47304bdab1a505c82bd5a7a995 [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
11vector_base tftf_vector
Sandrine Bailleux8b170a22019-01-11 18:47:26 +010012
13 /*
14 * Current EL with SP0 : 0x0 - 0x200.
15 */
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020016vector_entry SynchronousExceptionSP0
17 b SynchronousExceptionSP0
Sandrine Bailleux452f3602019-01-14 13:49:22 +010018end_vector_entry SynchronousExceptionSP0
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020019
20vector_entry IrqSP0
21 b IrqSP0
Sandrine Bailleux452f3602019-01-14 13:49:22 +010022end_vector_entry IrqSP0
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020023
24vector_entry FiqSP0
25 b FiqSP0
Sandrine Bailleux452f3602019-01-14 13:49:22 +010026end_vector_entry FiqSP0
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020027
28vector_entry SErrorSP0
29 b SErrorSP0
Sandrine Bailleux452f3602019-01-14 13:49:22 +010030end_vector_entry SErrorSP0
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020031
Sandrine Bailleux8b170a22019-01-11 18:47:26 +010032 /*
33 * Current EL with SPx : 0x200 - 0x400.
34 */
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020035vector_entry SynchronousExceptionSPx
36 b SynchronousExceptionSPx
Sandrine Bailleux452f3602019-01-14 13:49:22 +010037end_vector_entry SynchronousExceptionSPx
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020038
39vector_entry IrqSPx
40 /*
41 * TODO: Investigate whether the Trusted Firmware-A code for context
42 * save/restore could be reused
43 */
44 stp x29, x30, [sp, #-0x10]!
45 bl save_regs
46 bl tftf_irq_handler_dispatcher
47 bl restore_regs
48 ldp x29, x30, [sp], #0x10
49 eret
Sandrine Bailleux452f3602019-01-14 13:49:22 +010050end_vector_entry IrqSPx
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020051
52vector_entry FiqSPx
53 b FiqSPx
Sandrine Bailleux452f3602019-01-14 13:49:22 +010054end_vector_entry FiqSPx
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020055
56vector_entry SErrorSPx
57 b SErrorSPx
Sandrine Bailleux452f3602019-01-14 13:49:22 +010058end_vector_entry SErrorSPx
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020059
Sandrine Bailleux8b170a22019-01-11 18:47:26 +010060 /*
61 * Lower EL using AArch64 : 0x400 - 0x600.
62 */
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020063vector_entry SynchronousExceptionA64
64 b SynchronousExceptionA64
Sandrine Bailleux452f3602019-01-14 13:49:22 +010065end_vector_entry SynchronousExceptionA64
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020066
67vector_entry IrqA64
68 b IrqA64
Sandrine Bailleux452f3602019-01-14 13:49:22 +010069end_vector_entry IrqA64
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020070
71vector_entry FiqA64
72 b FiqA64
Sandrine Bailleux452f3602019-01-14 13:49:22 +010073end_vector_entry FiqA64
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020074
75vector_entry SErrorA64
76 b SErrorA64
Sandrine Bailleux452f3602019-01-14 13:49:22 +010077end_vector_entry SErrorA64
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020078
Sandrine Bailleux8b170a22019-01-11 18:47:26 +010079 /*
80 * Lower EL using AArch32 : 0x600 - 0x800.
81 */
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020082vector_entry SynchronousExceptionA32
83 b SynchronousExceptionA32
Sandrine Bailleux452f3602019-01-14 13:49:22 +010084end_vector_entry SynchronousExceptionA32
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020085
86vector_entry IrqA32
87 b IrqA32
Sandrine Bailleux452f3602019-01-14 13:49:22 +010088end_vector_entry IrqA32
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020089
90vector_entry FiqA32
91 b FiqA32
Sandrine Bailleux452f3602019-01-14 13:49:22 +010092end_vector_entry FiqA32
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020093
94vector_entry SErrorA32
95 b SErrorA32
Sandrine Bailleux452f3602019-01-14 13:49:22 +010096end_vector_entry SErrorA32
Sandrine Bailleux3cd87d72018-10-09 11:12:55 +020097
98
99// Note: Exceptions will always be from the same EL, so no need to save spsr
100func save_regs
101 sub sp, sp, #0x100
102 stp x0, x1, [sp, #0x0]
103 stp x2, x3, [sp, #0x10]
104 stp x4, x5, [sp, #0x20]
105 stp x6, x7, [sp, #0x30]
106 stp x8, x9, [sp, #0x40]
107 stp x10, x11, [sp, #0x50]
108 stp x12, x13, [sp, #0x60]
109 stp x14, x15, [sp, #0x70]
110 stp x16, x17, [sp, #0x80]
111 stp x18, x19, [sp, #0x90]
112 stp x20, x21, [sp, #0xa0]
113 stp x22, x23, [sp, #0xb0]
114 stp x24, x25, [sp, #0xc0]
115 stp x26, x27, [sp, #0xd0]
116 mrs x0, sp_el0
117 stp x28, x0, [sp, #0xe0]
118 str x0, [sp, #0xf0]
119 ret
120endfunc save_regs
121
122
123// Note: Exceptions will always be from the same EL, so no need to restore spsr
124func restore_regs
125 ldr x9, [sp, #0xf0]
126 ldp x28, x9, [sp, #0xe0]
127 msr sp_el0, x9
128 ldp x26, x27, [sp, #0xd0]
129 ldp x24, x25, [sp, #0xc0]
130 ldp x22, x23, [sp, #0xb0]
131 ldp x20, x21, [sp, #0xa0]
132 ldp x18, x19, [sp, #0x90]
133 ldp x16, x17, [sp, #0x80]
134 ldp x14, x15, [sp, #0x70]
135 ldp x12, x13, [sp, #0x60]
136 ldp x10, x11, [sp, #0x50]
137 ldp x8, x9, [sp, #0x40]
138 ldp x6, x7, [sp, #0x30]
139 ldp x4, x5, [sp, #0x20]
140 ldp x2, x3, [sp, #0x10]
141 ldp x0, x1, [sp, #0x0]
142 add sp, sp, #0x100
143 ret
144endfunc restore_regs