2 * Xenio FDT client protocol driver for xen,xen DT node
4 * Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>
6 * SPDX-License-Identifier: BSD-2-Clause-Patent
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>
16 #include <Protocol/FdtClient.h>
20 InitializeXenioFdtDxe (
21 IN EFI_HANDLE ImageHandle
,
22 IN EFI_SYSTEM_TABLE
*SystemTable
26 FDT_CLIENT_PROTOCOL
*FdtClient
;
29 UINTN AddressCells
, SizeCells
;
33 Status
= gBS
->LocateProtocol (&gFdtClientProtocolGuid
, NULL
,
35 ASSERT_EFI_ERROR (Status
);
37 Status
= FdtClient
->FindCompatibleNodeReg (FdtClient
, "xen,xen",
38 (CONST VOID
**)&Reg
, &AddressCells
, &SizeCells
,
40 if (EFI_ERROR (Status
)) {
41 DEBUG ((EFI_D_WARN
, "%a: No 'xen,xen' compatible DT node found\n",
43 return EFI_UNSUPPORTED
;
46 ASSERT (AddressCells
== 2);
47 ASSERT (SizeCells
== 2);
48 ASSERT (RegSize
== 2 * sizeof (UINT64
));
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
54 RegBase
= SwapBytes64 (Reg
[0]);
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
));
63 DEBUG ((EFI_D_INFO
, "Found Xen node with Grant table @ 0x%Lx\n", RegBase
));