TianoCore EDK2 master
Loading...
Searching...
No Matches
BaseTraceHubDebugSysTLib.c
Go to the documentation of this file.
1
11#include <Base.h>
12#include <Library/BaseLib.h>
13#include <Library/PcdLib.h>
16#include <Library/MipiSysTLib.h>
17#include <Library/MipiSysTLib/mipi_syst.h>
20#include "InternalTraceHubApi.h"
21
32RETURN_STATUS
33EFIAPI
35 IN TRACE_HUB_SEVERITY_TYPE SeverityType,
36 IN UINT8 *Buffer,
37 IN UINTN NumberOfBytes
38 )
39{
40 MIPI_SYST_HANDLE MipiSystHandle;
41 MIPI_SYST_HEADER MipiSystHeader;
42 RETURN_STATUS Status;
43 UINT32 DbgInstCount;
44 UINT32 Index;
45
46 if (NumberOfBytes == 0) {
47 //
48 // No data need to be written to Trace Hub
49 //
50 return RETURN_SUCCESS;
51 }
52
53 if (Buffer == NULL) {
55 }
56
57 DbgInstCount = CountThDebugInstance ();
58
59 ZeroMem (&MipiSystHandle, sizeof (MIPI_SYST_HANDLE));
60 MipiSystHandle.systh_header = &MipiSystHeader;
61
62 Status = InitMipiSystHandle (&MipiSystHandle);
63 if (RETURN_ERROR (Status)) {
64 return Status;
65 }
66
67 for (Index = 0; Index < DbgInstCount; Index++) {
69 &MipiSystHandle,
70 NULL,
71 SeverityType,
72 TraceHubDebugType
73 );
74 if (!RETURN_ERROR (Status)) {
75 Status = MipiSystWriteDebug (
76 &MipiSystHandle,
77 SeverityType,
78 (UINT16)NumberOfBytes,
79 (CHAR8 *)Buffer
80 );
81 if (RETURN_ERROR (Status)) {
82 break;
83 }
84 }
85 }
86
87 return Status;
88}
89
100RETURN_STATUS
101EFIAPI
103 IN TRACE_HUB_SEVERITY_TYPE SeverityType,
104 IN UINT64 Id,
105 IN GUID *Guid
106 )
107{
108 MIPI_SYST_HANDLE MipiSystHandle;
109 MIPI_SYST_HEADER MipiSystHeader;
110 RETURN_STATUS Status;
111 UINT32 DbgInstCount;
112 UINT32 Index;
113
114 if (Guid == NULL) {
116 }
117
118 DbgInstCount = CountThDebugInstance ();
119
120 ZeroMem (&MipiSystHandle, sizeof (MIPI_SYST_HANDLE));
121 MipiSystHandle.systh_header = &MipiSystHeader;
122
123 Status = InitMipiSystHandle (&MipiSystHandle);
124 if (RETURN_ERROR (Status)) {
125 return Status;
126 }
127
128 SwapBytesGuid (Guid, (GUID *)(VOID *)&MipiSystHandle.systh_guid);
129 MipiSystHandle.systh_tag.et_guid = 1;
130
131 for (Index = 0; Index < DbgInstCount; Index++) {
132 Status = CheckWhetherToOutputMsg (
133 &MipiSystHandle,
134 NULL,
135 SeverityType,
136 TraceHubCatalogType
137 );
138 if (!RETURN_ERROR (Status)) {
139 Status = MipiSystWriteCatalog (
140 &MipiSystHandle,
141 SeverityType,
142 Id
143 );
144 if (RETURN_ERROR (Status)) {
145 break;
146 }
147 }
148 }
149
150 return Status;
151}
152
164RETURN_STATUS
165EFIAPI
167 IN TRACE_HUB_SEVERITY_TYPE SeverityType,
168 IN UINT64 Id,
169 IN UINTN NumberOfParams,
170 ...
171 )
172{
173 MIPI_SYST_HANDLE MipiSystHandle;
174 MIPI_SYST_HEADER MipiSystHeader;
175 VA_LIST Args;
176 UINTN Index;
177 RETURN_STATUS Status;
178 UINT32 DbgInstCount;
179
180 DbgInstCount = 0;
181
182 if (NumberOfParams > sizeof (MipiSystHandle.systh_param) / sizeof (UINT32)) {
184 }
185
186 DbgInstCount = CountThDebugInstance ();
187
188 ZeroMem (&MipiSystHandle, sizeof (MIPI_SYST_HANDLE));
189 MipiSystHandle.systh_header = &MipiSystHeader;
190
191 Status = InitMipiSystHandle (&MipiSystHandle);
192 if (RETURN_ERROR (Status)) {
193 return Status;
194 }
195
196 MipiSystHandle.systh_param_count = (UINT32)NumberOfParams;
197 VA_START (Args, NumberOfParams);
198 for (Index = 0; Index < NumberOfParams; Index++) {
199 MipiSystHandle.systh_param[Index] = VA_ARG (Args, UINT32);
200 }
201
202 VA_END (Args);
203
204 for (Index = 0; Index < DbgInstCount; Index++) {
205 Status = CheckWhetherToOutputMsg (
206 &MipiSystHandle,
207 NULL,
208 SeverityType,
209 TraceHubCatalogType
210 );
211 if (!RETURN_ERROR (Status)) {
212 Status = MipiSystWriteCatalog (
213 &MipiSystHandle,
214 SeverityType,
215 Id
216 );
217 if (RETURN_ERROR (Status)) {
218 break;
219 }
220 }
221 }
222
223 return Status;
224}
225
231UINT32
232EFIAPI
234 VOID
235 )
236{
237 UINT32 DbgInstCount;
238
239 //
240 // 1 from PCD.
241 //
242 DbgInstCount = 1;
243
244 return DbgInstCount;
245}
UINT64 UINTN
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
UINT32 EFIAPI CountThDebugInstance(VOID)
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)
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)
struct mipi_syst_msg_tag systh_tag
Definition: mipi_syst.h:756
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