--- /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) 2021, Arm Limited. All rights reserved.<BR>\r
+\r
+ SPDX-License-Identifier: BSD-2-Clause-Patent\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
+/** Entry point for the Cloud Hypervisor PlatformHasAcpiDtDxe.\r
+\r
+ @param [in] ImageHandle Handle for this image.\r
+ @param [in] SystemTable Pointer to the EFI system table.\r
+\r
+ @return EFI_SUCCESS If ACPI or Device Tree based hardware\r
+ description protocol was installed.\r
+ @return EFI_INVALID_PARAMETER A parameter was invalid.\r
+ @return EFI_OUT_OF_RESOURCES Insufficient resources exist to complete\r
+ the request.\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
+ //\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
+ if (MAX_UINTN == MAX_UINT64 &&\r
+ !PcdGetBool (PcdForceNoAcpi)) {\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
+ return Status;\r
+ }\r
+\r
+ //\r
+ // Expose the Device Tree otherwise.\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) 2021, Arm Limited. All rights reserved.<BR>\r
+#\r
+# SPDX-License-Identifier: BSD-2-Clause-Patent\r
+##\r
+\r
+[Defines]\r
+ INF_VERSION = 0x0001001B\r
+ BASE_NAME = CloudHvPlatformHasAcpiDtDxe\r
+ FILE_GUID = 71fe72f9-6dc1-199d-5054-13b4200ee88d\r
+ MODULE_TYPE = DXE_DRIVER\r
+ VERSION_STRING = 1.0\r
+ ENTRY_POINT = PlatformHasAcpiDt\r
+\r
+[Sources]\r
+ CloudHvHasAcpiDtDxe.c\r
+\r
+[Packages]\r
+ ArmVirtPkg/ArmVirtPkg.dec\r
+ EmbeddedPkg/EmbeddedPkg.dec\r
+ MdeModulePkg/MdeModulePkg.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
+[Pcd]\r
+ gArmVirtTokenSpaceGuid.PcdForceNoAcpi\r
+\r
+[Depex]\r
+ gEfiVariableArchProtocolGuid\r