diff options
author | Vincent Guittot <vincent.guittot@linaro.org> | 2023-11-28 15:53:14 +0100 |
---|---|---|
committer | Vincent Guittot <vincent.guittot@linaro.org> | 2023-11-30 08:52:20 +0100 |
commit | 0c6d2b491fbdb0998f1f79ec05383a9234007a6c (patch) | |
tree | 37ee711f764675b118f70b8fdaa90d317319f300 /spm/scmi/aarch64/lib/exceptions/sync.c | |
parent | da7d6f217f3fb6c8634f433cf008c2fe03994108 (diff) |
Add standalone scmi partition
Add a SCMI server partition based on cactus one.
scmi is compiled only with header and C files in spm/scmi directory to
help tracking dependency and ease the move of the code in SCP-firmware.
Signed-off-by: Vincent Guittot <vincent.guittot@linaro.org>
Diffstat (limited to 'spm/scmi/aarch64/lib/exceptions/sync.c')
-rw-r--r-- | spm/scmi/aarch64/lib/exceptions/sync.c | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/spm/scmi/aarch64/lib/exceptions/sync.c b/spm/scmi/aarch64/lib/exceptions/sync.c new file mode 100644 index 0000000..49b6bd8 --- /dev/null +++ b/spm/scmi/aarch64/lib/exceptions/sync.c @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2022, Arm Limited. All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ +#include <stdbool.h> + +#include <arch_helpers.h> +#include <debug.h> +#include <sync.h> + +static exception_handler_t custom_sync_exception_handler; + +void register_custom_sync_exception_handler(exception_handler_t handler) +{ + custom_sync_exception_handler = handler; +} + +void unregister_custom_sync_exception_handler(void) +{ + custom_sync_exception_handler = NULL; +} + +bool tftf_sync_exception_handler(void) +{ + uint64_t elr_elx = IS_IN_EL2() ? read_elr_el2() : read_elr_el1(); + bool resume = false; + + if (custom_sync_exception_handler == NULL) { + return false; + } + + resume = custom_sync_exception_handler(); + + if (resume) { + /* Move ELR to next instruction to allow tftf to continue */ + if (IS_IN_EL2()) { + write_elr_el2(elr_elx + 4U); + } else { + write_elr_el1(elr_elx + 4U); + } + } + + return resume; +} |