TianoCore EDK2 master
Loading...
Searching...
No Matches
XenioFdtDxe.c
Go to the documentation of this file.
1
10#include <Library/BaseLib.h>
11#include <Library/DebugLib.h>
15
16#include <Protocol/FdtClient.h>
17
19EFIAPI
20InitializeXenioFdtDxe (
21 IN EFI_HANDLE ImageHandle,
22 IN EFI_SYSTEM_TABLE *SystemTable
23 )
24{
25 EFI_STATUS Status;
26 FDT_CLIENT_PROTOCOL *FdtClient;
27 CONST UINT64 *Reg;
28 UINT32 RegSize;
29 UINTN AddressCells, SizeCells;
30 EFI_HANDLE Handle;
31 UINT64 RegBase;
32
33 Status = gBS->LocateProtocol (
34 &gFdtClientProtocolGuid,
35 NULL,
36 (VOID **)&FdtClient
37 );
38 ASSERT_EFI_ERROR (Status);
39
40 Status = FdtClient->FindCompatibleNodeReg (
41 FdtClient,
42 "xen,xen",
43 (CONST VOID **)&Reg,
44 &AddressCells,
45 &SizeCells,
46 &RegSize
47 );
48 if (EFI_ERROR (Status)) {
49 DEBUG ((
50 DEBUG_WARN,
51 "%a: No 'xen,xen' compatible DT node found\n",
52 __func__
53 ));
54 return EFI_UNSUPPORTED;
55 }
56
57 ASSERT (AddressCells == 2);
58 ASSERT (SizeCells == 2);
59 ASSERT (RegSize == 2 * sizeof (UINT64));
60
61 //
62 // Retrieve the reg base from this node and wire it up to the
63 // MMIO flavor of the XenBus root device I/O protocol
64 //
65 RegBase = SwapBytes64 (Reg[0]);
66 Handle = NULL;
67 Status = XenIoMmioInstall (&Handle, RegBase);
68 if (EFI_ERROR (Status)) {
69 DEBUG ((
70 DEBUG_ERROR,
71 "%a: XenIoMmioInstall () failed on a new handle "
72 "(Status == %r)\n",
73 __func__,
74 Status
75 ));
76 return Status;
77 }
78
79 DEBUG ((DEBUG_INFO, "Found Xen node with Grant table @ 0x%Lx\n", RegBase));
80
81 return EFI_SUCCESS;
82}
UINT64 UINTN
UINT64 EFIAPI SwapBytes64(IN UINT64 Value)
Definition: SwapBytes64.c:25
#define NULL
Definition: Base.h:319
#define CONST
Definition: Base.h:259
#define IN
Definition: Base.h:279
#define ASSERT_EFI_ERROR(StatusParameter)
Definition: DebugLib.h:462
#define DEBUG(Expression)
Definition: DebugLib.h:434
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
EFI_BOOT_SERVICES * gBS
EFI_STATUS XenIoMmioInstall(IN OUT EFI_HANDLE *Handle, IN EFI_PHYSICAL_ADDRESS GrantTableAddress)
Definition: XenIoMmioLib.c:68