[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [Xen-devel] [edk2-devel] [PATCH v2 13/31] OvmfPkg/Library/XenPlatformLib: New library
On 04/09/19 13:08, Anthony PERARD wrote: > The purpose of XenPlatformPei is to regroup the few functions that are (1) did you mean XenPlatformLib here? > used in several places to detect if Xen is detected, and to get the > XenInfo HOB. > > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Anthony PERARD <anthony.perard@xxxxxxxxxx> > --- > OvmfPkg/XenOvmf.dsc > | 1 + > MdePkg/Library/BaseSmbusLibNull/BaseSmbusLibNull.inf => > OvmfPkg/Library/XenPlatformLib/XenPlatformLib.inf | 27 +++---- > OvmfPkg/Include/Library/XenPlatformLib.h > | 59 +++++++++++++++ > OvmfPkg/Library/XenPlatformLib/XenPlatformLib.c > | 75 ++++++++++++++++++++ > 4 files changed, 150 insertions(+), 12 deletions(-) > > diff --git a/OvmfPkg/XenOvmf.dsc b/OvmfPkg/XenOvmf.dsc > index cc51bac3be..9529b4834f 100644 > --- a/OvmfPkg/XenOvmf.dsc > +++ b/OvmfPkg/XenOvmf.dsc > @@ -198,6 +198,7 @@ [LibraryClasses] > SmbusLib|MdePkg/Library/BaseSmbusLibNull/BaseSmbusLibNull.inf > > OrderedCollectionLib|MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.inf > XenHypercallLib|OvmfPkg/Library/XenHypercallLib/XenHypercallLib.inf > + XenPlatformLib|OvmfPkg/Library/XenPlatformLib/XenPlatformLib.inf > > > Tcg2PhysicalPresenceLib|OvmfPkg/Library/Tcg2PhysicalPresenceLibNull/DxeTcg2PhysicalPresenceLib.inf > > diff --git a/MdePkg/Library/BaseSmbusLibNull/BaseSmbusLibNull.inf > b/OvmfPkg/Library/XenPlatformLib/XenPlatformLib.inf > similarity index 56% > copy from MdePkg/Library/BaseSmbusLibNull/BaseSmbusLibNull.inf > copy to OvmfPkg/Library/XenPlatformLib/XenPlatformLib.inf > index 4fd4874595..ca078f7263 100644 > --- a/MdePkg/Library/BaseSmbusLibNull/BaseSmbusLibNull.inf > +++ b/OvmfPkg/Library/XenPlatformLib/XenPlatformLib.inf obviously this is a false positive for git's "--find-copies-harder", but I can look at the file in isolation using your git branch... (3) Please use "SPDX-License-Identifier: BSD-2-Clause-Patent", rather than the open-coded 2-clause BSDL. (This applies to other new files in this patch as well.) [...] > diff --git a/OvmfPkg/Include/Library/XenPlatformLib.h > b/OvmfPkg/Include/Library/XenPlatformLib.h > new file mode 100644 > index 0000000000..8f57450575 > --- /dev/null > +++ b/OvmfPkg/Include/Library/XenPlatformLib.h > @@ -0,0 +1,59 @@ > +/** @file > +* Get information about Xen > +* > +* This library simply allow to find out if OVMF is running under Xen and > +* allow to get more information when it is the case. > +* > +* Copyright (c) 2019, Citrix Systems, Inc. > +* > +* This program and the accompanying materials are > +* licensed and made available under the terms and conditions of the BSD > License > +* which accompanies this distribution. The full text of the license may be > found at > +* http://opensource.org/licenses/bsd-license.php > +* > +* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, > +* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR > IMPLIED. > +* > +**/ > + > +#ifndef _XEN_PLATFORM_LIB_H_ > +#define _XEN_PLATFORM_LIB_H_ > + > +#include <Guid/XenInfo.h> > + > +/** > + This function detects if OVMF is running on Xen. > + > + @retval TRUE OVMF is running on Xen > + @retval FALSE Xen as not been detected (4) "has" not been detected ... same for the function definition as well, in the .c file below. (5) At the introduction of a new library class, we should update the [LibraryClasses] section in the "OvmfPkg/OvmfPkg.dec" file. I think you can add this new class under XenHypercallLib and XenIoMmioLib there. (To confirm, I'm not speaking about the .dsc file, but the .dec file.) Thanks Laszlo > +**/ > +BOOLEAN > +EFIAPI > +XenDetected ( > + VOID > + ); > + > +/** > + This function detect if OVMF have started via the PVH entry point. > + > + @retval TRUE PVH entry point as been used > + @retval FALSE OVMF have started via the HVM route > +**/ > +BOOLEAN > +EFIAPI > +XenPvhDetected ( > + VOID > + ); > + > +/** > + This function return a pointer to the XenInfo HOB. > + > + @return XenInfo pointer or NULL if not available > +**/ > +EFI_XEN_INFO * > +EFIAPI > +XenGetInfoHOB ( > + VOID > + ); > + > +#endif > diff --git a/OvmfPkg/Library/XenPlatformLib/XenPlatformLib.c > b/OvmfPkg/Library/XenPlatformLib/XenPlatformLib.c > new file mode 100644 > index 0000000000..274ddfc9ad > --- /dev/null > +++ b/OvmfPkg/Library/XenPlatformLib/XenPlatformLib.c > @@ -0,0 +1,75 @@ > +/** @file > +* Get information about Xen > +* > +* This library simply allow to find out if OVMF is running under Xen and > +* allow to get more information when it is the case. > +* > +* Copyright (c) 2019, Citrix Systems, Inc. > +* > +* This program and the accompanying materials are > +* licensed and made available under the terms and conditions of the BSD > License > +* which accompanies this distribution. The full text of the license may be > found at > +* http://opensource.org/licenses/bsd-license.php > +* > +* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, > +* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR > IMPLIED. > +* > +**/ > + > +#include <PiDxe.h> > +#include <Library/HobLib.h> > +#include <Library/XenPlatformLib.h> > + > +/** > + This function return a pointer to the XenInfo HOB. > + > + @return XenInfo pointer or NULL if not available > +**/ > +EFI_XEN_INFO * > +EFIAPI > +XenGetInfoHOB ( > + VOID > + ) > +{ > + EFI_HOB_GUID_TYPE *GuidHob; > + > + GuidHob = GetFirstGuidHob (&gEfiXenInfoGuid); > + if (GuidHob == NULL) { > + return NULL; > + } > + > + return (EFI_XEN_INFO *) GET_GUID_HOB_DATA (GuidHob); > +} > + > +/** > + This function detects if OVMF is running on Xen. > + > + @retval TRUE OVMF is running on Xen > + @retval FALSE Xen as not been detected > +**/ > +BOOLEAN > +EFIAPI > +XenDetected ( > + VOID > + ) > +{ > + return (XenGetInfoHOB () != NULL); > +} > + > +/** > + This function detect if OVMF have started via the PVH entry point. > + > + @retval TRUE PVH entry point as been used > + @retval FALSE OVMF have started via the HVM route > +**/ > +BOOLEAN > +EFIAPI > +XenPvhDetected ( > + VOID > + ) > +{ > + EFI_XEN_INFO *XenInfo; > + > + XenInfo = XenGetInfoHOB (); > + return (XenInfo != NULL && XenInfo->RsdpPvh != NULL); > +} > _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/mailman/listinfo/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |