\r
// If the mapped buffer is not an uncached buffer\r
if ((GcdDescriptor.Attributes & (EFI_MEMORY_WB | EFI_MEMORY_WT)) != 0) {\r
+ //\r
+ // Operations of type MapOperationBusMasterCommonBuffer are only allowed\r
+ // on uncached buffers.\r
+ //\r
+ if (Operation == MapOperationBusMasterCommonBuffer) {\r
+ DEBUG ((EFI_D_ERROR,\r
+ "%a: Operation type 'MapOperationBusMasterCommonBuffer' is only supported\n"\r
+ "on memory regions that were allocated using DmaAllocateBuffer ()\n",\r
+ __FUNCTION__));\r
+ return EFI_UNSUPPORTED;\r
+ }\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
return Status;\r
}\r
\r
- if ((Operation == MapOperationBusMasterRead) || (Operation == MapOperationBusMasterCommonBuffer)) {\r
+ if (Operation == MapOperationBusMasterRead) {\r
CopyMem (Buffer, HostAddress, *NumberOfBytes);\r
}\r
\r
\r
@retval EFI_SUCCESS The range was unmapped.\r
@retval EFI_DEVICE_ERROR The data was not committed to the target system memory.\r
+ @retval EFI_INVALID_PARAMETER An inconsistency was detected between the mapping type\r
+ and the DoubleBuffer field\r
\r
**/\r
EFI_STATUS\r
)\r
{\r
MAP_INFO_INSTANCE *Map;\r
+ EFI_STATUS Status;\r
\r
if (Mapping == NULL) {\r
ASSERT (FALSE);\r
\r
Map = (MAP_INFO_INSTANCE *)Mapping;\r
\r
+ Status = EFI_SUCCESS;\r
if (Map->DoubleBuffer) {\r
- if ((Map->Operation == MapOperationBusMasterWrite) || (Map->Operation == MapOperationBusMasterCommonBuffer)) {\r
+ ASSERT (Map->Operation != MapOperationBusMasterCommonBuffer);\r
+\r
+ if (Map->Operation == MapOperationBusMasterCommonBuffer) {\r
+ Status = EFI_INVALID_PARAMETER;\r
+ } else if (Map->Operation == MapOperationBusMasterWrite) {\r
CopyMem ((VOID *)(UINTN)Map->HostAddress, (VOID *)(UINTN)Map->DeviceAddress, Map->NumberOfBytes);\r
}\r
\r
\r
FreePool (Map);\r
\r
- return EFI_SUCCESS;\r
+ return Status;\r
}\r
\r
/**\r