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

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