From 3aa94411be3ee39b0cbad2ca3ef66abcf2c81e13 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 25 Apr 2013 15:19:59 -0600 Subject: [PATCH] Remove up_assert_code --- arch/8051/src/up_assert.c | 26 +--- arch/8051/src/up_blocktask.c | 135 ++++++++++----------- arch/8051/src/up_reprioritizertr.c | 2 +- arch/8051/src/up_unblocktask.c | 113 +++++++++--------- arch/arm/src/arm/up_assert.c | 26 +--- arch/arm/src/arm/up_blocktask.c | 125 ++++++++++---------- arch/arm/src/arm/up_dataabort.c | 6 +- arch/arm/src/arm/up_doirq.c | 4 +- arch/arm/src/arm/up_prefetchabort.c | 4 +- arch/arm/src/arm/up_reprioritizertr.c | 4 +- arch/arm/src/arm/up_syscall.c | 2 +- arch/arm/src/arm/up_unblocktask.c | 103 ++++++++-------- arch/arm/src/arm/up_undefinedinsn.c | 4 +- arch/arm/src/armv6-m/up_assert.c | 24 +--- arch/arm/src/armv6-m/up_blocktask.c | 121 +++++++++---------- arch/arm/src/armv6-m/up_doirq.c | 2 +- arch/arm/src/armv6-m/up_hardfault.c | 4 +- arch/arm/src/armv6-m/up_reprioritizertr.c | 2 +- arch/arm/src/armv6-m/up_unblocktask.c | 93 +++++++-------- arch/arm/src/armv7-m/up_assert.c | 24 +--- arch/arm/src/armv7-m/up_blocktask.c | 123 ++++++++++--------- arch/arm/src/armv7-m/up_doirq.c | 4 +- arch/arm/src/armv7-m/up_hardfault.c | 2 +- arch/arm/src/armv7-m/up_memfault.c | 6 +- arch/arm/src/armv7-m/up_reprioritizertr.c | 2 +- arch/arm/src/armv7-m/up_unblocktask.c | 93 +++++++-------- arch/arm/src/c5471/c5471_serial.c | 2 +- arch/arm/src/calypso/calypso_serial.c | 2 +- arch/arm/src/dm320/dm320_decodeirq.c | 2 +- arch/arm/src/dm320/dm320_serial.c | 2 +- arch/arm/src/imx/imx_decodeirq.c | 2 +- arch/arm/src/imx/imx_serial.c | 2 +- arch/arm/src/kinetis/kinetis_irq.c | 12 +- arch/arm/src/kinetis/kinetis_serial.c | 4 +- arch/arm/src/kl/kl_irq.c | 6 +- arch/arm/src/kl/kl_serial.c | 2 +- arch/arm/src/lm/lm_irq.c | 12 +- arch/arm/src/lm/lm_serial.c | 2 +- arch/arm/src/lpc17xx/lpc17_i2c.c | 2 +- arch/arm/src/lpc17xx/lpc17_irq.c | 12 +- arch/arm/src/lpc17xx/lpc17_serial.c | 2 +- arch/arm/src/lpc214x/lpc214x_decodeirq.c | 2 +- arch/arm/src/lpc214x/lpc214x_serial.c | 2 +- arch/arm/src/lpc2378/lpc23xx_decodeirq.c | 2 +- arch/arm/src/lpc2378/lpc23xx_serial.c | 2 +- arch/arm/src/lpc31xx/lpc31_decodeirq.c | 2 +- arch/arm/src/lpc43xx/lpc43_i2c.c | 2 +- arch/arm/src/lpc43xx/lpc43_irq.c | 12 +- arch/arm/src/lpc43xx/lpc43_serial.c | 2 +- arch/arm/src/nuc1xx/nuc_irq.c | 6 +- arch/arm/src/nuc1xx/nuc_serial.c | 2 +- arch/arm/src/sam3u/sam3u_irq.c | 12 +- arch/arm/src/sam3u/sam3u_serial.c | 2 +- arch/arm/src/stm32/stm32_can.c | 4 +- arch/arm/src/stm32/stm32_irq.c | 12 +- arch/arm/src/stm32/stm32f10xxx_dma.c | 2 +- arch/arm/src/stm32/stm32f20xxx_dma.c | 2 +- arch/arm/src/stm32/stm32f40xxx_dma.c | 2 +- arch/arm/src/str71x/str71x_decodeirq.c | 4 +- arch/arm/src/str71x/str71x_serial.c | 2 +- arch/avr/src/at32uc3/at32uc3_irq.c | 2 +- arch/avr/src/at32uc3/at32uc3_serial.c | 2 +- arch/avr/src/avr/up_blocktask.c | 123 ++++++++++--------- arch/avr/src/avr/up_doirq.c | 2 +- arch/avr/src/avr/up_reprioritizertr.c | 2 +- arch/avr/src/avr/up_unblocktask.c | 95 +++++++-------- arch/avr/src/avr32/up_blocktask.c | 123 ++++++++++--------- arch/avr/src/avr32/up_doirq.c | 2 +- arch/avr/src/avr32/up_reprioritizertr.c | 2 +- arch/avr/src/avr32/up_unblocktask.c | 95 +++++++-------- arch/avr/src/common/up_assert.c | 27 +---- arch/hc/src/common/up_blocktask.c | 125 ++++++++++---------- arch/hc/src/common/up_doirq.c | 2 +- arch/hc/src/common/up_reprioritizertr.c | 2 +- arch/hc/src/common/up_unblocktask.c | 103 ++++++++-------- arch/hc/src/m9s12/m9s12_assert.c | 27 +---- arch/hc/src/m9s12/m9s12_serial.c | 2 +- arch/mips/src/common/up_exit.c | 2 +- arch/mips/src/mips32/up_assert.c | 25 +--- arch/mips/src/mips32/up_blocktask.c | 123 ++++++++++--------- arch/mips/src/mips32/up_doirq.c | 2 +- arch/mips/src/mips32/up_reprioritizertr.c | 2 +- arch/mips/src/mips32/up_sigdeliver.c | 2 +- arch/mips/src/mips32/up_unblocktask.c | 95 +++++++-------- arch/mips/src/pic32mx/pic32mx-exception.c | 2 +- arch/mips/src/pic32mx/pic32mx-serial.c | 2 +- arch/rgmp/src/nuttx.c | 17 --- arch/sh/src/common/up_assert.c | 26 +--- arch/sh/src/common/up_blocktask.c | 125 ++++++++++---------- arch/sh/src/common/up_doirq.c | 2 +- arch/sh/src/common/up_reprioritizertr.c | 2 +- arch/sh/src/common/up_unblocktask.c | 103 ++++++++-------- arch/sh/src/m16c/m16c_serial.c | 4 +- arch/sh/src/sh1/sh1_serial.c | 2 +- arch/sim/src/up_blocktask.c | 114 +++++++++--------- arch/sim/src/up_head.c | 8 +- arch/sim/src/up_reprioritizertr.c | 2 +- arch/sim/src/up_unblocktask.c | 90 +++++++------- arch/x86/src/common/up_assert.c | 27 +---- arch/x86/src/common/up_blocktask.c | 125 ++++++++++---------- arch/x86/src/common/up_reprioritizertr.c | 2 +- arch/x86/src/common/up_unblocktask.c | 103 ++++++++-------- arch/x86/src/qemu/qemu_handlers.c | 4 +- arch/z16/src/common/up_assert.c | 39 +----- arch/z16/src/common/up_blocktask.c | 137 +++++++++++----------- arch/z16/src/common/up_doirq.c | 2 +- arch/z16/src/common/up_reprioritizertr.c | 2 +- arch/z16/src/common/up_unblocktask.c | 113 +++++++++--------- arch/z16/src/z16f/z16f_serial.c | 4 +- arch/z16/src/z16f/z16f_sysexec.c | 12 +- arch/z80/src/common/up_assert.c | 39 +----- arch/z80/src/common/up_blocktask.c | 137 +++++++++++----------- arch/z80/src/common/up_doirq.c | 2 +- arch/z80/src/common/up_reprioritizertr.c | 2 +- arch/z80/src/common/up_unblocktask.c | 113 +++++++++--------- arch/z80/src/ez80/ez80_serial.c | 2 +- arch/z80/src/z8/z8_serial.c | 4 +- 117 files changed, 1571 insertions(+), 1980 deletions(-) diff --git a/arch/8051/src/up_assert.c b/arch/8051/src/up_assert.c index f1f9bb87f7..53e74feb71 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 554111ae01..0185774773 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 14c14e663a..649db3a43c 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 f3f9215497..621c8a7836 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 e5bf00d6ee..03f6e4d8fa 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 090cc64071..04caa44815 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 99b3bf2ab7..d5e652856b 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 7cd1a6a1be..3b47a56b03 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 541586de97..78ca496abc 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 7697940832..9d898ed7ba 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 eb9bac8ade..db3231646c 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 a2dc0f6943..2e373f38ef 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 88e3a79d95..dd4f15e356 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 86347672e1..3afef2dff3 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 a332cbefd9..57db2b4aab 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 7dec211528..2edbc55ddb 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 049f71d058..a2a0982a7e 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 0bc0d41706..07eeef14ba 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 c496a8f438..e4bfede97a 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 b0df6d729d..5d14ff34a8 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 15558ed4d7..8caf4a2b69 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 6063f9ca1c..d8a1446deb 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 e43b18cb3f..d99473bde6 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 c9f1b57b1e..6ab160d031 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 94708a3be9..a0d54a688f 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 b2ff98879b..8c6551b8e3 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 db28e196de..cdc5b6f24c 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 01e65d062a..5817b338b7 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 98ba760977..c29207a5b9 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 58ff1e710a..fbeefd8e90 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 230a4fc20b..dc23265241 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 9182d4ac8d..d7a4c3296c 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 f651c9e5d6..f8b35656c7 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 8ede027ec5..f176f5fa0b 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 cc2303ae1e..9e7d84e358 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 d4f37f9f27..290192dcd4 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 11ea6fbb61..920eee8af4 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 e9b9f72fb8..6e772ecd50 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 866a668abb..777349defc 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 80de4596c5..770874717e 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 713426b6e7..b2da4839f2 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 057e526c2f..7886e55000 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 b035e91fcc..c647e458a8 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 3a50beb50e..75e6c98b4c 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 c17a578409..08fe4ec73e 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 0e73f131b9..1929d864d3 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 64a044f135..1dc8b7679b 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 042b3360b8..7195092bba 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 a6e6b7b18b..adbfb282a7 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 01a7bd7ba4..2ee01762d2 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 dbf34f8ec2..c07ef1109c 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 9c1e9bb3e4..29c9908c98 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 1494742077..a4d79a11b6 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 86a53dab09..a3011cde42 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 96b239c36b..d1cd37e360 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 80408e58b8..29b09150d6 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 e5905a9096..844fa6a670 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 850ab62ae0..fd8164a321 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 48c9aa7e4d..da7b5a48ee 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 5de63a1b99..2098758b1c 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 771d1b9da9..70ade3e2a0 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 f33ce7d726..1ddb9901be 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 7d48da78a3..82fcd65db1 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 7533d21592..4db08c0469 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 5b23a37a11..4c510f4ea4 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 f1707b7bde..970deedd65 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 a5ff53ae9e..1da4eb5736 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 2d4a5e14a9..c4513e77f5 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 bc9ba21f04..621f08613f 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 5ce48e3665..1fcfa1dd78 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 2e70a9c289..a9012202e7 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 da7131c4c1..5a29862914 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 4a56dedbdc..61d67d395c 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 92e18ff47e..d9689a0f3e 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 7d5f67a1b1..de787418a6 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 9f97ec4dbf..69d5e3c738 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 24d3e7765d..bb61d7dbc3 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 8791fa40bd..974bdc6131 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 9f503ac852..36414d71c0 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 8d209da9f5..e0d1cf2471 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 b963881e30..bf1a197278 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 f4034cc1ee..a8f0158b96 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 0abc270d38..defa6bd102 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 70a5a72410..99cd25052c 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 dd3b88b140..cf0813e5ff 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 0254051d24..0a03b98a9c 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 a4f713be6d..e963176210 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 72880fd2ab..7e8f134518 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 db7f0297c6..9959e71df7 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 185fa96845..d6a121330b 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 dcf0fcd7b0..64f5d9969b 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 b7c88f8239..455c50ce29 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 f9125cf112..a936dd922e 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 e696c96f5b..5f521fa5a4 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 46598b442c..db97014343 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 7326e73dca..00018865f1 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 0b18defe6d..7423a71129 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 f8b229f8d7..35961c5f80 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 ed83eb6ce5..f9a36dc536 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 b1653f1e42..dba388cb09 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 47c55f6b29..8c83b0790d 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 eac913886f..873ff14206 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 a0d6028aaa..ae889a63f7 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 06c77a73e7..c5efc174a4 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 93efee96f8..56618ab3da 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 9964f44325..fea0a86d28 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 2eb5c2cdb5..bbfee78452 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 f63981ab54..a629b50669 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 b0f1a4674d..28c3f94b75 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 e824076b0d..bd922237f5 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 27929c97a8..644aa5c7a4 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 6a9f050aae..875c0602cf 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 ad318e17f9..231e787ca5 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 476f324e37..a5b3a18c8e 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 9f9714bb9e..e6141d4fcf 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 bf938529c3..a178ecb19f 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 fd499b1839..553e3fb400 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;