This is an automated email from the ASF dual-hosted git repository. gustavonihei pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git
commit 98d8d2a1ff4e60514e7c18a7b1607430c1310d06 Author: Abdelatif Guettouche <abdelatif.guettou...@espressif.com> AuthorDate: Mon Apr 25 15:31:24 2022 +0200 arch/xtensa: Group all the macros in one file. Signed-off-by: Abdelatif Guettouche <abdelatif.guettou...@espressif.com> --- arch/xtensa/src/common/xtensa_int_handlers.S | 67 ++------------------ arch/xtensa/src/common/xtensa_macros.S | 94 ++++++++++++++++++++++++++++ arch/xtensa/src/common/xtensa_panic.S | 31 +-------- arch/xtensa/src/common/xtensa_user_handler.S | 67 +------------------- 4 files changed, 105 insertions(+), 154 deletions(-) diff --git a/arch/xtensa/src/common/xtensa_int_handlers.S b/arch/xtensa/src/common/xtensa_int_handlers.S index 5f405aa8c0..bc5d141b49 100644 --- a/arch/xtensa/src/common/xtensa_int_handlers.S +++ b/arch/xtensa/src/common/xtensa_int_handlers.S @@ -64,10 +64,16 @@ #include <arch/xtensa/xtensa_abi.h> #include <arch/xtensa/xtensa_specregs.h> +#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 0000000000..cb57846d1c --- /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 <nuttx/config.h> + +#include <arch/irq.h> +#include <arch/chip/core-isa.h> +#include <arch/xtensa/xtensa_abi.h> +#include <arch/xtensa/xtensa_specregs.h> + +/**************************************************************************** + * 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 f5ebd53801..dbd2ce7099 100644 --- a/arch/xtensa/src/common/xtensa_panic.S +++ b/arch/xtensa/src/common/xtensa_panic.S @@ -64,27 +64,9 @@ #include <arch/xtensa/core.h> #include <arch/xtensa/xtensa_specregs.h> -#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. - * - ****************************************************************************/ +#include "xtensa_macros.S" -#if !defined(CONFIG_SMP) && CONFIG_ARCH_INTERRUPTSTACK > 15 - .macro setintstack tmp1 tmp2 - movi a1, g_intstacktop - .endm -#endif +#include "chip.h" /**************************************************************************** * 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 61ef9c1742..10b787d6e4 100644 --- a/arch/xtensa/src/common/xtensa_user_handler.S +++ b/arch/xtensa/src/common/xtensa_user_handler.S @@ -64,72 +64,9 @@ #include <arch/xtensa/core.h> #include <arch/xtensa/xtensa_specregs.h> -#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 +#include "xtensa_macros.S" -/**************************************************************************** - * 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 +#include "chip.h" /**************************************************************************** * Waypoints