From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:4864:20::543; helo=mail-ed1-x543.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-ed1-x543.google.com (mail-ed1-x543.google.com [IPv6:2a00:1450:4864:20::543]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 832BF2194D3B9 for ; Wed, 21 Nov 2018 03:58:42 -0800 (PST) Received: by mail-ed1-x543.google.com with SMTP id d39so4631670edb.12 for ; Wed, 21 Nov 2018 03:58:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=jDNsAZxgM2+Eo8XXOkKPVaoJBEcVPe4kmsU52EMbbEA=; b=HRw0SByhMpxzNH2rJ2StMZdM9UoI6yMXqOHHAXwPpjnIgwLEiUkj6/kqPw60cwuBk1 sAAvNL04GRg0C2M4tQxFmNl6WvR3iF60EywHqxSDMsNNsK9SeYCRA9nOtxd5/+sdYmpT XMXMbRBikSZjgBhOibYYoFsGidRxbOjbbQsXI= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=jDNsAZxgM2+Eo8XXOkKPVaoJBEcVPe4kmsU52EMbbEA=; b=IPHuEY1E6sxd2RiSstMs58vyRm//VA53KK4yD8eU8ktRGlEOG7/ANDsSi3lS1en84g +zjMtdqpNTPIEN3rfwCe1RKE0Azcu3lSv/bsGGI+8/u49ccqYrtX5JkkVT5fYxLu1hi/ ZTvGEfcchap2sLCwc+IN7V7I7XJrikmWSUwqtyoWhgjO2Rm2+fs7CKZPgo1szmxDOtp6 R3xa+kOvUQ2L8Wq39eXOo673sXVL/qHZO42pyhnDku9kuJrOjDeBYQVxOV5iVR26J2VQ S9yi67SOM5rTHc5ciT5x5fqZauChj9o0nsLFa7kJ5ipMGOMgsyHfqD3rPLrzNdDL6NRy xR2Q== X-Gm-Message-State: AGRZ1gIUHpK2ud0zybr9FWObKHzCSdBp22WE3aosWI491HOuZ5hgxAh4 lTyD7H0Dki1AfOaWumM4AE2U7Eb0cb8txg== X-Google-Smtp-Source: AJdET5dv1CPg6C/hxELA+F7X+Nwrk37NaJKhwVF+GCkM0i9R/sifRRkLK+cfM7+f+LmuXQd/+OtiUw== X-Received: by 2002:a17:906:195b:: with SMTP id b27-v6mr4900951eje.220.1542801520774; Wed, 21 Nov 2018 03:58:40 -0800 (PST) Received: from mba13.wifi.ns.nl (dhcp-077-251-017-237.chello.nl. [77.251.17.237]) by smtp.gmail.com with ESMTPSA id x90sm4090716ede.35.2018.11.21.03.58.39 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Nov 2018 03:58:39 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Cc: leif.lindholm@linaro.org, lersek@redhat.com, philmd@redhat.com, hongbo.zhang@linaro.org, nariman.poushin@linaro.org, thomas.abraham@arm.com, Ard Biesheuvel Date: Wed, 21 Nov 2018 12:58:26 +0100 Message-Id: <20181121115828.3026-4-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181121115828.3026-1-ard.biesheuvel@linaro.org> References: <20181121115828.3026-1-ard.biesheuvel@linaro.org> Subject: [PATCH v2 3/5] ArmVirtPkg/FdtClientDxe: take DT node 'status' properties into account X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 21 Nov 2018 11:58:43 -0000 DT has a [pseudo-]standardized 'status' property that can be set on any node, and which signifies that a node should be treated as absent unless it is set to 'ok' or 'okay'. So take this into account when iterating over nodes. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- ArmVirtPkg/FdtClientDxe/FdtClientDxe.c | 38 +++++++++++++++++--- 1 file changed, 33 insertions(+), 5 deletions(-) diff --git a/ArmVirtPkg/FdtClientDxe/FdtClientDxe.c b/ArmVirtPkg/FdtClientDxe/FdtClientDxe.c index fb6e0aeb9215..5bfde381ecd0 100644 --- a/ArmVirtPkg/FdtClientDxe/FdtClientDxe.c +++ b/ArmVirtPkg/FdtClientDxe/FdtClientDxe.c @@ -78,6 +78,33 @@ SetNodeProperty ( return EFI_SUCCESS; } +STATIC +BOOLEAN +IsNodeEnabled ( + INT32 Node + ) +{ + CONST CHAR8 *NodeStatus; + INT32 Len; + + // + // A missing status property implies 'ok' so ignore any errors that + // may occur here. If the status property is present, check whether + // it is set to 'ok' or 'okay', anything else is treated as 'disabled'. + // + NodeStatus = fdt_getprop (mDeviceTreeBase, Node, "status", &Len); + if (NodeStatus == NULL) { + return TRUE; + } + if (Len >= 5 && AsciiStrCmp (NodeStatus, "okay") == 0) { + return TRUE; + } + if (Len >= 3 && AsciiStrCmp (NodeStatus, "ok") == 0) { + return TRUE; + } + return FALSE; +} + STATIC EFI_STATUS EFIAPI @@ -101,6 +128,10 @@ FindNextCompatibleNode ( break; } + if (!IsNodeEnabled (Next)) { + continue; + } + Type = fdt_getprop (mDeviceTreeBase, Next, "compatible", &Len); if (Type == NULL) { continue; @@ -210,7 +241,6 @@ FindNextMemoryNodeReg ( { INT32 Prev, Next; CONST CHAR8 *DeviceType; - CONST CHAR8 *NodeStatus; INT32 Len; EFI_STATUS Status; @@ -223,10 +253,8 @@ FindNextMemoryNodeReg ( break; } - NodeStatus = fdt_getprop (mDeviceTreeBase, Next, "status", &Len); - if (NodeStatus != NULL && AsciiStrCmp (NodeStatus, "okay") != 0) { - DEBUG ((DEBUG_WARN, "%a: ignoring memory node with status \"%a\"\n", - __FUNCTION__, NodeStatus)); + if (!IsNodeEnabled (Next)) { + DEBUG ((DEBUG_WARN, "%a: ignoring disabled memory node\n", __FUNCTION__)); continue; } -- 2.17.1