From nobody Sat Nov 2 12:24:44 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 149096977689495.27744552890431; Fri, 31 Mar 2017 07:16:16 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 24C4C20080323; Fri, 31 Mar 2017 07:16:11 -0700 (PDT) Received: from mail-lf0-x22d.google.com (mail-lf0-x22d.google.com [IPv6:2a00:1450:4010:c07::22d]) (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 8203D2008031D for ; Fri, 31 Mar 2017 07:16:08 -0700 (PDT) Received: by mail-lf0-x22d.google.com with SMTP id h125so44937717lfe.0 for ; Fri, 31 Mar 2017 07:16:08 -0700 (PDT) Received: from localhost.localdomain ([160.171.180.74]) by smtp.gmail.com with ESMTPSA id h187sm3057561wma.32.2017.03.31.07.16.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 31 Mar 2017 07:16:06 -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=uB4xXQqqbiBiBe6qbgHf+yQehoIX3s+EnH9PLxIXb/Y=; b=X9j11V05Gyf7GrgTwt6jwYui8sp23DoiZD5J/lMiX0mley+maPDB1gJ50vcMcUd1Nn BRVI6hvLnMEZDLij1rGn0sqQEhAknpfO7OnUBca6fXF0+B+ccB/PeaTVTYMeMyDnJRZ0 Pea7NjnpSWuxbVV1ifX8254xabTyWd8W5+BGQ= 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=uB4xXQqqbiBiBe6qbgHf+yQehoIX3s+EnH9PLxIXb/Y=; b=irj/DsaLc4vaZpa9Szn39xrHnQQY5aaVyc41xBfTeOMHWHQRQvk0slcP+GUWZlSgNS fDkMCc3h072noOQ0BHP5iNpEPyWncc24qoMoSDy5PGDBE+B8X8nYlmH0eE+g3bM+7TZW qtPmcJynbEQ3XS3KfjZvdP3Syn258swYYwfzTnnlh8385hrpm8oA+vYRSjMqxtP5FmAA 4hZ55QufMshyH4H8BFmFvu9QxisrgXEkRueSBnCJIxeqVvO+4ULVHtPIjcF6Na+4JPYL sCif9ve7I17zlAaliufQq4u/MSkVN6C1Q7Erohvm6Y22tDg/I2jVE0QPvfZa+ehdxGzd FEVQ== X-Gm-Message-State: AFeK/H0AoYnHRttsODfENTvViAt9ssr42c0RntdM0xOdA5tCw0RQbJ3LHyD4XO1RoUFE1KD7 X-Received: by 10.28.105.92 with SMTP id e89mr2947497wmc.93.1490969766718; Fri, 31 Mar 2017 07:16:06 -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:15:44 +0100 Message-Id: <20170331141547.20987-7-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170331141547.20987-1-ard.biesheuvel@linaro.org> References: <20170331141547.20987-1-ard.biesheuvel@linaro.org> Subject: [edk2] [PATCH v2 06/13] Platforms/FVP: 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 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" 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/VExpress/Library/ArmVExpressDtPlatformDtbLoaderLib/ArmVExpre= ssDtPlatformDtbLoaderLib.c | 134 ++++++++++++++++++++ Platforms/ARM/VExpress/Library/ArmVExpressDtPlatformDtbLoaderLib/ArmVExpre= ssDtPlatformDtbLoaderLib.inf | 39 ++++++ 2 files changed, 173 insertions(+) diff --git a/Platforms/ARM/VExpress/Library/ArmVExpressDtPlatformDtbLoaderL= ib/ArmVExpressDtPlatformDtbLoaderLib.c b/Platforms/ARM/VExpress/Library/Arm= VExpressDtPlatformDtbLoaderLib/ArmVExpressDtPlatformDtbLoaderLib.c new file mode 100644 index 000000000000..3a5613c83709 --- /dev/null +++ b/Platforms/ARM/VExpress/Library/ArmVExpressDtPlatformDtbLoaderLib/ArmV= ExpressDtPlatformDtbLoaderLib.c @@ -0,0 +1,134 @@ +/** @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 +#include +#include +#include + +#include "ArmPlatform.h" + +typedef enum { + ARM_FVP_BASE_AEMv8x4_AEMv8x4_GICV2, + ARM_FVP_BASE_AEMv8x4_AEMv8x4_GICV2_LEGACY, + ARM_FVP_BASE_AEMv8x4_AEMv8x4_GICV3, + ARM_FVP_FOUNDATION_GICV2, + ARM_FVP_FOUNDATION_GICV2_LEGACY, + ARM_FVP_FOUNDATION_GICV3, + ARM_FVP_UNKNOWN, +} ARM_VEXPRESS_PLATFORM_ID; + +ARM_VEXPRESS_PLATFORM_ID +GetPlatformId ( + VOID + ) +{ + UINT32 SysId; + UINT32 FvpSysId; + UINT32 VariantSysId; + ARM_GIC_ARCH_REVISION GicRevision; + + SysId =3D MmioRead32 (ARM_VE_SYS_ID_REG); + + // Remove the GIC variant to identify if we are running on the FVP Base = or + // Foundation models + FvpSysId =3D SysId & (ARM_FVP_SYS_ID_HBI_MASK | ARM_FVP_SYS_ID_PLAT_= MASK ); + // Extract the variant from the SysId + VariantSysId =3D SysId & ARM_FVP_SYS_ID_VARIANT_MASK; + + if (FvpSysId =3D=3D ARM_FVP_BASE_BOARD_SYS_ID) { + if (VariantSysId =3D=3D ARM_FVP_GIC_VE_MMAP) { + // FVP Base Model with legacy GIC memory map -- no longer supported + return ARM_FVP_BASE_AEMv8x4_AEMv8x4_GICV2_LEGACY; + } else { + GicRevision =3D ArmGicGetSupportedArchRevision (); + + if (GicRevision =3D=3D ARM_GIC_ARCH_REVISION_2) { + // FVP Base Model with GICv2 support + return ARM_FVP_BASE_AEMv8x4_AEMv8x4_GICV2; + } else { + // FVP Base Model with GICv3 support + return ARM_FVP_BASE_AEMv8x4_AEMv8x4_GICV3; + } + } + } else if (FvpSysId =3D=3D ARM_FVP_FOUNDATION_BOARD_SYS_ID) { + if (VariantSysId =3D=3D ARM_FVP_GIC_VE_MMAP) { + // FVP Foundation Model with legacy GIC memory map -- no longer supp= orted + return ARM_FVP_FOUNDATION_GICV2_LEGACY; + } else { + GicRevision =3D ArmGicGetSupportedArchRevision (); + + if (GicRevision =3D=3D ARM_GIC_ARCH_REVISION_2) { + // FVP Foundation Model with GICv2 + return ARM_FVP_FOUNDATION_GICV2; + } else { + // FVP Foundation Model with GICv3 + return ARM_FVP_FOUNDATION_GICV3; + } + } + } + return ARM_FVP_UNKNOWN; +} + +/** + 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; + ARM_VEXPRESS_PLATFORM_ID PlatformId; + + PlatformId =3D GetPlatformId (); + ASSERT (PlatformId < ARM_FVP_UNKNOWN); + if (PlatformId >=3D ARM_FVP_UNKNOWN) { + return EFI_NOT_FOUND; + } + + Status =3D GetSectionFromAnyFv (&gDtPlatformDefaultDtbFileGuid, + EFI_SECTION_RAW, (UINTN)PlatformId, &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/Platforms/ARM/VExpress/Library/ArmVExpressDtPlatformDtbLoaderL= ib/ArmVExpressDtPlatformDtbLoaderLib.inf b/Platforms/ARM/VExpress/Library/A= rmVExpressDtPlatformDtbLoaderLib/ArmVExpressDtPlatformDtbLoaderLib.inf new file mode 100644 index 000000000000..5012101fe8db --- /dev/null +++ b/Platforms/ARM/VExpress/Library/ArmVExpressDtPlatformDtbLoaderLib/ArmV= ExpressDtPlatformDtbLoaderLib.inf @@ -0,0 +1,39 @@ +/** @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 ArmVExpressDtPlatformDtbLoaderLib + FILE_GUID =3D 050d6041-1508-4ae7-a69f-250155ccb567 + MODULE_TYPE =3D DXE_DRIVER + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D DtPlatformDtbLoaderLib|DXE_DRIVER + +[Sources] + ArmVExpressDtPlatformDtbLoaderLib.c + +[Packages] + ArmPkg/ArmPkg.dec + MdePkg/MdePkg.dec + EmbeddedPkg/EmbeddedPkg.dec + +[LibraryClasses] + ArmGicLib + BaseLib + DxeServicesLib + IoLib + MemoryAllocationLib + +[Guids] + gDtPlatformDefaultDtbFileGuid --=20 2.9.3 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel