diff --git a/runtime/include/arch/aarch64/context.h b/runtime/include/arch/aarch64/context.h index 8c85b4a..459050a 100644 --- a/runtime/include/arch/aarch64/context.h +++ b/runtime/include/arch/aarch64/context.h @@ -2,9 +2,7 @@ #if defined(AARCH64) || defined(aarch64) #include - #include "arch/common.h" -#include "current_sandbox.h" #define ARCH_SIG_JMP_OFF 0x100 /* Based on code generated! */ @@ -48,10 +46,10 @@ arch_context_switch(struct arch_context *a, struct arch_context *b) * Assumption: In the case of a slow context switch, the caller * set current_sandbox to the sandbox containing the target context */ - if (b->variant == ARCH_CONTEXT_VARIANT_SLOW) { + /*if (b->variant == ARCH_CONTEXT_VARIANT_SLOW) { struct sandbox *current = current_sandbox_get(); assert(current != NULL && b == ¤t->ctxt); - } + }*/ #endif /* if both a and b are NULL, there is no state change */ @@ -110,6 +108,34 @@ arch_context_switch(struct arch_context *a, struct arch_context *b) return 0; } +/** + * Load a new sandbox that preempted an existing sandbox, restoring only the + * instruction pointer and stack pointer registers. + * @param active_context - the context of the current worker thread + * @param sandbox_context - the context that we want to restore + */ +static inline void +arch_context_restore_new(mcontext_t *active_context, struct arch_context *sandbox_context) +{ + assert(active_context != NULL); + assert(sandbox_context != NULL); + + /* Assumption: Base Context is only ever used by arch_context_switch */ + assert(sandbox_context != &worker_thread_base_context); + + assert(sandbox_context->regs[UREG_SP]); + assert(sandbox_context->regs[UREG_IP]); + + /* Transitioning from Fast -> Running */ + assert(sandbox_context->variant == ARCH_CONTEXT_VARIANT_FAST); + sandbox_context->variant = ARCH_CONTEXT_VARIANT_RUNNING; + + active_context->sp = sandbox_context->regs[UREG_SP]; + active_context->pc = sandbox_context->regs[UREG_IP] + ARCH_SIG_JMP_OFF; +} + + #else #warning "Neither AARCH64 nor aarch64 was defined, but aarch64/context.h was included!" #endif +