TianoCore EDK2 master
Loading...
Searching...
No Matches
DxePerformanceLib.c
Go to the documentation of this file.
1
14#include <PiDxe.h>
15
17
19#include <Library/DebugLib.h>
21#include <Library/PcdLib.h>
22
23//
24// The cached Performance Protocol and PerformanceEx Protocol interface.
25//
26EDKII_PERFORMANCE_MEASUREMENT_PROTOCOL *mPerformanceMeasurement = NULL;
27
39 VOID
40 )
41{
42 EFI_STATUS Status;
43 EDKII_PERFORMANCE_MEASUREMENT_PROTOCOL *PerformanceMeasurement;
44
45 if (mPerformanceMeasurement != NULL) {
46 return EFI_SUCCESS;
47 }
48
49 Status = gBS->LocateProtocol (&gEdkiiPerformanceMeasurementProtocolGuid, NULL, (VOID **)&PerformanceMeasurement);
50 if (!EFI_ERROR (Status)) {
51 ASSERT (PerformanceMeasurement != NULL);
52 //
53 // Cache PerformanceMeasurement Protocol.
54 //
55 mPerformanceMeasurement = PerformanceMeasurement;
56 return EFI_SUCCESS;
57 }
58
59 return EFI_NOT_FOUND;
60}
61
84RETURN_STATUS
85EFIAPI
87 IN CONST VOID *Handle OPTIONAL,
88 IN CONST CHAR8 *Token OPTIONAL,
89 IN CONST CHAR8 *Module OPTIONAL,
90 IN UINT64 TimeStamp,
91 IN UINT32 Identifier
92 )
93{
94 EFI_STATUS Status;
95 CONST CHAR8 *String;
96
98 if (EFI_ERROR (Status)) {
99 return RETURN_NOT_FOUND;
100 }
101
102 if (Token != NULL) {
103 String = Token;
104 } else if (Module != NULL) {
105 String = Module;
106 } else {
107 String = NULL;
108 }
109
110 if (mPerformanceMeasurement != NULL) {
111 Status = mPerformanceMeasurement->CreatePerformanceMeasurement (Handle, NULL, String, TimeStamp, 0, Identifier, PerfStartEntry);
112 } else {
113 ASSERT (FALSE);
114 }
115
116 return (RETURN_STATUS)Status;
117}
118
143RETURN_STATUS
144EFIAPI
146 IN CONST VOID *Handle OPTIONAL,
147 IN CONST CHAR8 *Token OPTIONAL,
148 IN CONST CHAR8 *Module OPTIONAL,
149 IN UINT64 TimeStamp,
150 IN UINT32 Identifier
151 )
152{
153 EFI_STATUS Status;
154 CONST CHAR8 *String;
155
157 if (EFI_ERROR (Status)) {
158 return RETURN_NOT_FOUND;
159 }
160
161 if (Token != NULL) {
162 String = Token;
163 } else if (Module != NULL) {
164 String = Module;
165 } else {
166 String = NULL;
167 }
168
169 if (mPerformanceMeasurement != NULL) {
170 Status = mPerformanceMeasurement->CreatePerformanceMeasurement (Handle, NULL, String, TimeStamp, 0, Identifier, PerfEndEntry);
171 } else {
172 ASSERT (FALSE);
173 }
174
175 return (RETURN_STATUS)Status;
176}
177
219UINTN
220EFIAPI
222 IN UINTN LogEntryKey,
223 OUT CONST VOID **Handle,
224 OUT CONST CHAR8 **Token,
225 OUT CONST CHAR8 **Module,
226 OUT UINT64 *StartTimeStamp,
227 OUT UINT64 *EndTimeStamp,
228 OUT UINT32 *Identifier
229 )
230{
231 return 0;
232}
233
254RETURN_STATUS
255EFIAPI
257 IN CONST VOID *Handle OPTIONAL,
258 IN CONST CHAR8 *Token OPTIONAL,
259 IN CONST CHAR8 *Module OPTIONAL,
260 IN UINT64 TimeStamp
261 )
262{
263 return StartPerformanceMeasurementEx (Handle, Token, Module, TimeStamp, 0);
264}
265
288RETURN_STATUS
289EFIAPI
291 IN CONST VOID *Handle OPTIONAL,
292 IN CONST CHAR8 *Token OPTIONAL,
293 IN CONST CHAR8 *Module OPTIONAL,
294 IN UINT64 TimeStamp
295 )
296{
297 return EndPerformanceMeasurementEx (Handle, Token, Module, TimeStamp, 0);
298}
299
339UINTN
340EFIAPI
342 IN UINTN LogEntryKey,
343 OUT CONST VOID **Handle,
344 OUT CONST CHAR8 **Token,
345 OUT CONST CHAR8 **Module,
346 OUT UINT64 *StartTimeStamp,
347 OUT UINT64 *EndTimeStamp
348 )
349{
350 return 0;
351}
352
365BOOLEAN
366EFIAPI
368 VOID
369 )
370{
371 return (BOOLEAN)((PcdGet8 (PcdPerformanceLibraryPropertyMask) & PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED) != 0);
372}
373
389RETURN_STATUS
390EFIAPI
392 IN CONST VOID *CallerIdentifier,
393 IN CONST VOID *Guid OPTIONAL,
394 IN CONST CHAR8 *String OPTIONAL,
395 IN UINT64 Address OPTIONAL,
396 IN UINT32 Identifier
397 )
398{
399 EFI_STATUS Status;
400
402 if (EFI_ERROR (Status)) {
404 }
405
406 if (mPerformanceMeasurement != NULL) {
407 Status = mPerformanceMeasurement->CreatePerformanceMeasurement (CallerIdentifier, Guid, String, 0, Address, Identifier, PerfEntry);
408 } else {
409 ASSERT (FALSE);
410 }
411
412 return (RETURN_STATUS)Status;
413}
414
427BOOLEAN
428EFIAPI
430 IN CONST UINTN Type
431 )
432{
433 //
434 // When Performance measurement is enabled and the type is not filtered, the performance can be logged.
435 //
436 if (PerformanceMeasurementEnabled () && ((PcdGet8 (PcdPerformanceLibraryPropertyMask) & Type) == 0)) {
437 return TRUE;
438 }
439
440 return FALSE;
441}
UINT64 UINTN
EFI_STATUS GetPerformanceMeasurementProtocol(VOID)
RETURN_STATUS EFIAPI EndPerformanceMeasurementEx(IN CONST VOID *Handle OPTIONAL, IN CONST CHAR8 *Token OPTIONAL, IN CONST CHAR8 *Module OPTIONAL, IN UINT64 TimeStamp, IN UINT32 Identifier)
UINTN EFIAPI GetPerformanceMeasurement(IN UINTN LogEntryKey, OUT CONST VOID **Handle, OUT CONST CHAR8 **Token, OUT CONST CHAR8 **Module, OUT UINT64 *StartTimeStamp, OUT UINT64 *EndTimeStamp)
RETURN_STATUS EFIAPI StartPerformanceMeasurementEx(IN CONST VOID *Handle OPTIONAL, IN CONST CHAR8 *Token OPTIONAL, IN CONST CHAR8 *Module OPTIONAL, IN UINT64 TimeStamp, IN UINT32 Identifier)
RETURN_STATUS EFIAPI LogPerformanceMeasurement(IN CONST VOID *CallerIdentifier, IN CONST VOID *Guid OPTIONAL, IN CONST CHAR8 *String OPTIONAL, IN UINT64 Address OPTIONAL, IN UINT32 Identifier)
BOOLEAN EFIAPI LogPerformanceMeasurementEnabled(IN CONST UINTN Type)
BOOLEAN EFIAPI PerformanceMeasurementEnabled(VOID)
UINTN EFIAPI GetPerformanceMeasurementEx(IN UINTN LogEntryKey, OUT CONST VOID **Handle, OUT CONST CHAR8 **Token, OUT CONST CHAR8 **Module, OUT UINT64 *StartTimeStamp, OUT UINT64 *EndTimeStamp, OUT UINT32 *Identifier)
RETURN_STATUS EFIAPI EndPerformanceMeasurement(IN CONST VOID *Handle OPTIONAL, IN CONST CHAR8 *Token OPTIONAL, IN CONST CHAR8 *Module OPTIONAL, IN UINT64 TimeStamp)
RETURN_STATUS EFIAPI StartPerformanceMeasurement(IN CONST VOID *Handle OPTIONAL, IN CONST CHAR8 *Token OPTIONAL, IN CONST CHAR8 *Module OPTIONAL, IN UINT64 TimeStamp)
#define NULL
Definition: Base.h:319
#define CONST
Definition: Base.h:259
#define RETURN_NOT_FOUND
Definition: Base.h:1142
#define RETURN_OUT_OF_RESOURCES
Definition: Base.h:1114
#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 PcdGet8(TokenName)
Definition: PcdLib.h:336
#define PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
EFI_BOOT_SERVICES * gBS