]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BasePerformanceLibNull/PerformanceLib.c
e9f21b5774564c329381c86ad6f959f1135b390f
[mirror_edk2.git] / MdePkg / Library / BasePerformanceLibNull / PerformanceLib.c
1 /** @file
2 Base Performance Library which provides no service.
3
4 Copyright (c) 2006, Intel Corporation<BR>
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 Module Name: PerformanceLib.c
14
15 **/
16
17 //
18 // The package level header files this module uses
19 //
20 #include <Base.h>
21 //
22 // The protocols, PPI and GUID defintions for this module
23 //
24 //
25 // The Library classes this module consumes
26 //
27 #include <Library/PerformanceLib.h>
28 #include <Library/DebugLib.h>
29 #include <Library/PcdLib.h>
30
31 /**
32 Creates a record for the beginning of a performance measurement.
33
34 Creates a record that contains the Handle, Token, and Module.
35 If TimeStamp is not zero, then TimeStamp is added to the record as the start time.
36 If TimeStamp is zero, then this function reads the current time stamp
37 and adds that time stamp value to the record as the start time.
38
39 @param Handle Pointer to environment specific context used
40 to identify the component being measured.
41 @param Token Pointer to a Null-terminated ASCII string
42 that identifies the component being measured.
43 @param Module Pointer to a Null-terminated ASCII string
44 that identifies the module being measured.
45 @param TimeStamp 64-bit time stamp.
46
47 @retval RETURN_SUCCESS The start of the measurement was recorded.
48 @retval RETURN_OUT_OF_RESOURCES There are not enough resources to record the measurement.
49
50 **/
51 RETURN_STATUS
52 EFIAPI
53 StartPerformanceMeasurement (
54 IN CONST VOID *Handle, OPTIONAL
55 IN CONST CHAR8 *Token,
56 IN CONST CHAR8 *Module,
57 IN UINT64 TimeStamp
58 )
59 {
60 return RETURN_SUCCESS;
61 }
62
63 /**
64 Fills in the end time of a performance measurement.
65
66 Looks up the record that matches Handle, Token, and Module.
67 If the record can not be found then return RETURN_NOT_FOUND.
68 If the record is found and TimeStamp is not zero,
69 then TimeStamp is added to the record as the end time.
70 If the record is found and TimeStamp is zero, then this function reads
71 the current time stamp and adds that time stamp value to the record as the end time.
72 If this function is called multiple times for the same record, then the end time is overwritten.
73
74 @param Handle Pointer to environment specific context used
75 to identify the component being measured.
76 @param Token Pointer to a Null-terminated ASCII string
77 that identifies the component being measured.
78 @param Module Pointer to a Null-terminated ASCII string
79 that identifies the module being measured.
80 @param TimeStamp 64-bit time stamp.
81
82 @retval RETURN_SUCCESS The end of the measurement was recorded.
83 @retval RETURN_NOT_FOUND The specified measurement record could not be found.
84
85 **/
86 RETURN_STATUS
87 EFIAPI
88 EndPerformanceMeasurement (
89 IN CONST VOID *Handle, OPTIONAL
90 IN CONST CHAR8 *Token,
91 IN CONST CHAR8 *Module,
92 IN UINT64 TimeStamp
93 )
94 {
95 return RETURN_SUCCESS;
96 }
97
98 /**
99 Attempts to retrieve a performance measurement log entry from the performance measurement log.
100
101 Attempts to retrieve the performance log entry specified by LogEntryKey. If LogEntryKey is
102 zero on entry, then an attempt is made to retrieve the first entry from the performance log,
103 and the key for the second entry in the log is returned. If the performance log is empty,
104 then no entry is retrieved and zero is returned. If LogEntryKey is not zero, then the performance
105 log entry associated with LogEntryKey is retrieved, and the key for the next entry in the log is
106 returned. If LogEntryKey is the key for the last entry in the log, then the last log entry is
107 retrieved and an implementation specific non-zero key value that specifies the end of the performance
108 log is returned. If LogEntryKey is equal this implementation specific non-zero key value, then no entry
109 is retrieved and zero is returned. In the cases where a performance log entry can be returned,
110 the log entry is returned in Handle, Token, Module, StartTimeStamp, and EndTimeStamp.
111 If LogEntryKey is not a valid log entry key for the performance measurement log, then ASSERT().
112 If Handle is NULL, then ASSERT().
113 If Token is NULL, then ASSERT().
114 If Module is NULL, then ASSERT().
115 If StartTimeStamp is NULL, then ASSERT().
116 If EndTimeStamp is NULL, then ASSERT().
117
118 @param LogEntryKey On entry, the key of the performance measurement log entry to retrieve.
119 0, then the first performance measurement log entry is retrieved.
120 On exit, the key of the next performance lof entry entry.
121 @param Handle Pointer to environment specific context used to identify the component
122 being measured.
123 @param Token Pointer to a Null-terminated ASCII string that identifies the component
124 being measured.
125 @param Module Pointer to a Null-terminated ASCII string that identifies the module
126 being measured.
127 @param StartTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement
128 was started.
129 @param EndTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement
130 was ended.
131
132 @return The key for the next performance log entry (in general case).
133
134 **/
135 UINTN
136 EFIAPI
137 GetPerformanceMeasurement (
138 IN UINTN LogEntryKey,
139 OUT CONST VOID **Handle,
140 OUT CONST CHAR8 **Token,
141 OUT CONST CHAR8 **Module,
142 OUT UINT64 *StartTimeStamp,
143 OUT UINT64 *EndTimeStamp
144 )
145 {
146 ASSERT (Handle != NULL);
147 ASSERT (Token != NULL);
148 ASSERT (Module != NULL);
149 ASSERT (StartTimeStamp != NULL);
150 ASSERT (EndTimeStamp != NULL);
151
152 return 0;
153 }
154
155 /**
156 Returns TRUE if the performance measurement macros are enabled.
157
158 This function returns TRUE if the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of
159 PcdPerformanceLibraryPropertyMask is set. Otherwise FALSE is returned.
160
161 @retval TRUE The PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of
162 PcdPerformanceLibraryPropertyMask is set.
163 @retval FALSE The PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of
164 PcdPerformanceLibraryPropertyMask is clear.
165
166 **/
167 BOOLEAN
168 EFIAPI
169 PerformanceMeasurementEnabled (
170 VOID
171 )
172 {
173 return (BOOLEAN) ((PcdGet8(PcdPerformanceLibraryPropertyMask) & PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED) != 0);
174 }