public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Leif Lindholm" <leif@nuviainc.com>
To: devel@edk2.groups.io
Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
Subject: [PATCH 5/9] ArmPkg: add ArmHasSecurityExtensions () helper function
Date: Fri, 18 Dec 2020 14:16:13 +0000	[thread overview]
Message-ID: <20201218141617.26947-6-leif@nuviainc.com> (raw)
In-Reply-To: <20201218141617.26947-1-leif@nuviainc.com>

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 <ard.biesheuvel@arm.com>
Signed-off-by: Leif Lindholm <leif@nuviainc.com>
---
 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 8a364f2ca96f..c2ed72112b73 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 3faada3a6539..9f81a7223732 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);
+}
-- 
2.20.1


  parent reply	other threads:[~2020-12-18 14:16 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-18 14:16 [PATCH 0/9] ArmPkg: Start cleaning up ID register handling Leif Lindholm
2020-12-18 14:16 ` [PATCH 1/9] ArmPkg/ArmLib: add ArmHasGicSystemRegisters () helper function Leif Lindholm
2020-12-18 14:16 ` [PATCH 2/9] ArmPkg: use ID register helper for ArmGicArch(Sec)Lib Leif Lindholm
2020-12-18 14:16 ` [PATCH 3/9] ArmPkg: remove duplicated ARM/AArch64 ArmGicArchLib sources Leif Lindholm
2020-12-18 14:16 ` [PATCH 4/9] ArmPkg: remove duplicated ARM/AArch64 ArmGicArchSecLib sources Leif Lindholm
2020-12-18 14:16 ` Leif Lindholm [this message]
2020-12-18 14:16 ` [PATCH 6/9] ArmPkg: use helper to check for Security extensions in ArmArchTimerLib Leif Lindholm
2020-12-18 14:16 ` [PATCH 7/9] ArmPkg/ArmLib: delete AArch64 version of ArmReadIdPfr1 Leif Lindholm
2020-12-18 14:16 ` [PATCH 8/9] ArmPkg/ArmLib: rename AArch64 variant of ArmReadIdPfr0 Leif Lindholm
2020-12-18 14:16 ` [PATCH 9/9] ArmPkg/ArmLib: move ArmReadIdPfr0/1 into private header ArmV7Lib.h Leif Lindholm
2020-12-18 15:02 ` [PATCH 0/9] ArmPkg: Start cleaning up ID register handling Ard Biesheuvel
2020-12-18 15:36   ` Leif Lindholm

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201218141617.26947-6-leif@nuviainc.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox