+\r
+ // If the mapped buffer is not an uncached buffer\r
+ if ( (GcdDescriptor.Attributes != EFI_MEMORY_WC) &&\r
+ (GcdDescriptor.Attributes != EFI_MEMORY_UC) )\r
+ {\r
+ //\r
+ // If the buffer does not fill entire cache lines we must double buffer into\r
+ // uncached memory. Device (PCI) address becomes uncached page.\r
+ //\r
+ Map->DoubleBuffer = TRUE;\r
+ Status = DmaAllocateBuffer (EfiBootServicesData, EFI_SIZE_TO_PAGES (*NumberOfBytes), &Buffer);\r
+ if (EFI_ERROR (Status)) {\r
+ return Status;\r
+ }\r
+\r
+ if ((Operation == MapOperationBusMasterRead) || (Operation == MapOperationBusMasterCommonBuffer)) {\r
+ CopyMem (Buffer, HostAddress, *NumberOfBytes);\r
+ }\r
+\r
+ *DeviceAddress = (PHYSICAL_ADDRESS)(UINTN)Buffer;\r
+ } else {\r
+ Map->DoubleBuffer = FALSE;\r
+ }\r