IntelSiliconPkg IntelVTdDxe: Use ACPI table event to get DMAR table

Use ACPI table event to get DMAR table instead of using ACPI SDT
notification as ACPI SDT is optional and the default value of
PcdInstallAcpiSdtProtocol is FALSE in MdeModulePkg.dec.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
This commit is contained in:
Star Zeng 2017-10-25 17:23:03 +08:00
parent 3909c4a193
commit f6f486e7bf
4 changed files with 46 additions and 30 deletions

View File

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

View File

@ -36,7 +36,6 @@
#include <Protocol/PciRootBridgeIo.h> #include <Protocol/PciRootBridgeIo.h>
#include <Protocol/PciIo.h> #include <Protocol/PciIo.h>
#include <Protocol/PciEnumerationComplete.h> #include <Protocol/PciEnumerationComplete.h>
#include <Protocol/AcpiSystemDescriptionTable.h>
#include <Protocol/PlatformVtdPolicy.h> #include <Protocol/PlatformVtdPolicy.h>
#include <Protocol/IoMmu.h> #include <Protocol/IoMmu.h>

View File

@ -989,6 +989,10 @@ GetDmarAcpiTable (
VOID *AcpiTable; VOID *AcpiTable;
EFI_STATUS Status; EFI_STATUS Status;
if (mAcpiDmarTable != NULL) {
return EFI_SUCCESS;
}
AcpiTable = NULL; AcpiTable = NULL;
Status = EfiGetSystemConfigurationTable ( Status = EfiGetSystemConfigurationTable (
&gEfiAcpi20TableGuid, &gEfiAcpi20TableGuid,
@ -1006,10 +1010,10 @@ GetDmarAcpiTable (
(EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *)AcpiTable, (EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER *)AcpiTable,
EFI_ACPI_4_0_DMA_REMAPPING_TABLE_SIGNATURE EFI_ACPI_4_0_DMA_REMAPPING_TABLE_SIGNATURE
); );
DEBUG ((DEBUG_INFO,"DMAR Table - 0x%08x\n", mAcpiDmarTable));
if (mAcpiDmarTable == NULL) { if (mAcpiDmarTable == NULL) {
return EFI_UNSUPPORTED; return EFI_NOT_FOUND;
} }
DEBUG ((DEBUG_INFO,"DMAR Table - 0x%08x\n", mAcpiDmarTable));
VtdDumpDmarTable(); VtdDumpDmarTable();
return EFI_SUCCESS; return EFI_SUCCESS;

View File

@ -63,12 +63,15 @@
[Guids] [Guids]
gEfiEventExitBootServicesGuid ## CONSUMES ## Event gEfiEventExitBootServicesGuid ## CONSUMES ## Event
gEfiAcpi20TableGuid ## CONSUMES ## SystemTable ## CONSUMES ## SystemTable
gEfiAcpi10TableGuid ## CONSUMES ## SystemTable ## CONSUMES ## Event
gEfiAcpi20TableGuid
## CONSUMES ## SystemTable
## CONSUMES ## Event
gEfiAcpi10TableGuid
[Protocols] [Protocols]
gEdkiiIoMmuProtocolGuid ## PRODUCES gEdkiiIoMmuProtocolGuid ## PRODUCES
gEfiAcpiSdtProtocolGuid ## CONSUMES
gEfiPciIoProtocolGuid ## CONSUMES gEfiPciIoProtocolGuid ## CONSUMES
gEfiPciEnumerationCompleteProtocolGuid ## CONSUMES gEfiPciEnumerationCompleteProtocolGuid ## CONSUMES
gEdkiiPlatformVTdPolicyProtocolGuid ## SOMETIMES_CONSUMES gEdkiiPlatformVTdPolicyProtocolGuid ## SOMETIMES_CONSUMES
@ -77,8 +80,7 @@
gIntelSiliconPkgTokenSpaceGuid.PcdVTdPolicyPropertyMask ## CONSUMES gIntelSiliconPkgTokenSpaceGuid.PcdVTdPolicyPropertyMask ## CONSUMES
[Depex] [Depex]
gEfiPciRootBridgeIoProtocolGuid AND gEfiPciRootBridgeIoProtocolGuid
gEfiAcpiSdtProtocolGuid
[UserExtensions.TianoCore."ExtraFiles"] [UserExtensions.TianoCore."ExtraFiles"]
IntelVTdDxeExtra.uni IntelVTdDxeExtra.uni