Add z80 signals

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@472 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2007-12-31 15:45:58 +00:00
parent 8911f88d6f
commit ac067ee3f2
7 changed files with 85 additions and 62 deletions

View File

@ -159,9 +159,14 @@ arch/m68322
arch/pjrc-8051
8051 Microcontroller. This port is not quite ready for prime time.
arch/z80
z80 Microcontroller.
STATUS: Functional with no known defects. There are still several
OS features that have not yet been tested (e.g., networking).
The following architecture directories are deprecated. They have been
replaced by the logic in arm/arm and will deleted when arch/arm is fully
verified.
replaced by the logic in arm/arm and will deleted at some point in the
future.
arch/c5471
Replaced with arch/arm/include/c5471 and arch/arm/src/c5471

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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 */

View File

@ -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 */

View File

@ -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 =