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