From nobody Fri Dec 27 03:40:17 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 1503663032874452.13185396894346; Fri, 25 Aug 2017 05:10:32 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id DD25D2095B9FD; Fri, 25 Aug 2017 05:07:53 -0700 (PDT) Received: from mail-wr0-x232.google.com (mail-wr0-x232.google.com [IPv6:2a00:1450:400c:c0c::232]) (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 D72EF2095B9FD for ; Fri, 25 Aug 2017 05:07:51 -0700 (PDT) Received: by mail-wr0-x232.google.com with SMTP id a47so6763585wra.4 for ; Fri, 25 Aug 2017 05:10:27 -0700 (PDT) Received: from localhost.localdomain ([105.137.125.182]) by smtp.gmail.com with ESMTPSA id 9sm1996137wmo.35.2017.08.25.05.10.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 25 Aug 2017 05:10:25 -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=rWygZacTeInJ9LG1E3+ZiW0wBGTA9q2MX6A864NVj2Q=; b=AQ5S6B9iN2Y9WkqQItQiCvGxJISaBGB82T1Ve4rC8ORK8v0H6VgD/hESugxxc8p//8 ttGK9qmFuX92epdJWPaJ+unzbTOyLGCJiGsU01kuc+pv4FEIA8SSFVuo4BaChvmoNSnL u+7LlQFYHM/6tsqxc4ItTaF/McrttOWddfhq4= 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=rWygZacTeInJ9LG1E3+ZiW0wBGTA9q2MX6A864NVj2Q=; b=KwarGP1Pka+3X/W5FBy3bTU09AD5boyBP8D1lWpjuoJrPGw9q6yMEXTWGdvxR61D6q SCXWB4gCy9xKw/ocjodcbnY5GNifTUA0rdD6GvFESxqlVh5j1QUnpyUoDQJCUh0nBclD EQXs6TSBx+XTUg2vFW87c3i8TWBVRx5pA+hwSa3HXI3jiq1s8ToVJOtOMiyFu0D2e1EG yFWC3EF8MoNAW4/NaSyhCTNGeyQhWwdeZJzHJsnN2YIjYOUH97cMEpxGoQqkwEvfRsqu UBnvMPru35fnrhvfy9TTeWe2oxObo7CqKUt+XWtQabKPyvMFnnK/7BaI6Kp9BLcJreKg +vCw== X-Gm-Message-State: AHYfb5gKaafqnMj2CGRzUQR7pArfMiJWUrYR7fgVhaKuEc6VdfRkxxVV Q0tlqdxNTjWktBVXteLmSA== X-Received: by 10.223.165.129 with SMTP id g1mr5432724wrc.108.1503663025830; Fri, 25 Aug 2017 05:10:25 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org Date: Fri, 25 Aug 2017 13:10:11 +0100 Message-Id: <20170825121014.15739-3-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170825121014.15739-1-ard.biesheuvel@linaro.org> References: <20170825121014.15739-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH 2/5] ArmPkg/ArmDmaLib: implement DmaAllocateAlignedBuffer() 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" Implement the new DmaLib routine that returns DMA'able buffers at a specified minimum alignment. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- ArmPkg/Library/ArmDmaLib/ArmDmaLib.c | 42 ++++++++++++++++++-- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/ArmPkg/Library/ArmDmaLib/ArmDmaLib.c b/ArmPkg/Library/ArmDmaLi= b/ArmDmaLib.c index e12bda4c2d33..2a8cf0fe21a4 100644 --- a/ArmPkg/Library/ArmDmaLib/ArmDmaLib.c +++ b/ArmPkg/Library/ArmDmaLib/ArmDmaLib.c @@ -285,20 +285,56 @@ DmaAllocateBuffer ( OUT VOID **HostAddress ) { + return DmaAllocateAlignedBuffer (MemoryType, Pages, 0, HostAddress); +} + +/** + Allocates pages that are suitable for an DmaMap() of type + MapOperationBusMasterCommonBuffer mapping, at the requested alignment. + + @param MemoryType The type of memory to allocate, EfiBootSer= vicesData or + EfiRuntimeServicesData. + @param Pages The number of pages to allocate. + @param Alignment Alignment in bytes of the base of the retu= rned + buffer (must be a power of 2) + @param HostAddress A pointer to store the base system memory = address of the + allocated range. + + @retval EFI_SUCCESS The requested memory pages were allocated. + @retval EFI_UNSUPPORTED Attributes is unsupported. The only legal = attribute bits are + MEMORY_WRITE_COMBINE and MEMORY_CACHED. + @retval EFI_INVALID_PARAMETER One or more parameters are invalid. + @retval EFI_OUT_OF_RESOURCES The memory pages could not be allocated. + +**/ +EFI_STATUS +EFIAPI +DmaAllocateAlignedBuffer ( + IN EFI_MEMORY_TYPE MemoryType, + IN UINTN Pages, + IN UINTN Alignment, + OUT VOID **HostAddress + ) +{ EFI_GCD_MEMORY_SPACE_DESCRIPTOR GcdDescriptor; VOID *Allocation; UINT64 MemType; UNCACHED_ALLOCATION *Alloc; EFI_STATUS Status; =20 - if (HostAddress =3D=3D NULL) { + if (Alignment =3D=3D 0) { + Alignment =3D EFI_PAGE_SIZE; + } + + if (HostAddress =3D=3D NULL || + (Alignment & (Alignment - 1)) !=3D 0) { return EFI_INVALID_PARAMETER; } =20 if (MemoryType =3D=3D EfiBootServicesData) { - Allocation =3D AllocatePages (Pages); + Allocation =3D AllocateAlignedPages (Pages, Alignment); } else if (MemoryType =3D=3D EfiRuntimeServicesData) { - Allocation =3D AllocateRuntimePages (Pages); + Allocation =3D AllocateAlignedRuntimePages (Pages, Alignment); } else { return EFI_INVALID_PARAMETER; } --=20 2.11.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel