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