From e6dc1927ce61a16359477bb93a2292caade5df75 Mon Sep 17 00:00:00 2001 From: patacongo Date: Sun, 17 Mar 2013 00:40:49 +0000 Subject: Add support for calling to and returning from signal handlers in in user-mode threads git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5750 42af7a65-404d-4744-a932-0658087f49c3 --- nuttx/arch/arm/include/armv7-m/irq.h | 8 ++++++++ nuttx/arch/arm/include/armv7-m/syscall.h | 26 ++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) (limited to 'nuttx/arch/arm/include/armv7-m') diff --git a/nuttx/arch/arm/include/armv7-m/irq.h b/nuttx/arch/arm/include/armv7-m/irq.h index 7556d0747..afeebdb4f 100644 --- a/nuttx/arch/arm/include/armv7-m/irq.h +++ b/nuttx/arch/arm/include/armv7-m/irq.h @@ -124,6 +124,14 @@ struct xcptcontext uint32_t saved_primask; #endif uint32_t saved_xpsr; + +# ifdef CONFIG_NUTTX_KERNEL + /* This is the saved address to use when returning from a user-space + * signal handler. + */ + + uint32_t sigreturn; +# endif #endif #ifdef CONFIG_NUTTX_KERNEL diff --git a/nuttx/arch/arm/include/armv7-m/syscall.h b/nuttx/arch/arm/include/armv7-m/syscall.h index 4278c3a36..91220f359 100644 --- a/nuttx/arch/arm/include/armv7-m/syscall.h +++ b/nuttx/arch/arm/include/armv7-m/syscall.h @@ -54,8 +54,22 @@ * Pro-processor Definitions ****************************************************************************/ +/* This is the value used as the argument to the SVC instruction. It is not + * used. + */ + #define SYS_syscall 0x00 +/* The SYS_signal_handler_return is executed here... its value is not always + * available in this context and so is assumed to be 7. + */ + +#ifndef SYS_signal_handler_return +# define SYS_signal_handler_return (7) +#elif SYS_signal_handler_return != 7 +# error "SYS_signal_handler_return was assumed to be 7" +#endif + /**************************************************************************** * Public Types ****************************************************************************/ @@ -218,6 +232,18 @@ static inline uintptr_t sys_call6(unsigned int nbr, uintptr_t parm1, return reg0; } +/* This inline function is used by user-space code in order to return from + * a signal handler. + */ + +#if defined(CONFIG_NUTTX_KERNEL) && !defined(__KERNEL__) +static inline void signal_handler_return(void) noreturn_function; +static inline void signal_handler_return(void) +{ + sys_call0(SYS_signal_handler_return); +} +#endif + /**************************************************************************** * Public Variables ****************************************************************************/ -- cgit v1.2.3