From patchwork Fri Mar 31 10:56:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 96355 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp666296qgd; Fri, 31 Mar 2017 03:56:21 -0700 (PDT) X-Received: by 10.98.93.150 with SMTP id n22mr2217489pfj.103.1490957781511; Fri, 31 Mar 2017 03:56:21 -0700 (PDT) Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id l3si4886452pld.144.2017.03.31.03.56.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 31 Mar 2017 03:56:21 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; 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 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id E25222050AB0C; Fri, 31 Mar 2017 03:56:19 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received: from mail-wr0-x229.google.com (mail-wr0-x229.google.com [IPv6:2a00:1450:400c:c0c::229]) (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 CBAD92050AB07 for ; Fri, 31 Mar 2017 03:56:18 -0700 (PDT) Received: by mail-wr0-x229.google.com with SMTP id w43so100165288wrb.0 for ; Fri, 31 Mar 2017 03:56:18 -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=89287JPmINkGiku6/A/HPcvnIw9kYhRW40Yeqov+Ysw=; b=MwM/16IVvoChbsvHNcW7IsT7gzUxcU4/VU01M0rYM6qUgSrZ8keuOOUhm9DYDllDeS OZhIIwHDVU84Mdwq8AetnxmGecdfOb3oWLA43/eEIRj3grzPfUsFJ3A3kshAIUgYYd3r h6S60o89EZjJt0VvDJtKm1kSuRzkivRDPocKo= 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=89287JPmINkGiku6/A/HPcvnIw9kYhRW40Yeqov+Ysw=; b=tHuS3zXxQ7FNs7BTyhgDxBlEDswucs6V0Ps7pvGa0uQbMEhjIzDi7WFN/DTNOvgeye suh+jXTi/PVij7N9iEMmKKfHfYEuoyr/B5vniNqnbokJf19mHdkXrELGvEtL8/3RktsR Kt8FDUZmXXXREe0v9/4qcYFcF/sFw95qSzj3Nwtzwcu5QlOT8uZUq4WQ9UTReBk77ul+ pUvxm9fafEf/2iCkJDItrPMCiMLqgp2/aRIYfEByl4UEKW9A3rYyqXZMXAgfIe7Qp8ey ExwtEGN/XVzqq9jJqiwHcZh6//F8aW3bcoryCv5Tkmvo910d8O8p+dG2IxRDy0lHsjS1 q7dg== X-Gm-Message-State: AFeK/H0HcSWPKuqrY+hGYHxPjizPylzTJDw7x1/Lh1UmWZ5k+nPf3YkSXYYc5XxKK+PTrpMH X-Received: by 10.28.172.7 with SMTP id v7mr2788735wme.78.1490957777106; Fri, 31 Mar 2017 03:56:17 -0700 (PDT) Received: from localhost.localdomain ([160.171.180.74]) by smtp.gmail.com with ESMTPSA id 92sm6300006wrh.8.2017.03.31.03.56.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 31 Mar 2017 03:56:16 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org, lersek@redhat.com Date: Fri, 31 Mar 2017 11:56:05 +0100 Message-Id: <20170331105607.3477-2-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 1/3] EmbeddedPkg: add DtPlatformDtbLoaderLib library class 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 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" To abstract the way a platform reasons about which DTB is appropriate, and the way it ultimately supplies the DTB image, introduce a new library class to encapsulate this functionality. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel --- EmbeddedPkg/EmbeddedPkg.dec | 1 + EmbeddedPkg/Include/Library/DtPlatformDtbLoaderLib.h | 37 ++++++++++++++++++++ 2 files changed, 38 insertions(+) -- 2.9.3 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Reviewed-by: Laszlo Ersek diff --git a/EmbeddedPkg/EmbeddedPkg.dec b/EmbeddedPkg/EmbeddedPkg.dec index 871fc5ff4016..0bed2736c8c3 100644 --- a/EmbeddedPkg/EmbeddedPkg.dec +++ b/EmbeddedPkg/EmbeddedPkg.dec @@ -45,6 +45,7 @@ [LibraryClasses.common] GdbSerialLib|Include/Library/GdbSerialLib.h DebugAgentTimerLib|Include/Library/DebugAgentTimerLib.h + DtPlatformDtbLoaderLib|Include/Library/DtPlatformDtbLoaderLib.h [Guids.common] gEmbeddedTokenSpaceGuid = { 0xe0d8ca17, 0x4276, 0x4386, { 0xbb, 0x79, 0x48, 0xcb, 0x81, 0x3d, 0x3c, 0x4f }} diff --git a/EmbeddedPkg/Include/Library/DtPlatformDtbLoaderLib.h b/EmbeddedPkg/Include/Library/DtPlatformDtbLoaderLib.h new file mode 100644 index 000000000000..bb79d2a190f4 --- /dev/null +++ b/EmbeddedPkg/Include/Library/DtPlatformDtbLoaderLib.h @@ -0,0 +1,37 @@ +/** @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 BSD 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 IMPLIED. +* +**/ + +#ifndef __DT_PLATFORM_DTB_LOADER_LIB_H__ +#define __DT_PLATFORM_DTB_LOADER_LIB_H__ + +/** + 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 located + @retval EFI_OUT_OF_RESOURCES No pool memory available + +**/ +EFI_STATUS +EFIAPI +DtPlatformLoadDtb ( + OUT VOID **Dtb, + OUT UINTN *DtbSize + ); + +#endif From patchwork Fri Mar 31 10:56:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 96356 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp666311qgd; Fri, 31 Mar 2017 03:56:23 -0700 (PDT) X-Received: by 10.99.65.4 with SMTP id o4mr2618131pga.90.1490957783471; Fri, 31 Mar 2017 03:56:23 -0700 (PDT) Return-Path: Received: from ml01.01.org (ml01.01.org. [2001:19d0:306:5::1]) by mx.google.com with ESMTPS id 205si4881591pfz.263.2017.03.31.03.56.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 31 Mar 2017 03:56:23 -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 sp=NONE dis=NONE) header.from=linaro.org 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) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org 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) 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) 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) 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 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" 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 --- EmbeddedPkg/EmbeddedPkg.dsc | 4 ++ EmbeddedPkg/Library/DtPlatformDtbLoaderBaseLib/DtPlatformDtbLoaderBaseLib.c | 60 ++++++++++++++++++++ EmbeddedPkg/Library/DtPlatformDtbLoaderBaseLib/DtPlatformDtbLoaderBaseLib.inf | 36 ++++++++++++ 3 files changed, 100 insertions(+) -- 2.9.3 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Reviewed-by: Laszlo Ersek 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/UefiHiiServicesLib.inf + DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf + DtPlatformDtbLoaderLib|EmbeddedPkg/Library/DtPlatformDtbLoaderBaseLib/DtPlatformDtbLoaderBaseLib.inf + [LibraryClasses.common.DXE_DRIVER] PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf ReportStatusCodeLib|IntelFrameworkModulePkg/Library/DxeReportStatusCodeLibFramework/DxeReportStatusCodeLib.inf @@ -247,6 +250,7 @@ [Components.common] EmbeddedPkg/Library/TemplateRealTimeClockLib/TemplateRealTimeClockLib.inf EmbeddedPkg/Library/LzmaHobCustomDecompressLib/LzmaHobCustomDecompressLib.inf EmbeddedPkg/Library/NullDmaLib/NullDmaLib.inf + EmbeddedPkg/Library/DtPlatformDtbLoaderBaseLib/DtPlatformDtbLoaderBaseLib.inf EmbeddedPkg/Ebl/Ebl.inf #### EmbeddedPkg/EblExternCmd/EblExternCmd.inf diff --git a/EmbeddedPkg/Library/DtPlatformDtbLoaderBaseLib/DtPlatformDtbLoaderBaseLib.c b/EmbeddedPkg/Library/DtPlatformDtbLoaderBaseLib/DtPlatformDtbLoaderBaseLib.c new file mode 100644 index 000000000000..313d0b104681 --- /dev/null +++ b/EmbeddedPkg/Library/DtPlatformDtbLoaderBaseLib/DtPlatformDtbLoaderBaseLib.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 BSD 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 IMPLIED. +* +**/ + +#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 located + @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 = GetSectionFromAnyFv (&gDtPlatformDefaultDtbFileGuid, + EFI_SECTION_RAW, 0, &OrigDtb, &OrigDtbSize); + if (EFI_ERROR (Status)) { + return EFI_NOT_FOUND; + } + + CopyDtb = AllocateCopyPool (OrigDtbSize, OrigDtb); + if (CopyDtb == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + *Dtb = CopyDtb; + *DtbSize = OrigDtbSize; + + return EFI_SUCCESS; +} diff --git a/EmbeddedPkg/Library/DtPlatformDtbLoaderBaseLib/DtPlatformDtbLoaderBaseLib.inf b/EmbeddedPkg/Library/DtPlatformDtbLoaderBaseLib/DtPlatformDtbLoaderBaseLib.inf new file mode 100644 index 000000000000..7c337aace3ef --- /dev/null +++ b/EmbeddedPkg/Library/DtPlatformDtbLoaderBaseLib/DtPlatformDtbLoaderBaseLib.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 BSD 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 IMPLIED. +* +**/ + +[Defines] + INF_VERSION = 0x00010019 + BASE_NAME = DtPlatformDtbLoaderBaseLib + FILE_GUID = 419a1910-70da-4c99-8696-ba81a57be508 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + LIBRARY_CLASS = DtPlatformDtbLoaderLib|DXE_DRIVER + +[Sources] + DtPlatformDtbLoaderBaseLib.c + +[Packages] + MdePkg/MdePkg.dec + EmbeddedPkg/EmbeddedPkg.dec + +[LibraryClasses] + BaseLib + DxeServicesLib + MemoryAllocationLib + +[Guids] + gDtPlatformDefaultDtbFileGuid From patchwork Fri Mar 31 10:56:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 96357 Delivered-To: patch@linaro.org Received: by 10.140.89.233 with SMTP id v96csp666326qgd; Fri, 31 Mar 2017 03:56:25 -0700 (PDT) X-Received: by 10.84.218.130 with SMTP id r2mr2750188pli.79.1490957785601; Fri, 31 Mar 2017 03:56:25 -0700 (PDT) Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id q75si4868548pgq.363.2017.03.31.03.56.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 31 Mar 2017 03:56:25 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; 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 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 6240A2063E066; Fri, 31 Mar 2017 03:56:23 -0700 (PDT) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received: from mail-wr0-x235.google.com (mail-wr0-x235.google.com [IPv6:2a00:1450:400c:c0c::235]) (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 1CD8F2050AAFE for ; Fri, 31 Mar 2017 03:56:22 -0700 (PDT) Received: by mail-wr0-x235.google.com with SMTP id l43so101933931wre.1 for ; Fri, 31 Mar 2017 03:56:22 -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=+59sh1ZBSPFQCsO5xByGV97fP1n75dCxvEJDF1B2vws=; b=Nu2feIoavy+XDiB+VcW2b44RAstDGQ0hon4IFEXlqyoDFefbWai+sDrZ1/ie2CH6UH GwgWmbS81Z42+7drKZhcHL4mtLCw7mWPXtJXESgOZIvreZqm7IIMWwuIBRoJfEc2zxH6 vCXktQ+61wIv7iGz0lLO/9H4JpjlstJBtxxk8= 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=+59sh1ZBSPFQCsO5xByGV97fP1n75dCxvEJDF1B2vws=; b=oyy+HCYO9RuzV+qbcfjy77ZLzuykbcpVW22JOP4fYcbdTz4khMzDRHHVnYQLyD811A vvUr00VKAAhx5PMqsrhonW2rPIX7U2yCqcLXF+WwnzLFlhXYFRq39++jeUm97+Kh+RqF wEBQdcMQ8xS97od0l3Ksyv5GJ46qqsAkkPiWZ7nvTGJNzLIBjqHM3kQgZpxaYrhYtLj2 W2YMCUADoJIJ4B7qRN6KrJjWNT6AWG2e9DjINH/inpfWozEEkTkXjDTyWBqlbrYmt0iv euAiVqOUp4cjunw+iOZVNGXqpfjic0lGCrv8SVJtzuMi0PUJOWWydDszP2rHkBqvci89 J/vQ== X-Gm-Message-State: AFeK/H2YjrWVuPuoXYRvzCAHjs3Hy5ZzNeWgIbEfgIZ4MMLaqtD6OM1pLt5VzxUygW0e173v X-Received: by 10.28.134.70 with SMTP id i67mr2677577wmd.124.1490957780687; 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.18 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 31 Mar 2017 03:56:20 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org, lersek@redhat.com Date: Fri, 31 Mar 2017 11:56:07 +0100 Message-Id: <20170331105607.3477-4-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 3/3] EmbeddedPkg/DtPlatformDxe: load platform DTB via new library 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 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" To give platforms some room to decide which DTB is suitable and where to load it from, indirect loading of the DTB image via the new DtPlatformDtbLoaderLib library class. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel --- EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformDxe.c | 26 ++++++++++---------- EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformDxe.inf | 2 +- EmbeddedPkg/EmbeddedPkg.dsc | 2 ++ 3 files changed, 16 insertions(+), 14 deletions(-) -- 2.9.3 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Reviewed-by: Laszlo Ersek diff --git a/EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformDxe.c b/EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformDxe.c index 5778633b4985..c75f088a34e5 100644 --- a/EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformDxe.c +++ b/EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformDxe.c @@ -15,7 +15,7 @@ #include #include #include -#include +#include #include #include #include @@ -114,14 +114,12 @@ DtPlatformDxeEntryPoint ( UINTN BufferSize; VOID *Dtb; UINTN DtbSize; - VOID *DtbCopy; // // Check whether a DTB blob is included in the firmware image. // Dtb = NULL; - Status = GetSectionFromAnyFv (&gDtPlatformDefaultDtbFileGuid, - EFI_SECTION_RAW, 0, &Dtb, &DtbSize); + Status = DtPlatformLoadDtb (&Dtb, &DtbSize); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_WARN, "%a: no DTB blob found, defaulting to ACPI\n", __FUNCTION__)); @@ -157,7 +155,7 @@ DtPlatformDxeEntryPoint ( EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS, sizeof (DtAcpiPref), &DtAcpiPref); if (EFI_ERROR (Status)) { - return Status; + goto FreeDtb; } } @@ -172,23 +170,18 @@ DtPlatformDxeEntryPoint ( DEBUG ((DEBUG_ERROR, "%a: failed to install gEdkiiPlatformHasAcpiGuid as a protocol\n", __FUNCTION__)); - return Status; + goto FreeDtb; } } else if (DtAcpiPref.Pref == DT_ACPI_SELECT_DT) { // // DT was selected: copy the blob into newly allocated memory and install // a reference to it as the FDT configuration table. // - DtbCopy = AllocateCopyPool (DtbSize, Dtb); - if (DtbCopy == NULL) { - return EFI_OUT_OF_RESOURCES; - } - Status = gBS->InstallConfigurationTable (&gFdtTableGuid, DtbCopy); + Status = gBS->InstallConfigurationTable (&gFdtTableGuid, Dtb); if (EFI_ERROR (Status)) { DEBUG ((DEBUG_ERROR, "%a: failed to install FDT configuration table\n", __FUNCTION__)); - FreePool (DtbCopy); - return Status; + goto FreeDtb; } } else { ASSERT (FALSE); @@ -210,4 +203,11 @@ DtPlatformDxeEntryPoint ( // installed in that case. // return InstallHiiPages (); + +FreeDtb: + if (Dtb != NULL) { + FreePool (Dtb); + } + + return Status; } diff --git a/EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformDxe.inf b/EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformDxe.inf index b73877a6086b..45dfd9088bf0 100644 --- a/EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformDxe.inf +++ b/EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformDxe.inf @@ -40,7 +40,7 @@ [Packages] [LibraryClasses] BaseLib DebugLib - DxeServicesLib + DtPlatformDtbLoaderLib HiiLib MemoryAllocationLib UefiBootServicesTableLib diff --git a/EmbeddedPkg/EmbeddedPkg.dsc b/EmbeddedPkg/EmbeddedPkg.dsc index 0d5db68631bb..b75678276e8d 100644 --- a/EmbeddedPkg/EmbeddedPkg.dsc +++ b/EmbeddedPkg/EmbeddedPkg.dsc @@ -294,5 +294,7 @@ [Components.common] EmbeddedPkg/Library/PrePiHobLib/PrePiHobLib.inf EmbeddedPkg/Library/PrePiMemoryAllocationLib/PrePiMemoryAllocationLib.inf + EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformDxe.inf + [Components.IA32, Components.X64, Components.IPF, Components.ARM] EmbeddedPkg/GdbStub/GdbStub.inf