diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2008-02-14 17:24:14 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2008-02-14 17:24:14 +0000 |
commit | 32051bc141f4b729a8738fc19633a4010201348b (patch) | |
tree | 0be9084477336c255bb8488761ccc0a439d20dab /nuttx/arch/z80/src/common | |
parent | 1d68d382c2facf034ca7cb891abac3c710955e60 (diff) | |
download | px4-nuttx-32051bc141f4b729a8738fc19633a4010201348b.tar.gz px4-nuttx-32051bc141f4b729a8738fc19633a4010201348b.tar.bz2 px4-nuttx-32051bc141f4b729a8738fc19633a4010201348b.zip |
Move all z80-dependencies into arch/z80/src/z80
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@683 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/arch/z80/src/common')
-rw-r--r-- | nuttx/arch/z80/src/common/up_assert.c | 4 | ||||
-rw-r--r-- | nuttx/arch/z80/src/common/up_blocktask.c | 5 | ||||
-rw-r--r-- | nuttx/arch/z80/src/common/up_copystate.c | 78 | ||||
-rw-r--r-- | nuttx/arch/z80/src/common/up_doirq.c | 42 | ||||
-rw-r--r-- | nuttx/arch/z80/src/common/up_initialize.c | 12 | ||||
-rw-r--r-- | nuttx/arch/z80/src/common/up_internal.h | 102 | ||||
-rw-r--r-- | nuttx/arch/z80/src/common/up_interruptcontext.c | 8 | ||||
-rw-r--r-- | nuttx/arch/z80/src/common/up_registerdump.c | 91 | ||||
-rw-r--r-- | nuttx/arch/z80/src/common/up_releasepending.c | 5 | ||||
-rw-r--r-- | nuttx/arch/z80/src/common/up_reprioritizertr.c | 5 | ||||
-rw-r--r-- | nuttx/arch/z80/src/common/up_schedulesigaction.c | 70 | ||||
-rw-r--r-- | nuttx/arch/z80/src/common/up_sigdeliver.c | 5 | ||||
-rw-r--r-- | nuttx/arch/z80/src/common/up_unblocktask.c | 5 |
13 files changed, 111 insertions, 321 deletions
diff --git a/nuttx/arch/z80/src/common/up_assert.c b/nuttx/arch/z80/src/common/up_assert.c index d7243e716..1d8fd6a5a 100644 --- a/nuttx/arch/z80/src/common/up_assert.c +++ b/nuttx/arch/z80/src/common/up_assert.c @@ -137,7 +137,7 @@ void up_assert(void) #endif up_stackdump(); - up_registerdump(); + REGISTER_DUMP(); _up_assert(EXIT_FAILURE); } @@ -174,6 +174,6 @@ void up_assert_code(int errorcode) #endif up_stackdump(); - up_registerdump(); + REGISTER_DUMP(); _up_assert(errorcode); } diff --git a/nuttx/arch/z80/src/common/up_blocktask.c b/nuttx/arch/z80/src/common/up_blocktask.c index e2d405b36..d0e792203 100644 --- a/nuttx/arch/z80/src/common/up_blocktask.c +++ b/nuttx/arch/z80/src/common/up_blocktask.c @@ -1,5 +1,5 @@ /**************************************************************************** - * common/up_blocktask.c + * arch/z80/src/common/up_blocktask.c * * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> @@ -45,6 +45,7 @@ #include <nuttx/arch.h> +#include "chip/switch.h" #include "os_internal.h" #include "up_internal.h" @@ -128,7 +129,7 @@ void up_block_task(FAR _TCB *tcb, tstate_t task_state) { /* Are we in an interrupt handler? */ - if (IN_INTERRUPT) + if (IN_INTERRUPT()) { /* Yes, then we have to do things differently. * Just copy the current registers into the OLD rtcb. diff --git a/nuttx/arch/z80/src/common/up_copystate.c b/nuttx/arch/z80/src/common/up_copystate.c deleted file mode 100644 index b05ab82c3..000000000 --- a/nuttx/arch/z80/src/common/up_copystate.c +++ /dev/null @@ -1,78 +0,0 @@ -/**************************************************************************** - * common/up_copystate.c - * - * 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 - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * 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 <arch/irq.h> - -#include "os_internal.h" -#include "up_internal.h" - -/**************************************************************************** - * Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Public Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: up_undefinedinsn - ****************************************************************************/ - -/* Maybe a little faster than most memcpy's */ - -void up_copystate(FAR chipreg_t *dest, FAR const chipreg_t *src) -{ - int i; - for (i = 0; i < XCPTCONTEXT_REGS; i++) - { - *dest++ = *src++; - } -} - diff --git a/nuttx/arch/z80/src/common/up_doirq.c b/nuttx/arch/z80/src/common/up_doirq.c index 9e9105426..f9c9f72bb 100644 --- a/nuttx/arch/z80/src/common/up_doirq.c +++ b/nuttx/arch/z80/src/common/up_doirq.c @@ -1,5 +1,5 @@ /**************************************************************************** - * common/up_doirq.c + * arch/z80/src/common/up_doirq.c * * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> @@ -38,11 +38,15 @@ ****************************************************************************/ #include <nuttx/config.h> + #include <sys/types.h> -#include <nuttx/irq.h> -#include <nuttx/arch.h> #include <assert.h> #include "up_arch.h" + +#include <nuttx/irq.h> +#include <nuttx/arch.h> + +#include "chip/switch.h" #include "os_internal.h" #include "up_internal.h" @@ -66,39 +70,37 @@ * Public Functions ****************************************************************************/ -void up_doirq(int irq, chipreg_t *regs) +FAR chipreg_t *up_doirq(ubyte irq, FAR chipreg_t *regs) { up_ledon(LED_INIRQ); + #ifdef CONFIG_SUPPRESS_INTERRUPTS + + lib_lowprintf("Unexpected IRQ\n"); + IRQ_ENTER(regs); PANIC(OSERR_ERREXCEPTION); + return NULL; /* Won't get here */ + #else - if ((unsigned)irq < NR_IRQS) + if (irq < NR_IRQS) { - /* Current regs non-zero indicates that we are processing - * an interrupt; current_regs is also used to manage - * interrupt level context switches. - */ - - current_regs = regs; - - /* Mask and acknowledge the interrupt */ + /* Indicate that we have enter IRQ processing logic */ - up_maskack_irq(irq); + IRQ_ENTER(irq, regs); /* Deliver the IRQ */ irq_dispatch(irq, regs); - /* Indicate that we are no long in an interrupt handler */ + /* If a context switch occurred, 'regs' will hold the new context */ - current_regs = NULL; + regs = IRQ_STATE(); - /* Unmask the last interrupt (global interrupts are still - * disabled. - */ + /* Indicate that we are no long in interrupt processing logic */ - up_enable_irq(irq); + IRQ_LEAVE(irq); } up_ledoff(LED_INIRQ); + return regs; #endif } diff --git a/nuttx/arch/z80/src/common/up_initialize.c b/nuttx/arch/z80/src/common/up_initialize.c index 40205133b..036e4618a 100644 --- a/nuttx/arch/z80/src/common/up_initialize.c +++ b/nuttx/arch/z80/src/common/up_initialize.c @@ -1,5 +1,5 @@ /**************************************************************************** - * common/up_initialize.c + * arch/z80/src/common/up_initialize.c * * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> @@ -47,6 +47,7 @@ #include <nuttx/mm.h> #include <arch/board/board.h> +#include "chip/switch.h" #include "up_internal.h" /**************************************************************************** @@ -61,13 +62,6 @@ * Public Data ****************************************************************************/ -/* This holds a references to the current interrupt level - * register storage structure. If is non-NULL only during - * interrupt processing. - */ - -uint16 *current_regs; - /**************************************************************************** * Private Types ****************************************************************************/ @@ -130,7 +124,7 @@ void up_initialize(void) { /* Initialize global variables */ - current_regs = NULL; + INIT_IRQCONTEXT(); /* Calibrate the timing loop */ diff --git a/nuttx/arch/z80/src/common/up_internal.h b/nuttx/arch/z80/src/common/up_internal.h index e90bec766..838b4cf36 100644 --- a/nuttx/arch/z80/src/common/up_internal.h +++ b/nuttx/arch/z80/src/common/up_internal.h @@ -1,5 +1,5 @@ /**************************************************************************** - * common/up_internal.h + * arch/z80/src/common/up_internal.h * * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> @@ -37,14 +37,7 @@ #define __UP_INTERNAL_H /**************************************************************************** - * Included Files - ****************************************************************************/ - -#include <arch/irq.h> -#include "chip/chip.h" - -/**************************************************************************** - * Definitions + * Conditional Compilation ****************************************************************************/ /* Bring-up debug configurations. These are here (vs defconfig) @@ -58,69 +51,52 @@ #undef CONFIG_SUPPRESS_UART_CONFIG /* Do not reconfig UART */ #undef CONFIG_DUMP_ON_EXIT /* Dump task state on exit */ -/* Macros for portability */ +/**************************************************************************** + * Included Files + ****************************************************************************/ -#define IN_INTERRUPT (current_regs != NULL) -#define SAVE_IRQCONTEXT(tcb) up_copystate((tcb)->xcp.regs, current_regs) -#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) +#include <arch/irq.h> +#include "chip/chip.h" +#include "chip/switch.h" /**************************************************************************** - * Public Types + * Definitions ****************************************************************************/ -#ifndef __ASSEMBLY__ -typedef void (*up_vector_t)(void); -#endif +/**************************************************************************** + * Public Types + ****************************************************************************/ /**************************************************************************** * Public Variables ****************************************************************************/ -#ifndef __ASSEMBLY__ -/* This holds a references to the current interrupt level - * register storage structure. If is non-NULL only during - * interrupt processing. - */ - -extern uint16 *current_regs; -#endif - /**************************************************************************** * Public Functions ****************************************************************************/ #ifndef __ASSEMBLY__ +#ifdef __cplusplus +#define EXTERN extern "C" +extern "C" { +#else +#define EXTERN extern +#endif -/* Defined in up_copystate.c */ - -extern void up_copystate(FAR chipreg_t *dest, FAR const chipreg_t *src); - -/* Defined in up_saveusercontext.asm */ - -extern int up_saveusercontext(chipreg_t *regs); - -/* Defined in up_restoreusercontext.asm */ - -extern int up_restoreusercontext(chipreg_t *regs); - -/* Supplied by board-specific logic */ +/* Supplied by chip- or board-specific logic */ -extern FAR chipreg_t *up_decodeirq(uint8 rstno, FAR chipreg_t *regs); -extern void up_irqinitialize(void); -extern int up_timerisr(int irq, FAR chipreg_t *regs); -extern void up_lowputc(char ch) naked_function; -extern char up_lowgetc(void) naked_function; +EXTERN void up_irqinitialize(void); +EXTERN int up_timerisr(int irq, FAR chipreg_t *regs); +EXTERN void up_lowputc(char ch) naked_function; +EXTERN char up_lowgetc(void) naked_function; /* Defined in up_doirq.c */ -extern void up_doirq(int irq, FAR chipreg_t *regs); +EXTERN FAR chipreg_t *up_doirq(ubyte irq, FAR chipreg_t *regs); /* Define in up_sigdeliver */ -extern void up_sigdeliver(void); +EXTERN void up_sigdeliver(void); /* Defined in up_allocateheap.c */ @@ -131,8 +107,8 @@ void up_addregion(void); /* Defined in up_serial.c */ #if CONFIG_NFILE_DESCRIPTORS > 0 -extern void up_earlyserialinit(void); -extern void up_serialinit(void); +EXTERN void up_earlyserialinit(void); +EXTERN void up_serialinit(void); #else # define up_earlyserialinit() # define up_serialinit() @@ -140,14 +116,14 @@ extern void up_serialinit(void); /* Defined in up_timerisr.c */ -extern void up_timerinit(void); +EXTERN void up_timerinit(void); /* Defined in board/up_leds.c */ #ifdef CONFIG_ARCH_LEDS -extern void up_ledinit(void); -extern void up_ledon(int led); -extern void up_ledoff(int led); +EXTERN void up_ledinit(void); +EXTERN void up_ledon(int led); +EXTERN void up_ledoff(int led); #else # define up_ledinit() # define up_ledon(led) @@ -157,25 +133,29 @@ extern void up_ledoff(int led); /* Defined in board/up_network.c */ #ifdef CONFIG_NET -extern void up_netinitialize(void); +EXTERN void up_netinitialize(void); #else # define up_netinitialize() #endif /* Return the current value of the stack pointer (used in stack dump logic) */ -extern uint16 up_getsp(void); +EXTERN uint16 up_getsp(void); /* Dump stack and registers */ #ifdef CONFIG_ARCH_STACKDUMP -extern void up_stackdump(void); -extern void up_registerdump(void); +EXTERN void up_stackdump(void); +# define REGISTER_DUMP() _REGISTER_DUMP() #else # define up_stackdump() -# define up_registerdump() +# define REGISTER_DUMP() #endif -#endif /* __ASSEMBLY__ */ +#undef EXTERN +#ifdef __cplusplus +} +#endif +#endif #endif /* __UP_INTERNAL_H */ diff --git a/nuttx/arch/z80/src/common/up_interruptcontext.c b/nuttx/arch/z80/src/common/up_interruptcontext.c index 6e9e752c9..354227cc2 100644 --- a/nuttx/arch/z80/src/common/up_interruptcontext.c +++ b/nuttx/arch/z80/src/common/up_interruptcontext.c @@ -1,5 +1,5 @@ /**************************************************************************** - * common/up_interruptcontext.c + * arch/z80/src/common/up_interruptcontext.c * * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> @@ -38,9 +38,13 @@ ****************************************************************************/ #include <nuttx/config.h> + #include <sys/types.h> + #include <nuttx/arch.h> #include <nuttx/irq.h> + +#include "chip/switch.h" #include "up_internal.h" /**************************************************************************** @@ -64,5 +68,5 @@ boolean up_interrupt_context(void) { - return current_regs != NULL; + return IN_INTERRUPT(); } diff --git a/nuttx/arch/z80/src/common/up_registerdump.c b/nuttx/arch/z80/src/common/up_registerdump.c deleted file mode 100644 index 05761bf85..000000000 --- a/nuttx/arch/z80/src/common/up_registerdump.c +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** - * common/up_registerdump.c - * - * 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 - * modification, are permitted provided that the following conditions - * are met: - * - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * 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. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN - * 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 <debug.h> - -#include <nuttx/irq.h> -#include <nuttx/arch.h> - -#include "os_internal.h" -#include "up_internal.h" - -/**************************************************************************** - * Definitions - ****************************************************************************/ - -/* Output debug info if stack dump is selected -- even if - * debug is not selected. - */ - -#ifdef CONFIG_ARCH_STACKDUMP -# undef lldbg -# define lldbg lib_lowprintf -#endif - -/**************************************************************************** - * Private Data - ****************************************************************************/ - -/**************************************************************************** - * Private Functions - ****************************************************************************/ - -/**************************************************************************** - * Name: up_registerdump - ****************************************************************************/ - -#ifdef CONFIG_ARCH_STACKDUMP -static void up_registerdump(void) -{ - if (current_regs) - { - lldbg("AF: %04x I: %04x\n", - current_regs[XCPT_AF], current_regs[XCPT_I]); - lldbg("BC: %04x DE: %04x HL: %04x\n", - current_regs[XCPT_BC], current_regs[XCPT_DE], current_regs[XCPT_HL]); - lldbg("IX: %04x IY: %04x\n", - current_regs[XCPT_IX], current_regs[XCPT_IY]); - lldbg("SP: %04x PC: $04x\n" - current_regs[XCPT_SP], current_regs[XCPT_PC]); - } -} -#endif diff --git a/nuttx/arch/z80/src/common/up_releasepending.c b/nuttx/arch/z80/src/common/up_releasepending.c index 853cc7350..e4048152f 100644 --- a/nuttx/arch/z80/src/common/up_releasepending.c +++ b/nuttx/arch/z80/src/common/up_releasepending.c @@ -1,5 +1,5 @@ /**************************************************************************** - * common/up_releasepending.c + * arch/z80/src/common/up_releasepending.c * * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> @@ -46,6 +46,7 @@ #include <nuttx/arch.h> #include "chip/chip.h" +#include "chip/switch.h" #include "os_internal.h" #include "up_internal.h" @@ -92,7 +93,7 @@ void up_release_pending(void) * interrupt context: */ - if (IN_INTERRUPT) + if (IN_INTERRUPT()) { /* Yes, then we have to do things differently. * Just copy the current context into the OLD rtcb. diff --git a/nuttx/arch/z80/src/common/up_reprioritizertr.c b/nuttx/arch/z80/src/common/up_reprioritizertr.c index 3adf33735..4576852ac 100644 --- a/nuttx/arch/z80/src/common/up_reprioritizertr.c +++ b/nuttx/arch/z80/src/common/up_reprioritizertr.c @@ -1,5 +1,5 @@ /**************************************************************************** - * common/up_reprioritizertr.c + * arch/z80/src/common/up_reprioritizertr.c * * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> @@ -46,6 +46,7 @@ #include <nuttx/arch.h> #include "chip/chip.h" +#include "chip/switch.h" #include "os_internal.h" #include "up_internal.h" @@ -140,7 +141,7 @@ void up_reprioritize_rtr(FAR _TCB *tcb, ubyte priority) /* Are we in an interrupt handler? */ - if (IN_INTERRUPT) + if (IN_INTERRUPT()) { /* Yes, then we have to do things differently. * Just copy the current context into the OLD rtcb. diff --git a/nuttx/arch/z80/src/common/up_schedulesigaction.c b/nuttx/arch/z80/src/common/up_schedulesigaction.c index 946ba859b..bad83e551 100644 --- a/nuttx/arch/z80/src/common/up_schedulesigaction.c +++ b/nuttx/arch/z80/src/common/up_schedulesigaction.c @@ -1,5 +1,5 @@ /**************************************************************************** - * common/up_schedulesigaction.c + * arch/z80/src/common/up_schedulesigaction.c * * Copyright (C) 2007,2008 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> @@ -46,6 +46,7 @@ #include <nuttx/arch.h> #include <arch/irq.h> +#include "chip/switch.h" #include "os_internal.h" #include "up_internal.h" @@ -102,11 +103,11 @@ void up_schedule_sigaction(FAR _TCB *tcb, sig_deliver_t sigdeliver) { - /* Refuse to handle nested signal actions */ - dbg("tcb=0x%p sigdeliver=0x%04x\n", tcb, (uint16)sigdeliver); - if (!tcb->xcp.sigdeliver) + /* Refuse to handle nested signal actions */ + + if (!SIGNAL_DELIVERING(tcb)) { irqstate_t flags; @@ -114,80 +115,53 @@ void up_schedule_sigaction(FAR _TCB *tcb, sig_deliver_t sigdeliver) flags = irqsave(); - /* First, handle some special cases when the signal is - * being delivered to the currently executing task. + /* First, handle some special cases when the signal is being delivered + * to the currently executing task. */ - dbg("rtcb=0x%p current_regs=0x%p\n", g_readytorun.head, current_regs); - 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. + /* CASE 1: We are not in an interrupt handler and a task is + * signalling itself for some reason. */ - if (!current_regs) + if (!IN_INTERRUPT()) { /* In this case just deliver the signal now. */ sigdeliver(tcb); } - /* CASE 2: We are in an interrupt handler AND the - * interrupted task is the same as the one that - * must receive the signal, then we will have to modify - * the return state as well as the state in the TCB. + /* CASE 2: We are in an interrupt handler AND the interrupted task + * is the same as the one that must receive the signal, then we + * will have to modify the return state as well as the state in + * the TCB. */ else { - /* Save the return address and interrupt state. - * These will be restored by the signal trampoline after - * the signals have been delivered. - */ + /* Set up to vector to the trampoline with interrupts disabled. */ - tcb->xcp.sigdeliver = sigdeliver; - 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[XCPT_PC] = (uint16)up_sigdeliver; - current_regs[XCPT_I] = 0; + SIGNAL_SETUP(tcb, sigdeliver, IRQ_STATE()); /* And make sure that the saved context in the TCB * is the same as the interrupt return context. */ - up_copystate(tcb->xcp.regs, current_regs); + SAVE_IRQCONTEXT(tcb); } } - /* Otherwise, we are (1) signaling a task is not running - * from an interrupt handler or (2) we are not in an - * interrupt handler and the running task is signalling - * some non-running task. + /* Otherwise, we are (1) signaling a task is not running from an interrupt + * handler or (2) we are not in an interrupt handler and the running task + * is signalling some non-running task. */ else { - /* Save the return lr and cpsr and one scratch register - * These will be restored by the signal trampoline after - * the signals have been delivered. - */ - - tcb->xcp.sigdeliver = sigdeliver; - 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 - */ + /* Set up to vector to the trampoline with interrupts disabled. */ - tcb->xcp.regs[XCPT_PC] = (uint16)up_sigdeliver; - tcb->xcp.regs[XCPT_I] = 0; + SIGNAL_SETUP(tcb, sigdeliver, tcb->xcp.regs) } irqrestore(flags); diff --git a/nuttx/arch/z80/src/common/up_sigdeliver.c b/nuttx/arch/z80/src/common/up_sigdeliver.c index 757e5020b..9ab8f8447 100644 --- a/nuttx/arch/z80/src/common/up_sigdeliver.c +++ b/nuttx/arch/z80/src/common/up_sigdeliver.c @@ -1,5 +1,5 @@ /**************************************************************************** - * common/up_sigdeliver.c + * arch/z80/src/common/up_sigdeliver.c * * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> @@ -46,6 +46,7 @@ #include <nuttx/irq.h> #include <nuttx/arch.h> +#include "chip/switch.h" #include "os_internal.h" #include "up_internal.h" @@ -100,7 +101,7 @@ void up_sigdeliver(void) /* Save the real return state on the stack. */ - up_copystate(regs, rtcb->xcp.regs); + COPYSTATE(regs, rtcb->xcp.regs); regs[XCPT_PC] = rtcb->xcp.saved_pc; regs[XCPT_I] = rtcb->xcp.saved_i; diff --git a/nuttx/arch/z80/src/common/up_unblocktask.c b/nuttx/arch/z80/src/common/up_unblocktask.c index 1ce672a5d..aa09342c6 100644 --- a/nuttx/arch/z80/src/common/up_unblocktask.c +++ b/nuttx/arch/z80/src/common/up_unblocktask.c @@ -1,5 +1,5 @@ /**************************************************************************** - * common/up_unblocktask.c + * arch/z80/src/common/up_unblocktask.c * * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <spudmonkey@racsa.co.cr> @@ -46,6 +46,7 @@ #include <nuttx/arch.h> #include "chip/chip.h" +#include "chip/switch.h" #include "os_internal.h" #include "clock_internal.h" #include "up_internal.h" @@ -121,7 +122,7 @@ void up_unblock_task(FAR _TCB *tcb) * Are we in an interrupt handler? */ - if (IN_INTERRUPT) + if (IN_INTERRUPT()) { /* Yes, then we have to do things differently. * Just copy the current context into the OLD rtcb. |