From 81996ba8b406a2e08a0d381d5991ab386462bf22 Mon Sep 17 00:00:00 2001 From: Ard Biesheuvel Date: Fri, 8 Apr 2016 11:45:10 +0200 Subject: ArmVirtPkg/ArmVirtXen: move from VirtFdtDxe to new XenioFdtDxe driver Now that the only functionality that remains in VirtFdtDxe is enumerating the respective virtual I/O buses, it no longer makes sense to have a driver that is shared between Xen domU and QEMU. So move the Xen I/O DT node handling to a new driver, and update ArmVirtXen to switch to it. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel Reviewed-by: Laszlo Ersek --- ArmVirtPkg/XenioFdtDxe/XenioFdtDxe.c | 68 ++++++++++++++++++++++++++++++++++++ 1 file changed, 68 insertions(+) create mode 100644 ArmVirtPkg/XenioFdtDxe/XenioFdtDxe.c (limited to 'ArmVirtPkg/XenioFdtDxe/XenioFdtDxe.c') diff --git a/ArmVirtPkg/XenioFdtDxe/XenioFdtDxe.c b/ArmVirtPkg/XenioFdtDxe/XenioFdtDxe.c new file mode 100644 index 0000000000..4a88db3217 --- /dev/null +++ b/ArmVirtPkg/XenioFdtDxe/XenioFdtDxe.c @@ -0,0 +1,68 @@ +/** @file +* Xenio FDT client protocol driver for xen,xen DT node +* +* Copyright (c) 2016, Linaro Ltd. All rights reserved.
+* +* This program and the accompanying materials are +* licensed and made available under the terms and conditions of the BSD License +* which accompanies this distribution. The full text of the license may be found at +* http://opensource.org/licenses/bsd-license.php +* +* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, +* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +* +**/ + +#include +#include +#include +#include +#include + +#include + +EFI_STATUS +EFIAPI +InitializeXenioFdtDxe ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + FDT_CLIENT_PROTOCOL *FdtClient; + CONST UINT64 *Reg; + UINT32 RegElemSize, RegSize; + EFI_HANDLE Handle; + UINT64 RegBase; + + Status = gBS->LocateProtocol (&gFdtClientProtocolGuid, NULL, + (VOID **)&FdtClient); + ASSERT_EFI_ERROR (Status); + + Status = FdtClient->FindCompatibleNodeReg (FdtClient, "xen,xen", + (CONST VOID **)&Reg, &RegElemSize, &RegSize); + if (EFI_ERROR (Status)) { + DEBUG ((EFI_D_WARN, "%a: No 'xen,xen' compatible DT node found\n", + __FUNCTION__)); + return EFI_UNSUPPORTED; + } + + ASSERT (RegSize == 16); + + // + // Retrieve the reg base from this node and wire it up to the + // MMIO flavor of the XenBus root device I/O protocol + // + RegBase = SwapBytes64 (Reg[0]); + Handle = NULL; + Status = XenIoMmioInstall (&Handle, RegBase); + if (EFI_ERROR (Status)) { + DEBUG ((EFI_D_ERROR, "%a: XenIoMmioInstall () failed on a new handle " + "(Status == %r)\n", __FUNCTION__, Status)); + return Status; + } + + DEBUG ((EFI_D_INFO, "Found Xen node with Grant table @ 0x%Lx\n", RegBase)); + + return EFI_SUCCESS; +} -- cgit v1.2.3