diff --git a/arch/xtensa/include/esp32/irq.h b/arch/xtensa/include/esp32/irq.h index a91ee2a2d60..3bc5270d6a6 100644 --- a/arch/xtensa/include/esp32/irq.h +++ b/arch/xtensa/include/esp32/irq.h @@ -495,6 +495,23 @@ static inline_function int esp32_irq_gpio(int cpu) #endif #endif +#ifdef CONFIG_ARCH_HAVE_MULTICPU +noinstrument_function +static inline_function int xtensa_cpu_index(void) +{ + int index; + + __asm__ __volatile__ + ( + "rsr.prid %0\n" + "extui %0,%0,13,1\n" + : "=r"(index) + ); + + return index; +} +#endif /* CONFIG_ARCH_HAVE_MULTICPU */ + /**************************************************************************** * Public Data ****************************************************************************/ diff --git a/arch/xtensa/include/esp32s3/irq.h b/arch/xtensa/include/esp32s3/irq.h index a7eb48bec6a..06de3c37e71 100644 --- a/arch/xtensa/include/esp32s3/irq.h +++ b/arch/xtensa/include/esp32s3/irq.h @@ -498,6 +498,23 @@ * Inline functions ****************************************************************************/ +#ifdef CONFIG_ARCH_HAVE_MULTICPU +noinstrument_function +static inline_function int xtensa_cpu_index(void) +{ + int index; + + __asm__ __volatile__ + ( + "rsr.prid %0\n" + "extui %0,%0,13,1\n" + : "=r"(index) + ); + + return index; +} +#endif /* CONFIG_ARCH_HAVE_MULTICPU */ + /**************************************************************************** * Public Data ****************************************************************************/ diff --git a/arch/xtensa/include/irq.h b/arch/xtensa/include/irq.h index 8e45fa8d897..f62ae250788 100644 --- a/arch/xtensa/include/irq.h +++ b/arch/xtensa/include/irq.h @@ -408,7 +408,11 @@ irqstate_t xtensa_disable_interrupts(irqstate_t mask); ****************************************************************************/ #ifdef CONFIG_ARCH_HAVE_MULTICPU -int up_cpu_index(void) noinstrument_function; +noinstrument_function +static inline_function int up_cpu_index(void) +{ + return xtensa_cpu_index(); +} #endif /* CONFIG_ARCH_HAVE_MULTICPU */ /**************************************************************************** diff --git a/arch/xtensa/src/esp32/Make.defs b/arch/xtensa/src/esp32/Make.defs index 3cd9cf8723c..d607dcec60e 100644 --- a/arch/xtensa/src/esp32/Make.defs +++ b/arch/xtensa/src/esp32/Make.defs @@ -133,10 +133,6 @@ ifeq ($(CONFIG_SMP),y) CHIP_CSRCS += esp32_cpuidlestack.c esp32_cpustart.c esp32_intercpu_interrupt.c endif -ifeq ($(CONFIG_ARCH_HAVE_MULTICPU),y) -CHIP_ASRCS = esp32_cpuindex.S -endif - ifeq ($(CONFIG_ESP32_UART),y) CHIP_CSRCS += esp32_serial.c endif diff --git a/arch/xtensa/src/esp32/esp32_cpuindex.S b/arch/xtensa/src/esp32/esp32_cpuindex.S deleted file mode 100644 index 24f24f0e96f..00000000000 --- a/arch/xtensa/src/esp32/esp32_cpuindex.S +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** - * arch/xtensa/src/esp32/esp32_cpuindex.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_cpumacros.S" - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include -#include "chip_macros.h" - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: up_cpu_index - * - * Description: - * Return the real core number regardless CONFIG_SMP setting - * - ****************************************************************************/ - - .text - .align 4 - .global up_cpu_index - .type up_cpu_index, @function - -up_cpu_index: - ENTRY(16) - getcoreid a2 - RET(16) - - .size up_cpu_index, . - up_cpu_index diff --git a/arch/xtensa/src/esp32s3/Make.defs b/arch/xtensa/src/esp32s3/Make.defs index 0732ee0465c..f5c876e8856 100644 --- a/arch/xtensa/src/esp32s3/Make.defs +++ b/arch/xtensa/src/esp32s3/Make.defs @@ -47,10 +47,6 @@ ifeq ($(CONFIG_SMP),y) CHIP_CSRCS += esp32s3_cpuidlestack.c esp32s3_cpustart.c esp32s3_intercpu_interrupt.c endif -ifeq ($(CONFIG_ARCH_HAVE_MULTICPU),y) -CHIP_ASRCS = esp32s3_cpuindex.S -endif - ifeq ($(CONFIG_ESP32S3_EFUSE),y) CHIP_CSRCS += esp32s3_efuse.c CHIP_CSRCS += esp32s3_efuse_table.c diff --git a/arch/xtensa/src/esp32s3/esp32s3_cpuindex.S b/arch/xtensa/src/esp32s3/esp32s3_cpuindex.S deleted file mode 100644 index 1984996db31..00000000000 --- a/arch/xtensa/src/esp32s3/esp32s3_cpuindex.S +++ /dev/null @@ -1,52 +0,0 @@ -/**************************************************************************** - * arch/xtensa/src/esp32s3/esp32s3_cpuindex.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 "esp32s3_cpuindex.S" - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include -#include "chip_macros.h" - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: up_cpu_index - * - * Description: - * Return the real core number regardless CONFIG_SMP setting - * - ****************************************************************************/ - - .text - .align 4 - .global up_cpu_index - .type up_cpu_index, @function - -up_cpu_index: - ENTRY(16) - getcoreid a2 - RET(16) - - .size up_cpu_index, . - up_cpu_index