Blame SOURCES/ovmf-ArmVirtPkg-add-PlatformHasAcpiDtDxe.patch

eb7fe6
From ac36ad4d62798a4a9e2275040c0c8d1133e9dd80 Mon Sep 17 00:00:00 2001
eb7fe6
From: Laszlo Ersek <lersek@redhat.com>
eb7fe6
Date: Wed, 29 Mar 2017 12:26:19 +0200
eb7fe6
Subject: [PATCH 07/11] ArmVirtPkg: add PlatformHasAcpiDtDxe
eb7fe6
eb7fe6
Message-id: <20170329102623.11570-8-lersek@redhat.com>
eb7fe6
Patchwork-id: 74576
eb7fe6
O-Subject:  [RHEL-7.4 ovmf PATCH 07/11] ArmVirtPkg: add PlatformHasAcpiDtDxe
eb7fe6
Bugzilla: 1430262
eb7fe6
Acked-by: Andrew Jones <drjones@redhat.com>
eb7fe6
Acked-by: Al Stone <ahs3@redhat.com>
eb7fe6
Acked-by: Vitaly Kuznetsov <vkuznets@redhat.com>
eb7fe6
eb7fe6
This driver produces the EDKII Platform Has ACPI and Platform Has Device
eb7fe6
Tree protocols, exactly matching the current ACPI / DT exposure on QEMU,
eb7fe6
according to ARM vs. AARCH64, and (in the latter case) to PcdPureAcpiBoot.
eb7fe6
eb7fe6
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
eb7fe6
Cc: Leif Lindholm <leif.lindholm@linaro.org>
eb7fe6
Contributed-under: TianoCore Contribution Agreement 1.0
eb7fe6
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
eb7fe6
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
eb7fe6
(cherry picked from commit 2558bfe3e907c6607991b50300cba9eeb04e6f43)
eb7fe6
---
eb7fe6
 .../PlatformHasAcpiDtDxe/PlatformHasAcpiDtDxe.c    | 77 ++++++++++++++++++++++
eb7fe6
 .../PlatformHasAcpiDtDxe/PlatformHasAcpiDtDxe.inf  | 47 +++++++++++++
eb7fe6
 2 files changed, 124 insertions(+)
eb7fe6
 create mode 100644 ArmVirtPkg/PlatformHasAcpiDtDxe/PlatformHasAcpiDtDxe.c
eb7fe6
 create mode 100644 ArmVirtPkg/PlatformHasAcpiDtDxe/PlatformHasAcpiDtDxe.inf
eb7fe6
eb7fe6
diff --git a/ArmVirtPkg/PlatformHasAcpiDtDxe/PlatformHasAcpiDtDxe.c b/ArmVirtPkg/PlatformHasAcpiDtDxe/PlatformHasAcpiDtDxe.c
eb7fe6
new file mode 100644
eb7fe6
index 0000000..a718ce1
eb7fe6
--- /dev/null
eb7fe6
+++ b/ArmVirtPkg/PlatformHasAcpiDtDxe/PlatformHasAcpiDtDxe.c
eb7fe6
@@ -0,0 +1,77 @@
eb7fe6
+/** @file
eb7fe6
+  Decide whether the firmware should expose an ACPI- and/or a Device Tree-based
eb7fe6
+  hardware description to the operating system.
eb7fe6
+
eb7fe6
+  Copyright (c) 2017, Red Hat, Inc.
eb7fe6
+
eb7fe6
+  This program and the accompanying materials are licensed and made available
eb7fe6
+  under the terms and conditions of the BSD License which accompanies this
eb7fe6
+  distribution.  The full text of the license may be found at
eb7fe6
+  http://opensource.org/licenses/bsd-license.php
eb7fe6
+
eb7fe6
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
eb7fe6
+  WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
eb7fe6
+**/
eb7fe6
+
eb7fe6
+#include <Guid/PlatformHasAcpi.h>
eb7fe6
+#include <Guid/PlatformHasDeviceTree.h>
eb7fe6
+#include <Library/BaseLib.h>
eb7fe6
+#include <Library/DebugLib.h>
eb7fe6
+#include <Library/PcdLib.h>
eb7fe6
+#include <Library/UefiBootServicesTableLib.h>
eb7fe6
+
eb7fe6
+EFI_STATUS
eb7fe6
+EFIAPI
eb7fe6
+PlatformHasAcpiDt (
eb7fe6
+  IN EFI_HANDLE       ImageHandle,
eb7fe6
+  IN EFI_SYSTEM_TABLE *SystemTable
eb7fe6
+  )
eb7fe6
+{
eb7fe6
+  EFI_STATUS Status;
eb7fe6
+
eb7fe6
+  Status = EFI_SUCCESS;
eb7fe6
+
eb7fe6
+  //
eb7fe6
+  // If we fail to install any of the necessary protocols below, the OS will be
eb7fe6
+  // unbootable anyway (due to lacking hardware description), so tolerate no
eb7fe6
+  // errors here.
eb7fe6
+  //
eb7fe6
+  // Always make ACPI available on 64-bit systems.
eb7fe6
+  //
eb7fe6
+  if (MAX_UINTN == MAX_UINT64) {
eb7fe6
+    Status = gBS->InstallProtocolInterface (
eb7fe6
+                    &ImageHandle,
eb7fe6
+                    &gEdkiiPlatformHasAcpiGuid,
eb7fe6
+                    EFI_NATIVE_INTERFACE,
eb7fe6
+                    NULL
eb7fe6
+                    );
eb7fe6
+    if (EFI_ERROR (Status)) {
eb7fe6
+      goto Failed;
eb7fe6
+    }
eb7fe6
+  }
eb7fe6
+
eb7fe6
+  //
eb7fe6
+  // Expose the Device Tree unless PcdPureAcpiBoot is set.
eb7fe6
+  //
eb7fe6
+  if (!FeaturePcdGet (PcdPureAcpiBoot)) {
eb7fe6
+    Status = gBS->InstallProtocolInterface (
eb7fe6
+                    &ImageHandle,
eb7fe6
+                    &gEdkiiPlatformHasDeviceTreeGuid,
eb7fe6
+                    EFI_NATIVE_INTERFACE,
eb7fe6
+                    NULL
eb7fe6
+                    );
eb7fe6
+    if (EFI_ERROR (Status)) {
eb7fe6
+      goto Failed;
eb7fe6
+    }
eb7fe6
+  }
eb7fe6
+
eb7fe6
+  return Status;
eb7fe6
+
eb7fe6
+Failed:
eb7fe6
+  ASSERT_EFI_ERROR (Status);
eb7fe6
+  CpuDeadLoop ();
eb7fe6
+  //
eb7fe6
+  // Keep compilers happy.
eb7fe6
+  //
eb7fe6
+  return Status;
eb7fe6
+}
eb7fe6
diff --git a/ArmVirtPkg/PlatformHasAcpiDtDxe/PlatformHasAcpiDtDxe.inf b/ArmVirtPkg/PlatformHasAcpiDtDxe/PlatformHasAcpiDtDxe.inf
eb7fe6
new file mode 100644
eb7fe6
index 0000000..2450500
eb7fe6
--- /dev/null
eb7fe6
+++ b/ArmVirtPkg/PlatformHasAcpiDtDxe/PlatformHasAcpiDtDxe.inf
eb7fe6
@@ -0,0 +1,47 @@
eb7fe6
+## @file
eb7fe6
+# Decide whether the firmware should expose an ACPI- and/or a Device Tree-based
eb7fe6
+# hardware description to the operating system.
eb7fe6
+#
eb7fe6
+# Copyright (c) 2017, Red Hat, Inc.
eb7fe6
+#
eb7fe6
+# This program and the accompanying materials are licensed and made available
eb7fe6
+# under the terms and conditions of the BSD License which accompanies this
eb7fe6
+# distribution.  The full text of the license may be found at
eb7fe6
+# http://opensource.org/licenses/bsd-license.php
eb7fe6
+#
eb7fe6
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT
eb7fe6
+# WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
eb7fe6
+##
eb7fe6
+
eb7fe6
+[Defines]
eb7fe6
+  INF_VERSION                    = 1.25
eb7fe6
+  BASE_NAME                      = PlatformHasAcpiDtDxe
eb7fe6
+  FILE_GUID                      = 9d1dd27f-6d7f-427b-aec4-b62f6279c2f1
eb7fe6
+  MODULE_TYPE                    = DXE_DRIVER
eb7fe6
+  VERSION_STRING                 = 1.0
eb7fe6
+  ENTRY_POINT                    = PlatformHasAcpiDt
eb7fe6
+
eb7fe6
+[Sources]
eb7fe6
+  PlatformHasAcpiDtDxe.c
eb7fe6
+
eb7fe6
+[Packages]
eb7fe6
+  ArmVirtPkg/ArmVirtPkg.dec
eb7fe6
+  EmbeddedPkg/EmbeddedPkg.dec
eb7fe6
+  MdePkg/MdePkg.dec
eb7fe6
+
eb7fe6
+[LibraryClasses]
eb7fe6
+  BaseLib
eb7fe6
+  DebugLib
eb7fe6
+  PcdLib
eb7fe6
+  UefiBootServicesTableLib
eb7fe6
+  UefiDriverEntryPoint
eb7fe6
+
eb7fe6
+[Guids]
eb7fe6
+  gEdkiiPlatformHasAcpiGuid       ## SOMETIMES_PRODUCES ## PROTOCOL
eb7fe6
+  gEdkiiPlatformHasDeviceTreeGuid ## SOMETIMES_PRODUCES ## PROTOCOL
eb7fe6
+
eb7fe6
+[FeaturePcd]
eb7fe6
+  gArmVirtTokenSpaceGuid.PcdPureAcpiBoot ## CONSUMES
eb7fe6
+
eb7fe6
+[Depex]
eb7fe6
+  TRUE
eb7fe6
-- 
eb7fe6
1.8.3.1
eb7fe6