@@ -26,19 +26,49 @@
#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
+EFI_STATUS
EFIAPI
ArmPsciResetSystemLibConstructor (
- VOID
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
)
{
- mArmPsciMethod = PcdGet32 (PcdArmPsciMethod);
- return RETURN_SUCCESS;
+ EFI_STATUS Status;
+ FDT_CLIENT_PROTOCOL *FdtClient;
+ CONST VOID *Prop;
+
+ Status = gBS->LocateProtocol (&gFdtClientProtocolGuid, NULL, (VOID **)&FdtClient);
+ if (EFI_ERROR (Status)) {
+ return 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;
}
/**
@@ -18,9 +18,9 @@ [Defines]
INF_VERSION = 0x00010005
BASE_NAME = ArmVirtPsciResetSystemLib
FILE_GUID = c81d76ed-66fa-44a3-ac4a-f163120187a9
- MODULE_TYPE = BASE
+ MODULE_TYPE = DXE_DRIVER
VERSION_STRING = 1.0
- LIBRARY_CLASS = EfiResetSystemLib
+ LIBRARY_CLASS = EfiResetSystemLib|DXE_DRIVER DXE_RUNTIME_DRIVER
CONSTRUCTOR = ArmPsciResetSystemLibConstructor
[Sources]
@@ -38,5 +38,8 @@ [LibraryClasses]
ArmSmcLib
ArmHvcLib
-[Pcd]
- gArmVirtTokenSpaceGuid.PcdArmPsciMethod
+[Protocols]
+ gFdtClientProtocolGuid
+
+[Depex]
+ gFdtClientProtocolGuid
Instead of relying on VirtFdtDxe to detect the PSCI method, move our EfiResetSystemLib to the FDT client protocol to interrogate the device tree directly. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> --- ArmVirtPkg/Library/ArmVirtPsciResetSystemLib/ArmVirtPsciResetSystemLib.c | 38 +++++++++++++++++--- ArmVirtPkg/Library/ArmVirtPsciResetSystemLib/ArmVirtPsciResetSystemLib.inf | 11 +++--- 2 files changed, 41 insertions(+), 8 deletions(-) -- 2.5.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel