--- /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/UefiBootServicesTableLib.h>\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+XenPlatformHasAcpiDt (\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN EFI_SYSTEM_TABLE *SystemTable\r
+ )\r
+{\r
+ EFI_STATUS Status;\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 unconditionally.\r
+ //\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
+ 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 = XenPlatformHasAcpiDtDxe\r
+ FILE_GUID = 6914c46f-d46e-48dc-9998-8a5f64f02553\r
+ MODULE_TYPE = DXE_DRIVER\r
+ VERSION_STRING = 1.0\r
+ ENTRY_POINT = XenPlatformHasAcpiDt\r
+\r
+[Sources]\r
+ XenPlatformHasAcpiDtDxe.c\r
+\r
+[Packages]\r
+ EmbeddedPkg/EmbeddedPkg.dec\r
+ MdePkg/MdePkg.dec\r
+\r
+[LibraryClasses]\r
+ BaseLib\r
+ DebugLib\r
+ UefiBootServicesTableLib\r
+ UefiDriverEntryPoint\r
+\r
+[Guids]\r
+ gEdkiiPlatformHasAcpiGuid ## SOMETIMES_PRODUCES ## PROTOCOL\r
+ gEdkiiPlatformHasDeviceTreeGuid ## PRODUCES ## PROTOCOL\r
+\r
+[Depex]\r
+ TRUE\r