2006-06-30 18:54:34 +00:00
|
|
|
/*
|
|
|
|
* PROJECT: ReactOS Kernel
|
|
|
|
* LICENSE: GPL - See COPYING in the top level directory
|
2005-01-26 13:58:37 +00:00
|
|
|
* FILE: ntoskrnl/io/remlock.c
|
2006-06-30 18:54:34 +00:00
|
|
|
* PURPOSE: Remove Lock Support
|
|
|
|
* PROGRAMMERS: Alex Ionescu (alex.ionescu@reactos.org)
|
|
|
|
* Filip Navara (navaraf@reactos.org)
|
2011-05-24 21:21:54 +00:00
|
|
|
* Pierre Schweitzer (pierre.schweitzer@reactos.org)
|
Plug & Play manager improvments + few other things
ntoskrnl/ntoskrnl.edf:
Added exports for IoGetDmaAdapter, IoIsWdmVersionAvailable,
KefAcquireSpinLockAtDpcLevel, KefReleaseSpinLockFromDpcLevel,
ExFreePoolWithTag.
ntoskrnl/io/driver.c:
Implementation of NtUnloadDriver.
ntoskrnl/io/device.c:
Added prepending "\\SystemRoot\" and displaying "PnP Loading xxx..." message
in IopInitializeDeviceNodeService.
ntoskrnl/io/pnpmgr.c:
Split into ntoskrnl/io/pnpmgr.c, ntoskrnl/io/deviface.c,
ntoskrnl/io/pnpnotify.c, ntoskrnl/io/pnpmgr/pnpdma.c,
ntoskrnl/io/pnpmgr.c, ntoskrnl/io/pnpmgr/pnproot.c,
ntoskrnl/io/remlock.c, ntoskrnl/io/pnpmgr/pnpreport.c.
Fixed registry handling in IopActionInterrogateDeviceStack and
IopActionConfigureChildServices.
Partial implementation of IoGetDeviceProperty.
ntoskrnl/io/pnpdma.c:
Implementation of IoGetDmaAdapter.
ntoskrnl/io/wdm.c:
New file. Contains implementation of IoIsWdmVersionAvailable.
ntoskrnl/ke/spinlock.c:
Added KeAcquireSpinLockAtDpcLevel and KefReleaseSpinLockFromDpcLevel.
ntoskrnl/mm/pool.c:
Partial implementation of ExFreePoolWithTag.
svn path=/trunk/; revision=6136
2003-09-25 15:54:43 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
/* INCLUDES ******************************************************************/
|
|
|
|
|
2004-08-15 16:39:12 +00:00
|
|
|
#include <ntoskrnl.h>
|
2006-06-30 18:54:34 +00:00
|
|
|
#define NDEBUG
|
2008-08-30 16:31:06 +00:00
|
|
|
#include <debug.h>
|
Plug & Play manager improvments + few other things
ntoskrnl/ntoskrnl.edf:
Added exports for IoGetDmaAdapter, IoIsWdmVersionAvailable,
KefAcquireSpinLockAtDpcLevel, KefReleaseSpinLockFromDpcLevel,
ExFreePoolWithTag.
ntoskrnl/io/driver.c:
Implementation of NtUnloadDriver.
ntoskrnl/io/device.c:
Added prepending "\\SystemRoot\" and displaying "PnP Loading xxx..." message
in IopInitializeDeviceNodeService.
ntoskrnl/io/pnpmgr.c:
Split into ntoskrnl/io/pnpmgr.c, ntoskrnl/io/deviface.c,
ntoskrnl/io/pnpnotify.c, ntoskrnl/io/pnpmgr/pnpdma.c,
ntoskrnl/io/pnpmgr.c, ntoskrnl/io/pnpmgr/pnproot.c,
ntoskrnl/io/remlock.c, ntoskrnl/io/pnpmgr/pnpreport.c.
Fixed registry handling in IopActionInterrogateDeviceStack and
IopActionConfigureChildServices.
Partial implementation of IoGetDeviceProperty.
ntoskrnl/io/pnpdma.c:
Implementation of IoGetDmaAdapter.
ntoskrnl/io/wdm.c:
New file. Contains implementation of IoIsWdmVersionAvailable.
ntoskrnl/ke/spinlock.c:
Added KeAcquireSpinLockAtDpcLevel and KefReleaseSpinLockFromDpcLevel.
ntoskrnl/mm/pool.c:
Partial implementation of ExFreePoolWithTag.
svn path=/trunk/; revision=6136
2003-09-25 15:54:43 +00:00
|
|
|
|
2011-05-24 21:21:54 +00:00
|
|
|
typedef struct _IO_REMOVE_LOCK_TRACKING_BLOCK
|
|
|
|
{
|
2011-05-29 22:29:10 +00:00
|
|
|
PIO_REMOVE_LOCK_TRACKING_BLOCK Next;
|
2011-05-24 21:21:54 +00:00
|
|
|
PVOID Tag;
|
|
|
|
LARGE_INTEGER LockMoment;
|
|
|
|
LPCSTR File;
|
|
|
|
ULONG Line;
|
|
|
|
} IO_REMOVE_LOCK_TRACKING_BLOCK;
|
|
|
|
|
Plug & Play manager improvments + few other things
ntoskrnl/ntoskrnl.edf:
Added exports for IoGetDmaAdapter, IoIsWdmVersionAvailable,
KefAcquireSpinLockAtDpcLevel, KefReleaseSpinLockFromDpcLevel,
ExFreePoolWithTag.
ntoskrnl/io/driver.c:
Implementation of NtUnloadDriver.
ntoskrnl/io/device.c:
Added prepending "\\SystemRoot\" and displaying "PnP Loading xxx..." message
in IopInitializeDeviceNodeService.
ntoskrnl/io/pnpmgr.c:
Split into ntoskrnl/io/pnpmgr.c, ntoskrnl/io/deviface.c,
ntoskrnl/io/pnpnotify.c, ntoskrnl/io/pnpmgr/pnpdma.c,
ntoskrnl/io/pnpmgr.c, ntoskrnl/io/pnpmgr/pnproot.c,
ntoskrnl/io/remlock.c, ntoskrnl/io/pnpmgr/pnpreport.c.
Fixed registry handling in IopActionInterrogateDeviceStack and
IopActionConfigureChildServices.
Partial implementation of IoGetDeviceProperty.
ntoskrnl/io/pnpdma.c:
Implementation of IoGetDmaAdapter.
ntoskrnl/io/wdm.c:
New file. Contains implementation of IoIsWdmVersionAvailable.
ntoskrnl/ke/spinlock.c:
Added KeAcquireSpinLockAtDpcLevel and KefReleaseSpinLockFromDpcLevel.
ntoskrnl/mm/pool.c:
Partial implementation of ExFreePoolWithTag.
svn path=/trunk/; revision=6136
2003-09-25 15:54:43 +00:00
|
|
|
/* FUNCTIONS *****************************************************************/
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
VOID
|
2006-06-30 18:54:34 +00:00
|
|
|
NTAPI
|
|
|
|
IoInitializeRemoveLockEx(IN PIO_REMOVE_LOCK RemoveLock,
|
|
|
|
IN ULONG AllocateTag,
|
|
|
|
IN ULONG MaxLockedMinutes,
|
|
|
|
IN ULONG HighWatermark,
|
|
|
|
IN ULONG RemlockSize)
|
Plug & Play manager improvments + few other things
ntoskrnl/ntoskrnl.edf:
Added exports for IoGetDmaAdapter, IoIsWdmVersionAvailable,
KefAcquireSpinLockAtDpcLevel, KefReleaseSpinLockFromDpcLevel,
ExFreePoolWithTag.
ntoskrnl/io/driver.c:
Implementation of NtUnloadDriver.
ntoskrnl/io/device.c:
Added prepending "\\SystemRoot\" and displaying "PnP Loading xxx..." message
in IopInitializeDeviceNodeService.
ntoskrnl/io/pnpmgr.c:
Split into ntoskrnl/io/pnpmgr.c, ntoskrnl/io/deviface.c,
ntoskrnl/io/pnpnotify.c, ntoskrnl/io/pnpmgr/pnpdma.c,
ntoskrnl/io/pnpmgr.c, ntoskrnl/io/pnpmgr/pnproot.c,
ntoskrnl/io/remlock.c, ntoskrnl/io/pnpmgr/pnpreport.c.
Fixed registry handling in IopActionInterrogateDeviceStack and
IopActionConfigureChildServices.
Partial implementation of IoGetDeviceProperty.
ntoskrnl/io/pnpdma.c:
Implementation of IoGetDmaAdapter.
ntoskrnl/io/wdm.c:
New file. Contains implementation of IoIsWdmVersionAvailable.
ntoskrnl/ke/spinlock.c:
Added KeAcquireSpinLockAtDpcLevel and KefReleaseSpinLockFromDpcLevel.
ntoskrnl/mm/pool.c:
Partial implementation of ExFreePoolWithTag.
svn path=/trunk/; revision=6136
2003-09-25 15:54:43 +00:00
|
|
|
{
|
2006-06-30 18:54:34 +00:00
|
|
|
PEXTENDED_IO_REMOVE_LOCK Lock = (PEXTENDED_IO_REMOVE_LOCK)RemoveLock;
|
|
|
|
PAGED_CODE();
|
|
|
|
|
2011-05-24 21:21:54 +00:00
|
|
|
ASSERT(HighWatermark < MAXLONG);
|
|
|
|
|
|
|
|
/* If no lock given, nothing to do */
|
|
|
|
if (!Lock)
|
2006-06-30 18:54:34 +00:00
|
|
|
{
|
2011-05-24 21:21:54 +00:00
|
|
|
return;
|
2006-06-30 18:54:34 +00:00
|
|
|
}
|
2011-05-24 21:21:54 +00:00
|
|
|
|
|
|
|
switch (RemlockSize)
|
2006-06-30 18:54:34 +00:00
|
|
|
{
|
2011-05-24 21:21:54 +00:00
|
|
|
/* Check if this is a debug lock */
|
2011-05-27 21:21:36 +00:00
|
|
|
case (sizeof(IO_REMOVE_LOCK_DBG_BLOCK) + sizeof(IO_REMOVE_LOCK_COMMON_BLOCK)):
|
2011-05-24 21:21:54 +00:00
|
|
|
/* Setup debug parameters */
|
|
|
|
Lock->Dbg.Signature = 'COLR';
|
|
|
|
Lock->Dbg.HighWatermark = HighWatermark;
|
|
|
|
Lock->Dbg.MaxLockedTicks = KeQueryTimeIncrement() * MaxLockedMinutes * 600000000;
|
|
|
|
Lock->Dbg.AllocateTag = AllocateTag;
|
|
|
|
KeInitializeSpinLock(&(Lock->Dbg.Spin));
|
|
|
|
Lock->Dbg.LowMemoryCount = 0;
|
|
|
|
Lock->Dbg.Blocks = NULL;
|
|
|
|
|
|
|
|
case sizeof(IO_REMOVE_LOCK_COMMON_BLOCK):
|
|
|
|
/* Setup a free block */
|
|
|
|
Lock->Common.Removed = FALSE;
|
|
|
|
Lock->Common.IoCount = 1;
|
|
|
|
KeInitializeEvent(&Lock->Common.RemoveEvent,
|
|
|
|
SynchronizationEvent,
|
|
|
|
FALSE);
|
2006-06-30 18:54:34 +00:00
|
|
|
}
|
Plug & Play manager improvments + few other things
ntoskrnl/ntoskrnl.edf:
Added exports for IoGetDmaAdapter, IoIsWdmVersionAvailable,
KefAcquireSpinLockAtDpcLevel, KefReleaseSpinLockFromDpcLevel,
ExFreePoolWithTag.
ntoskrnl/io/driver.c:
Implementation of NtUnloadDriver.
ntoskrnl/io/device.c:
Added prepending "\\SystemRoot\" and displaying "PnP Loading xxx..." message
in IopInitializeDeviceNodeService.
ntoskrnl/io/pnpmgr.c:
Split into ntoskrnl/io/pnpmgr.c, ntoskrnl/io/deviface.c,
ntoskrnl/io/pnpnotify.c, ntoskrnl/io/pnpmgr/pnpdma.c,
ntoskrnl/io/pnpmgr.c, ntoskrnl/io/pnpmgr/pnproot.c,
ntoskrnl/io/remlock.c, ntoskrnl/io/pnpmgr/pnpreport.c.
Fixed registry handling in IopActionInterrogateDeviceStack and
IopActionConfigureChildServices.
Partial implementation of IoGetDeviceProperty.
ntoskrnl/io/pnpdma.c:
Implementation of IoGetDmaAdapter.
ntoskrnl/io/wdm.c:
New file. Contains implementation of IoIsWdmVersionAvailable.
ntoskrnl/ke/spinlock.c:
Added KeAcquireSpinLockAtDpcLevel and KefReleaseSpinLockFromDpcLevel.
ntoskrnl/mm/pool.c:
Partial implementation of ExFreePoolWithTag.
svn path=/trunk/; revision=6136
2003-09-25 15:54:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
NTSTATUS
|
2006-06-30 18:54:34 +00:00
|
|
|
NTAPI
|
|
|
|
IoAcquireRemoveLockEx(IN PIO_REMOVE_LOCK RemoveLock,
|
|
|
|
IN OPTIONAL PVOID Tag,
|
|
|
|
IN LPCSTR File,
|
|
|
|
IN ULONG Line,
|
|
|
|
IN ULONG RemlockSize)
|
Plug & Play manager improvments + few other things
ntoskrnl/ntoskrnl.edf:
Added exports for IoGetDmaAdapter, IoIsWdmVersionAvailable,
KefAcquireSpinLockAtDpcLevel, KefReleaseSpinLockFromDpcLevel,
ExFreePoolWithTag.
ntoskrnl/io/driver.c:
Implementation of NtUnloadDriver.
ntoskrnl/io/device.c:
Added prepending "\\SystemRoot\" and displaying "PnP Loading xxx..." message
in IopInitializeDeviceNodeService.
ntoskrnl/io/pnpmgr.c:
Split into ntoskrnl/io/pnpmgr.c, ntoskrnl/io/deviface.c,
ntoskrnl/io/pnpnotify.c, ntoskrnl/io/pnpmgr/pnpdma.c,
ntoskrnl/io/pnpmgr.c, ntoskrnl/io/pnpmgr/pnproot.c,
ntoskrnl/io/remlock.c, ntoskrnl/io/pnpmgr/pnpreport.c.
Fixed registry handling in IopActionInterrogateDeviceStack and
IopActionConfigureChildServices.
Partial implementation of IoGetDeviceProperty.
ntoskrnl/io/pnpdma.c:
Implementation of IoGetDmaAdapter.
ntoskrnl/io/wdm.c:
New file. Contains implementation of IoIsWdmVersionAvailable.
ntoskrnl/ke/spinlock.c:
Added KeAcquireSpinLockAtDpcLevel and KefReleaseSpinLockFromDpcLevel.
ntoskrnl/mm/pool.c:
Partial implementation of ExFreePoolWithTag.
svn path=/trunk/; revision=6136
2003-09-25 15:54:43 +00:00
|
|
|
{
|
2011-05-24 21:21:54 +00:00
|
|
|
KIRQL OldIrql;
|
|
|
|
LONG LockValue;
|
|
|
|
PIO_REMOVE_LOCK_TRACKING_BLOCK TrackingBlock;
|
2006-06-30 18:54:34 +00:00
|
|
|
PEXTENDED_IO_REMOVE_LOCK Lock = (PEXTENDED_IO_REMOVE_LOCK)RemoveLock;
|
|
|
|
|
|
|
|
/* Increase the lock count */
|
2011-05-24 21:21:54 +00:00
|
|
|
LockValue = InterlockedIncrement(&(Lock->Common.IoCount));
|
|
|
|
ASSERT(LockValue > 0);
|
2006-06-30 18:54:34 +00:00
|
|
|
if (!Lock->Common.Removed)
|
Plug & Play manager improvments + few other things
ntoskrnl/ntoskrnl.edf:
Added exports for IoGetDmaAdapter, IoIsWdmVersionAvailable,
KefAcquireSpinLockAtDpcLevel, KefReleaseSpinLockFromDpcLevel,
ExFreePoolWithTag.
ntoskrnl/io/driver.c:
Implementation of NtUnloadDriver.
ntoskrnl/io/device.c:
Added prepending "\\SystemRoot\" and displaying "PnP Loading xxx..." message
in IopInitializeDeviceNodeService.
ntoskrnl/io/pnpmgr.c:
Split into ntoskrnl/io/pnpmgr.c, ntoskrnl/io/deviface.c,
ntoskrnl/io/pnpnotify.c, ntoskrnl/io/pnpmgr/pnpdma.c,
ntoskrnl/io/pnpmgr.c, ntoskrnl/io/pnpmgr/pnproot.c,
ntoskrnl/io/remlock.c, ntoskrnl/io/pnpmgr/pnpreport.c.
Fixed registry handling in IopActionInterrogateDeviceStack and
IopActionConfigureChildServices.
Partial implementation of IoGetDeviceProperty.
ntoskrnl/io/pnpdma.c:
Implementation of IoGetDmaAdapter.
ntoskrnl/io/wdm.c:
New file. Contains implementation of IoIsWdmVersionAvailable.
ntoskrnl/ke/spinlock.c:
Added KeAcquireSpinLockAtDpcLevel and KefReleaseSpinLockFromDpcLevel.
ntoskrnl/mm/pool.c:
Partial implementation of ExFreePoolWithTag.
svn path=/trunk/; revision=6136
2003-09-25 15:54:43 +00:00
|
|
|
{
|
2006-06-30 18:54:34 +00:00
|
|
|
/* Check what kind of lock this is */
|
2011-05-27 21:21:36 +00:00
|
|
|
if (RemlockSize == (sizeof(IO_REMOVE_LOCK_DBG_BLOCK) + sizeof(IO_REMOVE_LOCK_COMMON_BLOCK)))
|
2006-06-30 18:54:34 +00:00
|
|
|
{
|
2011-05-24 21:21:54 +00:00
|
|
|
ASSERT(Lock->Dbg.HighWatermark == 0 || LockValue <= Lock->Dbg.HighWatermark);
|
|
|
|
|
|
|
|
/* Allocate a tracking block */
|
|
|
|
TrackingBlock = ExAllocatePoolWithTag(NonPagedPool, sizeof(IO_REMOVE_LOCK_TRACKING_BLOCK), Lock->Dbg.AllocateTag);
|
|
|
|
if (!TrackingBlock)
|
|
|
|
{
|
|
|
|
/* Keep count of failures for lock release and missing tags */
|
|
|
|
InterlockedIncrement(&(Lock->Dbg.LowMemoryCount));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Initialize block */
|
|
|
|
RtlZeroMemory(TrackingBlock, sizeof(IO_REMOVE_LOCK_TRACKING_BLOCK));
|
|
|
|
TrackingBlock->Tag = Tag;
|
|
|
|
TrackingBlock->File = File;
|
|
|
|
TrackingBlock->Line = Line;
|
|
|
|
KeQueryTickCount(&(TrackingBlock->LockMoment));
|
|
|
|
|
|
|
|
/* Queue the block */
|
|
|
|
KeAcquireSpinLock(&(Lock->Dbg.Spin), &OldIrql);
|
2011-05-29 22:29:10 +00:00
|
|
|
TrackingBlock->Next = Lock->Dbg.Blocks;
|
|
|
|
Lock->Dbg.Blocks = TrackingBlock;
|
2011-05-24 21:21:54 +00:00
|
|
|
KeReleaseSpinLock(&(Lock->Dbg.Spin), OldIrql);
|
|
|
|
}
|
2006-06-30 18:54:34 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Otherwise, decrement the count and check if it's gone */
|
2011-05-24 21:21:54 +00:00
|
|
|
if (!InterlockedDecrement(&(Lock->Common.IoCount)))
|
2006-06-30 18:54:34 +00:00
|
|
|
{
|
|
|
|
/* Signal the event */
|
2011-05-24 21:21:54 +00:00
|
|
|
KeSetEvent(&(Lock->Common.RemoveEvent), IO_NO_INCREMENT, FALSE);
|
2006-06-30 18:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Return pending delete */
|
|
|
|
return STATUS_DELETE_PENDING;
|
Plug & Play manager improvments + few other things
ntoskrnl/ntoskrnl.edf:
Added exports for IoGetDmaAdapter, IoIsWdmVersionAvailable,
KefAcquireSpinLockAtDpcLevel, KefReleaseSpinLockFromDpcLevel,
ExFreePoolWithTag.
ntoskrnl/io/driver.c:
Implementation of NtUnloadDriver.
ntoskrnl/io/device.c:
Added prepending "\\SystemRoot\" and displaying "PnP Loading xxx..." message
in IopInitializeDeviceNodeService.
ntoskrnl/io/pnpmgr.c:
Split into ntoskrnl/io/pnpmgr.c, ntoskrnl/io/deviface.c,
ntoskrnl/io/pnpnotify.c, ntoskrnl/io/pnpmgr/pnpdma.c,
ntoskrnl/io/pnpmgr.c, ntoskrnl/io/pnpmgr/pnproot.c,
ntoskrnl/io/remlock.c, ntoskrnl/io/pnpmgr/pnpreport.c.
Fixed registry handling in IopActionInterrogateDeviceStack and
IopActionConfigureChildServices.
Partial implementation of IoGetDeviceProperty.
ntoskrnl/io/pnpdma.c:
Implementation of IoGetDmaAdapter.
ntoskrnl/io/wdm.c:
New file. Contains implementation of IoIsWdmVersionAvailable.
ntoskrnl/ke/spinlock.c:
Added KeAcquireSpinLockAtDpcLevel and KefReleaseSpinLockFromDpcLevel.
ntoskrnl/mm/pool.c:
Partial implementation of ExFreePoolWithTag.
svn path=/trunk/; revision=6136
2003-09-25 15:54:43 +00:00
|
|
|
}
|
2006-06-30 18:54:34 +00:00
|
|
|
|
|
|
|
/* Otherwise, return success */
|
|
|
|
return STATUS_SUCCESS;
|
Plug & Play manager improvments + few other things
ntoskrnl/ntoskrnl.edf:
Added exports for IoGetDmaAdapter, IoIsWdmVersionAvailable,
KefAcquireSpinLockAtDpcLevel, KefReleaseSpinLockFromDpcLevel,
ExFreePoolWithTag.
ntoskrnl/io/driver.c:
Implementation of NtUnloadDriver.
ntoskrnl/io/device.c:
Added prepending "\\SystemRoot\" and displaying "PnP Loading xxx..." message
in IopInitializeDeviceNodeService.
ntoskrnl/io/pnpmgr.c:
Split into ntoskrnl/io/pnpmgr.c, ntoskrnl/io/deviface.c,
ntoskrnl/io/pnpnotify.c, ntoskrnl/io/pnpmgr/pnpdma.c,
ntoskrnl/io/pnpmgr.c, ntoskrnl/io/pnpmgr/pnproot.c,
ntoskrnl/io/remlock.c, ntoskrnl/io/pnpmgr/pnpreport.c.
Fixed registry handling in IopActionInterrogateDeviceStack and
IopActionConfigureChildServices.
Partial implementation of IoGetDeviceProperty.
ntoskrnl/io/pnpdma.c:
Implementation of IoGetDmaAdapter.
ntoskrnl/io/wdm.c:
New file. Contains implementation of IoIsWdmVersionAvailable.
ntoskrnl/ke/spinlock.c:
Added KeAcquireSpinLockAtDpcLevel and KefReleaseSpinLockFromDpcLevel.
ntoskrnl/mm/pool.c:
Partial implementation of ExFreePoolWithTag.
svn path=/trunk/; revision=6136
2003-09-25 15:54:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
VOID
|
2006-06-30 18:54:34 +00:00
|
|
|
NTAPI
|
|
|
|
IoReleaseRemoveLockEx(IN PIO_REMOVE_LOCK RemoveLock,
|
|
|
|
IN PVOID Tag,
|
|
|
|
IN ULONG RemlockSize)
|
Plug & Play manager improvments + few other things
ntoskrnl/ntoskrnl.edf:
Added exports for IoGetDmaAdapter, IoIsWdmVersionAvailable,
KefAcquireSpinLockAtDpcLevel, KefReleaseSpinLockFromDpcLevel,
ExFreePoolWithTag.
ntoskrnl/io/driver.c:
Implementation of NtUnloadDriver.
ntoskrnl/io/device.c:
Added prepending "\\SystemRoot\" and displaying "PnP Loading xxx..." message
in IopInitializeDeviceNodeService.
ntoskrnl/io/pnpmgr.c:
Split into ntoskrnl/io/pnpmgr.c, ntoskrnl/io/deviface.c,
ntoskrnl/io/pnpnotify.c, ntoskrnl/io/pnpmgr/pnpdma.c,
ntoskrnl/io/pnpmgr.c, ntoskrnl/io/pnpmgr/pnproot.c,
ntoskrnl/io/remlock.c, ntoskrnl/io/pnpmgr/pnpreport.c.
Fixed registry handling in IopActionInterrogateDeviceStack and
IopActionConfigureChildServices.
Partial implementation of IoGetDeviceProperty.
ntoskrnl/io/pnpdma.c:
Implementation of IoGetDmaAdapter.
ntoskrnl/io/wdm.c:
New file. Contains implementation of IoIsWdmVersionAvailable.
ntoskrnl/ke/spinlock.c:
Added KeAcquireSpinLockAtDpcLevel and KefReleaseSpinLockFromDpcLevel.
ntoskrnl/mm/pool.c:
Partial implementation of ExFreePoolWithTag.
svn path=/trunk/; revision=6136
2003-09-25 15:54:43 +00:00
|
|
|
{
|
2011-05-24 21:21:54 +00:00
|
|
|
KIRQL OldIrql;
|
|
|
|
LONG LockValue;
|
|
|
|
BOOLEAN TagFound;
|
|
|
|
LARGE_INTEGER CurrentMoment;
|
|
|
|
PIO_REMOVE_LOCK_TRACKING_BLOCK TrackingBlock;
|
2011-05-29 22:29:10 +00:00
|
|
|
PIO_REMOVE_LOCK_TRACKING_BLOCK *TrackingBlockLink;
|
2006-06-30 18:54:34 +00:00
|
|
|
PEXTENDED_IO_REMOVE_LOCK Lock = (PEXTENDED_IO_REMOVE_LOCK)RemoveLock;
|
|
|
|
|
|
|
|
/* Check what kind of lock this is */
|
2011-05-27 21:21:36 +00:00
|
|
|
if (RemlockSize == (sizeof(IO_REMOVE_LOCK_DBG_BLOCK) + sizeof(IO_REMOVE_LOCK_COMMON_BLOCK)))
|
2006-06-30 18:54:34 +00:00
|
|
|
{
|
2011-05-24 21:21:54 +00:00
|
|
|
/* Acquire blocks queue */
|
|
|
|
KeAcquireSpinLock(&(Lock->Dbg.Spin), &OldIrql);
|
|
|
|
|
|
|
|
/* Get the release moment */
|
|
|
|
KeQueryTickCount(&CurrentMoment);
|
|
|
|
|
|
|
|
/* Start browsing tracking blocks to find a block that would match given tag */
|
|
|
|
TagFound = FALSE;
|
2011-05-29 22:29:10 +00:00
|
|
|
TrackingBlock = Lock->Dbg.Blocks;
|
|
|
|
TrackingBlockLink = &(Lock->Dbg.Blocks);
|
|
|
|
while (TrackingBlock != NULL)
|
2011-05-24 21:21:54 +00:00
|
|
|
{
|
|
|
|
/* First of all, check if the lock was locked for too long */
|
2011-08-18 18:06:07 +00:00
|
|
|
if (Lock->Dbg.MaxLockedTicks &&
|
|
|
|
CurrentMoment.QuadPart - TrackingBlock->LockMoment.QuadPart > Lock->Dbg.MaxLockedTicks)
|
2011-05-24 21:21:54 +00:00
|
|
|
{
|
|
|
|
DPRINT("Lock %#08lx (with tag %#08lx) was supposed to be held at max %I64d ticks but lasted longer\n",
|
|
|
|
Lock, TrackingBlock->Tag, Lock->Dbg.MaxLockedTicks);
|
2013-08-31 16:02:13 +00:00
|
|
|
DPRINT("Lock was acquired in file %s at line %lu\n", TrackingBlock->File, TrackingBlock->Line);
|
2011-05-24 21:21:54 +00:00
|
|
|
ASSERT(FALSE);
|
|
|
|
}
|
|
|
|
|
2011-05-29 22:29:10 +00:00
|
|
|
/* Check if this is the first matching tracking block */
|
|
|
|
if ((TagFound == FALSE) && (TrackingBlock->Tag == Tag))
|
|
|
|
{
|
|
|
|
/* Unlink this tracking block, and free it */
|
|
|
|
TagFound = TRUE;
|
|
|
|
*TrackingBlockLink = TrackingBlock->Next;
|
|
|
|
ExFreePoolWithTag(TrackingBlock, Lock->Dbg.AllocateTag);
|
|
|
|
TrackingBlock = *TrackingBlockLink;
|
|
|
|
}
|
|
|
|
else
|
2011-05-24 21:21:54 +00:00
|
|
|
{
|
2011-05-29 22:29:10 +00:00
|
|
|
/* Go to the next tracking block */
|
|
|
|
TrackingBlockLink = &(TrackingBlock->Next);
|
|
|
|
TrackingBlock = TrackingBlock->Next;
|
|
|
|
}
|
2011-05-24 21:21:54 +00:00
|
|
|
}
|
2011-05-29 22:29:10 +00:00
|
|
|
|
2011-05-24 21:21:54 +00:00
|
|
|
/* We're done, release queue lock */
|
|
|
|
KeReleaseSpinLock(&(Lock->Dbg.Spin), OldIrql);
|
|
|
|
|
|
|
|
/* If we didn't find any matching block */
|
|
|
|
if (TagFound == FALSE)
|
|
|
|
{
|
|
|
|
/* Check if it was because we were low in memory
|
|
|
|
* If yes, then ignore, that's normal
|
|
|
|
*/
|
2011-06-25 10:26:59 +00:00
|
|
|
if (InterlockedDecrement(&(Lock->Dbg.LowMemoryCount)) < 0)
|
2011-05-24 21:21:54 +00:00
|
|
|
{
|
|
|
|
/* Otherwise signal the issue, it shouldn't happen */
|
|
|
|
InterlockedIncrement(&(Lock->Dbg.LowMemoryCount));
|
|
|
|
DPRINT("Failed finding block for tag: %#08lx\n", Tag);
|
|
|
|
ASSERT(FALSE);
|
|
|
|
}
|
|
|
|
}
|
2006-06-30 18:54:34 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Decrement the lock count */
|
2011-05-24 21:21:54 +00:00
|
|
|
LockValue = InterlockedDecrement(&(Lock->Common.IoCount));
|
|
|
|
ASSERT(LockValue >= 0);
|
|
|
|
|
|
|
|
if (!LockValue)
|
2006-06-30 18:54:34 +00:00
|
|
|
{
|
2011-05-24 21:21:54 +00:00
|
|
|
/* Someone should be waiting... */
|
|
|
|
ASSERT(Lock->Common.Removed);
|
|
|
|
|
2006-06-30 18:54:34 +00:00
|
|
|
/* Signal the event */
|
2011-05-24 21:21:54 +00:00
|
|
|
KeSetEvent(&(Lock->Common.RemoveEvent), IO_NO_INCREMENT, FALSE);
|
2006-06-30 18:54:34 +00:00
|
|
|
}
|
Plug & Play manager improvments + few other things
ntoskrnl/ntoskrnl.edf:
Added exports for IoGetDmaAdapter, IoIsWdmVersionAvailable,
KefAcquireSpinLockAtDpcLevel, KefReleaseSpinLockFromDpcLevel,
ExFreePoolWithTag.
ntoskrnl/io/driver.c:
Implementation of NtUnloadDriver.
ntoskrnl/io/device.c:
Added prepending "\\SystemRoot\" and displaying "PnP Loading xxx..." message
in IopInitializeDeviceNodeService.
ntoskrnl/io/pnpmgr.c:
Split into ntoskrnl/io/pnpmgr.c, ntoskrnl/io/deviface.c,
ntoskrnl/io/pnpnotify.c, ntoskrnl/io/pnpmgr/pnpdma.c,
ntoskrnl/io/pnpmgr.c, ntoskrnl/io/pnpmgr/pnproot.c,
ntoskrnl/io/remlock.c, ntoskrnl/io/pnpmgr/pnpreport.c.
Fixed registry handling in IopActionInterrogateDeviceStack and
IopActionConfigureChildServices.
Partial implementation of IoGetDeviceProperty.
ntoskrnl/io/pnpdma.c:
Implementation of IoGetDmaAdapter.
ntoskrnl/io/wdm.c:
New file. Contains implementation of IoIsWdmVersionAvailable.
ntoskrnl/ke/spinlock.c:
Added KeAcquireSpinLockAtDpcLevel and KefReleaseSpinLockFromDpcLevel.
ntoskrnl/mm/pool.c:
Partial implementation of ExFreePoolWithTag.
svn path=/trunk/; revision=6136
2003-09-25 15:54:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
VOID
|
2006-06-30 18:54:34 +00:00
|
|
|
NTAPI
|
|
|
|
IoReleaseRemoveLockAndWaitEx(IN PIO_REMOVE_LOCK RemoveLock,
|
|
|
|
IN PVOID Tag,
|
|
|
|
IN ULONG RemlockSize)
|
Plug & Play manager improvments + few other things
ntoskrnl/ntoskrnl.edf:
Added exports for IoGetDmaAdapter, IoIsWdmVersionAvailable,
KefAcquireSpinLockAtDpcLevel, KefReleaseSpinLockFromDpcLevel,
ExFreePoolWithTag.
ntoskrnl/io/driver.c:
Implementation of NtUnloadDriver.
ntoskrnl/io/device.c:
Added prepending "\\SystemRoot\" and displaying "PnP Loading xxx..." message
in IopInitializeDeviceNodeService.
ntoskrnl/io/pnpmgr.c:
Split into ntoskrnl/io/pnpmgr.c, ntoskrnl/io/deviface.c,
ntoskrnl/io/pnpnotify.c, ntoskrnl/io/pnpmgr/pnpdma.c,
ntoskrnl/io/pnpmgr.c, ntoskrnl/io/pnpmgr/pnproot.c,
ntoskrnl/io/remlock.c, ntoskrnl/io/pnpmgr/pnpreport.c.
Fixed registry handling in IopActionInterrogateDeviceStack and
IopActionConfigureChildServices.
Partial implementation of IoGetDeviceProperty.
ntoskrnl/io/pnpdma.c:
Implementation of IoGetDmaAdapter.
ntoskrnl/io/wdm.c:
New file. Contains implementation of IoIsWdmVersionAvailable.
ntoskrnl/ke/spinlock.c:
Added KeAcquireSpinLockAtDpcLevel and KefReleaseSpinLockFromDpcLevel.
ntoskrnl/mm/pool.c:
Partial implementation of ExFreePoolWithTag.
svn path=/trunk/; revision=6136
2003-09-25 15:54:43 +00:00
|
|
|
{
|
2011-05-24 21:21:54 +00:00
|
|
|
LONG LockValue;
|
|
|
|
PIO_REMOVE_LOCK_TRACKING_BLOCK TrackingBlock;
|
2006-06-30 18:54:34 +00:00
|
|
|
PEXTENDED_IO_REMOVE_LOCK Lock = (PEXTENDED_IO_REMOVE_LOCK)RemoveLock;
|
|
|
|
PAGED_CODE();
|
|
|
|
|
|
|
|
/* Remove the lock and decrement the count */
|
|
|
|
Lock->Common.Removed = TRUE;
|
2011-05-24 21:21:54 +00:00
|
|
|
LockValue = InterlockedDecrement(&Lock->Common.IoCount);
|
|
|
|
ASSERT(LockValue > 0);
|
|
|
|
|
|
|
|
/* If we are still > 0, then wait for the others to remove lock */
|
2006-06-30 18:54:34 +00:00
|
|
|
if (InterlockedDecrement(&Lock->Common.IoCount) > 0)
|
|
|
|
{
|
|
|
|
/* Wait for it */
|
2011-05-24 21:21:54 +00:00
|
|
|
KeWaitForSingleObject(&(Lock->Common.RemoveEvent),
|
2006-06-30 18:54:34 +00:00
|
|
|
Executive,
|
|
|
|
KernelMode,
|
|
|
|
FALSE,
|
|
|
|
NULL);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Check what kind of lock this is */
|
2011-05-27 21:21:36 +00:00
|
|
|
if (RemlockSize == (sizeof(IO_REMOVE_LOCK_DBG_BLOCK) + sizeof(IO_REMOVE_LOCK_COMMON_BLOCK)))
|
2006-06-30 18:54:34 +00:00
|
|
|
{
|
2011-05-24 21:21:54 +00:00
|
|
|
/* A block must be remaining */
|
|
|
|
ASSERT(Lock->Dbg.Blocks);
|
|
|
|
|
|
|
|
/* Get it */
|
2011-05-29 22:29:10 +00:00
|
|
|
TrackingBlock = Lock->Dbg.Blocks;
|
2011-05-24 21:21:54 +00:00
|
|
|
/* Tag should match */
|
|
|
|
if (TrackingBlock->Tag != Tag)
|
|
|
|
{
|
2013-08-31 16:02:13 +00:00
|
|
|
DPRINT("Last tracking block tag invalid! Expected: %p, having: %p\n", Tag, TrackingBlock->Tag);
|
2011-05-24 21:21:54 +00:00
|
|
|
ASSERT(TrackingBlock->Tag != Tag);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Release block */
|
|
|
|
ExFreePoolWithTag(Lock->Dbg.Blocks, Lock->Dbg.AllocateTag);
|
2006-06-30 18:54:34 +00:00
|
|
|
}
|
Plug & Play manager improvments + few other things
ntoskrnl/ntoskrnl.edf:
Added exports for IoGetDmaAdapter, IoIsWdmVersionAvailable,
KefAcquireSpinLockAtDpcLevel, KefReleaseSpinLockFromDpcLevel,
ExFreePoolWithTag.
ntoskrnl/io/driver.c:
Implementation of NtUnloadDriver.
ntoskrnl/io/device.c:
Added prepending "\\SystemRoot\" and displaying "PnP Loading xxx..." message
in IopInitializeDeviceNodeService.
ntoskrnl/io/pnpmgr.c:
Split into ntoskrnl/io/pnpmgr.c, ntoskrnl/io/deviface.c,
ntoskrnl/io/pnpnotify.c, ntoskrnl/io/pnpmgr/pnpdma.c,
ntoskrnl/io/pnpmgr.c, ntoskrnl/io/pnpmgr/pnproot.c,
ntoskrnl/io/remlock.c, ntoskrnl/io/pnpmgr/pnpreport.c.
Fixed registry handling in IopActionInterrogateDeviceStack and
IopActionConfigureChildServices.
Partial implementation of IoGetDeviceProperty.
ntoskrnl/io/pnpdma.c:
Implementation of IoGetDmaAdapter.
ntoskrnl/io/wdm.c:
New file. Contains implementation of IoIsWdmVersionAvailable.
ntoskrnl/ke/spinlock.c:
Added KeAcquireSpinLockAtDpcLevel and KefReleaseSpinLockFromDpcLevel.
ntoskrnl/mm/pool.c:
Partial implementation of ExFreePoolWithTag.
svn path=/trunk/; revision=6136
2003-09-25 15:54:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* EOF */
|