]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - ArmVirtPkg/PlatformHasAcpiDtDxe/PlatformHasAcpiDtDxe.c
Maintainers.txt: Update email address
[mirror_edk2.git] / ArmVirtPkg / PlatformHasAcpiDtDxe / PlatformHasAcpiDtDxe.c
... / ...
CommitLineData
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 SPDX-License-Identifier: BSD-2-Clause-Patent\r
8**/\r
9\r
10#include <Guid/PlatformHasAcpi.h>\r
11#include <Guid/PlatformHasDeviceTree.h>\r
12#include <Library/BaseLib.h>\r
13#include <Library/DebugLib.h>\r
14#include <Library/PcdLib.h>\r
15#include <Library/QemuFwCfgLib.h>\r
16#include <Library/UefiBootServicesTableLib.h>\r
17\r
18EFI_STATUS\r
19EFIAPI\r
20PlatformHasAcpiDt (\r
21 IN EFI_HANDLE ImageHandle,\r
22 IN EFI_SYSTEM_TABLE *SystemTable\r
23 )\r
24{\r
25 EFI_STATUS Status;\r
26 FIRMWARE_CONFIG_ITEM FwCfgItem;\r
27 UINTN FwCfgSize;\r
28\r
29 //\r
30 // If we fail to install any of the necessary protocols below, the OS will be\r
31 // unbootable anyway (due to lacking hardware description), so tolerate no\r
32 // errors here.\r
33 //\r
34 if ((MAX_UINTN == MAX_UINT64) &&\r
35 !PcdGetBool (PcdForceNoAcpi) &&\r
36 !EFI_ERROR (\r
37 QemuFwCfgFindFile (\r
38 "etc/table-loader",\r
39 &FwCfgItem,\r
40 &FwCfgSize\r
41 )\r
42 ))\r
43 {\r
44 //\r
45 // Only make ACPI available on 64-bit systems, and only if QEMU generates\r
46 // (a subset of) the ACPI tables.\r
47 //\r
48 Status = gBS->InstallProtocolInterface (\r
49 &ImageHandle,\r
50 &gEdkiiPlatformHasAcpiGuid,\r
51 EFI_NATIVE_INTERFACE,\r
52 NULL\r
53 );\r
54 if (EFI_ERROR (Status)) {\r
55 goto Failed;\r
56 }\r
57\r
58 return Status;\r
59 }\r
60\r
61 //\r
62 // Expose the Device Tree otherwise.\r
63 //\r
64 Status = gBS->InstallProtocolInterface (\r
65 &ImageHandle,\r
66 &gEdkiiPlatformHasDeviceTreeGuid,\r
67 EFI_NATIVE_INTERFACE,\r
68 NULL\r
69 );\r
70 if (EFI_ERROR (Status)) {\r
71 goto Failed;\r
72 }\r
73\r
74 return Status;\r
75\r
76Failed:\r
77 ASSERT_EFI_ERROR (Status);\r
78 CpuDeadLoop ();\r
79 //\r
80 // Keep compilers happy.\r
81 //\r
82 return Status;\r
83}\r