| 1 | // SPDX-License-Identifier: GPL-3.0-or-later |
|---|---|
| 2 | |
| 3 | #pragma once |
| 4 | |
| 5 | #include "mos/platform/platform_defs.hpp" |
| 6 | |
| 7 | #include <mos/mos_global.h> |
| 8 | |
| 9 | #ifndef MOS_PLATFORM_DEBUG_MODULES |
| 10 | #define MOS_PLATFORM_DEBUG_MODULES(X) |
| 11 | #endif |
| 12 | |
| 13 | // clang-format off |
| 14 | // ! Keep this list consistent with arch/generic/Kconfig.debug |
| 15 | #define MOS_GENERIC_PLATFORM_DEBUG_MODULES(X) \ |
| 16 | X(limine) |
| 17 | |
| 18 | // ! Keep this list consistent with kernel/Kconfig.debug |
| 19 | #define MOS_ALL_DEBUG_MODULES(X) \ |
| 20 | MOS_PLATFORM_DEBUG_MODULES(X) \ |
| 21 | MOS_GENERIC_PLATFORM_DEBUG_MODULES(X) \ |
| 22 | X(cpio) \ |
| 23 | X(dcache) \ |
| 24 | X(dcache_ref) \ |
| 25 | X(dma) \ |
| 26 | X(elf) \ |
| 27 | X(futex) \ |
| 28 | X(io) \ |
| 29 | X(ipc) \ |
| 30 | X(ipi) \ |
| 31 | X(naive_sched) \ |
| 32 | X(panic) \ |
| 33 | X(pagefault) \ |
| 34 | X(pipe) \ |
| 35 | X(pmm) \ |
| 36 | X(pmm_buddy) \ |
| 37 | X(process) \ |
| 38 | X(scheduler) \ |
| 39 | X(setup) \ |
| 40 | X(signal) \ |
| 41 | X(slab) \ |
| 42 | X(spinlock) \ |
| 43 | X(syscall) \ |
| 44 | X(sysfs) \ |
| 45 | X(thread) \ |
| 46 | X(tmpfs) \ |
| 47 | X(userfs) \ |
| 48 | X(vfs) \ |
| 49 | X(vmm) |
| 50 | // clang-format on |
| 51 | |
| 52 | #if MOS_CONFIG(MOS_DYNAMIC_DEBUG) |
| 53 | |
| 54 | typedef struct _debug_info_entry |
| 55 | { |
| 56 | const u32 id; |
| 57 | const char *name; |
| 58 | bool enabled; |
| 59 | } debug_info_entry; |
| 60 | |
| 61 | extern struct mos_debug_info_entry |
| 62 | { |
| 63 | #define _expand_field(name) debug_info_entry name; |
| 64 | MOS_ALL_DEBUG_MODULES(_expand_field) |
| 65 | #undef _expand_field |
| 66 | } mos_debug_info; |
| 67 | |
| 68 | #define _mos_debug_enum(name) name, |
| 69 | enum DebugFeature |
| 70 | { |
| 71 | MOS_ALL_DEBUG_MODULES(_mos_debug_enum) // |
| 72 | _none, |
| 73 | }; |
| 74 | #undef _mos_debug_enum |
| 75 | |
| 76 | /// debug enum to mos_debug_info_entry mapping |
| 77 | #define _mos_debug_info_entry(name) [name] = &mos_debug_info.name, |
| 78 | static inline constexpr debug_info_entry *const mos_debug_info_map[] = { |
| 79 | MOS_ALL_DEBUG_MODULES(_mos_debug_info_entry) // |
| 80 | [_none] = nullptr, |
| 81 | }; |
| 82 | #undef _mos_debug_info_entry |
| 83 | |
| 84 | #define mos_debug_enabled(name) (mos_debug_info.name.enabled) |
| 85 | #define mos_debug_enabled_ptr(name) (&mos_debug_info.name.enabled) |
| 86 | #else |
| 87 | #define mos_debug_enabled(name) MOS_DEBUG_FEATURE(name) |
| 88 | #define mos_debug_enabled_ptr(name) NULL |
| 89 | #endif |
| 90 |