]> git.proxmox.com Git - mirror_edk2.git/blame - ArmVirtPkg/XenioFdtDxe/XenioFdtDxe.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / ArmVirtPkg / XenioFdtDxe / XenioFdtDxe.c
CommitLineData
81996ba8
AB
1/** @file\r
2* Xenio FDT client protocol driver for xen,xen DT node\r
3*\r
4* Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>\r
5*\r
9792fb0e 6* SPDX-License-Identifier: BSD-2-Clause-Patent\r
81996ba8
AB
7*\r
8**/\r
9\r
10#include <Library/BaseLib.h>\r
11#include <Library/DebugLib.h>\r
12#include <Library/UefiDriverEntryPoint.h>\r
13#include <Library/UefiBootServicesTableLib.h>\r
14#include <Library/XenIoMmioLib.h>\r
15\r
16#include <Protocol/FdtClient.h>\r
17\r
18EFI_STATUS\r
19EFIAPI\r
20InitializeXenioFdtDxe (\r
2b16a4fb
MK
21 IN EFI_HANDLE ImageHandle,\r
22 IN EFI_SYSTEM_TABLE *SystemTable\r
81996ba8
AB
23 )\r
24{\r
2b16a4fb
MK
25 EFI_STATUS Status;\r
26 FDT_CLIENT_PROTOCOL *FdtClient;\r
27 CONST UINT64 *Reg;\r
28 UINT32 RegSize;\r
29 UINTN AddressCells, SizeCells;\r
30 EFI_HANDLE Handle;\r
31 UINT64 RegBase;\r
81996ba8 32\r
2b16a4fb
MK
33 Status = gBS->LocateProtocol (\r
34 &gFdtClientProtocolGuid,\r
35 NULL,\r
36 (VOID **)&FdtClient\r
37 );\r
81996ba8
AB
38 ASSERT_EFI_ERROR (Status);\r
39\r
2b16a4fb
MK
40 Status = FdtClient->FindCompatibleNodeReg (\r
41 FdtClient,\r
42 "xen,xen",\r
43 (CONST VOID **)&Reg,\r
44 &AddressCells,\r
45 &SizeCells,\r
46 &RegSize\r
47 );\r
81996ba8 48 if (EFI_ERROR (Status)) {\r
2b16a4fb
MK
49 DEBUG ((\r
50 DEBUG_WARN,\r
51 "%a: No 'xen,xen' compatible DT node found\n",\r
52 __FUNCTION__\r
53 ));\r
81996ba8
AB
54 return EFI_UNSUPPORTED;\r
55 }\r
56\r
cfc8d51c
AB
57 ASSERT (AddressCells == 2);\r
58 ASSERT (SizeCells == 2);\r
59 ASSERT (RegSize == 2 * sizeof (UINT64));\r
81996ba8
AB
60\r
61 //\r
62 // Retrieve the reg base from this node and wire it up to the\r
63 // MMIO flavor of the XenBus root device I/O protocol\r
64 //\r
65 RegBase = SwapBytes64 (Reg[0]);\r
2b16a4fb
MK
66 Handle = NULL;\r
67 Status = XenIoMmioInstall (&Handle, RegBase);\r
81996ba8 68 if (EFI_ERROR (Status)) {\r
2b16a4fb
MK
69 DEBUG ((\r
70 DEBUG_ERROR,\r
71 "%a: XenIoMmioInstall () failed on a new handle "\r
72 "(Status == %r)\n",\r
73 __FUNCTION__,\r
74 Status\r
75 ));\r
81996ba8
AB
76 return Status;\r
77 }\r
78\r
c5b3a56e 79 DEBUG ((DEBUG_INFO, "Found Xen node with Grant table @ 0x%Lx\n", RegBase));\r
81996ba8
AB
80\r
81 return EFI_SUCCESS;\r
82}\r