]> git.proxmox.com Git - mirror_edk2.git/blob - OvmfPkg/Library/XenHypercallLib/XenHypercall.c
OvmfPkg: Apply uncrustify changes
[mirror_edk2.git] / OvmfPkg / Library / XenHypercallLib / XenHypercall.c
1 /** @file
2 Functions to make Xen hypercalls.
3
4 Copyright (C) 2014, Citrix Ltd.
5
6 SPDX-License-Identifier: BSD-2-Clause-Patent
7
8 **/
9
10 #include <PiDxe.h>
11
12 #include <IndustryStandard/Xen/hvm/params.h>
13 #include <IndustryStandard/Xen/memory.h>
14
15 #include <Library/DebugLib.h>
16 #include <Library/XenHypercallLib.h>
17
18 RETURN_STATUS
19 EFIAPI
20 XenHypercallLibConstruct (
21 VOID
22 )
23 {
24 XenHypercallLibInit ();
25 //
26 // We don't fail library construction, since that has catastrophic
27 // consequences for client modules (whereas those modules may easily be
28 // running on a non-Xen platform). Instead, XenHypercallIsAvailable()
29 // will return FALSE.
30 //
31 return RETURN_SUCCESS;
32 }
33
34 UINT64
35 EFIAPI
36 XenHypercallHvmGetParam (
37 IN UINT32 Index
38 )
39 {
40 xen_hvm_param_t Parameter;
41 INTN Error;
42
43 Parameter.domid = DOMID_SELF;
44 Parameter.index = Index;
45 Error = XenHypercall2 (
46 __HYPERVISOR_hvm_op,
47 HVMOP_get_param,
48 (INTN)&Parameter
49 );
50 if (Error != 0) {
51 DEBUG ((
52 DEBUG_ERROR,
53 "XenHypercall: Error %Ld trying to get HVM parameter %d\n",
54 (INT64)Error,
55 Index
56 ));
57 return 0;
58 }
59
60 return Parameter.value;
61 }
62
63 INTN
64 EFIAPI
65 XenHypercallMemoryOp (
66 IN UINTN Operation,
67 IN OUT VOID *Arguments
68 )
69 {
70 return XenHypercall2 (
71 __HYPERVISOR_memory_op,
72 Operation,
73 (INTN)Arguments
74 );
75 }
76
77 INTN
78 EFIAPI
79 XenHypercallEventChannelOp (
80 IN INTN Operation,
81 IN OUT VOID *Arguments
82 )
83 {
84 return XenHypercall2 (
85 __HYPERVISOR_event_channel_op,
86 Operation,
87 (INTN)Arguments
88 );
89 }