VirtualBox

Ignore:
Timestamp:
Apr 14, 2023 3:17:44 PM (2 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
156854
Message:

Devices/EFI/FirmwareNew: Update to edk2-stable202302 and make it build, bugref:4643

Location:
trunk/src/VBox/Devices/EFI/FirmwareNew
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/EFI/FirmwareNew

  • trunk/src/VBox/Devices/EFI/FirmwareNew/ShellPkg/DynamicCommand/DpDynamicCommand/DpTrace.c

    r85718 r99404  
    4747UINTN
    4848GetPerformanceMeasurementRecord (
    49  IN  UINTN       LogEntryKey,
    50  OUT CONST VOID  **Handle,
    51  OUT CONST CHAR8 **Token,
    52  OUT CONST CHAR8 **Module,
    53  OUT UINT64      *StartTimeStamp,
    54  OUT UINT64      *EndTimeStamp,
    55  OUT UINT32      *Identifier
     49  IN  UINTN        LogEntryKey,
     50  OUT CONST VOID   **Handle,
     51  OUT CONST CHAR8 **Token,
     52  OUT CONST CHAR8 **Module,
     53  OUT UINT64       *StartTimeStamp,
     54  OUT UINT64       *EndTimeStamp,
     55  OUT UINT32       *Identifier
    5656  )
    5757{
     
    6060  }
    6161
    62   *Handle         = (VOID *) (UINTN) mMeasurementList[LogEntryKey].Handle;
     62  *Handle         = (VOID *)(UINTN)mMeasurementList[LogEntryKey].Handle;
    6363  *Token          = mMeasurementList[LogEntryKey].Token;
    6464  *Module         = mMeasurementList[LogEntryKey].Module;
     
    6767  *Identifier     = mMeasurementList[LogEntryKey].Identifier;
    6868
    69   LogEntryKey ++;
     69  LogEntryKey++;
    7070
    7171  return LogEntryKey;
     
    9090**/
    9191VOID
    92 GatherStatistics(
    93   IN OUT PERF_CUM_DATA              *CustomCumulativeData OPTIONAL
     92GatherStatistics (
     93  IN OUT PERF_CUM_DATA  *CustomCumulativeData OPTIONAL
    9494  )
    9595{
    96   MEASUREMENT_RECORD        Measurement;
    97   UINT64                    Duration;
    98   UINTN                     LogEntryKey;
    99   INTN                      TIndex;
     96  MEASUREMENT_RECORD  Measurement;
     97  UINT64              Duration;
     98  UINTN               LogEntryKey;
     99  INTN                TIndex;
    100100
    101101  LogEntryKey = 0;
    102102  while ((LogEntryKey = GetPerformanceMeasurementRecord (
    103                         LogEntryKey,
    104                         &Measurement.Handle,
    105                         &Measurement.Token,
    106                         &Measurement.Module,
    107                         &Measurement.StartTimeStamp,
    108                         &Measurement.EndTimeStamp,
    109                         &Measurement.Identifier)) != 0)
     103                          LogEntryKey,
     104                          &Measurement.Handle,
     105                          &Measurement.Token,
     106                          &Measurement.Module,
     107                          &Measurement.StartTimeStamp,
     108                          &Measurement.EndTimeStamp,
     109                          &Measurement.Identifier
     110                          )) != 0)
    110111  {
    111112    ++SummaryData.NumTrace;           // Count the number of TRACE Measurement records
     
    119120    }
    120121
    121     if (IsPhase( &Measurement)) {
     122    if (IsPhase (&Measurement)) {
    122123      ++SummaryData.NumSummary;       // Count the number of major phases
    123     }
    124     else {  // !IsPhase
    125       if(Measurement.Handle == NULL) {
     124    } else {
     125      // !IsPhase
     126      if (Measurement.Handle == NULL) {
    126127        ++SummaryData.NumGlobal;
    127128      }
     
    133134
    134135    Duration = GetDuration (&Measurement);
    135     TIndex = GetCumulativeItem (&Measurement);
     136    TIndex   = GetCumulativeItem (&Measurement);
    136137    if (TIndex >= 0) {
    137138      CumData[TIndex].Duration += Duration;
     
    140141        CumData[TIndex].MinDur = Duration;
    141142      }
     143
    142144      if ( Duration > CumData[TIndex].MaxDur ) {
    143145        CumData[TIndex].MaxDur = Duration;
     
    154156        CustomCumulativeData->MinDur = Duration;
    155157      }
     158
    156159      if (Duration > CustomCumulativeData->MaxDur) {
    157160        CustomCumulativeData->MaxDur = Duration;
     
    183186**/
    184187EFI_STATUS
    185 DumpAllTrace(
    186   IN UINTN             Limit,
    187   IN BOOLEAN           ExcludeFlag
     188DumpAllTrace (
     189  IN UINTN    Limit,
     190  IN BOOLEAN  ExcludeFlag
    188191  )
    189192{
    190   MEASUREMENT_RECORD        Measurement;
    191   UINT64                    ElapsedTime;
    192   UINT64                    Duration;
    193   CHAR16                    *IncFlag;
    194   UINTN                     LogEntryKey;
    195   UINTN                     Count;
    196   UINTN                     Index;
    197   UINTN                     TIndex;
    198 
    199   EFI_HANDLE                *HandleBuffer;
    200   UINTN                     HandleCount;
    201   EFI_STATUS                Status;
    202   EFI_STRING                StringPtrUnknown;
     193  MEASUREMENT_RECORD  Measurement;
     194  UINT64              ElapsedTime;
     195  UINT64              Duration;
     196  CHAR16              *IncFlag;
     197  UINTN               LogEntryKey;
     198  UINTN               Count;
     199  UINTN               Index;
     200  UINTN               TIndex;
     201
     202  EFI_HANDLE  *HandleBuffer;
     203  UINTN       HandleCount;
     204  EFI_STATUS  Status;
     205  EFI_STRING  StringPtrUnknown;
    203206
    204207  StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
    205   IncFlag = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_ALL), NULL);
    206   ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,
    207               (IncFlag == NULL) ? StringPtrUnknown : IncFlag);
     208  IncFlag          = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_ALL), NULL);
     209  ShellPrintHiiEx (
     210    -1,
     211    -1,
     212    NULL,
     213    STRING_TOKEN (STR_DP_SECTION_HEADER),
     214    mDpHiiHandle,
     215    (IncFlag == NULL) ? StringPtrUnknown : IncFlag
     216    );
    208217  FreePool (StringPtrUnknown);
    209218
    210219  // Get Handle information
    211220  //
    212   Status  = gBS->LocateHandleBuffer (AllHandles, NULL, NULL, &HandleCount, &HandleBuffer);
     221  Status = gBS->LocateHandleBuffer (AllHandles, NULL, NULL, &HandleCount, &HandleBuffer);
    213222  if (EFI_ERROR (Status)) {
    214223    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLES_ERROR), mDpHiiHandle, Status);
    215   }
    216   else {
     224  } else {
    217225    // We have successfully populated the HandleBuffer
    218226    // Display ALL Measurement Records
     
    230238
    231239    LogEntryKey = 0;
    232     Count = 0;
    233     Index = 0;
    234     while ( WITHIN_LIMIT(Count, Limit) &&
     240    Count       = 0;
     241    Index       = 0;
     242    while ( WITHIN_LIMIT (Count, Limit) &&
    235243            ((LogEntryKey = GetPerformanceMeasurementRecord (
    236                             LogEntryKey,
    237                             &Measurement.Handle,
    238                             &Measurement.Token,
    239                             &Measurement.Module,
    240                             &Measurement.StartTimeStamp,
    241                             &Measurement.EndTimeStamp,
    242                             &Measurement.Identifier)) != 0)
    243           )
     244                              LogEntryKey,
     245                              &Measurement.Handle,
     246                              &Measurement.Token,
     247                              &Measurement.Module,
     248                              &Measurement.StartTimeStamp,
     249                              &Measurement.EndTimeStamp,
     250                              &Measurement.Identifier
     251                              )) != 0)
     252            )
    244253    {
    245254      ++Index;    // Count every record.  First record is 1.
     
    247256      SHELL_FREE_NON_NULL (IncFlag);
    248257      if (Measurement.EndTimeStamp != 0) {
    249         Duration = GetDuration (&Measurement);
    250         ElapsedTime = DurationInMicroSeconds ( Duration );
    251         IncFlag = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_COMPLETE), NULL);
    252       }
    253       else {
     258        Duration    = GetDuration (&Measurement);
     259        ElapsedTime = DurationInMicroSeconds (Duration);
     260        IncFlag     = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_COMPLETE), NULL);
     261      } else {
    254262        IncFlag = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_INCOMPLETE), NULL);  // Mark incomplete records
    255263      }
     264
    256265      if (((Measurement.EndTimeStamp != 0) && (ElapsedTime < mInterestThreshold)) ||
    257           ((ExcludeFlag) && (GetCumulativeItem(&Measurement) >= 0))
    258          ) {      // Ignore "uninteresting" or excluded records
     266          ((ExcludeFlag) && (GetCumulativeItem (&Measurement) >= 0))
     267          )       // Ignore "uninteresting" or excluded records
     268      {
    259269        continue;
    260270      }
     271
    261272      ++Count;    // Count the number of records printed
    262273
     
    280291      // Ensure that the argument strings are not too long.
    281292      mGaugeString[DP_GAUGE_STRING_LENGTH] = 0;
    282       mUnicodeToken[13] = 0;
     293      mUnicodeToken[13]                    = 0;
    283294
    284295      if (mShowId) {
    285         ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_ALL_VARS2), mDpHiiHandle,
     296        ShellPrintHiiEx (
     297          -1,
     298          -1,
     299          NULL,
     300          STRING_TOKEN (STR_DP_ALL_VARS2),
     301          mDpHiiHandle,
    286302          Index,      // 1 based, Which measurement record is being printed
    287303          IncFlag,
     
    291307          ElapsedTime,
    292308          Measurement.Identifier
    293         );
     309          );
    294310      } else {
    295         ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_ALL_VARS), mDpHiiHandle,
     311        ShellPrintHiiEx (
     312          -1,
     313          -1,
     314          NULL,
     315          STRING_TOKEN (STR_DP_ALL_VARS),
     316          mDpHiiHandle,
    296317          Index,      // 1 based, Which measurement record is being printed
    297318          IncFlag,
     
    300321          mUnicodeToken,
    301322          ElapsedTime
    302         );
    303       }
     323          );
     324      }
     325
    304326      if (ShellGetExecutionBreakFlag ()) {
    305327        Status = EFI_ABORTED;
     
    308330    }
    309331  }
     332
    310333  if (HandleBuffer != NULL) {
    311334    FreePool (HandleBuffer);
    312335  }
     336
    313337  SHELL_FREE_NON_NULL (IncFlag);
    314338
     
    337361**/
    338362EFI_STATUS
    339 DumpRawTrace(
    340   IN UINTN          Limit,
    341   IN BOOLEAN        ExcludeFlag
     363DumpRawTrace (
     364  IN UINTN    Limit,
     365  IN BOOLEAN  ExcludeFlag
    342366  )
    343367{
    344   MEASUREMENT_RECORD        Measurement;
    345   UINT64                    ElapsedTime;
    346   UINT64                    Duration;
    347   UINTN                     LogEntryKey;
    348   UINTN                     Count;
    349   UINTN                     Index;
    350 
    351   EFI_STRING    StringPtr;
    352   EFI_STRING    StringPtrUnknown;
    353   EFI_STATUS    Status;
     368  MEASUREMENT_RECORD  Measurement;
     369  UINT64              ElapsedTime;
     370  UINT64              Duration;
     371  UINTN               LogEntryKey;
     372  UINTN               Count;
     373  UINTN               Index;
     374
     375  EFI_STRING  StringPtr;
     376  EFI_STRING  StringPtrUnknown;
     377  EFI_STATUS  Status;
    354378
    355379  Status = EFI_SUCCESS;
    356380
    357381  StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
    358   StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_RAWTRACE), NULL);
    359   ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,
    360               (StringPtr == NULL) ? StringPtrUnknown : StringPtr);
     382  StringPtr        = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_RAWTRACE), NULL);
     383  ShellPrintHiiEx (
     384    -1,
     385    -1,
     386    NULL,
     387    STRING_TOKEN (STR_DP_SECTION_HEADER),
     388    mDpHiiHandle,
     389    (StringPtr == NULL) ? StringPtrUnknown : StringPtr
     390    );
    361391  FreePool (StringPtr);
    362392  FreePool (StringPtrUnknown);
     
    371401
    372402  LogEntryKey = 0;
    373   Count = 0;
    374   Index = 0;
    375   while ( WITHIN_LIMIT(Count, Limit) &&
     403  Count       = 0;
     404  Index       = 0;
     405  while ( WITHIN_LIMIT (Count, Limit) &&
    376406          ((LogEntryKey = GetPerformanceMeasurementRecord (
    377                           LogEntryKey,
    378                           &Measurement.Handle,
    379                           &Measurement.Token,
    380                           &Measurement.Module,
    381                           &Measurement.StartTimeStamp,
    382                           &Measurement.EndTimeStamp,
    383                           &Measurement.Identifier)) != 0)
    384         )
     407                            LogEntryKey,
     408                            &Measurement.Handle,
     409                            &Measurement.Token,
     410                            &Measurement.Module,
     411                            &Measurement.StartTimeStamp,
     412                            &Measurement.EndTimeStamp,
     413                            &Measurement.Identifier
     414                            )) != 0)
     415          )
    385416  {
    386417    ++Index;    // Count every record.  First record is 1.
    387418    ElapsedTime = 0;
    388419    if (Measurement.EndTimeStamp != 0) {
    389       Duration = GetDuration (&Measurement);
    390       ElapsedTime = DurationInMicroSeconds ( Duration );
    391     }
     420      Duration    = GetDuration (&Measurement);
     421      ElapsedTime = DurationInMicroSeconds (Duration);
     422    }
     423
    392424    if ((ElapsedTime < mInterestThreshold)                 ||
    393         ((ExcludeFlag) && (GetCumulativeItem(&Measurement) >= 0))
    394         ) { // Ignore "uninteresting" or Excluded records
     425        ((ExcludeFlag) && (GetCumulativeItem (&Measurement) >= 0))
     426        )   // Ignore "uninteresting" or Excluded records
     427    {
    395428      continue;
    396429    }
     430
    397431    ++Count;    // Count the number of records printed
    398432
    399433    if (mShowId) {
    400       ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_VARS2), mDpHiiHandle,
     434      ShellPrintHiiEx (
     435        -1,
     436        -1,
     437        NULL,
     438        STRING_TOKEN (STR_DP_RAW_VARS2),
     439        mDpHiiHandle,
    401440        Index,      // 1 based, Which measurement record is being printed
    402441        Measurement.Handle,
     
    406445        Measurement.Module,
    407446        Measurement.Identifier
    408       );
     447        );
    409448    } else {
    410       ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_VARS), mDpHiiHandle,
     449      ShellPrintHiiEx (
     450        -1,
     451        -1,
     452        NULL,
     453        STRING_TOKEN (STR_DP_RAW_VARS),
     454        mDpHiiHandle,
    411455        Index,      // 1 based, Which measurement record is being printed
    412456        Measurement.Handle,
     
    415459        Measurement.Token,
    416460        Measurement.Module
    417       );
    418     }
     461        );
     462    }
     463
    419464    if (ShellGetExecutionBreakFlag ()) {
    420465      Status = EFI_ABORTED;
     
    422467    }
    423468  }
     469
    424470  return Status;
    425471}
     
    430476**/
    431477VOID
    432 ProcessPhases(
     478ProcessPhases (
    433479  VOID
    434480  )
    435481{
    436   MEASUREMENT_RECORD        Measurement;
    437   UINT64                    BdsTimeoutValue;
    438   UINT64                    SecTime;
    439   UINT64                    PeiTime;
    440   UINT64                    DxeTime;
    441   UINT64                    BdsTime;
    442   UINT64                    ElapsedTime;
    443   UINT64                    Duration;
    444   UINT64                    Total;
    445   EFI_STRING                StringPtr;
    446   UINTN                     LogEntryKey;
    447   EFI_STRING                StringPtrUnknown;
     482  MEASUREMENT_RECORD  Measurement;
     483  UINT64              BdsTimeoutValue;
     484  UINT64              SecTime;
     485  UINT64              PeiTime;
     486  UINT64              DxeTime;
     487  UINT64              BdsTime;
     488  UINT64              ElapsedTime;
     489  UINT64              Duration;
     490  UINT64              Total;
     491  EFI_STRING          StringPtr;
     492  UINTN               LogEntryKey;
     493  EFI_STRING          StringPtrUnknown;
    448494
    449495  BdsTimeoutValue = 0;
     
    456502  //
    457503  StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
    458   StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_PHASES), NULL);
    459   ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,
    460               (StringPtr == NULL) ? StringPtrUnknown : StringPtr);
     504  StringPtr        = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_PHASES), NULL);
     505  ShellPrintHiiEx (
     506    -1,
     507    -1,
     508    NULL,
     509    STRING_TOKEN (STR_DP_SECTION_HEADER),
     510    mDpHiiHandle,
     511    (StringPtr == NULL) ? StringPtrUnknown : StringPtr
     512    );
    461513  FreePool (StringPtr);
    462514  FreePool (StringPtrUnknown);
     
    470522                          &Measurement.StartTimeStamp,
    471523                          &Measurement.EndTimeStamp,
    472                           &Measurement.Identifier)) != 0)
     524                          &Measurement.Identifier
     525                          )) != 0)
    473526  {
    474     if (Measurement.EndTimeStamp == 0) { // Skip "incomplete" records
     527    if (Measurement.EndTimeStamp == 0) {
     528      // Skip "incomplete" records
    475529      continue;
    476530    }
     531
    477532    Duration = GetDuration (&Measurement);
    478     if (   Measurement.Handle != NULL
    479         && (AsciiStrCmp (Measurement.Token, ALit_BdsTO) == 0)
    480        )
     533    if (  (Measurement.Handle != NULL)
     534       && (AsciiStrCmp (Measurement.Token, ALit_BdsTO) == 0)
     535          )
    481536    {
    482537      BdsTimeoutValue = Duration;
    483538    } else if (AsciiStrCmp (Measurement.Token, ALit_SEC) == 0) {
    484       SecTime     = Duration;
     539      SecTime = Duration;
    485540    } else if (AsciiStrCmp (Measurement.Token, ALit_PEI) == 0) {
    486       PeiTime     = Duration;
     541      PeiTime = Duration;
    487542    } else if (AsciiStrCmp (Measurement.Token, ALit_DXE) == 0) {
    488       DxeTime      = Duration;
     543      DxeTime = Duration;
    489544    } else if (AsciiStrCmp (Measurement.Token, ALit_BDS) == 0) {
    490       BdsTime      = Duration;
     545      BdsTime = Duration;
    491546    }
    492547  }
    493548
    494549  Total = 0;
     550
     551  // print Reset End if it's valid
     552  //
     553  if (SecTime > mResetEnd) {
     554    SecTime     = SecTime - mResetEnd;                // Calculate sec time duration start from the beginning of firmware image execution
     555    ElapsedTime = DurationInMicroSeconds (mResetEnd); // Calculate elapsed time in microseconds
     556    Total      += DivU64x32 (ElapsedTime, 1000);      // Accumulate time in milliseconds
     557    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RESET_END), mDpHiiHandle, ElapsedTime);
     558  }
    495559
    496560  // print SEC phase duration time
    497561  //
    498562  if (SecTime > 0) {
    499     ElapsedTime = DurationInMicroSeconds ( SecTime );    // Calculate elapsed time in microseconds
    500     Total += DivU64x32 (ElapsedTime, 1000);   // Accumulate time in milliseconds
     563    ElapsedTime = DurationInMicroSeconds (SecTime); // Calculate elapsed time in microseconds
     564    Total      += DivU64x32 (ElapsedTime, 1000);    // Accumulate time in milliseconds
    501565    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SEC_PHASE), mDpHiiHandle, ElapsedTime);
    502566  }
     
    506570  if (PeiTime > 0) {
    507571    ElapsedTime = DivU64x32 (PeiTime, 1000000);
    508     Total += ElapsedTime;
     572    Total      += ElapsedTime;
    509573    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PHASE_DURATION), mDpHiiHandle, ALit_PEI, ElapsedTime);
    510574  }
     
    514578  if (DxeTime > 0) {
    515579    ElapsedTime = DivU64x32 (DxeTime, 1000000);
    516     Total += ElapsedTime;
     580    Total      += ElapsedTime;
    517581    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PHASE_DURATION), mDpHiiHandle, ALit_DXE, ElapsedTime);
    518582  }
     
    522586  if (BdsTime > 0) {
    523587    ElapsedTime = DivU64x32 (BdsTime, 1000000);
    524     Total += ElapsedTime;
     588    Total      += ElapsedTime;
    525589    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PHASE_DURATION), mDpHiiHandle, ALit_BDS, ElapsedTime);
    526590  }
     
    544608**/
    545609EFI_STATUS
    546 ProcessHandles(
    547   IN BOOLEAN      ExcludeFlag
     610ProcessHandles (
     611  IN BOOLEAN  ExcludeFlag
    548612  )
    549613{
    550   MEASUREMENT_RECORD        Measurement;
    551   UINT64                    ElapsedTime;
    552   UINT64                    Duration;
    553   EFI_HANDLE                *HandleBuffer;
    554   EFI_STRING                StringPtr;
    555   UINTN                     Index;
    556   UINTN                     LogEntryKey;
    557   UINTN                     Count;
    558   UINTN                     HandleCount;
    559   EFI_STATUS                Status;
    560   EFI_STRING                StringPtrUnknown;
     614  MEASUREMENT_RECORD  Measurement;
     615  UINT64              ElapsedTime;
     616  UINT64              Duration;
     617  EFI_HANDLE          *HandleBuffer;
     618  EFI_STRING          StringPtr;
     619  UINTN               Index;
     620  UINTN               LogEntryKey;
     621  UINTN               Count;
     622  UINTN               HandleCount;
     623  EFI_STATUS          Status;
     624  EFI_STRING          StringPtrUnknown;
    561625
    562626  StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
    563   StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_DRIVERS), NULL);
    564   ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,
    565               (StringPtr == NULL) ? StringPtrUnknown : StringPtr);
     627  StringPtr        = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_DRIVERS), NULL);
     628  ShellPrintHiiEx (
     629    -1,
     630    -1,
     631    NULL,
     632    STRING_TOKEN (STR_DP_SECTION_HEADER),
     633    mDpHiiHandle,
     634    (StringPtr == NULL) ? StringPtrUnknown : StringPtr
     635    );
    566636  FreePool (StringPtr);
    567637  FreePool (StringPtrUnknown);
     
    570640  if (EFI_ERROR (Status)) {
    571641    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLES_ERROR), mDpHiiHandle, Status);
    572   }
    573   else {
    574 #if DP_DEBUG == 2
    575     Print (L"There are %,d Handles defined.\n", (Size / sizeof(HandleBuffer[0])));
    576 #endif
     642  } else {
     643 #if DP_DEBUG == 2
     644    Print (L"There are %,d Handles defined.\n", (Size / sizeof (HandleBuffer[0])));
     645 #endif
    577646
    578647    if (mShowId) {
     
    581650      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLE_SECTION), mDpHiiHandle);
    582651    }
     652
    583653    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), mDpHiiHandle);
    584654
    585655    LogEntryKey = 0;
    586     Count   = 0;
     656    Count       = 0;
    587657    while ((LogEntryKey = GetPerformanceMeasurementRecord (
    588658                            LogEntryKey,
     
    592662                            &Measurement.StartTimeStamp,
    593663                            &Measurement.EndTimeStamp,
    594                             &Measurement.Identifier)) != 0)
     664                            &Measurement.Identifier
     665                            )) != 0)
    595666    {
    596667      Count++;
    597       Duration = GetDuration (&Measurement);
    598       ElapsedTime = DurationInMicroSeconds ( Duration );
     668      Duration    = GetDuration (&Measurement);
     669      ElapsedTime = DurationInMicroSeconds (Duration);
    599670      if ((ElapsedTime < mInterestThreshold)                 ||
    600671          (Measurement.EndTimeStamp == 0)                    ||
    601672          (!IsCorePerf (&Measurement))                       ||
    602           ((ExcludeFlag) && (GetCumulativeItem(&Measurement) >= 0))
    603          ) { // Ignore "uninteresting" or excluded records
     673          ((ExcludeFlag) && (GetCumulativeItem (&Measurement) >= 0))
     674          )  // Ignore "uninteresting" or excluded records
     675      {
    604676        continue;
    605677      }
     678
    606679      mGaugeString[0] = 0;    // Empty driver name by default
    607680      AsciiStrToUnicodeStrS (Measurement.Token, mUnicodeToken, ARRAY_SIZE (mUnicodeToken));
     
    613686        }
    614687      }
     688
    615689      // Ensure that the argument strings are not too long.
    616690      mGaugeString[DP_GAUGE_STRING_LENGTH] = 0;
    617       mUnicodeToken[11] = 0;
     691      mUnicodeToken[11]                    = 0;
    618692      if (mGaugeString[0] != 0) {
    619693        // Display the record if it has a valid handle.
    620694        if (mShowId) {
    621           ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLE_VARS2), mDpHiiHandle,
     695          ShellPrintHiiEx (
     696            -1,
     697            -1,
     698            NULL,
     699            STRING_TOKEN (STR_DP_HANDLE_VARS2),
     700            mDpHiiHandle,
    622701            Count,      // 1 based, Which measurement record is being printed
    623702            Index + 1,  // 1 based, Which handle is being printed
     
    626705            ElapsedTime,
    627706            Measurement.Identifier
    628           );
     707            );
    629708        } else {
    630           ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLE_VARS), mDpHiiHandle,
     709          ShellPrintHiiEx (
     710            -1,
     711            -1,
     712            NULL,
     713            STRING_TOKEN (STR_DP_HANDLE_VARS),
     714            mDpHiiHandle,
    631715            Count,      // 1 based, Which measurement record is being printed
    632716            Index + 1,  // 1 based, Which handle is being printed
     
    634718            mUnicodeToken,
    635719            ElapsedTime
    636           );
     720            );
    637721        }
    638722      }
     723
    639724      if (ShellGetExecutionBreakFlag ()) {
    640725        Status = EFI_ABORTED;
     
    643728    }
    644729  }
     730
    645731  if (HandleBuffer != NULL) {
    646732    FreePool (HandleBuffer);
    647733  }
     734
    648735  return Status;
    649736}
     
    658745**/
    659746EFI_STATUS
    660 ProcessPeims(
     747ProcessPeims (
    661748  VOID
    662 )
     749  )
    663750{
    664   MEASUREMENT_RECORD        Measurement;
    665   UINT64                    Duration;
    666   UINT64                    ElapsedTime;
    667   EFI_STRING                StringPtr;
    668   UINTN                     LogEntryKey;
    669   UINTN                     TIndex;
    670   EFI_STRING                StringPtrUnknown;
    671   EFI_STATUS                Status;
     751  MEASUREMENT_RECORD  Measurement;
     752  UINT64              Duration;
     753  UINT64              ElapsedTime;
     754  EFI_STRING          StringPtr;
     755  UINTN               LogEntryKey;
     756  UINTN               TIndex;
     757  EFI_STRING          StringPtrUnknown;
     758  EFI_STATUS          Status;
    672759
    673760  Status = EFI_SUCCESS;
    674761
    675762  StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
    676   StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_PEIMS), NULL);
    677   ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,
    678               (StringPtr == NULL) ? StringPtrUnknown : StringPtr);
     763  StringPtr        = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_PEIMS), NULL);
     764  ShellPrintHiiEx (
     765    -1,
     766    -1,
     767    NULL,
     768    STRING_TOKEN (STR_DP_SECTION_HEADER),
     769    mDpHiiHandle,
     770    (StringPtr == NULL) ? StringPtrUnknown : StringPtr
     771    );
    679772  FreePool (StringPtr);
    680773  FreePool (StringPtrUnknown);
     
    685778    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PEIM_SECTION), mDpHiiHandle);
    686779  }
     780
    687781  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), mDpHiiHandle);
    688   TIndex  = 0;
     782  TIndex      = 0;
    689783  LogEntryKey = 0;
    690784  while ((LogEntryKey = GetPerformanceMeasurementRecord (
     
    695789                          &Measurement.StartTimeStamp,
    696790                          &Measurement.EndTimeStamp,
    697                           &Measurement.Identifier)) != 0)
     791                          &Measurement.Identifier
     792                          )) != 0)
    698793  {
    699794    TIndex++;
    700795    if ((Measurement.EndTimeStamp == 0) ||
    701796        (AsciiStrCmp (Measurement.Token, ALit_PEIM) != 0)
    702        ) {
     797        )
     798    {
    703799      continue;
    704800    }
    705801
    706     Duration = GetDuration (&Measurement);
    707     ElapsedTime = DurationInMicroSeconds ( Duration );  // Calculate elapsed time in microseconds
     802    Duration    = GetDuration (&Measurement);
     803    ElapsedTime = DurationInMicroSeconds (Duration);    // Calculate elapsed time in microseconds
    708804    if (ElapsedTime >= mInterestThreshold) {
    709805      // PEIM FILE Handle is the start address of its FFS file that contains its file guid.
    710806      if (mShowId) {
    711         ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PEIM_VARS2), mDpHiiHandle,
    712               TIndex,   // 1 based, Which measurement record is being printed
    713               Measurement.Handle,  // file guid
    714               ElapsedTime,
    715               Measurement.Identifier
    716         );
     807        ShellPrintHiiEx (
     808          -1,
     809          -1,
     810          NULL,
     811          STRING_TOKEN (STR_DP_PEIM_VARS2),
     812          mDpHiiHandle,
     813          TIndex,             // 1 based, Which measurement record is being printed
     814          Measurement.Handle, // file guid
     815          ElapsedTime,
     816          Measurement.Identifier
     817          );
    717818      } else {
    718         ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PEIM_VARS), mDpHiiHandle,
    719               TIndex,   // 1 based, Which measurement record is being printed
    720               Measurement.Handle,  // file guid
    721               ElapsedTime
    722         );
    723       }
    724     }
     819        ShellPrintHiiEx (
     820          -1,
     821          -1,
     822          NULL,
     823          STRING_TOKEN (STR_DP_PEIM_VARS),
     824          mDpHiiHandle,
     825          TIndex,             // 1 based, Which measurement record is being printed
     826          Measurement.Handle, // file guid
     827          ElapsedTime
     828          );
     829      }
     830    }
     831
    725832    if (ShellGetExecutionBreakFlag ()) {
    726833      Status = EFI_ABORTED;
     
    728835    }
    729836  }
     837
    730838  return Status;
    731839}
     
    743851**/
    744852EFI_STATUS
    745 ProcessGlobal(
     853ProcessGlobal (
    746854  VOID
    747 )
     855  )
    748856{
    749   MEASUREMENT_RECORD        Measurement;
    750   UINT64                    Duration;
    751   UINT64                    ElapsedTime;
    752   EFI_STRING                StringPtr;
    753   UINTN                     LogEntryKey;
    754   UINTN                     Index;        // Index, or number, of the measurement record being processed
    755   EFI_STRING                StringPtrUnknown;
    756   EFI_STATUS                Status;
     857  MEASUREMENT_RECORD  Measurement;
     858  UINT64              Duration;
     859  UINT64              ElapsedTime;
     860  EFI_STRING          StringPtr;
     861  UINTN               LogEntryKey;
     862  UINTN               Index;              // Index, or number, of the measurement record being processed
     863  EFI_STRING          StringPtrUnknown;
     864  EFI_STATUS          Status;
    757865
    758866  Status = EFI_SUCCESS;
    759867
    760868  StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
    761   StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_GENERAL), NULL);
    762   ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,
    763               (StringPtr == NULL) ? StringPtrUnknown: StringPtr);
     869  StringPtr        = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_GENERAL), NULL);
     870  ShellPrintHiiEx (
     871    -1,
     872    -1,
     873    NULL,
     874    STRING_TOKEN (STR_DP_SECTION_HEADER),
     875    mDpHiiHandle,
     876    (StringPtr == NULL) ? StringPtrUnknown : StringPtr
     877    );
    764878  FreePool (StringPtr);
    765879  FreePool (StringPtrUnknown);
     
    770884    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GLOBAL_SECTION), mDpHiiHandle);
    771885  }
     886
    772887  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), mDpHiiHandle);
    773888
    774   Index = 1;
     889  Index       = 1;
    775890  LogEntryKey = 0;
    776891
     
    782897                          &Measurement.StartTimeStamp,
    783898                          &Measurement.EndTimeStamp,
    784                           &Measurement.Identifier)) != 0)
     899                          &Measurement.Identifier
     900                          )) != 0)
    785901  {
    786902    AsciiStrToUnicodeStrS (Measurement.Module, mGaugeString, ARRAY_SIZE (mGaugeString));
    787903    AsciiStrToUnicodeStrS (Measurement.Token, mUnicodeToken, ARRAY_SIZE (mUnicodeToken));
    788     mGaugeString[25] = 0;
     904    mGaugeString[25]  = 0;
    789905    mUnicodeToken[31] = 0;
    790     if ( ! ( IsPhase( &Measurement)  ||
    791         IsCorePerf (&Measurement)      ||
    792         (Measurement.EndTimeStamp == 0)
    793         ))
     906    if ( !(IsPhase (&Measurement)  ||
     907           IsCorePerf (&Measurement)      ||
     908           (Measurement.EndTimeStamp == 0)
     909           ))
    794910    {
    795       Duration = GetDuration (&Measurement);
    796       ElapsedTime = DurationInMicroSeconds ( Duration );
     911      Duration    = GetDuration (&Measurement);
     912      ElapsedTime = DurationInMicroSeconds (Duration);
    797913      if (ElapsedTime >= mInterestThreshold) {
    798914        if (mShowId) {
    799           ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GLOBAL_VARS2), mDpHiiHandle,
     915          ShellPrintHiiEx (
     916            -1,
     917            -1,
     918            NULL,
     919            STRING_TOKEN (STR_DP_GLOBAL_VARS2),
     920            mDpHiiHandle,
    800921            Index,
    801922            mGaugeString,
     
    805926            );
    806927        } else {
    807            ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GLOBAL_VARS), mDpHiiHandle,
     928          ShellPrintHiiEx (
     929            -1,
     930            -1,
     931            NULL,
     932            STRING_TOKEN (STR_DP_GLOBAL_VARS),
     933            mDpHiiHandle,
    808934            Index,
    809935            mGaugeString,
     
    814940      }
    815941    }
     942
    816943    if (ShellGetExecutionBreakFlag ()) {
    817944      Status = EFI_ABORTED;
    818945      break;
    819946    }
     947
    820948    Index++;
    821949  }
     950
    822951  return Status;
    823952}
     
    835964**/
    836965VOID
    837 ProcessCumulative(
    838   IN PERF_CUM_DATA                  *CustomCumulativeData OPTIONAL
     966ProcessCumulative (
     967  IN PERF_CUM_DATA  *CustomCumulativeData OPTIONAL
    839968  )
    840969{
    841   UINT64                    AvgDur;         // the computed average duration
    842   UINT64                    Dur;
    843   UINT64                    MinDur;
    844   UINT64                    MaxDur;
    845   EFI_STRING                StringPtr;
    846   UINTN                     TIndex;
    847   EFI_STRING                StringPtrUnknown;
     970  UINT64      AvgDur;                       // the computed average duration
     971  UINT64      Dur;
     972  UINT64      MinDur;
     973  UINT64      MaxDur;
     974  EFI_STRING  StringPtr;
     975  UINTN       TIndex;
     976  EFI_STRING  StringPtrUnknown;
    848977
    849978  StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
    850   StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_CUMULATIVE), NULL);
    851   ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,
    852               (StringPtr == NULL) ? StringPtrUnknown: StringPtr);
     979  StringPtr        = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_CUMULATIVE), NULL);
     980  ShellPrintHiiEx (
     981    -1,
     982    -1,
     983    NULL,
     984    STRING_TOKEN (STR_DP_SECTION_HEADER),
     985    mDpHiiHandle,
     986    (StringPtr == NULL) ? StringPtrUnknown : StringPtr
     987    );
    853988  FreePool (StringPtr);
    854989  FreePool (StringPtrUnknown);
     
    861996    if (CumData[TIndex].Count != 0) {
    862997      AvgDur = DivU64x32 (CumData[TIndex].Duration, CumData[TIndex].Count);
    863       AvgDur = DurationInMicroSeconds(AvgDur);
    864       Dur    = DurationInMicroSeconds(CumData[TIndex].Duration);
    865       MaxDur = DurationInMicroSeconds(CumData[TIndex].MaxDur);
    866       MinDur = DurationInMicroSeconds(CumData[TIndex].MinDur);
    867 
    868       ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_CUMULATIVE_STATS), mDpHiiHandle,
    869                   CumData[TIndex].Name,
    870                   CumData[TIndex].Count,
    871                   Dur,
    872                   AvgDur,
    873                   MinDur,
    874                   MaxDur
    875                  );
     998      AvgDur = DurationInMicroSeconds (AvgDur);
     999      Dur    = DurationInMicroSeconds (CumData[TIndex].Duration);
     1000      MaxDur = DurationInMicroSeconds (CumData[TIndex].MaxDur);
     1001      MinDur = DurationInMicroSeconds (CumData[TIndex].MinDur);
     1002
     1003      ShellPrintHiiEx (
     1004        -1,
     1005        -1,
     1006        NULL,
     1007        STRING_TOKEN (STR_DP_CUMULATIVE_STATS),
     1008        mDpHiiHandle,
     1009        CumData[TIndex].Name,
     1010        CumData[TIndex].Count,
     1011        Dur,
     1012        AvgDur,
     1013        MinDur,
     1014        MaxDur
     1015        );
    8761016    }
    8771017  }
     
    8931033      MinDur = 0;
    8941034    }
    895     ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_CUMULATIVE_STATS), mDpHiiHandle,
    896                 CustomCumulativeData->Name,
    897                 CustomCumulativeData->Count,
    898                 Dur,
    899                 AvgDur,
    900                 MinDur,
    901                 MaxDur
    902                 );
     1035
     1036    ShellPrintHiiEx (
     1037      -1,
     1038      -1,
     1039      NULL,
     1040      STRING_TOKEN (STR_DP_CUMULATIVE_STATS),
     1041      mDpHiiHandle,
     1042      CustomCumulativeData->Name,
     1043      CustomCumulativeData->Count,
     1044      Dur,
     1045      AvgDur,
     1046      MinDur,
     1047      MaxDur
     1048      );
    9031049  }
    9041050}
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette