diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2007-12-31 15:45:58 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2007-12-31 15:45:58 +0000 |
commit | d63b9bf5f59c5d16a3e9e5dffe50a9bbbb453c19 (patch) | |
tree | c76395b9d789715f198ad824844d10cb315791c7 /nuttx/arch/z80 | |
parent | a3124243d36a5729304fd2822efca8c96a6f5c6f (diff) | |
download | px4-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')
-rw-r--r-- | nuttx/arch/z80/include/z80/irq.h | 5 | ||||
-rw-r--r-- | nuttx/arch/z80/src/Makefile | 11 | ||||
-rw-r--r-- | nuttx/arch/z80/src/common/up_internal.h | 1 | ||||
-rw-r--r-- | nuttx/arch/z80/src/common/up_schedulesigaction.c | 62 | ||||
-rw-r--r-- | nuttx/arch/z80/src/common/up_sigdeliver.c | 54 | ||||
-rw-r--r-- | nuttx/arch/z80/src/z80/Make.defs | 5 |
6 files changed, 78 insertions, 60 deletions
diff --git a/nuttx/arch/z80/include/z80/irq.h b/nuttx/arch/z80/include/z80/irq.h index 3bcaaed20..86bdfd273 100644 --- a/nuttx/arch/z80/include/z80/irq.h +++ b/nuttx/arch/z80/include/z80/irq.h @@ -106,6 +106,11 @@ struct xcptcontext #ifndef CONFIG_DISABLE_SIGNALS void *sigdeliver; /* Actual type is sig_deliver_t */ + + /* The following retains that state during signal execution */ + + uint16 saved_pc; /* Saved return address */ + uint16 saved_i; /* Saved interrupt state */ #endif }; #endif diff --git a/nuttx/arch/z80/src/Makefile b/nuttx/arch/z80/src/Makefile index e822fd05a..8917a4402 100644 --- a/nuttx/arch/z80/src/Makefile +++ b/nuttx/arch/z80/src/Makefile @@ -126,11 +126,12 @@ $(COBJS): %$(OBJEXT): %.c $(SDCCLIBDIR)/myz80.lib: $(SDCCLIBDIR)/$(SDCCLIB) @cat $(SDCCLIBDIR)/$(SDCCLIB) | \ - grep -v calloc | grep -v malloc | grep -v realloc | \ - grep -v free | grep -v vprintf | grep -v _strncpy | \ - grep -v _strchr | grep -v _strlen | grep -v _strcmp | \ - grep -v _strcpy | grep -v _memcmp | grep -v _memcpy | \ - grep -v _memset | grep -v crt0 \ + grep -v calloc | grep -v malloc | grep -v realloc | \ + grep -v free | grep -v getenv | grep -v vprintf | \ + grep -v sprintf | grep -v _strncpy | grep -v _strchr | \ + grep -v _strlen | grep -v _strcmp | grep -v _strcpy | \ + grep -v _memcmp | grep -v _memcpy | grep -v _memset | \ + grep -v crt0 \ > myz80.lib @sudo mv -f myz80.lib $(SDCCLIBDIR)/myz80.lib 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 diff --git a/nuttx/arch/z80/src/z80/Make.defs b/nuttx/arch/z80/src/z80/Make.defs index d4e38b11c..0688d159b 100644 --- a/nuttx/arch/z80/src/z80/Make.defs +++ b/nuttx/arch/z80/src/z80/Make.defs @@ -41,12 +41,9 @@ CMN_CSRCS = up_initialize.c up_allocateheap.c up_initialstate.c \ up_blocktask.c up_unblocktask.c up_exit.c up_releasepending.c \ up_reprioritizertr.c up_copystate.c up_irq.c up_idle.c \ up_assert.c up_mdelay.c up_udelay.c \ + up_schedulesigaction.c up_sigdeliver.c \ up_registerdump.c up_usestack.c -ifneq ($(CONFIG_DISABLE_SIGNALS),y) -CMD_CSRCS += up_schedulesigaction.c up_sigdeliver.c -endif - CHIP_ASRCS = CHIP_CSRCS = |