1/* 2 * Copyright 2017, Data61 3 * Commonwealth Scientific and Industrial Research Organisation (CSIRO) 4 * ABN 41 687 119 230. 5 * 6 * This software may be distributed and modified according to the terms of 7 * the BSD 2-Clause license. Note that NO WARRANTY is provided. 8 * See "LICENSE_BSD2.txt" for details. 9 * 10 * @TAG(DATA61_BSD) 11 */ 12#include <autoconf.h> 13#include <sel4utils/gen_config.h> 14#include <sel4/types.h> 15#include <sel4utils/thread.h> 16#include <sel4utils/helpers.h> 17#include <utils/zf_log.h> 18#include <utils/stack.h> 19#include <stdbool.h> 20 21int sel4utils_arch_init_context(void *entry_point, void *stack_top, seL4_UserContext *context) 22{ 23 context->pc = (seL4_Word) entry_point; 24 context->sp = (seL4_Word) stack_top; 25 if (!IS_ALIGNED((uintptr_t)stack_top, STACK_CALL_ALIGNMENT_BITS)) { 26 ZF_LOGE("Initial stack pointer must be %d byte aligned", STACK_CALL_ALIGNMENT); 27 return -1; 28 } 29 return 0; 30} 31 32int sel4utils_arch_init_context_with_args(sel4utils_thread_entry_fn entry_point, 33 void *arg0, void *arg1, void *arg2, 34 bool local_stack, void *stack_top, 35 seL4_UserContext *context, 36 vka_t *vka, vspace_t *local_vspace, vspace_t *remote_vspace) 37{ 38 39 context->r0 = (seL4_Word) arg0; 40 context->r1 = (seL4_Word) arg1; 41 context->r2 = (seL4_Word) arg2; 42 43 return sel4utils_arch_init_context(entry_point, stack_top, context); 44} 45