diff --git a/arch/xtensa/include/irq.h b/arch/xtensa/include/irq.h index e1aacd825b..6db63a6fbe 100644 --- a/arch/xtensa/include/irq.h +++ b/arch/xtensa/include/irq.h @@ -39,6 +39,7 @@ #include #ifndef __ASSEMBLY__ # include +# include #endif #include @@ -448,6 +449,15 @@ noinstrument_function static inline_function bool up_interrupt_context(void) } #endif +#define up_switch_context(tcb, rtcb) \ + do { \ + if (!up_interrupt_context()) \ + { \ + sys_call0(SYS_switch_context); \ + } \ + UNUSED(rtcb); \ + } while (0) + /**************************************************************************** * Name: up_getusrpc ****************************************************************************/ diff --git a/arch/xtensa/src/common/CMakeLists.txt b/arch/xtensa/src/common/CMakeLists.txt index fc6d69a9f5..a3c89b037c 100644 --- a/arch/xtensa/src/common/CMakeLists.txt +++ b/arch/xtensa/src/common/CMakeLists.txt @@ -71,7 +71,6 @@ list( xtensa_releasestack.c xtensa_registerdump.c xtensa_sigdeliver.c - xtensa_switchcontext.c xtensa_swint.c xtensa_stackframe.c xtensa_saveusercontext.c diff --git a/arch/xtensa/src/common/Make.defs b/arch/xtensa/src/common/Make.defs index 79949ab29e..e62a973af8 100644 --- a/arch/xtensa/src/common/Make.defs +++ b/arch/xtensa/src/common/Make.defs @@ -36,7 +36,7 @@ CMN_CSRCS += xtensa_irqdispatch.c xtensa_lowputs.c xtensa_mdelay.c CMN_CSRCS += xtensa_modifyreg8.c xtensa_modifyreg16.c xtensa_modifyreg32.c CMN_CSRCS += xtensa_mpu.c xtensa_nputs.c xtensa_oneshot.c xtensa_perf.c CMN_CSRCS += xtensa_releasestack.c xtensa_registerdump.c xtensa_sigdeliver.c -CMN_CSRCS += xtensa_switchcontext.c xtensa_swint.c xtensa_stackframe.c +CMN_CSRCS += xtensa_swint.c xtensa_stackframe.c CMN_CSRCS += xtensa_saveusercontext.c xtensa_schedsigaction.c xtensa_udelay.c CMN_CSRCS += xtensa_usestack.c xtensa_tcbinfo.c diff --git a/arch/xtensa/src/common/xtensa.h b/arch/xtensa/src/common/xtensa.h index a657afc0be..49ed92c5d1 100644 --- a/arch/xtensa/src/common/xtensa.h +++ b/arch/xtensa/src/common/xtensa.h @@ -109,8 +109,6 @@ #define xtensa_context_restore() sys_call0(SYS_restore_context) -#define xtensa_switchcontext() sys_call0(SYS_switch_context) - /* Interrupt codes from other CPUs: */ #define CPU_INTCODE_NONE 0 diff --git a/arch/xtensa/src/common/xtensa_switchcontext.c b/arch/xtensa/src/common/xtensa_switchcontext.c deleted file mode 100644 index 645b7f0f0f..0000000000 --- a/arch/xtensa/src/common/xtensa_switchcontext.c +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** - * arch/xtensa/src/common/xtensa_switchcontext.c - * - * SPDX-License-Identifier: Apache-2.0 - * - * 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. - * - ****************************************************************************/ - -/**************************************************************************** - * Included Files - ****************************************************************************/ - -#include - -#include -#include -#include - -#include -#include -#include - -#include "sched/sched.h" -#include "group/group.h" -#include "clock/clock.h" -#include "xtensa.h" - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: up_switch_context - * - * Description: - * A task is currently in the ready-to-run list but has been prepped - * to execute. Restore its context, and start execution. - * - * Input Parameters: - * tcb: Refers to the head task of the ready-to-run list - * which will be executed. - * rtcb: Refers to the running task which will be blocked. - * - ****************************************************************************/ - -void up_switch_context(struct tcb_s *tcb, struct tcb_s *rtcb) -{ - /* Are we in an interrupt handler? */ - - if (!up_interrupt_context()) - { - /* Switch context to the context of the task at the head of the - * ready to run list. - */ - - xtensa_switchcontext(); - - /* xtensa_switchcontext forces a context switch to the task at the - * head of the ready-to-run list. It does not 'return' in the - * normal sense. When it does return, it is because the blocked - * task is again ready to run and has execution priority. - */ - } -}