- Implement NdisMAllocateSharedMemoryAsync

- Zero the entire packet in NdisAllocatePacket

svn path=/trunk/; revision=40270
This commit is contained in:
Cameron Gutman 2009-03-28 17:49:27 +00:00
parent 02258e7e39
commit efaf3a892a
4 changed files with 78 additions and 23 deletions

View file

@ -58,11 +58,13 @@ typedef struct _MINIPORT_BUGCHECK_CONTEXT {
/* a miniport's shared memory */
typedef struct _MINIPORT_SHARED_MEMORY {
PDMA_ADAPTER AdapterObject;
ULONG Length;
PHYSICAL_ADDRESS PhysicalAddress;
PVOID VirtualAddress;
BOOLEAN Cached;
PDMA_ADAPTER AdapterObject;
ULONG Length;
PHYSICAL_ADDRESS PhysicalAddress;
PVOID VirtualAddress;
BOOLEAN Cached;
PNDIS_MINIPORT_BLOCK Adapter;
PVOID Context;
} MINIPORT_SHARED_MEMORY, *PMINIPORT_SHARED_MEMORY;
/* A structure of WrapperConfigurationContext (not compatible with the

View file

@ -661,23 +661,6 @@ NdisMDeregisterIoPortRange(
UNIMPLEMENTED
}
/*
* @unimplemented
*/
NDIS_STATUS
EXPORT
NdisMAllocateSharedMemoryAsync(
IN NDIS_HANDLE MiniportAdapterHandle,
IN ULONG Length,
IN BOOLEAN Cached,
IN PVOID Context)
{
UNIMPLEMENTED
return NDIS_STATUS_FAILURE;
}
/*
* @unimplemented
*/
@ -701,6 +684,8 @@ NdisCopyBuffer(
* Length = Number of bytes to copy
*/
{
UNIMPLEMENTED
*Status = NDIS_STATUS_FAILURE;
}

View file

@ -424,7 +424,7 @@ NdisAllocatePacket(
KeReleaseSpinLock(&Pool->SpinLock.SpinLock, OldIrql);
RtlZeroMemory(&Temp->Private, sizeof(NDIS_PACKET_PRIVATE));
RtlZeroMemory(Temp, sizeof(NDIS_PACKET));
Temp->Private.Pool = Pool;
*Packet = Temp;

View file

@ -245,6 +245,74 @@ NdisMFreeSharedMemory(
ZwClose(ThreadHandle);
}
VOID
NTAPI
NdisMAllocateSharedMemoryPassive(
PVOID Context)
/*
* FUNCTION: Allocate a common buffer
* ARGUMENTS:
* Context: Pointer to a miniport shared memory context
* NOTES:
* - Called by NdisMAllocateSharedMemoryAsync to do the actual work
*/
{
PMINIPORT_SHARED_MEMORY Memory = (PMINIPORT_SHARED_MEMORY)Context;
NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
ASSERT(KeGetCurrentIrql() == PASSIVE_LEVEL);
Memory->VirtualAddress = Memory->AdapterObject->DmaOperations->AllocateCommonBuffer(
Memory->AdapterObject, Memory->Length, &Memory->PhysicalAddress, Memory->Cached);
if (Memory->Adapter->DriverHandle->MiniportCharacteristics.AllocateCompleteHandler)
Memory->Adapter->DriverHandle->MiniportCharacteristics.AllocateCompleteHandler(
Memory->Adapter, Memory->VirtualAddress, &Memory->PhysicalAddress, Memory->Length, Memory->Context);
ExFreePool(Memory);
}
/*
* @implemented
*/
NDIS_STATUS
EXPORT
NdisMAllocateSharedMemoryAsync(
IN NDIS_HANDLE MiniportAdapterHandle,
IN ULONG Length,
IN BOOLEAN Cached,
IN PVOID Context)
{
HANDLE ThreadHandle;
PLOGICAL_ADAPTER Adapter = (PLOGICAL_ADAPTER)MiniportAdapterHandle;
PMINIPORT_SHARED_MEMORY Memory;
NDIS_DbgPrint(MAX_TRACE,("Called.\n"));
ASSERT(KeGetCurrentIrql() <= DISPATCH_LEVEL);
/* Must be NonpagedPool because by definition we're at DISPATCH_LEVEL */
Memory = ExAllocatePool(NonPagedPool, sizeof(MINIPORT_SHARED_MEMORY));
if(!Memory)
{
NDIS_DbgPrint(MID_TRACE, ("Insufficient resources\n"));
return NDIS_STATUS_FAILURE;
}
Memory->AdapterObject = Adapter->NdisMiniportBlock.SystemAdapterObject;
Memory->Length = Length;
Memory->Cached = Cached;
Memory->Adapter = &Adapter->NdisMiniportBlock;
Memory->Context = Context;
PsCreateSystemThread(&ThreadHandle, THREAD_ALL_ACCESS, 0, 0, 0, NdisMAllocateSharedMemoryPassive, Memory);
ZwClose(ThreadHandle);
return NDIS_STATUS_PENDING;
}
/*
* @implemented