TianoCore EDK2 master
Loading...
Searching...
No Matches
InternalTraceHubApiCommon.c
Go to the documentation of this file.
1
10#include <Base.h>
11#include <Library/BaseLib.h>
14#include <Library/MipiSysTLib/mipi_syst.h>
17#include "InternalTraceHubApi.h"
18
29BOOLEAN
30EFIAPI
32 IN BOOLEAN Flag,
33 IN UINT8 DbgLevel,
34 IN TRACE_HUB_SEVERITY_TYPE SeverityType
35 )
36{
37 if (Flag == TraceHubRoutingDisable) {
38 return FALSE;
39 }
40
41 if (DbgLevel == TraceHubDebugLevelError) {
42 if (((SeverityType == SeverityFatal) || (SeverityType == SeverityError))) {
43 return TRUE;
44 }
45 } else if (DbgLevel == TraceHubDebugLevelErrorWarning) {
46 if (((SeverityType == SeverityFatal) || (SeverityType == SeverityError) || (SeverityType == SeverityWarning))) {
47 return TRUE;
48 }
49 } else if (DbgLevel == TraceHubDebugLevelErrorWarningInfo) {
50 if (((SeverityType == SeverityFatal) || (SeverityType == SeverityError) || (SeverityType == SeverityWarning) || (SeverityType == SeverityNormal))) {
51 return TRUE;
52 }
53 } else if (DbgLevel == TraceHubDebugLevelErrorWarningInfoVerbose) {
54 return TRUE;
55 }
56
57 return FALSE;
58}
59
66VOID
67EFIAPI
69 IN GUID *Guid,
70 OUT GUID *ConvertedGuid
71 )
72{
73 CopyGuid (ConvertedGuid, Guid);
74 ConvertedGuid->Data1 = SwapBytes32 (ConvertedGuid->Data1);
75 ConvertedGuid->Data2 = SwapBytes16 (ConvertedGuid->Data2);
76 ConvertedGuid->Data3 = SwapBytes16 (ConvertedGuid->Data3);
77}
78
92RETURN_STATUS
93EFIAPI
95 IN OUT MIPI_SYST_HANDLE *MipiSystHandle,
96 IN UINT8 *DbgContext,
97 IN TRACE_HUB_SEVERITY_TYPE SeverityType,
98 IN TRACEHUB_PRINTTYPE PrintType
99 )
100{
101 UINT8 DbgLevel;
102 BOOLEAN Flag;
103 UINT64 Addr;
104 RETURN_STATUS Status;
105
106 if (MipiSystHandle == NULL) {
108 }
109
110 if (PrintType == TraceHubDebugType) {
111 Status = GetTraceHubMsgVisibility (DbgContext, &Flag, &DbgLevel);
112 if (RETURN_ERROR (Status)) {
113 return Status;
114 }
115
116 if (!TraceHubDataEnabled (Flag, DbgLevel, SeverityType)) {
117 return RETURN_ABORTED;
118 }
119 }
120
121 Status = GetTraceHubMmioAddress (DbgContext, &Addr);
122 if (RETURN_ERROR (Status)) {
123 return Status;
124 }
125
126 MipiSystHandle->systh_platform.TraceHubPlatformData.MmioAddr = Addr;
127 if (MipiSystHandle->systh_platform.TraceHubPlatformData.MmioAddr == 0) {
128 return RETURN_ABORTED;
129 }
130
131 return RETURN_SUCCESS;
132}
133
143RETURN_STATUS
144EFIAPI
146 IN UINT8 *DbgContext,
147 IN OUT UINT64 *TraceAddress
148 )
149{
150 TRACEHUB_DEBUG_INFO_HOB *ThDbgContext;
151
152 if (TraceAddress == NULL) {
154 }
155
156 if (DbgContext != NULL) {
157 ThDbgContext = (TRACEHUB_DEBUG_INFO_HOB *)DbgContext;
158 *TraceAddress = ThDbgContext->TraceHubMmioAddress;
159 } else {
160 *TraceAddress = FixedPcdGet64 (PcdTraceHubDebugMmioAddress);
161 }
162
163 return RETURN_SUCCESS;
164}
165
176RETURN_STATUS
177EFIAPI
179 IN UINT8 *DbgContext,
180 IN OUT BOOLEAN *Flag,
181 IN OUT UINT8 *DbgLevel
182 )
183{
184 TRACEHUB_DEBUG_INFO_HOB *ThDbgContext;
185
186 if ((Flag == NULL) || (DbgLevel == NULL)) {
188 }
189
190 if (DbgContext != NULL) {
191 ThDbgContext = (TRACEHUB_DEBUG_INFO_HOB *)DbgContext;
192 *Flag = ThDbgContext->Flag;
193 *DbgLevel = ThDbgContext->DebugLevel;
194 } else {
195 *DbgLevel = FixedPcdGet8 (PcdTraceHubDebugLevel);
196 *Flag = FixedPcdGetBool (PcdEnableTraceHubDebugMsg);
197 }
198
199 return RETURN_SUCCESS;
200}
UINT16 EFIAPI SwapBytes16(IN UINT16 Value)
Definition: SwapBytes16.c:25
UINT32 EFIAPI SwapBytes32(IN UINT32 Value)
Definition: SwapBytes32.c:25
GUID *EFIAPI CopyGuid(OUT GUID *DestinationGuid, IN CONST GUID *SourceGuid)
Definition: MemLibGuid.c:39
RETURN_STATUS EFIAPI GetTraceHubMmioAddress(IN UINT8 *DbgContext, IN OUT UINT64 *TraceAddress)
RETURN_STATUS EFIAPI CheckWhetherToOutputMsg(IN OUT MIPI_SYST_HANDLE *MipiSystHandle, IN UINT8 *DbgContext, IN TRACE_HUB_SEVERITY_TYPE SeverityType, IN TRACEHUB_PRINTTYPE PrintType)
RETURN_STATUS EFIAPI GetTraceHubMsgVisibility(IN UINT8 *DbgContext, IN OUT BOOLEAN *Flag, IN OUT UINT8 *DbgLevel)
BOOLEAN EFIAPI TraceHubDataEnabled(IN BOOLEAN Flag, IN UINT8 DbgLevel, IN TRACE_HUB_SEVERITY_TYPE SeverityType)
VOID EFIAPI SwapBytesGuid(IN GUID *Guid, OUT GUID *ConvertedGuid)
#define NULL
Definition: Base.h:319
#define RETURN_ERROR(StatusCode)
Definition: Base.h:1061
#define RETURN_ABORTED
Definition: Base.h:1177
#define RETURN_SUCCESS
Definition: Base.h:1066
#define TRUE
Definition: Base.h:301
#define FALSE
Definition: Base.h:307
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
#define RETURN_INVALID_PARAMETER
Definition: Base.h:1076
#define FixedPcdGet64(TokenName)
Definition: PcdLib.h:106
#define FixedPcdGetBool(TokenName)
Definition: PcdLib.h:120
#define FixedPcdGet8(TokenName)
Definition: PcdLib.h:64
Definition: Base.h:213