--- /dev/null
+/** @file\r
+ Decide whether the firmware should expose an ACPI- and/or a Device Tree-based\r
+ hardware description to the operating system.\r
+\r
+ Copyright (c) 2017, Red Hat, Inc.\r
+\r
+ This program and the accompanying materials are licensed and made available\r
+ under the terms and conditions of the BSD License which accompanies this\r
+ distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT\r
+ WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+**/\r
+\r
+#include <Guid/PlatformHasAcpi.h>\r
+#include <Guid/PlatformHasDeviceTree.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+PlatformHasAcpiDt (\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN EFI_SYSTEM_TABLE *SystemTable\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ Status = EFI_SUCCESS;\r
+\r
+ //\r
+ // If we fail to install any of the necessary protocols below, the OS will be\r
+ // unbootable anyway (due to lacking hardware description), so tolerate no\r
+ // errors here.\r
+ //\r
+ // Always make ACPI available on 64-bit systems.\r
+ //\r
+ if (MAX_UINTN == MAX_UINT64) {\r
+ Status = gBS->InstallProtocolInterface (\r
+ &ImageHandle,\r
+ &gEdkiiPlatformHasAcpiGuid,\r
+ EFI_NATIVE_INTERFACE,\r
+ NULL\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ goto Failed;\r
+ }\r
+ }\r
+\r
+ //\r
+ // Expose the Device Tree unless PcdPureAcpiBoot is set.\r
+ //\r
+ if (!FeaturePcdGet (PcdPureAcpiBoot)) {\r
+ Status = gBS->InstallProtocolInterface (\r
+ &ImageHandle,\r
+ &gEdkiiPlatformHasDeviceTreeGuid,\r
+ EFI_NATIVE_INTERFACE,\r
+ NULL\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ goto Failed;\r
+ }\r
+ }\r
+\r
+ return Status;\r
+\r
+Failed:\r
+ ASSERT_EFI_ERROR (Status);\r
+ CpuDeadLoop ();\r
+ //\r
+ // Keep compilers happy.\r
+ //\r
+ return Status;\r
+}\r
--- /dev/null
+## @file\r
+# Decide whether the firmware should expose an ACPI- and/or a Device Tree-based\r
+# hardware description to the operating system.\r
+#\r
+# Copyright (c) 2017, Red Hat, Inc.\r
+#\r
+# This program and the accompanying materials are licensed and made available\r
+# under the terms and conditions of the BSD License which accompanies this\r
+# distribution. The full text of the license may be found at\r
+# http://opensource.org/licenses/bsd-license.php\r
+#\r
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT\r
+# WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+##\r
+\r
+[Defines]\r
+ INF_VERSION = 1.25\r
+ BASE_NAME = PlatformHasAcpiDtDxe\r
+ FILE_GUID = 9d1dd27f-6d7f-427b-aec4-b62f6279c2f1\r
+ MODULE_TYPE = DXE_DRIVER\r
+ VERSION_STRING = 1.0\r
+ ENTRY_POINT = PlatformHasAcpiDt\r
+\r
+[Sources]\r
+ PlatformHasAcpiDtDxe.c\r
+\r
+[Packages]\r
+ ArmVirtPkg/ArmVirtPkg.dec\r
+ EmbeddedPkg/EmbeddedPkg.dec\r
+ MdePkg/MdePkg.dec\r
+\r
+[LibraryClasses]\r
+ BaseLib\r
+ DebugLib\r
+ PcdLib\r
+ UefiBootServicesTableLib\r
+ UefiDriverEntryPoint\r
+\r
+[Guids]\r
+ gEdkiiPlatformHasAcpiGuid ## SOMETIMES_PRODUCES ## PROTOCOL\r
+ gEdkiiPlatformHasDeviceTreeGuid ## SOMETIMES_PRODUCES ## PROTOCOL\r
+\r
+[FeaturePcd]\r
+ gArmVirtTokenSpaceGuid.PcdPureAcpiBoot ## CONSUMES\r
+\r
+[Depex]\r
+ TRUE\r