Author: cgutman
Date: Fri May 22 05:26:18 2009
New Revision: 41039
URL:
http://svn.reactos.org/svn/reactos?rev=41039&view=rev
Log:
- Fix our DMA implementation to use documented structs
Modified:
trunk/reactos/drivers/network/ndis/ndis/io.c
Modified: trunk/reactos/drivers/network/ndis/ndis/io.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/drivers/network/ndis/ndis/…
==============================================================================
--- trunk/reactos/drivers/network/ndis/ndis/io.c [iso-8859-1] (original)
+++ trunk/reactos/drivers/network/ndis/ndis/io.c [iso-8859-1] Fri May 22 05:26:18 2009
@@ -503,14 +503,17 @@
VOID
EXPORT
NdisMDeregisterDmaChannel(
- IN PNDIS_HANDLE MiniportDmaHandle)
-{
- PNDIS_MINIPORT_BLOCK NdisMiniportBlock = (PNDIS_MINIPORT_BLOCK)MiniportDmaHandle;
- PDMA_ADAPTER AdapterObject = NdisMiniportBlock->SystemAdapterObject;
+ IN NDIS_HANDLE MiniportDmaHandle)
+{
+ PNDIS_DMA_BLOCK DmaBlock = MiniportDmaHandle;
+ PDMA_ADAPTER AdapterObject = (PDMA_ADAPTER)DmaBlock->SystemAdapterObject;
+
+ if (AdapterObject ==
((PLOGICAL_ADAPTER)DmaBlock->Miniport)->NdisMiniportBlock.SystemAdapterObject)
+
((PLOGICAL_ADAPTER)DmaBlock->Miniport)->NdisMiniportBlock.SystemAdapterObject =
NULL;
AdapterObject->DmaOperations->PutDmaAdapter(AdapterObject);
- NdisMiniportBlock->SystemAdapterObject = NULL;
+ ExFreePool(DmaBlock);
}
@@ -650,13 +653,10 @@
NdisMReadDmaCounter(
IN NDIS_HANDLE MiniportDmaHandle)
{
- PNDIS_MINIPORT_BLOCK MiniportBlock = (PNDIS_MINIPORT_BLOCK)MiniportDmaHandle;
- PDMA_ADAPTER AdapterObject = MiniportBlock->SystemAdapterObject;
-
- NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
-
- if (AdapterObject == NULL)
- return 0;
+ PNDIS_DMA_BLOCK DmaBlock = MiniportDmaHandle;
+ PDMA_ADAPTER AdapterObject = (PDMA_ADAPTER)DmaBlock->SystemAdapterObject;
+
+ NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
return AdapterObject->DmaOperations->ReadDmaCounter(AdapterObject);
}
@@ -670,13 +670,10 @@
NdisMGetDmaAlignment(
IN NDIS_HANDLE MiniportDmaHandle)
{
- PNDIS_MINIPORT_BLOCK MiniportBlock = (PNDIS_MINIPORT_BLOCK)MiniportDmaHandle;
- PDMA_ADAPTER AdapterObject = MiniportBlock->SystemAdapterObject;
-
- NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
-
- if (AdapterObject == NULL)
- return 0;
+ PNDIS_DMA_BLOCK DmaBlock = MiniportDmaHandle;
+ PDMA_ADAPTER AdapterObject = (PDMA_ADAPTER)DmaBlock->SystemAdapterObject;
+
+ NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
return AdapterObject->DmaOperations->GetDmaAlignment(AdapterObject);
}
@@ -698,15 +695,9 @@
PLOGICAL_ADAPTER Adapter = (PLOGICAL_ADAPTER)MiniportAdapterHandle;
DEVICE_DESCRIPTION DeviceDesc;
ULONG MapRegisters;
-
- NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
-
- if (Adapter->NdisMiniportBlock.SystemAdapterObject)
- {
- NDIS_DbgPrint(MIN_TRACE,("Using existing DMA adapter\n"));
- *MiniportDmaHandle = &Adapter->NdisMiniportBlock;
- return NDIS_STATUS_SUCCESS;
- }
+ PNDIS_DMA_BLOCK DmaBlock;
+
+ NDIS_DbgPrint(MAX_TRACE, ("Called.\n"));
RtlZeroMemory(&DeviceDesc, sizeof(DEVICE_DESCRIPTION));
@@ -724,13 +715,23 @@
DeviceDesc.DmaSpeed = DmaDescription->DmaSpeed;
DeviceDesc.MaximumLength = MaximumLength;
- Adapter->NdisMiniportBlock.SystemAdapterObject =
- IoGetDmaAdapter(Adapter->NdisMiniportBlock.PhysicalDeviceObject,
&DeviceDesc, &MapRegisters);
-
- if (!Adapter->NdisMiniportBlock.SystemAdapterObject)
+
+ DmaBlock = ExAllocatePool(NonPagedPool, sizeof(NDIS_DMA_BLOCK));
+ if (!DmaBlock)
return NDIS_STATUS_RESOURCES;
- *MiniportDmaHandle = &Adapter->NdisMiniportBlock;
+ DmaBlock->SystemAdapterObject =
(PVOID)IoGetDmaAdapter(Adapter->NdisMiniportBlock.PhysicalDeviceObject,
&DeviceDesc, &MapRegisters);
+
+ if (!DmaBlock->SystemAdapterObject) {
+ ExFreePool(DmaBlock);
+ return NDIS_STATUS_RESOURCES;
+ }
+
+ Adapter->NdisMiniportBlock.SystemAdapterObject =
(PDMA_ADAPTER)DmaBlock->SystemAdapterObject;
+
+ DmaBlock->Miniport = Adapter;
+
+ *MiniportDmaHandle = DmaBlock;
return NDIS_STATUS_SUCCESS;
}