From 3a10e56852c8280a50c48d7add6c8bf9b73a49bc Mon Sep 17 00:00:00 2001 From: Filip Navara Date: Sun, 4 Sep 2005 10:02:19 +0000 Subject: [PATCH] - Set the MAP_BASE_SW_SG flag for map registers in IoFreeMapRegisters. - Fix address calculation in HalpCopyBufferMap. - Correctly set the map register counter in IoMapTransfer if dealing with MAP_BASE_SW_SG map registers. svn path=/trunk/; revision=17629 --- reactos/hal/halx86/generic/dma.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/reactos/hal/halx86/generic/dma.c b/reactos/hal/halx86/generic/dma.c index fd0e03863aa..e5bb32796eb 100644 --- a/reactos/hal/halx86/generic/dma.c +++ b/reactos/hal/halx86/generic/dma.c @@ -1402,6 +1402,13 @@ IoFreeMapRegisters( AdapterObject->MapRegisterBase = MasterAdapter->MapRegisterBase + Index; + if (!AdapterObject->ScatterGather) + { + AdapterObject->MapRegisterBase = + (PMAP_REGISTER_ENTRY)( + (ULONG_PTR)AdapterObject->MapRegisterBase | + MAP_BASE_SW_SG); + } Result = ((PDRIVER_CONTROL)AdapterObject->CurrentWcb->DeviceRoutine)( AdapterObject->CurrentWcb->DeviceObject, @@ -1471,7 +1478,8 @@ HalpCopyBufferMap( KEBUGCHECK(0); } - CurrentAddress = (ULONG_PTR)CurrentVa - + CurrentAddress = (ULONG_PTR)VirtualAddress + + (ULONG_PTR)CurrentVa - (ULONG_PTR)MmGetMdlVirtualAddress(Mdl); while (Length > 0) @@ -1583,7 +1591,7 @@ IoFlushAdapterBuffers( Length -= HalReadDmaCounter(AdapterObject); } - HalpCopyBufferMap(Mdl, RealMapRegisterBase, CurrentVa, Length, 0); + HalpCopyBufferMap(Mdl, RealMapRegisterBase, CurrentVa, Length, FALSE); } else { @@ -1763,7 +1771,7 @@ IoMapTransfer( RealMapRegisterBase->Counter += BYTES_TO_PAGES(ByteOffset + TransferLength); /* - * Check if the buffer doesn't exceed the highest phisical address + * Check if the buffer doesn't exceed the highest physical address * limit of the device. In that case we must use the map registers to * store the data. */ @@ -1775,6 +1783,10 @@ IoMapTransfer( UseMapRegisters = TRUE; PhysicalAddress = RealMapRegisterBase->PhysicalAddress; PhysicalAddress.QuadPart += ByteOffset; + if ((ULONG_PTR)MapRegisterBase & MAP_BASE_SW_SG) + { + RealMapRegisterBase->Counter = ~0; + } } }