]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg: Add a PEIM to install Debug PPI
authorZhichao Gao <zhichao.gao@intel.com>
Thu, 14 Mar 2019 09:03:49 +0000 (17:03 +0800)
committerLiming Gao <liming.gao@intel.com>
Tue, 2 Apr 2019 04:49:29 +0000 (12:49 +0800)
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=1549

Add a PEIM to install Debug PPI so that PEI debug library
instance can locate gEdkiiDebugPpiGuid to implement the
debug functions. Using this PPI can reduce the size of
PEIMs which consume the debug library.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhichao Gao <zhichao.gao@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Hao Wu <hao.a.wu@intel.com>
Cc: Ray Ni <ray.ni@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Sean Brogan <sean.brogan@microsoft.com>
Cc: Michael Turner <Michael.Turner@microsoft.com>
Cc: Bret Barkelew <Bret.Barkelew@microsoft.com>
Reviewed-by: Hao Wu <hao.a.wu@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
MdeModulePkg/Universal/DebugServicePei/DebugService.h [new file with mode: 0644]
MdeModulePkg/Universal/DebugServicePei/DebugServicePei.c [new file with mode: 0644]
MdeModulePkg/Universal/DebugServicePei/DebugServicePei.inf [new file with mode: 0644]
MdeModulePkg/Universal/DebugServicePei/DebugServicePei.uni [new file with mode: 0644]

diff --git a/MdeModulePkg/Universal/DebugServicePei/DebugService.h b/MdeModulePkg/Universal/DebugServicePei/DebugService.h
new file mode 100644 (file)
index 0000000..3e234f7
--- /dev/null
@@ -0,0 +1,56 @@
+/** @file\r
+  Header file of Debug services instances.\r
+\r
+  Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>\r
+\r
+  This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+#ifndef __DEBUG_SERVICE_H__\r
+#define __DEBUG_SERVICE_H__\r
+\r
+#include <Ppi/Debug.h>\r
+\r
+/**\r
+  Print a debug message to debug output device if the specified error level\r
+  is enabled.\r
+\r
+  @param[in] ErrorLevel               The error level of the debug message.\r
+  @param[in] Format                   Format string for the debug message to print.\r
+  @param[in] Marker                   BASE_LIST marker for the variable argument list.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+PeiDebugBPrint(\r
+  IN UINTN                          ErrorLevel,\r
+  IN CONST CHAR8                    *Format,\r
+  IN BASE_LIST                      Marker\r
+  );\r
+\r
+/**\r
+  Prints an assert message containing a filename, line number, and description.\r
+  This may be followed by a breakpoint or a dead loop.\r
+\r
+  @param[in] FileName                 The pointer to the name of the source file that\r
+                                      generated the assert condition.\r
+  @param[in] LineNumber               The line number in the source file that generated\r
+                                      the assert condition\r
+  @param[in] Description              The pointer to the description of the assert condition.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+PeiDebugAssert(\r
+  IN CONST CHAR8                    *FileName,\r
+  IN UINTN                          LineNumber,\r
+  IN CONST CHAR8                    *Description\r
+  );\r
+\r
+#endif\r
diff --git a/MdeModulePkg/Universal/DebugServicePei/DebugServicePei.c b/MdeModulePkg/Universal/DebugServicePei/DebugServicePei.c
new file mode 100644 (file)
index 0000000..6e85e70
--- /dev/null
@@ -0,0 +1,100 @@
+/** @file\r
+  This driver installs gEdkiiDebugPpiGuid PPI to provide\r
+  debug services for PEIMs.\r
+\r
+  Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>\r
+\r
+  This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include <Uefi/UefiBaseType.h>\r
+#include <Library/PeimEntryPoint.h>\r
+#include <Library/PeiServicesLib.h>\r
+#include <Library/DebugLib.h>\r
+\r
+#include <Ppi/Debug.h>\r
+\r
+#include "DebugService.h"\r
+\r
+EDKII_DEBUG_PPI mDebugPpi = {\r
+  PeiDebugBPrint,\r
+  PeiDebugAssert\r
+};\r
+\r
+EFI_PEI_PPI_DESCRIPTOR mDebugServicePpi = {\r
+  (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r
+  &gEdkiiDebugPpiGuid,\r
+  (VOID *)&mDebugPpi\r
+};\r
+\r
+/**\r
+  Print a debug message to debug output device if the specified error level\r
+  is enabled.\r
+\r
+  @param[in] ErrorLevel               The error level of the debug message.\r
+  @param[in] Format                   Format string for the debug message to print.\r
+  @param[in] Marker                   BASE_LIST marker for the variable argument list.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+PeiDebugBPrint(\r
+  IN UINTN                          ErrorLevel,\r
+  IN CONST CHAR8                    *Format,\r
+  IN BASE_LIST                      Marker\r
+  )\r
+{\r
+  DebugBPrint(ErrorLevel, Format, Marker);\r
+}\r
+\r
+/**\r
+  Print an assert message containing a filename, line number, and description.\r
+  This may be followed by a breakpoint or a dead loop.\r
+\r
+  @param[in] FileName                 The pointer to the name of the source file that\r
+                                      generated the assert condition.\r
+  @param[in] LineNumber               The line number in the source file that generated\r
+                                      the assert condition\r
+  @param[in] Description              The pointer to the description of the assert condition.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+PeiDebugAssert(\r
+  IN CONST CHAR8                    *FileName,\r
+  IN UINTN                          LineNumber,\r
+  IN CONST CHAR8                    *Description\r
+  )\r
+{\r
+  DebugAssert(FileName, LineNumber, Description);\r
+}\r
+\r
+/**\r
+  Entry point of Debug Service PEIM\r
+\r
+  This funciton installs EDKII DEBUG PPI\r
+\r
+  @param  FileHandle  Handle of the file being invoked.\r
+  @param  PeiServices Describes the list of possible PEI Services.\r
+\r
+  @retval EFI_SUCESS  The entry point of Debug Service PEIM executes successfully.\r
+  @retval Others      Some error occurs during the execution of this function.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+DebugSerivceInitialize (\r
+  IN EFI_PEI_FILE_HANDLE        FileHandle,\r
+  IN CONST EFI_PEI_SERVICES     **PeiServices\r
+  )\r
+{\r
+  return PeiServicesInstallPpi (&mDebugServicePpi);\r
+}\r
+\r
diff --git a/MdeModulePkg/Universal/DebugServicePei/DebugServicePei.inf b/MdeModulePkg/Universal/DebugServicePei/DebugServicePei.inf
new file mode 100644 (file)
index 0000000..d1642cd
--- /dev/null
@@ -0,0 +1,51 @@
+## @file\r
+#  Debug services for PEI phase\r
+#\r
+#  This module installs gEdkiiDebugPpiGuid PPI to provide\r
+#  debug services for PEIMs.\r
+#\r
+#  Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>\r
+#\r
+#  This program and the accompanying materials\r
+#  are licensed and made available under the terms and conditions of the BSD License\r
+#  which accompanies this distribution. The full text of the license may be found at\r
+#  http://opensource.org/licenses/bsd-license.php\r
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+#\r
+##\r
+[Defines]\r
+  INF_VERSION                    = 0x00010005\r
+  BASE_NAME                      = DebugServicePei\r
+  MODULE_UNI_FILE                = DebugServicePei.uni\r
+  FILE_GUID                      = B73F81B9-1DFC-487C-824C-0509EE2B0128\r
+  MODULE_TYPE                    = PEIM\r
+  VERSION_STRING                 = 1.0\r
+\r
+  ENTRY_POINT                    = DebugSerivceInitialize\r
+\r
+#\r
+# The following information is for reference only and not required by the build tools.\r
+#\r
+#  VALID_ARCHITECTURES           = IA32 X64 EBC\r
+#\r
+\r
+[Sources]\r
+  DebugServicePei.c\r
+  DebugService.h\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  MdeModulePkg/MdeModulePkg.dec\r
+\r
+[LibraryClasses]\r
+  PeimEntryPoint\r
+  PeiServicesLib\r
+  DebugLib\r
+\r
+[Ppis]\r
+  gEdkiiDebugPpiGuid                    ## PRODUCE\r
+\r
+[Depex]\r
+  TRUE\r
+\r
diff --git a/MdeModulePkg/Universal/DebugServicePei/DebugServicePei.uni b/MdeModulePkg/Universal/DebugServicePei/DebugServicePei.uni
new file mode 100644 (file)
index 0000000..c49a7ac
--- /dev/null
@@ -0,0 +1,20 @@
+///** @file\r
+//  This driver installs gEdkiiDebugPpiGuid PPI to provide\r
+//  debug services for PEIMs.\r
+//\r
+//  Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>\r
+//\r
+//  This program and the accompanying materials\r
+//  are licensed and made available under the terms and conditions of the BSD License\r
+//  which accompanies this distribution.  The full text of the license may be found at\r
+//  http://opensource.org/licenses/bsd-license.php\r
+//\r
+//  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+//  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+//\r
+//**/\r
+\r
+#string STR_MODULE_ABSTRACT             #language en-US "Provide debug services at PEI phase."\r
+\r
+#string STR_MODULE_DESCRIPTION          #language en-US "It produces gEdkiiDebugPpiGuid to print message to debug output device"\r
+\r