Author: cgutman
Date: Fri Mar 20 23:43:43 2009
New Revision: 40139
URL:
http://svn.reactos.org/svn/reactos?rev=40139&view=rev
Log:
- Implement NdisMCreateLog, NdisMCloseLog, and NdisMFlushLog
- Patch by Dmitry Chapyshev (with modifications by me)
Modified:
trunk/reactos/drivers/network/ndis/ndis/miniport.c
Modified: trunk/reactos/drivers/network/ndis/ndis/miniport.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/ndis/ndis/…
==============================================================================
--- trunk/reactos/drivers/network/ndis/ndis/miniport.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/ndis/ndis/miniport.c [iso-8859-1] Fri Mar 20 23:43:43
2009
@@ -1164,19 +1164,28 @@
/*
- * @unimplemented
+ * @implemented
*/
VOID
EXPORT
NdisMCloseLog(
IN NDIS_HANDLE LogHandle)
{
- UNIMPLEMENTED
-}
-
-
-/*
- * @unimplemented
+ PNDIS_LOG Log = (PNDIS_LOG)LogHandle;
+ PNDIS_MINIPORT_BLOCK Miniport = Log->Miniport;
+ KIRQL OldIrql;
+
+ NDIS_DbgPrint(MAX_TRACE, ("called: LogHandle 0x%x\n", LogHandle));
+
+ KeAcquireSpinLock(&(Miniport)->Lock, &OldIrql);
+ Miniport->Log = NULL;
+ KeReleaseSpinLock(&(Miniport)->Lock, OldIrql);
+
+ ExFreePool(Log);
+}
+
+/*
+ * @implemented
*/
NDIS_STATUS
EXPORT
@@ -1185,12 +1194,45 @@
IN UINT Size,
OUT PNDIS_HANDLE LogHandle)
{
- UNIMPLEMENTED
-
- return NDIS_STATUS_FAILURE;
-}
-
-
+ PLOGICAL_ADAPTER Adapter = MiniportAdapterHandle;
+ PNDIS_LOG Log;
+ KIRQL OldIrql;
+
+ NDIS_DbgPrint(MAX_TRACE, ("called: MiniportAdapterHandle 0x%x, Size %ld\n",
MiniportAdapterHandle, Size));
+
+ KeAcquireSpinLock(&Adapter->NdisMiniportBlock.Lock, &OldIrql);
+
+ if (Adapter->NdisMiniportBlock.Log)
+ {
+ *LogHandle = NULL;
+ return NDIS_STATUS_FAILURE;
+ }
+
+ Log = ExAllocatePool(NonPagedPool, Size + sizeof(NDIS_LOG));
+ if (!Log)
+ {
+ *LogHandle = NULL;
+ return NDIS_STATUS_RESOURCES;
+ }
+
+ Adapter->NdisMiniportBlock.Log = Log;
+
+ KeInitializeSpinLock(&Log->LogLock);
+
+ Log->Miniport = &Adapter->NdisMiniportBlock;
+ Log->TotalSize = Size;
+ Log->CurrentSize = 0;
+ Log->OutPtr = 0;
+ Log->InPtr = 0;
+ Log->Irp = NULL;
+
+ *LogHandle = Log;
+
+ KeReleaseSpinLock(&Adapter->NdisMiniportBlock.Lock, OldIrql);
+
+ return NDIS_STATUS_SUCCESS;
+}
+
/*
* @implemented
*/
@@ -1213,16 +1255,29 @@
}
}
-
-/*
- * @unimplemented
+/*
+ * @implemented
*/
VOID
EXPORT
NdisMFlushLog(
IN NDIS_HANDLE LogHandle)
{
- UNIMPLEMENTED
+ PNDIS_LOG Log = (PNDIS_LOG) LogHandle;
+ KIRQL OldIrql;
+
+ NDIS_DbgPrint(MAX_TRACE, ("called: LogHandle 0x%x\n", LogHandle));
+
+ /* Lock object */
+ KeAcquireSpinLock(&Log->LogLock, &OldIrql);
+
+ /* Set buffers size */
+ Log->CurrentSize = 0;
+ Log->OutPtr = 0;
+ Log->InPtr = 0;
+
+ /* Unlock object */
+ KeReleaseSpinLock(&Log->LogLock, OldIrql);
}
/*