summaryrefslogtreecommitdiffstats
path: root/OvmfPkg/XenBusDxe
diff options
context:
space:
mode:
authorArd Biesheuvel <ard.biesheuvel@linaro.org>2015-02-28 20:32:39 +0000
committerlersek <lersek@Edk2>2015-02-28 20:32:39 +0000
commitcd8ff8fdda24c83be6ac247f8c21e5e4032fe586 (patch)
tree1931452cf00096df4bb7fd945e6fadbd4de68981 /OvmfPkg/XenBusDxe
parentbbc3758ab5bc0e526994a63d739d445416ff0c07 (diff)
downloadedk2-cd8ff8fdda24c83be6ac247f8c21e5e4032fe586.tar.gz
edk2-cd8ff8fdda24c83be6ac247f8c21e5e4032fe586.tar.bz2
edk2-cd8ff8fdda24c83be6ac247f8c21e5e4032fe586.zip
Ovmf/Xen: move XenBusDxe hypercall code to separate library
This moves all of the Xen hypercall code that was private to XenBusDxe to a new library class XenHypercallLib. This will allow us to reimplement it for ARM, and to export the Xen hypercall functionality to other parts of the code, such as a Xen console SerialPortLib driver. Contributed-under: TianoCore Contribution Agreement 1.0 Reviewed-by: Laszlo Ersek <lersek@redhat.com> Reviewed-by: Anthony PERARD <anthony.perard@citrix.com> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org> Signed-off-by: Laszlo Ersek <lersek@redhat.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16970 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'OvmfPkg/XenBusDxe')
-rw-r--r--OvmfPkg/XenBusDxe/EventChannel.c3
-rw-r--r--OvmfPkg/XenBusDxe/GrantTable.c2
-rw-r--r--OvmfPkg/XenBusDxe/Ia32/hypercall.nasm25
-rw-r--r--OvmfPkg/XenBusDxe/X64/hypercall.nasm26
-rw-r--r--OvmfPkg/XenBusDxe/XenBusDxe.c9
-rw-r--r--OvmfPkg/XenBusDxe/XenBusDxe.inf11
-rw-r--r--OvmfPkg/XenBusDxe/XenHypercall.c107
-rw-r--r--OvmfPkg/XenBusDxe/XenHypercall.h91
-rw-r--r--OvmfPkg/XenBusDxe/XenStore.c2
9 files changed, 6 insertions, 270 deletions
diff --git a/OvmfPkg/XenBusDxe/EventChannel.c b/OvmfPkg/XenBusDxe/EventChannel.c
index a86323e6ad..6a36dca299 100644
--- a/OvmfPkg/XenBusDxe/EventChannel.c
+++ b/OvmfPkg/XenBusDxe/EventChannel.c
@@ -16,7 +16,8 @@
**/
#include "EventChannel.h"
-#include "XenHypercall.h"
+
+#include <Library/XenHypercallLib.h>
UINT32
XenEventChannelNotify (
diff --git a/OvmfPkg/XenBusDxe/GrantTable.c b/OvmfPkg/XenBusDxe/GrantTable.c
index 53cb99f0e0..a80d5eff39 100644
--- a/OvmfPkg/XenBusDxe/GrantTable.c
+++ b/OvmfPkg/XenBusDxe/GrantTable.c
@@ -34,7 +34,7 @@
#include <IndustryStandard/Xen/memory.h>
-#include "XenHypercall.h"
+#include <Library/XenHypercallLib.h>
#include "GrantTable.h"
#include "InterlockedCompareExchange16.h"
diff --git a/OvmfPkg/XenBusDxe/Ia32/hypercall.nasm b/OvmfPkg/XenBusDxe/Ia32/hypercall.nasm
deleted file mode 100644
index e0fa71bb5b..0000000000
--- a/OvmfPkg/XenBusDxe/Ia32/hypercall.nasm
+++ /dev/null
@@ -1,25 +0,0 @@
-SECTION .text
-
-; INTN
-; EFIAPI
-; __XenHypercall2 (
-; IN VOID *HypercallAddr,
-; IN OUT INTN Arg1,
-; IN OUT INTN Arg2
-; );
-global ASM_PFX(__XenHypercall2)
-ASM_PFX(__XenHypercall2):
- ; Save only ebx, ecx is supposed to be a scratch register and needs to be
- ; saved by the caller
- push ebx
- ; Copy HypercallAddr to eax
- mov eax, [esp + 8]
- ; Copy Arg1 to the register expected by Xen
- mov ebx, [esp + 12]
- ; Copy Arg2 to the register expected by Xen
- mov ecx, [esp + 16]
- ; Call HypercallAddr
- call eax
- pop ebx
- ret
-
diff --git a/OvmfPkg/XenBusDxe/X64/hypercall.nasm b/OvmfPkg/XenBusDxe/X64/hypercall.nasm
deleted file mode 100644
index 5e6a0c05c5..0000000000
--- a/OvmfPkg/XenBusDxe/X64/hypercall.nasm
+++ /dev/null
@@ -1,26 +0,0 @@
-DEFAULT REL
-SECTION .text
-
-; INTN
-; EFIAPI
-; __XenHypercall2 (
-; IN VOID *HypercallAddr,
-; IN OUT INTN Arg1,
-; IN OUT INTN Arg2
-; );
-global ASM_PFX(__XenHypercall2)
-ASM_PFX(__XenHypercall2):
- push rdi
- push rsi
- ; Copy HypercallAddr to rax
- mov rax, rcx
- ; Copy Arg1 to the register expected by Xen
- mov rdi, rdx
- ; Copy Arg2 to the register expected by Xen
- mov rsi, r8
- ; Call HypercallAddr
- call rax
- pop rsi
- pop rdi
- ret
-
diff --git a/OvmfPkg/XenBusDxe/XenBusDxe.c b/OvmfPkg/XenBusDxe/XenBusDxe.c
index d333b331b6..cc334c086c 100644
--- a/OvmfPkg/XenBusDxe/XenBusDxe.c
+++ b/OvmfPkg/XenBusDxe/XenBusDxe.c
@@ -26,10 +26,10 @@
#include <IndustryStandard/Pci.h>
#include <IndustryStandard/Acpi.h>
#include <Library/DebugLib.h>
+#include <Library/XenHypercallLib.h>
#include "XenBusDxe.h"
-#include "XenHypercall.h"
#include "GrantTable.h"
#include "XenStore.h"
#include "XenBus.h"
@@ -390,13 +390,6 @@ XenBusDxeDriverBindingStart (
MmioAddr = BarDesc->AddrRangeMin;
FreePool (BarDesc);
- Status = XenHyperpageInit ();
- if (EFI_ERROR (Status)) {
- DEBUG ((EFI_D_ERROR, "XenBus: Unable to retrieve the hyperpage.\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"));
diff --git a/OvmfPkg/XenBusDxe/XenBusDxe.inf b/OvmfPkg/XenBusDxe/XenBusDxe.inf
index 4ce4743454..714607dbd6 100644
--- a/OvmfPkg/XenBusDxe/XenBusDxe.inf
+++ b/OvmfPkg/XenBusDxe/XenBusDxe.inf
@@ -34,8 +34,6 @@
DriverBinding.h
ComponentName.c
ComponentName.h
- XenHypercall.c
- XenHypercall.h
InterlockedCompareExchange16.c
InterlockedCompareExchange16.h
GrantTable.c
@@ -49,12 +47,10 @@
Helpers.c
[Sources.IA32]
- Ia32/hypercall.nasm
Ia32/InterlockedCompareExchange16.nasm
Ia32/TestAndClearBit.nasm
[Sources.X64]
- X64/hypercall.nasm
X64/InterlockedCompareExchange16.nasm
X64/TestAndClearBit.nasm
@@ -67,8 +63,7 @@
UefiLib
DevicePathLib
DebugLib
- HobLib
-
+ XenHypercallLib
[Protocols]
gEfiDriverBindingProtocolGuid
@@ -77,7 +72,3 @@
gEfiComponentNameProtocolGuid
gXenBusProtocolGuid
-
-[Guids]
- gEfiXenInfoGuid
-
diff --git a/OvmfPkg/XenBusDxe/XenHypercall.c b/OvmfPkg/XenBusDxe/XenHypercall.c
deleted file mode 100644
index e7134fcf74..0000000000
--- a/OvmfPkg/XenBusDxe/XenHypercall.c
+++ /dev/null
@@ -1,107 +0,0 @@
-/** @file
- Functions to make Xen hypercalls.
-
- Copyright (C) 2014, Citrix Ltd.
-
- 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 <Guid/XenInfo.h>
-
-#include "XenBusDxe.h"
-#include "XenHypercall.h"
-
-#include <IndustryStandard/Xen/hvm/params.h>
-#include <IndustryStandard/Xen/memory.h>
-
-STATIC VOID *HyperPage;
-
-//
-// Interface exposed by the ASM implementation of the core hypercall
-//
-INTN
-EFIAPI
-__XenHypercall2 (
- IN VOID *HypercallAddr,
- IN OUT INTN Arg1,
- IN OUT INTN Arg2
- );
-
-EFI_STATUS
-XenHyperpageInit (
- )
-{
- EFI_HOB_GUID_TYPE *GuidHob;
- EFI_XEN_INFO *XenInfo;
-
- GuidHob = GetFirstGuidHob (&gEfiXenInfoGuid);
- if (GuidHob == NULL) {
- return EFI_NOT_FOUND;
- }
- XenInfo = (EFI_XEN_INFO *) GET_GUID_HOB_DATA (GuidHob);
- HyperPage = XenInfo->HyperPages;
- return EFI_SUCCESS;
-}
-
-UINT64
-XenHypercallHvmGetParam (
- IN UINT32 Index
- )
-{
- xen_hvm_param_t Parameter;
- INTN Error;
-
- Parameter.domid = DOMID_SELF;
- Parameter.index = Index;
- Error = XenHypercall2 (__HYPERVISOR_hvm_op,
- HVMOP_get_param, (INTN) &Parameter);
- if (Error != 0) {
- DEBUG ((EFI_D_ERROR,
- "XenHypercall: Error %d trying to get HVM parameter %d\n",
- Error, Index));
- return 0;
- }
- return Parameter.value;
-}
-
-INTN
-XenHypercallMemoryOp (
- IN UINTN Operation,
- IN OUT VOID *Arguments
- )
-{
- return XenHypercall2 (__HYPERVISOR_memory_op,
- Operation, (INTN) Arguments);
-}
-
-INTN
-XenHypercallEventChannelOp (
- IN INTN Operation,
- IN OUT VOID *Arguments
- )
-{
- return XenHypercall2 (__HYPERVISOR_event_channel_op,
- Operation, (INTN) Arguments);
-}
-
-INTN
-EFIAPI
-XenHypercall2 (
- IN UINTN HypercallID,
- IN OUT INTN Arg1,
- IN OUT INTN Arg2
- )
-{
- ASSERT (HyperPage != NULL);
-
- return __XenHypercall2 ((UINT8*)HyperPage + HypercallID * 32, Arg1, Arg2);
-}
diff --git a/OvmfPkg/XenBusDxe/XenHypercall.h b/OvmfPkg/XenBusDxe/XenHypercall.h
deleted file mode 100644
index 9d49e33eb5..0000000000
--- a/OvmfPkg/XenBusDxe/XenHypercall.h
+++ /dev/null
@@ -1,91 +0,0 @@
-/** @file
- Functions declarations to make Xen hypercalls.
-
- Copyright (C) 2014, Citrix Ltd.
-
- 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 __XENBUS_DXE_HYPERCALL_H__
-#define __XENBUS_DXE_HYPERCALL_H__
-
-/**
- This function will put the two arguments in the right place (registers) and
- invoke the hypercall identified by HypercallID.
-
- @param HypercallID The symbolic ID of the hypercall to be invoked
- @param Arg1 First argument.
- @param Arg2 Second argument.
-
- @return Return 0 if success otherwise it return an errno.
-**/
-INTN
-EFIAPI
-XenHypercall2 (
- IN INTN HypercallID,
- IN OUT INTN Arg1,
- IN OUT INTN Arg2
- );
-
-/**
- Get the page where all hypercall are from the XenInfo hob.
-
- @param Dev A XENBUS_DEVICE instance.
-
- @retval EFI_NOT_FOUND hyperpage could not be found.
- @retval EFI_SUCCESS Successfully retrieve the hyperpage pointer.
-**/
-EFI_STATUS
-XenHyperpageInit (
- );
-
-/**
- Return the value of the HVM parameter Index.
-
- @param Index The parameter to get, e.g. HVM_PARAM_STORE_EVTCHN.
-
- @return The value of the asked parameter or 0 in case of error.
-**/
-UINT64
-XenHypercallHvmGetParam (
- UINT32 Index
- );
-
-/**
- Hypercall to do different operation on the memory.
-
- @param Operation The operation number, e.g. XENMEM_add_to_physmap.
- @param Arguments The arguments associated to the operation.
-
- @return Return the return value from the hypercall, 0 in case of success
- otherwise, an error code.
-**/
-INTN
-XenHypercallMemoryOp (
- IN UINTN Operation,
- IN OUT VOID *Arguments
- );
-
-/**
- Do an operation on the event channels.
-
- @param Operation The operation number, e.g. EVTCHNOP_send.
- @param Arguments The argument associated to the operation.
-
- @return Return the return value from the hypercall, 0 in case of success
- otherwise, an error code.
-**/
-INTN
-XenHypercallEventChannelOp (
- IN INTN Operation,
- IN OUT VOID *Arguments
- );
-
-#endif
diff --git a/OvmfPkg/XenBusDxe/XenStore.c b/OvmfPkg/XenBusDxe/XenStore.c
index 7ec1e634bc..9850f1e644 100644
--- a/OvmfPkg/XenBusDxe/XenStore.c
+++ b/OvmfPkg/XenBusDxe/XenStore.c
@@ -60,8 +60,8 @@
#include <IndustryStandard/Xen/hvm/params.h>
-#include "XenHypercall.h"
#include "EventChannel.h"
+#include <Library/XenHypercallLib.h>
//
// Private Data Structures