blob: 218245d8e20dd269e40373ea84ea1e3630484a5b [file] [log] [blame]
Antonio Nino Diazc41f2062017-10-24 10:07:35 +01001/*
2 * Copyright (c) 2017, ARM Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <arch.h>
8#include <asm_macros.S>
9#include <bl_common.h>
10#include <context.h>
11
12/* -----------------------------------------------------------------------------
13 * Very simple stackless exception handlers used by the spm shim layer.
14 * -----------------------------------------------------------------------------
15 */
16 .globl spm_shim_exceptions_ptr
17
18vector_base spm_shim_exceptions_ptr, .spm_shim_exceptions
19
20 /* -----------------------------------------------------
21 * Current EL with SP0 : 0x0 - 0x200
22 * -----------------------------------------------------
23 */
24vector_entry SynchronousExceptionSP0, .spm_shim_exceptions
25 b .
26 check_vector_size SynchronousExceptionSP0
27
28vector_entry IrqSP0, .spm_shim_exceptions
29 b .
30 check_vector_size IrqSP0
31
32vector_entry FiqSP0, .spm_shim_exceptions
33 b .
34 check_vector_size FiqSP0
35
36vector_entry SErrorSP0, .spm_shim_exceptions
37 b .
38 check_vector_size SErrorSP0
39
40 /* -----------------------------------------------------
41 * Current EL with SPx: 0x200 - 0x400
42 * -----------------------------------------------------
43 */
44vector_entry SynchronousExceptionSPx, .spm_shim_exceptions
45 b .
46 check_vector_size SynchronousExceptionSPx
47
48vector_entry IrqSPx, .spm_shim_exceptions
49 b .
50 check_vector_size IrqSPx
51
52vector_entry FiqSPx, .spm_shim_exceptions
53 b .
54 check_vector_size FiqSPx
55
56vector_entry SErrorSPx, .spm_shim_exceptions
57 b .
58 check_vector_size SErrorSPx
59
60 /* -----------------------------------------------------
61 * Lower EL using AArch64 : 0x400 - 0x600. No exceptions
62 * are handled since secure_partition does not implement
63 * a lower EL
64 * -----------------------------------------------------
65 */
66vector_entry SynchronousExceptionA64, .spm_shim_exceptions
67 msr tpidr_el1, x30
68 mrs x30, esr_el1
69 ubfx x30, x30, #ESR_EC_SHIFT, #ESR_EC_LENGTH
70
71 cmp x30, #EC_AARCH64_SVC
72 b.eq do_smc
73
74 cmp x30, #EC_AARCH32_SVC
75 b.eq do_smc
76
77 cmp x30, #EC_AARCH64_SYS
78 b.eq handle_sys_trap
79
80 /* Fail in all the other cases */
81 b panic
82
83 /* ---------------------------------------------
84 * Tell SPM that we are done initialising
85 * ---------------------------------------------
86 */
87do_smc:
88 mrs x30, tpidr_el1
89 smc #0
90 eret
91
92 /* AArch64 system instructions trap are handled as a panic for now */
93handle_sys_trap:
94panic:
95 b panic
96 check_vector_size SynchronousExceptionA64
97
98vector_entry IrqA64, .spm_shim_exceptions
99 b .
100 check_vector_size IrqA64
101
102vector_entry FiqA64, .spm_shim_exceptions
103 b .
104 check_vector_size FiqA64
105
106vector_entry SErrorA64, .spm_shim_exceptions
107 b .
108 check_vector_size SErrorA64
109
110 /* -----------------------------------------------------
111 * Lower EL using AArch32 : 0x600 - 0x800
112 * -----------------------------------------------------
113 */
114vector_entry SynchronousExceptionA32, .spm_shim_exceptions
115 b .
116 check_vector_size SynchronousExceptionA32
117
118vector_entry IrqA32, .spm_shim_exceptions
119 b .
120 check_vector_size IrqA32
121
122vector_entry FiqA32, .spm_shim_exceptions
123 b .
124 check_vector_size FiqA32
125
126vector_entry SErrorA32, .spm_shim_exceptions
127 b .
128 check_vector_size SErrorA32