blob: a8b64fcefef2ac07ea60e52dd0d9e5524a7fb0b0 [file] [log] [blame]
Hesham Almataryc7e78f22016-07-06 13:48:07 +10001/*
Gerwin Klein600fe152021-02-10 19:19:17 +11002 * Copyright 2018, Data61, CSIRO (ABN 41 687 119 230)
Hesham Almataryc7e78f22016-07-06 13:48:07 +10003 *
Gerwin Klein600fe152021-02-10 19:19:17 +11004 * SPDX-License-Identifier: BSD-2-Clause
Hesham Almataryc7e78f22016-07-06 13:48:07 +10005 */
Anna Lyons73d9d0a2018-04-05 11:17:11 +10006#pragma once
Hesham Almataryc7e78f22016-07-06 13:48:07 +10007
8#include <stdint.h>
9#include <sel4/sel4.h>
10#include <sel4/arch/pfIPC.h>
11#include <sel4/arch/exIPC.h>
Anna Lyons9a2af0e2018-04-04 14:15:44 +100012
13#define EXCEPT_IPC_SYS_MR_IP EXCEPT_IPC_SYS_MR_RIP
14#define ARCH_SYSCALL_INSTRUCTION_SIZE 4
Hesham Almataryc7e78f22016-07-06 13:48:07 +100015
16static inline int
17sel4utils_is_read_fault(void)
18{
19 seL4_Word fsr = seL4_GetMR(seL4_VMFault_FSR);
20 return (fsr == 1 || fsr == 2 || fsr == 5);
21}
22
Anna Lyons9a2af0e2018-04-04 14:15:44 +100023static inline void
24sel4utils_set_instruction_pointer(seL4_UserContext *regs, seL4_Word value)
25{
26 regs->pc = value;
27}
28
29static inline seL4_Word
30sel4utils_get_instruction_pointer(seL4_UserContext regs)
31{
32 return regs.pc;
33}
34
35static inline seL4_Word
36sel4utils_get_sp(seL4_UserContext regs)
37{
38 return regs.sp;
39}
40
41static inline void
42sel4utils_set_stack_pointer(seL4_UserContext *regs, seL4_Word value)
43{
44 regs->sp = value;
45}
46