diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2013-04-25 15:19:59 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2013-04-25 15:19:59 -0600 |
commit | 1ffc15c3233c8d61953fc2ebc80b5d3c46fc429f (patch) | |
tree | 95050f5e635b87d26f4dd98612b05edf632b2a96 /nuttx/arch/hc | |
parent | 5f6e91b0ed1b373d0b4f963b0e0f8f7fe05ec766 (diff) | |
download | px4-nuttx-1ffc15c3233c8d61953fc2ebc80b5d3c46fc429f.tar.gz px4-nuttx-1ffc15c3233c8d61953fc2ebc80b5d3c46fc429f.tar.bz2 px4-nuttx-1ffc15c3233c8d61953fc2ebc80b5d3c46fc429f.zip |
Remove up_assert_code
Diffstat (limited to 'nuttx/arch/hc')
-rw-r--r-- | nuttx/arch/hc/src/common/up_blocktask.c | 107 | ||||
-rw-r--r-- | nuttx/arch/hc/src/common/up_doirq.c | 2 | ||||
-rw-r--r-- | nuttx/arch/hc/src/common/up_reprioritizertr.c | 2 | ||||
-rw-r--r-- | nuttx/arch/hc/src/common/up_unblocktask.c | 95 | ||||
-rw-r--r-- | nuttx/arch/hc/src/m9s12/m9s12_assert.c | 27 | ||||
-rw-r--r-- | nuttx/arch/hc/src/m9s12/m9s12_serial.c | 2 |
6 files changed, 102 insertions, 133 deletions
diff --git a/nuttx/arch/hc/src/common/up_blocktask.c b/nuttx/arch/hc/src/common/up_blocktask.c index da7131c4c..5a2986291 100644 --- a/nuttx/arch/hc/src/common/up_blocktask.c +++ b/nuttx/arch/hc/src/common/up_blocktask.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/hc/src/common/up_blocktask.c * - * Copyright (C) 2010 Gregory Nutt. All rights reserved. + * Copyright (C) 2010, 2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without @@ -86,82 +86,77 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state) { + struct tcb_s *rtcb = (struct tcb_s*)g_readytorun.head; + bool switch_needed; + /* Verify that the context switch can be performed */ - if ((tcb->task_state < FIRST_READY_TO_RUN_STATE) || - (tcb->task_state > LAST_READY_TO_RUN_STATE)) - { - PANIC(OSERR_BADBLOCKSTATE); - } - else - { - struct tcb_s *rtcb = (struct tcb_s*)g_readytorun.head; - bool switch_needed; - - /* Remove the tcb task from the ready-to-run list. If we - * are blocking the task at the head of the task list (the - * most likely case), then a context switch to the next - * ready-to-run task is needed. In this case, it should - * also be true that rtcb == tcb. - */ + ASSERT((tcb->task_state >= FIRST_READY_TO_RUN_STATE) && + (tcb->task_state <= LAST_READY_TO_RUN_STATE)); - switch_needed = sched_removereadytorun(tcb); + /* Remove the tcb task from the ready-to-run list. If we + * are blocking the task at the head of the task list (the + * most likely case), then a context switch to the next + * ready-to-run task is needed. In this case, it should + * also be true that rtcb == tcb. + */ - /* Add the task to the specified blocked task list */ + switch_needed = sched_removereadytorun(tcb); - sched_addblocked(tcb, (tstate_t)task_state); + /* Add the task to the specified blocked task list */ - /* If there are any pending tasks, then add them to the g_readytorun - * task list now - */ + sched_addblocked(tcb, (tstate_t)task_state); - if (g_pendingtasks.head) - { - switch_needed |= sched_mergepending(); - } + /* If there are any pending tasks, then add them to the g_readytorun + * task list now + */ - /* Now, perform the context switch if one is needed */ + if (g_pendingtasks.head) + { + switch_needed |= sched_mergepending(); + } - if (switch_needed) + /* Now, perform the context switch if one is needed */ + + if (switch_needed) + { + /* Are we in an interrupt handler? */ + + if (current_regs) { - /* Are we in an interrupt handler? */ + /* Yes, then we have to do things differently. + * Just copy the current_regs into the OLD rtcb. + */ - if (current_regs) - { - /* Yes, then we have to do things differently. - * Just copy the current_regs into the OLD rtcb. - */ + up_savestate(rtcb->xcp.regs); - up_savestate(rtcb->xcp.regs); + /* Restore the exception context of the rtcb at the (new) head + * of the g_readytorun task list. + */ - /* Restore the exception context of the rtcb at the (new) head - * of the g_readytorun task list. - */ + rtcb = (struct tcb_s*)g_readytorun.head; - rtcb = (struct tcb_s*)g_readytorun.head; + /* Then switch contexts */ - /* Then switch contexts */ + up_restorestate(rtcb->xcp.regs); + } - up_restorestate(rtcb->xcp.regs); - } + /* 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 + * value, then this is really the previously running task restarting! + */ - /* 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 - * 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. */ - else if (!up_saveusercontext(rtcb->xcp.regs)) - { - /* Restore the exception context of the rtcb at the (new) head - * of the g_readytorun task list. - */ - - rtcb = (struct tcb_s*)g_readytorun.head; + rtcb = (struct tcb_s*)g_readytorun.head; - /* Then switch contexts */ + /* Then switch contexts */ - up_fullcontextrestore(rtcb->xcp.regs); - } + up_fullcontextrestore(rtcb->xcp.regs); } } } diff --git a/nuttx/arch/hc/src/common/up_doirq.c b/nuttx/arch/hc/src/common/up_doirq.c index 4a56dedbd..61d67d395 100644 --- a/nuttx/arch/hc/src/common/up_doirq.c +++ b/nuttx/arch/hc/src/common/up_doirq.c @@ -74,7 +74,7 @@ uint8_t *up_doirq(int irq, uint8_t *regs) { up_ledon(LED_INIRQ); #ifdef CONFIG_SUPPRESS_INTERRUPTS - PANIC(OSERR_ERREXCEPTION); + PANIC(); #else uint8_t *savestate; diff --git a/nuttx/arch/hc/src/common/up_reprioritizertr.c b/nuttx/arch/hc/src/common/up_reprioritizertr.c index 92e18ff47..d9689a0f3 100644 --- a/nuttx/arch/hc/src/common/up_reprioritizertr.c +++ b/nuttx/arch/hc/src/common/up_reprioritizertr.c @@ -98,7 +98,7 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority) #endif ) { - PANIC(OSERR_BADREPRIORITIZESTATE); + PANIC(); } else { diff --git a/nuttx/arch/hc/src/common/up_unblocktask.c b/nuttx/arch/hc/src/common/up_unblocktask.c index 7d5f67a1b..de787418a 100644 --- a/nuttx/arch/hc/src/common/up_unblocktask.c +++ b/nuttx/arch/hc/src/common/up_unblocktask.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/hc/src/common/up_unblocktask.c * - * Copyright (C) 2011 Gregory Nutt. All rights reserved. + * Copyright (C) 2011, 2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without @@ -81,79 +81,74 @@ void up_unblock_task(struct tcb_s *tcb) { + struct tcb_s *rtcb = (struct tcb_s*)g_readytorun.head; + /* Verify that the context switch can be performed */ - if ((tcb->task_state < FIRST_BLOCKED_STATE) || - (tcb->task_state > LAST_BLOCKED_STATE)) - { - PANIC(OSERR_BADUNBLOCKSTATE); - } - else - { - struct tcb_s *rtcb = (struct tcb_s*)g_readytorun.head; + ASSERT((tcb->task_state >= FIRST_BLOCKED_STATE) && + (tcb->task_state <= LAST_BLOCKED_STATE)); - /* Remove the task from the blocked task list */ + /* Remove the task from the blocked task list */ - sched_removeblocked(tcb); + sched_removeblocked(tcb); - /* Reset its timeslice. This is only meaningful for round - * robin tasks but it doesn't here to do it for everything - */ + /* Reset its timeslice. This is only meaningful for round + * robin tasks but it doesn't here to do it for everything + */ #if CONFIG_RR_INTERVAL > 0 - tcb->timeslice = CONFIG_RR_INTERVAL / MSEC_PER_TICK; + tcb->timeslice = CONFIG_RR_INTERVAL / MSEC_PER_TICK; #endif - /* Add the task in the correct location in the prioritized - * g_readytorun task list + /* Add the task in the correct location in the prioritized + * g_readytorun task list + */ + + if (sched_addreadytorun(tcb)) + { + /* The currently active task has changed! We need to do + * a context switch to the new task. + * + * Are we in an interrupt handler? */ - if (sched_addreadytorun(tcb)) + if (current_regs) { - /* The currently active task has changed! We need to do - * a context switch to the new task. - * - * Are we in an interrupt handler? + /* Yes, then we have to do things differently. + * Just copy the current_regs into the OLD rtcb. */ - if (current_regs) - { - /* Yes, then we have to do things differently. - * Just copy the current_regs into the OLD rtcb. - */ + up_savestate(rtcb->xcp.regs); - up_savestate(rtcb->xcp.regs); + /* Restore the exception context of the rtcb at the (new) head + * of the g_readytorun task list. + */ - /* Restore the exception context of the rtcb at the (new) head - * of the g_readytorun task list. - */ + rtcb = (struct tcb_s*)g_readytorun.head; - rtcb = (struct tcb_s*)g_readytorun.head; + /* Then switch contexts */ - /* Then switch contexts */ + up_restorestate(rtcb->xcp.regs); + } - up_restorestate(rtcb->xcp.regs); - } + /* We are not in an interrupt handler. Copy the user C context + * into the TCB of the task that was previously active. if + * up_saveusercontext returns a non-zero value, then this is really the + * previously running task restarting! + */ - /* We are not in an interrupt handler. Copy the user C context - * into the TCB of the task that was previously active. 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 new task that is ready to + * run (probably tcb). This is the new rtcb at the head of the + * g_readytorun task list. */ - else if (!up_saveusercontext(rtcb->xcp.regs)) - { - /* 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. - */ - - rtcb = (struct tcb_s*)g_readytorun.head; + rtcb = (struct tcb_s*)g_readytorun.head; - /* Then switch contexts */ + /* Then switch contexts */ - up_fullcontextrestore(rtcb->xcp.regs); - } + up_fullcontextrestore(rtcb->xcp.regs); } } } diff --git a/nuttx/arch/hc/src/m9s12/m9s12_assert.c b/nuttx/arch/hc/src/m9s12/m9s12_assert.c index 9f97ec4db..69d5e3c73 100644 --- a/nuttx/arch/hc/src/m9s12/m9s12_assert.c +++ b/nuttx/arch/hc/src/m9s12/m9s12_assert.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/hc/src/m9s12/m9s12_assert.c * - * Copyright (C) 2011-2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2011-2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without @@ -286,6 +286,7 @@ void up_assert(const uint8_t *filename, int lineno) #endif up_ledon(LED_ASSERTION); + #ifdef CONFIG_PRINT_TASKNAME lldbg("Assertion failed at file:%s line: %d task: %s\n", filename, lineno, rtcb->name); @@ -293,29 +294,7 @@ void up_assert(const uint8_t *filename, int lineno) lldbg("Assertion failed at file:%s line: %d\n", filename, lineno); #endif - up_dumpstate(); - _up_assert(EXIT_FAILURE); -} - -/**************************************************************************** - * Name: up_assert_code - ****************************************************************************/ - -void up_assert_code(const uint8_t *filename, int lineno, int errorcode) -{ -#ifdef CONFIG_PRINT_TASKNAME - struct tcb_s *rtcb = (struct tcb_s*)g_readytorun.head; -#endif - - up_ledon(LED_ASSERTION); -#ifdef CONFIG_PRINT_TASKNAME - lldbg("Assertion failed at file:%s line: %d task: %s error code: %d\n", - filename, lineno, rtcb->name, errorcode); -#else - lldbg("Assertion failed at file:%s line: %d error code: %d\n", - filename, lineno, errorcode); -#endif up_dumpstate(); - _up_assert(errorcode); + _up_assert(EXIT_FAILURE); } diff --git a/nuttx/arch/hc/src/m9s12/m9s12_serial.c b/nuttx/arch/hc/src/m9s12/m9s12_serial.c index 24d3e7765..bb61d7dbc 100644 --- a/nuttx/arch/hc/src/m9s12/m9s12_serial.c +++ b/nuttx/arch/hc/src/m9s12/m9s12_serial.c @@ -483,7 +483,7 @@ static int up_interrupt(int irq, void *context) else #endif { - PANIC(OSERR_INTERNAL); + PANIC(); } priv = (struct up_dev_s*)dev->priv; |