1/* 2 * Copyright 2020, Data61, CSIRO (ABN 41 687 119 230) 3 * 4 * SPDX-License-Identifier: BSD-2-Clause 5 */ 6 7#pragma once 8 9#include <autoconf.h> 10#include <sel4/faults.h> 11#include <sel4/sel4_arch/constants.h> 12 13LIBSEL4_INLINE_FUNC seL4_Fault_t seL4_getArchFault(seL4_MessageInfo_t tag) 14{ 15 switch (seL4_MessageInfo_get_label(tag)) { 16 case seL4_Fault_UnknownSyscall: 17 return seL4_Fault_UnknownSyscall_new(seL4_GetMR(seL4_UnknownSyscall_R0), 18 seL4_GetMR(seL4_UnknownSyscall_R1), 19 seL4_GetMR(seL4_UnknownSyscall_R2), 20 seL4_GetMR(seL4_UnknownSyscall_R3), 21 seL4_GetMR(seL4_UnknownSyscall_R4), 22 seL4_GetMR(seL4_UnknownSyscall_R5), 23 seL4_GetMR(seL4_UnknownSyscall_R6), 24 seL4_GetMR(seL4_UnknownSyscall_R7), 25 seL4_GetMR(seL4_UnknownSyscall_FaultIP), 26 seL4_GetMR(seL4_UnknownSyscall_SP), 27 seL4_GetMR(seL4_UnknownSyscall_LR), 28 seL4_GetMR(seL4_UnknownSyscall_CPSR), 29 seL4_GetMR(seL4_UnknownSyscall_Syscall)); 30 31 case seL4_Fault_UserException: 32 return seL4_Fault_UserException_new(seL4_GetMR(seL4_UserException_FaultIP), 33 seL4_GetMR(seL4_UserException_SP), 34 seL4_GetMR(seL4_UserException_CPSR), 35 seL4_GetMR(seL4_UserException_Number), 36 seL4_GetMR(seL4_UserException_Code)); 37 case seL4_Fault_VMFault: 38 return seL4_Fault_VMFault_new(seL4_GetMR(seL4_VMFault_IP), 39 seL4_GetMR(seL4_VMFault_Addr), 40 seL4_GetMR(seL4_VMFault_PrefetchFault), 41 seL4_GetMR(seL4_VMFault_FSR)); 42#ifdef CONFIG_ARM_HYPERVISOR_SUPPORT 43 case seL4_Fault_VGICMaintenance: 44 return seL4_Fault_VGICMaintenance_new(seL4_GetMR(seL4_VGICMaintenance_IDX)); 45 case seL4_Fault_VCPUFault: 46 return seL4_Fault_VCPUFault_new(seL4_GetMR(seL4_VCPUFault_HSR)); 47 case seL4_Fault_VPPIEvent: 48 return seL4_Fault_VPPIEvent_new(seL4_GetMR(seL4_VPPIEvent_IRQ)); 49#endif /* CONFIG_ARM_HYPERVISOR_SUPPORT */ 50#ifdef CONFIG_KERNEL_MCS 51 case seL4_Fault_Timeout: 52 return seL4_Fault_Timeout_new(seL4_GetMR(seL4_Timeout_Data), 53 seL4_GetMR(seL4_Timeout_Consumed_HighBits), 54 seL4_GetMR(seL4_Timeout_Consumed_LowBits)); 55#endif /* CONFIG_KERNEL_MCS */ 56 default: 57 return seL4_Fault_NullFault_new(); 58 } 59} 60 61#ifdef CONFIG_ARM_HYPERVISOR_SUPPORT 62LIBSEL4_INLINE_FUNC seL4_Bool seL4_isVGICMaintenance_tag(seL4_MessageInfo_t tag) 63{ 64 return seL4_MessageInfo_get_label(tag) == seL4_Fault_VGICMaintenance; 65} 66 67LIBSEL4_INLINE_FUNC seL4_Bool seL4_isVCPUFault_tag(seL4_MessageInfo_t tag) 68{ 69 return seL4_MessageInfo_get_label(tag) == seL4_Fault_VCPUFault; 70} 71#endif /* CONFIG_ARM_HYPERVISOR_SUPPORT */ 72