From nobody Sat Nov 2 12:32:41 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 1490957786486833.9698826563089; Fri, 31 Mar 2017 03:56:26 -0700 (PDT) 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) 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) 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) 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=+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) 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 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" 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 Reviewed-by: Laszlo Ersek --- EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformDxe.c | 26 ++++++++++-------= --- EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformDxe.inf | 2 +- EmbeddedPkg/EmbeddedPkg.dsc | 2 ++ 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformDxe.c b/EmbeddedPk= g/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; =20 // // Check whether a DTB blob is included in the firmware image. // Dtb =3D NULL; - Status =3D GetSectionFromAnyFv (&gDtPlatformDefaultDtbFileGuid, - EFI_SECTION_RAW, 0, &Dtb, &DtbSize); + Status =3D 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_A= CCESS, sizeof (DtAcpiPref), &DtAcpiPref); if (EFI_ERROR (Status)) { - return Status; + goto FreeDtb; } } =20 @@ -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 =3D=3D DT_ACPI_SELECT_DT) { // // DT was selected: copy the blob into newly allocated memory and inst= all // a reference to it as the FDT configuration table. // - DtbCopy =3D AllocateCopyPool (DtbSize, Dtb); - if (DtbCopy =3D=3D NULL) { - return EFI_OUT_OF_RESOURCES; - } - Status =3D gBS->InstallConfigurationTable (&gFdtTableGuid, DtbCopy); + Status =3D 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 !=3D NULL) { + FreePool (Dtb); + } + + return Status; } diff --git a/EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformDxe.inf b/Embedded= Pkg/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 =20 + EmbeddedPkg/Drivers/DtPlatformDxe/DtPlatformDxe.inf + [Components.IA32, Components.X64, Components.IPF, Components.ARM] EmbeddedPkg/GdbStub/GdbStub.inf --=20 2.9.3 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel