]> git.proxmox.com Git - mirror_edk2.git/blame - OvmfPkg/Library/XenHypercallLib/X86XenHypercall.c
OvmfPkg/EnrollDefaultKeys: enroll PK/KEK1 from the Type 11 SMBIOS table
[mirror_edk2.git] / OvmfPkg / Library / XenHypercallLib / X86XenHypercall.c
CommitLineData
cd8ff8fd
AB
1/** @file\r
2 Xen Hypercall Library implementation for Intel architecture\r
3\r
4Copyright (c) 2014, Linaro Ltd. All rights reserved.<BR>\r
b26f0cf9 5SPDX-License-Identifier: BSD-2-Clause-Patent\r
cd8ff8fd
AB
6\r
7**/\r
8\r
9#include <PiDxe.h>\r
10#include <Library/HobLib.h>\r
11#include <Library/DebugLib.h>\r
12#include <Guid/XenInfo.h>\r
13\r
14STATIC VOID *HyperPage;\r
15\r
02f69a25
LE
16/**\r
17 Check if the Xen Hypercall library is able to make calls to the Xen\r
18 hypervisor.\r
19\r
20 Client code should call further functions in this library only if, and after,\r
21 this function returns TRUE.\r
22\r
23 @retval TRUE Hypercalls are available.\r
24 @retval FALSE Hypercalls are not available.\r
25**/\r
26BOOLEAN\r
27EFIAPI\r
28XenHypercallIsAvailable (\r
29 VOID\r
30 )\r
31{\r
32 return HyperPage != NULL;\r
33}\r
34\r
cd8ff8fd
AB
35//\r
36// Interface exposed by the ASM implementation of the core hypercall\r
37//\r
38INTN\r
39EFIAPI\r
40__XenHypercall2 (\r
41 IN VOID *HypercallAddr,\r
42 IN OUT INTN Arg1,\r
43 IN OUT INTN Arg2\r
44 );\r
45\r
46/**\r
47 Library constructor: retrieves the Hyperpage address\r
48 from the gEfiXenInfoGuid HOB\r
49**/\r
50\r
51RETURN_STATUS\r
52EFIAPI\r
df040c00 53XenHypercallLibInit (\r
cd8ff8fd
AB
54 VOID\r
55 )\r
56{\r
57 EFI_HOB_GUID_TYPE *GuidHob;\r
58 EFI_XEN_INFO *XenInfo;\r
59\r
60 GuidHob = GetFirstGuidHob (&gEfiXenInfoGuid);\r
61 if (GuidHob == NULL) {\r
48b3ff04
LE
62 //\r
63 // We don't fail library construction, since that has catastrophic\r
64 // consequences for client modules (whereas those modules may easily be\r
65 // running on a non-Xen platform). Instead, XenHypercallIsAvailable() above\r
66 // will return FALSE.\r
67 //\r
68 return RETURN_SUCCESS;\r
cd8ff8fd
AB
69 }\r
70 XenInfo = (EFI_XEN_INFO *) GET_GUID_HOB_DATA (GuidHob);\r
71 HyperPage = XenInfo->HyperPages;\r
72 return RETURN_SUCCESS;\r
73}\r
74\r
75/**\r
76 This function will put the two arguments in the right place (registers) and\r
77 invoke the hypercall identified by HypercallID.\r
78\r
79 @param HypercallID The symbolic ID of the hypercall to be invoked\r
80 @param Arg1 First argument.\r
81 @param Arg2 Second argument.\r
82\r
83 @return Return 0 if success otherwise it return an errno.\r
84**/\r
85INTN\r
86EFIAPI\r
87XenHypercall2 (\r
88 IN UINTN HypercallID,\r
89 IN OUT INTN Arg1,\r
90 IN OUT INTN Arg2\r
91 )\r
92{\r
93 ASSERT (HyperPage != NULL);\r
94\r
95 return __XenHypercall2 ((UINT8*)HyperPage + HypercallID * 32, Arg1, Arg2);\r
96}\r