summaryrefslogtreecommitdiff
path: root/storage/class/classpnp/src/debug.h
blob: bd2e04ba11de4133ddd7036867939414b9333541 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
/*++

Copyright (C) Microsoft Corporation, 1991 - 1999

Module Name:

    debug.h

Abstract:


Author:

Environment:

    kernel mode only

Notes:


Revision History:

--*/

#define DBGGETIOCTLSTR(_ioctl)              DbgGetIoctlStr(_ioctl)
#define DBGGETSCSIOPSTR(_pSrb)              DbgGetScsiOpStr(_pSrb)
#define DBGGETSRBSTATUSSTR(_pSrb)           DbgGetSrbStatusStr(_pSrb)
#define DBGGETSENSECODESTR(_pSrb)           DbgGetSenseCodeStr(_pSrb)
#define DBGGETADSENSECODESTR(_pSrb)         DbgGetAdditionalSenseCodeStr(_pSrb)
#define DBGGETADSENSEQUALIFIERSTR(_pSrb)    DbgGetAdditionalSenseCodeQualifierStr(_pSrb)

char *DbgGetIoctlStr(ULONG ioctl);
char *DbgGetScsiOpStr(PSTORAGE_REQUEST_BLOCK_HEADER Srb);
char *DbgGetSrbStatusStr(PSTORAGE_REQUEST_BLOCK_HEADER Srb);
char *DbgGetSenseCodeStr(PSTORAGE_REQUEST_BLOCK_HEADER Srb);
char *DbgGetAdditionalSenseCodeStr(PSTORAGE_REQUEST_BLOCK_HEADER Srb);
char *DbgGetAdditionalSenseCodeQualifierStr(PSTORAGE_REQUEST_BLOCK_HEADER Srb);

#if DBG

    typedef struct _CLASSPNP_GLOBALS {

        //
        // whether or not to NT_ASSERT for lost irps
        //

        ULONG BreakOnLostIrps;
        ULONG SecondsToWaitForIrps;

        //
        // use a buffered debug print to help
        // catch timing issues that do not
        // reproduce with std debugprints enabled
        //

        ULONG UseBufferedDebugPrint;
        ULONG UseDelayedRetry;

        //
        // the next four are the buffered printing support
        // (currently unimplemented) and require the spinlock
        // to use
        //

        ULONG Index;                // index into buffer
        KSPIN_LOCK SpinLock;
        PUCHAR Buffer;              // requires spinlock to access
        ULONG NumberOfBuffers;      // number of buffers available
        SIZE_T EachBufferSize;      // size of each buffer

        //
        // interlocked variables to initialize
        // this data only once
        //

        LONG Initializing;
        LONG Initialized;

    } CLASSPNP_GLOBALS, *PCLASSPNP_GLOBALS;


    //
    // Define a structure used to capture stack traces when we
    // get an access request and the disks are powered off.  This
    // will help us determine who's causing disk respins.
    //

    //
    // How many stack frames to capture each time?
    //
    #define DISK_SPINUP_BACKTRACE_LENGTH    (0x18)

    //
    // How many stack traces can we capture before
    // out buffer wraps? (needs to be power of 2)
    //
    #define NUMBER_OF_DISK_SPINUP_TRACES    (0x10)

    typedef struct _DISK_SPINUP_TRACES {

        LARGE_INTEGER   TimeStamp;  // timestamp of the spinup event.
        PVOID   StackTrace[DISK_SPINUP_BACKTRACE_LENGTH]; // Holds stack trace
    } DISK_SPINUP_TRACES, *PDISK_SPINUP_TRACES;


    #define DBGCHECKRETURNEDPKT(_pkt) DbgCheckReturnedPkt(_pkt)
    #define DBGLOGSENDPACKET(_pkt) DbgLogSendPacket(_pkt)
    #define DBGLOGRETURNPACKET(_pkt) DbgLogReturnPacket(_pkt)
    #define DBGLOGFLUSHINFO(_fdoData, _isIO, _isFUA, _isFlush) DbgLogFlushInfo(_fdoData, _isIO, _isFUA, _isFlush)

    VOID ClasspInitializeDebugGlobals();
    VOID DbgCheckReturnedPkt(TRANSFER_PACKET *Pkt);
    VOID DbgLogSendPacket(TRANSFER_PACKET *Pkt);
    VOID DbgLogReturnPacket(TRANSFER_PACKET *Pkt);
    VOID DbgLogFlushInfo(PCLASS_PRIVATE_FDO_DATA FdoData, BOOLEAN IsIO, BOOLEAN IsFUA, BOOLEAN IsFlush);
    VOID SnapDiskStartup(VOID);
    extern CLASSPNP_GLOBALS ClasspnpGlobals;
    extern LONG ClassDebug;
    extern BOOLEAN DebugTrapOnWarn;

#else

    #define ClasspInitializeDebugGlobals()
    #define SnapDiskStartup()

    #define DBGCHECKRETURNEDPKT(_pkt)
    #define DBGLOGSENDPACKET(_pkt)
    #define DBGLOGRETURNPACKET(_pkt)
    #define DBGLOGFLUSHINFO(_fdoData, _isIO, _isFUA, _isFlush)

#endif