summaryrefslogtreecommitdiff
path: root/nuttx/arch/sim/src
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2013-04-25 15:19:59 -0600
committerGregory Nutt <gnutt@nuttx.org>2013-04-25 15:19:59 -0600
commit1ffc15c3233c8d61953fc2ebc80b5d3c46fc429f (patch)
tree95050f5e635b87d26f4dd98612b05edf632b2a96 /nuttx/arch/sim/src
parent5f6e91b0ed1b373d0b4f963b0e0f8f7fe05ec766 (diff)
downloadpx4-nuttx-1ffc15c3233c8d61953fc2ebc80b5d3c46fc429f.tar.gz
px4-nuttx-1ffc15c3233c8d61953fc2ebc80b5d3c46fc429f.tar.bz2
px4-nuttx-1ffc15c3233c8d61953fc2ebc80b5d3c46fc429f.zip
Remove up_assert_code
Diffstat (limited to 'nuttx/arch/sim/src')
-rw-r--r--nuttx/arch/sim/src/up_blocktask.c102
-rw-r--r--nuttx/arch/sim/src/up_head.c8
-rw-r--r--nuttx/arch/sim/src/up_reprioritizertr.c2
-rw-r--r--nuttx/arch/sim/src/up_unblocktask.c104
4 files changed, 101 insertions, 115 deletions
diff --git a/nuttx/arch/sim/src/up_blocktask.c b/nuttx/arch/sim/src/up_blocktask.c
index 46598b442..db9701434 100644
--- a/nuttx/arch/sim/src/up_blocktask.c
+++ b/nuttx/arch/sim/src/up_blocktask.c
@@ -1,7 +1,7 @@
/****************************************************************************
* up_blocktask.c
*
- * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007-2009, 2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -86,75 +86,71 @@
void up_block_task(struct tcb_s *tcb, tstate_t task_state)
{
+ struct tcb_s *rtcb = (struct tcb_s*)g_readytorun.head;
+ bool switch_needed;
+
/* Verify that the context switch can be performed */
- if ((tcb->task_state < FIRST_READY_TO_RUN_STATE) ||
- (tcb->task_state > LAST_READY_TO_RUN_STATE))
- {
- PANIC(OSERR_BADBLOCKSTATE);
- }
- else
- {
- struct tcb_s *rtcb = (struct tcb_s*)g_readytorun.head;
- bool switch_needed;
- sdbg("Blocking TCB=%p\n", tcb);
+ ASSERT((tcb->task_state >= FIRST_READY_TO_RUN_STATE) &&
+ (tcb->task_state <= LAST_READY_TO_RUN_STATE));
- /* Remove the tcb task from the ready-to-run list. If we
- * are blocking the task at the head of the task list (the
- * most likely case), then a context switch to the next
- * ready-to-run task is needed. In this case, it should
- * also be true that rtcb == tcb.
- */
+ sdbg("Blocking TCB=%p\n", tcb);
- switch_needed = sched_removereadytorun(tcb);
+ /* Remove the tcb task from the ready-to-run list. If we
+ * are blocking the task at the head of the task list (the
+ * most likely case), then a context switch to the next
+ * ready-to-run task is needed. In this case, it should
+ * also be true that rtcb == tcb.
+ */
- /* Add the task to the specified blocked task list */
+ switch_needed = sched_removereadytorun(tcb);
- sched_addblocked(tcb, (tstate_t)task_state);
+ /* Add the task to the specified blocked task list */
- /* If there are any pending tasks, then add them to the g_readytorun
- * task list now
- */
+ sched_addblocked(tcb, (tstate_t)task_state);
- if (g_pendingtasks.head)
- {
- switch_needed |= sched_mergepending();
- }
+ /* If there are any pending tasks, then add them to the g_readytorun
+ * task list now
+ */
+
+ if (g_pendingtasks.head)
+ {
+ switch_needed |= sched_mergepending();
+ }
- /* Now, perform the context switch if one is needed */
+ /* Now, perform the context switch if one is needed */
- if (switch_needed)
+ if (switch_needed)
+ {
+ /* Copy the exception context into the TCB at the (old) head of the
+ * g_readytorun Task list. if up_setjmp returns a non-zero
+ * value, then this is really the previously running task restarting!
+ */
+
+ if (!up_setjmp(rtcb->xcp.regs))
{
- /* Copy the exception context into the TCB at the (old) head of the
- * g_readytorun Task list. if up_setjmp returns a non-zero
- * value, then this is really the previously running task restarting!
+ /* Restore the exception context of the rtcb at the (new) head
+ * of the g_readytorun task list.
*/
- if (!up_setjmp(rtcb->xcp.regs))
- {
- /* Restore the exception context of the rtcb at the (new) head
- * of the g_readytorun task list.
- */
-
- rtcb = (struct tcb_s*)g_readytorun.head;
- sdbg("New Active Task TCB=%p\n", rtcb);
+ rtcb = (struct tcb_s*)g_readytorun.head;
+ sdbg("New Active Task TCB=%p\n", rtcb);
- /* The way that we handle signals in the simulation is kind of
- * a kludge. This would be unsafe in a truly multi-threaded, interrupt
- * driven environment.
- */
+ /* The way that we handle signals in the simulation is kind of
+ * a kludge. This would be unsafe in a truly multi-threaded, interrupt
+ * driven environment.
+ */
- if (rtcb->xcp.sigdeliver)
- {
- sdbg("Delivering signals TCB=%p\n", rtcb);
- ((sig_deliver_t)rtcb->xcp.sigdeliver)(rtcb);
- rtcb->xcp.sigdeliver = NULL;
- }
+ if (rtcb->xcp.sigdeliver)
+ {
+ sdbg("Delivering signals TCB=%p\n", rtcb);
+ ((sig_deliver_t)rtcb->xcp.sigdeliver)(rtcb);
+ rtcb->xcp.sigdeliver = NULL;
+ }
- /* Then switch contexts */
+ /* Then switch contexts */
- up_longjmp(rtcb->xcp.regs, 1);
- }
+ up_longjmp(rtcb->xcp.regs, 1);
}
}
}
diff --git a/nuttx/arch/sim/src/up_head.c b/nuttx/arch/sim/src/up_head.c
index 7326e73dc..00018865f 100644
--- a/nuttx/arch/sim/src/up_head.c
+++ b/nuttx/arch/sim/src/up_head.c
@@ -1,7 +1,7 @@
/****************************************************************************
* up_head.c
*
- * Copyright (C) 2007-2009, 2011-2112 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007-2009, 2011-2113 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -83,9 +83,3 @@ void up_assert(const uint8_t *filename, int line)
fprintf(stderr, "Assertion failed at file:%s line: %d\n", filename, line);
longjmp(sim_abort, 1);
}
-
-void up_assert_code(const uint8_t *filename, int line, int code)
-{
- fprintf(stderr, "Assertion failed at file:%s line: %d error code: %d\n", filename, line, code);
- longjmp(sim_abort, 1);
-}
diff --git a/nuttx/arch/sim/src/up_reprioritizertr.c b/nuttx/arch/sim/src/up_reprioritizertr.c
index 0b18defe6..7423a7112 100644
--- a/nuttx/arch/sim/src/up_reprioritizertr.c
+++ b/nuttx/arch/sim/src/up_reprioritizertr.c
@@ -99,7 +99,7 @@ void up_reprioritize_rtr(struct tcb_s *tcb, uint8_t priority)
#endif
)
{
- PANIC(OSERR_BADREPRIORITIZESTATE);
+ PANIC();
}
else
{
diff --git a/nuttx/arch/sim/src/up_unblocktask.c b/nuttx/arch/sim/src/up_unblocktask.c
index f8b229f8d..35961c5f8 100644
--- a/nuttx/arch/sim/src/up_unblocktask.c
+++ b/nuttx/arch/sim/src/up_unblocktask.c
@@ -1,7 +1,7 @@
/****************************************************************************
* up_unblocktask.c
*
- * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved.
+ * Copyright (C) 2007-2009, 2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@@ -81,68 +81,64 @@
void up_unblock_task(struct tcb_s *tcb)
{
+ struct tcb_s *rtcb = (struct tcb_s*)g_readytorun.head;
+
/* Verify that the context switch can be performed */
- if ((tcb->task_state < FIRST_BLOCKED_STATE) ||
- (tcb->task_state > LAST_BLOCKED_STATE))
- {
- PANIC(OSERR_BADUNBLOCKSTATE);
- }
- else
- {
- struct tcb_s *rtcb = (struct tcb_s*)g_readytorun.head;
- sdbg("Unblocking TCB=%p\n", tcb);
+ ASSERT((tcb->task_state >= FIRST_BLOCKED_STATE) &&
+ (tcb->task_state <= LAST_BLOCKED_STATE));
- /* Remove the task from the blocked task list */
+ sdbg("Unblocking TCB=%p\n", tcb);
- sched_removeblocked(tcb);
+ /* Remove the task from the blocked task list */
- /* Reset its timeslice. This is only meaningful for round
- * robin tasks but it doesn't here to do it for everything
- */
+ sched_removeblocked(tcb);
+
+ /* Reset its timeslice. This is only meaningful for round
+ * robin tasks but it doesn't here to do it for everything
+ */
#if CONFIG_RR_INTERVAL > 0
- tcb->timeslice = CONFIG_RR_INTERVAL / MSEC_PER_TICK;
+ tcb->timeslice = CONFIG_RR_INTERVAL / MSEC_PER_TICK;
#endif
- /* Add the task in the correct location in the prioritized
- * g_readytorun task list
- */
-
- if (sched_addreadytorun(tcb))
- {
- /* The currently active task has changed! Copy the exception context
- * into the TCB of the task that was previously active. if
- * up_setjmp returns a non-zero value, then this is really the
- * previously running task restarting!
- */
-
- if (!up_setjmp(rtcb->xcp.regs))
- {
- /* Restore the exception context of the new task that is ready to
- * run (probably tcb). This is the new rtcb at the head of the
- * g_readytorun task list.
- */
-
- rtcb = (struct tcb_s*)g_readytorun.head;
- sdbg("New Active Task TCB=%p\n", rtcb);
-
- /* The way that we handle signals in the simulation is kind of
- * a kludge. This would be unsafe in a truly multi-threaded, interrupt
- * driven environment.
- */
-
- if (rtcb->xcp.sigdeliver)
- {
- sdbg("Delivering signals TCB=%p\n", rtcb);
- ((sig_deliver_t)rtcb->xcp.sigdeliver)(rtcb);
- rtcb->xcp.sigdeliver = NULL;
- }
-
- /* Then switch contexts */
-
- up_longjmp(rtcb->xcp.regs, 1);
- }
+ /* Add the task in the correct location in the prioritized
+ * g_readytorun task list
+ */
+
+ if (sched_addreadytorun(tcb))
+ {
+ /* The currently active task has changed! Copy the exception context
+ * into the TCB of the task that was previously active. if
+ * up_setjmp returns a non-zero value, then this is really the
+ * previously running task restarting!
+ */
+
+ if (!up_setjmp(rtcb->xcp.regs))
+ {
+ /* Restore the exception context of the new task that is ready to
+ * run (probably tcb). This is the new rtcb at the head of the
+ * g_readytorun task list.
+ */
+
+ rtcb = (struct tcb_s*)g_readytorun.head;
+ sdbg("New Active Task TCB=%p\n", rtcb);
+
+ /* The way that we handle signals in the simulation is kind of
+ * a kludge. This would be unsafe in a truly multi-threaded, interrupt
+ * driven environment.
+ */
+
+ if (rtcb->xcp.sigdeliver)
+ {
+ sdbg("Delivering signals TCB=%p\n", rtcb);
+ ((sig_deliver_t)rtcb->xcp.sigdeliver)(rtcb);
+ rtcb->xcp.sigdeliver = NULL;
+ }
+
+ /* Then switch contexts */
+
+ up_longjmp(rtcb->xcp.regs, 1);
}
}
}