]> git.proxmox.com Git - mirror_edk2.git/blobdiff - PerformancePkg/Dp_App/DpUtilities.c
Enhance inf to follow spec.
[mirror_edk2.git] / PerformancePkg / Dp_App / DpUtilities.c
index dbb268a21c0eac5fe1c46c7f179afa7501afc611..48e2952aa79eed2d108de7a1bb3e37717d7dc7d1 100644 (file)
@@ -23,7 +23,7 @@
 #include <Library/PcdLib.h>\r
 \r
 #include <Protocol/LoadedImage.h>\r
-#include <Protocol/Driverbinding.h>\r
+#include <Protocol/DriverBinding.h>\r
 \r
 #include <Guid/Performance.h>\r
 \r
 #include "Literals.h"\r
 #include "DpInternal.h"\r
 \r
-/** Calculate an event's duration in timer ticks.\r
-  *\r
-  * Given the count direction and the event's start and end timer values,\r
-  * calculate the duration of the event in timer ticks.  Information for\r
-  * the current measurement is pointed to by the parameter.\r
-  *\r
-  * If the measurement's start time is 1, it indicates that the developer\r
-  * is indicating that the measurement began at the release of reset.\r
-  * The start time is adjusted to the timer's starting count before performing\r
-  * the elapsed time calculation.\r
-  *\r
-  * The calculated duration, in ticks, is the absolute difference between\r
-  * the measurement's ending and starting counts.\r
-  *\r
-  * @pre  The global TimerInfo structure must have already been initialized\r
-  *       before this function is called.\r
-  *\r
-  * @param[in,out]    Measurement   Pointer to a MEASUREMENT_RECORD structure containing\r
-  *                   data for the current measurement.\r
-  *\r
-  * @return       The 64-bit duration of the event.\r
+/** \r
+  Calculate an event's duration in timer ticks.\r
+  \r
+  Given the count direction and the event's start and end timer values,\r
+  calculate the duration of the event in timer ticks.  Information for\r
+  the current measurement is pointed to by the parameter.\r
+  \r
+  If the measurement's start time is 1, it indicates that the developer\r
+  is indicating that the measurement began at the release of reset.\r
+  The start time is adjusted to the timer's starting count before performing\r
+  the elapsed time calculation.\r
+  \r
+  The calculated duration, in ticks, is the absolute difference between\r
+  the measurement's ending and starting counts.\r
+  \r
+  @param Measurement   Pointer to a MEASUREMENT_RECORD structure containing\r
+                       data for the current measurement.\r
+  \r
+  @return              The 64-bit duration of the event.\r
 **/\r
 UINT64\r
 GetDuration (\r
@@ -85,15 +83,16 @@ GetDuration (
   return Duration;\r
 }\r
 \r
-/** Determine whether the Measurement record is for an EFI Phase.\r
-  *\r
-  * The Token and Module members of the measurement record are checked.\r
-  * Module must be empty and Token must be one of SEC, PEI, DXE, BDS, or SHELL.\r
-  *\r
-  * @param[in]  Measurement A pointer to the Measurement record to test.\r
-  *\r
-  * @retval     TRUE        The measurement record is for an EFI Phase.\r
-  * @retval     FALSE       The measurement record is NOT for an EFI Phase.\r
+/** \r
+  Determine whether the Measurement record is for an EFI Phase.\r
+  \r
+  The Token and Module members of the measurement record are checked.\r
+  Module must be empty and Token must be one of SEC, PEI, DXE, BDS, or SHELL.\r
+  \r
+  @param[in]  Measurement A pointer to the Measurement record to test.\r
+  \r
+  @retval     TRUE        The measurement record is for an EFI Phase.\r
+  @retval     FALSE       The measurement record is NOT for an EFI Phase.\r
 **/\r
 BOOLEAN\r
 IsPhase(\r
@@ -111,16 +110,17 @@ IsPhase(
   return RetVal;\r
 }\r
 \r
-/** Get the file name portion of the Pdb File Name.\r
-  *\r
-  * The portion of the Pdb File Name between the last backslash and\r
-  * either a following period or the end of the string is converted\r
-  * to Unicode and copied into UnicodeBuffer.  The name is truncated,\r
-  * if necessary, to ensure that UnicodeBuffer is not overrun.\r
-  *\r
-  * @param[in]  PdbFileName     Pdb file name.\r
-  * @param[out] UnicodeBuffer   The resultant Unicode File Name.\r
-  *\r
+/** \r
+  Get the file name portion of the Pdb File Name.\r
+  \r
+  The portion of the Pdb File Name between the last backslash and\r
+  either a following period or the end of the string is converted\r
+  to Unicode and copied into UnicodeBuffer.  The name is truncated,\r
+  if necessary, to ensure that UnicodeBuffer is not overrun.\r
+  \r
+  @param[in]  PdbFileName     Pdb file name.\r
+  @param[out] UnicodeBuffer   The resultant Unicode File Name.\r
+  \r
 **/\r
 VOID\r
 GetShortPdbFileName (\r
@@ -163,13 +163,14 @@ GetShortPdbFileName (
   }\r
 }\r
 \r
-/** Get a human readable name for an image handle.\r
-  *\r
-  * @param[in]    Handle\r
-  *\r
-  * @post   The resulting Unicode name string is stored in the\r
-  *         mGaugeString global array.\r
-  *\r
+/** \r
+  Get a human readable name for an image handle.\r
+  \r
+  @param[in]    Handle\r
+  \r
+  @post   The resulting Unicode name string is stored in the\r
+          mGaugeString global array.\r
+  \r
 **/\r
 VOID\r
 GetNameFromHandle (\r
@@ -191,7 +192,7 @@ GetNameFromHandle (
   Status = gBS->HandleProtocol (\r
                 Handle,\r
                 &gEfiLoadedImageProtocolGuid,\r
-                &Image\r
+                (VOID**) &Image\r
                 );\r
 \r
   if (EFI_ERROR (Status)) {\r
@@ -205,6 +206,7 @@ GetNameFromHandle (
                   );\r
     if (EFI_ERROR (Status)) {\r
       StrCpy (mGaugeString, StringPtr);\r
+      FreePool (StringPtr);\r
       return ;\r
     }\r
 \r
@@ -213,7 +215,7 @@ GetNameFromHandle (
     Status = gBS->HandleProtocol (\r
                   DriverBinding->ImageHandle,\r
                   &gEfiLoadedImageProtocolGuid,\r
-                  &Image\r
+                  (VOID**) &Image\r
                   );\r
   }\r
 \r
@@ -224,20 +226,22 @@ GetNameFromHandle (
   } else {\r
     StrCpy (mGaugeString, StringPtr);\r
   }\r
+  FreePool (StringPtr);\r
   return ;\r
 }\r
 \r
-/** Calculate the Duration in microseconds.\r
-  *\r
-  * Duration is multiplied by 1000, instead of Frequency being divided by 1000 or\r
-  * multiplying the result by 1000, in order to maintain precision.  Since Duration is\r
-  * a 64-bit value, multiplying it by 1000 is unlikely to produce an overflow.\r
-  *\r
-  * The time is calculated as (Duration * 1000) / Timer_Frequency.\r
-  *\r
-  * @param[in]  Duration   The event duration in timer ticks.\r
-  *\r
-  * @return     A 64-bit value which is the Elapsed time in microseconds.\r
+/** \r
+  Calculate the Duration in microseconds.\r
+  \r
+  Duration is multiplied by 1000, instead of Frequency being divided by 1000 or\r
+  multiplying the result by 1000, in order to maintain precision.  Since Duration is\r
+  a 64-bit value, multiplying it by 1000 is unlikely to produce an overflow.\r
+  \r
+  The time is calculated as (Duration * 1000) / Timer_Frequency.\r
+  \r
+  @param[in]  Duration   The event duration in timer ticks.\r
+  \r
+  @return     A 64-bit value which is the Elapsed time in microseconds.\r
 **/\r
 UINT64\r
 DurationInMicroSeconds (\r
@@ -250,12 +254,14 @@ DurationInMicroSeconds (
   return DivU64x32 (Temp, TimerInfo.Frequency);\r
 }\r
 \r
-/** Formatted Print using a Hii Token to reference the localized format string.\r
-  *\r
-  * @param[in]  Token   A HII token associated with a localized Unicode string.\r
-  *\r
-  * @return             The number of characters converted by UnicodeVSPrint().\r
-  *\r
+/** \r
+  Formatted Print using a Hii Token to reference the localized format string.\r
+  \r
+  @param[in]  Token   A HII token associated with a localized Unicode string.\r
+  @param[in]  ...     The variable argument list.\r
+  \r
+  @return             The number of characters converted by UnicodeVSPrint().\r
+  \r
 **/\r
 UINTN\r
 PrintToken (\r
@@ -285,20 +291,22 @@ PrintToken (
   if (Return > 0 && gST->ConOut != NULL) {\r
     gST->ConOut->OutputString (gST->ConOut, mPrintTokenBuffer);\r
   }\r
+  FreePool (StringPtr);\r
   return Return;\r
 }\r
 \r
-/** Get index of Measurement Record's match in the CumData array.\r
-  *\r
-  * If the Measurement's Token value matches a Token in one of the CumData\r
-  * records, the index of the matching record is returned.  The returned\r
-  * index is a signed value so that negative values can indicate that\r
-  * the Measurement didn't match any entry in the CumData array.\r
-  *\r
-  * @param[in]  Measurement A pointer to a Measurement Record to match against the CumData array.\r
-  *\r
-  * @retval     <0    Token is not in the CumData array.\r
-  * @retval     >=0   Return value is the index into CumData where Token is found.\r
+/** \r
+  Get index of Measurement Record's match in the CumData array.\r
+  \r
+  If the Measurement's Token value matches a Token in one of the CumData\r
+  records, the index of the matching record is returned.  The returned\r
+  index is a signed value so that negative values can indicate that\r
+  the Measurement didn't match any entry in the CumData array.\r
+  \r
+  @param[in]  Measurement A pointer to a Measurement Record to match against the CumData array.\r
+  \r
+  @retval     <0    Token is not in the CumData array.\r
+  @retval     >=0   Return value is the index into CumData where Token is found.\r
 **/\r
 INTN\r
 GetCumulativeItem(\r