OvmfPkg/Bhyve: build platform info HOB

Copy the function BuildPlatformInfoHob() from OvmfPkg/PlatformPei.

QemuFwCfgLib expect this HOB to be present, or fails to do anything.
InternalQemuFwCfgIsAvailable() from QemuFwCfgPeiLib module will not
check if the HOB is actually present for example and try to use a NULL
pointer.

Fixes: cda98df16228970dcf9a4ce2af5368219711b4b0 ("OvmfPkg/QemuFwCfgLib: remove mQemuFwCfgSupported + mQemuFwCfgDmaSupported")
Signed-off-by: Corvin Köhne <corvink@FreeBSD.org>
Reviewed-by: Rebecca Cran <rebecca@bsdio.com>
diff --git a/OvmfPkg/Bhyve/PlatformPei/Platform.c b/OvmfPkg/Bhyve/PlatformPei/Platform.c
index 5bfe435..f6d9a90 100644
--- a/OvmfPkg/Bhyve/PlatformPei/Platform.c
+++ b/OvmfPkg/Bhyve/PlatformPei/Platform.c
@@ -17,6 +17,7 @@
 //

 // The Library classes this module consumes

 //

+#include <Library/BaseMemoryLib.h>

 #include <Library/BaseLib.h>

 #include <Library/DebugLib.h>

 #include <Library/HobLib.h>

@@ -27,6 +28,7 @@
 #include <Library/PciLib.h>

 #include <Library/PeimEntryPoint.h>

 #include <Library/PeiServicesLib.h>

+#include <Library/PlatformInitLib.h>

 #include <Library/ResourcePublicationLib.h>

 #include <Guid/MemoryTypeInformation.h>

 #include <Ppi/MasterBootMode.h>

@@ -535,6 +537,24 @@
 }

 

 /**

+ * @brief Builds PlatformInfo Hob

+ */

+STATIC

+EFI_HOB_PLATFORM_INFO *

+BuildPlatformInfoHob (

+  VOID

+  )

+{

+  EFI_HOB_PLATFORM_INFO  PlatformInfoHob;

+  EFI_HOB_GUID_TYPE      *GuidHob;

+

+  ZeroMem (&PlatformInfoHob, sizeof PlatformInfoHob);

+  BuildGuidDataHob (&gUefiOvmfPkgPlatformInfoGuid, &PlatformInfoHob, sizeof (EFI_HOB_PLATFORM_INFO));

+  GuidHob = GetFirstGuidHob (&gUefiOvmfPkgPlatformInfoGuid);

+  return (EFI_HOB_PLATFORM_INFO *)GET_GUID_HOB_DATA (GuidHob);

+}

+

+/**

   Perform Platform PEI initialization.

 

   @param  FileHandle      Handle of the file being invoked.

@@ -551,6 +571,7 @@
   )

 {

   DEBUG ((DEBUG_INFO, "Platform PEIM Loaded\n"));

+  BuildPlatformInfoHob ();

 

   //

   // Initialize Local APIC Timer hardware and disable Local APIC Timer

diff --git a/OvmfPkg/Bhyve/PlatformPei/PlatformPei.inf b/OvmfPkg/Bhyve/PlatformPei/PlatformPei.inf
index 739d630..07570d4 100644
--- a/OvmfPkg/Bhyve/PlatformPei/PlatformPei.inf
+++ b/OvmfPkg/Bhyve/PlatformPei/PlatformPei.inf
@@ -44,6 +44,7 @@
 

 [Guids]

   gEfiMemoryTypeInformationGuid

+  gUefiOvmfPkgPlatformInfoGuid

 

 [LibraryClasses]

   BaseLib