xiaoxiang781216 commented on code in PR #6302:
URL: https://github.com/apache/incubator-nuttx/pull/6302#discussion_r878349648


##########
arch/xtensa/src/common/xtensa_coproc.S:
##########
@@ -89,31 +85,18 @@ _xtensa_coproc_saoffsets:
  *   around the assembly language call to _xtensa_coproc_savestate.
  *
  * Entry Conditions:
- *   - A2 holds the address of current interrupt stack pointer.
+ *   in - Pointer to where the save is performed (e.g. a2)
  *   - Registers have been saved/spilled already.
  *
  * Exit conditions:
  *   - All necessary CP callee-saved state has been saved.
- *   - Registers a2-a7, a13-a15 have been trashed.
- *
- * Must be called from assembly code only, using CALL0.
+ *   - Registers a2-a7, a13-a14 have been trashed.
  *
  ****************************************************************************/
 
-  .global      _xtensa_coproc_savestate
-  .type        _xtensa_coproc_savestate, @function
-
-  .align       4
-  .literal_position
-  .align       4
-
-_xtensa_coproc_savestate:
-
-       /* Move the address of the thread state save area to R15 */
+       .macro xtensa_coproc_savestate in

Review Comment:
   why need in argument? Since xtensa_coproc_savestate already touch many 
registers(a2-a7, a13-a14), we can directly:
   ```
   .macro xtensa_coproc_savestate
   add a3, sp, (4 * XCPTCONTEXT_REGS)
   ```
   and keep the rest unchanged.



##########
arch/xtensa/src/common/xtensa_context.S:
##########
@@ -66,6 +66,7 @@
 #include <arch/xtensa/xtensa_abi.h>
 #include <arch/xtensa/xtensa_specregs.h>
 
+#include "xtensa_coproc.S"

Review Comment:
   move after line 71



##########
arch/xtensa/src/common/xtensa_coproc.S:
##########
@@ -216,28 +198,15 @@ _xtensa_coproc_savestate:
  *   around the assembly language call to _xtensa_coproc_restorestate.
  *
  * Entry Conditions:
- *   - A2 holds the address of the current interrupt stack pointer.
+ *   in - Pointer to where the save is performed (e.g. a2)
  *
  * Exit conditions:
  *   - All necessary CP callee-saved state has been restored.
- *   - Registers a2-a7, a13-a15 have been trashed.
- *
- * Must be called from assembly code only, using CALL0.
+ *   - Registers a2-a7, a13-a14 have been trashed.
  *
  ****************************************************************************/
 
-       .global _xtensa_coproc_restorestate
-       .type   _xtensa_coproc_restorestate, @function
-
-       .align  4
-       .literal_position
-       .align  4
-
-_xtensa_coproc_restorestate:
-
-       /* Move the address of the thread state save area to R15 */
-
-       mov             a3, a2                          /* A3 is now the 
address of the save area */
+       .macro xtensa_coproc_restorestate out

Review Comment:
   ditto, let's:
   ```
   .macro xtensa_coproc_restorestate
   addi         a3, a2, (4 * XCPTCONTEXT_REGS)
   ```
   and keep the rest unchanged.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to