mirror of
https://github.com/apache/nuttx.git
synced 2026-05-28 11:56:10 +08:00
nuttx/sched: merge up_block_task and up_unblock_task
This commit is contained in:
@@ -102,7 +102,7 @@ function will perform the following operations:
|
|||||||
with the page fill worker must be "`locked <#MemoryOrg>`__" and
|
with the page fill worker must be "`locked <#MemoryOrg>`__" and
|
||||||
always present in memory.
|
always present in memory.
|
||||||
#. **Block the currently executing task**. This function will call
|
#. **Block the currently executing task**. This function will call
|
||||||
``up_block_task()`` to block the task at the head of the ready-to-run
|
``up_switch_context()`` to block the task at the head of the ready-to-run
|
||||||
list. This should cause an interrupt level context switch to the next
|
list. This should cause an interrupt level context switch to the next
|
||||||
highest priority task. The blocked task will be marked with state
|
highest priority task. The blocked task will be marked with state
|
||||||
``TSTATE_WAIT_PAGEFILL`` and will be retained in the
|
``TSTATE_WAIT_PAGEFILL`` and will be retained in the
|
||||||
@@ -373,8 +373,8 @@ Most standard, architecture-specific functions are declared in
|
|||||||
``include/nuttx/arch.h``. However, for the case of this paging logic,
|
``include/nuttx/arch.h``. However, for the case of this paging logic,
|
||||||
the architecture specific functions are declared in
|
the architecture specific functions are declared in
|
||||||
``include/nuttx/page.h``. Standard, architecture-specific functions that
|
``include/nuttx/page.h``. Standard, architecture-specific functions that
|
||||||
should already be provided in the architecture port are :c:func:`up_block_task`
|
should already be provided in the architecture port are
|
||||||
and :c:func:`up_unblock_task`. New, additional functions that must be
|
:c:func:`up_switch_context`. New, additional functions that must be
|
||||||
implemented just for on-demand paging support are:
|
implemented just for on-demand paging support are:
|
||||||
|
|
||||||
.. c:function:: int up_checkmapping(FAR struct tcb_s *tcb)
|
.. c:function:: int up_checkmapping(FAR struct tcb_s *tcb)
|
||||||
|
|||||||
@@ -174,7 +174,7 @@ APIs Exported by Architecture-Specific Logic to NuttX
|
|||||||
and threads must have come from memory that is accessible to
|
and threads must have come from memory that is accessible to
|
||||||
user
|
user
|
||||||
|
|
||||||
.. c:function:: void up_unblock_task(FAR struct tcb_s *tcb, FAR struct tcb_s *rtcb)
|
.. c:function:: void up_switch_context(FAR struct tcb_s *tcb, FAR struct tcb_s *rtcb)
|
||||||
|
|
||||||
A task is currently in the ready-to-run list but has been preppe
|
A task is currently in the ready-to-run list but has been preppe
|
||||||
to execute. Restore its context, and start execution.
|
to execute. Restore its context, and start execution.
|
||||||
@@ -186,18 +186,6 @@ APIs Exported by Architecture-Specific Logic to NuttX
|
|||||||
which will be executed.
|
which will be executed.
|
||||||
:param rtcb: Refers to the running task which will be blocked.
|
:param rtcb: Refers to the running task which will be blocked.
|
||||||
|
|
||||||
.. c:function:: void up_block_task(FAR struct tcb_s *rtcb)
|
|
||||||
|
|
||||||
The currently executing task has already removed from ready-to-run list.
|
|
||||||
Save its context and switch to the next running task at the head of the
|
|
||||||
ready-to-run list.
|
|
||||||
|
|
||||||
This function is called only from the NuttX scheduling logic.
|
|
||||||
Interrupts will always be disabled when this function is called.
|
|
||||||
|
|
||||||
:param rtcb: Reference to the running task which is different to the
|
|
||||||
task (next running task) at the head of the list.
|
|
||||||
|
|
||||||
.. c:function:: void up_release_pending(void)
|
.. c:function:: void up_release_pending(void)
|
||||||
|
|
||||||
When tasks become ready-to-run but cannot run
|
When tasks become ready-to-run but cannot run
|
||||||
|
|||||||
@@ -20,14 +20,14 @@
|
|||||||
|
|
||||||
# Common ARM files
|
# Common ARM files
|
||||||
|
|
||||||
CMN_CSRCS += arm_allocateheap.c arm_assert.c arm_blocktask.c
|
CMN_CSRCS += arm_allocateheap.c arm_assert.c
|
||||||
CMN_CSRCS += arm_createstack.c arm_exit.c
|
CMN_CSRCS += arm_createstack.c arm_exit.c
|
||||||
CMN_CSRCS += arm_initialize.c arm_lowputs.c
|
CMN_CSRCS += arm_initialize.c arm_lowputs.c
|
||||||
CMN_CSRCS += arm_modifyreg16.c arm_modifyreg32.c
|
CMN_CSRCS += arm_modifyreg16.c arm_modifyreg32.c
|
||||||
CMN_CSRCS += arm_modifyreg8.c arm_nputs.c arm_releasepending.c
|
CMN_CSRCS += arm_modifyreg8.c arm_nputs.c arm_releasepending.c
|
||||||
CMN_CSRCS += arm_releasestack.c arm_saveusercontext.c
|
CMN_CSRCS += arm_releasestack.c arm_saveusercontext.c
|
||||||
CMN_CSRCS += arm_stackframe.c
|
CMN_CSRCS += arm_stackframe.c
|
||||||
CMN_CSRCS += arm_vfork.c arm_unblocktask.c arm_usestack.c
|
CMN_CSRCS += arm_vfork.c arm_switchcontext.c arm_usestack.c
|
||||||
|
|
||||||
ifneq ($(CONFIG_ALARM_ARCH),y)
|
ifneq ($(CONFIG_ALARM_ARCH),y)
|
||||||
ifneq ($(CONFIG_TIMER_ARCH),y)
|
ifneq ($(CONFIG_TIMER_ARCH),y)
|
||||||
|
|||||||
@@ -1,112 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
* arch/arm/src/common/arm_blocktask.c
|
|
||||||
*
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
|
||||||
* this work for additional information regarding copyright ownership. The
|
|
||||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
||||||
* "License"); you may not use this file except in compliance with the
|
|
||||||
* License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
* License for the specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Included Files
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
|
||||||
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <sched.h>
|
|
||||||
#include <assert.h>
|
|
||||||
#include <debug.h>
|
|
||||||
|
|
||||||
#include <nuttx/arch.h>
|
|
||||||
#include <nuttx/sched.h>
|
|
||||||
|
|
||||||
#include "sched/sched.h"
|
|
||||||
#include "group/group.h"
|
|
||||||
#include "arm_internal.h"
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Public Functions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: up_block_task
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* The currently executing task has already removed from ready-to-run list.
|
|
||||||
* Save its context and switch to the next running task at the head of the
|
|
||||||
* ready-to-run list.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* rtcb: Reference to the running task which is different to the
|
|
||||||
* task (next running task) at the head of the list.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
void up_block_task(struct tcb_s *rtcb)
|
|
||||||
{
|
|
||||||
/* Update scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_suspend_scheduler(rtcb);
|
|
||||||
|
|
||||||
/* Are we in an interrupt handler? */
|
|
||||||
|
|
||||||
if (CURRENT_REGS)
|
|
||||||
{
|
|
||||||
/* Yes, then we have to do things differently.
|
|
||||||
* Just copy the CURRENT_REGS into the OLD rtcb.
|
|
||||||
*/
|
|
||||||
|
|
||||||
arm_savestate(rtcb->xcp.regs);
|
|
||||||
|
|
||||||
/* Restore the exception context of the rtcb at the (new) head
|
|
||||||
* of the ready-to-run task list.
|
|
||||||
*/
|
|
||||||
|
|
||||||
rtcb = this_task();
|
|
||||||
|
|
||||||
/* Reset scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_resume_scheduler(rtcb);
|
|
||||||
|
|
||||||
/* Then switch contexts. Any necessary address environment
|
|
||||||
* changes will be made when the interrupt returns.
|
|
||||||
*/
|
|
||||||
|
|
||||||
arm_restorestate(rtcb->xcp.regs);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* No, then we will need to perform the user context switch */
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
struct tcb_s *nexttcb = this_task();
|
|
||||||
|
|
||||||
/* Reset scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_resume_scheduler(nexttcb);
|
|
||||||
|
|
||||||
/* Switch context to the context of the task at the head of the
|
|
||||||
* ready to run list.
|
|
||||||
*/
|
|
||||||
|
|
||||||
arm_switchcontext(&rtcb->xcp.regs, nexttcb->xcp.regs);
|
|
||||||
|
|
||||||
/* arm_switchcontext forces a context switch to the task at the
|
|
||||||
* head of the ready-to-run list. It does not 'return' in the
|
|
||||||
* normal sense. When it does return, it is because the blocked
|
|
||||||
* task is again ready to run and has execution priority.
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* arch/arm/src/common/arm_unblocktask.c
|
* arch/arm/src/common/arm_switchcontext.c
|
||||||
*
|
*
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
@@ -40,7 +40,7 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: up_unblock_task
|
* Name: up_switch_context
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* A task is currently in the ready-to-run list but has been prepped
|
* A task is currently in the ready-to-run list but has been prepped
|
||||||
@@ -53,7 +53,7 @@
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void up_unblock_task(struct tcb_s *tcb, struct tcb_s *rtcb)
|
void up_switch_context(struct tcb_s *tcb, struct tcb_s *rtcb)
|
||||||
{
|
{
|
||||||
/* Update scheduler parameters */
|
/* Update scheduler parameters */
|
||||||
|
|
||||||
@@ -46,7 +46,7 @@ CMN_CSRCS = arm64_initialize.c arm64_initialstate.c arm64_boot.c
|
|||||||
CMN_CSRCS += arm64_nputs.c arm64_idle.c arm64_copystate.c
|
CMN_CSRCS += arm64_nputs.c arm64_idle.c arm64_copystate.c
|
||||||
CMN_CSRCS += arm64_createstack.c arm64_releasestack.c arm64_stackframe.c arm64_usestack.c
|
CMN_CSRCS += arm64_createstack.c arm64_releasestack.c arm64_stackframe.c arm64_usestack.c
|
||||||
CMN_CSRCS += arm64_task_sched.c arm64_exit.c arm64_vfork.c
|
CMN_CSRCS += arm64_task_sched.c arm64_exit.c arm64_vfork.c
|
||||||
CMN_CSRCS += arm64_releasepending.c arm64_unblocktask.c arm64_blocktask.c
|
CMN_CSRCS += arm64_releasepending.c arm64_switchcontext.c
|
||||||
CMN_CSRCS += arm64_assert.c arm64_schedulesigaction.c arm64_backtrace.c
|
CMN_CSRCS += arm64_assert.c arm64_schedulesigaction.c arm64_backtrace.c
|
||||||
CMN_CSRCS += arm64_sigdeliver.c
|
CMN_CSRCS += arm64_sigdeliver.c
|
||||||
|
|
||||||
|
|||||||
@@ -1,112 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
* arch/arm64/src/common/arm64_blocktask.c
|
|
||||||
*
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
|
||||||
* this work for additional information regarding copyright ownership. The
|
|
||||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
||||||
* "License"); you may not use this file except in compliance with the
|
|
||||||
* License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
* License for the specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Included Files
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
|
||||||
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <sched.h>
|
|
||||||
#include <assert.h>
|
|
||||||
#include <debug.h>
|
|
||||||
|
|
||||||
#include <nuttx/arch.h>
|
|
||||||
#include <nuttx/sched.h>
|
|
||||||
|
|
||||||
#include "sched/sched.h"
|
|
||||||
#include "group/group.h"
|
|
||||||
#include "arm64_internal.h"
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Public Functions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: up_block_task
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* The currently executing task has already removed from ready-to-run list.
|
|
||||||
* Save its context and switch to the next running task at the head of the
|
|
||||||
* ready-to-run list.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* rtcb: Reference to the running task which is different to the
|
|
||||||
* task (next running task) at the head of the list.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
void up_block_task(struct tcb_s *rtcb)
|
|
||||||
{
|
|
||||||
/* Update scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_suspend_scheduler(rtcb);
|
|
||||||
|
|
||||||
/* Are we in an interrupt handler? */
|
|
||||||
|
|
||||||
if (CURRENT_REGS)
|
|
||||||
{
|
|
||||||
/* Yes, then we have to do things differently.
|
|
||||||
* Just copy the CURRENT_REGS into the OLD rtcb.
|
|
||||||
*/
|
|
||||||
|
|
||||||
arm64_savestate(rtcb->xcp.regs);
|
|
||||||
|
|
||||||
/* Restore the exception context of the rtcb at the (new) head
|
|
||||||
* of the ready-to-run task list.
|
|
||||||
*/
|
|
||||||
|
|
||||||
rtcb = this_task();
|
|
||||||
|
|
||||||
/* Reset scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_resume_scheduler(rtcb);
|
|
||||||
|
|
||||||
/* Then switch contexts. Any necessary address environment
|
|
||||||
* changes will be made when the interrupt returns.
|
|
||||||
*/
|
|
||||||
|
|
||||||
arm64_restorestate(rtcb->xcp.regs);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* No, then we will need to perform the user context switch */
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
struct tcb_s *nexttcb = this_task();
|
|
||||||
|
|
||||||
/* Reset scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_resume_scheduler(nexttcb);
|
|
||||||
|
|
||||||
/* Switch context to the context of the task at the head of the
|
|
||||||
* ready to run list.
|
|
||||||
*/
|
|
||||||
|
|
||||||
arm64_switchcontext(&rtcb->xcp.regs, nexttcb->xcp.regs);
|
|
||||||
|
|
||||||
/* arm_switchcontext forces a context switch to the task at the
|
|
||||||
* head of the ready-to-run list. It does not 'return' in the
|
|
||||||
* normal sense. When it does return, it is because the blocked
|
|
||||||
* task is again ready to run and has execution priority.
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+3
-3
@@ -1,5 +1,5 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* arch/arm64/src/common/arm64_unblocktask.c
|
* arch/arm64/src/common/arm64_switchcontext.c
|
||||||
*
|
*
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
@@ -40,7 +40,7 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: up_unblock_task
|
* Name: up_switch_context
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* A task is currently in the ready-to-run list but has been prepped
|
* A task is currently in the ready-to-run list but has been prepped
|
||||||
@@ -53,7 +53,7 @@
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void up_unblock_task(struct tcb_s *tcb, struct tcb_s *rtcb)
|
void up_switch_context(struct tcb_s *tcb, struct tcb_s *rtcb)
|
||||||
{
|
{
|
||||||
/* Update scheduler parameters */
|
/* Update scheduler parameters */
|
||||||
|
|
||||||
@@ -24,14 +24,14 @@ HEAD_ASRC = avr_nommuhead.S
|
|||||||
|
|
||||||
# Common AVR/AVR32 files
|
# Common AVR/AVR32 files
|
||||||
|
|
||||||
CMN_ASRCS = avr_exceptions.S avr_fullcontextrestore.S avr_switchcontext.S
|
CMN_ASRCS = avr_exceptions.S avr_fullcontextrestore.S avr_doswitch.S
|
||||||
CMN_CSRCS = avr_assert.c avr_allocateheap.c avr_blocktask.c avr_copystate.c
|
CMN_CSRCS = avr_assert.c avr_allocateheap.c avr_copystate.c
|
||||||
CMN_CSRCS += avr_createstack.c avr_mdelay.c avr_udelay.c avr_exit.c avr_idle.c
|
CMN_CSRCS += avr_createstack.c avr_mdelay.c avr_udelay.c avr_exit.c avr_idle.c
|
||||||
CMN_CSRCS += avr_initialize.c avr_initialstate.c
|
CMN_CSRCS += avr_initialize.c avr_initialstate.c
|
||||||
CMN_CSRCS += avr_modifyreg8.c avr_modifyreg16.c avr_modifyreg32.c
|
CMN_CSRCS += avr_modifyreg8.c avr_modifyreg16.c avr_modifyreg32.c
|
||||||
CMN_CSRCS += avr_releasepending.c avr_releasestack.c
|
CMN_CSRCS += avr_releasepending.c avr_releasestack.c
|
||||||
CMN_CSRCS += avr_schedulesigaction.c avr_sigdeliver.c avr_stackframe.c
|
CMN_CSRCS += avr_schedulesigaction.c avr_sigdeliver.c avr_stackframe.c
|
||||||
CMN_CSRCS += avr_unblocktask.c avr_usestack.c avr_doirq.c avr_nputs.c
|
CMN_CSRCS += avr_switchcontext.c avr_usestack.c avr_doirq.c avr_nputs.c
|
||||||
|
|
||||||
# Configuration-dependent common files
|
# Configuration-dependent common files
|
||||||
|
|
||||||
|
|||||||
@@ -24,14 +24,14 @@ HEAD_ASRC = at90usb_head.S
|
|||||||
|
|
||||||
# Common AVR files
|
# Common AVR files
|
||||||
|
|
||||||
CMN_ASRCS = avr_switchcontext.S
|
CMN_ASRCS = avr_doswitch.S
|
||||||
CMN_CSRCS = avr_allocateheap.c avr_assert.c avr_blocktask.c avr_copystate.c
|
CMN_CSRCS = avr_allocateheap.c avr_assert.c avr_copystate.c
|
||||||
CMN_CSRCS += avr_createstack.c avr_doirq.c avr_exit.c avr_idle.c avr_initialize.c
|
CMN_CSRCS += avr_createstack.c avr_doirq.c avr_exit.c avr_idle.c avr_initialize.c
|
||||||
CMN_CSRCS += avr_initialstate.c avr_irq.c avr_lowputs.c
|
CMN_CSRCS += avr_initialstate.c avr_irq.c avr_lowputs.c
|
||||||
CMN_CSRCS += avr_mdelay.c avr_modifyreg8.c avr_modifyreg16.c avr_modifyreg32.c
|
CMN_CSRCS += avr_mdelay.c avr_modifyreg8.c avr_modifyreg16.c avr_modifyreg32.c
|
||||||
CMN_CSRCS += avr_nputs.c avr_releasepending.c avr_releasestack.c
|
CMN_CSRCS += avr_nputs.c avr_releasepending.c avr_releasestack.c
|
||||||
CMN_CSRCS += avr_schedulesigaction.c avr_sigdeliver.c
|
CMN_CSRCS += avr_schedulesigaction.c avr_sigdeliver.c
|
||||||
CMN_CSRCS += avr_stackframe.c avr_udelay.c avr_unblocktask.c avr_usestack.c
|
CMN_CSRCS += avr_stackframe.c avr_udelay.c avr_switchcontext.c avr_usestack.c
|
||||||
|
|
||||||
# Configuration-dependent common files
|
# Configuration-dependent common files
|
||||||
|
|
||||||
|
|||||||
@@ -24,14 +24,14 @@ HEAD_ASRC = atmega_head.S
|
|||||||
|
|
||||||
# Common AVR files
|
# Common AVR files
|
||||||
|
|
||||||
CMN_ASRCS = avr_switchcontext.S
|
CMN_ASRCS = avr_doswitch.S
|
||||||
CMN_CSRCS = avr_allocateheap.c avr_assert.c avr_blocktask.c avr_copystate.c
|
CMN_CSRCS = avr_allocateheap.c avr_assert.c avr_copystate.c
|
||||||
CMN_CSRCS += avr_createstack.c avr_doirq.c avr_exit.c avr_idle.c avr_initialize.c
|
CMN_CSRCS += avr_createstack.c avr_doirq.c avr_exit.c avr_idle.c avr_initialize.c
|
||||||
CMN_CSRCS += avr_initialstate.c avr_irq.c avr_lowputs.c
|
CMN_CSRCS += avr_initialstate.c avr_irq.c avr_lowputs.c
|
||||||
CMN_CSRCS += avr_mdelay.c avr_modifyreg8.c avr_modifyreg16.c avr_modifyreg32.c
|
CMN_CSRCS += avr_mdelay.c avr_modifyreg8.c avr_modifyreg16.c avr_modifyreg32.c
|
||||||
CMN_CSRCS += avr_nputs.c avr_releasepending.c avr_releasestack.c
|
CMN_CSRCS += avr_nputs.c avr_releasepending.c avr_releasestack.c
|
||||||
CMN_CSRCS += avr_schedulesigaction.c avr_sigdeliver.c
|
CMN_CSRCS += avr_schedulesigaction.c avr_sigdeliver.c
|
||||||
CMN_CSRCS += avr_stackframe.c avr_udelay.c avr_unblocktask.c avr_usestack.c
|
CMN_CSRCS += avr_stackframe.c avr_udelay.c avr_switchcontext.c avr_usestack.c
|
||||||
|
|
||||||
# Configuration-dependent common files
|
# Configuration-dependent common files
|
||||||
|
|
||||||
|
|||||||
@@ -1,109 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
* arch/avr/src/avr/avr_blocktask.c
|
|
||||||
*
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
|
||||||
* this work for additional information regarding copyright ownership. The
|
|
||||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
||||||
* "License"); you may not use this file except in compliance with the
|
|
||||||
* License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
* License for the specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Included Files
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
|
||||||
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <sched.h>
|
|
||||||
#include <assert.h>
|
|
||||||
#include <debug.h>
|
|
||||||
|
|
||||||
#include <nuttx/arch.h>
|
|
||||||
#include <nuttx/sched.h>
|
|
||||||
|
|
||||||
#include "sched/sched.h"
|
|
||||||
#include "avr_internal.h"
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Public Functions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: up_block_task
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* The currently executing task has already removed from ready-to-run list.
|
|
||||||
* Save its context and switch to the next running task at the head of the
|
|
||||||
* ready-to-run list.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* rtcb: Reference to the running task which is different to the
|
|
||||||
* task (next running task) at the head of the list.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
void up_block_task(struct tcb_s *rtcb)
|
|
||||||
{
|
|
||||||
/* Update scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_suspend_scheduler(rtcb);
|
|
||||||
|
|
||||||
/* Are we in an interrupt handler? */
|
|
||||||
|
|
||||||
if (g_current_regs)
|
|
||||||
{
|
|
||||||
/* Yes, then we have to do things differently.
|
|
||||||
* Just copy the g_current_regs into the OLD rtcb.
|
|
||||||
*/
|
|
||||||
|
|
||||||
avr_savestate(rtcb->xcp.regs);
|
|
||||||
|
|
||||||
/* Restore the exception context of the rtcb at the (new) head
|
|
||||||
* of the ready-to-run task list.
|
|
||||||
*/
|
|
||||||
|
|
||||||
rtcb = this_task();
|
|
||||||
|
|
||||||
/* Reset scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_resume_scheduler(rtcb);
|
|
||||||
|
|
||||||
/* Then switch contexts */
|
|
||||||
|
|
||||||
avr_restorestate(rtcb->xcp.regs);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* No, then we will need to perform the user context switch */
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
struct tcb_s *nexttcb = this_task();
|
|
||||||
|
|
||||||
/* Reset scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_resume_scheduler(nexttcb);
|
|
||||||
|
|
||||||
/* Switch context to the context of the task at the head of the
|
|
||||||
* ready to run list.
|
|
||||||
*/
|
|
||||||
|
|
||||||
avr_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs);
|
|
||||||
|
|
||||||
/* avr_switchcontext forces a context switch to the task at the
|
|
||||||
* head of the ready-to-run list. It does not 'return' in the
|
|
||||||
* normal sense. When it does return, it is because the blocked
|
|
||||||
* task is again ready to run and has execution priority.
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* arch/avr/src/avr/avr_switchcontext.S
|
* arch/avr/src/avr/avr_doswitch.S
|
||||||
*
|
*
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
@@ -36,7 +36,7 @@
|
|||||||
* Public Symbols
|
* Public Symbols
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
|
|
||||||
.file "avr_switchcontext.S"
|
.file "avr_doswitch.S"
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* Macros
|
* Macros
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* arch/avr/src/avr/avr_unblocktask.c
|
* arch/avr/src/avr/avr_switchcontext.c
|
||||||
*
|
*
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
@@ -39,7 +39,7 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: up_unblock_task
|
* Name: up_switch_context
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* A task is currently in the ready-to-run list but has been prepped
|
* A task is currently in the ready-to-run list but has been prepped
|
||||||
@@ -52,7 +52,7 @@
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void up_unblock_task(struct tcb_s *tcb, struct tcb_s *rtcb)
|
void up_switch_context(struct tcb_s *tcb, struct tcb_s *rtcb)
|
||||||
{
|
{
|
||||||
/* Update scheduler parameters */
|
/* Update scheduler parameters */
|
||||||
|
|
||||||
@@ -546,7 +546,7 @@
|
|||||||
* interrupt_enable - return sequence.
|
* interrupt_enable - return sequence.
|
||||||
*
|
*
|
||||||
* NOTE: since actual returning is handled by this macro it has been
|
* NOTE: since actual returning is handled by this macro it has been
|
||||||
* removed from avr_fullcontextrestore function (avr_switchcontext.S)
|
* removed from avr_fullcontextrestore function (avr_doswitch.S)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* If interrupts shall be enabled go to 'restore remaining and reti' code
|
/* If interrupts shall be enabled go to 'restore remaining and reti' code
|
||||||
|
|||||||
@@ -1,124 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
* arch/avr/src/avr32/avr_blocktask.c
|
|
||||||
*
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
|
||||||
* this work for additional information regarding copyright ownership. The
|
|
||||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
||||||
* "License"); you may not use this file except in compliance with the
|
|
||||||
* License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
* License for the specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Included Files
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
|
||||||
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <sched.h>
|
|
||||||
#include <assert.h>
|
|
||||||
#include <debug.h>
|
|
||||||
|
|
||||||
#include <nuttx/arch.h>
|
|
||||||
#include <nuttx/sched.h>
|
|
||||||
|
|
||||||
#include "sched/sched.h"
|
|
||||||
#include "group/group.h"
|
|
||||||
#include "avr_internal.h"
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Public Functions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: up_block_task
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* The currently executing task has already removed from ready-to-run list.
|
|
||||||
* Save its context and switch to the next running task at the head of the
|
|
||||||
* ready-to-run list.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* rtcb: Reference to the running task which is different to the
|
|
||||||
* task (next running task) at the head of the list.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
void up_block_task(struct tcb_s *rtcb)
|
|
||||||
{
|
|
||||||
/* Update scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_suspend_scheduler(rtcb);
|
|
||||||
|
|
||||||
/* Are we in an interrupt handler? */
|
|
||||||
|
|
||||||
if (g_current_regs)
|
|
||||||
{
|
|
||||||
/* Yes, then we have to do things differently.
|
|
||||||
* Just copy the g_current_regs into the OLD rtcb.
|
|
||||||
*/
|
|
||||||
|
|
||||||
avr_savestate(rtcb->xcp.regs);
|
|
||||||
|
|
||||||
/* Restore the exception context of the rtcb at the (new) head
|
|
||||||
* of the ready-to-run task list.
|
|
||||||
*/
|
|
||||||
|
|
||||||
rtcb = this_task();
|
|
||||||
|
|
||||||
/* Reset scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_resume_scheduler(rtcb);
|
|
||||||
|
|
||||||
/* Then switch contexts. Any new address environment needed by
|
|
||||||
* the new thread will be instantiated before the return from
|
|
||||||
* interrupt.
|
|
||||||
*/
|
|
||||||
|
|
||||||
avr_restorestate(rtcb->xcp.regs);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* No, then we will need to perform the user context switch */
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Get the context of the task at the head of the ready to
|
|
||||||
* run list.
|
|
||||||
*/
|
|
||||||
|
|
||||||
struct tcb_s *nexttcb = this_task();
|
|
||||||
|
|
||||||
#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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
group_addrenv(nexttcb);
|
|
||||||
#endif
|
|
||||||
/* Reset scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_resume_scheduler(nexttcb);
|
|
||||||
|
|
||||||
/* Then switch contexts */
|
|
||||||
|
|
||||||
avr_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs);
|
|
||||||
|
|
||||||
/* avr_switchcontext forces a context switch to the task at the
|
|
||||||
* head of the ready-to-run list. It does not 'return' in the
|
|
||||||
* normal sense. When it does return, it is because the blocked
|
|
||||||
* task is again ready to run and has execution priority.
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* arch/avr/src/avr32/avr_switchcontext.S
|
* arch/avr/src/avr32/avr_doswitch.S
|
||||||
*
|
*
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
@@ -34,7 +34,7 @@
|
|||||||
* Public Symbols
|
* Public Symbols
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
|
|
||||||
.file "avr_switchcontext.S"
|
.file "avr_doswitch.S"
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* Macros
|
* Macros
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* arch/avr/src/avr32/avr_unblocktask.c
|
* arch/avr/src/avr32/avr_switchcontext.c
|
||||||
*
|
*
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
@@ -40,7 +40,7 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: up_unblock_task
|
* Name: up_switch_context
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* A task is currently in the ready-to-run list but has been prepped
|
* A task is currently in the ready-to-run list but has been prepped
|
||||||
@@ -53,7 +53,7 @@
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void up_unblock_task(struct tcb_s *tcb, struct tcb_s *rtcb)
|
void up_switch_context(struct tcb_s *tcb, struct tcb_s *rtcb)
|
||||||
{
|
{
|
||||||
/* Update scheduler parameters */
|
/* Update scheduler parameters */
|
||||||
|
|
||||||
@@ -1,102 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
* arch/ceva/src/common/ceva_blocktask.c
|
|
||||||
*
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
|
||||||
* this work for additional information regarding copyright ownership. The
|
|
||||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
||||||
* "License"); you may not use this file except in compliance with the
|
|
||||||
* License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
* License for the specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Included Files
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
|
||||||
#include <nuttx/arch.h>
|
|
||||||
|
|
||||||
#include "sched/sched.h"
|
|
||||||
#include "ceva_internal.h"
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Public Functions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: up_block_task
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* The currently executing task has already removed from ready-to-run list.
|
|
||||||
* Save its context and switch to the next running task at the head of the
|
|
||||||
* ready-to-run list.
|
|
||||||
*
|
|
||||||
* Inputs:
|
|
||||||
* rtcb: Reference to the running task which is different to the
|
|
||||||
* task (next running task) at the head of the list.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
void up_block_task(struct tcb_s *rtcb)
|
|
||||||
{
|
|
||||||
/* Update scheduler parameters */
|
|
||||||
|
|
||||||
sched_suspend_scheduler(rtcb);
|
|
||||||
|
|
||||||
/* Are we in an interrupt handler? */
|
|
||||||
|
|
||||||
if (CURRENT_REGS)
|
|
||||||
{
|
|
||||||
/* Yes, then we have to do things differently.
|
|
||||||
* Just copy the CURRENT_REGS into the OLD rtcb.
|
|
||||||
*/
|
|
||||||
|
|
||||||
rtcb->xcp.regs = CURRENT_REGS;
|
|
||||||
|
|
||||||
/* Restore the exception context of the rtcb at the (new) head
|
|
||||||
* of the ready-to-run task list.
|
|
||||||
*/
|
|
||||||
|
|
||||||
rtcb = this_task();
|
|
||||||
|
|
||||||
/* Reset scheduler parameters */
|
|
||||||
|
|
||||||
sched_resume_scheduler(rtcb);
|
|
||||||
|
|
||||||
/* Then switch contexts */
|
|
||||||
|
|
||||||
CURRENT_REGS = rtcb->xcp.regs;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* No, then we will need to perform the user context switch */
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
struct tcb_s *nexttcb = this_task();
|
|
||||||
|
|
||||||
/* Reset scheduler parameters */
|
|
||||||
|
|
||||||
sched_resume_scheduler(nexttcb);
|
|
||||||
|
|
||||||
/* Switch context to the context of the task at the head of the
|
|
||||||
* ready to run list.
|
|
||||||
*/
|
|
||||||
|
|
||||||
ceva_switchcontext(&rtcb->xcp.regs, nexttcb->xcp.regs);
|
|
||||||
|
|
||||||
/* ceva_switchcontext forces a context switch to the task at the
|
|
||||||
* head of the ready-to-run list. It does not 'return' in the
|
|
||||||
* normal sense. When it does return, it is because the blocked
|
|
||||||
* task is again ready to run and has execution priority.
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -22,8 +22,10 @@
|
|||||||
* Included Files
|
* Included Files
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
|
#include <nuttx/arch.h>
|
||||||
#include <arch/syscall.h>
|
#include <arch/syscall.h>
|
||||||
|
|
||||||
|
#include "sched/sched.h"
|
||||||
#include "ceva_internal.h"
|
#include "ceva_internal.h"
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
@@ -50,3 +52,64 @@ void ceva_switchcontext(uint32_t **saveregs, uint32_t *restoreregs)
|
|||||||
|
|
||||||
sys_call2(SYS_switch_context, (uintptr_t)saveregs, (uintptr_t)restoreregs);
|
sys_call2(SYS_switch_context, (uintptr_t)saveregs, (uintptr_t)restoreregs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/****************************************************************************
|
||||||
|
* Name: up_switch_context
|
||||||
|
*
|
||||||
|
* Description:
|
||||||
|
* A task is currently in the ready-to-run list but has been prepped
|
||||||
|
* to execute. Restore its context, and start execution.
|
||||||
|
*
|
||||||
|
* Input Parameters:
|
||||||
|
* tcb: Refers to the head task of the ready-to-run list
|
||||||
|
* which will be executed.
|
||||||
|
* rtcb: Refers to the running task which will be blocked.
|
||||||
|
*
|
||||||
|
****************************************************************************/
|
||||||
|
|
||||||
|
void up_switch_context(struct tcb_s *tcb, struct tcb_s *rtcb)
|
||||||
|
{
|
||||||
|
/* Update scheduler parameters */
|
||||||
|
|
||||||
|
sched_suspend_scheduler(rtcb);
|
||||||
|
|
||||||
|
/* Are we in an interrupt handler? */
|
||||||
|
|
||||||
|
if (CURRENT_REGS)
|
||||||
|
{
|
||||||
|
/* Yes, then we have to do things differently.
|
||||||
|
* Just copy the CURRENT_REGS into the OLD rtcb.
|
||||||
|
*/
|
||||||
|
|
||||||
|
rtcb->xcp.regs = CURRENT_REGS;
|
||||||
|
|
||||||
|
/* Update scheduler parameters */
|
||||||
|
|
||||||
|
sched_resume_scheduler(tcb);
|
||||||
|
|
||||||
|
/* Then switch contexts */
|
||||||
|
|
||||||
|
CURRENT_REGS = tcb->xcp.regs;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* No, then we will need to perform the user context switch */
|
||||||
|
|
||||||
|
else
|
||||||
|
{
|
||||||
|
/* Update scheduler parameters */
|
||||||
|
|
||||||
|
sched_resume_scheduler(tcb);
|
||||||
|
|
||||||
|
/* Switch context to the context of the task at the head of the
|
||||||
|
* ready to run list.
|
||||||
|
*/
|
||||||
|
|
||||||
|
ceva_switchcontext(&rtcb->xcp.regs, tcb->xcp.regs);
|
||||||
|
|
||||||
|
/* ceva_switchcontext forces a context switch to the task at the
|
||||||
|
* head of the ready-to-run list. It does not 'return' in the
|
||||||
|
* normal sense. When it does return, it is because the blocked
|
||||||
|
* task is again ready to run and has execution priority.
|
||||||
|
*/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,96 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
* arch/ceva/src/common/ceva_unblocktask.c
|
|
||||||
*
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
|
||||||
* this work for additional information regarding copyright ownership. The
|
|
||||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
||||||
* "License"); you may not use this file except in compliance with the
|
|
||||||
* License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
* License for the specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Included Files
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
|
||||||
|
|
||||||
#include <debug.h>
|
|
||||||
#include <nuttx/arch.h>
|
|
||||||
|
|
||||||
#include "sched/sched.h"
|
|
||||||
#include "ceva_internal.h"
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Public Functions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: up_unblock_task
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* A task is currently in the ready-to-run list but has been prepped
|
|
||||||
* to execute. Restore its context, and start execution.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* tcb: Refers to the head task of the ready-to-run list
|
|
||||||
* which will be executed.
|
|
||||||
* rtcb: Refers to the running task which will be blocked.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
void up_unblock_task(struct tcb_s *tcb, struct tcb_s *rtcb)
|
|
||||||
{
|
|
||||||
/* Update scheduler parameters */
|
|
||||||
|
|
||||||
sched_suspend_scheduler(rtcb);
|
|
||||||
|
|
||||||
/* Are we in an interrupt handler? */
|
|
||||||
|
|
||||||
if (CURRENT_REGS)
|
|
||||||
{
|
|
||||||
/* Yes, then we have to do things differently.
|
|
||||||
* Just copy the CURRENT_REGS into the OLD rtcb.
|
|
||||||
*/
|
|
||||||
|
|
||||||
rtcb->xcp.regs = CURRENT_REGS;
|
|
||||||
|
|
||||||
/* Update scheduler parameters */
|
|
||||||
|
|
||||||
sched_resume_scheduler(tcb);
|
|
||||||
|
|
||||||
/* Then switch contexts */
|
|
||||||
|
|
||||||
CURRENT_REGS = tcb->xcp.regs;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* No, then we will need to perform the user context switch */
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Update scheduler parameters */
|
|
||||||
|
|
||||||
sched_resume_scheduler(tcb);
|
|
||||||
|
|
||||||
/* Switch context to the context of the task at the head of the
|
|
||||||
* ready to run list.
|
|
||||||
*/
|
|
||||||
|
|
||||||
ceva_switchcontext(&rtcb->xcp.regs, tcb->xcp.regs);
|
|
||||||
|
|
||||||
/* ceva_switchcontext forces a context switch to the task at the
|
|
||||||
* head of the ready-to-run list. It does not 'return' in the
|
|
||||||
* normal sense. When it does return, it is because the blocked
|
|
||||||
* task is again ready to run and has execution priority.
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,120 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
* arch/hc/src/common/hc_blocktask.c
|
|
||||||
*
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
|
||||||
* this work for additional information regarding copyright ownership. The
|
|
||||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
||||||
* "License"); you may not use this file except in compliance with the
|
|
||||||
* License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
* License for the specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Included Files
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
|
||||||
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <sched.h>
|
|
||||||
#include <assert.h>
|
|
||||||
#include <debug.h>
|
|
||||||
|
|
||||||
#include <nuttx/arch.h>
|
|
||||||
#include <nuttx/sched.h>
|
|
||||||
|
|
||||||
#include "sched/sched.h"
|
|
||||||
#include "group/group.h"
|
|
||||||
#include "hc_internal.h"
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Public Functions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: up_block_task
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* The currently executing task has already removed from ready-to-run list.
|
|
||||||
* Save its context and switch to the next running task at the head of the
|
|
||||||
* ready-to-run list.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* rtcb: Reference to the running task which is different to the
|
|
||||||
* task (next running task) at the head of the list.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
void up_block_task(struct tcb_s *rtcb)
|
|
||||||
{
|
|
||||||
/* Update scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_suspend_scheduler(rtcb);
|
|
||||||
|
|
||||||
/* Are we in an interrupt handler? */
|
|
||||||
|
|
||||||
if (g_current_regs)
|
|
||||||
{
|
|
||||||
/* Yes, then we have to do things differently.
|
|
||||||
* Just copy the g_current_regs into the OLD rtcb.
|
|
||||||
*/
|
|
||||||
|
|
||||||
hc_savestate(rtcb->xcp.regs);
|
|
||||||
|
|
||||||
/* Restore the exception context of the rtcb at the (new) head
|
|
||||||
* of the ready-to-run task list.
|
|
||||||
*/
|
|
||||||
|
|
||||||
rtcb = this_task();
|
|
||||||
|
|
||||||
/* Reset scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_resume_scheduler(rtcb);
|
|
||||||
|
|
||||||
/* Then switch contexts. Any necessary address environment
|
|
||||||
* changes will be made when the interrupt returns.
|
|
||||||
*/
|
|
||||||
|
|
||||||
hc_restorestate(rtcb->xcp.regs);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Copy the user C context into the TCB at the (old) head of the
|
|
||||||
* ready-to-run Task list. if up_saveusercontext returns a non-zero
|
|
||||||
* value, then this is really the previously running task restarting!
|
|
||||||
*/
|
|
||||||
|
|
||||||
else if (!up_saveusercontext(rtcb->xcp.regs))
|
|
||||||
{
|
|
||||||
/* Restore the exception context of the rtcb at the (new) head
|
|
||||||
* of the ready-to-run task list.
|
|
||||||
*/
|
|
||||||
|
|
||||||
rtcb = this_task();
|
|
||||||
|
|
||||||
#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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
group_addrenv(rtcb);
|
|
||||||
#endif
|
|
||||||
/* Reset scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_resume_scheduler(rtcb);
|
|
||||||
|
|
||||||
/* Then switch contexts */
|
|
||||||
|
|
||||||
hc_fullcontextrestore(rtcb->xcp.regs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* arch/hc/src/common/hc_unblocktask.c
|
* arch/hc/src/common/hc_switchcontext.c
|
||||||
*
|
*
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
@@ -40,7 +40,7 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: up_unblock_task
|
* Name: up_switch_context
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* A task is currently in the ready-to-run list but has been prepped
|
* A task is currently in the ready-to-run list but has been prepped
|
||||||
@@ -53,7 +53,7 @@
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void up_unblock_task(struct tcb_s *tcb, struct tcb_s *rtcb)
|
void up_switch_context(struct tcb_s *tcb, struct tcb_s *rtcb)
|
||||||
{
|
{
|
||||||
/* Update scheduler parameters */
|
/* Update scheduler parameters */
|
||||||
|
|
||||||
@@ -20,11 +20,11 @@
|
|||||||
|
|
||||||
HEAD_ASRC = m9s12_vectors.S
|
HEAD_ASRC = m9s12_vectors.S
|
||||||
|
|
||||||
CMN_CSRCS = hc_allocateheap.c hc_blocktask.c hc_copystate.c hc_createstack.c
|
CMN_CSRCS = hc_allocateheap.c hc_copystate.c hc_createstack.c
|
||||||
CMN_CSRCS += hc_doirq.c hc_exit.c hc_idle.c hc_initialize.c
|
CMN_CSRCS += hc_doirq.c hc_exit.c hc_idle.c hc_initialize.c
|
||||||
CMN_CSRCS += hc_mdelay.c hc_modifyreg16.c hc_modifyreg32.c hc_modifyreg8.c
|
CMN_CSRCS += hc_mdelay.c hc_modifyreg16.c hc_modifyreg32.c hc_modifyreg8.c
|
||||||
CMN_CSRCS += hc_nputs.c hc_releasepending.c hc_releasestack.c
|
CMN_CSRCS += hc_nputs.c hc_releasepending.c hc_releasestack.c
|
||||||
CMN_CSRCS += hc_stackframe.c hc_udelay.c hc_unblocktask.c hc_usestack.c
|
CMN_CSRCS += hc_stackframe.c hc_udelay.c hc_switchcontext.c hc_usestack.c
|
||||||
|
|
||||||
CHIP_ASRCS = m9s12_start.S m9s12_lowputc.S m9s12_saveusercontext.S
|
CHIP_ASRCS = m9s12_start.S m9s12_lowputc.S m9s12_saveusercontext.S
|
||||||
CHIP_CSRCS = m9s12_assert.c m9s12_gpio.c m9s12_gpioirq.c m9s12_initialstate.c
|
CHIP_CSRCS = m9s12_assert.c m9s12_gpio.c m9s12_gpioirq.c m9s12_initialstate.c
|
||||||
|
|||||||
@@ -1,115 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
* arch/mips/src/mips32/mips_blocktask.c
|
|
||||||
*
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
|
||||||
* this work for additional information regarding copyright ownership. The
|
|
||||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
||||||
* "License"); you may not use this file except in compliance with the
|
|
||||||
* License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
* License for the specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Included Files
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
|
||||||
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <sched.h>
|
|
||||||
#include <syscall.h>
|
|
||||||
#include <assert.h>
|
|
||||||
#include <debug.h>
|
|
||||||
|
|
||||||
#include <nuttx/arch.h>
|
|
||||||
#include <nuttx/sched.h>
|
|
||||||
|
|
||||||
#include "sched/sched.h"
|
|
||||||
#include "group/group.h"
|
|
||||||
#include "mips_internal.h"
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Public Functions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: up_block_task
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* The currently executing task has already removed from ready-to-run list.
|
|
||||||
* Save its context and switch to the next running task at the head of the
|
|
||||||
* ready-to-run list.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* rtcb: Reference to the running task which is different to the
|
|
||||||
* task (next running task) at the head of the list.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
void up_block_task(struct tcb_s *rtcb)
|
|
||||||
{
|
|
||||||
/* Update scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_suspend_scheduler(rtcb);
|
|
||||||
|
|
||||||
/* Are we in an interrupt handler? */
|
|
||||||
|
|
||||||
if (CURRENT_REGS)
|
|
||||||
{
|
|
||||||
/* Yes, then we have to do things differently.
|
|
||||||
* Just copy the g_current_regs into the OLD rtcb.
|
|
||||||
*/
|
|
||||||
|
|
||||||
mips_savestate(rtcb->xcp.regs);
|
|
||||||
|
|
||||||
/* Restore the exception context of the rtcb at the (new) head
|
|
||||||
* of the ready-to-run task list.
|
|
||||||
*/
|
|
||||||
|
|
||||||
rtcb = this_task();
|
|
||||||
|
|
||||||
/* Reset scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_resume_scheduler(rtcb);
|
|
||||||
|
|
||||||
/* Then switch contexts. Any necessary address environment
|
|
||||||
* changes will be made when the interrupt returns.
|
|
||||||
*/
|
|
||||||
|
|
||||||
mips_restorestate(rtcb->xcp.regs);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* No, then we will need to perform the user context switch */
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Get the context of the task at the head of the ready to
|
|
||||||
* run list.
|
|
||||||
*/
|
|
||||||
|
|
||||||
struct tcb_s *nexttcb = this_task();
|
|
||||||
|
|
||||||
/* Reset scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_resume_scheduler(nexttcb);
|
|
||||||
|
|
||||||
/* Then switch contexts */
|
|
||||||
|
|
||||||
mips_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs);
|
|
||||||
|
|
||||||
/* mips_switchcontext forces a context switch to the task at the
|
|
||||||
* head of the ready-to-run list. It does not 'return' in the
|
|
||||||
* normal sense. When it does return, it is because the blocked
|
|
||||||
* task is again ready to run and has execution priority.
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* arch/mips/src/mips32/mips_unblocktask.c
|
* arch/mips/src/mips32/mips_switchcontext.c
|
||||||
*
|
*
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
@@ -42,7 +42,7 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: up_unblock_task
|
* Name: up_switch_context
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* A task is currently in the ready-to-run list but has been prepped
|
* A task is currently in the ready-to-run list but has been prepped
|
||||||
@@ -55,7 +55,7 @@
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void up_unblock_task(struct tcb_s *tcb, struct tcb_s *rtcb)
|
void up_switch_context(struct tcb_s *tcb, struct tcb_s *rtcb)
|
||||||
{
|
{
|
||||||
/* Update scheduler parameters */
|
/* Update scheduler parameters */
|
||||||
|
|
||||||
@@ -25,13 +25,13 @@ HEAD_ASRC = pic32mx_head.S
|
|||||||
# Common MIPS files
|
# Common MIPS files
|
||||||
|
|
||||||
CMN_ASRCS = mips_syscall0.S vfork.S
|
CMN_ASRCS = mips_syscall0.S vfork.S
|
||||||
CMN_CSRCS = mips_allocateheap.c mips_assert.c mips_blocktask.c mips_copystate.c
|
CMN_CSRCS = mips_allocateheap.c mips_assert.c mips_copystate.c
|
||||||
CMN_CSRCS += mips_createstack.c mips_doirq.c mips_exit.c mips_initialize.c
|
CMN_CSRCS += mips_createstack.c mips_doirq.c mips_exit.c mips_initialize.c
|
||||||
CMN_CSRCS += mips_initialstate.c mips_irq.c mips_lowputs.c
|
CMN_CSRCS += mips_initialstate.c mips_irq.c mips_lowputs.c
|
||||||
CMN_CSRCS += mips_mdelay.c mips_modifyreg8.c mips_modifyreg16.c mips_modifyreg32.c
|
CMN_CSRCS += mips_mdelay.c mips_modifyreg8.c mips_modifyreg16.c mips_modifyreg32.c
|
||||||
CMN_CSRCS += mips_nputs.c mips_releasepending.c mips_releasestack.c
|
CMN_CSRCS += mips_nputs.c mips_releasepending.c mips_releasestack.c
|
||||||
CMN_CSRCS += mips_schedulesigaction.c mips_sigdeliver.c
|
CMN_CSRCS += mips_schedulesigaction.c mips_sigdeliver.c
|
||||||
CMN_CSRCS += mips_stackframe.c mips_swint0.c mips_udelay.c mips_unblocktask.c
|
CMN_CSRCS += mips_stackframe.c mips_swint0.c mips_udelay.c mips_switchcontext.c
|
||||||
CMN_CSRCS += mips_usestack.c mips_vfork.c
|
CMN_CSRCS += mips_usestack.c mips_vfork.c
|
||||||
|
|
||||||
# Configuration dependent common files
|
# Configuration dependent common files
|
||||||
|
|||||||
@@ -25,13 +25,13 @@ HEAD_ASRC = pic32mz_head.S
|
|||||||
# Common MIPS files
|
# Common MIPS files
|
||||||
|
|
||||||
CMN_ASRCS = mips_syscall0.S vfork.S mips_cache.S
|
CMN_ASRCS = mips_syscall0.S vfork.S mips_cache.S
|
||||||
CMN_CSRCS = mips_allocateheap.c mips_assert.c mips_blocktask.c mips_copystate.c
|
CMN_CSRCS = mips_allocateheap.c mips_assert.c mips_copystate.c
|
||||||
CMN_CSRCS += mips_createstack.c mips_doirq.c mips_exit.c mips_initialize.c
|
CMN_CSRCS += mips_createstack.c mips_doirq.c mips_exit.c mips_initialize.c
|
||||||
CMN_CSRCS += mips_initialstate.c mips_irq.c mips_lowputs.c
|
CMN_CSRCS += mips_initialstate.c mips_irq.c mips_lowputs.c
|
||||||
CMN_CSRCS += mips_mdelay.c mips_modifyreg8.c mips_modifyreg16.c mips_modifyreg32.c
|
CMN_CSRCS += mips_mdelay.c mips_modifyreg8.c mips_modifyreg16.c mips_modifyreg32.c
|
||||||
CMN_CSRCS += mips_nputs.c mips_releasepending.c mips_releasestack.c
|
CMN_CSRCS += mips_nputs.c mips_releasepending.c mips_releasestack.c
|
||||||
CMN_CSRCS += mips_schedulesigaction.c mips_sigdeliver.c
|
CMN_CSRCS += mips_schedulesigaction.c mips_sigdeliver.c
|
||||||
CMN_CSRCS += mips_stackframe.c mips_swint0.c mips_udelay.c mips_unblocktask.c
|
CMN_CSRCS += mips_stackframe.c mips_swint0.c mips_udelay.c mips_switchcontext.c
|
||||||
CMN_CSRCS += mips_usestack.c mips_vfork.c
|
CMN_CSRCS += mips_usestack.c mips_vfork.c
|
||||||
|
|
||||||
# Configuration dependent common files
|
# Configuration dependent common files
|
||||||
|
|||||||
@@ -27,11 +27,11 @@ CMN_CSRCS += misoc_timerisr.c misoc_net.c misoc_flushcache.c
|
|||||||
|
|
||||||
CHIP_ASRCS = lm32_syscall.S
|
CHIP_ASRCS = lm32_syscall.S
|
||||||
|
|
||||||
CHIP_CSRCS = lm32_allocateheap.c lm32_assert.c lm32_blocktask.c
|
CHIP_CSRCS = lm32_allocateheap.c lm32_assert.c
|
||||||
CHIP_CSRCS += lm32_copystate.c lm32_createstack.c lm32_decodeirq.c
|
CHIP_CSRCS += lm32_copystate.c lm32_createstack.c lm32_decodeirq.c
|
||||||
CHIP_CSRCS += lm32_doirq.c lm32_dumpstate.c lm32_exit.c lm32_idle.c
|
CHIP_CSRCS += lm32_doirq.c lm32_dumpstate.c lm32_exit.c lm32_idle.c
|
||||||
CHIP_CSRCS += lm32_initialstate.c lm32_irq.c lm32_releasepending.c
|
CHIP_CSRCS += lm32_initialstate.c lm32_irq.c lm32_releasepending.c
|
||||||
CHIP_CSRCS += lm32_releasestack.c lm32_stackframe.c lm32_swint.c
|
CHIP_CSRCS += lm32_releasestack.c lm32_stackframe.c lm32_swint.c
|
||||||
CHIP_CSRCS += lm32_unblocktask.c
|
CHIP_CSRCS += lm32_switchcontext.c
|
||||||
CHIP_CSRCS += lm32_schedulesigaction.c lm32_sigdeliver.c
|
CHIP_CSRCS += lm32_schedulesigaction.c lm32_sigdeliver.c
|
||||||
CHIP_CSRCS += lm32_flushcache.c lm32_usetack.c
|
CHIP_CSRCS += lm32_flushcache.c lm32_usetack.c
|
||||||
|
|||||||
@@ -1,115 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
* arch/misoc/src/lm32/lm32_blocktask.c
|
|
||||||
*
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
|
||||||
* this work for additional information regarding copyright ownership. The
|
|
||||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
||||||
* "License"); you may not use this file except in compliance with the
|
|
||||||
* License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
* License for the specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Included Files
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
|
||||||
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <sched.h>
|
|
||||||
#include <syscall.h>
|
|
||||||
#include <assert.h>
|
|
||||||
#include <debug.h>
|
|
||||||
|
|
||||||
#include <nuttx/arch.h>
|
|
||||||
#include <nuttx/sched.h>
|
|
||||||
|
|
||||||
#include "sched/sched.h"
|
|
||||||
#include "group/group.h"
|
|
||||||
#include "lm32.h"
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Public Functions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: up_block_task
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* The currently executing task has already removed from ready-to-run list.
|
|
||||||
* Save its context and switch to the next running task at the head of the
|
|
||||||
* ready-to-run list.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* rtcb: Reference to the running task which is different to the
|
|
||||||
* task (next running task) at the head of the list.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
void up_block_task(struct tcb_s *rtcb)
|
|
||||||
{
|
|
||||||
/* Update scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_suspend_scheduler(rtcb);
|
|
||||||
|
|
||||||
/* Are we in an interrupt handler? */
|
|
||||||
|
|
||||||
if (g_current_regs)
|
|
||||||
{
|
|
||||||
/* Yes, then we have to do things differently.
|
|
||||||
* Just copy the g_current_regs into the OLD rtcb.
|
|
||||||
*/
|
|
||||||
|
|
||||||
misoc_savestate(rtcb->xcp.regs);
|
|
||||||
|
|
||||||
/* Restore the exception context of the rtcb at the (new) head
|
|
||||||
* of the ready-to-run task list.
|
|
||||||
*/
|
|
||||||
|
|
||||||
rtcb = this_task();
|
|
||||||
|
|
||||||
/* Reset scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_resume_scheduler(rtcb);
|
|
||||||
|
|
||||||
/* Then switch contexts. Any necessary address environment
|
|
||||||
* changes will be made when the interrupt returns.
|
|
||||||
*/
|
|
||||||
|
|
||||||
misoc_restorestate(rtcb->xcp.regs);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* No, then we will need to perform the user context switch */
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Get the context of the task at the head of the ready to
|
|
||||||
* run list.
|
|
||||||
*/
|
|
||||||
|
|
||||||
struct tcb_s *nexttcb = this_task();
|
|
||||||
|
|
||||||
/* Reset scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_resume_scheduler(nexttcb);
|
|
||||||
|
|
||||||
/* Then switch contexts */
|
|
||||||
|
|
||||||
misoc_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs);
|
|
||||||
|
|
||||||
/* misoc_switchcontext forces a context switch to the task at the
|
|
||||||
* head of the ready-to-run list. It does not 'return' in the
|
|
||||||
* normal sense. When it does return, it is because the blocked
|
|
||||||
* task is again ready to run and has execution priority.
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* arch/misoc/src/lm32/lm32_unblocktask.c
|
* arch/misoc/src/lm32/lm32_switchcontext.c
|
||||||
*
|
*
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
@@ -42,7 +42,7 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: up_unblock_task
|
* Name: up_switch_context
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* A task is currently in the ready-to-run list but has been prepped
|
* A task is currently in the ready-to-run list but has been prepped
|
||||||
@@ -55,7 +55,7 @@
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void up_unblock_task(struct tcb_s *tcb, struct tcb_s *rtcb)
|
void up_switch_context(struct tcb_s *tcb, struct tcb_s *rtcb)
|
||||||
{
|
{
|
||||||
/* Update scheduler parameters */
|
/* Update scheduler parameters */
|
||||||
|
|
||||||
@@ -27,11 +27,11 @@ CMN_CSRCS += misoc_timerisr.c misoc_net.c misoc_flushcache.c
|
|||||||
|
|
||||||
CHIP_ASRCS = minerva_syscall.S
|
CHIP_ASRCS = minerva_syscall.S
|
||||||
|
|
||||||
CHIP_CSRCS = minerva_allocateheap.c minerva_assert.c minerva_blocktask.c
|
CHIP_CSRCS = minerva_allocateheap.c minerva_assert.c
|
||||||
CHIP_CSRCS += minerva_copystate.c minerva_createstack.c minerva_decodeirq.c
|
CHIP_CSRCS += minerva_copystate.c minerva_createstack.c minerva_decodeirq.c
|
||||||
CHIP_CSRCS += minerva_doirq.c minerva_dumpstate.c minerva_exit.c minerva_idle.c
|
CHIP_CSRCS += minerva_doirq.c minerva_dumpstate.c minerva_exit.c minerva_idle.c
|
||||||
CHIP_CSRCS += minerva_initialstate.c minerva_irq.c minerva_releasepending.c
|
CHIP_CSRCS += minerva_initialstate.c minerva_irq.c minerva_releasepending.c
|
||||||
CHIP_CSRCS += minerva_releasestack.c minerva_stackframe.c minerva_swint.c
|
CHIP_CSRCS += minerva_releasestack.c minerva_stackframe.c minerva_swint.c
|
||||||
CHIP_CSRCS += minerva_unblocktask.c
|
CHIP_CSRCS += minerva_switchcontext.c
|
||||||
CHIP_CSRCS += minerva_schedulesigaction.c minerva_sigdeliver.c
|
CHIP_CSRCS += minerva_schedulesigaction.c minerva_sigdeliver.c
|
||||||
CHIP_CSRCS += minerva_flushcache.c minerva_doexceptions.c minerva_usetack.c
|
CHIP_CSRCS += minerva_flushcache.c minerva_doexceptions.c minerva_usetack.c
|
||||||
|
|||||||
@@ -1,115 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
* arch/misoc/src/minerva/minerva_blocktask.c
|
|
||||||
*
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
|
||||||
* this work for additional information regarding copyright ownership. The
|
|
||||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
||||||
* "License"); you may not use this file except in compliance with the
|
|
||||||
* License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
* License for the specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Included Files
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
|
||||||
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <sched.h>
|
|
||||||
#include <syscall.h>
|
|
||||||
#include <assert.h>
|
|
||||||
#include <debug.h>
|
|
||||||
|
|
||||||
#include <nuttx/arch.h>
|
|
||||||
#include <nuttx/sched.h>
|
|
||||||
|
|
||||||
#include "sched/sched.h"
|
|
||||||
#include "group/group.h"
|
|
||||||
#include "minerva.h"
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Public Functions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: up_block_task
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* The currently executing task has already removed from ready-to-run list.
|
|
||||||
* Save its context and switch to the next running task at the head of the
|
|
||||||
* ready-to-run list.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* rtcb: Reference to the running task which is different to the
|
|
||||||
* task (next running task) at the head of the list.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
void up_block_task(struct tcb_s *rtcb)
|
|
||||||
{
|
|
||||||
/* Update scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_suspend_scheduler(rtcb);
|
|
||||||
|
|
||||||
/* Are we in an interrupt handler? */
|
|
||||||
|
|
||||||
if (g_current_regs)
|
|
||||||
{
|
|
||||||
/* Yes, then we have to do things differently. Just copy the
|
|
||||||
* g_current_regs into the OLD rtcb.
|
|
||||||
*/
|
|
||||||
|
|
||||||
misoc_savestate(rtcb->xcp.regs);
|
|
||||||
|
|
||||||
/* Restore the exception context of the rtcb at the (new) head of
|
|
||||||
* the ready-to-run task list.
|
|
||||||
*/
|
|
||||||
|
|
||||||
rtcb = this_task();
|
|
||||||
|
|
||||||
/* Reset scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_resume_scheduler(rtcb);
|
|
||||||
|
|
||||||
/* Then switch contexts. Any necessary address environment changes
|
|
||||||
* will be made when the interrupt returns.
|
|
||||||
*/
|
|
||||||
|
|
||||||
misoc_restorestate(rtcb->xcp.regs);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* No, then we will need to perform the user context switch */
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Get the context of the task at the head of the ready to run
|
|
||||||
* list.
|
|
||||||
*/
|
|
||||||
|
|
||||||
struct tcb_s *nexttcb = this_task();
|
|
||||||
|
|
||||||
/* Reset scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_resume_scheduler(nexttcb);
|
|
||||||
|
|
||||||
/* Then switch contexts */
|
|
||||||
|
|
||||||
misoc_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs);
|
|
||||||
|
|
||||||
/* misoc_switchcontext forces a context switch to the task at the head
|
|
||||||
* of the ready-to-run list. It does not 'return' in the normal
|
|
||||||
* sense. When it does return, it is because the blocked task is
|
|
||||||
* again ready to run and has execution priority.
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+3
-3
@@ -1,5 +1,5 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* arch/misoc/src/minerva/minerva_unblocktask.c
|
* arch/misoc/src/minerva/minerva_switchcontext.c
|
||||||
*
|
*
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
@@ -42,7 +42,7 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: up_unblock_task
|
* Name: up_switch_context
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* A task is currently in the ready-to-run list but has been prepped
|
* A task is currently in the ready-to-run list but has been prepped
|
||||||
@@ -55,7 +55,7 @@
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void up_unblock_task(struct tcb_s *tcb, struct tcb_s *rtcb)
|
void up_switch_context(struct tcb_s *tcb, struct tcb_s *rtcb)
|
||||||
{
|
{
|
||||||
/* Update scheduler parameters */
|
/* Update scheduler parameters */
|
||||||
|
|
||||||
@@ -1,120 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
* arch/or1k/src/common/or1k_blocktask.c
|
|
||||||
*
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
|
||||||
* this work for additional information regarding copyright ownership. The
|
|
||||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
||||||
* "License"); you may not use this file except in compliance with the
|
|
||||||
* License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
* License for the specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Included Files
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
|
||||||
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <sched.h>
|
|
||||||
#include <assert.h>
|
|
||||||
#include <debug.h>
|
|
||||||
|
|
||||||
#include <nuttx/arch.h>
|
|
||||||
#include <nuttx/sched.h>
|
|
||||||
|
|
||||||
#include "sched/sched.h"
|
|
||||||
#include "group/group.h"
|
|
||||||
#include "or1k_internal.h"
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Public Functions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: up_block_task
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* The currently executing task has already removed from ready-to-run list.
|
|
||||||
* Save its context and switch to the next running task at the head of the
|
|
||||||
* ready-to-run list.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* rtcb: Reference to the running task which is different to the
|
|
||||||
* task (next running task) at the head of the list.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
void up_block_task(struct tcb_s *rtcb)
|
|
||||||
{
|
|
||||||
/* Update scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_suspend_scheduler(rtcb);
|
|
||||||
|
|
||||||
/* Are we in an interrupt handler? */
|
|
||||||
|
|
||||||
if (CURRENT_REGS)
|
|
||||||
{
|
|
||||||
/* Yes, then we have to do things differently.
|
|
||||||
* Just copy the CURRENT_REGS into the OLD rtcb.
|
|
||||||
*/
|
|
||||||
|
|
||||||
or1k_savestate(rtcb->xcp.regs);
|
|
||||||
|
|
||||||
/* Restore the exception context of the rtcb at the (new) head
|
|
||||||
* of the ready-to-run task list.
|
|
||||||
*/
|
|
||||||
|
|
||||||
rtcb = this_task();
|
|
||||||
|
|
||||||
/* Reset scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_resume_scheduler(rtcb);
|
|
||||||
|
|
||||||
/* Then switch contexts. Any necessary address environment
|
|
||||||
* changes will be made when the interrupt returns.
|
|
||||||
*/
|
|
||||||
|
|
||||||
or1k_restorestate(rtcb->xcp.regs);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Copy the user C context into the TCB at the (old) head of the
|
|
||||||
* ready-to-run Task list. if up_saveusercontext returns a non-zero
|
|
||||||
* value, then this is really the previously running task restarting!
|
|
||||||
*/
|
|
||||||
|
|
||||||
else if (!up_saveusercontext(rtcb->xcp.regs))
|
|
||||||
{
|
|
||||||
/* Restore the exception context of the rtcb at the (new) head
|
|
||||||
* of the ready-to-run task list.
|
|
||||||
*/
|
|
||||||
|
|
||||||
rtcb = this_task();
|
|
||||||
|
|
||||||
#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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
group_addrenv(rtcb);
|
|
||||||
#endif
|
|
||||||
/* Reset scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_resume_scheduler(rtcb);
|
|
||||||
|
|
||||||
/* Then switch contexts */
|
|
||||||
|
|
||||||
or1k_fullcontextrestore(rtcb->xcp.regs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* arch/or1k/src/common/or1k_unblocktask.c
|
* arch/or1k/src/common/or1k_switchcontext.c
|
||||||
*
|
*
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
@@ -40,7 +40,7 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: up_unblock_task
|
* Name: up_switch_context
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* A task is currently in the ready-to-run list but has been prepped
|
* A task is currently in the ready-to-run list but has been prepped
|
||||||
@@ -53,7 +53,7 @@
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void up_unblock_task(struct tcb_s *tcb, struct tcb_s *rtcb)
|
void up_switch_context(struct tcb_s *tcb, struct tcb_s *rtcb)
|
||||||
{
|
{
|
||||||
/* Update scheduler parameters */
|
/* Update scheduler parameters */
|
||||||
|
|
||||||
@@ -29,8 +29,7 @@ CMN_CSRCS = or1k_initialize.c \
|
|||||||
or1k_releasestack.c \
|
or1k_releasestack.c \
|
||||||
or1k_stackframe.c \
|
or1k_stackframe.c \
|
||||||
or1k_initialstate.c \
|
or1k_initialstate.c \
|
||||||
or1k_blocktask.c \
|
or1k_switchcontext.c \
|
||||||
or1k_unblocktask.c \
|
|
||||||
or1k_releasepending.c \
|
or1k_releasepending.c \
|
||||||
or1k_schedulesigaction.c \
|
or1k_schedulesigaction.c \
|
||||||
or1k_copyfullstate.c \
|
or1k_copyfullstate.c \
|
||||||
|
|||||||
@@ -1,120 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
* arch/renesas/src/common/renesas_blocktask.c
|
|
||||||
*
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
|
||||||
* this work for additional information regarding copyright ownership. The
|
|
||||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
||||||
* "License"); you may not use this file except in compliance with the
|
|
||||||
* License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
* License for the specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Included Files
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
|
||||||
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <sched.h>
|
|
||||||
#include <assert.h>
|
|
||||||
#include <debug.h>
|
|
||||||
#include <nuttx/arch.h>
|
|
||||||
#include <nuttx/sched.h>
|
|
||||||
|
|
||||||
#include "sched/sched.h"
|
|
||||||
#include "group/group.h"
|
|
||||||
#include "renesas_internal.h"
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Public Functions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: up_block_task
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* The currently executing task has already removed from ready-to-run list.
|
|
||||||
* Save its context and switch to the next running task at the head of the
|
|
||||||
* ready-to-run list.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* rtcb: Reference to the running task which is different to the
|
|
||||||
* task (next running task) at the head of the list.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
void up_block_task(struct tcb_s *rtcb)
|
|
||||||
{
|
|
||||||
/* Update scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_suspend_scheduler(rtcb);
|
|
||||||
|
|
||||||
/* Are we in an interrupt handler? */
|
|
||||||
|
|
||||||
if (g_current_regs)
|
|
||||||
{
|
|
||||||
/* Yes, then we have to do things differently.
|
|
||||||
* Just copy the g_current_regs into the OLD rtcb.
|
|
||||||
*/
|
|
||||||
|
|
||||||
renesas_savestate(rtcb->xcp.regs);
|
|
||||||
|
|
||||||
/* Restore the exception context of the rtcb at the (new) head
|
|
||||||
* of the ready-to-run task list.
|
|
||||||
*/
|
|
||||||
|
|
||||||
rtcb = this_task();
|
|
||||||
|
|
||||||
/* Reset scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_resume_scheduler(rtcb);
|
|
||||||
|
|
||||||
/* Then switch contexts. Any necessary address environment
|
|
||||||
* changes will be made when the interrupt returns.
|
|
||||||
*/
|
|
||||||
|
|
||||||
g_current_regs = rtcb->xcp.regs;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Copy the user C context into the TCB at the (old) head of the
|
|
||||||
* ready-to-run Task list. if up_saveusercontext returns a non-zero
|
|
||||||
* value, then this is really the previously running task
|
|
||||||
* restarting!
|
|
||||||
*/
|
|
||||||
|
|
||||||
else if (!up_saveusercontext(rtcb->xcp.regs))
|
|
||||||
{
|
|
||||||
/* Restore the exception context of the rtcb at the (new) head
|
|
||||||
* of the ready-to-run task list.
|
|
||||||
*/
|
|
||||||
|
|
||||||
rtcb = this_task();
|
|
||||||
|
|
||||||
#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.
|
|
||||||
*/
|
|
||||||
|
|
||||||
group_addrenv(rtcb);
|
|
||||||
#endif
|
|
||||||
/* Reset scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_resume_scheduler(rtcb);
|
|
||||||
|
|
||||||
/* Then switch contexts */
|
|
||||||
|
|
||||||
renesas_fullcontextrestore(rtcb->xcp.regs);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+3
-3
@@ -1,5 +1,5 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* arch/renesas/src/common/renesas_unblocktask.c
|
* arch/renesas/src/common/renesas_switchcontext.c
|
||||||
*
|
*
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
@@ -40,7 +40,7 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: up_unblock_task
|
* Name: up_switch_context
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* A task is currently in the ready-to-run list but has been prepped
|
* A task is currently in the ready-to-run list but has been prepped
|
||||||
@@ -53,7 +53,7 @@
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void up_unblock_task(struct tcb_s *tcb, struct tcb_s *rtcb)
|
void up_switch_context(struct tcb_s *tcb, struct tcb_s *rtcb)
|
||||||
{
|
{
|
||||||
/* Update scheduler parameters */
|
/* Update scheduler parameters */
|
||||||
|
|
||||||
@@ -20,11 +20,11 @@
|
|||||||
|
|
||||||
HEAD_ASRC = m16c_head.S
|
HEAD_ASRC = m16c_head.S
|
||||||
|
|
||||||
CMN_CSRCS = renesas_allocateheap.c renesas_assert.c renesas_blocktask.c
|
CMN_CSRCS = renesas_allocateheap.c renesas_assert.c
|
||||||
CMN_CSRCS += renesas_createstack.c renesas_doirq.c renesas_exit.c renesas_idle.c renesas_initialize.c
|
CMN_CSRCS += renesas_createstack.c renesas_doirq.c renesas_exit.c renesas_idle.c renesas_initialize.c
|
||||||
CMN_CSRCS += renesas_lowputs.c renesas_mdelay.c renesas_nputs.c
|
CMN_CSRCS += renesas_lowputs.c renesas_mdelay.c renesas_nputs.c
|
||||||
CMN_CSRCS += renesas_releasepending.c renesas_releasestack.c
|
CMN_CSRCS += renesas_releasepending.c renesas_releasestack.c
|
||||||
CMN_CSRCS += renesas_stackframe.c renesas_udelay.c renesas_unblocktask.c renesas_usestack.c
|
CMN_CSRCS += renesas_stackframe.c renesas_udelay.c renesas_switchcontext.c renesas_usestack.c
|
||||||
|
|
||||||
CHIP_ASRCS = m16c_vectors.S
|
CHIP_ASRCS = m16c_vectors.S
|
||||||
CHIP_CSRCS = m16c_initialstate.c m16c_copystate.c m16c_lowputc.c m16c_irq.c
|
CHIP_CSRCS = m16c_initialstate.c m16c_copystate.c m16c_lowputc.c m16c_irq.c
|
||||||
|
|||||||
@@ -20,11 +20,11 @@
|
|||||||
|
|
||||||
HEAD_ASRC = rx65n_head.S
|
HEAD_ASRC = rx65n_head.S
|
||||||
|
|
||||||
CMN_CSRCS = renesas_allocateheap.c renesas_assert.c renesas_blocktask.c
|
CMN_CSRCS = renesas_allocateheap.c renesas_assert.c
|
||||||
CMN_CSRCS += renesas_createstack.c renesas_doirq.c renesas_exit.c renesas_idle.c renesas_initialize.c
|
CMN_CSRCS += renesas_createstack.c renesas_doirq.c renesas_exit.c renesas_idle.c renesas_initialize.c
|
||||||
CMN_CSRCS += renesas_lowputs.c renesas_mdelay.c renesas_nputs.c
|
CMN_CSRCS += renesas_lowputs.c renesas_mdelay.c renesas_nputs.c
|
||||||
CMN_CSRCS += renesas_releasepending.c renesas_releasestack.c
|
CMN_CSRCS += renesas_releasepending.c renesas_releasestack.c
|
||||||
CMN_CSRCS += renesas_stackframe.c renesas_udelay.c renesas_unblocktask.c renesas_usestack.c
|
CMN_CSRCS += renesas_stackframe.c renesas_udelay.c renesas_switchcontext.c renesas_usestack.c
|
||||||
|
|
||||||
CHIP_ASRCS = rx65n_vector.S
|
CHIP_ASRCS = rx65n_vector.S
|
||||||
CHIP_CSRCS = rx65n_lowputc.c rx65n_serial.c rx65n_copystate.c rx65n_irq.c
|
CHIP_CSRCS = rx65n_lowputc.c rx65n_serial.c rx65n_copystate.c rx65n_irq.c
|
||||||
|
|||||||
@@ -20,13 +20,13 @@
|
|||||||
|
|
||||||
HEAD_ASRC = sh1_head.S
|
HEAD_ASRC = sh1_head.S
|
||||||
|
|
||||||
CMN_CSRCS = renesas_allocateheap.c renesas_assert.c renesas_blocktask.c
|
CMN_CSRCS = renesas_allocateheap.c renesas_assert.c
|
||||||
CMN_CSRCS += renesas_createstack.c renesas_doirq.c renesas_exit.c renesas_idle.c renesas_initialize.c
|
CMN_CSRCS += renesas_createstack.c renesas_doirq.c renesas_exit.c renesas_idle.c renesas_initialize.c
|
||||||
CMN_CSRCS += renesas_initialstate.c renesas_lowputs.c
|
CMN_CSRCS += renesas_initialstate.c renesas_lowputs.c
|
||||||
CMN_CSRCS += renesas_mdelay.c renesas_nputs.c renesas_releasepending.c renesas_releasestack.c
|
CMN_CSRCS += renesas_mdelay.c renesas_nputs.c renesas_releasepending.c renesas_releasestack.c
|
||||||
CMN_CSRCS += renesas_stackframe.c renesas_udelay.c
|
CMN_CSRCS += renesas_stackframe.c renesas_udelay.c
|
||||||
CMN_CSRCS += sh1_schedulesigaction.c sh1_sigdeliver.c
|
CMN_CSRCS += sh1_schedulesigaction.c sh1_sigdeliver.c
|
||||||
CMN_CSRCS += renesas_unblocktask.c renesas_usestack.c
|
CMN_CSRCS += renesas_switchcontext.c renesas_usestack.c
|
||||||
|
|
||||||
CHIP_ASRCS = sh1_vector.S sh1_saveusercontext.S
|
CHIP_ASRCS = sh1_vector.S sh1_saveusercontext.S
|
||||||
CHIP_CSRCS = sh1_lowputc.c sh1_irq.c sh1_serial.c sh1_initialstate.c
|
CHIP_CSRCS = sh1_lowputc.c sh1_irq.c sh1_serial.c sh1_initialstate.c
|
||||||
|
|||||||
@@ -28,11 +28,11 @@ CMN_ASRCS += riscv_vectors.S riscv_exception_common.S riscv_mhartid.S
|
|||||||
# Specify C code within the common directory to be included
|
# Specify C code within the common directory to be included
|
||||||
CMN_CSRCS += riscv_initialize.c riscv_swint.c riscv_mtimer.c
|
CMN_CSRCS += riscv_initialize.c riscv_swint.c riscv_mtimer.c
|
||||||
CMN_CSRCS += riscv_allocateheap.c riscv_createstack.c riscv_exit.c
|
CMN_CSRCS += riscv_allocateheap.c riscv_createstack.c riscv_exit.c
|
||||||
CMN_CSRCS += riscv_assert.c riscv_blocktask.c riscv_copystate.c riscv_initialstate.c
|
CMN_CSRCS += riscv_assert.c riscv_copystate.c riscv_initialstate.c
|
||||||
CMN_CSRCS += riscv_modifyreg32.c riscv_nputs.c
|
CMN_CSRCS += riscv_modifyreg32.c riscv_nputs.c
|
||||||
CMN_CSRCS += riscv_releasepending.c
|
CMN_CSRCS += riscv_releasepending.c
|
||||||
CMN_CSRCS += riscv_releasestack.c riscv_stackframe.c riscv_schedulesigaction.c
|
CMN_CSRCS += riscv_releasestack.c riscv_stackframe.c riscv_schedulesigaction.c
|
||||||
CMN_CSRCS += riscv_sigdeliver.c riscv_unblocktask.c riscv_usestack.c
|
CMN_CSRCS += riscv_sigdeliver.c riscv_switchcontext.c riscv_usestack.c
|
||||||
CMN_CSRCS += riscv_idle.c riscv_tcbinfo.c riscv_cpuidlestack.c
|
CMN_CSRCS += riscv_idle.c riscv_tcbinfo.c riscv_cpuidlestack.c
|
||||||
CMN_CSRCS += riscv_exception.c riscv_getnewintctx.c riscv_doirq.c
|
CMN_CSRCS += riscv_exception.c riscv_getnewintctx.c riscv_doirq.c
|
||||||
CMN_CSRCS += riscv_saveusercontext.c
|
CMN_CSRCS += riscv_saveusercontext.c
|
||||||
|
|||||||
@@ -1,115 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
* arch/risc-v/src/common/riscv_blocktask.c
|
|
||||||
*
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
|
||||||
* this work for additional information regarding copyright ownership. The
|
|
||||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
||||||
* "License"); you may not use this file except in compliance with the
|
|
||||||
* License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
* License for the specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Included Files
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
|
||||||
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <sched.h>
|
|
||||||
#include <syscall.h>
|
|
||||||
#include <assert.h>
|
|
||||||
#include <debug.h>
|
|
||||||
|
|
||||||
#include <nuttx/arch.h>
|
|
||||||
#include <nuttx/sched.h>
|
|
||||||
|
|
||||||
#include "sched/sched.h"
|
|
||||||
#include "group/group.h"
|
|
||||||
#include "riscv_internal.h"
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Public Functions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: up_block_task
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* The currently executing task has already removed from ready-to-run list.
|
|
||||||
* Save its context and switch to the next running task at the head of the
|
|
||||||
* ready-to-run list.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* rtcb: Reference to the running task which is different to the
|
|
||||||
* task (next running task) at the head of the list.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
void up_block_task(struct tcb_s *rtcb)
|
|
||||||
{
|
|
||||||
/* Update scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_suspend_scheduler(rtcb);
|
|
||||||
|
|
||||||
/* Are we in an interrupt handler? */
|
|
||||||
|
|
||||||
if (CURRENT_REGS)
|
|
||||||
{
|
|
||||||
/* Yes, then we have to do things differently.
|
|
||||||
* Just copy the CURRENT_REGS into the OLD rtcb.
|
|
||||||
*/
|
|
||||||
|
|
||||||
riscv_savestate(rtcb->xcp.regs);
|
|
||||||
|
|
||||||
/* Restore the exception context of the rtcb at the (new) head
|
|
||||||
* of the ready-to-run task list.
|
|
||||||
*/
|
|
||||||
|
|
||||||
rtcb = this_task();
|
|
||||||
|
|
||||||
/* Reset scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_resume_scheduler(rtcb);
|
|
||||||
|
|
||||||
/* Then switch contexts. Any necessary address environment
|
|
||||||
* changes will be made when the interrupt returns.
|
|
||||||
*/
|
|
||||||
|
|
||||||
riscv_restorestate(rtcb->xcp.regs);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* No, then we will need to perform the user context switch */
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Get the context of the task at the head of the ready to
|
|
||||||
* run list.
|
|
||||||
*/
|
|
||||||
|
|
||||||
struct tcb_s *nexttcb = this_task();
|
|
||||||
|
|
||||||
/* Reset scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_resume_scheduler(nexttcb);
|
|
||||||
|
|
||||||
/* Then switch contexts */
|
|
||||||
|
|
||||||
riscv_switchcontext(&rtcb->xcp.regs, nexttcb->xcp.regs);
|
|
||||||
|
|
||||||
/* riscv_switchcontext forces a context switch to the task at the
|
|
||||||
* head of the ready-to-run list. It does not 'return' in the
|
|
||||||
* normal sense. When it does return, it is because the blocked
|
|
||||||
* task is again ready to run and has execution priority.
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+3
-3
@@ -1,5 +1,5 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* arch/risc-v/src/common/riscv_unblocktask.c
|
* arch/risc-v/src/common/riscv_switchcontext.c
|
||||||
*
|
*
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
@@ -42,7 +42,7 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: up_unblock_task
|
* Name: up_switch_context
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* A task is currently in the ready-to-run list but has been prepped
|
* A task is currently in the ready-to-run list but has been prepped
|
||||||
@@ -55,7 +55,7 @@
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void up_unblock_task(struct tcb_s *tcb, struct tcb_s *rtcb)
|
void up_switch_context(struct tcb_s *tcb, struct tcb_s *rtcb)
|
||||||
{
|
{
|
||||||
/* Update scheduler parameters */
|
/* Update scheduler parameters */
|
||||||
|
|
||||||
@@ -59,7 +59,7 @@ AOBJS = $(ASRCS:.S=$(OBJEXT))
|
|||||||
|
|
||||||
CSRCS = sim_initialize.c sim_idle.c sim_interruptcontext.c sim_initialstate.c
|
CSRCS = sim_initialize.c sim_idle.c sim_interruptcontext.c sim_initialstate.c
|
||||||
CSRCS += sim_createstack.c sim_usestack.c sim_releasestack.c sim_stackframe.c
|
CSRCS += sim_createstack.c sim_usestack.c sim_releasestack.c sim_stackframe.c
|
||||||
CSRCS += sim_unblocktask.c sim_blocktask.c sim_releasepending.c
|
CSRCS += sim_switchcontext.c sim_releasepending.c
|
||||||
CSRCS += sim_exit.c sim_schedulesigaction.c
|
CSRCS += sim_exit.c sim_schedulesigaction.c
|
||||||
CSRCS += sim_heap.c sim_uart.c sim_assert.c sim_nputs.c
|
CSRCS += sim_heap.c sim_uart.c sim_assert.c sim_nputs.c
|
||||||
CSRCS += sim_copyfullstate.c
|
CSRCS += sim_copyfullstate.c
|
||||||
|
|||||||
@@ -1,104 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
* arch/sim/src/sim/sim_blocktask.c
|
|
||||||
*
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
|
||||||
* this work for additional information regarding copyright ownership. The
|
|
||||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
||||||
* "License"); you may not use this file except in compliance with the
|
|
||||||
* License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
* License for the specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Included Files
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
|
||||||
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <sched.h>
|
|
||||||
#include <assert.h>
|
|
||||||
#include <debug.h>
|
|
||||||
|
|
||||||
#include <nuttx/arch.h>
|
|
||||||
#include <nuttx/sched.h>
|
|
||||||
|
|
||||||
#include "sched/sched.h"
|
|
||||||
#include "sim_internal.h"
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Public Functions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: up_block_task
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* The currently executing task has already removed from ready-to-run list.
|
|
||||||
* Save its context and switch to the next running task at the head of the
|
|
||||||
* ready-to-run list.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* rtcb: Reference to the running task which is different to the
|
|
||||||
* task (next running task) at the head of the list.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
void up_block_task(struct tcb_s *rtcb)
|
|
||||||
{
|
|
||||||
/* Update scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_suspend_scheduler(rtcb);
|
|
||||||
|
|
||||||
/* TODO */
|
|
||||||
|
|
||||||
if (CURRENT_REGS)
|
|
||||||
{
|
|
||||||
ASSERT(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Copy the exception context into the TCB at the (old) head of the
|
|
||||||
* ready-to-run Task list. if setjmp returns a non-zero
|
|
||||||
* value, then this is really the previously running task restarting!
|
|
||||||
*/
|
|
||||||
|
|
||||||
else if (!setjmp(rtcb->xcp.regs))
|
|
||||||
{
|
|
||||||
/* Restore the exception context of the rtcb at the (new) head
|
|
||||||
* of the ready-to-run task list.
|
|
||||||
*/
|
|
||||||
|
|
||||||
rtcb = this_task();
|
|
||||||
sinfo("New Active Task TCB=%p\n", rtcb);
|
|
||||||
|
|
||||||
/* Reset scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_resume_scheduler(rtcb);
|
|
||||||
|
|
||||||
/* Restore the cpu lock */
|
|
||||||
|
|
||||||
restore_critical_section();
|
|
||||||
|
|
||||||
/* Then switch contexts */
|
|
||||||
|
|
||||||
longjmp(rtcb->xcp.regs, 1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* The way that we handle signals in the simulation is kind of
|
|
||||||
* a kludge. This would be unsafe in a truly multi-threaded,
|
|
||||||
* interrupt driven environment.
|
|
||||||
*/
|
|
||||||
|
|
||||||
sim_sigdeliver();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* arch/sim/src/sim/sim_unblocktask.c
|
* arch/sim/src/sim/sim_switchcontext.c
|
||||||
*
|
*
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
@@ -39,7 +39,7 @@
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: up_unblock_task
|
* Name: up_switch_context
|
||||||
*
|
*
|
||||||
* Description:
|
* Description:
|
||||||
* A task is currently in the ready-to-run list but has been prepped
|
* A task is currently in the ready-to-run list but has been prepped
|
||||||
@@ -52,7 +52,7 @@
|
|||||||
*
|
*
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
void up_unblock_task(struct tcb_s *tcb, struct tcb_s *rtcb)
|
void up_switch_context(struct tcb_s *tcb, struct tcb_s *rtcb)
|
||||||
{
|
{
|
||||||
sinfo("Unblocking TCB=%p\n", tcb);
|
sinfo("Unblocking TCB=%p\n", tcb);
|
||||||
|
|
||||||
@@ -23,11 +23,11 @@
|
|||||||
include common/Make.defs
|
include common/Make.defs
|
||||||
|
|
||||||
CMN_ASRCS += sparc_v8_syscall.S
|
CMN_ASRCS += sparc_v8_syscall.S
|
||||||
CMN_CSRCS += sparc_v8_blocktask.c sparc_v8_copystate.c sparc_v8_doirq.c
|
CMN_CSRCS += sparc_v8_copystate.c sparc_v8_doirq.c
|
||||||
CMN_CSRCS += sparc_v8_initialstate.c sparc_v8_irq.c
|
CMN_CSRCS += sparc_v8_initialstate.c sparc_v8_irq.c
|
||||||
CMN_CSRCS += sparc_v8_releasepending.c sparc_v8_schedulesigaction.c
|
CMN_CSRCS += sparc_v8_releasepending.c sparc_v8_schedulesigaction.c
|
||||||
CMN_CSRCS += sparc_v8_sigdeliver.c sparc_v8_swint1.c sparc_v8_systemreset.c
|
CMN_CSRCS += sparc_v8_sigdeliver.c sparc_v8_swint1.c sparc_v8_systemreset.c
|
||||||
CMN_CSRCS += sparc_v8_unblocktask.c
|
CMN_CSRCS += sparc_v8_switchcontext.c
|
||||||
|
|
||||||
# Configuration-dependent common files
|
# Configuration-dependent common files
|
||||||
|
|
||||||
|
|||||||
@@ -1,115 +0,0 @@
|
|||||||
/****************************************************************************
|
|
||||||
* arch/sparc/src/sparc_v8/sparc_v8_blocktask.c
|
|
||||||
*
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
||||||
* contributor license agreements. See the NOTICE file distributed with
|
|
||||||
* this work for additional information regarding copyright ownership. The
|
|
||||||
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
||||||
* "License"); you may not use this file except in compliance with the
|
|
||||||
* License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
||||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
||||||
* License for the specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Included Files
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
#include <nuttx/config.h>
|
|
||||||
|
|
||||||
#include <stdbool.h>
|
|
||||||
#include <sched.h>
|
|
||||||
#include <syscall.h>
|
|
||||||
#include <assert.h>
|
|
||||||
#include <debug.h>
|
|
||||||
|
|
||||||
#include <nuttx/arch.h>
|
|
||||||
#include <nuttx/sched.h>
|
|
||||||
|
|
||||||
#include "sched/sched.h"
|
|
||||||
#include "group/group.h"
|
|
||||||
#include "sparc_internal.h"
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Public Functions
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
/****************************************************************************
|
|
||||||
* Name: up_block_task
|
|
||||||
*
|
|
||||||
* Description:
|
|
||||||
* The currently executing task has already removed from ready-to-run list.
|
|
||||||
* Save its context and switch to the next running task at the head of the
|
|
||||||
* ready-to-run list.
|
|
||||||
*
|
|
||||||
* Input Parameters:
|
|
||||||
* rtcb: Reference to the running task which is different to the
|
|
||||||
* task (next running task) at the head of the list.
|
|
||||||
*
|
|
||||||
****************************************************************************/
|
|
||||||
|
|
||||||
void up_block_task(struct tcb_s *rtcb)
|
|
||||||
{
|
|
||||||
/* Update scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_suspend_scheduler(rtcb);
|
|
||||||
|
|
||||||
/* Are we in an interrupt handler? */
|
|
||||||
|
|
||||||
if (CURRENT_REGS)
|
|
||||||
{
|
|
||||||
/* Yes, then we have to do things differently.
|
|
||||||
* Just copy the CURRENT_REGS into the OLD rtcb.
|
|
||||||
*/
|
|
||||||
|
|
||||||
sparc_savestate(rtcb->xcp.regs);
|
|
||||||
|
|
||||||
/* Restore the exception context of the rtcb at the (new) head
|
|
||||||
* of the ready-to-run task list.
|
|
||||||
*/
|
|
||||||
|
|
||||||
rtcb = this_task();
|
|
||||||
|
|
||||||
/* Reset scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_resume_scheduler(rtcb);
|
|
||||||
|
|
||||||
/* Then switch contexts. Any necessary address environment
|
|
||||||
* changes will be made when the interrupt returns.
|
|
||||||
*/
|
|
||||||
|
|
||||||
sparc_restorestate(rtcb->xcp.regs);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* No, then we will need to perform the user context switch */
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
/* Get the context of the task at the head of the ready to
|
|
||||||
* run list.
|
|
||||||
*/
|
|
||||||
|
|
||||||
struct tcb_s *nexttcb = this_task();
|
|
||||||
|
|
||||||
/* Reset scheduler parameters */
|
|
||||||
|
|
||||||
nxsched_resume_scheduler(nexttcb);
|
|
||||||
|
|
||||||
/* Then switch contexts */
|
|
||||||
|
|
||||||
sparc_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs);
|
|
||||||
|
|
||||||
/* sparc_switchcontext forces a context switch to the task at the
|
|
||||||
* head of the ready-to-run list. It does not 'return' in the
|
|
||||||
* normal sense. When it does return, it is because the blocked
|
|
||||||
* task is again ready to run and has execution priority.
|
|
||||||
*/
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user