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
;
34 UINT32 RegElemSize
, RegSize
;
38 Status
= gBS
->LocateProtocol (&gFdtClientProtocolGuid
, NULL
,
40 ASSERT_EFI_ERROR (Status
);
42 Status
= FdtClient
->FindCompatibleNodeReg (FdtClient
, "xen,xen",
43 (CONST VOID
**)&Reg
, &RegElemSize
, &RegSize
);
44 if (EFI_ERROR (Status
)) {
45 DEBUG ((EFI_D_WARN
, "%a: No 'xen,xen' compatible DT node found\n",
47 return EFI_UNSUPPORTED
;
50 ASSERT (RegSize
== 16);
53 // Retrieve the reg base from this node and wire it up to the
54 // MMIO flavor of the XenBus root device I/O protocol
56 RegBase
= SwapBytes64 (Reg
[0]);
58 Status
= XenIoMmioInstall (&Handle
, RegBase
);
59 if (EFI_ERROR (Status
)) {
60 DEBUG ((EFI_D_ERROR
, "%a: XenIoMmioInstall () failed on a new handle "
61 "(Status == %r)\n", __FUNCTION__
, Status
));
65 DEBUG ((EFI_D_INFO
, "Found Xen node with Grant table @ 0x%Lx\n", RegBase
));