[edk2-devel] [PATCH v3 2/5] OvmfPkg/Microvm/fdt: load fdt from fw_cfg
Philippe Mathieu-Daudé
philmd at redhat.com
Mon Dec 13 09:33:55 UTC 2021
On 12/13/21 09:16, Gerd Hoffmann 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
Link returns 404.
>
> 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__));
FreePages (NewBase)?
Otherwise:
Reviewed-by: Philippe Mathieu-Daude <philmd at redhat.com>
> + 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 ();
> PcdStatus = PcdSet16S (
> PcdOvmfHostBridgePciDevId,
> MICROVM_PSEUDO_DEVICE_ID
>
-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#84760): https://edk2.groups.io/g/devel/message/84760
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