forked from Mirrors/opensbi
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>
This commit is contained in:
@@ -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();
|
||||
}
|
||||
|
Reference in New Issue
Block a user