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

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