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