-/** @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