1 /*---------------------------------------------------------------------------* 2 Project: Horizon 3 File: os_ExceptionHandler.h 4 Copyright (C)2009 Nintendo Co., Ltd. All rights reserved. 5 These coded instructions, statements, and computer programs contain 6 proprietary information of Nintendo of America Inc. and/or Nintendo 7 Company Ltd., and are protected by Federal copyright law. They may 8 not be disclosed to third parties or copied or duplicated in any form, 9 in whole or in part, without the prior written consent of Nintendo. 10 $Rev: 25943 $ 11 *--------------------------------------------------------------------------- 12 13 14 */ 15 16 #ifndef NN_OS_ARM_OS_EXCEPTIONHANDLER_H_ 17 #define NN_OS_ARM_OS_EXCEPTIONHANDLER_H_ 18 19 #ifdef __cplusplus 20 21 #include <nn/types.h> 22 #include <nn/util.h> 23 24 namespace nn { 25 namespace os { 26 namespace ARM { 27 28 /* 29 30 31 */ 32 enum ExceptionType 33 { 34 EXCEPTION_TYPE_PABT, // 35 EXCEPTION_TYPE_DABT, // 36 EXCEPTION_TYPE_UNDEF, // 37 EXCEPTION_TYPE_VFP, // 38 39 EXCEPTION_TYPE_MAX_BIT = (1u << 7) 40 }; 41 42 43 /* 44 45 46 */ 47 struct ExceptionContext 48 { 49 bit32 r[16]; // 50 bit32 cpsr; // 51 }; 52 53 54 /* 55 56 57 */ 58 struct ExceptionInfo 59 { 60 util::SizedEnum1<ExceptionType> type; // 61 NN_PADDING3; 62 bit32 fsr; // 63 bit32 far; // 64 bit32 fpexc; // 65 bit32 fpinst; // 66 bit32 fpinst2; // 67 }; 68 69 70 /* 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 */ 92 typedef void (*UserExceptionHandler)(ExceptionInfo* pei, ExceptionContext* pec); 93 94 95 namespace detail 96 { 97 void SaveThreadLocalRegionAddress(); 98 } 99 100 101 /* 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 */ 130 void SetUserExceptionHandler(UserExceptionHandler pHandler, uptr stackBottom); 131 132 133 /* 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 */ 163 template <typename T> SetUserExceptionHandler(UserExceptionHandler pHandler,T * pStack)164 void SetUserExceptionHandler(UserExceptionHandler pHandler, T* pStack) 165 { 166 SetUserExceptionHandler(pHandler, pStack->GetStackBottom()); 167 } 168 169 170 171 } // end of namespace ARM 172 } // end of namespace os 173 } // end of namespace nn 174 175 #endif // __cplusplus 176 177 #endif /* NN_OS_ARM_OS_EXCEPTIONHANDLER_H_ */ 178