Skip to content

Commit

Permalink
MdeModulePkg: Upstream implementation of Trace Hub to Edk2
Browse files Browse the repository at this point in the history
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4144

Provide a library which consumed by Trace Hub in UPL architecture

Cc: Jian J Wang <jian.j.wang@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: VictorX Hsu <victorx.hsu@intel.com>
  • Loading branch information
hsuc1x committed Nov 10, 2022
1 parent 2695e49 commit 9bc21f5
Show file tree
Hide file tree
Showing 20 changed files with 3,772 additions and 0 deletions.
199 changes: 199 additions & 0 deletions MdeModulePkg/Include/Library/TraceHubDebugLib.h
@@ -0,0 +1,199 @@
/** @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 Statuscode to NPK with GUID information.
This API would be enabled for Release BIOS Only
@param[in] SeverityType Severity type of the written data buffer.
@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 data from buffer and Severity to TraceHub.
Writes NumberOfBytes data bytes from Buffer and Severity to TraceHub.
If Buffer is NULL or NumberOfBytes is larger than zero, then ASSERT().
If NumberOfBytes is zero, no buffer is written.
@param[in] SeverityType Severity type of the written data buffer.
@param[in] Buffer Pointer to the data buffer to be written.
@param[in] NumberOfBytes Number of bytes to written to TraceHub device.
@retval EFI_SUCCESS The number of bytes written to TraceHub.
@retval Other Fail to write the buffer to TraceHub.
**/
EFI_STATUS
EFIAPI
TraceHubDebugWrite (
IN TRACE_HUB_SEVERITY_TYPE SeverityType,
IN UINT8 *Buffer,
IN UINTN NumberOfBytes
);

/**
Write catalog64 message mipi_syst event with 0 parameters to TraceHub
@param[in] SeverityType Severity type of the catid message event.
@param[in] Id Catalog ID
**/
VOID
EFIAPI
TraceHubWriteCataLog64_0 (
IN TRACE_HUB_SEVERITY_TYPE SeverityType,
IN UINT64 Id
);

/**
Write catalog64 message mipi_syst event with 1 parameters to TraceHub
@param[in] SeverityType Severity type of the catid message event.
@param[in] Id Catalog ID
@param[in] Param1 Parameter 1 passed to catid message event.
**/
VOID
EFIAPI
TraceHubWriteCataLog64_1 (
IN TRACE_HUB_SEVERITY_TYPE SeverityType,
IN UINT64 Id,
IN UINT32 Param1
);

/**
Write catalog64 message mipi_syst event with 2 parameters to TraceHub
@param[in] SeverityType Severity type of the catid message event.
@param[in] Id Catalog ID
@param[in] Param1 Parameter 1 passed to catid message event.
@param[in] Param2 Parameter 2 passed to catid message event.
**/
VOID
EFIAPI
TraceHubWriteCataLog64_2 (
IN TRACE_HUB_SEVERITY_TYPE SeverityType,
IN UINT64 Id,
IN UINT32 Param1,
IN UINT32 Param2
);

/**
Write catalog64 message mipi_syst event with 3 parameters to TraceHub
@param[in] SeverityType Severity type of the catid message event.
@param[in] Id Catalog ID
@param[in] Param1 Parameter 1 passed to catid message event.
@param[in] Param2 Parameter 2 passed to catid message event.
@param[in] Param3 Parameter 3 passed to catid message event.
**/
VOID
EFIAPI
TraceHubWriteCataLog64_3 (
IN TRACE_HUB_SEVERITY_TYPE SeverityType,
IN UINT64 Id,
IN UINT32 Param1,
IN UINT32 Param2,
IN UINT32 Param3
);

/**
Write catalog64 message mipi_syst event with 4 parameters to TraceHub
@param[in] SeverityType Severity type of the catid message event.
@param[in] Id Catalog ID
@param[in] Param1 Parameter 1 passed to catid message event.
@param[in] Param2 Parameter 2 passed to catid message event.
@param[in] Param3 Parameter 3 passed to catid message event.
@param[in] Param4 Parameter 4 passed to catid message event.
**/
VOID
EFIAPI
TraceHubWriteCataLog64_4 (
IN TRACE_HUB_SEVERITY_TYPE SeverityType,
IN UINT64 Id,
IN UINT32 Param1,
IN UINT32 Param2,
IN UINT32 Param3,
IN UINT32 Param4
);

/**
Write catalog64 message mipi_syst event with 5 parameters to TraceHub
@param[in] SeverityType Severity type of the catid message event.
@param[in] Id Catalog ID
@param[in] Param1 Parameter 1 passed to catid message event.
@param[in] Param2 Parameter 2 passed to catid message event.
@param[in] Param3 Parameter 3 passed to catid message event.
@param[in] Param4 Parameter 4 passed to catid message event.
@param[in] Param5 Parameter 5 passed to catid message event.
**/
VOID
EFIAPI
TraceHubWriteCataLog64_5 (
IN TRACE_HUB_SEVERITY_TYPE SeverityType,
IN UINT64 Id,
IN UINT32 Param1,
IN UINT32 Param2,
IN UINT32 Param3,
IN UINT32 Param4,
IN UINT32 Param5
);

/**
Write catalog64 message mipi_syst event with 6 parameters to TraceHub
@param[in] SeverityType Severity type of the catid message event.
@param[in] Id Catalog ID
@param[in] Param1 Parameter 1 passed to catid message event.
@param[in] Param2 Parameter 2 passed to catid message event.
@param[in] Param3 Parameter 3 passed to catid message event.
@param[in] Param4 Parameter 4 passed to catid message event.
@param[in] Param5 Parameter 5 passed to catid message event.
@param[in] Param6 Parameter 6 passed to catid message event.
**/
VOID
EFIAPI
TraceHubWriteCataLog64_6 (
IN TRACE_HUB_SEVERITY_TYPE SeverityType,
IN UINT64 Id,
IN UINT32 Param1,
IN UINT32 Param2,
IN UINT32 Param3,
IN UINT32 Param4,
IN UINT32 Param5,
IN UINT32 Param6
);

#endif // TRACE_HUB_DEBUG_LIB_H_
35 changes: 35 additions & 0 deletions MdeModulePkg/Include/UniversalPayload/TraceHubDebugInfo.h
@@ -0,0 +1,35 @@
/** @file
Define the structure for the Universal Payload TraceHub Debug Info.
Copyright (c) 2022, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
@par Revision Reference:
- Universal Payload Specification 0.9 (https://universalpayload.github.io/documentation/)
**/

#ifndef UNIVERSAL_PAYLOAD_TRACEHUB_DEBUG_INFO_H_
#define UNIVERSAL_PAYLOAD_TRACEHUB_DEBUG_INFO_H_

#include <Uefi.h>
#include <UniversalPayload/UniversalPayload.h>

#pragma pack(1)

typedef struct {
UINT8 TraceVerbosity;
UINTN TraceAddress;
} TRACEHUB_DEBUG_CONTEXT;

typedef struct {
UNIVERSAL_PAYLOAD_GENERIC_HEADER Header;
TRACEHUB_DEBUG_CONTEXT DebugContext;
} UNIVERSAL_PAYLOAD_TRACEHUB_DEBUG_INFO;

#pragma pack()

#define UNIVERSAL_PAYLOAD_TRACEHUB_DEBUG_INFO_REVISION 1

extern EFI_GUID gUniversalPayloadTraceHubDebugInfoGuid;

#endif // UNIVERSAL_PAYLOAD_TRACEHUB_DEBUG_INFO_H_

0 comments on commit 9bc21f5

Please sign in to comment.