summaryrefslogtreecommitdiff
path: root/nuttx/arch/z80/src/common
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2007-12-31 15:45:58 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2007-12-31 15:45:58 +0000
commitd63b9bf5f59c5d16a3e9e5dffe50a9bbbb453c19 (patch)
treec76395b9d789715f198ad824844d10cb315791c7 /nuttx/arch/z80/src/common
parenta3124243d36a5729304fd2822efca8c96a6f5c6f (diff)
downloadpx4-nuttx-d63b9bf5f59c5d16a3e9e5dffe50a9bbbb453c19.tar.gz
px4-nuttx-d63b9bf5f59c5d16a3e9e5dffe50a9bbbb453c19.tar.bz2
px4-nuttx-d63b9bf5f59c5d16a3e9e5dffe50a9bbbb453c19.zip
Add z80 signals
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@472 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/arch/z80/src/common')
-rw-r--r--nuttx/arch/z80/src/common/up_internal.h1
-rw-r--r--nuttx/arch/z80/src/common/up_schedulesigaction.c62
-rw-r--r--nuttx/arch/z80/src/common/up_sigdeliver.c54
3 files changed, 66 insertions, 51 deletions
diff --git a/nuttx/arch/z80/src/common/up_internal.h b/nuttx/arch/z80/src/common/up_internal.h
index 7b0ba4474..5e4db68da 100644
--- a/nuttx/arch/z80/src/common/up_internal.h
+++ b/nuttx/arch/z80/src/common/up_internal.h
@@ -65,6 +65,7 @@
#define SET_IRQCONTEXT(tcb) up_copystate(current_regs, (tcb)->xcp.regs)
#define SAVE_USERCONTEXT(tcb) up_saveusercontext((tcb)->xcp.regs)
#define RESTORE_USERCONTEXT(tcb) up_restoreusercontext((tcb)->xcp.regs)
+#define SIGNAL_RETURN(regs) up_restoreusercontext(regs)
/****************************************************************************
* Public Types
diff --git a/nuttx/arch/z80/src/common/up_schedulesigaction.c b/nuttx/arch/z80/src/common/up_schedulesigaction.c
index f22144df4..946ba859b 100644
--- a/nuttx/arch/z80/src/common/up_schedulesigaction.c
+++ b/nuttx/arch/z80/src/common/up_schedulesigaction.c
@@ -1,4 +1,4 @@
-/************************************************************
+/****************************************************************************
* common/up_schedulesigaction.c
*
* Copyright (C) 2007,2008 Gregory Nutt. All rights reserved.
@@ -31,38 +31,43 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
- ************************************************************/
+ ****************************************************************************/
-/************************************************************
+/****************************************************************************
* Included Files
- ************************************************************/
+ ****************************************************************************/
#include <nuttx/config.h>
+
#include <sys/types.h>
#include <sched.h>
#include <debug.h>
+
#include <nuttx/arch.h>
+#include <arch/irq.h>
+
#include "os_internal.h"
#include "up_internal.h"
-#include "up_arch.h"
-/************************************************************
+#ifndef CONFIG_DISABLE_SIGNALS
+
+/****************************************************************************
* Private Definitions
- ************************************************************/
+ ****************************************************************************/
-/************************************************************
+/****************************************************************************
* Private Data
- ************************************************************/
+ ****************************************************************************/
-/************************************************************
+/****************************************************************************
* Private Functions
- ************************************************************/
+ ****************************************************************************/
-/************************************************************
+/****************************************************************************
* Public Functions
- ************************************************************/
+ ****************************************************************************/
-/************************************************************
+/****************************************************************************
* Name: up_schedule_sigaction
*
* Description:
@@ -93,13 +98,13 @@
* currently executing task -- just call the signal
* handler now.
*
- ************************************************************/
+ ****************************************************************************/
-void up_schedule_sigaction(_TCB *tcb, sig_deliver_t sigdeliver)
+void up_schedule_sigaction(FAR _TCB *tcb, sig_deliver_t sigdeliver)
{
/* Refuse to handle nested signal actions */
- dbg("tcb=0x%p sigdeliver=0x%p\n", tcb, sigdeliver);
+ dbg("tcb=0x%p sigdeliver=0x%04x\n", tcb, (uint16)sigdeliver);
if (!tcb->xcp.sigdeliver)
{
@@ -115,7 +120,7 @@ void up_schedule_sigaction(_TCB *tcb, sig_deliver_t sigdeliver)
dbg("rtcb=0x%p current_regs=0x%p\n", g_readytorun.head, current_regs);
- if (tcb == (_TCB*)g_readytorun.head)
+ if (tcb == (FAR _TCB*)g_readytorun.head)
{
/* CASE 1: We are not in an interrupt handler and
* a task is signalling itself for some reason.
@@ -136,21 +141,21 @@ void up_schedule_sigaction(_TCB *tcb, sig_deliver_t sigdeliver)
else
{
- /* Save the return lr and cpsr and one scratch register
+ /* Save the return address and interrupt state.
* These will be restored by the signal trampoline after
* the signals have been delivered.
*/
tcb->xcp.sigdeliver = sigdeliver;
- tcb->xcp.saved_pc = current_regs[REG_PC];
- tcb->xcp.saved_cpsr = current_regs[REG_CPSR];
+ tcb->xcp.saved_pc = current_regs[XCPT_PC];
+ tcb->xcp.saved_i = current_regs[XCPT_I];
/* Then set up to vector to the trampoline with interrupts
* disabled
*/
- current_regs[REG_PC] = (uint32)up_sigdeliver;
- current_regs[REG_CPSR] = SVC_MODE | PSR_I_BIT | PSR_F_BIT;
+ current_regs[XCPT_PC] = (uint16)up_sigdeliver;
+ current_regs[XCPT_I] = 0;
/* And make sure that the saved context in the TCB
* is the same as the interrupt return context.
@@ -174,17 +179,20 @@ void up_schedule_sigaction(_TCB *tcb, sig_deliver_t sigdeliver)
*/
tcb->xcp.sigdeliver = sigdeliver;
- tcb->xcp.saved_pc = tcb->xcp.regs[REG_PC];
- tcb->xcp.saved_cpsr = tcb->xcp.regs[REG_CPSR];
+ tcb->xcp.saved_pc = tcb->xcp.regs[XCPT_PC];
+ tcb->xcp.saved_i = tcb->xcp.regs[XCPT_I];
/* Then set up to vector to the trampoline with interrupts
* disabled
*/
- tcb->xcp.regs[REG_PC] = (uint32)up_sigdeliver;
- tcb->xcp.regs[REG_CPSR] = SVC_MODE | PSR_I_BIT | PSR_F_BIT;
+ tcb->xcp.regs[XCPT_PC] = (uint16)up_sigdeliver;
+ tcb->xcp.regs[XCPT_I] = 0;
}
irqrestore(flags);
}
}
+
+#endif /* CONFIG_DISABLE_SIGNALS */
+
diff --git a/nuttx/arch/z80/src/common/up_sigdeliver.c b/nuttx/arch/z80/src/common/up_sigdeliver.c
index 0877fffe3..adbc894cb 100644
--- a/nuttx/arch/z80/src/common/up_sigdeliver.c
+++ b/nuttx/arch/z80/src/common/up_sigdeliver.c
@@ -1,7 +1,7 @@
-/************************************************************
+/****************************************************************************
* common/up_sigdeliver.c
*
- * Copyright (C) 2007 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* Redistribution and use in source and binary forms, with or without
@@ -14,7 +14,7 @@
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
- * 3. Neither the name Gregory Nutt nor the names of its contributors may be
+ * 3. Neither the name NuttX nor the names of its contributors may be
* used to endorse or promote products derived from this software
* without specific prior written permission.
*
@@ -31,39 +31,43 @@
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
- ************************************************************/
+ ****************************************************************************/
-/************************************************************
+/****************************************************************************
* Included Files
- ************************************************************/
+ ****************************************************************************/
#include <nuttx/config.h>
+
#include <sys/types.h>
#include <sched.h>
#include <debug.h>
+
#include <nuttx/irq.h>
#include <nuttx/arch.h>
+
#include "os_internal.h"
#include "up_internal.h"
-#include "up_arch.h"
-/************************************************************
+#ifndef CONFIG_DISABLE_SIGNALS
+
+/****************************************************************************
* Definitions
- ************************************************************/
+ ****************************************************************************/
-/************************************************************
+/****************************************************************************
* Private Data
- ************************************************************/
+ ****************************************************************************/
-/************************************************************
+/****************************************************************************
* Private Functions
- ************************************************************/
+ ****************************************************************************/
-/************************************************************
+/****************************************************************************
* Public Functions
- ************************************************************/
+ ****************************************************************************/
-/************************************************************
+/****************************************************************************
* Name: up_sigdeliver
*
* Description:
@@ -72,7 +76,7 @@
* with and forced to branch to this location with interrupts
* disabled.
*
- ************************************************************/
+ ****************************************************************************/
void up_sigdeliver(void)
{
@@ -81,9 +85,9 @@ void up_sigdeliver(void)
uint32 regs[XCPTCONTEXT_REGS];
sig_deliver_t sigdeliver;
- /* Save the errno. This must be preserved throughout the
- * signal handling so that the the user code final gets
- * the correct errno value (probably EINTR).
+ /* Save the errno. This must be preserved throughout the signal handling
+ * so that the the user code final gets the correct errno value (probably
+ * EINTR).
*/
int saved_errno = rtcb->errno;
@@ -97,8 +101,8 @@ void up_sigdeliver(void)
/* Save the real return state on the stack. */
up_copystate(regs, rtcb->xcp.regs);
- regs[REG_PC] = rtcb->xcp.saved_pc;
- regs[REG_CPSR] = rtcb->xcp.saved_cpsr;
+ regs[XCPT_PC] = rtcb->xcp.saved_pc;
+ regs[XCPT_I] = rtcb->xcp.saved_i;
/* Get a local copy of the sigdeliver function pointer.
* we do this so that we can nullify the sigdeliver
@@ -112,7 +116,7 @@ void up_sigdeliver(void)
/* Then restore the task interrupt state. */
- irqrestore(regs[REG_CPSR]);
+ irqrestore(regs[XCPT_I]);
/* Deliver the signals */
@@ -132,6 +136,8 @@ void up_sigdeliver(void)
*/
up_ledoff(LED_SIGNAL);
- up_fullcontextrestore(regs);
+ SIGNAL_RETURN(regs);
#endif
}
+
+#endif /* CONFIG_DISABLE_SIGNALS */ \ No newline at end of file