diff options
author | Gregory Nutt <gnutt@nuttx.org> | 2013-04-25 15:19:59 -0600 |
---|---|---|
committer | Gregory Nutt <gnutt@nuttx.org> | 2013-04-25 15:19:59 -0600 |
commit | 1ffc15c3233c8d61953fc2ebc80b5d3c46fc429f (patch) | |
tree | 95050f5e635b87d26f4dd98612b05edf632b2a96 /nuttx/arch/x86 | |
parent | 5f6e91b0ed1b373d0b4f963b0e0f8f7fe05ec766 (diff) | |
download | nuttx-1ffc15c3233c8d61953fc2ebc80b5d3c46fc429f.tar.gz nuttx-1ffc15c3233c8d61953fc2ebc80b5d3c46fc429f.tar.bz2 nuttx-1ffc15c3233c8d61953fc2ebc80b5d3c46fc429f.zip |
Remove up_assert_code
Diffstat (limited to 'nuttx/arch/x86')
-rw-r--r-- | nuttx/arch/x86/src/common/up_assert.c | 27 | ||||
-rw-r--r-- | nuttx/arch/x86/src/common/up_blocktask.c | 107 | ||||
-rw-r--r-- | nuttx/arch/x86/src/common/up_reprioritizertr.c | 2 | ||||
-rw-r--r-- | nuttx/arch/x86/src/common/up_unblocktask.c | 95 | ||||
-rw-r--r-- | nuttx/arch/x86/src/qemu/qemu_handlers.c | 4 |
5 files changed, 102 insertions, 133 deletions
diff --git a/nuttx/arch/x86/src/common/up_assert.c b/nuttx/arch/x86/src/common/up_assert.c index ed83eb6ce..f9a36dc53 100644 --- a/nuttx/arch/x86/src/common/up_assert.c +++ b/nuttx/arch/x86/src/common/up_assert.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/x86/src/common/up_assert.c * - * Copyright (C) 2011-2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2011-2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without @@ -248,6 +248,7 @@ void up_assert(const uint8_t *filename, int lineno) #endif up_ledon(LED_ASSERTION); + #ifdef CONFIG_PRINT_TASKNAME lldbg("Assertion failed at file:%s line: %d task: %s\n", filename, lineno, rtcb->name); @@ -255,29 +256,7 @@ void up_assert(const uint8_t *filename, int lineno) lldbg("Assertion failed at file:%s line: %d\n", filename, lineno); #endif - up_dumpstate(); - _up_assert(EXIT_FAILURE); -} - -/**************************************************************************** - * Name: up_assert_code - ****************************************************************************/ - -void up_assert_code(const uint8_t *filename, int lineno, int errorcode) -{ -#ifdef CONFIG_PRINT_TASKNAME - struct tcb_s *rtcb = (struct tcb_s*)g_readytorun.head; -#endif - - up_ledon(LED_ASSERTION); -#ifdef CONFIG_PRINT_TASKNAME - lldbg("Assertion failed at file:%s line: %d task: %s error code: %d\n", - filename, lineno, rtcb->name, errorcode); -#else - lldbg("Assertion failed at file:%s line: %d error code: %d\n", - filename, lineno, errorcode); -#endif up_dumpstate(); - _up_assert(errorcode); + _up_assert(EXIT_FAILURE); } diff --git a/nuttx/arch/x86/src/common/up_blocktask.c b/nuttx/arch/x86/src/common/up_blocktask.c index b1653f1e4..dba388cb0 100644 --- a/nuttx/arch/x86/src/common/up_blocktask.c +++ b/nuttx/arch/x86/src/common/up_blocktask.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/x86/src/common/up_blocktask.c * - * Copyright (C) 2011 Gregory Nutt. All rights reserved. + * Copyright (C) 2011, 2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without @@ -85,82 +85,77 @@ void up_block_task(struct tcb_s *tcb, tstate_t task_state) { + struct tcb_s *rtcb = (struct tcb_s*)g_readytorun.head; + bool switch_needed; + /* Verify that the context switch can be performed */ - if ((tcb->task_state < FIRST_READY_TO_RUN_STATE) || - (tcb->task_state > LAST_READY_TO_RUN_STATE)) - { - PANIC(OSERR_BADBLOCKSTATE); - } - else - { - struct tcb_s *rtcb = (struct tcb_s*)g_readytorun.head; - bool switch_needed; - - /* Remove the tcb task from the ready-to-run list. If we - * are blocking the task at the head of the task list (the - * most likely case), then a context switch to the next - * ready-to-run task is needed. In this case, it should - * also be true that rtcb == tcb. - */ + ASSERT((tcb->task_state >= FIRST_READY_TO_RUN_STATE) && + (tcb->task_state <= LAST_READY_TO_RUN_STATE)); - switch_needed = sched_removereadytorun(tcb); + /* Remove the tcb task from the ready-to-run list. If we + * are blocking the task at the head of the task list (the + * most likely case), then a context switch to the next + * ready-to-run task is needed. In this case, it should + * also be true that rtcb == tcb. + */ - /* Add the task to the specified blocked task list */ + switch_needed = sched_removereadytorun(tcb); - sched_addblocked(tcb, (tstate_t)task_state); + /* Add the task to the specified blocked task list */ - /* If there are any pending tasks, then add them to the g_readytorun - * task list now - */ + sched_addblocked(tcb, (tstate_t)task_state); - if (g_pendingtasks.head) - { - switch_needed |= sched_mergepending(); - } + /* If there are any pending tasks, then add them to the g_readytorun + * task list now + */ - /* Now, perform the context switch if one is needed */ + if (g_pendingtasks.head) + { + switch_needed |= sched_mergepending(); + } - if (switch_needed) + /* Now, perform the context switch if one is needed */ + + if (switch_needed) + { + /* Are we in an interrupt handler? */ + + if (current_regs) { - /* Are we in an interrupt handler? */ + /* Yes, then we have to do things differently. + * Just copy the current_regs into the OLD rtcb. + */ - if (current_regs) - { - /* Yes, then we have to do things differently. - * Just copy the current_regs into the OLD rtcb. - */ + up_savestate(rtcb->xcp.regs); - up_savestate(rtcb->xcp.regs); + /* Restore the exception context of the rtcb at the (new) head + * of the g_readytorun task list. + */ - /* Restore the exception context of the rtcb at the (new) head - * of the g_readytorun task list. - */ + rtcb = (struct tcb_s*)g_readytorun.head; - rtcb = (struct tcb_s*)g_readytorun.head; + /* Then switch contexts */ - /* Then switch contexts */ + up_restorestate(rtcb->xcp.regs); + } - up_restorestate(rtcb->xcp.regs); - } + /* Copy the user C context into the TCB at the (old) head of the + * g_readytorun Task list. if up_saveusercontext returns a non-zero + * value, then this is really the previously running task restarting! + */ - /* Copy the user C context into the TCB at the (old) head of the - * g_readytorun Task list. if up_saveusercontext returns a non-zero - * value, then this is really the previously running task restarting! + else if (!up_saveusercontext(rtcb->xcp.regs)) + { + /* Restore the exception context of the rtcb at the (new) head + * of the g_readytorun task list. */ - else if (!up_saveusercontext(rtcb->xcp.regs)) - { - /* Restore the exception context of the rtcb at the (new) head - * of the g_readytorun task list. - */ - - rtcb = (struct tcb_s*)g_readytorun.head; + rtcb = (struct tcb_s*)g_readytorun.head; - /* Then switch contexts */ + /* Then switch contexts */ - up_fullcontextrestore(rtcb->xcp.regs); - } + up_fullcontextrestore(rtcb->xcp.regs); } } } diff --git a/nuttx/arch/x86/src/common/up_reprioritizertr.c b/nuttx/arch/x86/src/common/up_reprioritizertr.c index 47c55f6b2..8c83b0790 100644 --- a/nuttx/arch/x86/src/common/up_reprioritizertr.c +++ b/nuttx/arch/x86/src/common/up_reprioritizertr.c @@ -98,7 +98,7 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority) #endif ) { - PANIC(OSERR_BADREPRIORITIZESTATE); + PANIC(); } else { diff --git a/nuttx/arch/x86/src/common/up_unblocktask.c b/nuttx/arch/x86/src/common/up_unblocktask.c index eac913886..873ff1420 100644 --- a/nuttx/arch/x86/src/common/up_unblocktask.c +++ b/nuttx/arch/x86/src/common/up_unblocktask.c @@ -1,7 +1,7 @@ /**************************************************************************** * arch/x86/src/common/up_unblocktask.c * - * Copyright (C) 2011 Gregory Nutt. All rights reserved. + * Copyright (C) 2011, 2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt <gnutt@nuttx.org> * * Redistribution and use in source and binary forms, with or without @@ -80,79 +80,74 @@ void up_unblock_task(struct tcb_s *tcb) { + struct tcb_s *rtcb = (struct tcb_s*)g_readytorun.head; + /* Verify that the context switch can be performed */ - if ((tcb->task_state < FIRST_BLOCKED_STATE) || - (tcb->task_state > LAST_BLOCKED_STATE)) - { - PANIC(OSERR_BADUNBLOCKSTATE); - } - else - { - struct tcb_s *rtcb = (struct tcb_s*)g_readytorun.head; + ASSERT((tcb->task_state >= FIRST_BLOCKED_STATE) && + (tcb->task_state <= LAST_BLOCKED_STATE)); - /* Remove the task from the blocked task list */ + /* Remove the task from the blocked task list */ - sched_removeblocked(tcb); + sched_removeblocked(tcb); - /* Reset its timeslice. This is only meaningful for round - * robin tasks but it doesn't here to do it for everything - */ + /* Reset its timeslice. This is only meaningful for round + * robin tasks but it doesn't here to do it for everything + */ #if CONFIG_RR_INTERVAL > 0 - tcb->timeslice = CONFIG_RR_INTERVAL / MSEC_PER_TICK; + tcb->timeslice = CONFIG_RR_INTERVAL / MSEC_PER_TICK; #endif - /* Add the task in the correct location in the prioritized - * g_readytorun task list + /* Add the task in the correct location in the prioritized + * g_readytorun task list + */ + + if (sched_addreadytorun(tcb)) + { + /* The currently active task has changed! We need to do + * a context switch to the new task. + * + * Are we in an interrupt handler? */ - if (sched_addreadytorun(tcb)) + if (current_regs) { - /* The currently active task has changed! We need to do - * a context switch to the new task. - * - * Are we in an interrupt handler? + /* Yes, then we have to do things differently. + * Just copy the current_regs into the OLD rtcb. */ - if (current_regs) - { - /* Yes, then we have to do things differently. - * Just copy the current_regs into the OLD rtcb. - */ + up_savestate(rtcb->xcp.regs); - up_savestate(rtcb->xcp.regs); + /* Restore the exception context of the rtcb at the (new) head + * of the g_readytorun task list. + */ - /* Restore the exception context of the rtcb at the (new) head - * of the g_readytorun task list. - */ + rtcb = (struct tcb_s*)g_readytorun.head; - rtcb = (struct tcb_s*)g_readytorun.head; + /* Then switch contexts */ - /* Then switch contexts */ + up_restorestate(rtcb->xcp.regs); + } - up_restorestate(rtcb->xcp.regs); - } + /* We are not in an interrupt handler. Copy the user C context + * into the TCB of the task that was previously active. if + * up_saveusercontext returns a non-zero value, then this is really the + * previously running task restarting! + */ - /* We are not in an interrupt handler. Copy the user C context - * into the TCB of the task that was previously active. if - * up_saveusercontext returns a non-zero value, then this is really the - * previously running task restarting! + else if (!up_saveusercontext(rtcb->xcp.regs)) + { + /* Restore the exception context of the new task that is ready to + * run (probably tcb). This is the new rtcb at the head of the + * g_readytorun task list. */ - else if (!up_saveusercontext(rtcb->xcp.regs)) - { - /* Restore the exception context of the new task that is ready to - * run (probably tcb). This is the new rtcb at the head of the - * g_readytorun task list. - */ - - rtcb = (struct tcb_s*)g_readytorun.head; + rtcb = (struct tcb_s*)g_readytorun.head; - /* Then switch contexts */ + /* Then switch contexts */ - up_fullcontextrestore(rtcb->xcp.regs); - } + up_fullcontextrestore(rtcb->xcp.regs); } } } diff --git a/nuttx/arch/x86/src/qemu/qemu_handlers.c b/nuttx/arch/x86/src/qemu/qemu_handlers.c index a0d6028aa..ae889a63f 100644 --- a/nuttx/arch/x86/src/qemu/qemu_handlers.c +++ b/nuttx/arch/x86/src/qemu/qemu_handlers.c @@ -142,7 +142,7 @@ uint32_t *isr_handler(uint32_t *regs) { #ifdef CONFIG_SUPPRESS_INTERRUPTS up_ledon(LED_INIRQ); - PANIC(OSERR_ERREXCEPTION); /* Doesn't return */ + PANIC(); /* Doesn't return */ return regs; /* To keep the compiler happy */ #else uint32_t *ret; @@ -168,7 +168,7 @@ uint32_t *irq_handler(uint32_t *regs) { #ifdef CONFIG_SUPPRESS_INTERRUPTS up_ledon(LED_INIRQ); - PANIC(OSERR_ERREXCEPTION); /* Doesn't return */ + PANIC(); /* Doesn't return */ return regs; /* To keep the compiler happy */ #else uint32_t *ret; |