Blame SOURCES/0013-ArmVirtPkg-take-PcdResizeXterm-from-the-QEMU-command.patch

6009e6
From 8338545260fbb423f796d5196faaaf8ff6e1ed99 Mon Sep 17 00:00:00 2001
6009e6
From: Laszlo Ersek <lersek@redhat.com>
6009e6
Date: Sun, 26 Jul 2015 08:02:50 +0000
6009e6
Subject: ArmVirtPkg: take PcdResizeXterm from the QEMU command line (RH only)
6009e6
6009e6
Notes about the RHEL-8.1/20190308-89910a39dcfd [edk2-stable201903] ->
6009e6
RHEL-8.2/20190904-37eef91017ad [edk2-stable201908] rebase:
6009e6
6009e6
- no change
6009e6
6009e6
Notes about the RHEL-8.0/20180508-ee3198e672e2 ->
6009e6
RHEL-8.1/20190308-89910a39dcfd rebase:
6009e6
6009e6
- no change
6009e6
6009e6
Notes about the RHEL-7.6/ovmf-20180508-2.gitee3198e672e2.el7 ->
6009e6
RHEL-8.0/20180508-ee3198e672e2 rebase:
6009e6
6009e6
- reorder the rebase changelog in the commit message so that it reads like
6009e6
  a blog: place more recent entries near the top
6009e6
- no changes to the patch body
6009e6
6009e6
Notes about the 20171011-92d07e48907f -> 20180508-ee3198e672e2 rebase:
6009e6
6009e6
- no change
6009e6
6009e6
Notes about the 20170228-c325e41585e3 -> 20171011-92d07e48907f rebase:
6009e6
6009e6
- Refresh downstream-only commit d4564d39dfdb against context changes in
6009e6
  "ArmVirtPkg/ArmVirtQemu.dsc" from upstream commit 7e5f1b673870
6009e6
  ("ArmVirtPkg/PlatformHasAcpiDtDxe: allow guest level ACPI disable
6009e6
  override", 2017-03-29).
6009e6
6009e6
Notes about the 20160608b-988715a -> 20170228-c325e41585e3 rebase:
6009e6
6009e6
- Adapt commit 6b97969096a3 to the fact that upstream has deprecated such
6009e6
  setter functions for dynamic PCDs that don't return a status code (such
6009e6
  as PcdSetBool()). Employ PcdSetBoolS(), and assert that it succeeds --
6009e6
  there's really no circumstance in this case when it could fail.
6009e6
6009e6
Contributed-under: TianoCore Contribution Agreement 1.0
6009e6
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
6009e6
(cherry picked from commit d4564d39dfdbf74e762af43314005a2c026cb262)
6009e6
(cherry picked from commit c9081ebe3bcd28e5cce4bf58bd8d4fca12f9af7c)
6009e6
(cherry picked from commit 8e92730c8e1cdb642b3b3e680e643ff774a90c65)
6009e6
(cherry picked from commit 9448b6b46267d8d807fac0c648e693171bb34806)
6009e6
(cherry picked from commit 232fcf06f6b3048b7c2ebd6931f23186b3852f04)
6009e6
---
6009e6
 ArmVirtPkg/ArmVirtQemu.dsc                    |  7 +-
6009e6
 .../TerminalPcdProducerLib.c                  | 87 +++++++++++++++++++
6009e6
 .../TerminalPcdProducerLib.inf                | 41 +++++++++
6009e6
 3 files changed, 134 insertions(+), 1 deletion(-)
6009e6
 create mode 100644 ArmVirtPkg/Library/TerminalPcdProducerLib/TerminalPcdProducerLib.c
6009e6
 create mode 100644 ArmVirtPkg/Library/TerminalPcdProducerLib/TerminalPcdProducerLib.inf
6009e6
6009e6
diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc
6009e6
index a3cc3f26ec..696b0b5bcd 100644
6009e6
--- a/ArmVirtPkg/ArmVirtQemu.dsc
6009e6
+++ b/ArmVirtPkg/ArmVirtQemu.dsc
6009e6
@@ -237,6 +237,8 @@
6009e6
   gEfiMdeModulePkgTokenSpaceGuid.PcdSmbiosDocRev|0x0
6009e6
   gUefiOvmfPkgTokenSpaceGuid.PcdQemuSmbiosValidated|FALSE
6009e6
 
6009e6
+  gEfiMdeModulePkgTokenSpaceGuid.PcdResizeXterm|FALSE
6009e6
+
6009e6
 [PcdsDynamicHii]
6009e6
   gArmVirtTokenSpaceGuid.PcdForceNoAcpi|L"ForceNoAcpi"|gArmVirtVariableGuid|0x0|FALSE|NV,BS
6009e6
 
6009e6
@@ -314,7 +316,10 @@
6009e6
   MdeModulePkg/Universal/Console/ConPlatformDxe/ConPlatformDxe.inf
6009e6
   MdeModulePkg/Universal/Console/ConSplitterDxe/ConSplitterDxe.inf
6009e6
   MdeModulePkg/Universal/Console/GraphicsConsoleDxe/GraphicsConsoleDxe.inf
6009e6
-  MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf
6009e6
+  MdeModulePkg/Universal/Console/TerminalDxe/TerminalDxe.inf {
6009e6
+    <LibraryClasses>
6009e6
+      NULL|ArmVirtPkg/Library/TerminalPcdProducerLib/TerminalPcdProducerLib.inf
6009e6
+  }
6009e6
   MdeModulePkg/Universal/SerialDxe/SerialDxe.inf
6009e6
 
6009e6
   MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
6009e6
diff --git a/ArmVirtPkg/Library/TerminalPcdProducerLib/TerminalPcdProducerLib.c b/ArmVirtPkg/Library/TerminalPcdProducerLib/TerminalPcdProducerLib.c
6009e6
new file mode 100644
6009e6
index 0000000000..814ad48199
6009e6
--- /dev/null
6009e6
+++ b/ArmVirtPkg/Library/TerminalPcdProducerLib/TerminalPcdProducerLib.c
6009e6
@@ -0,0 +1,87 @@
6009e6
+/** @file
6009e6
+*  Plugin library for setting up dynamic PCDs for TerminalDxe, from fw_cfg
6009e6
+*
6009e6
+*  Copyright (C) 2015-2016, Red Hat, Inc.
6009e6
+*  Copyright (c) 2014, Linaro Ltd. All rights reserved.
6009e6
+*
6009e6
+*  This program and the accompanying materials are licensed and made available
6009e6
+*  under the terms and conditions of the BSD License which accompanies this
6009e6
+*  distribution.  The full text of the license may be found at
6009e6
+*  http://opensource.org/licenses/bsd-license.php
6009e6
+*
6009e6
+*  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
6009e6
+*  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR
6009e6
+*  IMPLIED.
6009e6
+*
6009e6
+**/
6009e6
+
6009e6
+#include <Library/DebugLib.h>
6009e6
+#include <Library/PcdLib.h>
6009e6
+#include <Library/QemuFwCfgLib.h>
6009e6
+
6009e6
+STATIC
6009e6
+RETURN_STATUS
6009e6
+GetNamedFwCfgBoolean (
6009e6
+  IN  CONST CHAR8 *FwCfgFileName,
6009e6
+  OUT BOOLEAN     *Setting
6009e6
+  )
6009e6
+{
6009e6
+  RETURN_STATUS        Status;
6009e6
+  FIRMWARE_CONFIG_ITEM FwCfgItem;
6009e6
+  UINTN                FwCfgSize;
6009e6
+  UINT8                Value[3];
6009e6
+
6009e6
+  Status = QemuFwCfgFindFile (FwCfgFileName, &FwCfgItem, &FwCfgSize);
6009e6
+  if (RETURN_ERROR (Status)) {
6009e6
+    return Status;
6009e6
+  }
6009e6
+  if (FwCfgSize > sizeof Value) {
6009e6
+    return RETURN_BAD_BUFFER_SIZE;
6009e6
+  }
6009e6
+  QemuFwCfgSelectItem (FwCfgItem);
6009e6
+  QemuFwCfgReadBytes (FwCfgSize, Value);
6009e6
+
6009e6
+  if ((FwCfgSize == 1) ||
6009e6
+      (FwCfgSize == 2 && Value[1] == '\n') ||
6009e6
+      (FwCfgSize == 3 && Value[1] == '\r' && Value[2] == '\n')) {
6009e6
+    switch (Value[0]) {
6009e6
+      case '0':
6009e6
+      case 'n':
6009e6
+      case 'N':
6009e6
+        *Setting = FALSE;
6009e6
+        return RETURN_SUCCESS;
6009e6
+
6009e6
+      case '1':
6009e6
+      case 'y':
6009e6
+      case 'Y':
6009e6
+        *Setting = TRUE;
6009e6
+        return RETURN_SUCCESS;
6009e6
+
6009e6
+      default:
6009e6
+        break;
6009e6
+    }
6009e6
+  }
6009e6
+  return RETURN_PROTOCOL_ERROR;
6009e6
+}
6009e6
+
6009e6
+#define UPDATE_BOOLEAN_PCD_FROM_FW_CFG(TokenName)                             \
6009e6
+          do {                                                                \
6009e6
+            BOOLEAN       Setting;                                            \
6009e6
+            RETURN_STATUS PcdStatus;                                          \
6009e6
+                                                                              \
6009e6
+            if (!RETURN_ERROR (GetNamedFwCfgBoolean (                         \
6009e6
+                    "opt/org.tianocore.edk2.aavmf/" #TokenName, &Setting))) { \
6009e6
+              PcdStatus = PcdSetBoolS (TokenName, Setting);                   \
6009e6
+              ASSERT_RETURN_ERROR (PcdStatus);                                \
6009e6
+            }                                                                 \
6009e6
+          } while (0)
6009e6
+
6009e6
+RETURN_STATUS
6009e6
+EFIAPI
6009e6
+TerminalPcdProducerLibConstructor (
6009e6
+  VOID
6009e6
+  )
6009e6
+{
6009e6
+  UPDATE_BOOLEAN_PCD_FROM_FW_CFG (PcdResizeXterm);
6009e6
+  return RETURN_SUCCESS;
6009e6
+}
6009e6
diff --git a/ArmVirtPkg/Library/TerminalPcdProducerLib/TerminalPcdProducerLib.inf b/ArmVirtPkg/Library/TerminalPcdProducerLib/TerminalPcdProducerLib.inf
6009e6
new file mode 100644
6009e6
index 0000000000..fecb37bcdf
6009e6
--- /dev/null
6009e6
+++ b/ArmVirtPkg/Library/TerminalPcdProducerLib/TerminalPcdProducerLib.inf
6009e6
@@ -0,0 +1,41 @@
6009e6
+## @file
6009e6
+#  Plugin library for setting up dynamic PCDs for TerminalDxe, from fw_cfg
6009e6
+#
6009e6
+#  Copyright (C) 2015-2016, Red Hat, Inc.
6009e6
+#  Copyright (c) 2014, Linaro Ltd. All rights reserved.
6009e6
+#
6009e6
+#  This program and the accompanying materials are licensed and made available
6009e6
+#  under the terms and conditions of the BSD License which accompanies this
6009e6
+#  distribution.  The full text of the license may be found at
6009e6
+#  http://opensource.org/licenses/bsd-license.php
6009e6
+#
6009e6
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
6009e6
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR
6009e6
+#  IMPLIED.
6009e6
+#
6009e6
+##
6009e6
+
6009e6
+[Defines]
6009e6
+  INF_VERSION                    = 0x00010005
6009e6
+  BASE_NAME                      = TerminalPcdProducerLib
6009e6
+  FILE_GUID                      = 4a0c5ed7-8c42-4c01-8f4c-7bf258316a96
6009e6
+  MODULE_TYPE                    = BASE
6009e6
+  VERSION_STRING                 = 1.0
6009e6
+  LIBRARY_CLASS                  = TerminalPcdProducerLib|DXE_DRIVER
6009e6
+  CONSTRUCTOR                    = TerminalPcdProducerLibConstructor
6009e6
+
6009e6
+[Sources]
6009e6
+  TerminalPcdProducerLib.c
6009e6
+
6009e6
+[Packages]
6009e6
+  MdePkg/MdePkg.dec
6009e6
+  OvmfPkg/OvmfPkg.dec
6009e6
+  MdeModulePkg/MdeModulePkg.dec
6009e6
+
6009e6
+[LibraryClasses]
6009e6
+  DebugLib
6009e6
+  PcdLib
6009e6
+  QemuFwCfgLib
6009e6
+
6009e6
+[Pcd]
6009e6
+  gEfiMdeModulePkgTokenSpaceGuid.PcdResizeXterm
6009e6
-- 
6009e6
2.18.1
6009e6