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 2020/10/01 04:11:41 UTC
[incubator-nuttx] branch master updated: arch/sim: Make the SIGUSR1
host signal to use the NuttX irq logic
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
The following commit(s) were added to refs/heads/master by this push:
new d6210fc arch/sim: Make the SIGUSR1 host signal to use the NuttX irq logic
d6210fc is described below
commit d6210fcd84dfd7b3bc3bac6cd6d3ee00c4f92239
Author: Sebastian Ene <se...@apache.org>
AuthorDate: Fri Sep 25 17:44:46 2020 +0300
arch/sim: Make the SIGUSR1 host signal to use the NuttX irq logic
Signed-off-by: Sebastian Ene <se...@apache.org>
---
arch/sim/include/arch.h | 33 -------------------------
arch/sim/src/sim/up_internal.h | 1 +
arch/sim/src/sim/up_simsmp.c | 55 ++---------------------------------------
arch/sim/src/sim/up_smpsignal.c | 45 +++++++++++++++++++++++++++++++++
4 files changed, 48 insertions(+), 86 deletions(-)
diff --git a/arch/sim/include/arch.h b/arch/sim/include/arch.h
index 4798968..3fca681 100644
--- a/arch/sim/include/arch.h
+++ b/arch/sim/include/arch.h
@@ -41,14 +41,6 @@
#define __ARCH_SIM_INCLUDE_ARCH_H
/****************************************************************************
- * Included Files
- ****************************************************************************/
-
-/****************************************************************************
- * Pre-processor Definitions
- ****************************************************************************/
-
-/****************************************************************************
* Inline functions
****************************************************************************/
@@ -61,29 +53,4 @@ static inline uintptr_t sim_getsp(void)
return (uintptr_t)__builtin_frame_address(0);
}
-/****************************************************************************
- * Public Types
- ****************************************************************************/
-
-/****************************************************************************
- * Public Data
- ****************************************************************************/
-
-/****************************************************************************
- * Public Function Prototypes
- ****************************************************************************/
-
-#ifdef __cplusplus
-#define EXTERN extern "C"
-extern "C"
-{
-#else
-#define EXTERN extern
-#endif
-
-#undef EXTERN
-#ifdef __cplusplus
-}
-#endif
-
#endif /* __ARCH_SIM_INCLUDE_ARCH_H */
diff --git a/arch/sim/src/sim/up_internal.h b/arch/sim/src/sim/up_internal.h
index 2741c64..ac7d221 100644
--- a/arch/sim/src/sim/up_internal.h
+++ b/arch/sim/src/sim/up_internal.h
@@ -242,6 +242,7 @@ void sim_cpu0_start(void);
void up_cpu_started(void);
int up_cpu_paused(int cpu);
struct tcb_s *up_this_task(void);
+int up_cpu_set_pause_handler(int irq);
#endif
/* up_oneshot.c *************************************************************/
diff --git a/arch/sim/src/sim/up_simsmp.c b/arch/sim/src/sim/up_simsmp.c
index 56f8ac6..478b4d7 100644
--- a/arch/sim/src/sim/up_simsmp.c
+++ b/arch/sim/src/sim/up_simsmp.c
@@ -123,7 +123,6 @@ static void *sim_idle_trampoline(void *arg)
#ifdef CONFIG_SIM_WALLTIME
uint64_t now = 0;
#endif
- sigset_t set;
int ret;
/* Set the CPU number for the CPU thread */
@@ -137,14 +136,7 @@ static void *sim_idle_trampoline(void *arg)
/* Make sure the SIGUSR1 is not masked */
- sigemptyset(&set);
- sigaddset(&set, SIGUSR1);
-
- ret = pthread_sigmask(SIG_UNBLOCK, &set, NULL);
- if (ret < 0)
- {
- return NULL;
- }
+ up_cpu_set_pause_handler(SIGUSR1);
/* Let up_cpu_start() continue */
@@ -181,28 +173,6 @@ static void *sim_idle_trampoline(void *arg)
}
/****************************************************************************
- * Name: sim_handle_signal
- *
- * Description:
- * This is the SIGUSR signal handler. It implements the core logic of
- * up_cpu_pause() on the thread of execution the simulated CPU.
- *
- * Input Parameters:
- * arg - Standard sigaction arguments
- *
- * Returned Value:
- * None
- *
- ****************************************************************************/
-
-static void sim_handle_signal(int signo, siginfo_t *info, void *context)
-{
- int cpu = (int)((uintptr_t)pthread_getspecific(g_cpu_key));
-
- up_cpu_paused(cpu);
-}
-
-/****************************************************************************
* Public Functions
****************************************************************************/
@@ -223,8 +193,6 @@ static void sim_handle_signal(int signo, siginfo_t *info, void *context)
void sim_cpu0_start(void)
{
- struct sigaction act;
- sigset_t set;
int ret;
g_cpu_thread[0] = pthread_self();
@@ -247,26 +215,7 @@ void sim_cpu0_start(void)
/* Register the common signal handler for all threads */
- act.sa_sigaction = sim_handle_signal;
- act.sa_flags = SA_SIGINFO;
- sigemptyset(&act.sa_mask);
-
- ret = sigaction(SIGUSR1, &act, NULL);
- if (ret < 0)
- {
- return;
- }
-
- /* Make sure the SIGUSR1 is not masked */
-
- sigemptyset(&set);
- sigaddset(&set, SIGUSR1);
-
- ret = pthread_sigmask(SIG_UNBLOCK, &set, NULL);
- if (ret < 0)
- {
- return;
- }
+ up_cpu_set_pause_handler(SIGUSR1);
}
/****************************************************************************
diff --git a/arch/sim/src/sim/up_smpsignal.c b/arch/sim/src/sim/up_smpsignal.c
index 0179bbc..7417a87 100644
--- a/arch/sim/src/sim/up_smpsignal.c
+++ b/arch/sim/src/sim/up_smpsignal.c
@@ -47,6 +47,32 @@
#include "up_internal.h"
/****************************************************************************
+ * Private Functions
+ ****************************************************************************/
+
+/****************************************************************************
+ * Name: sim_cpupause_handler
+ *
+ * Description:
+ * This is the SIGUSR signal handler. It implements the core logic of
+ * up_cpu_pause() on the thread of execution the simulated CPU.
+ *
+ * Input Parameters:
+ * irq - the interrupt number
+ * context - not used
+ * arg - not used
+ *
+ * Returned Value:
+ * In case of success OK (0) is returned otherwise a negative value.
+ *
+ ****************************************************************************/
+
+static int sim_cpupause_handler(int irq, FAR void *context, FAR void *arg)
+{
+ return up_cpu_paused(this_cpu());
+}
+
+/****************************************************************************
* Public Functions
****************************************************************************/
@@ -204,3 +230,22 @@ struct tcb_s *up_this_task(void)
{
return this_task();
}
+
+/****************************************************************************
+ * Name: up_cpu_set_pause_handler
+ *
+ * Description:
+ * Attach the CPU pause request interrupt to the NuttX logic.
+ *
+ * Input Parameters:
+ * irq - the SIGUSR1 interrupt number
+ *
+ * Returned Value:
+ * On success returns OK (0), otherwise a negative value.
+ ****************************************************************************/
+
+int up_cpu_set_pause_handler(int irq)
+{
+ up_enable_irq(irq);
+ return irq_attach(irq, sim_cpupause_handler, NULL);
+}