]> git.proxmox.com Git - mirror_edk2.git/blob - ArmVirtPkg/XenioFdtDxe/XenioFdtDxe.c
BaseTools/BinToPcd: Fix Python 2.7.x compatibility issue
[mirror_edk2.git] / ArmVirtPkg / XenioFdtDxe / XenioFdtDxe.c
1 /** @file
2 * Xenio FDT client protocol driver for xen,xen DT node
3 *
4 * Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>
5 *
6 * This program and the accompanying materials are
7 * licensed and made available under the terms and conditions of the BSD License
8 * which accompanies this distribution. The full text of the license may be found at
9 * http://opensource.org/licenses/bsd-license.php
10 *
11 * THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13 *
14 **/
15
16 #include <Library/BaseLib.h>
17 #include <Library/DebugLib.h>
18 #include <Library/UefiDriverEntryPoint.h>
19 #include <Library/UefiBootServicesTableLib.h>
20 #include <Library/XenIoMmioLib.h>
21
22 #include <Protocol/FdtClient.h>
23
24 EFI_STATUS
25 EFIAPI
26 InitializeXenioFdtDxe (
27 IN EFI_HANDLE ImageHandle,
28 IN EFI_SYSTEM_TABLE *SystemTable
29 )
30 {
31 EFI_STATUS Status;
32 FDT_CLIENT_PROTOCOL *FdtClient;
33 CONST UINT64 *Reg;
34 UINT32 RegSize;
35 UINTN AddressCells, SizeCells;
36 EFI_HANDLE Handle;
37 UINT64 RegBase;
38
39 Status = gBS->LocateProtocol (&gFdtClientProtocolGuid, NULL,
40 (VOID **)&FdtClient);
41 ASSERT_EFI_ERROR (Status);
42
43 Status = FdtClient->FindCompatibleNodeReg (FdtClient, "xen,xen",
44 (CONST VOID **)&Reg, &AddressCells, &SizeCells,
45 &RegSize);
46 if (EFI_ERROR (Status)) {
47 DEBUG ((EFI_D_WARN, "%a: No 'xen,xen' compatible DT node found\n",
48 __FUNCTION__));
49 return EFI_UNSUPPORTED;
50 }
51
52 ASSERT (AddressCells == 2);
53 ASSERT (SizeCells == 2);
54 ASSERT (RegSize == 2 * sizeof (UINT64));
55
56 //
57 // Retrieve the reg base from this node and wire it up to the
58 // MMIO flavor of the XenBus root device I/O protocol
59 //
60 RegBase = SwapBytes64 (Reg[0]);
61 Handle = NULL;
62 Status = XenIoMmioInstall (&Handle, RegBase);
63 if (EFI_ERROR (Status)) {
64 DEBUG ((EFI_D_ERROR, "%a: XenIoMmioInstall () failed on a new handle "
65 "(Status == %r)\n", __FUNCTION__, Status));
66 return Status;
67 }
68
69 DEBUG ((EFI_D_INFO, "Found Xen node with Grant table @ 0x%Lx\n", RegBase));
70
71 return EFI_SUCCESS;
72 }