[edk2-devel] [PATCH v3 28/35] OvmfPkg/PlatformBootManagerLib: Use XenDetected from XenPlatformLib

Anthony PERARD posted 35 patches 5 years, 4 months ago
There is a newer version of this series
[edk2-devel] [PATCH v3 28/35] OvmfPkg/PlatformBootManagerLib: Use XenDetected from XenPlatformLib
Posted by Anthony PERARD 5 years, 4 months ago
Replace the XenDetected() implementation by the one from
XenPlatformLib.

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1689
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---

Notes:
    v3:
    - new patch

 .../PlatformBootManagerLib.inf                |  1 +
 .../PlatformBootManagerLib/BdsPlatform.c      | 33 +------------------
 2 files changed, 2 insertions(+), 32 deletions(-)

diff --git a/OvmfPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf b/OvmfPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
index 060a3ab4c5..b2d3b4fb4d 100644
--- a/OvmfPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
+++ b/OvmfPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
@@ -54,6 +54,7 @@ [LibraryClasses]
   UefiLib

   PlatformBmPrintScLib

   Tcg2PhysicalPresenceLib

+  XenPlatformLib

 

 [Pcd]

   gUefiOvmfPkgTokenSpaceGuid.PcdEmuVariableEvent

diff --git a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
index 797731a41c..e32969e63e 100644
--- a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
+++ b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
@@ -12,6 +12,7 @@
 #include <Protocol/FirmwareVolume2.h>

 #include <Library/PlatformBmPrintScLib.h>

 #include <Library/Tcg2PhysicalPresenceLib.h>

+#include <Library/XenPlatformLib.h>

 

 

 //

@@ -1225,38 +1226,6 @@ PciAcpiInitialization (
   IoOr16 ((PciRead32 (Pmba) & ~BIT0) + 4, BIT0);

 }

 

-/**

-  This function detects if OVMF is running on Xen.

-

-**/

-STATIC

-BOOLEAN

-XenDetected (

-  VOID

-  )

-{

-  EFI_HOB_GUID_TYPE         *GuidHob;

-  STATIC INTN               FoundHob = -1;

-

-  if (FoundHob == 0) {

-    return FALSE;

-  } else if (FoundHob == 1) {

-    return TRUE;

-  }

-

-  //

-  // See if a XenInfo HOB is available

-  //

-  GuidHob = GetFirstGuidHob (&gEfiXenInfoGuid);

-  if (GuidHob == NULL) {

-    FoundHob = 0;

-    return FALSE;

-  }

-

-  FoundHob = 1;

-  return TRUE;

-}

-

 EFI_STATUS

 EFIAPI

 ConnectRecursivelyIfPciMassStorage (

-- 
Anthony PERARD


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#43302): https://edk2.groups.io/g/devel/message/43302
Mute This Topic: https://groups.io/mt/32308726/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-

Re: [edk2-devel] [PATCH v3 28/35] OvmfPkg/PlatformBootManagerLib: Use XenDetected from XenPlatformLib
Posted by Laszlo Ersek 5 years, 4 months ago
On 07/04/19 16:42, Anthony PERARD wrote:
> Replace the XenDetected() implementation by the one from
> XenPlatformLib.
> 
> Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1689
> Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
> ---
> 
> Notes:
>     v3:
>     - new patch
> 
>  .../PlatformBootManagerLib.inf                |  1 +
>  .../PlatformBootManagerLib/BdsPlatform.c      | 33 +------------------
>  2 files changed, 2 insertions(+), 32 deletions(-)
> 
> diff --git a/OvmfPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf b/OvmfPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
> index 060a3ab4c5..b2d3b4fb4d 100644
> --- a/OvmfPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
> +++ b/OvmfPkg/Library/PlatformBootManagerLib/PlatformBootManagerLib.inf
> @@ -54,6 +54,7 @@ [LibraryClasses]
>    UefiLib
>    PlatformBmPrintScLib
>    Tcg2PhysicalPresenceLib
> +  XenPlatformLib
>  
>  [Pcd]
>    gUefiOvmfPkgTokenSpaceGuid.PcdEmuVariableEvent
> diff --git a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
> index 797731a41c..e32969e63e 100644
> --- a/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
> +++ b/OvmfPkg/Library/PlatformBootManagerLib/BdsPlatform.c
> @@ -12,6 +12,7 @@
>  #include <Protocol/FirmwareVolume2.h>
>  #include <Library/PlatformBmPrintScLib.h>
>  #include <Library/Tcg2PhysicalPresenceLib.h>
> +#include <Library/XenPlatformLib.h>
>  
>  
>  //
> @@ -1225,38 +1226,6 @@ PciAcpiInitialization (
>    IoOr16 ((PciRead32 (Pmba) & ~BIT0) + 4, BIT0);
>  }
>  
> -/**
> -  This function detects if OVMF is running on Xen.
> -
> -**/
> -STATIC
> -BOOLEAN
> -XenDetected (
> -  VOID
> -  )
> -{
> -  EFI_HOB_GUID_TYPE         *GuidHob;
> -  STATIC INTN               FoundHob = -1;
> -
> -  if (FoundHob == 0) {
> -    return FALSE;
> -  } else if (FoundHob == 1) {
> -    return TRUE;
> -  }
> -
> -  //
> -  // See if a XenInfo HOB is available
> -  //
> -  GuidHob = GetFirstGuidHob (&gEfiXenInfoGuid);
> -  if (GuidHob == NULL) {
> -    FoundHob = 0;
> -    return FALSE;
> -  }
> -
> -  FoundHob = 1;
> -  return TRUE;
> -}
> -
>  EFI_STATUS
>  EFIAPI
>  ConnectRecursivelyIfPciMassStorage (
> 

Is it possible to clean up the remaining code a bit more, such as:

(1) removing

#include <Guid/XenInfo.h>

from "BdsPlatform.c",

(2) removing "gEfiXenInfoGuid" from [Guids] in "PlatformBootManagerLib.inf"?

With those:

Reviewed-by: Laszlo Ersek <lersek@redhat.com>

Thanks
Laszlo

-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#43471): https://edk2.groups.io/g/devel/message/43471
Mute This Topic: https://groups.io/mt/32308726/1787277
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [importer@patchew.org]
-=-=-=-=-=-=-=-=-=-=-=-