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