Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 1 | /* |
Igor Podgainõi | 58fadd6 | 2024-11-15 15:20:50 +0100 | [diff] [blame] | 2 | * Copyright (c) 2013-2025, Arm Limited and Contributors. All rights reserved. |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 3 | * |
dp-arm | 82cb2c1 | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 5 | */ |
Antonio Nino Diaz | c3cf06f | 2018-11-08 10:20:19 +0000 | [diff] [blame] | 6 | #ifndef ASM_MACROS_S |
| 7 | #define ASM_MACROS_S |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 8 | |
Dan Handley | 97043ac | 2014-04-09 13:14:54 +0100 | [diff] [blame] | 9 | #include <arch.h> |
Antonio Nino Diaz | 09d40e0 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 10 | #include <common/asm_macros_common.S> |
Boyan Karatotev | 0d02082 | 2024-11-19 11:27:01 +0000 | [diff] [blame] | 11 | #include <lib/cpus/cpu_ops.h> |
Antonio Nino Diaz | 09d40e0 | 2018-12-14 00:18:21 +0000 | [diff] [blame] | 12 | #include <lib/spinlock.h> |
Dan Handley | 97043ac | 2014-04-09 13:14:54 +0100 | [diff] [blame] | 13 | |
Jeenu Viswambharan | 0cc7aa8 | 2018-04-27 15:06:57 +0100 | [diff] [blame] | 14 | /* |
| 15 | * TLBI instruction with type specifier that implements the workaround for |
Soby Mathew | f85edce | 2019-05-03 13:17:56 +0100 | [diff] [blame] | 16 | * errata 813419 of Cortex-A57 or errata 1286807 of Cortex-A76. |
Jeenu Viswambharan | 0cc7aa8 | 2018-04-27 15:06:57 +0100 | [diff] [blame] | 17 | */ |
Soby Mathew | f85edce | 2019-05-03 13:17:56 +0100 | [diff] [blame] | 18 | #if ERRATA_A57_813419 || ERRATA_A76_1286807 |
Jeenu Viswambharan | 0cc7aa8 | 2018-04-27 15:06:57 +0100 | [diff] [blame] | 19 | #define TLB_INVALIDATE(_type) \ |
| 20 | tlbi _type; \ |
| 21 | dsb ish; \ |
| 22 | tlbi _type |
| 23 | #else |
| 24 | #define TLB_INVALIDATE(_type) \ |
| 25 | tlbi _type |
| 26 | #endif |
| 27 | |
Dan Handley | 97043ac | 2014-04-09 13:14:54 +0100 | [diff] [blame] | 28 | |
Boyan Karatotev | f832885 | 2023-03-10 18:24:50 +0000 | [diff] [blame] | 29 | /* |
| 30 | * Create a stack frame at the start of an assembly function. Will also |
| 31 | * add all necessary call frame information (cfi) directives for a |
| 32 | * pretty stack trace. This is necessary as there is quite a bit of |
| 33 | * flexibility within a stack frame and the stack pointer can move |
| 34 | * around throughout the function. If the debugger isn't told where to |
| 35 | * find things, it gets lost, gives up and displays nothing. So inform |
| 36 | * the debugger of what's where. Anchor the Canonical Frame Address |
| 37 | * (CFA; the thing used to track what's where) to the frame pointer as |
| 38 | * that's not expected to change in the function body and no extra |
| 39 | * bookkeeping will be necessary, allowing free movement of the sp |
| 40 | * |
| 41 | * _frame_size: requested space for caller to use. Must be a mutliple |
| 42 | * of 16 for stack pointer alignment |
| 43 | */ |
| 44 | .macro func_prologue _frame_size=0 |
| 45 | .if \_frame_size & 0xf |
| 46 | .error "frame_size must have stack pointer alignment (multiple of 16)" |
| 47 | .endif |
| 48 | |
| 49 | /* put frame record at top of frame */ |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 50 | stp x29, x30, [sp, #-0x10]! |
| 51 | mov x29,sp |
Boyan Karatotev | f832885 | 2023-03-10 18:24:50 +0000 | [diff] [blame] | 52 | .if \_frame_size |
| 53 | sub sp, sp, #\_frame_size |
| 54 | .endif |
| 55 | |
| 56 | /* point CFA to start of frame record, i.e. x29 + 0x10 */ |
| 57 | .cfi_def_cfa x29, 0x10 |
| 58 | /* inform it about x29, x30 locations */ |
| 59 | .cfi_offset x30, -0x8 |
| 60 | .cfi_offset x29, -0x10 |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 61 | .endm |
| 62 | |
Boyan Karatotev | f832885 | 2023-03-10 18:24:50 +0000 | [diff] [blame] | 63 | /* |
| 64 | * Clear stack frame at the end of an assembly function. |
| 65 | * |
| 66 | * _frame_size: the value passed to func_prologue |
| 67 | */ |
| 68 | .macro func_epilogue _frame_size=0 |
| 69 | /* remove requested space */ |
| 70 | .if \_frame_size |
| 71 | add sp, sp, #\_frame_size |
| 72 | .endif |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 73 | ldp x29, x30, [sp], #0x10 |
| 74 | .endm |
| 75 | |
| 76 | |
| 77 | .macro dcache_line_size reg, tmp |
Achin Gupta | 07f4e07 | 2014-02-02 12:02:23 +0000 | [diff] [blame] | 78 | mrs \tmp, ctr_el0 |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 79 | ubfx \tmp, \tmp, #16, #4 |
Achin Gupta | 07f4e07 | 2014-02-02 12:02:23 +0000 | [diff] [blame] | 80 | mov \reg, #4 |
| 81 | lsl \reg, \reg, \tmp |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 82 | .endm |
| 83 | |
| 84 | |
| 85 | .macro icache_line_size reg, tmp |
Achin Gupta | 07f4e07 | 2014-02-02 12:02:23 +0000 | [diff] [blame] | 86 | mrs \tmp, ctr_el0 |
| 87 | and \tmp, \tmp, #0xf |
| 88 | mov \reg, #4 |
| 89 | lsl \reg, \reg, \tmp |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 90 | .endm |
| 91 | |
| 92 | |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 93 | .macro smc_check label |
Andrew Thoelke | 7935d0a | 2014-04-28 12:32:02 +0100 | [diff] [blame] | 94 | mrs x0, esr_el3 |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 95 | ubfx x0, x0, #ESR_EC_SHIFT, #ESR_EC_LENGTH |
| 96 | cmp x0, #EC_AARCH64_SMC |
| 97 | b.ne $label |
| 98 | .endm |
| 99 | |
Sandrine Bailleux | e0ae9fa | 2016-05-24 16:56:03 +0100 | [diff] [blame] | 100 | /* |
| 101 | * Declare the exception vector table, enforcing it is aligned on a |
| 102 | * 2KB boundary, as required by the ARMv8 architecture. |
Sandrine Bailleux | 79627dc | 2016-05-24 16:22:59 +0100 | [diff] [blame] | 103 | * Use zero bytes as the fill value to be stored in the padding bytes |
| 104 | * so that it inserts illegal AArch64 instructions. This increases |
| 105 | * security, robustness and potentially facilitates debugging. |
Sandrine Bailleux | e0ae9fa | 2016-05-24 16:56:03 +0100 | [diff] [blame] | 106 | */ |
Antonio Nino Diaz | 2fccb22 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 107 | .macro vector_base label, section_name=.vectors |
| 108 | .section \section_name, "ax" |
Sandrine Bailleux | 79627dc | 2016-05-24 16:22:59 +0100 | [diff] [blame] | 109 | .align 11, 0 |
Sandrine Bailleux | e0ae9fa | 2016-05-24 16:56:03 +0100 | [diff] [blame] | 110 | \label: |
| 111 | .endm |
Achin Gupta | 4f6ad66 | 2013-10-25 09:08:21 +0100 | [diff] [blame] | 112 | |
Jeenu Viswambharan | a7934d6 | 2014-02-07 15:53:18 +0000 | [diff] [blame] | 113 | /* |
Sandrine Bailleux | e0ae9fa | 2016-05-24 16:56:03 +0100 | [diff] [blame] | 114 | * Create an entry in the exception vector table, enforcing it is |
| 115 | * aligned on a 128-byte boundary, as required by the ARMv8 architecture. |
Sandrine Bailleux | 79627dc | 2016-05-24 16:22:59 +0100 | [diff] [blame] | 116 | * Use zero bytes as the fill value to be stored in the padding bytes |
| 117 | * so that it inserts illegal AArch64 instructions. This increases |
| 118 | * security, robustness and potentially facilitates debugging. |
Sandrine Bailleux | e0ae9fa | 2016-05-24 16:56:03 +0100 | [diff] [blame] | 119 | */ |
Antonio Nino Diaz | 2fccb22 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 120 | .macro vector_entry label, section_name=.vectors |
Douglas Raillard | 31823b6 | 2017-08-07 16:20:46 +0100 | [diff] [blame] | 121 | .cfi_sections .debug_frame |
Antonio Nino Diaz | 2fccb22 | 2017-10-24 10:07:35 +0100 | [diff] [blame] | 122 | .section \section_name, "ax" |
Sandrine Bailleux | 79627dc | 2016-05-24 16:22:59 +0100 | [diff] [blame] | 123 | .align 7, 0 |
Douglas Raillard | 31823b6 | 2017-08-07 16:20:46 +0100 | [diff] [blame] | 124 | .type \label, %function |
Douglas Raillard | 31823b6 | 2017-08-07 16:20:46 +0100 | [diff] [blame] | 125 | .cfi_startproc |
Sandrine Bailleux | e0ae9fa | 2016-05-24 16:56:03 +0100 | [diff] [blame] | 126 | \label: |
| 127 | .endm |
| 128 | |
| 129 | /* |
Roberto Vargas | a9203ed | 2018-04-17 11:31:43 +0100 | [diff] [blame] | 130 | * Add the bytes until fill the full exception vector, whose size is always |
| 131 | * 32 instructions. If there are more than 32 instructions in the |
| 132 | * exception vector then an error is emitted. |
| 133 | */ |
| 134 | .macro end_vector_entry label |
| 135 | .cfi_endproc |
| 136 | .fill \label + (32 * 4) - . |
| 137 | .endm |
| 138 | |
| 139 | /* |
Soby Mathew | 12d0d00 | 2015-04-09 13:40:55 +0100 | [diff] [blame] | 140 | * This macro calculates the base address of the current CPU's MP stack |
| 141 | * using the plat_my_core_pos() index, the name of the stack storage |
| 142 | * and the size of each stack |
| 143 | * Out: X0 = physical address of stack base |
| 144 | * Clobber: X30, X1, X2 |
| 145 | */ |
| 146 | .macro get_my_mp_stack _name, _size |
Soby Mathew | f1722b6 | 2018-10-12 16:40:28 +0100 | [diff] [blame] | 147 | bl plat_my_core_pos |
| 148 | adrp x2, (\_name + \_size) |
| 149 | add x2, x2, :lo12:(\_name + \_size) |
Soby Mathew | 12d0d00 | 2015-04-09 13:40:55 +0100 | [diff] [blame] | 150 | mov x1, #\_size |
| 151 | madd x0, x0, x1, x2 |
| 152 | .endm |
| 153 | |
| 154 | /* |
Andrew Thoelke | 2bf28e6 | 2014-03-20 10:48:23 +0000 | [diff] [blame] | 155 | * This macro calculates the base address of a UP stack using the |
| 156 | * name of the stack storage and the size of the stack |
| 157 | * Out: X0 = physical address of stack base |
| 158 | */ |
| 159 | .macro get_up_stack _name, _size |
Soby Mathew | f1722b6 | 2018-10-12 16:40:28 +0100 | [diff] [blame] | 160 | adrp x0, (\_name + \_size) |
| 161 | add x0, x0, :lo12:(\_name + \_size) |
Andrew Thoelke | 2bf28e6 | 2014-03-20 10:48:23 +0000 | [diff] [blame] | 162 | .endm |
Soby Mathew | c67b09b | 2014-07-14 16:57:23 +0100 | [diff] [blame] | 163 | |
| 164 | /* |
| 165 | * Helper macro to generate the best mov/movk combinations according |
| 166 | * the value to be moved. The 16 bits from '_shift' are tested and |
| 167 | * if not zero, they are moved into '_reg' without affecting |
| 168 | * other bits. |
| 169 | */ |
| 170 | .macro _mov_imm16 _reg, _val, _shift |
| 171 | .if (\_val >> \_shift) & 0xffff |
| 172 | .if (\_val & (1 << \_shift - 1)) |
| 173 | movk \_reg, (\_val >> \_shift) & 0xffff, LSL \_shift |
| 174 | .else |
| 175 | mov \_reg, \_val & (0xffff << \_shift) |
| 176 | .endif |
| 177 | .endif |
| 178 | .endm |
| 179 | |
| 180 | /* |
| 181 | * Helper macro to load arbitrary values into 32 or 64-bit registers |
| 182 | * which generates the best mov/movk combinations. Many base addresses |
| 183 | * are 64KB aligned the macro will eliminate updating bits 15:0 in |
| 184 | * that case |
| 185 | */ |
| 186 | .macro mov_imm _reg, _val |
| 187 | .if (\_val) == 0 |
| 188 | mov \_reg, #0 |
| 189 | .else |
| 190 | _mov_imm16 \_reg, (\_val), 0 |
| 191 | _mov_imm16 \_reg, (\_val), 16 |
| 192 | _mov_imm16 \_reg, (\_val), 32 |
| 193 | _mov_imm16 \_reg, (\_val), 48 |
| 194 | .endif |
| 195 | .endm |
Dan Handley | e2bf57f | 2015-04-01 17:34:24 +0100 | [diff] [blame] | 196 | |
Jeenu Viswambharan | a806dad | 2016-11-30 15:21:11 +0000 | [diff] [blame] | 197 | /* |
| 198 | * Macro to mark instances where we're jumping to a function and don't |
| 199 | * expect a return. To provide the function being jumped to with |
| 200 | * additional information, we use 'bl' instruction to jump rather than |
| 201 | * 'b'. |
| 202 | * |
| 203 | * Debuggers infer the location of a call from where LR points to, which |
| 204 | * is usually the instruction after 'bl'. If this macro expansion |
| 205 | * happens to be the last location in a function, that'll cause the LR |
| 206 | * to point a location beyond the function, thereby misleading debugger |
| 207 | * back trace. We therefore insert a 'nop' after the function call for |
| 208 | * debug builds, unless 'skip_nop' parameter is non-zero. |
| 209 | */ |
| 210 | .macro no_ret _func:req, skip_nop=0 |
| 211 | bl \_func |
| 212 | #if DEBUG |
| 213 | .ifeq \skip_nop |
| 214 | nop |
| 215 | .endif |
| 216 | #endif |
| 217 | .endm |
| 218 | |
Jeenu Viswambharan | b38bc68 | 2017-01-19 14:23:36 +0000 | [diff] [blame] | 219 | /* |
| 220 | * Reserve space for a spin lock in assembly file. |
| 221 | */ |
| 222 | .macro define_asm_spinlock _name:req |
| 223 | .align SPINLOCK_ASM_ALIGN |
| 224 | \_name: |
| 225 | .space SPINLOCK_ASM_SIZE |
| 226 | .endm |
| 227 | |
Manish Pandey | 7d5036b | 2023-04-27 10:02:35 +0100 | [diff] [blame] | 228 | /* |
Alexei Fedorov | 9fc5963 | 2019-05-24 12:17:09 +0100 | [diff] [blame] | 229 | * Helper macro to read system register value into x0 |
| 230 | */ |
| 231 | .macro read reg:req |
| 232 | #if ENABLE_BTI |
| 233 | bti j |
| 234 | #endif |
| 235 | mrs x0, \reg |
| 236 | ret |
| 237 | .endm |
| 238 | |
| 239 | /* |
| 240 | * Helper macro to write value from x1 to system register |
| 241 | */ |
| 242 | .macro write reg:req |
| 243 | #if ENABLE_BTI |
| 244 | bti j |
| 245 | #endif |
| 246 | msr \reg, x1 |
| 247 | ret |
| 248 | .endm |
| 249 | |
Anthony Steinhauser | f461fe3 | 2020-01-07 15:44:06 -0800 | [diff] [blame] | 250 | /* |
Andre Przywara | 387b880 | 2022-11-25 14:10:13 +0000 | [diff] [blame] | 251 | * The "sb" instruction was introduced later into the architecture, |
| 252 | * so not all toolchains understand it. Some deny its usage unless |
| 253 | * a supported processor is specified on the build command line. |
| 254 | * Use sb's system register encoding to work around this, we already |
| 255 | * guard the sb execution with a feature flag. |
| 256 | */ |
| 257 | |
| 258 | .macro sb_barrier_insn |
| 259 | msr SYSREG_SB, xzr |
| 260 | .endm |
| 261 | |
Boyan Karatotev | f808873 | 2024-11-21 13:55:59 +0000 | [diff] [blame] | 262 | .macro psb_csync |
| 263 | hint #17 /* use the hint synonym for compatibility */ |
| 264 | .endm |
| 265 | |
Boyan Karatotev | 73d98e3 | 2024-12-02 09:36:10 +0000 | [diff] [blame] | 266 | .macro tsb_csync |
| 267 | hint #18 /* use the hint synonym for compatibility */ |
| 268 | .endm |
| 269 | |
Andre Przywara | 387b880 | 2022-11-25 14:10:13 +0000 | [diff] [blame] | 270 | /* |
Bipin Ravi | e74d658 | 2022-10-13 17:25:51 -0500 | [diff] [blame] | 271 | * Macro for using speculation barrier instruction introduced by |
| 272 | * FEAT_SB, if it's enabled. |
| 273 | */ |
| 274 | .macro speculation_barrier |
| 275 | #if ENABLE_FEAT_SB |
Andre Przywara | 387b880 | 2022-11-25 14:10:13 +0000 | [diff] [blame] | 276 | sb_barrier_insn |
Bipin Ravi | e74d658 | 2022-10-13 17:25:51 -0500 | [diff] [blame] | 277 | #else |
| 278 | dsb sy |
| 279 | isb |
| 280 | #endif |
| 281 | .endm |
| 282 | |
| 283 | /* |
Chris Kay | 4e04478 | 2021-03-09 13:34:35 +0000 | [diff] [blame] | 284 | * Macro for mitigating against speculative execution beyond ERET. Uses the |
| 285 | * speculation barrier instruction introduced by FEAT_SB, if it's enabled. |
Anthony Steinhauser | f461fe3 | 2020-01-07 15:44:06 -0800 | [diff] [blame] | 286 | */ |
| 287 | .macro exception_return |
| 288 | eret |
Chris Kay | 4e04478 | 2021-03-09 13:34:35 +0000 | [diff] [blame] | 289 | #if ENABLE_FEAT_SB |
Andre Przywara | 387b880 | 2022-11-25 14:10:13 +0000 | [diff] [blame] | 290 | sb_barrier_insn |
Madhukar Pappireddy | ccfb5c8 | 2020-03-10 18:04:59 -0500 | [diff] [blame] | 291 | #else |
| 292 | dsb nsh |
Anthony Steinhauser | f461fe3 | 2020-01-07 15:44:06 -0800 | [diff] [blame] | 293 | isb |
Madhukar Pappireddy | ccfb5c8 | 2020-03-10 18:04:59 -0500 | [diff] [blame] | 294 | #endif |
Anthony Steinhauser | f461fe3 | 2020-01-07 15:44:06 -0800 | [diff] [blame] | 295 | .endm |
| 296 | |
Manish Pandey | d04c04a | 2023-05-25 13:46:14 +0100 | [diff] [blame] | 297 | /* |
| 298 | * Macro to unmask External Aborts by changing PSTATE.A bit. |
| 299 | * Put explicit synchronization event to ensure newly unmasked interrupt |
| 300 | * is taken immediately. |
| 301 | */ |
| 302 | .macro unmask_async_ea |
| 303 | msr daifclr, #DAIF_ABT_BIT |
| 304 | isb |
| 305 | .endm |
Manish Pandey | 6597fcf | 2023-06-26 17:46:14 +0100 | [diff] [blame] | 306 | |
| 307 | /* Macro for error synchronization on exception boundries. |
| 308 | * With FEAT_RAS enabled, it is assumed that FEAT_IESB is also present |
| 309 | * and enabled. |
| 310 | * FEAT_IESB provides an implicit error synchronization event at exception |
| 311 | * entry and exception return, so there is no need for any explicit instruction. |
| 312 | */ |
| 313 | .macro synchronize_errors |
Manish Pandey | 970a4a8 | 2023-10-10 13:53:25 +0100 | [diff] [blame] | 314 | #if !ENABLE_FEAT_RAS |
Manish Pandey | 6597fcf | 2023-06-26 17:46:14 +0100 | [diff] [blame] | 315 | /* Complete any stores that may return an abort */ |
| 316 | dsb sy |
| 317 | /* Synchronise the CPU context with the completion of the dsb */ |
| 318 | isb |
| 319 | #endif |
| 320 | .endm |
| 321 | |
Hsin-Hsiung Wang | 31857d4 | 2024-02-22 15:16:32 +0800 | [diff] [blame] | 322 | /* |
| 323 | * Helper macro to instruction adr <reg>, <symbol> where <symbol> is |
| 324 | * within the range +/- 4 GB. |
| 325 | */ |
| 326 | .macro adr_l, dst, sym |
| 327 | adrp \dst, \sym |
| 328 | add \dst, \dst, :lo12:\sym |
| 329 | .endm |
Igor Podgainõi | 58fadd6 | 2024-11-15 15:20:50 +0100 | [diff] [blame] | 330 | |
| 331 | /* |
Boyan Karatotev | 8d9f5f2 | 2025-04-02 11:16:18 +0100 | [diff] [blame] | 332 | * is_feat_XYZ_present_asm - Set flags and reg if FEAT_XYZ |
Igor Podgainõi | 58fadd6 | 2024-11-15 15:20:50 +0100 | [diff] [blame] | 333 | * is enabled at runtime. |
| 334 | * |
| 335 | * Arguments: |
| 336 | * reg: Register for temporary use. |
| 337 | * |
| 338 | * Clobbers: reg |
| 339 | */ |
| 340 | .macro is_feat_sysreg128_present_asm reg:req |
| 341 | mrs \reg, ID_AA64ISAR2_EL1 |
| 342 | ands \reg, \reg, #(ID_AA64ISAR2_SYSREG128_MASK << ID_AA64ISAR2_SYSREG128_SHIFT) |
| 343 | .endm |
Boyan Karatotev | 0d02082 | 2024-11-19 11:27:01 +0000 | [diff] [blame] | 344 | |
Boyan Karatotev | 8d9f5f2 | 2025-04-02 11:16:18 +0100 | [diff] [blame] | 345 | .macro is_feat_pauth_present_asm reg:req, clobber:req |
| 346 | mrs \reg, ID_AA64ISAR1_EL1 |
| 347 | mov_imm \clobber, ((ID_AA64ISAR1_GPI_MASK << ID_AA64ISAR1_GPI_SHIFT) \ |
| 348 | | (ID_AA64ISAR1_GPA_MASK << ID_AA64ISAR1_GPA_SHIFT) \ |
| 349 | | (ID_AA64ISAR1_API_MASK << ID_AA64ISAR1_API_SHIFT) \ |
| 350 | | (ID_AA64ISAR1_APA_MASK << ID_AA64ISAR1_APA_SHIFT)) |
| 351 | tst \reg, \clobber |
| 352 | .endm |
| 353 | |
Boyan Karatotev | 0d02082 | 2024-11-19 11:27:01 +0000 | [diff] [blame] | 354 | .macro call_reset_handler |
| 355 | #if !(defined(IMAGE_BL2) && ENABLE_RME) |
| 356 | /* --------------------------------------------------------------------- |
| 357 | * It is a cold boot. |
| 358 | * Perform any processor specific actions upon reset e.g. cache, TLB |
| 359 | * invalidations etc. |
| 360 | * --------------------------------------------------------------------- |
| 361 | */ |
| 362 | /* The plat_reset_handler can clobber x0 - x18, x30 */ |
| 363 | bl plat_reset_handler |
| 364 | |
| 365 | /* Get the matching cpu_ops pointer */ |
| 366 | bl get_cpu_ops_ptr |
| 367 | |
| 368 | /* Get the cpu_ops reset handler */ |
| 369 | ldr x2, [x0, #CPU_RESET_FUNC] |
| 370 | |
| 371 | /* The cpu_ops reset handler can clobber x0 - x19, x30 */ |
| 372 | blr x2 |
| 373 | #endif |
| 374 | .endm |
Antonio Nino Diaz | c3cf06f | 2018-11-08 10:20:19 +0000 | [diff] [blame] | 375 | #endif /* ASM_MACROS_S */ |