]> git.proxmox.com Git - mirror_edk2.git/blob - ArmVirtPkg/PlatformHasAcpiDtDxe/PlatformHasAcpiDtDxe.c
ArmVirtPkg/PlatformHasAcpiDtDxe: allow guest level ACPI disable override
[mirror_edk2.git] / ArmVirtPkg / PlatformHasAcpiDtDxe / PlatformHasAcpiDtDxe.c
1 /** @file
2 Decide whether the firmware should expose an ACPI- and/or a Device Tree-based
3 hardware description to the operating system.
4
5 Copyright (c) 2017, Red Hat, Inc.
6
7 This program and the accompanying materials are licensed and made available
8 under the terms and conditions of the BSD License which accompanies this
9 distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
11
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
13 WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14 **/
15
16 #include <Guid/PlatformHasAcpi.h>
17 #include <Guid/PlatformHasDeviceTree.h>
18 #include <Library/BaseLib.h>
19 #include <Library/DebugLib.h>
20 #include <Library/PcdLib.h>
21 #include <Library/QemuFwCfgLib.h>
22 #include <Library/UefiBootServicesTableLib.h>
23
24 EFI_STATUS
25 EFIAPI
26 PlatformHasAcpiDt (
27 IN EFI_HANDLE ImageHandle,
28 IN EFI_SYSTEM_TABLE *SystemTable
29 )
30 {
31 EFI_STATUS Status;
32 FIRMWARE_CONFIG_ITEM FwCfgItem;
33 UINTN FwCfgSize;
34
35 //
36 // If we fail to install any of the necessary protocols below, the OS will be
37 // unbootable anyway (due to lacking hardware description), so tolerate no
38 // errors here.
39 //
40 if (MAX_UINTN == MAX_UINT64 &&
41 !PcdGetBool (PcdForceNoAcpi) &&
42 !EFI_ERROR (
43 QemuFwCfgFindFile (
44 "etc/table-loader",
45 &FwCfgItem,
46 &FwCfgSize
47 )
48 )) {
49 //
50 // Only make ACPI available on 64-bit systems, and only if QEMU generates
51 // (a subset of) the ACPI tables.
52 //
53 Status = gBS->InstallProtocolInterface (
54 &ImageHandle,
55 &gEdkiiPlatformHasAcpiGuid,
56 EFI_NATIVE_INTERFACE,
57 NULL
58 );
59 if (EFI_ERROR (Status)) {
60 goto Failed;
61 }
62
63 return Status;
64 }
65
66 //
67 // Expose the Device Tree otherwise.
68 //
69 Status = gBS->InstallProtocolInterface (
70 &ImageHandle,
71 &gEdkiiPlatformHasDeviceTreeGuid,
72 EFI_NATIVE_INTERFACE,
73 NULL
74 );
75 if (EFI_ERROR (Status)) {
76 goto Failed;
77 }
78
79 return Status;
80
81 Failed:
82 ASSERT_EFI_ERROR (Status);
83 CpuDeadLoop ();
84 //
85 // Keep compilers happy.
86 //
87 return Status;
88 }