]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/io/server/src/debug.cc
update
[l4.git] / l4 / pkg / io / server / src / debug.cc
1 /*
2  * (c) 2011 Alexander Warg <warg@os.inf.tu-dresden.de>
3  *     economic rights: Technische Universität Dresden (Germany)
4  *
5  * This file is part of TUD:OS and distributed under the terms of the
6  * GNU General Public License 2.
7  * Please see the COPYING-GPL-2 file for details.
8  */
9
10 #include "debug.h"
11
12 #include <cstdio>
13 #include <cstdarg>
14
15 static unsigned _debug_level = 1;
16 static unsigned _trace_mask;
17
18 void set_debug_level(unsigned level)
19 {
20   _debug_level = level;
21 }
22
23 bool dlevel(unsigned level)
24 {
25   return _debug_level >= level;
26 }
27
28 void d_printf(unsigned level, char const *fmt, ...)
29 {
30   if (_debug_level < level)
31     return;
32
33   va_list a;
34   va_start(a, fmt);
35   vprintf(fmt, a);
36   va_end(a);
37 }
38
39 /**
40  * \brief Set the mask for event tracing (See debug.h for possible trace
41  * events).
42  */
43 void set_trace_mask(unsigned mask)
44 {
45   _trace_mask = mask;
46 }
47
48 /**
49  * \brief Trace an event.
50  *
51  * \param event Event to be traced
52  */
53 void trace_event(unsigned event, char const *fmt, ...)
54 {
55   if ((_trace_mask & event) == 0)
56     return;
57
58   va_list a;
59   va_start(a, fmt);
60   vprintf(fmt, a);
61   va_end(a);
62 }
63
64 /**
65  * \brief Determine if an event was selected for tracing.
66  *
67  * \param event Event to be queried.
68  *
69  * \returns true if event was selected for tracing, false otherwise
70  */
71 bool trace_event_enabled(unsigned event)
72 {
73   return (_trace_mask & event);
74 }
75
76 // Set the ACPICA debug flags
77 // This function is overridden in acpi/acpi.cc.
78 void __attribute__((weak)) acpi_set_debug_level(unsigned) {}
79