MIPS: Replace explict references to g_readytorun with indirect references via the this_task() macro

This commit is contained in:
Gregory Nutt 2016-02-06 16:49:34 -06:00
parent 2b8d1fcbdb
commit b373894fbc
10 changed files with 31 additions and 31 deletions

View File

@ -148,7 +148,7 @@ void _exit(int status)
(void)irqsave(); (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) #if defined(CONFIG_DUMP_ON_EXIT) && defined(CONFIG_DEBUG)
slldbg("Other tasks:\n"); slldbg("Other tasks:\n");
@ -163,7 +163,7 @@ void _exit(int status)
* head of the list. * head of the list.
*/ */
tcb = (struct tcb_s *)g_readytorun.head; tcb = this_task();
#ifdef CONFIG_ARCH_ADDRENV #ifdef CONFIG_ARCH_ADDRENV
/* Make sure that the address environment for the previously running /* Make sure that the address environment for the previously running

View File

@ -105,7 +105,7 @@ static void _up_assert(int errorcode)
{ {
/* Are we in an interrupt handler or the idle task? */ /* 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(); (void)irqsave();
for (; ; ) for (; ; )
@ -160,7 +160,7 @@ static int assert_tracecallback(FAR struct usbtrace_s *trace, FAR void *arg)
void up_assert(const uint8_t *filename, int lineno) void up_assert(const uint8_t *filename, int lineno)
{ {
#ifdef CONFIG_PRINT_TASKNAME #ifdef CONFIG_PRINT_TASKNAME
struct tcb_s *rtcb = (struct tcb_s *)g_readytorun.head; struct tcb_s *rtcb = this_task();
#endif #endif
board_autoled_on(LED_ASSERTION); board_autoled_on(LED_ASSERTION);
@ -182,7 +182,7 @@ void up_assert(const uint8_t *filename, int lineno)
#endif #endif
#ifdef CONFIG_BOARD_CRASHDUMP #ifdef CONFIG_BOARD_CRASHDUMP
board_crashdump(up_getsp(), g_readytorun.head, filename, lineno); board_crashdump(up_getsp(), this_task(), filename, lineno);
#endif #endif
_up_assert(EXIT_FAILURE); _up_assert(EXIT_FAILURE);

View File

@ -77,7 +77,7 @@
void up_block_task(struct tcb_s *tcb, tstate_t task_state) 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; bool switch_needed;
/* Verify that the context switch can be performed */ /* Verify that the context switch can be performed */
@ -98,7 +98,7 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state)
sched_addblocked(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 * task list now
*/ */
@ -126,10 +126,10 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state)
up_savestate(rtcb->xcp.regs); up_savestate(rtcb->xcp.regs);
/* Restore the exception context of the rtcb at the (new) head /* 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 */ /* Reset scheduler parameters */
@ -150,7 +150,7 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state)
* run list. * run list.
*/ */
struct tcb_s *nexttcb = (struct tcb_s *)g_readytorun.head; struct tcb_s *nexttcb = this_task();
#ifdef CONFIG_ARCH_ADDRENV #ifdef CONFIG_ARCH_ADDRENV
/* Make sure that the address environment for the previously /* Make sure that the address environment for the previously

View File

@ -154,7 +154,7 @@ static inline void up_registerdump(void)
void up_dumpstate(void) 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 sp = up_getsp();
uint32_t ustackbase; uint32_t ustackbase;
uint32_t ustacksize; uint32_t ustacksize;

View File

@ -67,11 +67,11 @@
void up_release_pending(void) 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); 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(); */ /* sched_lock(); */
if (sched_mergepending()) if (sched_mergepending())
@ -95,10 +95,10 @@ void up_release_pending(void)
up_savestate(rtcb->xcp.regs); up_savestate(rtcb->xcp.regs);
/* Restore the exception context of the rtcb at the (new) head /* 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 */ /* Update scheduler parameters */
@ -119,7 +119,7 @@ void up_release_pending(void)
* ready to run list. * ready to run list.
*/ */
struct tcb_s *nexttcb = (struct tcb_s *)g_readytorun.head; struct tcb_s *nexttcb = this_task();
#ifdef CONFIG_ARCH_ADDRENV #ifdef CONFIG_ARCH_ADDRENV
/* Make sure that the address environment for the previously /* Make sure that the address environment for the previously

View File

@ -94,7 +94,7 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
} }
else else
{ {
struct tcb_s *rtcb = (struct tcb_s *)g_readytorun.head; struct tcb_s *rtcb = this_task();
bool switch_needed; bool switch_needed;
slldbg("TCB=%p PRI=%d\n", tcb, priority); slldbg("TCB=%p PRI=%d\n", tcb, priority);
@ -149,10 +149,10 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
up_savestate(rtcb->xcp.regs); up_savestate(rtcb->xcp.regs);
/* Restore the exception context of the rtcb at the (new) head /* 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 */ /* Update scheduler parameters */
@ -173,7 +173,7 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
* ready to run list. * ready to run list.
*/ */
struct tcb_s *nexttcb = (struct tcb_s *)g_readytorun.head; struct tcb_s *nexttcb = this_task();
#ifdef CONFIG_ARCH_ADDRENV #ifdef CONFIG_ARCH_ADDRENV
/* Make sure that the address environment for the previously /* Make sure that the address environment for the previously

View File

@ -120,9 +120,9 @@ void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver)
* being delivered to the currently executing task. * 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 /* CASE 1: We are not in an interrupt handler and
* a task is signalling itself for some reason. * a task is signalling itself for some reason.
@ -144,7 +144,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 * logic would fail in the strange case where we are in an
* interrupt handler, the thread is signalling itself, but * interrupt handler, the thread is signalling itself, but
* a context switch to another task has occurred so that * 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 else

View File

@ -83,7 +83,7 @@
void up_sigdeliver(void) 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]; uint32_t regs[XCPTCONTEXT_REGS];
sig_deliver_t sigdeliver; sig_deliver_t sigdeliver;

View File

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

View File

@ -113,7 +113,7 @@
pid_t up_vfork(const struct vfork_s *context) 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; struct task_tcb_s *child;
size_t stacksize; size_t stacksize;
uint32_t newsp; uint32_t newsp;