[edk2-devel] [PATCH v3 2/5] OvmfPkg/Microvm/fdt: load fdt from fw_cfg

Ard Biesheuvel ardb at kernel.org
Mon Dec 13 09:43:35 UTC 2021


On Mon, 13 Dec 2021 at 09:17, Gerd Hoffmann <kraxel at redhat.com> wrote:
>
> Needed for hardware detection: virtio-mmio devices for now,
> later also pcie root bridge.
>
> Depends on patched qemu which actually provides an fdt:
> https://gitlab.com/kraxel/qemu/-/commits/sirius/microvm-device-tree
>
> https://bugzilla.tianocore.org/show_bug.cgi?id=3689
> Signed-off-by: Gerd Hoffmann <kraxel at redhat.com>
> ---
>  OvmfPkg/PlatformPei/PlatformPei.inf |  1 +
>  OvmfPkg/PlatformPei/Platform.c      | 45 +++++++++++++++++++++++++++++
>  2 files changed, 46 insertions(+)
>
> diff --git a/OvmfPkg/PlatformPei/PlatformPei.inf b/OvmfPkg/PlatformPei/PlatformPei.inf
> index 1c56ba275835..8ef404168c45 100644
> --- a/OvmfPkg/PlatformPei/PlatformPei.inf
> +++ b/OvmfPkg/PlatformPei/PlatformPei.inf
> @@ -44,6 +44,7 @@ [Packages]
>
>  [Guids]
>    gEfiMemoryTypeInformationGuid
> +  gFdtHobGuid
>
>  [LibraryClasses]
>    BaseLib
> diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c
> index 906f64615de7..c9ec1d7e99fb 100644
> --- a/OvmfPkg/PlatformPei/Platform.c
> +++ b/OvmfPkg/PlatformPei/Platform.c
> @@ -321,6 +321,50 @@ PciExBarInitialization (
>      );
>  }
>
> +VOID
> +MicrovmInitialization (
> +  VOID
> +  )
> +{
> +  FIRMWARE_CONFIG_ITEM  FdtItem;
> +  UINTN                 FdtSize;
> +  UINTN                 FdtPages;
> +  EFI_STATUS            Status;
> +  UINT64                *FdtHobData;
> +  VOID                  *NewBase;
> +
> +  Status = QemuFwCfgFindFile ("etc/fdt", &FdtItem, &FdtSize);
> +  if (EFI_ERROR (Status)) {
> +    DEBUG ((DEBUG_INFO, "%a: no etc/fdt found in fw_cfg\n", __FUNCTION__));
> +    return;
> +  }
> +
> +  FdtPages = EFI_SIZE_TO_PAGES (FdtSize);
> +  NewBase  = AllocatePages (FdtPages);
> +  if (NewBase == NULL) {
> +    DEBUG ((DEBUG_INFO, "%a: AllocatePages failed\n", __FUNCTION__));
> +    return;
> +  }
> +
> +  QemuFwCfgSelectItem (FdtItem);
> +  QemuFwCfgReadBytes (FdtSize, NewBase);
> +
> +  FdtHobData = BuildGuidHob (&gFdtHobGuid, sizeof (*FdtHobData));
> +  if (FdtHobData == NULL) {
> +    DEBUG ((DEBUG_INFO, "%a: BuildGuidHob failed\n", __FUNCTION__));
> +    return;
> +  }
> +
> +  DEBUG ((
> +    DEBUG_INFO,
> +    "%a: fdt at 0x%x (size %d)\n",
> +    __FUNCTION__,
> +    NewBase,
> +    FdtSize
> +    ));
> +  *FdtHobData = (UINTN)NewBase;
> +}
> +
>  VOID
>  MiscInitialization (
>    VOID
> @@ -368,6 +412,7 @@ MiscInitialization (
>        break;
>      case 0xffff: /* microvm */
>        DEBUG ((DEBUG_INFO, "%a: microvm\n", __FUNCTION__));
> +      MicrovmInitialization ();

Is this the best spot for calling Microvm related init code that is
entirely unrelated to PCIe?

>        PcdStatus = PcdSet16S (
>                      PcdOvmfHostBridgePciDevId,
>                      MICROVM_PSEUDO_DEVICE_ID
> --
> 2.33.1
>
>
>
> 
>
>


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#84693): https://edk2.groups.io/g/devel/message/84693
Mute This Topic: https://groups.io/mt/87693654/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-





More information about the edk2-devel-archive mailing list