ArmVirtPkg/FdtClientDxe: install DT configuration table at ReadyToBoot

Defer FDT configuration table installation until ReadyToBoot is signaled.
This allows any driver to make modifications in the mean time, and will
also allow us to defer the decision of whether to install it in the first
place to later on in the boot.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
This commit is contained in:
Ard Biesheuvel 2017-03-09 16:45:07 +01:00
parent d5256ba932
commit 18f6d4df9e
2 changed files with 41 additions and 9 deletions

View File

@ -20,6 +20,7 @@
#include <Library/HobLib.h> #include <Library/HobLib.h>
#include <libfdt.h> #include <libfdt.h>
#include <Guid/EventGroup.h>
#include <Guid/Fdt.h> #include <Guid/Fdt.h>
#include <Guid/FdtHob.h> #include <Guid/FdtHob.h>
@ -306,6 +307,30 @@ STATIC FDT_CLIENT_PROTOCOL mFdtClientProtocol = {
GetOrInsertChosenNode, GetOrInsertChosenNode,
}; };
STATIC
VOID
EFIAPI
OnReadyToBoot (
EFI_EVENT Event,
VOID *Context
)
{
EFI_STATUS Status;
if (!FeaturePcdGet (PcdPureAcpiBoot)) {
//
// Only install the FDT as a configuration table if we want to leave it up
// to the OS to decide whether it prefers ACPI over DT.
//
Status = gBS->InstallConfigurationTable (&gFdtTableGuid, mDeviceTreeBase);
ASSERT_EFI_ERROR (Status);
}
gBS->CloseEvent (Event);
}
STATIC EFI_EVENT mReadyToBootEvent;
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
InitializeFdtClientDxe ( InitializeFdtClientDxe (
@ -333,15 +358,21 @@ InitializeFdtClientDxe (
DEBUG ((EFI_D_INFO, "%a: DTB @ 0x%p\n", __FUNCTION__, mDeviceTreeBase)); DEBUG ((EFI_D_INFO, "%a: DTB @ 0x%p\n", __FUNCTION__, mDeviceTreeBase));
if (!FeaturePcdGet (PcdPureAcpiBoot)) { Status = gBS->InstallProtocolInterface (&ImageHandle, &gFdtClientProtocolGuid,
// EFI_NATIVE_INTERFACE, &mFdtClientProtocol);
// Only install the FDT as a configuration table if we want to leave it up if (EFI_ERROR (Status)) {
// to the OS to decide whether it prefers ACPI over DT. return Status;
//
Status = gBS->InstallConfigurationTable (&gFdtTableGuid, DeviceTreeBase);
ASSERT_EFI_ERROR (Status);
} }
return gBS->InstallProtocolInterface (&ImageHandle, &gFdtClientProtocolGuid, Status = gBS->CreateEventEx (
EFI_NATIVE_INTERFACE, &mFdtClientProtocol); EVT_NOTIFY_SIGNAL,
TPL_CALLBACK,
OnReadyToBoot,
NULL,
&gEfiEventReadyToBootGuid,
&mReadyToBootEvent
);
ASSERT_EFI_ERROR (Status);
return EFI_SUCCESS;
} }

View File

@ -42,6 +42,7 @@
gFdtClientProtocolGuid ## PRODUCES gFdtClientProtocolGuid ## PRODUCES
[Guids] [Guids]
gEfiEventReadyToBootGuid
gFdtHobGuid gFdtHobGuid
gFdtTableGuid gFdtTableGuid