#include <Library/PciSegmentLib.h>\r
#include <Library/DebugLib.h>\r
#include <Library/UefiLib.h>\r
+#include <Library/CacheMaintenanceLib.h>\r
+#include <Library/PerformanceLib.h>\r
+#include <Library/PrintLib.h>\r
\r
#include <Guid/EventGroup.h>\r
#include <Guid/Acpi.h>\r
#include <IndustryStandard/DmaRemappingReportingTable.h>\r
#include <IndustryStandard/Vtd.h>\r
\r
+#define VTD_64BITS_ADDRESS(Lo, Hi) (LShiftU64 (Lo, 12) | LShiftU64 (Hi, 32))\r
+\r
#define ALIGN_VALUE_UP(Value, Alignment) (((Value) + (Alignment) - 1) & (~((Alignment) - 1)))\r
#define ALIGN_VALUE_LOW(Value, Alignment) ((Value) & (~((Alignment) - 1)))\r
\r
UINTN PciDescriptorMaxNumber;\r
BOOLEAN *IsRealPciDevice;\r
VTD_SOURCE_ID *PciDescriptors;\r
+ // for statistic analysis\r
+ UINTN *AccessCount;\r
} PCI_DEVICE_INFORMATION;\r
\r
typedef struct {\r
VTD_ROOT_ENTRY *RootEntryTable;\r
VTD_EXT_ROOT_ENTRY *ExtRootEntryTable;\r
VTD_SECOND_LEVEL_PAGING_ENTRY *FixedSecondLevelPagingEntry;\r
+ BOOLEAN HasDirtyContext;\r
BOOLEAN HasDirtyPages;\r
PCI_DEVICE_INFORMATION PciDeviceInfo;\r
} VTD_UNIT_INFORMATION;\r
VOID\r
);\r
\r
-/**\r
- Invalid VTd IOTLB page.\r
-\r
- @param[in] VtdIndex The index of VTd engine.\r
- @param[in] Address The address of IOTLB page.\r
- @param[in] AddressMode The address mode of IOTLB page.\r
- @param[in] DomainIdentifier The domain ID of the source.\r
-\r
- @retval EFI_SUCCESS VTd IOTLB page is invalidated.\r
- @retval EFI_DEVICE_ERROR VTd IOTLB page is not invalidated.\r
-**/\r
-EFI_STATUS\r
-InvalidateVtdIOTLBPage (\r
- IN UINTN VtdIndex,\r
- IN UINT64 Address,\r
- IN UINT8 AddressMode,\r
- IN UINT16 DomainIdentifier\r
- );\r
-\r
-/**\r
- Invalid VTd IOTLB domain.\r
-\r
- @param[in] VtdIndex The index of VTd engine.\r
- @param[in] DomainIdentifier The domain ID of the source.\r
-\r
- @retval EFI_SUCCESS VTd IOTLB domain is invalidated.\r
- @retval EFI_DEVICE_ERROR VTd IOTLB domain is not invalidated.\r
-**/\r
-EFI_STATUS\r
-InvalidateVtdIOTLBDomain (\r
- IN UINTN VtdIndex,\r
- IN UINT16 DomainIdentifier\r
- );\r
-\r
/**\r
Invalid VTd global IOTLB.\r
\r
Set VTd attribute for a system memory.\r
\r
@param[in] VtdIndex The index used to identify a VTd engine.\r
+ @param[in] DomainIdentifier The domain ID of the source.\r
@param[in] SecondLevelPagingEntry The second level paging entry in VTd table for the device.\r
@param[in] BaseAddress The base of device memory address to be used as the DMA memory.\r
@param[in] Length The length of device memory address to be used as the DMA memory.\r
EFI_STATUS\r
SetPageAttribute (\r
IN UINTN VtdIndex,\r
+ IN UINT16 DomainIdentifier,\r
IN VTD_SECOND_LEVEL_PAGING_ENTRY *SecondLevelPagingEntry,\r
IN UINT64 BaseAddress,\r
IN UINT64 Length,\r
IN UINTN Pages\r
);\r
\r
+/**\r
+ Flush VTD page table and context table memory.\r
+\r
+ This action is to make sure the IOMMU engine can get final data in memory.\r
+\r
+ @param[in] VtdIndex The index used to identify a VTd engine.\r
+ @param[in] Base The base address of memory to be flushed.\r
+ @param[in] Size The size of memory in bytes to be flushed.\r
+**/\r
+VOID\r
+FlushPageTableMemory (\r
+ IN UINTN VtdIndex,\r
+ IN UINTN Base,\r
+ IN UINTN Size\r
+ );\r
+\r
#endif\r