From 740b870dc8660906523c85187ab5badd2fd8ea08 Mon Sep 17 00:00:00 2001 From: Leif Lindholm Date: Fri, 18 Dec 2020 13:21:08 +0000 Subject: [PATCH] ArmPkg: add ArmHasSecurityExtensions () helper function Create a helper function to eliminate direct feature register reading. Returns BOOLEAN True if the CPU implements the Security extensions, otherwise returns BOOL False. This function is only implemented for ARM, not AArch64. Cc: Ard Biesheuvel Signed-off-by: Leif Lindholm Reviewed-by: Ard Biesheuvel --- ArmPkg/Include/Library/ArmLib.h | 17 +++++++++++++++++ ArmPkg/Library/ArmLib/Arm/ArmV7Lib.c | 15 +++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/ArmPkg/Include/Library/ArmLib.h b/ArmPkg/Include/Library/ArmLib.h index 8a364f2ca9..c2ed72112b 100644 --- a/ArmPkg/Include/Library/ArmLib.h +++ b/ArmPkg/Include/Library/ArmLib.h @@ -733,4 +733,21 @@ ArmHasGicSystemRegisters ( VOID ); +#ifdef MDE_CPU_ARM +/// +/// AArch32-only ID Register Helper functions +/// +/** + Check whether the CPU supports the Security extensions + + @return Whether the Security extensions are implemented + +**/ +BOOLEAN +EFIAPI +ArmHasSecurityExtensions ( + VOID + ); +#endif // MDE_CPU_ARM + #endif // __ARM_LIB__ diff --git a/ArmPkg/Library/ArmLib/Arm/ArmV7Lib.c b/ArmPkg/Library/ArmLib/Arm/ArmV7Lib.c index 3faada3a65..9f81a72237 100644 --- a/ArmPkg/Library/ArmLib/Arm/ArmV7Lib.c +++ b/ArmPkg/Library/ArmLib/Arm/ArmV7Lib.c @@ -87,3 +87,18 @@ ArmHasGicSystemRegisters ( { return ((ArmReadIdPfr1 () & ARM_PFR1_GIC) != 0); } + +/** + Check whether the CPU supports the Security extensions + + @return Whether the Security extensions are implemented + +**/ +BOOLEAN +EFIAPI +ArmHasSecurityExtensions ( + VOID + ) +{ + return ((ArmReadIdPfr1 () & ARM_PFR1_SEC) != 0); +}