Sync with trunk r58740.
[reactos.git] / drivers / storage / classpnp / debug.h
1 /*++
2
3 Copyright (C) Microsoft Corporation, 1991 - 1999
4
5 Module Name:
6
7 debug.h
8
9 Abstract:
10
11
12 Author:
13
14 Environment:
15
16 kernel mode only
17
18 Notes:
19
20
21 Revision History:
22
23 --*/
24
25
26 VOID ClassDebugPrint(CLASS_DEBUG_LEVEL DebugPrintLevel, PCCHAR DebugMessage, ...);
27
28 #if DBG
29
30 typedef struct _CLASSPNP_GLOBALS {
31
32 //
33 // whether or not to ASSERT for lost irps
34 //
35
36 ULONG BreakOnLostIrps;
37 ULONG SecondsToWaitForIrps;
38
39 //
40 // use a buffered debug print to help
41 // catch timing issues that do not
42 // reproduce with std debugprints enabled
43 //
44
45 ULONG UseBufferedDebugPrint;
46 ULONG UseDelayedRetry;
47
48 //
49 // the next four are the buffered printing support
50 // (currently unimplemented) and require the spinlock
51 // to use
52 //
53
54 ULONG Index; // index into buffer
55 KSPIN_LOCK SpinLock;
56 PUCHAR Buffer; // requires spinlock to access
57 ULONG NumberOfBuffers; // number of buffers available
58 SIZE_T EachBufferSize; // size of each buffer
59
60 //
61 // interlocked variables to initialize
62 // this data only once
63 //
64
65 LONG Initializing;
66 LONG Initialized;
67
68 } CLASSPNP_GLOBALS, *PCLASSPNP_GLOBALS;
69
70 #define DBGTRACE(dbgTraceLevel, args_in_parens) \
71 if (ClassDebug & (1 << (dbgTraceLevel+15))){ \
72 DbgPrint("CLASSPNP> *** TRACE *** (file %s, line %d)\n", __FILE__, __LINE__ ); \
73 DbgPrint(" > "); \
74 DbgPrint args_in_parens; \
75 DbgPrint("\n"); \
76 if (DebugTrapOnWarn && (dbgTraceLevel == ClassDebugWarning)){ \
77 DbgBreakPoint(); \
78 } \
79 }
80 #define DBGWARN(args_in_parens) \
81 { \
82 DbgPrint("CLASSPNP> *** WARNING *** (file %s, line %d)\n", __FILE__, __LINE__ ); \
83 DbgPrint(" > "); \
84 DbgPrint args_in_parens; \
85 DbgPrint("\n"); \
86 if (DebugTrapOnWarn){ \
87 DbgBreakPoint(); \
88 } \
89 }
90 #define DBGERR(args_in_parens) \
91 { \
92 DbgPrint("CLASSPNP> *** ERROR *** (file %s, line %d)\n", __FILE__, __LINE__ ); \
93 DbgPrint(" > "); \
94 DbgPrint args_in_parens; \
95 DbgPrint("\n"); \
96 DbgBreakPoint(); \
97 }
98 #define DBGTRAP(args_in_parens) \
99 { \
100 DbgPrint("CLASSPNP> *** COVERAGE TRAP *** (file %s, line %d)\n", __FILE__, __LINE__ ); \
101 DbgPrint(" > "); \
102 DbgPrint args_in_parens; \
103 DbgPrint("\n"); \
104 DbgBreakPoint(); \
105 }
106
107
108 #define DBGGETIOCTLSTR(_ioctl) DbgGetIoctlStr(_ioctl)
109 #define DBGGETSCSIOPSTR(_pSrb) DbgGetScsiOpStr(_pSrb)
110 #define DBGGETSENSECODESTR(_pSrb) DbgGetSenseCodeStr(_pSrb)
111 #define DBGGETADSENSECODESTR(_pSrb) DbgGetAdditionalSenseCodeStr(_pSrb)
112 #define DBGGETADSENSEQUALIFIERSTR(_pSrb) DbgGetAdditionalSenseCodeQualifierStr(_pSrb)
113 #define DBGCHECKRETURNEDPKT(_pkt) DbgCheckReturnedPkt(_pkt)
114 #define DBGGETSRBSTATUSSTR(_pSrb) DbgGetSrbStatusStr(_pSrb)
115
116 VOID ClasspInitializeDebugGlobals(VOID);
117 char *DbgGetIoctlStr(ULONG ioctl);
118 char *DbgGetScsiOpStr(PSCSI_REQUEST_BLOCK Srb);
119 char *DbgGetSenseCodeStr(PSCSI_REQUEST_BLOCK Srb);
120 char *DbgGetAdditionalSenseCodeStr(PSCSI_REQUEST_BLOCK Srb);
121 char *DbgGetAdditionalSenseCodeQualifierStr(PSCSI_REQUEST_BLOCK Srb);
122 VOID DbgCheckReturnedPkt(TRANSFER_PACKET *Pkt);
123 char *DbgGetSrbStatusStr(PSCSI_REQUEST_BLOCK Srb);
124
125
126 extern CLASSPNP_GLOBALS ClasspnpGlobals;
127 extern LONG ClassDebug;
128 extern BOOLEAN DebugTrapOnWarn;
129
130 #else
131
132 #define ClasspInitializeDebugGlobals()
133 #define DBGWARN(args_in_parens)
134 #define DBGERR(args_in_parens)
135 #define DBGTRACE(dbgTraceLevel, args_in_parens)
136 #define DBGTRAP(args_in_parens)
137
138 #define DBGGETIOCTLSTR(_ioctl)
139 #define DBGGETSCSIOPSTR(_pSrb)
140 #define DBGGETSENSECODESTR(_pSrb)
141 #define DBGGETADSENSECODESTR(_pSrb)
142 #define DBGGETADSENSEQUALIFIERSTR(_pSrb)
143 #define DBGCHECKRETURNEDPKT(_pkt)
144 #define DBGGETSRBSTATUSSTR(_pSrb)
145
146 #endif
147
148