]> git.proxmox.com Git - mirror_edk2.git/blob - OvmfPkg/Library/XenHypercallLib/X86XenHypercall.c
OvmfPkg, ArmVirtualizationPkg: clean up XenHypercallLib names
[mirror_edk2.git] / OvmfPkg / Library / XenHypercallLib / X86XenHypercall.c
1 /** @file
2 Xen Hypercall Library implementation for Intel architecture
3
4 Copyright (c) 2014, Linaro Ltd. All rights reserved.<BR>
5 This program and the accompanying materials are licensed and made available under
6 the terms and conditions of the BSD License that accompanies this distribution.
7 The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php.
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #include <PiDxe.h>
16 #include <Library/HobLib.h>
17 #include <Library/DebugLib.h>
18 #include <Guid/XenInfo.h>
19
20 STATIC VOID *HyperPage;
21
22 //
23 // Interface exposed by the ASM implementation of the core hypercall
24 //
25 INTN
26 EFIAPI
27 __XenHypercall2 (
28 IN VOID *HypercallAddr,
29 IN OUT INTN Arg1,
30 IN OUT INTN Arg2
31 );
32
33 /**
34 Library constructor: retrieves the Hyperpage address
35 from the gEfiXenInfoGuid HOB
36 **/
37
38 RETURN_STATUS
39 EFIAPI
40 XenHypercallLibInit (
41 VOID
42 )
43 {
44 EFI_HOB_GUID_TYPE *GuidHob;
45 EFI_XEN_INFO *XenInfo;
46
47 GuidHob = GetFirstGuidHob (&gEfiXenInfoGuid);
48 if (GuidHob == NULL) {
49 return RETURN_NOT_FOUND;
50 }
51 XenInfo = (EFI_XEN_INFO *) GET_GUID_HOB_DATA (GuidHob);
52 HyperPage = XenInfo->HyperPages;
53 return RETURN_SUCCESS;
54 }
55
56 /**
57 This function will put the two arguments in the right place (registers) and
58 invoke the hypercall identified by HypercallID.
59
60 @param HypercallID The symbolic ID of the hypercall to be invoked
61 @param Arg1 First argument.
62 @param Arg2 Second argument.
63
64 @return Return 0 if success otherwise it return an errno.
65 **/
66 INTN
67 EFIAPI
68 XenHypercall2 (
69 IN UINTN HypercallID,
70 IN OUT INTN Arg1,
71 IN OUT INTN Arg2
72 )
73 {
74 ASSERT (HyperPage != NULL);
75
76 return __XenHypercall2 ((UINT8*)HyperPage + HypercallID * 32, Arg1, Arg2);
77 }