From 64e4c9ca02ddaf5e4b0176bb29aacb4e59fe08d5 Mon Sep 17 00:00:00 2001 From: Abdelatif Guettouche Date: Wed, 20 Apr 2022 17:44:13 +0200 Subject: [PATCH] arch/xtensa: Move xtensa_save_context to up_saveusercontext for consistency with other archs. Signed-off-by: Abdelatif Guettouche --- arch/xtensa/src/common/xtensa.h | 3 -- arch/xtensa/src/common/xtensa_dumpstate.c | 2 +- .../src/common/xtensa_saveusercontext.c | 50 +++++++++++++++++++ arch/xtensa/src/esp32/Make.defs | 1 + arch/xtensa/src/esp32s2/Make.defs | 1 + arch/xtensa/src/esp32s3/Make.defs | 1 + 6 files changed, 54 insertions(+), 4 deletions(-) create mode 100644 arch/xtensa/src/common/xtensa_saveusercontext.c diff --git a/arch/xtensa/src/common/xtensa.h b/arch/xtensa/src/common/xtensa.h index 0af851cc05..3828cbf527 100644 --- a/arch/xtensa/src/common/xtensa.h +++ b/arch/xtensa/src/common/xtensa.h @@ -115,9 +115,6 @@ /* Context switching via system calls ***************************************/ -#define xtensa_context_save(regs)\ - sys_call1(SYS_save_context, (uintptr_t)regs) - #define xtensa_context_restore(regs)\ sys_call1(SYS_restore_context, (uintptr_t)regs) diff --git a/arch/xtensa/src/common/xtensa_dumpstate.c b/arch/xtensa/src/common/xtensa_dumpstate.c index 1b9e59fcd5..d2aaec56e1 100644 --- a/arch/xtensa/src/common/xtensa_dumpstate.c +++ b/arch/xtensa/src/common/xtensa_dumpstate.c @@ -300,7 +300,7 @@ void xtensa_dumpstate(void) } else { - xtensa_context_save(rtcb->xcp.regs); + up_saveusercontext(rtcb->xcp.regs); } /* Dump the registers (if available) */ diff --git a/arch/xtensa/src/common/xtensa_saveusercontext.c b/arch/xtensa/src/common/xtensa_saveusercontext.c new file mode 100644 index 0000000000..5d436674ee --- /dev/null +++ b/arch/xtensa/src/common/xtensa_saveusercontext.c @@ -0,0 +1,50 @@ +/**************************************************************************** + * arch/xtensa/src/common/xtensa_saveusercontext.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 + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: up_saveusercontext + * + * Description: + * Save the current thread context. Full prototype is: + * + * int up_saveusercontext(void *saveregs); + * + * Returned Value: + * 0: Normal return + * 1: Context switch return + * + ****************************************************************************/ + +int up_saveusercontext(void *saveregs) +{ + return sys_call1(SYS_save_context, (uintptr_t)saveregs); +} diff --git a/arch/xtensa/src/esp32/Make.defs b/arch/xtensa/src/esp32/Make.defs index 9a2c846565..90bda81fec 100644 --- a/arch/xtensa/src/esp32/Make.defs +++ b/arch/xtensa/src/esp32/Make.defs @@ -40,6 +40,7 @@ CMN_CSRCS += xtensa_puts.c xtensa_releasepending.c xtensa_releasestack.c CMN_CSRCS += xtensa_reprioritizertr.c xtensa_schedsigaction.c CMN_CSRCS += xtensa_sigdeliver.c xtensa_stackframe.c xtensa_udelay.c CMN_CSRCS += xtensa_unblocktask.c xtensa_usestack.c xtensa_swint.c +CMN_CSRCS += xtensa_saveusercontext.c # Configuration-dependent common XTENSA files diff --git a/arch/xtensa/src/esp32s2/Make.defs b/arch/xtensa/src/esp32s2/Make.defs index 59eaad7755..5cb84c637d 100644 --- a/arch/xtensa/src/esp32s2/Make.defs +++ b/arch/xtensa/src/esp32s2/Make.defs @@ -40,6 +40,7 @@ CMN_CSRCS += xtensa_puts.c xtensa_releasepending.c xtensa_releasestack.c CMN_CSRCS += xtensa_reprioritizertr.c xtensa_schedsigaction.c CMN_CSRCS += xtensa_sigdeliver.c xtensa_stackframe.c xtensa_udelay.c CMN_CSRCS += xtensa_unblocktask.c xtensa_usestack.c xtensa_swint.c +CMN_CSRCS += xtensa_saveusercontext.c # Configuration-dependent common XTENSA files diff --git a/arch/xtensa/src/esp32s3/Make.defs b/arch/xtensa/src/esp32s3/Make.defs index fe04717293..cd5373e5c5 100644 --- a/arch/xtensa/src/esp32s3/Make.defs +++ b/arch/xtensa/src/esp32s3/Make.defs @@ -40,6 +40,7 @@ CMN_CSRCS += xtensa_puts.c xtensa_releasepending.c xtensa_releasestack.c CMN_CSRCS += xtensa_reprioritizertr.c xtensa_schedsigaction.c CMN_CSRCS += xtensa_sigdeliver.c xtensa_stackframe.c xtensa_udelay.c CMN_CSRCS += xtensa_unblocktask.c xtensa_usestack.c xtensa_swint.c +CMN_CSRCS += xtensa_saveusercontext.c # Configuration-dependent common XTENSA files