Fix issue in DmaMap with buffers that are smaller than a cache line. Also make any buffer that is not an even quanta of cache lines double buffer.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10654 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
andrewfish 2010-07-15 17:27:13 +00:00
parent d34689b44a
commit 3ea3ff88e3
1 changed files with 6 additions and 3 deletions

View File

@ -95,7 +95,12 @@ DmaMap (
*Mapping = Map;
if (((UINTN)HostAddress & (gCacheAlignment - 1)) != 0) {
if ((((UINTN)HostAddress & (gCacheAlignment - 1)) != 0) ||
((*NumberOfBytes % gCacheAlignment) != 0)) {
//
// If the buffer does not fill entire cache lines we must double buffer into
// uncached memory. Device (PCI) address becomes uncached page.
//
Map->DoubleBuffer = TRUE;
Status = DmaAllocateBuffer (EfiBootServicesData, EFI_SIZE_TO_PAGES (*NumberOfBytes), &Buffer);
if (EFI_ERROR (Status)) {
@ -108,8 +113,6 @@ DmaMap (
Map->DoubleBuffer = FALSE;
}
*NumberOfBytes &= *NumberOfBytes & ~(gCacheAlignment - 1); // Only do it on full cache lines
Map->HostAddress = (UINTN)HostAddress;
Map->DeviceAddress = *DeviceAddress;
Map->NumberOfBytes = *NumberOfBytes;