You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2022/04/20 17:59:40 UTC

[incubator-nuttx] branch master updated (0315283c21 -> 64e4c9ca02)

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git


    from 0315283c21 arch/clang: add support for Clang LTO
     new 6db910a1aa arch/xtensa: Use syscall interface for xtensa_save/restore_context.
     new 0831539af1 arch.h: Fix up_exit prototype.
     new 64e4c9ca02 arch/xtensa: Move xtensa_save_context to up_saveusercontext for consistency with other archs.

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 arch/xtensa/src/common/xtensa.h                    | 15 ++--
 arch/xtensa/src/common/xtensa_context.S            | 88 ----------------------
 arch/xtensa/src/common/xtensa_dumpstate.c          |  2 +-
 arch/xtensa/src/common/xtensa_exit.c               |  2 +-
 .../src/common/xtensa_saveusercontext.c}           |  2 +-
 arch/xtensa/src/common/xtensa_switchcontext.c      | 47 ------------
 arch/xtensa/src/esp32/Make.defs                    |  3 +-
 arch/xtensa/src/esp32s2/Make.defs                  |  2 +-
 arch/xtensa/src/esp32s3/Make.defs                  |  2 +-
 include/nuttx/arch.h                               |  2 +-
 10 files changed, 17 insertions(+), 148 deletions(-)
 copy arch/{risc-v/src/common/riscv_saveusercontext.c => xtensa/src/common/xtensa_saveusercontext.c} (97%)
 delete mode 100644 arch/xtensa/src/common/xtensa_switchcontext.c


[incubator-nuttx] 03/03: arch/xtensa: Move xtensa_save_context to up_saveusercontext for consistency with other archs.

Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 64e4c9ca02ddaf5e4b0176bb29aacb4e59fe08d5
Author: Abdelatif Guettouche <ab...@espressif.com>
AuthorDate: Wed Apr 20 17:44:13 2022 +0200

    arch/xtensa: Move xtensa_save_context to up_saveusercontext for
    consistency with other archs.
    
    Signed-off-by: Abdelatif Guettouche <ab...@espressif.com>
---
 arch/xtensa/src/common/xtensa.h                 |  3 --
 arch/xtensa/src/common/xtensa_dumpstate.c       |  2 +-
 arch/xtensa/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(-)

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 <nuttx/config.h>
+
+#include <arch/syscall.h>
+
+/****************************************************************************
+ * 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
 


[incubator-nuttx] 01/03: arch/xtensa: Use syscall interface for xtensa_save/restore_context.

Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 6db910a1aa824f11b55004beee4f8e1d9ecea335
Author: Abdelatif Guettouche <ab...@espressif.com>
AuthorDate: Wed Apr 20 04:30:00 2022 +0200

    arch/xtensa: Use syscall interface for xtensa_save/restore_context.
    
    Signed-off-by: Abdelatif Guettouche <ab...@espressif.com>
---
 arch/xtensa/src/common/xtensa.h               | 18 ++++--
 arch/xtensa/src/common/xtensa_context.S       | 88 ---------------------------
 arch/xtensa/src/common/xtensa_exit.c          |  2 +-
 arch/xtensa/src/common/xtensa_switchcontext.c | 47 --------------
 arch/xtensa/src/esp32/Make.defs               |  2 +-
 arch/xtensa/src/esp32s2/Make.defs             |  1 -
 arch/xtensa/src/esp32s3/Make.defs             |  1 -
 7 files changed, 14 insertions(+), 145 deletions(-)

diff --git a/arch/xtensa/src/common/xtensa.h b/arch/xtensa/src/common/xtensa.h
index a984976ef0..0af851cc05 100644
--- a/arch/xtensa/src/common/xtensa.h
+++ b/arch/xtensa/src/common/xtensa.h
@@ -32,6 +32,7 @@
 #  include <stdint.h>
 #  include <sys/types.h>
 #  include <stdbool.h>
+#  include <syscall.h>
 #endif
 
 #include <arch/chip/core-isa.h>
@@ -112,6 +113,17 @@
 #define xtensa_savestate(regs)    xtensa_copystate(regs, (uint32_t*)CURRENT_REGS)
 #define xtensa_restorestate(regs) do { CURRENT_REGS = regs; } while (0)
 
+/* 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)
+
+#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
@@ -279,12 +291,6 @@ int xtensa_intercpu_interrupt(int tocpu, int intcode);
 void xtensa_pause_handler(void);
 #endif
 
-/* Synchronous context switching */
-
-int xtensa_context_save(uint32_t *regs);
-void xtensa_context_restore(uint32_t *regs) noreturn_function;
-void xtensa_switchcontext(uint32_t *saveregs, uint32_t *restoreregs);
-
 #if XCHAL_CP_NUM > 0
 void xtensa_coproc_savestate(struct xtensa_cpstate_s *cpstate);
 void xtensa_coproc_restorestate(struct xtensa_cpstate_s *cpstate);
diff --git a/arch/xtensa/src/common/xtensa_context.S b/arch/xtensa/src/common/xtensa_context.S
index 539518394a..1521b53b24 100644
--- a/arch/xtensa/src/common/xtensa_context.S
+++ b/arch/xtensa/src/common/xtensa_context.S
@@ -204,47 +204,6 @@ _xtensa_context_save:
 
 	.size	_xtensa_context_save, . - _xtensa_context_save
 
-/****************************************************************************
- * Name: xtensa_context_save
- *
- * Description:
- *
- *   This function implements the moral equivalent of setjmp().  It is
- *   called from user code (with interrupts disabled) to save the current
- *   state of the running thread.  This function always returns zero.
- *
- *   The counterpart to this function is xtensa_context_restore().
- *
- * Input State:
- *   a0 = The true return value to the caller.
- *   a2 = The address of the register state structure
- *
- * Return state:
- *   a0, a2, and a3 modified.
- *   Returned value is in a2
- *
- ****************************************************************************/
-
-	.global	xtensa_context_save
-	.type	xtensa_context_save, @function
-
-	.align	4
-	.literal_position
-	.align	4
-
-xtensa_context_save:
-	ENTRY(16)
-
-	mov  a3, a2
-	movi a2, SYS_save_context
-	movi a4, XCHAL_SWINT_CALL
-	wsr  a4, intset
-	rsync
-
-	RET(16)
-
-	.size	xtensa_context_save, . - xtensa_context_save
-
 /****************************************************************************
  * Name: _xtensa_context_restore
  *
@@ -331,50 +290,3 @@ _xtensa_context_restore:
 
 	.size	_xtensa_context_restore, . - _xtensa_context_restore
 
-/****************************************************************************
- * Name: xtensa_context_restore
- *
- * Description:
- *
- *   This functions implements the moral equivalent of longjmp().  It is
- *   called from user code (with interrupts disabled) to restore the current
- *   state of the running thread.  This function always appears to be a
- *   second return from xtensa_context_save except that that it returns the
- *   value 1 (because the saved value of A2 was set to 1
- *   inxtensa_context_save()).
- *
- *   The counterpart to this function is xtensa_context_save().
- *
- * Entry Conditions:
- *   - A0  = Return address to caller.
- *   - A2  = Pointer to the processor state save area
- *
- * Exit conditions:
- *   NOTE: That this function does NOT return to the caller but rather
- *   to a new threading context.  It is not necessary to save any of the
- *   caller's registers.
- *
- * Assumptions:
- *   - Interrupts are disabled.
- *
- ****************************************************************************/
-
-	.global	xtensa_context_restore
-	.type	xtensa_context_restore, @function
-
-	.align	4
-	.literal_position
-	.align	4
-
-xtensa_context_restore:
-	ENTRY(16)
-
-	mov  a3, a2
-	movi a2, SYS_restore_context
-	movi a4, XCHAL_SWINT_CALL
-	wsr  a4, intset
-	rsync
-
-	RET(16)
-
-	.size	xtensa_context_restore, . - xtensa_context_restore
diff --git a/arch/xtensa/src/common/xtensa_exit.c b/arch/xtensa/src/common/xtensa_exit.c
index bbd050afa1..66f529ff8c 100644
--- a/arch/xtensa/src/common/xtensa_exit.c
+++ b/arch/xtensa/src/common/xtensa_exit.c
@@ -151,5 +151,5 @@ void up_exit(int status)
    * software interrupts are disabled.
    */
 
-  DEBUGPANIC();
+  PANIC();
 }
diff --git a/arch/xtensa/src/common/xtensa_switchcontext.c b/arch/xtensa/src/common/xtensa_switchcontext.c
deleted file mode 100644
index 3aecda2a99..0000000000
--- a/arch/xtensa/src/common/xtensa_switchcontext.c
+++ /dev/null
@@ -1,47 +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 <nuttx/config.h>
-
-#include "syscall.h"
-
-/****************************************************************************
- * Public Functions
- ****************************************************************************/
-
-/****************************************************************************
- * Name: xtensa_switchcontext
- *
- * Description:
- *   Save the current thread context and restore the specified context.
- *
- * Returned Value:
- *   None
- *
- ****************************************************************************/
-
-void xtensa_switchcontext(uint32_t *saveregs, uint32_t *restoreregs)
-{
-  sys_call2(SYS_switch_context, (uintptr_t)saveregs, (uintptr_t)restoreregs);
-}
diff --git a/arch/xtensa/src/esp32/Make.defs b/arch/xtensa/src/esp32/Make.defs
index 77fd05d0f4..9a2c846565 100644
--- a/arch/xtensa/src/esp32/Make.defs
+++ b/arch/xtensa/src/esp32/Make.defs
@@ -39,7 +39,7 @@ CMN_CSRCS += xtensa_modifyreg8.c xtensa_modifyreg16.c xtensa_modifyreg32.c
 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 xtensa_switchcontext.c
+CMN_CSRCS += xtensa_unblocktask.c xtensa_usestack.c xtensa_swint.c
 
 # Configuration-dependent common XTENSA files
 
diff --git a/arch/xtensa/src/esp32s2/Make.defs b/arch/xtensa/src/esp32s2/Make.defs
index 74ddefa0af..59eaad7755 100644
--- a/arch/xtensa/src/esp32s2/Make.defs
+++ b/arch/xtensa/src/esp32s2/Make.defs
@@ -40,7 +40,6 @@ 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_switchcontext.c
 
 # Configuration-dependent common XTENSA files
 
diff --git a/arch/xtensa/src/esp32s3/Make.defs b/arch/xtensa/src/esp32s3/Make.defs
index 2ffe1d149a..fe04717293 100644
--- a/arch/xtensa/src/esp32s3/Make.defs
+++ b/arch/xtensa/src/esp32s3/Make.defs
@@ -40,7 +40,6 @@ 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_switchcontext.c
 
 # Configuration-dependent common XTENSA files
 


[incubator-nuttx] 02/03: arch.h: Fix up_exit prototype.

Posted by xi...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit 0831539af14704c51114dace8c90e0d2e5469b69
Author: Abdelatif Guettouche <ab...@espressif.com>
AuthorDate: Wed Apr 20 12:25:35 2022 +0200

    arch.h: Fix up_exit prototype.
    
    Signed-off-by: Abdelatif Guettouche <ab...@espressif.com>
---
 include/nuttx/arch.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/nuttx/arch.h b/include/nuttx/arch.h
index 2a930d1e7d..c269ec6f36 100644
--- a/include/nuttx/arch.h
+++ b/include/nuttx/arch.h
@@ -479,7 +479,7 @@ void up_reprioritize_rtr(FAR struct tcb_s *tcb, uint8_t priority);
  *
  ****************************************************************************/
 
-void up_exit() noreturn_function;
+void up_exit(int status) noreturn_function;
 
 /* Prototype is in unistd.h */