You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ma...@apache.org on 2022/12/21 08:00:01 UTC

[nuttx] branch master updated (64a54d2dfd -> 1544adb548)

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

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


    from 64a54d2dfd arm64/a64: Add driver for Display Engine
     new 5744c62443 sim: set timer irq as real timer
     new ec191d05b6 sim/looper: close interrupt when looper run
     new 1544adb548 sim: open CONFIG_SIM_WALLTIME_SIGNAL=y in sim:nsh sim:smp

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/sim/include/irq.h                   |  1 +
 arch/sim/include/setjmp.h                | 17 +++++++++++++----
 arch/sim/src/sim/posix/sim_hostirq.c     | 17 +++++++++++++++++
 arch/sim/src/sim/sim_doirq.c             |  9 ++-------
 arch/sim/src/sim/sim_exit.c              |  3 ++-
 arch/sim/src/sim/sim_initialize.c        |  7 +++++++
 arch/sim/src/sim/sim_internal.h          | 23 +++++++++++++++++++++++
 arch/sim/src/sim/sim_switchcontext.c     |  9 ++++-----
 boards/sim/sim/sim/configs/nsh/defconfig |  1 +
 boards/sim/sim/sim/configs/smp/defconfig |  1 +
 10 files changed, 71 insertions(+), 17 deletions(-)


[nuttx] 01/03: sim: set timer irq as real timer

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

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

commit 5744c62443507a88d280c9f2369254c27216b6c0
Author: ligd <li...@xiaomi.com>
AuthorDate: Tue Dec 13 21:39:22 2022 +0800

    sim: set timer irq as real timer
    
    Signed-off-by: ligd <li...@xiaomi.com>
---
 arch/sim/include/irq.h               |  1 +
 arch/sim/include/setjmp.h            | 17 +++++++++++++----
 arch/sim/src/sim/posix/sim_hostirq.c | 17 +++++++++++++++++
 arch/sim/src/sim/sim_doirq.c         |  9 ++-------
 arch/sim/src/sim/sim_exit.c          |  3 ++-
 arch/sim/src/sim/sim_internal.h      | 23 +++++++++++++++++++++++
 arch/sim/src/sim/sim_switchcontext.c |  9 ++++-----
 7 files changed, 62 insertions(+), 17 deletions(-)

diff --git a/arch/sim/include/irq.h b/arch/sim/include/irq.h
index 5d1b343f81..93397018d6 100644
--- a/arch/sim/include/irq.h
+++ b/arch/sim/include/irq.h
@@ -115,6 +115,7 @@ int up_cpu_index(void);
  * leave_critical section(), are probably what you really want.
  */
 
+irqstate_t up_irq_flags(void);
 irqstate_t up_irq_save(void);
 void up_irq_restore(irqstate_t flags);
 
diff --git a/arch/sim/include/setjmp.h b/arch/sim/include/setjmp.h
index 20f8bdfbfe..7e510ef005 100644
--- a/arch/sim/include/setjmp.h
+++ b/arch/sim/include/setjmp.h
@@ -37,7 +37,7 @@
 #if defined(CONFIG_HOST_X86_64) && !defined(CONFIG_SIM_M32)
   /* Storage order: %rbx, %rsp, %rbp, %r12, %r13, %r14, %r15, %rip */
 
-#  define XCPTCONTEXT_REGS    8
+#  define XCPTCONTEXT_REGS    9
 #  define XCPTCONTEXT_SIZE    (8 * XCPTCONTEXT_REGS)
 
 #  ifdef __ASSEMBLY__
@@ -50,6 +50,7 @@
 #    define JB_R14            (5*8)
 #    define JB_R15            (6*8)
 #    define JB_RSI            (7*8)
+#    define JB_FLAG           (8*8)
 
 #  else
 
@@ -61,6 +62,7 @@
 #    define JB_R14            (5)
 #    define JB_R15            (6)
 #    define JB_RSI            (7)
+#    define JB_FLAG           (8)
 
 #  endif /* __ASSEMBLY__ */
 
@@ -73,7 +75,7 @@
 #elif defined(CONFIG_HOST_X86) || defined(CONFIG_SIM_M32)
   /* Storage order: %ebx, %esi, %edi, %ebp, sp, and return PC */
 
-#  define XCPTCONTEXT_REGS    6
+#  define XCPTCONTEXT_REGS    (8)
 #  define XCPTCONTEXT_SIZE    (4 * XCPTCONTEXT_REGS)
 
 #  ifdef __ASSEMBLY__
@@ -84,6 +86,8 @@
 #    define JB_EBP            (3*4)
 #    define JB_SP             (4*4)
 #    define JB_PC             (5*4)
+#    define JB_FLAG           (6*4)
+#    define JB_FLAG1          (7*4)
 
 #  else
 
@@ -93,6 +97,8 @@
 #    define JB_EBP            (3)
 #    define JB_SP             (4)
 #    define JB_PC             (5)
+#    define JB_FLAG           (6)
+#    define JB_FLAG1          (7)
 
 #  endif /* __ASSEMBLY__ */
 
@@ -102,16 +108,18 @@
 
 #elif defined(CONFIG_HOST_ARM)
 
-#  define XCPTCONTEXT_REGS    16
+#  define XCPTCONTEXT_REGS    18
 #  define XCPTCONTEXT_SIZE    (4 * XCPTCONTEXT_REGS)
 
 #  define JB_FP               7
 #  define JB_SP               8
 #  define JB_PC               9
+#  define JB_FLAG             16
+#  define JB_FLAG1            17
 
 #elif defined(CONFIG_HOST_ARM64)
 
-#  define XCPTCONTEXT_REGS    32
+#  define XCPTCONTEXT_REGS    33
 #  define XCPTCONTEXT_SIZE    (8 * XCPTCONTEXT_REGS)
 
 #  ifdef __ASSEMBLY__
@@ -134,6 +142,7 @@
 #    define JB_PC             (11)
 #    define JB_FP             (12)
 #    define JB_SP             (13)
+#    define JB_FLAG           (32)
 
 #  endif /* __ASSEMBLY__ */
 
diff --git a/arch/sim/src/sim/posix/sim_hostirq.c b/arch/sim/src/sim/posix/sim_hostirq.c
index 1426b0e3a0..8b6086c3cd 100644
--- a/arch/sim/src/sim/posix/sim_hostirq.c
+++ b/arch/sim/src/sim/posix/sim_hostirq.c
@@ -62,6 +62,23 @@ static void up_handle_irq(int irq, siginfo_t *info, void *context)
  * Public Functions
  ****************************************************************************/
 
+/****************************************************************************
+ * Name: up_irq_flags
+ *
+ * Description:
+ *   Get the current irq flags
+ *
+ ****************************************************************************/
+
+uint64_t up_irq_flags(void)
+{
+  union sigset_u omask;
+
+  pthread_sigmask(SIG_SETMASK, NULL, &omask.sigset);
+
+  return omask.flags;
+}
+
 /****************************************************************************
  * Name: up_irq_save
  *
diff --git a/arch/sim/src/sim/sim_doirq.c b/arch/sim/src/sim/sim_doirq.c
index 2c23be0182..a55b984e61 100644
--- a/arch/sim/src/sim/sim_doirq.c
+++ b/arch/sim/src/sim/sim_doirq.c
@@ -48,11 +48,8 @@ void *sim_doirq(int irq, void *context)
    * CURRENT_REGS is also used to manage interrupt level context switches.
    */
 
-#ifdef CONFIG_SMP
-  if (setjmp(regs) == 0)
+  if (sim_saveusercontext(regs) == 0)
     {
-#endif
-
       CURRENT_REGS = regs;
 
       /* Deliver the IRQ */
@@ -74,12 +71,10 @@ void *sim_doirq(int irq, void *context)
 
       CURRENT_REGS = NULL;
 
-#ifdef CONFIG_SMP
       /* Then switch contexts */
 
-      longjmp(regs, 1);
+      sim_fullcontextrestore(regs);
     }
-#endif
 
   return regs;
 }
diff --git a/arch/sim/src/sim/sim_exit.c b/arch/sim/src/sim/sim_exit.c
index 255e0b3d4e..fe4be9fa14 100644
--- a/arch/sim/src/sim/sim_exit.c
+++ b/arch/sim/src/sim/sim_exit.c
@@ -31,6 +31,7 @@
 
 #include "task/task.h"
 #include "sched/sched.h"
+#include "sim_internal.h"
 
 /****************************************************************************
  * Public Functions
@@ -82,7 +83,7 @@ void up_exit(int status)
 
   /* Then switch contexts */
 
-  longjmp(tcb->xcp.regs, 1);
+  sim_fullcontextrestore(tcb->xcp.regs);
 
   /* The function does not return */
 
diff --git a/arch/sim/src/sim/sim_internal.h b/arch/sim/src/sim/sim_internal.h
index 037bc27300..3805b5770c 100644
--- a/arch/sim/src/sim/sim_internal.h
+++ b/arch/sim/src/sim/sim_internal.h
@@ -85,6 +85,29 @@
 #define sim_savestate(regs) sim_copyfullstate(regs, (xcpt_reg_t *)CURRENT_REGS)
 #define sim_restorestate(regs) (CURRENT_REGS = regs)
 
+#define sim_saveusercontext(saveregs)                           \
+    ({                                                          \
+       irqstate_t flags = up_irq_flags();                       \
+       uint32_t *env = (uint32_t *)saveregs + JB_FLAG;          \
+       int ret;                                                 \
+                                                                \
+       env[0] = flags & UINT32_MAX;                             \
+       env[1] = (flags >> 32) & UINT32_MAX;                     \
+                                                                \
+       ret = setjmp(saveregs);                                  \
+       ret;                                                     \
+    })
+#define sim_fullcontextrestore(restoreregs)                     \
+    do                                                          \
+      {                                                         \
+        xcpt_reg_t *env = restoreregs;                          \
+        uint32_t *flags = (uint32_t *)&env[JB_FLAG];            \
+                                                                \
+        up_irq_restore(((uint64_t)flags[1] << 32) | flags[0]);  \
+        longjmp(env, 1);                                        \
+      }                                                         \
+    while (0)
+
 /* File System Definitions **************************************************/
 
 /* These definitions characterize the compressed filesystem image */
diff --git a/arch/sim/src/sim/sim_switchcontext.c b/arch/sim/src/sim/sim_switchcontext.c
index a3dee9c937..3ecb284d71 100644
--- a/arch/sim/src/sim/sim_switchcontext.c
+++ b/arch/sim/src/sim/sim_switchcontext.c
@@ -31,7 +31,6 @@
 #include <nuttx/sched.h>
 
 #include "clock/clock.h"
-#include "sched/sched.h"
 #include "sim_internal.h"
 
 /****************************************************************************
@@ -84,11 +83,11 @@ void up_switch_context(struct tcb_s *tcb, struct tcb_s *rtcb)
     }
 
   /* Copy the exception context into the TCB of the task that was
-   * previously active.  if setjmp returns a non-zero value, then
-   * this is really the previously running task restarting!
+   * previously active.  if sim_saveusercontext returns a non-zero value,
+   * then this is really the previously running task restarting!
    */
 
-  else if (!setjmp(rtcb->xcp.regs))
+  else if (!sim_saveusercontext(rtcb->xcp.regs))
     {
       sinfo("New Active Task TCB=%p\n", tcb);
 
@@ -102,7 +101,7 @@ void up_switch_context(struct tcb_s *tcb, struct tcb_s *rtcb)
 
       /* Then switch contexts */
 
-      longjmp(tcb->xcp.regs, 1);
+      sim_fullcontextrestore(tcb->xcp.regs);
     }
   else
     {


[nuttx] 03/03: sim: open CONFIG_SIM_WALLTIME_SIGNAL=y in sim:nsh sim:smp

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

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

commit 1544adb548662965f91e32a15a8ff1b1e7c21804
Author: ligd <li...@xiaomi.com>
AuthorDate: Mon Dec 19 23:26:11 2022 +0800

    sim: open CONFIG_SIM_WALLTIME_SIGNAL=y in sim:nsh sim:smp
    
    Signed-off-by: ligd <li...@xiaomi.com>
---
 boards/sim/sim/sim/configs/nsh/defconfig | 1 +
 boards/sim/sim/sim/configs/smp/defconfig | 1 +
 2 files changed, 2 insertions(+)

diff --git a/boards/sim/sim/sim/configs/nsh/defconfig b/boards/sim/sim/sim/configs/nsh/defconfig
index f139a7a978..8321d62c39 100644
--- a/boards/sim/sim/sim/configs/nsh/defconfig
+++ b/boards/sim/sim/sim/configs/nsh/defconfig
@@ -64,6 +64,7 @@ CONFIG_SCHED_BACKTRACE=y
 CONFIG_SCHED_HAVE_PARENT=y
 CONFIG_SCHED_HPWORK=y
 CONFIG_SCHED_WAITPID=y
+CONFIG_SIM_WALLTIME_SIGNAL=y
 CONFIG_START_MONTH=6
 CONFIG_START_YEAR=2008
 CONFIG_SYSTEM_DUMPSTACK=y
diff --git a/boards/sim/sim/sim/configs/smp/defconfig b/boards/sim/sim/sim/configs/smp/defconfig
index 22a56da5e3..ef81c95ec3 100644
--- a/boards/sim/sim/sim/configs/smp/defconfig
+++ b/boards/sim/sim/sim/configs/smp/defconfig
@@ -25,6 +25,7 @@ CONFIG_NSH_BUILTIN_APPS=y
 CONFIG_NSH_READLINE=y
 CONFIG_READLINE_CMD_HISTORY=y
 CONFIG_SCHED_HAVE_PARENT=y
+CONFIG_SIM_WALLTIME_SIGNAL=y
 CONFIG_SMP=y
 CONFIG_STACK_COLORATION=y
 CONFIG_SYSTEM_NSH=y


[nuttx] 02/03: sim/looper: close interrupt when looper run

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

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

commit ec191d05b6b7101021341a8938e61ba5a2443fc3
Author: ligd <li...@xiaomi.com>
AuthorDate: Mon Dec 19 17:42:39 2022 +0800

    sim/looper: close interrupt when looper run
    
    Signed-off-by: ligd <li...@xiaomi.com>
---
 arch/sim/src/sim/sim_initialize.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/arch/sim/src/sim/sim_initialize.c b/arch/sim/src/sim/sim_initialize.c
index 1eb23e5879..5b6a267ff4 100644
--- a/arch/sim/src/sim/sim_initialize.c
+++ b/arch/sim/src/sim/sim_initialize.c
@@ -162,6 +162,10 @@ static int sim_loop_task(int argc, char **argv)
 {
   while (1)
     {
+      irqstate_t flags = up_irq_save();
+
+      sched_lock();
+
       /* Handle UART data availability */
 
       sim_uartloop();
@@ -209,6 +213,9 @@ static int sim_loop_task(int argc, char **argv)
       foc_dummy_update();
 #endif
 
+      sched_unlock();
+      up_irq_restore(flags);
+
       /* Sleep minimal time, let the idle run */
 
       usleep(USEC_PER_TICK);