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/types.h> 16#include <sel4/sel4_arch/faults.h> 17 18LIBSEL4_INLINE_FUNC seL4_Fault_t 19seL4_getFault(seL4_MessageInfo_t tag) 20{ 21 22 switch (seL4_MessageInfo_get_label(tag)) { 23 case seL4_Fault_CapFault: 24 return seL4_Fault_CapFault_new(seL4_GetMR(seL4_CapFault_IP), 25 seL4_GetMR(seL4_CapFault_Addr), 26 seL4_GetMR(seL4_CapFault_InRecvPhase), 27 seL4_GetMR(seL4_CapFault_LookupFailureType), 28 seL4_GetMR(seL4_CapFault_BitsLeft), 29 seL4_GetMR(seL4_CapFault_GuardMismatch_GuardFound), 30 seL4_GetMR(seL4_CapFault_GuardMismatch_BitsFound)); 31#ifdef CONFIG_HARDWARE_DEBUG_API 32 case seL4_Fault_DebugException: 33 return seL4_Fault_DebugException_new(seL4_GetMR(seL4_DebugException_FaultIP), 34 seL4_GetMR(seL4_DebugException_ExceptionReason), 35 seL4_GetMR(seL4_DebugException_TriggerAddress), 36 seL4_GetMR(seL4_DebugException_BreakpointNumber)); 37#endif 38 default: 39 return seL4_getArchFault(tag); 40 } 41} 42 43#ifdef CONFIG_HARDWARE_DEBUG_API 44LIBSEL4_INLINE_FUNC seL4_Bool 45seL4_isDebugException_tag(seL4_MessageInfo_t tag) 46{ 47 return seL4_MessageInfo_get_label(tag) == seL4_Fault_DebugException; 48} 49#endif 50 51LIBSEL4_INLINE_FUNC seL4_Bool 52seL4_isVMFault_tag(seL4_MessageInfo_t tag) 53{ 54 return seL4_MessageInfo_get_label(tag) == seL4_Fault_VMFault; 55} 56 57LIBSEL4_INLINE_FUNC seL4_Bool 58seL4_isUnknownSyscall_tag(seL4_MessageInfo_t tag) 59{ 60 return seL4_MessageInfo_get_label(tag) == seL4_Fault_UnknownSyscall; 61} 62 63LIBSEL4_INLINE_FUNC seL4_Bool 64seL4_isUserException_tag(seL4_MessageInfo_t tag) 65{ 66 return seL4_MessageInfo_get_label(tag) == seL4_Fault_UserException; 67} 68 69LIBSEL4_INLINE_FUNC seL4_Bool 70seL4_isNullFault_tag(seL4_MessageInfo_t tag) 71{ 72 return seL4_MessageInfo_get_label(tag) == seL4_Fault_NullFault; 73} 74 75LIBSEL4_INLINE_FUNC seL4_Bool 76seL4_isCapFault_tag(seL4_MessageInfo_t tag) 77{ 78 return seL4_MessageInfo_get_label(tag) == seL4_Fault_CapFault; 79} 80