1// Copyright 2015-2017 Espressif Systems (Shanghai) PTE LTD 2// 3// Licensed under the Apache License, Version 2.0 (the "License"); 4// you may not use this file except in compliance with the License. 5// You may obtain a copy of the License at 6 7// http://www.apache.org/licenses/LICENSE-2.0 8// 9// Unless required by applicable law or agreed to in writing, software 10// distributed under the License is distributed on an "AS IS" BASIS, 11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12// See the License for the specific language governing permissions and 13// limitations under the License. 14 15#include "xtensa_rtos.h" 16#include "esp_private/panic_reason.h" 17#include "sdkconfig.h" 18#include "soc/soc.h" 19 20/* 21This file contains the default handlers for the high interrupt levels as well as some specialized exceptions. 22The default behaviour is to just exit the interrupt or call the panic handler on the exceptions 23*/ 24 25 26#if XCHAL_HAVE_DEBUG 27 .global xt_debugexception 28 .weak xt_debugexception 29 .set xt_debugexception, _xt_debugexception 30 .section .iram1,"ax" 31 .type _xt_debugexception,@function 32 .align 4 33 34_xt_debugexception: 35 movi a0,PANIC_RSN_DEBUGEXCEPTION 36 wsr a0,EXCCAUSE 37 /* _xt_panic assumes a level 1 exception. As we're 38 crashing anyhow, copy EPC & EXCSAVE from DEBUGLEVEL 39 to level 1. */ 40 rsr a0,(EPC + XCHAL_DEBUGLEVEL) 41 wsr a0,EPC_1 42 rsr a0,(EXCSAVE + XCHAL_DEBUGLEVEL) 43 wsr a0,EXCSAVE_1 44 call0 _xt_panic /* does not return */ 45 rfi XCHAL_DEBUGLEVEL 46 47#endif /* Debug exception */ 48 49 50#if XCHAL_NUM_INTLEVELS >=2 && XCHAL_EXCM_LEVEL <2 && XCHAL_DEBUGLEVEL !=2 51 .global xt_highint2 52 .weak xt_highint2 53 .set xt_highint2, _xt_highint2 54 .section .iram1,"ax" 55 .type _xt_highint2,@function 56 .align 4 57_xt_highint2: 58 59 /* Default handler does nothing; just returns */ 60 .align 4 61.L_xt_highint2_exit: 62 rsr a0, EXCSAVE_2 /* restore a0 */ 63 rfi 2 64 65#endif /* Level 2 */ 66 67#if XCHAL_NUM_INTLEVELS >=3 && XCHAL_EXCM_LEVEL <3 && XCHAL_DEBUGLEVEL !=3 68 69 .global xt_highint3 70 .weak xt_highint3 71 .set xt_highint3, _xt_highint3 72 .section .iram1,"ax" 73 .type _xt_highint3,@function 74 .align 4 75_xt_highint3: 76 77 /* Default handler does nothing; just returns */ 78 79 .align 4 80.L_xt_highint3_exit: 81 rsr a0, EXCSAVE_3 /* restore a0 */ 82 rfi 3 83 84#endif /* Level 3 */ 85 86#if XCHAL_NUM_INTLEVELS >=4 && XCHAL_EXCM_LEVEL <4 && XCHAL_DEBUGLEVEL !=4 87 88 .global xt_highint4 89 .weak xt_highint4 90 .set xt_highint4, _xt_highint4 91 .section .iram1,"ax" 92 .type _xt_highint4,@function 93 .align 4 94_xt_highint4: 95 96 /* Default handler does nothing; just returns */ 97 98 .align 4 99.L_xt_highint4_exit: 100 rsr a0, EXCSAVE_4 /* restore a0 */ 101 rfi 4 102 103#endif /* Level 4 */ 104 105#if XCHAL_NUM_INTLEVELS >=5 && XCHAL_EXCM_LEVEL <5 && XCHAL_DEBUGLEVEL !=5 106 107 .global xt_highint5 108 .weak xt_highint5 109 .set xt_highint5, _xt_highint5 110 .section .iram1,"ax" 111 .type _xt_highint5,@function 112 .align 4 113_xt_highint5: 114 115 /* Default handler does nothing; just returns */ 116 117 .align 4 118.L_xt_highint5_exit: 119 rsr a0, EXCSAVE_5 /* restore a0 */ 120 rfi 5 121 122 123#endif /* Level 5 */ 124 125#if XCHAL_NUM_INTLEVELS >=6 && XCHAL_EXCM_LEVEL <6 && XCHAL_DEBUGLEVEL !=6 126 127 .global _xt_highint6 128 .global xt_highint6 129 .weak xt_highint6 130 .set xt_highint6, _xt_highint6 131 .section .iram1,"ax" 132 .type _xt_highint6,@function 133 .align 4 134_xt_highint6: 135 136 /* Default handler does nothing; just returns */ 137 138 .align 4 139.L_xt_highint6_exit: 140 rsr a0, EXCSAVE_6 /* restore a0 */ 141 rfi 6 142 143#endif /* Level 6 */ 144 145#if XCHAL_HAVE_NMI 146 147 .global _xt_nmi 148 .global xt_nmi 149 .weak xt_nmi 150 .set xt_nmi, _xt_nmi 151 .section .iram1,"ax" 152 .type _xt_nmi,@function 153 .align 4 154_xt_nmi: 155 156 /* Default handler does nothing; just returns */ 157 158 .align 4 159.L_xt_nmi_exit: 160 rsr a0, EXCSAVE + XCHAL_NMILEVEL /* restore a0 */ 161 rfi XCHAL_NMILEVEL 162 163#endif /* NMI */ 164