pussuw commented on a change in pull request #5782:
URL: https://github.com/apache/incubator-nuttx/pull/5782#discussion_r837864721



##########
File path: arch/risc-v/src/common/supervisor/riscv_syscall_dispatch.S
##########
@@ -0,0 +1,93 @@
+/****************************************************************************
+ * arch/risc-v/src/common/supervisor/riscv_syscall_dispatch.S
+ *
+ * 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.
+ *
+ ****************************************************************************/
+
+.file "riscv_syscall_dispatch.S"
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include <nuttx/config.h>
+#include <arch/mode.h>
+
+#include "riscv_exception_macros.S"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Public Symbols
+ ****************************************************************************/
+
+    .globl  riscv_syscall_dispatch
+
+/****************************************************************************
+ * Name: riscv_syscall_dispatch
+ *
+ * Description:
+ *   Dispatch syscall from kernel, return to user mode
+ *
+ * C Function Prototype:
+ *   void riscv_syscall_dispatch(void);
+ *
+ * Input Parameters:
+ *   Assumes the context to return is already set up
+ *
+ * Returned Value:
+ *   Return value of system call is returned into contex
+ *
+ * Assumptions:
+ *   User task is running in privileged mode with interrupts masked,
+ *   ready to resume the user task in unprivileged mode with interrupts
+ *   restored
+ *
+ ****************************************************************************/
+
+.type riscv_syscall_dispatch, function
+
+riscv_syscall_dispatch:
+
+  addi       sp, sp, -XCPTCONTEXT_SIZE /* make room */
+  save_ctx   sp                        /* save current context */
+

Review comment:
       This is the earliest point where IRQs can be masked. With ecall, they 
would already be masked before the stack frame is created. 
   
   But I guess since we make room in the stack atomically it should not matter 
if the context switches here, the local context will still be safe.




-- 
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