From nobody Fri Dec 27 02:28:34 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1504081287202797.2214533410524; Wed, 30 Aug 2017 01:21:27 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 3C61221E95E1B; Wed, 30 Aug 2017 01:18:41 -0700 (PDT) Received: from mail-wr0-x22d.google.com (mail-wr0-x22d.google.com [IPv6:2a00:1450:400c:c0c::22d]) (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 AAF2421E95E0F for ; Wed, 30 Aug 2017 01:18:39 -0700 (PDT) Received: by mail-wr0-x22d.google.com with SMTP id k9so4035687wre.4 for ; Wed, 30 Aug 2017 01:21:21 -0700 (PDT) Received: from localhost.localdomain ([105.133.189.215]) by smtp.gmail.com with ESMTPSA id h8sm3051642wma.46.2017.08.30.01.21.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Aug 2017 01:21:18 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org 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=SgtBES6SoFg23UKzdJujgYroDdhbOcZqSjp3kaa8R+A=; b=R5b//KOwKBnGJ5lcED39JT21ICC4T7APPBx4JVupzkMZo+PBRKKpCVKrOIz8DuA9n4 oYeP0w+dOA49eGxvqRq4up7EOmbSfEbK2IpOqFx8wz0W2xPD7cS0jgIjlyfwgHiuo6a7 IjkSK5C8VN1b4d3pTrocTAIHeNstxCmZCyks8= 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=SgtBES6SoFg23UKzdJujgYroDdhbOcZqSjp3kaa8R+A=; b=QajPVR4AYbiW7XgzMniZRG+TeZpuLAgC0BbybFn4fGydDF2Z8QmTiW79kJJloBfHS+ QigaNSLuIuSSoZA4MDFgrVyjO69Ysl2Cf3S9BYOQ1XvF/AEJXpgYYm/gYrao+7nINq03 FY/h5WouZeEtOPC2ZFJVUWQ12a8GheoqgaAuOAHoYDbfMf7GyjJoj3vyqubTtsVio80U qfRHPWbseNT0XBv4uQr8tycCC2HoI6iTwYQ6E2uGeiMYffrFgjEQ+bNt5z5weHU4zXAc /Hcx8WWWHA2ybCqdOrrAZp7wav10D1vTzjnXhxdch/1ceOB194XJtfk6hTFdib2WvWMp eJsw== X-Gm-Message-State: AHYfb5gwuigx1ytg4Sb8Ba0kSxRM/w01cNbXfXo+AHnW0jqew079evhm SGEi5moPBPUpikm9eaWI0g== X-Received: by 10.223.132.39 with SMTP id 36mr538117wrf.69.1504081279505; Wed, 30 Aug 2017 01:21:19 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org Date: Wed, 30 Aug 2017 09:21:04 +0100 Message-Id: <20170830082108.7470-3-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170830082108.7470-1-ard.biesheuvel@linaro.org> References: <20170830082108.7470-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH 2/6] EmbeddedPkg/CoherentDmaLib: add support for non-1:1 DMA translation 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: , Cc: Ard Biesheuvel MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Bring CoherentDmaLib in line with ArmDmaLib, and add support for defining a static offset between the host's and the bus master's view of memory. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel Reviewed-by: Leif Lindholm --- EmbeddedPkg/EmbeddedPkg.dec | 7 +++++++ EmbeddedPkg/Library/CoherentDmaLib/CoherentDmaLib.c | 10 +++++++++- EmbeddedPkg/Library/CoherentDmaLib/CoherentDmaLib.inf | 3 +++ 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/EmbeddedPkg/EmbeddedPkg.dec b/EmbeddedPkg/EmbeddedPkg.dec index 8ad2a84c045c..ccdf38e36a8c 100644 --- a/EmbeddedPkg/EmbeddedPkg.dec +++ b/EmbeddedPkg/EmbeddedPkg.dec @@ -208,3 +208,10 @@ [PcdsFixedAtBuild.X64] =20 [PcdsFixedAtBuild.common, PcdsDynamic.common] gEmbeddedTokenSpaceGuid.PcdFdtDevicePaths|L""|VOID*|0x00000055 + + # + # Value to add to a host address to obtain a device address, using + # unsigned 64-bit integer arithmetic. This means we can rely on + # truncation on overflow to specify negative offsets. + # + gEmbeddedTokenSpaceGuid.PcdDmaDeviceOffset|0x0|UINT64|0x0000058 diff --git a/EmbeddedPkg/Library/CoherentDmaLib/CoherentDmaLib.c b/Embedded= Pkg/Library/CoherentDmaLib/CoherentDmaLib.c index 4cbe349190a9..564db83c901c 100644 --- a/EmbeddedPkg/Library/CoherentDmaLib/CoherentDmaLib.c +++ b/EmbeddedPkg/Library/CoherentDmaLib/CoherentDmaLib.c @@ -19,6 +19,14 @@ #include =20 =20 +STATIC +PHYSICAL_ADDRESS +HostToDeviceAddress ( + IN VOID *Address + ) +{ + return (PHYSICAL_ADDRESS)(UINTN)Address + PcdGet64 (PcdDmaDeviceOffset); +} =20 /** Provides the DMA controller-specific addresses needed to access system m= emory. @@ -50,7 +58,7 @@ DmaMap ( OUT VOID **Mapping ) { - *DeviceAddress =3D (PHYSICAL_ADDRESS)(UINTN)HostAddress; + *DeviceAddress =3D HostToDeviceAddress (HostAddress); *Mapping =3D NULL; return EFI_SUCCESS; } diff --git a/EmbeddedPkg/Library/CoherentDmaLib/CoherentDmaLib.inf b/Embedd= edPkg/Library/CoherentDmaLib/CoherentDmaLib.inf index c40a600cf6a3..f64d780e16ed 100644 --- a/EmbeddedPkg/Library/CoherentDmaLib/CoherentDmaLib.inf +++ b/EmbeddedPkg/Library/CoherentDmaLib/CoherentDmaLib.inf @@ -31,3 +31,6 @@ [Packages] [LibraryClasses] DebugLib MemoryAllocationLib + +[Pcd] + gEmbeddedTokenSpaceGuid.PcdDmaDeviceOffset --=20 2.11.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel