]> git.proxmox.com Git - mirror_edk2.git/blame - ArmVirtPkg/PlatformHasAcpiDtDxe/PlatformHasAcpiDtDxe.c
ArmVirtPkg/PlatformHasAcpiDtDxe: don't expose DT if QEMU provides ACPI
[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
110316a9 20#include <Library/QemuFwCfgLib.h>\r
2558bfe3
LE
21#include <Library/UefiBootServicesTableLib.h>\r
22\r
23EFI_STATUS\r
24EFIAPI\r
25PlatformHasAcpiDt (\r
26 IN EFI_HANDLE ImageHandle,\r
27 IN EFI_SYSTEM_TABLE *SystemTable\r
28 )\r
29{\r
110316a9
LE
30 EFI_STATUS Status;\r
31 FIRMWARE_CONFIG_ITEM FwCfgItem;\r
32 UINTN FwCfgSize;\r
2558bfe3
LE
33\r
34 //\r
35 // If we fail to install any of the necessary protocols below, the OS will be\r
36 // unbootable anyway (due to lacking hardware description), so tolerate no\r
37 // errors here.\r
38 //\r
110316a9
LE
39 if (MAX_UINTN == MAX_UINT64 &&\r
40 !EFI_ERROR (\r
41 QemuFwCfgFindFile (\r
42 "etc/table-loader",\r
43 &FwCfgItem,\r
44 &FwCfgSize\r
45 )\r
46 )) {\r
47 //\r
48 // Only make ACPI available on 64-bit systems, and only if QEMU generates\r
49 // (a subset of) the ACPI tables.\r
50 //\r
2558bfe3
LE
51 Status = gBS->InstallProtocolInterface (\r
52 &ImageHandle,\r
53 &gEdkiiPlatformHasAcpiGuid,\r
54 EFI_NATIVE_INTERFACE,\r
55 NULL\r
56 );\r
57 if (EFI_ERROR (Status)) {\r
58 goto Failed;\r
59 }\r
110316a9
LE
60\r
61 return Status;\r
2558bfe3
LE
62 }\r
63\r
64 //\r
110316a9 65 // Expose the Device Tree otherwise.\r
2558bfe3 66 //\r
110316a9
LE
67 Status = gBS->InstallProtocolInterface (\r
68 &ImageHandle,\r
69 &gEdkiiPlatformHasDeviceTreeGuid,\r
70 EFI_NATIVE_INTERFACE,\r
71 NULL\r
72 );\r
73 if (EFI_ERROR (Status)) {\r
74 goto Failed;\r
2558bfe3
LE
75 }\r
76\r
77 return Status;\r
78\r
79Failed:\r
80 ASSERT_EFI_ERROR (Status);\r
81 CpuDeadLoop ();\r
82 //\r
83 // Keep compilers happy.\r
84 //\r
85 return Status;\r
86}\r