You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "zyfeier (via GitHub)" <gi...@apache.org> on 2023/04/27 11:39:23 UTC

[GitHub] [nuttx] zyfeier commented on a diff in pull request #9114: arch/risc-v: change up_saveusercontext to assembly code

zyfeier commented on code in PR #9114:
URL: https://github.com/apache/nuttx/pull/9114#discussion_r1179024212


##########
arch/risc-v/src/common/riscv_saveusercontext.S:
##########
@@ -24,27 +24,42 @@
 
 #include <nuttx/config.h>
 
-#include <arch/syscall.h>
+#include "riscv_macros.S"
 
 /****************************************************************************
- * Public Functions
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Symbols
  ****************************************************************************/
 
 /****************************************************************************
  * 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
+ *   Save the current thread context
  *
  ****************************************************************************/
 
-int up_saveusercontext(void *saveregs)
-{
-  return sys_call1(SYS_save_context, (uintptr_t)saveregs);
-}
+  .section .text
+  .global up_saveusercontext
+  .align  8
+
+up_saveusercontext:
+
+  save_ctx   a0
+
+  csrr       a1, CSR_STATUS

Review Comment:
   Hi, from the risc-v calling convention, we can see a0-a1 is caller registers, so no need to do REGLOAD.



-- 
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-unsubscribe@nuttx.apache.org

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