2016-04-08 11:45:10 +02:00
|
|
|
/** @file
|
|
|
|
* Xenio FDT client protocol driver for xen,xen DT node
|
|
|
|
*
|
|
|
|
* Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>
|
|
|
|
*
|
2019-04-04 01:03:23 +02:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause-Patent
|
2016-04-08 11:45:10 +02:00
|
|
|
*
|
|
|
|
**/
|
|
|
|
|
|
|
|
#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 (
|
2021-12-05 23:53:52 +01:00
|
|
|
IN EFI_HANDLE ImageHandle,
|
|
|
|
IN EFI_SYSTEM_TABLE *SystemTable
|
2016-04-08 11:45:10 +02:00
|
|
|
)
|
|
|
|
{
|
2021-12-05 23:53:52 +01:00
|
|
|
EFI_STATUS Status;
|
|
|
|
FDT_CLIENT_PROTOCOL *FdtClient;
|
|
|
|
CONST UINT64 *Reg;
|
|
|
|
UINT32 RegSize;
|
|
|
|
UINTN AddressCells, SizeCells;
|
|
|
|
EFI_HANDLE Handle;
|
|
|
|
UINT64 RegBase;
|
2016-04-08 11:45:10 +02:00
|
|
|
|
2021-12-05 23:53:52 +01:00
|
|
|
Status = gBS->LocateProtocol (
|
|
|
|
&gFdtClientProtocolGuid,
|
|
|
|
NULL,
|
|
|
|
(VOID **)&FdtClient
|
|
|
|
);
|
2016-04-08 11:45:10 +02:00
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
|
2021-12-05 23:53:52 +01:00
|
|
|
Status = FdtClient->FindCompatibleNodeReg (
|
|
|
|
FdtClient,
|
|
|
|
"xen,xen",
|
|
|
|
(CONST VOID **)&Reg,
|
|
|
|
&AddressCells,
|
|
|
|
&SizeCells,
|
|
|
|
&RegSize
|
|
|
|
);
|
2016-04-08 11:45:10 +02:00
|
|
|
if (EFI_ERROR (Status)) {
|
2021-12-05 23:53:52 +01:00
|
|
|
DEBUG ((
|
|
|
|
DEBUG_WARN,
|
|
|
|
"%a: No 'xen,xen' compatible DT node found\n",
|
|
|
|
__FUNCTION__
|
|
|
|
));
|
2016-04-08 11:45:10 +02:00
|
|
|
return EFI_UNSUPPORTED;
|
|
|
|
}
|
|
|
|
|
2016-09-15 15:15:14 +02:00
|
|
|
ASSERT (AddressCells == 2);
|
|
|
|
ASSERT (SizeCells == 2);
|
|
|
|
ASSERT (RegSize == 2 * sizeof (UINT64));
|
2016-04-08 11:45:10 +02:00
|
|
|
|
|
|
|
//
|
|
|
|
// 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]);
|
2021-12-05 23:53:52 +01:00
|
|
|
Handle = NULL;
|
|
|
|
Status = XenIoMmioInstall (&Handle, RegBase);
|
2016-04-08 11:45:10 +02:00
|
|
|
if (EFI_ERROR (Status)) {
|
2021-12-05 23:53:52 +01:00
|
|
|
DEBUG ((
|
|
|
|
DEBUG_ERROR,
|
|
|
|
"%a: XenIoMmioInstall () failed on a new handle "
|
|
|
|
"(Status == %r)\n",
|
|
|
|
__FUNCTION__,
|
|
|
|
Status
|
|
|
|
));
|
2016-04-08 11:45:10 +02:00
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
2021-11-17 04:21:15 +01:00
|
|
|
DEBUG ((DEBUG_INFO, "Found Xen node with Grant table @ 0x%Lx\n", RegBase));
|
2016-04-08 11:45:10 +02:00
|
|
|
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|