Add ADDRENV support to all implementations of up_block_task()

This commit is contained in:
Gregory Nutt 2014-08-27 15:36:52 -06:00
parent d35723749b
commit 57c066b7a3
9 changed files with 189 additions and 14 deletions

View File

@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* arch/arm/src/arm/up_blocktask.c * arch/arm/src/arm/up_blocktask.c
* *
* Copyright (C) 2007-2009, 2013 Gregory Nutt. All rights reserved. * Copyright (C) 2007-2009, 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
@ -46,6 +46,7 @@
#include <nuttx/arch.h> #include <nuttx/arch.h>
#include "sched/sched.h" #include "sched/sched.h"
#include "group/group.h"
#include "up_internal.h" #include "up_internal.h"
/**************************************************************************** /****************************************************************************
@ -139,6 +140,16 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state)
/* Then switch contexts */ /* Then switch contexts */
up_restorestate(rtcb->xcp.regs); 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);
#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
@ -154,6 +165,15 @@ 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;
#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
/* Then switch contexts */ /* Then switch contexts */
up_fullcontextrestore(rtcb->xcp.regs); up_fullcontextrestore(rtcb->xcp.regs);

View File

@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* arch/arm/src/armv7-a/up_blocktask.c * arch/arm/src/armv7-a/up_blocktask.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
@ -46,6 +46,7 @@
#include <nuttx/arch.h> #include <nuttx/arch.h>
#include "sched/sched.h" #include "sched/sched.h"
#include "group/group.h"
#include "up_internal.h" #include "up_internal.h"
/**************************************************************************** /****************************************************************************
@ -139,6 +140,16 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state)
/* Then switch contexts */ /* Then switch contexts */
up_restorestate(rtcb->xcp.regs); 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);
#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
@ -154,6 +165,15 @@ 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;
#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
/* Then switch contexts */ /* Then switch contexts */
up_fullcontextrestore(rtcb->xcp.regs); up_fullcontextrestore(rtcb->xcp.regs);

View File

@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* arch/avr/src/avr32/up_blocktask.c * arch/avr/src/avr32/up_blocktask.c
* *
* Copyright (C) 2010, 2013 Gregory Nutt. All rights reserved. * Copyright (C) 2010, 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
@ -46,6 +46,7 @@
#include <nuttx/arch.h> #include <nuttx/arch.h>
#include "sched/sched.h" #include "sched/sched.h"
#include "group/group.h"
#include "up_internal.h" #include "up_internal.h"
/**************************************************************************** /****************************************************************************
@ -139,17 +140,39 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state)
/* Then switch contexts */ /* Then switch contexts */
up_restorestate(rtcb->xcp.regs); 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);
#endif
} }
/* No, then we will need to perform the user context switch */ /* No, then we will need to perform the user context switch */
else else
{ {
/* Switch context to the context of the task at the head of the /* Get the context of the task at the head of the ready to
* ready to run list. * run list.
*/ */
struct tcb_s *nexttcb = (struct tcb_s*)g_readytorun.head; struct tcb_s *nexttcb = (struct tcb_s*)g_readytorun.head;
#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(nexttcb);
#endif
/* Then switch contexts */
up_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs); up_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs);
/* up_switchcontext forces a context switch to the task at the /* up_switchcontext forces a context switch to the task at the

View File

@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* arch/hc/src/common/up_blocktask.c * arch/hc/src/common/up_blocktask.c
* *
* Copyright (C) 2010, 2013 Gregory Nutt. All rights reserved. * Copyright (C) 2010, 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
@ -46,6 +46,7 @@
#include <nuttx/arch.h> #include <nuttx/arch.h>
#include "sched/sched.h" #include "sched/sched.h"
#include "group/group.h"
#include "up_internal.h" #include "up_internal.h"
/**************************************************************************** /****************************************************************************
@ -139,6 +140,16 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state)
/* Then switch contexts */ /* Then switch contexts */
up_restorestate(rtcb->xcp.regs); 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);
#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
@ -154,6 +165,15 @@ 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;
#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
/* Then switch contexts */ /* Then switch contexts */
up_fullcontextrestore(rtcb->xcp.regs); up_fullcontextrestore(rtcb->xcp.regs);

View File

@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* arch/mips/src/mips32/up_blocktask.c * arch/mips/src/mips32/up_blocktask.c
* *
* Copyright (C) 2011, 2013 Gregory Nutt. All rights reserved. * Copyright (C) 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
@ -47,6 +47,7 @@
#include <nuttx/arch.h> #include <nuttx/arch.h>
#include "sched/sched.h" #include "sched/sched.h"
#include "group/group.h"
#include "up_internal.h" #include "up_internal.h"
/**************************************************************************** /****************************************************************************
@ -140,17 +141,39 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state)
/* Then switch contexts */ /* Then switch contexts */
up_restorestate(rtcb->xcp.regs); 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);
#endif
} }
/* No, then we will need to perform the user context switch */ /* No, then we will need to perform the user context switch */
else else
{ {
/* Switch context to the context of the task at the head of the /* Get the context of the task at the head of the ready to
* ready to run list. * run list.
*/ */
struct tcb_s *nexttcb = (struct tcb_s*)g_readytorun.head; struct tcb_s *nexttcb = (struct tcb_s*)g_readytorun.head;
#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(nexttcb);
#endif
/* Then switch contexts */
up_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs); up_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs);
/* up_switchcontext forces a context switch to the task at the /* up_switchcontext forces a context switch to the task at the

View File

@ -6,7 +6,7 @@
* *
* This file is a part of NuttX: * This file is a part of NuttX:
* *
* Copyright (C) 2011 Gregory Nutt. All rights reserved. * Copyright (C) 2011, 2014 Gregory Nutt. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions * modification, are permitted provided that the following conditions
@ -55,6 +55,7 @@
#include "task/task.h" #include "task/task.h"
#include "sched/sched.h" #include "sched/sched.h"
#include "group/group.h"
struct tcb_s *current_task = NULL; struct tcb_s *current_task = NULL;
@ -288,6 +289,15 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state)
sched_mergepending(); sched_mergepending();
} }
nexttcb = (struct tcb_s*)g_readytorun.head; nexttcb = (struct tcb_s*)g_readytorun.head;
#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(nexttcb);
#endif
// context switch // context switch
up_switchcontext(rtcb, nexttcb); up_switchcontext(rtcb, nexttcb);
} }

View File

@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* arch/sh/src/common/up_blocktask.c * arch/sh/src/common/up_blocktask.c
* *
* Copyright (C) 2008-2009, 2013 Gregory Nutt. All rights reserved. * Copyright (C) 2008-2009, 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
@ -45,6 +45,7 @@
#include <nuttx/arch.h> #include <nuttx/arch.h>
#include "sched/sched.h" #include "sched/sched.h"
#include "group/group.h"
#include "up_internal.h" #include "up_internal.h"
/**************************************************************************** /****************************************************************************
@ -138,6 +139,16 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state)
/* Then switch contexts */ /* Then switch contexts */
current_regs = rtcb->xcp.regs; current_regs = 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);
#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
@ -153,6 +164,15 @@ 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;
#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
/* Then switch contexts */ /* Then switch contexts */
up_fullcontextrestore(rtcb->xcp.regs); up_fullcontextrestore(rtcb->xcp.regs);

View File

@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* arch/x86/src/common/up_blocktask.c * arch/x86/src/common/up_blocktask.c
* *
* Copyright (C) 2011, 2013 Gregory Nutt. All rights reserved. * Copyright (C) 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
@ -46,6 +46,7 @@
#include <nuttx/arch.h> #include <nuttx/arch.h>
#include "sched/sched.h" #include "sched/sched.h"
#include "group/group.h"
#include "up_internal.h" #include "up_internal.h"
/**************************************************************************** /****************************************************************************
@ -138,6 +139,16 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state)
/* Then switch contexts */ /* Then switch contexts */
up_restorestate(rtcb->xcp.regs); 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);
#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
@ -153,6 +164,15 @@ 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;
#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
/* Then switch contexts */ /* Then switch contexts */
up_fullcontextrestore(rtcb->xcp.regs); up_fullcontextrestore(rtcb->xcp.regs);

View File

@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* arch/z80/src/common/up_blocktask.c * arch/z80/src/common/up_blocktask.c
* *
* Copyright (C) 2007-2009, 2013 Gregory Nutt. All rights reserved. * Copyright (C) 2007-2009, 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
@ -47,6 +47,7 @@
#include "chip/switch.h" #include "chip/switch.h"
#include "sched/sched.h" #include "sched/sched.h"
#include "group/group.h"
#include "up_internal.h" #include "up_internal.h"
/**************************************************************************** /****************************************************************************
@ -145,6 +146,16 @@ void up_block_task(FAR struct tcb_s *tcb, tstate_t task_state)
*/ */
SET_IRQCONTEXT(rtcb); 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 /* Copy the user C context into the TCB at the (old) head of the
@ -159,8 +170,16 @@ void up_block_task(FAR struct tcb_s *tcb, tstate_t task_state)
*/ */
rtcb = (FAR struct tcb_s*)g_readytorun.head; rtcb = (FAR struct tcb_s*)g_readytorun.head;
/* dbg("New Active Task TCB=%p\n", 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
/* Then switch contexts */ /* Then switch contexts */
RESTORE_USERCONTEXT(rtcb); RESTORE_USERCONTEXT(rtcb);