diff options
author | Gua Guo <gua.guo@intel.com> | 2023-05-10 10:15:35 +0800 |
---|---|---|
committer | mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> | 2023-05-11 07:26:38 +0000 |
commit | 0f0422cedc752d305d8d12a25b11e1dff4d8ff8b (patch) | |
tree | 613581c4ff815a4d87a68a3830a26517247a9888 /MdeModulePkg/Library/TraceHubDebugSysTLib/InternalTraceHubApi.c | |
parent | 3d50fdc5c6878b865a4b244430c3f26b77943996 (diff) | |
download | edk2-0f0422cedc752d305d8d12a25b11e1dff4d8ff8b.tar.gz edk2-0f0422cedc752d305d8d12a25b11e1dff4d8ff8b.tar.bz2 edk2-0f0422cedc752d305d8d12a25b11e1dff4d8ff8b.zip |
MdeModulePkg: Add TraceHubDebugSysTLib library
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4144
This Library provides API to dump Trace Hub message.
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Guo Gua <gua.guo@intel.com>
Cc: Chan Laura <laura.chan@intel.com>
Cc: Prakashan Krishnadas Veliyathuparambil <krishnadas.veliyathuparambil.prakashan@intel.com>
Cc: K N Karthik <karthik.k.n@intel.com>
Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Guo Gua <gua.guo@intel.com>
Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>
Reviewed-by: K N Karthik <karthik.k.n@intel.com>
Reviewed-by: Chan Laura <laura.chan@intel.com>
Acked-by: Liming Gao <gaoliming@byosoft.com.cn>
Diffstat (limited to 'MdeModulePkg/Library/TraceHubDebugSysTLib/InternalTraceHubApi.c')
-rw-r--r-- | MdeModulePkg/Library/TraceHubDebugSysTLib/InternalTraceHubApi.c | 74 |
1 files changed, 74 insertions, 0 deletions
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);
+ }
+ }
+}
|