From nobody Sat Nov 2 12:24:47 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.zoho.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 1490957784261571.0829497756154; Fri, 31 Mar 2017 03:56:24 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 2B8662050AB0F; Fri, 31 Mar 2017 03:56:23 -0700 (PDT) Received: from mail-wr0-x231.google.com (mail-wr0-x231.google.com [IPv6:2a00:1450:400c:c0c::231]) (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 2D5962050AAFE for ; Fri, 31 Mar 2017 03:56:20 -0700 (PDT) Received: by mail-wr0-x231.google.com with SMTP id l43so101932632wre.1 for ; Fri, 31 Mar 2017 03:56:20 -0700 (PDT) Received: from localhost.localdomain ([160.171.180.74]) by smtp.gmail.com with ESMTPSA id 92sm6300006wrh.8.2017.03.31.03.56.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 31 Mar 2017 03:56: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=aMuXhepu4hwQn+yKWYGbd4YzVzG9qGAjG37Pzr+G89Y=; b=TFrBwV4cBTMtD3qNDuKPHzhFbDPnLVsaCzz+gfbnz6X8nPzZnAOl6JtzVqQWKuzGZ7 wJF3gIzNWY6u+ws9lNwG4s4ZT6V833hlYY3xPrdimWJO8Zc6MIeKsZqfZBntbapOLTgA /0dJ+fLotjvp8DBE3MtjTtS1AwJ6H4jKws3gM= 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=aMuXhepu4hwQn+yKWYGbd4YzVzG9qGAjG37Pzr+G89Y=; b=ram30bs9QFnzPEmbl1CVrFfVUUwiPjNXVJuLwBDMFjP866ubk7xn61c1E0vTaLUzPP odfSEVjEA9fnUGPbGd9y2JAf1JItRpAf6reKxFibfLDtMPHgJ9w/Ds6yCq/apHIZz3JV SxyYl1lLN2ccIzrSnvpGrGFdcGjCpB2SjfGt5tVZFYYkRt7jcoIIDk/ISfkzpz62c8JQ 7X5Rqq5Z8ZrMGzT2x1+DB6Roq0kQTwLsydopy0cyMUHnklXCeAPNkapOAPP9s/tihwRg nfTiK50Mg7Ihy/iYtygck7YoORPuub/y4NjW6vcTAMy4XucDwgksmgt7dNYruD9mhkEK HLbg== X-Gm-Message-State: AFeK/H06jQ08lJGZM74omFzzv8BfpXA98kk5eGwVqDBpAQ5as9QPnNdAURMiuzs+OzrZb9Sl X-Received: by 10.28.14.7 with SMTP id 7mr2239534wmo.64.1490957778726; Fri, 31 Mar 2017 03:56:18 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org, lersek@redhat.com Date: Fri, 31 Mar 2017 11:56:06 +0100 Message-Id: <20170331105607.3477-3-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170331105607.3477-1-ard.biesheuvel@linaro.org> References: <20170331105607.3477-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH v2 2/3] EmbeddedPkg: add base DtPlatformDtbLoaderLib implementation 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: leif.lindholm@linaro.org, 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" Introduce an implementation of the new DtPlatformDtbLoaderLib library class that simply retrieves the first raw section for an FV file named gDtPlatformDefaultDtbFileGuid. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel Reviewed-by: Laszlo Ersek --- EmbeddedPkg/EmbeddedPkg.dsc = | 4 ++ EmbeddedPkg/Library/DtPlatformDtbLoaderBaseLib/DtPlatformDtbLoaderBaseLib.= c | 60 ++++++++++++++++++++ EmbeddedPkg/Library/DtPlatformDtbLoaderBaseLib/DtPlatformDtbLoaderBaseLib.= inf | 36 ++++++++++++ 3 files changed, 100 insertions(+) diff --git a/EmbeddedPkg/EmbeddedPkg.dsc b/EmbeddedPkg/EmbeddedPkg.dsc index ba4f1ea0f004..0d5db68631bb 100644 --- a/EmbeddedPkg/EmbeddedPkg.dsc +++ b/EmbeddedPkg/EmbeddedPkg.dsc @@ -109,6 +109,9 @@ [LibraryClasses.common] HiiLib|MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServic= esLib.inf =20 + DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf + DtPlatformDtbLoaderLib|EmbeddedPkg/Library/DtPlatformDtbLoaderBaseLib/Dt= PlatformDtbLoaderBaseLib.inf + [LibraryClasses.common.DXE_DRIVER] PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf ReportStatusCodeLib|IntelFrameworkModulePkg/Library/DxeReportStatusCodeL= ibFramework/DxeReportStatusCodeLib.inf @@ -247,6 +250,7 @@ [Components.common] EmbeddedPkg/Library/TemplateRealTimeClockLib/TemplateRealTimeClockLib.inf EmbeddedPkg/Library/LzmaHobCustomDecompressLib/LzmaHobCustomDecompressLi= b.inf EmbeddedPkg/Library/NullDmaLib/NullDmaLib.inf + EmbeddedPkg/Library/DtPlatformDtbLoaderBaseLib/DtPlatformDtbLoaderBaseLi= b.inf =20 EmbeddedPkg/Ebl/Ebl.inf #### EmbeddedPkg/EblExternCmd/EblExternCmd.inf diff --git a/EmbeddedPkg/Library/DtPlatformDtbLoaderBaseLib/DtPlatformDtbLo= aderBaseLib.c b/EmbeddedPkg/Library/DtPlatformDtbLoaderBaseLib/DtPlatformDt= bLoaderBaseLib.c new file mode 100644 index 000000000000..313d0b104681 --- /dev/null +++ b/EmbeddedPkg/Library/DtPlatformDtbLoaderBaseLib/DtPlatformDtbLoaderBas= eLib.c @@ -0,0 +1,60 @@ +/** @file +* +* Copyright (c) 2017, Linaro, Ltd. All rights reserved. +* +* This program and the accompanying materials +* are licensed and made available under the terms and conditions of the B= SD License +* which accompanies this distribution. The full text of the license may = be found at +* http://opensource.org/licenses/bsd-license.php +* +* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IM= PLIED. +* +**/ + +#include + +#include +#include +#include + +/** + Return a pool allocated copy of the DTB image that is appropriate for + booting the current platform via DT. + + @param[out] Dtb Pointer to the DTB copy + @param[out] DtbSize Size of the DTB copy + + @retval EFI_SUCCESS Operation completed successfully + @retval EFI_NOT_FOUND No suitable DTB image could be locat= ed + @retval EFI_OUT_OF_RESOURCES No pool memory available + +**/ +EFI_STATUS +EFIAPI +DtPlatformLoadDtb ( + OUT VOID **Dtb, + OUT UINTN *DtbSize + ) +{ + EFI_STATUS Status; + VOID *OrigDtb; + VOID *CopyDtb; + UINTN OrigDtbSize; + + Status =3D GetSectionFromAnyFv (&gDtPlatformDefaultDtbFileGuid, + EFI_SECTION_RAW, 0, &OrigDtb, &OrigDtbSize); + if (EFI_ERROR (Status)) { + return EFI_NOT_FOUND; + } + + CopyDtb =3D AllocateCopyPool (OrigDtbSize, OrigDtb); + if (CopyDtb =3D=3D NULL) { + return EFI_OUT_OF_RESOURCES; + } + + *Dtb =3D CopyDtb; + *DtbSize =3D OrigDtbSize; + + return EFI_SUCCESS; +} diff --git a/EmbeddedPkg/Library/DtPlatformDtbLoaderBaseLib/DtPlatformDtbLo= aderBaseLib.inf b/EmbeddedPkg/Library/DtPlatformDtbLoaderBaseLib/DtPlatform= DtbLoaderBaseLib.inf new file mode 100644 index 000000000000..7c337aace3ef --- /dev/null +++ b/EmbeddedPkg/Library/DtPlatformDtbLoaderBaseLib/DtPlatformDtbLoaderBas= eLib.inf @@ -0,0 +1,36 @@ +/** @file +* +* Copyright (c) 2017, Linaro, Ltd. All rights reserved. +* +* This program and the accompanying materials +* are licensed and made available under the terms and conditions of the B= SD License +* which accompanies this distribution. The full text of the license may = be found at +* http://opensource.org/licenses/bsd-license.php +* +* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IM= PLIED. +* +**/ + +[Defines] + INF_VERSION =3D 0x00010019 + BASE_NAME =3D DtPlatformDtbLoaderBaseLib + FILE_GUID =3D 419a1910-70da-4c99-8696-ba81a57be508 + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D DtPlatformDtbLoaderLib|DXE_DRIVER + +[Sources] + DtPlatformDtbLoaderBaseLib.c + +[Packages] + MdePkg/MdePkg.dec + EmbeddedPkg/EmbeddedPkg.dec + +[LibraryClasses] + BaseLib + DxeServicesLib + MemoryAllocationLib + +[Guids] + gDtPlatformDefaultDtbFileGuid --=20 2.9.3 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel