1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @ingroup rtems_bsd_rtems |
---|
5 | * |
---|
6 | * @brief TODO. |
---|
7 | */ |
---|
8 | |
---|
9 | /* |
---|
10 | * Copyright (c) 2009, 2010 embedded brains GmbH. All rights reserved. |
---|
11 | * |
---|
12 | * embedded brains GmbH |
---|
13 | * Obere Lagerstr. 30 |
---|
14 | * 82178 Puchheim |
---|
15 | * Germany |
---|
16 | * <rtems@embedded-brains.de> |
---|
17 | * |
---|
18 | * The license and distribution terms for this file may be |
---|
19 | * found in the file LICENSE in this distribution or at |
---|
20 | * http://www.rtems.com/license/LICENSE. |
---|
21 | */ |
---|
22 | |
---|
23 | #include <freebsd/machine/rtems-bsd-config.h> |
---|
24 | |
---|
25 | #include <freebsd/sys/param.h> |
---|
26 | #include <freebsd/sys/types.h> |
---|
27 | #include <freebsd/sys/systm.h> |
---|
28 | #include <freebsd/sys/kernel.h> |
---|
29 | #include <freebsd/sys/lock.h> |
---|
30 | #include <freebsd/sys/mutex.h> |
---|
31 | #include <freebsd/sys/proc.h> |
---|
32 | |
---|
33 | static void |
---|
34 | suspend_all_threads(void) |
---|
35 | { |
---|
36 | rtems_chain_control *chain = &rtems_bsd_thread_chain; |
---|
37 | rtems_chain_node *node = rtems_chain_first(chain); |
---|
38 | rtems_id self = rtems_task_self(); |
---|
39 | |
---|
40 | while (!rtems_chain_is_tail(chain, node)) { |
---|
41 | struct thread *td = (struct thread *) node; |
---|
42 | |
---|
43 | if (td->td_id != self && td->td_id != RTEMS_SELF) { |
---|
44 | rtems_task_suspend(td->td_id); |
---|
45 | } |
---|
46 | |
---|
47 | node = rtems_chain_next(node); |
---|
48 | } |
---|
49 | |
---|
50 | rtems_task_suspend(RTEMS_SELF); |
---|
51 | } |
---|
52 | |
---|
53 | void |
---|
54 | panic(const char *fmt, ...) |
---|
55 | { |
---|
56 | va_list ap; |
---|
57 | |
---|
58 | printf("*** BSD PANIC *** "); |
---|
59 | |
---|
60 | va_start(ap, fmt); |
---|
61 | vprintf(fmt, ap); |
---|
62 | va_end(ap); |
---|
63 | |
---|
64 | printf("\n"); |
---|
65 | |
---|
66 | suspend_all_threads(); |
---|
67 | |
---|
68 | /* FIXME */ |
---|
69 | rtems_fatal_error_occurred(0xdeadbeef); |
---|
70 | } |
---|