1 /*++
2 
3 Copyright (c) Microsoft Corporation
4 
5 ModuleName:
6 
7     MxLock.h
8 
9 Abstract:
10 
11     Mode agnostic definition of lock
12 
13     See MxLockKm.h and MxLockUm.h for mode
14     specific implementations
15 
16 Author:
17 
18 
19 
20 Revision History:
21 
22 
23 
24 --*/
25 
26 #pragma once
27 
28 //
29 // MxLockNoDynam has no c'tor/d'tor
30 // so as to be usable in global structs in km
31 //
32 // MxLock dervies from it and adds c'tor/d'tor
33 //
34 class MxLockNoDynam
35 {
36 
37 DECLARE_DBGFLAG_INITIALIZED;
38 
39 protected:
40     MdLock m_Lock;
41 public:
42     MdLock &
43     Get(
44         )
45     {
46         return m_Lock;
47     }
48 
49     __inline
50     VOID
51     Initialize(
52         );
53 
54     _Acquires_lock_(this->m_Lock)
55     __drv_maxIRQL(DISPATCH_LEVEL)
56     __drv_setsIRQL(DISPATCH_LEVEL)
57     __inline
58     VOID
59     Acquire(
60         __out __drv_deref(__drv_savesIRQL) KIRQL * OldIrql
61         );
62 
63 #if ((FX_CORE_MODE)==(FX_CORE_USER_MODE))
64 
65     CHECK_RETURN_IF_USER_MODE
66     __inline
67     BOOLEAN
68     TryToAcquire(
69         VOID
70         );
71 #endif
72 
73     _Acquires_lock_(this->m_Lock)
74     __drv_requiresIRQL(DISPATCH_LEVEL)
75     __inline
76     VOID
77     AcquireAtDpcLevel(
78         );
79 
80     _Releases_lock_(this->m_Lock)
81     __drv_requiresIRQL(DISPATCH_LEVEL)
82     __inline
83     VOID
84     Release(
85         __drv_restoresIRQL KIRQL NewIrql
86         );
87 
88     _Releases_lock_(this->m_Lock)
89     __drv_requiresIRQL(DISPATCH_LEVEL)
90     __inline
91     VOID
92     ReleaseFromDpcLevel(
93         );
94 
95     __inline
96     VOID
97     Uninitialize(
98         );
99 };
100 
101 class MxLock : public MxLockNoDynam
102 {
103 public:
104     __inline
105     MxLock();
106 
107     __inline
108     ~MxLock();
109 };
110