From patchwork Fri Mar 31 14:19:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 96449 Delivered-To: patch@linaro.org Received: by 10.182.246.10 with SMTP id xs10csp1252605obc; Fri, 31 Mar 2017 07:19:48 -0700 (PDT) X-Received: by 10.99.127.29 with SMTP id a29mr3588128pgd.11.1490969988060; Fri, 31 Mar 2017 07:19:48 -0700 (PDT) Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id i8si5404978pll.24.2017.03.31.07.19.47 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 31 Mar 2017 07:19:48 -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 AF29F20080314; Fri, 31 Mar 2017 07:19:46 -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 948E520080314 for ; Fri, 31 Mar 2017 07:19:45 -0700 (PDT) Received: by mail-wr0-x235.google.com with SMTP id l43so109973106wre.1 for ; Fri, 31 Mar 2017 07:19:45 -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=n18Z5yORr6iHDxMXgPTp8ZCiLvRZbgEh2UZMHqfG//U=; b=SzVvTLrPbHiLOq9uqUysdQtUbtOLlSfNBCipoYNIJLsmeDTta4zbAe7VIXooi1X6pY Qxlxttc4BmCCR4YR/Q5t4V3FoLzt/i5Q/p7tqocRiRHmROTHbwqQzpShszUo4OY1XR01 taX1W9CNQ/36SOuob7eDIGeW6D1UNzVFoOvvc= 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=n18Z5yORr6iHDxMXgPTp8ZCiLvRZbgEh2UZMHqfG//U=; b=G5GMsTYUTWm7OKnFF8rfbV/9ZmAUkn0gQme+mKSm/DOf4pKeFGoK7uYPal0XEsXBkR 1/358/rPArtl5oGjcsfLVkGsd1+BFhDAunuzHAMUGaJ9m8GMNIncQseeU4l7T3Lh+O7R FYqaktJym88/LKA/qqHm/hyJ7hA6gUPbf8TfBWFDueYfOR/3mWtBeJqnGiRm32ZpsuqC JDvpdbf8a11RKpQdWtjdUo62eIi1DQjyRvY49Ts1DsTYcDqSXZ9b5MXhgZOpWBRC7Q4L hiNy0SOjI40wNT4rdlG59KwrfYn8V7S8YBkSnhp7FpP48gmPCX1Sv5BOK7O0MtgRlyOa UIBQ== X-Gm-Message-State: AFeK/H2vhx0JfD0vKtqposDBb0RvYWeJ6AHvjxrsdPhwR1LiVGxoto4w+22xLlx8PaTqhaaC X-Received: by 10.28.209.75 with SMTP id i72mr3342204wmg.31.1490969984159; Fri, 31 Mar 2017 07:19:44 -0700 (PDT) Received: from localhost.localdomain ([160.171.180.74]) by smtp.gmail.com with ESMTPSA id w12sm6902962wra.21.2017.03.31.07.19.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 31 Mar 2017 07:19:43 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org, leif.lindholm@linaro.org, ryan.harkin@linaro.org Date: Fri, 31 Mar 2017 15:19:28 +0100 Message-Id: <20170331141929.21121-3-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170331141929.21121-1-ard.biesheuvel@linaro.org> References: <20170331141547.20987-1-ard.biesheuvel@linaro.org> <20170331141929.21121-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH v2 12/13] Platforms/Juno: add 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: Ard Biesheuvel MIME-Version: 1.0 Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" In preparation of switching to DtPlatformDxe to supply the device tree image to the OS, add an implementation of DtPlatformDtbLoaderLib that loads the correct version from an FV. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel --- Platforms/ARM/Juno/Library/JunoDtPlatformDtbLoaderLib/JunoDtPlatformDtbLoaderLib.c | 71 ++++++++++++++++++++ Platforms/ARM/Juno/Library/JunoDtPlatformDtbLoaderLib/JunoDtPlatformDtbLoaderLib.inf | 38 +++++++++++ 2 files changed, 109 insertions(+) -- 2.9.3 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel diff --git a/Platforms/ARM/Juno/Library/JunoDtPlatformDtbLoaderLib/JunoDtPlatformDtbLoaderLib.c b/Platforms/ARM/Juno/Library/JunoDtPlatformDtbLoaderLib/JunoDtPlatformDtbLoaderLib.c new file mode 100644 index 000000000000..8b4d1cbecffb --- /dev/null +++ b/Platforms/ARM/Juno/Library/JunoDtPlatformDtbLoaderLib/JunoDtPlatformDtbLoaderLib.c @@ -0,0 +1,71 @@ +/** @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 +#include +#include + +#include "ArmPlatform.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 + ) +{ + EFI_STATUS Status; + VOID *OrigDtb; + VOID *CopyDtb; + UINTN OrigDtbSize; + UINT32 JunoRevision; + + GetJunoRevision(JunoRevision); + ASSERT (JunoRevision >= JUNO_REVISION_R0 && JunoRevision <= JUNO_REVISION_R2); + if (JunoRevision < JUNO_REVISION_R0 || JunoRevision > JUNO_REVISION_R2) { + return EFI_NOT_FOUND; + } + + Status = GetSectionFromAnyFv (&gDtPlatformDefaultDtbFileGuid, + EFI_SECTION_RAW, (UINTN)JunoRevision - 1, &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/Platforms/ARM/Juno/Library/JunoDtPlatformDtbLoaderLib/JunoDtPlatformDtbLoaderLib.inf b/Platforms/ARM/Juno/Library/JunoDtPlatformDtbLoaderLib/JunoDtPlatformDtbLoaderLib.inf new file mode 100644 index 000000000000..8018278546fe --- /dev/null +++ b/Platforms/ARM/Juno/Library/JunoDtPlatformDtbLoaderLib/JunoDtPlatformDtbLoaderLib.inf @@ -0,0 +1,38 @@ +/** @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 = JunoDtPlatformDtbLoaderLib + FILE_GUID = 050d6041-1508-4ae7-a69f-250155ccb567 + MODULE_TYPE = DXE_DRIVER + VERSION_STRING = 1.0 + LIBRARY_CLASS = DtPlatformDtbLoaderLib|DXE_DRIVER + +[Sources] + JunoDtPlatformDtbLoaderLib.c + +[Packages] + ArmPkg/ArmPkg.dec + MdePkg/MdePkg.dec + EmbeddedPkg/EmbeddedPkg.dec + +[LibraryClasses] + BaseLib + DxeServicesLib + IoLib + MemoryAllocationLib + +[Guids] + gDtPlatformDefaultDtbFileGuid