2 * Xenio FDT client protocol driver for xen,xen DT node
4 * Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>
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
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.
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>
22 #include <Protocol/FdtClient.h>
26 InitializeXenioFdtDxe (
27 IN EFI_HANDLE ImageHandle
,
28 IN EFI_SYSTEM_TABLE
*SystemTable
32 FDT_CLIENT_PROTOCOL
*FdtClient
;
35 UINTN AddressCells
, SizeCells
;
39 Status
= gBS
->LocateProtocol (&gFdtClientProtocolGuid
, NULL
,
41 ASSERT_EFI_ERROR (Status
);
43 Status
= FdtClient
->FindCompatibleNodeReg (FdtClient
, "xen,xen",
44 (CONST VOID
**)&Reg
, &AddressCells
, &SizeCells
,
46 if (EFI_ERROR (Status
)) {
47 DEBUG ((EFI_D_WARN
, "%a: No 'xen,xen' compatible DT node found\n",
49 return EFI_UNSUPPORTED
;
52 ASSERT (AddressCells
== 2);
53 ASSERT (SizeCells
== 2);
54 ASSERT (RegSize
== 2 * sizeof (UINT64
));
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
60 RegBase
= SwapBytes64 (Reg
[0]);
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
));
69 DEBUG ((EFI_D_INFO
, "Found Xen node with Grant table @ 0x%Lx\n", RegBase
));