1 | /** @file
|
---|
2 | * Xenio FDT client protocol driver for xen,xen DT node
|
---|
3 | *
|
---|
4 | * Copyright (c) 2016, Linaro Ltd. All rights reserved.<BR>
|
---|
5 | *
|
---|
6 | * SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
7 | *
|
---|
8 | **/
|
---|
9 |
|
---|
10 | #include <Library/BaseLib.h>
|
---|
11 | #include <Library/DebugLib.h>
|
---|
12 | #include <Library/UefiDriverEntryPoint.h>
|
---|
13 | #include <Library/UefiBootServicesTableLib.h>
|
---|
14 | #include <Library/XenIoMmioLib.h>
|
---|
15 |
|
---|
16 | #include <Protocol/FdtClient.h>
|
---|
17 |
|
---|
18 | EFI_STATUS
|
---|
19 | EFIAPI
|
---|
20 | InitializeXenioFdtDxe (
|
---|
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 | __FUNCTION__
|
---|
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 | __FUNCTION__,
|
---|
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 | }
|
---|