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