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#pragma once 13 14#include <autoconf.h> 15#include <sel4/faults.h> 16#include <sel4/sel4_arch/constants.h> 17 18LIBSEL4_INLINE_FUNC seL4_Fault_t 19seL4_getArchFault(seL4_MessageInfo_t tag) 20{ 21 switch (seL4_MessageInfo_get_label(tag)) { 22 case seL4_Fault_UnknownSyscall: 23 return seL4_Fault_UnknownSyscall_new(seL4_GetMR(seL4_UnknownSyscall_R0), 24 seL4_GetMR(seL4_UnknownSyscall_R1), 25 seL4_GetMR(seL4_UnknownSyscall_R2), 26 seL4_GetMR(seL4_UnknownSyscall_R3), 27 seL4_GetMR(seL4_UnknownSyscall_R4), 28 seL4_GetMR(seL4_UnknownSyscall_R5), 29 seL4_GetMR(seL4_UnknownSyscall_R6), 30 seL4_GetMR(seL4_UnknownSyscall_R7), 31 seL4_GetMR(seL4_UnknownSyscall_FaultIP), 32 seL4_GetMR(seL4_UnknownSyscall_SP), 33 seL4_GetMR(seL4_UnknownSyscall_LR), 34 seL4_GetMR(seL4_UnknownSyscall_CPSR), 35 seL4_GetMR(seL4_UnknownSyscall_Syscall)); 36 37 case seL4_Fault_UserException: 38 return seL4_Fault_UserException_new(seL4_GetMR(seL4_UserException_FaultIP), 39 seL4_GetMR(seL4_UserException_SP), 40 seL4_GetMR(seL4_UserException_CPSR), 41 seL4_GetMR(seL4_UserException_Number), 42 seL4_GetMR(seL4_UserException_Code)); 43 case seL4_Fault_VMFault: 44 return seL4_Fault_VMFault_new(seL4_GetMR(seL4_VMFault_IP), 45 seL4_GetMR(seL4_VMFault_Addr), 46 seL4_GetMR(seL4_VMFault_PrefetchFault), 47 seL4_GetMR(seL4_VMFault_FSR)); 48#ifdef CONFIG_ARM_HYPERVISOR_SUPPORT 49 case seL4_Fault_VGICMaintenance: 50 return seL4_Fault_VGICMaintenance_new(seL4_GetMR(seL4_VGICMaintenance_IDX)); 51 case seL4_Fault_VCPUFault: 52 return seL4_Fault_VCPUFault_new(seL4_GetMR(seL4_VCPUFault_HSR)); 53#endif /* CONFIG_ARM_HYPERVISOR_SUPPORT */ 54 default: 55 return seL4_Fault_NullFault_new(); 56 } 57} 58 59#ifdef CONFIG_ARM_HYPERVISOR_SUPPORT 60LIBSEL4_INLINE_FUNC seL4_Bool 61seL4_isVGICMaintenance_tag(seL4_MessageInfo_t tag) 62{ 63 return seL4_MessageInfo_get_label(tag) == seL4_Fault_VGICMaintenance; 64} 65 66LIBSEL4_INLINE_FUNC seL4_Bool 67seL4_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