diff options
Diffstat (limited to 'MdeModulePkg/Library')
11 files changed, 1391 insertions, 0 deletions
diff --git a/MdeModulePkg/Library/TraceHubDebugSysTLib/BaseTraceHubDebugSysTLib.c b/MdeModulePkg/Library/TraceHubDebugSysTLib/BaseTraceHubDebugSysTLib.c new file mode 100644 index 0000000000..45dfd3127a --- /dev/null +++ b/MdeModulePkg/Library/TraceHubDebugSysTLib/BaseTraceHubDebugSysTLib.c @@ -0,0 +1,245 @@ +/** @file
+System prints Trace Hub message in SEC/PEI/DXE/SMM based on fixed PCDs.
+Only support single Trace Hub debug instance.
+
+Copyright (c) 2023, Intel Corporation. All rights reserved.<BR>
+
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Base.h>
+#include <Library/BaseLib.h>
+#include <Library/PcdLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/TraceHubDebugSysTLib.h>
+#include <Library/MipiSysTLib.h>
+#include <Library/MipiSysTLib/mipi_syst.h>
+#include <Guid/TraceHubDebugInfoHob.h>
+#include "InternalTraceHubApiCommon.h"
+#include "InternalTraceHubApi.h"
+
+/**
+ Write debug string to specified Trace Hub MMIO address.
+
+ @param[in] SeverityType Severity type of input message.
+ @param[in] Buffer A pointer to the data buffer.
+ @param[in] NumberOfBytes The size of data buffer.
+
+ @retval RETURN_SUCCESS Data was written to Trace Hub.
+ @retval Other Failed to output Trace Hub message.
+**/
+RETURN_STATUS
+EFIAPI
+TraceHubSysTDebugWrite (
+ IN TRACE_HUB_SEVERITY_TYPE SeverityType,
+ IN UINT8 *Buffer,
+ IN UINTN NumberOfBytes
+ )
+{
+ MIPI_SYST_HANDLE MipiSystHandle;
+ MIPI_SYST_HEADER MipiSystHeader;
+ RETURN_STATUS Status;
+ UINT32 DbgInstCount;
+ UINT16 Index;
+
+ if (NumberOfBytes == 0) {
+ //
+ // No data need to be written to Trace Hub
+ //
+ return RETURN_SUCCESS;
+ }
+
+ if (Buffer == NULL) {
+ return RETURN_INVALID_PARAMETER;
+ }
+
+ DbgInstCount = CountThDebugInstance ();
+
+ ZeroMem (&MipiSystHandle, sizeof (MIPI_SYST_HANDLE));
+ MipiSystHandle.systh_header = &MipiSystHeader;
+
+ Status = InitMipiSystHandle (&MipiSystHandle);
+ if (RETURN_ERROR (Status)) {
+ return Status;
+ }
+
+ for (Index = 0; Index < DbgInstCount; Index++) {
+ Status = CheckWhetherToOutputMsg (
+ &MipiSystHandle,
+ NULL,
+ SeverityType,
+ TraceHubDebugType
+ );
+ if (!RETURN_ERROR (Status)) {
+ Status = MipiSystWriteDebug (
+ &MipiSystHandle,
+ SeverityType,
+ (UINT16)NumberOfBytes,
+ (CHAR8 *)Buffer
+ );
+ if (RETURN_ERROR (Status)) {
+ break;
+ }
+ }
+ }
+
+ return Status;
+}
+
+/**
+ Write catalog status code message to specified Trace Hub MMIO address.
+
+ @param[in] SeverityType Severity type of input message.
+ @param[in] Id Catalog ID.
+ @param[in] Guid Driver Guid.
+
+ @retval RETURN_SUCCESS Data was written to Trace Hub.
+ @retval Other Failed to output Trace Hub message.
+**/
+RETURN_STATUS
+EFIAPI
+TraceHubSysTWriteCataLog64StatusCode (
+ IN TRACE_HUB_SEVERITY_TYPE SeverityType,
+ IN UINT64 Id,
+ IN GUID *Guid
+ )
+{
+ MIPI_SYST_HANDLE MipiSystHandle;
+ MIPI_SYST_HEADER MipiSystHeader;
+ RETURN_STATUS Status;
+ UINT32 DbgInstCount;
+ UINT16 Index;
+
+ if (Guid == NULL) {
+ return RETURN_INVALID_PARAMETER;
+ }
+
+ DbgInstCount = CountThDebugInstance ();
+
+ ZeroMem (&MipiSystHandle, sizeof (MIPI_SYST_HANDLE));
+ MipiSystHandle.systh_header = &MipiSystHeader;
+
+ Status = InitMipiSystHandle (&MipiSystHandle);
+ if (RETURN_ERROR (Status)) {
+ return Status;
+ }
+
+ SwapBytesGuid (Guid, (GUID *)(VOID *)&MipiSystHandle.systh_guid);
+ MipiSystHandle.systh_tag.et_guid = 1;
+
+ for (Index = 0; Index < DbgInstCount; Index++) {
+ Status = CheckWhetherToOutputMsg (
+ &MipiSystHandle,
+ NULL,
+ SeverityType,
+ TraceHubCatalogType
+ );
+ if (!RETURN_ERROR (Status)) {
+ Status = MipiSystWriteCatalog (
+ &MipiSystHandle,
+ SeverityType,
+ Id
+ );
+ if (RETURN_ERROR (Status)) {
+ break;
+ }
+ }
+ }
+
+ return Status;
+}
+
+/**
+ Write catalog message to specified Trace Hub MMIO address.
+
+ @param[in] SeverityType Severity type of input message.
+ @param[in] Id Catalog ID.
+ @param[in] NumberOfParams Number of entries in argument list.
+ @param[in] ... Catalog message parameters.
+
+ @retval RETURN_SUCCESS Data was written to Trace Hub.
+ @retval Other Failed to output Trace Hub message.
+**/
+RETURN_STATUS
+EFIAPI
+TraceHubSysTWriteCataLog64 (
+ IN TRACE_HUB_SEVERITY_TYPE SeverityType,
+ IN UINT64 Id,
+ IN UINTN NumberOfParams,
+ ...
+ )
+{
+ MIPI_SYST_HANDLE MipiSystHandle;
+ MIPI_SYST_HEADER MipiSystHeader;
+ VA_LIST Args;
+ UINTN Index;
+ RETURN_STATUS Status;
+ UINT32 DbgInstCount;
+
+ DbgInstCount = 0;
+
+ if (NumberOfParams > sizeof (MipiSystHandle.systh_param) / sizeof (UINT32)) {
+ return RETURN_INVALID_PARAMETER;
+ }
+
+ DbgInstCount = CountThDebugInstance ();
+
+ ZeroMem (&MipiSystHandle, sizeof (MIPI_SYST_HANDLE));
+ MipiSystHandle.systh_header = &MipiSystHeader;
+
+ Status = InitMipiSystHandle (&MipiSystHandle);
+ if (RETURN_ERROR (Status)) {
+ return Status;
+ }
+
+ MipiSystHandle.systh_param_count = (UINT32)NumberOfParams;
+ VA_START (Args, NumberOfParams);
+ for (Index = 0; Index < NumberOfParams; Index++) {
+ MipiSystHandle.systh_param[Index] = VA_ARG (Args, UINT32);
+ }
+
+ VA_END (Args);
+
+ for (Index = 0; Index < DbgInstCount; Index++) {
+ Status = CheckWhetherToOutputMsg (
+ &MipiSystHandle,
+ NULL,
+ SeverityType,
+ TraceHubCatalogType
+ );
+ if (!RETURN_ERROR (Status)) {
+ Status = MipiSystWriteCatalog (
+ &MipiSystHandle,
+ SeverityType,
+ Id
+ );
+ if (RETURN_ERROR (Status)) {
+ break;
+ }
+ }
+ }
+
+ return Status;
+}
+
+/**
+ Collect the total number of Trace Hub debug instance in the system.
+
+ @retval UINT32 The total number of Trace Hub debug instance in the system.
+**/
+UINT32
+EFIAPI
+CountThDebugInstance (
+ VOID
+ )
+{
+ UINT32 DbgInstCount;
+
+ //
+ // 1 from PCD.
+ //
+ DbgInstCount = 1;
+
+ return DbgInstCount;
+}
diff --git a/MdeModulePkg/Library/TraceHubDebugSysTLib/BaseTraceHubDebugSysTLib.inf b/MdeModulePkg/Library/TraceHubDebugSysTLib/BaseTraceHubDebugSysTLib.inf new file mode 100644 index 0000000000..3edc4e8fd8 --- /dev/null +++ b/MdeModulePkg/Library/TraceHubDebugSysTLib/BaseTraceHubDebugSysTLib.inf @@ -0,0 +1,44 @@ +## @file
+# Debug library to output Trace Hub message.
+# Support SEC/PEI/DXE/SMM phase TraceHub debug message based on fixed settings.
+#
+# Copyright (c) 2023, Intel Corporation. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = BaseTraceHubDebugSysTLib
+ FILE_GUID = 336DA571-AD65-423C-9A43-E0056E5B2D8D
+ MODULE_TYPE = BASE
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = TraceHubDebugSysTLib
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64
+#
+
+[LibraryClasses]
+ BaseLib
+ PcdLib
+ BaseMemoryLib
+ MipiSysTLib
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+
+[Sources]
+ BaseTraceHubDebugSysTLib.c
+ InternalTraceHubApiCommon.c
+ InternalTraceHubApiCommon.h
+ InternalTraceHubApi.h
+
+[Pcd]
+ gEfiMdeModulePkgTokenSpaceGuid.PcdTraceHubDebugLevel
+ gEfiMdeModulePkgTokenSpaceGuid.PcdEnableTraceHubDebugMsg
+ gEfiMdeModulePkgTokenSpaceGuid.PcdTraceHubDebugMmioAddress
diff --git a/MdeModulePkg/Library/TraceHubDebugSysTLib/DxeSmmTraceHubDebugSysTLib.c b/MdeModulePkg/Library/TraceHubDebugSysTLib/DxeSmmTraceHubDebugSysTLib.c new file mode 100644 index 0000000000..35c239b5fe --- /dev/null +++ b/MdeModulePkg/Library/TraceHubDebugSysTLib/DxeSmmTraceHubDebugSysTLib.c @@ -0,0 +1,263 @@ +/** @file
+System prints Trace Hub message in DXE/SMM based on fixed PCDs and HOB.
+Trace Hub PCDs will be applied if no HOB exist.
+
+Copyright (c) 2023, Intel Corporation. All rights reserved.<BR>
+
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Base.h>
+#include <Library/BaseLib.h>
+#include <Library/PcdLib.h>
+#include <Library/HobLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/TraceHubDebugSysTLib.h>
+#include <Library/MipiSysTLib.h>
+#include <Library/MipiSysTLib/mipi_syst.h>
+#include <Guid/TraceHubDebugInfoHob.h>
+#include "InternalTraceHubApiCommon.h"
+#include "InternalTraceHubApi.h"
+
+GLOBAL_REMOVE_IF_UNREFERENCED TRACEHUB_DEBUG_INFO_HOB *mThDebugInstArray = NULL;
+GLOBAL_REMOVE_IF_UNREFERENCED UINT32 mDbgInstCount = 0;
+
+/**
+ Write debug string to specified Trace Hub MMIO address.
+
+ @param[in] SeverityType Severity type of input message.
+ @param[in] Buffer A pointer to the data buffer.
+ @param[in] NumberOfBytes The size of data buffer.
+
+ @retval RETURN_SUCCESS Data was written to Trace Hub.
+ @retval Other Failed to output Trace Hub message.
+**/
+RETURN_STATUS
+EFIAPI
+TraceHubSysTDebugWrite (
+ IN TRACE_HUB_SEVERITY_TYPE SeverityType,
+ IN UINT8 *Buffer,
+ IN UINTN NumberOfBytes
+ )
+{
+ MIPI_SYST_HANDLE MipiSystHandle;
+ MIPI_SYST_HEADER MipiSystHeader;
+ RETURN_STATUS Status;
+ UINT16 Index;
+
+ if ((mDbgInstCount == 0) || (mThDebugInstArray == NULL)) {
+ return RETURN_ABORTED;
+ }
+
+ if (NumberOfBytes == 0) {
+ //
+ // No data need to be written to Trace Hub
+ //
+ return RETURN_SUCCESS;
+ }
+
+ if (Buffer == NULL) {
+ return RETURN_INVALID_PARAMETER;
+ }
+
+ ZeroMem (&MipiSystHandle, sizeof (MIPI_SYST_HANDLE));
+ MipiSystHandle.systh_header = &MipiSystHeader;
+
+ Status = InitMipiSystHandle (&MipiSystHandle);
+ if (RETURN_ERROR (Status)) {
+ return Status;
+ }
+
+ for (Index = 0; Index < mDbgInstCount; Index++) {
+ Status = CheckWhetherToOutputMsg (
+ &MipiSystHandle,
+ (UINT8 *)&mThDebugInstArray[Index],
+ SeverityType,
+ TraceHubDebugType
+ );
+ if (!RETURN_ERROR (Status)) {
+ Status = MipiSystWriteDebug (
+ &MipiSystHandle,
+ SeverityType,
+ (UINT16)NumberOfBytes,
+ (CHAR8 *)Buffer
+ );
+ if (RETURN_ERROR (Status)) {
+ break;
+ }
+ }
+ }
+
+ return Status;
+}
+
+/**
+ Write catalog status code message to specified Trace Hub MMIO address.
+
+ @param[in] SeverityType Severity type of input message.
+ @param[in] Id Catalog ID.
+ @param[in] Guid Driver Guid.
+
+ @retval RETURN_SUCCESS Data was written to Trace Hub.
+ @retval Other Failed to output Trace Hub message.
+**/
+RETURN_STATUS
+EFIAPI
+TraceHubSysTWriteCataLog64StatusCode (
+ IN TRACE_HUB_SEVERITY_TYPE SeverityType,
+ IN UINT64 Id,
+ IN GUID *Guid
+ )
+{
+ MIPI_SYST_HANDLE MipiSystHandle;
+ MIPI_SYST_HEADER MipiSystHeader;
+ UINTN Index;
+ RETURN_STATUS Status;
+
+ if ((mDbgInstCount == 0) || (mThDebugInstArray == NULL)) {
+ return RETURN_ABORTED;
+ }
+
+ ZeroMem (&MipiSystHandle, sizeof (MIPI_SYST_HANDLE));
+ MipiSystHandle.systh_header = &MipiSystHeader;
+
+ Status = InitMipiSystHandle (&MipiSystHandle);
+ if (RETURN_ERROR (Status)) {
+ return Status;
+ }
+
+ if (Guid != NULL) {
+ SwapBytesGuid (Guid, (GUID *)(VOID *)&MipiSystHandle.systh_guid);
+ MipiSystHandle.systh_tag.et_guid = 1;
+ } else {
+ MipiSystHandle.systh_tag.et_modunit = 2;
+ MipiSystHandle.systh_tag.et_guid = 0;
+ }
+
+ for (Index = 0; Index < mDbgInstCount; Index++) {
+ Status = CheckWhetherToOutputMsg (
+ &MipiSystHandle,
+ (UINT8 *)&mThDebugInstArray[Index],
+ SeverityType,
+ TraceHubCatalogType
+ );
+ if (!RETURN_ERROR (Status)) {
+ Status = MipiSystWriteCatalog (
+ &MipiSystHandle,
+ SeverityType,
+ Id
+ );
+ if (RETURN_ERROR (Status)) {
+ break;
+ }
+ }
+ }
+
+ return Status;
+}
+
+/**
+ Write catalog message to specified Trace Hub MMIO address.
+
+ @param[in] SeverityType Severity type of input message.
+ @param[in] Id Catalog ID.
+ @param[in] NumberOfParams Number of entries in argument list.
+ @param[in] ... Catalog message parameters.
+
+ @retval RETURN_SUCCESS Data was written to Trace Hub.
+ @retval Other Failed to output Trace Hub message.
+**/
+RETURN_STATUS
+EFIAPI
+TraceHubSysTWriteCataLog64 (
+ IN TRACE_HUB_SEVERITY_TYPE SeverityType,
+ IN UINT64 Id,
+ IN UINTN NumberOfParams,
+ ...
+ )
+{
+ MIPI_SYST_HANDLE MipiSystHandle;
+ MIPI_SYST_HEADER MipiSystHeader;
+ VA_LIST Args;
+ UINTN Index;
+ RETURN_STATUS Status;
+
+ if (NumberOfParams > sizeof (MipiSystHandle.systh_param) / sizeof (UINT32)) {
+ return RETURN_INVALID_PARAMETER;
+ }
+
+ if ((mDbgInstCount == 0) || (mThDebugInstArray == NULL)) {
+ return RETURN_ABORTED;
+ }
+
+ ZeroMem (&MipiSystHandle, sizeof (MIPI_SYST_HANDLE));
+ MipiSystHandle.systh_header = &MipiSystHeader;
+
+ Status = InitMipiSystHandle (&MipiSystHandle);
+ if (RETURN_ERROR (Status)) {
+ return Status;
+ }
+
+ MipiSystHandle.systh_param_count = (UINT32)NumberOfParams;
+ VA_START (Args, NumberOfParams);
+ for (Index = 0; Index < NumberOfParams; Index++) {
+ MipiSystHandle.systh_param[Index] = VA_ARG (Args, UINT32);
+ }
+
+ VA_END (Args);
+
+ for (Index = 0; Index < mDbgInstCount; Index++) {
+ Status = CheckWhetherToOutputMsg (
+ &MipiSystHandle,
+ (UINT8 *)&mThDebugInstArray[Index],
+ SeverityType,
+ TraceHubCatalogType
+ );
+ if (!RETURN_ERROR (Status)) {
+ Status = MipiSystWriteCatalog (
+ &MipiSystHandle,
+ SeverityType,
+ Id
+ );
+ if (RETURN_ERROR (Status)) {
+ break;
+ }
+ }
+ }
+
+ return Status;
+}
+
+/**
+ Constructor to get TraceHob configuration data
+
+ @param ImageHandle The firmware allocated handle for the EFI image.
+ @param SystemTable A pointer to the EFI System Table.
+
+ @retval RETURN_SUCCESS The constructor always returns EFI_SUCCESS.
+ @retval RETURN_OUT_OF_RESOURCES There are not enough resources available to retrieve the matching FFS section.
+
+**/
+RETURN_STATUS
+EFIAPI
+DxeSmmTraceHubDebugSysTLibConstructor (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ if (mDbgInstCount == 0) {
+ mDbgInstCount = CountThDebugInstance ();
+ }
+
+ mThDebugInstArray = AllocateZeroPool (mDbgInstCount * sizeof (TRACEHUB_DEBUG_INFO_HOB));
+
+ if (mThDebugInstArray != NULL) {
+ PackThDebugInstance (mThDebugInstArray, mDbgInstCount);
+ } else {
+ return RETURN_OUT_OF_RESOURCES;
+ }
+
+ return RETURN_SUCCESS;
+}
diff --git a/MdeModulePkg/Library/TraceHubDebugSysTLib/DxeSmmTraceHubDebugSysTLib.inf b/MdeModulePkg/Library/TraceHubDebugSysTLib/DxeSmmTraceHubDebugSysTLib.inf new file mode 100644 index 0000000000..90213beee1 --- /dev/null +++ b/MdeModulePkg/Library/TraceHubDebugSysTLib/DxeSmmTraceHubDebugSysTLib.inf @@ -0,0 +1,51 @@ +## @file
+# Debug library to output Trace Hub message.
+# Support DXE/SMM phase TraceHub debug message based on fixed or dynamic settings.
+#
+# Copyright (c) 2023, Intel Corporation. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = DxeSmmTraceHubDebugSysTLib
+ FILE_GUID = A9B7B825-7902-4616-8556-085DA4DFEC72
+ MODULE_TYPE = DXE_DRIVER
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = TraceHubDebugSysTLib|DXE_CORE DXE_DRIVER SMM_CORE DXE_SMM_DRIVER UEFI_DRIVER UEFI_APPLICATION
+ CONSTRUCTOR = DxeSmmTraceHubDebugSysTLibConstructor
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64
+#
+
+[LibraryClasses]
+ BaseLib
+ PcdLib
+ HobLib
+ BaseMemoryLib
+ MemoryAllocationLib
+ MipiSysTLib
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+
+[Sources]
+ DxeSmmTraceHubDebugSysTLib.c
+ InternalTraceHubApiCommon.c
+ InternalTraceHubApiCommon.h
+ InternalTraceHubApi.h
+ InternalTraceHubApi.c
+
+[Guids]
+ gTraceHubDebugInfoHobGuid
+
+[Pcd]
+ gEfiMdeModulePkgTokenSpaceGuid.PcdTraceHubDebugLevel
+ gEfiMdeModulePkgTokenSpaceGuid.PcdEnableTraceHubDebugMsg
+ gEfiMdeModulePkgTokenSpaceGuid.PcdTraceHubDebugMmioAddress
diff --git a/MdeModulePkg/Library/TraceHubDebugSysTLib/InternalTraceHubApi.c b/MdeModulePkg/Library/TraceHubDebugSysTLib/InternalTraceHubApi.c new file mode 100644 index 0000000000..fe946fe60c --- /dev/null +++ b/MdeModulePkg/Library/TraceHubDebugSysTLib/InternalTraceHubApi.c @@ -0,0 +1,74 @@ +/** @file
+Functions implementation in this file are not common for all type of TraceHubDebugSysTLib.
+
+Copyright (c) 2023, Intel Corporation. All rights reserved.<BR>
+
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Base.h>
+#include <Guid/TraceHubDebugInfoHob.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/HobLib.h>
+#include "InternalTraceHubApi.h"
+
+/**
+ Count the total number of Trace Hub debug instance in the system.
+
+ @retval UINT32 The total number of Trace Hub debug instance in the system.
+**/
+UINT32
+EFIAPI
+CountThDebugInstance (
+ VOID
+ )
+{
+ UINT8 *DbgContext;
+ UINT32 DbgInstCount;
+
+ DbgInstCount = 0;
+
+ DbgContext = (UINT8 *)GetFirstGuidHob (&gTraceHubDebugInfoHobGuid);
+ if (DbgContext != NULL) {
+ while (DbgContext != NULL) {
+ DbgInstCount++;
+ DbgContext = (UINT8 *)GetNextGuidHob (&gTraceHubDebugInfoHobGuid, GET_NEXT_HOB (DbgContext));
+ }
+ } else {
+ DbgInstCount++;
+ }
+
+ return DbgInstCount;
+}
+
+/**
+ Pack Trace Hub debug instances in the system.
+
+ @param[in, out] ThPtr A pointer to TRACEHUB_DEBUG_INFO_HOB structure.
+ @param[in] Count Number of Trace Hub HOBs.
+**/
+VOID
+EFIAPI
+PackThDebugInstance (
+ IN OUT TRACEHUB_DEBUG_INFO_HOB *ThPtr,
+ IN UINT32 Count
+ )
+{
+ UINT8 *DbgContext;
+ UINT16 Index;
+
+ DbgContext = GetFirstGuidHob (&gTraceHubDebugInfoHobGuid);
+ if (DbgContext != NULL) {
+ for (Index = 0; Index < Count; Index++) {
+ CopyMem (&ThPtr[Index], GET_GUID_HOB_DATA (DbgContext), sizeof (TRACEHUB_DEBUG_INFO_HOB));
+ DbgContext = GetNextGuidHob (&gTraceHubDebugInfoHobGuid, GET_NEXT_HOB (DbgContext));
+ }
+ } else {
+ for (Index = 0; Index < Count; Index++) {
+ ThPtr[Index].TraceHubMmioAddress = FixedPcdGet64 (PcdTraceHubDebugMmioAddress);
+ ThPtr[Index].Flag = FixedPcdGetBool (PcdEnableTraceHubDebugMsg);
+ ThPtr[Index].DebugLevel = FixedPcdGet8 (PcdTraceHubDebugLevel);
+ }
+ }
+}
diff --git a/MdeModulePkg/Library/TraceHubDebugSysTLib/InternalTraceHubApi.h b/MdeModulePkg/Library/TraceHubDebugSysTLib/InternalTraceHubApi.h new file mode 100644 index 0000000000..f624f73768 --- /dev/null +++ b/MdeModulePkg/Library/TraceHubDebugSysTLib/InternalTraceHubApi.h @@ -0,0 +1,37 @@ +/** @file
+This header file declares functions that are not for common use.
+
+Copyright (c) 2023, Intel Corporation. All rights reserved.<BR>
+
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef INTERNAL_TRACE_HUB_API_H_
+#define INTERNAL_TRACE_HUB_API_H_
+
+/**
+ Count the total number of Trace Hub debug instance in the system.
+
+ @retval UINT32 The total number of Trace Hub debug instance in the system.
+**/
+UINT32
+EFIAPI
+CountThDebugInstance (
+ VOID
+ );
+
+/**
+ Pack Trace Hub debug instances in the system.
+
+ @param[in, out] ThPtr A pointer to TRACEHUB_DEBUG_INFO_HOB structure.
+ @param[in] Count Number of Trace Hub HOBs.
+**/
+VOID
+EFIAPI
+PackThDebugInstance (
+ IN OUT TRACEHUB_DEBUG_INFO_HOB *ThPtr,
+ IN UINT32 Count
+ );
+
+#endif // INTERNAL_TRACE_HUB_API_H_
diff --git a/MdeModulePkg/Library/TraceHubDebugSysTLib/InternalTraceHubApiCommon.c b/MdeModulePkg/Library/TraceHubDebugSysTLib/InternalTraceHubApiCommon.c new file mode 100644 index 0000000000..fe77f486f4 --- /dev/null +++ b/MdeModulePkg/Library/TraceHubDebugSysTLib/InternalTraceHubApiCommon.c @@ -0,0 +1,200 @@ +/** @file
+Functions implementation defined in this file are common for all type of TraceHubDebugSysTLib
+
+Copyright (c) 2023, Intel Corporation. All rights reserved.<BR>
+
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Base.h>
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/TraceHubDebugSysTLib.h>
+#include <Library/MipiSysTLib/mipi_syst.h>
+#include <Guid/TraceHubDebugInfoHob.h>
+#include "InternalTraceHubApiCommon.h"
+#include "InternalTraceHubApi.h"
+
+/**
+ Conditionally determine whether to enable Trace Hub message.
+
+ @param[in] Flag Flag to enable or disable Trace Hub message.
+ @param[in] DbgLevel Debug Level of Trace Hub.
+ @param[in] SeverityType Severity type of input message.
+
+ @retval TRUE Enable trace hub message.
+ @retval FALSE Disable trace hub message.
+**/
+BOOLEAN
+EFIAPI
+TraceHubDataEnabled (
+ IN BOOLEAN Flag,
+ IN UINT8 DbgLevel,
+ IN TRACE_HUB_SEVERITY_TYPE SeverityType
+ )
+{
+ if (Flag == TraceHubRoutingDisable) {
+ return FALSE;
+ }
+
+ if (DbgLevel == TraceHubDebugLevelError) {
+ if (((SeverityType == SeverityFatal) || (SeverityType == SeverityError))) {
+ return TRUE;
+ }
+ } else if (DbgLevel == TraceHubDebugLevelErrorWarning) {
+ if (((SeverityType == SeverityFatal) || (SeverityType == SeverityError) || (SeverityType == SeverityWarning))) {
+ return TRUE;
+ }
+ } else if (DbgLevel == TraceHubDebugLevelErrorWarningInfo) {
+ if (((SeverityType == SeverityFatal) || (SeverityType == SeverityError) || (SeverityType == SeverityWarning) || (SeverityType == SeverityNormal))) {
+ return TRUE;
+ }
+ } else if (DbgLevel == TraceHubDebugLevelErrorWarningInfoVerbose) {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+/**
+ Convert GUID from LE to BE or BE to LE.
+
+ @param[in] Guid GUID that need to be converted.
+ @param[out] ConvertedGuid GUID that is converted.
+**/
+VOID
+EFIAPI
+SwapBytesGuid (
+ IN GUID *Guid,
+ OUT GUID *ConvertedGuid
+ )
+{
+ CopyGuid (ConvertedGuid, Guid);
+ ConvertedGuid->Data1 = SwapBytes32 (ConvertedGuid->Data1);
+ ConvertedGuid->Data2 = SwapBytes16 (ConvertedGuid->Data2);
+ ConvertedGuid->Data3 = SwapBytes16 (ConvertedGuid->Data3);
+}
+
+/**
+ Check whether to output Trace Hub message according to some conditions.
+ Trace Hub message will be disabled if TraceHubDataEnabled() return FALSE
+ or Trace Hub MMIO address is 0.
+
+ @param[in, out] MipiSystHandle A pointer to MIPI_SYST_HANDLE structure.
+ @param[in] DbgContext A pointer to Trace Hub debug instance.
+ @param[in] SeverityType Severity type of input message.
+ @param[in] PrintType Either catalog print or debug print.
+
+ @retval RETURN_SUCCESS Current Trace Hub message need to be output.
+ @retval Other Current Trace Hub message will be disabled.
+**/
+RETURN_STATUS
+EFIAPI
+CheckWhetherToOutputMsg (
+ IN OUT MIPI_SYST_HANDLE *MipiSystHandle,
+ IN UINT8 *DbgContext,
+ IN TRACE_HUB_SEVERITY_TYPE SeverityType,
+ IN TRACEHUB_PRINTTYPE PrintType
+ )
+{
+ UINT8 DbgLevel;
+ BOOLEAN Flag;
+ UINT64 Addr;
+ RETURN_STATUS Status;
+
+ if (MipiSystHandle == NULL) {
+ return RETURN_INVALID_PARAMETER;
+ }
+
+ if (PrintType == TraceHubDebugType) {
+ Status = GetTraceHubMsgVisibility (DbgContext, &Flag, &DbgLevel);
+ if (RETURN_ERROR (Status)) {
+ return Status;
+ }
+
+ if (!TraceHubDataEnabled (Flag, DbgLevel, SeverityType)) {
+ return RETURN_ABORTED;
+ }
+ }
+
+ Status = GetTraceHubMmioAddress (DbgContext, &Addr);
+ if (RETURN_ERROR (Status)) {
+ return Status;
+ }
+
+ MipiSystHandle->systh_platform.TraceHubPlatformData.MmioAddr = Addr;
+ if (MipiSystHandle->systh_platform.TraceHubPlatformData.MmioAddr == 0) {
+ return RETURN_ABORTED;
+ }
+
+ return RETURN_SUCCESS;
+}
+
+/**
+ Get Trace Hub MMIO Address.
+
+ @param[in] DbgContext A pointer to Trace Hub debug instance.
+ @param[in, out] TraceAddress Trace Hub MMIO Address.
+
+ @retval RETURN_SUCCESS Operation is successfully.
+ @retval Other Operation is failed.
+**/
+RETURN_STATUS
+EFIAPI
+GetTraceHubMmioAddress (
+ IN UINT8 *DbgContext,
+ IN OUT UINT64 *TraceAddress
+ )
+{
+ TRACEHUB_DEBUG_INFO_HOB *ThDbgContext;
+
+ if (TraceAddress == NULL) {
+ return RETURN_INVALID_PARAMETER;
+ }
+
+ if (DbgContext != NULL) {
+ ThDbgContext = (TRACEHUB_DEBUG_INFO_HOB *)DbgContext;
+ *TraceAddress = ThDbgContext->TraceHubMmioAddress;
+ } else {
+ *TraceAddress = FixedPcdGet64 (PcdTraceHubDebugMmioAddress);
+ }
+
+ return RETURN_SUCCESS;
+}
+
+/**
+ Get visibility of Trace Hub Msg.
+
+ @param[in] DbgContext A pointer to Trace Hub debug instance.
+ @param[in, out] Flag Flag to enable or disable Trace Hub message.
+ @param[in, out] DbgLevel Debug Level of Trace Hub.
+
+ @retval RETURN_SUCCESS Operation is successfully.
+ @retval Other Operation is failed.
+**/
+RETURN_STATUS
+EFIAPI
+GetTraceHubMsgVisibility (
+ IN UINT8 *DbgContext,
+ IN OUT BOOLEAN *Flag,
+ IN OUT UINT8 *DbgLevel
+ )
+{
+ TRACEHUB_DEBUG_INFO_HOB *ThDbgContext;
+
+ if ((Flag == NULL) || (DbgLevel == NULL)) {
+ return RETURN_INVALID_PARAMETER;
+ }
+
+ if (DbgContext != NULL) {
+ ThDbgContext = (TRACEHUB_DEBUG_INFO_HOB *)DbgContext;
+ *Flag = ThDbgContext->Flag;
+ *DbgLevel = ThDbgContext->DebugLevel;
+ } else {
+ *DbgLevel = FixedPcdGet8 (PcdTraceHubDebugLevel);
+ *Flag = FixedPcdGetBool (PcdEnableTraceHubDebugMsg);
+ }
+
+ return RETURN_SUCCESS;
+}
diff --git a/MdeModulePkg/Library/TraceHubDebugSysTLib/InternalTraceHubApiCommon.h b/MdeModulePkg/Library/TraceHubDebugSysTLib/InternalTraceHubApiCommon.h new file mode 100644 index 0000000000..b8be48a8bb --- /dev/null +++ b/MdeModulePkg/Library/TraceHubDebugSysTLib/InternalTraceHubApiCommon.h @@ -0,0 +1,119 @@ +/** @file
+This header file declares functions and type for common use.
+
+Copyright (c) 2023, Intel Corporation. All rights reserved.<BR>
+
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#ifndef INTERNAL_TRACE_HUB_API_COMMON_H_
+#define INTERNAL_TRACE_HUB_API_COMMON_H_
+
+typedef enum {
+ TraceHubDebugType = 0,
+ TraceHubCatalogType
+} TRACEHUB_PRINTTYPE;
+
+typedef enum {
+ TraceHubRoutingDisable = 0,
+ TraceHubRoutingEnable,
+ TraceHubRoutingMax
+} TRACE_HUB_ROUTING;
+
+typedef enum {
+ TraceHubDebugLevelError = 0,
+ TraceHubDebugLevelErrorWarning,
+ TraceHubDebugLevelErrorWarningInfo,
+ TraceHubDebugLevelErrorWarningInfoVerbose,
+ TraceHubDebugLevelMax
+} TRACE_HUB_DEBUG_LEVEL;
+
+/**
+ Conditionally determine whether to enable Trace Hub message.
+
+ @param[in] Flag Flag to enable or disable Trace Hub message.
+ @param[in] DbgLevel Debug Level of Trace Hub.
+ @param[in] SeverityType Severity type of input message.
+
+ @retval TRUE Enable trace hub message.
+ @retval FALSE Disable trace hub message.
+**/
+BOOLEAN
+EFIAPI
+TraceHubDataEnabled (
+ IN BOOLEAN Flag,
+ IN UINT8 DbgLevel,
+ IN TRACE_HUB_SEVERITY_TYPE SeverityType
+ );
+
+/**
+ Convert GUID from LE to BE or BE to LE.
+
+ @param[in] Guid GUID that need to be converted.
+ @param[out] ConvertedGuid GUID that is converted.
+**/
+VOID
+EFIAPI
+SwapBytesGuid (
+ IN GUID *Guid,
+ OUT GUID *ConvertedGuid
+ );
+
+/**
+ Check whether to output Trace Hub message according to some conditions.
+ Trace Hub message will be disabled if TraceHubDataEnabled() return FALSE
+ or Trace Hub MMIO address is 0.
+
+ @param[in, out] MipiSystHandle A pointer to MIPI_SYST_HANDLE structure.
+ @param[in] DbgContext A pointer to Trace Hub debug instance.
+ @param[in] SeverityType Severity type of input message.
+ @param[in] PrintType Either catalog print or debug print.
+
+ @retval RETURN_SUCCESS Current Trace Hub message need to be output.
+ @retval Other Current Trace Hub message will be disabled.
+**/
+RETURN_STATUS
+EFIAPI
+CheckWhetherToOutputMsg (
+ IN OUT MIPI_SYST_HANDLE *MipiSystHandle,
+ IN UINT8 *DbgContext,
+ IN TRACE_HUB_SEVERITY_TYPE SeverityType,
+ IN TRACEHUB_PRINTTYPE PrintType
+ );
+
+/**
+ Get Trace Hub MMIO Address.
+
+ @param[in] DbgContext A pointer to Trace Hub debug instance.
+ @param[in, out] TraceAddress Trace Hub MMIO Address.
+
+ @retval RETURN_SUCCESS Operation is successfully.
+ @retval Other Operation is failed.
+**/
+RETURN_STATUS
+EFIAPI
+GetTraceHubMmioAddress (
+ IN UINT8 *DbgContext,
+ IN OUT UINT64 *TraceAddress
+ );
+
+/**
+ Get visibility of Trace Hub Msg.
+
+ @param[in] DbgContext A pointer to Trace Hub debug instance.
+ @param[in, out] Flag Flag to enable or disable Trace Hub message.
+ @param[in, out] DbgLevel Debug Level of Trace Hub.
+
+ @retval RETURN_SUCCESS Operation is successfully.
+ @retval Other Operation is failed.
+**/
+RETURN_STATUS
+EFIAPI
+GetTraceHubMsgVisibility (
+ IN UINT8 *DbgContext,
+ IN OUT BOOLEAN *Flag,
+ IN OUT UINT8 *DbgLevel
+ );
+
+#endif // INTERNAL_TRACE_HUB_API_COMMON_H_
diff --git a/MdeModulePkg/Library/TraceHubDebugSysTLib/PeiTraceHubDebugSysTLib.c b/MdeModulePkg/Library/TraceHubDebugSysTLib/PeiTraceHubDebugSysTLib.c new file mode 100644 index 0000000000..e68fb8b242 --- /dev/null +++ b/MdeModulePkg/Library/TraceHubDebugSysTLib/PeiTraceHubDebugSysTLib.c @@ -0,0 +1,282 @@ +/** @file
+System prints Trace Hub message in PEI based on fixed PCDs and HOB.
+System applies Trace Hub HOB once it detect gTraceHubDebugInfoHobGuid HOB.
+Trace Hub PCDs will be applied if no HOB exist.
+
+Copyright (c) 2023, Intel Corporation. All rights reserved.<BR>
+
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <Base.h>
+#include <Library/BaseLib.h>
+#include <Library/PcdLib.h>
+#include <Library/HobLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/TraceHubDebugSysTLib.h>
+#include <Library/MipiSysTLib.h>
+#include <Library/MipiSysTLib/mipi_syst.h>
+#include <Guid/TraceHubDebugInfoHob.h>
+#include "InternalTraceHubApiCommon.h"
+#include "InternalTraceHubApi.h"
+
+/**
+ Write debug string to specified Trace Hub MMIO address.
+
+ @param[in] SeverityType Severity type of input message.
+ @param[in] Buffer A pointer to the data buffer.
+ @param[in] NumberOfBytes The size of data buffer.
+
+ @retval RETURN_SUCCESS Data was written to Trace Hub.
+ @retval Other Failed to output Trace Hub message.
+**/
+RETURN_STATUS
+EFIAPI
+TraceHubSysTDebugWrite (
+ IN TRACE_HUB_SEVERITY_TYPE SeverityType,
+ IN UINT8 *Buffer,
+ IN UINTN NumberOfBytes
+ )
+{
+ MIPI_SYST_HANDLE MipiSystHandle;
+ MIPI_SYST_HEADER MipiSystHeader;
+ RETURN_STATUS Status;
+ UINT8 *DbgContext;
+ UINTN Index;
+ UINT32 DbgInstCount;
+ UINT8 *ThDebugInfo;
+
+ if (NumberOfBytes == 0) {
+ //
+ // No data need to be written to Trace Hub
+ //
+ return RETURN_SUCCESS;
+ }
+
+ if (Buffer == NULL) {
+ return RETURN_INVALID_PARAMETER;
+ }
+
+ DbgInstCount = CountThDebugInstance ();
+
+ ZeroMem (&MipiSystHandle, sizeof (MIPI_SYST_HANDLE));
+ MipiSystHandle.systh_header = &MipiSystHeader;
+
+ Status = InitMipiSystHandle (&MipiSystHandle);
+ if (RETURN_ERROR (Status)) {
+ return Status;
+ }
+
+ DbgContext = (UINT8 *)GetFirstGuidHob (&gTraceHubDebugInfoHobGuid);
+ if (DbgContext != NULL) {
+ ThDebugInfo = GET_GUID_HOB_DATA (DbgContext);
+ } else {
+ ThDebugInfo = NULL;
+ }
+
+ for (Index = 0; Index < DbgInstCount; Index++) {
+ Status = CheckWhetherToOutputMsg (
+ &MipiSystHandle,
+ ThDebugInfo,
+ SeverityType,
+ TraceHubDebugType
+ );
+ if (!RETURN_ERROR (Status)) {
+ Status = MipiSystWriteDebug (
+ &MipiSystHandle,
+ SeverityType,
+ (UINT16)NumberOfBytes,
+ (CHAR8 *)Buffer
+ );
+ if (RETURN_ERROR (Status)) {
+ break;
+ }
+ }
+
+ if (DbgContext != NULL) {
+ DbgContext = (UINT8 *)GetNextGuidHob (&gTraceHubDebugInfoHobGuid, GET_NEXT_HOB (DbgContext));
+ if (DbgContext == NULL) {
+ break;
+ }
+
+ ThDebugInfo = GET_GUID_HOB_DATA (DbgContext);
+ }
+ }
+
+ return Status;
+}
+
+/**
+ Write catalog status code message to specified Trace Hub MMIO address.
+
+ @param[in] SeverityType Severity type of input message.
+ @param[in] Id Catalog ID.
+ @param[in] Guid Driver Guid.
+
+ @retval RETURN_SUCCESS Data was written to Trace Hub.
+ @retval Other Failed to output Trace Hub message.
+**/
+RETURN_STATUS
+EFIAPI
+TraceHubSysTWriteCataLog64StatusCode (
+ IN TRACE_HUB_SEVERITY_TYPE SeverityType,
+ IN UINT64 Id,
+ IN GUID *Guid
+ )
+{
+ MIPI_SYST_HANDLE MipiSystHandle;
+ MIPI_SYST_HEADER MipiSystHeader;
+ UINT32 DbgInstCount;
+ UINT8 *DbgContext;
+ RETURN_STATUS Status;
+ UINTN Index;
+ UINT8 *ThDebugInfo;
+
+ DbgInstCount = CountThDebugInstance ();
+
+ ZeroMem (&MipiSystHandle, sizeof (MIPI_SYST_HANDLE));
+ MipiSystHandle.systh_header = &MipiSystHeader;
+
+ Status = InitMipiSystHandle (&MipiSystHandle);
+ if (RETURN_ERROR (Status)) {
+ return Status;
+ }
+
+ if (Guid != NULL) {
+ SwapBytesGuid (Guid, (GUID *)(VOID *)&MipiSystHandle.systh_guid);
+ MipiSystHandle.systh_tag.et_guid = 1;
+ } else {
+ MipiSystHandle.systh_tag.et_modunit = 2;
+ MipiSystHandle.systh_tag.et_guid = 0;
+ }
+
+ DbgContext = (UINT8 *)GetFirstGuidHob (&gTraceHubDebugInfoHobGuid);
+ if (DbgContext != NULL) {
+ ThDebugInfo = GET_GUID_HOB_DATA (DbgContext);
+ } else {
+ ThDebugInfo = NULL;
+ }
+
+ for (Index = 0; Index < DbgInstCount; Index++) {
+ Status = CheckWhetherToOutputMsg (
+ &MipiSystHandle,
+ ThDebugInfo,
+ SeverityType,
+ TraceHubCatalogType
+ );
+ if (!RETURN_ERROR (Status)) {
+ Status = MipiSystWriteCatalog (
+ &MipiSystHandle,
+ SeverityType,
+ Id
+ );
+ if (RETURN_ERROR (Status)) {
+ break;
+ }
+ }
+
+ if (DbgContext != NULL) {
+ DbgContext = (UINT8 *)GetNextGuidHob (&gTraceHubDebugInfoHobGuid, GET_NEXT_HOB (DbgContext));
+ if (DbgContext == NULL) {
+ break;
+ }
+
+ ThDebugInfo = GET_GUID_HOB_DATA (DbgContext);
+ }
+ }
+
+ return Status;
+}
+
+/**
+ Write catalog message to specified Trace Hub MMIO address.
+
+ @param[in] SeverityType Severity type of input message.
+ @param[in] Id Catalog ID.
+ @param[in] NumberOfParams Number of entries in argument list.
+ @param[in] ... Catalog message parameters.
+
+ @retval RETURN_SUCCESS Data was written to Trace Hub.
+ @retval Other Failed to output Trace Hub message.
+**/
+RETURN_STATUS
+EFIAPI
+TraceHubSysTWriteCataLog64 (
+ IN TRACE_HUB_SEVERITY_TYPE SeverityType,
+ IN UINT64 Id,
+ IN UINTN NumberOfParams,
+ ...
+ )
+{
+ MIPI_SYST_HANDLE MipiSystHandle;
+ MIPI_SYST_HEADER MipiSystHeader;
+ VA_LIST Args;
+ UINTN Index;
+ UINT32 DbgInstCount;
+ UINT8 *DbgContext;
+ RETURN_STATUS Status;
+ UINT8 *ThDebugInfo;
+
+ DbgInstCount = 0;
+
+ if (NumberOfParams > sizeof (MipiSystHandle.systh_param) / sizeof (UINT32)) {
+ return RETURN_INVALID_PARAMETER;
+ }
+
+ DbgInstCount = CountThDebugInstance ();
+
+ ZeroMem (&MipiSystHandle, sizeof (MIPI_SYST_HANDLE));
+ MipiSystHandle.systh_header = &MipiSystHeader;
+
+ Status = InitMipiSystHandle (&MipiSystHandle);
+ if (RETURN_ERROR (Status)) {
+ return Status;
+ }
+
+ MipiSystHandle.systh_param_count = (UINT32)NumberOfParams;
+ VA_START (Args, NumberOfParams);
+ for (Index = 0; Index < NumberOfParams; Index++) {
+ MipiSystHandle.systh_param[Index] = VA_ARG (Args, UINT32);
+ }
+
+ VA_END (Args);
+
+ DbgContext = (UINT8 *)GetFirstGuidHob (&gTraceHubDebugInfoHobGuid);
+ if (DbgContext != NULL) {
+ ThDebugInfo = GET_GUID_HOB_DATA (DbgContext);
+ } else {
+ ThDebugInfo = NULL;
+ }
+
+ for (Index = 0; Index < DbgInstCount; Index++) {
+ Status = CheckWhetherToOutputMsg (
+ &MipiSystHandle,
+ ThDebugInfo,
+ SeverityType,
+ TraceHubCatalogType
+ );
+ if (!RETURN_ERROR (Status)) {
+ Status = MipiSystWriteCatalog (
+ &MipiSystHandle,
+ SeverityType,
+ Id
+ );
+ if (RETURN_ERROR (Status)) {
+ break;
+ }
+ }
+
+ if (DbgContext != NULL) {
+ DbgContext = (UINT8 *)GetNextGuidHob (&gTraceHubDebugInfoHobGuid, GET_NEXT_HOB (DbgContext));
+ if (DbgContext == NULL) {
+ break;
+ }
+
+ ThDebugInfo = GET_GUID_HOB_DATA (DbgContext);
+ }
+ }
+
+ return Status;
+}
diff --git a/MdeModulePkg/Library/TraceHubDebugSysTLib/PeiTraceHubDebugSysTLib.inf b/MdeModulePkg/Library/TraceHubDebugSysTLib/PeiTraceHubDebugSysTLib.inf new file mode 100644 index 0000000000..2a8184d927 --- /dev/null +++ b/MdeModulePkg/Library/TraceHubDebugSysTLib/PeiTraceHubDebugSysTLib.inf @@ -0,0 +1,50 @@ +## @file
+# Debug library to output Trace Hub message.
+# Support PEI phase TraceHub debug message based on fixed or dynamic settings.
+#
+# Copyright (c) 2023, Intel Corporation. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = PeiTraceHubDebugSysTLib
+ FILE_GUID = C61E8C2E-0935-4E3D-BCBB-5ED84AFD9FD1
+ MODULE_TYPE = PEIM
+ VERSION_STRING = 1.0
+ LIBRARY_CLASS = TraceHubDebugSysTLib|PEI_CORE PEIM
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64
+#
+
+[LibraryClasses]
+ BaseLib
+ PcdLib
+ HobLib
+ BaseMemoryLib
+ MemoryAllocationLib
+ MipiSysTLib
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+
+[Sources]
+ PeiTraceHubDebugSysTLib.c
+ InternalTraceHubApiCommon.c
+ InternalTraceHubApiCommon.h
+ InternalTraceHubApi.h
+ InternalTraceHubApi.c
+
+[Guids]
+ gTraceHubDebugInfoHobGuid
+
+[Pcd]
+ gEfiMdeModulePkgTokenSpaceGuid.PcdTraceHubDebugLevel
+ gEfiMdeModulePkgTokenSpaceGuid.PcdEnableTraceHubDebugMsg
+ gEfiMdeModulePkgTokenSpaceGuid.PcdTraceHubDebugMmioAddress
diff --git a/MdeModulePkg/Library/TraceHubDebugSysTLib/Readme.md b/MdeModulePkg/Library/TraceHubDebugSysTLib/Readme.md new file mode 100644 index 0000000000..9e798a41bf --- /dev/null +++ b/MdeModulePkg/Library/TraceHubDebugSysTLib/Readme.md @@ -0,0 +1,26 @@ +## Introduction of TrcaceHubDebugSysTLib ##
+TrcaceHubDebugSysTLib library is a top level library for dumping Trace Hub messages.
+It provides Trace Hub related APIs to dump Trace Hub message via MIPI SYS-T submodule.
+User need to properly configure following Trace Hub related PCDs and HOB.
+ (See MdeModulePkg.dec to get detailed definition for PCDs below)
+ - PcdTraceHubDebugLevel
+ - PcdEnableTraceHubDebugMsg
+ - PcdTraceHubDebugMmioAddress
+ (See TraceHubDebugInfoHob.h to get detailed definition for HOB below)
+ - gTraceHubDebugInfoHobGuid
+
+## BaseTraceHubDebugSysTLib.inf ##
+System prints Trace Hub message in SEC/PEI/DXE/SMM based on fixed PCDs.
+Only support single Trace Hub debug instance.
+
+## PeiTraceHubDebugSysTLib.inf ##
+System prints Trace Hub message in PEI based on fixed PCDs and HOB.
+System applies Trace Hub HOB once it detect gTraceHubDebugInfoHobGuid HOB.
+Trace Hub PCDs will be applied if no HOB exist.
+
+## DxeSmmTraceHubDebugSysTLib.inf ##
+System prints Trace Hub message in DXE/SMM based on fixed PCDs and HOB.
+Trace Hub PCDs will be applied if no HOB exist.
+
+## Note ##
+Trace Hub debug library not support DXE_RUNTIME_DRIVER type of module currently.
|