1*bf1b3cb1SVictor Perevertkin /*++ 2*bf1b3cb1SVictor Perevertkin 3*bf1b3cb1SVictor Perevertkin Copyright (C) Microsoft Corporation, 1991 - 1999 4*bf1b3cb1SVictor Perevertkin 5*bf1b3cb1SVictor Perevertkin Module Name: 6*bf1b3cb1SVictor Perevertkin 7*bf1b3cb1SVictor Perevertkin debug.h 8*bf1b3cb1SVictor Perevertkin 9*bf1b3cb1SVictor Perevertkin Abstract: 10*bf1b3cb1SVictor Perevertkin 11*bf1b3cb1SVictor Perevertkin 12*bf1b3cb1SVictor Perevertkin Author: 13*bf1b3cb1SVictor Perevertkin 14*bf1b3cb1SVictor Perevertkin Environment: 15*bf1b3cb1SVictor Perevertkin 16*bf1b3cb1SVictor Perevertkin kernel mode only 17*bf1b3cb1SVictor Perevertkin 18*bf1b3cb1SVictor Perevertkin Notes: 19*bf1b3cb1SVictor Perevertkin 20*bf1b3cb1SVictor Perevertkin 21*bf1b3cb1SVictor Perevertkin Revision History: 22*bf1b3cb1SVictor Perevertkin 23*bf1b3cb1SVictor Perevertkin --*/ 24*bf1b3cb1SVictor Perevertkin 25*bf1b3cb1SVictor Perevertkin #define DBGGETIOCTLSTR(_ioctl) DbgGetIoctlStr(_ioctl) 26*bf1b3cb1SVictor Perevertkin #define DBGGETSCSIOPSTR(_pSrb) DbgGetScsiOpStr(_pSrb) 27*bf1b3cb1SVictor Perevertkin #define DBGGETSRBSTATUSSTR(_pSrb) DbgGetSrbStatusStr(_pSrb) 28*bf1b3cb1SVictor Perevertkin #define DBGGETSENSECODESTR(_pSrb) DbgGetSenseCodeStr(_pSrb) 29*bf1b3cb1SVictor Perevertkin #define DBGGETADSENSECODESTR(_pSrb) DbgGetAdditionalSenseCodeStr(_pSrb) 30*bf1b3cb1SVictor Perevertkin #define DBGGETADSENSEQUALIFIERSTR(_pSrb) DbgGetAdditionalSenseCodeQualifierStr(_pSrb) 31*bf1b3cb1SVictor Perevertkin 32*bf1b3cb1SVictor Perevertkin char *DbgGetIoctlStr(ULONG ioctl); 33*bf1b3cb1SVictor Perevertkin char *DbgGetScsiOpStr(PSTORAGE_REQUEST_BLOCK_HEADER Srb); 34*bf1b3cb1SVictor Perevertkin char *DbgGetSrbStatusStr(PSTORAGE_REQUEST_BLOCK_HEADER Srb); 35*bf1b3cb1SVictor Perevertkin char *DbgGetSenseCodeStr(PSTORAGE_REQUEST_BLOCK_HEADER Srb); 36*bf1b3cb1SVictor Perevertkin char *DbgGetAdditionalSenseCodeStr(PSTORAGE_REQUEST_BLOCK_HEADER Srb); 37*bf1b3cb1SVictor Perevertkin char *DbgGetAdditionalSenseCodeQualifierStr(PSTORAGE_REQUEST_BLOCK_HEADER Srb); 38*bf1b3cb1SVictor Perevertkin 39*bf1b3cb1SVictor Perevertkin #if DBG 40*bf1b3cb1SVictor Perevertkin 41*bf1b3cb1SVictor Perevertkin typedef struct _CLASSPNP_GLOBALS { 42*bf1b3cb1SVictor Perevertkin 43*bf1b3cb1SVictor Perevertkin // 44*bf1b3cb1SVictor Perevertkin // whether or not to NT_ASSERT for lost irps 45*bf1b3cb1SVictor Perevertkin // 46*bf1b3cb1SVictor Perevertkin 47*bf1b3cb1SVictor Perevertkin ULONG BreakOnLostIrps; 48*bf1b3cb1SVictor Perevertkin ULONG SecondsToWaitForIrps; 49*bf1b3cb1SVictor Perevertkin 50*bf1b3cb1SVictor Perevertkin // 51*bf1b3cb1SVictor Perevertkin // use a buffered debug print to help 52*bf1b3cb1SVictor Perevertkin // catch timing issues that do not 53*bf1b3cb1SVictor Perevertkin // reproduce with std debugprints enabled 54*bf1b3cb1SVictor Perevertkin // 55*bf1b3cb1SVictor Perevertkin 56*bf1b3cb1SVictor Perevertkin ULONG UseBufferedDebugPrint; 57*bf1b3cb1SVictor Perevertkin ULONG UseDelayedRetry; 58*bf1b3cb1SVictor Perevertkin 59*bf1b3cb1SVictor Perevertkin // 60*bf1b3cb1SVictor Perevertkin // the next four are the buffered printing support 61*bf1b3cb1SVictor Perevertkin // (currently unimplemented) and require the spinlock 62*bf1b3cb1SVictor Perevertkin // to use 63*bf1b3cb1SVictor Perevertkin // 64*bf1b3cb1SVictor Perevertkin 65*bf1b3cb1SVictor Perevertkin ULONG Index; // index into buffer 66*bf1b3cb1SVictor Perevertkin KSPIN_LOCK SpinLock; 67*bf1b3cb1SVictor Perevertkin PUCHAR Buffer; // requires spinlock to access 68*bf1b3cb1SVictor Perevertkin ULONG NumberOfBuffers; // number of buffers available 69*bf1b3cb1SVictor Perevertkin SIZE_T EachBufferSize; // size of each buffer 70*bf1b3cb1SVictor Perevertkin 71*bf1b3cb1SVictor Perevertkin // 72*bf1b3cb1SVictor Perevertkin // interlocked variables to initialize 73*bf1b3cb1SVictor Perevertkin // this data only once 74*bf1b3cb1SVictor Perevertkin // 75*bf1b3cb1SVictor Perevertkin 76*bf1b3cb1SVictor Perevertkin LONG Initializing; 77*bf1b3cb1SVictor Perevertkin LONG Initialized; 78*bf1b3cb1SVictor Perevertkin 79*bf1b3cb1SVictor Perevertkin } CLASSPNP_GLOBALS, *PCLASSPNP_GLOBALS; 80*bf1b3cb1SVictor Perevertkin 81*bf1b3cb1SVictor Perevertkin 82*bf1b3cb1SVictor Perevertkin // 83*bf1b3cb1SVictor Perevertkin // Define a structure used to capture stack traces when we 84*bf1b3cb1SVictor Perevertkin // get an access request and the disks are powered off. This 85*bf1b3cb1SVictor Perevertkin // will help us determine who's causing disk respins. 86*bf1b3cb1SVictor Perevertkin // 87*bf1b3cb1SVictor Perevertkin 88*bf1b3cb1SVictor Perevertkin // 89*bf1b3cb1SVictor Perevertkin // How many stack frames to capture each time? 90*bf1b3cb1SVictor Perevertkin // 91*bf1b3cb1SVictor Perevertkin #define DISK_SPINUP_BACKTRACE_LENGTH (0x18) 92*bf1b3cb1SVictor Perevertkin 93*bf1b3cb1SVictor Perevertkin // 94*bf1b3cb1SVictor Perevertkin // How many stack traces can we capture before 95*bf1b3cb1SVictor Perevertkin // out buffer wraps? (needs to be power of 2) 96*bf1b3cb1SVictor Perevertkin // 97*bf1b3cb1SVictor Perevertkin #define NUMBER_OF_DISK_SPINUP_TRACES (0x10) 98*bf1b3cb1SVictor Perevertkin 99*bf1b3cb1SVictor Perevertkin typedef struct _DISK_SPINUP_TRACES { 100*bf1b3cb1SVictor Perevertkin 101*bf1b3cb1SVictor Perevertkin LARGE_INTEGER TimeStamp; // timestamp of the spinup event. 102*bf1b3cb1SVictor Perevertkin PVOID StackTrace[DISK_SPINUP_BACKTRACE_LENGTH]; // Holds stack trace 103*bf1b3cb1SVictor Perevertkin } DISK_SPINUP_TRACES, *PDISK_SPINUP_TRACES; 104*bf1b3cb1SVictor Perevertkin 105*bf1b3cb1SVictor Perevertkin 106*bf1b3cb1SVictor Perevertkin #define DBGCHECKRETURNEDPKT(_pkt) DbgCheckReturnedPkt(_pkt) 107*bf1b3cb1SVictor Perevertkin #define DBGLOGSENDPACKET(_pkt) DbgLogSendPacket(_pkt) 108*bf1b3cb1SVictor Perevertkin #define DBGLOGRETURNPACKET(_pkt) DbgLogReturnPacket(_pkt) 109*bf1b3cb1SVictor Perevertkin #define DBGLOGFLUSHINFO(_fdoData, _isIO, _isFUA, _isFlush) DbgLogFlushInfo(_fdoData, _isIO, _isFUA, _isFlush) 110*bf1b3cb1SVictor Perevertkin 111*bf1b3cb1SVictor Perevertkin VOID ClasspInitializeDebugGlobals(); 112*bf1b3cb1SVictor Perevertkin VOID DbgCheckReturnedPkt(TRANSFER_PACKET *Pkt); 113*bf1b3cb1SVictor Perevertkin VOID DbgLogSendPacket(TRANSFER_PACKET *Pkt); 114*bf1b3cb1SVictor Perevertkin VOID DbgLogReturnPacket(TRANSFER_PACKET *Pkt); 115*bf1b3cb1SVictor Perevertkin VOID DbgLogFlushInfo(PCLASS_PRIVATE_FDO_DATA FdoData, BOOLEAN IsIO, BOOLEAN IsFUA, BOOLEAN IsFlush); 116*bf1b3cb1SVictor Perevertkin VOID SnapDiskStartup(VOID); 117*bf1b3cb1SVictor Perevertkin extern CLASSPNP_GLOBALS ClasspnpGlobals; 118*bf1b3cb1SVictor Perevertkin extern LONG ClassDebug; 119*bf1b3cb1SVictor Perevertkin extern BOOLEAN DebugTrapOnWarn; 120*bf1b3cb1SVictor Perevertkin 121*bf1b3cb1SVictor Perevertkin #else 122*bf1b3cb1SVictor Perevertkin 123*bf1b3cb1SVictor Perevertkin #define ClasspInitializeDebugGlobals() 124*bf1b3cb1SVictor Perevertkin #define SnapDiskStartup() 125*bf1b3cb1SVictor Perevertkin 126*bf1b3cb1SVictor Perevertkin #define DBGCHECKRETURNEDPKT(_pkt) 127*bf1b3cb1SVictor Perevertkin #define DBGLOGSENDPACKET(_pkt) 128*bf1b3cb1SVictor Perevertkin #define DBGLOGRETURNPACKET(_pkt) 129*bf1b3cb1SVictor Perevertkin #define DBGLOGFLUSHINFO(_fdoData, _isIO, _isFUA, _isFlush) 130*bf1b3cb1SVictor Perevertkin 131*bf1b3cb1SVictor Perevertkin #endif 132*bf1b3cb1SVictor Perevertkin 133