/** @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
\r
#include "DmaProtection.h"\r
\r
-EFI_ACPI_SDT_PROTOCOL *mAcpiSdt;\r
UINT64 mBelow4GMemoryLimit;\r
UINT64 mAbove4GMemoryLimit;\r
\r
//\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
}\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
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_CALLBACK,\r