summaryrefslogtreecommitdiffstats
path: root/rtems/freebsd/rtems/rtems-bsd-panic.c
diff options
context:
space:
mode:
authorJoel Sherrill <joel.sherrill@oarcorp.com>2012-03-07 09:52:04 -0600
committerJoel Sherrill <joel.sherrill@oarcorp.com>2012-03-07 09:52:04 -0600
commita9153ec3040f54fa52b68e14dafed2aba7b780ae (patch)
treefda80e3380dfebf7d97868507aa185757852e882 /rtems/freebsd/rtems/rtems-bsd-panic.c
downloadrtems-libbsd-a9153ec3040f54fa52b68e14dafed2aba7b780ae.tar.bz2
Initial import
Code is based on FreeBSD 8.2 with USB support from Sebastian Huber and Thomas Doerfler. Initial TCP/IP stack work is from Kevel Kirspel.
Diffstat (limited to 'rtems/freebsd/rtems/rtems-bsd-panic.c')
-rw-r--r--rtems/freebsd/rtems/rtems-bsd-panic.c70
1 files changed, 70 insertions, 0 deletions
diff --git a/rtems/freebsd/rtems/rtems-bsd-panic.c b/rtems/freebsd/rtems/rtems-bsd-panic.c
new file mode 100644
index 00000000..2425abed
--- /dev/null
+++ b/rtems/freebsd/rtems/rtems-bsd-panic.c
@@ -0,0 +1,70 @@
+/**
+ * @file
+ *
+ * @ingroup rtems_bsd_rtems
+ *
+ * @brief TODO.
+ */
+
+/*
+ * Copyright (c) 2009, 2010 embedded brains GmbH. All rights reserved.
+ *
+ * embedded brains GmbH
+ * Obere Lagerstr. 30
+ * 82178 Puchheim
+ * Germany
+ * <rtems@embedded-brains.de>
+ *
+ * The license and distribution terms for this file may be
+ * found in the file LICENSE in this distribution or at
+ * http://www.rtems.com/license/LICENSE.
+ */
+
+#include <rtems/freebsd/machine/rtems-bsd-config.h>
+
+#include <rtems/freebsd/sys/param.h>
+#include <rtems/freebsd/sys/types.h>
+#include <rtems/freebsd/sys/systm.h>
+#include <rtems/freebsd/sys/kernel.h>
+#include <rtems/freebsd/sys/lock.h>
+#include <rtems/freebsd/sys/mutex.h>
+#include <rtems/freebsd/sys/proc.h>
+
+static void
+suspend_all_threads(void)
+{
+ rtems_chain_control *chain = &rtems_bsd_thread_chain;
+ rtems_chain_node *node = rtems_chain_first(chain);
+ rtems_id self = rtems_task_self();
+
+ while (!rtems_chain_is_tail(chain, node)) {
+ struct thread *td = (struct thread *) node;
+
+ if (td->td_id != self && td->td_id != RTEMS_SELF) {
+ rtems_task_suspend(td->td_id);
+ }
+
+ node = rtems_chain_next(node);
+ }
+
+ rtems_task_suspend(RTEMS_SELF);
+}
+
+void
+panic(const char *fmt, ...)
+{
+ va_list ap;
+
+ printf("*** BSD PANIC *** ");
+
+ va_start(ap, fmt);
+ vprintf(fmt, ap);
+ va_end(ap);
+
+ printf("\n");
+
+ suspend_all_threads();
+
+ /* FIXME */
+ rtems_fatal_error_occurred(0xdeadbeef);
+}