]> git.proxmox.com Git - mirror_edk2.git/blob - ArmVirtPkg/XenioFdtDxe/XenioFdtDxe.c
BaseTools: Library hashing fix and optimization for --hash feature
[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 * SPDX-License-Identifier: BSD-2-Clause-Patent
7 *
8 **/
9
10 #include <Library/BaseLib.h>
11 #include <Library/DebugLib.h>
12 #include <Library/UefiDriverEntryPoint.h>
13 #include <Library/UefiBootServicesTableLib.h>
14 #include <Library/XenIoMmioLib.h>
15
16 #include <Protocol/FdtClient.h>
17
18 EFI_STATUS
19 EFIAPI
20 InitializeXenioFdtDxe (
21 IN EFI_HANDLE ImageHandle,
22 IN EFI_SYSTEM_TABLE *SystemTable
23 )
24 {
25 EFI_STATUS Status;
26 FDT_CLIENT_PROTOCOL *FdtClient;
27 CONST UINT64 *Reg;
28 UINT32 RegSize;
29 UINTN AddressCells, SizeCells;
30 EFI_HANDLE Handle;
31 UINT64 RegBase;
32
33 Status = gBS->LocateProtocol (&gFdtClientProtocolGuid, NULL,
34 (VOID **)&FdtClient);
35 ASSERT_EFI_ERROR (Status);
36
37 Status = FdtClient->FindCompatibleNodeReg (FdtClient, "xen,xen",
38 (CONST VOID **)&Reg, &AddressCells, &SizeCells,
39 &RegSize);
40 if (EFI_ERROR (Status)) {
41 DEBUG ((EFI_D_WARN, "%a: No 'xen,xen' compatible DT node found\n",
42 __FUNCTION__));
43 return EFI_UNSUPPORTED;
44 }
45
46 ASSERT (AddressCells == 2);
47 ASSERT (SizeCells == 2);
48 ASSERT (RegSize == 2 * sizeof (UINT64));
49
50 //
51 // Retrieve the reg base from this node and wire it up to the
52 // MMIO flavor of the XenBus root device I/O protocol
53 //
54 RegBase = SwapBytes64 (Reg[0]);
55 Handle = NULL;
56 Status = XenIoMmioInstall (&Handle, RegBase);
57 if (EFI_ERROR (Status)) {
58 DEBUG ((EFI_D_ERROR, "%a: XenIoMmioInstall () failed on a new handle "
59 "(Status == %r)\n", __FUNCTION__, Status));
60 return Status;
61 }
62
63 DEBUG ((EFI_D_INFO, "Found Xen node with Grant table @ 0x%Lx\n", RegBase));
64
65 return EFI_SUCCESS;
66 }