public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Ard Biesheuvel" <ard.biesheuvel@arm.com>
To: Sami Mujawar <sami.mujawar@arm.com>, 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
Subject: Re: [PATCH v3 11/15] ArmVirtPkg: Add Kvmtool Platform Pei Lib
Date: Thu, 25 Jun 2020 16:05:32 +0200	[thread overview]
Message-ID: <2ac8972d-ae3c-e847-0cc5-e41d13c0f42f@arm.com> (raw)
In-Reply-To: <20200624133458.61920-12-sami.mujawar@arm.com>

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 <sami.mujawar@arm.com>

Reviewed-by: Ard Biesheuvel <ard.biesheuvel@arm.com>

> ---
>   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 <PiPei.h>
> +
> +#include <Guid/Early16550UartBaseAddress.h>
> +#include <Guid/FdtHob.h>
> +
> +#include <Library/MemoryAllocationLib.h>
> +#include <Library/DebugLib.h>
> +#include <Library/HobLib.h>
> +#include <Library/PcdLib.h>
> +#include <Library/PeiServicesLib.h>
> +#include <libfdt.h>
> +
> +/** 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
> 


  reply	other threads:[~2020-06-25 14:05 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-06-24 13:34 [PATCH v3 00/15] Kvmtool guest firmware support for Arm Sami Mujawar
2020-06-24 13:34 ` [PATCH v3 01/15] PcAtChipsetPkg: Add MMIO Support to RTC driver Sami Mujawar
2020-06-25 11:24   ` Ard Biesheuvel
2020-06-29  2:36     ` [edk2-devel] " Guomin Jiang
2020-06-24 13:34 ` [PATCH v3 02/15] ArmVirtPkg: Add Kvmtool RTC Fdt Client Library Sami Mujawar
2020-06-25 11:31   ` Ard Biesheuvel
2020-06-24 13:34 ` [PATCH v3 03/15] ArmPlatformPkg: Dynamic flash variable base Sami Mujawar
2020-06-24 13:34 ` [PATCH v3 04/15] ArmVirtPkg: Add kvmtool platform driver Sami Mujawar
2020-06-25 11:35   ` Ard Biesheuvel
2020-06-24 13:34 ` [PATCH v3 05/15] ArmVirtPkg: kvmtool platform memory map Sami Mujawar
2020-06-24 13:34 ` [PATCH v3 06/15] ArmVirtPkg: Add Kvmtool NOR flash lib Sami Mujawar
2020-06-25  8:45   ` Philippe Mathieu-Daudé
2020-06-25 11:19     ` [edk2-devel] " Ard Biesheuvel
2020-06-25 11:41       ` Philippe Mathieu-Daudé
2020-06-25 11:38   ` Ard Biesheuvel
2020-06-25 17:33     ` Sami Mujawar
2020-06-24 13:34 ` [PATCH v3 07/15] ArmVirtPkg: Early serial port initialisation Sami Mujawar
2020-06-25 11:42   ` Ard Biesheuvel
2020-06-26  9:23     ` Julien Grall
2020-06-24 13:34 ` [PATCH v3 08/15] MdeModulePkg: Fix constructor invocation ordering Sami Mujawar
2020-06-25 13:51   ` Ard Biesheuvel
2020-06-26 13:22     ` Laszlo Ersek
2020-06-27 11:37       ` Ard Biesheuvel
2020-06-24 13:34 ` [PATCH v3 09/15] ArmVirtPkg: GUID Hob for 16550 UART base address Sami Mujawar
2020-06-25 13:52   ` Ard Biesheuvel
2020-06-24 13:34 ` [PATCH v3 10/15] ArmVirtPkg: 16550 UART Platform hook library Sami Mujawar
2020-06-25 13:56   ` Ard Biesheuvel
2020-06-24 13:34 ` [PATCH v3 11/15] ArmVirtPkg: Add Kvmtool Platform Pei Lib Sami Mujawar
2020-06-25 14:05   ` Ard Biesheuvel [this message]
2020-06-24 13:34 ` [PATCH v3 12/15] ArmVirtPkg: Support for kvmtool virtual platform Sami Mujawar
2020-06-25 14:08   ` Ard Biesheuvel
2020-06-26 13:26     ` Laszlo Ersek
2020-06-24 13:34 ` [PATCH v3 13/15] ArmVirtPkg: Package dependency for MC146818 RTC Sami Mujawar
2020-06-25 14:08   ` Ard Biesheuvel
2020-06-24 13:34 ` [PATCH v3 14/15] ArmVirtPkg: Add kvmtool to package dictionary Sami Mujawar
2020-06-25 14:09   ` Ard Biesheuvel
2020-06-24 13:34 ` [PATCH v3 15/15] Maintainer.txt: Add Kvmtool platform reviewer Sami Mujawar
2020-06-25 14:09   ` Ard Biesheuvel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2ac8972d-ae3c-e847-0cc5-e41d13c0f42f@arm.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox