- Make NdisMAllocateSharedMemoryAsync and NdisMFreeSharedMemory safe to call at IRQL <= DISPATCH_LEVEL
svn path=/trunk/; revision=54557
BOOLEAN Cached;
PNDIS_MINIPORT_BLOCK Adapter;
PVOID Context;
BOOLEAN Cached;
PNDIS_MINIPORT_BLOCK Adapter;
PVOID Context;
} MINIPORT_SHARED_MEMORY, *PMINIPORT_SHARED_MEMORY;
/* A structure of WrapperConfigurationContext (not compatible with the
} MINIPORT_SHARED_MEMORY, *PMINIPORT_SHARED_MEMORY;
/* A structure of WrapperConfigurationContext (not compatible with the
VOID
NTAPI
NdisMFreeSharedMemoryPassive(
VOID
NTAPI
NdisMFreeSharedMemoryPassive(
+ PDEVICE_OBJECT DeviceObject,
PVOID Context)
/*
* FUNCTION: Free a common buffer
PVOID Context)
/*
* FUNCTION: Free a common buffer
*/
{
PMINIPORT_SHARED_MEMORY Memory = (PMINIPORT_SHARED_MEMORY)Context;
*/
{
PMINIPORT_SHARED_MEMORY Memory = (PMINIPORT_SHARED_MEMORY)Context;
- PRKEVENT Event = Memory->Event;
NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
Memory->AdapterObject, Memory->Length, Memory->PhysicalAddress,
Memory->VirtualAddress, Memory->Cached);
Memory->AdapterObject, Memory->Length, Memory->PhysicalAddress,
Memory->VirtualAddress, Memory->Cached);
+ IoFreeWorkItem(Memory->WorkItem);
-
- KeSetEvent(Event,
- IO_NO_INCREMENT,
- FALSE);
* Therefore we have to do this in a worker thread.
*/
{
* Therefore we have to do this in a worker thread.
*/
{
PLOGICAL_ADAPTER Adapter = (PLOGICAL_ADAPTER)MiniportAdapterHandle;
PMINIPORT_SHARED_MEMORY Memory;
PLOGICAL_ADAPTER Adapter = (PLOGICAL_ADAPTER)MiniportAdapterHandle;
PMINIPORT_SHARED_MEMORY Memory;
NDIS_DbgPrint(MAX_TRACE,("Called.\n"));
NDIS_DbgPrint(MAX_TRACE,("Called.\n"));
- KeInitializeEvent(&Event, NotificationEvent, FALSE);
-
Memory->AdapterObject = Adapter->NdisMiniportBlock.SystemAdapterObject;
Memory->Length = Length;
Memory->PhysicalAddress = PhysicalAddress;
Memory->VirtualAddress = VirtualAddress;
Memory->Cached = Cached;
Memory->Adapter = &Adapter->NdisMiniportBlock;
Memory->AdapterObject = Adapter->NdisMiniportBlock.SystemAdapterObject;
Memory->Length = Length;
Memory->PhysicalAddress = PhysicalAddress;
Memory->VirtualAddress = VirtualAddress;
Memory->Cached = Cached;
Memory->Adapter = &Adapter->NdisMiniportBlock;
- Memory->Event = &Event;
- PsCreateSystemThread(&ThreadHandle, THREAD_ALL_ACCESS, 0, 0, 0, NdisMFreeSharedMemoryPassive, Memory);
- ZwClose(ThreadHandle);
+ Memory->WorkItem = IoAllocateWorkItem(Adapter->NdisMiniportBlock.DeviceObject);
+ if (!Memory->WorkItem)
+ {
+ NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources\n"));
+ ExFreePool(Memory);
+ return;
+ }
- KeWaitForSingleObject(&Event,
- Executive,
- KernelMode,
- FALSE,
- NULL);
+ IoQueueWorkItem(Memory->WorkItem,
+ NdisMFreeSharedMemoryPassive,
+ CriticalWorkQueue,
+ Memory);
}
VOID
NTAPI
NdisMAllocateSharedMemoryPassive(
}
VOID
NTAPI
NdisMAllocateSharedMemoryPassive(
+ PDEVICE_OBJECT DeviceObject,
PVOID Context)
/*
* FUNCTION: Allocate a common buffer
PVOID Context)
/*
* FUNCTION: Allocate a common buffer
Memory->Adapter->MiniportAdapterContext, Memory->VirtualAddress,
&Memory->PhysicalAddress, Memory->Length, Memory->Context);
Memory->Adapter->MiniportAdapterContext, Memory->VirtualAddress,
&Memory->PhysicalAddress, Memory->Length, Memory->Context);
+ IoFreeWorkItem(Memory->WorkItem);
IN BOOLEAN Cached,
IN PVOID Context)
{
IN BOOLEAN Cached,
IN PVOID Context)
{
PLOGICAL_ADAPTER Adapter = (PLOGICAL_ADAPTER)MiniportAdapterHandle;
PMINIPORT_SHARED_MEMORY Memory;
PLOGICAL_ADAPTER Adapter = (PLOGICAL_ADAPTER)MiniportAdapterHandle;
PMINIPORT_SHARED_MEMORY Memory;
Memory->Adapter = &Adapter->NdisMiniportBlock;
Memory->Context = Context;
Memory->Adapter = &Adapter->NdisMiniportBlock;
Memory->Context = Context;
- PsCreateSystemThread(&ThreadHandle, THREAD_ALL_ACCESS, 0, 0, 0, NdisMAllocateSharedMemoryPassive, Memory);
- ZwClose(ThreadHandle);
+ Memory->WorkItem = IoAllocateWorkItem(Adapter->NdisMiniportBlock.DeviceObject);
+ if (!Memory->WorkItem)
+ {
+ NDIS_DbgPrint(MIN_TRACE, ("Insufficient resources\n"));
+ ExFreePool(Memory);
+ return NDIS_STATUS_FAILURE;
+ }
+
+ IoQueueWorkItem(Memory->WorkItem,
+ NdisMAllocateSharedMemoryPassive,
+ DelayedWorkQueue,
+ Memory);
return NDIS_STATUS_PENDING;
}
return NDIS_STATUS_PENDING;
}