Author: cgutman
Date: Sat Mar 28 20:49:27 2009
New Revision: 40270
URL:
http://svn.reactos.org/svn/reactos?rev=40270&view=rev
Log:
- Implement NdisMAllocateSharedMemoryAsync
- Zero the entire packet in NdisAllocatePacket
Modified:
trunk/reactos/drivers/network/ndis/include/miniport.h
trunk/reactos/drivers/network/ndis/ndis/50stubs.c
trunk/reactos/drivers/network/ndis/ndis/buffer.c
trunk/reactos/drivers/network/ndis/ndis/memory.c
Modified: trunk/reactos/drivers/network/ndis/include/miniport.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/ndis/inclu…
==============================================================================
--- trunk/reactos/drivers/network/ndis/include/miniport.h [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/ndis/include/miniport.h [iso-8859-1] Sat Mar 28 20:49:27
2009
@@ -58,11 +58,13 @@
/* 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
Modified: trunk/reactos/drivers/network/ndis/ndis/50stubs.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/ndis/ndis/…
==============================================================================
--- trunk/reactos/drivers/network/ndis/ndis/50stubs.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/ndis/ndis/50stubs.c [iso-8859-1] Sat Mar 28 20:49:27
2009
@@ -661,23 +661,6 @@
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 @@
* Length = Number of bytes to copy
*/
{
+ UNIMPLEMENTED
+
*Status = NDIS_STATUS_FAILURE;
}
Modified: trunk/reactos/drivers/network/ndis/ndis/buffer.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/ndis/ndis/…
==============================================================================
--- trunk/reactos/drivers/network/ndis/ndis/buffer.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/ndis/ndis/buffer.c [iso-8859-1] Sat Mar 28 20:49:27
2009
@@ -424,7 +424,7 @@
KeReleaseSpinLock(&Pool->SpinLock.SpinLock, OldIrql);
- RtlZeroMemory(&Temp->Private, sizeof(NDIS_PACKET_PRIVATE));
+ RtlZeroMemory(Temp, sizeof(NDIS_PACKET));
Temp->Private.Pool = Pool;
*Packet = Temp;
Modified: trunk/reactos/drivers/network/ndis/ndis/memory.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/ndis/ndis/…
==============================================================================
--- trunk/reactos/drivers/network/ndis/ndis/memory.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/ndis/ndis/memory.c [iso-8859-1] Sat Mar 28 20:49:27
2009
@@ -245,6 +245,74 @@
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