18a978a17SVictor Perevertkin /*++ 28a978a17SVictor Perevertkin 38a978a17SVictor Perevertkin Copyright (c) Microsoft Corporation 48a978a17SVictor Perevertkin 58a978a17SVictor Perevertkin ModuleName: 68a978a17SVictor Perevertkin 78a978a17SVictor Perevertkin MxLockKm.h 88a978a17SVictor Perevertkin 98a978a17SVictor Perevertkin Abstract: 108a978a17SVictor Perevertkin 118a978a17SVictor Perevertkin Kernel mode implementation of lock 128a978a17SVictor Perevertkin class defined in MxLock.h 138a978a17SVictor Perevertkin 148a978a17SVictor Perevertkin Author: 158a978a17SVictor Perevertkin 168a978a17SVictor Perevertkin 178a978a17SVictor Perevertkin 188a978a17SVictor Perevertkin Revision History: 198a978a17SVictor Perevertkin 208a978a17SVictor Perevertkin 218a978a17SVictor Perevertkin 228a978a17SVictor Perevertkin --*/ 238a978a17SVictor Perevertkin 248a978a17SVictor Perevertkin #pragma once 258a978a17SVictor Perevertkin 26*1f377076SVictor Perevertkin #include "dbgmacros.h" 278a978a17SVictor Perevertkin 288a978a17SVictor Perevertkin typedef KSPIN_LOCK MdLock; 298a978a17SVictor Perevertkin 30*1f377076SVictor Perevertkin #include "mxlock.h" 318a978a17SVictor Perevertkin 328a978a17SVictor Perevertkin __inline MxLock()338a978a17SVictor PerevertkinMxLock::MxLock( 348a978a17SVictor Perevertkin ) 358a978a17SVictor Perevertkin { 368a978a17SVictor Perevertkin CLEAR_DBGFLAG_INITIALIZED; 378a978a17SVictor Perevertkin 388a978a17SVictor Perevertkin MxLock::Initialize(); 398a978a17SVictor Perevertkin } 408a978a17SVictor Perevertkin 418a978a17SVictor Perevertkin __inline 428a978a17SVictor Perevertkin VOID Initialize()438a978a17SVictor PerevertkinMxLockNoDynam::Initialize( 448a978a17SVictor Perevertkin ) 458a978a17SVictor Perevertkin { 468a978a17SVictor Perevertkin KeInitializeSpinLock(&m_Lock); 478a978a17SVictor Perevertkin 488a978a17SVictor Perevertkin SET_DBGFLAG_INITIALIZED; 498a978a17SVictor Perevertkin } 508a978a17SVictor Perevertkin 518a978a17SVictor Perevertkin _Acquires_lock_(this->m_Lock) __drv_maxIRQL(DISPATCH_LEVEL)528a978a17SVictor Perevertkin__drv_maxIRQL(DISPATCH_LEVEL) 538a978a17SVictor Perevertkin __drv_setsIRQL(DISPATCH_LEVEL) 548a978a17SVictor Perevertkin __inline 558a978a17SVictor Perevertkin VOID 568a978a17SVictor Perevertkin MxLockNoDynam::Acquire( 578a978a17SVictor Perevertkin __out __drv_deref(__drv_savesIRQL) KIRQL * OldIrql 588a978a17SVictor Perevertkin ) 598a978a17SVictor Perevertkin { 608a978a17SVictor Perevertkin ASSERT_DBGFLAG_INITIALIZED; 618a978a17SVictor Perevertkin 628a978a17SVictor Perevertkin KeAcquireSpinLock(&m_Lock, OldIrql); 638a978a17SVictor Perevertkin } 648a978a17SVictor Perevertkin 658a978a17SVictor Perevertkin _Acquires_lock_(this->m_Lock) __drv_requiresIRQL(DISPATCH_LEVEL)668a978a17SVictor Perevertkin__drv_requiresIRQL(DISPATCH_LEVEL) 678a978a17SVictor Perevertkin __inline 688a978a17SVictor Perevertkin VOID 698a978a17SVictor Perevertkin MxLockNoDynam::AcquireAtDpcLevel( 708a978a17SVictor Perevertkin ) 718a978a17SVictor Perevertkin { 728a978a17SVictor Perevertkin ASSERT_DBGFLAG_INITIALIZED; 738a978a17SVictor Perevertkin 748a978a17SVictor Perevertkin KeAcquireSpinLockAtDpcLevel(&m_Lock); 758a978a17SVictor Perevertkin } 768a978a17SVictor Perevertkin 778a978a17SVictor Perevertkin _Releases_lock_(this->m_Lock) __drv_requiresIRQL(DISPATCH_LEVEL)788a978a17SVictor Perevertkin__drv_requiresIRQL(DISPATCH_LEVEL) 798a978a17SVictor Perevertkin __inline 808a978a17SVictor Perevertkin VOID 818a978a17SVictor Perevertkin MxLockNoDynam::Release( 828a978a17SVictor Perevertkin __drv_restoresIRQL KIRQL NewIrql 838a978a17SVictor Perevertkin ) 848a978a17SVictor Perevertkin { 858a978a17SVictor Perevertkin ASSERT_DBGFLAG_INITIALIZED; 868a978a17SVictor Perevertkin 878a978a17SVictor Perevertkin KeReleaseSpinLock(&m_Lock, NewIrql); 888a978a17SVictor Perevertkin } 898a978a17SVictor Perevertkin 908a978a17SVictor Perevertkin _Releases_lock_(this->m_Lock) __drv_requiresIRQL(DISPATCH_LEVEL)918a978a17SVictor Perevertkin__drv_requiresIRQL(DISPATCH_LEVEL) 928a978a17SVictor Perevertkin __inline 938a978a17SVictor Perevertkin VOID 948a978a17SVictor Perevertkin MxLockNoDynam::ReleaseFromDpcLevel( 958a978a17SVictor Perevertkin ) 968a978a17SVictor Perevertkin { 978a978a17SVictor Perevertkin ASSERT_DBGFLAG_INITIALIZED; 988a978a17SVictor Perevertkin 998a978a17SVictor Perevertkin KeReleaseSpinLockFromDpcLevel(&m_Lock); 1008a978a17SVictor Perevertkin } 1018a978a17SVictor Perevertkin 1028a978a17SVictor Perevertkin __inline 1038a978a17SVictor Perevertkin VOID Uninitialize()1048a978a17SVictor PerevertkinMxLockNoDynam::Uninitialize( 1058a978a17SVictor Perevertkin ) 1068a978a17SVictor Perevertkin { 1078a978a17SVictor Perevertkin CLEAR_DBGFLAG_INITIALIZED; 1088a978a17SVictor Perevertkin } 1098a978a17SVictor Perevertkin 1108a978a17SVictor Perevertkin __inline ~MxLock()1118a978a17SVictor PerevertkinMxLock::~MxLock( 1128a978a17SVictor Perevertkin ) 1138a978a17SVictor Perevertkin { 1148a978a17SVictor Perevertkin CLEAR_DBGFLAG_INITIALIZED; 1158a978a17SVictor Perevertkin } 116