+/** @file\r
+\r
+ The KvmtoolPlatformDxe performs the platform specific initialization like:\r
+ - It decides if the firmware should expose ACPI or Device Tree-based\r
+ hardware description to the operating system.\r
+\r
+ Copyright (c) 2018 - 2020, ARM Limited. All rights reserved.\r
+\r
+ SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+\r
+#include <Guid/VariableFormat.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Protocol/FdtClient.h>\r
+\r
+/** Decide if the firmware should expose ACPI tables or Device Tree and\r
+ install the appropriate protocol interface.\r
+\r
+ Note: This function is derived from "ArmVirtPkg/PlatformHasAcpiDtDxe",\r
+ by dropping the word size check, and the fw_cfg check.\r
+\r
+ @param [in] ImageHandle Handle for this image.\r
+\r
+ @retval EFI_SUCCESS Success.\r
+ @retval EFI_OUT_OF_RESOURCES There was not enough memory to install the\r
+ protocols.\r
+ @retval EFI_INVALID_PARAMETER A parameter is invalid.\r
+\r
+**/\r
+STATIC\r
+EFI_STATUS\r
+PlatformHasAcpiDt (\r
+ IN EFI_HANDLE ImageHandle\r
+ )\r
+{\r
+ if (!PcdGetBool (PcdForceNoAcpi)) {\r
+ // Expose ACPI tables\r
+ return gBS->InstallProtocolInterface (\r
+ &ImageHandle,\r
+ &gEdkiiPlatformHasAcpiGuid,\r
+ EFI_NATIVE_INTERFACE,\r
+ NULL\r
+ );\r
+ }\r
+\r
+ // Expose the Device Tree.\r
+ return gBS->InstallProtocolInterface (\r
+ &ImageHandle,\r
+ &gEdkiiPlatformHasDeviceTreeGuid,\r
+ EFI_NATIVE_INTERFACE,\r
+ NULL\r
+ );\r
+}\r
+\r
+/** Entry point for Kvmtool Platform Dxe\r
+\r
+ @param [in] ImageHandle Handle for this image.\r
+ @param [in] SystemTable Pointer to the EFI system table.\r
+\r
+ @retval EFI_SUCCESS Success.\r
+ @retval EFI_OUT_OF_RESOURCES There was not enough memory to install the\r
+ protocols.\r
+ @retval EFI_INVALID_PARAMETER A parameter is invalid.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+KvmtoolPlatformDxeEntryPoint (\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN EFI_SYSTEM_TABLE *SystemTable\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ Status = PlatformHasAcpiDt (ImageHandle);\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ return Status;\r
+}\r