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/03/14 03:12:44 UTC

[incubator-nuttx] 01/09: xtensa_context.S: Remove the CALL0 ABI version of xtensa_context_switch as it's the same as the Window ABI now.

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 e9018b29bf758c4721917a70c356b2c47176c199
Author: Abdelatif Guettouche <ab...@espressif.com>
AuthorDate: Fri Mar 11 15:58:56 2022 +0100

    xtensa_context.S: Remove the CALL0 ABI version of xtensa_context_switch
    as it's the same as the Window ABI now.
    
    Signed-off-by: Abdelatif Guettouche <ab...@espressif.com>
---
 arch/xtensa/src/common/xtensa_context.S | 118 +++-----------------------------
 1 file changed, 9 insertions(+), 109 deletions(-)

diff --git a/arch/xtensa/src/common/xtensa_context.S b/arch/xtensa/src/common/xtensa_context.S
index fa5850d..6e9b41b 100644
--- a/arch/xtensa/src/common/xtensa_context.S
+++ b/arch/xtensa/src/common/xtensa_context.S
@@ -82,21 +82,17 @@
  *
  *   NOTE: MUST BE CALLED ONLY BY 'CALL0' INSTRUCTION!
  *
- *   This function saves Xtensa processor state:  xtensa_context_save
- *   saves all registers except PC, PS, A0, A1 (SP), and A2
- *
- *   This function is called directly by interrupt handling logic and from
- *   xtensa_context_save() below with interrupts disabled.  In either calling
- *   context, caller saves PC, PS, A0, A1 (SP), and A2.  This
- *   logic also executes indirectly from xtensa_context_save() by falling
- *   through from above.
+ *   This function saves Xtensa processor state.
+ *   It is called directly by interrupt handling logic with interrupts
+ *   disabled.  Registers PC, PS, A0, A1 (SP), A2 and A3 are saved before
+ *   calling this function. 
  *
  *   The counterpart to this function is _xtensa_context_restore().
  *
  * Entry Conditions:
  *   - A0  = Return address to caller.
  *   - A2  = Pointer to the processor state save area
- *   - Other processor state except PC, PS, A0, A1 (SP), and A2 are as at
+ *   - Other processor state except PC, PS, A0, A1 (SP), A2 and A3 are as at
  *     the point of interruption.
  *
  * Exit conditions:
@@ -185,107 +181,12 @@ _xtensa_context_save:
  *
  * Description:
  *
- *   This functions implements the moral equivalent of setjmp().  It is
+ *   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.
- *   However, it sets the saved value of the return address (A2) to 1.
- *   If the thread is s via _xtensa_context_restore or
- *   xtensa_context_restore, it will appear as a second return from
- *   xtensa_context_save but with the returned value of 1 to distinguish
- *   the two cases.
  *
  *   The counterpart to this function is xtensa_context_restore().
  *
- * Entry Conditions:
- *   - A0  = Return address to caller.
- *   - A2  = Pointer to the processor state save area
- *
- * Exit conditions:
- *   - A0  = Return address in caller.
- *   - A2  = 0
- *
- * Assumptions:
- *   - Interrupts are disabled.
- *
- ****************************************************************************/
-
-#ifdef __XTENSA_CALL0_ABI__
-
-/****************************************************************************
- * Name: xtensa_context_save:
- *
- * Description:
- *   This implementation of xtensa_context_save for the case of the CALL0 ABI
- *
- * Input State:
- *   a0 = The return value to the caller.
- *   a2 = The address of the register state structure
- *
- * Return state:
- *   a0 = The return value to the caller.
- *   a2, a12-a15 preserved as at entry
- *
- ****************************************************************************/
-
-	.global	xtensa_context_save
-	.type	xtensa_context_save, @function
-
-	.align	4
-	.literal_position
-	.align	4
-
-xtensa_context_save:
-	ENTRY(16)
-
-	/* Set up for (potential) call to _xtensa_context_save() */
-
-	s32i	a3,  a2, (4 * REG_A3)			/* Get  scratch register */
-	rsr		a3, PS							/* Save callee's PS */
-	s32i	a3, a2, (4 * REG_PS)
-	s32i	a0, a2, (4 * REG_PC)			/* Save Return address as PC */
-
-	s32i	a0, a2, (4 * REG_A0)			/* Save callee's a0 */
-	s32i	sp, a2, (4 * REG_A1)			/* Save callee's SP */
-	movi	a3, 1							/* Set saved A2 to 1 */
-	s32i	a3, a2, (4 * REG_A2)
-
-	/* Save the rest of the processor state.  For the CALL0 ABI, we can use
-	 * _xtensa_context_save(),  Otherwise we duplicate the context save here
-	 * to avoid the window spill.
-	 */
-
-	l32i	a3, a2, (4 * REG_A3)			/* Recover original a3 */
-	call0	_xtensa_context_save			/* Save full register state */
-
-	/* Recover the return address and return zero */
-
-	l32i	a0, a2, (4 * REG_A0)			/* Recover return address */
-	movi	a2, 0							/* Return zero */
-	RET(16)
-
-	.size	xtensa_context_save, . - xtensa_context_save
-#endif
-
-/****************************************************************************
- * This implementation of xtensa_context_save for the case of the window ABI.
- * This case is more complex.  For the Window ABI, there is a "hook" that
- * performs the low level state.  xtensa_context_save() is simply a
- * trampoline function that performs the window operations in that
- * configuration.
- ****************************************************************************/
-
-#ifndef __XTENSA_CALL0_ABI__
-
-/****************************************************************************
- * Name: xtensa_context_save:
- *
- * Description:
- *   This is the implementation of xtensa_context_save for the case of the
- *   window ABI.  In the window ABI configuration, xtensa_context_save is a
- *   thin  "trampoline" layer.  It performs the ENTRY window operations on
- *   entry and the exit.  A call0 is used to force the return from the context
- *   switch to the window return within this trampoline.
- *
  * Input State:
  *   a0 = The true return value to the caller.
  *   a2 = The address of the register state structure
@@ -315,7 +216,6 @@ xtensa_context_save:
 	RET(16)
 
 	.size	xtensa_context_save, . - xtensa_context_save
-#endif
 
 /****************************************************************************
  * Name: _xtensa_context_restore
@@ -324,9 +224,9 @@ xtensa_context_save:
  *
  *   NOTE: MUST BE CALLED ONLY BY 'CALL0' INSTRUCTION!
  *
- *   These functions restores Xtensa processor state and differ in which
- *   registers are saved: _xtensa_context_restore() restores all registers
- *   except PC, PS, A0, and A2
+ *   This function restores Xtensa processor state.
+ *   It is called directly by interrupt handling logic with interrupts
+ *   disabled.  It restores all registers except PC, PS, A0, and A2
  *
  *   The caller is responsible for restoring PC, PS, A0, and A2.
  *