From 02f69a25f0aa9f6dda38e2b72789136574928f93 Mon Sep 17 00:00:00 2001 From: Laszlo Ersek Date: Tue, 3 Mar 2015 08:13:30 +0000 Subject: [PATCH] OvmfPkg: XenHypercallLib: introduce XenHypercallIsAvailable() Similarly to QemuFwCfgLib, we prefer mellow library construction code and an explicit "are you available" query function in the XenHypercallLib class. In this step we introduce that query function, but move no client code to it yet. Suggested-by: Jordan Justen Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek Reviewed-by: Jordan Justen Reviewed-by: Ard Biesheuvel Tested-by: Ard Biesheuvel git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17000 6f19259b-4bc3-4df7-8a09-765794883524 --- OvmfPkg/Include/Library/XenHypercallLib.h | 16 ++++++++++++++++ .../Library/XenHypercallLib/ArmXenHypercall.c | 19 +++++++++++++++++++ .../Library/XenHypercallLib/X86XenHypercall.c | 19 +++++++++++++++++++ 3 files changed, 54 insertions(+) diff --git a/OvmfPkg/Include/Library/XenHypercallLib.h b/OvmfPkg/Include/Library/XenHypercallLib.h index 1a468ea7dc..509855d302 100644 --- a/OvmfPkg/Include/Library/XenHypercallLib.h +++ b/OvmfPkg/Include/Library/XenHypercallLib.h @@ -16,6 +16,22 @@ #ifndef __XEN_HYPERCALL_LIB_H__ #define __XEN_HYPERCALL_LIB_H__ +/** + Check if the Xen Hypercall library is able to make calls to the Xen + hypervisor. + + Client code should call further functions in this library only if, and after, + this function returns TRUE. + + @retval TRUE Hypercalls are available. + @retval FALSE Hypercalls are not available. +**/ +BOOLEAN +EFIAPI +XenHypercallIsAvailable ( + VOID + ); + /** This function will put the two arguments in the right place (registers) and invoke the hypercall identified by HypercallID. diff --git a/OvmfPkg/Library/XenHypercallLib/ArmXenHypercall.c b/OvmfPkg/Library/XenHypercallLib/ArmXenHypercall.c index 1f213d6e6f..58cd3ec76b 100644 --- a/OvmfPkg/Library/XenHypercallLib/ArmXenHypercall.c +++ b/OvmfPkg/Library/XenHypercallLib/ArmXenHypercall.c @@ -15,6 +15,25 @@ #include +/** + Check if the Xen Hypercall library is able to make calls to the Xen + hypervisor. + + Client code should call further functions in this library only if, and after, + this function returns TRUE. + + @retval TRUE Hypercalls are available. + @retval FALSE Hypercalls are not available. +**/ +BOOLEAN +EFIAPI +XenHypercallIsAvailable ( + VOID + ) +{ + return TRUE; +} + RETURN_STATUS EFIAPI XenHypercallLibInit ( diff --git a/OvmfPkg/Library/XenHypercallLib/X86XenHypercall.c b/OvmfPkg/Library/XenHypercallLib/X86XenHypercall.c index 7ee1f2f38d..67892bcf37 100644 --- a/OvmfPkg/Library/XenHypercallLib/X86XenHypercall.c +++ b/OvmfPkg/Library/XenHypercallLib/X86XenHypercall.c @@ -19,6 +19,25 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. STATIC VOID *HyperPage; +/** + Check if the Xen Hypercall library is able to make calls to the Xen + hypervisor. + + Client code should call further functions in this library only if, and after, + this function returns TRUE. + + @retval TRUE Hypercalls are available. + @retval FALSE Hypercalls are not available. +**/ +BOOLEAN +EFIAPI +XenHypercallIsAvailable ( + VOID + ) +{ + return HyperPage != NULL; +} + // // Interface exposed by the ASM implementation of the core hypercall //