Skip to content

Commit

Permalink
MdeModulePkg: Add Trace Hub debug library
Browse files Browse the repository at this point in the history
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4144

Part 2: Provide a debug library which consumed by Trace Hub to
output debug message.

Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: VictorX Hsu <victorx.hsu@intel.com>
  • Loading branch information
hsuc1x committed Jan 4, 2023
1 parent 2712055 commit 35aa958
Show file tree
Hide file tree
Showing 17 changed files with 2,563 additions and 0 deletions.
78 changes: 78 additions & 0 deletions MdeModulePkg/Include/Library/TraceHubDebugLib.h
@@ -0,0 +1,78 @@
/** @file
Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/

#ifndef TRACE_HUB_DEBUG_LIB_H_
#define TRACE_HUB_DEBUG_LIB_H_

#include <Uefi/UefiBaseType.h>
#include <Guid/StatusCodeDataTypeDebug.h>

typedef enum {
SeverityNone = 0,
SeverityFatal = 1,
SeverityError = 2,
SeverityWarning = 3,
SeverityNormal = 4,
SeverityUser1 = 5,
SeverityUser2 = 6,
SeverityUser3 = 7,
SeverityMax
} TRACE_HUB_SEVERITY_TYPE;

/**
Write debug string to specified Trace Hub MMIO address.
@param[in] SeverityType An error level to decide whether to enable Trace Hub data.
@param[in] Buffer A pointer to the data buffer.
@param[in] NumberOfBytes Number of bytes to be written.
@retval EFI_SUCCESS Data was written to Trace Hub.
@retval EFI_DEVICE_ERROR No available Mipi Sys-T handle.
@retval Other Data failed to write to Trace Hub.
**/
EFI_STATUS
EFIAPI
TraceHubDebugWrite (
IN TRACE_HUB_SEVERITY_TYPE SeverityType,
IN UINT8 *Buffer,
IN UINTN NumberOfBytes
);

/**
Write catalog status code message to specified Trace Hub MMIO address.
@param[in] SeverityType An error level to decide whether to enable Trace Hub data.
@param[in] Id Catalog ID.
@param[in] Guid Driver Guid.
**/
VOID
EFIAPI
TraceHubWriteCataLog64StatusCode (
IN TRACE_HUB_SEVERITY_TYPE SeverityType,
IN UINT64 Id,
IN EFI_GUID *Guid
);

/**
Write catalog message to specified Trace Hub MMIO address.
@param[in] SeverityType An error level to decide whether to enable Trace Hub data.
@param[in] Id Catalog ID.
@param[in] NumberOfParams Number of parameters in argument list.
@param[in] ... Argument list that pass to Trace Hub.
**/
VOID
EFIAPI
TraceHubWriteCataLog64 (
IN TRACE_HUB_SEVERITY_TYPE SeverityType,
IN UINT64 Id,
IN UINTN NumberOfParams,
...
);

#endif // TRACE_HUB_DEBUG_LIB_H_
71 changes: 71 additions & 0 deletions MdeModulePkg/Library/TraceHubDebugLibNull/TraceHubDebugLibNull.c
@@ -0,0 +1,71 @@
/** @file
Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/

#include <Base.h>
#include <Library/DebugLib.h>
#include <Library/TraceHubDebugLib.h>

/**
Write debug string to specified Trace Hub MMIO address.
@param[in] SeverityType An error level to decide whether to enable Trace Hub data.
@param[in] Buffer A pointer to the data buffer.
@param[in] NumberOfBytes Number of bytes to be written.
@retval EFI_SUCCESS Data was written to Trace Hub.
@retval EFI_DEVICE_ERROR No available Mipi Sys-T handle.
@retval Other Data failed to write to Trace Hub.
**/
EFI_STATUS
EFIAPI
TraceHubDebugWrite (
IN TRACE_HUB_SEVERITY_TYPE SeverityType,
IN UINT8 *Buffer,
IN UINTN NumberOfBytes
)
{
ASSERT (Buffer != NULL || NumberOfBytes == 0);

return EFI_UNSUPPORTED;
}

/**
Write catalog status code message to specified Trace Hub MMIO address.
@param[in] SeverityType An error level to decide whether to enable Trace Hub data.
@param[in] Id Catalog ID.
@param[in] Guid Driver Guid.
**/
VOID
EFIAPI
TraceHubWriteCataLog64StatusCode (
IN TRACE_HUB_SEVERITY_TYPE SeverityType,
IN UINT64 Id,
IN EFI_GUID *Guid
)
{
}

/**
Write catalog message to specified Trace Hub MMIO address.
@param[in] SeverityType An error level to decide whether to enable Trace Hub data.
@param[in] Id Catalog ID.
@param[in] NumberOfParams Number of parameters in argument list.
@param[in] ... Argument list that pass to Trace Hub.
**/
VOID
EFIAPI
TraceHubWriteCataLog64 (
IN TRACE_HUB_SEVERITY_TYPE SeverityType,
IN UINT64 Id,
IN UINTN NumberOfParams,
...
)
{
}
33 changes: 33 additions & 0 deletions MdeModulePkg/Library/TraceHubDebugLibNull/TraceHubDebugLibNull.inf
@@ -0,0 +1,33 @@
## @file
# Null library of TraceHubDebugLib.
#
# Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
##


[Defines]
INF_VERSION = 0x00010005
BASE_NAME = TraceHubDebugLibNull
FILE_GUID = 16196A4E-4196-4AF4-9A6B-F4D2ACC430A8
MODULE_TYPE = BASE
VERSION_STRING = 1.0
LIBRARY_CLASS = TraceHubDebugLib

#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64
#

[LibraryClasses]
DebugLib

[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec

[Sources]
TraceHubDebugLibNull.c
@@ -0,0 +1,44 @@
## @file
# TraceHubDebugLib for common usage.
#
# Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
##

[Defines]
INF_VERSION = 0x00010005
BASE_NAME = BaseTraceHubDebugLibSyst
FILE_GUID = 336DA571-AD65-423C-9A43-E0056E5B2D8D
MODULE_TYPE = BASE
VERSION_STRING = 1.0
LIBRARY_CLASS = TraceHubDebugLib

#
# The following information is for reference only and not required by the build tools.
#
# VALID_ARCHITECTURES = IA32 X64
#

[LibraryClasses]
PcdLib
DebugLib
BaseMemoryLib
BaseLib

[Packages]
MdePkg/MdePkg.dec
MdeModulePkg/MdeModulePkg.dec

[Sources]
BaseTraceHubDebugSystLib.c
EnableTraceHubData.c
EnableTraceHubData.h
MipiSystApi.c
MipiSystApi.h
MipiSyst.h

[Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdTraceHubDebugVerbosity
gEfiMdeModulePkgTokenSpaceGuid.PcdTraceHubDebugAddress

0 comments on commit 35aa958

Please sign in to comment.