diff --git a/ChangeLog b/ChangeLog index ada4463bca5..dcaf044101a 100644 --- a/ChangeLog +++ b/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/Documentation/NuttxPortingGuide.html b/Documentation/NuttxPortingGuide.html index 642cb1a3c27..bb457ffd311 100644 --- a/Documentation/NuttxPortingGuide.html +++ b/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/arch/8051/src/up_assert.c b/arch/8051/src/up_assert.c index f1f9bb87f79..53e74feb710 100644 --- a/arch/8051/src/up_assert.c +++ b/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/arch/8051/src/up_blocktask.c b/arch/8051/src/up_blocktask.c index 554111ae014..01857747734 100644 --- a/arch/8051/src/up_blocktask.c +++ b/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)) + ASSERT((tcb->task_state >= FIRST_READY_TO_RUN_STATE) && + (tcb->task_state <= LAST_READY_TO_RUN_STATE)); + + 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. + */ + + switch_needed = sched_removereadytorun(tcb); + + /* Add the task to the specified blocked task list */ + + sched_addblocked(tcb, (tstate_t)task_state); + + /* If there are any pending tasks, then add them to the g_readytorun + * task list now + */ + + if (g_pendingtasks.head) { - PANIC(OSERR_BADBLOCKSTATE); + switch_needed |= sched_mergepending(); } - else + + /* Now, perform the context switch if one is needed */ + + if (switch_needed) { - FAR struct tcb_s *rtcb = (FAR struct tcb_s*)g_readytorun.head; - bool switch_needed; + /* Are we in an interrupt handler? */ - 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. - */ - - switch_needed = sched_removereadytorun(tcb); - - /* Add the task to the specified blocked task list */ - - sched_addblocked(tcb, (tstate_t)task_state); - - /* If there are any pending tasks, then add them to the g_readytorun - * task list now - */ - - if (g_pendingtasks.head) + if (g_irqtos) { - switch_needed |= sched_mergepending(); - } - - /* Now, perform the context switch if one is needed */ - - if (switch_needed) - { - /* Are we in an interrupt handler? */ - - if (g_irqtos) - { - /* Yes, then we have to do things differently. - * Just copy the current registers into the OLD rtcb. - */ - - up_saveirqcontext(&tcb->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; - } - - /* 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! + /* Yes, then we have to do things differently. + * Just copy the current registers into the OLD rtcb. */ - else if (!up_savecontext(&rtcb->xcp)) - { - /* Restore the exception context of the rtcb at the (new) head - * of the g_readytorun task list. - */ + up_saveirqcontext(&tcb->xcp); - rtcb = (FAR struct tcb_s*)g_readytorun.head; - dbg("New Active Task TCB=%p\n", rtcb); + /* Restore the exception context of the rtcb at the (new) head + * of the g_readytorun task list. + */ - /* Then switch contexts */ + rtcb = (FAR struct tcb_s*)g_readytorun.head; + dbg("New Active Task TCB=%p\n", rtcb); - up_restorecontext(&rtcb->xcp); - } + /* Then setup so that the context will be performed on exit + * from the interrupt. + */ + + 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! + */ + + 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); + + /* Then switch contexts */ + + up_restorecontext(&rtcb->xcp); } } } diff --git a/arch/8051/src/up_reprioritizertr.c b/arch/8051/src/up_reprioritizertr.c index 14c14e663a8..649db3a43c4 100644 --- a/arch/8051/src/up_reprioritizertr.c +++ b/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/arch/8051/src/up_unblocktask.c b/arch/8051/src/up_unblocktask.c index f3f9215497e..621c8a78369 100644 --- a/arch/8051/src/up_unblocktask.c +++ b/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 - */ + /* 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)) + { + /* 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. - */ + if (g_irqtos) + { + /* Yes, then we have to do things differently. + * Just copy the current stack into the OLD rtcb. + */ - up_saveirqcontext(&rtcb->xcp); + up_saveirqcontext(&rtcb->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; + } - /* 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! - */ + /* 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. - */ + 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); + 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/arch/arm/src/arm/up_assert.c b/arch/arm/src/arm/up_assert.c index e5bf00d6ee3..03f6e4d8fa8 100644 --- a/arch/arm/src/arm/up_assert.c +++ b/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/arch/arm/src/arm/up_blocktask.c b/arch/arm/src/arm/up_blocktask.c index 090cc64071e..04caa448150 100644 --- a/arch/arm/src/arm/up_blocktask.c +++ b/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)) + 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. + */ + + switch_needed = sched_removereadytorun(tcb); + + /* Add the task to the specified blocked task list */ + + sched_addblocked(tcb, (tstate_t)task_state); + + /* If there are any pending tasks, then add them to the g_readytorun + * task list now + */ + + if (g_pendingtasks.head) { - PANIC(OSERR_BADBLOCKSTATE); + switch_needed |= sched_mergepending(); } - else + + /* Now, perform the context switch if one is needed */ + + if (switch_needed) { - struct tcb_s *rtcb = (struct tcb_s*)g_readytorun.head; - bool switch_needed; + /* Are we in an interrupt handler? */ - /* 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); - - /* Add the task to the specified blocked task list */ - - sched_addblocked(tcb, (tstate_t)task_state); - - /* If there are any pending tasks, then add them to the g_readytorun - * task list now - */ - - if (g_pendingtasks.head) + if (current_regs) { - switch_needed |= sched_mergepending(); - } - - /* Now, perform the context switch if one is needed */ - - if (switch_needed) - { - /* Are we in an interrupt handler? */ - - if (current_regs) - { - /* Yes, then we have to do things differently. - * Just copy the current_regs into the OLD rtcb. - */ - - up_savestate(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; - - /* Then switch contexts */ - - 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! + /* Yes, then we have to do things differently. + * Just copy the current_regs into the OLD rtcb. */ - else if (!up_saveusercontext(rtcb->xcp.regs)) - { - /* Restore the exception context of the rtcb at the (new) head - * of the g_readytorun task list. - */ + up_savestate(rtcb->xcp.regs); - rtcb = (struct tcb_s*)g_readytorun.head; + /* Restore the exception context of the rtcb at the (new) head + * of the g_readytorun task list. + */ - /* Then switch contexts */ + rtcb = (struct tcb_s*)g_readytorun.head; - up_fullcontextrestore(rtcb->xcp.regs); - } + /* Then switch contexts */ + + 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! + */ + + 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; + + /* Then switch contexts */ + + up_fullcontextrestore(rtcb->xcp.regs); } } } diff --git a/arch/arm/src/arm/up_dataabort.c b/arch/arm/src/arm/up_dataabort.c index 99b3bf2ab79..d5e652856bd 100644 --- a/arch/arm/src/arm/up_dataabort.c +++ b/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/arch/arm/src/arm/up_doirq.c b/arch/arm/src/arm/up_doirq.c index 7cd1a6a1be7..3b47a56b037 100644 --- a/arch/arm/src/arm/up_doirq.c +++ b/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/arch/arm/src/arm/up_prefetchabort.c b/arch/arm/src/arm/up_prefetchabort.c index 541586de97b..78ca496abc7 100644 --- a/arch/arm/src/arm/up_prefetchabort.c +++ b/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/arch/arm/src/arm/up_reprioritizertr.c b/arch/arm/src/arm/up_reprioritizertr.c index 76979408327..9d898ed7bac 100644 --- a/arch/arm/src/arm/up_reprioritizertr.c +++ b/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/arch/arm/src/arm/up_syscall.c b/arch/arm/src/arm/up_syscall.c index eb9bac8ade8..db3231646c4 100644 --- a/arch/arm/src/arm/up_syscall.c +++ b/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/arch/arm/src/arm/up_unblocktask.c b/arch/arm/src/arm/up_unblocktask.c index a2dc0f69431..2e373f38ef6 100644 --- a/arch/arm/src/arm/up_unblocktask.c +++ b/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. - */ - - rtcb = (struct tcb_s*)g_readytorun.head; - - /* Then switch contexts */ - - 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! + /* 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 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_restorestate(rtcb->xcp.regs); + } - up_fullcontextrestore(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! + */ + + 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; + + /* Then switch contexts */ + + up_fullcontextrestore(rtcb->xcp.regs); } } } diff --git a/arch/arm/src/arm/up_undefinedinsn.c b/arch/arm/src/arm/up_undefinedinsn.c index 88e3a79d956..dd4f15e356b 100644 --- a/arch/arm/src/arm/up_undefinedinsn.c +++ b/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/arch/arm/src/armv6-m/up_assert.c b/arch/arm/src/armv6-m/up_assert.c index 86347672e15..3afef2dff31 100644 --- a/arch/arm/src/armv6-m/up_assert.c +++ b/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); -} diff --git a/arch/arm/src/armv6-m/up_blocktask.c b/arch/arm/src/armv6-m/up_blocktask.c index a332cbefd9c..57db2b4aab6 100644 --- a/arch/arm/src/armv6-m/up_blocktask.c +++ b/arch/arm/src/armv6-m/up_blocktask.c @@ -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)) + 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. + */ + + switch_needed = sched_removereadytorun(tcb); + + /* Add the task to the specified blocked task list */ + + sched_addblocked(tcb, (tstate_t)task_state); + + /* If there are any pending tasks, then add them to the g_readytorun + * task list now + */ + + if (g_pendingtasks.head) { - PANIC(OSERR_BADBLOCKSTATE); + switch_needed |= sched_mergepending(); } - else + + /* Now, perform the context switch if one is needed */ + + if (switch_needed) { - struct tcb_s *rtcb = (struct tcb_s*)g_readytorun.head; - bool switch_needed; + /* Are we in an interrupt handler? */ - /* 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); - - /* Add the task to the specified blocked task list */ - - sched_addblocked(tcb, (tstate_t)task_state); - - /* If there are any pending tasks, then add them to the g_readytorun - * task list now - */ - - if (g_pendingtasks.head) + if (current_regs) { - switch_needed |= sched_mergepending(); + /* Yes, then we have to do things differently. + * Just copy the current_regs into the OLD rtcb. + */ + + up_savestate(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; + + /* Then switch contexts */ + + up_restorestate(rtcb->xcp.regs); } - /* Now, perform the context switch if one is needed */ + /* No, then we will need to perform the user context switch */ - if (switch_needed) + else { - /* Are we in an interrupt handler? */ + /* Switch context to the context of the task at the head of the + * ready to run list. + */ - if (current_regs) - { - /* Yes, then we have to do things differently. - * Just copy the current_regs into the OLD rtcb. - */ + struct tcb_s *nexttcb = (struct tcb_s*)g_readytorun.head; + up_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs); - up_savestate(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; - - /* Then switch contexts */ - - up_restorestate(rtcb->xcp.regs); - } - - /* 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. - */ - - 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/arch/arm/src/armv6-m/up_doirq.c b/arch/arm/src/armv6-m/up_doirq.c index 7dec2115281..2edbc55ddb5 100644 --- a/arch/arm/src/armv6-m/up_doirq.c +++ b/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/arch/arm/src/armv6-m/up_hardfault.c b/arch/arm/src/armv6-m/up_hardfault.c index 049f71d0585..a2a0982a7ef 100644 --- a/arch/arm/src/armv6-m/up_hardfault.c +++ b/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/arch/arm/src/armv6-m/up_reprioritizertr.c b/arch/arm/src/armv6-m/up_reprioritizertr.c index 0bc0d417061..07eeef14ba6 100644 --- a/arch/arm/src/armv6-m/up_reprioritizertr.c +++ b/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/arch/arm/src/armv6-m/up_unblocktask.c b/arch/arm/src/armv6-m/up_unblocktask.c index c496a8f4386..e4bfede97ac 100644 --- a/arch/arm/src/armv6-m/up_unblocktask.c +++ b/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/arch/arm/src/armv7-m/up_assert.c b/arch/arm/src/armv7-m/up_assert.c index b0df6d729d6..5d14ff34a8b 100644 --- a/arch/arm/src/armv7-m/up_assert.c +++ b/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); -} diff --git a/arch/arm/src/armv7-m/up_blocktask.c b/arch/arm/src/armv7-m/up_blocktask.c index 15558ed4d7f..8caf4a2b692 100644 --- a/arch/arm/src/armv7-m/up_blocktask.c +++ b/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) { + 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)) + 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. + */ + + switch_needed = sched_removereadytorun(tcb); + + /* Add the task to the specified blocked task list */ + + sched_addblocked(tcb, (tstate_t)task_state); + + /* If there are any pending tasks, then add them to the g_readytorun + * task list now + */ + + if (g_pendingtasks.head) { - PANIC(OSERR_BADBLOCKSTATE); + switch_needed |= sched_mergepending(); } - else + + /* Now, perform the context switch if one is needed */ + + if (switch_needed) { - struct tcb_s *rtcb = (struct tcb_s*)g_readytorun.head; - bool switch_needed; + /* Are we in an interrupt handler? */ - /* 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); - - /* Add the task to the specified blocked task list */ - - sched_addblocked(tcb, (tstate_t)task_state); - - /* If there are any pending tasks, then add them to the g_readytorun - * task list now - */ - - if (g_pendingtasks.head) + if (current_regs) { - switch_needed |= sched_mergepending(); + /* Yes, then we have to do things differently. + * Just copy the current_regs into the OLD rtcb. + */ + + up_savestate(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; + + /* Then switch contexts */ + + up_restorestate(rtcb->xcp.regs); } - /* Now, perform the context switch if one is needed */ + /* No, then we will need to perform the user context switch */ - if (switch_needed) + else { - /* Are we in an interrupt handler? */ + /* Switch context to the context of the task at the head of the + * ready to run list. + */ - if (current_regs) - { - /* Yes, then we have to do things differently. - * Just copy the current_regs into the OLD rtcb. - */ + struct tcb_s *nexttcb = (struct tcb_s*)g_readytorun.head; + up_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs); - up_savestate(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; - - /* Then switch contexts */ - - up_restorestate(rtcb->xcp.regs); - } - - /* 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. - */ - - 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/arch/arm/src/armv7-m/up_doirq.c b/arch/arm/src/armv7-m/up_doirq.c index 6063f9ca1cb..d8a1446deb2 100644 --- a/arch/arm/src/armv7-m/up_doirq.c +++ b/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/arch/arm/src/armv7-m/up_hardfault.c b/arch/arm/src/armv7-m/up_hardfault.c index e43b18cb3f0..d99473bde6f 100644 --- a/arch/arm/src/armv7-m/up_hardfault.c +++ b/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/arch/arm/src/armv7-m/up_memfault.c b/arch/arm/src/armv7-m/up_memfault.c index c9f1b57b1ec..6ab160d0316 100644 --- a/arch/arm/src/armv7-m/up_memfault.c +++ b/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/arch/arm/src/armv7-m/up_reprioritizertr.c b/arch/arm/src/armv7-m/up_reprioritizertr.c index 94708a3be94..a0d54a688fc 100644 --- a/arch/arm/src/armv7-m/up_reprioritizertr.c +++ b/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/arch/arm/src/armv7-m/up_unblocktask.c b/arch/arm/src/armv7-m/up_unblocktask.c index b2ff98879b4..8c6551b8e36 100644 --- a/arch/arm/src/armv7-m/up_unblocktask.c +++ b/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/arch/arm/src/c5471/c5471_serial.c b/arch/arm/src/c5471/c5471_serial.c index db28e196ded..cdc5b6f24c4 100644 --- a/arch/arm/src/c5471/c5471_serial.c +++ b/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/arch/arm/src/calypso/calypso_serial.c b/arch/arm/src/calypso/calypso_serial.c index 01e65d062a1..5817b338b73 100644 --- a/arch/arm/src/calypso/calypso_serial.c +++ b/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/arch/arm/src/dm320/dm320_decodeirq.c b/arch/arm/src/dm320/dm320_decodeirq.c index 98ba760977f..c29207a5b98 100644 --- a/arch/arm/src/dm320/dm320_decodeirq.c +++ b/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/arch/arm/src/dm320/dm320_serial.c b/arch/arm/src/dm320/dm320_serial.c index 58ff1e710aa..fbeefd8e90a 100644 --- a/arch/arm/src/dm320/dm320_serial.c +++ b/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/arch/arm/src/imx/imx_decodeirq.c b/arch/arm/src/imx/imx_decodeirq.c index 230a4fc20b0..dc23265241f 100644 --- a/arch/arm/src/imx/imx_decodeirq.c +++ b/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/arch/arm/src/imx/imx_serial.c b/arch/arm/src/imx/imx_serial.c index 9182d4ac8da..d7a4c3296c1 100644 --- a/arch/arm/src/imx/imx_serial.c +++ b/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/arch/arm/src/kinetis/kinetis_irq.c b/arch/arm/src/kinetis/kinetis_irq.c index f651c9e5d6f..f8b35656c74 100644 --- a/arch/arm/src/kinetis/kinetis_irq.c +++ b/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/arch/arm/src/kinetis/kinetis_serial.c b/arch/arm/src/kinetis/kinetis_serial.c index 8ede027ec5c..f176f5fa0b8 100644 --- a/arch/arm/src/kinetis/kinetis_serial.c +++ b/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/arch/arm/src/kl/kl_irq.c b/arch/arm/src/kl/kl_irq.c index cc2303ae1ee..9e7d84e358b 100644 --- a/arch/arm/src/kl/kl_irq.c +++ b/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/arch/arm/src/kl/kl_serial.c b/arch/arm/src/kl/kl_serial.c index d4f37f9f276..290192dcd4c 100644 --- a/arch/arm/src/kl/kl_serial.c +++ b/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/arch/arm/src/lm/lm_irq.c b/arch/arm/src/lm/lm_irq.c index 11ea6fbb616..920eee8af41 100644 --- a/arch/arm/src/lm/lm_irq.c +++ b/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/arch/arm/src/lm/lm_serial.c b/arch/arm/src/lm/lm_serial.c index e9b9f72fb85..6e772ecd507 100644 --- a/arch/arm/src/lm/lm_serial.c +++ b/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/arch/arm/src/lpc17xx/lpc17_i2c.c b/arch/arm/src/lpc17xx/lpc17_i2c.c index 866a668abba..777349defcb 100644 --- a/arch/arm/src/lpc17xx/lpc17_i2c.c +++ b/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/arch/arm/src/lpc17xx/lpc17_irq.c b/arch/arm/src/lpc17xx/lpc17_irq.c index 80de4596c50..770874717e5 100644 --- a/arch/arm/src/lpc17xx/lpc17_irq.c +++ b/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/arch/arm/src/lpc17xx/lpc17_serial.c b/arch/arm/src/lpc17xx/lpc17_serial.c index 713426b6e72..b2da4839f2d 100644 --- a/arch/arm/src/lpc17xx/lpc17_serial.c +++ b/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/arch/arm/src/lpc214x/lpc214x_decodeirq.c b/arch/arm/src/lpc214x/lpc214x_decodeirq.c index 057e526c2f8..7886e550000 100644 --- a/arch/arm/src/lpc214x/lpc214x_decodeirq.c +++ b/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/arch/arm/src/lpc214x/lpc214x_serial.c b/arch/arm/src/lpc214x/lpc214x_serial.c index b035e91fcc7..c647e458a86 100644 --- a/arch/arm/src/lpc214x/lpc214x_serial.c +++ b/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/arch/arm/src/lpc2378/lpc23xx_decodeirq.c b/arch/arm/src/lpc2378/lpc23xx_decodeirq.c index 3a50beb50ee..75e6c98b4c2 100644 --- a/arch/arm/src/lpc2378/lpc23xx_decodeirq.c +++ b/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/arch/arm/src/lpc2378/lpc23xx_serial.c b/arch/arm/src/lpc2378/lpc23xx_serial.c index c17a578409b..08fe4ec73e9 100644 --- a/arch/arm/src/lpc2378/lpc23xx_serial.c +++ b/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/arch/arm/src/lpc31xx/lpc31_decodeirq.c b/arch/arm/src/lpc31xx/lpc31_decodeirq.c index 0e73f131b95..1929d864d30 100644 --- a/arch/arm/src/lpc31xx/lpc31_decodeirq.c +++ b/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/arch/arm/src/lpc43xx/lpc43_i2c.c b/arch/arm/src/lpc43xx/lpc43_i2c.c index 64a044f1350..1dc8b7679b9 100644 --- a/arch/arm/src/lpc43xx/lpc43_i2c.c +++ b/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/arch/arm/src/lpc43xx/lpc43_irq.c b/arch/arm/src/lpc43xx/lpc43_irq.c index 042b3360b83..7195092bba3 100644 --- a/arch/arm/src/lpc43xx/lpc43_irq.c +++ b/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/arch/arm/src/lpc43xx/lpc43_serial.c b/arch/arm/src/lpc43xx/lpc43_serial.c index a6e6b7b18b9..adbfb282a7d 100644 --- a/arch/arm/src/lpc43xx/lpc43_serial.c +++ b/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/arch/arm/src/nuc1xx/nuc_irq.c b/arch/arm/src/nuc1xx/nuc_irq.c index 01a7bd7ba4f..2ee01762d2a 100644 --- a/arch/arm/src/nuc1xx/nuc_irq.c +++ b/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/arch/arm/src/nuc1xx/nuc_serial.c b/arch/arm/src/nuc1xx/nuc_serial.c index dbf34f8ec2a..c07ef1109cd 100644 --- a/arch/arm/src/nuc1xx/nuc_serial.c +++ b/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/arch/arm/src/sam3u/sam3u_irq.c b/arch/arm/src/sam3u/sam3u_irq.c index 9c1e9bb3e4d..29c9908c98e 100644 --- a/arch/arm/src/sam3u/sam3u_irq.c +++ b/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/arch/arm/src/sam3u/sam3u_serial.c b/arch/arm/src/sam3u/sam3u_serial.c index 1494742077c..a4d79a11b65 100644 --- a/arch/arm/src/sam3u/sam3u_serial.c +++ b/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/arch/arm/src/stm32/stm32_can.c b/arch/arm/src/stm32/stm32_can.c index 86a53dab092..a3011cde42d 100644 --- a/arch/arm/src/stm32/stm32_can.c +++ b/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/arch/arm/src/stm32/stm32_irq.c b/arch/arm/src/stm32/stm32_irq.c index 96b239c36b7..d1cd37e3606 100644 --- a/arch/arm/src/stm32/stm32_irq.c +++ b/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/arch/arm/src/stm32/stm32f10xxx_dma.c b/arch/arm/src/stm32/stm32f10xxx_dma.c index 80408e58b8e..29b09150d6c 100644 --- a/arch/arm/src/stm32/stm32f10xxx_dma.c +++ b/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/arch/arm/src/stm32/stm32f20xxx_dma.c b/arch/arm/src/stm32/stm32f20xxx_dma.c index e5905a90962..844fa6a670d 100644 --- a/arch/arm/src/stm32/stm32f20xxx_dma.c +++ b/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/arch/arm/src/stm32/stm32f40xxx_dma.c b/arch/arm/src/stm32/stm32f40xxx_dma.c index 850ab62ae0e..fd8164a321e 100644 --- a/arch/arm/src/stm32/stm32f40xxx_dma.c +++ b/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/arch/arm/src/str71x/str71x_decodeirq.c b/arch/arm/src/str71x/str71x_decodeirq.c index 48c9aa7e4d4..da7b5a48ee9 100644 --- a/arch/arm/src/str71x/str71x_decodeirq.c +++ b/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/arch/arm/src/str71x/str71x_serial.c b/arch/arm/src/str71x/str71x_serial.c index 5de63a1b991..2098758b1c0 100644 --- a/arch/arm/src/str71x/str71x_serial.c +++ b/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/arch/avr/src/at32uc3/at32uc3_irq.c b/arch/avr/src/at32uc3/at32uc3_irq.c index 771d1b9da92..70ade3e2a0e 100644 --- a/arch/avr/src/at32uc3/at32uc3_irq.c +++ b/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/arch/avr/src/at32uc3/at32uc3_serial.c b/arch/avr/src/at32uc3/at32uc3_serial.c index f33ce7d726e..1ddb9901be9 100644 --- a/arch/avr/src/at32uc3/at32uc3_serial.c +++ b/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/arch/avr/src/avr/up_blocktask.c b/arch/avr/src/avr/up_blocktask.c index 7d48da78a35..82fcd65db14 100644 --- a/arch/avr/src/avr/up_blocktask.c +++ b/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) { + 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)) + 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. + */ + + switch_needed = sched_removereadytorun(tcb); + + /* Add the task to the specified blocked task list */ + + sched_addblocked(tcb, (tstate_t)task_state); + + /* If there are any pending tasks, then add them to the g_readytorun + * task list now + */ + + if (g_pendingtasks.head) { - PANIC(OSERR_BADBLOCKSTATE); + switch_needed |= sched_mergepending(); } - else + + /* Now, perform the context switch if one is needed */ + + if (switch_needed) { - struct tcb_s *rtcb = (struct tcb_s*)g_readytorun.head; - bool switch_needed; + /* Are we in an interrupt handler? */ - /* 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); - - /* Add the task to the specified blocked task list */ - - sched_addblocked(tcb, (tstate_t)task_state); - - /* If there are any pending tasks, then add them to the g_readytorun - * task list now - */ - - if (g_pendingtasks.head) + if (current_regs) { - switch_needed |= sched_mergepending(); + /* Yes, then we have to do things differently. + * Just copy the current_regs into the OLD rtcb. + */ + + up_savestate(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; + + /* Then switch contexts */ + + up_restorestate(rtcb->xcp.regs); } - /* Now, perform the context switch if one is needed */ + /* No, then we will need to perform the user context switch */ - if (switch_needed) + else { - /* Are we in an interrupt handler? */ + /* Switch context to the context of the task at the head of the + * ready to run list. + */ - if (current_regs) - { - /* Yes, then we have to do things differently. - * Just copy the current_regs into the OLD rtcb. - */ + struct tcb_s *nexttcb = (struct tcb_s*)g_readytorun.head; + up_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs); - up_savestate(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; - - /* Then switch contexts */ - - up_restorestate(rtcb->xcp.regs); - } - - /* 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. - */ - - 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/arch/avr/src/avr/up_doirq.c b/arch/avr/src/avr/up_doirq.c index 7533d215921..4db08c04692 100644 --- a/arch/avr/src/avr/up_doirq.c +++ b/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/arch/avr/src/avr/up_reprioritizertr.c b/arch/avr/src/avr/up_reprioritizertr.c index 5b23a37a11a..4c510f4ea48 100644 --- a/arch/avr/src/avr/up_reprioritizertr.c +++ b/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/arch/avr/src/avr/up_unblocktask.c b/arch/avr/src/avr/up_unblocktask.c index f1707b7bdee..970deedd65a 100644 --- a/arch/avr/src/avr/up_unblocktask.c +++ b/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/arch/avr/src/avr32/up_blocktask.c b/arch/avr/src/avr32/up_blocktask.c index a5ff53ae9ed..1da4eb5736d 100644 --- a/arch/avr/src/avr32/up_blocktask.c +++ b/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) { + 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)) + 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. + */ + + switch_needed = sched_removereadytorun(tcb); + + /* Add the task to the specified blocked task list */ + + sched_addblocked(tcb, (tstate_t)task_state); + + /* If there are any pending tasks, then add them to the g_readytorun + * task list now + */ + + if (g_pendingtasks.head) { - PANIC(OSERR_BADBLOCKSTATE); + switch_needed |= sched_mergepending(); } - else + + /* Now, perform the context switch if one is needed */ + + if (switch_needed) { - struct tcb_s *rtcb = (struct tcb_s*)g_readytorun.head; - bool switch_needed; + /* Are we in an interrupt handler? */ - /* 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); - - /* Add the task to the specified blocked task list */ - - sched_addblocked(tcb, (tstate_t)task_state); - - /* If there are any pending tasks, then add them to the g_readytorun - * task list now - */ - - if (g_pendingtasks.head) + if (current_regs) { - switch_needed |= sched_mergepending(); + /* Yes, then we have to do things differently. + * Just copy the current_regs into the OLD rtcb. + */ + + up_savestate(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; + + /* Then switch contexts */ + + up_restorestate(rtcb->xcp.regs); } - /* Now, perform the context switch if one is needed */ + /* No, then we will need to perform the user context switch */ - if (switch_needed) + else { - /* Are we in an interrupt handler? */ + /* Switch context to the context of the task at the head of the + * ready to run list. + */ - if (current_regs) - { - /* Yes, then we have to do things differently. - * Just copy the current_regs into the OLD rtcb. - */ + struct tcb_s *nexttcb = (struct tcb_s*)g_readytorun.head; + up_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs); - up_savestate(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; - - /* Then switch contexts */ - - up_restorestate(rtcb->xcp.regs); - } - - /* 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. - */ - - 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/arch/avr/src/avr32/up_doirq.c b/arch/avr/src/avr32/up_doirq.c index 2d4a5e14a91..c4513e77f5d 100644 --- a/arch/avr/src/avr32/up_doirq.c +++ b/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/arch/avr/src/avr32/up_reprioritizertr.c b/arch/avr/src/avr32/up_reprioritizertr.c index bc9ba21f049..621f08613fa 100644 --- a/arch/avr/src/avr32/up_reprioritizertr.c +++ b/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/arch/avr/src/avr32/up_unblocktask.c b/arch/avr/src/avr32/up_unblocktask.c index 5ce48e3665b..1fcfa1dd781 100644 --- a/arch/avr/src/avr32/up_unblocktask.c +++ b/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/arch/avr/src/common/up_assert.c b/arch/avr/src/common/up_assert.c index 2e70a9c2893..a9012202e7c 100644 --- a/arch/avr/src/common/up_assert.c +++ b/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); -} - diff --git a/arch/hc/src/common/up_blocktask.c b/arch/hc/src/common/up_blocktask.c index da7131c4c14..5a29862914c 100644 --- a/arch/hc/src/common/up_blocktask.c +++ b/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)) + 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. + */ + + switch_needed = sched_removereadytorun(tcb); + + /* Add the task to the specified blocked task list */ + + sched_addblocked(tcb, (tstate_t)task_state); + + /* If there are any pending tasks, then add them to the g_readytorun + * task list now + */ + + if (g_pendingtasks.head) { - PANIC(OSERR_BADBLOCKSTATE); + switch_needed |= sched_mergepending(); } - else + + /* Now, perform the context switch if one is needed */ + + if (switch_needed) { - struct tcb_s *rtcb = (struct tcb_s*)g_readytorun.head; - bool switch_needed; + /* Are we in an interrupt handler? */ - /* 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); - - /* Add the task to the specified blocked task list */ - - sched_addblocked(tcb, (tstate_t)task_state); - - /* If there are any pending tasks, then add them to the g_readytorun - * task list now - */ - - if (g_pendingtasks.head) + if (current_regs) { - switch_needed |= sched_mergepending(); - } - - /* Now, perform the context switch if one is needed */ - - if (switch_needed) - { - /* Are we in an interrupt handler? */ - - if (current_regs) - { - /* Yes, then we have to do things differently. - * Just copy the current_regs into the OLD rtcb. - */ - - up_savestate(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; - - /* Then switch contexts */ - - 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! + /* Yes, then we have to do things differently. + * Just copy the current_regs into the OLD rtcb. */ - else if (!up_saveusercontext(rtcb->xcp.regs)) - { - /* Restore the exception context of the rtcb at the (new) head - * of the g_readytorun task list. - */ + up_savestate(rtcb->xcp.regs); - rtcb = (struct tcb_s*)g_readytorun.head; + /* Restore the exception context of the rtcb at the (new) head + * of the g_readytorun task list. + */ - /* Then switch contexts */ + rtcb = (struct tcb_s*)g_readytorun.head; - up_fullcontextrestore(rtcb->xcp.regs); - } + /* Then switch contexts */ + + 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! + */ + + 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; + + /* Then switch contexts */ + + up_fullcontextrestore(rtcb->xcp.regs); } } } diff --git a/arch/hc/src/common/up_doirq.c b/arch/hc/src/common/up_doirq.c index 4a56dedbdc9..61d67d395cf 100644 --- a/arch/hc/src/common/up_doirq.c +++ b/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/arch/hc/src/common/up_reprioritizertr.c b/arch/hc/src/common/up_reprioritizertr.c index 92e18ff47e1..d9689a0f3ec 100644 --- a/arch/hc/src/common/up_reprioritizertr.c +++ b/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/arch/hc/src/common/up_unblocktask.c b/arch/hc/src/common/up_unblocktask.c index 7d5f67a1b14..de787418a6b 100644 --- a/arch/hc/src/common/up_unblocktask.c +++ b/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. - */ - - rtcb = (struct tcb_s*)g_readytorun.head; - - /* Then switch contexts */ - - 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! + /* 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 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_restorestate(rtcb->xcp.regs); + } - up_fullcontextrestore(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! + */ + + 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; + + /* Then switch contexts */ + + up_fullcontextrestore(rtcb->xcp.regs); } } } diff --git a/arch/hc/src/m9s12/m9s12_assert.c b/arch/hc/src/m9s12/m9s12_assert.c index 9f97ec4dbf5..69d5e3c738c 100644 --- a/arch/hc/src/m9s12/m9s12_assert.c +++ b/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); -} diff --git a/arch/hc/src/m9s12/m9s12_serial.c b/arch/hc/src/m9s12/m9s12_serial.c index 24d3e7765df..bb61d7dbc3b 100644 --- a/arch/hc/src/m9s12/m9s12_serial.c +++ b/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/arch/mips/src/common/up_exit.c b/arch/mips/src/common/up_exit.c index 8791fa40bd5..974bdc6131d 100644 --- a/arch/mips/src/common/up_exit.c +++ b/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/arch/mips/src/mips32/up_assert.c b/arch/mips/src/mips32/up_assert.c index 9f503ac8520..36414d71c07 100644 --- a/arch/mips/src/mips32/up_assert.c +++ b/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); -} diff --git a/arch/mips/src/mips32/up_blocktask.c b/arch/mips/src/mips32/up_blocktask.c index 8d209da9f5e..e0d1cf2471b 100644 --- a/arch/mips/src/mips32/up_blocktask.c +++ b/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) { + 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)) + 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. + */ + + switch_needed = sched_removereadytorun(tcb); + + /* Add the task to the specified blocked task list */ + + sched_addblocked(tcb, (tstate_t)task_state); + + /* If there are any pending tasks, then add them to the g_readytorun + * task list now + */ + + if (g_pendingtasks.head) { - PANIC(OSERR_BADBLOCKSTATE); + switch_needed |= sched_mergepending(); } - else + + /* Now, perform the context switch if one is needed */ + + if (switch_needed) { - struct tcb_s *rtcb = (struct tcb_s*)g_readytorun.head; - bool switch_needed; + /* Are we in an interrupt handler? */ - /* 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); - - /* Add the task to the specified blocked task list */ - - sched_addblocked(tcb, (tstate_t)task_state); - - /* If there are any pending tasks, then add them to the g_readytorun - * task list now - */ - - if (g_pendingtasks.head) + if (current_regs) { - switch_needed |= sched_mergepending(); + /* Yes, then we have to do things differently. + * Just copy the current_regs into the OLD rtcb. + */ + + up_savestate(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; + + /* Then switch contexts */ + + up_restorestate(rtcb->xcp.regs); } - /* Now, perform the context switch if one is needed */ + /* No, then we will need to perform the user context switch */ - if (switch_needed) + else { - /* Are we in an interrupt handler? */ + /* Switch context to the context of the task at the head of the + * ready to run list. + */ - if (current_regs) - { - /* Yes, then we have to do things differently. - * Just copy the current_regs into the OLD rtcb. - */ + struct tcb_s *nexttcb = (struct tcb_s*)g_readytorun.head; + up_switchcontext(rtcb->xcp.regs, nexttcb->xcp.regs); - up_savestate(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; - - /* Then switch contexts */ - - up_restorestate(rtcb->xcp.regs); - } - - /* 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. - */ - - 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/arch/mips/src/mips32/up_doirq.c b/arch/mips/src/mips32/up_doirq.c index b963881e305..bf1a197278f 100644 --- a/arch/mips/src/mips32/up_doirq.c +++ b/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/arch/mips/src/mips32/up_reprioritizertr.c b/arch/mips/src/mips32/up_reprioritizertr.c index f4034cc1eee..a8f0158b96c 100644 --- a/arch/mips/src/mips32/up_reprioritizertr.c +++ b/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/arch/mips/src/mips32/up_sigdeliver.c b/arch/mips/src/mips32/up_sigdeliver.c index 0abc270d388..defa6bd1023 100644 --- a/arch/mips/src/mips32/up_sigdeliver.c +++ b/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/arch/mips/src/mips32/up_unblocktask.c b/arch/mips/src/mips32/up_unblocktask.c index 70a5a72410d..99cd25052ce 100644 --- a/arch/mips/src/mips32/up_unblocktask.c +++ b/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/arch/mips/src/pic32mx/pic32mx-exception.c b/arch/mips/src/pic32mx/pic32mx-exception.c index dd3b88b140f..cf0813e5ff8 100644 --- a/arch/mips/src/pic32mx/pic32mx-exception.c +++ b/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/arch/mips/src/pic32mx/pic32mx-serial.c b/arch/mips/src/pic32mx/pic32mx-serial.c index 0254051d243..0a03b98a9c7 100644 --- a/arch/mips/src/pic32mx/pic32mx-serial.c +++ b/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/arch/rgmp/src/nuttx.c b/arch/rgmp/src/nuttx.c index a4f713be6d9..e9631762103 100644 --- a/arch/rgmp/src/nuttx.c +++ b/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/arch/sh/src/common/up_assert.c b/arch/sh/src/common/up_assert.c index 72880fd2ab0..7e8f1345182 100644 --- a/arch/sh/src/common/up_assert.c +++ b/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); -} diff --git a/arch/sh/src/common/up_blocktask.c b/arch/sh/src/common/up_blocktask.c index db7f0297c66..9959e71df7e 100644 --- a/arch/sh/src/common/up_blocktask.c +++ b/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)) + 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. + */ + + switch_needed = sched_removereadytorun(tcb); + + /* Add the task to the specified blocked task list */ + + sched_addblocked(tcb, (tstate_t)task_state); + + /* If there are any pending tasks, then add them to the g_readytorun + * task list now + */ + + if (g_pendingtasks.head) { - PANIC(OSERR_BADBLOCKSTATE); + switch_needed |= sched_mergepending(); } - else + + /* Now, perform the context switch if one is needed */ + + if (switch_needed) { - struct tcb_s *rtcb = (struct tcb_s*)g_readytorun.head; - bool switch_needed; + /* Are we in an interrupt handler? */ - /* 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); - - /* Add the task to the specified blocked task list */ - - sched_addblocked(tcb, (tstate_t)task_state); - - /* If there are any pending tasks, then add them to the g_readytorun - * task list now - */ - - if (g_pendingtasks.head) + if (current_regs) { - switch_needed |= sched_mergepending(); - } - - /* Now, perform the context switch if one is needed */ - - if (switch_needed) - { - /* Are we in an interrupt handler? */ - - if (current_regs) - { - /* Yes, then we have to do things differently. - * Just copy the current_regs into the OLD rtcb. - */ - - up_copystate(rtcb->xcp.regs, current_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; - - /* Then switch contexts */ - - 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! + /* Yes, then we have to do things differently. + * Just copy the current_regs into the OLD rtcb. */ - else if (!up_saveusercontext(rtcb->xcp.regs)) - { - /* Restore the exception context of the rtcb at the (new) head - * of the g_readytorun task list. - */ + up_copystate(rtcb->xcp.regs, current_regs); - rtcb = (struct tcb_s*)g_readytorun.head; + /* Restore the exception context of the rtcb at the (new) head + * of the g_readytorun task list. + */ - /* Then switch contexts */ + rtcb = (struct tcb_s*)g_readytorun.head; - up_fullcontextrestore(rtcb->xcp.regs); - } + /* Then switch contexts */ + + 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! + */ + + 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; + + /* Then switch contexts */ + + up_fullcontextrestore(rtcb->xcp.regs); } } } diff --git a/arch/sh/src/common/up_doirq.c b/arch/sh/src/common/up_doirq.c index 185fa968456..d6a121330bf 100644 --- a/arch/sh/src/common/up_doirq.c +++ b/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/arch/sh/src/common/up_reprioritizertr.c b/arch/sh/src/common/up_reprioritizertr.c index dcf0fcd7b0b..64f5d9969b0 100644 --- a/arch/sh/src/common/up_reprioritizertr.c +++ b/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/arch/sh/src/common/up_unblocktask.c b/arch/sh/src/common/up_unblocktask.c index b7c88f82394..455c50ce291 100644 --- a/arch/sh/src/common/up_unblocktask.c +++ b/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. - */ - - rtcb = (struct tcb_s*)g_readytorun.head; - - /* Then switch contexts */ - - 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! + /* 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 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 */ + current_regs = rtcb->xcp.regs; + } - up_fullcontextrestore(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! + */ + + 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; + + /* Then switch contexts */ + + up_fullcontextrestore(rtcb->xcp.regs); } } } diff --git a/arch/sh/src/m16c/m16c_serial.c b/arch/sh/src/m16c/m16c_serial.c index f9125cf1128..a936dd922e4 100644 --- a/arch/sh/src/m16c/m16c_serial.c +++ b/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/arch/sh/src/sh1/sh1_serial.c b/arch/sh/src/sh1/sh1_serial.c index e696c96f5bf..5f521fa5a46 100644 --- a/arch/sh/src/sh1/sh1_serial.c +++ b/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/arch/sim/src/up_blocktask.c b/arch/sim/src/up_blocktask.c index 46598b442cd..db970143438 100644 --- a/arch/sim/src/up_blocktask.c +++ b/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)) + + ASSERT((tcb->task_state >= FIRST_READY_TO_RUN_STATE) && + (tcb->task_state <= LAST_READY_TO_RUN_STATE)); + + sdbg("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. + */ + + switch_needed = sched_removereadytorun(tcb); + + /* Add the task to the specified blocked task list */ + + sched_addblocked(tcb, (tstate_t)task_state); + + /* If there are any pending tasks, then add them to the g_readytorun + * task list now + */ + + if (g_pendingtasks.head) { - PANIC(OSERR_BADBLOCKSTATE); + switch_needed |= sched_mergepending(); } - else + + /* Now, perform the context switch if one is needed */ + + if (switch_needed) { - struct tcb_s *rtcb = (struct tcb_s*)g_readytorun.head; - bool switch_needed; - - sdbg("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. + /* 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! */ - switch_needed = sched_removereadytorun(tcb); - - /* Add the task to the specified blocked task list */ - - sched_addblocked(tcb, (tstate_t)task_state); - - /* If there are any pending tasks, then add them to the g_readytorun - * task list now - */ - - if (g_pendingtasks.head) + if (!up_setjmp(rtcb->xcp.regs)) { - switch_needed |= sched_mergepending(); - } - - /* Now, perform the context switch if one is 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! + /* Restore the exception context of the rtcb at the (new) head + * of the g_readytorun task list. */ - if (!up_setjmp(rtcb->xcp.regs)) + 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) { - /* 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); - - /* 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); + 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/arch/sim/src/up_head.c b/arch/sim/src/up_head.c index 7326e73dca4..00018865f11 100644 --- a/arch/sim/src/up_head.c +++ b/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/arch/sim/src/up_reprioritizertr.c b/arch/sim/src/up_reprioritizertr.c index 0b18defe6d8..7423a71129b 100644 --- a/arch/sim/src/up_reprioritizertr.c +++ b/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/arch/sim/src/up_unblocktask.c b/arch/sim/src/up_unblocktask.c index f8b229f8d7c..35961c5f801 100644 --- a/arch/sim/src/up_unblocktask.c +++ b/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 - */ + /* 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 (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. - */ + 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); + 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/arch/x86/src/common/up_assert.c b/arch/x86/src/common/up_assert.c index ed83eb6ce52..f9a36dc5368 100644 --- a/arch/x86/src/common/up_assert.c +++ b/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); -} diff --git a/arch/x86/src/common/up_blocktask.c b/arch/x86/src/common/up_blocktask.c index b1653f1e42a..dba388cb091 100644 --- a/arch/x86/src/common/up_blocktask.c +++ b/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)) + 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. + */ + + switch_needed = sched_removereadytorun(tcb); + + /* Add the task to the specified blocked task list */ + + sched_addblocked(tcb, (tstate_t)task_state); + + /* If there are any pending tasks, then add them to the g_readytorun + * task list now + */ + + if (g_pendingtasks.head) { - PANIC(OSERR_BADBLOCKSTATE); + switch_needed |= sched_mergepending(); } - else + + /* Now, perform the context switch if one is needed */ + + if (switch_needed) { - struct tcb_s *rtcb = (struct tcb_s*)g_readytorun.head; - bool switch_needed; + /* Are we in an interrupt handler? */ - /* 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); - - /* Add the task to the specified blocked task list */ - - sched_addblocked(tcb, (tstate_t)task_state); - - /* If there are any pending tasks, then add them to the g_readytorun - * task list now - */ - - if (g_pendingtasks.head) + if (current_regs) { - switch_needed |= sched_mergepending(); - } - - /* Now, perform the context switch if one is needed */ - - if (switch_needed) - { - /* Are we in an interrupt handler? */ - - if (current_regs) - { - /* Yes, then we have to do things differently. - * Just copy the current_regs into the OLD rtcb. - */ - - up_savestate(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; - - /* Then switch contexts */ - - 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! + /* Yes, then we have to do things differently. + * Just copy the current_regs into the OLD rtcb. */ - else if (!up_saveusercontext(rtcb->xcp.regs)) - { - /* Restore the exception context of the rtcb at the (new) head - * of the g_readytorun task list. - */ + up_savestate(rtcb->xcp.regs); - rtcb = (struct tcb_s*)g_readytorun.head; + /* Restore the exception context of the rtcb at the (new) head + * of the g_readytorun task list. + */ - /* Then switch contexts */ + rtcb = (struct tcb_s*)g_readytorun.head; - up_fullcontextrestore(rtcb->xcp.regs); - } + /* Then switch contexts */ + + 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! + */ + + 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; + + /* Then switch contexts */ + + up_fullcontextrestore(rtcb->xcp.regs); } } } diff --git a/arch/x86/src/common/up_reprioritizertr.c b/arch/x86/src/common/up_reprioritizertr.c index 47c55f6b299..8c83b0790d2 100644 --- a/arch/x86/src/common/up_reprioritizertr.c +++ b/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/arch/x86/src/common/up_unblocktask.c b/arch/x86/src/common/up_unblocktask.c index eac913886fc..873ff142068 100644 --- a/arch/x86/src/common/up_unblocktask.c +++ b/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. - */ - - rtcb = (struct tcb_s*)g_readytorun.head; - - /* Then switch contexts */ - - 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! + /* 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 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_restorestate(rtcb->xcp.regs); + } - up_fullcontextrestore(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! + */ + + 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; + + /* Then switch contexts */ + + up_fullcontextrestore(rtcb->xcp.regs); } } } diff --git a/arch/x86/src/qemu/qemu_handlers.c b/arch/x86/src/qemu/qemu_handlers.c index a0d6028aaa1..ae889a63f7f 100644 --- a/arch/x86/src/qemu/qemu_handlers.c +++ b/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/arch/z16/src/common/up_assert.c b/arch/z16/src/common/up_assert.c index 06c77a73e7c..c5efc174a43 100644 --- a/arch/z16/src/common/up_assert.c +++ b/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/arch/z16/src/common/up_blocktask.c b/arch/z16/src/common/up_blocktask.c index 93efee96f84..56618ab3da5 100644 --- a/arch/z16/src/common/up_blocktask.c +++ b/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)) + ASSERT((tcb->task_state >= FIRST_READY_TO_RUN_STATE) && + (tcb->task_state <= LAST_READY_TO_RUN_STATE)); + + /* 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. + */ + + switch_needed = sched_removereadytorun(tcb); + + /* Add the task to the specified blocked task list */ + + sched_addblocked(tcb, (tstate_t)task_state); + + /* If there are any pending tasks, then add them to the g_readytorun + * task list now + */ + + if (g_pendingtasks.head) { - PANIC(OSERR_BADBLOCKSTATE); + switch_needed |= sched_mergepending(); } - else + + /* Now, perform the context switch if one is needed */ + + if (switch_needed) { - FAR struct tcb_s *rtcb = (FAR struct tcb_s*)g_readytorun.head; - bool switch_needed; + /* Are we in an interrupt handler? */ - /* 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. - */ - - switch_needed = sched_removereadytorun(tcb); - - /* Add the task to the specified blocked task list */ - - sched_addblocked(tcb, (tstate_t)task_state); - - /* If there are any pending tasks, then add them to the g_readytorun - * task list now - */ - - if (g_pendingtasks.head) + if (IN_INTERRUPT) { - switch_needed |= sched_mergepending(); - } - - /* Now, perform the context switch if one is needed */ - - if (switch_needed) - { - /* Are we in an interrupt handler? */ - - if (IN_INTERRUPT) - { - /* Yes, then we have to do things differently. - * Just copy the current registers into the OLD rtcb. - */ - - SAVE_IRQCONTEXT(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); */ - - /* Then setup so that the context will be performed on exit - * from the interrupt. - */ - - 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! + /* Yes, then we have to do things differently. + * Just copy the current registers into the OLD rtcb. */ - else if (!SAVE_USERCONTEXT(rtcb)) - { - /* Restore the exception context of the rtcb at the (new) head - * of the g_readytorun task list. - */ + SAVE_IRQCONTEXT(rtcb); - rtcb = (FAR struct tcb_s*)g_readytorun.head; - /* dbg("New Active Task TCB=%p\n", rtcb); */ + /* Restore the exception context of the rtcb at the (new) head + * of the g_readytorun task list. + */ - /* Then switch contexts */ + rtcb = (FAR struct tcb_s*)g_readytorun.head; + /* dbg("New Active Task TCB=%p\n", rtcb); */ - RESTORE_USERCONTEXT(rtcb); - } + /* Then setup so that the context will be performed on exit + * from the interrupt. + */ + + 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! + */ + + 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); */ + + /* Then switch contexts */ + + RESTORE_USERCONTEXT(rtcb); } } } diff --git a/arch/z16/src/common/up_doirq.c b/arch/z16/src/common/up_doirq.c index 9964f44325b..fea0a86d284 100644 --- a/arch/z16/src/common/up_doirq.c +++ b/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/arch/z16/src/common/up_reprioritizertr.c b/arch/z16/src/common/up_reprioritizertr.c index 2eb5c2cdb50..bbfee78452b 100644 --- a/arch/z16/src/common/up_reprioritizertr.c +++ b/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/arch/z16/src/common/up_unblocktask.c b/arch/z16/src/common/up_unblocktask.c index f63981ab54e..a629b50669a 100644 --- a/arch/z16/src/common/up_unblocktask.c +++ b/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. - */ - - 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. - */ - - 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! + /* 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 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 setup so that the context will be performed on exit + * from the interrupt. + */ - /* Then switch contexts */ + SET_IRQCONTEXT(rtcb); + } - RESTORE_USERCONTEXT(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! + */ + + 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); */ + + /* Then switch contexts */ + + RESTORE_USERCONTEXT(rtcb); } } } diff --git a/arch/z16/src/z16f/z16f_serial.c b/arch/z16/src/z16f/z16f_serial.c index b0f1a4674df..28c3f94b756 100644 --- a/arch/z16/src/z16f/z16f_serial.c +++ b/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/arch/z16/src/z16f/z16f_sysexec.c b/arch/z16/src/z16f/z16f_sysexec.c index e824076b0d1..bd922237f55 100644 --- a/arch/z16/src/z16f/z16f_sysexec.c +++ b/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/arch/z80/src/common/up_assert.c b/arch/z80/src/common/up_assert.c index 27929c97a80..644aa5c7a4b 100644 --- a/arch/z80/src/common/up_assert.c +++ b/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/arch/z80/src/common/up_blocktask.c b/arch/z80/src/common/up_blocktask.c index 6a9f050aaee..875c0602cfe 100644 --- a/arch/z80/src/common/up_blocktask.c +++ b/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)) + ASSERT((tcb->task_state >= FIRST_READY_TO_RUN_STATE) && + (tcb->task_state <= LAST_READY_TO_RUN_STATE)); + + /* 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. + */ + + switch_needed = sched_removereadytorun(tcb); + + /* Add the task to the specified blocked task list */ + + sched_addblocked(tcb, (tstate_t)task_state); + + /* If there are any pending tasks, then add them to the g_readytorun + * task list now + */ + + if (g_pendingtasks.head) { - PANIC(OSERR_BADBLOCKSTATE); + switch_needed |= sched_mergepending(); } - else + + /* Now, perform the context switch if one is needed */ + + if (switch_needed) { - FAR struct tcb_s *rtcb = (FAR struct tcb_s*)g_readytorun.head; - bool switch_needed; + /* Are we in an interrupt handler? */ - /* 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. - */ - - switch_needed = sched_removereadytorun(tcb); - - /* Add the task to the specified blocked task list */ - - sched_addblocked(tcb, (tstate_t)task_state); - - /* If there are any pending tasks, then add them to the g_readytorun - * task list now - */ - - if (g_pendingtasks.head) + if (IN_INTERRUPT()) { - switch_needed |= sched_mergepending(); - } - - /* Now, perform the context switch if one is needed */ - - if (switch_needed) - { - /* Are we in an interrupt handler? */ - - if (IN_INTERRUPT()) - { - /* Yes, then we have to do things differently. - * Just copy the current registers into the OLD rtcb. - */ - - SAVE_IRQCONTEXT(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); */ - - /* Then setup so that the context will be performed on exit - * from the interrupt. - */ - - 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! + /* Yes, then we have to do things differently. + * Just copy the current registers into the OLD rtcb. */ - else if (!SAVE_USERCONTEXT(rtcb)) - { - /* Restore the exception context of the rtcb at the (new) head - * of the g_readytorun task list. - */ + SAVE_IRQCONTEXT(rtcb); - rtcb = (FAR struct tcb_s*)g_readytorun.head; - /* dbg("New Active Task TCB=%p\n", rtcb); */ + /* Restore the exception context of the rtcb at the (new) head + * of the g_readytorun task list. + */ - /* Then switch contexts */ + rtcb = (FAR struct tcb_s*)g_readytorun.head; + /* dbg("New Active Task TCB=%p\n", rtcb); */ - RESTORE_USERCONTEXT(rtcb); - } + /* Then setup so that the context will be performed on exit + * from the interrupt. + */ + + 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! + */ + + 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); */ + + /* Then switch contexts */ + + RESTORE_USERCONTEXT(rtcb); } } } diff --git a/arch/z80/src/common/up_doirq.c b/arch/z80/src/common/up_doirq.c index ad318e17f95..231e787ca5c 100644 --- a/arch/z80/src/common/up_doirq.c +++ b/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/arch/z80/src/common/up_reprioritizertr.c b/arch/z80/src/common/up_reprioritizertr.c index 476f324e37b..a5b3a18c8e1 100644 --- a/arch/z80/src/common/up_reprioritizertr.c +++ b/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/arch/z80/src/common/up_unblocktask.c b/arch/z80/src/common/up_unblocktask.c index 9f9714bb9ef..e6141d4fcf7 100644 --- a/arch/z80/src/common/up_unblocktask.c +++ b/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. - */ - - 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. - */ - - 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! + /* 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 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 setup so that the context will be performed on exit + * from the interrupt. + */ - /* Then switch contexts */ + SET_IRQCONTEXT(rtcb); + } - RESTORE_USERCONTEXT(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! + */ + + 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); */ + + /* Then switch contexts */ + + RESTORE_USERCONTEXT(rtcb); } } } diff --git a/arch/z80/src/ez80/ez80_serial.c b/arch/z80/src/ez80/ez80_serial.c index bf938529c38..a178ecb19f4 100644 --- a/arch/z80/src/ez80/ez80_serial.c +++ b/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/arch/z80/src/z8/z8_serial.c b/arch/z80/src/z8/z8_serial.c index fd499b18390..553e3fb4008 100644 --- a/arch/z80/src/z8/z8_serial.c +++ b/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/configs/stm3210e-eval/RIDE/bigfatstub.c b/configs/stm3210e-eval/RIDE/bigfatstub.c index b9b51dd983d..69d679fd89a 100644 --- a/configs/stm3210e-eval/RIDE/bigfatstub.c +++ b/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/include/assert.h b/include/assert.h index f3e2854fc6f..29eb7a4b3dc 100644 --- a/include/assert.h +++ b/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/include/nuttx/arch.h b/include/nuttx/arch.h index 0382c45ef72..480b5fde577 100644 --- a/include/nuttx/arch.h +++ b/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/include/sys/syscall.h b/include/sys/syscall.h index 664cc1d7959..f29dfadde6f 100644 --- a/include/sys/syscall.h +++ b/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/libxx/libxx_cxapurevirtual.cxx b/libxx/libxx_cxapurevirtual.cxx index e8912558a5e..653793ec4e3 100644 --- a/libxx/libxx_cxapurevirtual.cxx +++ b/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/sched/irq_unexpectedisr.c b/sched/irq_unexpectedisr.c index c0090ead4ad..e0291b0261e 100644 --- a/sched/irq_unexpectedisr.c +++ b/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/sched/mq_msgfree.c b/sched/mq_msgfree.c index 61b0e1055c7..23ccc3a8efc 100644 --- a/sched/mq_msgfree.c +++ b/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/sched/mq_rcvinternal.c b/sched/mq_rcvinternal.c index 44f0edcb2d9..3ccc60dcaec 100644 --- a/sched/mq_rcvinternal.c +++ b/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/sched/mq_sndinternal.c b/sched/mq_sndinternal.c index e65b51c5a19..9b004ef91e1 100644 --- a/sched/mq_sndinternal.c +++ b/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/sched/mq_waitirq.c b/sched/mq_waitirq.c index c12de1675d8..c30bdf83633 100644 --- a/sched/mq_waitirq.c +++ b/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/sched/os_internal.h b/sched/os_internal.h index d13eb9cad2a..06cb3cf010f 100644 --- a/sched/os_internal.h +++ b/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/sched/sched_mergepending.c b/sched/sched_mergepending.c index 1364d2b1c86..c400fee4df6 100644 --- a/sched/sched_mergepending.c +++ b/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 */ + /* Insert in the middle of the list */ - 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; - } + 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/sched/sem_wait.c b/sched/sem_wait.c index 06884e59568..b7d16434c0e 100644 --- a/sched/sem_wait.c +++ b/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/sched/sig_action.c b/sched/sig_action.c index ac2c24cfb60..84a7ff6b6f9 100644 --- a/sched/sig_action.c +++ b/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/sched/sig_dispatch.c b/sched/sig_dispatch.c index 7c4d34138bb..82c891b46dd 100644 --- a/sched/sig_dispatch.c +++ b/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/sched/sig_suspend.c b/sched/sig_suspend.c index bc26aa35aa5..e57ac43961e 100644 --- a/sched/sig_suspend.c +++ b/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/sched/sig_timedwait.c b/sched/sig_timedwait.c index fd8939a1d1b..3d70f33db9b 100644 --- a/sched/sig_timedwait.c +++ b/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/sched/task_delete.c b/sched/task_delete.c index 637b536ec58..1cf9f97e58e 100644 --- a/sched/task_delete.c +++ b/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/sched/wd_cancel.c b/sched/wd_cancel.c index 0bd59cf8956..a1c220873dd 100644 --- a/sched/wd_cancel.c +++ b/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) { - PANIC(OSERR_WDOGNOTFOUND); + 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 { - /* 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/sched/wd_start.c b/sched/wd_start.c index 2a69d131a03..440c83b0c44 100644 --- a/sched/wd_start.c +++ b/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/syscall/syscall.csv b/syscall/syscall.csv index 988589ad2fc..0e9c452a1c1 100644 --- a/syscall/syscall.csv +++ b/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/syscall/syscall_lookup.h b/syscall/syscall_lookup.h index e134c7179f2..a5e2045bcbd 100644 --- a/syscall/syscall_lookup.h +++ b/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/syscall/syscall_stublookup.c b/syscall/syscall_stublookup.c index 0cb70d0a065..517c15af343 100644 --- a/syscall/syscall_stublookup.c +++ b/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 */