From e3df43d45273609e6cee0a1b1a38f64c218d37c2 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 28 Aug 2014 07:38:05 -0600 Subject: Z80: Move address environment switch from the task switchers to the interrupt handler. That may save doing the action multiple times per interrupt --- nuttx/arch/z80/src/common/up_blocktask.c | 13 ++------ nuttx/arch/z80/src/common/up_doirq.c | 48 +++++++++++++++++++++++------- nuttx/arch/z80/src/common/up_unblocktask.c | 13 ++------ 3 files changed, 41 insertions(+), 33 deletions(-) (limited to 'nuttx') diff --git a/nuttx/arch/z80/src/common/up_blocktask.c b/nuttx/arch/z80/src/common/up_blocktask.c index d8bed1318..1527e0698 100644 --- a/nuttx/arch/z80/src/common/up_blocktask.c +++ b/nuttx/arch/z80/src/common/up_blocktask.c @@ -142,20 +142,11 @@ void up_block_task(FAR struct tcb_s *tcb, tstate_t task_state) /* dbg("New Active Task TCB=%p\n", rtcb); */ /* Then setup so that the context will be performed on exit - * from the interrupt. + * from the interrupt. Any necessary address environment + * changes will be made when the interrupt returns. */ SET_IRQCONTEXT(rtcb); - -#ifdef CONFIG_ARCH_ADDRENV - /* Make sure that the address environment for the previously - * running task is closed down gracefully (data caches dump, - * MMU flushed) and set up the address environment for the new - * thread at the head of the ready-to-run list. - */ - - (void)group_addrenv(rtcb); -#endif } /* Copy the user C context into the TCB at the (old) head of the diff --git a/nuttx/arch/z80/src/common/up_doirq.c b/nuttx/arch/z80/src/common/up_doirq.c index a92d3d774..ab974c88a 100644 --- a/nuttx/arch/z80/src/common/up_doirq.c +++ b/nuttx/arch/z80/src/common/up_doirq.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/z80/src/common/up_doirq.c * - * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2014 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -49,8 +49,10 @@ #include "chip/switch.h" #include "up_internal.h" +#include "group/group.h" + /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** @@ -81,25 +83,49 @@ FAR chipreg_t *up_doirq(uint8_t irq, FAR chipreg_t *regs) return NULL; /* Won't get here */ #else +#ifdef CONFIG_ARCH_ADDRENV + FAR chipreg_t *newregs; +#endif + if (irq < NR_IRQS) { - DECL_SAVESTATE(); + DECL_SAVESTATE(); + + /* Indicate that we have entered IRQ processing logic */ + + IRQ_ENTER(irq, regs); - /* Indicate that we have entered IRQ processing logic */ + /* Deliver the IRQ */ - IRQ_ENTER(irq, regs); + irq_dispatch(irq, regs); - /* Deliver the IRQ */ +#ifdef CONFIG_ARCH_ADDRENV + /* If a context switch occurred, 'newregs' will hold the new context */ - irq_dispatch(irq, regs); + newregs = IRQ_STATE(); - /* If a context switch occurred, 'regs' will hold the new context */ + if (newregs != regs) + { + /* Make sure that the address environment for the previously + * running task is closed down gracefully and set up the + * address environment for the new thread at the head of the + * ready-to-run list. + */ - regs = IRQ_STATE(); + (void)group_addrenv(rtcb); + } + + regs = newregs; + +#else + /* If a context switch occurred, 'regs' will hold the new context */ + + regs = IRQ_STATE(); +#endif - /* Indicate that we are no longer in interrupt processing logic */ + /* Indicate that we are no longer in interrupt processing logic */ - IRQ_LEAVE(irq); + IRQ_LEAVE(irq); } board_led_off(LED_INIRQ); diff --git a/nuttx/arch/z80/src/common/up_unblocktask.c b/nuttx/arch/z80/src/common/up_unblocktask.c index 257b19c6f..12dcc4d51 100644 --- a/nuttx/arch/z80/src/common/up_unblocktask.c +++ b/nuttx/arch/z80/src/common/up_unblocktask.c @@ -133,20 +133,11 @@ void up_unblock_task(FAR struct tcb_s *tcb) rtcb = (FAR struct tcb_s*)g_readytorun.head; /* Then setup so that the context will be performed on exit - * from the interrupt. + * from the interrupt. Any necessary address environment + * changes will be made when the interrupt returns. */ SET_IRQCONTEXT(rtcb); - -#ifdef CONFIG_ARCH_ADDRENV - /* Make sure that the address environment for the previously - * running task is closed down gracefully (data caches dump, - * MMU flushed) and set up the address environment for the new - * thread at the head of the ready-to-run list. - */ - - (void)group_addrenv(rtcb); -#endif } /* We are not in an interrupt handler. Copy the user C context -- cgit v1.2.3