F: OvmfPkg/Include/IndustryStandard/Xen/\r
F: OvmfPkg/Include/Library/XenHypercallLib.h\r
F: OvmfPkg/Include/Library/XenIoMmioLib.h\r
+F: OvmfPkg/Include/Library/XenPlatformLib.h\r
F: OvmfPkg/Include/Protocol/XenBus.h\r
F: OvmfPkg/Include/Protocol/XenIo.h\r
F: OvmfPkg/Library/PciHostBridgeLib/XenSupport.c\r
F: OvmfPkg/Library/XenConsoleSerialPortLib/\r
F: OvmfPkg/Library/XenHypercallLib/\r
F: OvmfPkg/Library/XenIoMmioLib/\r
+F: OvmfPkg/Library/XenPlatformLib/\r
F: OvmfPkg/OvmfXen.*\r
F: OvmfPkg/OvmfXenElfHeaderGenerator.c\r
F: OvmfPkg/PlatformPei/MemDetect.c\r
--- /dev/null
+/** @file\r
+ Get information about Xen\r
+\r
+ This library simply allow to find out if OVMF is running under Xen and\r
+ allow to get more information when it is the case.\r
+\r
+ Copyright (c) 2019, Citrix Systems, Inc.\r
+\r
+ SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+\r
+#ifndef _XEN_PLATFORM_LIB_H_\r
+#define _XEN_PLATFORM_LIB_H_\r
+\r
+#include <Guid/XenInfo.h>\r
+\r
+/**\r
+ This function detects if OVMF is running on Xen.\r
+\r
+ @retval TRUE OVMF is running on Xen\r
+ @retval FALSE Xen has not been detected\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+XenDetected (\r
+ VOID\r
+ );\r
+\r
+/**\r
+ This function detect if OVMF have started via the PVH entry point.\r
+\r
+ @retval TRUE PVH entry point as been used\r
+ @retval FALSE OVMF have started via the HVM route\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+XenPvhDetected (\r
+ VOID\r
+ );\r
+\r
+/**\r
+ This function return a pointer to the XenInfo HOB.\r
+\r
+ @return XenInfo pointer or NULL if not available\r
+**/\r
+EFI_XEN_INFO *\r
+EFIAPI\r
+XenGetInfoHOB (\r
+ VOID\r
+ );\r
+\r
+#endif\r
--- /dev/null
+/** @file\r
+ Get information about Xen\r
+\r
+ This library simply allow to find out if OVMF is running under Xen and\r
+ allow to get more information when it is the case.\r
+\r
+ Copyright (c) 2019, Citrix Systems, Inc.\r
+\r
+ SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+\r
+#include <PiDxe.h>\r
+#include <Library/HobLib.h>\r
+#include <Library/XenPlatformLib.h>\r
+\r
+/**\r
+ This function return a pointer to the XenInfo HOB.\r
+\r
+ @return XenInfo pointer or NULL if not available\r
+**/\r
+EFI_XEN_INFO *\r
+EFIAPI\r
+XenGetInfoHOB (\r
+ VOID\r
+ )\r
+{\r
+ EFI_HOB_GUID_TYPE *GuidHob;\r
+\r
+ GuidHob = GetFirstGuidHob (&gEfiXenInfoGuid);\r
+ if (GuidHob == NULL) {\r
+ return NULL;\r
+ }\r
+\r
+ return (EFI_XEN_INFO *) GET_GUID_HOB_DATA (GuidHob);\r
+}\r
+\r
+/**\r
+ This function detects if OVMF is running on Xen.\r
+\r
+ @retval TRUE OVMF is running on Xen\r
+ @retval FALSE Xen has not been detected\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+XenDetected (\r
+ VOID\r
+ )\r
+{\r
+ return (XenGetInfoHOB () != NULL);\r
+}\r
+\r
+/**\r
+ This function detect if OVMF have started via the PVH entry point.\r
+\r
+ @retval TRUE PVH entry point as been used\r
+ @retval FALSE OVMF have started via the HVM route\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+XenPvhDetected (\r
+ VOID\r
+ )\r
+{\r
+ EFI_XEN_INFO *XenInfo;\r
+\r
+ XenInfo = XenGetInfoHOB ();\r
+ return (XenInfo != NULL && XenInfo->RsdpPvh != NULL);\r
+}\r
--- /dev/null
+## @file\r
+# Get information about Xen\r
+#\r
+# This library simply allow to find out if OVMF is running under Xen and\r
+# allow to get more information when it is the case.\r
+#\r
+# Copyright (c) 2019, Citrix Systems, Inc.\r
+#\r
+# SPDX-License-Identifier: BSD-2-Clause-Patent\r
+#\r
+#\r
+##\r
+\r
+[Defines]\r
+ INF_VERSION = 0x00010005\r
+ BASE_NAME = XenPlatformLib\r
+ FILE_GUID = DB54DBB7-8142-4EE5-9364-78C824B582EB\r
+ MODULE_TYPE = BASE\r
+ VERSION_STRING = 1.0\r
+ LIBRARY_CLASS = XenPlatformLib\r
+\r
+[Sources]\r
+ XenPlatformLib.c\r
+\r
+[Packages]\r
+ MdePkg/MdePkg.dec\r
+ OvmfPkg/OvmfPkg.dec\r
+\r
+[LibraryClasses]\r
+ HobLib\r
+\r
+[Guids]\r
+ gEfiXenInfoGuid\r
#\r
XenIoMmioLib|Include/Library/XenIoMmioLib.h\r
\r
+ ## @libraryclass Get information about Xen\r
+ #\r
+ XenPlatformLib|Include/Library/XenPlatformLib.h\r
+\r
[Guids]\r
gUefiOvmfPkgTokenSpaceGuid = {0x93bb96af, 0xb9f2, 0x4eb8, {0x94, 0x62, 0xe0, 0xba, 0x74, 0x56, 0x42, 0x36}}\r
gEfiXenInfoGuid = {0xd3b46f3b, 0xd441, 0x1244, {0x9a, 0x12, 0x0, 0x12, 0x27, 0x3f, 0xc1, 0x4d}}\r
SmbusLib|MdePkg/Library/BaseSmbusLibNull/BaseSmbusLibNull.inf\r
OrderedCollectionLib|MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.inf\r
XenHypercallLib|OvmfPkg/Library/XenHypercallLib/XenHypercallLib.inf\r
+ XenPlatformLib|OvmfPkg/Library/XenPlatformLib/XenPlatformLib.inf\r
\r
Tcg2PhysicalPresenceLib|OvmfPkg/Library/Tcg2PhysicalPresenceLibNull/DxeTcg2PhysicalPresenceLib.inf\r
TpmMeasurementLib|MdeModulePkg/Library/TpmMeasurementLibNull/TpmMeasurementLibNull.inf\r