From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mx.groups.io with SMTP id smtpd.web10.7326.1648029673272515079 for ; Wed, 23 Mar 2022 03:01:14 -0700 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=Qtk5qJ9T; spf=pass (domain: intel.com, ip: 134.134.136.31, mailfrom: yuanhao.xie@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1648029673; x=1679565673; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=5Ydayly9FOgmpLWq0AJVCQaRFUUSVgImxUmzfLnSuJc=; b=Qtk5qJ9TpM4sym8/WotGSebXs4LpBbf1WOj2rSaZ1zdZWhPnei1TXTWm JeS6CUVz0RFjZwJGCD7CyoQS3OQmxlXl+BRgoaMI8C/xhINy9MkO3LqBi MOA98L9Yk1BXytaZDTazPTvUk77uvbOTpA7azBLo2HQXX7/AScwcDnrYd o9R3l4CpvBzClVsJ6qpSvqF/jKDUBsr6YgKuSsmFt3LAaDEhFVURxrYo/ ZKaMDB6UnQ6aHuiArZuZOE6TDO/5O4HQjwVGEzQ5Vb9lUn42hZJKSZftV 3p7pP9IzpJi26g9+0oZIqV4tC4PIbPtNiG9M8lqeUVvyOZg1Y261UlCfY A==; X-IronPort-AV: E=McAfee;i="6200,9189,10294"; a="318781349" X-IronPort-AV: E=Sophos;i="5.90,203,1643702400"; d="scan'208";a="318781349" Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Mar 2022 03:01:12 -0700 X-IronPort-AV: E=Sophos;i="5.90,203,1643702400"; d="scan'208";a="560828555" Received: from shwdeopenlab705.ccr.corp.intel.com ([10.239.182.56]) by orsmga008-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Mar 2022 03:01:10 -0700 From: "Yuanhao Xie" To: devel@edk2.groups.io Cc: Guo Dong , Ray Ni , Maurice Ma , Benjamin You , Sean Rhodes Subject: [PATCH 1/2] UefiPayloadPkg: Add a new DebugPrintErrorLevelLib instance. Date: Wed, 23 Mar 2022 18:00:52 +0800 Message-Id: <20220323100053.373-1-yuanhao.xie@intel.com> X-Mailer: git-send-email 2.30.0.windows.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit It consumes the HOB defined in UefiPayloadPkg/Include/Guid/DebugPrintErrorLevel.h, and allow bootloader to config DebugPrintErrorLevel Cc: Guo Dong Cc: Ray Ni Cc: Maurice Ma Cc: Benjamin You Cc: Sean Rhodes Signed-off-by: Yuanhao Xie --- UefiPayloadPkg/Include/Guid/DebugPrintErrorLevel.h | 27 +++++++++++++++++++++++++++ UefiPayloadPkg/Library/DebugPrintErrorLevelLibCmos/DebugPrintErrorLevelLibCmos.c | 84 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ UefiPayloadPkg/Library/DebugPrintErrorLevelLibCmos/DebugPrintErrorLevelLibCmos.inf | 39 +++++++++++++++++++++++++++++++++++++++ UefiPayloadPkg/UefiPayloadPkg.dec | 2 +- 4 files changed, 151 insertions(+), 1 deletion(-) diff --git a/UefiPayloadPkg/Include/Guid/DebugPrintErrorLevel.h b/UefiPayloadPkg/Include/Guid/DebugPrintErrorLevel.h new file mode 100644 index 0000000000..9a3f4eb28e --- /dev/null +++ b/UefiPayloadPkg/Include/Guid/DebugPrintErrorLevel.h @@ -0,0 +1,27 @@ +/** @file + Define the structure for Debug Print Error Level Guid Hob. + +Copyright (c) 2022, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#ifndef UNIVERSAL_PAYLOAD_DEBUG_PRINT_ERROR_LEVEL_H_ +#define UNIVERSAL_PAYLOAD_DEBUG_PRINT_ERROR_LEVEL_H_ + +#include +#include + +#pragma pack (1) + +typedef struct { + UNIVERSAL_PAYLOAD_GENERIC_HEADER Header; + UINT32 ErrorLevel; +} UNIVERSAL_PAYLOAD_DEBUG_PRINT_ERROR_LEVEL; + +#pragma pack() + +#define UNIVERSAL_PAYLOAD_DEBUG_PRINT_ERROR_LEVEL_REVISION 1 + +extern GUID gEdkiiDebugPrintErrorLevelGuid; +#endif diff --git a/UefiPayloadPkg/Library/DebugPrintErrorLevelLibCmos/DebugPrintErrorLevelLibCmos.c b/UefiPayloadPkg/Library/DebugPrintErrorLevelLibCmos/DebugPrintErrorLevelLibCmos.c new file mode 100644 index 0000000000..e3057620d9 --- /dev/null +++ b/UefiPayloadPkg/Library/DebugPrintErrorLevelLibCmos/DebugPrintErrorLevelLibCmos.c @@ -0,0 +1,84 @@ +/** @file + Debug Print Error Level library instance that retrieves + the DebugPrintErrorLevel from bootloader. + + Copyright (c) 2022, Intel Corporation. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/** + Returns the debug print error level mask for the current module. + + @return Debug print error level mask for the current module. + +**/ +UINT32 +EFIAPI +GetDebugPrintErrorLevel ( + VOID + ) +{ + VOID *GuidHob; + UNIVERSAL_PAYLOAD_GENERIC_HEADER *GenericHeader; + UNIVERSAL_PAYLOAD_DEBUG_PRINT_ERROR_LEVEL *DebugPrintErrorLevel; + + GuidHob = GetFirstGuidHob (&gEdkiiDebugPrintErrorLevelGuid); + + if (GuidHob == NULL) { + // + // If the HOB is not create, the default value of PcdDebugPrintErrorLevel will be used. + // + return PcdGet32(PcdDebugPrintErrorLevel); + } + + GenericHeader = (UNIVERSAL_PAYLOAD_GENERIC_HEADER *)GET_GUID_HOB_DATA (GuidHob); + if ((sizeof (UNIVERSAL_PAYLOAD_GENERIC_HEADER) > GET_GUID_HOB_DATA_SIZE (GuidHob)) || + (GenericHeader->Length > GET_GUID_HOB_DATA_SIZE (GuidHob))) { + return PcdGet32(PcdDebugPrintErrorLevel); + } + + if (GenericHeader->Revision == UNIVERSAL_PAYLOAD_DEBUG_PRINT_ERROR_LEVEL_REVISION) { + DebugPrintErrorLevel = GET_GUID_HOB_DATA (GuidHob); + return DebugPrintErrorLevel->ErrorLevel; + } else { + return PcdGet32(PcdDebugPrintErrorLevel); + } + +} + +/** + Sets the global debug print error level mask fpr the entire platform. + + @param ErrorLevel Global debug print error level. + + @retval TRUE The debug print error level mask was sucessfully set. + @retval FALSE The debug print error level mask could not be set. + +**/ +BOOLEAN +EFIAPI +SetDebugPrintErrorLevel ( + UINT32 ErrorLevel + ) +{ + // + // This library uinstance does not support setting the global debug print error + // level mask. + // + return FALSE; +} diff --git a/UefiPayloadPkg/Library/DebugPrintErrorLevelLibCmos/DebugPrintErrorLevelLibCmos.inf b/UefiPayloadPkg/Library/DebugPrintErrorLevelLibCmos/DebugPrintErrorLevelLibCmos.inf new file mode 100644 index 0000000000..a63dc4b83f --- /dev/null +++ b/UefiPayloadPkg/Library/DebugPrintErrorLevelLibCmos/DebugPrintErrorLevelLibCmos.inf @@ -0,0 +1,39 @@ +## @file +# Debug Print Error Level library instance that retrieves +# the DebugPrintErrorLevel from bootloader. +# +# Copyright (c) 2022, Intel Corporation. All rights reserved.
+# +# SPDX-License-Identifier: BSD-2-Clause-Patent +# +## + +[Defines] + INF_VERSION = 0x00010005 + BASE_NAME = DebugPrintErrorLevelLib + FILE_GUID = c3fead6d-bd4c-4131-bd5f-4bbceecc0fef + MODULE_TYPE = BASE + VERSION_STRING = 1.0 + LIBRARY_CLASS = DebugPrintErrorLevelLib + +# +# VALID_ARCHITECTURES = IA32 X64 EBC +# + +[Sources] + DebugPrintErrorLevelLibCmos.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + UefiPayloadPkg/UefiPayloadPkg.dec + +[LibraryClasses] + PcdLib + HobLib + +[Pcd] + gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel + +[Guids] + gEdkiiDebugPrintErrorLevelGuid diff --git a/UefiPayloadPkg/UefiPayloadPkg.dec b/UefiPayloadPkg/UefiPayloadPkg.dec index 4051172caf..5c1aeb8235 100644 --- a/UefiPayloadPkg/UefiPayloadPkg.dec +++ b/UefiPayloadPkg/UefiPayloadPkg.dec @@ -31,7 +31,7 @@ ##include/Guid/BootManagerMenu.h gEdkiiBootManagerMenuFileGuid = { 0xdf939333, 0x42fc, 0x4b2a, { 0xa5, 0x9e, 0xbb, 0xae, 0x82, 0x81, 0xfe, 0xef }} - + gEdkiiDebugPrintErrorLevelGuid = { 0xad82f436, 0x75c5, 0x4aa9, { 0x92, 0x93, 0xc5, 0x55, 0x0a, 0x7f, 0xf9, 0x71 }} gUefiAcpiBoardInfoGuid = {0xad3d31b, 0xb3d8, 0x4506, {0xae, 0x71, 0x2e, 0xf1, 0x10, 0x6, 0xd9, 0xf}} gUefiSerialPortInfoGuid = { 0x6c6872fe, 0x56a9, 0x4403, { 0xbb, 0x98, 0x95, 0x8d, 0x62, 0xde, 0x87, 0xf1 } } gLoaderMemoryMapInfoGuid = { 0xa1ff7424, 0x7a1a, 0x478e, { 0xa9, 0xe4, 0x92, 0xf3, 0x57, 0xd1, 0x28, 0x32 } } -- 2.30.0.windows.1