1*8a978a17SVictor Perevertkin /*++ 2*8a978a17SVictor Perevertkin 3*8a978a17SVictor Perevertkin Copyright (c) Microsoft Corporation 4*8a978a17SVictor Perevertkin 5*8a978a17SVictor Perevertkin ModuleName: 6*8a978a17SVictor Perevertkin 7*8a978a17SVictor Perevertkin MxPagedLock.h 8*8a978a17SVictor Perevertkin 9*8a978a17SVictor Perevertkin Abstract: 10*8a978a17SVictor Perevertkin 11*8a978a17SVictor Perevertkin Mode agnostic definition of paged lock 12*8a978a17SVictor Perevertkin 13*8a978a17SVictor Perevertkin See MxPagedLockKm.h and MxPagedLockUm.h for mode 14*8a978a17SVictor Perevertkin specific implementations 15*8a978a17SVictor Perevertkin 16*8a978a17SVictor Perevertkin Author: 17*8a978a17SVictor Perevertkin 18*8a978a17SVictor Perevertkin 19*8a978a17SVictor Perevertkin 20*8a978a17SVictor Perevertkin Revision History: 21*8a978a17SVictor Perevertkin 22*8a978a17SVictor Perevertkin 23*8a978a17SVictor Perevertkin 24*8a978a17SVictor Perevertkin --*/ 25*8a978a17SVictor Perevertkin 26*8a978a17SVictor Perevertkin #pragma once 27*8a978a17SVictor Perevertkin 28*8a978a17SVictor Perevertkin // 29*8a978a17SVictor Perevertkin // MxPagedLockNoDynam has no c'tor/d'tor 30*8a978a17SVictor Perevertkin // so as to be usable in global structs in km 31*8a978a17SVictor Perevertkin // 32*8a978a17SVictor Perevertkin // MxPagedLock dervies from it and adds c'tor/d'tor 33*8a978a17SVictor Perevertkin // 34*8a978a17SVictor Perevertkin class MxPagedLockNoDynam 35*8a978a17SVictor Perevertkin { 36*8a978a17SVictor Perevertkin 37*8a978a17SVictor Perevertkin DECLARE_DBGFLAG_INITIALIZED; 38*8a978a17SVictor Perevertkin 39*8a978a17SVictor Perevertkin protected: 40*8a978a17SVictor Perevertkin MdPagedLock m_Lock; 41*8a978a17SVictor Perevertkin public: 42*8a978a17SVictor Perevertkin _Must_inspect_result_ 43*8a978a17SVictor Perevertkin __inline 44*8a978a17SVictor Perevertkin NTSTATUS 45*8a978a17SVictor Perevertkin Initialize( 46*8a978a17SVictor Perevertkin ); 47*8a978a17SVictor Perevertkin 48*8a978a17SVictor Perevertkin __drv_maxIRQL(APC_LEVEL) 49*8a978a17SVictor Perevertkin __drv_setsIRQL(APC_LEVEL) 50*8a978a17SVictor Perevertkin __drv_savesIRQLGlobal(FastMutexObject, this->m_Lock) 51*8a978a17SVictor Perevertkin _Acquires_lock_(this->m_Lock) 52*8a978a17SVictor Perevertkin __inline 53*8a978a17SVictor Perevertkin VOID 54*8a978a17SVictor Perevertkin Acquire( 55*8a978a17SVictor Perevertkin ); 56*8a978a17SVictor Perevertkin 57*8a978a17SVictor Perevertkin 58*8a978a17SVictor Perevertkin __inline 59*8a978a17SVictor Perevertkin VOID 60*8a978a17SVictor Perevertkin AcquireUnsafe( 61*8a978a17SVictor Perevertkin ); 62*8a978a17SVictor Perevertkin 63*8a978a17SVictor Perevertkin _Must_inspect_result_ 64*8a978a17SVictor Perevertkin __drv_maxIRQL(APC_LEVEL) 65*8a978a17SVictor Perevertkin __drv_savesIRQLGlobal(FastMutexObject, this->m_Lock) 66*8a978a17SVictor Perevertkin __drv_valueIs(==1;==0) 67*8a978a17SVictor Perevertkin __drv_when(return==1, __drv_setsIRQL(APC_LEVEL)) 68*8a978a17SVictor Perevertkin _When_(return==1, _Acquires_lock_(this->m_Lock)) 69*8a978a17SVictor Perevertkin __inline 70*8a978a17SVictor Perevertkin BOOLEAN 71*8a978a17SVictor Perevertkin TryToAcquire( 72*8a978a17SVictor Perevertkin ); 73*8a978a17SVictor Perevertkin 74*8a978a17SVictor Perevertkin __drv_requiresIRQL(APC_LEVEL) 75*8a978a17SVictor Perevertkin __drv_restoresIRQLGlobal(FastMutexObject,this->m_Lock) 76*8a978a17SVictor Perevertkin _Releases_lock_(this->m_Lock) 77*8a978a17SVictor Perevertkin __inline 78*8a978a17SVictor Perevertkin VOID 79*8a978a17SVictor Perevertkin Release( 80*8a978a17SVictor Perevertkin ); 81*8a978a17SVictor Perevertkin 82*8a978a17SVictor Perevertkin 83*8a978a17SVictor Perevertkin __inline 84*8a978a17SVictor Perevertkin VOID 85*8a978a17SVictor Perevertkin ReleaseUnsafe( 86*8a978a17SVictor Perevertkin ); 87*8a978a17SVictor Perevertkin 88*8a978a17SVictor Perevertkin __inline 89*8a978a17SVictor Perevertkin VOID 90*8a978a17SVictor Perevertkin Uninitialize( 91*8a978a17SVictor Perevertkin ); 92*8a978a17SVictor Perevertkin }; 93*8a978a17SVictor Perevertkin 94*8a978a17SVictor Perevertkin class MxPagedLock : public MxPagedLockNoDynam 95*8a978a17SVictor Perevertkin { 96*8a978a17SVictor Perevertkin public: 97*8a978a17SVictor Perevertkin __inline 98*8a978a17SVictor Perevertkin MxPagedLock(); 99*8a978a17SVictor Perevertkin 100*8a978a17SVictor Perevertkin __inline 101*8a978a17SVictor Perevertkin ~MxPagedLock(); 102*8a978a17SVictor Perevertkin }; 103*8a978a17SVictor Perevertkin 104