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 13#pragma once 14 15#include <autoconf.h> 16#include <sel4utils/gen_config.h> 17#include <sel4/sel4.h> 18#include <utils/arith.h> 19 20#define ARCH_SYSCALL_INSTRUCTION_SIZE 4 21 22static inline int sel4utils_is_read_fault(void) 23{ 24 seL4_Word fsr = seL4_GetMR(seL4_VMFault_FSR); 25#if defined(CONFIG_ARM_HYPERVISOR_SUPPORT) 26 return (fsr & (BIT(6))) == 0; 27#else 28 return (fsr & (BIT(11))) == 0; 29#endif 30} 31 32static inline void sel4utils_set_instruction_pointer(seL4_UserContext *regs, seL4_Word value) 33{ 34 regs->pc = value; 35} 36 37static inline seL4_Word sel4utils_get_instruction_pointer(seL4_UserContext regs) 38{ 39 return regs.pc; 40} 41 42static inline void sel4utils_set_stack_pointer(seL4_UserContext *regs, seL4_Word value) 43{ 44 regs->sp = value; 45} 46 47static inline void sel4utils_set_arg0(seL4_UserContext *regs, seL4_Word value) 48{ 49 regs->r0 = value; 50} 51 52static inline seL4_Word sel4utils_get_sp(seL4_UserContext regs) 53{ 54 return regs.sp; 55} 56 57