]> git.proxmox.com Git - mirror_edk2.git/blame - ArmVirtPkg/XenioFdtDxe/XenioFdtDxe.c
BaseTools: Library hashing fix and optimization for --hash feature
[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
21 IN EFI_HANDLE ImageHandle,\r
22 IN EFI_SYSTEM_TABLE *SystemTable\r
23 )\r
24{\r
25 EFI_STATUS Status;\r
26 FDT_CLIENT_PROTOCOL *FdtClient;\r
27 CONST UINT64 *Reg;\r
cfc8d51c
AB
28 UINT32 RegSize;\r
29 UINTN AddressCells, SizeCells;\r
81996ba8
AB
30 EFI_HANDLE Handle;\r
31 UINT64 RegBase;\r
32\r
33 Status = gBS->LocateProtocol (&gFdtClientProtocolGuid, NULL,\r
34 (VOID **)&FdtClient);\r
35 ASSERT_EFI_ERROR (Status);\r
36\r
37 Status = FdtClient->FindCompatibleNodeReg (FdtClient, "xen,xen",\r
cfc8d51c
AB
38 (CONST VOID **)&Reg, &AddressCells, &SizeCells,\r
39 &RegSize);\r
81996ba8
AB
40 if (EFI_ERROR (Status)) {\r
41 DEBUG ((EFI_D_WARN, "%a: No 'xen,xen' compatible DT node found\n",\r
42 __FUNCTION__));\r
43 return EFI_UNSUPPORTED;\r
44 }\r
45\r
cfc8d51c
AB
46 ASSERT (AddressCells == 2);\r
47 ASSERT (SizeCells == 2);\r
48 ASSERT (RegSize == 2 * sizeof (UINT64));\r
81996ba8
AB
49\r
50 //\r
51 // Retrieve the reg base from this node and wire it up to the\r
52 // MMIO flavor of the XenBus root device I/O protocol\r
53 //\r
54 RegBase = SwapBytes64 (Reg[0]);\r
55 Handle = NULL;\r
56 Status = XenIoMmioInstall (&Handle, RegBase);\r
57 if (EFI_ERROR (Status)) {\r
58 DEBUG ((EFI_D_ERROR, "%a: XenIoMmioInstall () failed on a new handle "\r
59 "(Status == %r)\n", __FUNCTION__, Status));\r
60 return Status;\r
61 }\r
62\r
63 DEBUG ((EFI_D_INFO, "Found Xen node with Grant table @ 0x%Lx\n", RegBase));\r
64\r
65 return EFI_SUCCESS;\r
66}\r