TianoCore EDK2 master
Loading...
Searching...
No Matches
PeiTraceHubDebugSysTLib.c
Go to the documentation of this file.
1
12#include <Base.h>
13#include <Library/BaseLib.h>
14#include <Library/PcdLib.h>
15#include <Library/HobLib.h>
19#include <Library/MipiSysTLib.h>
20#include <Library/MipiSysTLib/mipi_syst.h>
23#include "InternalTraceHubApi.h"
24
35RETURN_STATUS
36EFIAPI
38 IN TRACE_HUB_SEVERITY_TYPE SeverityType,
39 IN UINT8 *Buffer,
40 IN UINTN NumberOfBytes
41 )
42{
43 MIPI_SYST_HANDLE MipiSystHandle;
44 MIPI_SYST_HEADER MipiSystHeader;
45 RETURN_STATUS Status;
46 UINT8 *DbgContext;
47 UINTN Index;
48 UINT32 DbgInstCount;
49 UINT8 *ThDebugInfo;
50
51 if (NumberOfBytes == 0) {
52 //
53 // No data need to be written to Trace Hub
54 //
55 return RETURN_SUCCESS;
56 }
57
58 if (Buffer == NULL) {
60 }
61
62 DbgInstCount = CountThDebugInstance ();
63
64 ZeroMem (&MipiSystHandle, sizeof (MIPI_SYST_HANDLE));
65 MipiSystHandle.systh_header = &MipiSystHeader;
66
67 Status = InitMipiSystHandle (&MipiSystHandle);
68 if (RETURN_ERROR (Status)) {
69 return Status;
70 }
71
72 DbgContext = (UINT8 *)GetFirstGuidHob (&gTraceHubDebugInfoHobGuid);
73 if (DbgContext != NULL) {
74 ThDebugInfo = GET_GUID_HOB_DATA (DbgContext);
75 } else {
76 ThDebugInfo = NULL;
77 }
78
79 for (Index = 0; Index < DbgInstCount; Index++) {
81 &MipiSystHandle,
82 ThDebugInfo,
83 SeverityType,
84 TraceHubDebugType
85 );
86 if (!RETURN_ERROR (Status)) {
87 Status = MipiSystWriteDebug (
88 &MipiSystHandle,
89 SeverityType,
90 (UINT16)NumberOfBytes,
91 (CHAR8 *)Buffer
92 );
93 if (RETURN_ERROR (Status)) {
94 break;
95 }
96 }
97
98 if (DbgContext != NULL) {
99 DbgContext = (UINT8 *)GetNextGuidHob (&gTraceHubDebugInfoHobGuid, GET_NEXT_HOB (DbgContext));
100 if (DbgContext == NULL) {
101 break;
102 }
103
104 ThDebugInfo = GET_GUID_HOB_DATA (DbgContext);
105 }
106 }
107
108 return Status;
109}
110
121RETURN_STATUS
122EFIAPI
124 IN TRACE_HUB_SEVERITY_TYPE SeverityType,
125 IN UINT64 Id,
126 IN GUID *Guid
127 )
128{
129 MIPI_SYST_HANDLE MipiSystHandle;
130 MIPI_SYST_HEADER MipiSystHeader;
131 UINT32 DbgInstCount;
132 UINT8 *DbgContext;
133 RETURN_STATUS Status;
134 UINTN Index;
135 UINT8 *ThDebugInfo;
136
137 DbgInstCount = CountThDebugInstance ();
138
139 ZeroMem (&MipiSystHandle, sizeof (MIPI_SYST_HANDLE));
140 MipiSystHandle.systh_header = &MipiSystHeader;
141
142 Status = InitMipiSystHandle (&MipiSystHandle);
143 if (RETURN_ERROR (Status)) {
144 return Status;
145 }
146
147 if (Guid != NULL) {
148 SwapBytesGuid (Guid, (GUID *)(VOID *)&MipiSystHandle.systh_guid);
149 MipiSystHandle.systh_tag.et_guid = 1;
150 } else {
151 MipiSystHandle.systh_tag.et_modunit = 2;
152 MipiSystHandle.systh_tag.et_guid = 0;
153 }
154
155 DbgContext = (UINT8 *)GetFirstGuidHob (&gTraceHubDebugInfoHobGuid);
156 if (DbgContext != NULL) {
157 ThDebugInfo = GET_GUID_HOB_DATA (DbgContext);
158 } else {
159 ThDebugInfo = NULL;
160 }
161
162 for (Index = 0; Index < DbgInstCount; Index++) {
163 Status = CheckWhetherToOutputMsg (
164 &MipiSystHandle,
165 ThDebugInfo,
166 SeverityType,
167 TraceHubCatalogType
168 );
169 if (!RETURN_ERROR (Status)) {
170 Status = MipiSystWriteCatalog (
171 &MipiSystHandle,
172 SeverityType,
173 Id
174 );
175 if (RETURN_ERROR (Status)) {
176 break;
177 }
178 }
179
180 if (DbgContext != NULL) {
181 DbgContext = (UINT8 *)GetNextGuidHob (&gTraceHubDebugInfoHobGuid, GET_NEXT_HOB (DbgContext));
182 if (DbgContext == NULL) {
183 break;
184 }
185
186 ThDebugInfo = GET_GUID_HOB_DATA (DbgContext);
187 }
188 }
189
190 return Status;
191}
192
204RETURN_STATUS
205EFIAPI
207 IN TRACE_HUB_SEVERITY_TYPE SeverityType,
208 IN UINT64 Id,
209 IN UINTN NumberOfParams,
210 ...
211 )
212{
213 MIPI_SYST_HANDLE MipiSystHandle;
214 MIPI_SYST_HEADER MipiSystHeader;
215 VA_LIST Args;
216 UINTN Index;
217 UINT32 DbgInstCount;
218 UINT8 *DbgContext;
219 RETURN_STATUS Status;
220 UINT8 *ThDebugInfo;
221
222 DbgInstCount = 0;
223
224 if (NumberOfParams > sizeof (MipiSystHandle.systh_param) / sizeof (UINT32)) {
226 }
227
228 DbgInstCount = CountThDebugInstance ();
229
230 ZeroMem (&MipiSystHandle, sizeof (MIPI_SYST_HANDLE));
231 MipiSystHandle.systh_header = &MipiSystHeader;
232
233 Status = InitMipiSystHandle (&MipiSystHandle);
234 if (RETURN_ERROR (Status)) {
235 return Status;
236 }
237
238 MipiSystHandle.systh_param_count = (UINT32)NumberOfParams;
239 VA_START (Args, NumberOfParams);
240 for (Index = 0; Index < NumberOfParams; Index++) {
241 MipiSystHandle.systh_param[Index] = VA_ARG (Args, UINT32);
242 }
243
244 VA_END (Args);
245
246 DbgContext = (UINT8 *)GetFirstGuidHob (&gTraceHubDebugInfoHobGuid);
247 if (DbgContext != NULL) {
248 ThDebugInfo = GET_GUID_HOB_DATA (DbgContext);
249 } else {
250 ThDebugInfo = NULL;
251 }
252
253 for (Index = 0; Index < DbgInstCount; Index++) {
254 Status = CheckWhetherToOutputMsg (
255 &MipiSystHandle,
256 ThDebugInfo,
257 SeverityType,
258 TraceHubCatalogType
259 );
260 if (!RETURN_ERROR (Status)) {
261 Status = MipiSystWriteCatalog (
262 &MipiSystHandle,
263 SeverityType,
264 Id
265 );
266 if (RETURN_ERROR (Status)) {
267 break;
268 }
269 }
270
271 if (DbgContext != NULL) {
272 DbgContext = (UINT8 *)GetNextGuidHob (&gTraceHubDebugInfoHobGuid, GET_NEXT_HOB (DbgContext));
273 if (DbgContext == NULL) {
274 break;
275 }
276
277 ThDebugInfo = GET_GUID_HOB_DATA (DbgContext);
278 }
279 }
280
281 return Status;
282}
UINT64 UINTN
VOID *EFIAPI GetFirstGuidHob(IN CONST EFI_GUID *Guid)
Definition: HobLib.c:215
VOID *EFIAPI GetNextGuidHob(IN CONST EFI_GUID *Guid, IN CONST VOID *HobStart)
Definition: HobLib.c:176
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
UINT32 EFIAPI CountThDebugInstance(VOID)
RETURN_STATUS EFIAPI CheckWhetherToOutputMsg(IN OUT MIPI_SYST_HANDLE *MipiSystHandle, IN UINT8 *DbgContext, IN TRACE_HUB_SEVERITY_TYPE SeverityType, IN TRACEHUB_PRINTTYPE PrintType)
VOID EFIAPI SwapBytesGuid(IN GUID *Guid, OUT GUID *ConvertedGuid)
#define NULL
Definition: Base.h:319
#define RETURN_ERROR(StatusCode)
Definition: Base.h:1061
#define VA_ARG(Marker, TYPE)
Definition: Base.h:679
#define VA_START(Marker, Parameter)
Definition: Base.h:661
#define RETURN_SUCCESS
Definition: Base.h:1066
CHAR8 * VA_LIST
Definition: Base.h:643
#define IN
Definition: Base.h:279
#define RETURN_INVALID_PARAMETER
Definition: Base.h:1076
#define VA_END(Marker)
Definition: Base.h:691
RETURN_STATUS EFIAPI InitMipiSystHandle(IN OUT VOID *MipiSystHandle)
Definition: MipiSysTLib.c:23
RETURN_STATUS EFIAPI MipiSystWriteCatalog(IN VOID *MipiSystHandle, IN UINT32 Severity, IN UINT64 CatId)
RETURN_STATUS EFIAPI MipiSystWriteDebug(IN VOID *MipiSystHandle, IN UINT32 Severity, IN UINT16 Len, IN CONST CHAR8 *Str)
RETURN_STATUS EFIAPI TraceHubSysTWriteCataLog64StatusCode(IN TRACE_HUB_SEVERITY_TYPE SeverityType, IN UINT64 Id, IN GUID *Guid)
RETURN_STATUS EFIAPI TraceHubSysTWriteCataLog64(IN TRACE_HUB_SEVERITY_TYPE SeverityType, IN UINT64 Id, IN UINTN NumberOfParams,...)
RETURN_STATUS EFIAPI TraceHubSysTDebugWrite(IN TRACE_HUB_SEVERITY_TYPE SeverityType, IN UINT8 *Buffer, IN UINTN NumberOfBytes)
struct mipi_syst_msg_tag systh_tag
Definition: mipi_syst.h:756
mipi_syst_u32 et_modunit
Definition: mipi_syst.h:664
mipi_syst_u32 et_guid
Definition: mipi_syst.h:665
struct mipi_syst_guid systh_guid
Definition: mipi_syst.h:759
mipi_syst_u32 systh_param_count
Definition: mipi_syst.h:766
mipi_syst_u32 systh_param[6]
Definition: mipi_syst.h:767
struct mipi_syst_header * systh_header
Definition: mipi_syst.h:754
Definition: Base.h:213