diff --git a/arch/xtensa/src/common/xtensa_int_handlers.S b/arch/xtensa/src/common/xtensa_int_handlers.S index 5f405aa8c00..bc5d141b490 100644 --- a/arch/xtensa/src/common/xtensa_int_handlers.S +++ b/arch/xtensa/src/common/xtensa_int_handlers.S @@ -64,10 +64,16 @@ #include #include +#include "xtensa_macros.S" + #include "chip.h" #include "xtensa.h" #include "xtensa_timer.h" +/**************************************************************************** + * Public Symbols + ****************************************************************************/ + #if !defined(CONFIG_SMP) && CONFIG_ARCH_INTERRUPTSTACK > 15 .data .align 16 @@ -104,67 +110,6 @@ g_intstacktop: addi \aout, \aout, 1 /* Return aout + 1 */ .endm -/**************************************************************************** - * Name: setintstack - * - * Description: - * Set the current stack pointer to the "top" the interrupt stack. - * Single CPU case. - * Must be provided by MCU-specific logic in the SMP case. - * - ****************************************************************************/ - -#if !defined(CONFIG_SMP) && CONFIG_ARCH_INTERRUPTSTACK > 15 - .macro setintstack tmp1 tmp2 - movi a1, g_intstacktop - .endm -#endif - -/**************************************************************************** - * Macro: ps_setup - * - * Description: - * Set up PS for C, enable interrupts above this level and clear EXCM. - * - * Entry Conditions: - * level - interrupt level - * tmp - scratch register - * - * Side Effects: - * PS and scratch register modified - * - * Assumptions: - * - PS.EXCM = 1, C calling disabled - * - ****************************************************************************/ - - .macro ps_setup level tmp - -#if 0 /* Nested interrupts no yet supported */ -# ifdef __XTENSA_CALL0_ABI__ - /* Disable interrupts at level and below */ - - movi \tmp, PS_INTLEVEL(\level) | PS_UM -# else - movi \tmp, PS_INTLEVEL(\level) | PS_UM | PS_WOE -# endif -#else -# ifdef __XTENSA_CALL0_ABI__ - /* Disable all low- and medium-priority interrupts. Nested are not yet - * supported. - */ - - movi \tmp, PS_INTLEVEL(XCHAL_EXCM_LEVEL) | PS_UM -# else - movi \tmp, PS_INTLEVEL(XCHAL_EXCM_LEVEL) | PS_UM | PS_WOE -# endif -#endif - - wsr \tmp, PS - rsync - - .endm - /**************************************************************************** * Macro dispatch_c_isr level mask tmp * diff --git a/arch/xtensa/src/common/xtensa_macros.S b/arch/xtensa/src/common/xtensa_macros.S new file mode 100644 index 00000000000..cb57846d1c7 --- /dev/null +++ b/arch/xtensa/src/common/xtensa_macros.S @@ -0,0 +1,94 @@ +/**************************************************************************** + * arch/xtensa/src/common/xtensa_macros.S + * + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. The + * ASF licenses this file to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance with the + * License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT + * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the + * License for the specific language governing permissions and limitations + * under the License. + * + ****************************************************************************/ + +.file "xtensa_macros.S" + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include +#include + +/**************************************************************************** + * Name: setintstack + * + * Description: + * Set the current stack pointer to the "top" the interrupt stack. + * Single CPU case. + * Must be provided by MCU-specific logic in the SMP case. + * + ****************************************************************************/ + +#if !defined(CONFIG_SMP) && CONFIG_ARCH_INTERRUPTSTACK > 15 + .macro setintstack tmp1 tmp2 + movi a1, g_intstacktop + .endm +#endif + +/**************************************************************************** + * Macro: ps_setup + * + * Description: + * Set up PS for C, enable interrupts above this level and clear EXCM. + * + * Entry Conditions: + * level - interrupt level + * tmp - scratch register + * + * Side Effects: + * PS and scratch register modified + * + * Assumptions: + * - PS.EXCM = 1, C calling disabled + * + ****************************************************************************/ + + .macro ps_setup level tmp + +#if 0 /* Nested interrupts no yet supported */ +# ifdef __XTENSA_CALL0_ABI__ + /* Disable interrupts at level and below */ + + movi \tmp, PS_INTLEVEL(\level) | PS_UM +# else + movi \tmp, PS_INTLEVEL(\level) | PS_UM | PS_WOE +# endif +#else +# ifdef __XTENSA_CALL0_ABI__ + /* Disable all low- and medium-priority interrupts. Nested are not yet + * supported. + */ + + movi \tmp, PS_INTLEVEL(XCHAL_EXCM_LEVEL) | PS_UM +# else + movi \tmp, PS_INTLEVEL(XCHAL_EXCM_LEVEL) | PS_UM | PS_WOE +# endif +#endif + + wsr \tmp, PS + rsync + + .endm + diff --git a/arch/xtensa/src/common/xtensa_panic.S b/arch/xtensa/src/common/xtensa_panic.S index f5ebd53801b..dbd2ce70997 100644 --- a/arch/xtensa/src/common/xtensa_panic.S +++ b/arch/xtensa/src/common/xtensa_panic.S @@ -64,28 +64,10 @@ #include #include +#include "xtensa_macros.S" + #include "chip.h" -/**************************************************************************** - * Assembly Language Macros - ****************************************************************************/ - -/**************************************************************************** - * Name: setintstack - * - * Description: - * Set the current stack pointer to the "top" the interrupt stack. - * Single CPU case. - * Must be provided by MCU-specific logic in the SMP case. - * - ****************************************************************************/ - -#if !defined(CONFIG_SMP) && CONFIG_ARCH_INTERRUPTSTACK > 15 - .macro setintstack tmp1 tmp2 - movi a1, g_intstacktop - .endm -#endif - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -147,14 +129,7 @@ _xtensa_panic: /* Set up PS for C, re-enable hi-pri interrupts, and clear EXCM. */ -#ifdef __XTENSA_CALL0_ABI__ - movi a0, PS_INTLEVEL(XCHAL_EXCM_LEVEL) | PS_UM -#else - movi a0, PS_INTLEVEL(XCHAL_EXCM_LEVEL) | PS_UM | PS_WOE -#endif - - wsr a0, PS - rsync + ps_setup XCHAL_EXCM_LEVEL a0 /* Call C panic handler: Arg1 (A2) = Exception code; Arg 2 (A3) = start * of the register save area. diff --git a/arch/xtensa/src/common/xtensa_user_handler.S b/arch/xtensa/src/common/xtensa_user_handler.S index 61ef9c17422..10b787d6e49 100644 --- a/arch/xtensa/src/common/xtensa_user_handler.S +++ b/arch/xtensa/src/common/xtensa_user_handler.S @@ -64,73 +64,10 @@ #include #include +#include "xtensa_macros.S" + #include "chip.h" -/**************************************************************************** - * Assembly Language Macros - ****************************************************************************/ - -/**************************************************************************** - * Name: setintstack - * - * Description: - * Set the current stack pointer to the "top" the interrupt stack. - * Single CPU case. - * Must be provided by MCU-specific logic in the SMP case. - * - ****************************************************************************/ - -#if !defined(CONFIG_SMP) && CONFIG_ARCH_INTERRUPTSTACK > 15 - .macro setintstack tmp1 tmp2 - movi a1, g_intstacktop - .endm -#endif - -/**************************************************************************** - * Macro: ps_setup - * - * Description: - * Set up PS for C, enable interrupts above this level and clear EXCM. - * - * Entry Conditions: - * level - interrupt level - * tmp - scratch register - * - * Side Effects: - * PS and scratch register modified - * - * Assumptions: - * - PS.EXCM = 1, C calling disabled - * - ****************************************************************************/ - - .macro ps_setup level tmp - -#if 0 /* Nested interrupts no yet supported */ -# ifdef __XTENSA_CALL0_ABI__ - /* Disable interrupts at level and below */ - - movi \tmp, PS_INTLEVEL(\level) | PS_UM -# else - movi \tmp, PS_INTLEVEL(\level) | PS_UM | PS_WOE -# endif -#else -# ifdef __XTENSA_CALL0_ABI__ - /* Disable all low- and medium-priority interrupts. Nested are not yet - * supported. - */ - - movi \tmp, PS_INTLEVEL(XCHAL_EXCM_LEVEL) | PS_UM -# else - movi \tmp, PS_INTLEVEL(XCHAL_EXCM_LEVEL) | PS_UM | PS_WOE -# endif -#endif - - wsr \tmp, PS - rsync - - .endm - /**************************************************************************** * Waypoints ****************************************************************************/