Revert "arch/sim: Make the SIGUSR1 host signal to use the NuttX irq logic"

This reverts commit d6210fcd84.
This commit is contained in:
Masayuki Ishikawa 2020-10-26 07:36:58 +09:00
parent 3285517910
commit 13db23bd40
4 changed files with 86 additions and 48 deletions

View file

@ -40,6 +40,14 @@
#ifndef __ARCH_SIM_INCLUDE_ARCH_H
#define __ARCH_SIM_INCLUDE_ARCH_H
/****************************************************************************
* Included Files
****************************************************************************/
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Inline functions
****************************************************************************/
@ -53,4 +61,29 @@ 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 */

View file

@ -242,7 +242,6 @@ 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 *************************************************************/

View file

@ -123,6 +123,7 @@ 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 */
@ -136,7 +137,14 @@ static void *sim_idle_trampoline(void *arg)
/* Make sure the SIGUSR1 is not masked */
up_cpu_set_pause_handler(SIGUSR1);
sigemptyset(&set);
sigaddset(&set, SIGUSR1);
ret = pthread_sigmask(SIG_UNBLOCK, &set, NULL);
if (ret < 0)
{
return NULL;
}
/* Let up_cpu_start() continue */
@ -172,6 +180,28 @@ static void *sim_idle_trampoline(void *arg)
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
****************************************************************************/
@ -193,6 +223,8 @@ static void *sim_idle_trampoline(void *arg)
void sim_cpu0_start(void)
{
struct sigaction act;
sigset_t set;
int ret;
g_cpu_thread[0] = pthread_self();
@ -215,7 +247,26 @@ void sim_cpu0_start(void)
/* Register the common signal handler for all threads */
up_cpu_set_pause_handler(SIGUSR1);
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;
}
}
/****************************************************************************

View file

@ -46,32 +46,6 @@
#include "sched/sched.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
****************************************************************************/
@ -230,22 +204,3 @@ 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);
}