2019-08-13 13:31:17 +02:00
|
|
|
/** @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 (
|
2021-12-05 23:54:09 +01:00
|
|
|
IN EFI_HANDLE ImageHandle,
|
|
|
|
IN EFI_SYSTEM_TABLE *SystemTable
|
2019-08-13 13:31:17 +02:00
|
|
|
)
|
|
|
|
{
|
2021-12-05 23:54:09 +01:00
|
|
|
VOID *Allocation;
|
|
|
|
EFI_STATUS Status;
|
|
|
|
EFI_HANDLE XenIoHandle;
|
2019-08-13 13:31:17 +02:00
|
|
|
|
2021-12-05 23:54:09 +01:00
|
|
|
Allocation = NULL;
|
2019-08-13 13:31:17 +02:00
|
|
|
XenIoHandle = NULL;
|
|
|
|
|
|
|
|
if (!XenPvhDetected ()) {
|
|
|
|
return EFI_UNSUPPORTED;
|
|
|
|
}
|
|
|
|
|
|
|
|
Allocation = AllocateReservedPages (FixedPcdGet32 (PcdXenGrantFrames));
|
|
|
|
if (Allocation == NULL) {
|
|
|
|
Status = EFI_OUT_OF_RESOURCES;
|
|
|
|
goto Error;
|
|
|
|
}
|
|
|
|
|
2021-12-05 23:54:09 +01:00
|
|
|
Status = XenIoMmioInstall (&XenIoHandle, (UINTN)Allocation);
|
2019-08-13 13:31:17 +02:00
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
goto Error;
|
|
|
|
}
|
|
|
|
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
|
|
|
|
Error:
|
|
|
|
if (Allocation != NULL) {
|
|
|
|
FreePages (Allocation, FixedPcdGet32 (PcdXenGrantFrames));
|
|
|
|
}
|
2021-12-05 23:54:09 +01:00
|
|
|
|
2019-08-13 13:31:17 +02:00
|
|
|
return Status;
|
|
|
|
}
|