From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by mx.groups.io with SMTP id smtpd.web11.11316.1593093937347810232 for ; Thu, 25 Jun 2020 07:05:37 -0700 Authentication-Results: mx.groups.io; dkim=missing; spf=pass (domain: arm.com, ip: 217.140.110.172, mailfrom: ard.biesheuvel@arm.com) Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 076CBC0A; Thu, 25 Jun 2020 07:05:37 -0700 (PDT) Received: from [192.168.1.69] (unknown [10.37.8.29]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 7228C3F73C; Thu, 25 Jun 2020 07:05:34 -0700 (PDT) Subject: Re: [PATCH v3 11/15] ArmVirtPkg: Add Kvmtool Platform Pei Lib To: Sami Mujawar , devel@edk2.groups.io Cc: leif@nuviainc.com, lersek@redhat.com, Alexandru.Elisei@arm.com, Andre.Przywara@arm.com, Matteo.Carlini@arm.com, Laura.Moretta@arm.com, nd@arm.com References: <20200624133458.61920-1-sami.mujawar@arm.com> <20200624133458.61920-12-sami.mujawar@arm.com> From: "Ard Biesheuvel" Message-ID: <2ac8972d-ae3c-e847-0cc5-e41d13c0f42f@arm.com> Date: Thu, 25 Jun 2020 16:05:32 +0200 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 MIME-Version: 1.0 In-Reply-To: <20200624133458.61920-12-sami.mujawar@arm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit On 6/24/20 3:34 PM, Sami Mujawar wrote: > The PlatformPeim() in the PlatformPeiLib is invoked > by the PrePiMain() and provides the platform an > opportunity to setup the plaform specific HOBs. > > This PlatfromPeiLib initialises the Kvmtool platform > HOBs like the Fdt, 16550BaseAddress, etc. > > Signed-off-by: Sami Mujawar Reviewed-by: Ard Biesheuvel > --- > ArmVirtPkg/Library/KvmtoolPlatformPeiLib/KvmtoolPlatformPeiLib.c | 78 ++++++++++++++++++++ > ArmVirtPkg/Library/KvmtoolPlatformPeiLib/KvmtoolPlatformPeiLib.inf | 48 ++++++++++++ > 2 files changed, 126 insertions(+) > > diff --git a/ArmVirtPkg/Library/KvmtoolPlatformPeiLib/KvmtoolPlatformPeiLib.c b/ArmVirtPkg/Library/KvmtoolPlatformPeiLib/KvmtoolPlatformPeiLib.c > new file mode 100644 > index 0000000000000000000000000000000000000000..a97b31537fbc8071eed030f912ade60de3945356 > --- /dev/null > +++ b/ArmVirtPkg/Library/KvmtoolPlatformPeiLib/KvmtoolPlatformPeiLib.c > @@ -0,0 +1,78 @@ > +/** @file > +* > +* Copyright (c) 2020, ARM Limited. All rights reserved. > +* > +* SPDX-License-Identifier: BSD-2-Clause-Patent > +* > +**/ > + > +#include > + > +#include > +#include > + > +#include > +#include > +#include > +#include > +#include > +#include > + > +/** Initialise Platform HOBs > + > + @retval EFI_SUCCESS Success. > + @retval EFI_INVALID_PARAMETER A parameter is invalid. > + @retval EFI_OUT_OF_RESOURCES Out of resources. > +**/ > +EFI_STATUS > +EFIAPI > +PlatformPeim ( > + VOID > + ) > +{ > + VOID *Base; > + VOID *NewBase; > + UINTN FdtSize; > + UINTN FdtPages; > + UINT64 *FdtHobData; > + UINT64 *UartHobData; > + > + Base = (VOID*)(UINTN)PcdGet64 (PcdDeviceTreeInitialBaseAddress); > + if ((Base == NULL) || (fdt_check_header (Base) != 0)) { > + ASSERT (0); > + return EFI_INVALID_PARAMETER; > + } > + > + FdtSize = fdt_totalsize (Base) + PcdGet32 (PcdDeviceTreeAllocationPadding); > + FdtPages = EFI_SIZE_TO_PAGES (FdtSize); > + NewBase = AllocatePages (FdtPages); > + if (NewBase == NULL) { > + ASSERT (0); > + return EFI_OUT_OF_RESOURCES; > + } > + > + fdt_open_into (Base, NewBase, EFI_PAGES_TO_SIZE (FdtPages)); > + > + FdtHobData = BuildGuidHob (&gFdtHobGuid, sizeof (*FdtHobData)); > + if (FdtHobData == NULL) { > + ASSERT (0); > + return EFI_OUT_OF_RESOURCES; > + } > + > + *FdtHobData = (UINTN)NewBase; > + > + UartHobData = BuildGuidHob ( > + &gEarly16550UartBaseAddressGuid, > + sizeof (*UartHobData) > + ); > + if (UartHobData == NULL) { > + ASSERT (0); > + return EFI_OUT_OF_RESOURCES; > + } > + > + *UartHobData = PcdGet64 (PcdSerialRegisterBase); > + > + BuildFvHob (PcdGet64 (PcdFvBaseAddress), PcdGet32 (PcdFvSize)); > + > + return EFI_SUCCESS; > +} > diff --git a/ArmVirtPkg/Library/KvmtoolPlatformPeiLib/KvmtoolPlatformPeiLib.inf b/ArmVirtPkg/Library/KvmtoolPlatformPeiLib/KvmtoolPlatformPeiLib.inf > new file mode 100644 > index 0000000000000000000000000000000000000000..9f44b8885d3c131de1d41ac6947bd9218cfdf3e7 > --- /dev/null > +++ b/ArmVirtPkg/Library/KvmtoolPlatformPeiLib/KvmtoolPlatformPeiLib.inf > @@ -0,0 +1,48 @@ > +#/** @file > +# > +# Copyright (c) 2020, ARM Limited. All rights reserved. > +# > +# SPDX-License-Identifier: BSD-2-Clause-Patent > +# > +#**/ > + > +[Defines] > + INF_VERSION = 0x0001001B > + BASE_NAME = PlatformPeiLib > + FILE_GUID = 21073FB3-BA6F-43EB-83F0-4A840C648165 > + MODULE_TYPE = BASE > + VERSION_STRING = 1.0 > + LIBRARY_CLASS = KvmtoolPlatformPeiLib > + > +[Sources] > + KvmtoolPlatformPeiLib.c > + > +[Packages] > + ArmPkg/ArmPkg.dec > + ArmVirtPkg/ArmVirtPkg.dec > + EmbeddedPkg/EmbeddedPkg.dec > + MdeModulePkg/MdeModulePkg.dec > + MdePkg/MdePkg.dec > + > +[LibraryClasses] > + DebugLib > + HobLib > + FdtLib > + PcdLib > + PeiServicesLib > + > +[FixedPcd] > + gArmTokenSpaceGuid.PcdFvSize > + gArmVirtTokenSpaceGuid.PcdDeviceTreeAllocationPadding > + > +[Pcd] > + gArmTokenSpaceGuid.PcdFvBaseAddress > + gArmVirtTokenSpaceGuid.PcdDeviceTreeInitialBaseAddress > + gEfiMdeModulePkgTokenSpaceGuid.PcdSerialRegisterBase > + > +[Guids] > + gFdtHobGuid > + gEarly16550UartBaseAddressGuid > + > +[Depex] > + gEfiPeiMemoryDiscoveredPpiGuid >