1 /*++
2 
3 Copyright (c) Microsoft Corporation
4 
5 ModuleName:
6 
7     MxLockKm.h
8 
9 Abstract:
10 
11     Kernel mode implementation of lock
12     class defined in MxLock.h
13 
14 Author:
15 
16 
17 
18 Revision History:
19 
20 
21 
22 --*/
23 
24 #pragma once
25 
26 #include "dbgmacros.h"
27 
28 typedef KSPIN_LOCK MdLock;
29 
30 #include "mxlock.h"
31 
32 __inline
33 MxLock::MxLock(
34     )
35 {
36     CLEAR_DBGFLAG_INITIALIZED;
37 
38     MxLock::Initialize();
39 }
40 
41 __inline
42 VOID
43 MxLockNoDynam::Initialize(
44     )
45 {
46     KeInitializeSpinLock(&m_Lock);
47 
48     SET_DBGFLAG_INITIALIZED;
49 }
50 
51 _Acquires_lock_(this->m_Lock)
52 __drv_maxIRQL(DISPATCH_LEVEL)
53 __drv_setsIRQL(DISPATCH_LEVEL)
54 __inline
55 VOID
56 MxLockNoDynam::Acquire(
57     __out __drv_deref(__drv_savesIRQL) KIRQL * OldIrql
58     )
59 {
60     ASSERT_DBGFLAG_INITIALIZED;
61 
62     KeAcquireSpinLock(&m_Lock, OldIrql);
63 }
64 
65 _Acquires_lock_(this->m_Lock)
66 __drv_requiresIRQL(DISPATCH_LEVEL)
67 __inline
68 VOID
69 MxLockNoDynam::AcquireAtDpcLevel(
70     )
71 {
72     ASSERT_DBGFLAG_INITIALIZED;
73 
74     KeAcquireSpinLockAtDpcLevel(&m_Lock);
75 }
76 
77 _Releases_lock_(this->m_Lock)
78 __drv_requiresIRQL(DISPATCH_LEVEL)
79 __inline
80 VOID
81 MxLockNoDynam::Release(
82     __drv_restoresIRQL KIRQL NewIrql
83     )
84 {
85     ASSERT_DBGFLAG_INITIALIZED;
86 
87     KeReleaseSpinLock(&m_Lock, NewIrql);
88 }
89 
90 _Releases_lock_(this->m_Lock)
91 __drv_requiresIRQL(DISPATCH_LEVEL)
92 __inline
93 VOID
94 MxLockNoDynam::ReleaseFromDpcLevel(
95     )
96 {
97     ASSERT_DBGFLAG_INITIALIZED;
98 
99     KeReleaseSpinLockFromDpcLevel(&m_Lock);
100 }
101 
102 __inline
103 VOID
104 MxLockNoDynam::Uninitialize(
105     )
106 {
107     CLEAR_DBGFLAG_INITIALIZED;
108 }
109 
110 __inline
111 MxLock::~MxLock(
112     )
113 {
114     CLEAR_DBGFLAG_INITIALIZED;
115 }
116