2023-01-25 21:39:03 +02:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <BAN/Formatter.h>
|
2024-02-28 22:39:02 +02:00
|
|
|
#include <kernel/Lock/SpinLock.h>
|
2023-01-25 21:39:03 +02:00
|
|
|
|
2023-08-04 10:22:20 +03:00
|
|
|
#define dprintln(...) \
|
|
|
|
do { \
|
2024-02-28 22:39:02 +02:00
|
|
|
Kernel::SpinLockGuard _(Debug::s_debug_lock); \
|
2024-02-05 01:24:09 +02:00
|
|
|
Debug::print_prefix(__FILE__, __LINE__); \
|
2023-08-04 10:22:20 +03:00
|
|
|
BAN::Formatter::print(Debug::putchar, __VA_ARGS__); \
|
|
|
|
BAN::Formatter::print(Debug::putchar, "\r\n"); \
|
2023-01-25 21:39:03 +02:00
|
|
|
} while(false)
|
|
|
|
|
2023-04-22 17:58:51 +03:00
|
|
|
#define dwarnln(...) \
|
|
|
|
do { \
|
2024-02-28 22:39:02 +02:00
|
|
|
Kernel::SpinLockGuard _(Debug::s_debug_lock); \
|
2023-01-25 21:39:03 +02:00
|
|
|
BAN::Formatter::print(Debug::putchar, "\e[33m"); \
|
2023-04-22 17:58:51 +03:00
|
|
|
dprintln(__VA_ARGS__); \
|
2023-01-25 21:39:03 +02:00
|
|
|
BAN::Formatter::print(Debug::putchar, "\e[m"); \
|
|
|
|
} while(false)
|
|
|
|
|
2023-04-22 17:58:51 +03:00
|
|
|
#define derrorln(...) \
|
|
|
|
do { \
|
2024-02-28 22:39:02 +02:00
|
|
|
Kernel::SpinLockGuard _(Debug::s_debug_lock); \
|
2023-01-25 21:39:03 +02:00
|
|
|
BAN::Formatter::print(Debug::putchar, "\e[31m"); \
|
2023-04-22 17:58:51 +03:00
|
|
|
dprintln(__VA_ARGS__); \
|
2023-01-25 21:39:03 +02:00
|
|
|
BAN::Formatter::print(Debug::putchar, "\e[m"); \
|
|
|
|
} while(false)
|
|
|
|
|
2023-09-20 19:55:27 +03:00
|
|
|
#define dprintln_if(cond, ...) \
|
|
|
|
do { \
|
|
|
|
if constexpr(cond) \
|
|
|
|
dprintln(__VA_ARGS__); \
|
|
|
|
} while(false)
|
|
|
|
|
|
|
|
#define dwarnln_if(cond, ...) \
|
|
|
|
do { \
|
|
|
|
if constexpr(cond) \
|
|
|
|
dwarnln(__VA_ARGS__); \
|
|
|
|
} while(false)
|
|
|
|
|
|
|
|
#define derrorln_if(cond, ...) \
|
|
|
|
do { \
|
|
|
|
if constexpr(cond) \
|
|
|
|
derrorln(__VA_ARGS__); \
|
|
|
|
} while(false)
|
|
|
|
|
2023-01-25 21:39:03 +02:00
|
|
|
#define BOCHS_BREAK() asm volatile("xchgw %bx, %bx")
|
|
|
|
|
2024-12-09 03:35:51 +02:00
|
|
|
#define DEBUG_VTTY 1
|
2024-09-20 11:00:07 +03:00
|
|
|
|
|
|
|
#define DEBUG_PCI 0
|
|
|
|
#define DEBUG_SCHEDULER 0
|
|
|
|
#define DEBUG_PS2 1
|
|
|
|
|
|
|
|
#define DEBUG_ARP 0
|
|
|
|
#define DEBUG_IPV4 0
|
|
|
|
#define DEBUG_ETHERTYPE 0
|
|
|
|
#define DEBUG_TCP 0
|
|
|
|
#define DEBUG_E1000 0
|
|
|
|
|
|
|
|
#define DEBUG_DISK_SYNC 0
|
|
|
|
#define DEBUG_NVMe 0
|
|
|
|
|
|
|
|
#define DEBUG_XHCI 0
|
|
|
|
#define DEBUG_USB 0
|
|
|
|
#define DEBUG_USB_HID 0
|
|
|
|
#define DEBUG_USB_KEYBOARD 0
|
|
|
|
#define DEBUG_USB_MOUSE 0
|
2024-11-21 18:08:37 +02:00
|
|
|
#define DEBUG_USB_MASS_STORAGE 0
|
2024-09-20 11:00:07 +03:00
|
|
|
|
|
|
|
|
2023-01-25 21:39:03 +02:00
|
|
|
namespace Debug
|
|
|
|
{
|
2023-02-01 21:05:44 +02:00
|
|
|
void dump_stack_trace();
|
2023-01-25 21:39:03 +02:00
|
|
|
void putchar(char);
|
2023-08-04 10:22:20 +03:00
|
|
|
void print_prefix(const char*, int);
|
2023-04-22 17:58:51 +03:00
|
|
|
|
2024-02-28 22:39:02 +02:00
|
|
|
extern Kernel::RecursiveSpinLock s_debug_lock;
|
2024-01-24 14:43:46 +02:00
|
|
|
}
|