9#include <l4/re/util/debug>
11struct Err : L4Re::Util::Err
13 Err(Level l = Fatal) : L4Re::Util::Err(l,
"VSwitch") {}
16class Dbg :
public L4Re::Util::Dbg
19 static constexpr unsigned Verbosity_shift = 4;
20 static constexpr unsigned long Verbosity_mask = (1UL << Verbosity_shift) - 1;
24 enum Verbosity :
unsigned long
50 static_assert(Max_component * Verbosity_shift <=
sizeof(level) * 8,
51 "Too many components for level mask");
52 static_assert((Max_verbosity & Verbosity_mask) == Max_verbosity,
53 "Verbosity_shift to small for verbosity levels");
60 static void set_verbosity(
unsigned mask)
62 for (
unsigned i = 0; i < Max_component; ++i)
63 set_verbosity(i, mask);
72 static void set_verbosity(
unsigned c,
unsigned mask)
74 level &= ~(Verbosity_mask << (Verbosity_shift * c));
75 level |= (mask & Verbosity_mask) << (Verbosity_shift * c);
87 static bool is_active(
unsigned c,
unsigned mask)
88 {
return level & (mask & Verbosity_mask) << (Verbosity_shift * c); }
96 using L4Re::Util::Dbg::is_active;
98 Dbg(Component c = Core, Verbosity v = Warn,
char const *subsys =
nullptr)
99 : L4Re::Util::Dbg(v << (Verbosity_shift * c),
"SWI", subsys)
104 static void set_verbosity(
unsigned) {}
105 static void set_verbosity(
unsigned,
unsigned) {}
107 static bool is_active(
unsigned,
unsigned) {
return false; }
108 using L4Re::Util::Dbg::is_active;
110 Dbg(Component c = Core, Verbosity v = Warn,
char const *subsys =
nullptr)
111 : L4Re::Util::Dbg(v << (Verbosity_shift * c),
"", subsys)