]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ArmVirtPkg/FdtClientDxe/FdtClientDxe.c
ArmVirtPkg/FdtClientDxe: take DT node 'status' properties into account
[mirror_edk2.git] / ArmVirtPkg / FdtClientDxe / FdtClientDxe.c
index fb6e0aeb9215e122ece6f8074715c7ad7a0aae2f..5bfde381ecd0d53996272771bdee6ebe5d5ada96 100644 (file)
@@ -78,6 +78,33 @@ SetNodeProperty (
   return EFI_SUCCESS;\r
 }\r
 \r
+STATIC\r
+BOOLEAN\r
+IsNodeEnabled (\r
+  INT32                       Node\r
+  )\r
+{\r
+  CONST CHAR8   *NodeStatus;\r
+  INT32         Len;\r
+\r
+  //\r
+  // A missing status property implies 'ok' so ignore any errors that\r
+  // may occur here. If the status property is present, check whether\r
+  // it is set to 'ok' or 'okay', anything else is treated as 'disabled'.\r
+  //\r
+  NodeStatus = fdt_getprop (mDeviceTreeBase, Node, "status", &Len);\r
+  if (NodeStatus == NULL) {\r
+    return TRUE;\r
+  }\r
+  if (Len >= 5 && AsciiStrCmp (NodeStatus, "okay") == 0) {\r
+    return TRUE;\r
+  }\r
+  if (Len >= 3 && AsciiStrCmp (NodeStatus, "ok") == 0) {\r
+    return TRUE;\r
+  }\r
+  return FALSE;\r
+}\r
+\r
 STATIC\r
 EFI_STATUS\r
 EFIAPI\r
@@ -101,6 +128,10 @@ FindNextCompatibleNode (
       break;\r
     }\r
 \r
+    if (!IsNodeEnabled (Next)) {\r
+      continue;\r
+    }\r
+\r
     Type = fdt_getprop (mDeviceTreeBase, Next, "compatible", &Len);\r
     if (Type == NULL) {\r
       continue;\r
@@ -210,7 +241,6 @@ FindNextMemoryNodeReg (
 {\r
   INT32          Prev, Next;\r
   CONST CHAR8    *DeviceType;\r
-  CONST CHAR8    *NodeStatus;\r
   INT32          Len;\r
   EFI_STATUS     Status;\r
 \r
@@ -223,10 +253,8 @@ FindNextMemoryNodeReg (
       break;\r
     }\r
 \r
-    NodeStatus = fdt_getprop (mDeviceTreeBase, Next, "status", &Len);\r
-    if (NodeStatus != NULL && AsciiStrCmp (NodeStatus, "okay") != 0) {\r
-      DEBUG ((DEBUG_WARN, "%a: ignoring memory node with status \"%a\"\n",\r
-        __FUNCTION__, NodeStatus));\r
+    if (!IsNodeEnabled (Next)) {\r
+      DEBUG ((DEBUG_WARN, "%a: ignoring disabled memory node\n", __FUNCTION__));\r
       continue;\r
     }\r
 \r