diff options
author | Anup Patel <anup.patel@wdc.com> | 2020-12-29 11:39:22 +0530 |
---|---|---|
committer | Anup Patel <anup@brainfault.org> | 2021-01-07 09:53:17 +0530 |
commit | b7df5e4392d34d8b8d5290d5b857676e672d4c96 (patch) | |
tree | 193d41e0ea471a58e64100c6f57ec0152432ff17 /lib/sbi/sbi_trap.c | |
parent | 80bc5065bb67f9d118b83f64cbe96f2e3e1bc0c6 (diff) |
lib: sbi: Introduce sbi_trap_exit() API
We introduce sbi_trap_exit() API which can help non-firmware
(i.e. generic or platform) code to force exit trap/interrupt
handling and resume execution at context pointed by parameter
"const struct sbi_trap_regs *regs".
This new sbi_trap_exit() API will help Keystone Enclave project
to resume execution of enclave from custom SBI call handler.
Signed-off-by: Anup Patel <anup.patel@wdc.com>
Reviewed-by: Atish Patra <atish.patra@wdc.com>
Diffstat (limited to 'lib/sbi/sbi_trap.c')
-rw-r--r-- | lib/sbi/sbi_trap.c | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/lib/sbi/sbi_trap.c b/lib/sbi/sbi_trap.c index db5aa2f..b7349d2 100644 --- a/lib/sbi/sbi_trap.c +++ b/lib/sbi/sbi_trap.c @@ -16,6 +16,7 @@ #include <sbi/sbi_illegal_insn.h> #include <sbi/sbi_ipi.h> #include <sbi/sbi_misaligned_ldst.h> +#include <sbi/sbi_scratch.h> #include <sbi/sbi_timer.h> #include <sbi/sbi_trap.h> @@ -271,3 +272,22 @@ trap_error: if (rc) sbi_trap_error(msg, rc, mcause, mtval, mtval2, mtinst, regs); } + +typedef void (*trap_exit_t)(const struct sbi_trap_regs *regs); + +/** + * Exit trap/interrupt handling + * + * This function is called by non-firmware code to abruptly exit + * trap/interrupt handling and resume execution at context pointed + * by given register state. + * + * @param regs pointer to register state + */ +void __noreturn sbi_trap_exit(const struct sbi_trap_regs *regs) +{ + struct sbi_scratch *scratch = sbi_scratch_thishart_ptr(); + + ((trap_exit_t)scratch->trap_exit)(regs); + __builtin_unreachable(); +} |