]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelSiliconPkg/IntelVTdDxe/DmaProtection.h
IntelSiliconPkg/IntelVTdDxe: Update function comments
[mirror_edk2.git] / IntelSiliconPkg / IntelVTdDxe / DmaProtection.h
index 6efed6e555d1698ded000a72731c966b307b88fb..c311b298d1d1d81593a178d6cbcbc4548ca85f71 100644 (file)
@@ -25,6 +25,9 @@
 #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
@@ -41,6 +44,8 @@
 #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
@@ -56,6 +61,8 @@ typedef struct {
   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
@@ -66,6 +73,7 @@ typedef struct {
   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
@@ -122,40 +130,6 @@ DisableDmar (
   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
@@ -342,6 +316,7 @@ DumpSecondLevelPagingEntry (
   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
@@ -360,6 +335,7 @@ DumpSecondLevelPagingEntry (
 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
@@ -498,4 +474,20 @@ AllocateZeroPages (
   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