]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Ovmf/Xen: move XenBusDxe hypercall code to separate library
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Sat, 28 Feb 2015 20:32:39 +0000 (20:32 +0000)
committerlersek <lersek@Edk2>
Sat, 28 Feb 2015 20:32:39 +0000 (20:32 +0000)
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

19 files changed:
OvmfPkg/Include/Library/XenHypercallLib.h [new file with mode: 0644]
OvmfPkg/Library/XenHypercallLib/Ia32/hypercall.nasm [new file with mode: 0644]
OvmfPkg/Library/XenHypercallLib/X64/hypercall.nasm [new file with mode: 0644]
OvmfPkg/Library/XenHypercallLib/XenHypercall.c [new file with mode: 0644]
OvmfPkg/Library/XenHypercallLib/XenHypercallIntel.c [new file with mode: 0644]
OvmfPkg/Library/XenHypercallLib/XenHypercallLibIntel.inf [new file with mode: 0644]
OvmfPkg/OvmfPkg.dec
OvmfPkg/OvmfPkgIa32.dsc
OvmfPkg/OvmfPkgIa32X64.dsc
OvmfPkg/OvmfPkgX64.dsc
OvmfPkg/XenBusDxe/EventChannel.c
OvmfPkg/XenBusDxe/GrantTable.c
OvmfPkg/XenBusDxe/Ia32/hypercall.nasm [deleted file]
OvmfPkg/XenBusDxe/X64/hypercall.nasm [deleted file]
OvmfPkg/XenBusDxe/XenBusDxe.c
OvmfPkg/XenBusDxe/XenBusDxe.inf
OvmfPkg/XenBusDxe/XenHypercall.c [deleted file]
OvmfPkg/XenBusDxe/XenHypercall.h [deleted file]
OvmfPkg/XenBusDxe/XenStore.c

diff --git a/OvmfPkg/Include/Library/XenHypercallLib.h b/OvmfPkg/Include/Library/XenHypercallLib.h
new file mode 100644 (file)
index 0000000..1a468ea
--- /dev/null
@@ -0,0 +1,79 @@
+/** @file\r
+  Functions declarations to make Xen hypercalls.\r
+\r
+  Copyright (C) 2014, Citrix Ltd.\r
+\r
+  This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#ifndef __XEN_HYPERCALL_LIB_H__\r
+#define __XEN_HYPERCALL_LIB_H__\r
+\r
+/**\r
+  This function will put the two arguments in the right place (registers) and\r
+  invoke the hypercall identified by HypercallID.\r
+\r
+  @param HypercallID    The symbolic ID of the hypercall to be invoked\r
+  @param Arg1           First argument.\r
+  @param Arg2           Second argument.\r
+\r
+  @return   Return 0 if success otherwise it return an errno.\r
+**/\r
+INTN\r
+EFIAPI\r
+XenHypercall2 (\r
+  IN     UINTN  HypercallID,\r
+  IN OUT INTN   Arg1,\r
+  IN OUT INTN   Arg2\r
+  );\r
+\r
+/**\r
+  Return the value of the HVM parameter Index.\r
+\r
+  @param Index  The parameter to get, e.g. HVM_PARAM_STORE_EVTCHN.\r
+\r
+  @return   The value of the asked parameter or 0 in case of error.\r
+**/\r
+UINT64\r
+XenHypercallHvmGetParam (\r
+  UINT32 Index\r
+  );\r
+\r
+/**\r
+  Hypercall to do different operation on the memory.\r
+\r
+  @param Operation  The operation number, e.g. XENMEM_add_to_physmap.\r
+  @param Arguments  The arguments associated to the operation.\r
+\r
+  @return  Return the return value from the hypercall, 0 in case of success\r
+           otherwise, an error code.\r
+**/\r
+INTN\r
+XenHypercallMemoryOp (\r
+  IN     UINTN Operation,\r
+  IN OUT VOID *Arguments\r
+  );\r
+\r
+/**\r
+  Do an operation on the event channels.\r
+\r
+  @param Operation  The operation number, e.g. EVTCHNOP_send.\r
+  @param Arguments  The argument associated to the operation.\r
+\r
+  @return  Return the return value from the hypercall, 0 in case of success\r
+           otherwise, an error code.\r
+**/\r
+INTN\r
+XenHypercallEventChannelOp (\r
+  IN     INTN Operation,\r
+  IN OUT VOID *Arguments\r
+  );\r
+\r
+#endif\r
diff --git a/OvmfPkg/Library/XenHypercallLib/Ia32/hypercall.nasm b/OvmfPkg/Library/XenHypercallLib/Ia32/hypercall.nasm
new file mode 100644 (file)
index 0000000..e0fa71b
--- /dev/null
@@ -0,0 +1,25 @@
+SECTION .text\r
+\r
+; INTN\r
+; EFIAPI\r
+; __XenHypercall2 (\r
+;   IN     VOID *HypercallAddr,\r
+;   IN OUT INTN Arg1,\r
+;   IN OUT INTN Arg2\r
+;   );\r
+global ASM_PFX(__XenHypercall2)\r
+ASM_PFX(__XenHypercall2):\r
+  ; Save only ebx, ecx is supposed to be a scratch register and needs to be\r
+  ; saved by the caller\r
+  push ebx\r
+  ; Copy HypercallAddr to eax\r
+  mov eax, [esp + 8]\r
+  ; Copy Arg1 to the register expected by Xen\r
+  mov ebx, [esp + 12]\r
+  ; Copy Arg2 to the register expected by Xen\r
+  mov ecx, [esp + 16]\r
+  ; Call HypercallAddr\r
+  call eax\r
+  pop ebx\r
+  ret\r
+\r
diff --git a/OvmfPkg/Library/XenHypercallLib/X64/hypercall.nasm b/OvmfPkg/Library/XenHypercallLib/X64/hypercall.nasm
new file mode 100644 (file)
index 0000000..5e6a0c0
--- /dev/null
@@ -0,0 +1,26 @@
+DEFAULT REL\r
+SECTION .text\r
+\r
+; INTN\r
+; EFIAPI\r
+; __XenHypercall2 (\r
+;   IN     VOID *HypercallAddr,\r
+;   IN OUT INTN Arg1,\r
+;   IN OUT INTN Arg2\r
+;   );\r
+global ASM_PFX(__XenHypercall2)\r
+ASM_PFX(__XenHypercall2):\r
+  push rdi\r
+  push rsi\r
+  ; Copy HypercallAddr to rax\r
+  mov rax, rcx\r
+  ; Copy Arg1 to the register expected by Xen\r
+  mov rdi, rdx\r
+  ; Copy Arg2 to the register expected by Xen\r
+  mov rsi, r8\r
+  ; Call HypercallAddr\r
+  call rax\r
+  pop rsi\r
+  pop rdi\r
+  ret\r
+\r
diff --git a/OvmfPkg/Library/XenHypercallLib/XenHypercall.c b/OvmfPkg/Library/XenHypercallLib/XenHypercall.c
new file mode 100644 (file)
index 0000000..ecc757c
--- /dev/null
@@ -0,0 +1,63 @@
+/** @file\r
+  Functions to make Xen hypercalls.\r
+\r
+  Copyright (C) 2014, Citrix Ltd.\r
+\r
+  This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include <PiDxe.h>\r
+\r
+#include <IndustryStandard/Xen/hvm/params.h>\r
+#include <IndustryStandard/Xen/memory.h>\r
+\r
+#include <Library/DebugLib.h>\r
+#include <Library/XenHypercallLib.h>\r
+\r
+UINT64\r
+XenHypercallHvmGetParam (\r
+  IN UINT32        Index\r
+  )\r
+{\r
+  xen_hvm_param_t     Parameter;\r
+  INTN                Error;\r
+\r
+  Parameter.domid = DOMID_SELF;\r
+  Parameter.index = Index;\r
+  Error = XenHypercall2 (__HYPERVISOR_hvm_op,\r
+                         HVMOP_get_param, (INTN) &Parameter);\r
+  if (Error != 0) {\r
+    DEBUG ((EFI_D_ERROR,\r
+            "XenHypercall: Error %d trying to get HVM parameter %d\n",\r
+            Error, Index));\r
+    return 0;\r
+  }\r
+  return Parameter.value;\r
+}\r
+\r
+INTN\r
+XenHypercallMemoryOp (\r
+  IN     UINTN Operation,\r
+  IN OUT VOID *Arguments\r
+  )\r
+{\r
+  return XenHypercall2 (__HYPERVISOR_memory_op,\r
+                        Operation, (INTN) Arguments);\r
+}\r
+\r
+INTN\r
+XenHypercallEventChannelOp (\r
+  IN     INTN Operation,\r
+  IN OUT VOID *Arguments\r
+  )\r
+{\r
+  return XenHypercall2 (__HYPERVISOR_event_channel_op,\r
+                        Operation, (INTN) Arguments);\r
+}\r
diff --git a/OvmfPkg/Library/XenHypercallLib/XenHypercallIntel.c b/OvmfPkg/Library/XenHypercallLib/XenHypercallIntel.c
new file mode 100644 (file)
index 0000000..fc52823
--- /dev/null
@@ -0,0 +1,77 @@
+/** @file\r
+  Xen Hypercall Library implementation for Intel architecture\r
+\r
+Copyright (c) 2014, Linaro Ltd. All rights reserved.<BR>\r
+This program and the accompanying materials are licensed and made available under\r
+the terms and conditions of the BSD License that accompanies this distribution.\r
+The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php.\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include <PiDxe.h>\r
+#include <Library/HobLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Guid/XenInfo.h>\r
+\r
+STATIC VOID    *HyperPage;\r
+\r
+//\r
+// Interface exposed by the ASM implementation of the core hypercall\r
+//\r
+INTN\r
+EFIAPI\r
+__XenHypercall2 (\r
+  IN     VOID *HypercallAddr,\r
+  IN OUT INTN Arg1,\r
+  IN OUT INTN Arg2\r
+  );\r
+\r
+/**\r
+  Library constructor: retrieves the Hyperpage address\r
+  from the gEfiXenInfoGuid HOB\r
+**/\r
+\r
+RETURN_STATUS\r
+EFIAPI\r
+XenHypercallLibIntelInit (\r
+  VOID\r
+  )\r
+{\r
+  EFI_HOB_GUID_TYPE   *GuidHob;\r
+  EFI_XEN_INFO        *XenInfo;\r
+\r
+  GuidHob = GetFirstGuidHob (&gEfiXenInfoGuid);\r
+  if (GuidHob == NULL) {\r
+    return RETURN_NOT_FOUND;\r
+  }\r
+  XenInfo = (EFI_XEN_INFO *) GET_GUID_HOB_DATA (GuidHob);\r
+  HyperPage = XenInfo->HyperPages;\r
+  return RETURN_SUCCESS;\r
+}\r
+\r
+/**\r
+  This function will put the two arguments in the right place (registers) and\r
+  invoke the hypercall identified by HypercallID.\r
+\r
+  @param HypercallID    The symbolic ID of the hypercall to be invoked\r
+  @param Arg1           First argument.\r
+  @param Arg2           Second argument.\r
+\r
+  @return   Return 0 if success otherwise it return an errno.\r
+**/\r
+INTN\r
+EFIAPI\r
+XenHypercall2 (\r
+  IN     UINTN  HypercallID,\r
+  IN OUT INTN   Arg1,\r
+  IN OUT INTN   Arg2\r
+  )\r
+{\r
+  ASSERT (HyperPage != NULL);\r
+\r
+  return __XenHypercall2 ((UINT8*)HyperPage + HypercallID * 32, Arg1, Arg2);\r
+}\r
diff --git a/OvmfPkg/Library/XenHypercallLib/XenHypercallLibIntel.inf b/OvmfPkg/Library/XenHypercallLib/XenHypercallLibIntel.inf
new file mode 100644 (file)
index 0000000..2afd608
--- /dev/null
@@ -0,0 +1,52 @@
+## @file\r
+#  Xen Hypercall abstraction lib for Intel architecture\r
+#\r
+#  Copyright (c) 2014, Linaro Ltd. All rights reserved.<BR>\r
+#  This program and the accompanying materials\r
+#  are licensed and made available under the terms and conditions of the BSD License\r
+#  which accompanies this distribution.  The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php\r
+#\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = XenHypercallLibIntel\r
+  FILE_GUID                      = B5EE9A32-CA5A-49A8-82E3-ADA4CCB77C7C\r
+  MODULE_TYPE                    = BASE\r
+  VERSION_STRING                 = 1.0\r
+  LIBRARY_CLASS                  = XenHypercallLib|DXE_DRIVER UEFI_DRIVER\r
+  CONSTRUCTOR                    = XenHypercallLibIntelInit\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64\r
+#\r
+\r
+[Sources]\r
+  XenHypercallIntel.c\r
+\r
+[Sources.IA32]\r
+  Ia32/hypercall.nasm\r
+\r
+[Sources.X64]\r
+  X64/hypercall.nasm\r
+\r
+[Sources]\r
+  XenHypercall.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  OvmfPkg/OvmfPkg.dec\r
+\r
+[LibraryClasses]\r
+  BaseLib\r
+  HobLib\r
+  DebugLib\r
+\r
+[Guids]\r
+  gEfiXenInfoGuid\r
index 6eb551a8d43660ae7c6ca810b8946ec6d2c278d9..30a9fb1e9b420cc423b268841e8ed5b3d2d2e776 100644 (file)
   #\r
   SerializeVariablesLib|Include/Library/SerializeVariablesLib.h\r
 \r
+  ##  @libraryclass  Invoke Xen hypercalls\r
+  #\r
+  XenHypercallLib|Include/Library/XenHypercallLib.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
index ca656698754b9db8cf9f6e280ee74c04a0388b7c..90540272745c2070b79496c28a97988c36a429c7 100644 (file)
   S3BootScriptLib|MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf\r
   SmbusLib|MdePkg/Library/BaseSmbusLibNull/BaseSmbusLibNull.inf\r
   OrderedCollectionLib|MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.inf\r
+  XenHypercallLib|OvmfPkg/Library/XenHypercallLib/XenHypercallLibIntel.inf\r
 \r
 [LibraryClasses.common]\r
 !if $(SECURE_BOOT_ENABLE) == TRUE\r
index 4b4a1da717c1112039f282ff9cde3f60384f8b13..0a331eda8be03f44f2b12be2b5677cd465cf9b02 100644 (file)
   S3BootScriptLib|MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf\r
   SmbusLib|MdePkg/Library/BaseSmbusLibNull/BaseSmbusLibNull.inf\r
   OrderedCollectionLib|MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.inf\r
+  XenHypercallLib|OvmfPkg/Library/XenHypercallLib/XenHypercallLibIntel.inf\r
 \r
 [LibraryClasses.common]\r
 !if $(SECURE_BOOT_ENABLE) == TRUE\r
index eb3f34b8350b9c474cb56161acc778c3787843db..e2b37c2716819d6a339196afccef1d0e69f97b84 100644 (file)
   S3BootScriptLib|MdeModulePkg/Library/PiDxeS3BootScriptLib/DxeS3BootScriptLib.inf\r
   SmbusLib|MdePkg/Library/BaseSmbusLibNull/BaseSmbusLibNull.inf\r
   OrderedCollectionLib|MdePkg/Library/BaseOrderedCollectionRedBlackTreeLib/BaseOrderedCollectionRedBlackTreeLib.inf\r
+  XenHypercallLib|OvmfPkg/Library/XenHypercallLib/XenHypercallLibIntel.inf\r
 \r
 [LibraryClasses.common]\r
 !if $(SECURE_BOOT_ENABLE) == TRUE\r
index a86323e6adfd5667aa5db1c7233d5f17f444e83f..6a36dca29911103071b92ab287137d501fd6f7d6 100644 (file)
@@ -16,7 +16,8 @@
 \r
 **/\r
 #include "EventChannel.h"\r
-#include "XenHypercall.h"\r
+\r
+#include <Library/XenHypercallLib.h>\r
 \r
 UINT32\r
 XenEventChannelNotify (\r
index 53cb99f0e004db879c0727055de1fef754c2760f..a80d5eff39cdfd65d2eac6f517e7f1431a90091a 100644 (file)
@@ -34,7 +34,7 @@
 \r
 #include <IndustryStandard/Xen/memory.h>\r
 \r
-#include "XenHypercall.h"\r
+#include <Library/XenHypercallLib.h>\r
 \r
 #include "GrantTable.h"\r
 #include "InterlockedCompareExchange16.h"\r
diff --git a/OvmfPkg/XenBusDxe/Ia32/hypercall.nasm b/OvmfPkg/XenBusDxe/Ia32/hypercall.nasm
deleted file mode 100644 (file)
index e0fa71b..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-SECTION .text\r
-\r
-; INTN\r
-; EFIAPI\r
-; __XenHypercall2 (\r
-;   IN     VOID *HypercallAddr,\r
-;   IN OUT INTN Arg1,\r
-;   IN OUT INTN Arg2\r
-;   );\r
-global ASM_PFX(__XenHypercall2)\r
-ASM_PFX(__XenHypercall2):\r
-  ; Save only ebx, ecx is supposed to be a scratch register and needs to be\r
-  ; saved by the caller\r
-  push ebx\r
-  ; Copy HypercallAddr to eax\r
-  mov eax, [esp + 8]\r
-  ; Copy Arg1 to the register expected by Xen\r
-  mov ebx, [esp + 12]\r
-  ; Copy Arg2 to the register expected by Xen\r
-  mov ecx, [esp + 16]\r
-  ; Call HypercallAddr\r
-  call eax\r
-  pop ebx\r
-  ret\r
-\r
diff --git a/OvmfPkg/XenBusDxe/X64/hypercall.nasm b/OvmfPkg/XenBusDxe/X64/hypercall.nasm
deleted file mode 100644 (file)
index 5e6a0c0..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-DEFAULT REL\r
-SECTION .text\r
-\r
-; INTN\r
-; EFIAPI\r
-; __XenHypercall2 (\r
-;   IN     VOID *HypercallAddr,\r
-;   IN OUT INTN Arg1,\r
-;   IN OUT INTN Arg2\r
-;   );\r
-global ASM_PFX(__XenHypercall2)\r
-ASM_PFX(__XenHypercall2):\r
-  push rdi\r
-  push rsi\r
-  ; Copy HypercallAddr to rax\r
-  mov rax, rcx\r
-  ; Copy Arg1 to the register expected by Xen\r
-  mov rdi, rdx\r
-  ; Copy Arg2 to the register expected by Xen\r
-  mov rsi, r8\r
-  ; Call HypercallAddr\r
-  call rax\r
-  pop rsi\r
-  pop rdi\r
-  ret\r
-\r
index d333b331b6db72b94e9d9663b706139d0bc1a8d0..cc334c086c1f16983ddabe3e28b31c29ed2abfb9 100644 (file)
 #include <IndustryStandard/Pci.h>\r
 #include <IndustryStandard/Acpi.h>\r
 #include <Library/DebugLib.h>\r
+#include <Library/XenHypercallLib.h>\r
 \r
 #include "XenBusDxe.h"\r
 \r
-#include "XenHypercall.h"\r
 #include "GrantTable.h"\r
 #include "XenStore.h"\r
 #include "XenBus.h"\r
@@ -390,13 +390,6 @@ XenBusDxeDriverBindingStart (
   MmioAddr = BarDesc->AddrRangeMin;\r
   FreePool (BarDesc);\r
 \r
-  Status = XenHyperpageInit ();\r
-  if (EFI_ERROR (Status)) {\r
-    DEBUG ((EFI_D_ERROR, "XenBus: Unable to retrieve the hyperpage.\n"));\r
-    Status = EFI_UNSUPPORTED;\r
-    goto ErrorAllocated;\r
-  }\r
-\r
   Status = XenGetSharedInfoPage (Dev);\r
   if (EFI_ERROR (Status)) {\r
     DEBUG ((EFI_D_ERROR, "XenBus: Unable to get the shared info page.\n"));\r
index 4ce47434545204e3af9a92d834438509808f0d04..714607dbd6f8144f975509d1a4f6f9033f419177 100644 (file)
@@ -34,8 +34,6 @@
   DriverBinding.h\r
   ComponentName.c\r
   ComponentName.h\r
-  XenHypercall.c\r
-  XenHypercall.h\r
   InterlockedCompareExchange16.c\r
   InterlockedCompareExchange16.h\r
   GrantTable.c\r
   Helpers.c\r
 \r
 [Sources.IA32]\r
-  Ia32/hypercall.nasm\r
   Ia32/InterlockedCompareExchange16.nasm\r
   Ia32/TestAndClearBit.nasm\r
 \r
 [Sources.X64]\r
-  X64/hypercall.nasm\r
   X64/InterlockedCompareExchange16.nasm\r
   X64/TestAndClearBit.nasm\r
 \r
@@ -67,8 +63,7 @@
   UefiLib\r
   DevicePathLib\r
   DebugLib\r
-  HobLib\r
-\r
+  XenHypercallLib\r
 \r
 [Protocols]\r
   gEfiDriverBindingProtocolGuid\r
@@ -77,7 +72,3 @@
   gEfiComponentNameProtocolGuid\r
   gXenBusProtocolGuid\r
 \r
-\r
-[Guids]\r
-  gEfiXenInfoGuid\r
-\r
diff --git a/OvmfPkg/XenBusDxe/XenHypercall.c b/OvmfPkg/XenBusDxe/XenHypercall.c
deleted file mode 100644 (file)
index e7134fc..0000000
+++ /dev/null
@@ -1,107 +0,0 @@
-/** @file\r
-  Functions to make Xen hypercalls.\r
-\r
-  Copyright (C) 2014, Citrix Ltd.\r
-\r
-  This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#include <PiDxe.h>\r
-#include <Library/HobLib.h>\r
-#include <Guid/XenInfo.h>\r
-\r
-#include "XenBusDxe.h"\r
-#include "XenHypercall.h"\r
-\r
-#include <IndustryStandard/Xen/hvm/params.h>\r
-#include <IndustryStandard/Xen/memory.h>\r
-\r
-STATIC VOID       *HyperPage;\r
-\r
-//\r
-// Interface exposed by the ASM implementation of the core hypercall\r
-//\r
-INTN\r
-EFIAPI\r
-__XenHypercall2 (\r
-  IN     VOID *HypercallAddr,\r
-  IN OUT INTN Arg1,\r
-  IN OUT INTN Arg2\r
-  );\r
-\r
-EFI_STATUS\r
-XenHyperpageInit (\r
-  )\r
-{\r
-  EFI_HOB_GUID_TYPE   *GuidHob;\r
-  EFI_XEN_INFO        *XenInfo;\r
-\r
-  GuidHob = GetFirstGuidHob (&gEfiXenInfoGuid);\r
-  if (GuidHob == NULL) {\r
-    return EFI_NOT_FOUND;\r
-  }\r
-  XenInfo = (EFI_XEN_INFO *) GET_GUID_HOB_DATA (GuidHob);\r
-  HyperPage = XenInfo->HyperPages;\r
-  return EFI_SUCCESS;\r
-}\r
-\r
-UINT64\r
-XenHypercallHvmGetParam (\r
-  IN UINT32        Index\r
-  )\r
-{\r
-  xen_hvm_param_t     Parameter;\r
-  INTN                Error;\r
-\r
-  Parameter.domid = DOMID_SELF;\r
-  Parameter.index = Index;\r
-  Error = XenHypercall2 (__HYPERVISOR_hvm_op,\r
-                         HVMOP_get_param, (INTN) &Parameter);\r
-  if (Error != 0) {\r
-    DEBUG ((EFI_D_ERROR,\r
-            "XenHypercall: Error %d trying to get HVM parameter %d\n",\r
-            Error, Index));\r
-    return 0;\r
-  }\r
-  return Parameter.value;\r
-}\r
-\r
-INTN\r
-XenHypercallMemoryOp (\r
-  IN     UINTN Operation,\r
-  IN OUT VOID *Arguments\r
-  )\r
-{\r
-  return XenHypercall2 (__HYPERVISOR_memory_op,\r
-                        Operation, (INTN) Arguments);\r
-}\r
-\r
-INTN\r
-XenHypercallEventChannelOp (\r
-  IN     INTN Operation,\r
-  IN OUT VOID *Arguments\r
-  )\r
-{\r
-  return XenHypercall2 (__HYPERVISOR_event_channel_op,\r
-                        Operation, (INTN) Arguments);\r
-}\r
-\r
-INTN\r
-EFIAPI\r
-XenHypercall2 (\r
-  IN     UINTN  HypercallID,\r
-  IN OUT INTN   Arg1,\r
-  IN OUT INTN   Arg2\r
-  )\r
-{\r
-  ASSERT (HyperPage != NULL);\r
-\r
-  return __XenHypercall2 ((UINT8*)HyperPage + HypercallID * 32, Arg1, Arg2);\r
-}\r
diff --git a/OvmfPkg/XenBusDxe/XenHypercall.h b/OvmfPkg/XenBusDxe/XenHypercall.h
deleted file mode 100644 (file)
index 9d49e33..0000000
+++ /dev/null
@@ -1,91 +0,0 @@
-/** @file\r
-  Functions declarations to make Xen hypercalls.\r
-\r
-  Copyright (C) 2014, Citrix Ltd.\r
-\r
-  This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-\r
-**/\r
-\r
-#ifndef __XENBUS_DXE_HYPERCALL_H__\r
-#define __XENBUS_DXE_HYPERCALL_H__\r
-\r
-/**\r
-  This function will put the two arguments in the right place (registers) and\r
-  invoke the hypercall identified by HypercallID.\r
-\r
-  @param HypercallID    The symbolic ID of the hypercall to be invoked\r
-  @param Arg1           First argument.\r
-  @param Arg2           Second argument.\r
-\r
-  @return   Return 0 if success otherwise it return an errno.\r
-**/\r
-INTN\r
-EFIAPI\r
-XenHypercall2 (\r
-  IN     INTN HypercallID,\r
-  IN OUT INTN Arg1,\r
-  IN OUT INTN Arg2\r
-  );\r
-\r
-/**\r
-  Get the page where all hypercall are from the XenInfo hob.\r
-\r
-  @param Dev    A XENBUS_DEVICE instance.\r
-\r
-  @retval EFI_NOT_FOUND   hyperpage could not be found.\r
-  @retval EFI_SUCCESS     Successfully retrieve the hyperpage pointer.\r
-**/\r
-EFI_STATUS\r
-XenHyperpageInit (\r
-  );\r
-\r
-/**\r
-  Return the value of the HVM parameter Index.\r
-\r
-  @param Index  The parameter to get, e.g. HVM_PARAM_STORE_EVTCHN.\r
-\r
-  @return   The value of the asked parameter or 0 in case of error.\r
-**/\r
-UINT64\r
-XenHypercallHvmGetParam (\r
-  UINT32 Index\r
-  );\r
-\r
-/**\r
-  Hypercall to do different operation on the memory.\r
-\r
-  @param Operation  The operation number, e.g. XENMEM_add_to_physmap.\r
-  @param Arguments  The arguments associated to the operation.\r
-\r
-  @return  Return the return value from the hypercall, 0 in case of success\r
-           otherwise, an error code.\r
-**/\r
-INTN\r
-XenHypercallMemoryOp (\r
-  IN     UINTN Operation,\r
-  IN OUT VOID *Arguments\r
-  );\r
-\r
-/**\r
-  Do an operation on the event channels.\r
-\r
-  @param Operation  The operation number, e.g. EVTCHNOP_send.\r
-  @param Arguments  The argument associated to the operation.\r
-\r
-  @return  Return the return value from the hypercall, 0 in case of success\r
-           otherwise, an error code.\r
-**/\r
-INTN\r
-XenHypercallEventChannelOp (\r
-  IN     INTN Operation,\r
-  IN OUT VOID *Arguments\r
-  );\r
-\r
-#endif\r
index 7ec1e634bc5c16e6e76a324bb7645327f17a4c65..9850f1e644fcdf018fe5ced27b12930e1a7181f3 100644 (file)
@@ -60,8 +60,8 @@
 \r
 #include <IndustryStandard/Xen/hvm/params.h>\r
 \r
-#include "XenHypercall.h"\r
 #include "EventChannel.h"\r
+#include <Library/XenHypercallLib.h>\r
 \r
 //\r
 // Private Data Structures\r