The purpose of XenPlatformLib is to regroup the few functions that are used in several places to detect if Xen is detected, and to get the XenInfo HOB. Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1689 Signed-off-by: Anthony PERARD <anthony.perard@citrix.com> Reviewed-by: Laszlo Ersek <lersek@redhat.com> Message-Id: <20190813113119.14804-14-anthony.perard@citrix.com>
70 lines
1.3 KiB
C
70 lines
1.3 KiB
C
/** @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.
|
|
|
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
|
|
|
**/
|
|
|
|
#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 has 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);
|
|
}
|