]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BasePerformanceLibNull/PerformanceLib.c
1785bab28f7132b544e643975dda8e3ed56278db
[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 // Include common header file for this module.
19 //
20 #include "CommonHeader.h"
21
22 /**
23 Creates a record for the beginning of a performance measurement.
24
25 Creates a record that contains the Handle, Token, and Module.
26 If TimeStamp is not zero, then TimeStamp is added to the record as the start time.
27 If TimeStamp is zero, then this function reads the current time stamp
28 and adds that time stamp value to the record as the start time.
29
30 @param Handle Pointer to environment specific context used
31 to identify the component being measured.
32 @param Token Pointer to a Null-terminated ASCII string
33 that identifies the component being measured.
34 @param Module Pointer to a Null-terminated ASCII string
35 that identifies the module being measured.
36 @param TimeStamp 64-bit time stamp.
37
38 @retval RETURN_SUCCESS The start of the measurement was recorded.
39 @retval RETURN_OUT_OF_RESOURCES There are not enough resources to record the measurement.
40
41 **/
42 RETURN_STATUS
43 EFIAPI
44 StartPerformanceMeasurement (
45 IN CONST VOID *Handle, OPTIONAL
46 IN CONST CHAR8 *Token,
47 IN CONST CHAR8 *Module,
48 IN UINT64 TimeStamp
49 )
50 {
51 return RETURN_SUCCESS;
52 }
53
54 /**
55 Fills in the end time of a performance measurement.
56
57 Looks up the record that matches Handle, Token, and Module.
58 If the record can not be found then return RETURN_NOT_FOUND.
59 If the record is found and TimeStamp is not zero,
60 then TimeStamp is added to the record as the end time.
61 If the record is found and TimeStamp is zero, then this function reads
62 the current time stamp and adds that time stamp value to the record as the end time.
63 If this function is called multiple times for the same record, then the end time is overwritten.
64
65 @param Handle Pointer to environment specific context used
66 to identify the component being measured.
67 @param Token Pointer to a Null-terminated ASCII string
68 that identifies the component being measured.
69 @param Module Pointer to a Null-terminated ASCII string
70 that identifies the module being measured.
71 @param TimeStamp 64-bit time stamp.
72
73 @retval RETURN_SUCCESS The end of the measurement was recorded.
74 @retval RETURN_NOT_FOUND The specified measurement record could not be found.
75
76 **/
77 RETURN_STATUS
78 EFIAPI
79 EndPerformanceMeasurement (
80 IN CONST VOID *Handle, OPTIONAL
81 IN CONST CHAR8 *Token,
82 IN CONST CHAR8 *Module,
83 IN UINT64 TimeStamp
84 )
85 {
86 return RETURN_SUCCESS;
87 }
88
89 /**
90 Attempts to retrieve a performance measurement log entry from the performance measurement log.
91
92 Attempts to retrieve the performance log entry specified by LogEntryKey. If LogEntryKey is
93 zero on entry, then an attempt is made to retrieve the first entry from the performance log,
94 and the key for the second entry in the log is returned. If the performance log is empty,
95 then no entry is retrieved and zero is returned. If LogEntryKey is not zero, then the performance
96 log entry associated with LogEntryKey is retrieved, and the key for the next entry in the log is
97 returned. If LogEntryKey is the key for the last entry in the log, then the last log entry is
98 retrieved and an implementation specific non-zero key value that specifies the end of the performance
99 log is returned. If LogEntryKey is equal this implementation specific non-zero key value, then no entry
100 is retrieved and zero is returned. In the cases where a performance log entry can be returned,
101 the log entry is returned in Handle, Token, Module, StartTimeStamp, and EndTimeStamp.
102 If LogEntryKey is not a valid log entry key for the performance measurement log, then ASSERT().
103 If Handle is NULL, then ASSERT().
104 If Token is NULL, then ASSERT().
105 If Module is NULL, then ASSERT().
106 If StartTimeStamp is NULL, then ASSERT().
107 If EndTimeStamp is NULL, then ASSERT().
108
109 @param LogEntryKey On entry, the key of the performance measurement log entry to retrieve.
110 0, then the first performance measurement log entry is retrieved.
111 On exit, the key of the next performance lof entry entry.
112 @param Handle Pointer to environment specific context used to identify the component
113 being measured.
114 @param Token Pointer to a Null-terminated ASCII string that identifies the component
115 being measured.
116 @param Module Pointer to a Null-terminated ASCII string that identifies the module
117 being measured.
118 @param StartTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement
119 was started.
120 @param EndTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement
121 was ended.
122
123 @return The key for the next performance log entry (in general case).
124
125 **/
126 UINTN
127 EFIAPI
128 GetPerformanceMeasurement (
129 IN UINTN LogEntryKey,
130 OUT CONST VOID **Handle,
131 OUT CONST CHAR8 **Token,
132 OUT CONST CHAR8 **Module,
133 OUT UINT64 *StartTimeStamp,
134 OUT UINT64 *EndTimeStamp
135 )
136 {
137 ASSERT (Handle != NULL);
138 ASSERT (Token != NULL);
139 ASSERT (Module != NULL);
140 ASSERT (StartTimeStamp != NULL);
141 ASSERT (EndTimeStamp != NULL);
142
143 return 0;
144 }
145
146 /**
147 Returns TRUE if the performance measurement macros are enabled.
148
149 This function returns TRUE if the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of
150 PcdPerformanceLibraryPropertyMask is set. Otherwise FALSE is returned.
151
152 @retval TRUE The PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of
153 PcdPerformanceLibraryPropertyMask is set.
154 @retval FALSE The PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of
155 PcdPerformanceLibraryPropertyMask is clear.
156
157 **/
158 BOOLEAN
159 EFIAPI
160 PerformanceMeasurementEnabled (
161 VOID
162 )
163 {
164 return (BOOLEAN) ((PcdGet8(PcdPerformanceLibraryPropertyMask) & PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED) != 0);
165 }