]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelSiliconPkg/Feature/VTd/IntelVTdDxe/DmaProtection.c
IntelSiliconPkg IntelVTdDxe: Signal AcpiNotificationFunc() initially
[mirror_edk2.git] / IntelSiliconPkg / Feature / VTd / IntelVTdDxe / DmaProtection.c
index f5de01f3806cc35a87cac2311049c77b00272a75..648f64c20b7751690d8cda38cc25bf93c1b57c90 100644 (file)
@@ -1,6 +1,6 @@
 /** @file\r
 \r
-  Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2017 - 2018, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -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,32 @@ SetupVtd (
 }\r
 \r
 /**\r
-  ACPI notification function.\r
+  Notification function of ACPI Table change.\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
+  This is a notification function registered on ACPI Table change event.\r
+\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
+    if (Status == EFI_ALREADY_STARTED) {\r
+      gBS->CloseEvent (Event);\r
+    }\r
+    return;\r
   }\r
-  return EFI_SUCCESS;\r
+  SetupVtd ();\r
+  gBS->CloseEvent (Event);\r
 }\r
 \r
 /**\r
@@ -474,16 +473,39 @@ InitializeDmaProtection (
   EFI_STATUS  Status;\r
   EFI_EVENT   ExitBootServicesEvent;\r
   EFI_EVENT   LegacyBootEvent;\r
-\r
-  Status = gBS->LocateProtocol (&gEfiAcpiSdtProtocolGuid, NULL, (VOID **) &mAcpiSdt);\r
+  EFI_EVENT   EventAcpi10;\r
+  EFI_EVENT   EventAcpi20;\r
+  \r
+  Status = gBS->CreateEventEx (\r
+                  EVT_NOTIFY_SIGNAL,\r
+                  TPL_CALLBACK,\r
+                  AcpiNotificationFunc,\r
+                  NULL,\r
+                  &gEfiAcpi10TableGuid,\r
+                  &EventAcpi10\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
+                  &EventAcpi20\r
+                  );\r
   ASSERT_EFI_ERROR (Status);\r
 \r
+  //\r
+  // Signal the events initially for the case\r
+  // that DMAR table has been installed.\r
+  //\r
+  gBS->SignalEvent (EventAcpi20);\r
+  gBS->SignalEvent (EventAcpi10);\r
+\r
   Status = gBS->CreateEventEx (\r
                   EVT_NOTIFY_SIGNAL,\r
-                  TPL_NOTIFY,\r
+                  TPL_CALLBACK,\r
                   OnExitBootServices,\r
                   NULL,\r
                   &gEfiEventExitBootServicesGuid,\r
@@ -492,7 +514,7 @@ InitializeDmaProtection (
   ASSERT_EFI_ERROR (Status);\r
 \r
   Status = EfiCreateEventLegacyBootEx (\r
-             TPL_NOTIFY,\r
+             TPL_CALLBACK,\r
              OnLegacyBoot,\r
              NULL,\r
              &LegacyBootEvent\r