]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmVirtPkg: Add PlatformHasAcpiDtDxe for Cloud Hypervisor
authorJianyong Wu <jianyong.wu@arm.com>
Mon, 5 Jul 2021 10:06:39 +0000 (18:06 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Wed, 7 Jul 2021 16:41:37 +0000 (16:41 +0000)
The ArmVirtPkg\PlatformHasAcpiDtDxe implementation is not common
and is specific for Qemu. So add a Cloud Hypervisor specific
version that decides whether the firmware should expose an ACPI
based or a Device Tree based hardware description to an operating
system.

Cc: Laszlo Ersek <lersek@redhat.com>
Cc: Sami Mujawar <sami.mujawar@arm.com>
Signed-off-by: Jianyong Wu <jianyong.wu@arm.com>
Reviewed-by: Sami Mujawar <sami.mujawar@arm.com>
ArmVirtPkg/CloudHvPlatformHasAcpiDtDxe/CloudHvHasAcpiDtDxe.c [new file with mode: 0644]
ArmVirtPkg/CloudHvPlatformHasAcpiDtDxe/CloudHvHasAcpiDtDxe.inf [new file with mode: 0644]

diff --git a/ArmVirtPkg/CloudHvPlatformHasAcpiDtDxe/CloudHvHasAcpiDtDxe.c b/ArmVirtPkg/CloudHvPlatformHasAcpiDtDxe/CloudHvHasAcpiDtDxe.c
new file mode 100644 (file)
index 0000000..4cf1d39
--- /dev/null
@@ -0,0 +1,79 @@
+/** @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
diff --git a/ArmVirtPkg/CloudHvPlatformHasAcpiDtDxe/CloudHvHasAcpiDtDxe.inf b/ArmVirtPkg/CloudHvPlatformHasAcpiDtDxe/CloudHvHasAcpiDtDxe.inf
new file mode 100644 (file)
index 0000000..4af06b2
--- /dev/null
@@ -0,0 +1,42 @@
+## @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