From patchwork Thu Sep 15 13:30:31 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 76304 Delivered-To: patch@linaro.org Received: by 10.140.106.72 with SMTP id d66csp2444750qgf; Thu, 15 Sep 2016 06:30:54 -0700 (PDT) X-Received: by 10.66.76.225 with SMTP id n1mr4466816paw.122.1473946254845; Thu, 15 Sep 2016 06:30:54 -0700 (PDT) Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id e76si11975357pfj.177.2016.09.15.06.30.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 15 Sep 2016 06:30:54 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) client-ip=2001:19d0:306:5::1; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 2001:19d0:306:5::1 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 3C2671A1EFB; Thu, 15 Sep 2016 06:30:54 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received: from mail-qt0-x22a.google.com (mail-qt0-x22a.google.com [IPv6:2607:f8b0:400d:c0d::22a]) (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 CDD9C1A1EF6 for ; Thu, 15 Sep 2016 06:30:52 -0700 (PDT) Received: by mail-qt0-x22a.google.com with SMTP id 38so24223175qte.1 for ; Thu, 15 Sep 2016 06:30:52 -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=P7l/+8zbpYHRlCnjCmr9ocopiGdOXv/AHMwJzd6wKIE=; b=JJTFwRnDc+OovcqjPiVLHVRcKZFsoF8rkjxqt6f5FNkCS2cVfcZ+nOmEDjmU0XmOcl JhyY6kh+3NDdIOp4OXK9e9lofTyUNBe7/nIo5XJLTqoimRN9Xo8oOtmbElbUzumYHVlp fds2JMLgoQ+QgKZ0FBzCyMlsaX3MVm1AGZ/oo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=P7l/+8zbpYHRlCnjCmr9ocopiGdOXv/AHMwJzd6wKIE=; b=jmxFkkYqoUEXW0kX0hFHiafw038YFMlBh4fXGL+6SmSUlibFu2T4WNu1KWSd1RL8hd T+OxI0lDhueiGZPCyVR+vUEiWOoOQB9E6NPc080cuyHAL3w2mbxsR438eGLKwgLMKJeN v0tj8c8nFwQOspZE62Tyjp832njRrBSFmAxtbc7yk+DiYQqjj+H8mSScb8oqKlbD8OSA e5Xx0XV+1PU53tdlPrsTN/tKmML+s/zUHrWKnLXJ7kCw2WkwZh0ZKc06webTSpjyHacs +ffZsDA5asnb5gww/kK98c102CLxmD+7FkhxLGmkicUOR4Y4SSn1vHkQ3AwAd5026uKs czpQ== X-Gm-Message-State: AE9vXwNoy8QCfR6+M8ewkVw4Py+TADy1KjokVdvp4KTIMNmhMT8KrbCFJswt5HZZASASl6AS X-Received: by 10.28.134.136 with SMTP id i130mr2946919wmd.76.1473946251717; Thu, 15 Sep 2016 06:30:51 -0700 (PDT) Received: from localhost.localdomain ([160.168.239.246]) by smtp.gmail.com with ESMTPSA id r9sm3532696wjp.15.2016.09.15.06.30.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 15 Sep 2016 06:30:51 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org, lersek@redhat.com Date: Thu, 15 Sep 2016 14:30:31 +0100 Message-Id: <1473946233-10547-3-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1473946233-10547-1-git-send-email-ard.biesheuvel@linaro.org> References: <1473946233-10547-1-git-send-email-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH 2/4] ArmVirtPkg/FdtClientDxe: report address and size cell count directly X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" The FDT client protocol methods dealing with "reg" properties return the size of a 'reg' element. Currently, we have hardcoded this as '8', since #address-cells == #size-cells == 2 in most cases. However, for different values, have a single 'reg' element size is not unambiguous, since - however unlikely - if #address-cells != #size-cells, we do not know which is which. So before adding more methods to the protocol, fix up this oversight. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel --- ArmVirtPkg/FdtClientDxe/FdtClientDxe.c | 6 ++++-- ArmVirtPkg/Include/Protocol/FdtClient.h | 3 ++- ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.c | 9 ++++++--- ArmVirtPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c | 9 ++++++--- ArmVirtPkg/XenAcpiPlatformDxe/XenAcpiPlatformDxe.c | 8 ++++++-- ArmVirtPkg/XenioFdtDxe/XenioFdtDxe.c | 10 +++++++--- 6 files changed, 31 insertions(+), 14 deletions(-) -- 2.7.4 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Reviewed-by: Laszlo Ersek diff --git a/ArmVirtPkg/FdtClientDxe/FdtClientDxe.c b/ArmVirtPkg/FdtClientDxe/FdtClientDxe.c index 2063a597323b..382e9af6bf84 100644 --- a/ArmVirtPkg/FdtClientDxe/FdtClientDxe.c +++ b/ArmVirtPkg/FdtClientDxe/FdtClientDxe.c @@ -159,7 +159,8 @@ FindCompatibleNodeReg ( IN FDT_CLIENT_PROTOCOL *This, IN CONST CHAR8 *CompatibleString, OUT CONST VOID **Reg, - OUT UINT32 *RegElemSize, + OUT UINTN *AddressCells, + OUT UINTN *SizeCells, OUT UINT32 *RegSize ) { @@ -185,7 +186,8 @@ FindCompatibleNodeReg ( return EFI_NOT_FOUND; } - *RegElemSize = 8; + *AddressCells = 2; + *SizeCells = 2; return EFI_SUCCESS; } diff --git a/ArmVirtPkg/Include/Protocol/FdtClient.h b/ArmVirtPkg/Include/Protocol/FdtClient.h index 79a8f3ce1b5d..b593c7441426 100644 --- a/ArmVirtPkg/Include/Protocol/FdtClient.h +++ b/ArmVirtPkg/Include/Protocol/FdtClient.h @@ -80,7 +80,8 @@ EFI_STATUS IN FDT_CLIENT_PROTOCOL *This, IN CONST CHAR8 *CompatibleString, OUT CONST VOID **Reg, - OUT UINT32 *RegElemSize, + OUT UINTN *AddressCells, + OUT UINTN *SizeCells, OUT UINT32 *RegSize ); diff --git a/ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.c b/ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.c index a1cd2da2d43a..64afc4de6b4d 100644 --- a/ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.c +++ b/ArmVirtPkg/Library/ArmVirtGicArchLib/ArmVirtGicArchLib.c @@ -36,7 +36,8 @@ ArmVirtGicArchLibConstructor ( UINT32 IccSre; FDT_CLIENT_PROTOCOL *FdtClient; CONST UINT64 *Reg; - UINT32 RegElemSize, RegSize; + UINT32 RegSize; + UINTN AddressCells, SizeCells; UINTN GicRevision; EFI_STATUS Status; UINT64 DistBase, CpuBase, RedistBase; @@ -47,11 +48,13 @@ ArmVirtGicArchLibConstructor ( GicRevision = 2; Status = FdtClient->FindCompatibleNodeReg (FdtClient, "arm,cortex-a15-gic", - (CONST VOID **)&Reg, &RegElemSize, &RegSize); + (CONST VOID **)&Reg, &AddressCells, &SizeCells, + &RegSize); if (Status == EFI_NOT_FOUND) { GicRevision = 3; Status = FdtClient->FindCompatibleNodeReg (FdtClient, "arm,gic-v3", - (CONST VOID **)&Reg, &RegElemSize, &RegSize); + (CONST VOID **)&Reg, &AddressCells, &SizeCells, + &RegSize); } if (EFI_ERROR (Status)) { return Status; diff --git a/ArmVirtPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c b/ArmVirtPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c index 377262563e3e..8ecbe3fb5fe6 100644 --- a/ArmVirtPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c +++ b/ArmVirtPkg/Library/QemuFwCfgLib/QemuFwCfgLib.c @@ -122,7 +122,8 @@ QemuFwCfgInitialize ( EFI_STATUS Status; FDT_CLIENT_PROTOCOL *FdtClient; CONST UINT64 *Reg; - UINT32 RegElemSize, RegSize; + UINT32 RegSize; + UINTN AddressCells, SizeCells; UINT64 FwCfgSelectorAddress; UINT64 FwCfgSelectorSize; UINT64 FwCfgDataAddress; @@ -135,7 +136,8 @@ QemuFwCfgInitialize ( ASSERT_EFI_ERROR (Status); Status = FdtClient->FindCompatibleNodeReg (FdtClient, "qemu,fw-cfg-mmio", - (CONST VOID **)&Reg, &RegElemSize, &RegSize); + (CONST VOID **)&Reg, &AddressCells, &SizeCells, + &RegSize); if (EFI_ERROR (Status)) { DEBUG ((EFI_D_WARN, "%a: No 'qemu,fw-cfg-mmio' compatible DT node found (Status == %r)\n", @@ -143,7 +145,8 @@ QemuFwCfgInitialize ( return EFI_SUCCESS; } - ASSERT (RegElemSize == sizeof (UINT64)); + ASSERT (AddressCells == 2); + ASSERT (SizeCells == 2); ASSERT (RegSize == 2 * sizeof (UINT64)); FwCfgDataAddress = SwapBytes64 (Reg[0]); diff --git a/ArmVirtPkg/XenAcpiPlatformDxe/XenAcpiPlatformDxe.c b/ArmVirtPkg/XenAcpiPlatformDxe/XenAcpiPlatformDxe.c index 37aea806283e..203946f97bf8 100644 --- a/ArmVirtPkg/XenAcpiPlatformDxe/XenAcpiPlatformDxe.c +++ b/ArmVirtPkg/XenAcpiPlatformDxe/XenAcpiPlatformDxe.c @@ -45,7 +45,8 @@ GetXenArmAcpiRsdp ( EFI_STATUS Status; FDT_CLIENT_PROTOCOL *FdtClient; CONST UINT64 *Reg; - UINT32 RegElemSize, RegSize; + UINT32 RegSize; + UINTN AddressCells, SizeCells; UINT64 RegBase; UINT8 Sum; @@ -59,13 +60,16 @@ GetXenArmAcpiRsdp ( ASSERT_EFI_ERROR (Status); Status = FdtClient->FindCompatibleNodeReg (FdtClient, "xen,guest-acpi", - (CONST VOID **)&Reg, &RegElemSize, &RegSize); + (CONST VOID **)&Reg, &AddressCells, &SizeCells, + &RegSize); if (EFI_ERROR (Status)) { DEBUG ((EFI_D_WARN, "%a: No 'xen,guest-acpi' compatible DT node found\n", __FUNCTION__)); return EFI_NOT_FOUND; } + ASSERT (AddressCells == 2); + ASSERT (SizeCells == 2); ASSERT (RegSize == 2 * sizeof (UINT64)); RegBase = SwapBytes64(Reg[0]); diff --git a/ArmVirtPkg/XenioFdtDxe/XenioFdtDxe.c b/ArmVirtPkg/XenioFdtDxe/XenioFdtDxe.c index 4a88db32170c..ae012a76f5e0 100644 --- a/ArmVirtPkg/XenioFdtDxe/XenioFdtDxe.c +++ b/ArmVirtPkg/XenioFdtDxe/XenioFdtDxe.c @@ -31,7 +31,8 @@ InitializeXenioFdtDxe ( EFI_STATUS Status; FDT_CLIENT_PROTOCOL *FdtClient; CONST UINT64 *Reg; - UINT32 RegElemSize, RegSize; + UINT32 RegSize; + UINTN AddressCells, SizeCells; EFI_HANDLE Handle; UINT64 RegBase; @@ -40,14 +41,17 @@ InitializeXenioFdtDxe ( ASSERT_EFI_ERROR (Status); Status = FdtClient->FindCompatibleNodeReg (FdtClient, "xen,xen", - (CONST VOID **)&Reg, &RegElemSize, &RegSize); + (CONST VOID **)&Reg, &AddressCells, &SizeCells, + &RegSize); if (EFI_ERROR (Status)) { DEBUG ((EFI_D_WARN, "%a: No 'xen,xen' compatible DT node found\n", __FUNCTION__)); return EFI_UNSUPPORTED; } - ASSERT (RegSize == 16); + ASSERT (AddressCells == 2); + ASSERT (SizeCells == 2); + ASSERT (RegSize == 2 * sizeof (UINT64)); // // Retrieve the reg base from this node and wire it up to the