From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by mx.groups.io with SMTP id smtpd.web10.3768.1675133376074032994 for ; Mon, 30 Jan 2023 18:49:36 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="unable to parse pub key" header.i=@intel.com header.s=intel header.b=K9qXa7Nh; spf=pass (domain: intel.com, ip: 134.134.136.24, mailfrom: victorx.hsu@intel.com) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1675133376; x=1706669376; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=GycMk5nbJw5qHPxGzD7rdkwIArEECv/ViHNVhx8UMyA=; b=K9qXa7NhBnj+x66pIBJiRGjDyIRyHkP/SKawmdkxAMbKPSpyMoVsb/YZ qAnlZwca4JZyBmnIPUj9EoLq87efJLYNaye/GvNXwDPTp/kV42RN2pS8x QPWM+SWpA5rl1NwM7d0VO9zRcEDxU+59MTbDe96xoQWe1ppg+KrSRFfUL pMTTsfjAeR5MzNLjHHQV4fXAjajfxF9dZWiZ+YiyZXIiw0l+upi8Q4h3o 2reR3BDqmcZHCsLftl+ni5FhxjBgBfLBPmKAzxr1e551+jbNZ59P6Cy67 RGlVxNaHIwdWA1mYjCyC3VYldMYASuG47mDzAORjCumCrC2FINUeCt3kI Q==; X-IronPort-AV: E=McAfee;i="6500,9779,10606"; a="329008476" X-IronPort-AV: E=Sophos;i="5.97,259,1669104000"; d="scan'208";a="329008476" Received: from fmsmga003.fm.intel.com ([10.253.24.29]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 30 Jan 2023 18:49:35 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=McAfee;i="6500,9779,10606"; a="753077509" X-IronPort-AV: E=Sophos;i="5.97,259,1669104000"; d="scan'208";a="753077509" Received: from hsuc1x-desk1.gar.corp.intel.com ([10.227.107.38]) by FMSMGA003.fm.intel.com with ESMTP; 30 Jan 2023 18:49:32 -0800 From: victorx.hsu@intel.com To: devel@edk2.groups.io Cc: VictorX Hsu , Michael D Kinney , Guo Gua , Chan Laura , Prakashan Krishnadas Veliyathuparambil , K N Karthik Subject: [PATCH 2/4] MdeModulePkg: Add TraceHubDebugLibSysT library Date: Tue, 31 Jan 2023 10:49:00 +0800 Message-Id: X-Mailer: git-send-email 2.28.0.windows.1 In-Reply-To: <29c690501f493d9d003ee7089228a7273c3ff091.1675131785.git.victorx.hsu@intel.com> References: <29c690501f493d9d003ee7089228a7273c3ff091.1675131785.git.victorx.hsu@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable From: VictorX Hsu REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4144 This Library provide Trace Hub API which consume MipiSysTLib. Cc: Michael D Kinney Cc: Guo Gua Cc: Chan Laura Cc: Prakashan Krishnadas Veliyathuparambil Cc: K N Karthik Signed-off-by: VictorX Hsu --- .../UniversalPayload/TraceHubDebugInfo.h | 31 ++ .../BaseTraceHubDebugLibSyst.inf | 44 ++ .../BaseTraceHubDebugSystLib.c | 386 +++++++++++++++ .../DxeSmmTraceHubDebugLibSyst.inf | 49 ++ .../DxeSmmTraceHubDebugSystLib.c | 462 ++++++++++++++++++ .../PeiTraceHubDebugLibSyst.inf | 49 ++ .../PeiTraceHubDebugSystLib.c | 446 +++++++++++++++++ .../TraceHubDebugLibSysT/TraceHubApiCommon.c | 81 +++ .../TraceHubDebugLibSysT/TraceHubApiCommon.h | 64 +++ .../TraceHubApiInternal.h | 92 ++++ MdeModulePkg/MdeModulePkg.dec | 21 + MdeModulePkg/MdeModulePkg.dsc | 6 + MdeModulePkg/MdeModulePkg.uni | 18 + 13 files changed, 1749 insertions(+) create mode 100644 MdeModulePkg/Include/UniversalPayload/TraceHubDebugInfo= .h create mode 100644 MdeModulePkg/Library/TraceHubDebugLibSysT/BaseTraceHubD= ebugLibSyst.inf create mode 100644 MdeModulePkg/Library/TraceHubDebugLibSysT/BaseTraceHubD= ebugSystLib.c create mode 100644 MdeModulePkg/Library/TraceHubDebugLibSysT/DxeSmmTraceHu= bDebugLibSyst.inf create mode 100644 MdeModulePkg/Library/TraceHubDebugLibSysT/DxeSmmTraceHu= bDebugSystLib.c create mode 100644 MdeModulePkg/Library/TraceHubDebugLibSysT/PeiTraceHubDe= bugLibSyst.inf create mode 100644 MdeModulePkg/Library/TraceHubDebugLibSysT/PeiTraceHubDe= bugSystLib.c create mode 100644 MdeModulePkg/Library/TraceHubDebugLibSysT/TraceHubApiCo= mmon.c create mode 100644 MdeModulePkg/Library/TraceHubDebugLibSysT/TraceHubApiCo= mmon.h create mode 100644 MdeModulePkg/Library/TraceHubDebugLibSysT/TraceHubApiIn= ternal.h diff --git a/MdeModulePkg/Include/UniversalPayload/TraceHubDebugInfo.h b/Md= eModulePkg/Include/UniversalPayload/TraceHubDebugInfo.h new file mode 100644 index 0000000000..6c95a85451 --- /dev/null +++ b/MdeModulePkg/Include/UniversalPayload/TraceHubDebugInfo.h @@ -0,0 +1,31 @@ +/** @file=0D + Define the structure for the Universal Payload TraceHub Debug Info.=0D +=0D +Copyright (c) 2023, Intel Corporation. All rights reserved.
=0D +SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D + @par Revision Reference:=0D + - Universal Payload Specification 0.9 (https://universalpayload.github= .io/documentation/)=0D +**/=0D +=0D +#ifndef UNIVERSAL_PAYLOAD_TRACEHUB_DEBUG_INFO_H_=0D +#define UNIVERSAL_PAYLOAD_TRACEHUB_DEBUG_INFO_H_=0D +=0D +#include =0D +=0D +typedef struct {=0D + BOOLEAN Flag; // Flag to enable or disable Trace Hub debug me= ssage.=0D + UINT8 DebugLevel; // Debug level for Trace Hub.=0D + UINTN TraceAddress; // MMIO address where Trace Hub debug message o= utput to.=0D +} TRACEHUB_DEBUG_CONTEXT;=0D +=0D +typedef struct {=0D + UNIVERSAL_PAYLOAD_GENERIC_HEADER Header;=0D + TRACEHUB_DEBUG_CONTEXT DebugContext;=0D +} UNIVERSAL_PAYLOAD_TRACEHUB_DEBUG_INFO;=0D +=0D +#define UNIVERSAL_PAYLOAD_TRACEHUB_DEBUG_INFO_REVISION 1=0D +=0D +extern EFI_GUID gUniversalPayloadTraceHubDebugInfoGuid;=0D +=0D +#endif // UNIVERSAL_PAYLOAD_TRACEHUB_DEBUG_INFO_H_=0D diff --git a/MdeModulePkg/Library/TraceHubDebugLibSysT/BaseTraceHubDebugLib= Syst.inf b/MdeModulePkg/Library/TraceHubDebugLibSysT/BaseTraceHubDebugLibSy= st.inf new file mode 100644 index 0000000000..96ecf9147a --- /dev/null +++ b/MdeModulePkg/Library/TraceHubDebugLibSysT/BaseTraceHubDebugLibSyst.inf @@ -0,0 +1,44 @@ +## @file=0D +# Debug library to output Trace Hub message.=0D +# Support SEC/PEI/DXE/SMM phase TraceHub debug message based on fixed set= tings.=0D +#=0D +# Copyright (c) 2023, Intel Corporation. All rights reserved.
=0D +#=0D +# SPDX-License-Identifier: BSD-2-Clause-Patent=0D +#=0D +##=0D +=0D +[Defines]=0D + INF_VERSION =3D 0x00010005=0D + BASE_NAME =3D BaseTraceHubDebugLibSyst=0D + FILE_GUID =3D 336DA571-AD65-423C-9A43-E0056E5B2D8D= =0D + MODULE_TYPE =3D BASE=0D + VERSION_STRING =3D 1.0=0D + LIBRARY_CLASS =3D TraceHubDebugLib=0D +=0D +#=0D +# The following information is for reference only and not required by the = build tools.=0D +#=0D +# VALID_ARCHITECTURES =3D IA32 X64=0D +#=0D +=0D +[LibraryClasses]=0D + BaseLib=0D + PcdLib=0D + BaseMemoryLib=0D + MipiSysTLib=0D +=0D +[Packages]=0D + MdePkg/MdePkg.dec=0D + MdeModulePkg/MdeModulePkg.dec=0D +=0D +[Sources]=0D + BaseTraceHubDebugSystLib.c=0D + TraceHubApiCommon.c=0D + TraceHubApiCommon.h=0D + TraceHubApiInternal.h=0D +=0D +[Pcd]=0D + gEfiMdeModulePkgTokenSpaceGuid.PcdTraceHubDebugLevel=0D + gEfiMdeModulePkgTokenSpaceGuid.PcdEnableTraceHubDebugMsg=0D + gEfiMdeModulePkgTokenSpaceGuid.PcdTraceHubDebugAddress=0D diff --git a/MdeModulePkg/Library/TraceHubDebugLibSysT/BaseTraceHubDebugSys= tLib.c b/MdeModulePkg/Library/TraceHubDebugLibSysT/BaseTraceHubDebugSystLib= .c new file mode 100644 index 0000000000..b0e99c69a3 --- /dev/null +++ b/MdeModulePkg/Library/TraceHubDebugLibSysT/BaseTraceHubDebugSystLib.c @@ -0,0 +1,386 @@ +/** @file=0D +=0D +Copyright (c) 2023, Intel Corporation. All rights reserved.
=0D +=0D +SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D +**/=0D +=0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include "TraceHubApiCommon.h"=0D +#include "TraceHubApiInternal.h"=0D +=0D +/**=0D + Write debug string to specified Trace Hub MMIO address.=0D +=0D + @param[in] SeverityType An error level to decide whether to enable = Trace Hub data.=0D + @param[in] Buffer A pointer to the data buffer.=0D + @param[in] NumberOfBytes Number of bytes to be written.=0D +=0D + @retval EFI_SUCCESS Data was written to Trace Hub.=0D + @retval Other Failed to output Trace Hub message.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +TraceHubDebugWrite (=0D + IN TRACE_HUB_SEVERITY_TYPE SeverityType,=0D + IN UINT8 *Buffer,=0D + IN UINTN NumberOfBytes=0D + )=0D +{=0D + MIPI_SYST_HANDLE MipiSystHandle;=0D + MIPI_SYST_HEADER MipiSystHeader;=0D + EFI_STATUS Status;=0D + UINT32 DbgInstCount;=0D + UINT16 Index;=0D +=0D + DbgInstCount =3D 0;=0D +=0D + if ((NumberOfBytes =3D=3D 0) || (Buffer =3D=3D NULL)) {=0D + //=0D + // No data need to be written to Trace Hub=0D + //=0D + return EFI_ABORTED;=0D + }=0D +=0D + Status =3D MigrateTraceHubHobData ();=0D +=0D + MipiSystHandle.systh_header =3D &MipiSystHeader;=0D +=0D + Status =3D InitMipiSystHandle (&MipiSystHandle);=0D + if (EFI_ERROR (Status)) {=0D + return Status;=0D + }=0D +=0D + Status =3D CountDebugInstance (&DbgInstCount);=0D + if (EFI_ERROR (Status)) {=0D + return Status;=0D + }=0D +=0D + for (Index =3D 0; Index < DbgInstCount; Index++) {=0D + Status =3D CheckWhetherToOutputMsg (=0D + &MipiSystHandle,=0D + NULL,=0D + (MIPI_SYST_SEVERITY)SeverityType,=0D + TraceHubDebugType=0D + );=0D + if (!EFI_ERROR (Status)) {=0D + Status =3D MipiSystWriteDebug (=0D + &MipiSystHandle,=0D + (MIPI_SYST_SEVERITY)SeverityType,=0D + (UINT16)NumberOfBytes,=0D + (CHAR8 *)Buffer=0D + );=0D + if (EFI_ERROR (Status)) {=0D + break;=0D + }=0D + }=0D + }=0D +=0D + return Status;=0D +}=0D +=0D +/**=0D + Write catalog status code message to specified Trace Hub MMIO address.=0D +=0D + @param[in] SeverityType An error level to decide whether to enable = Trace Hub data.=0D + @param[in] Id Catalog ID.=0D + @param[in] Guid Driver Guid.=0D +=0D + @retval EFI_SUCCESS Data was written to Trace Hub.=0D + @retval Other Failed to output Trace Hub message.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +TraceHubWriteCataLog64StatusCode (=0D + IN TRACE_HUB_SEVERITY_TYPE SeverityType,=0D + IN UINT64 Id,=0D + IN EFI_GUID *Guid=0D + )=0D +{=0D + MIPI_SYST_HANDLE MipiSystHandle;=0D + MIPI_SYST_HEADER MipiSystHeader;=0D + EFI_STATUS Status;=0D + UINT32 DbgInstCount;=0D + UINT16 Index;=0D +=0D + DbgInstCount =3D 0;=0D +=0D + if (Guid =3D=3D NULL) {=0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D + Status =3D MigrateTraceHubHobData ();=0D +=0D + MipiSystHandle.systh_header =3D &MipiSystHeader;=0D +=0D + Status =3D InitMipiSystHandle (&MipiSystHandle);=0D + if (EFI_ERROR (Status)) {=0D + return Status;=0D + }=0D +=0D + //=0D + // Convert little endian to big endian.=0D + //=0D + Status =3D LittleEndianToBigEndian (Guid);=0D + CopyMem (&MipiSystHandle.systh_guid, Guid, sizeof (EFI_GUID));=0D + MipiSystHandle.systh_tag.et_guid =3D 1;=0D +=0D + Status =3D CountDebugInstance (&DbgInstCount);=0D + if (EFI_ERROR (Status)) {=0D + return Status;=0D + }=0D +=0D + for (Index =3D 0; Index < DbgInstCount; Index++) {=0D + Status =3D CheckWhetherToOutputMsg (=0D + &MipiSystHandle,=0D + NULL,=0D + (MIPI_SYST_SEVERITY)SeverityType,=0D + TraceHubCatalogType=0D + );=0D + if (!EFI_ERROR (Status)) {=0D + Status =3D MipiSystWriteCatalog (=0D + &MipiSystHandle,=0D + (MIPI_SYST_SEVERITY)SeverityType,=0D + Id=0D + );=0D + if (EFI_ERROR (Status)) {=0D + break;=0D + }=0D + }=0D + }=0D +=0D + return Status;=0D +}=0D +=0D +/**=0D + Write catalog message to specified Trace Hub MMIO address.=0D +=0D + @param[in] SeverityType An error level to decide whether to enable Tr= ace Hub data.=0D + @param[in] Id Catalog ID.=0D + @param[in] NumberOfParams Number of parameters in argument list.=0D + @param[in] ... Argument list that pass to Trace Hub.=0D +=0D + @retval EFI_SUCCESS Data was written to Trace Hub.=0D + @retval Other Failed to output Trace Hub message.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +TraceHubWriteCataLog64 (=0D + IN TRACE_HUB_SEVERITY_TYPE SeverityType,=0D + IN UINT64 Id,=0D + IN UINTN NumberOfParams,=0D + ...=0D + )=0D +{=0D + MIPI_SYST_HANDLE MipiSystHandle;=0D + MIPI_SYST_HEADER MipiSystHeader;=0D + VA_LIST Args;=0D + UINTN Index;=0D + EFI_STATUS Status;=0D + UINT32 DbgInstCount;=0D +=0D + DbgInstCount =3D 0;=0D +=0D + if (NumberOfParams > 6) {=0D + //=0D + // Message with more than 6 parameter is illegal.=0D + //=0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D + Status =3D MigrateTraceHubHobData ();=0D +=0D + MipiSystHandle.systh_header =3D &MipiSystHeader;=0D +=0D + Status =3D InitMipiSystHandle (&MipiSystHandle);=0D + if (EFI_ERROR (Status)) {=0D + return Status;=0D + }=0D +=0D + MipiSystHandle.systh_param_count =3D (UINT32)NumberOfParams;=0D + VA_START (Args, NumberOfParams);=0D + for (Index =3D 0; Index < NumberOfParams; Index++) {=0D + MipiSystHandle.systh_param[Index] =3D VA_ARG (Args, UINT32);=0D + }=0D +=0D + VA_END (Args);=0D +=0D + Status =3D CountDebugInstance (&DbgInstCount);=0D + if (EFI_ERROR (Status)) {=0D + return Status;=0D + }=0D +=0D + for (Index =3D 0; Index < DbgInstCount; Index++) {=0D + Status =3D CheckWhetherToOutputMsg (=0D + &MipiSystHandle,=0D + NULL,=0D + (MIPI_SYST_SEVERITY)SeverityType,=0D + TraceHubCatalogType=0D + );=0D + if (!EFI_ERROR (Status)) {=0D + Status =3D MipiSystWriteCatalog (=0D + &MipiSystHandle,=0D + (MIPI_SYST_SEVERITY)SeverityType,=0D + Id=0D + );=0D + if (EFI_ERROR (Status)) {=0D + break;=0D + }=0D + }=0D + }=0D +=0D + return Status;=0D +}=0D +=0D +/**=0D + Get Trace Hub MMIO Address.=0D +=0D + @param[in] DgbContext Always NULL.=0D + @param[in, out] TraceAddress Trace Hub MMIO Address.=0D +=0D + @retval EFI_SUCCESS Get MMIO address successfully.=0D + @retval EFI_INVALID_PARAMETER TraceAddress is a NULL pointer.=0D +**/=0D +STATIC=0D +EFI_STATUS=0D +GetTraceHubMmioAddress (=0D + IN UINT8 *DgbContext,=0D + IN OUT UINTN *TraceAddress=0D + )=0D +{=0D + if (TraceAddress =3D=3D NULL) {=0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D + *TraceAddress =3D FixedPcdGet64 (PcdTraceHubDebugAddress);=0D +=0D + return EFI_SUCCESS;=0D +}=0D +=0D +/**=0D + Get visibility of Trace Hub Msg.=0D +=0D + @param[in] DgbContext Always NULL.=0D + @param[in, out] Flag Flag to enable or disable Trace Hub mess= age.=0D + @param[in, out] DbgLevel Debug Level of Trace Hub.=0D +=0D + @retval EFI_SUCCESS Get visibility of Trace Hub Msg successf= ully.=0D + @retval EFI_INVALID_PARAMETER On entry, Flag or DbgLevel is a NULL poi= nter.=0D +**/=0D +STATIC=0D +EFI_STATUS=0D +GetTraceHubMsgVisibility (=0D + IN UINT8 *DgbContext,=0D + IN OUT BOOLEAN *Flag,=0D + IN OUT UINT8 *DbgLevel=0D + )=0D +{=0D + if ((DbgLevel =3D=3D NULL) || (Flag =3D=3D NULL)) {=0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D + *DbgLevel =3D FixedPcdGet8 (PcdTraceHubDebugLevel);=0D + *Flag =3D FixedPcdGetBool (PcdEnableTraceHubDebugMsg);=0D +=0D + return EFI_SUCCESS;=0D +}=0D +=0D +/**=0D + Collect the number of available Trace Hub debug instance.=0D +=0D + @param[in, out] DbgInstCount The number of available Trace Hub debug = instance.=0D +=0D + @retval EFI_SUCCESS Collect the number of available Trace Hub debug= instance successfully.=0D + @retval Other Failed to collect the number of available Trace= Hub debug instance.=0D +**/=0D +STATIC=0D +EFI_STATUS=0D +CountDebugInstance (=0D + IN OUT UINT32 *DbgInstCount=0D + )=0D +{=0D + if (DbgInstCount =3D=3D NULL) {=0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D + //=0D + // 1 for fixed PCD.=0D + //=0D + *DbgInstCount =3D 1;=0D +=0D + return EFI_SUCCESS;=0D +}=0D +=0D +/**=0D + Allocate boot time pool memory to store Trace Hub HOB data.=0D +=0D + @retval EFI_SUCCESS Migration process is successful.=0D + @retval Other Migration process is unsuccessful=0D +**/=0D +STATIC=0D +EFI_STATUS=0D +MigrateTraceHubHobData (=0D + VOID=0D + )=0D +{=0D + return EFI_UNSUPPORTED;=0D +}=0D +=0D +/**=0D + Check whether to output Tracr Hub message.=0D +=0D + @param[in, out] MipiSystHandle A pointer to MIPI_SYST_HANDLE structur= e.=0D + @param[in, out] DgbContext Always NULL.=0D + @param[in] SeverityType An error level to decide whether to en= able Trace Hub data.=0D + @param[in] PrintType Either catalog print or debug print.=0D +=0D + @retval EFI_SUCCESS Current Trace Hub message need to be processed.= =0D + @retval Other Current Trace Hub message no need to be process= ed.=0D +**/=0D +STATIC=0D +EFI_STATUS=0D +CheckWhetherToOutputMsg (=0D + IN OUT MIPI_SYST_HANDLE *MipiSystHandle,=0D + IN OUT UINT8 *DgbContext,=0D + IN TRACE_HUB_SEVERITY_TYPE SeverityType,=0D + IN TRACEHUB_PRINTTYPE PrintType=0D + )=0D +{=0D + EFI_STATUS Status;=0D + UINTN Addr;=0D + UINT8 DbgLevel;=0D + BOOLEAN Flag;=0D +=0D + if (MipiSystHandle =3D=3D NULL) {=0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D + if (PrintType =3D=3D TraceHubDebugType) {=0D + Status =3D GetTraceHubMsgVisibility (NULL, &Flag, &DbgLevel);=0D + if (EFI_ERROR (Status)) {=0D + return Status;=0D + }=0D +=0D + if (!EnableTraceHubData (Flag, DbgLevel, SeverityType)) {=0D + return EFI_ABORTED;=0D + }=0D + }=0D +=0D + Status =3D GetTraceHubMmioAddress (NULL, &Addr);=0D + if (EFI_ERROR (Status)) {=0D + return Status;=0D + }=0D +=0D + MipiSystHandle->systh_platform.TraceHubPlatformData.MmioAddr =3D Addr;=0D + if (MipiSystHandle->systh_platform.TraceHubPlatformData.MmioAddr =3D=3D = 0) {=0D + return EFI_ABORTED;=0D + }=0D +=0D + return EFI_SUCCESS;=0D +}=0D diff --git a/MdeModulePkg/Library/TraceHubDebugLibSysT/DxeSmmTraceHubDebugL= ibSyst.inf b/MdeModulePkg/Library/TraceHubDebugLibSysT/DxeSmmTraceHubDebugL= ibSyst.inf new file mode 100644 index 0000000000..d5bc316083 --- /dev/null +++ b/MdeModulePkg/Library/TraceHubDebugLibSysT/DxeSmmTraceHubDebugLibSyst.= inf @@ -0,0 +1,49 @@ +## @file=0D +# Debug library to output Trace Hub message.=0D +# Support DXE/SMM phase TraceHub debug message based on dynamic settings.= =0D +#=0D +# Copyright (c) 2023, Intel Corporation. All rights reserved.
=0D +#=0D +# SPDX-License-Identifier: BSD-2-Clause-Patent=0D +#=0D +##=0D +=0D +[Defines]=0D + INF_VERSION =3D 0x00010005=0D + BASE_NAME =3D DxeSmmTraceHubDebugLibSyst=0D + FILE_GUID =3D A9B7B825-7902-4616-8556-085DA4DFEC72= =0D + MODULE_TYPE =3D DXE_DRIVER=0D + VERSION_STRING =3D 1.0=0D + LIBRARY_CLASS =3D TraceHubDebugLib|DXE_RUNTIME_DRIVER S= MM_CORE DXE_SMM_DRIVER DXE_DRIVER DXE_CORE UEFI_DRIVER UEFI_APPLICATION=0D +=0D +#=0D +# The following information is for reference only and not required by the = build tools.=0D +#=0D +# VALID_ARCHITECTURES =3D IA32 X64=0D +#=0D +=0D +[LibraryClasses]=0D + BaseLib=0D + PcdLib=0D + HobLib=0D + BaseMemoryLib=0D + MemoryAllocationLib=0D + MipiSysTLib=0D +=0D +[Packages]=0D + MdePkg/MdePkg.dec=0D + MdeModulePkg/MdeModulePkg.dec=0D +=0D +[Sources]=0D + DxeSmmTraceHubDebugSystLib.c=0D + TraceHubApiCommon.c=0D + TraceHubApiCommon.h=0D + TraceHubApiInternal.h=0D +=0D +[Guids]=0D + gUniversalPayloadTraceHubDebugInfoGuid=0D +=0D +[Pcd]=0D + gEfiMdeModulePkgTokenSpaceGuid.PcdTraceHubDebugLevel=0D + gEfiMdeModulePkgTokenSpaceGuid.PcdEnableTraceHubDebugMsg=0D + gEfiMdeModulePkgTokenSpaceGuid.PcdTraceHubDebugAddress=0D diff --git a/MdeModulePkg/Library/TraceHubDebugLibSysT/DxeSmmTraceHubDebugS= ystLib.c b/MdeModulePkg/Library/TraceHubDebugLibSysT/DxeSmmTraceHubDebugSys= tLib.c new file mode 100644 index 0000000000..d81abd2c97 --- /dev/null +++ b/MdeModulePkg/Library/TraceHubDebugLibSysT/DxeSmmTraceHubDebugSystLib.c @@ -0,0 +1,462 @@ +/** @file=0D +=0D +Copyright (c) 2023, Intel Corporation. All rights reserved.
=0D +=0D +SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D +**/=0D +=0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include "TraceHubApiCommon.h"=0D +#include "TraceHubApiInternal.h"=0D +=0D +GLOBAL_REMOVE_IF_UNREFERENCED UNIVERSAL_PAYLOAD_TRACEHUB_DEBUG_INFO *mThD= ebugInstArray =3D NULL;=0D +GLOBAL_REMOVE_IF_UNREFERENCED UINT32 mDbgI= nstCount =3D 0;=0D +=0D +/**=0D + Write debug string to specified Trace Hub MMIO address.=0D +=0D + @param[in] SeverityType An error level to decide whether to enable = Trace Hub data.=0D + @param[in] Buffer A pointer to the data buffer.=0D + @param[in] NumberOfBytes Number of bytes to be written.=0D +=0D + @retval EFI_SUCCESS Data was written to Trace Hub.=0D + @retval Other Failed to output Trace Hub message.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +TraceHubDebugWrite (=0D + IN TRACE_HUB_SEVERITY_TYPE SeverityType,=0D + IN UINT8 *Buffer,=0D + IN UINTN NumberOfBytes=0D + )=0D +{=0D + MIPI_SYST_HANDLE MipiSystHandle;=0D + MIPI_SYST_HEADER MipiSystHeader;=0D + EFI_STATUS Status;=0D + UINT16 Index;=0D + UINT32 DbgInstCount;=0D +=0D + DbgInstCount =3D 0;=0D +=0D + if ((NumberOfBytes =3D=3D 0) || (Buffer =3D=3D NULL)) {=0D + //=0D + // No data need to be written to Trace Hub=0D + //=0D + return EFI_ABORTED;=0D + }=0D +=0D + Status =3D MigrateTraceHubHobData ();=0D + if (EFI_ERROR (Status)) {=0D + return Status;=0D + }=0D +=0D + MipiSystHandle.systh_header =3D &MipiSystHeader;=0D +=0D + Status =3D InitMipiSystHandle (&MipiSystHandle);=0D + if (EFI_ERROR (Status)) {=0D + return Status;=0D + }=0D +=0D + Status =3D CountDebugInstance (&DbgInstCount);=0D + if (EFI_ERROR (Status)) {=0D + return Status;=0D + }=0D +=0D + for (Index =3D 0; Index < DbgInstCount; Index++) {=0D + Status =3D CheckWhetherToOutputMsg (=0D + &MipiSystHandle,=0D + (UINT8 *)&mThDebugInstArray[Index],=0D + (MIPI_SYST_SEVERITY)SeverityType,=0D + TraceHubDebugType=0D + );=0D + if (!EFI_ERROR (Status)) {=0D + Status =3D MipiSystWriteDebug (=0D + &MipiSystHandle,=0D + (MIPI_SYST_SEVERITY)SeverityType,=0D + (UINT16)NumberOfBytes,=0D + (CHAR8 *)Buffer=0D + );=0D + if (EFI_ERROR (Status)) {=0D + break;=0D + }=0D + }=0D + }=0D +=0D + return Status;=0D +}=0D +=0D +/**=0D + Write catalog status code message to specified Trace Hub MMIO address.=0D +=0D + @param[in] SeverityType An error level to decide whether to enable = Trace Hub data.=0D + @param[in] Id Catalog ID.=0D + @param[in] Guid Driver Guid.=0D +=0D + @retval EFI_SUCCESS Data was written to Trace Hub.=0D + @retval Other Failed to output Trace Hub message.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +TraceHubWriteCataLog64StatusCode (=0D + IN TRACE_HUB_SEVERITY_TYPE SeverityType,=0D + IN UINT64 Id,=0D + IN EFI_GUID *Guid=0D + )=0D +{=0D + MIPI_SYST_HANDLE MipiSystHandle;=0D + MIPI_SYST_HEADER MipiSystHeader;=0D + UINTN Index;=0D + EFI_STATUS Status;=0D + UINT32 DbgInstCount;=0D +=0D + DbgInstCount =3D 0;=0D +=0D + Status =3D MigrateTraceHubHobData ();=0D + if (EFI_ERROR (Status)) {=0D + return Status;=0D + }=0D +=0D + MipiSystHandle.systh_header =3D &MipiSystHeader;=0D +=0D + Status =3D InitMipiSystHandle (&MipiSystHandle);=0D + if (EFI_ERROR (Status)) {=0D + return Status;=0D + }=0D +=0D + if (Guid !=3D NULL) {=0D + //=0D + // Convert little endian to big endian.=0D + //=0D + Status =3D LittleEndianToBigEndian (Guid);=0D + CopyMem (&MipiSystHandle.systh_guid, Guid, sizeof (EFI_GUID));=0D + MipiSystHandle.systh_tag.et_guid =3D 1;=0D + } else {=0D + MipiSystHandle.systh_tag.et_modunit =3D 2;=0D + MipiSystHandle.systh_tag.et_guid =3D 0;=0D + }=0D +=0D + Status =3D CountDebugInstance (&DbgInstCount);=0D + if (EFI_ERROR (Status)) {=0D + return Status;=0D + }=0D +=0D + for (Index =3D 0; Index < DbgInstCount; Index++) {=0D + Status =3D CheckWhetherToOutputMsg (=0D + &MipiSystHandle,=0D + (UINT8 *)&mThDebugInstArray[Index],=0D + (MIPI_SYST_SEVERITY)SeverityType,=0D + TraceHubCatalogType=0D + );=0D + if (!EFI_ERROR (Status)) {=0D + Status =3D MipiSystWriteCatalog (=0D + &MipiSystHandle,=0D + (MIPI_SYST_SEVERITY)SeverityType,=0D + Id=0D + );=0D + if (EFI_ERROR (Status)) {=0D + break;=0D + }=0D + }=0D + }=0D +=0D + return Status;=0D +}=0D +=0D +/**=0D + Write catalog message to specified Trace Hub MMIO address.=0D +=0D + @param[in] SeverityType An error level to decide whether to enable Tr= ace Hub data.=0D + @param[in] Id Catalog ID.=0D + @param[in] NumberOfParams Number of parameters in argument list.=0D + @param[in] ... Argument list that pass to Trace Hub.=0D +=0D + @retval EFI_SUCCESS Data was written to Trace Hub.=0D + @retval Other Failed to output Trace Hub message.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +TraceHubWriteCataLog64 (=0D + IN TRACE_HUB_SEVERITY_TYPE SeverityType,=0D + IN UINT64 Id,=0D + IN UINTN NumberOfParams,=0D + ...=0D + )=0D +{=0D + MIPI_SYST_HANDLE MipiSystHandle;=0D + MIPI_SYST_HEADER MipiSystHeader;=0D + VA_LIST Args;=0D + UINTN Index;=0D + EFI_STATUS Status;=0D + UINT32 DbgInstCount;=0D +=0D + DbgInstCount =3D 0;=0D +=0D + if (NumberOfParams > 6) {=0D + //=0D + // Message with more than 6 parameter is illegal.=0D + //=0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D + Status =3D MigrateTraceHubHobData ();=0D + if (EFI_ERROR (Status)) {=0D + return Status;=0D + }=0D +=0D + MipiSystHandle.systh_header =3D &MipiSystHeader;=0D +=0D + Status =3D InitMipiSystHandle (&MipiSystHandle);=0D + if (EFI_ERROR (Status)) {=0D + return Status;=0D + }=0D +=0D + MipiSystHandle.systh_param_count =3D (UINT32)NumberOfParams;=0D + VA_START (Args, NumberOfParams);=0D + for (Index =3D 0; Index < NumberOfParams; Index++) {=0D + MipiSystHandle.systh_param[Index] =3D VA_ARG (Args, UINT32);=0D + }=0D +=0D + VA_END (Args);=0D +=0D + Status =3D CountDebugInstance (&DbgInstCount);=0D + if (EFI_ERROR (Status)) {=0D + return Status;=0D + }=0D +=0D + for (Index =3D 0; Index < DbgInstCount; Index++) {=0D + Status =3D CheckWhetherToOutputMsg (=0D + &MipiSystHandle,=0D + (UINT8 *)&mThDebugInstArray[Index],=0D + (MIPI_SYST_SEVERITY)SeverityType,=0D + TraceHubCatalogType=0D + );=0D + if (!EFI_ERROR (Status)) {=0D + Status =3D MipiSystWriteCatalog (=0D + &MipiSystHandle,=0D + (MIPI_SYST_SEVERITY)SeverityType,=0D + Id=0D + );=0D + if (EFI_ERROR (Status)) {=0D + break;=0D + }=0D + }=0D + }=0D +=0D + return Status;=0D +}=0D +=0D +/**=0D + Collect the number of available Trace Hub debug instance.=0D +=0D + @param[in, out] DbgInstCount The number of available Trace Hub debug = instance.=0D +=0D + @retval EFI_SUCCESS Collect the number of available Trace Hub debug= instance successfully.=0D + @retval Other Failed to collect the number of available Trace= Hub debug instance.=0D +**/=0D +STATIC=0D +EFI_STATUS=0D +CountDebugInstance (=0D + IN OUT UINT32 *DbgInstCount=0D + )=0D +{=0D + UINT8 *DgbContext;=0D +=0D + if (DbgInstCount =3D=3D NULL) {=0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D + if (mThDebugInstArray =3D=3D NULL) {=0D + DgbContext =3D (UINT8 *)GetFirstGuidHob (&gUniversalPayloadTraceHubDeb= ugInfoGuid);=0D + if (DgbContext !=3D NULL) {=0D + while (DgbContext !=3D NULL) {=0D + (*DbgInstCount)++;=0D + DgbContext =3D (UINT8 *)GetNextGuidHob (&gUniversalPayloadTraceHub= DebugInfoGuid, GET_NEXT_HOB (DgbContext));=0D + }=0D + } else {=0D + //=0D + // Trace Hub debug instance for PCD=0D + //=0D + (*DbgInstCount)++;=0D + }=0D + } else {=0D + *DbgInstCount =3D mDbgInstCount;=0D + }=0D +=0D + return EFI_SUCCESS;=0D +}=0D +=0D +/**=0D + Check whether to output Tracr Hub message.=0D +=0D + @param[in, out] MipiSystHandle A pointer to MIPI_SYST_HANDLE structur= e.=0D + @param[in, out] DgbContext A pointer to Trace Hub debug instance.= =0D + @param[in] SeverityType An error level to decide whether to en= able Trace Hub data.=0D + @param[in] PrintType Either catalog print or debug print.=0D +=0D + @retval EFI_SUCCESS Current Trace Hub message need to be processed.= =0D + @retval Other Current Trace Hub message no need to be process= ed.=0D +**/=0D +STATIC=0D +EFI_STATUS=0D +CheckWhetherToOutputMsg (=0D + IN OUT MIPI_SYST_HANDLE *MipiSystHandle,=0D + IN OUT UINT8 *DgbContext,=0D + IN TRACE_HUB_SEVERITY_TYPE SeverityType,=0D + IN TRACEHUB_PRINTTYPE PrintType=0D + )=0D +{=0D + UINT8 DbgLevel;=0D + BOOLEAN Flag;=0D + UINTN Addr;=0D + EFI_STATUS Status;=0D +=0D + if ((MipiSystHandle =3D=3D NULL) || (DgbContext =3D=3D NULL)) {=0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D + if (PrintType =3D=3D TraceHubDebugType) {=0D + Status =3D GetTraceHubMsgVisibility (DgbContext, &Flag, &DbgLevel);=0D + if (EFI_ERROR (Status)) {=0D + return Status;=0D + }=0D +=0D + if (!EnableTraceHubData (Flag, DbgLevel, SeverityType)) {=0D + return EFI_ABORTED;=0D + }=0D + }=0D +=0D + Status =3D GetTraceHubMmioAddress (DgbContext, &Addr);=0D + if (EFI_ERROR (Status)) {=0D + return Status;=0D + }=0D +=0D + MipiSystHandle->systh_platform.TraceHubPlatformData.MmioAddr =3D Addr;=0D + if (MipiSystHandle->systh_platform.TraceHubPlatformData.MmioAddr =3D=3D = 0) {=0D + return EFI_ABORTED;=0D + }=0D +=0D + return EFI_SUCCESS;=0D +}=0D +=0D +/**=0D + Get Trace Hub MMIO Address.=0D +=0D + @param[in] DgbContext A pointer to Trace Hub debug instance.= =0D + @param[in, out] TraceAddress Trace Hub MMIO Address.=0D +=0D + @retval EFI_SUCCESS Get MMIO address successfully.=0D + @retval EFI_INVALID_PARAMETER TraceAddress or DgbContext is a NULL p= ointer.=0D +**/=0D +STATIC=0D +EFI_STATUS=0D +GetTraceHubMmioAddress (=0D + IN UINT8 *DgbContext,=0D + IN OUT UINTN *TraceAddress=0D + )=0D +{=0D + UNIVERSAL_PAYLOAD_TRACEHUB_DEBUG_INFO *ThDbgContext;=0D +=0D + if ((DgbContext =3D=3D NULL) || (TraceAddress =3D=3D NULL)) {=0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D + ThDbgContext =3D (UNIVERSAL_PAYLOAD_TRACEHUB_DEBUG_INFO *)DgbContext;=0D + *TraceAddress =3D ThDbgContext->DebugContext.TraceAddress;=0D +=0D + return EFI_SUCCESS;=0D +}=0D +=0D +/**=0D + Get visibility of Trace Hub Msg.=0D +=0D + @param[in] DgbContext A pointer to Trace Hub debug instance.=0D + @param[in, out] Flag Flag to enable or disable Trace Hub mess= age.=0D + @param[in, out] DbgLevel Debug Level of Trace Hub.=0D +=0D + @retval EFI_SUCCESS Get visibility of Trace Hub Msg successf= ully.=0D + @retval EFI_INVALID_PARAMETER On entry, DgbContext or Flag or DbgLevel= is a NULL pointer.=0D +**/=0D +STATIC=0D +EFI_STATUS=0D +GetTraceHubMsgVisibility (=0D + IN UINT8 *DgbContext,=0D + IN OUT BOOLEAN *Flag,=0D + IN OUT UINT8 *DbgLevel=0D + )=0D +{=0D + UNIVERSAL_PAYLOAD_TRACEHUB_DEBUG_INFO *ThDbgContext;=0D +=0D + if ((DgbContext =3D=3D NULL) || (Flag =3D=3D NULL) || (DbgLevel =3D=3D N= ULL)) {=0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D + ThDbgContext =3D (UNIVERSAL_PAYLOAD_TRACEHUB_DEBUG_INFO *)DgbContext;=0D + *Flag =3D ThDbgContext->DebugContext.Flag;=0D + *DbgLevel =3D ThDbgContext->DebugContext.DebugLevel;=0D +=0D + return EFI_SUCCESS;=0D +}=0D +=0D +/**=0D + Allocate boot time pool memory to store Trace Hub HOB data.=0D +=0D + @retval EFI_SUCCESS Migration process is successful.=0D + @retval Other Migration process is unsuccessful=0D +**/=0D +STATIC=0D +EFI_STATUS=0D +MigrateTraceHubHobData (=0D + VOID=0D + )=0D +{=0D + UINT8 *DgbContext;=0D + UINT16 Index;=0D + UINT32 DbgInstCount;=0D + EFI_STATUS Status;=0D +=0D + Index =3D 0;=0D + DgbContext =3D NULL;=0D + DbgInstCount =3D 0;=0D +=0D + if (mThDebugInstArray =3D=3D NULL) {=0D + Status =3D CountDebugInstance (&DbgInstCount);=0D + if (EFI_ERROR (Status)) {=0D + return Status;=0D + }=0D +=0D + mDbgInstCount =3D DbgInstCount;=0D + if (mDbgInstCount !=3D 0) {=0D + mThDebugInstArray =3D AllocateZeroPool (sizeof (UNIVERSAL_PAYLOAD_TR= ACEHUB_DEBUG_INFO) * mDbgInstCount);=0D + if (mThDebugInstArray =3D=3D NULL) {=0D + return EFI_OUT_OF_RESOURCES;=0D + }=0D +=0D + DgbContext =3D GetFirstGuidHob (&gUniversalPayloadTraceHubDebugInfoG= uid);=0D + if (DgbContext !=3D NULL) {=0D + for (Index =3D 0; Index < mDbgInstCount; Index++) {=0D + CopyMem (&mThDebugInstArray[Index], GET_GUID_HOB_DATA (DgbContex= t), sizeof (UNIVERSAL_PAYLOAD_TRACEHUB_DEBUG_INFO));=0D + DgbContext =3D GetNextGuidHob (&gUniversalPayloadTraceHubDebugIn= foGuid, GET_NEXT_HOB (DgbContext));=0D + }=0D + } else {=0D + for (Index =3D 0; Index < mDbgInstCount; Index++) {=0D + mThDebugInstArray[Index].DebugContext.TraceAddress =3D FixedPcdG= et64 (PcdTraceHubDebugAddress);=0D + mThDebugInstArray[Index].DebugContext.Flag =3D FixedPcdG= etBool (PcdEnableTraceHubDebugMsg);=0D + mThDebugInstArray[Index].DebugContext.DebugLevel =3D FixedPcdG= et8 (PcdTraceHubDebugLevel);=0D + }=0D + }=0D + } else {=0D + return EFI_ABORTED;=0D + }=0D + }=0D +=0D + return EFI_SUCCESS;=0D +}=0D diff --git a/MdeModulePkg/Library/TraceHubDebugLibSysT/PeiTraceHubDebugLibS= yst.inf b/MdeModulePkg/Library/TraceHubDebugLibSysT/PeiTraceHubDebugLibSyst= .inf new file mode 100644 index 0000000000..4f4bfb695b --- /dev/null +++ b/MdeModulePkg/Library/TraceHubDebugLibSysT/PeiTraceHubDebugLibSyst.inf @@ -0,0 +1,49 @@ +## @file=0D +# Debug library to output Trace Hub message.=0D +# Support PEI phase TraceHub debug message based on dynamic settings=0D +#=0D +# Copyright (c) 2023, Intel Corporation. All rights reserved.
=0D +#=0D +# SPDX-License-Identifier: BSD-2-Clause-Patent=0D +#=0D +##=0D +=0D +[Defines]=0D + INF_VERSION =3D 0x00010005=0D + BASE_NAME =3D PeiTraceHubDebugLibSyst=0D + FILE_GUID =3D C61E8C2E-0935-4E3D-BCBB-5ED84AFD9FD1= =0D + MODULE_TYPE =3D PEIM=0D + VERSION_STRING =3D 1.0=0D + LIBRARY_CLASS =3D TraceHubDebugLib|PEI_CORE PEIM=0D +=0D +#=0D +# The following information is for reference only and not required by the = build tools.=0D +#=0D +# VALID_ARCHITECTURES =3D IA32 X64=0D +#=0D +=0D +[LibraryClasses]=0D + BaseLib=0D + PcdLib=0D + HobLib=0D + BaseMemoryLib=0D + MemoryAllocationLib=0D + MipiSysTLib=0D +=0D +[Packages]=0D + MdePkg/MdePkg.dec=0D + MdeModulePkg/MdeModulePkg.dec=0D +=0D +[Sources]=0D + PeiTraceHubDebugSystLib.c=0D + TraceHubApiCommon.c=0D + TraceHubApiCommon.h=0D + TraceHubApiInternal.h=0D +=0D +[Guids]=0D + gUniversalPayloadTraceHubDebugInfoGuid=0D +=0D +[Pcd]=0D + gEfiMdeModulePkgTokenSpaceGuid.PcdTraceHubDebugLevel=0D + gEfiMdeModulePkgTokenSpaceGuid.PcdEnableTraceHubDebugMsg=0D + gEfiMdeModulePkgTokenSpaceGuid.PcdTraceHubDebugAddress=0D diff --git a/MdeModulePkg/Library/TraceHubDebugLibSysT/PeiTraceHubDebugSyst= Lib.c b/MdeModulePkg/Library/TraceHubDebugLibSysT/PeiTraceHubDebugSystLib.c new file mode 100644 index 0000000000..10bde71fd3 --- /dev/null +++ b/MdeModulePkg/Library/TraceHubDebugLibSysT/PeiTraceHubDebugSystLib.c @@ -0,0 +1,446 @@ +/** @file=0D +=0D +Copyright (c) 2023, Intel Corporation. All rights reserved.
=0D +=0D +SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D +**/=0D +=0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include =0D +#include "TraceHubApiCommon.h"=0D +#include "TraceHubApiInternal.h"=0D +=0D +/**=0D + Write debug string to specified Trace Hub MMIO address.=0D +=0D + @param[in] SeverityType An error level to decide whether to enable = Trace Hub data.=0D + @param[in] Buffer A pointer to the data buffer.=0D + @param[in] NumberOfBytes Number of bytes to be written.=0D +=0D + @retval EFI_SUCCESS Data was written to Trace Hub.=0D + @retval Other Failed to output Trace Hub message.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +TraceHubDebugWrite (=0D + IN TRACE_HUB_SEVERITY_TYPE SeverityType,=0D + IN UINT8 *Buffer,=0D + IN UINTN NumberOfBytes=0D + )=0D +{=0D + MIPI_SYST_HANDLE MipiSystHandle;=0D + MIPI_SYST_HEADER MipiSystHeader;=0D + EFI_STATUS Status;=0D + UINT8 *DgbContext;=0D + UINTN Index;=0D + UINT32 DbgInstCount;=0D +=0D + DbgInstCount =3D 0;=0D +=0D + if ((NumberOfBytes =3D=3D 0) || (Buffer =3D=3D NULL)) {=0D + //=0D + // No data need to be written to Trace Hub=0D + //=0D + return EFI_ABORTED;=0D + }=0D +=0D + Status =3D MigrateTraceHubHobData ();=0D +=0D + MipiSystHandle.systh_header =3D &MipiSystHeader;=0D +=0D + Status =3D InitMipiSystHandle (&MipiSystHandle);=0D + if (EFI_ERROR (Status)) {=0D + return Status;=0D + }=0D +=0D + Status =3D CountDebugInstance (&DbgInstCount);=0D + if (EFI_ERROR (Status)) {=0D + return Status;=0D + }=0D +=0D + DgbContext =3D (UINT8 *)GetFirstGuidHob (&gUniversalPayloadTraceHubDebug= InfoGuid);=0D + for (Index =3D 0; Index < DbgInstCount; Index++) {=0D + Status =3D CheckWhetherToOutputMsg (=0D + &MipiSystHandle,=0D + DgbContext,=0D + (MIPI_SYST_SEVERITY)SeverityType,=0D + TraceHubDebugType=0D + );=0D + if (!EFI_ERROR (Status)) {=0D + Status =3D MipiSystWriteDebug (=0D + &MipiSystHandle,=0D + (MIPI_SYST_SEVERITY)SeverityType,=0D + (UINT16)NumberOfBytes,=0D + (CHAR8 *)Buffer=0D + );=0D + if (EFI_ERROR (Status)) {=0D + break;=0D + }=0D + }=0D +=0D + if (DgbContext !=3D NULL) {=0D + DgbContext =3D (UINT8 *)GetNextGuidHob (&gUniversalPayloadTraceHubDe= bugInfoGuid, GET_NEXT_HOB (DgbContext));=0D + if (DgbContext =3D=3D NULL) {=0D + break;=0D + }=0D + }=0D + }=0D +=0D + return Status;=0D +}=0D +=0D +/**=0D + Write catalog status code message to specified Trace Hub MMIO address.=0D +=0D + @param[in] SeverityType An error level to decide whether to enable = Trace Hub data.=0D + @param[in] Id Catalog ID.=0D + @param[in] Guid Driver Guid.=0D +=0D + @retval EFI_SUCCESS Data was written to Trace Hub.=0D + @retval Other Failed to output Trace Hub message.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +TraceHubWriteCataLog64StatusCode (=0D + IN TRACE_HUB_SEVERITY_TYPE SeverityType,=0D + IN UINT64 Id,=0D + IN EFI_GUID *Guid=0D + )=0D +{=0D + MIPI_SYST_HANDLE MipiSystHandle;=0D + MIPI_SYST_HEADER MipiSystHeader;=0D + UINT32 DbgInstCount;=0D + UINT8 *DgbContext;=0D + EFI_STATUS Status;=0D + UINTN Index;=0D +=0D + DbgInstCount =3D 0;=0D +=0D + Status =3D MigrateTraceHubHobData ();=0D +=0D + MipiSystHandle.systh_header =3D &MipiSystHeader;=0D +=0D + Status =3D InitMipiSystHandle (&MipiSystHandle);=0D + if (EFI_ERROR (Status)) {=0D + return Status;=0D + }=0D +=0D + if (Guid !=3D NULL) {=0D + //=0D + // Convert little endian to big endian.=0D + //=0D + Status =3D LittleEndianToBigEndian (Guid);=0D + CopyMem (&MipiSystHandle.systh_guid, Guid, sizeof (EFI_GUID));=0D + MipiSystHandle.systh_tag.et_guid =3D 1;=0D + } else {=0D + MipiSystHandle.systh_tag.et_modunit =3D 2;=0D + MipiSystHandle.systh_tag.et_guid =3D 0;=0D + }=0D +=0D + Status =3D CountDebugInstance (&DbgInstCount);=0D + if (EFI_ERROR (Status)) {=0D + return Status;=0D + }=0D +=0D + DgbContext =3D (UINT8 *)GetFirstGuidHob (&gUniversalPayloadTraceHubDebug= InfoGuid);=0D + for (Index =3D 0; Index < DbgInstCount; Index++) {=0D + Status =3D CheckWhetherToOutputMsg (=0D + &MipiSystHandle,=0D + DgbContext,=0D + (MIPI_SYST_SEVERITY)SeverityType,=0D + TraceHubCatalogType=0D + );=0D + if (!EFI_ERROR (Status)) {=0D + Status =3D MipiSystWriteCatalog (=0D + &MipiSystHandle,=0D + (MIPI_SYST_SEVERITY)SeverityType,=0D + Id=0D + );=0D + if (EFI_ERROR (Status)) {=0D + break;=0D + }=0D + }=0D +=0D + if (DgbContext !=3D NULL) {=0D + DgbContext =3D (UINT8 *)GetNextGuidHob (&gUniversalPayloadTraceHubDe= bugInfoGuid, GET_NEXT_HOB (DgbContext));=0D + if (DgbContext =3D=3D NULL) {=0D + break;=0D + }=0D + }=0D + }=0D +=0D + return Status;=0D +}=0D +=0D +/**=0D + Write catalog message to specified Trace Hub MMIO address.=0D +=0D + @param[in] SeverityType An error level to decide whether to enable Tr= ace Hub data.=0D + @param[in] Id Catalog ID.=0D + @param[in] NumberOfParams Number of parameters in argument list.=0D + @param[in] ... Argument list that pass to Trace Hub.=0D +=0D + @retval EFI_SUCCESS Data was written to Trace Hub.=0D + @retval Other Failed to output Trace Hub message.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +TraceHubWriteCataLog64 (=0D + IN TRACE_HUB_SEVERITY_TYPE SeverityType,=0D + IN UINT64 Id,=0D + IN UINTN NumberOfParams,=0D + ...=0D + )=0D +{=0D + MIPI_SYST_HANDLE MipiSystHandle;=0D + MIPI_SYST_HEADER MipiSystHeader;=0D + VA_LIST Args;=0D + UINTN Index;=0D + UINT32 DbgInstCount;=0D + UINT8 *DgbContext;=0D + EFI_STATUS Status;=0D +=0D + DbgInstCount =3D 0;=0D +=0D + if (NumberOfParams > 6) {=0D + //=0D + // Message with more than 6 parameter is illegal.=0D + //=0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D + Status =3D MigrateTraceHubHobData ();=0D +=0D + MipiSystHandle.systh_header =3D &MipiSystHeader;=0D +=0D + Status =3D InitMipiSystHandle (&MipiSystHandle);=0D + if (EFI_ERROR (Status)) {=0D + return Status;=0D + }=0D +=0D + MipiSystHandle.systh_param_count =3D (UINT32)NumberOfParams;=0D + VA_START (Args, NumberOfParams);=0D + for (Index =3D 0; Index < NumberOfParams; Index++) {=0D + MipiSystHandle.systh_param[Index] =3D VA_ARG (Args, UINT32);=0D + }=0D +=0D + VA_END (Args);=0D +=0D + Status =3D CountDebugInstance (&DbgInstCount);=0D + if (EFI_ERROR (Status)) {=0D + return Status;=0D + }=0D +=0D + DgbContext =3D (UINT8 *)GetFirstGuidHob (&gUniversalPayloadTraceHubDebug= InfoGuid);=0D + for (Index =3D 0; Index < DbgInstCount; Index++) {=0D + Status =3D CheckWhetherToOutputMsg (=0D + &MipiSystHandle,=0D + DgbContext,=0D + (MIPI_SYST_SEVERITY)SeverityType,=0D + TraceHubCatalogType=0D + );=0D + if (!EFI_ERROR (Status)) {=0D + Status =3D MipiSystWriteCatalog (=0D + &MipiSystHandle,=0D + (MIPI_SYST_SEVERITY)SeverityType,=0D + Id=0D + );=0D + if (EFI_ERROR (Status)) {=0D + break;=0D + }=0D + }=0D +=0D + if (DgbContext !=3D NULL) {=0D + DgbContext =3D (UINT8 *)GetNextGuidHob (&gUniversalPayloadTraceHubDe= bugInfoGuid, GET_NEXT_HOB (DgbContext));=0D + if (DgbContext =3D=3D NULL) {=0D + break;=0D + }=0D + }=0D + }=0D +=0D + return Status;=0D +}=0D +=0D +/**=0D + Collect the number of available Trace Hub debug instance.=0D +=0D + @param[in, out] DbgInstCount The number of available Trace Hub debug = instance.=0D +=0D + @retval EFI_SUCCESS Collect the number of available Trace Hub debug= instance successfully.=0D + @retval Other Failed to collect the number of available Trace= Hub debug instance.=0D +**/=0D +STATIC=0D +EFI_STATUS=0D +CountDebugInstance (=0D + IN OUT UINT32 *DbgInstCount=0D + )=0D +{=0D + UINT8 *DgbContext;=0D +=0D + if (DbgInstCount =3D=3D NULL) {=0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D + DgbContext =3D (UINT8 *)GetFirstGuidHob (&gUniversalPayloadTraceHubDebug= InfoGuid);=0D + if (DgbContext !=3D NULL) {=0D + while (DgbContext !=3D NULL) {=0D + (*DbgInstCount)++;=0D + DgbContext =3D (UINT8 *)GetNextGuidHob (&gUniversalPayloadTraceHubDe= bugInfoGuid, GET_NEXT_HOB (DgbContext));=0D + }=0D + } else {=0D + //=0D + // Trace Hub debug instance for PCD=0D + //=0D + (*DbgInstCount)++;=0D + }=0D +=0D + return EFI_SUCCESS;=0D +}=0D +=0D +/**=0D + Check whether to output Tracr Hub message.=0D +=0D + @param[in, out] MipiSystHandle A pointer to MIPI_SYST_HANDLE structur= e.=0D + @param[in, out] DgbContext A pointer to Trace Hub debug instance.= NULL is acceptable.=0D + @param[in] SeverityType An error level to decide whether to en= able Trace Hub data.=0D + @param[in] PrintType Either catalog print or debug print.=0D +=0D + @retval EFI_SUCCESS Current Trace Hub message need to be processed.= =0D + @retval Other Current Trace Hub message no need to be process= ed.=0D +**/=0D +STATIC=0D +EFI_STATUS=0D +CheckWhetherToOutputMsg (=0D + IN OUT MIPI_SYST_HANDLE *MipiSystHandle,=0D + IN OUT UINT8 *DgbContext,=0D + IN TRACE_HUB_SEVERITY_TYPE SeverityType,=0D + IN TRACEHUB_PRINTTYPE PrintType=0D + )=0D +{=0D + EFI_STATUS Status;=0D + UINTN Addr;=0D + UINT8 DbgLevel;=0D + BOOLEAN Flag;=0D +=0D + if (MipiSystHandle =3D=3D NULL) {=0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D + if (PrintType =3D=3D TraceHubDebugType) {=0D + Status =3D GetTraceHubMsgVisibility (DgbContext, &Flag, &DbgLevel);=0D + if (EFI_ERROR (Status)) {=0D + return Status;=0D + }=0D +=0D + if (!EnableTraceHubData (Flag, DbgLevel, SeverityType)) {=0D + return EFI_ABORTED;=0D + }=0D + }=0D +=0D + Status =3D GetTraceHubMmioAddress (DgbContext, &Addr);=0D + if (EFI_ERROR (Status)) {=0D + return Status;=0D + }=0D +=0D + MipiSystHandle->systh_platform.TraceHubPlatformData.MmioAddr =3D Addr;=0D + if (MipiSystHandle->systh_platform.TraceHubPlatformData.MmioAddr =3D=3D = 0) {=0D + return EFI_ABORTED;=0D + }=0D +=0D + return EFI_SUCCESS;=0D +}=0D +=0D +/**=0D + Get Trace Hub MMIO Address.=0D +=0D + @param[in] DgbContext A pointer to Trace Hub debug instance.= NULL is acceptable.=0D + @param[in, out] TraceAddress Trace Hub MMIO Address.=0D +=0D + @retval EFI_SUCCESS Get MMIO address successfully.=0D + @retval EFI_INVALID_PARAMETER TraceAddress is a NULL pointer.=0D +**/=0D +STATIC=0D +EFI_STATUS=0D +GetTraceHubMmioAddress (=0D + IN UINT8 *DgbContext,=0D + IN OUT UINTN *TraceAddress=0D + )=0D +{=0D + UNIVERSAL_PAYLOAD_TRACEHUB_DEBUG_INFO *ThDebugInfo;=0D +=0D + ThDebugInfo =3D NULL;=0D +=0D + if (TraceAddress =3D=3D NULL) {=0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D + if (DgbContext !=3D NULL) {=0D + ThDebugInfo =3D GET_GUID_HOB_DATA (DgbContext);=0D + *TraceAddress =3D ThDebugInfo->DebugContext.TraceAddress;=0D + } else {=0D + *TraceAddress =3D FixedPcdGet64 (PcdTraceHubDebugAddress);=0D + }=0D +=0D + return EFI_SUCCESS;=0D +}=0D +=0D +/**=0D + Get visibility of Trace Hub Msg.=0D +=0D + @param[in] DgbContext A pointer to Trace Hub debug instance. N= ULL is acceptable.=0D + @param[in, out] Flag Flag to enable or disable Trace Hub mess= age.=0D + @param[in, out] DbgLevel Debug Level of Trace Hub.=0D +=0D + @retval EFI_SUCCESS Get visibility of Trace Hub Msg successf= ully.=0D + @retval EFI_INVALID_PARAMETER On entry, Flag or DbgLevel is a NULL poi= nter.=0D +**/=0D +STATIC=0D +EFI_STATUS=0D +GetTraceHubMsgVisibility (=0D + IN UINT8 *DgbContext,=0D + IN OUT BOOLEAN *Flag,=0D + IN OUT UINT8 *DbgLevel=0D + )=0D +{=0D + UNIVERSAL_PAYLOAD_TRACEHUB_DEBUG_INFO *ThDebugInfo;=0D +=0D + ThDebugInfo =3D NULL;=0D +=0D + if ((DbgLevel =3D=3D NULL) || (Flag =3D=3D NULL)) {=0D + return EFI_INVALID_PARAMETER;=0D + }=0D +=0D + if (DgbContext !=3D NULL) {=0D + ThDebugInfo =3D GET_GUID_HOB_DATA (DgbContext);=0D + *DbgLevel =3D ThDebugInfo->DebugContext.DebugLevel;=0D + *Flag =3D ThDebugInfo->DebugContext.Flag;=0D + } else {=0D + *DbgLevel =3D FixedPcdGet8 (PcdTraceHubDebugLevel);=0D + *Flag =3D FixedPcdGetBool (PcdEnableTraceHubDebugMsg);=0D + }=0D +=0D + return EFI_SUCCESS;=0D +}=0D +=0D +/**=0D + Allocate boot time pool memory to store Trace Hub HOB data.=0D +=0D + @retval EFI_SUCCESS Migration process is successful.=0D + @retval Other Migration process is unsuccessful=0D +**/=0D +STATIC=0D +EFI_STATUS=0D +MigrateTraceHubHobData (=0D + VOID=0D + )=0D +{=0D + return EFI_UNSUPPORTED;=0D +}=0D diff --git a/MdeModulePkg/Library/TraceHubDebugLibSysT/TraceHubApiCommon.c = b/MdeModulePkg/Library/TraceHubDebugLibSysT/TraceHubApiCommon.c new file mode 100644 index 0000000000..0e7a09c95e --- /dev/null +++ b/MdeModulePkg/Library/TraceHubDebugLibSysT/TraceHubApiCommon.c @@ -0,0 +1,81 @@ +/** @file=0D +=0D +Copyright (c) 2023, Intel Corporation. All rights reserved.
=0D +=0D +SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D +**/=0D +=0D +#include =0D +#include =0D +#include =0D +#include "TraceHubApiCommon.h"=0D +=0D +/**=0D + Determine whether to enable Trace Hub message.=0D +=0D + @param[in] Flag Flag to enable or disable Trace Hub message.= =0D + @param[in] DbgLevel Debug Level of Trace Hub.=0D + @param[in] SeverityType Severity type of input message.=0D +=0D + @retval TRUE Enable trace hub message.=0D + @retval FALSE Disable trace hub message.=0D +**/=0D +BOOLEAN=0D +EFIAPI=0D +EnableTraceHubData (=0D + IN BOOLEAN Flag,=0D + IN UINT8 DbgLevel,=0D + IN TRACE_HUB_SEVERITY_TYPE SeverityType=0D + )=0D +{=0D + if (Flag =3D=3D TraceHubRoutingDisable) {=0D + return FALSE;=0D + }=0D +=0D + if (DbgLevel =3D=3D TraceHubDebugLevelError) {=0D + if (((SeverityType =3D=3D SeverityFatal) || (SeverityType =3D=3D Sever= ityError))) {=0D + return TRUE;=0D + }=0D + } else if (DbgLevel =3D=3D TraceHubDebugLevelErrorWarning) {=0D + if (((SeverityType =3D=3D SeverityFatal) || (SeverityType =3D=3D Sever= ityError) || (SeverityType =3D=3D SeverityWarning))) {=0D + return TRUE;=0D + }=0D + } else if (DbgLevel =3D=3D TraceHubDebugLevelErrorWarningInfo) {=0D + if (((SeverityType =3D=3D SeverityFatal) || (SeverityType =3D=3D Sever= ityError) || (SeverityType =3D=3D SeverityWarning) || (SeverityType =3D=3D = SeverityNormal))) {=0D + return TRUE;=0D + }=0D + } else if (DbgLevel =3D=3D TraceHubDebugLevelErrorWarningInfoVerbose) {= =0D + return TRUE;=0D + }=0D +=0D + return FALSE;=0D +}=0D +=0D +/**=0D + Convert GUID from little endian to big endian.=0D +=0D + @param[in, out] Guid GUID in little endian format on entry. GUID in b= ig endian format on exit.=0D +=0D + @retval EFI_SUCCESS Convert GUID successfully.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +LittleEndianToBigEndian (=0D + IN OUT EFI_GUID *Guid=0D + )=0D +{=0D + EFI_GUID TempGuid;=0D + UINT64 GuidData4;=0D +=0D + ZeroMem (&TempGuid, sizeof (EFI_GUID));=0D + TempGuid.Data1 =3D SwapBytes32 (Guid->Data1);=0D + TempGuid.Data2 =3D SwapBytes16 (Guid->Data2);=0D + TempGuid.Data3 =3D SwapBytes16 (Guid->Data3);=0D + CopyMem (&GuidData4, Guid->Data4, sizeof (Guid->Data4));=0D + GuidData4 =3D SwapBytes64 (GuidData4);=0D + CopyMem (TempGuid.Data4, &GuidData4, sizeof (GuidData4));=0D + CopyMem (Guid, &TempGuid, sizeof (EFI_GUID));=0D +=0D + return EFI_SUCCESS;=0D +}=0D diff --git a/MdeModulePkg/Library/TraceHubDebugLibSysT/TraceHubApiCommon.h = b/MdeModulePkg/Library/TraceHubDebugLibSysT/TraceHubApiCommon.h new file mode 100644 index 0000000000..f2f3cda8b7 --- /dev/null +++ b/MdeModulePkg/Library/TraceHubDebugLibSysT/TraceHubApiCommon.h @@ -0,0 +1,64 @@ +/** @file=0D +=0D +Copyright (c) 2023, Intel Corporation. All rights reserved.
=0D +=0D +SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D +**/=0D +=0D +#ifndef TRACE_HUB_API_COMMON_H_=0D +#define TRACE_HUB_API_COMMON_H_=0D +=0D +#include =0D +=0D +typedef enum {=0D + TraceHubDebugType =3D 0,=0D + TraceHubCatalogType=0D +} TRACEHUB_PRINTTYPE;=0D +=0D +typedef enum {=0D + TraceHubRoutingDisable =3D 0,=0D + TraceHubRoutingEnable,=0D + TraceHubRoutingMax=0D +} TRACE_HUB_ROUTING;=0D +=0D +typedef enum {=0D + TraceHubDebugLevelError =3D 0,=0D + TraceHubDebugLevelErrorWarning,=0D + TraceHubDebugLevelErrorWarningInfo,=0D + TraceHubDebugLevelErrorWarningInfoVerbose,=0D + TraceHubDebugLevelMax=0D +} TRACE_HUB_DEBUG_LEVEL;=0D +=0D +/**=0D + Determine whether to enable Trace Hub message.=0D +=0D + @param[in] Flag Flag to enable or disable Trace Hub message.= =0D + @param[in] DbgLevel Debug Level of Trace Hub.=0D + @param[in] SeverityType Severity type of input message.=0D +=0D + @retval TRUE Enable trace hub message.=0D + @retval FALSE Disable trace hub message.=0D +**/=0D +BOOLEAN=0D +EFIAPI=0D +EnableTraceHubData (=0D + IN BOOLEAN Flag,=0D + IN UINT8 DbgLevel,=0D + IN TRACE_HUB_SEVERITY_TYPE SeverityType=0D + );=0D +=0D +/**=0D + Convert GUID from little endian to big endian.=0D +=0D + @param[in, out] Guid GUID in little endian format on entry. GUID in b= ig endian format on exit.=0D +=0D + @retval EFI_SUCCESS Convert GUID successfully.=0D +**/=0D +EFI_STATUS=0D +EFIAPI=0D +LittleEndianToBigEndian (=0D + IN OUT EFI_GUID *Guid=0D + );=0D +=0D +#endif // TRACE_HUB_API_COMMON_H_=0D diff --git a/MdeModulePkg/Library/TraceHubDebugLibSysT/TraceHubApiInternal.= h b/MdeModulePkg/Library/TraceHubDebugLibSysT/TraceHubApiInternal.h new file mode 100644 index 0000000000..23a9879316 --- /dev/null +++ b/MdeModulePkg/Library/TraceHubDebugLibSysT/TraceHubApiInternal.h @@ -0,0 +1,92 @@ +/** @file=0D +=0D +Copyright (c) 2023, Intel Corporation. All rights reserved.
=0D +=0D +SPDX-License-Identifier: BSD-2-Clause-Patent=0D +=0D +**/=0D +=0D +#ifndef TRACE_HUB_API_INTERNAL_H_=0D +#define TRACE_HUB_API_INTERNAL_H_=0D +=0D +/**=0D + Collect the number of available Trace Hub debug instance.=0D +=0D + @param[in, out] DbgInstCount The number of available Trace Hub debug = instance.=0D +=0D + @retval EFI_SUCCESS Collect the number of available Trace Hub debug= instance successfully.=0D + @retval Other Failed to collect the number of available Trace= Hub debug instance.=0D +**/=0D +STATIC=0D +EFI_STATUS=0D +CountDebugInstance (=0D + IN OUT UINT32 *DbgInstCount=0D + );=0D +=0D +/**=0D + Check whether to output Tracr Hub message.=0D +=0D + @param[in, out] MipiSystHandle A pointer to MIPI_SYST_HANDLE structur= e.=0D + @param[in, out] DgbContext A pointer to Trace Hub debug instance.= =0D + @param[in] SeverityType An error level to decide whether to en= able Trace Hub data.=0D + @param[in] PrintType Either catalog print or debug print.=0D +=0D + @retval EFI_SUCCESS Current Trace Hub message need to be processed.= =0D + @retval Other Current Trace Hub message no need to be process= ed.=0D +**/=0D +STATIC=0D +EFI_STATUS=0D +CheckWhetherToOutputMsg (=0D + IN OUT MIPI_SYST_HANDLE *MipiSystHandle,=0D + IN OUT UINT8 *DgbContext,=0D + IN TRACE_HUB_SEVERITY_TYPE SeverityType,=0D + IN TRACEHUB_PRINTTYPE PrintType=0D + );=0D +=0D +/**=0D + Get visibility of Trace Hub Msg.=0D +=0D + @param[in] DgbContext A pointer to Trace Hub debug instance.=0D + @param[in, out] Flag Flag to enable or disable Trace Hub mess= age.=0D + @param[in, out] DbgLevel Debug Level of Trace Hub.=0D +=0D + @retval EFI_SUCCESS Get visibility of Trace Hub Msg successf= ully.=0D + @retval EFI_INVALID_PARAMETER On entry, Flag or DbgLevel is a NULL poi= nter.=0D +**/=0D +STATIC=0D +EFI_STATUS=0D +GetTraceHubMsgVisibility (=0D + IN UINT8 *DgbContext,=0D + IN OUT BOOLEAN *Flag,=0D + IN OUT UINT8 *DbgLevel=0D + );=0D +=0D +/**=0D + Get Trace Hub MMIO Address.=0D +=0D + @param[in] DgbContext A pointer to Trace Hub debug instance.= =0D + @param[in, out] TraceAddress Trace Hub MMIO Address.=0D +=0D + @retval EFI_SUCCESS Get MMIO address successfully.=0D + @retval EFI_INVALID_PARAMETER TraceAddress is a NULL pointer.=0D +**/=0D +STATIC=0D +EFI_STATUS=0D +GetTraceHubMmioAddress (=0D + IN UINT8 *DgbContext,=0D + IN OUT UINTN *TraceAddress=0D + );=0D +=0D +/**=0D + Allocate boot time pool memory to store Trace Hub HOB data.=0D +=0D + @retval EFI_SUCCESS Migration process is successful.=0D + @retval Other Migration process is unsuccessful=0D +**/=0D +STATIC=0D +EFI_STATUS=0D +MigrateTraceHubHobData (=0D + VOID=0D + );=0D +=0D +#endif // TRACE_HUB_API_INTERNAL_H_=0D diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index 9605c617b7..8300c88141 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -438,6 +438,9 @@ ## Include/UniversalPayload/SerialPortInfo.h=0D gUniversalPayloadSerialPortInfoGuid =3D { 0xaa7e190d, 0xbe21, 0x4409, { = 0x8e, 0x67, 0xa2, 0xcd, 0xf, 0x61, 0xe1, 0x70 } }=0D =0D + ## Include/UniversalPayload/TraceHubDebugInfo.h=0D + gUniversalPayloadTraceHubDebugInfoGuid =3D { 0xf88c9c23, 0x646c, 0x4f6c,= { 0x8e, 0x3d, 0x36, 0xa9, 0x43, 0xc1, 0x08, 0x35 } }=0D +=0D ## GUID used for Boot Discovery Policy FormSet guid and related variable= s.=0D gBootDiscoveryPolicyMgrFormsetGuid =3D { 0x5b6f7107, 0xbb3c, 0x4660, { 0= x92, 0xcd, 0x54, 0x26, 0x90, 0x28, 0x0b, 0xbd } }=0D =0D @@ -1093,6 +1096,24 @@ # @Prompt Enable UEFI Stack Guard.=0D gEfiMdeModulePkgTokenSpaceGuid.PcdCpuStackGuard|FALSE|BOOLEAN|0x30001055= =0D =0D + ## Indicate debug level of Trace Hub.=0D + # 0x0 - TraceHubDebugLevelError.
=0D + # 0x1 - TraceHubDebugLevelErrorWarning.
=0D + # 0x2 - TraceHubDebugLevelErrorWarningInfo.
=0D + # 0x3 - TraceHubDebugLevelErrorWarningInfoVerbose.
=0D + # @Prompt Debug level of Trace Hub.=0D + gEfiMdeModulePkgTokenSpaceGuid.PcdTraceHubDebugLevel|0|UINT8|0x30001056= =0D +=0D + ## Flag to enable or disable Trace Hub message.=0D + # FALSE - Disable Trace Hub debug message.
=0D + # TRUE - Enable Trace Hub debug message.
=0D + # @Prompt Enable or Disable Trace Hub message.=0D + gEfiMdeModulePkgTokenSpaceGuid.PcdEnableTraceHubDebugMsg|0|BOOLEAN|0x300= 01057=0D +=0D + ## Indicate MMIO address where Trace Hub message output to.=0D + # @Prompt Output MMIO address of Trace Hub message.=0D + gEfiMdeModulePkgTokenSpaceGuid.PcdTraceHubDebugAddress|0|UINT64|0x300010= 58=0D +=0D [PcdsFixedAtBuild, PcdsPatchableInModule]=0D ## Dynamic type PCD can be registered callback function for Pcd setting = action.=0D # PcdMaxPeiPcdCallBackNumberPerPcdEntry indicates the maximum number of= callback function=0D diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc index 1014598f31..a11f26572a 100644 --- a/MdeModulePkg/MdeModulePkg.dsc +++ b/MdeModulePkg/MdeModulePkg.dsc @@ -106,6 +106,9 @@ MmUnblockMemoryLib|MdePkg/Library/MmUnblockMemoryLib/MmUnblockMemoryLibN= ull.inf=0D VariableFlashInfoLib|MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseV= ariableFlashInfoLib.inf=0D IpmiCommandLib|MdeModulePkg/Library/BaseIpmiCommandLibNull/BaseIpmiComma= ndLibNull.inf=0D + TraceHubDebugLib|MdeModulePkg/Library/TraceHubDebugLibSysT/BaseTraceHubD= ebugLibSyst.inf=0D + TraceHubDebugLib|MdeModulePkg/Library/TraceHubDebugLibSysT/PeiTraceHubDe= bugLibSyst.inf=0D + TraceHubDebugLib|MdeModulePkg/Library/TraceHubDebugLibSysT/DxeSmmTraceHu= bDebugLibSyst.inf=0D =0D [LibraryClasses.EBC.PEIM]=0D IoLib|MdePkg/Library/PeiIoLibCpuIo/PeiIoLibCpuIo.inf=0D @@ -446,6 +449,9 @@ MdeModulePkg/Library/DxeCapsuleLibFmp/DxeCapsuleLib.inf=0D MdeModulePkg/Library/DxeCapsuleLibFmp/DxeRuntimeCapsuleLib.inf=0D MdeModulePkg/Library/BaseVariableFlashInfoLib/BaseVariableFlashInfoLib.i= nf=0D + MdeModulePkg/Library/TraceHubDebugLibSysT/BaseTraceHubDebugLibSyst.inf=0D + MdeModulePkg/Library/TraceHubDebugLibSysT/PeiTraceHubDebugLibSyst.inf=0D + MdeModulePkg/Library/TraceHubDebugLibSysT/DxeSmmTraceHubDebugLibSyst.inf= =0D =0D [Components.IA32, Components.X64, Components.AARCH64]=0D MdeModulePkg/Universal/EbcDxe/EbcDxe.inf=0D diff --git a/MdeModulePkg/MdeModulePkg.uni b/MdeModulePkg/MdeModulePkg.uni index 33ce9f6198..b64f26d255 100644 --- a/MdeModulePkg/MdeModulePkg.uni +++ b/MdeModulePkg/MdeModulePkg.uni @@ -1290,6 +1290,24 @@ = " TRUE - UEFI Stack Guard will be enabled.
\n"=0D = " FALSE - UEFI Stack Guard will be disabled.
"=0D =0D +#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdTraceHubDebugLevel_PROMPT #= language en-US "Debug level of Trace Hub."=0D +=0D +#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdTraceHubDebugLevel_HELP #= language en-US "Indicate debug level of Trace Hub"=0D + = " 0x0 - TraceHubDebugLevelError.
"=0D + = " 0x1 - TraceHubDebugLevelErrorWarning.
"=0D + = " 0x2 - TraceHubDebugLevelErrorWarningInfo.
"=0D + = " 0x3 - TraceHubDebugLevelErrorWarningInfoVerbose.
"=0D +=0D +#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdEnableTraceHubDebugMsg_PROMP= T #language en-US "Flag to enable or disable Trace Hub message"=0D +=0D +#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdEnableTraceHubDebugMsg_HELP = #language en-US "Enable or Disable Trace Hub message"=0D + = " FALSE - Disable Trace Hub debug message.
"=0D + = " TRUE - Enable Trace Hub debug message.
"=0D +=0D +#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdTraceHubDebugAddress_PROMPT = #language en-US "Output MMIO address of Trace Hub message"=0D +=0D +#string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdTraceHubDebugAddress_HELP = #language en-US "Indicate MMIO address where Trace Hub message output to."= =0D +=0D #string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdSetNvStoreDefaultId_PROMPT = #language en-US "NV Storage DefaultId"=0D =0D #string STR_gEfiMdeModulePkgTokenSpaceGuid_PcdSetNvStoreDefaultId_HELP = #language en-US "This dynamic PCD enables the default variable setting.\n"= =0D --=20 2.28.0.windows.1