[edk2] [PATCH 3/3] ArmVirtPkg/PlatformPeiLib: take DT node 'status' property into account

Ard Biesheuvel posted 3 patches 7 years, 7 months ago
[edk2] [PATCH 3/3] ArmVirtPkg/PlatformPeiLib: take DT node 'status' property into account
Posted by Ard Biesheuvel 7 years, 7 months ago
In some cases, (e.g., when running QEMU with TrustZone emulation), the
DT may contain DT nodes whose status is set to 'secure'. Similarly, the
status may be set to 'disabled' if the consumer of the DT image is expected
to treat it as if it weren't there.

So check whether a 'status' property is present, and if so, ignore the node
if the status is not 'okay'.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c b/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c
index bdf2b57fcb1e..df52d3653360 100644
--- a/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c
+++ b/ArmVirtPkg/Library/PlatformPeiLib/PlatformPeiLib.c
@@ -39,7 +39,9 @@ PlatformPeim (
   INT32              Node, Prev;
   CONST CHAR8        *Compatible;
   CONST CHAR8        *CompItem;
+  CONST CHAR8        *NodeStatus;
   INT32              Len;
+  INT32              StatusLen;
   CONST UINT64       *RegProp;
   UINT64             UartBase;
 
@@ -83,6 +85,11 @@ PlatformPeim (
       CompItem += 1 + AsciiStrLen (CompItem)) {
 
       if (AsciiStrCmp (CompItem, "arm,pl011") == 0) {
+        NodeStatus = fdt_getprop (Base, Node, "status", &StatusLen);
+        if (NodeStatus != NULL && AsciiStrCmp (NodeStatus, "okay") != 0) {
+          continue;
+        }
+
         RegProp = fdt_getprop (Base, Node, "reg", &Len);
         ASSERT (Len == 16);
 
-- 
2.9.3

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel