]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmVirtPkg: add XenPlatformHasAcpiDtDxe
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:17:04 +0000 (14:17 +0200)
This driver produces the EDKII Platform Has ACPI and Platform Has Device
Tree protocols, exactly matching the current ACPI / DT exposure on Xen,
according to ARM vs. AARCH64. At this point it differs from the QEMU
driver PlatformHasAcpiDtDxe in that this one always installs the DT.

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/XenPlatformHasAcpiDtDxe/XenPlatformHasAcpiDtDxe.c [new file with mode: 0644]
ArmVirtPkg/XenPlatformHasAcpiDtDxe/XenPlatformHasAcpiDtDxe.inf [new file with mode: 0644]

diff --git a/ArmVirtPkg/XenPlatformHasAcpiDtDxe/XenPlatformHasAcpiDtDxe.c b/ArmVirtPkg/XenPlatformHasAcpiDtDxe/XenPlatformHasAcpiDtDxe.c
new file mode 100644 (file)
index 0000000..596f4ea
--- /dev/null
@@ -0,0 +1,72 @@
+/** @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
diff --git a/ArmVirtPkg/XenPlatformHasAcpiDtDxe/XenPlatformHasAcpiDtDxe.inf b/ArmVirtPkg/XenPlatformHasAcpiDtDxe/XenPlatformHasAcpiDtDxe.inf
new file mode 100644 (file)
index 0000000..2833075
--- /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) 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