diff --git a/arch/arm/include/armv7-m/irq.h b/arch/arm/include/armv7-m/irq.h index f63fadbc49..39210b07ac 100644 --- a/arch/arm/include/armv7-m/irq.h +++ b/arch/arm/include/armv7-m/irq.h @@ -292,7 +292,7 @@ static inline irqstate_t up_irq_save(void) static inline void up_irq_enable(void) inline_function; static inline void up_irq_enable(void) { - setbasepri(0); + setbasepri(NVIC_SYSH_PRIORITY_MIN); __asm__ __volatile__ ("\tcpsie i\n"); } diff --git a/arch/arm/src/arm/up_sigdeliver.c b/arch/arm/src/arm/up_sigdeliver.c index 29176429f3..1fb7b1eeff 100644 --- a/arch/arm/src/arm/up_sigdeliver.c +++ b/arch/arm/src/arm/up_sigdeliver.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/arm/up_sigdeliver.c * - * Copyright (C) 2007-2010, 2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2010, 2015, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -113,9 +113,13 @@ void up_sigdeliver(void) sigdeliver = rtcb->xcp.sigdeliver; rtcb->xcp.sigdeliver = NULL; - /* Then restore the task interrupt state */ +#ifndef CONFIG_SUPPRESS_INTERRUPTS + /* Then make sure that interrupts are enabled. Signal handlers must always + * run with interrupts enabled. + */ - up_irq_restore(regs[REG_CPSR]); + up_irq_enable(); +#endif /* Deliver the signals */ diff --git a/arch/arm/src/armv6-m/up_sigdeliver.c b/arch/arm/src/armv6-m/up_sigdeliver.c index c2b3e8675e..ed045faf38 100644 --- a/arch/arm/src/armv6-m/up_sigdeliver.c +++ b/arch/arm/src/armv6-m/up_sigdeliver.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/armv6-m/up_sigdeliver.c * - * Copyright (C) 2013-2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2013-2015, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -54,18 +54,6 @@ #ifndef CONFIG_DISABLE_SIGNALS -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -122,9 +110,13 @@ void up_sigdeliver(void) sigdeliver = rtcb->xcp.sigdeliver; rtcb->xcp.sigdeliver = NULL; - /* Then restore the task interrupt state */ +#ifndef CONFIG_SUPPRESS_INTERRUPTS + /* Then make sure that interrupts are enabled. Signal handlers must always + * run with interrupts enabled. + */ - up_irq_restore((uint8_t)regs[REG_PRIMASK]); + up_irq_enable(); +#endif /* Deliver the signal */ diff --git a/arch/arm/src/armv7-a/arm_sigdeliver.c b/arch/arm/src/armv7-a/arm_sigdeliver.c index 5d89583282..861e065f7d 100644 --- a/arch/arm/src/armv7-a/arm_sigdeliver.c +++ b/arch/arm/src/armv7-a/arm_sigdeliver.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/armv7-a/arm_sigdeliver.c * - * Copyright (C) 2013, 2015-2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2013, 2015-2016, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -101,9 +101,13 @@ void up_sigdeliver(void) sigdeliver = rtcb->xcp.sigdeliver; rtcb->xcp.sigdeliver = NULL; - /* Then restore the task interrupt state */ +#ifndef CONFIG_SUPPRESS_INTERRUPTS + /* Then make sure that interrupts are enabled. Signal handlers must always + * run with interrupts enabled. + */ - leave_critical_section(regs[REG_CPSR]); + up_irq_enable(); +#endif /* Deliver the signal */ diff --git a/arch/arm/src/armv7-m/up_sigdeliver.c b/arch/arm/src/armv7-m/up_sigdeliver.c index 5aff11499c..6ecd0ee66d 100644 --- a/arch/arm/src/armv7-m/up_sigdeliver.c +++ b/arch/arm/src/armv7-m/up_sigdeliver.c @@ -1,7 +1,8 @@ /**************************************************************************** * arch/arm/src/armv7-m/up_sigdeliver.c * - * Copyright (C) 2009-2010, 2013-2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2009-2010, 2013-2016, 2018 Gregory Nutt. All rights + * reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -109,12 +110,12 @@ void up_sigdeliver(void) sigdeliver = (sig_deliver_t)rtcb->xcp.sigdeliver; rtcb->xcp.sigdeliver = NULL; - /* Then restore the task interrupt state */ +#ifndef CONFIG_SUPPRESS_INTERRUPTS + /* Then make sure that interrupts are enabled. Signal handlers must always + * run with interrupts enabled. + */ -#ifdef CONFIG_ARMV7M_USEBASEPRI - leave_critical_section((uint8_t)regs[REG_BASEPRI]); -#else - leave_critical_section((uint16_t)regs[REG_PRIMASK]); + up_irq_enable(); #endif /* Deliver the signal */ diff --git a/arch/arm/src/armv7-r/arm_sigdeliver.c b/arch/arm/src/armv7-r/arm_sigdeliver.c index 280a5ef9c7..be24c2c01c 100644 --- a/arch/arm/src/armv7-r/arm_sigdeliver.c +++ b/arch/arm/src/armv7-r/arm_sigdeliver.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/armv7-r/arm_sigdeliver.c * - * Copyright (C) 2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2015, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -101,9 +101,13 @@ void up_sigdeliver(void) sigdeliver = rtcb->xcp.sigdeliver; rtcb->xcp.sigdeliver = NULL; - /* Then restore the task interrupt state */ +#ifndef CONFIG_SUPPRESS_INTERRUPTS + /* Then make sure that interrupts are enabled. Signal handlers must always + * run with interrupts enabled. + */ - up_irq_restore(regs[REG_CPSR]); + up_irq_enable(); +#endif /* Deliver the signals */ diff --git a/arch/avr/src/avr/up_sigdeliver.c b/arch/avr/src/avr/up_sigdeliver.c index c73460793e..7b33c79afd 100644 --- a/arch/avr/src/avr/up_sigdeliver.c +++ b/arch/avr/src/avr/up_sigdeliver.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/avr/src/avr/up_sigdeliver.c * - * Copyright (C) 2011, 2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2011, 2015, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -104,9 +104,13 @@ void up_sigdeliver(void) sigdeliver = rtcb->xcp.sigdeliver; rtcb->xcp.sigdeliver = NULL; - /* Then restore the task interrupt state */ +#ifndef CONFIG_SUPPRESS_INTERRUPTS + /* Then make sure that interrupts are enabled. Signal handlers must always + * run with interrupts enabled. + */ - up_irq_restore(regs[REG_SREG]); + up_irq_enable(); +#endif /* Deliver the signals */ diff --git a/arch/avr/src/avr32/up_sigdeliver.c b/arch/avr/src/avr32/up_sigdeliver.c index 811e4b031c..1ef31dfb61 100644 --- a/arch/avr/src/avr32/up_sigdeliver.c +++ b/arch/avr/src/avr32/up_sigdeliver.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/avr/src/avr32/up_sigdeliver.c * - * Copyright (C) 2010, 2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2010, 2015, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -104,9 +104,13 @@ void up_sigdeliver(void) sigdeliver = rtcb->xcp.sigdeliver; rtcb->xcp.sigdeliver = NULL; - /* Then restore the task interrupt state */ +#ifndef CONFIG_SUPPRESS_INTERRUPTS + /* Then make sure that interrupts are enabled. Signal handlers must always + * run with interrupts enabled. + */ - up_irq_restore(regs[REG_SR]); + up_irq_enable(); +#endif /* Deliver the signals */ diff --git a/arch/mips/src/mips32/up_sigdeliver.c b/arch/mips/src/mips32/up_sigdeliver.c index bf8f8e1708..4c986d4235 100644 --- a/arch/mips/src/mips32/up_sigdeliver.c +++ b/arch/mips/src/mips32/up_sigdeliver.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/mips/src/mips32/up_sigdeliver.c * - * Copyright (C) 2011, 2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2011, 2015, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -114,9 +114,13 @@ void up_sigdeliver(void) sigdeliver = rtcb->xcp.sigdeliver; rtcb->xcp.sigdeliver = NULL; - /* Then restore the task interrupt state */ +#ifndef CONFIG_SUPPRESS_INTERRUPTS + /* Then make sure that interrupts are enabled. Signal handlers must always + * run with interrupts enabled. + */ - up_irq_restore((irqstate_t)regs[REG_STATUS]); + up_irq_enable(); +#endif /* Deliver the signals */ diff --git a/arch/misoc/src/lm32/lm32_sigdeliver.c b/arch/misoc/src/lm32/lm32_sigdeliver.c index f889691469..8b96ae47d7 100644 --- a/arch/misoc/src/lm32/lm32_sigdeliver.c +++ b/arch/misoc/src/lm32/lm32_sigdeliver.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/misoc/src/lm32/lm32_sigdeliver.c * - * Copyright (C) 2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2016, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -101,9 +101,13 @@ void lm32_sigdeliver(void) sigdeliver = rtcb->xcp.sigdeliver; rtcb->xcp.sigdeliver = NULL; - /* Then restore the task interrupt state */ +#ifndef CONFIG_SUPPRESS_INTERRUPTS + /* Then make sure that interrupts are enabled. Signal handlers must always + * run with interrupts enabled. + */ - up_irq_restore((irqstate_t)regs[REG_INT_CTX]); + up_irq_enable(); +#endif /* Deliver the signals */ diff --git a/arch/renesas/src/m16c/m16c_sigdeliver.c b/arch/renesas/src/m16c/m16c_sigdeliver.c index a56448c36b..199bb6f752 100644 --- a/arch/renesas/src/m16c/m16c_sigdeliver.c +++ b/arch/renesas/src/m16c/m16c_sigdeliver.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/renesas/src/m16c/m16c_sigdeliver.c * - * Copyright (C) 2009-2010, 2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2009-2010, 2015, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -115,9 +115,13 @@ void up_sigdeliver(void) sigdeliver = rtcb->xcp.sigdeliver; rtcb->xcp.sigdeliver = NULL; - /* Then restore the task interrupt state. */ +#ifndef CONFIG_SUPPRESS_INTERRUPTS + /* Then make sure that interrupts are enabled. Signal handlers must always + * run with interrupts enabled. + */ - up_irq_restore(rtcb->xcp.saved_flg); + up_irq_enable(); +#endif /* Deliver the signals */ diff --git a/arch/renesas/src/sh1/sh1_sigdeliver.c b/arch/renesas/src/sh1/sh1_sigdeliver.c index 8662cb47c5..5e1e286eca 100644 --- a/arch/renesas/src/sh1/sh1_sigdeliver.c +++ b/arch/renesas/src/sh1/sh1_sigdeliver.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/renesas/src/common/up_sigdeliver.c * - * Copyright (C) 2008-2010, 2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2010, 2015, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -114,9 +114,13 @@ void up_sigdeliver(void) sigdeliver = rtcb->xcp.sigdeliver; rtcb->xcp.sigdeliver = NULL; - /* Then restore the task interrupt state. */ +#ifndef CONFIG_SUPPRESS_INTERRUPTS + /* Then make sure that interrupts are enabled. Signal handlers must always + * run with interrupts enabled. + */ - up_irq_restore(regs[REG_SR] & 0x000000f0); + up_irq_enable(); +#endif /* Deliver the signals */ diff --git a/arch/risc-v/src/rv32im/up_sigdeliver.c b/arch/risc-v/src/rv32im/up_sigdeliver.c index 6d57a2b4a3..73ecbcb227 100644 --- a/arch/risc-v/src/rv32im/up_sigdeliver.c +++ b/arch/risc-v/src/rv32im/up_sigdeliver.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/risc-v/src/rv32im/up_sigdeliver.c * - * Copyright (C) 2011, 2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2011, 2015, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Modified for RISC-V: @@ -60,18 +60,6 @@ #ifndef CONFIG_DISABLE_SIGNALS -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -119,9 +107,13 @@ void up_sigdeliver(void) sigdeliver = rtcb->xcp.sigdeliver; rtcb->xcp.sigdeliver = NULL; - /* Then restore the task interrupt state */ +#ifndef CONFIG_SUPPRESS_INTERRUPTS + /* Then make sure that interrupts are enabled. Signal handlers must always + * run with interrupts enabled. + */ - up_irq_restore((irqstate_t)regs[REG_INT_CTX]); + up_irq_enable(); +#endif /* Deliver the signals */ diff --git a/arch/x86/src/i486/up_sigdeliver.c b/arch/x86/src/i486/up_sigdeliver.c index b6ec9a09d5..9805d3be90 100644 --- a/arch/x86/src/i486/up_sigdeliver.c +++ b/arch/x86/src/i486/up_sigdeliver.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/x86/src/i486/up_sigdeliver.c * - * Copyright (C) 2011, 2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2011, 2015, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -54,18 +54,6 @@ #ifndef CONFIG_DISABLE_SIGNALS -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - /**************************************************************************** * Public Functions ****************************************************************************/ @@ -113,9 +101,13 @@ void up_sigdeliver(void) sigdeliver = rtcb->xcp.sigdeliver; rtcb->xcp.sigdeliver = NULL; - /* Then restore the task interrupt state */ +#ifndef CONFIG_SUPPRESS_INTERRUPTS + /* Then make sure that interrupts are enabled. Signal handlers must always + * run with interrupts enabled. + */ - up_irq_restore(regs[REG_EFLAGS]); + up_irq_enable(); +#endif /* Deliver the signals */ diff --git a/arch/xtensa/src/common/xtensa_sigdeliver.c b/arch/xtensa/src/common/xtensa_sigdeliver.c index ec6e6c56dd..9aed74990b 100644 --- a/arch/xtensa/src/common/xtensa_sigdeliver.c +++ b/arch/xtensa/src/common/xtensa_sigdeliver.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/xtensa/src/common/arm_sigdeliver.c * - * Copyright (C) 2016 Gregory Nutt. All rights reserved. + * Copyright (C) 2016, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -100,9 +100,13 @@ void xtensa_sig_deliver(void) sigdeliver = rtcb->xcp.sigdeliver; rtcb->xcp.sigdeliver = NULL; - /* Then restore the task interrupt state */ +#ifndef CONFIG_SUPPRESS_INTERRUPTS + /* Then make sure that interrupts are enabled. Signal handlers must always + * run with interrupts enabled. + */ - up_irq_restore(regs[REG_PS]); + up_irq_enable(); +#endif /* Deliver the signals */ diff --git a/arch/z16/src/common/up_sigdeliver.c b/arch/z16/src/common/up_sigdeliver.c index f9429d041b..4e40bc6a35 100644 --- a/arch/z16/src/common/up_sigdeliver.c +++ b/arch/z16/src/common/up_sigdeliver.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/z16/src/common/up_sigdeliver.c * - * Copyright (C) 2008-2010, 2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2010, 2015, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -103,12 +103,13 @@ void up_sigdeliver(void) sigdeliver = (sig_deliver_t)rtcb->xcp.sigdeliver; rtcb->xcp.sigdeliver = NULL; - /* Then restore the task interrupt state. */ +#ifndef CONFIG_SUPPRESS_INTERRUPTS + /* Then make sure that interrupts are enabled. Signal handlers must always + * run with interrupts enabled. + */ - if ((regs[REG_FLAGS] & Z16F_CNTRL_FLAGS_IRQE) != 0) - { - EI(); - } + up_irq_enable(); +#endif /* Deliver the signals */ diff --git a/arch/z80/src/ez80/ez80_sigdeliver.c b/arch/z80/src/ez80/ez80_sigdeliver.c index 694b3c0186..de2d60a358 100644 --- a/arch/z80/src/ez80/ez80_sigdeliver.c +++ b/arch/z80/src/ez80/ez80_sigdeliver.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/z80/src/ez80/ez80_sigdeliver.c * - * Copyright (C) 2008-2010, 2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2010, 2015, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -114,9 +114,13 @@ void up_sigdeliver(void) sigdeliver = rtcb->xcp.sigdeliver; rtcb->xcp.sigdeliver = NULL; - /* Then restore the task interrupt state. */ +#ifndef CONFIG_SUPPRESS_INTERRUPTS + /* Then make sure that interrupts are enabled. Signal handlers must always + * run with interrupts enabled. + */ - up_irq_restore(regs[XCPT_I]); + up_irq_enable(); +#endif /* Deliver the signals */ diff --git a/arch/z80/src/z180/z180_sigdeliver.c b/arch/z80/src/z180/z180_sigdeliver.c index 3a67b345f8..75ffb20dc6 100644 --- a/arch/z80/src/z180/z180_sigdeliver.c +++ b/arch/z80/src/z180/z180_sigdeliver.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/z80/src/z180/z180_sigdeliver.c * - * Copyright (C) 2012, 2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2012, 2015, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -113,9 +113,13 @@ void up_sigdeliver(void) sigdeliver = rtcb->xcp.sigdeliver; rtcb->xcp.sigdeliver = NULL; - /* Then restore the task interrupt state. */ +#ifndef CONFIG_SUPPRESS_INTERRUPTS + /* Then make sure that interrupts are enabled. Signal handlers must always + * run with interrupts enabled. + */ - up_irq_restore(regs[XCPT_I]); + up_irq_enable(); +#endif /* Deliver the signals */ diff --git a/arch/z80/src/z8/z8_sigdeliver.c b/arch/z80/src/z8/z8_sigdeliver.c index b6abac296a..57aeb48d65 100644 --- a/arch/z80/src/z8/z8_sigdeliver.c +++ b/arch/z80/src/z8/z8_sigdeliver.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/z80/src/z8/z8_sigdeliver.c * - * Copyright (C) 2008-2010, 2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2010, 2015, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -52,14 +52,6 @@ #ifndef CONFIG_DISABLE_SIGNALS -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - /**************************************************************************** * Private Functions ****************************************************************************/ @@ -128,9 +120,13 @@ void up_sigdeliver(void) sigdeliver = rtcb->xcp.sigdeliver; rtcb->xcp.sigdeliver = NULL; - /* Then restore the task interrupt state. */ +#ifndef CONFIG_SUPPRESS_INTERRUPTS + /* Then make sure that interrupts are enabled. Signal handlers must always + * run with interrupts enabled. + */ - up_irq_restore(regs[XCPT_IRQCTL]); + up_irq_enable(); +#endif /* Deliver the signals */ diff --git a/arch/z80/src/z80/z80_sigdeliver.c b/arch/z80/src/z80/z80_sigdeliver.c index 232eb4be98..e173f92357 100644 --- a/arch/z80/src/z80/z80_sigdeliver.c +++ b/arch/z80/src/z80/z80_sigdeliver.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/z80/src/z80/z80_sigdeliver.c * - * Copyright (C) 2007-2010, 2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2010, 2015, 2018 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -113,9 +113,13 @@ void up_sigdeliver(void) sigdeliver = rtcb->xcp.sigdeliver; rtcb->xcp.sigdeliver = NULL; - /* Then restore the task interrupt state. */ +#ifndef CONFIG_SUPPRESS_INTERRUPTS + /* Then make sure that interrupts are enabled. Signal handlers must always + * run with interrupts enabled. + */ - up_irq_restore(regs[XCPT_I]); + up_irq_enable(); +#endif /* Deliver the signals */