]> git.proxmox.com Git - mirror_edk2.git/blob - ArmVirtPkg/KvmtoolPlatformDxe/KvmtoolPlatformDxe.c
a42b64d1061dcdf8163775f66b6d2f550e481315
[mirror_edk2.git] / ArmVirtPkg / KvmtoolPlatformDxe / KvmtoolPlatformDxe.c
1 /** @file
2
3 The KvmtoolPlatformDxe performs the platform specific initialization like:
4 - It decides if the firmware should expose ACPI or Device Tree-based
5 hardware description to the operating system.
6
7 Copyright (c) 2018 - 2020, ARM Limited. All rights reserved.
8
9 SPDX-License-Identifier: BSD-2-Clause-Patent
10
11 **/
12
13 #include <Guid/VariableFormat.h>
14 #include <Library/BaseLib.h>
15 #include <Library/DebugLib.h>
16 #include <Library/UefiBootServicesTableLib.h>
17 #include <Protocol/FdtClient.h>
18
19 /** Decide if the firmware should expose ACPI tables or Device Tree and
20 install the appropriate protocol interface.
21
22 Note: This function is derived from "ArmVirtPkg/PlatformHasAcpiDtDxe",
23 by dropping the word size check, and the fw_cfg check.
24
25 @param [in] ImageHandle Handle for this image.
26
27 @retval EFI_SUCCESS Success.
28 @retval EFI_OUT_OF_RESOURCES There was not enough memory to install the
29 protocols.
30 @retval EFI_INVALID_PARAMETER A parameter is invalid.
31
32 **/
33 STATIC
34 EFI_STATUS
35 PlatformHasAcpiDt (
36 IN EFI_HANDLE ImageHandle
37 )
38 {
39 if (!PcdGetBool (PcdForceNoAcpi)) {
40 // Expose ACPI tables
41 return gBS->InstallProtocolInterface (
42 &ImageHandle,
43 &gEdkiiPlatformHasAcpiGuid,
44 EFI_NATIVE_INTERFACE,
45 NULL
46 );
47 }
48
49 // Expose the Device Tree.
50 return gBS->InstallProtocolInterface (
51 &ImageHandle,
52 &gEdkiiPlatformHasDeviceTreeGuid,
53 EFI_NATIVE_INTERFACE,
54 NULL
55 );
56 }
57
58 /** Entry point for Kvmtool Platform Dxe
59
60 @param [in] ImageHandle Handle for this image.
61 @param [in] SystemTable Pointer to the EFI system table.
62
63 @retval EFI_SUCCESS Success.
64 @retval EFI_OUT_OF_RESOURCES There was not enough memory to install the
65 protocols.
66 @retval EFI_INVALID_PARAMETER A parameter is invalid.
67
68 **/
69 EFI_STATUS
70 EFIAPI
71 KvmtoolPlatformDxeEntryPoint (
72 IN EFI_HANDLE ImageHandle,
73 IN EFI_SYSTEM_TABLE *SystemTable
74 )
75 {
76 EFI_STATUS Status;
77
78 Status = PlatformHasAcpiDt (ImageHandle);
79 ASSERT_EFI_ERROR (Status);
80
81 return Status;
82 }