ReactOS  0.4.15-dev-3163-gf17c2c0
fxcallbackspinlock.hpp
Go to the documentation of this file.
1 /*++
2 
3 Copyright (c) Microsoft Corporation
4 
5 Module Name:
6 
7  FxCallbackSpinLock.hpp
8 
9 Abstract:
10 
11  This is the C++ header for the FxCallbackSpinLock
12 
13  This is the spinlock based driver callback lock
14 
15 
16 Author:
17 
18 
19 
20 
21 Revision History:
22 
23 
24 --*/
25 
26 #ifndef _FXCALLBACKSPINLOCK_H_
27 #define _FXCALLBACKSPINLOCK_H_
28 
29 extern "C" {
30 
31 #if defined(EVENT_TRACING)
32 #include "FxCallbackSpinLock.hpp.tmh"
33 #endif
34 
35 }
36 
38 
39 private:
41 
42 public:
43 
45  PFX_DRIVER_GLOBALS FxDriverGlobals
46  ) :
47  FxCallbackLock(FxDriverGlobals)
48  {
49  }
50 
51  virtual
53  VOID
54  )
55  {
56  if (m_Verifier) {
57  delete m_Verifier;
58  }
59  }
60 
61  virtual
62  void
64  FxObject* ParentObject
65  )
66  {
68 
69  m_Verifier = NULL;
71 
73 
74  //
75  // VerifierLock CreateAndInitialize failure is not fatal,
76  // we just won't track anything
77  //
80  ParentObject,
81  FALSE);
82 
83  }
84  }
85 
86  virtual
87  void
89  __out PKIRQL PreviousIrql
90  )
91  {
93 
94  if (m_OwnerThread == cur) {
96 
99 
100  //
101  // For now we have decided not to allow this.
102  //
103 
104 
105 
106 
107 
108  //
110  "Recursive acquire of callback lock! 0x%p", this);
111 
114  (ULONG_PTR) this);
115  return;
116  }
117  else {
118  if (m_Verifier != NULL) {
119  m_Verifier->Lock(PreviousIrql, FALSE);
120  }
121  else {
122  m_Lock.Acquire(PreviousIrql);
123  }
124 
125  m_OwnerThread = cur;
126  return;
127  }
128  }
129 
130  virtual
131  void
133  __in KIRQL PreviousIrql
134  )
135  {
136  CheckOwnership();
137 
138  if (m_RecursionCount > 0) {
140  }
141  else {
143  if (m_Verifier != NULL) {
144  m_Verifier->Unlock(PreviousIrql, FALSE);
145  }
146  else {
147  m_Lock.Release(PreviousIrql);
148  }
149  }
150  }
151 
153  inline
154  virtual
155  BOOLEAN
157  VOID
158  )
159  {
161 
162  if (m_OwnerThread == cur) {
163  return TRUE;
164  }
165  else {
166  return FALSE;
167  }
168  }
169 };
170 
171 #endif // _FXCALLBACKSPINLOCK_H_
virtual ~FxCallbackSpinLock(VOID)
virtual void Unlock(__in KIRQL PreviousIrql)
FxCallbackSpinLock(PFX_DRIVER_GLOBALS FxDriverGlobals)
struct png_info_def **typedef void(__cdecl typeof(png_destroy_read_struct))(struct png_struct_def **
Definition: typeof.h:49
MxThread m_OwnerThread
#define TRUE
Definition: types.h:120
VOID Unlock(__in KIRQL PreviousIrql, __in BOOLEAN AtDpc)
virtual void Lock(__out PKIRQL PreviousIrql)
#define FxVerifierBugCheck(FxDriverGlobals, Error,...)
Definition: fxverifier.h:58
uint32_t ULONG_PTR
Definition: typedefs.h:65
UCHAR KIRQL
Definition: env_spec_w32.h:591
#define FALSE
Definition: types.h:117
#define TRACE_LEVEL_FATAL
Definition: storswtr.h:26
VOID Lock(__out PKIRQL PreviousIrql, __in BOOLEAN AtDpc)
#define __out
Definition: dbghelp.h:62
unsigned char BOOLEAN
BOOLEAN FxVerifierLock
Definition: fxglobals.h:451
virtual void Initialize(FxObject *ParentObject)
#define TRACINGDEVICE
Definition: dbgtrace.h:58
FxVerifierLock * m_Verifier
KIRQL * PKIRQL
Definition: env_spec_w32.h:592
#define _Must_inspect_result_
Definition: ms_sal.h:558
Definition: mxlock.h:101
FxCollectionEntry * cur
virtual _Must_inspect_result_ BOOLEAN IsOwner(VOID)
static __inline MxThread MxGetCurrentThread()
Definition: mxgeneralkm.h:61
VOID CheckOwnership(VOID)
PFX_DRIVER_GLOBALS fxDriverGlobals
DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_VERBOSE, TRACINGPNP, "Enter, WDFDEVICE %p", Device)
#define NULL
Definition: types.h:112
_Must_inspect_result_ static __inline NTSTATUS CreateAndInitialize(__out FxVerifierLock **VerifierLock, __in PFX_DRIVER_GLOBALS FxDriverGlobals, __in FxObject *ParentObject, __in BOOLEAN UseMutex)
#define __in
Definition: dbghelp.h:35
PFX_DRIVER_GLOBALS GetDriverGlobals(VOID)
Definition: fxstump.hpp:98