Hesham Almatary | c7e78f2 | 2016-07-06 13:48:07 +1000 | [diff] [blame] | 1 | /* |
Gerwin Klein | 600fe15 | 2021-02-10 19:19:17 +1100 | [diff] [blame^] | 2 | * Copyright 2018, Data61, CSIRO (ABN 41 687 119 230) |
Hesham Almatary | c7e78f2 | 2016-07-06 13:48:07 +1000 | [diff] [blame] | 3 | * |
Gerwin Klein | 600fe15 | 2021-02-10 19:19:17 +1100 | [diff] [blame^] | 4 | * SPDX-License-Identifier: BSD-2-Clause |
Hesham Almatary | c7e78f2 | 2016-07-06 13:48:07 +1000 | [diff] [blame] | 5 | */ |
Anna Lyons | 73d9d0a | 2018-04-05 11:17:11 +1000 | [diff] [blame] | 6 | #pragma once |
Hesham Almatary | c7e78f2 | 2016-07-06 13:48:07 +1000 | [diff] [blame] | 7 | |
| 8 | #include <stdint.h> |
| 9 | #include <sel4/sel4.h> |
| 10 | #include <sel4/arch/pfIPC.h> |
| 11 | #include <sel4/arch/exIPC.h> |
Anna Lyons | 9a2af0e | 2018-04-04 14:15:44 +1000 | [diff] [blame] | 12 | |
| 13 | #define EXCEPT_IPC_SYS_MR_IP EXCEPT_IPC_SYS_MR_RIP |
| 14 | #define ARCH_SYSCALL_INSTRUCTION_SIZE 4 |
Hesham Almatary | c7e78f2 | 2016-07-06 13:48:07 +1000 | [diff] [blame] | 15 | |
| 16 | static inline int |
| 17 | sel4utils_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 Lyons | 9a2af0e | 2018-04-04 14:15:44 +1000 | [diff] [blame] | 23 | static inline void |
| 24 | sel4utils_set_instruction_pointer(seL4_UserContext *regs, seL4_Word value) |
| 25 | { |
| 26 | regs->pc = value; |
| 27 | } |
| 28 | |
| 29 | static inline seL4_Word |
| 30 | sel4utils_get_instruction_pointer(seL4_UserContext regs) |
| 31 | { |
| 32 | return regs.pc; |
| 33 | } |
| 34 | |
| 35 | static inline seL4_Word |
| 36 | sel4utils_get_sp(seL4_UserContext regs) |
| 37 | { |
| 38 | return regs.sp; |
| 39 | } |
| 40 | |
| 41 | static inline void |
| 42 | sel4utils_set_stack_pointer(seL4_UserContext *regs, seL4_Word value) |
| 43 | { |
| 44 | regs->sp = value; |
| 45 | } |
| 46 | |