]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmaProtection.c
IntelSiliconPkg IntelVTdDxe: Use ACPI table event to get DMAR table
[mirror_edk2.git] / IntelSiliconPkg / Feature / VTd / IntelVTdDxe / DmaProtection.c
index 4a4d82e7f1069664219226653cda0b6e6a80852a..6052a0aebe45197d9fd81c8280bed467893b6a71 100644 (file)
@@ -13,7 +13,6 @@
 \r
 #include "DmaProtection.h"\r
 \r
-EFI_ACPI_SDT_PROTOCOL                   *mAcpiSdt;\r
 UINT64                                  mBelow4GMemoryLimit;\r
 UINT64                                  mAbove4GMemoryLimit;\r
 \r
@@ -350,11 +349,6 @@ SetupVtd (
   //\r
   // 1. setup\r
   //\r
-  DEBUG ((DEBUG_INFO, "GetDmarAcpiTable\n"));\r
-  Status = GetDmarAcpiTable ();\r
-  if (EFI_ERROR (Status)) {\r
-    return;\r
-  }\r
   DEBUG ((DEBUG_INFO, "ParseDmarAcpiTable\n"));\r
   Status = ParseDmarAcpiTableDrhd ();\r
   if (EFI_ERROR (Status)) {\r
@@ -399,27 +393,29 @@ SetupVtd (
 }\r
 \r
 /**\r
-  ACPI notification function.\r
+  Notification function of ACPI Table change.\r
+\r
+  This is a notification function registered on ACPI Table change event.\r
 \r
-  @param[in] Table    A pointer to the ACPI table header.\r
-  @param[in] Version  The ACPI table's version.\r
-  @param[in] TableKey The table key for this ACPI table.\r
+  @param  Event        Event whose notification function is being invoked.\r
+  @param  Context      Pointer to the notification function's context.\r
 \r
-  @retval EFI_SUCCESS The notification function is executed.\r
 **/\r
-EFI_STATUS\r
+VOID\r
 EFIAPI\r
 AcpiNotificationFunc (\r
-  IN EFI_ACPI_SDT_HEADER    *Table,\r
-  IN EFI_ACPI_TABLE_VERSION Version,\r
-  IN UINTN                  TableKey\r
+  IN EFI_EVENT        Event,\r
+  IN VOID             *Context\r
   )\r
 {\r
-  if (Table->Signature == EFI_ACPI_4_0_DMA_REMAPPING_TABLE_SIGNATURE) {\r
-    DEBUG((DEBUG_INFO, "Vtd AcpiNotificationFunc\n"));\r
-    SetupVtd ();\r
+  EFI_STATUS          Status;\r
+\r
+  Status = GetDmarAcpiTable ();\r
+  if (EFI_ERROR (Status)) {\r
+    return;\r
   }\r
-  return EFI_SUCCESS;\r
+  SetupVtd ();\r
+  gBS->CloseEvent (Event);\r
 }\r
 \r
 /**\r
@@ -474,11 +470,26 @@ InitializeDmaProtection (
   EFI_STATUS  Status;\r
   EFI_EVENT   ExitBootServicesEvent;\r
   EFI_EVENT   LegacyBootEvent;\r
-\r
-  Status = gBS->LocateProtocol (&gEfiAcpiSdtProtocolGuid, NULL, (VOID **) &mAcpiSdt);\r
+  EFI_EVENT   Event;\r
+  \r
+  Status = gBS->CreateEventEx (\r
+                  EVT_NOTIFY_SIGNAL,\r
+                  TPL_CALLBACK,\r
+                  AcpiNotificationFunc,\r
+                  NULL,\r
+                  &gEfiAcpi10TableGuid,\r
+                  &Event\r
+                  );\r
   ASSERT_EFI_ERROR (Status);\r
 \r
-  Status = mAcpiSdt->RegisterNotify (TRUE, AcpiNotificationFunc);\r
+  Status = gBS->CreateEventEx (\r
+                  EVT_NOTIFY_SIGNAL,\r
+                  TPL_CALLBACK,\r
+                  AcpiNotificationFunc,\r
+                  NULL,\r
+                  &gEfiAcpi20TableGuid,\r
+                  &Event\r
+                  );\r
   ASSERT_EFI_ERROR (Status);\r
 \r
   Status = gBS->CreateEventEx (\r