Files
system76-edk2/OvmfPkg/XenIoPvhDxe/XenIoPvhDxe.c
Anthony PERARD 833cd3e0c0 OvmfPkg: Introduce XenIoPvhDxe to initialize Grant Tables
XenIoPvhDxe use XenIoMmioLib to reserve some space to be use by the
Grant Tables.

The call is only done if it is necessary, we simply detect if the
guest is PVH, as in this case there is currently no PCI bus, and no
PCI Xen platform device which would start the XenIoPciDxe and allocate
the space for the Grant Tables.

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1689
Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Message-Id: <20190813113119.14804-34-anthony.perard@citrix.com>
2019-08-21 18:03:50 +02:00

55 lines
1.1 KiB
C

/** @file
Driver for the XenIo protocol
This driver simply allocate space for the grant tables.
Copyright (c) 2019, Citrix Systems, Inc.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/
#include <Library/MemoryAllocationLib.h>
#include <Library/PcdLib.h>
#include <Library/XenIoMmioLib.h>
#include <Library/XenPlatformLib.h>
EFI_STATUS
EFIAPI
InitializeXenIoPvhDxe (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
{
VOID *Allocation;
EFI_STATUS Status;
EFI_HANDLE XenIoHandle;
Allocation = NULL;
XenIoHandle = NULL;
if (!XenPvhDetected ()) {
return EFI_UNSUPPORTED;
}
Allocation = AllocateReservedPages (FixedPcdGet32 (PcdXenGrantFrames));
if (Allocation == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto Error;
}
Status = XenIoMmioInstall (&XenIoHandle, (UINTN) Allocation);
if (EFI_ERROR (Status)) {
goto Error;
}
return EFI_SUCCESS;
Error:
if (Allocation != NULL) {
FreePages (Allocation, FixedPcdGet32 (PcdXenGrantFrames));
}
return Status;
}