mirror of
https://github.com/apache/nuttx.git
synced 2026-05-27 19:36:35 +08:00
Revert "Revert "arch/sim: Make the SIGUSR1 host signal to use the NuttX irq logic""
This reverts commit 3098b61776.
This commit is contained in:
committed by
Alin Jerpelea
parent
409c65ce0b
commit
ad9f88f042
@@ -40,14 +40,6 @@
|
|||||||
#ifndef __ARCH_SIM_INCLUDE_ARCH_H
|
#ifndef __ARCH_SIM_INCLUDE_ARCH_H
|
||||||
#define __ARCH_SIM_INCLUDE_ARCH_H
|
#define __ARCH_SIM_INCLUDE_ARCH_H
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Included Files
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Pre-processor Definitions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Inline functions
|
* Inline functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -61,29 +53,4 @@ static inline uintptr_t sim_getsp(void)
|
|||||||
return (uintptr_t)__builtin_frame_address(0);
|
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 */
|
#endif /* __ARCH_SIM_INCLUDE_ARCH_H */
|
||||||
|
|||||||
@@ -243,6 +243,7 @@ void sim_cpu0_start(void);
|
|||||||
void up_cpu_started(void);
|
void up_cpu_started(void);
|
||||||
int up_cpu_paused(int cpu);
|
int up_cpu_paused(int cpu);
|
||||||
struct tcb_s *up_this_task(void);
|
struct tcb_s *up_this_task(void);
|
||||||
|
int up_cpu_set_pause_handler(int irq);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
/* up_oneshot.c *************************************************************/
|
/* up_oneshot.c *************************************************************/
|
||||||
|
|||||||
@@ -123,7 +123,6 @@ static void *sim_idle_trampoline(void *arg)
|
|||||||
#ifdef CONFIG_SIM_WALLTIME
|
#ifdef CONFIG_SIM_WALLTIME
|
||||||
uint64_t now = 0;
|
uint64_t now = 0;
|
||||||
#endif
|
#endif
|
||||||
sigset_t set;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
/* Set the CPU number for the CPU thread */
|
/* 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 */
|
/* Make sure the SIGUSR1 is not masked */
|
||||||
|
|
||||||
sigemptyset(&set);
|
up_cpu_set_pause_handler(SIGUSR1);
|
||||||
sigaddset(&set, SIGUSR1);
|
|
||||||
|
|
||||||
ret = pthread_sigmask(SIG_UNBLOCK, &set, NULL);
|
|
||||||
if (ret < 0)
|
|
||||||
{
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Let up_cpu_start() continue */
|
/* Let up_cpu_start() continue */
|
||||||
|
|
||||||
@@ -180,28 +172,6 @@ static void *sim_idle_trampoline(void *arg)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* 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
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -223,8 +193,6 @@ static void sim_handle_signal(int signo, siginfo_t *info, void *context)
|
|||||||
|
|
||||||
void sim_cpu0_start(void)
|
void sim_cpu0_start(void)
|
||||||
{
|
{
|
||||||
struct sigaction act;
|
|
||||||
sigset_t set;
|
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
g_cpu_thread[0] = pthread_self();
|
g_cpu_thread[0] = pthread_self();
|
||||||
@@ -247,26 +215,7 @@ void sim_cpu0_start(void)
|
|||||||
|
|
||||||
/* Register the common signal handler for all threads */
|
/* Register the common signal handler for all threads */
|
||||||
|
|
||||||
act.sa_sigaction = sim_handle_signal;
|
up_cpu_set_pause_handler(SIGUSR1);
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
|
|||||||
@@ -46,6 +46,32 @@
|
|||||||
#include "sched/sched.h"
|
#include "sched/sched.h"
|
||||||
#include "up_internal.h"
|
#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
|
* Public Functions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -204,3 +230,22 @@ struct tcb_s *up_this_task(void)
|
|||||||
{
|
{
|
||||||
return this_task();
|
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);
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user