From af1a266670d040d2f4083ff309d732d648afba2a Mon Sep 17 00:00:00 2001 From: Angelos Mouzakitis <a.mouzakitis@virtualopensystems.com> Date: Tue, 10 Oct 2023 14:33:42 +0000 Subject: Add submodule dependency files Change-Id: Iaf8d18082d3991dec7c0ebbea540f092188eb4ec --- roms/edk2/ArmVirtPkg/XenioFdtDxe/XenioFdtDxe.c | 66 ++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 roms/edk2/ArmVirtPkg/XenioFdtDxe/XenioFdtDxe.c (limited to 'roms/edk2/ArmVirtPkg/XenioFdtDxe/XenioFdtDxe.c') diff --git a/roms/edk2/ArmVirtPkg/XenioFdtDxe/XenioFdtDxe.c b/roms/edk2/ArmVirtPkg/XenioFdtDxe/XenioFdtDxe.c new file mode 100644 index 000000000..745160054 --- /dev/null +++ b/roms/edk2/ArmVirtPkg/XenioFdtDxe/XenioFdtDxe.c @@ -0,0 +1,66 @@ +/** @file +* Xenio FDT client protocol driver for xen,xen DT node +* +* Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR> +* +* SPDX-License-Identifier: BSD-2-Clause-Patent +* +**/ + +#include <Library/BaseLib.h> +#include <Library/DebugLib.h> +#include <Library/UefiDriverEntryPoint.h> +#include <Library/UefiBootServicesTableLib.h> +#include <Library/XenIoMmioLib.h> + +#include <Protocol/FdtClient.h> + +EFI_STATUS +EFIAPI +InitializeXenioFdtDxe ( + IN EFI_HANDLE ImageHandle, + IN EFI_SYSTEM_TABLE *SystemTable + ) +{ + EFI_STATUS Status; + FDT_CLIENT_PROTOCOL *FdtClient; + CONST UINT64 *Reg; + UINT32 RegSize; + UINTN AddressCells, SizeCells; + 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, &AddressCells, &SizeCells, + &RegSize); + if (EFI_ERROR (Status)) { + DEBUG ((EFI_D_WARN, "%a: No 'xen,xen' compatible DT node found\n", + __FUNCTION__)); + return EFI_UNSUPPORTED; + } + + ASSERT (AddressCells == 2); + ASSERT (SizeCells == 2); + ASSERT (RegSize == 2 * sizeof (UINT64)); + + // + // 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