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

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