XenIoPvhDxe.c 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /** @file
  2. Driver for the XenIo protocol
  3. This driver simply allocate space for the grant tables.
  4. Copyright (c) 2019, Citrix Systems, Inc.
  5. SPDX-License-Identifier: BSD-2-Clause-Patent
  6. **/
  7. #include <Library/MemoryAllocationLib.h>
  8. #include <Library/PcdLib.h>
  9. #include <Library/XenIoMmioLib.h>
  10. #include <Library/XenPlatformLib.h>
  11. EFI_STATUS
  12. EFIAPI
  13. InitializeXenIoPvhDxe (
  14. IN EFI_HANDLE ImageHandle,
  15. IN EFI_SYSTEM_TABLE *SystemTable
  16. )
  17. {
  18. VOID *Allocation;
  19. EFI_STATUS Status;
  20. EFI_HANDLE XenIoHandle;
  21. Allocation = NULL;
  22. XenIoHandle = NULL;
  23. if (!XenPvhDetected ()) {
  24. return EFI_UNSUPPORTED;
  25. }
  26. Allocation = AllocateReservedPages (FixedPcdGet32 (PcdXenGrantFrames));
  27. if (Allocation == NULL) {
  28. Status = EFI_OUT_OF_RESOURCES;
  29. goto Error;
  30. }
  31. Status = XenIoMmioInstall (&XenIoHandle, (UINTN)Allocation);
  32. if (EFI_ERROR (Status)) {
  33. goto Error;
  34. }
  35. return EFI_SUCCESS;
  36. Error:
  37. if (Allocation != NULL) {
  38. FreePages (Allocation, FixedPcdGet32 (PcdXenGrantFrames));
  39. }
  40. return Status;
  41. }