From patchwork Wed Nov 21 11:58:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 151672 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp1828979ljp; Wed, 21 Nov 2018 03:58:49 -0800 (PST) X-Google-Smtp-Source: AFSGD/U0wQFxkRtF8NErNMQRWdb9otnUdeyITc71F/GrU7jAdAEfM2HJhit7/yzjbxl53f1zvltm X-Received: by 2002:a63:224f:: with SMTP id t15mr5649879pgm.69.1542801529302; Wed, 21 Nov 2018 03:58:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542801529; cv=none; d=google.com; s=arc-20160816; b=iI7QqMx6/DD1OgCEB2QKxv0ci9w2WdItLKcDJMEq8trHDBZGcMkZBqMDcRh6e675YV 35iIfHu3TBYp43n4hX8dOx4WLY8had4HCbJpO+MkLrN6lNC2cgLqMObBNweKfxI7qtdC qxnxLIriymOLIzaxM55nlZEHEJYjGZCW1rBW35NR0UUDMSi/P74+aA4wDiQgzQ5nmzSW zhFrfPJaukIiUOPnCf14swTV7Otr9v7K9iccf2dLkwHTn8jJS5mBzKesscquaMjQ8+UB GQc3zvCDl1UOey9JsC8Q3NjGz5dwCc30BH4pgZJndlP9XOq049FSGmJ5JCcEj7C51J0B ztGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to; bh=boDKu3FaX9LsAQe83vXPv2VCFMOf97lVmGs7ctcRlJw=; b=buTJLbrJjbC9707TpT6hjw/xZl/IdJzrrs0ysgFqDHtb4cdPKV94XXAaz/B/Ujm6n7 M1AC1rtTKxCFL89MHKV8aMFrsezp/RV2BAI8PF6tkJ511pSea9YNCExGBl0jbtIhoahV fqQi19UG6mC8tblOXKK66uAsNPVwpf8tWXX76QtLCEjHBojbmotT/EJPzNRELXNfk3/V Q/gasZyHPATuXtP0MVXskhKIC96o974nsHC81DUXxyBBoJZTcvQquFEjp1OaA7quKtNS FBaGGNZXiPvMMN1+5/tveFVN8Ggxy9kxVjl0Tzs8Xcw3jN42MqGXlw6yWaDgXPckfYRe yvCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=HRw0SByh; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id q24si856340pls.325.2018.11.21.03.58.49 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 21 Nov 2018 03:58:49 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=HRw0SByh; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 2DB3A2119376C; Wed, 21 Nov 2018 03:58:44 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org 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-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 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: [edk2] [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: , Cc: lersek@redhat.com, nariman.poushin@linaro.org MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" 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(-) -- 2.17.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Reviewed-by: Laszlo Ersek Reviewed-by: Philippe Mathieu-Daudé 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; }