ARM: Replace explicit references to g_readytorun with indirect references via the macro this_task()

This commit is contained in:
Gregory Nutt 2016-02-06 13:41:28 -06:00
parent 03b382d443
commit ed4e3c0a9e
42 changed files with 162 additions and 246 deletions

View file

@ -198,7 +198,7 @@ static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg)
#ifdef CONFIG_ARCH_STACKDUMP
static void up_dumpstate(void)
{
struct tcb_s *rtcb = (struct tcb_s *)g_readytorun.head;
struct tcb_s *rtcb = this_task();
uint32_t sp = up_getsp();
uint32_t ustackbase;
uint32_t ustacksize;
@ -310,7 +310,7 @@ static void _up_assert(int errorcode)
{
/* Are we in an interrupt handler or the idle task? */
if (current_regs || ((struct tcb_s *)g_readytorun.head)->pid == 0)
if (current_regs || this_task()->pid == 0)
{
(void)irqsave();
for (; ; )
@ -340,7 +340,7 @@ static void _up_assert(int errorcode)
void up_assert(const uint8_t *filename, int lineno)
{
#ifdef CONFIG_PRINT_TASKNAME
struct tcb_s *rtcb = (struct tcb_s *)g_readytorun.head;
struct tcb_s *rtcb = this_task();
#endif
board_autoled_on(LED_ASSERTION);
@ -356,7 +356,7 @@ void up_assert(const uint8_t *filename, int lineno)
up_dumpstate();
#ifdef CONFIG_BOARD_CRASHDUMP
board_crashdump(up_getsp(), g_readytorun.head, filename, lineno);
board_crashdump(up_getsp(), this_task(), filename, lineno);
#endif
_up_assert(EXIT_FAILURE);

View file

@ -76,7 +76,7 @@
void up_block_task(struct tcb_s *tcb, tstate_t task_state)
{
struct tcb_s *rtcb = (struct tcb_s *)g_readytorun.head;
struct tcb_s *rtcb = this_task();
bool switch_needed;
/* Verify that the context switch can be performed */
@ -97,7 +97,7 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state)
sched_addblocked(tcb, (tstate_t)task_state);
/* If there are any pending tasks, then add them to the g_readytorun
/* If there are any pending tasks, then add them to the ready-to-run
* task list now
*/
@ -125,10 +125,10 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state)
up_savestate(rtcb->xcp.regs);
/* Restore the exception context of the rtcb at the (new) head
* of the g_readytorun task list.
* of the ready-to-run task list.
*/
rtcb = (struct tcb_s *)g_readytorun.head;
rtcb = this_task();
/* Reset scheduler parameters */
@ -142,17 +142,17 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state)
}
/* Copy the user C context into the TCB at the (old) head of the
* g_readytorun Task list. if up_saveusercontext returns a non-zero
* 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 g_readytorun task list.
* of the ready-to-run task list.
*/
rtcb = (struct tcb_s *)g_readytorun.head;
rtcb = this_task();
#ifdef CONFIG_ARCH_ADDRENV
/* Make sure that the address environment for the previously

View file

@ -104,7 +104,7 @@
#ifdef CONFIG_PAGING
void up_dataabort(uint32_t *regs, uint32_t far, uint32_t fsr)
{
FAR struct tcb_s *tcb = (FAR struct tcb_s *)g_readytorun.head;
struct tcb_s *tcb = this_task();
#ifdef CONFIG_PAGING
uint32_t *savestate;

View file

@ -121,7 +121,7 @@ void up_prefetchabort(uint32_t *regs)
* prefetch and data aborts.
*/
FAR struct tcb_s *tcb = (FAR struct tcb_s *)g_readytorun.head;
struct tcb_s *tcb = this_task();
tcb->xcp.far = regs[REG_R15];
/* Call pg_miss() to schedule the page fill. A consequences of this

View file

@ -65,11 +65,11 @@
void up_release_pending(void)
{
struct tcb_s *rtcb = (struct tcb_s *)g_readytorun.head;
struct tcb_s *rtcb = this_task();
slldbg("From TCB=%p\n", rtcb);
/* Merge the g_pendingtasks list into the g_readytorun task list */
/* Merge the g_pendingtasks list into the ready-to-run task list */
/* sched_lock(); */
if (sched_mergepending())
@ -93,10 +93,10 @@ void up_release_pending(void)
up_savestate(rtcb->xcp.regs);
/* Restore the exception context of the rtcb at the (new) head
* of the g_readytorun task list.
* of the ready-to-run task list.
*/
rtcb = (struct tcb_s *)g_readytorun.head;
rtcb = this_task();
/* Update scheduler parameters */
@ -118,10 +118,10 @@ void up_release_pending(void)
else if (!up_saveusercontext(rtcb->xcp.regs))
{
/* Restore the exception context of the rtcb at the (new) head
* of the g_readytorun task list.
* of the ready-to-run task list.
*/
rtcb = (struct tcb_s *)g_readytorun.head;
rtcb = this_task();
#ifdef CONFIG_ARCH_ADDRENV
/* Make sure that the address environment for the previously

View file

@ -92,7 +92,7 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
}
else
{
struct tcb_s *rtcb = (struct tcb_s *)g_readytorun.head;
struct tcb_s *rtcb = this_task();
bool switch_needed;
slldbg("TCB=%p PRI=%d\n", tcb, priority);
@ -147,10 +147,10 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
up_savestate(rtcb->xcp.regs);
/* Restore the exception context of the rtcb at the (new) head
* of the g_readytorun task list.
* of the ready-to-run task list.
*/
rtcb = (struct tcb_s *)g_readytorun.head;
rtcb = this_task();
/* Update scheduler parameters */
@ -164,17 +164,17 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
}
/* Copy the exception context into the TCB at the (old) head of the
* g_readytorun Task list. if up_saveusercontext returns a non-zero
* 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 g_readytorun task list.
* of the ready-to-run task list.
*/
rtcb = (struct tcb_s *)g_readytorun.head;
rtcb = this_task();
#ifdef CONFIG_ARCH_ADDRENV
/* Make sure that the address environment for the previously

View file

@ -119,9 +119,9 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* being delivered to the currently executing task.
*/
sdbg("rtcb=0x%p current_regs=0x%p\n", g_readytorun.head, current_regs);
sdbg("rtcb=0x%p current_regs=0x%p\n", this_task(), current_regs);
if (tcb == (struct tcb_s *)g_readytorun.head)
if (tcb == this_task())
{
/* CASE 1: We are not in an interrupt handler and
* a task is signalling itself for some reason.
@ -143,7 +143,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* logic would fail in the strange case where we are in an
* interrupt handler, the thread is signalling itself, but
* a context switch to another task has occurred so that
* current_regs does not refer to the thread at g_readytorun.head!
* current_regs does not refer to the thread of this_task()!
*/
else

View file

@ -82,7 +82,7 @@
void up_sigdeliver(void)
{
struct tcb_s *rtcb = (struct tcb_s *)g_readytorun.head;
struct tcb_s *rtcb = this_task();
uint32_t regs[XCPTCONTEXT_REGS];
sig_deliver_t sigdeliver;

View file

@ -71,7 +71,7 @@
void up_unblock_task(struct tcb_s *tcb)
{
struct tcb_s *rtcb = (struct tcb_s *)g_readytorun.head;
struct tcb_s *rtcb = this_task();
/* Verify that the context switch can be performed */
@ -83,7 +83,7 @@ void up_unblock_task(struct tcb_s *tcb)
sched_removeblocked(tcb);
/* Add the task in the correct location in the prioritized
* g_readytorun task list
* ready-to-run task list
*/
if (sched_addreadytorun(tcb))
@ -107,10 +107,10 @@ void up_unblock_task(struct tcb_s *tcb)
up_savestate(rtcb->xcp.regs);
/* Restore the exception context of the rtcb at the (new) head
* of the g_readytorun task list.
* of the ready-to-run task list.
*/
rtcb = (struct tcb_s *)g_readytorun.head;
rtcb = this_task();
/* Update scheduler parameters */
@ -133,10 +133,10 @@ void up_unblock_task(struct tcb_s *tcb)
{
/* Restore the exception context of the new task that is ready to
* run (probably tcb). This is the new rtcb at the head of the
* g_readytorun task list.
* ready-to-run task list.
*/
rtcb = (struct tcb_s *)g_readytorun.head;
rtcb = this_task();
#ifdef CONFIG_ARCH_ADDRENV
/* Make sure that the address environment for the previously

View file

@ -240,7 +240,7 @@ static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg)
#ifdef CONFIG_ARCH_STACKDUMP
static void up_dumpstate(void)
{
struct tcb_s *rtcb = (struct tcb_s *)g_readytorun.head;
struct tcb_s *rtcb = this_task();
uint32_t sp = up_getsp();
uint32_t ustackbase;
uint32_t ustacksize;
@ -365,7 +365,7 @@ static void _up_assert(int errorcode)
{
/* Are we in an interrupt handler or the idle task? */
if (current_regs || ((struct tcb_s *)g_readytorun.head)->pid == 0)
if (current_regs || this_task()->pid == 0)
{
(void)irqsave();
for (; ; )
@ -395,7 +395,7 @@ static void _up_assert(int errorcode)
void up_assert(const uint8_t *filename, int lineno)
{
#ifdef CONFIG_PRINT_TASKNAME
struct tcb_s *rtcb = (struct tcb_s *)g_readytorun.head;
struct tcb_s *rtcb = this_task();
#endif
board_autoled_on(LED_ASSERTION);
@ -411,7 +411,7 @@ void up_assert(const uint8_t *filename, int lineno)
up_dumpstate();
#ifdef CONFIG_BOARD_CRASHDUMP
board_crashdump(up_getsp(), g_readytorun.head, filename, lineno);
board_crashdump(up_getsp(), this_task(), filename, lineno);
#endif
_up_assert(EXIT_FAILURE);

View file

@ -74,7 +74,7 @@
void up_block_task(struct tcb_s *tcb, tstate_t task_state)
{
struct tcb_s *rtcb = (struct tcb_s *)g_readytorun.head;
struct tcb_s *rtcb = this_task();
bool switch_needed;
/* Verify that the context switch can be performed */
@ -95,7 +95,7 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state)
sched_addblocked(tcb, (tstate_t)task_state);
/* If there are any pending tasks, then add them to the g_readytorun
/* If there are any pending tasks, then add them to the ready-to-run
* task list now
*/
@ -123,10 +123,10 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state)
up_savestate(rtcb->xcp.regs);
/* Restore the exception context of the rtcb at the (new) head
* of the g_readytorun task list.
* of the ready-to-run task list.
*/
rtcb = (struct tcb_s *)g_readytorun.head;
rtcb = this_task();
/* Reset scheduler parameters */
@ -141,7 +141,7 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state)
else
{
struct tcb_s *nexttcb = (struct tcb_s *)g_readytorun.head;
struct tcb_s *nexttcb = this_task();
/* Reset scheduler parameters */

View file

@ -64,11 +64,11 @@
void up_release_pending(void)
{
struct tcb_s *rtcb = (struct tcb_s *)g_readytorun.head;
struct tcb_s *rtcb = this_task();
slldbg("From TCB=%p\n", rtcb);
/* Merge the g_pendingtasks list into the g_readytorun task list */
/* Merge the g_pendingtasks list into the ready-to-run task list */
/* sched_lock(); */
if (sched_mergepending())
@ -92,10 +92,10 @@ void up_release_pending(void)
up_savestate(rtcb->xcp.regs);
/* Restore the exception context of the rtcb at the (new) head
* of the g_readytorun task list.
* of the ready-to-run task list.
*/
rtcb = (struct tcb_s *)g_readytorun.head;
rtcb = this_task();
/* Update scheduler parameters */
@ -110,7 +110,7 @@ void up_release_pending(void)
else
{
struct tcb_s *nexttcb = (struct tcb_s *)g_readytorun.head;
struct tcb_s *nexttcb = this_task();
/* Update scheduler parameters */

View file

@ -91,7 +91,7 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
}
else
{
struct tcb_s *rtcb = (struct tcb_s *)g_readytorun.head;
struct tcb_s *rtcb = this_task();
bool switch_needed;
slldbg("TCB=%p PRI=%d\n", tcb, priority);
@ -147,10 +147,10 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
up_savestate(rtcb->xcp.regs);
/* Restore the exception context of the rtcb at the (new) head
* of the g_readytorun task list.
* of the ready-to-run task list.
*/
rtcb = (struct tcb_s *)g_readytorun.head;
rtcb = this_task();
/* Update scheduler parameters */
@ -165,7 +165,7 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
else
{
struct tcb_s *nexttcb = (struct tcb_s *)g_readytorun.head;
struct tcb_s *nexttcb = this_task();
/* Update scheduler parameters */

View file

@ -120,9 +120,9 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* to the currently executing task.
*/
sdbg("rtcb=0x%p current_regs=0x%p\n", g_readytorun.head, current_regs);
sdbg("rtcb=0x%p current_regs=0x%p\n", this_task(), current_regs);
if (tcb == (struct tcb_s *)g_readytorun.head)
if (tcb == this_task())
{
/* CASE 1: We are not in an interrupt handler and a task is
* signalling itself for some reason.

View file

@ -87,7 +87,7 @@ void up_sigdeliver(void)
* copy an may overwrite the regs[] array contents. Sorry.
*/
struct tcb_s *rtcb = (struct tcb_s *)g_readytorun.head;
struct tcb_s *rtcb = this_task();
uint32_t regs[XCPTCONTEXT_REGS + 4];
sig_deliver_t sigdeliver;

View file

@ -69,7 +69,7 @@
void up_unblock_task(struct tcb_s *tcb)
{
struct tcb_s *rtcb = (struct tcb_s *)g_readytorun.head;
struct tcb_s *rtcb = this_task();
/* Verify that the context switch can be performed */
@ -81,7 +81,7 @@ void up_unblock_task(struct tcb_s *tcb)
sched_removeblocked(tcb);
/* Add the task in the correct location in the prioritized
* g_readytorun task list
* ready-to-run task list
*/
if (sched_addreadytorun(tcb))
@ -105,10 +105,10 @@ void up_unblock_task(struct tcb_s *tcb)
up_savestate(rtcb->xcp.regs);
/* Restore the exception context of the rtcb at the (new) head
* of the g_readytorun task list.
* of the ready-to-run task list.
*/
rtcb = (struct tcb_s *)g_readytorun.head;
rtcb = this_task();
/* Update scheduler parameters */
@ -123,7 +123,7 @@ void up_unblock_task(struct tcb_s *tcb)
else
{
struct tcb_s *nexttcb = (struct tcb_s *)g_readytorun.head;
struct tcb_s *nexttcb = this_task();
/* Update scheduler parameters */

View file

@ -88,10 +88,6 @@
# define CONFIG_PRINT_TASKNAME 1
#endif
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
@ -232,7 +228,7 @@ static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg)
#ifdef CONFIG_ARCH_STACKDUMP
static void up_dumpstate(void)
{
struct tcb_s *rtcb = (struct tcb_s *)g_readytorun.head;
struct tcb_s *rtcb = this_task();
uint32_t sp = up_getsp();
uint32_t ustackbase;
uint32_t ustacksize;
@ -365,7 +361,7 @@ static void _up_assert(int errorcode)
{
/* Are we in an interrupt handler or the idle task? */
if (current_regs || ((struct tcb_s *)g_readytorun.head)->pid == 0)
if (current_regs || this_task()->pid == 0)
{
(void)irqsave();
for (; ; )
@ -395,7 +391,7 @@ static void _up_assert(int errorcode)
void up_assert(const uint8_t *filename, int lineno)
{
#ifdef CONFIG_PRINT_TASKNAME
struct tcb_s *rtcb = (struct tcb_s *)g_readytorun.head;
struct tcb_s *rtcb = this_task();
#endif
board_autoled_on(LED_ASSERTION);
@ -409,7 +405,7 @@ void up_assert(const uint8_t *filename, int lineno)
up_dumpstate();
#ifdef CONFIG_BOARD_CRASHDUMP
board_crashdump(up_getsp(), g_readytorun.head, filename, lineno);
board_crashdump(up_getsp(), this_task(), filename, lineno);
#endif
_up_assert(EXIT_FAILURE);

View file

@ -76,7 +76,7 @@
void up_block_task(struct tcb_s *tcb, tstate_t task_state)
{
struct tcb_s *rtcb = (struct tcb_s *)g_readytorun.head;
struct tcb_s *rtcb = this_task();
bool switch_needed;
/* Verify that the context switch can be performed */
@ -97,7 +97,7 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state)
sched_addblocked(tcb, (tstate_t)task_state);
/* If there are any pending tasks, then add them to the g_readytorun
/* If there are any pending tasks, then add them to the ready-to-run
* task list now
*/
@ -125,10 +125,10 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state)
up_savestate(rtcb->xcp.regs);
/* Restore the exception context of the rtcb at the (new) head
* of the g_readytorun task list.
* of the ready-to-run task list.
*/
rtcb = (struct tcb_s *)g_readytorun.head;
rtcb = this_task();
/* Reset scheduler parameters */
@ -142,17 +142,17 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state)
}
/* Copy the user C context into the TCB at the (old) head of the
* g_readytorun Task list. if up_saveusercontext returns a non-zero
* 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 g_readytorun task list.
* of the ready-to-run task list.
*/
rtcb = (struct tcb_s *)g_readytorun.head;
rtcb = this_task();
#ifdef CONFIG_ARCH_ADDRENV
/* Make sure that the address environment for the previously

View file

@ -63,18 +63,6 @@
# include "arm.h"
#endif
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
@ -102,10 +90,9 @@
****************************************************************************/
#ifdef CONFIG_PAGING
uint32_t *arm_dataabort(uint32_t *regs, uint32_t dfar, uint32_t dfsr)
{
DFAR struct tcb_s *tcb = (DFAR struct tcb_s *)g_readytorun.head;
struct tcb_s *tcb = this_task();
uint32_t *savestate;
/* Save the saved processor context in current_regs where it can be accessed

View file

@ -120,7 +120,7 @@ uint32_t *arm_prefetchabort(uint32_t *regs, uint32_t ifar, uint32_t ifsr)
* prefetch and data aborts.
*/
FAR struct tcb_s *tcb = (FAR struct tcb_s *)g_readytorun.head;
struct tcb_s *tcb = this_task();
tcb->xcp.far = regs[REG_R15];
/* Call pg_miss() to schedule the page fill. A consequences of this

View file

@ -65,11 +65,11 @@
void up_release_pending(void)
{
struct tcb_s *rtcb = (struct tcb_s *)g_readytorun.head;
struct tcb_s *rtcb = this_task();
slldbg("From TCB=%p\n", rtcb);
/* Merge the g_pendingtasks list into the g_readytorun task list */
/* Merge the g_pendingtasks list into the ready-to-run task list */
/* sched_lock(); */
if (sched_mergepending())
@ -93,10 +93,10 @@ void up_release_pending(void)
up_savestate(rtcb->xcp.regs);
/* Restore the exception context of the rtcb at the (new) head
* of the g_readytorun task list.
* of the ready-to-run task list.
*/
rtcb = (struct tcb_s *)g_readytorun.head;
rtcb = this_task();
/* Update scheduler parameters */
@ -118,10 +118,10 @@ void up_release_pending(void)
else if (!up_saveusercontext(rtcb->xcp.regs))
{
/* Restore the exception context of the rtcb at the (new) head
* of the g_readytorun task list.
* of the ready-to-run task list.
*/
rtcb = (struct tcb_s *)g_readytorun.head;
rtcb = this_task();
#ifdef CONFIG_ARCH_ADDRENV
/* Make sure that the address environment for the previously

View file

@ -92,7 +92,7 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
}
else
{
struct tcb_s *rtcb = (struct tcb_s *)g_readytorun.head;
struct tcb_s *rtcb = this_task();
bool switch_needed;
slldbg("TCB=%p PRI=%d\n", tcb, priority);
@ -147,10 +147,10 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
up_savestate(rtcb->xcp.regs);
/* Restore the exception context of the rtcb at the (new) head
* of the g_readytorun task list.
* of the ready-to-run task list.
*/
rtcb = (struct tcb_s *)g_readytorun.head;
rtcb = this_task();
/* Update scheduler parameters */
@ -164,17 +164,17 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
}
/* Copy the exception context into the TCB at the (old) head of the
* g_readytorun Task list. if up_saveusercontext returns a non-zero
* 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 g_readytorun task list.
* of the ready-to-run task list.
*/
rtcb = (struct tcb_s *)g_readytorun.head;
rtcb = this_task();
#ifdef CONFIG_ARCH_ADDRENV
/* Make sure that the address environment for the previously

View file

@ -119,9 +119,9 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* to the currently executing task.
*/
sdbg("rtcb=0x%p current_regs=0x%p\n", g_readytorun.head, current_regs);
sdbg("rtcb=0x%p current_regs=0x%p\n", this_task(), current_regs);
if (tcb == (struct tcb_s *)g_readytorun.head)
if (tcb == this_task())
{
/* CASE 1: We are not in an interrupt handler and a task is
* signalling itself for some reason.
@ -143,7 +143,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* would fail in the strange case where we are in an interrupt
* handler, the thread is signalling itself, but a context switch
* to another task has occurred so that current_regs does not
* refer to the thread at g_readytorun.head!
* refer to the thread of this_task()!
*/
else

View file

@ -54,18 +54,6 @@
#ifndef CONFIG_DISABLE_SIGNALS
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
@ -82,7 +70,7 @@
void up_sigdeliver(void)
{
struct tcb_s *rtcb = (struct tcb_s *)g_readytorun.head;
struct tcb_s *rtcb = this_task();
uint32_t regs[XCPTCONTEXT_REGS];
sig_deliver_t sigdeliver;

View file

@ -83,7 +83,7 @@
void up_unblock_task(struct tcb_s *tcb)
{
struct tcb_s *rtcb = (struct tcb_s *)g_readytorun.head;
struct tcb_s *rtcb = this_task();
/* Verify that the context switch can be performed */
@ -95,7 +95,7 @@ void up_unblock_task(struct tcb_s *tcb)
sched_removeblocked(tcb);
/* Add the task in the correct location in the prioritized
* g_readytorun task list
* ready-to-run task list
*/
if (sched_addreadytorun(tcb))
@ -119,10 +119,10 @@ void up_unblock_task(struct tcb_s *tcb)
up_savestate(rtcb->xcp.regs);
/* Restore the exception context of the rtcb at the (new) head
* of the g_readytorun task list.
* of the ready-to-run task list.
*/
rtcb = (struct tcb_s *)g_readytorun.head;
rtcb = this_task();
/* Update scheduler parameters */
@ -145,10 +145,10 @@ void up_unblock_task(struct tcb_s *tcb)
{
/* Restore the exception context of the new task that is ready to
* run (probably tcb). This is the new rtcb at the head of the
* g_readytorun task list.
* ready-to-run task list.
*/
rtcb = (struct tcb_s *)g_readytorun.head;
rtcb = this_task();
#ifdef CONFIG_ARCH_ADDRENV
/* Make sure that the address environment for the previously

View file

@ -245,7 +245,7 @@ static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg)
#ifdef CONFIG_ARCH_STACKDUMP
static void up_dumpstate(void)
{
struct tcb_s *rtcb = (struct tcb_s *)g_readytorun.head;
struct tcb_s *rtcb = this_task();
uint32_t sp = up_getsp();
uint32_t ustackbase;
uint32_t ustacksize;
@ -374,7 +374,7 @@ static void _up_assert(int errorcode)
{
/* Are we in an interrupt handler or the idle task? */
if (current_regs || ((struct tcb_s *)g_readytorun.head)->pid == 0)
if (current_regs || (this_task())->pid == 0)
{
(void)irqsave();
for (; ; )
@ -404,7 +404,7 @@ static void _up_assert(int errorcode)
void up_assert(const uint8_t *filename, int lineno)
{
#ifdef CONFIG_PRINT_TASKNAME
struct tcb_s *rtcb = (struct tcb_s *)g_readytorun.head;
struct tcb_s *rtcb = this_task();
#endif
board_autoled_on(LED_ASSERTION);
@ -420,7 +420,7 @@ void up_assert(const uint8_t *filename, int lineno)
up_dumpstate();
#ifdef CONFIG_BOARD_CRASHDUMP
board_crashdump(up_getsp(), g_readytorun.head, filename, lineno);
board_crashdump(up_getsp(), this_task(), filename, lineno);
#endif
_up_assert(EXIT_FAILURE);

View file

@ -75,7 +75,7 @@
void up_block_task(struct tcb_s *tcb, tstate_t task_state)
{
struct tcb_s *rtcb = (struct tcb_s *)g_readytorun.head;
struct tcb_s *rtcb = this_task();
bool switch_needed;
/* Verify that the context switch can be performed */
@ -96,7 +96,7 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state)
sched_addblocked(tcb, (tstate_t)task_state);
/* If there are any pending tasks, then add them to the g_readytorun
/* If there are any pending tasks, then add them to the ready-to-run
* task list now
*/
@ -124,10 +124,10 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state)
up_savestate(rtcb->xcp.regs);
/* Restore the exception context of the rtcb at the (new) head
* of the g_readytorun task list.
* of the ready-to-run task list.
*/
rtcb = (struct tcb_s *)g_readytorun.head;
rtcb = this_task();
/* Reset scheduler parameters */
@ -142,7 +142,7 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state)
else
{
struct tcb_s *nexttcb = (struct tcb_s *)g_readytorun.head;
struct tcb_s *nexttcb = this_task();
/* Reset scheduler parameters */

View file

@ -64,11 +64,11 @@
void up_release_pending(void)
{
struct tcb_s *rtcb = (struct tcb_s *)g_readytorun.head;
struct tcb_s *rtcb = this_task();
slldbg("From TCB=%p\n", rtcb);
/* Merge the g_pendingtasks list into the g_readytorun task list */
/* Merge the g_pendingtasks list into the ready-to-run task list */
/* sched_lock(); */
if (sched_mergepending())
@ -92,10 +92,10 @@ void up_release_pending(void)
up_savestate(rtcb->xcp.regs);
/* Restore the exception context of the rtcb at the (new) head
* of the g_readytorun task list.
* of the ready-to-run task list.
*/
rtcb = (struct tcb_s *)g_readytorun.head;
rtcb = this_task();
/* Update scheduler parameters */
@ -110,7 +110,7 @@ void up_release_pending(void)
else
{
struct tcb_s *nexttcb = (struct tcb_s *)g_readytorun.head;
struct tcb_s *nexttcb = this_task();
/* Update scheduler parameters */

View file

@ -91,7 +91,7 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
}
else
{
struct tcb_s *rtcb = (struct tcb_s *)g_readytorun.head;
struct tcb_s *rtcb = this_task();
bool switch_needed;
slldbg("TCB=%p PRI=%d\n", tcb, priority);
@ -147,10 +147,10 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
up_savestate(rtcb->xcp.regs);
/* Restore the exception context of the rtcb at the (new) head
* of the g_readytorun task list.
* of the ready-to-run task list.
*/
rtcb = (struct tcb_s *)g_readytorun.head;
rtcb = this_task();
/* Update scheduler parameters */
@ -165,7 +165,7 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
else
{
struct tcb_s *nexttcb = (struct tcb_s *)g_readytorun.head;
struct tcb_s *nexttcb = this_task();
/* Update scheduler parameters */

View file

@ -53,18 +53,6 @@
#ifndef CONFIG_DISABLE_SIGNALS
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
@ -121,9 +109,9 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* to the currently executing task.
*/
sdbg("rtcb=0x%p current_regs=0x%p\n", g_readytorun.head, current_regs);
sdbg("rtcb=0x%p current_regs=0x%p\n", this_task(), current_regs);
if (tcb == (struct tcb_s *)g_readytorun.head)
if (tcb == this_task())
{
/* CASE 1: We are not in an interrupt handler and a task is
* signalling itself for some reason.

View file

@ -82,7 +82,7 @@
void up_sigdeliver(void)
{
struct tcb_s *rtcb = (struct tcb_s *)g_readytorun.head;
struct tcb_s *rtcb = this_task();
uint32_t regs[XCPTCONTEXT_REGS];
sig_deliver_t sigdeliver;

View file

@ -70,7 +70,7 @@
void up_unblock_task(struct tcb_s *tcb)
{
struct tcb_s *rtcb = (struct tcb_s *)g_readytorun.head;
struct tcb_s *rtcb = this_task();
/* Verify that the context switch can be performed */
@ -82,7 +82,7 @@ void up_unblock_task(struct tcb_s *tcb)
sched_removeblocked(tcb);
/* Add the task in the correct location in the prioritized
* g_readytorun task list
* ready-to-run task list
*/
if (sched_addreadytorun(tcb))
@ -106,10 +106,10 @@ void up_unblock_task(struct tcb_s *tcb)
up_savestate(rtcb->xcp.regs);
/* Restore the exception context of the rtcb at the (new) head
* of the g_readytorun task list.
* of the ready-to-run task list.
*/
rtcb = (struct tcb_s *)g_readytorun.head;
rtcb = this_task();
/* Update scheduler parameters */
@ -124,7 +124,7 @@ void up_unblock_task(struct tcb_s *tcb)
else
{
struct tcb_s *nexttcb = (struct tcb_s *)g_readytorun.head;
struct tcb_s *nexttcb = this_task();
/* Update scheduler parameters */

View file

@ -88,10 +88,6 @@
# define CONFIG_PRINT_TASKNAME 1
#endif
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
@ -232,7 +228,7 @@ static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg)
#ifdef CONFIG_ARCH_STACKDUMP
static void up_dumpstate(void)
{
struct tcb_s *rtcb = (struct tcb_s *)g_readytorun.head;
struct tcb_s *rtcb = this_task();
uint32_t sp = up_getsp();
uint32_t ustackbase;
uint32_t ustacksize;
@ -365,7 +361,7 @@ static void _up_assert(int errorcode)
{
/* Are we in an interrupt handler or the idle task? */
if (current_regs || ((struct tcb_s *)g_readytorun.head)->pid == 0)
if (current_regs || (this_task())->pid == 0)
{
(void)irqsave();
for (; ; )
@ -395,7 +391,7 @@ static void _up_assert(int errorcode)
void up_assert(const uint8_t *filename, int lineno)
{
#ifdef CONFIG_PRINT_TASKNAME
struct tcb_s *rtcb = (struct tcb_s *)g_readytorun.head;
struct tcb_s *rtcb = this_task();
#endif
board_autoled_on(LED_ASSERTION);
@ -409,7 +405,7 @@ void up_assert(const uint8_t *filename, int lineno)
up_dumpstate();
#ifdef CONFIG_BOARD_CRASHDUMP
board_crashdump(up_getsp(), g_readytorun.head, filename, lineno);
board_crashdump(up_getsp(), this_task(), filename, lineno);
#endif
_up_assert(EXIT_FAILURE);

View file

@ -76,7 +76,7 @@
void up_block_task(struct tcb_s *tcb, tstate_t task_state)
{
struct tcb_s *rtcb = (struct tcb_s *)g_readytorun.head;
struct tcb_s *rtcb = this_task();
bool switch_needed;
/* Verify that the context switch can be performed */
@ -97,7 +97,7 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state)
sched_addblocked(tcb, (tstate_t)task_state);
/* If there are any pending tasks, then add them to the g_readytorun
/* If there are any pending tasks, then add them to the ready-to-run
* task list now
*/
@ -125,10 +125,10 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state)
up_savestate(rtcb->xcp.regs);
/* Restore the exception context of the rtcb at the (new) head
* of the g_readytorun task list.
* of the ready-to-run task list.
*/
rtcb = (struct tcb_s *)g_readytorun.head;
rtcb = this_task();
/* Reset scheduler parameters */
@ -140,17 +140,17 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state)
}
/* Copy the user C context into the TCB at the (old) head of the
* g_readytorun Task list. if up_saveusercontext returns a non-zero
* 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 g_readytorun task list.
* of the ready-to-run task list.
*/
rtcb = (struct tcb_s *)g_readytorun.head;
rtcb = this_task();
/* Reset scheduler parameters */

View file

@ -65,11 +65,11 @@
void up_release_pending(void)
{
struct tcb_s *rtcb = (struct tcb_s *)g_readytorun.head;
struct tcb_s *rtcb = this_task();
slldbg("From TCB=%p\n", rtcb);
/* Merge the g_pendingtasks list into the g_readytorun task list */
/* Merge the g_pendingtasks list into the ready-to-run task list */
/* sched_lock(); */
if (sched_mergepending())
@ -93,10 +93,10 @@ void up_release_pending(void)
up_savestate(rtcb->xcp.regs);
/* Restore the exception context of the rtcb at the (new) head
* of the g_readytorun task list.
* of the ready-to-run task list.
*/
rtcb = (struct tcb_s *)g_readytorun.head;
rtcb = this_task();
/* Update scheduler parameters */
@ -118,10 +118,10 @@ void up_release_pending(void)
else if (!up_saveusercontext(rtcb->xcp.regs))
{
/* Restore the exception context of the rtcb at the (new) head
* of the g_readytorun task list.
* of the ready-to-run task list.
*/
rtcb = (struct tcb_s *)g_readytorun.head;
rtcb = this_task();
/* Update scheduler parameters */

View file

@ -92,7 +92,7 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
}
else
{
struct tcb_s *rtcb = (struct tcb_s *)g_readytorun.head;
struct tcb_s *rtcb = this_task();
bool switch_needed;
slldbg("TCB=%p PRI=%d\n", tcb, priority);
@ -147,10 +147,10 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
up_savestate(rtcb->xcp.regs);
/* Restore the exception context of the rtcb at the (new) head
* of the g_readytorun task list.
* of the ready-to-run task list.
*/
rtcb = (struct tcb_s *)g_readytorun.head;
rtcb = this_task();
/* Update scheduler parameters */
@ -164,17 +164,17 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
}
/* Copy the exception context into the TCB at the (old) head of the
* g_readytorun Task list. if up_saveusercontext returns a non-zero
* 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 g_readytorun task list.
* of the ready-to-run task list.
*/
rtcb = (struct tcb_s *)g_readytorun.head;
rtcb = this_task();
/* Update scheduler parameters */

View file

@ -52,18 +52,6 @@
#ifndef CONFIG_DISABLE_SIGNALS
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
@ -119,9 +107,9 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* to the currently executing task.
*/
sdbg("rtcb=0x%p current_regs=0x%p\n", g_readytorun.head, current_regs);
sdbg("rtcb=0x%p current_regs=0x%p\n", this_task(), current_regs);
if (tcb == (struct tcb_s *)g_readytorun.head)
if (tcb == this_task())
{
/* CASE 1: We are not in an interrupt handler and a task is
* signalling itself for some reason.
@ -143,7 +131,7 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* would fail in the strange case where we are in an interrupt
* handler, the thread is signalling itself, but a context switch
* to another task has occurred so that current_regs does not
* refer to the thread at g_readytorun.head!
* refer to the thread of this_task()!
*/
else

View file

@ -54,18 +54,6 @@
#ifndef CONFIG_DISABLE_SIGNALS
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
@ -82,7 +70,7 @@
void up_sigdeliver(void)
{
struct tcb_s *rtcb = (struct tcb_s *)g_readytorun.head;
struct tcb_s *rtcb = this_task();
uint32_t regs[XCPTCONTEXT_REGS];
sig_deliver_t sigdeliver;

View file

@ -83,7 +83,7 @@
void up_unblock_task(struct tcb_s *tcb)
{
struct tcb_s *rtcb = (struct tcb_s *)g_readytorun.head;
struct tcb_s *rtcb = this_task();
/* Verify that the context switch can be performed */
@ -95,7 +95,7 @@ void up_unblock_task(struct tcb_s *tcb)
sched_removeblocked(tcb);
/* Add the task in the correct location in the prioritized
* g_readytorun task list
* ready-to-run task list
*/
if (sched_addreadytorun(tcb))
@ -119,10 +119,10 @@ void up_unblock_task(struct tcb_s *tcb)
up_savestate(rtcb->xcp.regs);
/* Restore the exception context of the rtcb at the (new) head
* of the g_readytorun task list.
* of the ready-to-run task list.
*/
rtcb = (struct tcb_s *)g_readytorun.head;
rtcb = this_task();
/* Update scheduler parameters */
@ -145,10 +145,10 @@ void up_unblock_task(struct tcb_s *tcb)
{
/* Restore the exception context of the new task that is ready to
* run (probably tcb). This is the new rtcb at the head of the
* g_readytorun task list.
* ready-to-run task list.
*/
rtcb = (struct tcb_s *)g_readytorun.head;
rtcb = this_task();
/* Update scheduler parameters */

View file

@ -50,19 +50,16 @@
#include "sched/sched.h"
#include "up_internal.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#ifdef CONFIG_STACK_COLORATION
/****************************************************************************
* Public Data
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
static size_t do_stackcheck(uintptr_t alloc, size_t size);
/****************************************************************************
@ -180,12 +177,12 @@ ssize_t up_check_tcbstack_remain(FAR struct tcb_s *tcb)
size_t up_check_stack(void)
{
return up_check_tcbstack((FAR struct tcb_s *)g_readytorun.head);
return up_check_tcbstack(this_task());
}
ssize_t up_check_stack_remain(void)
{
return up_check_tcbstack_remain((FAR struct tcb_s *)g_readytorun.head);
return up_check_tcbstack_remain(this_task());
}
#if CONFIG_ARCH_INTERRUPTSTACK > 3

View file

@ -52,14 +52,6 @@
#include "group/group.h"
#include "up_internal.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
@ -146,7 +138,7 @@ void _exit(int status)
(void)irqsave();
slldbg("TCB=%p exiting\n", g_readytorun.head);
slldbg("TCB=%p exiting\n", this_task());
#if defined(CONFIG_DUMP_ON_EXIT) && defined(CONFIG_DEBUG)
slldbg("Other tasks:\n");
@ -161,7 +153,7 @@ void _exit(int status)
* head of the list.
*/
tcb = (struct tcb_s *)g_readytorun.head;
tcb = this_task();
#ifdef CONFIG_ARCH_ADDRENV
/* Make sure that the address environment for the previously running

View file

@ -73,10 +73,6 @@
# endif
#endif
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
@ -126,7 +122,7 @@
pid_t up_vfork(const struct vfork_s *context)
{
struct tcb_s *parent = (FAR struct tcb_s *)g_readytorun.head;
struct tcb_s *parent = this_task();
struct task_tcb_s *child;
size_t stacksize;
uint32_t newsp;