render / rpms / edk2

Forked from rpms/edk2 3 months ago
Clone

Blame 0023-OvmfPkg-create-a-separate-PlatformDebugLibIoPort-ins.patch

Paolo Bonzini 2e34e0
From ba774b89b5a206c71a2ce0db8184747fac0f6af7 Mon Sep 17 00:00:00 2001
Paolo Bonzini 2e34e0
From: Paolo Bonzini <pbonzini@redhat.com>
Paolo Bonzini 2e34e0
Date: Thu, 16 Nov 2017 10:33:29 +0100
Paolo Bonzini 2e34e0
Subject: [PATCH 2/3] OvmfPkg: create a separate PlatformDebugLibIoPort
Paolo Bonzini 2e34e0
 instance for SEC
Paolo Bonzini 2e34e0
Paolo Bonzini 2e34e0
The next patch will want to add a global variable to
Paolo Bonzini 2e34e0
PlatformDebugLibIoPort, but this is not suitable for the SEC
Paolo Bonzini 2e34e0
phase, because SEC runs from read-only flash.  The solution is
Paolo Bonzini 2e34e0
to have two library instances, one for SEC and another
Paolo Bonzini 2e34e0
for all other firmware phases.  This patch adds the "plumbing"
Paolo Bonzini 2e34e0
for the SEC library instance, separating the INF files and
Paolo Bonzini 2e34e0
moving the constructor to a separate C source file.
Paolo Bonzini 2e34e0
Paolo Bonzini 2e34e0
Contributed-under: TianoCore Contribution Agreement 1.1
Paolo Bonzini 2e34e0
Cc: Laszlo Ersek <lersek@redhat.com>
Paolo Bonzini 2e34e0
Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Paolo Bonzini 2e34e0
Cc: Jordan Justen (Intel address) <jordan.l.justen@intel.com>
Paolo Bonzini 2e34e0
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Paolo Bonzini 2e34e0
---
Paolo Bonzini 2e34e0
 OvmfPkg/OvmfPkgIa32.dsc                            |  2 +-
Paolo Bonzini 2e34e0
 OvmfPkg/OvmfPkgIa32X64.dsc                         |  2 +-
Paolo Bonzini 2e34e0
 OvmfPkg/OvmfPkgX64.dsc                             |  2 +-
Paolo Bonzini 2e34e0
 .../PlatformDebugLibIoPort.inf                     |  3 +-
Paolo Bonzini 2e34e0
 .../PlatformRomDebugLibIoPort.inf                  | 52 ++++++++++++++++++++++
Paolo Bonzini 2e34e0
 OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c  | 15 -------
Paolo Bonzini 2e34e0
 .../PlatformDebugLibIoPort/DebugLibDetect.c        | 31 +++++++++++++
Paolo Bonzini 2e34e0
 .../PlatformDebugLibIoPort/DebugLibDetectRom.c     | 31 +++++++++++++
Paolo Bonzini 2e34e0
 8 files changed, 119 insertions(+), 19 deletions(-)
Paolo Bonzini 2e34e0
 create mode 100644 OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPort.inf
Paolo Bonzini 2e34e0
 create mode 100644 OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetect.c
Paolo Bonzini 2e34e0
 create mode 100644 OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetectRom.c
Paolo Bonzini 2e34e0
Paolo Bonzini 2e34e0
diff --git a/OvmfPkg/OvmfPkgIa32.dsc b/OvmfPkg/OvmfPkgIa32.dsc
Paolo Bonzini 2e34e0
index c2f534fdbf..7ccb61147f 100644
Paolo Bonzini 2e34e0
--- a/OvmfPkg/OvmfPkgIa32.dsc
Paolo Bonzini 2e34e0
+++ b/OvmfPkg/OvmfPkgIa32.dsc
Paolo Bonzini 2e34e0
@@ -207,7 +207,7 @@ [LibraryClasses.common.SEC]
Paolo Bonzini 2e34e0
 !ifdef $(DEBUG_ON_SERIAL_PORT)
Paolo Bonzini 2e34e0
   DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
Paolo Bonzini 2e34e0
 !else
Paolo Bonzini 2e34e0
-  DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf
Paolo Bonzini 2e34e0
+  DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPort.inf
Paolo Bonzini 2e34e0
 !endif
Paolo Bonzini 2e34e0
   ReportStatusCodeLib|MdeModulePkg/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf
Paolo Bonzini 2e34e0
   ExtractGuidedSectionLib|MdePkg/Library/BaseExtractGuidedSectionLib/BaseExtractGuidedSectionLib.inf
Paolo Bonzini 2e34e0
diff --git a/OvmfPkg/OvmfPkgIa32X64.dsc b/OvmfPkg/OvmfPkgIa32X64.dsc
Paolo Bonzini 2e34e0
index 9f300a2e6f..237ec71b5e 100644
Paolo Bonzini 2e34e0
--- a/OvmfPkg/OvmfPkgIa32X64.dsc
Paolo Bonzini 2e34e0
+++ b/OvmfPkg/OvmfPkgIa32X64.dsc
Paolo Bonzini 2e34e0
@@ -212,7 +212,7 @@ [LibraryClasses.common.SEC]
Paolo Bonzini 2e34e0
 !ifdef $(DEBUG_ON_SERIAL_PORT)
Paolo Bonzini 2e34e0
   DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
Paolo Bonzini 2e34e0
 !else
Paolo Bonzini 2e34e0
-  DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf
Paolo Bonzini 2e34e0
+  DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPort.inf
Paolo Bonzini 2e34e0
 !endif
Paolo Bonzini 2e34e0
   ReportStatusCodeLib|MdeModulePkg/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf
Paolo Bonzini 2e34e0
   ExtractGuidedSectionLib|MdePkg/Library/BaseExtractGuidedSectionLib/BaseExtractGuidedSectionLib.inf
Paolo Bonzini 2e34e0
diff --git a/OvmfPkg/OvmfPkgX64.dsc b/OvmfPkg/OvmfPkgX64.dsc
Paolo Bonzini 2e34e0
index 1ffcf37f8b..a5047fa38e 100644
Paolo Bonzini 2e34e0
--- a/OvmfPkg/OvmfPkgX64.dsc
Paolo Bonzini 2e34e0
+++ b/OvmfPkg/OvmfPkgX64.dsc
Paolo Bonzini 2e34e0
@@ -212,7 +212,7 @@ [LibraryClasses.common.SEC]
Paolo Bonzini 2e34e0
 !ifdef $(DEBUG_ON_SERIAL_PORT)
Paolo Bonzini 2e34e0
   DebugLib|MdePkg/Library/BaseDebugLibSerialPort/BaseDebugLibSerialPort.inf
Paolo Bonzini 2e34e0
 !else
Paolo Bonzini 2e34e0
-  DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf
Paolo Bonzini 2e34e0
+  DebugLib|OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPort.inf
Paolo Bonzini 2e34e0
 !endif
Paolo Bonzini 2e34e0
   ReportStatusCodeLib|MdeModulePkg/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf
Paolo Bonzini 2e34e0
   ExtractGuidedSectionLib|MdePkg/Library/BaseExtractGuidedSectionLib/BaseExtractGuidedSectionLib.inf
Paolo Bonzini 2e34e0
diff --git a/OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf b/OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf
Paolo Bonzini 2e34e0
index 0e74fe94cb..de3c2f542b 100644
Paolo Bonzini 2e34e0
--- a/OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf
Paolo Bonzini 2e34e0
+++ b/OvmfPkg/Library/PlatformDebugLibIoPort/PlatformDebugLibIoPort.inf
Paolo Bonzini 2e34e0
@@ -21,7 +21,7 @@ [Defines]
Paolo Bonzini 2e34e0
   FILE_GUID                      = DF934DA3-CD31-49FE-AF50-B3C87C79325F
Paolo Bonzini 2e34e0
   MODULE_TYPE                    = BASE
Paolo Bonzini 2e34e0
   VERSION_STRING                 = 1.0
Paolo Bonzini 2e34e0
-  LIBRARY_CLASS                  = DebugLib
Paolo Bonzini 2e34e0
+  LIBRARY_CLASS                  = DebugLib|PEI_CORE PEIM DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER SMM_CORE DXE_SMM_DRIVER UEFI_DRIVER UEFI_APPLICATION
Paolo Bonzini 2e34e0
   CONSTRUCTOR                    = PlatformDebugLibIoPortConstructor
Paolo Bonzini 2e34e0
 
Paolo Bonzini 2e34e0
 #
Paolo Bonzini 2e34e0
@@ -30,6 +30,7 @@ [Defines]
Paolo Bonzini 2e34e0
 
Paolo Bonzini 2e34e0
 [Sources]
Paolo Bonzini 2e34e0
   DebugLib.c
Paolo Bonzini 2e34e0
+  DebugLibDetect.c
Paolo Bonzini 2e34e0
 
Paolo Bonzini 2e34e0
 [Packages]
Paolo Bonzini 2e34e0
   MdePkg/MdePkg.dec
Paolo Bonzini 2e34e0
diff --git a/OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPort.inf b/OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPort.inf
Paolo Bonzini 2e34e0
new file mode 100644
Paolo Bonzini 2e34e0
index 0000000000..491c0318de
Paolo Bonzini 2e34e0
--- /dev/null
Paolo Bonzini 2e34e0
+++ b/OvmfPkg/Library/PlatformDebugLibIoPort/PlatformRomDebugLibIoPort.inf
Paolo Bonzini 2e34e0
@@ -0,0 +1,52 @@
Paolo Bonzini 2e34e0
+## @file
Paolo Bonzini 2e34e0
+#  Instance of Debug Library for the QEMU debug console port.
Paolo Bonzini 2e34e0
+#  It uses Print Library to produce formatted output strings.
Paolo Bonzini 2e34e0
+#
Paolo Bonzini 2e34e0
+#  Copyright (c) 2006 - 2015, Intel Corporation. All rights reserved.
Paolo Bonzini 2e34e0
+#  Copyright (c) 2017, Red Hat, Inc.
Paolo Bonzini 2e34e0
+#
Paolo Bonzini 2e34e0
+#  This program and the accompanying materials
Paolo Bonzini 2e34e0
+#  are licensed and made available under the terms and conditions of the BSD License
Paolo Bonzini 2e34e0
+#  which accompanies this distribution. The full text of the license may be found at
Paolo Bonzini 2e34e0
+#  http://opensource.org/licenses/bsd-license.php.
Paolo Bonzini 2e34e0
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
Paolo Bonzini 2e34e0
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Paolo Bonzini 2e34e0
+#
Paolo Bonzini 2e34e0
+#
Paolo Bonzini 2e34e0
+##
Paolo Bonzini 2e34e0
+
Paolo Bonzini 2e34e0
+[Defines]
Paolo Bonzini 2e34e0
+  INF_VERSION                    = 0x00010005
Paolo Bonzini 2e34e0
+  BASE_NAME                      = PlatformRomDebugLibIoPort
Paolo Bonzini 2e34e0
+  FILE_GUID                      = CEB0D9D3-328F-4C24-8C02-28FA1986AE1B
Paolo Bonzini 2e34e0
+  MODULE_TYPE                    = BASE
Paolo Bonzini 2e34e0
+  VERSION_STRING                 = 1.0
Paolo Bonzini 2e34e0
+  LIBRARY_CLASS                  = DebugLib|SEC
Paolo Bonzini 2e34e0
+  CONSTRUCTOR                    = PlatformRomDebugLibIoPortConstructor
Paolo Bonzini 2e34e0
+
Paolo Bonzini 2e34e0
+#
Paolo Bonzini 2e34e0
+#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC
Paolo Bonzini 2e34e0
+#
Paolo Bonzini 2e34e0
+
Paolo Bonzini 2e34e0
+[Sources]
Paolo Bonzini 2e34e0
+  DebugLib.c
Paolo Bonzini 2e34e0
+  DebugLibDetectRom.c
Paolo Bonzini 2e34e0
+
Paolo Bonzini 2e34e0
+[Packages]
Paolo Bonzini 2e34e0
+  MdePkg/MdePkg.dec
Paolo Bonzini 2e34e0
+  OvmfPkg/OvmfPkg.dec
Paolo Bonzini 2e34e0
+
Paolo Bonzini 2e34e0
+[LibraryClasses]
Paolo Bonzini 2e34e0
+  BaseMemoryLib
Paolo Bonzini 2e34e0
+  IoLib
Paolo Bonzini 2e34e0
+  PcdLib
Paolo Bonzini 2e34e0
+  PrintLib
Paolo Bonzini 2e34e0
+  BaseLib
Paolo Bonzini 2e34e0
+  DebugPrintErrorLevelLib
Paolo Bonzini 2e34e0
+
Paolo Bonzini 2e34e0
+[Pcd]
Paolo Bonzini 2e34e0
+  gUefiOvmfPkgTokenSpaceGuid.PcdDebugIoPort                ## CONSUMES
Paolo Bonzini 2e34e0
+  gEfiMdePkgTokenSpaceGuid.PcdDebugClearMemoryValue        ## CONSUMES
Paolo Bonzini 2e34e0
+  gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask            ## CONSUMES
Paolo Bonzini 2e34e0
+  gEfiMdePkgTokenSpaceGuid.PcdFixedDebugPrintErrorLevel    ## CONSUMES
Paolo Bonzini 2e34e0
+
Paolo Bonzini 2e34e0
diff --git a/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c b/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c
Paolo Bonzini 2e34e0
index 74f4d9c2d6..5a1c86f2c3 100644
Paolo Bonzini 2e34e0
--- a/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c
Paolo Bonzini 2e34e0
+++ b/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLib.c
Paolo Bonzini 2e34e0
@@ -28,21 +28,6 @@
Paolo Bonzini 2e34e0
 //
Paolo Bonzini 2e34e0
 #define MAX_DEBUG_MESSAGE_LENGTH  0x200
Paolo Bonzini 2e34e0
 
Paolo Bonzini 2e34e0
-/**
Paolo Bonzini 2e34e0
-  This constructor function does not have to do anything.
Paolo Bonzini 2e34e0
-
Paolo Bonzini 2e34e0
-  @retval RETURN_SUCCESS   The constructor always returns RETURN_SUCCESS.
Paolo Bonzini 2e34e0
-
Paolo Bonzini 2e34e0
-**/
Paolo Bonzini 2e34e0
-RETURN_STATUS
Paolo Bonzini 2e34e0
-EFIAPI
Paolo Bonzini 2e34e0
-PlatformDebugLibIoPortConstructor (
Paolo Bonzini 2e34e0
-  VOID
Paolo Bonzini 2e34e0
-  )
Paolo Bonzini 2e34e0
-{
Paolo Bonzini 2e34e0
-  return RETURN_SUCCESS;
Paolo Bonzini 2e34e0
-}
Paolo Bonzini 2e34e0
-
Paolo Bonzini 2e34e0
 /**
Paolo Bonzini 2e34e0
   Prints a debug message to the debug output device if the specified error level is enabled.
Paolo Bonzini 2e34e0
 
Paolo Bonzini 2e34e0
diff --git a/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetect.c b/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetect.c
Paolo Bonzini 2e34e0
new file mode 100644
Paolo Bonzini 2e34e0
index 0000000000..bad054f286
Paolo Bonzini 2e34e0
--- /dev/null
Paolo Bonzini 2e34e0
+++ b/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetect.c
Paolo Bonzini 2e34e0
@@ -0,0 +1,31 @@
Paolo Bonzini 2e34e0
+/** @file
Paolo Bonzini 2e34e0
+  Constructor code for QEMU debug port library.
Paolo Bonzini 2e34e0
+  Non-SEC instance.
Paolo Bonzini 2e34e0
+
Paolo Bonzini 2e34e0
+  Copyright (c) 2017, Red Hat, Inc.
Paolo Bonzini 2e34e0
+  This program and the accompanying materials
Paolo Bonzini 2e34e0
+  are licensed and made available under the terms and conditions of the BSD License
Paolo Bonzini 2e34e0
+  which accompanies this distribution.  The full text of the license may be found at
Paolo Bonzini 2e34e0
+  http://opensource.org/licenses/bsd-license.php.
Paolo Bonzini 2e34e0
+
Paolo Bonzini 2e34e0
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
Paolo Bonzini 2e34e0
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Paolo Bonzini 2e34e0
+
Paolo Bonzini 2e34e0
+**/
Paolo Bonzini 2e34e0
+
Paolo Bonzini 2e34e0
+#include <Base.h>
Paolo Bonzini 2e34e0
+
Paolo Bonzini 2e34e0
+/**
Paolo Bonzini 2e34e0
+  This constructor function does not have anything to do.
Paolo Bonzini 2e34e0
+
Paolo Bonzini 2e34e0
+  @retval RETURN_SUCCESS   The constructor always returns RETURN_SUCCESS.
Paolo Bonzini 2e34e0
+
Paolo Bonzini 2e34e0
+**/
Paolo Bonzini 2e34e0
+RETURN_STATUS
Paolo Bonzini 2e34e0
+EFIAPI
Paolo Bonzini 2e34e0
+PlatformDebugLibIoPortConstructor (
Paolo Bonzini 2e34e0
+  VOID
Paolo Bonzini 2e34e0
+  )
Paolo Bonzini 2e34e0
+{
Paolo Bonzini 2e34e0
+  return RETURN_SUCCESS;
Paolo Bonzini 2e34e0
+}
Paolo Bonzini 2e34e0
diff --git a/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetectRom.c b/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetectRom.c
Paolo Bonzini 2e34e0
new file mode 100644
Paolo Bonzini 2e34e0
index 0000000000..83a118a0f7
Paolo Bonzini 2e34e0
--- /dev/null
Paolo Bonzini 2e34e0
+++ b/OvmfPkg/Library/PlatformDebugLibIoPort/DebugLibDetectRom.c
Paolo Bonzini 2e34e0
@@ -0,0 +1,31 @@
Paolo Bonzini 2e34e0
+/** @file
Paolo Bonzini 2e34e0
+  Constructor code for QEMU debug port library.
Paolo Bonzini 2e34e0
+  SEC instance.
Paolo Bonzini 2e34e0
+
Paolo Bonzini 2e34e0
+  Copyright (c) 2017, Red Hat, Inc.
Paolo Bonzini 2e34e0
+  This program and the accompanying materials
Paolo Bonzini 2e34e0
+  are licensed and made available under the terms and conditions of the BSD License
Paolo Bonzini 2e34e0
+  which accompanies this distribution.  The full text of the license may be found at
Paolo Bonzini 2e34e0
+  http://opensource.org/licenses/bsd-license.php.
Paolo Bonzini 2e34e0
+
Paolo Bonzini 2e34e0
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
Paolo Bonzini 2e34e0
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
Paolo Bonzini 2e34e0
+
Paolo Bonzini 2e34e0
+**/
Paolo Bonzini 2e34e0
+
Paolo Bonzini 2e34e0
+#include <Base.h>
Paolo Bonzini 2e34e0
+
Paolo Bonzini 2e34e0
+/**
Paolo Bonzini 2e34e0
+  This constructor function does not have anything to do.
Paolo Bonzini 2e34e0
+
Paolo Bonzini 2e34e0
+  @retval RETURN_SUCCESS   The constructor always returns RETURN_SUCCESS.
Paolo Bonzini 2e34e0
+
Paolo Bonzini 2e34e0
+**/
Paolo Bonzini 2e34e0
+RETURN_STATUS
Paolo Bonzini 2e34e0
+EFIAPI
Paolo Bonzini 2e34e0
+PlatformRomDebugLibIoPortConstructor (
Paolo Bonzini 2e34e0
+  VOID
Paolo Bonzini 2e34e0
+  )
Paolo Bonzini 2e34e0
+{
Paolo Bonzini 2e34e0
+  return RETURN_SUCCESS;
Paolo Bonzini 2e34e0
+}
Paolo Bonzini 2e34e0
-- 
Paolo Bonzini 2e34e0
2.14.3
Paolo Bonzini 2e34e0