From 1ffc15c3233c8d61953fc2ebc80b5d3c46fc429f Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 25 Apr 2013 15:19:59 -0600 Subject: Remove up_assert_code --- nuttx/ChangeLog | 5 + nuttx/Documentation/NuttxPortingGuide.html | 6 +- nuttx/arch/8051/src/up_assert.c | 26 +---- nuttx/arch/8051/src/up_blocktask.c | 113 ++++++++++--------- nuttx/arch/8051/src/up_reprioritizertr.c | 2 +- nuttx/arch/8051/src/up_unblocktask.c | 137 ++++++++++++------------ nuttx/arch/arm/src/arm/up_assert.c | 26 +---- nuttx/arch/arm/src/arm/up_blocktask.c | 107 +++++++++--------- nuttx/arch/arm/src/arm/up_dataabort.c | 6 +- nuttx/arch/arm/src/arm/up_doirq.c | 4 +- nuttx/arch/arm/src/arm/up_prefetchabort.c | 4 +- nuttx/arch/arm/src/arm/up_reprioritizertr.c | 4 +- nuttx/arch/arm/src/arm/up_syscall.c | 2 +- nuttx/arch/arm/src/arm/up_unblocktask.c | 95 ++++++++-------- nuttx/arch/arm/src/arm/up_undefinedinsn.c | 4 +- nuttx/arch/arm/src/armv6-m/up_assert.c | 24 +---- nuttx/arch/arm/src/armv6-m/up_blocktask.c | 111 +++++++++---------- nuttx/arch/arm/src/armv6-m/up_doirq.c | 2 +- nuttx/arch/arm/src/armv6-m/up_hardfault.c | 4 +- nuttx/arch/arm/src/armv6-m/up_reprioritizertr.c | 2 +- nuttx/arch/arm/src/armv6-m/up_unblocktask.c | 93 ++++++++-------- nuttx/arch/arm/src/armv7-m/up_assert.c | 24 +---- nuttx/arch/arm/src/armv7-m/up_blocktask.c | 113 ++++++++++--------- nuttx/arch/arm/src/armv7-m/up_doirq.c | 4 +- nuttx/arch/arm/src/armv7-m/up_hardfault.c | 2 +- nuttx/arch/arm/src/armv7-m/up_memfault.c | 6 +- nuttx/arch/arm/src/armv7-m/up_reprioritizertr.c | 2 +- nuttx/arch/arm/src/armv7-m/up_unblocktask.c | 93 ++++++++-------- nuttx/arch/arm/src/c5471/c5471_serial.c | 2 +- nuttx/arch/arm/src/calypso/calypso_serial.c | 2 +- nuttx/arch/arm/src/dm320/dm320_decodeirq.c | 2 +- nuttx/arch/arm/src/dm320/dm320_serial.c | 2 +- nuttx/arch/arm/src/imx/imx_decodeirq.c | 2 +- nuttx/arch/arm/src/imx/imx_serial.c | 2 +- nuttx/arch/arm/src/kinetis/kinetis_irq.c | 12 +-- nuttx/arch/arm/src/kinetis/kinetis_serial.c | 4 +- nuttx/arch/arm/src/kl/kl_irq.c | 6 +- nuttx/arch/arm/src/kl/kl_serial.c | 2 +- nuttx/arch/arm/src/lm/lm_irq.c | 12 +-- nuttx/arch/arm/src/lm/lm_serial.c | 2 +- nuttx/arch/arm/src/lpc17xx/lpc17_i2c.c | 2 +- nuttx/arch/arm/src/lpc17xx/lpc17_irq.c | 12 +-- nuttx/arch/arm/src/lpc17xx/lpc17_serial.c | 2 +- nuttx/arch/arm/src/lpc214x/lpc214x_decodeirq.c | 2 +- nuttx/arch/arm/src/lpc214x/lpc214x_serial.c | 2 +- nuttx/arch/arm/src/lpc2378/lpc23xx_decodeirq.c | 2 +- nuttx/arch/arm/src/lpc2378/lpc23xx_serial.c | 2 +- nuttx/arch/arm/src/lpc31xx/lpc31_decodeirq.c | 2 +- nuttx/arch/arm/src/lpc43xx/lpc43_i2c.c | 2 +- nuttx/arch/arm/src/lpc43xx/lpc43_irq.c | 12 +-- nuttx/arch/arm/src/lpc43xx/lpc43_serial.c | 2 +- nuttx/arch/arm/src/nuc1xx/nuc_irq.c | 6 +- nuttx/arch/arm/src/nuc1xx/nuc_serial.c | 2 +- nuttx/arch/arm/src/sam3u/sam3u_irq.c | 12 +-- nuttx/arch/arm/src/sam3u/sam3u_serial.c | 2 +- nuttx/arch/arm/src/stm32/stm32_can.c | 4 +- nuttx/arch/arm/src/stm32/stm32_irq.c | 12 +-- nuttx/arch/arm/src/stm32/stm32f10xxx_dma.c | 2 +- nuttx/arch/arm/src/stm32/stm32f20xxx_dma.c | 2 +- nuttx/arch/arm/src/stm32/stm32f40xxx_dma.c | 2 +- nuttx/arch/arm/src/str71x/str71x_decodeirq.c | 4 +- nuttx/arch/arm/src/str71x/str71x_serial.c | 2 +- nuttx/arch/avr/src/at32uc3/at32uc3_irq.c | 2 +- nuttx/arch/avr/src/at32uc3/at32uc3_serial.c | 2 +- nuttx/arch/avr/src/avr/up_blocktask.c | 113 ++++++++++--------- nuttx/arch/avr/src/avr/up_doirq.c | 2 +- nuttx/arch/avr/src/avr/up_reprioritizertr.c | 2 +- nuttx/arch/avr/src/avr/up_unblocktask.c | 95 ++++++++-------- nuttx/arch/avr/src/avr32/up_blocktask.c | 113 ++++++++++--------- nuttx/arch/avr/src/avr32/up_doirq.c | 2 +- nuttx/arch/avr/src/avr32/up_reprioritizertr.c | 2 +- nuttx/arch/avr/src/avr32/up_unblocktask.c | 95 ++++++++-------- nuttx/arch/avr/src/common/up_assert.c | 27 +---- nuttx/arch/hc/src/common/up_blocktask.c | 107 +++++++++--------- nuttx/arch/hc/src/common/up_doirq.c | 2 +- nuttx/arch/hc/src/common/up_reprioritizertr.c | 2 +- nuttx/arch/hc/src/common/up_unblocktask.c | 95 ++++++++-------- nuttx/arch/hc/src/m9s12/m9s12_assert.c | 27 +---- nuttx/arch/hc/src/m9s12/m9s12_serial.c | 2 +- nuttx/arch/mips/src/common/up_exit.c | 2 +- nuttx/arch/mips/src/mips32/up_assert.c | 25 +---- nuttx/arch/mips/src/mips32/up_blocktask.c | 113 ++++++++++--------- nuttx/arch/mips/src/mips32/up_doirq.c | 2 +- nuttx/arch/mips/src/mips32/up_reprioritizertr.c | 2 +- nuttx/arch/mips/src/mips32/up_sigdeliver.c | 2 +- nuttx/arch/mips/src/mips32/up_unblocktask.c | 95 ++++++++-------- nuttx/arch/mips/src/pic32mx/pic32mx-exception.c | 2 +- nuttx/arch/mips/src/pic32mx/pic32mx-serial.c | 2 +- nuttx/arch/rgmp/src/nuttx.c | 17 --- nuttx/arch/sh/src/common/up_assert.c | 26 +---- nuttx/arch/sh/src/common/up_blocktask.c | 107 +++++++++--------- nuttx/arch/sh/src/common/up_doirq.c | 2 +- nuttx/arch/sh/src/common/up_reprioritizertr.c | 2 +- nuttx/arch/sh/src/common/up_unblocktask.c | 95 ++++++++-------- nuttx/arch/sh/src/m16c/m16c_serial.c | 4 +- nuttx/arch/sh/src/sh1/sh1_serial.c | 2 +- nuttx/arch/sim/src/up_blocktask.c | 102 +++++++++--------- nuttx/arch/sim/src/up_head.c | 8 +- nuttx/arch/sim/src/up_reprioritizertr.c | 2 +- nuttx/arch/sim/src/up_unblocktask.c | 104 +++++++++--------- nuttx/arch/x86/src/common/up_assert.c | 27 +---- nuttx/arch/x86/src/common/up_blocktask.c | 107 +++++++++--------- nuttx/arch/x86/src/common/up_reprioritizertr.c | 2 +- nuttx/arch/x86/src/common/up_unblocktask.c | 95 ++++++++-------- nuttx/arch/x86/src/qemu/qemu_handlers.c | 4 +- nuttx/arch/z16/src/common/up_assert.c | 39 +------ nuttx/arch/z16/src/common/up_blocktask.c | 115 ++++++++++---------- nuttx/arch/z16/src/common/up_doirq.c | 2 +- nuttx/arch/z16/src/common/up_reprioritizertr.c | 2 +- nuttx/arch/z16/src/common/up_unblocktask.c | 105 +++++++++--------- nuttx/arch/z16/src/z16f/z16f_serial.c | 4 +- nuttx/arch/z16/src/z16f/z16f_sysexec.c | 12 ++- nuttx/arch/z80/src/common/up_assert.c | 39 +------ nuttx/arch/z80/src/common/up_blocktask.c | 115 ++++++++++---------- nuttx/arch/z80/src/common/up_doirq.c | 2 +- nuttx/arch/z80/src/common/up_reprioritizertr.c | 2 +- nuttx/arch/z80/src/common/up_unblocktask.c | 105 +++++++++--------- nuttx/arch/z80/src/ez80/ez80_serial.c | 2 +- nuttx/arch/z80/src/z8/z8_serial.c | 4 +- nuttx/configs/stm3210e-eval/RIDE/bigfatstub.c | 2 +- nuttx/include/assert.h | 15 +-- nuttx/include/nuttx/arch.h | 5 +- nuttx/include/sys/syscall.h | 3 +- nuttx/libxx/libxx_cxapurevirtual.cxx | 4 +- nuttx/sched/irq_unexpectedisr.c | 4 +- nuttx/sched/mq_msgfree.c | 4 +- nuttx/sched/mq_rcvinternal.c | 17 ++- nuttx/sched/mq_sndinternal.c | 29 ++--- nuttx/sched/mq_waitirq.c | 32 +----- nuttx/sched/os_internal.h | 30 ------ nuttx/sched/sched_mergepending.c | 59 +++++----- nuttx/sched/sem_wait.c | 5 +- nuttx/sched/sig_action.c | 5 +- nuttx/sched/sig_dispatch.c | 5 +- nuttx/sched/sig_suspend.c | 5 +- nuttx/sched/sig_timedwait.c | 13 +-- nuttx/sched/task_delete.c | 2 +- nuttx/sched/wd_cancel.c | 48 ++++----- nuttx/sched/wd_start.c | 2 +- nuttx/syscall/syscall.csv | 2 - nuttx/syscall/syscall_lookup.h | 1 - nuttx/syscall/syscall_stublookup.c | 2 - 142 files changed, 1560 insertions(+), 2086 deletions(-) diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index ada4463bc..dcaf04410 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -4623,3 +4623,8 @@ KL architecture directory as need to get the interrupt-driven serial driver to work. The Freedom KL25Z NSH configuration now works (2014-4-25). + * include/nuttx/assert.h, arch/*/src/*/up_assert.c, and other file: + Remove up_assert_code(). While asserting with an encoded value + could be a good feature, the codes have not be well utilized nor + documented. Give that situation it is better to remove the API + and reduce the footprint a little (2014-4-25). diff --git a/nuttx/Documentation/NuttxPortingGuide.html b/nuttx/Documentation/NuttxPortingGuide.html index 642cb1a3c..bb457ffd3 100644 --- a/nuttx/Documentation/NuttxPortingGuide.html +++ b/nuttx/Documentation/NuttxPortingGuide.html @@ -1910,13 +1910,11 @@ The system can be re-made subsequently by just typing make.

4.1.13 up_assert()

Prototype:
- void up_assert(FAR const uint8_t *filename, int linenum);
- void up_assert_code(FAR const uint8_t *filename, int linenum, int error_code);
+ void up_assert(FAR const uint8_t *filename, int linenum);

Description. - Assertions may be handled in an architecture-specific - way. + Assertions may be handled in an architecture-specific way.

4.1.14 up_schedule_sigaction()

diff --git a/nuttx/arch/8051/src/up_assert.c b/nuttx/arch/8051/src/up_assert.c index f1f9bb87f..53e74feb7 100644 --- a/nuttx/arch/8051/src/up_assert.c +++ b/nuttx/arch/8051/src/up_assert.c @@ -1,7 +1,7 @@ /************************************************************************ * up_assert.c * - * Copyright (C) 2007, 2009, 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2009, 2012-2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -116,27 +116,3 @@ void up_assert(const uint8_t *filename, int lineno) up_dumpstack(); _up_assert(EXIT_FAILURE); } - -/************************************************************************ - * Name: up_assert_code - ************************************************************************/ - -void up_assert_code(const uint8_t *filename, int lineno, int errorcode) -{ -#if CONFIG_TASK_NAME_SIZE > 0 - struct tcb_s *rtcb = (struct tcb_s*)g_readytorun.head; -#endif - - up_ledon(LED_ASSERTION); - -#if CONFIG_TASK_NAME_SIZE > 0 - 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_dumpstack(); - _up_assert(errorcode); -} diff --git a/nuttx/arch/8051/src/up_blocktask.c b/nuttx/arch/8051/src/up_blocktask.c index 554111ae0..018577477 100644 --- a/nuttx/arch/8051/src/up_blocktask.c +++ b/nuttx/arch/8051/src/up_blocktask.c @@ -85,88 +85,83 @@ void up_block_task(FAR struct tcb_s *tcb, tstate_t task_state) { + FAR struct tcb_s *rtcb = (FAR 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 - { - FAR struct tcb_s *rtcb = (FAR struct tcb_s*)g_readytorun.head; - bool switch_needed; + ASSERT((tcb->task_state >= FIRST_READY_TO_RUN_STATE) && + (tcb->task_state <= LAST_READY_TO_RUN_STATE)); - dbg("Blocking TCB=%p\n", tcb); + dbg("Blocking TCB=%p\n", 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. - */ + /* 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. + */ - switch_needed = sched_removereadytorun(tcb); + switch_needed = sched_removereadytorun(tcb); - /* Add the task to the specified blocked task list */ + /* Add the task to the specified blocked task list */ - 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 - * task list now - */ + /* If there are any pending tasks, then add them to the g_readytorun + * task list now + */ - if (g_pendingtasks.head) - { - switch_needed |= sched_mergepending(); - } + if (g_pendingtasks.head) + { + switch_needed |= sched_mergepending(); + } - /* Now, perform the context switch if one is needed */ + /* Now, perform the context switch if one is needed */ - if (switch_needed) + if (switch_needed) + { + /* Are we in an interrupt handler? */ + + if (g_irqtos) { - /* Are we in an interrupt handler? */ + /* Yes, then we have to do things differently. + * Just copy the current registers into the OLD rtcb. + */ - if (g_irqtos) - { - /* Yes, then we have to do things differently. - * Just copy the current registers into the OLD rtcb. - */ + up_saveirqcontext(&tcb->xcp); - up_saveirqcontext(&tcb->xcp); + /* 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 = (FAR struct tcb_s*)g_readytorun.head; + dbg("New Active Task TCB=%p\n", rtcb); - rtcb = (FAR struct tcb_s*)g_readytorun.head; - dbg("New Active Task TCB=%p\n", rtcb); + /* Then setup so that the context will be performed on exit + * from the interrupt. + */ - /* Then setup so that the context will be performed on exit - * from the interrupt. - */ + g_irqcontext = &rtcb->xcp; + } - g_irqcontext = &rtcb->xcp; - } + /* Copy the user C context into the TCB at the (old) head of the + * g_readytorun Task list. if up_savecontext 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_savecontext returns a non-zero - * value, then this is really the previously running task restarting! + else if (!up_savecontext(&rtcb->xcp)) + { + /* Restore the exception context of the rtcb at the (new) head + * of the g_readytorun task list. */ - else if (!up_savecontext(&rtcb->xcp)) - { - /* Restore the exception context of the rtcb at the (new) head - * of the g_readytorun task list. - */ - - rtcb = (FAR struct tcb_s*)g_readytorun.head; - dbg("New Active Task TCB=%p\n", rtcb); + rtcb = (FAR struct tcb_s*)g_readytorun.head; + dbg("New Active Task TCB=%p\n", rtcb); - /* Then switch contexts */ + /* Then switch contexts */ - up_restorecontext(&rtcb->xcp); - } + up_restorecontext(&rtcb->xcp); } } } diff --git a/nuttx/arch/8051/src/up_reprioritizertr.c b/nuttx/arch/8051/src/up_reprioritizertr.c index 14c14e663..649db3a43 100644 --- a/nuttx/arch/8051/src/up_reprioritizertr.c +++ b/nuttx/arch/8051/src/up_reprioritizertr.c @@ -99,7 +99,7 @@ void up_reprioritize_rtr(FAR struct tcb_s *tcb, uint8_t priority) #endif ) { - PANIC(OSERR_BADREPRIORITIZESTATE); + PANIC(); } else { diff --git a/nuttx/arch/8051/src/up_unblocktask.c b/nuttx/arch/8051/src/up_unblocktask.c index f3f921549..621c8a783 100644 --- a/nuttx/arch/8051/src/up_unblocktask.c +++ b/nuttx/arch/8051/src/up_unblocktask.c @@ -1,7 +1,7 @@ /************************************************************************ * up_unblocktask.c * - * Copyright (C) 2007, 2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2009, 2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -82,85 +82,80 @@ void up_unblock_task(FAR struct tcb_s *tcb) { + FAR struct tcb_s *rtcb = (FAR 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 - { - FAR struct tcb_s *rtcb = (FAR struct tcb_s*)g_readytorun.head; + ASSERT((tcb->task_state >= FIRST_BLOCKED_STATE) && + (tcb->task_state <= LAST_BLOCKED_STATE)); - dbg("Unblocking TCB=%p\n", tcb); + dbg("Unblocking TCB=%p\n", tcb); - /* 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 - */ - - 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 (g_irqtos) - { - /* Yes, then we have to do things differently. - * Just copy the current stack into the OLD rtcb. - */ - - up_saveirqcontext(&rtcb->xcp); - - /* Restore the exception context of the rtcb at the (new) head - * of the g_readytorun task list. - */ - - rtcb = (FAR struct tcb_s*)g_readytorun.head; - dbg("New Active Task TCB=%p\n", rtcb); - - /* Then setup so that the context will be performed on exit - * from the interrupt. - */ - - g_irqcontext = &rtcb->xcp; - } - - /* We are not in an interrupt andler. Copy the user C context - * into the TCB of the task that was previously active. if - * up_savecontext returns a non-zero value, then this is really the - * previously running task restarting! - */ - - else if (!up_savecontext(&rtcb->xcp)) - { - /* 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 = (FAR struct tcb_s*)g_readytorun.head; - dbg("New Active Task TCB=%p\n", rtcb); - - /* Then switch contexts */ - - up_restorecontext(&rtcb->xcp); - } - } + /* 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 (g_irqtos) + { + /* Yes, then we have to do things differently. + * Just copy the current stack into the OLD rtcb. + */ + + up_saveirqcontext(&rtcb->xcp); + + /* Restore the exception context of the rtcb at the (new) head + * of the g_readytorun task list. + */ + + rtcb = (FAR struct tcb_s*)g_readytorun.head; + dbg("New Active Task TCB=%p\n", rtcb); + + /* Then setup so that the context will be performed on exit + * from the interrupt. + */ + + g_irqcontext = &rtcb->xcp; + } + + /* We are not in an interrupt andler. Copy the user C context + * into the TCB of the task that was previously active. if + * up_savecontext returns a non-zero value, then this is really the + * previously running task restarting! + */ + + else if (!up_savecontext(&rtcb->xcp)) + { + /* 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 = (FAR struct tcb_s*)g_readytorun.head; + dbg("New Active Task TCB=%p\n", rtcb); + + /* Then switch contexts */ + + up_restorecontext(&rtcb->xcp); + } } } diff --git a/nuttx/arch/arm/src/arm/up_assert.c b/nuttx/arch/arm/src/arm/up_assert.c index e5bf00d6e..03f6e4d8f 100644 --- a/nuttx/arch/arm/src/arm/up_assert.c +++ b/nuttx/arch/arm/src/arm/up_assert.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/arm/up_assert.c * - * Copyright (C) 2007-2010, 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2010, 2012-2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -291,6 +291,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); @@ -301,26 +302,3 @@ void up_assert(const uint8_t *filename, int lineno) 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); -} diff --git a/nuttx/arch/arm/src/arm/up_blocktask.c b/nuttx/arch/arm/src/arm/up_blocktask.c index 090cc6407..04caa4481 100644 --- a/nuttx/arch/arm/src/arm/up_blocktask.c +++ b/nuttx/arch/arm/src/arm/up_blocktask.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/arm/up_blocktask.c * - * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * 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/arm/src/arm/up_dataabort.c b/nuttx/arch/arm/src/arm/up_dataabort.c index 99b3bf2ab..d5e652856 100644 --- a/nuttx/arch/arm/src/arm/up_dataabort.c +++ b/nuttx/arch/arm/src/arm/up_dataabort.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/arm/up_dataabort.c * - * Copyright (C) 2007-2011 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2011, 2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -179,7 +179,7 @@ void up_dataabort(uint32_t *regs, uint32_t far, uint32_t fsr) segfault: #endif lldbg("Data abort. PC: %08x FAR: %08x FSR: %08x\n", regs[REG_PC], far, fsr); - PANIC(OSERR_ERREXCEPTION); + PANIC(); } #else /* CONFIG_PAGING */ @@ -195,7 +195,7 @@ void up_dataabort(uint32_t *regs) /* Crash -- possibly showing diagnost debug information. */ lldbg("Data abort. PC: %08x\n", regs[REG_PC]); - PANIC(OSERR_ERREXCEPTION); + PANIC(); } #endif /* CONFIG_PAGING */ diff --git a/nuttx/arch/arm/src/arm/up_doirq.c b/nuttx/arch/arm/src/arm/up_doirq.c index 7cd1a6a1b..3b47a56b0 100644 --- a/nuttx/arch/arm/src/arm/up_doirq.c +++ b/nuttx/arch/arm/src/arm/up_doirq.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/arm/up_doirq.c * - * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2011, 2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -74,7 +74,7 @@ void up_doirq(int irq, uint32_t *regs) { up_ledon(LED_INIRQ); #ifdef CONFIG_SUPPRESS_INTERRUPTS - PANIC(OSERR_ERREXCEPTION); + PANIC(); #else uint32_t *savestate; diff --git a/nuttx/arch/arm/src/arm/up_prefetchabort.c b/nuttx/arch/arm/src/arm/up_prefetchabort.c index 541586de9..78ca496ab 100644 --- a/nuttx/arch/arm/src/arm/up_prefetchabort.c +++ b/nuttx/arch/arm/src/arm/up_prefetchabort.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/src/up_prefetchabort.c * - * Copyright (C) 2007-2011 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2011, 2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -149,6 +149,6 @@ void up_prefetchabort(uint32_t *regs) #endif { lldbg("Prefetch abort. PC: %08x\n", regs[REG_PC]); - PANIC(OSERR_ERREXCEPTION); + PANIC(); } } diff --git a/nuttx/arch/arm/src/arm/up_reprioritizertr.c b/nuttx/arch/arm/src/arm/up_reprioritizertr.c index 769794083..9d898ed7b 100644 --- a/nuttx/arch/arm/src/arm/up_reprioritizertr.c +++ b/nuttx/arch/arm/src/arm/up_reprioritizertr.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/arm/up_reprioritizertr.c * - * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -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/arm/src/arm/up_syscall.c b/nuttx/arch/arm/src/arm/up_syscall.c index eb9bac8ad..db3231646 100644 --- a/nuttx/arch/arm/src/arm/up_syscall.c +++ b/nuttx/arch/arm/src/arm/up_syscall.c @@ -92,5 +92,5 @@ void up_syscall(uint32_t *regs) { lldbg("Syscall from 0x%x\n", regs[REG_PC]); current_regs = regs; - PANIC(OSERR_ERREXCEPTION); + PANIC(); } diff --git a/nuttx/arch/arm/src/arm/up_unblocktask.c b/nuttx/arch/arm/src/arm/up_unblocktask.c index a2dc0f694..2e373f38e 100644 --- a/nuttx/arch/arm/src/arm/up_unblocktask.c +++ b/nuttx/arch/arm/src/arm/up_unblocktask.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/arm/up_unblocktask.c * - * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * 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/arm/src/arm/up_undefinedinsn.c b/nuttx/arch/arm/src/arm/up_undefinedinsn.c index 88e3a79d9..dd4f15e35 100644 --- a/nuttx/arch/arm/src/arm/up_undefinedinsn.c +++ b/nuttx/arch/arm/src/arm/up_undefinedinsn.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/arm/up_undefinedinsn.c * - * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -77,5 +77,5 @@ void up_undefinedinsn(uint32_t *regs) { lldbg("Undefined instruction at 0x%x\n", regs[REG_PC]); current_regs = regs; - PANIC(OSERR_UNDEFINEDINSN); + PANIC(); } diff --git a/nuttx/arch/arm/src/armv6-m/up_assert.c b/nuttx/arch/arm/src/armv6-m/up_assert.c index 86347672e..3afef2dff 100644 --- a/nuttx/arch/arm/src/armv6-m/up_assert.c +++ b/nuttx/arch/arm/src/armv6-m/up_assert.c @@ -307,6 +307,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); @@ -314,28 +315,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/arm/src/armv6-m/up_blocktask.c b/nuttx/arch/arm/src/armv6-m/up_blocktask.c index a332cbefd..57db2b4aa 100644 --- a/nuttx/arch/arm/src/armv6-m/up_blocktask.c +++ b/nuttx/arch/arm/src/armv6-m/up_blocktask.c @@ -85,82 +85,77 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state) { - /* 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; + 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. - */ + /* Verify that the context switch can be performed */ - switch_needed = sched_removereadytorun(tcb); + ASSERT((tcb->task_state >= FIRST_READY_TO_RUN_STATE) && + (tcb->task_state <= LAST_READY_TO_RUN_STATE)); - /* Add the task to the specified blocked task list */ + /* 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. + */ - sched_addblocked(tcb, (tstate_t)task_state); + switch_needed = sched_removereadytorun(tcb); - /* If there are any pending tasks, then add them to the g_readytorun - * task list now - */ + /* Add the task to the specified blocked task list */ - if (g_pendingtasks.head) - { - switch_needed |= sched_mergepending(); - } + sched_addblocked(tcb, (tstate_t)task_state); - /* Now, perform the context switch if one is needed */ + /* If there are any pending tasks, then add them to the g_readytorun + * task list now + */ - if (switch_needed) - { - /* Are we in an interrupt handler? */ + if (g_pendingtasks.head) + { + switch_needed |= sched_mergepending(); + } - if (current_regs) - { - /* Yes, then we have to do things differently. - * Just copy the current_regs into the OLD rtcb. - */ + /* Now, perform the context switch if one is needed */ - up_savestate(rtcb->xcp.regs); + if (switch_needed) + { + /* Are we in an interrupt handler? */ - /* Restore the exception context of the rtcb at the (new) head - * of the g_readytorun task list. - */ + if (current_regs) + { + /* Yes, then we have to do things differently. + * Just copy the current_regs into the OLD rtcb. + */ - rtcb = (struct tcb_s*)g_readytorun.head; + up_savestate(rtcb->xcp.regs); - /* Then switch contexts */ + /* Restore the exception context of the rtcb at the (new) head + * of the g_readytorun task list. + */ - up_restorestate(rtcb->xcp.regs); - } + rtcb = (struct tcb_s*)g_readytorun.head; - /* No, then we will need to perform the user context switch */ + /* Then switch contexts */ - else - { - /* Switch context to the context of the task at the head of the - * ready to run list. - */ + up_restorestate(rtcb->xcp.regs); + } - struct tcb_s *nexttcb = (struct tcb_s*)g_readytorun.head; - up_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs); + /* No, then we will need to perform the user context switch */ - /* up_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. - */ - } + else + { + /* Switch context to the context of the task at the head of the + * ready to run list. + */ + + struct tcb_s *nexttcb = (struct tcb_s*)g_readytorun.head; + up_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs); + + /* up_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. + */ } } } diff --git a/nuttx/arch/arm/src/armv6-m/up_doirq.c b/nuttx/arch/arm/src/armv6-m/up_doirq.c index 7dec21152..2edbc55dd 100644 --- a/nuttx/arch/arm/src/armv6-m/up_doirq.c +++ b/nuttx/arch/arm/src/armv6-m/up_doirq.c @@ -74,7 +74,7 @@ uint32_t *up_doirq(int irq, uint32_t *regs) { up_ledon(LED_INIRQ); #ifdef CONFIG_SUPPRESS_INTERRUPTS - PANIC(OSERR_ERREXCEPTION); + PANIC(); #else uint32_t *savestate; diff --git a/nuttx/arch/arm/src/armv6-m/up_hardfault.c b/nuttx/arch/arm/src/armv6-m/up_hardfault.c index 049f71d05..a2a0982a7 100644 --- a/nuttx/arch/arm/src/armv6-m/up_hardfault.c +++ b/nuttx/arch/arm/src/armv6-m/up_hardfault.c @@ -151,6 +151,6 @@ int up_hardfault(int irq, FAR void *context) (void)irqsave(); lldbg("PANIC!!! Hard fault\n"); - PANIC(OSERR_UNEXPECTEDISR); - return OK; + PANIC(); + return OK; /* Won't get here */ } diff --git a/nuttx/arch/arm/src/armv6-m/up_reprioritizertr.c b/nuttx/arch/arm/src/armv6-m/up_reprioritizertr.c index 0bc0d4170..07eeef14b 100644 --- a/nuttx/arch/arm/src/armv6-m/up_reprioritizertr.c +++ b/nuttx/arch/arm/src/armv6-m/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/arm/src/armv6-m/up_unblocktask.c b/nuttx/arch/arm/src/armv6-m/up_unblocktask.c index c496a8f43..e4bfede97 100644 --- a/nuttx/arch/arm/src/armv6-m/up_unblocktask.c +++ b/nuttx/arch/arm/src/armv6-m/up_unblocktask.c @@ -80,77 +80,72 @@ 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); + } - /* No, then we will need to perform the user context switch */ + /* No, then we will need to perform the user context switch */ - else - { - /* Switch context to the context of the task at the head of the - * ready to run list. - */ + else + { + /* Switch context to the context of the task at the head of the + * ready to run list. + */ - struct tcb_s *nexttcb = (struct tcb_s*)g_readytorun.head; - up_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs); + struct tcb_s *nexttcb = (struct tcb_s*)g_readytorun.head; + up_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs); - /* up_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. - */ - } + /* up_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. + */ } } } diff --git a/nuttx/arch/arm/src/armv7-m/up_assert.c b/nuttx/arch/arm/src/armv7-m/up_assert.c index b0df6d729..5d14ff34a 100644 --- a/nuttx/arch/arm/src/armv7-m/up_assert.c +++ b/nuttx/arch/arm/src/armv7-m/up_assert.c @@ -318,6 +318,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); @@ -325,28 +326,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/arm/src/armv7-m/up_blocktask.c b/nuttx/arch/arm/src/armv7-m/up_blocktask.c index 15558ed4d..8caf4a2b6 100644 --- a/nuttx/arch/arm/src/armv7-m/up_blocktask.c +++ b/nuttx/arch/arm/src/armv7-m/up_blocktask.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/armv7-m/up_blocktask.c * - * Copyright (C) 2007-2009, 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2012-2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * 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) { - /* 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; + 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. - */ + /* Verify that the context switch can be performed */ - switch_needed = sched_removereadytorun(tcb); + ASSERT((tcb->task_state >= FIRST_READY_TO_RUN_STATE) && + (tcb->task_state <= LAST_READY_TO_RUN_STATE)); - /* Add the task to the specified blocked task list */ + /* 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. + */ - sched_addblocked(tcb, (tstate_t)task_state); + switch_needed = sched_removereadytorun(tcb); - /* If there are any pending tasks, then add them to the g_readytorun - * task list now - */ + /* Add the task to the specified blocked task list */ - if (g_pendingtasks.head) - { - switch_needed |= sched_mergepending(); - } + sched_addblocked(tcb, (tstate_t)task_state); - /* Now, perform the context switch if one is needed */ + /* If there are any pending tasks, then add them to the g_readytorun + * task list now + */ - if (switch_needed) - { - /* Are we in an interrupt handler? */ + if (g_pendingtasks.head) + { + switch_needed |= sched_mergepending(); + } - if (current_regs) - { - /* Yes, then we have to do things differently. - * Just copy the current_regs into the OLD rtcb. - */ + /* Now, perform the context switch if one is needed */ - up_savestate(rtcb->xcp.regs); + if (switch_needed) + { + /* Are we in an interrupt handler? */ - /* Restore the exception context of the rtcb at the (new) head - * of the g_readytorun task list. - */ + if (current_regs) + { + /* Yes, then we have to do things differently. + * Just copy the current_regs into the OLD rtcb. + */ - rtcb = (struct tcb_s*)g_readytorun.head; + up_savestate(rtcb->xcp.regs); - /* Then switch contexts */ + /* Restore the exception context of the rtcb at the (new) head + * of the g_readytorun task list. + */ - up_restorestate(rtcb->xcp.regs); - } + rtcb = (struct tcb_s*)g_readytorun.head; - /* No, then we will need to perform the user context switch */ + /* Then switch contexts */ - else - { - /* Switch context to the context of the task at the head of the - * ready to run list. - */ + up_restorestate(rtcb->xcp.regs); + } - struct tcb_s *nexttcb = (struct tcb_s*)g_readytorun.head; - up_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs); + /* No, then we will need to perform the user context switch */ - /* up_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. - */ - } + else + { + /* Switch context to the context of the task at the head of the + * ready to run list. + */ + + struct tcb_s *nexttcb = (struct tcb_s*)g_readytorun.head; + up_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs); + + /* up_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. + */ } } } diff --git a/nuttx/arch/arm/src/armv7-m/up_doirq.c b/nuttx/arch/arm/src/armv7-m/up_doirq.c index 6063f9ca1..d8a1446de 100644 --- a/nuttx/arch/arm/src/armv7-m/up_doirq.c +++ b/nuttx/arch/arm/src/armv7-m/up_doirq.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/armv7-m/up_doirq.c * - * Copyright (C) 2009, 2011 Gregory Nutt. All rights reserved. + * Copyright (C) 2009, 2011, 2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -74,7 +74,7 @@ uint32_t *up_doirq(int irq, uint32_t *regs) { up_ledon(LED_INIRQ); #ifdef CONFIG_SUPPRESS_INTERRUPTS - PANIC(OSERR_ERREXCEPTION); + PANIC(); #else uint32_t *savestate; diff --git a/nuttx/arch/arm/src/armv7-m/up_hardfault.c b/nuttx/arch/arm/src/armv7-m/up_hardfault.c index e43b18cb3..d99473bde 100644 --- a/nuttx/arch/arm/src/armv7-m/up_hardfault.c +++ b/nuttx/arch/arm/src/armv7-m/up_hardfault.c @@ -181,6 +181,6 @@ int up_hardfault(int irq, FAR void *context) (void)irqsave(); lldbg("PANIC!!! Hard fault: %08x\n", getreg32(NVIC_HFAULTS)); - PANIC(OSERR_UNEXPECTEDISR); + PANIC(); return OK; } diff --git a/nuttx/arch/arm/src/armv7-m/up_memfault.c b/nuttx/arch/arm/src/armv7-m/up_memfault.c index c9f1b57b1..6ab160d03 100644 --- a/nuttx/arch/arm/src/armv7-m/up_memfault.c +++ b/nuttx/arch/arm/src/armv7-m/up_memfault.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/arm/src/armv7-m/up_memfault.c * - * Copyright (C) 2011 Gregory Nutt. All rights reserved. + * Copyright (C) 2011, 2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -126,6 +126,6 @@ int up_memfault(int irq, FAR void *context) # endif #endif - PANIC(OSERR_UNEXPECTEDISR); - return OK; + PANIC(); + return OK; /* Won't get here */ } diff --git a/nuttx/arch/arm/src/armv7-m/up_reprioritizertr.c b/nuttx/arch/arm/src/armv7-m/up_reprioritizertr.c index 94708a3be..a0d54a688 100644 --- a/nuttx/arch/arm/src/armv7-m/up_reprioritizertr.c +++ b/nuttx/arch/arm/src/armv7-m/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/arm/src/armv7-m/up_unblocktask.c b/nuttx/arch/arm/src/armv7-m/up_unblocktask.c index b2ff98879..8c6551b8e 100644 --- a/nuttx/arch/arm/src/armv7-m/up_unblocktask.c +++ b/nuttx/arch/arm/src/armv7-m/up_unblocktask.c @@ -81,77 +81,72 @@ 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); + } - /* No, then we will need to perform the user context switch */ + /* No, then we will need to perform the user context switch */ - else - { - /* Switch context to the context of the task at the head of the - * ready to run list. - */ + else + { + /* Switch context to the context of the task at the head of the + * ready to run list. + */ - struct tcb_s *nexttcb = (struct tcb_s*)g_readytorun.head; - up_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs); + struct tcb_s *nexttcb = (struct tcb_s*)g_readytorun.head; + up_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs); - /* up_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. - */ - } + /* up_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. + */ } } } diff --git a/nuttx/arch/arm/src/c5471/c5471_serial.c b/nuttx/arch/arm/src/c5471/c5471_serial.c index db28e196d..cdc5b6f24 100644 --- a/nuttx/arch/arm/src/c5471/c5471_serial.c +++ b/nuttx/arch/arm/src/c5471/c5471_serial.c @@ -547,7 +547,7 @@ static int up_interrupt(int irq, void *context) } else { - PANIC(OSERR_INTERNAL); + PANIC(); } priv = (struct up_dev_s*)dev->priv; diff --git a/nuttx/arch/arm/src/calypso/calypso_serial.c b/nuttx/arch/arm/src/calypso/calypso_serial.c index 01e65d062..5817b338b 100644 --- a/nuttx/arch/arm/src/calypso/calypso_serial.c +++ b/nuttx/arch/arm/src/calypso/calypso_serial.c @@ -607,7 +607,7 @@ static int up_interrupt(int irq, void *context) } else { - PANIC(OSERR_INTERNAL); + PANIC(); } priv = (struct up_dev_s*)dev->priv; diff --git a/nuttx/arch/arm/src/dm320/dm320_decodeirq.c b/nuttx/arch/arm/src/dm320/dm320_decodeirq.c index 98ba76097..c29207a5b 100644 --- a/nuttx/arch/arm/src/dm320/dm320_decodeirq.c +++ b/nuttx/arch/arm/src/dm320/dm320_decodeirq.c @@ -76,7 +76,7 @@ void up_decodeirq(uint32_t* regs) #ifdef CONFIG_SUPPRESS_INTERRUPTS lowsyslog("Unexpected IRQ\n"); current_regs = regs; - PANIC(OSERR_ERREXCEPTION); + PANIC(); #else /* Decode the interrupt. First, fetch the interrupt id register. */ diff --git a/nuttx/arch/arm/src/dm320/dm320_serial.c b/nuttx/arch/arm/src/dm320/dm320_serial.c index 58ff1e710..fbeefd8e9 100644 --- a/nuttx/arch/arm/src/dm320/dm320_serial.c +++ b/nuttx/arch/arm/src/dm320/dm320_serial.c @@ -485,7 +485,7 @@ static int up_interrupt(int irq, void *context) } else { - PANIC(OSERR_INTERNAL); + PANIC(); } priv = (struct up_dev_s*)dev->priv; diff --git a/nuttx/arch/arm/src/imx/imx_decodeirq.c b/nuttx/arch/arm/src/imx/imx_decodeirq.c index 230a4fc20..dc2326524 100644 --- a/nuttx/arch/arm/src/imx/imx_decodeirq.c +++ b/nuttx/arch/arm/src/imx/imx_decodeirq.c @@ -76,7 +76,7 @@ void up_decodeirq(uint32_t* regs) #ifdef CONFIG_SUPPRESS_INTERRUPTS lowsyslog("Unexpected IRQ\n"); current_regs = regs; - PANIC(OSERR_ERREXCEPTION); + PANIC(); #else uint32_t* savestate; uint32_t regval; diff --git a/nuttx/arch/arm/src/imx/imx_serial.c b/nuttx/arch/arm/src/imx/imx_serial.c index 9182d4ac8..d7a4c3296 100644 --- a/nuttx/arch/arm/src/imx/imx_serial.c +++ b/nuttx/arch/arm/src/imx/imx_serial.c @@ -799,7 +799,7 @@ static inline struct uart_dev_s *up_mapirq(int irq) #endif default: - PANIC(OSERR_INTERNAL); + PANIC(); break; } return dev; diff --git a/nuttx/arch/arm/src/kinetis/kinetis_irq.c b/nuttx/arch/arm/src/kinetis/kinetis_irq.c index f651c9e5d..f8b35656c 100644 --- a/nuttx/arch/arm/src/kinetis/kinetis_irq.c +++ b/nuttx/arch/arm/src/kinetis/kinetis_irq.c @@ -164,7 +164,7 @@ static int kinetis_nmi(int irq, FAR void *context) { (void)irqsave(); dbg("PANIC!!! NMI received\n"); - PANIC(OSERR_UNEXPECTEDISR); + PANIC(); return 0; } @@ -172,7 +172,7 @@ static int kinetis_busfault(int irq, FAR void *context) { (void)irqsave(); dbg("PANIC!!! Bus fault recived\n"); - PANIC(OSERR_UNEXPECTEDISR); + PANIC(); return 0; } @@ -180,7 +180,7 @@ static int kinetis_usagefault(int irq, FAR void *context) { (void)irqsave(); dbg("PANIC!!! Usage fault received\n"); - PANIC(OSERR_UNEXPECTEDISR); + PANIC(); return 0; } @@ -188,7 +188,7 @@ static int kinetis_pendsv(int irq, FAR void *context) { (void)irqsave(); dbg("PANIC!!! PendSV received\n"); - PANIC(OSERR_UNEXPECTEDISR); + PANIC(); return 0; } @@ -196,7 +196,7 @@ static int kinetis_dbgmonitor(int irq, FAR void *context) { (void)irqsave(); dbg("PANIC!!! Debug Monitor receieved\n"); - PANIC(OSERR_UNEXPECTEDISR); + PANIC(); return 0; } @@ -204,7 +204,7 @@ static int kinetis_reserved(int irq, FAR void *context) { (void)irqsave(); dbg("PANIC!!! Reserved interrupt\n"); - PANIC(OSERR_UNEXPECTEDISR); + PANIC(); return 0; } #endif diff --git a/nuttx/arch/arm/src/kinetis/kinetis_serial.c b/nuttx/arch/arm/src/kinetis/kinetis_serial.c index 8ede027ec..f176f5fa0 100644 --- a/nuttx/arch/arm/src/kinetis/kinetis_serial.c +++ b/nuttx/arch/arm/src/kinetis/kinetis_serial.c @@ -782,7 +782,7 @@ static int up_interrupte(int irq, void *context) else #endif { - PANIC(OSERR_INTERNAL); + PANIC(); } priv = (struct up_dev_s*)dev->priv; DEBUGASSERT(priv); @@ -871,7 +871,7 @@ static int up_interrupts(int irq, void *context) else #endif { - PANIC(OSERR_INTERNAL); + PANIC(); } priv = (struct up_dev_s*)dev->priv; DEBUGASSERT(priv); diff --git a/nuttx/arch/arm/src/kl/kl_irq.c b/nuttx/arch/arm/src/kl/kl_irq.c index cc2303ae1..9e7d84e35 100644 --- a/nuttx/arch/arm/src/kl/kl_irq.c +++ b/nuttx/arch/arm/src/kl/kl_irq.c @@ -138,7 +138,7 @@ static int kl_nmi(int irq, FAR void *context) { (void)irqsave(); dbg("PANIC!!! NMI received\n"); - PANIC(OSERR_UNEXPECTEDISR); + PANIC(); return 0; } @@ -146,7 +146,7 @@ static int kl_pendsv(int irq, FAR void *context) { (void)irqsave(); dbg("PANIC!!! PendSV received\n"); - PANIC(OSERR_UNEXPECTEDISR); + PANIC(); return 0; } @@ -154,7 +154,7 @@ static int kl_reserved(int irq, FAR void *context) { (void)irqsave(); dbg("PANIC!!! Reserved interrupt\n"); - PANIC(OSERR_UNEXPECTEDISR); + PANIC(); return 0; } #endif diff --git a/nuttx/arch/arm/src/kl/kl_serial.c b/nuttx/arch/arm/src/kl/kl_serial.c index d4f37f9f2..290192dcd 100644 --- a/nuttx/arch/arm/src/kl/kl_serial.c +++ b/nuttx/arch/arm/src/kl/kl_serial.c @@ -528,7 +528,7 @@ static int up_interrupts(int irq, void *context) else #endif { - PANIC(OSERR_INTERNAL); + PANIC(); } priv = (struct up_dev_s*)dev->priv; DEBUGASSERT(priv); diff --git a/nuttx/arch/arm/src/lm/lm_irq.c b/nuttx/arch/arm/src/lm/lm_irq.c index 11ea6fbb6..920eee8af 100644 --- a/nuttx/arch/arm/src/lm/lm_irq.c +++ b/nuttx/arch/arm/src/lm/lm_irq.c @@ -146,7 +146,7 @@ static int lm_nmi(int irq, FAR void *context) { (void)irqsave(); dbg("PANIC!!! NMI received\n"); - PANIC(OSERR_UNEXPECTEDISR); + PANIC(); return 0; } @@ -154,7 +154,7 @@ static int lm_busfault(int irq, FAR void *context) { (void)irqsave(); dbg("PANIC!!! Bus fault recived\n"); - PANIC(OSERR_UNEXPECTEDISR); + PANIC(); return 0; } @@ -162,7 +162,7 @@ static int lm_usagefault(int irq, FAR void *context) { (void)irqsave(); dbg("PANIC!!! Usage fault received\n"); - PANIC(OSERR_UNEXPECTEDISR); + PANIC(); return 0; } @@ -170,7 +170,7 @@ static int lm_pendsv(int irq, FAR void *context) { (void)irqsave(); dbg("PANIC!!! PendSV received\n"); - PANIC(OSERR_UNEXPECTEDISR); + PANIC(); return 0; } @@ -178,7 +178,7 @@ static int lm_dbgmonitor(int irq, FAR void *context) { (void)irqsave(); dbg("PANIC!!! Debug Monitor receieved\n"); - PANIC(OSERR_UNEXPECTEDISR); + PANIC(); return 0; } @@ -186,7 +186,7 @@ static int lm_reserved(int irq, FAR void *context) { (void)irqsave(); dbg("PANIC!!! Reserved interrupt\n"); - PANIC(OSERR_UNEXPECTEDISR); + PANIC(); return 0; } #endif diff --git a/nuttx/arch/arm/src/lm/lm_serial.c b/nuttx/arch/arm/src/lm/lm_serial.c index e9b9f72fb..6e772ecd5 100644 --- a/nuttx/arch/arm/src/lm/lm_serial.c +++ b/nuttx/arch/arm/src/lm/lm_serial.c @@ -962,7 +962,7 @@ static int up_interrupt(int irq, void *context) else #endif { - PANIC(OSERR_INTERNAL); + PANIC(); } priv = (struct up_dev_s*)dev->priv; diff --git a/nuttx/arch/arm/src/lpc17xx/lpc17_i2c.c b/nuttx/arch/arm/src/lpc17xx/lpc17_i2c.c index 866a668ab..777349def 100644 --- a/nuttx/arch/arm/src/lpc17xx/lpc17_i2c.c +++ b/nuttx/arch/arm/src/lpc17xx/lpc17_i2c.c @@ -364,7 +364,7 @@ static int i2c_interrupt(int irq, FAR void *context) else #endif { - PANIC(OSERR_INTERNAL); + PANIC(); } /* Reference UM10360 19.10.5 */ diff --git a/nuttx/arch/arm/src/lpc17xx/lpc17_irq.c b/nuttx/arch/arm/src/lpc17xx/lpc17_irq.c index 80de4596c..770874717 100644 --- a/nuttx/arch/arm/src/lpc17xx/lpc17_irq.c +++ b/nuttx/arch/arm/src/lpc17xx/lpc17_irq.c @@ -145,7 +145,7 @@ static int lpc17_nmi(int irq, FAR void *context) { (void)irqsave(); dbg("PANIC!!! NMI received\n"); - PANIC(OSERR_UNEXPECTEDISR); + PANIC(); return 0; } @@ -153,7 +153,7 @@ static int lpc17_busfault(int irq, FAR void *context) { (void)irqsave(); dbg("PANIC!!! Bus fault recived\n"); - PANIC(OSERR_UNEXPECTEDISR); + PANIC(); return 0; } @@ -161,7 +161,7 @@ static int lpc17_usagefault(int irq, FAR void *context) { (void)irqsave(); dbg("PANIC!!! Usage fault received\n"); - PANIC(OSERR_UNEXPECTEDISR); + PANIC(); return 0; } @@ -169,7 +169,7 @@ static int lpc17_pendsv(int irq, FAR void *context) { (void)irqsave(); dbg("PANIC!!! PendSV received\n"); - PANIC(OSERR_UNEXPECTEDISR); + PANIC(); return 0; } @@ -177,7 +177,7 @@ static int lpc17_dbgmonitor(int irq, FAR void *context) { (void)irqsave(); dbg("PANIC!!! Debug Monitor receieved\n"); - PANIC(OSERR_UNEXPECTEDISR); + PANIC(); return 0; } @@ -185,7 +185,7 @@ static int lpc17_reserved(int irq, FAR void *context) { (void)irqsave(); dbg("PANIC!!! Reserved interrupt\n"); - PANIC(OSERR_UNEXPECTEDISR); + PANIC(); return 0; } #endif diff --git a/nuttx/arch/arm/src/lpc17xx/lpc17_serial.c b/nuttx/arch/arm/src/lpc17xx/lpc17_serial.c index 713426b6e..b2da4839f 100644 --- a/nuttx/arch/arm/src/lpc17xx/lpc17_serial.c +++ b/nuttx/arch/arm/src/lpc17xx/lpc17_serial.c @@ -1068,7 +1068,7 @@ static int up_interrupt(int irq, void *context) else #endif { - PANIC(OSERR_INTERNAL); + PANIC(); } priv = (struct up_dev_s*)dev->priv; diff --git a/nuttx/arch/arm/src/lpc214x/lpc214x_decodeirq.c b/nuttx/arch/arm/src/lpc214x/lpc214x_decodeirq.c index 057e526c2..7886e5500 100644 --- a/nuttx/arch/arm/src/lpc214x/lpc214x_decodeirq.c +++ b/nuttx/arch/arm/src/lpc214x/lpc214x_decodeirq.c @@ -114,7 +114,7 @@ static void lpc214x_decodeirq( uint32_t *regs) #ifdef CONFIG_SUPPRESS_INTERRUPTS lowsyslog("Unexpected IRQ\n"); current_regs = regs; - PANIC(OSERR_ERREXCEPTION); + PANIC(); #else /* Decode the interrupt. We have to do this by search for the lowest numbered diff --git a/nuttx/arch/arm/src/lpc214x/lpc214x_serial.c b/nuttx/arch/arm/src/lpc214x/lpc214x_serial.c index b035e91fc..c647e458a 100644 --- a/nuttx/arch/arm/src/lpc214x/lpc214x_serial.c +++ b/nuttx/arch/arm/src/lpc214x/lpc214x_serial.c @@ -468,7 +468,7 @@ static int up_interrupt(int irq, void *context) } else { - PANIC(OSERR_INTERNAL); + PANIC(); } priv = (struct up_dev_s*)dev->priv; diff --git a/nuttx/arch/arm/src/lpc2378/lpc23xx_decodeirq.c b/nuttx/arch/arm/src/lpc2378/lpc23xx_decodeirq.c index 3a50beb50..75e6c98b4 100644 --- a/nuttx/arch/arm/src/lpc2378/lpc23xx_decodeirq.c +++ b/nuttx/arch/arm/src/lpc2378/lpc23xx_decodeirq.c @@ -113,7 +113,7 @@ static void lpc23xx_decodeirq(uint32_t *regs) #ifdef CONFIG_SUPPRESS_INTERRUPTS lowsyslog("Unexpected IRQ\n"); current_regs = regs; - PANIC(OSERR_ERREXCEPTION); + PANIC(); #else /* Check which IRQ fires */ diff --git a/nuttx/arch/arm/src/lpc2378/lpc23xx_serial.c b/nuttx/arch/arm/src/lpc2378/lpc23xx_serial.c index c17a57840..08fe4ec73 100644 --- a/nuttx/arch/arm/src/lpc2378/lpc23xx_serial.c +++ b/nuttx/arch/arm/src/lpc2378/lpc23xx_serial.c @@ -598,7 +598,7 @@ static int up_interrupt(int irq, void *context) } else { - PANIC(OSERR_INTERNAL); + PANIC(); } priv = (struct up_dev_s *)dev->priv; diff --git a/nuttx/arch/arm/src/lpc31xx/lpc31_decodeirq.c b/nuttx/arch/arm/src/lpc31xx/lpc31_decodeirq.c index 0e73f131b..1929d864d 100644 --- a/nuttx/arch/arm/src/lpc31xx/lpc31_decodeirq.c +++ b/nuttx/arch/arm/src/lpc31xx/lpc31_decodeirq.c @@ -79,7 +79,7 @@ void up_decodeirq(uint32_t *regs) #ifdef CONFIG_SUPPRESS_INTERRUPTS lowsyslog("Unexpected IRQ\n"); current_regs = regs; - PANIC(OSERR_ERREXCEPTION); + PANIC(); #else int index; int irq; diff --git a/nuttx/arch/arm/src/lpc43xx/lpc43_i2c.c b/nuttx/arch/arm/src/lpc43xx/lpc43_i2c.c index 64a044f13..1dc8b7679 100644 --- a/nuttx/arch/arm/src/lpc43xx/lpc43_i2c.c +++ b/nuttx/arch/arm/src/lpc43xx/lpc43_i2c.c @@ -370,7 +370,7 @@ static int i2c_interrupt(int irq, FAR void *context) else #endif { - PANIC(OSERR_INTERNAL); + PANIC(); } /* Reference UM10360 19.10.5 */ diff --git a/nuttx/arch/arm/src/lpc43xx/lpc43_irq.c b/nuttx/arch/arm/src/lpc43xx/lpc43_irq.c index 042b3360b..7195092bb 100644 --- a/nuttx/arch/arm/src/lpc43xx/lpc43_irq.c +++ b/nuttx/arch/arm/src/lpc43xx/lpc43_irq.c @@ -147,7 +147,7 @@ static int lpc43_nmi(int irq, FAR void *context) { (void)irqsave(); dbg("PANIC!!! NMI received\n"); - PANIC(OSERR_UNEXPECTEDISR); + PANIC(); return 0; } @@ -155,7 +155,7 @@ static int lpc43_busfault(int irq, FAR void *context) { (void)irqsave(); dbg("PANIC!!! Bus fault recived\n"); - PANIC(OSERR_UNEXPECTEDISR); + PANIC(); return 0; } @@ -163,7 +163,7 @@ static int lpc43_usagefault(int irq, FAR void *context) { (void)irqsave(); dbg("PANIC!!! Usage fault received\n"); - PANIC(OSERR_UNEXPECTEDISR); + PANIC(); return 0; } @@ -171,7 +171,7 @@ static int lpc43_pendsv(int irq, FAR void *context) { (void)irqsave(); dbg("PANIC!!! PendSV received\n"); - PANIC(OSERR_UNEXPECTEDISR); + PANIC(); return 0; } @@ -179,7 +179,7 @@ static int lpc43_dbgmonitor(int irq, FAR void *context) { (void)irqsave(); dbg("PANIC!!! Debug Monitor receieved\n"); - PANIC(OSERR_UNEXPECTEDISR); + PANIC(); return 0; } @@ -187,7 +187,7 @@ static int lpc43_reserved(int irq, FAR void *context) { (void)irqsave(); dbg("PANIC!!! Reserved interrupt\n"); - PANIC(OSERR_UNEXPECTEDISR); + PANIC(); return 0; } #endif diff --git a/nuttx/arch/arm/src/lpc43xx/lpc43_serial.c b/nuttx/arch/arm/src/lpc43xx/lpc43_serial.c index a6e6b7b18..adbfb282a 100644 --- a/nuttx/arch/arm/src/lpc43xx/lpc43_serial.c +++ b/nuttx/arch/arm/src/lpc43xx/lpc43_serial.c @@ -777,7 +777,7 @@ static int up_interrupt(int irq, void *context) else #endif { - PANIC(OSERR_INTERNAL); + PANIC(); } priv = (struct up_dev_s*)dev->priv; diff --git a/nuttx/arch/arm/src/nuc1xx/nuc_irq.c b/nuttx/arch/arm/src/nuc1xx/nuc_irq.c index 01a7bd7ba..2ee01762d 100644 --- a/nuttx/arch/arm/src/nuc1xx/nuc_irq.c +++ b/nuttx/arch/arm/src/nuc1xx/nuc_irq.c @@ -138,7 +138,7 @@ static int nuc_nmi(int irq, FAR void *context) { (void)irqsave(); dbg("PANIC!!! NMI received\n"); - PANIC(OSERR_UNEXPECTEDISR); + PANIC(); return 0; } @@ -146,7 +146,7 @@ static int nuc_pendsv(int irq, FAR void *context) { (void)irqsave(); dbg("PANIC!!! PendSV received\n"); - PANIC(OSERR_UNEXPECTEDISR); + PANIC(); return 0; } @@ -154,7 +154,7 @@ static int nuc_reserved(int irq, FAR void *context) { (void)irqsave(); dbg("PANIC!!! Reserved interrupt\n"); - PANIC(OSERR_UNEXPECTEDISR); + PANIC(); return 0; } #endif diff --git a/nuttx/arch/arm/src/nuc1xx/nuc_serial.c b/nuttx/arch/arm/src/nuc1xx/nuc_serial.c index dbf34f8ec..c07ef1109 100644 --- a/nuttx/arch/arm/src/nuc1xx/nuc_serial.c +++ b/nuttx/arch/arm/src/nuc1xx/nuc_serial.c @@ -640,7 +640,7 @@ static int up_interrupt(int irq, void *context) else #endif { - PANIC(OSERR_INTERNAL); + PANIC(); } priv = (struct nuc_dev_s*)dev->priv; diff --git a/nuttx/arch/arm/src/sam3u/sam3u_irq.c b/nuttx/arch/arm/src/sam3u/sam3u_irq.c index 9c1e9bb3e..29c9908c9 100644 --- a/nuttx/arch/arm/src/sam3u/sam3u_irq.c +++ b/nuttx/arch/arm/src/sam3u/sam3u_irq.c @@ -140,7 +140,7 @@ static int sam3u_nmi(int irq, FAR void *context) { (void)irqsave(); dbg("PANIC!!! NMI received\n"); - PANIC(OSERR_UNEXPECTEDISR); + PANIC(); return 0; } @@ -148,7 +148,7 @@ static int sam3u_busfault(int irq, FAR void *context) { (void)irqsave(); dbg("PANIC!!! Bus fault recived\n"); - PANIC(OSERR_UNEXPECTEDISR); + PANIC(); return 0; } @@ -156,7 +156,7 @@ static int sam3u_usagefault(int irq, FAR void *context) { (void)irqsave(); dbg("PANIC!!! Usage fault received\n"); - PANIC(OSERR_UNEXPECTEDISR); + PANIC(); return 0; } @@ -164,7 +164,7 @@ static int sam3u_pendsv(int irq, FAR void *context) { (void)irqsave(); dbg("PANIC!!! PendSV received\n"); - PANIC(OSERR_UNEXPECTEDISR); + PANIC(); return 0; } @@ -172,7 +172,7 @@ static int sam3u_dbgmonitor(int irq, FAR void *context) { (void)irqsave(); dbg("PANIC!!! Debug Monitor receieved\n"); - PANIC(OSERR_UNEXPECTEDISR); + PANIC(); return 0; } @@ -180,7 +180,7 @@ static int sam3u_reserved(int irq, FAR void *context) { (void)irqsave(); dbg("PANIC!!! Reserved interrupt\n"); - PANIC(OSERR_UNEXPECTEDISR); + PANIC(); return 0; } #endif diff --git a/nuttx/arch/arm/src/sam3u/sam3u_serial.c b/nuttx/arch/arm/src/sam3u/sam3u_serial.c index 149474207..a4d79a11b 100644 --- a/nuttx/arch/arm/src/sam3u/sam3u_serial.c +++ b/nuttx/arch/arm/src/sam3u/sam3u_serial.c @@ -1077,7 +1077,7 @@ static int up_interrupt(int irq, void *context) else #endif { - PANIC(OSERR_INTERNAL); + PANIC(); } priv = (struct up_dev_s*)dev->priv; diff --git a/nuttx/arch/arm/src/stm32/stm32_can.c b/nuttx/arch/arm/src/stm32/stm32_can.c index 86a53dab0..a3011cde4 100644 --- a/nuttx/arch/arm/src/stm32/stm32_can.c +++ b/nuttx/arch/arm/src/stm32/stm32_can.c @@ -1009,7 +1009,7 @@ static int can_rx0interrupt(int irq, void *context) } else { - PANIC(OSERR_UNEXPECTEDISR); + PANIC(); } #elif defined(CONFIG_STM32_CAN1) dev = &g_can1dev; @@ -1125,7 +1125,7 @@ static int can_txinterrupt(int irq, void *context) } else { - PANIC(OSERR_UNEXPECTEDISR); + PANIC(); } #elif defined(CONFIG_STM32_CAN1) dev = &g_can1dev; diff --git a/nuttx/arch/arm/src/stm32/stm32_irq.c b/nuttx/arch/arm/src/stm32/stm32_irq.c index 96b239c36..d1cd37e36 100644 --- a/nuttx/arch/arm/src/stm32/stm32_irq.c +++ b/nuttx/arch/arm/src/stm32/stm32_irq.c @@ -144,7 +144,7 @@ static int stm32_nmi(int irq, FAR void *context) { (void)irqsave(); dbg("PANIC!!! NMI received\n"); - PANIC(OSERR_UNEXPECTEDISR); + PANIC(); return 0; } @@ -152,7 +152,7 @@ static int stm32_busfault(int irq, FAR void *context) { (void)irqsave(); dbg("PANIC!!! Bus fault recived\n"); - PANIC(OSERR_UNEXPECTEDISR); + PANIC(); return 0; } @@ -160,7 +160,7 @@ static int stm32_usagefault(int irq, FAR void *context) { (void)irqsave(); dbg("PANIC!!! Usage fault received\n"); - PANIC(OSERR_UNEXPECTEDISR); + PANIC(); return 0; } @@ -168,7 +168,7 @@ static int stm32_pendsv(int irq, FAR void *context) { (void)irqsave(); dbg("PANIC!!! PendSV received\n"); - PANIC(OSERR_UNEXPECTEDISR); + PANIC(); return 0; } @@ -176,7 +176,7 @@ static int stm32_dbgmonitor(int irq, FAR void *context) { (void)irqsave(); dbg("PANIC!!! Debug Monitor receieved\n"); - PANIC(OSERR_UNEXPECTEDISR); + PANIC(); return 0; } @@ -184,7 +184,7 @@ static int stm32_reserved(int irq, FAR void *context) { (void)irqsave(); dbg("PANIC!!! Reserved interrupt\n"); - PANIC(OSERR_UNEXPECTEDISR); + PANIC(); return 0; } #endif diff --git a/nuttx/arch/arm/src/stm32/stm32f10xxx_dma.c b/nuttx/arch/arm/src/stm32/stm32f10xxx_dma.c index 80408e58b..29b09150d 100644 --- a/nuttx/arch/arm/src/stm32/stm32f10xxx_dma.c +++ b/nuttx/arch/arm/src/stm32/stm32f10xxx_dma.c @@ -299,7 +299,7 @@ static int stm32_dmainterrupt(int irq, void *context) else #endif { - PANIC(OSERR_INTERNAL); + PANIC(); } dmach = &g_dma[chndx]; diff --git a/nuttx/arch/arm/src/stm32/stm32f20xxx_dma.c b/nuttx/arch/arm/src/stm32/stm32f20xxx_dma.c index e5905a909..844fa6a67 100644 --- a/nuttx/arch/arm/src/stm32/stm32f20xxx_dma.c +++ b/nuttx/arch/arm/src/stm32/stm32f20xxx_dma.c @@ -406,7 +406,7 @@ static int stm32_dmainterrupt(int irq, void *context) else #endif { - PANIC(OSERR_INTERNAL); + PANIC(); } /* Get the stream structure from the stream and controller numbers */ diff --git a/nuttx/arch/arm/src/stm32/stm32f40xxx_dma.c b/nuttx/arch/arm/src/stm32/stm32f40xxx_dma.c index 850ab62ae..fd8164a32 100644 --- a/nuttx/arch/arm/src/stm32/stm32f40xxx_dma.c +++ b/nuttx/arch/arm/src/stm32/stm32f40xxx_dma.c @@ -405,7 +405,7 @@ static int stm32_dmainterrupt(int irq, void *context) else #endif { - PANIC(OSERR_INTERNAL); + PANIC(); } /* Get the stream structure from the stream and controller numbers */ diff --git a/nuttx/arch/arm/src/str71x/str71x_decodeirq.c b/nuttx/arch/arm/src/str71x/str71x_decodeirq.c index 48c9aa7e4..da7b5a48e 100644 --- a/nuttx/arch/arm/src/str71x/str71x_decodeirq.c +++ b/nuttx/arch/arm/src/str71x/str71x_decodeirq.c @@ -93,7 +93,7 @@ void up_decodeirq(uint32_t *regs) up_ledon(LED_INIRQ); lowsyslog("Unexpected IRQ\n"); current_regs = regs; - PANIC(OSERR_ERREXCEPTION); + PANIC(); #else unsigned int irq; @@ -139,7 +139,7 @@ void up_decodeirq(uint32_t *regs) #if CONFIG_DEBUG else { - PANIC(OSERR_ERREXCEPTION); /* Normally never happens */ + PANIC(); /* Normally never happens */ } #endif up_ledoff(LED_INIRQ); diff --git a/nuttx/arch/arm/src/str71x/str71x_serial.c b/nuttx/arch/arm/src/str71x/str71x_serial.c index 5de63a1b9..2098758b1 100644 --- a/nuttx/arch/arm/src/str71x/str71x_serial.c +++ b/nuttx/arch/arm/src/str71x/str71x_serial.c @@ -698,7 +698,7 @@ static int up_interrupt(int irq, void *context) else #endif { - PANIC(OSERR_INTERNAL); + PANIC(); } priv = (struct up_dev_s*)dev->priv; diff --git a/nuttx/arch/avr/src/at32uc3/at32uc3_irq.c b/nuttx/arch/avr/src/at32uc3/at32uc3_irq.c index 771d1b9da..70ade3e2a 100644 --- a/nuttx/arch/avr/src/at32uc3/at32uc3_irq.c +++ b/nuttx/arch/avr/src/at32uc3/at32uc3_irq.c @@ -179,7 +179,7 @@ static int avr32_xcptn(int irq, FAR void *context) { (void)irqsave(); lldbg("PANIC!!! Exception IRQ: %d\n", irq); - PANIC(OSERR_UNEXPECTEDISR); + PANIC(); return 0; } diff --git a/nuttx/arch/avr/src/at32uc3/at32uc3_serial.c b/nuttx/arch/avr/src/at32uc3/at32uc3_serial.c index f33ce7d72..1ddb9901b 100644 --- a/nuttx/arch/avr/src/at32uc3/at32uc3_serial.c +++ b/nuttx/arch/avr/src/at32uc3/at32uc3_serial.c @@ -468,7 +468,7 @@ static int up_interrupt(int irq, void *context) else #endif { - PANIC(OSERR_INTERNAL); + PANIC(); } priv = (struct up_dev_s*)dev->priv; DEBUGASSERT(priv); diff --git a/nuttx/arch/avr/src/avr/up_blocktask.c b/nuttx/arch/avr/src/avr/up_blocktask.c index 7d48da78a..82fcd65db 100644 --- a/nuttx/arch/avr/src/avr/up_blocktask.c +++ b/nuttx/arch/avr/src/avr/up_blocktask.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/avr/src/avr/up_blocktask.c * - * Copyright (C) 2011 Gregory Nutt. All rights reserved. + * Copyright (C) 2011, 2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * 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) { - /* 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; + 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. - */ + /* Verify that the context switch can be performed */ - switch_needed = sched_removereadytorun(tcb); + ASSERT((tcb->task_state >= FIRST_READY_TO_RUN_STATE) && + (tcb->task_state <= LAST_READY_TO_RUN_STATE)); - /* Add the task to the specified blocked task list */ + /* 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. + */ - sched_addblocked(tcb, (tstate_t)task_state); + switch_needed = sched_removereadytorun(tcb); - /* If there are any pending tasks, then add them to the g_readytorun - * task list now - */ + /* Add the task to the specified blocked task list */ - if (g_pendingtasks.head) - { - switch_needed |= sched_mergepending(); - } + sched_addblocked(tcb, (tstate_t)task_state); - /* Now, perform the context switch if one is needed */ + /* If there are any pending tasks, then add them to the g_readytorun + * task list now + */ - if (switch_needed) - { - /* Are we in an interrupt handler? */ + if (g_pendingtasks.head) + { + switch_needed |= sched_mergepending(); + } - if (current_regs) - { - /* Yes, then we have to do things differently. - * Just copy the current_regs into the OLD rtcb. - */ + /* Now, perform the context switch if one is needed */ - up_savestate(rtcb->xcp.regs); + if (switch_needed) + { + /* Are we in an interrupt handler? */ - /* Restore the exception context of the rtcb at the (new) head - * of the g_readytorun task list. - */ + if (current_regs) + { + /* Yes, then we have to do things differently. + * Just copy the current_regs into the OLD rtcb. + */ - rtcb = (struct tcb_s*)g_readytorun.head; + up_savestate(rtcb->xcp.regs); - /* Then switch contexts */ + /* Restore the exception context of the rtcb at the (new) head + * of the g_readytorun task list. + */ - up_restorestate(rtcb->xcp.regs); - } + rtcb = (struct tcb_s*)g_readytorun.head; - /* No, then we will need to perform the user context switch */ + /* Then switch contexts */ - else - { - /* Switch context to the context of the task at the head of the - * ready to run list. - */ + up_restorestate(rtcb->xcp.regs); + } - struct tcb_s *nexttcb = (struct tcb_s*)g_readytorun.head; - up_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs); + /* No, then we will need to perform the user context switch */ - /* up_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. - */ - } + else + { + /* Switch context to the context of the task at the head of the + * ready to run list. + */ + + struct tcb_s *nexttcb = (struct tcb_s*)g_readytorun.head; + up_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs); + + /* up_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. + */ } } } diff --git a/nuttx/arch/avr/src/avr/up_doirq.c b/nuttx/arch/avr/src/avr/up_doirq.c index 7533d2159..4db08c046 100644 --- a/nuttx/arch/avr/src/avr/up_doirq.c +++ b/nuttx/arch/avr/src/avr/up_doirq.c @@ -74,7 +74,7 @@ uint8_t *up_doirq(uint8_t 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/avr/src/avr/up_reprioritizertr.c b/nuttx/arch/avr/src/avr/up_reprioritizertr.c index 5b23a37a1..4c510f4ea 100644 --- a/nuttx/arch/avr/src/avr/up_reprioritizertr.c +++ b/nuttx/arch/avr/src/avr/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/avr/src/avr/up_unblocktask.c b/nuttx/arch/avr/src/avr/up_unblocktask.c index f1707b7bd..970deedd6 100644 --- a/nuttx/arch/avr/src/avr/up_unblocktask.c +++ b/nuttx/arch/avr/src/avr/up_unblocktask.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/avr/src/avr/up_unblocktask.c * - * Copyright (C) 2011 Gregory Nutt. All rights reserved. + * Copyright (C) 2011, 2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -81,77 +81,72 @@ 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); + } - /* No, then we will need to perform the user context switch */ + /* No, then we will need to perform the user context switch */ - else - { - /* Switch context to the context of the task at the head of the - * ready to run list. - */ + else + { + /* Switch context to the context of the task at the head of the + * ready to run list. + */ - struct tcb_s *nexttcb = (struct tcb_s*)g_readytorun.head; - up_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs); + struct tcb_s *nexttcb = (struct tcb_s*)g_readytorun.head; + up_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs); - /* up_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. - */ - } + /* up_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. + */ } } } diff --git a/nuttx/arch/avr/src/avr32/up_blocktask.c b/nuttx/arch/avr/src/avr32/up_blocktask.c index a5ff53ae9..1da4eb573 100644 --- a/nuttx/arch/avr/src/avr32/up_blocktask.c +++ b/nuttx/arch/avr/src/avr32/up_blocktask.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/avr/src/avr32/up_blocktask.c * - * Copyright (C) 2010 Gregory Nutt. All rights reserved. + * Copyright (C) 2010, 2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * 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) { - /* 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; + 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. - */ + /* Verify that the context switch can be performed */ - switch_needed = sched_removereadytorun(tcb); + ASSERT((tcb->task_state >= FIRST_READY_TO_RUN_STATE) && + (tcb->task_state <= LAST_READY_TO_RUN_STATE)); - /* Add the task to the specified blocked task list */ + /* 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. + */ - sched_addblocked(tcb, (tstate_t)task_state); + switch_needed = sched_removereadytorun(tcb); - /* If there are any pending tasks, then add them to the g_readytorun - * task list now - */ + /* Add the task to the specified blocked task list */ - if (g_pendingtasks.head) - { - switch_needed |= sched_mergepending(); - } + sched_addblocked(tcb, (tstate_t)task_state); - /* Now, perform the context switch if one is needed */ + /* If there are any pending tasks, then add them to the g_readytorun + * task list now + */ - if (switch_needed) - { - /* Are we in an interrupt handler? */ + if (g_pendingtasks.head) + { + switch_needed |= sched_mergepending(); + } - if (current_regs) - { - /* Yes, then we have to do things differently. - * Just copy the current_regs into the OLD rtcb. - */ + /* Now, perform the context switch if one is needed */ - up_savestate(rtcb->xcp.regs); + if (switch_needed) + { + /* Are we in an interrupt handler? */ - /* Restore the exception context of the rtcb at the (new) head - * of the g_readytorun task list. - */ + if (current_regs) + { + /* Yes, then we have to do things differently. + * Just copy the current_regs into the OLD rtcb. + */ - rtcb = (struct tcb_s*)g_readytorun.head; + up_savestate(rtcb->xcp.regs); - /* Then switch contexts */ + /* Restore the exception context of the rtcb at the (new) head + * of the g_readytorun task list. + */ - up_restorestate(rtcb->xcp.regs); - } + rtcb = (struct tcb_s*)g_readytorun.head; - /* No, then we will need to perform the user context switch */ + /* Then switch contexts */ - else - { - /* Switch context to the context of the task at the head of the - * ready to run list. - */ + up_restorestate(rtcb->xcp.regs); + } - struct tcb_s *nexttcb = (struct tcb_s*)g_readytorun.head; - up_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs); + /* No, then we will need to perform the user context switch */ - /* up_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. - */ - } + else + { + /* Switch context to the context of the task at the head of the + * ready to run list. + */ + + struct tcb_s *nexttcb = (struct tcb_s*)g_readytorun.head; + up_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs); + + /* up_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. + */ } } } diff --git a/nuttx/arch/avr/src/avr32/up_doirq.c b/nuttx/arch/avr/src/avr32/up_doirq.c index 2d4a5e14a..c4513e77f 100644 --- a/nuttx/arch/avr/src/avr32/up_doirq.c +++ b/nuttx/arch/avr/src/avr32/up_doirq.c @@ -74,7 +74,7 @@ uint32_t *up_doirq(int irq, uint32_t *regs) { up_ledon(LED_INIRQ); #ifdef CONFIG_SUPPRESS_INTERRUPTS - PANIC(OSERR_ERREXCEPTION); + PANIC(); #else uint32_t *savestate; diff --git a/nuttx/arch/avr/src/avr32/up_reprioritizertr.c b/nuttx/arch/avr/src/avr32/up_reprioritizertr.c index bc9ba21f0..621f08613 100644 --- a/nuttx/arch/avr/src/avr32/up_reprioritizertr.c +++ b/nuttx/arch/avr/src/avr32/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/avr/src/avr32/up_unblocktask.c b/nuttx/arch/avr/src/avr32/up_unblocktask.c index 5ce48e366..1fcfa1dd7 100644 --- a/nuttx/arch/avr/src/avr32/up_unblocktask.c +++ b/nuttx/arch/avr/src/avr32/up_unblocktask.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/avr/src/avr32/up_unblocktask.c * - * Copyright (C) 2010 Gregory Nutt. All rights reserved. + * Copyright (C) 2010, 2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -81,77 +81,72 @@ 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); + } - /* No, then we will need to perform the user context switch */ + /* No, then we will need to perform the user context switch */ - else - { - /* Switch context to the context of the task at the head of the - * ready to run list. - */ + else + { + /* Switch context to the context of the task at the head of the + * ready to run list. + */ - struct tcb_s *nexttcb = (struct tcb_s*)g_readytorun.head; - up_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs); + struct tcb_s *nexttcb = (struct tcb_s*)g_readytorun.head; + up_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs); - /* up_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. - */ - } + /* up_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. + */ } } } diff --git a/nuttx/arch/avr/src/common/up_assert.c b/nuttx/arch/avr/src/common/up_assert.c index 2e70a9c28..a9012202e 100644 --- a/nuttx/arch/avr/src/common/up_assert.c +++ b/nuttx/arch/avr/src/common/up_assert.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/avr/src/common/up_assert.c * - * Copyright (C) 2010-2011 Gregory Nutt. All rights reserved. + * Copyright (C) 2010-2011, 2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -129,6 +129,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); @@ -136,29 +137,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/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 * * 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 * * 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 * * 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; diff --git a/nuttx/arch/mips/src/common/up_exit.c b/nuttx/arch/mips/src/common/up_exit.c index 8791fa40b..974bdc613 100644 --- a/nuttx/arch/mips/src/common/up_exit.c +++ b/nuttx/arch/mips/src/common/up_exit.c @@ -171,6 +171,6 @@ void _exit(int status) * interrupts are disabled. */ - PANIC(OSERR_INTERNAL); + PANIC(); } diff --git a/nuttx/arch/mips/src/mips32/up_assert.c b/nuttx/arch/mips/src/mips32/up_assert.c index 9f503ac85..36414d71c 100644 --- a/nuttx/arch/mips/src/mips32/up_assert.c +++ b/nuttx/arch/mips/src/mips32/up_assert.c @@ -129,6 +129,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); @@ -136,29 +137,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/mips/src/mips32/up_blocktask.c b/nuttx/arch/mips/src/mips32/up_blocktask.c index 8d209da9f..e0d1cf247 100644 --- a/nuttx/arch/mips/src/mips32/up_blocktask.c +++ b/nuttx/arch/mips/src/mips32/up_blocktask.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/mips/src/mips32/up_blocktask.c * - * Copyright (C) 2011 Gregory Nutt. All rights reserved. + * Copyright (C) 2011, 2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -87,82 +87,77 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state) { - /* 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; + 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. - */ + /* Verify that the context switch can be performed */ - switch_needed = sched_removereadytorun(tcb); + ASSERT((tcb->task_state >= FIRST_READY_TO_RUN_STATE) && + (tcb->task_state <= LAST_READY_TO_RUN_STATE)); - /* Add the task to the specified blocked task list */ + /* 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. + */ - sched_addblocked(tcb, (tstate_t)task_state); + switch_needed = sched_removereadytorun(tcb); - /* If there are any pending tasks, then add them to the g_readytorun - * task list now - */ + /* Add the task to the specified blocked task list */ - if (g_pendingtasks.head) - { - switch_needed |= sched_mergepending(); - } + sched_addblocked(tcb, (tstate_t)task_state); - /* Now, perform the context switch if one is needed */ + /* If there are any pending tasks, then add them to the g_readytorun + * task list now + */ - if (switch_needed) - { - /* Are we in an interrupt handler? */ + if (g_pendingtasks.head) + { + switch_needed |= sched_mergepending(); + } - if (current_regs) - { - /* Yes, then we have to do things differently. - * Just copy the current_regs into the OLD rtcb. - */ + /* Now, perform the context switch if one is needed */ - up_savestate(rtcb->xcp.regs); + if (switch_needed) + { + /* Are we in an interrupt handler? */ - /* Restore the exception context of the rtcb at the (new) head - * of the g_readytorun task list. - */ + if (current_regs) + { + /* Yes, then we have to do things differently. + * Just copy the current_regs into the OLD rtcb. + */ - rtcb = (struct tcb_s*)g_readytorun.head; + up_savestate(rtcb->xcp.regs); - /* Then switch contexts */ + /* Restore the exception context of the rtcb at the (new) head + * of the g_readytorun task list. + */ - up_restorestate(rtcb->xcp.regs); - } + rtcb = (struct tcb_s*)g_readytorun.head; - /* No, then we will need to perform the user context switch */ + /* Then switch contexts */ - else - { - /* Switch context to the context of the task at the head of the - * ready to run list. - */ + up_restorestate(rtcb->xcp.regs); + } - struct tcb_s *nexttcb = (struct tcb_s*)g_readytorun.head; - up_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs); + /* No, then we will need to perform the user context switch */ - /* up_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. - */ - } + else + { + /* Switch context to the context of the task at the head of the + * ready to run list. + */ + + struct tcb_s *nexttcb = (struct tcb_s*)g_readytorun.head; + up_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs); + + /* up_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. + */ } } } diff --git a/nuttx/arch/mips/src/mips32/up_doirq.c b/nuttx/arch/mips/src/mips32/up_doirq.c index b963881e3..bf1a19727 100644 --- a/nuttx/arch/mips/src/mips32/up_doirq.c +++ b/nuttx/arch/mips/src/mips32/up_doirq.c @@ -74,7 +74,7 @@ uint32_t *up_doirq(int irq, uint32_t *regs) { up_ledon(LED_INIRQ); #ifdef CONFIG_SUPPRESS_INTERRUPTS - PANIC(OSERR_ERREXCEPTION); + PANIC(); #else uint32_t *savestate; diff --git a/nuttx/arch/mips/src/mips32/up_reprioritizertr.c b/nuttx/arch/mips/src/mips32/up_reprioritizertr.c index f4034cc1e..a8f0158b9 100644 --- a/nuttx/arch/mips/src/mips32/up_reprioritizertr.c +++ b/nuttx/arch/mips/src/mips32/up_reprioritizertr.c @@ -100,7 +100,7 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority) #endif ) { - PANIC(OSERR_BADREPRIORITIZESTATE); + PANIC(); } else { diff --git a/nuttx/arch/mips/src/mips32/up_sigdeliver.c b/nuttx/arch/mips/src/mips32/up_sigdeliver.c index 0abc270d3..defa6bd10 100644 --- a/nuttx/arch/mips/src/mips32/up_sigdeliver.c +++ b/nuttx/arch/mips/src/mips32/up_sigdeliver.c @@ -142,7 +142,7 @@ void up_sigdeliver(void) * interrupts are disabled. */ - PANIC(OSERR_INTERNAL); + PANIC(); } #endif /* !CONFIG_DISABLE_SIGNALS */ diff --git a/nuttx/arch/mips/src/mips32/up_unblocktask.c b/nuttx/arch/mips/src/mips32/up_unblocktask.c index 70a5a7241..99cd25052 100644 --- a/nuttx/arch/mips/src/mips32/up_unblocktask.c +++ b/nuttx/arch/mips/src/mips32/up_unblocktask.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/mips/src/mips32/up_unblocktask.c * - * Copyright (C) 2011 Gregory Nutt. All rights reserved. + * Copyright (C) 2011, 2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -83,77 +83,72 @@ 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); + } - /* No, then we will need to perform the user context switch */ + /* No, then we will need to perform the user context switch */ - else - { - /* Switch context to the context of the task at the head of the - * ready to run list. - */ + else + { + /* Switch context to the context of the task at the head of the + * ready to run list. + */ - struct tcb_s *nexttcb = (struct tcb_s*)g_readytorun.head; - up_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs); + struct tcb_s *nexttcb = (struct tcb_s*)g_readytorun.head; + up_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs); - /* up_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. - */ - } + /* up_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. + */ } } } diff --git a/nuttx/arch/mips/src/pic32mx/pic32mx-exception.c b/nuttx/arch/mips/src/pic32mx/pic32mx-exception.c index dd3b88b14..cf0813e5f 100644 --- a/nuttx/arch/mips/src/pic32mx/pic32mx-exception.c +++ b/nuttx/arch/mips/src/pic32mx/pic32mx-exception.c @@ -194,6 +194,6 @@ uint32_t *pic32mx_exception(uint32_t *regs) /* Crash with currents_regs set so that we can dump the register contents. */ current_regs = regs; - PANIC(OSERR_ERREXCEPTION); + PANIC(); return regs; /* Won't get here */ } diff --git a/nuttx/arch/mips/src/pic32mx/pic32mx-serial.c b/nuttx/arch/mips/src/pic32mx/pic32mx-serial.c index 0254051d2..0a03b98a9 100644 --- a/nuttx/arch/mips/src/pic32mx/pic32mx-serial.c +++ b/nuttx/arch/mips/src/pic32mx/pic32mx-serial.c @@ -468,7 +468,7 @@ static int up_interrupt(int irq, void *context) else #endif { - PANIC(OSERR_INTERNAL); + PANIC(); } priv = (struct up_dev_s*)dev->priv; DEBUGASSERT(priv); diff --git a/nuttx/arch/rgmp/src/nuttx.c b/nuttx/arch/rgmp/src/nuttx.c index a4f713be6..e96317621 100644 --- a/nuttx/arch/rgmp/src/nuttx.c +++ b/nuttx/arch/rgmp/src/nuttx.c @@ -450,23 +450,6 @@ void up_assert(const uint8_t *filename, int line) } } -void up_assert_code(const uint8_t *filename, int line, int code) -{ - fprintf(stderr, "Assertion failed at file:%s line: %d error code: %d\n", - filename, line, code); - - // in interrupt context or idle task means kernel error - // which will stop the OS - // if in user space just terminate the task - if (up_interrupt_context() || current_task->pid == 0) { - panic("%s: %d\n", __func__, __LINE__); - } - else { - exit(EXIT_FAILURE); - } -} - - #ifndef CONFIG_DISABLE_SIGNALS void up_schedule_sigaction(struct tcb_s *tcb, sig_deliver_t sigdeliver) diff --git a/nuttx/arch/sh/src/common/up_assert.c b/nuttx/arch/sh/src/common/up_assert.c index 72880fd2a..7e8f13451 100644 --- a/nuttx/arch/sh/src/common/up_assert.c +++ b/nuttx/arch/sh/src/common/up_assert.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/sh/src/common/up_assert.c * - * Copyright (C) 2008-2009, 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009, 2012-2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -115,6 +115,7 @@ void up_assert(const uint8_t *filename, int lineno) #endif up_ledon(LED_ASSERTION); + #if CONFIG_TASK_NAME_SIZE > 0 lldbg("Assertion failed at file:%s line: %d task: %s\n", filename, lineno, rtcb->name); @@ -122,28 +123,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) -{ -#if CONFIG_TASK_NAME_SIZE > 0 && defined(CONFIG_DEBUG) - struct tcb_s *rtcb = (struct tcb_s*)g_readytorun.head; -#endif - - up_ledon(LED_ASSERTION); -#if CONFIG_TASK_NAME_SIZE > 0 - 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/sh/src/common/up_blocktask.c b/nuttx/arch/sh/src/common/up_blocktask.c index db7f0297c..9959e71df 100644 --- a/nuttx/arch/sh/src/common/up_blocktask.c +++ b/nuttx/arch/sh/src/common/up_blocktask.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/sh/src/common/up_blocktask.c * - * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009, 2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -85,82 +85,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_copystate(rtcb->xcp.regs, current_regs); - up_copystate(rtcb->xcp.regs, current_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 */ + current_regs = rtcb->xcp.regs; + } - current_regs = 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/sh/src/common/up_doirq.c b/nuttx/arch/sh/src/common/up_doirq.c index 185fa9684..d6a121330 100644 --- a/nuttx/arch/sh/src/common/up_doirq.c +++ b/nuttx/arch/sh/src/common/up_doirq.c @@ -73,7 +73,7 @@ uint32_t *up_doirq(int irq, uint32_t* regs) { up_ledon(LED_INIRQ); #ifdef CONFIG_SUPPRESS_INTERRUPTS - PANIC(OSERR_ERREXCEPTION); + PANIC(); #else if ((unsigned)irq < NR_IRQS) { diff --git a/nuttx/arch/sh/src/common/up_reprioritizertr.c b/nuttx/arch/sh/src/common/up_reprioritizertr.c index dcf0fcd7b..64f5d9969 100644 --- a/nuttx/arch/sh/src/common/up_reprioritizertr.c +++ b/nuttx/arch/sh/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/sh/src/common/up_unblocktask.c b/nuttx/arch/sh/src/common/up_unblocktask.c index b7c88f823..455c50ce2 100644 --- a/nuttx/arch/sh/src/common/up_unblocktask.c +++ b/nuttx/arch/sh/src/common/up_unblocktask.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/sh/src/common/up_unblocktask.c * - * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009, 2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * 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_copystate(rtcb->xcp.regs, current_regs); - up_copystate(rtcb->xcp.regs, current_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 */ + current_regs = rtcb->xcp.regs; + } - current_regs = 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/sh/src/m16c/m16c_serial.c b/nuttx/arch/sh/src/m16c/m16c_serial.c index f9125cf11..a936dd922 100644 --- a/nuttx/arch/sh/src/m16c/m16c_serial.c +++ b/nuttx/arch/sh/src/m16c/m16c_serial.c @@ -788,7 +788,7 @@ static int up_rcvinterrupt(int irq, void *context) else #endif { - PANIC(OSERR_INTERNAL); + PANIC(); } /* Handle incoming, receive bytes (RDRF: Receive Data Register Full) */ @@ -954,7 +954,7 @@ static int up_xmtinterrupt(int irq, void *context) else #endif { - PANIC(OSERR_INTERNAL); + PANIC(); } /* Handle outgoing, transmit bytes */ diff --git a/nuttx/arch/sh/src/sh1/sh1_serial.c b/nuttx/arch/sh/src/sh1/sh1_serial.c index e696c96f5..5f521fa5a 100644 --- a/nuttx/arch/sh/src/sh1/sh1_serial.c +++ b/nuttx/arch/sh/src/sh1/sh1_serial.c @@ -584,7 +584,7 @@ static int up_interrupt(int irq, void *context) else #endif { - PANIC(OSERR_INTERNAL); + PANIC(); } priv = (struct up_dev_s*)dev->priv; diff --git a/nuttx/arch/sim/src/up_blocktask.c b/nuttx/arch/sim/src/up_blocktask.c index 46598b442..db9701434 100644 --- a/nuttx/arch/sim/src/up_blocktask.c +++ b/nuttx/arch/sim/src/up_blocktask.c @@ -1,7 +1,7 @@ /**************************************************************************** * up_blocktask.c * - * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -86,75 +86,71 @@ 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; - sdbg("Blocking TCB=%p\n", tcb); + ASSERT((tcb->task_state >= FIRST_READY_TO_RUN_STATE) && + (tcb->task_state <= LAST_READY_TO_RUN_STATE)); - /* 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. - */ + sdbg("Blocking TCB=%p\n", tcb); - 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 + */ + + if (g_pendingtasks.head) + { + switch_needed |= sched_mergepending(); + } - /* Now, perform the context switch if one is needed */ + /* Now, perform the context switch if one is needed */ - if (switch_needed) + if (switch_needed) + { + /* Copy the exception context into the TCB at the (old) head of the + * g_readytorun Task list. if up_setjmp returns a non-zero + * value, then this is really the previously running task restarting! + */ + + if (!up_setjmp(rtcb->xcp.regs)) { - /* Copy the exception context into the TCB at the (old) head of the - * g_readytorun Task list. if up_setjmp returns a non-zero - * value, then this is really the previously running task restarting! + /* Restore the exception context of the rtcb at the (new) head + * of the g_readytorun task list. */ - if (!up_setjmp(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; - sdbg("New Active Task TCB=%p\n", rtcb); + rtcb = (struct tcb_s*)g_readytorun.head; + sdbg("New Active Task TCB=%p\n", rtcb); - /* 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. - */ + /* 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. + */ - if (rtcb->xcp.sigdeliver) - { - sdbg("Delivering signals TCB=%p\n", rtcb); - ((sig_deliver_t)rtcb->xcp.sigdeliver)(rtcb); - rtcb->xcp.sigdeliver = NULL; - } + if (rtcb->xcp.sigdeliver) + { + sdbg("Delivering signals TCB=%p\n", rtcb); + ((sig_deliver_t)rtcb->xcp.sigdeliver)(rtcb); + rtcb->xcp.sigdeliver = NULL; + } - /* Then switch contexts */ + /* Then switch contexts */ - up_longjmp(rtcb->xcp.regs, 1); - } + up_longjmp(rtcb->xcp.regs, 1); } } } diff --git a/nuttx/arch/sim/src/up_head.c b/nuttx/arch/sim/src/up_head.c index 7326e73dc..00018865f 100644 --- a/nuttx/arch/sim/src/up_head.c +++ b/nuttx/arch/sim/src/up_head.c @@ -1,7 +1,7 @@ /**************************************************************************** * up_head.c * - * Copyright (C) 2007-2009, 2011-2112 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2011-2113 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -83,9 +83,3 @@ void up_assert(const uint8_t *filename, int line) fprintf(stderr, "Assertion failed at file:%s line: %d\n", filename, line); longjmp(sim_abort, 1); } - -void up_assert_code(const uint8_t *filename, int line, int code) -{ - fprintf(stderr, "Assertion failed at file:%s line: %d error code: %d\n", filename, line, code); - longjmp(sim_abort, 1); -} diff --git a/nuttx/arch/sim/src/up_reprioritizertr.c b/nuttx/arch/sim/src/up_reprioritizertr.c index 0b18defe6..7423a7112 100644 --- a/nuttx/arch/sim/src/up_reprioritizertr.c +++ b/nuttx/arch/sim/src/up_reprioritizertr.c @@ -99,7 +99,7 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority) #endif ) { - PANIC(OSERR_BADREPRIORITIZESTATE); + PANIC(); } else { diff --git a/nuttx/arch/sim/src/up_unblocktask.c b/nuttx/arch/sim/src/up_unblocktask.c index f8b229f8d..35961c5f8 100644 --- a/nuttx/arch/sim/src/up_unblocktask.c +++ b/nuttx/arch/sim/src/up_unblocktask.c @@ -1,7 +1,7 @@ /**************************************************************************** * up_unblocktask.c * - * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -81,68 +81,64 @@ 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; - sdbg("Unblocking TCB=%p\n", tcb); + ASSERT((tcb->task_state >= FIRST_BLOCKED_STATE) && + (tcb->task_state <= LAST_BLOCKED_STATE)); - /* Remove the task from the blocked task list */ + sdbg("Unblocking TCB=%p\n", tcb); - sched_removeblocked(tcb); + /* Remove the task from the blocked task list */ - /* Reset its timeslice. This is only meaningful for round - * robin tasks but it doesn't here to do it for everything - */ + sched_removeblocked(tcb); + + /* 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 - */ - - if (sched_addreadytorun(tcb)) - { - /* The currently active task has changed! Copy the exception context - * into the TCB of the task that was previously active. if - * up_setjmp returns a non-zero value, then this is really the - * previously running task restarting! - */ - - if (!up_setjmp(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; - sdbg("New Active Task TCB=%p\n", rtcb); - - /* 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. - */ - - if (rtcb->xcp.sigdeliver) - { - sdbg("Delivering signals TCB=%p\n", rtcb); - ((sig_deliver_t)rtcb->xcp.sigdeliver)(rtcb); - rtcb->xcp.sigdeliver = NULL; - } - - /* Then switch contexts */ - - up_longjmp(rtcb->xcp.regs, 1); - } + /* Add the task in the correct location in the prioritized + * g_readytorun task list + */ + + if (sched_addreadytorun(tcb)) + { + /* The currently active task has changed! Copy the exception context + * into the TCB of the task that was previously active. if + * up_setjmp returns a non-zero value, then this is really the + * previously running task restarting! + */ + + if (!up_setjmp(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; + sdbg("New Active Task TCB=%p\n", rtcb); + + /* 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. + */ + + if (rtcb->xcp.sigdeliver) + { + sdbg("Delivering signals TCB=%p\n", rtcb); + ((sig_deliver_t)rtcb->xcp.sigdeliver)(rtcb); + rtcb->xcp.sigdeliver = NULL; + } + + /* Then switch contexts */ + + up_longjmp(rtcb->xcp.regs, 1); } } } diff --git a/nuttx/arch/x86/src/common/up_assert.c b/nuttx/arch/x86/src/common/up_assert.c index ed83eb6ce..f9a36dc53 100644 --- a/nuttx/arch/x86/src/common/up_assert.c +++ b/nuttx/arch/x86/src/common/up_assert.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/x86/src/common/up_assert.c * - * Copyright (C) 2011-2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2011-2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -248,6 +248,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); @@ -255,29 +256,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/x86/src/common/up_blocktask.c b/nuttx/arch/x86/src/common/up_blocktask.c index b1653f1e4..dba388cb0 100644 --- a/nuttx/arch/x86/src/common/up_blocktask.c +++ b/nuttx/arch/x86/src/common/up_blocktask.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/x86/src/common/up_blocktask.c * - * Copyright (C) 2011 Gregory Nutt. All rights reserved. + * Copyright (C) 2011, 2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -85,82 +85,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/x86/src/common/up_reprioritizertr.c b/nuttx/arch/x86/src/common/up_reprioritizertr.c index 47c55f6b2..8c83b0790 100644 --- a/nuttx/arch/x86/src/common/up_reprioritizertr.c +++ b/nuttx/arch/x86/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/x86/src/common/up_unblocktask.c b/nuttx/arch/x86/src/common/up_unblocktask.c index eac913886..873ff1420 100644 --- a/nuttx/arch/x86/src/common/up_unblocktask.c +++ b/nuttx/arch/x86/src/common/up_unblocktask.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/x86/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 * * Redistribution and use in source and binary forms, with or without @@ -80,79 +80,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/x86/src/qemu/qemu_handlers.c b/nuttx/arch/x86/src/qemu/qemu_handlers.c index a0d6028aa..ae889a63f 100644 --- a/nuttx/arch/x86/src/qemu/qemu_handlers.c +++ b/nuttx/arch/x86/src/qemu/qemu_handlers.c @@ -142,7 +142,7 @@ uint32_t *isr_handler(uint32_t *regs) { #ifdef CONFIG_SUPPRESS_INTERRUPTS up_ledon(LED_INIRQ); - PANIC(OSERR_ERREXCEPTION); /* Doesn't return */ + PANIC(); /* Doesn't return */ return regs; /* To keep the compiler happy */ #else uint32_t *ret; @@ -168,7 +168,7 @@ uint32_t *irq_handler(uint32_t *regs) { #ifdef CONFIG_SUPPRESS_INTERRUPTS up_ledon(LED_INIRQ); - PANIC(OSERR_ERREXCEPTION); /* Doesn't return */ + PANIC(); /* Doesn't return */ return regs; /* To keep the compiler happy */ #else uint32_t *ret; diff --git a/nuttx/arch/z16/src/common/up_assert.c b/nuttx/arch/z16/src/common/up_assert.c index 06c77a73e..c5efc174a 100644 --- a/nuttx/arch/z16/src/common/up_assert.c +++ b/nuttx/arch/z16/src/common/up_assert.c @@ -1,7 +1,7 @@ /**************************************************************************** * common/up_assert.c * - * Copyright (C) 2008-2009, 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009, 2012-2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -140,40 +140,3 @@ void up_assert(void) up_registerdump(); _up_assert(EXIT_FAILURE); } - -/**************************************************************************** - * Name: up_assert_code - ****************************************************************************/ - -#ifdef CONFIG_HAVE_FILENAME -void up_assert_code(const uint8_t *filename, int lineno, int errorcode) -#else -void up_assert_code(int errorcode) -#endif -{ -#if CONFIG_TASK_NAME_SIZE > 0 - struct tcb_s *rtcb = (struct tcb_s*)g_readytorun.head; -#endif - - up_ledon(LED_ASSERTION); - -#ifdef CONFIG_HAVE_FILENAME -#if CONFIG_TASK_NAME_SIZE > 0 - 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 -#else -#if CONFIG_TASK_NAME_SIZE > 0 - lldbg("Assertion failed: task: %s error code: %d\n", rtcb->name, errorcode); -#else - lldbg("Assertion failed: error code: %d\n", errorcode); -#endif -#endif - - up_stackdump(); - up_registerdump(); - _up_assert(errorcode); -} diff --git a/nuttx/arch/z16/src/common/up_blocktask.c b/nuttx/arch/z16/src/common/up_blocktask.c index 93efee96f..56618ab3d 100644 --- a/nuttx/arch/z16/src/common/up_blocktask.c +++ b/nuttx/arch/z16/src/common/up_blocktask.c @@ -1,7 +1,7 @@ /**************************************************************************** * common/up_blocktask.c * - * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009, 2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -86,88 +86,83 @@ void up_block_task(FAR struct tcb_s *tcb, tstate_t task_state) { + FAR struct tcb_s *rtcb = (FAR 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 - { - FAR struct tcb_s *rtcb = (FAR struct tcb_s*)g_readytorun.head; - bool switch_needed; + ASSERT((tcb->task_state >= FIRST_READY_TO_RUN_STATE) && + (tcb->task_state <= LAST_READY_TO_RUN_STATE)); - /* dbg("Blocking TCB=%p\n", tcb); */ + /* dbg("Blocking TCB=%p\n", 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. - */ + /* 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. + */ - switch_needed = sched_removereadytorun(tcb); + switch_needed = sched_removereadytorun(tcb); - /* Add the task to the specified blocked task list */ + /* Add the task to the specified blocked task list */ - 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 - * task list now - */ + /* If there are any pending tasks, then add them to the g_readytorun + * task list now + */ - if (g_pendingtasks.head) - { - switch_needed |= sched_mergepending(); - } + if (g_pendingtasks.head) + { + switch_needed |= sched_mergepending(); + } - /* Now, perform the context switch if one is needed */ + /* Now, perform the context switch if one is needed */ - if (switch_needed) + if (switch_needed) + { + /* Are we in an interrupt handler? */ + + if (IN_INTERRUPT) { - /* Are we in an interrupt handler? */ + /* Yes, then we have to do things differently. + * Just copy the current registers into the OLD rtcb. + */ - if (IN_INTERRUPT) - { - /* Yes, then we have to do things differently. - * Just copy the current registers into the OLD rtcb. - */ + SAVE_IRQCONTEXT(rtcb); - SAVE_IRQCONTEXT(rtcb); + /* 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 = (FAR struct tcb_s*)g_readytorun.head; + /* dbg("New Active Task TCB=%p\n", rtcb); */ - rtcb = (FAR struct tcb_s*)g_readytorun.head; - /* dbg("New Active Task TCB=%p\n", rtcb); */ + /* Then setup so that the context will be performed on exit + * from the interrupt. + */ - /* Then setup so that the context will be performed on exit - * from the interrupt. - */ + SET_IRQCONTEXT(rtcb); + } - SET_IRQCONTEXT(rtcb); - } + /* Copy the user C context into the TCB at the (old) head of the + * g_readytorun Task list. if SAVE_USERCONTEXT 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 SAVE_USERCONTEXT returns a non-zero - * value, then this is really the previously running task restarting! + else if (!SAVE_USERCONTEXT(rtcb)) + { + /* Restore the exception context of the rtcb at the (new) head + * of the g_readytorun task list. */ - else if (!SAVE_USERCONTEXT(rtcb)) - { - /* Restore the exception context of the rtcb at the (new) head - * of the g_readytorun task list. - */ - - rtcb = (FAR struct tcb_s*)g_readytorun.head; - /* dbg("New Active Task TCB=%p\n", rtcb); */ + rtcb = (FAR struct tcb_s*)g_readytorun.head; + /* dbg("New Active Task TCB=%p\n", rtcb); */ - /* Then switch contexts */ + /* Then switch contexts */ - RESTORE_USERCONTEXT(rtcb); - } + RESTORE_USERCONTEXT(rtcb); } } } diff --git a/nuttx/arch/z16/src/common/up_doirq.c b/nuttx/arch/z16/src/common/up_doirq.c index 9964f4432..fea0a86d2 100644 --- a/nuttx/arch/z16/src/common/up_doirq.c +++ b/nuttx/arch/z16/src/common/up_doirq.c @@ -84,7 +84,7 @@ FAR chipreg_t *up_doirq(int irq, FAR chipreg_t *regs) up_ledon(LED_INIRQ); #ifdef CONFIG_SUPPRESS_INTERRUPTS - PANIC(OSERR_ERREXCEPTION); + PANIC(); #else if ((unsigned)irq < NR_IRQS) { diff --git a/nuttx/arch/z16/src/common/up_reprioritizertr.c b/nuttx/arch/z16/src/common/up_reprioritizertr.c index 2eb5c2cdb..bbfee7845 100644 --- a/nuttx/arch/z16/src/common/up_reprioritizertr.c +++ b/nuttx/arch/z16/src/common/up_reprioritizertr.c @@ -100,7 +100,7 @@ void up_reprioritize_rtr(FAR struct tcb_s *tcb, uint8_t priority) #endif ) { - PANIC(OSERR_BADREPRIORITIZESTATE); + PANIC(); } else { diff --git a/nuttx/arch/z16/src/common/up_unblocktask.c b/nuttx/arch/z16/src/common/up_unblocktask.c index f63981ab5..a629b5066 100644 --- a/nuttx/arch/z16/src/common/up_unblocktask.c +++ b/nuttx/arch/z16/src/common/up_unblocktask.c @@ -1,7 +1,7 @@ /**************************************************************************** * common/up_unblocktask.c * - * Copyright (C) 2008-2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2008-2009, 2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -83,85 +83,80 @@ void up_unblock_task(FAR struct tcb_s *tcb) { + FAR struct tcb_s *rtcb = (FAR 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 - { - FAR struct tcb_s *rtcb = (FAR struct tcb_s*)g_readytorun.head; + ASSERT((tcb->task_state >= FIRST_BLOCKED_STATE) && + (tcb->task_state <= LAST_BLOCKED_STATE)); - /* dbg("Unblocking TCB=%p\n", tcb); */ + /* dbg("Unblocking TCB=%p\n", tcb); */ - /* 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 (IN_INTERRUPT) { - /* 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 context into the OLD rtcb. */ - if (IN_INTERRUPT) - { - /* Yes, then we have to do things differently. - * Just copy the current context into the OLD rtcb. - */ + SAVE_IRQCONTEXT(rtcb); - SAVE_IRQCONTEXT(rtcb); + /* 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 = (FAR struct tcb_s*)g_readytorun.head; + /* dbg("New Active Task TCB=%p\n", rtcb); */ - rtcb = (FAR struct tcb_s*)g_readytorun.head; - /* dbg("New Active Task TCB=%p\n", rtcb); */ + /* Then setup so that the context will be performed on exit + * from the interrupt. + */ - /* Then setup so that the context will be performed on exit - * from the interrupt. - */ + SET_IRQCONTEXT(rtcb); + } - SET_IRQCONTEXT(rtcb); - } + /* We are not in an interrupt handler. Copy the user C context + * into the TCB of the task that was previously active. if + * SAVE_USERCONTEXT 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 - * SAVE_USERCONTEXT returns a non-zero value, then this is really the - * previously running task restarting! + else if (!SAVE_USERCONTEXT(rtcb)) + { + /* 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 (!SAVE_USERCONTEXT(rtcb)) - { - /* 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 = (FAR struct tcb_s*)g_readytorun.head; - /* dbg("New Active Task TCB=%p\n", rtcb); */ + rtcb = (FAR struct tcb_s*)g_readytorun.head; + /* dbg("New Active Task TCB=%p\n", rtcb); */ - /* Then switch contexts */ + /* Then switch contexts */ - RESTORE_USERCONTEXT(rtcb); - } + RESTORE_USERCONTEXT(rtcb); } } } diff --git a/nuttx/arch/z16/src/z16f/z16f_serial.c b/nuttx/arch/z16/src/z16f/z16f_serial.c index b0f1a4674..28c3f94b7 100644 --- a/nuttx/arch/z16/src/z16f/z16f_serial.c +++ b/nuttx/arch/z16/src/z16f/z16f_serial.c @@ -443,7 +443,7 @@ static int z16f_rxinterrupt(int irq, void *context) } else { - PANIC(OSERR_INTERNAL); + PANIC(); } priv = (struct z16f_uart_s*)dev->priv; @@ -492,7 +492,7 @@ static int z16f_txinterrupt(int irq, void *context) } else { - PANIC(OSERR_INTERNAL); + PANIC(); } priv = (struct z16f_uart_s*)dev->priv; diff --git a/nuttx/arch/z16/src/z16f/z16f_sysexec.c b/nuttx/arch/z16/src/z16f/z16f_sysexec.c index e824076b0..bd922237f 100644 --- a/nuttx/arch/z16/src/z16f/z16f_sysexec.c +++ b/nuttx/arch/z16/src/z16f/z16f_sysexec.c @@ -80,7 +80,6 @@ void z16f_sysexec(FAR chipreg_t *regs) { - int errcode = OSERR_ERREXCEPTION; uint16_t excp; /* Save that register reference so that it can be used for built-in @@ -98,35 +97,42 @@ void z16f_sysexec(FAR chipreg_t *regs) { SYSDBG("SP OVERFLOW\n"); } + if ((excp & Z16F_SYSEXCP_PCOVF) != 0) { SYSDBG("PC OVERFLOW\n"); } + if ((excp & Z16F_SYSEXCP_DIV0) != 0) { SYSDBG("Divide by zero\n"); } + if ((excp & Z16F_SYSEXCP_DIVOVF) != 0) { SYSDBG("Divide overflow\n"); } + if ((excp & Z16F_SYSEXCP_ILL) != 0) { SYSDBG("Illegal instruction\n"); - errcode = OSERR_UNDEFINEDINSN; } + if ((excp & Z16F_SYSEXCP_WDTOSC) != 0) { SYSDBG("WDT oscillator failure\n"); } + if ((excp & Z16F_SYSEXCP_PRIOSC) != 0) { SYSDBG("Primary Oscillator Failure\n"); } + if ((excp & Z16F_SYSEXCP_WDT) != 0) { SYSDBG("Watchdog timeout\n"); z16f_reset(); } - PANIC(errcode); + + PANIC(); } diff --git a/nuttx/arch/z80/src/common/up_assert.c b/nuttx/arch/z80/src/common/up_assert.c index 27929c97a..644aa5c7a 100644 --- a/nuttx/arch/z80/src/common/up_assert.c +++ b/nuttx/arch/z80/src/common/up_assert.c @@ -1,7 +1,7 @@ /**************************************************************************** * common/up_assert.c * - * Copyright (C) 2007-2009, 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2012-2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -140,40 +140,3 @@ void up_assert(void) REGISTER_DUMP(); _up_assert(EXIT_FAILURE); } - -/**************************************************************************** - * Name: up_assert_code - ****************************************************************************/ - -#ifdef CONFIG_HAVE_FILENAME -void up_assert_code(const uint8_t *filename, int lineno, int errorcode) -#else -void up_assert_code(int errorcode) -#endif -{ -#if CONFIG_TASK_NAME_SIZE > 0 - struct tcb_s *rtcb = (struct tcb_s*)g_readytorun.head; -#endif - - up_ledon(LED_ASSERTION); - -#ifdef CONFIG_HAVE_FILENAME -#if CONFIG_TASK_NAME_SIZE > 0 - 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 -#else -#if CONFIG_TASK_NAME_SIZE > 0 - lldbg("Assertion failed: task: %s error code: %d\n", rtcb->name, errorcode); -#else - lldbg("Assertion failed: error code: %d\n", errorcode); -#endif -#endif - - up_stackdump(); - REGISTER_DUMP(); - _up_assert(errorcode); -} diff --git a/nuttx/arch/z80/src/common/up_blocktask.c b/nuttx/arch/z80/src/common/up_blocktask.c index 6a9f050aa..875c0602c 100644 --- a/nuttx/arch/z80/src/common/up_blocktask.c +++ b/nuttx/arch/z80/src/common/up_blocktask.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/z80/src/common/up_blocktask.c * - * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -87,88 +87,83 @@ void up_block_task(FAR struct tcb_s *tcb, tstate_t task_state) { + FAR struct tcb_s *rtcb = (FAR 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 - { - FAR struct tcb_s *rtcb = (FAR struct tcb_s*)g_readytorun.head; - bool switch_needed; + ASSERT((tcb->task_state >= FIRST_READY_TO_RUN_STATE) && + (tcb->task_state <= LAST_READY_TO_RUN_STATE)); - /* dbg("Blocking TCB=%p\n", tcb); */ + /* dbg("Blocking TCB=%p\n", 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. - */ + /* 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. + */ - switch_needed = sched_removereadytorun(tcb); + switch_needed = sched_removereadytorun(tcb); - /* Add the task to the specified blocked task list */ + /* Add the task to the specified blocked task list */ - 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 - * task list now - */ + /* If there are any pending tasks, then add them to the g_readytorun + * task list now + */ - if (g_pendingtasks.head) - { - switch_needed |= sched_mergepending(); - } + if (g_pendingtasks.head) + { + switch_needed |= sched_mergepending(); + } - /* Now, perform the context switch if one is needed */ + /* Now, perform the context switch if one is needed */ - if (switch_needed) + if (switch_needed) + { + /* Are we in an interrupt handler? */ + + if (IN_INTERRUPT()) { - /* Are we in an interrupt handler? */ + /* Yes, then we have to do things differently. + * Just copy the current registers into the OLD rtcb. + */ - if (IN_INTERRUPT()) - { - /* Yes, then we have to do things differently. - * Just copy the current registers into the OLD rtcb. - */ + SAVE_IRQCONTEXT(rtcb); - SAVE_IRQCONTEXT(rtcb); + /* 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 = (FAR struct tcb_s*)g_readytorun.head; + /* dbg("New Active Task TCB=%p\n", rtcb); */ - rtcb = (FAR struct tcb_s*)g_readytorun.head; - /* dbg("New Active Task TCB=%p\n", rtcb); */ + /* Then setup so that the context will be performed on exit + * from the interrupt. + */ - /* Then setup so that the context will be performed on exit - * from the interrupt. - */ + SET_IRQCONTEXT(rtcb); + } - SET_IRQCONTEXT(rtcb); - } + /* Copy the user C context into the TCB at the (old) head of the + * g_readytorun Task list. if SAVE_USERCONTEXT 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 SAVE_USERCONTEXT returns a non-zero - * value, then this is really the previously running task restarting! + else if (!SAVE_USERCONTEXT(rtcb)) + { + /* Restore the exception context of the rtcb at the (new) head + * of the g_readytorun task list. */ - else if (!SAVE_USERCONTEXT(rtcb)) - { - /* Restore the exception context of the rtcb at the (new) head - * of the g_readytorun task list. - */ - - rtcb = (FAR struct tcb_s*)g_readytorun.head; - /* dbg("New Active Task TCB=%p\n", rtcb); */ + rtcb = (FAR struct tcb_s*)g_readytorun.head; + /* dbg("New Active Task TCB=%p\n", rtcb); */ - /* Then switch contexts */ + /* Then switch contexts */ - RESTORE_USERCONTEXT(rtcb); - } + RESTORE_USERCONTEXT(rtcb); } } } diff --git a/nuttx/arch/z80/src/common/up_doirq.c b/nuttx/arch/z80/src/common/up_doirq.c index ad318e17f..231e787ca 100644 --- a/nuttx/arch/z80/src/common/up_doirq.c +++ b/nuttx/arch/z80/src/common/up_doirq.c @@ -78,7 +78,7 @@ FAR chipreg_t *up_doirq(uint8_t irq, FAR chipreg_t *regs) lowsyslog("Unexpected IRQ\n"); IRQ_ENTER(regs); - PANIC(OSERR_ERREXCEPTION); + PANIC(); return NULL; /* Won't get here */ #else diff --git a/nuttx/arch/z80/src/common/up_reprioritizertr.c b/nuttx/arch/z80/src/common/up_reprioritizertr.c index 476f324e3..a5b3a18c8 100644 --- a/nuttx/arch/z80/src/common/up_reprioritizertr.c +++ b/nuttx/arch/z80/src/common/up_reprioritizertr.c @@ -101,7 +101,7 @@ void up_reprioritize_rtr(FAR struct tcb_s *tcb, uint8_t priority) #endif ) { - PANIC(OSERR_BADREPRIORITIZESTATE); + PANIC(); } else { diff --git a/nuttx/arch/z80/src/common/up_unblocktask.c b/nuttx/arch/z80/src/common/up_unblocktask.c index 9f9714bb9..e6141d4fc 100644 --- a/nuttx/arch/z80/src/common/up_unblocktask.c +++ b/nuttx/arch/z80/src/common/up_unblocktask.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/z80/src/common/up_unblocktask.c * - * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -84,85 +84,80 @@ void up_unblock_task(FAR struct tcb_s *tcb) { + FAR struct tcb_s *rtcb = (FAR 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 - { - FAR struct tcb_s *rtcb = (FAR struct tcb_s*)g_readytorun.head; + ASSERT((tcb->task_state >= FIRST_BLOCKED_STATE) && + (tcb->task_state <= LAST_BLOCKED_STATE)); - /* dbg("Unblocking TCB=%p\n", tcb); */ + /* dbg("Unblocking TCB=%p\n", tcb); */ - /* 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 (IN_INTERRUPT()) { - /* 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 context into the OLD rtcb. */ - if (IN_INTERRUPT()) - { - /* Yes, then we have to do things differently. - * Just copy the current context into the OLD rtcb. - */ + SAVE_IRQCONTEXT(rtcb); - SAVE_IRQCONTEXT(rtcb); + /* 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 = (FAR struct tcb_s*)g_readytorun.head; + /* dbg("New Active Task TCB=%p\n", rtcb); */ - rtcb = (FAR struct tcb_s*)g_readytorun.head; - /* dbg("New Active Task TCB=%p\n", rtcb); */ + /* Then setup so that the context will be performed on exit + * from the interrupt. + */ - /* Then setup so that the context will be performed on exit - * from the interrupt. - */ + SET_IRQCONTEXT(rtcb); + } - SET_IRQCONTEXT(rtcb); - } + /* We are not in an interrupt handler. Copy the user C context + * into the TCB of the task that was previously active. if + * SAVE_USERCONTEXT 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 - * SAVE_USERCONTEXT returns a non-zero value, then this is really the - * previously running task restarting! + else if (!SAVE_USERCONTEXT(rtcb)) + { + /* 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 (!SAVE_USERCONTEXT(rtcb)) - { - /* 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 = (FAR struct tcb_s*)g_readytorun.head; - /* dbg("New Active Task TCB=%p\n", rtcb); */ + rtcb = (FAR struct tcb_s*)g_readytorun.head; + /* dbg("New Active Task TCB=%p\n", rtcb); */ - /* Then switch contexts */ + /* Then switch contexts */ - RESTORE_USERCONTEXT(rtcb); - } + RESTORE_USERCONTEXT(rtcb); } } } diff --git a/nuttx/arch/z80/src/ez80/ez80_serial.c b/nuttx/arch/z80/src/ez80/ez80_serial.c index bf938529c..a178ecb19 100644 --- a/nuttx/arch/z80/src/ez80/ez80_serial.c +++ b/nuttx/arch/z80/src/ez80/ez80_serial.c @@ -490,7 +490,7 @@ static int ez80_interrrupt(int irq, void *context) else #endif { - PANIC(OSERR_INTERNAL); + PANIC(); } priv = (struct ez80_dev_s*)dev->priv; diff --git a/nuttx/arch/z80/src/z8/z8_serial.c b/nuttx/arch/z80/src/z8/z8_serial.c index fd499b183..553e3fb40 100644 --- a/nuttx/arch/z80/src/z8/z8_serial.c +++ b/nuttx/arch/z80/src/z8/z8_serial.c @@ -505,7 +505,7 @@ static int z8_rxinterrupt(int irq, FAR void *context) } else { - PANIC(OSERR_INTERNAL); + PANIC(); } priv = (struct z8_uart_s*)dev->priv; @@ -554,7 +554,7 @@ static int z8_txinterrupt(int irq, FAR void *context) } else { - PANIC(OSERR_INTERNAL); + PANIC(); } priv = (struct z8_uart_s*)dev->priv; diff --git a/nuttx/configs/stm3210e-eval/RIDE/bigfatstub.c b/nuttx/configs/stm3210e-eval/RIDE/bigfatstub.c index b9b51dd98..69d679fd8 100644 --- a/nuttx/configs/stm3210e-eval/RIDE/bigfatstub.c +++ b/nuttx/configs/stm3210e-eval/RIDE/bigfatstub.c @@ -9,7 +9,7 @@ void os_start(void) for (;;); } -void up_assert_code(const uint8_t *filename, int lineno, int errorcode) +void up_assert(const uint8_t *filename, int lineno) { up_lowputc('?'); up_lowputc('\n'); diff --git a/nuttx/include/assert.h b/nuttx/include/assert.h index f3e2854fc..29eb7a4b3 100644 --- a/nuttx/include/assert.h +++ b/nuttx/include/assert.h @@ -61,9 +61,6 @@ # define ASSERT(f) \ { if (!(f)) up_assert((const uint8_t *)__FILE__, (int)__LINE__); } -# define ASSERTCODE(f, code) \ - { if (!(f)) up_assert_code((const uint8_t *)__FILE__, (int)__LINE__, code); } - # define VERIFY(f) \ { if ((f) < 0) up_assert((const uint8_t *)__FILE__, (int)__LINE__); } @@ -77,16 +74,13 @@ # define DEBUGVERIFY(f) ((void)(f)) # endif /* CONFIG_DEBUG */ -# define PANIC(code) \ - up_assert_code((const uint8_t *)__FILE__, (int)__LINE__, (code)|0x8000) +# define PANIC() \ + up_assert((const uint8_t *)__FILE__, (int)__LINE__) #else # define ASSERT(f) \ { if (!(f)) up_assert(); } -# define ASSERTCODE(f, code) \ - { if (!(f)) up_assert_code(code); } - # define VERIFY(f) \ { if ((f) < 0) up_assert(); } @@ -101,7 +95,7 @@ # endif /* CONFIG_DEBUG */ # define PANIC(code) \ - up_assert_code((code)|0x8000) + up_assert() #endif @@ -131,11 +125,8 @@ extern "C" #ifdef CONFIG_HAVE_FILENAME void up_assert(FAR const uint8_t *filename, int linenum) noreturn_function; -void up_assert_code(FAR const uint8_t *filename, int linenum, int errcode) - noreturn_function; #else void up_assert(void) noreturn_function; -void up_assert_code(int errcode) noreturn_function; #endif #undef EXTERN diff --git a/nuttx/include/nuttx/arch.h b/nuttx/include/nuttx/arch.h index 0382c45ef..480b5fde5 100644 --- a/nuttx/include/nuttx/arch.h +++ b/nuttx/include/nuttx/arch.h @@ -400,11 +400,10 @@ void up_reprioritize_rtr(FAR struct tcb_s *tcb, uint8_t priority); /* Prototype is in unistd.h */ /**************************************************************************** - * Name: up_assert and up_assert_code + * Name: up_assert * * Description: - * Assertions may be handled in an architecture-specific - * way. + * Assertions may be handled in an architecture-specific way. * ****************************************************************************/ /* Prototype is in assert.h */ diff --git a/nuttx/include/sys/syscall.h b/nuttx/include/sys/syscall.h index 664cc1d79..f29dfadde 100644 --- a/nuttx/include/sys/syscall.h +++ b/nuttx/include/sys/syscall.h @@ -94,8 +94,7 @@ #define SYS_task_delete (CONFIG_SYS_RESERVED+22) #define SYS_task_restart (CONFIG_SYS_RESERVED+23) #define SYS_up_assert (CONFIG_SYS_RESERVED+24) -#define SYS_up_assert_code (CONFIG_SYS_RESERVED+25) -#define __SYS_vfork (CONFIG_SYS_RESERVED+26) +#define __SYS_vfork (CONFIG_SYS_RESERVED+25) /* The following can be individually enabled */ diff --git a/nuttx/libxx/libxx_cxapurevirtual.cxx b/nuttx/libxx/libxx_cxapurevirtual.cxx index e8912558a..653793ec4 100644 --- a/nuttx/libxx/libxx_cxapurevirtual.cxx +++ b/nuttx/libxx/libxx_cxapurevirtual.cxx @@ -1,7 +1,7 @@ //*************************************************************************** // libxx/libxx_cxapurevirtual.cxx // -// Copyright (C) 2009 2011 Gregory Nutt. All rights reserved. +// Copyright (C) 2009, 2011, 2013 Gregory Nutt. All rights reserved. // Author: Gregory Nutt // // Redistribution and use in source and binary forms, with or without @@ -63,7 +63,7 @@ extern "C" { void __cxa_pure_virtual(void) { - PANIC(100); + PANIC(); } } diff --git a/nuttx/sched/irq_unexpectedisr.c b/nuttx/sched/irq_unexpectedisr.c index c0090ead4..e0291b026 100644 --- a/nuttx/sched/irq_unexpectedisr.c +++ b/nuttx/sched/irq_unexpectedisr.c @@ -1,7 +1,7 @@ /**************************************************************************** * sched/irq_unexpectedisr.c * - * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -83,6 +83,6 @@ int irq_unexpected_isr(int irq, FAR void *context) { (void)irqsave(); lldbg("irq: %d\n", irq); - PANIC(OSERR_UNEXPECTEDISR); + PANIC(); return OK; /* Won't get here */ } diff --git a/nuttx/sched/mq_msgfree.c b/nuttx/sched/mq_msgfree.c index 61b0e1055..23ccc3a8e 100644 --- a/nuttx/sched/mq_msgfree.c +++ b/nuttx/sched/mq_msgfree.c @@ -1,7 +1,7 @@ /************************************************************************ * sched/mq_msgfree.c * - * Copyright (C) 2007 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -129,6 +129,6 @@ void mq_msgfree(FAR mqmsg_t *mqmsg) } else { - PANIC(OSERR_BADMSGTYPE); + PANIC(); } } diff --git a/nuttx/sched/mq_rcvinternal.c b/nuttx/sched/mq_rcvinternal.c index 44f0edcb2..3ccc60dca 100644 --- a/nuttx/sched/mq_rcvinternal.c +++ b/nuttx/sched/mq_rcvinternal.c @@ -1,7 +1,7 @@ /**************************************************************************** * sched/mq_rcvinternal.c * - * Copyright (C) 2007, 2008, 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2007, 2008, 2012-2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -292,16 +292,11 @@ ssize_t mq_doreceive(mqd_t mqdes, mqmsg_t *mqmsg, void *ubuffer, int *prio) * time the task is unblocked */ - if (!btcb) - { - PANIC(OSERR_MQNOTFULLCOUNT); - } - else - { - btcb->msgwaitq = NULL; - msgq->nwaitnotfull--; - up_unblock_task(btcb); - } + ASSERT(btcb); + + btcb->msgwaitq = NULL; + msgq->nwaitnotfull--; + up_unblock_task(btcb); irqrestore(saved_state); } diff --git a/nuttx/sched/mq_sndinternal.c b/nuttx/sched/mq_sndinternal.c index e65b51c5a..9b004ef91 100644 --- a/nuttx/sched/mq_sndinternal.c +++ b/nuttx/sched/mq_sndinternal.c @@ -203,18 +203,8 @@ FAR mqmsg_t *mq_msgalloc(void) /* Check if we got an allocated message */ - if (mqmsg) - { - mqmsg->type = MQ_ALLOC_DYN; - } - - /* No? We are dead */ - - else - { - sdbg("Out of messages\n"); - PANIC((uint32_t)OSERR_OUTOFMESSAGES); - } + ASSERT(mqmsg); + mqmsg->type = MQ_ALLOC_DYN; } } @@ -436,16 +426,11 @@ int mq_dosend(mqd_t mqdes, FAR mqmsg_t *mqmsg, const void *msg, size_t msglen, i /* If one was found, unblock it */ - if (!btcb) - { - PANIC(OSERR_MQNONEMPTYCOUNT); - } - else - { - btcb->msgwaitq = NULL; - msgq->nwaitnotempty--; - up_unblock_task(btcb); - } + ASSERT(btcb); + + btcb->msgwaitq = NULL; + msgq->nwaitnotempty--; + up_unblock_task(btcb); } irqrestore(saved_state); diff --git a/nuttx/sched/mq_waitirq.c b/nuttx/sched/mq_waitirq.c index c12de1675..c30bdf836 100644 --- a/nuttx/sched/mq_waitirq.c +++ b/nuttx/sched/mq_waitirq.c @@ -113,46 +113,20 @@ void mq_waitirq(FAR struct tcb_s *wtcb, int errcode) /* Get the message queue associated with the waiter from the TCB */ msgq = wtcb->msgwaitq; -#ifdef CONFIG_DEBUG - if (!msgq) - { - /* In these states there must always be an associated message queue */ + DEBUGASSERT(msgq); - PANIC((uint32_t)OSERR_MQNOWAITER); - } -#endif wtcb->msgwaitq = NULL; /* Decrement the count of waiters and cancel the wait */ if (wtcb->task_state == TSTATE_WAIT_MQNOTEMPTY) { -#ifdef CONFIG_DEBUG - if (msgq->nwaitnotempty <= 0) - { - /* This state, there should be a positive, non-zero waiter - * count. - */ - - PANIC((uint32_t)OSERR_MQNONEMPTYCOUNT); - - } -#endif + DEBUGASSERT(msgq->nwaitnotempty > 0); msgq->nwaitnotempty--; } else { -#ifdef CONFIG_DEBUG - if (msgq->nwaitnotfull <= 0) - { - /* This state, there should be a positive, non-zero waiter - * count. - */ - - PANIC((uint32_t)OSERR_MQNOTFULLCOUNT); - - } -#endif + DEBUGASSERT(msgq->nwaitnotfull > 0); msgq->nwaitnotfull--; } diff --git a/nuttx/sched/os_internal.h b/nuttx/sched/os_internal.h index d13eb9cad..06cb3cf01 100644 --- a/nuttx/sched/os_internal.h +++ b/nuttx/sched/os_internal.h @@ -53,36 +53,6 @@ * Pre-processor Definitions ****************************************************************************/ -/* OS CRASH CODES: All must lie in the range 0-99 */ - -enum os_crash_codes_e -{ - OSERR_NOERROR = 0, /* No error */ - OSERR_NOTIMPLEMENTED, /* Feature is not implemented */ - OSERR_INTERNAL, /* Internal logic error */ - OSERR_UNEXPECTEDISR, /* Received unexpected interrupt */ - OSERR_UNDEFINEDINSN, /* Undefined instruction */ - OSERR_ERREXCEPTION, /* Other CPU-detected errors */ - OSERR_OUTOFMEMORY, /* Insufficient memory */ - OSERR_OUTOFMESSAGES, /* Out of messages */ - OSERR_NOIDLETASK, /* There is no idle task */ - OSERR_MQNONEMPTYCOUNT, /* Expected waiter for non-empty queue */ - OSERR_MQNOTFULLCOUNT, /* Expected waiter for non-full queue */ - OSERR_MQNOWAITER, /* Expected a queue for the waiter */ - OSERR_BADWAITSEM, /* Already waiting for a semaphore */ - OSERR_BADMSGTYPE, /* Tried to free a bad message type */ - OSERR_FAILEDTOADDSIGNAL, /* Failed to add pending signal */ - OSERR_FAILEDTOREMOVESIGNAL, /* Failed to remove pending signal */ - OSERR_TIMEOUTNOTCB, /* Timed out, but not TCB registered */ - OSERR_NOPENDINGSIGNAL, /* Expected a signal to be pending */ - OSERR_BADDELETESTATE, /* Bad state in task deletion */ - OSERR_WDOGNOTFOUND, /* Active watchdog not found */ - OSERR_EXITFROMINTERRUPT, /* Interrupt code attempted to exit */ - OSERR_BADUNBLOCKSTATE, /* Attempt to unblock from bad state */ - OSERR_BADBLOCKSTATE, /* Attempt to block from bad state */ - OSERR_BADREPRIORITIZESTATE /* Attempt to reprioritize in bad state or priority */ -}; - /* Special task IDS. Any negative PID is invalid. */ #define NULL_TASK_PROCESS_ID (pid_t)0 diff --git a/nuttx/sched/sched_mergepending.c b/nuttx/sched/sched_mergepending.c index 1364d2b1c..c400fee4d 100644 --- a/nuttx/sched/sched_mergepending.c +++ b/nuttx/sched/sched_mergepending.c @@ -125,42 +125,37 @@ bool sched_mergepending(void) * the g_readytorun list! */ - if (!rtrtcb) + ASSERT(rtrtcb); + + /* The pndtcb goes just before rtrtcb */ + + rtrprev = rtrtcb->blink; + if (!rtrprev) { - PANIC(OSERR_NOIDLETASK); + /* Special case: Inserting pndtcb at the head of the list */ + /* Inform the instrumentation layer that we are switching tasks */ + + sched_note_switch(rtrtcb, pndtcb); + + /* Then insert at the head of the list */ + + pndtcb->flink = rtrtcb; + pndtcb->blink = NULL; + rtrtcb->blink = pndtcb; + g_readytorun.head = (FAR dq_entry_t*)pndtcb; + rtrtcb->task_state = TSTATE_TASK_READYTORUN; + pndtcb->task_state = TSTATE_TASK_RUNNING; + ret = true; } else { - /* The pndtcb goes just before rtrtcb */ - - rtrprev = rtrtcb->blink; - if (!rtrprev) - { - /* Special case: Inserting pndtcb at the head of the list */ - /* Inform the instrumentation layer that we are switching tasks */ - - sched_note_switch(rtrtcb, pndtcb); - - /* Then insert at the head of the list */ - - pndtcb->flink = rtrtcb; - pndtcb->blink = NULL; - rtrtcb->blink = pndtcb; - g_readytorun.head = (FAR dq_entry_t*)pndtcb; - rtrtcb->task_state = TSTATE_TASK_READYTORUN; - pndtcb->task_state = TSTATE_TASK_RUNNING; - ret = true; - } - else - { - /* Insert in the middle of the list */ - - pndtcb->flink = rtrtcb; - pndtcb->blink = rtrprev; - rtrprev->flink = pndtcb; - rtrtcb->blink = pndtcb; - pndtcb->task_state = TSTATE_TASK_READYTORUN; - } + /* Insert in the middle of the list */ + + pndtcb->flink = rtrtcb; + pndtcb->blink = rtrprev; + rtrprev->flink = pndtcb; + rtrtcb->blink = pndtcb; + pndtcb->task_state = TSTATE_TASK_READYTORUN; } /* Set up for the next time through */ diff --git a/nuttx/sched/sem_wait.c b/nuttx/sched/sem_wait.c index 06884e595..b7d16434c 100644 --- a/nuttx/sched/sem_wait.c +++ b/nuttx/sched/sem_wait.c @@ -139,10 +139,7 @@ int sem_wait(FAR sem_t *sem) * semaphore */ - if (rtcb->waitsem != NULL) - { - PANIC(OSERR_BADWAITSEM); - } + ASSERT(rtcb->waitsem == NULL); /* Handle the POSIX semaphore (but don't set the owner yet) */ diff --git a/nuttx/sched/sig_action.c b/nuttx/sched/sig_action.c index ac2c24cfb..84a7ff6b6 100644 --- a/nuttx/sched/sig_action.c +++ b/nuttx/sched/sig_action.c @@ -101,10 +101,7 @@ static FAR sigactq_t *sig_allocateaction(void) /* And try again */ sigact = (FAR sigactq_t*)sq_remfirst(&g_sigfreeaction); - if (!sigact) - { - PANIC(OSERR_OUTOFMEMORY); - } + ASSERT(sigact); } return sigact; diff --git a/nuttx/sched/sig_dispatch.c b/nuttx/sched/sig_dispatch.c index 7c4d34138..82c891b46 100644 --- a/nuttx/sched/sig_dispatch.c +++ b/nuttx/sched/sig_dispatch.c @@ -349,10 +349,7 @@ int sig_tcbdispatch(FAR struct tcb_s *stcb, siginfo_t *info) else { irqrestore(saved_state); - if (!sig_addpendingsignal(stcb, info)) - { - PANIC(OSERR_FAILEDTOADDSIGNAL); - } + ASSERT(sig_addpendingsignal(stcb, info)); } } diff --git a/nuttx/sched/sig_suspend.c b/nuttx/sched/sig_suspend.c index bc26aa35a..e57ac4396 100644 --- a/nuttx/sched/sig_suspend.c +++ b/nuttx/sched/sig_suspend.c @@ -140,10 +140,7 @@ int sigsuspend(FAR const sigset_t *set) unblocksigno = sig_lowest(&intersection); sigpend = sig_removependingsignal(rtcb, unblocksigno); - if (!sigpend) - { - PANIC(OSERR_FAILEDTOREMOVESIGNAL); - } + ASSERT(sigpend); sig_releasependingsignal(sigpend); irqrestore(saved_state); diff --git a/nuttx/sched/sig_timedwait.c b/nuttx/sched/sig_timedwait.c index fd8939a1d..3d70f33db 100644 --- a/nuttx/sched/sig_timedwait.c +++ b/nuttx/sched/sig_timedwait.c @@ -104,12 +104,8 @@ static void sig_timeout(int argc, uint32_t itcb) uint32_t itcb; } u; - u.itcb = itcb; - - if (!u.wtcb) - { - PANIC(OSERR_TIMEOUTNOTCB); - } + u.itcb = itcb; + ASSERT(u.wtcb); /* There may be a race condition -- make sure the task is * still waiting for a signal @@ -210,10 +206,7 @@ int sigtimedwait(FAR const sigset_t *set, FAR struct siginfo *info, */ sigpend = sig_removependingsignal(rtcb, sig_lowest(&intersection)); - if (!sigpend) - { - PANIC(OSERR_NOPENDINGSIGNAL); - } + ASSERT(sigpend); /* Return the signal info to the caller if so requested */ diff --git a/nuttx/sched/task_delete.c b/nuttx/sched/task_delete.c index 637b536ec..1cf9f97e5 100644 --- a/nuttx/sched/task_delete.c +++ b/nuttx/sched/task_delete.c @@ -145,7 +145,7 @@ int task_terminate(pid_t pid, bool nonblocking) dtcb->task_state >= NUM_TASK_STATES) { sched_unlock(); - PANIC(OSERR_BADDELETESTATE); + PANIC(); } /* Perform common task termination logic (flushing streams, calling diff --git a/nuttx/sched/wd_cancel.c b/nuttx/sched/wd_cancel.c index 0bd59cf89..a1c220873 100644 --- a/nuttx/sched/wd_cancel.c +++ b/nuttx/sched/wd_cancel.c @@ -123,38 +123,34 @@ int wd_cancel (WDOG_ID wdid) * error has occurred because the watchdog is marked active! */ - if (!curr) + ASSERT(curr); + + /* If there is a watchdog in the timer queue after the one that + * is being canceled, then it inherits the remaining ticks. + */ + + if (curr->next) + { + curr->next->lag += curr->lag; + } + + /* Now, remove the watchdog from the timer queue */ + + if (prev) { - PANIC(OSERR_WDOGNOTFOUND); + (void)sq_remafter((FAR sq_entry_t*)prev, &g_wdactivelist); } else { - /* If there is a watchdog in the timer queue after the one that - * is being canceled, then it inherits the remaining ticks. - */ - - if (curr->next) - { - curr->next->lag += curr->lag; - } - - /* Now, remove the watchdog from the timer queue */ - - if (prev) - { - (void)sq_remafter((FAR sq_entry_t*)prev, &g_wdactivelist); - } - else - { - (void)sq_remfirst(&g_wdactivelist); - } - wdid->next = NULL; - - /* Return success */ - - ret = OK; + (void)sq_remfirst(&g_wdactivelist); } + wdid->next = NULL; + + /* Return success */ + + ret = OK; + /* Mark the watchdog inactive */ wdid->active = false; diff --git a/nuttx/sched/wd_start.c b/nuttx/sched/wd_start.c index 2a69d131a..440c83b0c 100644 --- a/nuttx/sched/wd_start.c +++ b/nuttx/sched/wd_start.c @@ -337,7 +337,7 @@ void wd_timer(void) { default: #ifdef CONFIG_DEBUG - PANIC(OSERR_INTERNAL); + PANIC(); #endif case 0: (*((wdentry0_t)(wdog->func)))(0); diff --git a/nuttx/syscall/syscall.csv b/nuttx/syscall/syscall.csv index 988589ad2..0e9c452a1 100644 --- a/nuttx/syscall/syscall.csv +++ b/nuttx/syscall/syscall.csv @@ -137,8 +137,6 @@ "unsetenv","stdlib.h","!defined(CONFIG_DISABLE_ENVIRON)","int","const char*" "up_assert","assert.h","","void","FAR const uint8_t*","int" #"up_assert","assert.h","","void" -"up_assert_code","assert.h","","void","FAR const uint8_t*","int","int" -#"up_assert_code","assert.h","","void","int" "usleep","unistd.h","!defined(CONFIG_DISABLE_SIGNALS)","int","useconds_t" "vfork","unistd.h","defined(CONFIG_ARCH_HAVE_VFORK)","pid_t" "wait","sys/wait.h","defined(CONFIG_SCHED_WAITPID) && defined(CONFIG_SCHED_HAVE_PARENT)","pid_t","int*" diff --git a/nuttx/syscall/syscall_lookup.h b/nuttx/syscall/syscall_lookup.h index e134c7179..a5e2045bc 100644 --- a/nuttx/syscall/syscall_lookup.h +++ b/nuttx/syscall/syscall_lookup.h @@ -68,7 +68,6 @@ SYSCALL_LOOKUP(task_create, 5, STUB_task_create) SYSCALL_LOOKUP(task_delete, 1, STUB_task_delete) SYSCALL_LOOKUP(task_restart, 1, STUB_task_restart) SYSCALL_LOOKUP(up_assert, 2, STUB_up_assert) -SYSCALL_LOOKUP(up_assert_code, 3, STUB_up_assert_code) /* The following can be individually enabled */ diff --git a/nuttx/syscall/syscall_stublookup.c b/nuttx/syscall/syscall_stublookup.c index 0cb70d0a0..517c15af3 100644 --- a/nuttx/syscall/syscall_stublookup.c +++ b/nuttx/syscall/syscall_stublookup.c @@ -87,8 +87,6 @@ uintptr_t STUB_task_create(int nbr, uintptr_t parm1, uintptr_t parm2, uintptr_t STUB_task_delete(int nbr, uintptr_t parm1); uintptr_t STUB_task_restart(int nbr, uintptr_t parm1); uintptr_t STUB_up_assert(int nbr, uintptr_t parm1, uintptr_t parm2); -uintptr_t STUB_up_assert_code(int nbr, uintptr_t parm1, uintptr_t parm2, - uintptr_t parm3); /* The following can be individually enabled */ -- cgit v1.2.3