From 2a77c202281f0672d8b9902e722b6cfb82f118e8 Mon Sep 17 00:00:00 2001 From: patacongo Date: Fri, 22 Mar 2013 21:59:05 +0000 Subject: [PATCH] A few fixes related to dispatched signals in kernel mode (there are still issues) git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5777 42af7a65-404d-4744-a932-0658087f49c3 --- arch/arm/include/armv6-m/syscall.h | 9 ++++++++- arch/arm/include/armv7-m/syscall.h | 9 ++++++++- arch/arm/src/armv6-m/up_svcall.c | 7 ++++--- arch/arm/src/armv7-m/up_svcall.c | 7 ++++--- arch/arm/src/common/up_signal_handler.c | 4 ++-- include/nuttx/arch.h | 2 +- 6 files changed, 27 insertions(+), 11 deletions(-) diff --git a/arch/arm/include/armv6-m/syscall.h b/arch/arm/include/armv6-m/syscall.h index 863a7afeca..75b9c4f8a2 100644 --- a/arch/arm/include/armv6-m/syscall.h +++ b/arch/arm/include/armv6-m/syscall.h @@ -249,7 +249,14 @@ static inline uintptr_t sys_call6(unsigned int nbr, uintptr_t parm1, static inline void signal_handler_return(void) noreturn_function; static inline void signal_handler_return(void) { - sys_call0(SYS_signal_handler_return); + __asm__ __volatile__ + ( + " mov r0, %0\n" + " svc %1\n" + : + : "i" (SYS_signal_handler_return), "i"(SYS_syscall) + : "memory" + ); } #endif diff --git a/arch/arm/include/armv7-m/syscall.h b/arch/arm/include/armv7-m/syscall.h index f6321fb4a2..62bd5c324c 100644 --- a/arch/arm/include/armv7-m/syscall.h +++ b/arch/arm/include/armv7-m/syscall.h @@ -249,7 +249,14 @@ static inline uintptr_t sys_call6(unsigned int nbr, uintptr_t parm1, static inline void signal_handler_return(void) noreturn_function; static inline void signal_handler_return(void) { - sys_call0(SYS_signal_handler_return); + __asm__ __volatile__ + ( + " mov r0, %0\n" + " svc %1\n" + : + : "i" (SYS_signal_handler_return), "i"(SYS_syscall) + : "memory" + ); } #endif diff --git a/arch/arm/src/armv6-m/up_svcall.c b/arch/arm/src/armv6-m/up_svcall.c index c917992ae5..84f8712a56 100644 --- a/arch/arm/src/armv6-m/up_svcall.c +++ b/arch/arm/src/armv6-m/up_svcall.c @@ -404,8 +404,8 @@ int up_svcall(int irq, FAR void *context) regs[REG_R1] = regs[REG_R2]; /* signal */ regs[REG_R2] = regs[REG_R3]; /* info */ - /* The last parameter, arg, is trickier. The arg parameter will - * reside at an offset of 4 from the stack pointer. + /* The last parameter, ucontext, is trickier. The ucontext + * parameter will reside at an offset of 4 from the stack pointer. */ regs[REG_R3] = *(uint32_t*)(regs[REG_SP+4]); @@ -433,6 +433,7 @@ int up_svcall(int irq, FAR void *context) regs[REG_PC] = rtcb->xcp.sigreturn; regs[REG_EXC_RETURN] = EXC_RETURN_PRIVTHR; + rtcb->xcp.sigreturn = 0; } break; #endif @@ -482,7 +483,7 @@ int up_svcall(int irq, FAR void *context) #if defined(CONFIG_DEBUG_SYSCALL) || defined(CONFIG_DEBUG_SVCALL) # ifndef CONFIG_DEBUG_SVCALL if (cmd > SYS_switch_context) -# elif +# else if (regs != current_regs) # endif { diff --git a/arch/arm/src/armv7-m/up_svcall.c b/arch/arm/src/armv7-m/up_svcall.c index 9f3a4ffaa6..40abb41c86 100644 --- a/arch/arm/src/armv7-m/up_svcall.c +++ b/arch/arm/src/armv7-m/up_svcall.c @@ -403,8 +403,8 @@ int up_svcall(int irq, FAR void *context) regs[REG_R1] = regs[REG_R2]; /* signal */ regs[REG_R2] = regs[REG_R3]; /* info */ - /* The last parameter, arg, is trickier. The arg parameter will - * reside at an offset of 4 from the stack pointer. + /* The last parameter, ucontext, is trickier. The ucontext + * parameter will reside at an offset of 4 from the stack pointer. */ regs[REG_R3] = *(uint32_t*)(regs[REG_SP+4]); @@ -432,6 +432,7 @@ int up_svcall(int irq, FAR void *context) regs[REG_PC] = rtcb->xcp.sigreturn; regs[REG_EXC_RETURN] = EXC_RETURN_PRIVTHR; + rtcb->xcp.sigreturn = 0; } break; #endif @@ -481,7 +482,7 @@ int up_svcall(int irq, FAR void *context) #if defined(CONFIG_DEBUG_SYSCALL) || defined(CONFIG_DEBUG_SVCALL) # ifndef CONFIG_DEBUG_SVCALL if (cmd > SYS_switch_context) -# elif +# else if (regs != current_regs) # endif { diff --git a/arch/arm/src/common/up_signal_handler.c b/arch/arm/src/common/up_signal_handler.c index 34407885eb..b2a828479b 100644 --- a/arch/arm/src/common/up_signal_handler.c +++ b/arch/arm/src/common/up_signal_handler.c @@ -93,8 +93,8 @@ void up_signal_handler(_sa_sigaction_t sighand, int signo, { /* Let sys_call4() do all of the work */ - sys_call4(SYS_signal_handler, (uintptr_t)sighand, (uintptr_t)signo, - (uintptr_t)info, (uintptr_t)ucontext); + (void)sys_call4(SYS_signal_handler, (uintptr_t)sighand, (uintptr_t)signo, + (uintptr_t)info, (uintptr_t)ucontext); } #endif /* CONFIG_NUTTX_KERNEL && __KERNEL__ && !CONFIG_DISABLE_SIGNALS */ diff --git a/include/nuttx/arch.h b/include/nuttx/arch.h index b8e62e6c2d..d8b8438e82 100644 --- a/include/nuttx/arch.h +++ b/include/nuttx/arch.h @@ -534,7 +534,7 @@ void up_pthread_start(pthread_startroutine_t entrypt, pthread_addr_t arg) #if defined(CONFIG_NUTTX_KERNEL) && defined(__KERNEL__) && !defined(CONFIG_DISABLE_SIGNALS) void up_signal_handler(_sa_sigaction_t sighand, int signo, - FAR siginfo_t *info, FAR void *ucontext); + FAR siginfo_t *info, FAR void *ucontext) noreturn_function; #endif /****************************************************************************