MdeModulePkg RamDiskDxe: Report ACPI NFIT for reserved memory RAM disks

The RamDiskDxe now will report RAM disks with reserved memory type to NFIT
in the ACPI table.

This commit will also make sure that an NVDIMM root device exists in the
\SB scope before reporting any RAM disk to NFIT.

To properly report the NVDIMM root device, one will need to append the
following content in the [Rule.Common.DXE_DRIVER] field in platform FDF
files:

RAW ACPI  Optional                |.acpi
RAW ASL   Optional                |.aml

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Feng Tian <feng.tian@intel.com>
Reviewed-by: Samer El-Haj-Mahmoud <elhaj@hpe.com>
This commit is contained in:
Hao Wu
2016-03-29 16:33:11 +08:00
parent 9f64a83484
commit 07a3fecd4c
5 changed files with 658 additions and 0 deletions

View File

@@ -34,6 +34,77 @@ EFI_RAM_DISK_PROTOCOL mRamDiskProtocol = {
LIST_ENTRY RegisteredRamDisks;
UINTN ListEntryNum;
//
// Pointers to the EFI_ACPI_TABLE_PROTOCOL and EFI_ACPI_SDT_PROTOCOL.
//
EFI_ACPI_TABLE_PROTOCOL *mAcpiTableProtocol = NULL;
EFI_ACPI_SDT_PROTOCOL *mAcpiSdtProtocol = NULL;
/**
Check whether EFI_ACPI_TABLE_PROTOCOL and EFI_ACPI_SDT_PROTOCOL are produced.
If both protocols are produced, publish all the reserved memory type RAM
disks to the NVDIMM Firmware Interface Table (NFIT).
@param[in] Event Event whose notification function is being invoked.
@param[in] Context The pointer to the notification function's context,
which is implementation-dependent.
**/
VOID
EFIAPI
RamDiskAcpiCheck (
IN EFI_EVENT Event,
IN VOID *Context
)
{
EFI_STATUS Status;
LIST_ENTRY *Entry;
RAM_DISK_PRIVATE_DATA *PrivateData;
gBS->CloseEvent (Event);
//
// Locate the EFI_ACPI_TABLE_PROTOCOL.
//
Status = gBS->LocateProtocol (
&gEfiAcpiTableProtocolGuid,
NULL,
(VOID **)&mAcpiTableProtocol
);
if (EFI_ERROR (Status)) {
DEBUG ((
EFI_D_INFO,
"RamDiskAcpiCheck: Cannot locate the EFI ACPI Table Protocol,",
"unable to publish RAM disks to NFIT.\n"
));
return;
}
//
// Locate the EFI_ACPI_SDT_PROTOCOL.
//
Status = gBS->LocateProtocol (
&gEfiAcpiSdtProtocolGuid,
NULL,
(VOID **)&mAcpiSdtProtocol
);
if (EFI_ERROR (Status)) {
DEBUG ((
EFI_D_INFO,
"RamDiskAcpiCheck: Cannot locate the EFI ACPI Sdt Protocol,",
"unable to publish RAM disks to NFIT.\n"
));
mAcpiTableProtocol = NULL;
return;
}
EFI_LIST_FOR_EACH (Entry, &RegisteredRamDisks) {
PrivateData = RAM_DISK_PRIVATE_FROM_THIS (Entry);
RamDiskPublishNfit (PrivateData);
}
}
/**
The entry point for RamDiskDxe driver.
@@ -58,6 +129,7 @@ RamDiskDxeEntryPoint (
EFI_STATUS Status;
RAM_DISK_CONFIG_PRIVATE_DATA *ConfigPrivate;
VOID *DummyInterface;
EFI_EVENT Event;
//
// If already started, return.
@@ -109,6 +181,14 @@ RamDiskDxeEntryPoint (
//
InitializeListHead (&RegisteredRamDisks);
Status = EfiCreateEventReadyToBootEx (
TPL_CALLBACK,
RamDiskAcpiCheck,
NULL,
&Event
);
ASSERT_EFI_ERROR (Status);
return EFI_SUCCESS;
ErrorExit: