Something went wrong. Try again.
Reactos
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185/*++
Copyright (c) Microsoft Corporation
Module Name:
FxSpinLockAPI.cpp
Abstract:
This module implements external APIS to access FxSpinLock
Author:
Environment:
Both kernel and user mode
Revision History:
--*/
#include "fxsupportpch.hpp"#include "fxspinlock.hpp"
extern "C" {// #include "FxSpinLockAPI.tmh"}
//// Extern the entire file//extern "C" {
_Must_inspect_result___drv_maxIRQL(DISPATCH_LEVEL)NTSTATUSNTAPIWDFEXPORT(WdfSpinLockCreate)( __in PWDF_DRIVER_GLOBALS DriverGlobals, __in_opt PWDF_OBJECT_ATTRIBUTES SpinLockAttributes, __out WDFSPINLOCK* SpinLock ){ DDI_ENTRY();
PFX_DRIVER_GLOBALS pFxDriverGlobals; NTSTATUS status; FxSpinLock* pLock; WDFSPINLOCK lock; USHORT extra;
pFxDriverGlobals = GetFxDriverGlobals(DriverGlobals);
// // Get the parent's globals if it is present // if (NT_SUCCESS(FxValidateObjectAttributesForParentHandle( pFxDriverGlobals, SpinLockAttributes))) { FxObject* pParent;
FxObjectHandleGetPtrAndGlobals(pFxDriverGlobals, SpinLockAttributes->ParentObject, FX_TYPE_OBJECT, (PVOID*)&pParent, &pFxDriverGlobals); }
FxPointerNotNull(pFxDriverGlobals, SpinLock);
status = FxValidateObjectAttributes(pFxDriverGlobals, SpinLockAttributes); if (!NT_SUCCESS(status)) { return status; }
if (pFxDriverGlobals->FxVerifierLock) { extra = sizeof(FX_SPIN_LOCK_HISTORY); } else { extra = 0; }
*SpinLock = NULL;
pLock = new(pFxDriverGlobals, SpinLockAttributes, extra) FxSpinLock(pFxDriverGlobals, extra);
if (pLock == NULL) { return STATUS_INSUFFICIENT_RESOURCES; }
status = pLock->Commit(SpinLockAttributes, (WDFOBJECT*)&lock);
if (NT_SUCCESS(status)) { *SpinLock = lock; } else { pLock->DeleteFromFailedCreate(); }
return status;}
__drv_raisesIRQL(DISPATCH_LEVEL)__drv_maxIRQL(DISPATCH_LEVEL)VOIDNTAPIWDFEXPORT(WdfSpinLockAcquire)( __in PWDF_DRIVER_GLOBALS DriverGlobals, __in __drv_savesIRQL _Requires_lock_not_held_(_Curr_) _Acquires_lock_(_Curr_) WDFSPINLOCK SpinLock ){ DDI_ENTRY();
PFX_DRIVER_GLOBALS pFxDriverGlobals; FxSpinLock* pLock;
FxObjectHandleGetPtrAndGlobals(GetFxDriverGlobals(DriverGlobals), SpinLock, FX_TYPE_SPIN_LOCK, (PVOID*) &pLock, &pFxDriverGlobals);
if (pLock->IsInterruptLock()) { DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGERROR, "WDFSPINLOCK %p is associated with an interrupt, " "cannot be used for normal sync operations", SpinLock); FxVerifierDbgBreakPoint(pFxDriverGlobals); return; }
pLock->AcquireLock( pFxDriverGlobals->FxVerifierLock ? _ReturnAddress() : NULL);}
__drv_maxIRQL(DISPATCH_LEVEL)__drv_minIRQL(DISPATCH_LEVEL)VOIDNTAPIWDFEXPORT(WdfSpinLockRelease)( __in PWDF_DRIVER_GLOBALS DriverGlobals, __in __drv_restoresIRQL _Requires_lock_held_(_Curr_) _Releases_lock_(_Curr_) WDFSPINLOCK SpinLock ){ DDI_ENTRY();
PFX_DRIVER_GLOBALS pFxDriverGlobals; FxSpinLock* pLock;
FxObjectHandleGetPtrAndGlobals(GetFxDriverGlobals(DriverGlobals), SpinLock, FX_TYPE_SPIN_LOCK, (PVOID*) &pLock, &pFxDriverGlobals);
if (pLock->IsInterruptLock()) { DoTraceLevelMessage(pFxDriverGlobals, TRACE_LEVEL_ERROR, TRACINGERROR, "WDFSPINLOCK %p is associated with an interrupt, " "cannot be used for normal sync operations", SpinLock); FxVerifierDbgBreakPoint(pFxDriverGlobals); return; }
pLock->ReleaseLock();}
} // extern "C"