arch: Save sigdeliver into xcp in the case of signal self delevery

to avoid the infinite recusive dispatch:
*0  myhandler (signo=27, info=0xf3e38b9c, context=0x0) at ltp/testcases/open_posix_testsuite/conformance/interfaces/sigqueue/7-1.c:39
*1  0x58f1c39e in nxsig_deliver (stcb=0xf4e20f40) at signal/sig_deliver.c:167
*2  0x58fa0664 in up_schedule_sigaction (tcb=0xf4e20f40, sigdeliver=0x58f1bab5 <nxsig_deliver>) at sim/sim_schedulesigaction.c:88
*3  0x58f19907 in nxsig_queue_action (stcb=0xf4e20f40, info=0xf4049334) at signal/sig_dispatch.c:115
*4  0x58f1b089 in nxsig_tcbdispatch (stcb=0xf4e20f40, info=0xf4049334) at signal/sig_dispatch.c:435
*5  0x58f31853 in nxsig_unmask_pendingsignal () at signal/sig_unmaskpendingsignal.c:104
*6  0x58f1ca09 in nxsig_deliver (stcb=0xf4e20f40) at signal/sig_deliver.c:199
*7  0x58fa0664 in up_schedule_sigaction (tcb=0xf4e20f40, sigdeliver=0x58f1bab5 <nxsig_deliver>) at sim/sim_schedulesigaction.c:88
*8  0x58f19907 in nxsig_queue_action (stcb=0xf4e20f40, info=0xf4049304) at signal/sig_dispatch.c:115
*9  0x58f1b089 in nxsig_tcbdispatch (stcb=0xf4e20f40, info=0xf4049304) at signal/sig_dispatch.c:435
*10 0x58f31853 in nxsig_unmask_pendingsignal () at signal/sig_unmaskpendingsignal.c:104
*11 0x58f1ca09 in nxsig_deliver (stcb=0xf4e20f40) at signal/sig_deliver.c:199
*12 0x58fa0664 in up_schedule_sigaction (tcb=0xf4e20f40, sigdeliver=0x58f1bab5 <nxsig_deliver>) at sim/sim_schedulesigaction.c:88
*13 0x58f19907 in nxsig_queue_action (stcb=0xf4e20f40, info=0xf40492d4) at signal/sig_dispatch.c:115
*14 0x58f1b089 in nxsig_tcbdispatch (stcb=0xf4e20f40, info=0xf40492d4) at signal/sig_dispatch.c:435
*15 0x58f31853 in nxsig_unmask_pendingsignal () at signal/sig_unmaskpendingsignal.c:104
*16 0x58f1ca09 in nxsig_deliver (stcb=0xf4e20f40) at signal/sig_deliver.c:199
*17 0x58fa0664 in up_schedule_sigaction (tcb=0xf4e20f40, sigdeliver=0x58f1bab5 <nxsig_deliver>) at sim/sim_schedulesigaction.c:88
*18 0x58f19907 in nxsig_queue_action (stcb=0xf4e20f40, info=0xf40492a4) at signal/sig_dispatch.c:115
*19 0x58f1b089 in nxsig_tcbdispatch (stcb=0xf4e20f40, info=0xf40492a4) at signal/sig_dispatch.c:435
*20 0x58f31853 in nxsig_unmask_pendingsignal () at signal/sig_unmaskpendingsignal.c:104
*21 0x58f1ca09 in nxsig_deliver (stcb=0xf4e20f40) at signal/sig_deliver.c:199
*22 0x58fa0664 in up_schedule_sigaction (tcb=0xf4e20f40, sigdeliver=0x58f1bab5 <nxsig_deliver>) at sim/sim_schedulesigaction.c:88
*23 0x58f19907 in nxsig_queue_action (stcb=0xf4e20f40, info=0xf4049274) at signal/sig_dispatch.c:115
*24 0x58f1b089 in nxsig_tcbdispatch (stcb=0xf4e20f40, info=0xf4049274) at signal/sig_dispatch.c:435
*25 0x58f31853 in nxsig_unmask_pendingsignal () at signal/sig_unmaskpendingsignal.c:104
*26 0x58f1ca09 in nxsig_deliver (stcb=0xf4e20f40) at signal/sig_deliver.c:199
*27 0x58fa0664 in up_schedule_sigaction (tcb=0xf4e20f40, sigdeliver=0x58f1bab5 <nxsig_deliver>) at sim/sim_schedulesigaction.c:88
*28 0x58f19907 in nxsig_queue_action (stcb=0xf4e20f40, info=0xf4049244) at signal/sig_dispatch.c:115
*29 0x58f1b089 in nxsig_tcbdispatch (stcb=0xf4e20f40, info=0xf4049244) at signal/sig_dispatch.c:435
*30 0x58f31853 in nxsig_unmask_pendingsignal () at signal/sig_unmaskpendingsignal.c:104
*31 0x58f1ca09 in nxsig_deliver (stcb=0xf4e20f40) at signal/sig_deliver.c:199

Signed-off-by: Xiang Xiao <xiaoxiang@xiaomi.com>
This commit is contained in:
Xiang Xiao
2023-05-13 22:35:21 +08:00
committed by patacongo
parent 8cca30b44c
commit 7dc0d70092
55 changed files with 420 additions and 423 deletions
+7 -8
View File
@@ -83,6 +83,8 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
if (!tcb->xcp.sigdeliver) if (!tcb->xcp.sigdeliver)
{ {
tcb->xcp.sigdeliver = sigdeliver;
/* First, handle some special cases when the signal is /* First, handle some special cases when the signal is
* being delivered to the currently executing task. * being delivered to the currently executing task.
*/ */
@@ -100,6 +102,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
/* In this case just deliver the signal now. */ /* In this case just deliver the signal now. */
sigdeliver(tcb); sigdeliver(tcb);
tcb->xcp.sigdeliver = NULL;
} }
/* CASE 2: We are in an interrupt handler AND the /* CASE 2: We are in an interrupt handler AND the
@@ -121,8 +124,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* the signals have been delivered. * the signals have been delivered.
*/ */
tcb->xcp.sigdeliver = sigdeliver;
/* And make sure that the saved context in the TCB /* And make sure that the saved context in the TCB
* is the same as the interrupt return context. * is the same as the interrupt return context.
*/ */
@@ -136,12 +137,12 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
CURRENT_REGS = (void *) CURRENT_REGS = (void *)
((uint32_t)CURRENT_REGS - ((uint32_t)CURRENT_REGS -
(uint32_t)XCPTCONTEXT_SIZE); XCPTCONTEXT_SIZE);
memcpy((uint32_t *)CURRENT_REGS, tcb->xcp.saved_regs, memcpy((uint32_t *)CURRENT_REGS, tcb->xcp.saved_regs,
XCPTCONTEXT_SIZE); XCPTCONTEXT_SIZE);
CURRENT_REGS[REG_SP] = (uint32_t)CURRENT_REGS + CURRENT_REGS[REG_SP] = (uint32_t)CURRENT_REGS +
(uint32_t)XCPTCONTEXT_SIZE; XCPTCONTEXT_SIZE;
/* Then set up to vector to the trampoline with interrupts /* Then set up to vector to the trampoline with interrupts
* disabled * disabled
@@ -168,8 +169,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* the signals have been delivered. * the signals have been delivered.
*/ */
tcb->xcp.sigdeliver = sigdeliver;
/* Save the current register context location */ /* Save the current register context location */
tcb->xcp.saved_regs = tcb->xcp.regs; tcb->xcp.saved_regs = tcb->xcp.regs;
@@ -181,11 +180,11 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
tcb->xcp.regs = (void *) tcb->xcp.regs = (void *)
((uint32_t)tcb->xcp.regs - ((uint32_t)tcb->xcp.regs -
(uint32_t)XCPTCONTEXT_SIZE); XCPTCONTEXT_SIZE);
memcpy(tcb->xcp.regs, tcb->xcp.saved_regs, XCPTCONTEXT_SIZE); memcpy(tcb->xcp.regs, tcb->xcp.saved_regs, XCPTCONTEXT_SIZE);
tcb->xcp.regs[REG_SP] = (uint32_t)tcb->xcp.regs + tcb->xcp.regs[REG_SP] = (uint32_t)tcb->xcp.regs +
(uint32_t)XCPTCONTEXT_SIZE; XCPTCONTEXT_SIZE;
/* Then set up to vector to the trampoline with interrupts /* Then set up to vector to the trampoline with interrupts
* disabled * disabled
+16 -20
View File
@@ -88,6 +88,8 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
if (tcb->xcp.sigdeliver == NULL) if (tcb->xcp.sigdeliver == NULL)
{ {
tcb->xcp.sigdeliver = sigdeliver;
/* First, handle some special cases when the signal is being delivered /* First, handle some special cases when the signal is being delivered
* to the currently executing task. * to the currently executing task.
*/ */
@@ -107,6 +109,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
*/ */
sigdeliver(tcb); sigdeliver(tcb);
tcb->xcp.sigdeliver = NULL;
} }
/* CASE 2: We are in an interrupt handler AND the interrupted /* CASE 2: We are in an interrupt handler AND the interrupted
@@ -123,8 +126,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* delivered. * delivered.
*/ */
tcb->xcp.sigdeliver = (void *)sigdeliver;
/* And make sure that the saved context in the TCB is the same /* And make sure that the saved context in the TCB is the same
* as the interrupt return context. * as the interrupt return context.
*/ */
@@ -138,12 +139,12 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
CURRENT_REGS = (void *) CURRENT_REGS = (void *)
((uint32_t)CURRENT_REGS - ((uint32_t)CURRENT_REGS -
(uint32_t)XCPTCONTEXT_SIZE); XCPTCONTEXT_SIZE);
memcpy((uint32_t *)CURRENT_REGS, tcb->xcp.saved_regs, memcpy((uint32_t *)CURRENT_REGS, tcb->xcp.saved_regs,
XCPTCONTEXT_SIZE); XCPTCONTEXT_SIZE);
CURRENT_REGS[REG_SP] = (uint32_t)CURRENT_REGS + CURRENT_REGS[REG_SP] = (uint32_t)CURRENT_REGS +
(uint32_t)XCPTCONTEXT_SIZE; XCPTCONTEXT_SIZE;
/* Then set up to vector to the trampoline with interrupts /* Then set up to vector to the trampoline with interrupts
* disabled. The kernel-space trampoline must run in * disabled. The kernel-space trampoline must run in
@@ -172,8 +173,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* by the signal trampoline after the signal has been delivered. * by the signal trampoline after the signal has been delivered.
*/ */
tcb->xcp.sigdeliver = (void *)sigdeliver;
/* Save the current register context location */ /* Save the current register context location */
tcb->xcp.saved_regs = tcb->xcp.regs; tcb->xcp.saved_regs = tcb->xcp.regs;
@@ -185,11 +184,11 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
tcb->xcp.regs = (void *) tcb->xcp.regs = (void *)
((uint32_t)tcb->xcp.regs - ((uint32_t)tcb->xcp.regs -
(uint32_t)XCPTCONTEXT_SIZE); XCPTCONTEXT_SIZE);
memcpy(tcb->xcp.regs, tcb->xcp.saved_regs, XCPTCONTEXT_SIZE); memcpy(tcb->xcp.regs, tcb->xcp.saved_regs, XCPTCONTEXT_SIZE);
tcb->xcp.regs[REG_SP] = (uint32_t)tcb->xcp.regs + tcb->xcp.regs[REG_SP] = (uint32_t)tcb->xcp.regs +
(uint32_t)XCPTCONTEXT_SIZE; XCPTCONTEXT_SIZE;
/* Then set up to vector to the trampoline with interrupts /* Then set up to vector to the trampoline with interrupts
* disabled. We must already be in privileged thread mode to be * disabled. We must already be in privileged thread mode to be
@@ -219,6 +218,8 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
if (!tcb->xcp.sigdeliver) if (!tcb->xcp.sigdeliver)
{ {
tcb->xcp.sigdeliver = sigdeliver;
/* First, handle some special cases when the signal is being delivered /* First, handle some special cases when the signal is being delivered
* to task that is currently executing on any CPU. * to task that is currently executing on any CPU.
*/ */
@@ -241,6 +242,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
*/ */
sigdeliver(tcb); sigdeliver(tcb);
tcb->xcp.sigdeliver = NULL;
} }
/* CASE 2: The task that needs to receive the signal is running. /* CASE 2: The task that needs to receive the signal is running.
@@ -276,8 +278,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* been delivered. * been delivered.
*/ */
tcb->xcp.sigdeliver = (void *)sigdeliver;
/* Save the current register context location */ /* Save the current register context location */
tcb->xcp.saved_regs = tcb->xcp.regs; tcb->xcp.saved_regs = tcb->xcp.regs;
@@ -289,12 +289,12 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
tcb->xcp.regs = (void *) tcb->xcp.regs = (void *)
((uint32_t)tcb->xcp.regs - ((uint32_t)tcb->xcp.regs -
(uint32_t)XCPTCONTEXT_SIZE); XCPTCONTEXT_SIZE);
memcpy(tcb->xcp.regs, tcb->xcp.saved_regs, memcpy(tcb->xcp.regs, tcb->xcp.saved_regs,
XCPTCONTEXT_SIZE); XCPTCONTEXT_SIZE);
tcb->xcp.regs[REG_SP] = (uint32_t)tcb->xcp.regs + tcb->xcp.regs[REG_SP] = (uint32_t)tcb->xcp.regs +
(uint32_t)XCPTCONTEXT_SIZE; XCPTCONTEXT_SIZE;
/* Then set up vector to the trampoline with interrupts /* Then set up vector to the trampoline with interrupts
* disabled. We must already be in privileged thread mode * disabled. We must already be in privileged thread mode
@@ -318,8 +318,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* signal has been delivered. * signal has been delivered.
*/ */
tcb->xcp.sigdeliver = (void *)sigdeliver;
/* And make sure that the saved context in the TCB is the /* And make sure that the saved context in the TCB is the
* same as the interrupt return context. * same as the interrupt return context.
*/ */
@@ -333,12 +331,12 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
CURRENT_REGS = (void *) CURRENT_REGS = (void *)
((uint32_t)CURRENT_REGS - ((uint32_t)CURRENT_REGS -
(uint32_t)XCPTCONTEXT_SIZE); XCPTCONTEXT_SIZE);
memcpy((uint32_t *)CURRENT_REGS, tcb->xcp.saved_regs, memcpy((uint32_t *)CURRENT_REGS, tcb->xcp.saved_regs,
XCPTCONTEXT_SIZE); XCPTCONTEXT_SIZE);
CURRENT_REGS[REG_SP] = (uint32_t)CURRENT_REGS + CURRENT_REGS[REG_SP] = (uint32_t)CURRENT_REGS +
(uint32_t)XCPTCONTEXT_SIZE; XCPTCONTEXT_SIZE;
/* Then set up vector to the trampoline with interrupts /* Then set up vector to the trampoline with interrupts
* disabled. The kernel-space trampoline must run in * disabled. The kernel-space trampoline must run in
@@ -388,8 +386,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* by the signal trampoline after the signal has been delivered. * by the signal trampoline after the signal has been delivered.
*/ */
tcb->xcp.sigdeliver = (void *)sigdeliver;
/* Save the current register context location */ /* Save the current register context location */
tcb->xcp.saved_regs = tcb->xcp.regs; tcb->xcp.saved_regs = tcb->xcp.regs;
@@ -401,11 +397,11 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
tcb->xcp.regs = (void *) tcb->xcp.regs = (void *)
((uint32_t)tcb->xcp.regs - ((uint32_t)tcb->xcp.regs -
(uint32_t)XCPTCONTEXT_SIZE); XCPTCONTEXT_SIZE);
memcpy(tcb->xcp.regs, tcb->xcp.saved_regs, XCPTCONTEXT_SIZE); memcpy(tcb->xcp.regs, tcb->xcp.saved_regs, XCPTCONTEXT_SIZE);
tcb->xcp.regs[REG_SP] = (uint32_t)tcb->xcp.regs + tcb->xcp.regs[REG_SP] = (uint32_t)tcb->xcp.regs +
(uint32_t)XCPTCONTEXT_SIZE; XCPTCONTEXT_SIZE;
/* Increment the IRQ lock count so that when the task is restarted, /* Increment the IRQ lock count so that when the task is restarted,
* it will hold the IRQ spinlock. * it will hold the IRQ spinlock.
+16 -20
View File
@@ -86,6 +86,8 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
if (!tcb->xcp.sigdeliver) if (!tcb->xcp.sigdeliver)
{ {
tcb->xcp.sigdeliver = sigdeliver;
/* First, handle some special cases when the signal is being delivered /* First, handle some special cases when the signal is being delivered
* to task that is currently executing on this CPU. * to task that is currently executing on this CPU.
*/ */
@@ -105,6 +107,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
*/ */
sigdeliver(tcb); sigdeliver(tcb);
tcb->xcp.sigdeliver = NULL;
} }
/* CASE 2: We are in an interrupt handler AND the interrupted /* CASE 2: We are in an interrupt handler AND the interrupted
@@ -126,8 +129,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* the signals have been delivered. * the signals have been delivered.
*/ */
tcb->xcp.sigdeliver = sigdeliver;
/* And make sure that the saved context in the TCB is the same /* And make sure that the saved context in the TCB is the same
* as the interrupt return context. * as the interrupt return context.
*/ */
@@ -141,12 +142,12 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
CURRENT_REGS = (void *) CURRENT_REGS = (void *)
((uint32_t)CURRENT_REGS - ((uint32_t)CURRENT_REGS -
(uint32_t)XCPTCONTEXT_SIZE); XCPTCONTEXT_SIZE);
memcpy((uint32_t *)CURRENT_REGS, tcb->xcp.saved_regs, memcpy((uint32_t *)CURRENT_REGS, tcb->xcp.saved_regs,
XCPTCONTEXT_SIZE); XCPTCONTEXT_SIZE);
CURRENT_REGS[REG_SP] = (uint32_t)CURRENT_REGS + CURRENT_REGS[REG_SP] = (uint32_t)CURRENT_REGS +
(uint32_t)XCPTCONTEXT_SIZE; XCPTCONTEXT_SIZE;
/* Then set up to vector to the trampoline with interrupts /* Then set up to vector to the trampoline with interrupts
* disabled * disabled
@@ -173,8 +174,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* have been delivered. * have been delivered.
*/ */
tcb->xcp.sigdeliver = sigdeliver;
/* Save the current register context location */ /* Save the current register context location */
tcb->xcp.saved_regs = tcb->xcp.regs; tcb->xcp.saved_regs = tcb->xcp.regs;
@@ -186,11 +185,11 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
tcb->xcp.regs = (void *) tcb->xcp.regs = (void *)
((uint32_t)tcb->xcp.regs - ((uint32_t)tcb->xcp.regs -
(uint32_t)XCPTCONTEXT_SIZE); XCPTCONTEXT_SIZE);
memcpy(tcb->xcp.regs, tcb->xcp.saved_regs, XCPTCONTEXT_SIZE); memcpy(tcb->xcp.regs, tcb->xcp.saved_regs, XCPTCONTEXT_SIZE);
tcb->xcp.regs[REG_SP] = (uint32_t)tcb->xcp.regs + tcb->xcp.regs[REG_SP] = (uint32_t)tcb->xcp.regs +
(uint32_t)XCPTCONTEXT_SIZE; XCPTCONTEXT_SIZE;
/* Then set up to vector to the trampoline with interrupts /* Then set up to vector to the trampoline with interrupts
* disabled * disabled
@@ -218,6 +217,8 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
if (!tcb->xcp.sigdeliver) if (!tcb->xcp.sigdeliver)
{ {
tcb->xcp.sigdeliver = sigdeliver;
/* First, handle some special cases when the signal is being delivered /* First, handle some special cases when the signal is being delivered
* to task that is currently executing on any CPU. * to task that is currently executing on any CPU.
*/ */
@@ -240,6 +241,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
*/ */
sigdeliver(tcb); sigdeliver(tcb);
tcb->xcp.sigdeliver = NULL;
} }
/* CASE 2: The task that needs to receive the signal is running. /* CASE 2: The task that needs to receive the signal is running.
@@ -275,8 +277,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* been delivered. * been delivered.
*/ */
tcb->xcp.sigdeliver = sigdeliver;
/* Save the current register context location */ /* Save the current register context location */
tcb->xcp.saved_regs = tcb->xcp.regs; tcb->xcp.saved_regs = tcb->xcp.regs;
@@ -288,12 +288,12 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
tcb->xcp.regs = (void *) tcb->xcp.regs = (void *)
((uint32_t)tcb->xcp.regs - ((uint32_t)tcb->xcp.regs -
(uint32_t)XCPTCONTEXT_SIZE); XCPTCONTEXT_SIZE);
memcpy(tcb->xcp.regs, tcb->xcp.saved_regs, memcpy(tcb->xcp.regs, tcb->xcp.saved_regs,
XCPTCONTEXT_SIZE); XCPTCONTEXT_SIZE);
tcb->xcp.regs[REG_SP] = (uint32_t)tcb->xcp.regs + tcb->xcp.regs[REG_SP] = (uint32_t)tcb->xcp.regs +
(uint32_t)XCPTCONTEXT_SIZE; XCPTCONTEXT_SIZE;
/* Then set up to vector to the trampoline with interrupts /* Then set up to vector to the trampoline with interrupts
* disabled * disabled
@@ -316,8 +316,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* has been delivered. * has been delivered.
*/ */
tcb->xcp.sigdeliver = (void *)sigdeliver;
/* And make sure that the saved context in the TCB is the /* And make sure that the saved context in the TCB is the
* same as the interrupt return context. * same as the interrupt return context.
*/ */
@@ -331,12 +329,12 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
CURRENT_REGS = (void *) CURRENT_REGS = (void *)
((uint32_t)CURRENT_REGS - ((uint32_t)CURRENT_REGS -
(uint32_t)XCPTCONTEXT_SIZE); XCPTCONTEXT_SIZE);
memcpy((uint32_t *)CURRENT_REGS, tcb->xcp.saved_regs, memcpy((uint32_t *)CURRENT_REGS, tcb->xcp.saved_regs,
XCPTCONTEXT_SIZE); XCPTCONTEXT_SIZE);
CURRENT_REGS[REG_SP] = (uint32_t)CURRENT_REGS + CURRENT_REGS[REG_SP] = (uint32_t)CURRENT_REGS +
(uint32_t)XCPTCONTEXT_SIZE; XCPTCONTEXT_SIZE;
/* Then set up vector to the trampoline with interrupts /* Then set up vector to the trampoline with interrupts
* disabled. The kernel-space trampoline must run in * disabled. The kernel-space trampoline must run in
@@ -386,8 +384,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* have been delivered. * have been delivered.
*/ */
tcb->xcp.sigdeliver = sigdeliver;
/* Save the current register context location */ /* Save the current register context location */
tcb->xcp.saved_regs = tcb->xcp.regs; tcb->xcp.saved_regs = tcb->xcp.regs;
@@ -399,11 +395,11 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
tcb->xcp.regs = (void *) tcb->xcp.regs = (void *)
((uint32_t)tcb->xcp.regs - ((uint32_t)tcb->xcp.regs -
(uint32_t)XCPTCONTEXT_SIZE); XCPTCONTEXT_SIZE);
memcpy(tcb->xcp.regs, tcb->xcp.saved_regs, XCPTCONTEXT_SIZE); memcpy(tcb->xcp.regs, tcb->xcp.saved_regs, XCPTCONTEXT_SIZE);
tcb->xcp.regs[REG_SP] = (uint32_t)tcb->xcp.regs + tcb->xcp.regs[REG_SP] = (uint32_t)tcb->xcp.regs +
(uint32_t)XCPTCONTEXT_SIZE; XCPTCONTEXT_SIZE;
/* Increment the IRQ lock count so that when the task is restarted, /* Increment the IRQ lock count so that when the task is restarted,
* it will hold the IRQ spinlock. * it will hold the IRQ spinlock.
+16 -20
View File
@@ -89,6 +89,8 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
if (tcb->xcp.sigdeliver == NULL) if (tcb->xcp.sigdeliver == NULL)
{ {
tcb->xcp.sigdeliver = sigdeliver;
/* First, handle some special cases when the signal is being delivered /* First, handle some special cases when the signal is being delivered
* to the currently executing task. * to the currently executing task.
*/ */
@@ -108,6 +110,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
*/ */
sigdeliver(tcb); sigdeliver(tcb);
tcb->xcp.sigdeliver = NULL;
} }
/* CASE 2: We are in an interrupt handler AND the interrupted /* CASE 2: We are in an interrupt handler AND the interrupted
@@ -124,8 +127,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* delivered. * delivered.
*/ */
tcb->xcp.sigdeliver = (void *)sigdeliver;
/* And make sure that the saved context in the TCB is the same /* And make sure that the saved context in the TCB is the same
* as the interrupt return context. * as the interrupt return context.
*/ */
@@ -139,12 +140,12 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
CURRENT_REGS = (void *) CURRENT_REGS = (void *)
((uint32_t)CURRENT_REGS - ((uint32_t)CURRENT_REGS -
(uint32_t)XCPTCONTEXT_SIZE); XCPTCONTEXT_SIZE);
memcpy((uint32_t *)CURRENT_REGS, tcb->xcp.saved_regs, memcpy((uint32_t *)CURRENT_REGS, tcb->xcp.saved_regs,
XCPTCONTEXT_SIZE); XCPTCONTEXT_SIZE);
CURRENT_REGS[REG_SP] = (uint32_t)CURRENT_REGS + CURRENT_REGS[REG_SP] = (uint32_t)CURRENT_REGS +
(uint32_t)XCPTCONTEXT_SIZE; XCPTCONTEXT_SIZE;
/* Then set up to vector to the trampoline with interrupts /* Then set up to vector to the trampoline with interrupts
* disabled. The kernel-space trampoline must run in * disabled. The kernel-space trampoline must run in
@@ -177,8 +178,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* by the signal trampoline after the signal has been delivered. * by the signal trampoline after the signal has been delivered.
*/ */
tcb->xcp.sigdeliver = (void *)sigdeliver;
/* Save the current register context location */ /* Save the current register context location */
tcb->xcp.saved_regs = tcb->xcp.regs; tcb->xcp.saved_regs = tcb->xcp.regs;
@@ -190,11 +189,11 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
tcb->xcp.regs = (void *) tcb->xcp.regs = (void *)
((uint32_t)tcb->xcp.regs - ((uint32_t)tcb->xcp.regs -
(uint32_t)XCPTCONTEXT_SIZE); XCPTCONTEXT_SIZE);
memcpy(tcb->xcp.regs, tcb->xcp.saved_regs, XCPTCONTEXT_SIZE); memcpy(tcb->xcp.regs, tcb->xcp.saved_regs, XCPTCONTEXT_SIZE);
tcb->xcp.regs[REG_SP] = (uint32_t)tcb->xcp.regs + tcb->xcp.regs[REG_SP] = (uint32_t)tcb->xcp.regs +
(uint32_t)XCPTCONTEXT_SIZE; XCPTCONTEXT_SIZE;
/* Then set up to vector to the trampoline with interrupts /* Then set up to vector to the trampoline with interrupts
* disabled. We must already be in privileged thread mode to be * disabled. We must already be in privileged thread mode to be
@@ -228,6 +227,8 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
if (!tcb->xcp.sigdeliver) if (!tcb->xcp.sigdeliver)
{ {
tcb->xcp.sigdeliver = sigdeliver;
/* First, handle some special cases when the signal is being delivered /* First, handle some special cases when the signal is being delivered
* to task that is currently executing on any CPU. * to task that is currently executing on any CPU.
*/ */
@@ -250,6 +251,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
*/ */
sigdeliver(tcb); sigdeliver(tcb);
tcb->xcp.sigdeliver = NULL;
} }
/* CASE 2: The task that needs to receive the signal is running. /* CASE 2: The task that needs to receive the signal is running.
@@ -285,8 +287,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* been delivered. * been delivered.
*/ */
tcb->xcp.sigdeliver = (void *)sigdeliver;
/* Save the current register context location */ /* Save the current register context location */
tcb->xcp.saved_regs = tcb->xcp.regs; tcb->xcp.saved_regs = tcb->xcp.regs;
@@ -298,12 +298,12 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
tcb->xcp.regs = (void *) tcb->xcp.regs = (void *)
((uint32_t)tcb->xcp.regs - ((uint32_t)tcb->xcp.regs -
(uint32_t)XCPTCONTEXT_SIZE); XCPTCONTEXT_SIZE);
memcpy(tcb->xcp.regs, tcb->xcp.saved_regs, memcpy(tcb->xcp.regs, tcb->xcp.saved_regs,
XCPTCONTEXT_SIZE); XCPTCONTEXT_SIZE);
tcb->xcp.regs[REG_SP] = (uint32_t)tcb->xcp.regs + tcb->xcp.regs[REG_SP] = (uint32_t)tcb->xcp.regs +
(uint32_t)XCPTCONTEXT_SIZE; XCPTCONTEXT_SIZE;
/* Then set up vector to the trampoline with interrupts /* Then set up vector to the trampoline with interrupts
* disabled. We must already be in privileged thread mode * disabled. We must already be in privileged thread mode
@@ -331,8 +331,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* signal has been delivered. * signal has been delivered.
*/ */
tcb->xcp.sigdeliver = (void *)sigdeliver;
/* And make sure that the saved context in the TCB is the /* And make sure that the saved context in the TCB is the
* same as the interrupt return context. * same as the interrupt return context.
*/ */
@@ -346,12 +344,12 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
CURRENT_REGS = (void *) CURRENT_REGS = (void *)
((uint32_t)CURRENT_REGS - ((uint32_t)CURRENT_REGS -
(uint32_t)XCPTCONTEXT_SIZE); XCPTCONTEXT_SIZE);
memcpy((uint32_t *)CURRENT_REGS, tcb->xcp.saved_regs, memcpy((uint32_t *)CURRENT_REGS, tcb->xcp.saved_regs,
XCPTCONTEXT_SIZE); XCPTCONTEXT_SIZE);
CURRENT_REGS[REG_SP] = (uint32_t)CURRENT_REGS + CURRENT_REGS[REG_SP] = (uint32_t)CURRENT_REGS +
(uint32_t)XCPTCONTEXT_SIZE; XCPTCONTEXT_SIZE;
/* Then set up vector to the trampoline with interrupts /* Then set up vector to the trampoline with interrupts
* disabled. The kernel-space trampoline must run in * disabled. The kernel-space trampoline must run in
@@ -405,8 +403,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* by the signal trampoline after the signal has been delivered. * by the signal trampoline after the signal has been delivered.
*/ */
tcb->xcp.sigdeliver = (void *)sigdeliver;
/* Save the current register context location */ /* Save the current register context location */
tcb->xcp.saved_regs = tcb->xcp.regs; tcb->xcp.saved_regs = tcb->xcp.regs;
@@ -418,11 +414,11 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
tcb->xcp.regs = (void *) tcb->xcp.regs = (void *)
((uint32_t)tcb->xcp.regs - ((uint32_t)tcb->xcp.regs -
(uint32_t)XCPTCONTEXT_SIZE); XCPTCONTEXT_SIZE);
memcpy(tcb->xcp.regs, tcb->xcp.saved_regs, XCPTCONTEXT_SIZE); memcpy(tcb->xcp.regs, tcb->xcp.saved_regs, XCPTCONTEXT_SIZE);
tcb->xcp.regs[REG_SP] = (uint32_t)tcb->xcp.regs + tcb->xcp.regs[REG_SP] = (uint32_t)tcb->xcp.regs +
(uint32_t)XCPTCONTEXT_SIZE; XCPTCONTEXT_SIZE;
/* Increment the IRQ lock count so that when the task is restarted, /* Increment the IRQ lock count so that when the task is restarted,
* it will hold the IRQ spinlock. * it will hold the IRQ spinlock.
+16 -20
View File
@@ -84,6 +84,8 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
if (!tcb->xcp.sigdeliver) if (!tcb->xcp.sigdeliver)
{ {
tcb->xcp.sigdeliver = sigdeliver;
/* First, handle some special cases when the signal is being delivered /* First, handle some special cases when the signal is being delivered
* to the currently executing task. * to the currently executing task.
*/ */
@@ -101,6 +103,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
/* In this case just deliver the signal now. */ /* In this case just deliver the signal now. */
sigdeliver(tcb); sigdeliver(tcb);
tcb->xcp.sigdeliver = NULL;
} }
/* CASE 2: We are in an interrupt handler AND the interrupted /* CASE 2: We are in an interrupt handler AND the interrupted
@@ -122,8 +125,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* the signals have been delivered. * the signals have been delivered.
*/ */
tcb->xcp.sigdeliver = sigdeliver;
/* And make sure that the saved context in the TCB is the same /* And make sure that the saved context in the TCB is the same
* as the interrupt return context. * as the interrupt return context.
*/ */
@@ -137,12 +138,12 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
CURRENT_REGS = (void *) CURRENT_REGS = (void *)
((uint32_t)CURRENT_REGS - ((uint32_t)CURRENT_REGS -
(uint32_t)XCPTCONTEXT_SIZE); XCPTCONTEXT_SIZE);
memcpy((uint32_t *)CURRENT_REGS, tcb->xcp.saved_regs, memcpy((uint32_t *)CURRENT_REGS, tcb->xcp.saved_regs,
XCPTCONTEXT_SIZE); XCPTCONTEXT_SIZE);
CURRENT_REGS[REG_SP] = (uint32_t)CURRENT_REGS + CURRENT_REGS[REG_SP] = (uint32_t)CURRENT_REGS +
(uint32_t)XCPTCONTEXT_SIZE; XCPTCONTEXT_SIZE;
/* Then set up to vector to the trampoline with interrupts /* Then set up to vector to the trampoline with interrupts
* disabled * disabled
@@ -173,8 +174,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* have been delivered. * have been delivered.
*/ */
tcb->xcp.sigdeliver = sigdeliver;
/* Save the current register context location */ /* Save the current register context location */
tcb->xcp.saved_regs = tcb->xcp.regs; tcb->xcp.saved_regs = tcb->xcp.regs;
@@ -186,11 +185,11 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
tcb->xcp.regs = (void *) tcb->xcp.regs = (void *)
((uint32_t)tcb->xcp.regs - ((uint32_t)tcb->xcp.regs -
(uint32_t)XCPTCONTEXT_SIZE); XCPTCONTEXT_SIZE);
memcpy(tcb->xcp.regs, tcb->xcp.saved_regs, XCPTCONTEXT_SIZE); memcpy(tcb->xcp.regs, tcb->xcp.saved_regs, XCPTCONTEXT_SIZE);
tcb->xcp.regs[REG_SP] = (uint32_t)tcb->xcp.regs + tcb->xcp.regs[REG_SP] = (uint32_t)tcb->xcp.regs +
(uint32_t)XCPTCONTEXT_SIZE; XCPTCONTEXT_SIZE;
/* Then set up to vector to the trampoline with interrupts /* Then set up to vector to the trampoline with interrupts
* disabled * disabled
@@ -221,6 +220,8 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
if (!tcb->xcp.sigdeliver) if (!tcb->xcp.sigdeliver)
{ {
tcb->xcp.sigdeliver = sigdeliver;
/* First, handle some special cases when the signal is being delivered /* First, handle some special cases when the signal is being delivered
* to task that is currently executing on any CPU. * to task that is currently executing on any CPU.
*/ */
@@ -243,6 +244,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
*/ */
sigdeliver(tcb); sigdeliver(tcb);
tcb->xcp.sigdeliver = NULL;
} }
/* CASE 2: The task that needs to receive the signal is running. /* CASE 2: The task that needs to receive the signal is running.
@@ -278,8 +280,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* been delivered. * been delivered.
*/ */
tcb->xcp.sigdeliver = sigdeliver;
/* Save the current register context location */ /* Save the current register context location */
tcb->xcp.saved_regs = tcb->xcp.regs; tcb->xcp.saved_regs = tcb->xcp.regs;
@@ -291,12 +291,12 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
tcb->xcp.regs = (void *) tcb->xcp.regs = (void *)
((uint32_t)tcb->xcp.regs - ((uint32_t)tcb->xcp.regs -
(uint32_t)XCPTCONTEXT_SIZE); XCPTCONTEXT_SIZE);
memcpy(tcb->xcp.regs, tcb->xcp.saved_regs, memcpy(tcb->xcp.regs, tcb->xcp.saved_regs,
XCPTCONTEXT_SIZE); XCPTCONTEXT_SIZE);
tcb->xcp.regs[REG_SP] = (uint32_t)tcb->xcp.regs + tcb->xcp.regs[REG_SP] = (uint32_t)tcb->xcp.regs +
(uint32_t)XCPTCONTEXT_SIZE; XCPTCONTEXT_SIZE;
/* Then set up to vector to the trampoline with interrupts /* Then set up to vector to the trampoline with interrupts
* disabled * disabled
@@ -319,8 +319,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* has been delivered. * has been delivered.
*/ */
tcb->xcp.sigdeliver = (void *)sigdeliver;
/* And make sure that the saved context in the TCB is the /* And make sure that the saved context in the TCB is the
* same as the interrupt return context. * same as the interrupt return context.
*/ */
@@ -334,12 +332,12 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
CURRENT_REGS = (void *) CURRENT_REGS = (void *)
((uint32_t)CURRENT_REGS - ((uint32_t)CURRENT_REGS -
(uint32_t)XCPTCONTEXT_SIZE); XCPTCONTEXT_SIZE);
memcpy((uint32_t *)CURRENT_REGS, tcb->xcp.saved_regs, memcpy((uint32_t *)CURRENT_REGS, tcb->xcp.saved_regs,
XCPTCONTEXT_SIZE); XCPTCONTEXT_SIZE);
CURRENT_REGS[REG_SP] = (uint32_t)CURRENT_REGS + CURRENT_REGS[REG_SP] = (uint32_t)CURRENT_REGS +
(uint32_t)XCPTCONTEXT_SIZE; XCPTCONTEXT_SIZE;
/* Then set up vector to the trampoline with interrupts /* Then set up vector to the trampoline with interrupts
* disabled. The kernel-space trampoline must run in * disabled. The kernel-space trampoline must run in
@@ -389,8 +387,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* have been delivered. * have been delivered.
*/ */
tcb->xcp.sigdeliver = sigdeliver;
/* Save the current register context location */ /* Save the current register context location */
tcb->xcp.saved_regs = tcb->xcp.regs; tcb->xcp.saved_regs = tcb->xcp.regs;
@@ -402,11 +398,11 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
tcb->xcp.regs = (void *) tcb->xcp.regs = (void *)
((uint32_t)tcb->xcp.regs - ((uint32_t)tcb->xcp.regs -
(uint32_t)XCPTCONTEXT_SIZE); XCPTCONTEXT_SIZE);
memcpy(tcb->xcp.regs, tcb->xcp.saved_regs, XCPTCONTEXT_SIZE); memcpy(tcb->xcp.regs, tcb->xcp.saved_regs, XCPTCONTEXT_SIZE);
tcb->xcp.regs[REG_SP] = (uint32_t)tcb->xcp.regs + tcb->xcp.regs[REG_SP] = (uint32_t)tcb->xcp.regs +
(uint32_t)XCPTCONTEXT_SIZE; XCPTCONTEXT_SIZE;
/* Increment the IRQ lock count so that when the task is restarted, /* Increment the IRQ lock count so that when the task is restarted,
* it will hold the IRQ spinlock. * it will hold the IRQ spinlock.
+16 -20
View File
@@ -89,6 +89,8 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
if (tcb->xcp.sigdeliver == NULL) if (tcb->xcp.sigdeliver == NULL)
{ {
tcb->xcp.sigdeliver = sigdeliver;
/* First, handle some special cases when the signal is being delivered /* First, handle some special cases when the signal is being delivered
* to the currently executing task. * to the currently executing task.
*/ */
@@ -108,6 +110,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
*/ */
sigdeliver(tcb); sigdeliver(tcb);
tcb->xcp.sigdeliver = NULL;
} }
/* CASE 2: We are in an interrupt handler AND the interrupted /* CASE 2: We are in an interrupt handler AND the interrupted
@@ -124,8 +127,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* delivered. * delivered.
*/ */
tcb->xcp.sigdeliver = (void *)sigdeliver;
/* And make sure that the saved context in the TCB is the same /* And make sure that the saved context in the TCB is the same
* as the interrupt return context. * as the interrupt return context.
*/ */
@@ -139,12 +140,12 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
CURRENT_REGS = (void *) CURRENT_REGS = (void *)
((uint32_t)CURRENT_REGS - ((uint32_t)CURRENT_REGS -
(uint32_t)XCPTCONTEXT_SIZE); XCPTCONTEXT_SIZE);
memcpy((uint32_t *)CURRENT_REGS, tcb->xcp.saved_regs, memcpy((uint32_t *)CURRENT_REGS, tcb->xcp.saved_regs,
XCPTCONTEXT_SIZE); XCPTCONTEXT_SIZE);
CURRENT_REGS[REG_SP] = (uint32_t)CURRENT_REGS + CURRENT_REGS[REG_SP] = (uint32_t)CURRENT_REGS +
(uint32_t)XCPTCONTEXT_SIZE; XCPTCONTEXT_SIZE;
/* Then set up to vector to the trampoline with interrupts /* Then set up to vector to the trampoline with interrupts
* disabled. The kernel-space trampoline must run in * disabled. The kernel-space trampoline must run in
@@ -177,8 +178,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* by the signal trampoline after the signal has been delivered. * by the signal trampoline after the signal has been delivered.
*/ */
tcb->xcp.sigdeliver = (void *)sigdeliver;
/* Save the current register context location */ /* Save the current register context location */
tcb->xcp.saved_regs = tcb->xcp.regs; tcb->xcp.saved_regs = tcb->xcp.regs;
@@ -190,11 +189,11 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
tcb->xcp.regs = (void *) tcb->xcp.regs = (void *)
((uint32_t)tcb->xcp.regs - ((uint32_t)tcb->xcp.regs -
(uint32_t)XCPTCONTEXT_SIZE); XCPTCONTEXT_SIZE);
memcpy(tcb->xcp.regs, tcb->xcp.saved_regs, XCPTCONTEXT_SIZE); memcpy(tcb->xcp.regs, tcb->xcp.saved_regs, XCPTCONTEXT_SIZE);
tcb->xcp.regs[REG_SP] = (uint32_t)tcb->xcp.regs + tcb->xcp.regs[REG_SP] = (uint32_t)tcb->xcp.regs +
(uint32_t)XCPTCONTEXT_SIZE; XCPTCONTEXT_SIZE;
/* Then set up to vector to the trampoline with interrupts /* Then set up to vector to the trampoline with interrupts
* disabled. We must already be in privileged thread mode to be * disabled. We must already be in privileged thread mode to be
@@ -228,6 +227,8 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
if (!tcb->xcp.sigdeliver) if (!tcb->xcp.sigdeliver)
{ {
tcb->xcp.sigdeliver = sigdeliver;
/* First, handle some special cases when the signal is being delivered /* First, handle some special cases when the signal is being delivered
* to task that is currently executing on any CPU. * to task that is currently executing on any CPU.
*/ */
@@ -250,6 +251,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
*/ */
sigdeliver(tcb); sigdeliver(tcb);
tcb->xcp.sigdeliver = NULL;
} }
/* CASE 2: The task that needs to receive the signal is running. /* CASE 2: The task that needs to receive the signal is running.
@@ -285,8 +287,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* been delivered. * been delivered.
*/ */
tcb->xcp.sigdeliver = (void *)sigdeliver;
/* Save the current register context location */ /* Save the current register context location */
tcb->xcp.saved_regs = tcb->xcp.regs; tcb->xcp.saved_regs = tcb->xcp.regs;
@@ -298,12 +298,12 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
tcb->xcp.regs = (void *) tcb->xcp.regs = (void *)
((uint32_t)tcb->xcp.regs - ((uint32_t)tcb->xcp.regs -
(uint32_t)XCPTCONTEXT_SIZE); XCPTCONTEXT_SIZE);
memcpy(tcb->xcp.regs, tcb->xcp.saved_regs, memcpy(tcb->xcp.regs, tcb->xcp.saved_regs,
XCPTCONTEXT_SIZE); XCPTCONTEXT_SIZE);
tcb->xcp.regs[REG_SP] = (uint32_t)tcb->xcp.regs + tcb->xcp.regs[REG_SP] = (uint32_t)tcb->xcp.regs +
(uint32_t)XCPTCONTEXT_SIZE; XCPTCONTEXT_SIZE;
/* Then set up vector to the trampoline with interrupts /* Then set up vector to the trampoline with interrupts
* disabled. We must already be in privileged thread mode * disabled. We must already be in privileged thread mode
@@ -331,8 +331,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* signal has been delivered. * signal has been delivered.
*/ */
tcb->xcp.sigdeliver = (void *)sigdeliver;
/* And make sure that the saved context in the TCB is the /* And make sure that the saved context in the TCB is the
* same as the interrupt return context. * same as the interrupt return context.
*/ */
@@ -346,12 +344,12 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
CURRENT_REGS = (void *) CURRENT_REGS = (void *)
((uint32_t)CURRENT_REGS - ((uint32_t)CURRENT_REGS -
(uint32_t)XCPTCONTEXT_SIZE); XCPTCONTEXT_SIZE);
memcpy((uint32_t *)CURRENT_REGS, tcb->xcp.saved_regs, memcpy((uint32_t *)CURRENT_REGS, tcb->xcp.saved_regs,
XCPTCONTEXT_SIZE); XCPTCONTEXT_SIZE);
CURRENT_REGS[REG_SP] = (uint32_t)CURRENT_REGS + CURRENT_REGS[REG_SP] = (uint32_t)CURRENT_REGS +
(uint32_t)XCPTCONTEXT_SIZE; XCPTCONTEXT_SIZE;
/* Then set up vector to the trampoline with interrupts /* Then set up vector to the trampoline with interrupts
* disabled. The kernel-space trampoline must run in * disabled. The kernel-space trampoline must run in
@@ -409,8 +407,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* by the signal trampoline after the signal has been delivered. * by the signal trampoline after the signal has been delivered.
*/ */
tcb->xcp.sigdeliver = (void *)sigdeliver;
/* Save the current register context location */ /* Save the current register context location */
tcb->xcp.saved_regs = tcb->xcp.regs; tcb->xcp.saved_regs = tcb->xcp.regs;
@@ -422,11 +418,11 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
tcb->xcp.regs = (void *) tcb->xcp.regs = (void *)
((uint32_t)tcb->xcp.regs - ((uint32_t)tcb->xcp.regs -
(uint32_t)XCPTCONTEXT_SIZE); XCPTCONTEXT_SIZE);
memcpy(tcb->xcp.regs, tcb->xcp.saved_regs, XCPTCONTEXT_SIZE); memcpy(tcb->xcp.regs, tcb->xcp.saved_regs, XCPTCONTEXT_SIZE);
tcb->xcp.regs[REG_SP] = (uint32_t)tcb->xcp.regs + tcb->xcp.regs[REG_SP] = (uint32_t)tcb->xcp.regs +
(uint32_t)XCPTCONTEXT_SIZE; XCPTCONTEXT_SIZE;
/* Increment the IRQ lock count so that when the task is restarted, /* Increment the IRQ lock count so that when the task is restarted,
* it will hold the IRQ spinlock. * it will hold the IRQ spinlock.
@@ -83,6 +83,8 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
if (!tcb->xcp.sigdeliver) if (!tcb->xcp.sigdeliver)
{ {
tcb->xcp.sigdeliver = sigdeliver;
/* First, handle some special cases when the signal is /* First, handle some special cases when the signal is
* being delivered to the currently executing task. * being delivered to the currently executing task.
*/ */
@@ -100,6 +102,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
/* In this case just deliver the signal now. */ /* In this case just deliver the signal now. */
sigdeliver(tcb); sigdeliver(tcb);
tcb->xcp.sigdeliver = NULL;
} }
/* CASE 2: We are in an interrupt handler AND the /* CASE 2: We are in an interrupt handler AND the
@@ -121,8 +124,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* the signals have been delivered. * the signals have been delivered.
*/ */
tcb->xcp.sigdeliver = sigdeliver;
/* And make sure that the saved context in the TCB /* And make sure that the saved context in the TCB
* is the same as the interrupt return context. * is the same as the interrupt return context.
*/ */
@@ -135,12 +136,12 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
*/ */
CURRENT_REGS = (void *)((uint32_t)CURRENT_REGS - CURRENT_REGS = (void *)((uint32_t)CURRENT_REGS -
(uint32_t)XCPTCONTEXT_SIZE); XCPTCONTEXT_SIZE);
memcpy((uint32_t *)CURRENT_REGS, tcb->xcp.saved_regs, memcpy((uint32_t *)CURRENT_REGS, tcb->xcp.saved_regs,
XCPTCONTEXT_SIZE); XCPTCONTEXT_SIZE);
CURRENT_REGS[REG_SP] = (uint32_t)CURRENT_REGS + CURRENT_REGS[REG_SP] = (uint32_t)CURRENT_REGS +
(uint32_t)XCPTCONTEXT_SIZE; XCPTCONTEXT_SIZE;
/* Then set up to vector to the trampoline with interrupts /* Then set up to vector to the trampoline with interrupts
* disabled * disabled
@@ -165,8 +166,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* the signals have been delivered. * the signals have been delivered.
*/ */
tcb->xcp.sigdeliver = sigdeliver;
/* Save the current register context location */ /* Save the current register context location */
tcb->xcp.saved_regs = tcb->xcp.regs; tcb->xcp.saved_regs = tcb->xcp.regs;
@@ -177,11 +176,11 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
*/ */
tcb->xcp.regs = (void *)((uint32_t)tcb->xcp.regs - tcb->xcp.regs = (void *)((uint32_t)tcb->xcp.regs -
(uint32_t)XCPTCONTEXT_SIZE); XCPTCONTEXT_SIZE);
memcpy(tcb->xcp.regs, tcb->xcp.saved_regs, XCPTCONTEXT_SIZE); memcpy(tcb->xcp.regs, tcb->xcp.saved_regs, XCPTCONTEXT_SIZE);
tcb->xcp.regs[REG_SP] = (uint32_t)tcb->xcp.regs + tcb->xcp.regs[REG_SP] = (uint32_t)tcb->xcp.regs +
(uint32_t)XCPTCONTEXT_SIZE; XCPTCONTEXT_SIZE;
/* Then set up to vector to the trampoline with interrupts /* Then set up to vector to the trampoline with interrupts
* disabled * disabled
@@ -126,6 +126,8 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
if (!tcb->xcp.sigdeliver) if (!tcb->xcp.sigdeliver)
{ {
tcb->xcp.sigdeliver = sigdeliver;
/* First, handle some special cases when the signal is being delivered /* First, handle some special cases when the signal is being delivered
* to task that is currently executing on this CPU. * to task that is currently executing on this CPU.
*/ */
@@ -143,6 +145,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
*/ */
sigdeliver(tcb); sigdeliver(tcb);
tcb->xcp.sigdeliver = NULL;
} }
/* CASE 2: We are in an interrupt handler AND the interrupted /* CASE 2: We are in an interrupt handler AND the interrupted
@@ -164,8 +167,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* the signals have been delivered. * the signals have been delivered.
*/ */
tcb->xcp.sigdeliver = sigdeliver;
/* create signal process context */ /* create signal process context */
tcb->xcp.saved_reg = (uint64_t *)CURRENT_REGS; tcb->xcp.saved_reg = (uint64_t *)CURRENT_REGS;
@@ -193,7 +194,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* have been delivered. * have been delivered.
*/ */
tcb->xcp.sigdeliver = sigdeliver;
#ifdef CONFIG_ARCH_FPU #ifdef CONFIG_ARCH_FPU
tcb->xcp.saved_fpu_regs = tcb->xcp.fpu_regs; tcb->xcp.saved_fpu_regs = tcb->xcp.fpu_regs;
#endif #endif
@@ -218,6 +218,8 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
if (!tcb->xcp.sigdeliver) if (!tcb->xcp.sigdeliver)
{ {
tcb->xcp.sigdeliver = sigdeliver;
/* First, handle some special cases when the signal is being delivered /* First, handle some special cases when the signal is being delivered
* to task that is currently executing on any CPU. * to task that is currently executing on any CPU.
*/ */
@@ -240,6 +242,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
*/ */
sigdeliver(tcb); sigdeliver(tcb);
tcb->xcp.sigdeliver = NULL;
} }
/* CASE 2: The task that needs to receive the signal is running. /* CASE 2: The task that needs to receive the signal is running.
@@ -275,8 +278,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* been delivered. * been delivered.
*/ */
tcb->xcp.sigdeliver = sigdeliver;
#ifdef CONFIG_ARCH_FPU #ifdef CONFIG_ARCH_FPU
tcb->xcp.saved_fpu_regs = tcb->xcp.fpu_regs; tcb->xcp.saved_fpu_regs = tcb->xcp.fpu_regs;
#endif #endif
@@ -295,8 +296,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* has been delivered. * has been delivered.
*/ */
tcb->xcp.sigdeliver = (void *)sigdeliver;
/* create signal process context */ /* create signal process context */
tcb->xcp.saved_reg = (uint64_t *)CURRENT_REGS; tcb->xcp.saved_reg = (uint64_t *)CURRENT_REGS;
@@ -346,8 +345,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* have been delivered. * have been delivered.
*/ */
tcb->xcp.sigdeliver = sigdeliver;
#ifdef CONFIG_ARCH_FPU #ifdef CONFIG_ARCH_FPU
tcb->xcp.saved_fpu_regs = tcb->xcp.fpu_regs; tcb->xcp.saved_fpu_regs = tcb->xcp.fpu_regs;
#endif #endif
+3 -2
View File
@@ -85,6 +85,8 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
if (!tcb->xcp.sigdeliver) if (!tcb->xcp.sigdeliver)
{ {
tcb->xcp.sigdeliver = sigdeliver;
/* First, handle some special cases when the signal is /* First, handle some special cases when the signal is
* being delivered to the currently executing task. * being delivered to the currently executing task.
*/ */
@@ -103,6 +105,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
/* In this case just deliver the signal now. */ /* In this case just deliver the signal now. */
sigdeliver(tcb); sigdeliver(tcb);
tcb->xcp.sigdeliver = NULL;
} }
/* CASE 2: We are in an interrupt handler AND the /* CASE 2: We are in an interrupt handler AND the
@@ -124,7 +127,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* trampoline after the signal(s) have been delivered. * trampoline after the signal(s) have been delivered.
*/ */
tcb->xcp.sigdeliver = sigdeliver;
tcb->xcp.saved_pc0 = g_current_regs[REG_PC0]; tcb->xcp.saved_pc0 = g_current_regs[REG_PC0];
tcb->xcp.saved_pc1 = g_current_regs[REG_PC1]; tcb->xcp.saved_pc1 = g_current_regs[REG_PC1];
#if defined(REG_PC2) #if defined(REG_PC2)
@@ -167,7 +169,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* the signals have been delivered. * the signals have been delivered.
*/ */
tcb->xcp.sigdeliver = sigdeliver;
tcb->xcp.saved_pc0 = tcb->xcp.regs[REG_PC0]; tcb->xcp.saved_pc0 = tcb->xcp.regs[REG_PC0];
tcb->xcp.saved_pc1 = tcb->xcp.regs[REG_PC1]; tcb->xcp.saved_pc1 = tcb->xcp.regs[REG_PC1];
#if defined(REG_PC2) #if defined(REG_PC2)
+3 -2
View File
@@ -83,6 +83,8 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
if (!tcb->xcp.sigdeliver) if (!tcb->xcp.sigdeliver)
{ {
tcb->xcp.sigdeliver = sigdeliver;
/* First, handle some special cases when the signal is /* First, handle some special cases when the signal is
* being delivered to the currently executing task. * being delivered to the currently executing task.
*/ */
@@ -101,6 +103,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
/* In this case just deliver the signal now. */ /* In this case just deliver the signal now. */
sigdeliver(tcb); sigdeliver(tcb);
tcb->xcp.sigdeliver = NULL;
} }
/* CASE 2: We are in an interrupt handler AND the /* CASE 2: We are in an interrupt handler AND the
@@ -122,7 +125,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* trampoline after the signal(s) have been delivered. * trampoline after the signal(s) have been delivered.
*/ */
tcb->xcp.sigdeliver = sigdeliver;
tcb->xcp.saved_pc = g_current_regs[REG_PC]; tcb->xcp.saved_pc = g_current_regs[REG_PC];
tcb->xcp.saved_sr = g_current_regs[REG_SR]; tcb->xcp.saved_sr = g_current_regs[REG_SR];
@@ -154,7 +156,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* the signals have been delivered. * the signals have been delivered.
*/ */
tcb->xcp.sigdeliver = sigdeliver;
tcb->xcp.saved_pc = tcb->xcp.regs[REG_PC]; tcb->xcp.saved_pc = tcb->xcp.regs[REG_PC];
tcb->xcp.saved_sr = tcb->xcp.regs[REG_SR]; tcb->xcp.saved_sr = tcb->xcp.regs[REG_SR];
@@ -81,6 +81,8 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
if (tcb->xcp.sigdeliver == NULL) if (tcb->xcp.sigdeliver == NULL)
{ {
tcb->xcp.sigdeliver = sigdeliver;
/* First, handle some special cases when the signal is being delivered /* First, handle some special cases when the signal is being delivered
* to task that is currently executing on any CPU. * to task that is currently executing on any CPU.
*/ */
@@ -105,6 +107,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
/* In this case just deliver the signal now. */ /* In this case just deliver the signal now. */
sigdeliver(tcb); sigdeliver(tcb);
tcb->xcp.sigdeliver = NULL;
} }
/* CASE 2: The task that needs to receive the signal is running. /* CASE 2: The task that needs to receive the signal is running.
@@ -141,7 +144,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
/* Save the current register context location */ /* Save the current register context location */
tcb->xcp.saved_regs = g_current_regs[cpu]; tcb->xcp.saved_regs = g_current_regs[cpu];
tcb->xcp.sigdeliver = (void *)sigdeliver;
/* Duplicate the register context. These will be /* Duplicate the register context. These will be
* restored by the signal trampoline after the signal has been * restored by the signal trampoline after the signal has been
@@ -149,8 +151,8 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
*/ */
g_current_regs[cpu] -= XCPTCONTEXT_REGS; g_current_regs[cpu] -= XCPTCONTEXT_REGS;
memcpy(g_current_regs[cpu], g_current_regs[cpu] memcpy(g_current_regs[cpu], g_current_regs[cpu] +
+ XCPTCONTEXT_REGS, XCPTCONTEXT_SIZE); XCPTCONTEXT_REGS, XCPTCONTEXT_SIZE);
g_current_regs[cpu][REG_SP] = (uint32_t)g_current_regs[cpu]; g_current_regs[cpu][REG_SP] = (uint32_t)g_current_regs[cpu];
@@ -186,15 +188,14 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
/* Save the current register context location */ /* Save the current register context location */
tcb->xcp.saved_regs = tcb->xcp.regs; tcb->xcp.saved_regs = tcb->xcp.regs;
tcb->xcp.sigdeliver = (void *)sigdeliver;
/* Duplicate the register context. These will be restored /* Duplicate the register context. These will be restored
* by the signal trampoline after the signal has been delivered. * by the signal trampoline after the signal has been delivered.
*/ */
tcb->xcp.regs -= XCPTCONTEXT_REGS; tcb->xcp.regs -= XCPTCONTEXT_REGS;
memcpy(tcb->xcp.regs, tcb->xcp.regs memcpy(tcb->xcp.regs, tcb->xcp.regs +
+ XCPTCONTEXT_REGS, XCPTCONTEXT_SIZE); XCPTCONTEXT_REGS, XCPTCONTEXT_SIZE);
tcb->xcp.regs[REG_SP] = (uint32_t)tcb->xcp.regs; tcb->xcp.regs[REG_SP] = (uint32_t)tcb->xcp.regs;
@@ -86,6 +86,8 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
if (!tcb->xcp.sigdeliver) if (!tcb->xcp.sigdeliver)
{ {
tcb->xcp.sigdeliver = sigdeliver;
/* First, handle some special cases when the signal is /* First, handle some special cases when the signal is
* being delivered to the currently executing task. * being delivered to the currently executing task.
*/ */
@@ -104,6 +106,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
/* In this case just deliver the signal now. */ /* In this case just deliver the signal now. */
sigdeliver(tcb); sigdeliver(tcb);
tcb->xcp.sigdeliver = NULL;
} }
/* CASE 2: We are in an interrupt handler AND the /* CASE 2: We are in an interrupt handler AND the
@@ -125,7 +128,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* been delivered. * been delivered.
*/ */
tcb->xcp.sigdeliver = sigdeliver;
tcb->xcp.saved_epc = CURRENT_REGS[REG_EPC]; tcb->xcp.saved_epc = CURRENT_REGS[REG_EPC];
tcb->xcp.saved_status = CURRENT_REGS[REG_STATUS]; tcb->xcp.saved_status = CURRENT_REGS[REG_STATUS];
@@ -165,7 +167,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* been delivered. * been delivered.
*/ */
tcb->xcp.sigdeliver = sigdeliver;
tcb->xcp.saved_epc = tcb->xcp.regs[REG_EPC]; tcb->xcp.saved_epc = tcb->xcp.regs[REG_EPC];
tcb->xcp.saved_status = tcb->xcp.regs[REG_STATUS]; tcb->xcp.saved_status = tcb->xcp.regs[REG_STATUS];
+3 -2
View File
@@ -83,6 +83,8 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
if (!tcb->xcp.sigdeliver) if (!tcb->xcp.sigdeliver)
{ {
tcb->xcp.sigdeliver = sigdeliver;
/* First, handle some special cases when the signal is /* First, handle some special cases when the signal is
* being delivered to the currently executing task. * being delivered to the currently executing task.
*/ */
@@ -101,6 +103,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
/* In this case just deliver the signal now. */ /* In this case just deliver the signal now. */
sigdeliver(tcb); sigdeliver(tcb);
tcb->xcp.sigdeliver = NULL;
} }
/* CASE 2: We are in an interrupt handler AND the /* CASE 2: We are in an interrupt handler AND the
@@ -122,7 +125,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* been delivered. * been delivered.
*/ */
tcb->xcp.sigdeliver = sigdeliver;
tcb->xcp.saved_epc = g_current_regs[REG_EPC]; tcb->xcp.saved_epc = g_current_regs[REG_EPC];
/* Then set up to vector to the trampoline with interrupts /* Then set up to vector to the trampoline with interrupts
@@ -157,7 +159,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* been delivered. * been delivered.
*/ */
tcb->xcp.sigdeliver = sigdeliver;
tcb->xcp.saved_epc = tcb->xcp.regs[REG_EPC]; tcb->xcp.saved_epc = tcb->xcp.regs[REG_EPC];
tcb->xcp.saved_int_ctx = tcb->xcp.regs[REG_INT_CTX]; tcb->xcp.saved_int_ctx = tcb->xcp.regs[REG_INT_CTX];
@@ -84,6 +84,8 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
if (!tcb->xcp.sigdeliver) if (!tcb->xcp.sigdeliver)
{ {
tcb->xcp.sigdeliver = sigdeliver;
/* First, handle some special cases when the signal is being delivered /* First, handle some special cases when the signal is being delivered
* to the currently executing task. * to the currently executing task.
*/ */
@@ -101,6 +103,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
/* In this case just deliver the signal now. */ /* In this case just deliver the signal now. */
sigdeliver(tcb); sigdeliver(tcb);
tcb->xcp.sigdeliver = NULL;
} }
/* CASE 2: We are in an interrupt handler AND the interrupted task /* CASE 2: We are in an interrupt handler AND the interrupted task
@@ -122,7 +125,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* been delivered. * been delivered.
*/ */
tcb->xcp.sigdeliver = sigdeliver;
tcb->xcp.saved_epc = g_current_regs[REG_CSR_MEPC]; tcb->xcp.saved_epc = g_current_regs[REG_CSR_MEPC];
/* Then set up to vector to the trampoline with interrupts /* Then set up to vector to the trampoline with interrupts
@@ -157,7 +159,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* delivered. * delivered.
*/ */
tcb->xcp.sigdeliver = sigdeliver;
tcb->xcp.saved_epc = tcb->xcp.regs[REG_CSR_MEPC]; tcb->xcp.saved_epc = tcb->xcp.regs[REG_CSR_MEPC];
tcb->xcp.saved_int_ctx = tcb->xcp.regs[REG_CSR_MSTATUS]; tcb->xcp.saved_int_ctx = tcb->xcp.regs[REG_CSR_MSTATUS];
@@ -82,6 +82,8 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
if (!tcb->xcp.sigdeliver) if (!tcb->xcp.sigdeliver)
{ {
tcb->xcp.sigdeliver = sigdeliver;
/* First, handle some special cases when the signal is /* First, handle some special cases when the signal is
* being delivered to the currently executing task. * being delivered to the currently executing task.
*/ */
@@ -99,6 +101,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
/* In this case just deliver the signal now. */ /* In this case just deliver the signal now. */
sigdeliver(tcb); sigdeliver(tcb);
tcb->xcp.sigdeliver = NULL;
} }
/* CASE 2: We are in an interrupt handler AND the /* CASE 2: We are in an interrupt handler AND the
@@ -120,7 +123,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* the signals have been delivered. * the signals have been delivered.
*/ */
tcb->xcp.sigdeliver = sigdeliver;
/* tcb->xcp.saved_pc = CURRENT_REGS[REG_PC]; /* tcb->xcp.saved_pc = CURRENT_REGS[REG_PC];
* tcb->xcp.saved_cpsr = CURRENT_REGS[REG_CPSR]; * tcb->xcp.saved_cpsr = CURRENT_REGS[REG_CPSR];
*/ */
@@ -155,7 +157,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* the signals have been delivered. * the signals have been delivered.
*/ */
tcb->xcp.sigdeliver = sigdeliver;
tcb->xcp.saved_pc = tcb->xcp.regs[REG_PC]; tcb->xcp.saved_pc = tcb->xcp.regs[REG_PC];
/* tcb->xcp.saved_cpsr = tcb->xcp.regs[REG_CPSR]; */ /* tcb->xcp.saved_cpsr = tcb->xcp.regs[REG_CPSR]; */
@@ -82,6 +82,8 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
if (!tcb->xcp.sigdeliver) if (!tcb->xcp.sigdeliver)
{ {
tcb->xcp.sigdeliver = sigdeliver;
/* First, handle some special cases when the signal is /* First, handle some special cases when the signal is
* being delivered to the currently executing task. * being delivered to the currently executing task.
*/ */
@@ -99,6 +101,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
/* In this case just deliver the signal now. */ /* In this case just deliver the signal now. */
sigdeliver(tcb); sigdeliver(tcb);
tcb->xcp.sigdeliver = NULL;
} }
/* CASE 2: We are in an interrupt handler AND the /* CASE 2: We are in an interrupt handler AND the
@@ -114,7 +117,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* the signals have been delivered. * the signals have been delivered.
*/ */
tcb->xcp.sigdeliver = sigdeliver;
tcb->xcp.saved_pc[0] = g_current_regs[REG_PC]; tcb->xcp.saved_pc[0] = g_current_regs[REG_PC];
tcb->xcp.saved_pc[1] = g_current_regs[REG_PC + 1]; tcb->xcp.saved_pc[1] = g_current_regs[REG_PC + 1];
tcb->xcp.saved_flg = g_current_regs[REG_FLG]; tcb->xcp.saved_flg = g_current_regs[REG_FLG];
@@ -148,7 +150,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* the signals have been delivered. * the signals have been delivered.
*/ */
tcb->xcp.sigdeliver = sigdeliver;
tcb->xcp.saved_pc[0] = tcb->xcp.regs[REG_PC]; tcb->xcp.saved_pc[0] = tcb->xcp.regs[REG_PC];
tcb->xcp.saved_pc[1] = tcb->xcp.regs[REG_PC + 1]; tcb->xcp.saved_pc[1] = tcb->xcp.regs[REG_PC + 1];
tcb->xcp.saved_flg = tcb->xcp.regs[REG_FLG]; tcb->xcp.saved_flg = tcb->xcp.regs[REG_FLG];
@@ -82,6 +82,8 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
if (!tcb->xcp.sigdeliver) if (!tcb->xcp.sigdeliver)
{ {
tcb->xcp.sigdeliver = sigdeliver;
/* First, handle some special cases when the signal is /* First, handle some special cases when the signal is
* being delivered to the currently executing task. * being delivered to the currently executing task.
*/ */
@@ -99,6 +101,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
/* In this case just deliver the signal now. */ /* In this case just deliver the signal now. */
sigdeliver(tcb); sigdeliver(tcb);
tcb->xcp.sigdeliver = NULL;
} }
/* CASE 2: We are in an interrupt handler AND the /* CASE 2: We are in an interrupt handler AND the
@@ -114,7 +117,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* the signals have been delivered. * the signals have been delivered.
*/ */
tcb->xcp.sigdeliver = sigdeliver;
tcb->xcp.saved_pc = g_current_regs[REG_PC]; tcb->xcp.saved_pc = g_current_regs[REG_PC];
tcb->xcp.saved_sr = g_current_regs[REG_PSW]; tcb->xcp.saved_sr = g_current_regs[REG_PSW];
@@ -146,7 +148,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* the signals have been delivered. * the signals have been delivered.
*/ */
tcb->xcp.sigdeliver = sigdeliver;
tcb->xcp.saved_pc = tcb->xcp.regs[REG_PC]; tcb->xcp.saved_pc = tcb->xcp.regs[REG_PC];
tcb->xcp.saved_sr = tcb->xcp.regs[REG_PSW]; tcb->xcp.saved_sr = tcb->xcp.regs[REG_PSW];
+3 -2
View File
@@ -82,6 +82,8 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
if (!tcb->xcp.sigdeliver) if (!tcb->xcp.sigdeliver)
{ {
tcb->xcp.sigdeliver = sigdeliver;
/* First, handle some special cases when the signal is /* First, handle some special cases when the signal is
* being delivered to the currently executing task. * being delivered to the currently executing task.
*/ */
@@ -99,6 +101,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
/* In this case just deliver the signal now. */ /* In this case just deliver the signal now. */
sigdeliver(tcb); sigdeliver(tcb);
tcb->xcp.sigdeliver = NULL;
} }
/* CASE 2: We are in an interrupt handler AND the /* CASE 2: We are in an interrupt handler AND the
@@ -114,7 +117,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* the signals have been delivered. * the signals have been delivered.
*/ */
tcb->xcp.sigdeliver = sigdeliver;
tcb->xcp.saved_pc = g_current_regs[REG_PC]; tcb->xcp.saved_pc = g_current_regs[REG_PC];
tcb->xcp.saved_sr = g_current_regs[REG_SR]; tcb->xcp.saved_sr = g_current_regs[REG_SR];
@@ -146,7 +148,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* the signals have been delivered. * the signals have been delivered.
*/ */
tcb->xcp.sigdeliver = sigdeliver;
tcb->xcp.saved_pc = tcb->xcp.regs[REG_PC]; tcb->xcp.saved_pc = tcb->xcp.regs[REG_PC];
tcb->xcp.saved_sr = tcb->xcp.regs[REG_SR]; tcb->xcp.saved_sr = tcb->xcp.regs[REG_SR];
@@ -87,6 +87,8 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
if (!tcb->xcp.sigdeliver) if (!tcb->xcp.sigdeliver)
{ {
tcb->xcp.sigdeliver = sigdeliver;
/* First, handle some special cases when the signal is /* First, handle some special cases when the signal is
* being delivered to the currently executing task. * being delivered to the currently executing task.
*/ */
@@ -105,6 +107,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
/* In this case just deliver the signal now. */ /* In this case just deliver the signal now. */
sigdeliver(tcb); sigdeliver(tcb);
tcb->xcp.sigdeliver = NULL;
} }
/* CASE 2: We are in an interrupt handler AND the /* CASE 2: We are in an interrupt handler AND the
@@ -144,7 +147,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* privileged thread mode. * privileged thread mode.
*/ */
tcb->xcp.sigdeliver = sigdeliver;
CURRENT_REGS[REG_EPC] = (uintptr_t)riscv_sigdeliver; CURRENT_REGS[REG_EPC] = (uintptr_t)riscv_sigdeliver;
int_ctx = CURRENT_REGS[REG_INT_CTX]; int_ctx = CURRENT_REGS[REG_INT_CTX];
@@ -179,8 +181,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* been delivered. * been delivered.
*/ */
tcb->xcp.sigdeliver = sigdeliver;
/* Save the current register context location */ /* Save the current register context location */
tcb->xcp.saved_regs = tcb->xcp.regs; tcb->xcp.saved_regs = tcb->xcp.regs;
@@ -227,6 +227,8 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
if (!tcb->xcp.sigdeliver) if (!tcb->xcp.sigdeliver)
{ {
tcb->xcp.sigdeliver = sigdeliver;
/* First, handle some special cases when the signal is being delivered /* First, handle some special cases when the signal is being delivered
* to task that is currently executing on any CPU. * to task that is currently executing on any CPU.
*/ */
@@ -249,6 +251,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
*/ */
sigdeliver(tcb); sigdeliver(tcb);
tcb->xcp.sigdeliver = NULL;
} }
/* CASE 2: The task that needs to receive the signal is running. /* CASE 2: The task that needs to receive the signal is running.
@@ -284,8 +287,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* been delivered. * been delivered.
*/ */
tcb->xcp.sigdeliver = sigdeliver;
/* Then set up vector to the trampoline with interrupts /* Then set up vector to the trampoline with interrupts
* disabled. We must already be in privileged thread mode * disabled. We must already be in privileged thread mode
* to be here. * to be here.
@@ -326,8 +327,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* been delivered. * been delivered.
*/ */
tcb->xcp.sigdeliver = (void *)sigdeliver;
tcb->xcp.saved_regs = (uintptr_t *)CURRENT_REGS; tcb->xcp.saved_regs = (uintptr_t *)CURRENT_REGS;
/* Duplicate the register context. These will be /* Duplicate the register context. These will be
@@ -394,8 +393,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* by the signal trampoline after the signal has been delivered. * by the signal trampoline after the signal has been delivered.
*/ */
tcb->xcp.sigdeliver = (void *)sigdeliver;
/* Save the current register context location */ /* Save the current register context location */
tcb->xcp.saved_regs = tcb->xcp.regs; tcb->xcp.saved_regs = tcb->xcp.regs;
@@ -405,7 +402,8 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* delivered. * delivered.
*/ */
tcb->xcp.regs = (uintptr_t *)((uintptr_t)tcb->xcp.regs - tcb->xcp.regs = (uintptr_t *)
((uintptr_t)tcb->xcp.regs -
XCPTCONTEXT_SIZE); XCPTCONTEXT_SIZE);
memcpy(tcb->xcp.regs, tcb->xcp.saved_regs, XCPTCONTEXT_SIZE); memcpy(tcb->xcp.regs, tcb->xcp.saved_regs, XCPTCONTEXT_SIZE);
+4 -3
View File
@@ -83,13 +83,14 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
flags = enter_critical_section(); flags = enter_critical_section();
if (tcb->xcp.sigdeliver == NULL)
{
tcb->xcp.sigdeliver = sigdeliver;
if (tcb == this_task()) if (tcb == this_task())
{ {
sigdeliver(tcb); sigdeliver(tcb);
tcb->xcp.sigdeliver = NULL;
} }
else
{
tcb->xcp.sigdeliver = sigdeliver;
} }
leave_critical_section(flags); leave_critical_section(flags);
@@ -86,6 +86,8 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
if (!tcb->xcp.sigdeliver) if (!tcb->xcp.sigdeliver)
{ {
tcb->xcp.sigdeliver = sigdeliver;
/* First, handle some special cases when the signal is /* First, handle some special cases when the signal is
* being delivered to the currently executing task. * being delivered to the currently executing task.
*/ */
@@ -103,6 +105,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
/* In this case just deliver the signal now. */ /* In this case just deliver the signal now. */
sigdeliver(tcb); sigdeliver(tcb);
tcb->xcp.sigdeliver = NULL;
} }
/* CASE 2: We are in an interrupt handler AND the /* CASE 2: We are in an interrupt handler AND the
@@ -124,7 +127,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* trampoline after the signal(s) have been delivered. * trampoline after the signal(s) have been delivered.
*/ */
tcb->xcp.sigdeliver = sigdeliver;
tcb->xcp.saved_pc = CURRENT_REGS[REG_PC]; tcb->xcp.saved_pc = CURRENT_REGS[REG_PC];
tcb->xcp.saved_npc = CURRENT_REGS[REG_NPC]; tcb->xcp.saved_npc = CURRENT_REGS[REG_NPC];
tcb->xcp.saved_status = CURRENT_REGS[REG_PSR]; tcb->xcp.saved_status = CURRENT_REGS[REG_PSR];
@@ -158,7 +160,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* the signals have been delivered. * the signals have been delivered.
*/ */
tcb->xcp.sigdeliver = sigdeliver;
tcb->xcp.saved_pc = tcb->xcp.regs[REG_PC]; tcb->xcp.saved_pc = tcb->xcp.regs[REG_PC];
tcb->xcp.saved_npc = tcb->xcp.regs[REG_NPC]; tcb->xcp.saved_npc = tcb->xcp.regs[REG_NPC];
tcb->xcp.saved_status = tcb->xcp.regs[REG_PSR]; tcb->xcp.saved_status = tcb->xcp.regs[REG_PSR];
@@ -194,6 +195,8 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
if (!tcb->xcp.sigdeliver) if (!tcb->xcp.sigdeliver)
{ {
tcb->xcp.sigdeliver = sigdeliver;
/* First, handle some special cases when the signal is being delivered /* First, handle some special cases when the signal is being delivered
* to task that is currently executing on any CPU. * to task that is currently executing on any CPU.
*/ */
@@ -216,6 +219,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
*/ */
sigdeliver(tcb); sigdeliver(tcb);
tcb->xcp.sigdeliver = NULL;
} }
/* CASE 2: The task that needs to receive the signal is running. /* CASE 2: The task that needs to receive the signal is running.
@@ -251,7 +255,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* been delivered. * been delivered.
*/ */
tcb->xcp.sigdeliver = (void *)sigdeliver;
tcb->xcp.saved_pc = tcb->xcp.regs[REG_PC]; tcb->xcp.saved_pc = tcb->xcp.regs[REG_PC];
tcb->xcp.saved_npc = tcb->xcp.regs[REG_NPC]; tcb->xcp.saved_npc = tcb->xcp.regs[REG_NPC];
tcb->xcp.saved_status = tcb->xcp.regs[REG_PSR]; tcb->xcp.saved_status = tcb->xcp.regs[REG_PSR];
@@ -274,7 +277,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* trampoline after the signal(s) have been delivered. * trampoline after the signal(s) have been delivered.
*/ */
tcb->xcp.sigdeliver = (void *)sigdeliver;
tcb->xcp.saved_pc = CURRENT_REGS[REG_PC]; tcb->xcp.saved_pc = CURRENT_REGS[REG_PC];
tcb->xcp.saved_npc = CURRENT_REGS[REG_NPC]; tcb->xcp.saved_npc = CURRENT_REGS[REG_NPC];
tcb->xcp.saved_status = CURRENT_REGS[REG_PSR]; tcb->xcp.saved_status = CURRENT_REGS[REG_PSR];
@@ -330,7 +332,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* trampoline after the signal(s) have been delivered. * trampoline after the signal(s) have been delivered.
*/ */
tcb->xcp.sigdeliver = (void *)sigdeliver;
tcb->xcp.saved_pc = CURRENT_REGS[REG_PC]; tcb->xcp.saved_pc = CURRENT_REGS[REG_PC];
tcb->xcp.saved_npc = CURRENT_REGS[REG_NPC]; tcb->xcp.saved_npc = CURRENT_REGS[REG_NPC];
tcb->xcp.saved_status = CURRENT_REGS[REG_PSR]; tcb->xcp.saved_status = CURRENT_REGS[REG_PSR];
+3 -2
View File
@@ -78,6 +78,8 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
if (!tcb->xcp.sigdeliver) if (!tcb->xcp.sigdeliver)
{ {
tcb->xcp.sigdeliver = sigdeliver;
/* First, handle some special cases when the signal is being delivered /* First, handle some special cases when the signal is being delivered
* to the currently executing task. * to the currently executing task.
*/ */
@@ -95,6 +97,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
/* In this case just deliver the signal now. */ /* In this case just deliver the signal now. */
sigdeliver(tcb); sigdeliver(tcb);
tcb->xcp.sigdeliver = NULL;
} }
/* CASE 2: We are in an interrupt handler AND the interrupted task /* CASE 2: We are in an interrupt handler AND the interrupted task
@@ -116,7 +119,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* have been delivered. * have been delivered.
*/ */
tcb->xcp.sigdeliver = sigdeliver;
tcb->xcp.saved_eip = g_current_regs[REG_EIP]; tcb->xcp.saved_eip = g_current_regs[REG_EIP];
tcb->xcp.saved_eflags = g_current_regs[REG_EFLAGS]; tcb->xcp.saved_eflags = g_current_regs[REG_EFLAGS];
@@ -148,7 +150,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* the signals have been delivered. * the signals have been delivered.
*/ */
tcb->xcp.sigdeliver = sigdeliver;
tcb->xcp.saved_eip = tcb->xcp.regs[REG_EIP]; tcb->xcp.saved_eip = tcb->xcp.regs[REG_EIP];
tcb->xcp.saved_eflags = tcb->xcp.regs[REG_EFLAGS]; tcb->xcp.saved_eflags = tcb->xcp.regs[REG_EFLAGS];
@@ -79,6 +79,8 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
if (!tcb->xcp.sigdeliver) if (!tcb->xcp.sigdeliver)
{ {
tcb->xcp.sigdeliver = sigdeliver;
/* First, handle some special cases when the signal is being delivered /* First, handle some special cases when the signal is being delivered
* to the currently executing task. * to the currently executing task.
*/ */
@@ -96,6 +98,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
*/ */
sigdeliver(tcb); sigdeliver(tcb);
tcb->xcp.sigdeliver = NULL;
} }
/* CASE 2: We are in an interrupt handler AND the interrupted task /* CASE 2: We are in an interrupt handler AND the interrupted task
@@ -117,7 +120,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* have been delivered. * have been delivered.
*/ */
tcb->xcp.sigdeliver = sigdeliver;
tcb->xcp.saved_rip = g_current_regs[REG_RIP]; tcb->xcp.saved_rip = g_current_regs[REG_RIP];
tcb->xcp.saved_rsp = tcb->xcp.regs[REG_RSP]; tcb->xcp.saved_rsp = tcb->xcp.regs[REG_RSP];
tcb->xcp.saved_rflags = g_current_regs[REG_RFLAGS]; tcb->xcp.saved_rflags = g_current_regs[REG_RFLAGS];
@@ -150,7 +152,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* the signals have been delivered. * the signals have been delivered.
*/ */
tcb->xcp.sigdeliver = sigdeliver;
tcb->xcp.saved_rip = tcb->xcp.regs[REG_RIP]; tcb->xcp.saved_rip = tcb->xcp.regs[REG_RIP];
tcb->xcp.saved_rsp = tcb->xcp.regs[REG_RSP]; tcb->xcp.saved_rsp = tcb->xcp.regs[REG_RSP];
tcb->xcp.saved_rflags = tcb->xcp.regs[REG_RFLAGS]; tcb->xcp.saved_rflags = tcb->xcp.regs[REG_RFLAGS];
+12 -11
View File
@@ -88,6 +88,8 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
if (!tcb->xcp.sigdeliver) if (!tcb->xcp.sigdeliver)
{ {
tcb->xcp.sigdeliver = sigdeliver;
sinfo("rtcb=%p CURRENT_REGS=%p\n", this_task(), CURRENT_REGS); sinfo("rtcb=%p CURRENT_REGS=%p\n", this_task(), CURRENT_REGS);
/* First, handle some special cases when the signal is being delivered /* First, handle some special cases when the signal is being delivered
@@ -107,6 +109,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
*/ */
sigdeliver(tcb); sigdeliver(tcb);
tcb->xcp.sigdeliver = NULL;
} }
/* CASE 2: We are in an interrupt handler AND the interrupted /* CASE 2: We are in an interrupt handler AND the interrupted
@@ -146,7 +149,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* disabled * disabled
*/ */
tcb->xcp.sigdeliver = sigdeliver;
CURRENT_REGS[REG_PC] = (uint32_t)xtensa_sig_deliver; CURRENT_REGS[REG_PC] = (uint32_t)xtensa_sig_deliver;
#ifdef __XTENSA_CALL0_ABI__ #ifdef __XTENSA_CALL0_ABI__
CURRENT_REGS[REG_PS] = (uint32_t) CURRENT_REGS[REG_PS] = (uint32_t)
@@ -178,7 +180,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* NOTE: that hi-priority interrupts are not disabled. * NOTE: that hi-priority interrupts are not disabled.
*/ */
tcb->xcp.sigdeliver = sigdeliver;
tcb->xcp.saved_regs = tcb->xcp.regs; tcb->xcp.saved_regs = tcb->xcp.regs;
/* Duplicate the register context. These will be /* Duplicate the register context. These will be
@@ -225,6 +226,8 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
if (!tcb->xcp.sigdeliver) if (!tcb->xcp.sigdeliver)
{ {
tcb->xcp.sigdeliver = sigdeliver;
/* First, handle some special cases when the signal is being delivered /* First, handle some special cases when the signal is being delivered
* to task that is currently executing on any CPU. * to task that is currently executing on any CPU.
*/ */
@@ -247,6 +250,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
*/ */
sigdeliver(tcb); sigdeliver(tcb);
tcb->xcp.sigdeliver = NULL;
} }
/* CASE 2: The task that needs to receive the signal is running. /* CASE 2: The task that needs to receive the signal is running.
@@ -284,7 +288,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* NOTE: that hi-priority interrupts are not disabled. * NOTE: that hi-priority interrupts are not disabled.
*/ */
tcb->xcp.sigdeliver = sigdeliver;
tcb->xcp.saved_regs = tcb->xcp.regs; tcb->xcp.saved_regs = tcb->xcp.regs;
/* The Inter-Processor Interrupt that pauses the other CPU /* The Inter-Processor Interrupt that pauses the other CPU
@@ -319,12 +322,12 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
tcb->xcp.regs = (void *) tcb->xcp.regs = (void *)
((uint32_t)tcb->xcp.regs - ((uint32_t)tcb->xcp.regs -
(uint32_t)XCPTCONTEXT_SIZE); XCPTCONTEXT_SIZE);
memcpy(tcb->xcp.regs, tcb->xcp.saved_regs, memcpy(tcb->xcp.regs, tcb->xcp.saved_regs,
XCPTCONTEXT_SIZE); XCPTCONTEXT_SIZE);
tcb->xcp.regs[REG_A1] = (uint32_t)tcb->xcp.regs + tcb->xcp.regs[REG_A1] = (uint32_t)tcb->xcp.regs +
(uint32_t)XCPTCONTEXT_SIZE; XCPTCONTEXT_SIZE;
/* Then set up to vector to the trampoline with interrupts /* Then set up to vector to the trampoline with interrupts
* disabled * disabled
@@ -354,7 +357,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* NOTE: that hi-priority interrupts are not disabled. * NOTE: that hi-priority interrupts are not disabled.
*/ */
tcb->xcp.sigdeliver = sigdeliver;
xtensa_savestate(tcb->xcp.saved_regs); xtensa_savestate(tcb->xcp.saved_regs);
/* Duplicate the register context. These will be /* Duplicate the register context. These will be
@@ -364,12 +366,12 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
CURRENT_REGS = (void *) CURRENT_REGS = (void *)
((uint32_t)CURRENT_REGS - ((uint32_t)CURRENT_REGS -
(uint32_t)XCPTCONTEXT_SIZE); XCPTCONTEXT_SIZE);
memcpy((uint32_t *)CURRENT_REGS, tcb->xcp.saved_regs, memcpy((uint32_t *)CURRENT_REGS, tcb->xcp.saved_regs,
XCPTCONTEXT_SIZE); XCPTCONTEXT_SIZE);
CURRENT_REGS[REG_A1] = (uint32_t)CURRENT_REGS + CURRENT_REGS[REG_A1] = (uint32_t)CURRENT_REGS +
(uint32_t)XCPTCONTEXT_SIZE; XCPTCONTEXT_SIZE;
/* Then set up to vector to the trampoline with interrupts /* Then set up to vector to the trampoline with interrupts
* disabled * disabled
@@ -425,7 +427,6 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* NOTE: that hi-priority interrupts are not disabled. * NOTE: that hi-priority interrupts are not disabled.
*/ */
tcb->xcp.sigdeliver = sigdeliver;
tcb->xcp.saved_regs = tcb->xcp.regs; tcb->xcp.saved_regs = tcb->xcp.regs;
/* Duplicate the register context. These will be /* Duplicate the register context. These will be
@@ -435,11 +436,11 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
tcb->xcp.regs = (void *) tcb->xcp.regs = (void *)
((uint32_t)tcb->xcp.regs - ((uint32_t)tcb->xcp.regs -
(uint32_t)XCPTCONTEXT_SIZE); XCPTCONTEXT_SIZE);
memcpy(tcb->xcp.regs, tcb->xcp.saved_regs, XCPTCONTEXT_SIZE); memcpy(tcb->xcp.regs, tcb->xcp.saved_regs, XCPTCONTEXT_SIZE);
tcb->xcp.regs[REG_A1] = (uint32_t)tcb->xcp.regs + tcb->xcp.regs[REG_A1] = (uint32_t)tcb->xcp.regs +
(uint32_t)XCPTCONTEXT_SIZE; XCPTCONTEXT_SIZE;
/* Increment the IRQ lock count so that when the task is restarted, /* Increment the IRQ lock count so that when the task is restarted,
* it will hold the IRQ spinlock. * it will hold the IRQ spinlock.
+3 -2
View File
@@ -82,6 +82,8 @@ void up_schedule_sigaction(FAR struct tcb_s *tcb, sig_deliver_t sigdeliver)
if (!tcb->xcp.sigdeliver) if (!tcb->xcp.sigdeliver)
{ {
tcb->xcp.sigdeliver = sigdeliver;
/* First, handle some special cases when the signal is /* First, handle some special cases when the signal is
* being delivered to the currently executing task. * being delivered to the currently executing task.
*/ */
@@ -99,6 +101,7 @@ void up_schedule_sigaction(FAR struct tcb_s *tcb, sig_deliver_t sigdeliver)
/* In this case just deliver the signal now. */ /* In this case just deliver the signal now. */
sigdeliver(tcb); sigdeliver(tcb);
tcb->xcp.sigdeliver = NULL;
} }
/* CASE 2: We are in an interrupt handler AND the interrupted /* CASE 2: We are in an interrupt handler AND the interrupted
@@ -117,7 +120,6 @@ void up_schedule_sigaction(FAR struct tcb_s *tcb, sig_deliver_t sigdeliver)
* been delivered. * been delivered.
*/ */
tcb->xcp.sigdeliver = sigdeliver;
tcb->xcp.saved_pc = *current_pc; tcb->xcp.saved_pc = *current_pc;
tcb->xcp.saved_i = g_current_regs[REG_FLAGS]; tcb->xcp.saved_i = g_current_regs[REG_FLAGS];
@@ -150,7 +152,6 @@ void up_schedule_sigaction(FAR struct tcb_s *tcb, sig_deliver_t sigdeliver)
* the signals have been delivered. * the signals have been delivered.
*/ */
tcb->xcp.sigdeliver = sigdeliver;
tcb->xcp.saved_pc = *saved_pc; tcb->xcp.saved_pc = *saved_pc;
tcb->xcp.saved_i = tcb->xcp.regs[REG_FLAGS]; tcb->xcp.saved_i = tcb->xcp.regs[REG_FLAGS];
+3 -1
View File
@@ -50,7 +50,6 @@ static void ez80_sigsetup(FAR struct tcb_s *tcb, sig_deliver_t sigdeliver,
* the signal trampoline after the signals have been delivered. * the signal trampoline after the signals have been delivered.
*/ */
tcb->xcp.sigdeliver = sigdeliver;
tcb->xcp.saved_pc = regs[XCPT_PC]; tcb->xcp.saved_pc = regs[XCPT_PC];
tcb->xcp.saved_i = regs[XCPT_I]; tcb->xcp.saved_i = regs[XCPT_I];
@@ -108,6 +107,8 @@ void up_schedule_sigaction(FAR struct tcb_s *tcb, sig_deliver_t sigdeliver)
if (tcb->xcp.sigdeliver == NULL) if (tcb->xcp.sigdeliver == NULL)
{ {
tcb->xcp.sigdeliver = sigdeliver;
/* First, handle some special cases when the signal is being delivered /* First, handle some special cases when the signal is being delivered
* to the currently executing task. * to the currently executing task.
*/ */
@@ -123,6 +124,7 @@ void up_schedule_sigaction(FAR struct tcb_s *tcb, sig_deliver_t sigdeliver)
/* In this case just deliver the signal now. */ /* In this case just deliver the signal now. */
sigdeliver(tcb); sigdeliver(tcb);
tcb->xcp.sigdeliver = NULL;
} }
/* CASE 2: We are in an interrupt handler AND the interrupted task /* CASE 2: We are in an interrupt handler AND the interrupted task
+3 -1
View File
@@ -53,7 +53,6 @@ static void z180_sigsetup(FAR struct tcb_s *tcb, sig_deliver_t sigdeliver,
* the signal trampoline after the signals have been delivered. * the signal trampoline after the signals have been delivered.
*/ */
tcb->xcp.sigdeliver = sigdeliver;
tcb->xcp.saved_pc = regs[XCPT_PC]; tcb->xcp.saved_pc = regs[XCPT_PC];
tcb->xcp.saved_i = regs[XCPT_I]; tcb->xcp.saved_i = regs[XCPT_I];
@@ -111,6 +110,8 @@ void up_schedule_sigaction(FAR struct tcb_s *tcb, sig_deliver_t sigdeliver)
if (tcb->xcp.sigdeliver == NULL) if (tcb->xcp.sigdeliver == NULL)
{ {
tcb->xcp.sigdeliver = sigdeliver;
/* First, handle some special cases when the signal is being delivered /* First, handle some special cases when the signal is being delivered
* to the currently executing task. * to the currently executing task.
*/ */
@@ -126,6 +127,7 @@ void up_schedule_sigaction(FAR struct tcb_s *tcb, sig_deliver_t sigdeliver)
/* In this case just deliver the signal now. */ /* In this case just deliver the signal now. */
sigdeliver(tcb); sigdeliver(tcb);
tcb->xcp.sigdeliver = NULL;
} }
/* CASE 2: We are in an interrupt handler AND the interrupted task /* CASE 2: We are in an interrupt handler AND the interrupted task
+3 -1
View File
@@ -50,7 +50,6 @@ static void z8_sigsetup(FAR struct tcb_s *tcb, sig_deliver_t sigdeliver,
* the signal trampoline after the signals have been delivered. * the signal trampoline after the signals have been delivered.
*/ */
tcb->xcp.sigdeliver = sigdeliver;
tcb->xcp.saved_pc = regs[XCPT_PC]; tcb->xcp.saved_pc = regs[XCPT_PC];
tcb->xcp.saved_irqctl = regs[XCPT_IRQCTL]; tcb->xcp.saved_irqctl = regs[XCPT_IRQCTL];
@@ -108,6 +107,8 @@ void up_schedule_sigaction(FAR struct tcb_s *tcb, sig_deliver_t sigdeliver)
if (tcb->xcp.sigdeliver == NULL) if (tcb->xcp.sigdeliver == NULL)
{ {
tcb->xcp.sigdeliver = sigdeliver;
/* First, handle some special cases when the signal is being delivered /* First, handle some special cases when the signal is being delivered
* to the currently executing task. * to the currently executing task.
*/ */
@@ -123,6 +124,7 @@ void up_schedule_sigaction(FAR struct tcb_s *tcb, sig_deliver_t sigdeliver)
/* In this case just deliver the signal now. */ /* In this case just deliver the signal now. */
sigdeliver(tcb); sigdeliver(tcb);
tcb->xcp.sigdeliver = NULL;
} }
/* CASE 2: We are in an interrupt handler AND the interrupted task /* CASE 2: We are in an interrupt handler AND the interrupted task
+3 -1
View File
@@ -51,7 +51,6 @@ static void z80_sigsetup(FAR struct tcb_s *tcb, sig_deliver_t sigdeliver,
* the signal trampoline after the signals have been delivered. * the signal trampoline after the signals have been delivered.
*/ */
tcb->xcp.sigdeliver = sigdeliver;
tcb->xcp.saved_pc = regs[XCPT_PC]; tcb->xcp.saved_pc = regs[XCPT_PC];
tcb->xcp.saved_i = regs[XCPT_I]; tcb->xcp.saved_i = regs[XCPT_I];
@@ -109,6 +108,8 @@ void up_schedule_sigaction(FAR struct tcb_s *tcb, sig_deliver_t sigdeliver)
if (tcb->xcp.sigdeliver == NULL) if (tcb->xcp.sigdeliver == NULL)
{ {
tcb->xcp.sigdeliver = sigdeliver;
/* First, handle some special cases when the signal is being delivered /* First, handle some special cases when the signal is being delivered
* to the currently executing task. * to the currently executing task.
*/ */
@@ -124,6 +125,7 @@ void up_schedule_sigaction(FAR struct tcb_s *tcb, sig_deliver_t sigdeliver)
/* In this case just deliver the signal now. */ /* In this case just deliver the signal now. */
sigdeliver(tcb); sigdeliver(tcb);
tcb->xcp.sigdeliver = NULL;
} }
/* CASE 2: We are in an interrupt handler AND the interrupted task /* CASE 2: We are in an interrupt handler AND the interrupted task