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