diff --git a/arch/xtensa/include/irq.h b/arch/xtensa/include/irq.h index f680b3dec0c..36a63bef284 100644 --- a/arch/xtensa/include/irq.h +++ b/arch/xtensa/include/irq.h @@ -37,6 +37,7 @@ #include #ifndef __ASSEMBLY__ # include +# include #endif #include @@ -458,6 +459,15 @@ noinstrument_function static inline_function bool up_interrupt_context(void) } #endif +#define up_switch_context(tcb, rtcb) \ + do { \ + if (!up_interrupt_context()) \ + { \ + sys_call2(SYS_switch_context, (uintptr_t)&rtcb->xcp.regs, \ + (uintptr_t)tcb->xcp.regs); \ + } \ + } while (0) + /**************************************************************************** * Name: up_getusrpc ****************************************************************************/ diff --git a/arch/xtensa/src/common/CMakeLists.txt b/arch/xtensa/src/common/CMakeLists.txt index 154bee98990..e677de7893e 100644 --- a/arch/xtensa/src/common/CMakeLists.txt +++ b/arch/xtensa/src/common/CMakeLists.txt @@ -69,7 +69,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 061575726be..8209da1bdd6 100644 --- a/arch/xtensa/src/common/Make.defs +++ b/arch/xtensa/src/common/Make.defs @@ -34,7 +34,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 f0eb3a5ff34..5d9edb40fa6 100644 --- a/arch/xtensa/src/common/xtensa.h +++ b/arch/xtensa/src/common/xtensa.h @@ -108,9 +108,6 @@ #define xtensa_context_restore(regs)\ sys_call1(SYS_restore_context, (uintptr_t)regs) -#define xtensa_switchcontext(saveregs, restoreregs)\ - sys_call2(SYS_switch_context, (uintptr_t)saveregs, (uintptr_t)restoreregs) - /* 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 a98e3e1069c..00000000000 --- a/arch/xtensa/src/common/xtensa_switchcontext.c +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** - * arch/xtensa/src/common/xtensa_switchcontext.c - * - * 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_current_regs()) - { - /* Switch context to the context of the task at the head of the - * ready to run list. - */ - - xtensa_switchcontext(&rtcb->xcp.regs, tcb->xcp.regs); - - /* 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. - */ - } -}