]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmVirtPkg: add PlatformHasAcpiDtDxe
authorLaszlo Ersek <lersek@redhat.com>
Fri, 17 Mar 2017 14:12:28 +0000 (15:12 +0100)
committerLaszlo Ersek <lersek@redhat.com>
Tue, 28 Mar 2017 12:13:25 +0000 (14:13 +0200)
This driver produces the EDKII Platform Has ACPI and Platform Has Device
Tree protocols, exactly matching the current ACPI / DT exposure on QEMU,
according to ARM vs. AARCH64, and (in the latter case) to PcdPureAcpiBoot.

Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Leif Lindholm <leif.lindholm@linaro.org>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
ArmVirtPkg/PlatformHasAcpiDtDxe/PlatformHasAcpiDtDxe.c [new file with mode: 0644]
ArmVirtPkg/PlatformHasAcpiDtDxe/PlatformHasAcpiDtDxe.inf [new file with mode: 0644]

diff --git a/ArmVirtPkg/PlatformHasAcpiDtDxe/PlatformHasAcpiDtDxe.c b/ArmVirtPkg/PlatformHasAcpiDtDxe/PlatformHasAcpiDtDxe.c
new file mode 100644 (file)
index 0000000..a718ce1
--- /dev/null
@@ -0,0 +1,77 @@
+/** @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
diff --git a/ArmVirtPkg/PlatformHasAcpiDtDxe/PlatformHasAcpiDtDxe.inf b/ArmVirtPkg/PlatformHasAcpiDtDxe/PlatformHasAcpiDtDxe.inf
new file mode 100644 (file)
index 0000000..2450500
--- /dev/null
@@ -0,0 +1,47 @@
+## @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