The constructor function locates Performance protocol from protocol database.\r
It will ASSERT() if that operation fails and it will always return EFI_SUCCESS. \r
\r
- @param ImageHandle The firmware allocated handle for the EFI image.\r
- @param SystemTable A pointer to the EFI System Table.\r
- \r
- @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.\r
+ @retval EFI_SUCCESS Performance protocol is successfully located.\r
+ @retval Other Performance protocol is not located to log performance. \r
\r
**/\r
EFI_STATUS\r
-EFIAPI\r
-PerformanceLibConstructor (\r
- IN EFI_HANDLE ImageHandle,\r
- IN EFI_SYSTEM_TABLE *SystemTable\r
+GetPerformanceProtocol (\r
+ VOID\r
)\r
{\r
EFI_STATUS Status;\r
+ PERFORMANCE_PROTOCOL *Performance;\r
+\r
+ if (mPerformance != NULL) {\r
+ return EFI_SUCCESS;\r
+ }\r
\r
- Status = gBS->LocateProtocol (&gPerformanceProtocolGuid, NULL, (VOID **) &mPerformance);\r
- ASSERT_EFI_ERROR (Status);\r
- ASSERT (mPerformance != NULL);\r
+ Status = gBS->LocateProtocol (&gPerformanceProtocolGuid, NULL, (VOID **) &Performance);\r
+ if (!EFI_ERROR (Status)) {\r
+ ASSERT (Performance != NULL);\r
+ //\r
+ // Cache performance protocol.\r
+ //\r
+ mPerformance = Performance;\r
+ }\r
\r
return Status;\r
}\r
)\r
{\r
EFI_STATUS Status;\r
+\r
+ Status = GetPerformanceProtocol ();\r
+ if (EFI_ERROR (Status)) {\r
+ return RETURN_OUT_OF_RESOURCES;\r
+ }\r
\r
Status = mPerformance->StartGauge (Handle, Token, Module, TimeStamp);\r
-\r
+ \r
return (RETURN_STATUS) Status;\r
}\r
\r
{\r
EFI_STATUS Status;\r
\r
+ Status = GetPerformanceProtocol ();\r
+ if (EFI_ERROR (Status)) {\r
+ return RETURN_NOT_FOUND;\r
+ }\r
+\r
Status = mPerformance->EndGauge (Handle, Token, Module, TimeStamp);\r
\r
return (RETURN_STATUS) Status;\r
ASSERT (StartTimeStamp != NULL);\r
ASSERT (EndTimeStamp != NULL);\r
\r
+ Status = GetPerformanceProtocol ();\r
+ if (EFI_ERROR (Status)) {\r
+ return 0;\r
+ }\r
+\r
Status = mPerformance->GetGauge (LogEntryKey++, &GaugeData);\r
\r
//\r