1/*
2 * Copyright 2018, 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#pragma once
13
14#include <stdint.h>
15#include <sel4/sel4.h>
16#include <sel4/arch/pfIPC.h>
17#include <sel4/arch/exIPC.h>
18
19#define EXCEPT_IPC_SYS_MR_IP EXCEPT_IPC_SYS_MR_RIP
20#define ARCH_SYSCALL_INSTRUCTION_SIZE 4
21
22static inline int
23sel4utils_is_read_fault(void)
24{
25    seL4_Word fsr = seL4_GetMR(seL4_VMFault_FSR);
26    return (fsr == 1 || fsr == 2 || fsr == 5);
27}
28
29static inline void
30sel4utils_set_instruction_pointer(seL4_UserContext *regs, seL4_Word value)
31{
32    regs->pc = value;
33}
34
35static inline seL4_Word
36sel4utils_get_instruction_pointer(seL4_UserContext regs)
37{
38    return regs.pc;
39}
40
41static inline seL4_Word
42sel4utils_get_sp(seL4_UserContext regs)
43{
44    return regs.sp;
45}
46
47static inline void
48sel4utils_set_stack_pointer(seL4_UserContext *regs, seL4_Word value)
49{
50    regs->sp = value;
51}
52
53