From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wr0-x234.google.com (mail-wr0-x234.google.com [IPv6:2a00:1450:400c:c0c::234]) (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 C550D21939316 for ; Tue, 4 Apr 2017 06:24:21 -0700 (PDT) Received: by mail-wr0-x234.google.com with SMTP id t20so10674103wra.1 for ; Tue, 04 Apr 2017 06:24:21 -0700 (PDT) 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=qghrqmGM63wTX0DSrePZT1WDzXWlchpX49dK9BLqLbw=; b=WPyUX8sEt83lzbCZwiZ2f/8YIfMiPpcOToidCroTDzdk3Uvi4SFkpNETZwv9S1NGj/ v+U0PnAc9MVh4YHXEIFtW0a3qiMPXi/hj2jiTPdc0FYjLd6QIgyrghnt0DE+uJdC4WbI QHX5QBIVEJxw0ZJJPRkl7oULST7+QkelvgqO0= 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=qghrqmGM63wTX0DSrePZT1WDzXWlchpX49dK9BLqLbw=; b=DdDAAVzqbZ4IdHUbaWVOUHeAYZbu3vBfuladPk6ooKWmAr/cu/tTag4bhfWnPgJ1E2 pFyHXU4+bPfPcUMURu1yycHvGXg2s/BVRTh2xdfRpLMVdDn+8zcng2BQ1PbDYdQC/oWj K5SkXVRh0IBjf+OZz5Z2kZscJ2tFSsUhlpMUlrInzSxmiTuDj8XSLbkORv22T/Lf+KEJ OoIZzsJK7YPCKOrmmazNnoaqrpX935DttELbzGLyw6uTp9+JOFryL7tlAyDcOJeYiZYx 1a90/1RGYKnp+fQoApVohC/dsmbmQNZESD1JYPDBOFBNG3pXBPR3MVylXxB3dxt9ZFzz AOmA== X-Gm-Message-State: AFeK/H1J/GL2hToGP4GfIsnniR5uJFyWGl3K8Dm4+0ykGuxOQf3hVZBUl3VBVMiWzSnhShqH X-Received: by 10.28.20.85 with SMTP id 82mr9333205wmu.59.1491312260261; Tue, 04 Apr 2017 06:24:20 -0700 (PDT) Received: from localhost.localdomain ([160.163.145.113]) by smtp.gmail.com with ESMTPSA id g10sm13773778wrb.56.2017.04.04.06.24.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 04 Apr 2017 06:24:19 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org, lersek@redhat.com Cc: jens.wiklander@linaro.org, Ard Biesheuvel Date: Tue, 4 Apr 2017 14:24:08 +0100 Message-Id: <20170404132409.20422-3-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170404132409.20422-1-ard.biesheuvel@linaro.org> References: <20170404132409.20422-1-ard.biesheuvel@linaro.org> Subject: [PATCH 2/3] ArmVirtPkg/FdtPL011SerialPortLib: take DT node 'status' property into account X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 04 Apr 2017 13:24:22 -0000 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 --- ArmVirtPkg/Library/FdtPL011SerialPortLib/EarlyFdtPL011SerialPortLib.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/ArmVirtPkg/Library/FdtPL011SerialPortLib/EarlyFdtPL011SerialPortLib.c b/ArmVirtPkg/Library/FdtPL011SerialPortLib/EarlyFdtPL011SerialPortLib.c index c458abb622d9..e28750f3b4c4 100644 --- a/ArmVirtPkg/Library/FdtPL011SerialPortLib/EarlyFdtPL011SerialPortLib.c +++ b/ArmVirtPkg/Library/FdtPL011SerialPortLib/EarlyFdtPL011SerialPortLib.c @@ -66,6 +66,7 @@ SerialPortGetBaseAddress ( INT32 Node, Prev; INT32 Len; CONST CHAR8 *Compatible; + CONST CHAR8 *NodeStatus; CONST CHAR8 *CompatibleItem; CONST UINT64 *RegProperty; UINTN UartBase; @@ -98,6 +99,11 @@ SerialPortGetBaseAddress ( CompatibleItem += 1 + AsciiStrLen (CompatibleItem)) { if (AsciiStrCmp (CompatibleItem, "arm,pl011") == 0) { + NodeStatus = fdt_getprop (DeviceTreeBase, Node, "status", &Len); + if (NodeStatus != NULL && AsciiStrCmp (NodeStatus, "okay") != 0) { + continue; + } + RegProperty = fdt_getprop (DeviceTreeBase, Node, "reg", &Len); if (Len != 16) { return 0; -- 2.9.3