mirror of
https://github.com/apache/nuttx.git
synced 2026-06-05 15:58:59 +08:00
ARM: Move address environment switch from the task switchers to the interrupt handler. That may save doing the actin multiple times per interrupt
This commit is contained in:
@@ -137,19 +137,11 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state)
|
|||||||
|
|
||||||
rtcb = (struct tcb_s*)g_readytorun.head;
|
rtcb = (struct tcb_s*)g_readytorun.head;
|
||||||
|
|
||||||
/* Then switch contexts */
|
/* Then switch contexts. Any necessary address environment
|
||||||
|
* changes will be made when the interrupt returns.
|
||||||
up_restorestate(rtcb->xcp.regs);
|
|
||||||
|
|
||||||
#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);
|
up_restorestate(rtcb->xcp.regs);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Copy the user C context into the TCB at the (old) head of the
|
/* Copy the user C context into the TCB at the (old) head of the
|
||||||
|
|||||||
+36
-14
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* arch/arm/src/arm/up_doirq.c
|
* arch/arm/src/arm/up_doirq.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2007-2009, 2011, 2013 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2007-2009, 2011, 2013-2014 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -49,6 +49,8 @@
|
|||||||
#include "up_arch.h"
|
#include "up_arch.h"
|
||||||
#include "up_internal.h"
|
#include "up_internal.h"
|
||||||
|
|
||||||
|
#include "group/group.h"
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -75,21 +77,14 @@ void up_doirq(int irq, uint32_t *regs)
|
|||||||
#ifdef CONFIG_SUPPRESS_INTERRUPTS
|
#ifdef CONFIG_SUPPRESS_INTERRUPTS
|
||||||
PANIC();
|
PANIC();
|
||||||
#else
|
#else
|
||||||
uint32_t *savestate;
|
/* Nested interrupts are not supported */
|
||||||
|
|
||||||
/* Nested interrupts are not supported in this implementation. If you want
|
DEBUGASSERT(current_regs == NULL);
|
||||||
* to implement nested interrupts, you would have to (1) change the way that
|
|
||||||
* current_regs is handled and (2) implement design changes associated with
|
|
||||||
* CONFIG_ARCH_INTERRUPTSTACK. The savestate variable will not work for
|
|
||||||
* that purpose as implemented here because only the outermost nested
|
|
||||||
* interrupt can result in a context switch (it can probably be deleted).
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* Current regs non-zero indicates that we are processing an interrupt;
|
/* Current regs non-zero indicates that we are processing an interrupt;
|
||||||
* current_regs is also used to manage interrupt level context switches.
|
* current_regs is also used to manage interrupt level context switches.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
savestate = (uint32_t*)current_regs;
|
|
||||||
current_regs = regs;
|
current_regs = regs;
|
||||||
|
|
||||||
/* Mask and acknowledge the interrupt */
|
/* Mask and acknowledge the interrupt */
|
||||||
@@ -100,12 +95,39 @@ void up_doirq(int irq, uint32_t *regs)
|
|||||||
|
|
||||||
irq_dispatch(irq, regs);
|
irq_dispatch(irq, regs);
|
||||||
|
|
||||||
/* Restore the previous value of current_regs. NULL would indicate that
|
/* Check for a context switch. If a context switch occurred, then
|
||||||
* we are no longer in an interrupt handler. It will be non-NULL if we
|
* current_regs will have a different value than it did on entry. If an
|
||||||
* are returning from a nested interrupt.
|
* interrupt level context switch has occurred, then restore the floating
|
||||||
|
* point state and the establish the correct address environment before
|
||||||
|
* returning from the interrupt.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
current_regs = savestate;
|
#if defined(CONFIG_ARCH_FPU) || defined(CONFIG_ARCH_ADDRENV)
|
||||||
|
if (regs != current_regs)
|
||||||
|
{
|
||||||
|
#ifdef CONFIG_ARCH_FPU
|
||||||
|
/* Restore floating point registers */
|
||||||
|
|
||||||
|
up_restorefpu((uint32_t*)current_regs);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#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
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* Set current_regs to NULL to indicate that we are no longer in an
|
||||||
|
* interrupt handler.
|
||||||
|
*/
|
||||||
|
|
||||||
|
current_regs = NULL;
|
||||||
|
|
||||||
/* Unmask the last interrupt (global interrupts are still disabled) */
|
/* Unmask the last interrupt (global interrupts are still disabled) */
|
||||||
|
|
||||||
|
|||||||
@@ -127,19 +127,11 @@ void up_unblock_task(struct tcb_s *tcb)
|
|||||||
|
|
||||||
rtcb = (struct tcb_s*)g_readytorun.head;
|
rtcb = (struct tcb_s*)g_readytorun.head;
|
||||||
|
|
||||||
/* Then switch contexts */
|
/* Then switch contexts. Any necessary address environment
|
||||||
|
* changes will be made when the interrupt returns.
|
||||||
up_restorestate(rtcb->xcp.regs);
|
|
||||||
|
|
||||||
#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);
|
up_restorestate(rtcb->xcp.regs);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We are not in an interrupt handler. Copy the user C context
|
/* We are not in an interrupt handler. Copy the user C context
|
||||||
|
|||||||
@@ -137,19 +137,11 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state)
|
|||||||
|
|
||||||
rtcb = (struct tcb_s*)g_readytorun.head;
|
rtcb = (struct tcb_s*)g_readytorun.head;
|
||||||
|
|
||||||
/* Then switch contexts */
|
/* Then switch contexts. Any necessary address environment
|
||||||
|
* changes will be made when the interrupt returns.
|
||||||
up_restorestate(rtcb->xcp.regs);
|
|
||||||
|
|
||||||
#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);
|
up_restorestate(rtcb->xcp.regs);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Copy the user C context into the TCB at the (old) head of the
|
/* Copy the user C context into the TCB at the (old) head of the
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* arch/arm/src/armv7-a/arm_doirq.c
|
* arch/arm/src/armv7-a/arm_doirq.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2013 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2013-2014 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* Redistribution and use in source and binary forms, with or without
|
||||||
@@ -49,6 +49,8 @@
|
|||||||
#include "up_arch.h"
|
#include "up_arch.h"
|
||||||
#include "up_internal.h"
|
#include "up_internal.h"
|
||||||
|
|
||||||
|
#include "group/group.h"
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
@@ -93,18 +95,31 @@ uint32_t *arm_doirq(int irq, uint32_t *regs)
|
|||||||
|
|
||||||
irq_dispatch(irq, regs);
|
irq_dispatch(irq, regs);
|
||||||
|
|
||||||
/* Check for a context switch. If a context switch occured, then
|
/* Check for a context switch. If a context switch occurred, then
|
||||||
* current_regs will have a different value than it did on entry. If an
|
* current_regs will have a different value than it did on entry. If an
|
||||||
* interrupt level context switch has occurred, then restore the floating
|
* interrupt level context switch has occurred, then restore the floating
|
||||||
* point state before returning from the interrupt.
|
* point state and the establish the correct address environment before
|
||||||
|
* returning from the interrupt.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef CONFIG_ARCH_FPU
|
#if defined(CONFIG_ARCH_FPU) || defined(CONFIG_ARCH_ADDRENV)
|
||||||
if (regs != current_regs)
|
if (regs != current_regs)
|
||||||
{
|
{
|
||||||
|
#ifdef CONFIG_ARCH_FPU
|
||||||
/* Restore floating point registers */
|
/* Restore floating point registers */
|
||||||
|
|
||||||
up_restorefpu((uint32_t*)current_regs);
|
up_restorefpu((uint32_t*)current_regs);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#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
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|||||||
@@ -127,19 +127,11 @@ void up_unblock_task(struct tcb_s *tcb)
|
|||||||
|
|
||||||
rtcb = (struct tcb_s*)g_readytorun.head;
|
rtcb = (struct tcb_s*)g_readytorun.head;
|
||||||
|
|
||||||
/* Then switch contexts */
|
/* Then switch contexts. Any necessary address environment
|
||||||
|
* changes will be made when the interrupt returns.
|
||||||
up_restorestate(rtcb->xcp.regs);
|
|
||||||
|
|
||||||
#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);
|
up_restorestate(rtcb->xcp.regs);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* We are not in an interrupt handler. Copy the user C context
|
/* We are not in an interrupt handler. Copy the user C context
|
||||||
|
|||||||
Reference in New Issue
Block a user