ArmVirtPkg/ArmVirtPsciResetSystemLib: move to FDT client protocol

Instead of relying on VirtFdtDxe to detect the PSCI method, move our
EfiResetSystemLib to the FDT client protocol to interrogate the device
tree directly.

Since this library is only consumed by EmbeddedPkg/ResetRuntimeDxe, and
considering that the PCD is no longer set, and even removed completely in a
subsequent patch, this conversion is guaranteed to be safe.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
This commit is contained in:
Ard Biesheuvel 2016-04-08 11:44:53 +02:00
parent 6c6ac050d9
commit 93f9a23f87
2 changed files with 36 additions and 7 deletions

View File

@ -26,9 +26,12 @@
#include <Library/EfiResetSystemLib.h>
#include <Library/ArmSmcLib.h>
#include <Library/ArmHvcLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <IndustryStandard/ArmStdSmc.h>
#include <Protocol/FdtClient.h>
STATIC UINT32 mArmPsciMethod;
RETURN_STATUS
@ -37,8 +40,30 @@ ArmPsciResetSystemLibConstructor (
VOID
)
{
mArmPsciMethod = PcdGet32 (PcdArmPsciMethod);
return RETURN_SUCCESS;
EFI_STATUS Status;
FDT_CLIENT_PROTOCOL *FdtClient;
CONST VOID *Prop;
Status = gBS->LocateProtocol (&gFdtClientProtocolGuid, NULL,
(VOID **)&FdtClient);
ASSERT_EFI_ERROR (Status);
Status = FdtClient->FindCompatibleNodeProperty (FdtClient, "arm,psci-0.2",
"method", &Prop, NULL);
if (EFI_ERROR (Status)) {
return Status;
}
if (AsciiStrnCmp (Prop, "hvc", 3) == 0) {
mArmPsciMethod = 1;
} else if (AsciiStrnCmp (Prop, "smc", 3) == 0) {
mArmPsciMethod = 2;
} else {
DEBUG ((EFI_D_ERROR, "%a: Unknown PSCI method \"%a\"\n", __FUNCTION__,
Prop));
return EFI_NOT_FOUND;
}
return EFI_SUCCESS;
}
/**

View File

@ -20,7 +20,7 @@
FILE_GUID = c81d76ed-66fa-44a3-ac4a-f163120187a9
MODULE_TYPE = BASE
VERSION_STRING = 1.0
LIBRARY_CLASS = EfiResetSystemLib
LIBRARY_CLASS = EfiResetSystemLib|DXE_DRIVER DXE_RUNTIME_DRIVER
CONSTRUCTOR = ArmPsciResetSystemLibConstructor
[Sources]
@ -33,10 +33,14 @@
EmbeddedPkg/EmbeddedPkg.dec
[LibraryClasses]
DebugLib
BaseLib
ArmSmcLib
ArmHvcLib
BaseLib
DebugLib
UefiBootServicesTableLib
[Pcd]
gArmVirtTokenSpaceGuid.PcdArmPsciMethod
[Protocols]
gFdtClientProtocolGuid ## CONSUMES
[Depex]
gFdtClientProtocolGuid