From cbffdb7fdc50cbf0175fd5cb6ae32f6f115d6035 Mon Sep 17 00:00:00 2001 From: Joel Sherrill Date: Wed, 7 Mar 2012 16:14:13 -0600 Subject: Separate RTEMS Specific Files from Those Direct from FreeBSD --- rtemsbsd/src/rtems-bsd-panic.c | 70 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 70 insertions(+) create mode 100644 rtemsbsd/src/rtems-bsd-panic.c (limited to 'rtemsbsd/src/rtems-bsd-panic.c') diff --git a/rtemsbsd/src/rtems-bsd-panic.c b/rtemsbsd/src/rtems-bsd-panic.c new file mode 100644 index 00000000..2425abed --- /dev/null +++ b/rtemsbsd/src/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 + * + * + * 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 + +#include +#include +#include +#include +#include +#include +#include + +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); +} -- cgit v1.2.3