#include <IndustryStandard/Pci.h>\r
#include <IndustryStandard/Acpi.h>\r
#include <Library/DebugLib.h>\r
+#include <Library/XenHypercallLib.h>\r
\r
#include "XenBusDxe.h"\r
\r
-#include "XenHypercall.h"\r
#include "GrantTable.h"\r
#include "XenStore.h"\r
#include "XenBus.h"\r
\r
+#include <IndustryStandard/Xen/hvm/params.h>\r
+#include <IndustryStandard/Xen/memory.h>\r
\r
///\r
/// Driver Binding Protocol instance\r
STATIC EFI_LOCK mMyDeviceLock = EFI_INITIALIZE_LOCK_VARIABLE (TPL_CALLBACK);\r
STATIC XENBUS_DEVICE *mMyDevice = NULL;\r
\r
+/**\r
+ Map the shared_info_t page into memory.\r
+\r
+ @param Dev A XENBUS_DEVICE instance.\r
+\r
+ @retval EFI_SUCCESS Dev->SharedInfo whill contain a pointer to\r
+ the shared info page\r
+ @retval EFI_LOAD_ERROR The shared info page could not be mapped. The\r
+ hypercall returned an error.\r
+**/\r
+STATIC\r
+EFI_STATUS\r
+XenGetSharedInfoPage (\r
+ IN OUT XENBUS_DEVICE *Dev\r
+ )\r
+{\r
+ xen_add_to_physmap_t Parameter;\r
+\r
+ ASSERT (Dev->SharedInfo == NULL);\r
+\r
+ Parameter.domid = DOMID_SELF;\r
+ Parameter.space = XENMAPSPACE_shared_info;\r
+ Parameter.idx = 0;\r
+\r
+ //\r
+ // using reserved page because the page is not released when Linux is\r
+ // starting because of the add_to_physmap. QEMU might try to access the\r
+ // page, and fail because it have no right to do so (segv).\r
+ //\r
+ Dev->SharedInfo = AllocateReservedPages (1);\r
+ Parameter.gpfn = (UINTN) Dev->SharedInfo >> EFI_PAGE_SHIFT;\r
+ if (XenHypercallMemoryOp (XENMEM_add_to_physmap, &Parameter) != 0) {\r
+ FreePages (Dev->SharedInfo, 1);\r
+ Dev->SharedInfo = NULL;\r
+ return EFI_LOAD_ERROR;\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+}\r
+\r
/**\r
Unloads an image.\r
\r
MmioAddr = BarDesc->AddrRangeMin;\r
FreePool (BarDesc);\r
\r
- Status = XenHyperpageInit (Dev);\r
- if (EFI_ERROR (Status)) {\r
- DEBUG ((EFI_D_ERROR, "XenBus: Unable to retrieve the hyperpage.\n"));\r
- Status = EFI_UNSUPPORTED;\r
- goto ErrorAllocated;\r
- }\r
-\r
Status = XenGetSharedInfoPage (Dev);\r
if (EFI_ERROR (Status)) {\r
DEBUG ((EFI_D_ERROR, "XenBus: Unable to get the shared info page.\n"));\r