xref: /reactos/drivers/network/dd/dc21x4/debug.h (revision 4514e91d)
1 /*
2  * PROJECT:     ReactOS DC21x4 Driver
3  * LICENSE:     GPL-2.0-or-later (https://spdx.org/licenses/GPL-2.0-or-later)
4  * PURPOSE:     Debug support header file
5  * COPYRIGHT:   Copyright 2023 Dmitry Borisov <di.sean@protonmail.com>
6  */
7 
8 #pragma once
9 
10 #ifndef __RELFILE__
11 #define __RELFILE__ __FILE__
12 #endif
13 
14 #if DBG
15 
16 // #define DEBUG_TRACE
17 // #define DEBUG_INFO
18 #define DEBUG_INFO_VERB
19 #define DEBUG_WARN
20 #define DEBUG_ERR
21 
22 #ifdef DEBUG_TRACE
23 #define TRACE(fmt, ...) \
24     do { \
25       if (DbgPrint("(%s:%d) %s " fmt, __RELFILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__)) \
26           DbgPrint("(%s:%d) DbgPrint() failed!\n", __RELFILE__, __LINE__); \
27     } while (0)
28 
29 #else
30 #define TRACE
31 #endif
32 
33 #ifdef DEBUG_INFO
34 #define INFO(fmt, ...) \
35     do { \
36       if (DbgPrint("(%s:%d) %s " fmt, __RELFILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__)) \
37           DbgPrint("(%s:%d) DbgPrint() failed!\n", __RELFILE__, __LINE__); \
38     } while (0)
39 
40 #else
41 #define INFO
42 #endif
43 
44 #ifdef DEBUG_INFO_VERB
45 #define INFO_VERB(fmt, ...) \
46     do { \
47       if (DbgPrint("(%s:%d) %s " fmt, __RELFILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__)) \
48           DbgPrint("(%s:%d) DbgPrint() failed!\n", __RELFILE__, __LINE__); \
49     } while (0)
50 
51 #else
52 #define INFO_VERB
53 #endif
54 
55 #ifdef DEBUG_WARN
56 #define WARN(fmt, ...) \
57     do { \
58       if (DbgPrint("(%s:%d) %s " fmt, __RELFILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__)) \
59           DbgPrint("(%s:%d) DbgPrint() failed!\n", __RELFILE__, __LINE__); \
60     } while (0)
61 
62 #else
63 #define WARN
64 #endif
65 
66 #ifdef DEBUG_ERR
67 #define ERR(fmt, ...) \
68     do { \
69       if (DbgPrint("(%s:%d) %s " fmt, __RELFILE__, __LINE__, __FUNCTION__, ##__VA_ARGS__)) \
70           DbgPrint("(%s:%d) DbgPrint() failed!\n", __RELFILE__, __LINE__); \
71     } while (0)
72 
73 #else
74 #define ERR
75 #endif
76 
77 PCSTR
78 MediaNumber2Str(
79     _In_ PDC21X4_ADAPTER Adapter,
80     _In_ ULONG MediaNumber);
81 
82 PCSTR
83 DcDbgBusError(
84     _In_ ULONG InterruptStatus);
85 
86 #else
87 
88 #define TRACE
89 #define INFO
90 #define INFO_VERB
91 #define WARN
92 #define ERR
93 #define MediaNumber2Str
94 #define DcDbgBusError
95 
96 #endif
97