]>
Commit | Line | Data |
---|---|---|
cd8ff8fd AB |
1 | /** @file\r |
2 | Xen Hypercall Library implementation for Intel architecture\r | |
3 | \r | |
4 | Copyright (c) 2014, Linaro Ltd. All rights reserved.<BR>\r | |
b26f0cf9 | 5 | SPDX-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 | |
14 | STATIC 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 | |
26 | BOOLEAN\r | |
27 | EFIAPI\r | |
28 | XenHypercallIsAvailable (\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 | |
38 | INTN\r | |
39 | EFIAPI\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 | |
51 | RETURN_STATUS\r | |
52 | EFIAPI\r | |
df040c00 | 53 | XenHypercallLibInit (\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 | |
68f4599d | 62 | return RETURN_NOT_FOUND;\r |
cd8ff8fd AB |
63 | }\r |
64 | XenInfo = (EFI_XEN_INFO *) GET_GUID_HOB_DATA (GuidHob);\r | |
65 | HyperPage = XenInfo->HyperPages;\r | |
66 | return RETURN_SUCCESS;\r | |
67 | }\r | |
68 | \r | |
69 | /**\r | |
70 | This function will put the two arguments in the right place (registers) and\r | |
71 | invoke the hypercall identified by HypercallID.\r | |
72 | \r | |
73 | @param HypercallID The symbolic ID of the hypercall to be invoked\r | |
74 | @param Arg1 First argument.\r | |
75 | @param Arg2 Second argument.\r | |
76 | \r | |
77 | @return Return 0 if success otherwise it return an errno.\r | |
78 | **/\r | |
79 | INTN\r | |
80 | EFIAPI\r | |
81 | XenHypercall2 (\r | |
82 | IN UINTN HypercallID,\r | |
83 | IN OUT INTN Arg1,\r | |
84 | IN OUT INTN Arg2\r | |
85 | )\r | |
86 | {\r | |
87 | ASSERT (HyperPage != NULL);\r | |
88 | \r | |
89 | return __XenHypercall2 ((UINT8*)HyperPage + HypercallID * 32, Arg1, Arg2);\r | |
90 | }\r |