@@ -17,6 +17,18 @@
#define __XEN_HYPERCALL_LIB_H__
/**
+ Initialize the Xen hypercall library
+
+ @return EFI_SUCCESS on success, or an EFI_xxx return code appropriate
+ for the failure mode on failure.
+**/
+EFI_STATUS
+EFIAPI
+XenHypercallLibInit (
+ VOID
+ );
+
+/**
This function will put the two arguments in the right place (registers) and
invoke the hypercall identified by HypercallID.
@@ -40,6 +40,13 @@ SerialPortInitialize (
VOID
)
{
+ EFI_STATUS Status;
+
+ Status = XenHypercallLibInit ();
+ if (EFI_ERROR (Status)) {
+ return RETURN_DEVICE_ERROR;
+ }
+
if (!mXenConsoleInterface) {
mXenConsoleEventChain.port = (UINT32)XenHypercallHvmGetParam (HVM_PARAM_CONSOLE_EVTCHN);
mXenConsoleInterface = (struct xencons_interface *)(UINTN)
new file mode 100644
@@ -0,0 +1,30 @@
+/** @file
+ Xen Hypercall Library implementation for ARM architecture
+
+Copyright (c) 2015, Linaro Ltd. All rights reserved.<BR>
+This program and the accompanying materials are licensed and made available under
+the terms and conditions of the BSD License that 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 <Uefi/UefiBaseType.h>
+#include <Library/XenHypercallLib.h>
+
+/**
+ Library constructor: retrieves the Hyperpage address
+ from the gEfiXenInfoGuid HOB
+**/
+
+EFI_STATUS
+EFIAPI
+XenHypercallLibInit (
+ VOID
+ )
+{
+ return EFI_SUCCESS;
+}
@@ -35,9 +35,9 @@ __XenHypercall2 (
from the gEfiXenInfoGuid HOB
**/
-RETURN_STATUS
+EFI_STATUS
EFIAPI
-XenHypercallLibIntelInit (
+XenHypercallLibInit (
VOID
)
{
@@ -46,11 +46,11 @@ XenHypercallLibIntelInit (
GuidHob = GetFirstGuidHob (&gEfiXenInfoGuid);
if (GuidHob == NULL) {
- return RETURN_NOT_FOUND;
+ return EFI_NOT_FOUND;
}
XenInfo = (EFI_XEN_INFO *) GET_GUID_HOB_DATA (GuidHob);
HyperPage = XenInfo->HyperPages;
- return RETURN_SUCCESS;
+ return EFI_SUCCESS;
}
/**
@@ -34,6 +34,7 @@
[Sources]
XenHypercall.c
+ XenHypercallArm.c
[Packages]
MdePkg/MdePkg.dec
@@ -19,7 +19,6 @@
MODULE_TYPE = BASE
VERSION_STRING = 1.0
LIBRARY_CLASS = XenHypercallLib|DXE_DRIVER UEFI_DRIVER
- CONSTRUCTOR = XenHypercallLibIntelInit
#
# The following information is for reference only and not required by the build tools.
@@ -361,6 +361,13 @@ XenBusDxeDriverBindingStart (
mMyDevice = Dev;
EfiReleaseLock (&mMyDeviceLock);
+ Status = XenHypercallLibInit ();
+ if (EFI_ERROR (Status)) {
+ DEBUG ((EFI_D_ERROR, "XenBus: XenHypercallLibInit () failed.\n"));
+ Status = EFI_UNSUPPORTED;
+ goto ErrorAllocated;
+ }
+
Status = XenGetSharedInfoPage (Dev);
if (EFI_ERROR (Status)) {
DEBUG ((EFI_D_ERROR, "XenBus: Unable to get the shared info page.\n"));
This refactors the XenHypercallLib implementation for ARM and x86, and their callers, so that the init code for the XenHypercallLib is only called in places where we have already established that we are running as a Xen guest, or (in the XenConsoleSerialPortLib case) where ARM is the only user of the library, and its init code is a nop. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> --- OvmfPkg/Include/Library/XenHypercallLib.h | 12 +++++++++ .../XenConsoleSerialPortLib.c | 7 +++++ OvmfPkg/Library/XenHypercallLib/XenHypercallArm.c | 30 ++++++++++++++++++++++ .../Library/XenHypercallLib/XenHypercallIntel.c | 8 +++--- .../Library/XenHypercallLib/XenHypercallLibArm.inf | 1 + .../XenHypercallLib/XenHypercallLibIntel.inf | 1 - OvmfPkg/XenBusDxe/XenBusDxe.c | 7 +++++ 7 files changed, 61 insertions(+), 5 deletions(-) create mode 100644 OvmfPkg/Library/XenHypercallLib/XenHypercallArm.c