Changeset 99404 in vbox for trunk/src/VBox/Devices/EFI/FirmwareNew/ShellPkg/DynamicCommand/DpDynamicCommand/DpTrace.c
- Timestamp:
- Apr 14, 2023 3:17:44 PM (2 years ago)
- svn:sync-xref-src-repo-rev:
- 156854
- Location:
- trunk/src/VBox/Devices/EFI/FirmwareNew
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/EFI/FirmwareNew
-
Property svn:mergeinfo
changed from (toggle deleted branches)
to (toggle deleted branches)/vendor/edk2/current 103735-103757,103769-103776,129194-145445 /vendor/edk2/current 103735-103757,103769-103776,129194-156846
-
Property svn:mergeinfo
changed from (toggle deleted branches)
-
trunk/src/VBox/Devices/EFI/FirmwareNew/ShellPkg/DynamicCommand/DpDynamicCommand/DpTrace.c
r85718 r99404 47 47 UINTN 48 48 GetPerformanceMeasurementRecord ( 49 IN UINTNLogEntryKey,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*Identifier49 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 56 56 ) 57 57 { … … 60 60 } 61 61 62 *Handle = (VOID *) (UINTN)mMeasurementList[LogEntryKey].Handle;62 *Handle = (VOID *)(UINTN)mMeasurementList[LogEntryKey].Handle; 63 63 *Token = mMeasurementList[LogEntryKey].Token; 64 64 *Module = mMeasurementList[LogEntryKey].Module; … … 67 67 *Identifier = mMeasurementList[LogEntryKey].Identifier; 68 68 69 LogEntryKey 69 LogEntryKey++; 70 70 71 71 return LogEntryKey; … … 90 90 **/ 91 91 VOID 92 GatherStatistics (93 IN OUT PERF_CUM_DATA 92 GatherStatistics ( 93 IN OUT PERF_CUM_DATA *CustomCumulativeData OPTIONAL 94 94 ) 95 95 { 96 MEASUREMENT_RECORD 97 UINT64 98 UINTN 99 INTN 96 MEASUREMENT_RECORD Measurement; 97 UINT64 Duration; 98 UINTN LogEntryKey; 99 INTN TIndex; 100 100 101 101 LogEntryKey = 0; 102 102 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) 110 111 { 111 112 ++SummaryData.NumTrace; // Count the number of TRACE Measurement records … … 119 120 } 120 121 121 if (IsPhase (&Measurement)) {122 if (IsPhase (&Measurement)) { 122 123 ++SummaryData.NumSummary; // Count the number of major phases 123 } 124 else {// !IsPhase125 if (Measurement.Handle == NULL) {124 } else { 125 // !IsPhase 126 if (Measurement.Handle == NULL) { 126 127 ++SummaryData.NumGlobal; 127 128 } … … 133 134 134 135 Duration = GetDuration (&Measurement); 135 TIndex = GetCumulativeItem (&Measurement);136 TIndex = GetCumulativeItem (&Measurement); 136 137 if (TIndex >= 0) { 137 138 CumData[TIndex].Duration += Duration; … … 140 141 CumData[TIndex].MinDur = Duration; 141 142 } 143 142 144 if ( Duration > CumData[TIndex].MaxDur ) { 143 145 CumData[TIndex].MaxDur = Duration; … … 154 156 CustomCumulativeData->MinDur = Duration; 155 157 } 158 156 159 if (Duration > CustomCumulativeData->MaxDur) { 157 160 CustomCumulativeData->MaxDur = Duration; … … 183 186 **/ 184 187 EFI_STATUS 185 DumpAllTrace (186 IN UINTN 187 IN BOOLEAN 188 DumpAllTrace ( 189 IN UINTN Limit, 190 IN BOOLEAN ExcludeFlag 188 191 ) 189 192 { 190 MEASUREMENT_RECORD 191 UINT64 192 UINT64 193 CHAR16 194 UINTN 195 UINTN 196 UINTN 197 UINTN 198 199 EFI_HANDLE 200 UINTN 201 EFI_STATUS 202 EFI_STRING 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; 203 206 204 207 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 ); 208 217 FreePool (StringPtrUnknown); 209 218 210 219 // Get Handle information 211 220 // 212 Status 221 Status = gBS->LocateHandleBuffer (AllHandles, NULL, NULL, &HandleCount, &HandleBuffer); 213 222 if (EFI_ERROR (Status)) { 214 223 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLES_ERROR), mDpHiiHandle, Status); 215 } 216 else { 224 } else { 217 225 // We have successfully populated the HandleBuffer 218 226 // Display ALL Measurement Records … … 230 238 231 239 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) && 235 243 ((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 ) 244 253 { 245 254 ++Index; // Count every record. First record is 1. … … 247 256 SHELL_FREE_NON_NULL (IncFlag); 248 257 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 { 254 262 IncFlag = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_INCOMPLETE), NULL); // Mark incomplete records 255 263 } 264 256 265 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 { 259 269 continue; 260 270 } 271 261 272 ++Count; // Count the number of records printed 262 273 … … 280 291 // Ensure that the argument strings are not too long. 281 292 mGaugeString[DP_GAUGE_STRING_LENGTH] = 0; 282 mUnicodeToken[13] = 0;293 mUnicodeToken[13] = 0; 283 294 284 295 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, 286 302 Index, // 1 based, Which measurement record is being printed 287 303 IncFlag, … … 291 307 ElapsedTime, 292 308 Measurement.Identifier 293 );309 ); 294 310 } 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, 296 317 Index, // 1 based, Which measurement record is being printed 297 318 IncFlag, … … 300 321 mUnicodeToken, 301 322 ElapsedTime 302 ); 303 } 323 ); 324 } 325 304 326 if (ShellGetExecutionBreakFlag ()) { 305 327 Status = EFI_ABORTED; … … 308 330 } 309 331 } 332 310 333 if (HandleBuffer != NULL) { 311 334 FreePool (HandleBuffer); 312 335 } 336 313 337 SHELL_FREE_NON_NULL (IncFlag); 314 338 … … 337 361 **/ 338 362 EFI_STATUS 339 DumpRawTrace (340 IN UINTN 341 IN BOOLEAN 363 DumpRawTrace ( 364 IN UINTN Limit, 365 IN BOOLEAN ExcludeFlag 342 366 ) 343 367 { 344 MEASUREMENT_RECORD 345 UINT64 346 UINT64 347 UINTN 348 UINTN 349 UINTN 350 351 EFI_STRING 352 EFI_STRING 353 EFI_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; 354 378 355 379 Status = EFI_SUCCESS; 356 380 357 381 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 ); 361 391 FreePool (StringPtr); 362 392 FreePool (StringPtrUnknown); … … 371 401 372 402 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) && 376 406 ((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 ) 385 416 { 386 417 ++Index; // Count every record. First record is 1. 387 418 ElapsedTime = 0; 388 419 if (Measurement.EndTimeStamp != 0) { 389 Duration = GetDuration (&Measurement); 390 ElapsedTime = DurationInMicroSeconds ( Duration ); 391 } 420 Duration = GetDuration (&Measurement); 421 ElapsedTime = DurationInMicroSeconds (Duration); 422 } 423 392 424 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 { 395 428 continue; 396 429 } 430 397 431 ++Count; // Count the number of records printed 398 432 399 433 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, 401 440 Index, // 1 based, Which measurement record is being printed 402 441 Measurement.Handle, … … 406 445 Measurement.Module, 407 446 Measurement.Identifier 408 );447 ); 409 448 } 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, 411 455 Index, // 1 based, Which measurement record is being printed 412 456 Measurement.Handle, … … 415 459 Measurement.Token, 416 460 Measurement.Module 417 ); 418 } 461 ); 462 } 463 419 464 if (ShellGetExecutionBreakFlag ()) { 420 465 Status = EFI_ABORTED; … … 422 467 } 423 468 } 469 424 470 return Status; 425 471 } … … 430 476 **/ 431 477 VOID 432 ProcessPhases (478 ProcessPhases ( 433 479 VOID 434 480 ) 435 481 { 436 MEASUREMENT_RECORD 437 UINT64 438 UINT64 439 UINT64 440 UINT64 441 UINT64 442 UINT64 443 UINT64 444 UINT64 445 EFI_STRING 446 UINTN 447 EFI_STRING 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; 448 494 449 495 BdsTimeoutValue = 0; … … 456 502 // 457 503 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 ); 461 513 FreePool (StringPtr); 462 514 FreePool (StringPtrUnknown); … … 470 522 &Measurement.StartTimeStamp, 471 523 &Measurement.EndTimeStamp, 472 &Measurement.Identifier)) != 0) 524 &Measurement.Identifier 525 )) != 0) 473 526 { 474 if (Measurement.EndTimeStamp == 0) { // Skip "incomplete" records 527 if (Measurement.EndTimeStamp == 0) { 528 // Skip "incomplete" records 475 529 continue; 476 530 } 531 477 532 Duration = GetDuration (&Measurement); 478 if ( Measurement.Handle != NULL479 480 )533 if ( (Measurement.Handle != NULL) 534 && (AsciiStrCmp (Measurement.Token, ALit_BdsTO) == 0) 535 ) 481 536 { 482 537 BdsTimeoutValue = Duration; 483 538 } else if (AsciiStrCmp (Measurement.Token, ALit_SEC) == 0) { 484 SecTime 539 SecTime = Duration; 485 540 } else if (AsciiStrCmp (Measurement.Token, ALit_PEI) == 0) { 486 PeiTime 541 PeiTime = Duration; 487 542 } else if (AsciiStrCmp (Measurement.Token, ALit_DXE) == 0) { 488 DxeTime 543 DxeTime = Duration; 489 544 } else if (AsciiStrCmp (Measurement.Token, ALit_BDS) == 0) { 490 BdsTime 545 BdsTime = Duration; 491 546 } 492 547 } 493 548 494 549 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 } 495 559 496 560 // print SEC phase duration time 497 561 // 498 562 if (SecTime > 0) { 499 ElapsedTime = DurationInMicroSeconds ( SecTime );// Calculate elapsed time in microseconds500 Total += DivU64x32 (ElapsedTime, 1000);// Accumulate time in milliseconds563 ElapsedTime = DurationInMicroSeconds (SecTime); // Calculate elapsed time in microseconds 564 Total += DivU64x32 (ElapsedTime, 1000); // Accumulate time in milliseconds 501 565 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SEC_PHASE), mDpHiiHandle, ElapsedTime); 502 566 } … … 506 570 if (PeiTime > 0) { 507 571 ElapsedTime = DivU64x32 (PeiTime, 1000000); 508 Total += ElapsedTime;572 Total += ElapsedTime; 509 573 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PHASE_DURATION), mDpHiiHandle, ALit_PEI, ElapsedTime); 510 574 } … … 514 578 if (DxeTime > 0) { 515 579 ElapsedTime = DivU64x32 (DxeTime, 1000000); 516 Total += ElapsedTime;580 Total += ElapsedTime; 517 581 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PHASE_DURATION), mDpHiiHandle, ALit_DXE, ElapsedTime); 518 582 } … … 522 586 if (BdsTime > 0) { 523 587 ElapsedTime = DivU64x32 (BdsTime, 1000000); 524 Total += ElapsedTime;588 Total += ElapsedTime; 525 589 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PHASE_DURATION), mDpHiiHandle, ALit_BDS, ElapsedTime); 526 590 } … … 544 608 **/ 545 609 EFI_STATUS 546 ProcessHandles (547 IN BOOLEAN 610 ProcessHandles ( 611 IN BOOLEAN ExcludeFlag 548 612 ) 549 613 { 550 MEASUREMENT_RECORD 551 UINT64 552 UINT64 553 EFI_HANDLE 554 EFI_STRING 555 UINTN 556 UINTN 557 UINTN 558 UINTN 559 EFI_STATUS 560 EFI_STRING 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; 561 625 562 626 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 ); 566 636 FreePool (StringPtr); 567 637 FreePool (StringPtrUnknown); … … 570 640 if (EFI_ERROR (Status)) { 571 641 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 577 646 578 647 if (mShowId) { … … 581 650 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLE_SECTION), mDpHiiHandle); 582 651 } 652 583 653 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), mDpHiiHandle); 584 654 585 655 LogEntryKey = 0; 586 Count = 0;656 Count = 0; 587 657 while ((LogEntryKey = GetPerformanceMeasurementRecord ( 588 658 LogEntryKey, … … 592 662 &Measurement.StartTimeStamp, 593 663 &Measurement.EndTimeStamp, 594 &Measurement.Identifier)) != 0) 664 &Measurement.Identifier 665 )) != 0) 595 666 { 596 667 Count++; 597 Duration = GetDuration (&Measurement);598 ElapsedTime = DurationInMicroSeconds ( Duration);668 Duration = GetDuration (&Measurement); 669 ElapsedTime = DurationInMicroSeconds (Duration); 599 670 if ((ElapsedTime < mInterestThreshold) || 600 671 (Measurement.EndTimeStamp == 0) || 601 672 (!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 { 604 676 continue; 605 677 } 678 606 679 mGaugeString[0] = 0; // Empty driver name by default 607 680 AsciiStrToUnicodeStrS (Measurement.Token, mUnicodeToken, ARRAY_SIZE (mUnicodeToken)); … … 613 686 } 614 687 } 688 615 689 // Ensure that the argument strings are not too long. 616 690 mGaugeString[DP_GAUGE_STRING_LENGTH] = 0; 617 mUnicodeToken[11] = 0;691 mUnicodeToken[11] = 0; 618 692 if (mGaugeString[0] != 0) { 619 693 // Display the record if it has a valid handle. 620 694 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, 622 701 Count, // 1 based, Which measurement record is being printed 623 702 Index + 1, // 1 based, Which handle is being printed … … 626 705 ElapsedTime, 627 706 Measurement.Identifier 628 );707 ); 629 708 } 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, 631 715 Count, // 1 based, Which measurement record is being printed 632 716 Index + 1, // 1 based, Which handle is being printed … … 634 718 mUnicodeToken, 635 719 ElapsedTime 636 );720 ); 637 721 } 638 722 } 723 639 724 if (ShellGetExecutionBreakFlag ()) { 640 725 Status = EFI_ABORTED; … … 643 728 } 644 729 } 730 645 731 if (HandleBuffer != NULL) { 646 732 FreePool (HandleBuffer); 647 733 } 734 648 735 return Status; 649 736 } … … 658 745 **/ 659 746 EFI_STATUS 660 ProcessPeims (747 ProcessPeims ( 661 748 VOID 662 )749 ) 663 750 { 664 MEASUREMENT_RECORD 665 UINT64 666 UINT64 667 EFI_STRING 668 UINTN 669 UINTN 670 EFI_STRING 671 EFI_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; 672 759 673 760 Status = EFI_SUCCESS; 674 761 675 762 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 ); 679 772 FreePool (StringPtr); 680 773 FreePool (StringPtrUnknown); … … 685 778 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PEIM_SECTION), mDpHiiHandle); 686 779 } 780 687 781 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), mDpHiiHandle); 688 TIndex = 0;782 TIndex = 0; 689 783 LogEntryKey = 0; 690 784 while ((LogEntryKey = GetPerformanceMeasurementRecord ( … … 695 789 &Measurement.StartTimeStamp, 696 790 &Measurement.EndTimeStamp, 697 &Measurement.Identifier)) != 0) 791 &Measurement.Identifier 792 )) != 0) 698 793 { 699 794 TIndex++; 700 795 if ((Measurement.EndTimeStamp == 0) || 701 796 (AsciiStrCmp (Measurement.Token, ALit_PEIM) != 0) 702 ) { 797 ) 798 { 703 799 continue; 704 800 } 705 801 706 Duration = GetDuration (&Measurement);707 ElapsedTime = DurationInMicroSeconds ( Duration );// Calculate elapsed time in microseconds802 Duration = GetDuration (&Measurement); 803 ElapsedTime = DurationInMicroSeconds (Duration); // Calculate elapsed time in microseconds 708 804 if (ElapsedTime >= mInterestThreshold) { 709 805 // PEIM FILE Handle is the start address of its FFS file that contains its file guid. 710 806 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 ); 717 818 } 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 725 832 if (ShellGetExecutionBreakFlag ()) { 726 833 Status = EFI_ABORTED; … … 728 835 } 729 836 } 837 730 838 return Status; 731 839 } … … 743 851 **/ 744 852 EFI_STATUS 745 ProcessGlobal (853 ProcessGlobal ( 746 854 VOID 747 )855 ) 748 856 { 749 MEASUREMENT_RECORD 750 UINT64 751 UINT64 752 EFI_STRING 753 UINTN 754 UINTN Index;// Index, or number, of the measurement record being processed755 EFI_STRING 756 EFI_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; 757 865 758 866 Status = EFI_SUCCESS; 759 867 760 868 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 ); 764 878 FreePool (StringPtr); 765 879 FreePool (StringPtrUnknown); … … 770 884 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GLOBAL_SECTION), mDpHiiHandle); 771 885 } 886 772 887 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), mDpHiiHandle); 773 888 774 Index = 1;889 Index = 1; 775 890 LogEntryKey = 0; 776 891 … … 782 897 &Measurement.StartTimeStamp, 783 898 &Measurement.EndTimeStamp, 784 &Measurement.Identifier)) != 0) 899 &Measurement.Identifier 900 )) != 0) 785 901 { 786 902 AsciiStrToUnicodeStrS (Measurement.Module, mGaugeString, ARRAY_SIZE (mGaugeString)); 787 903 AsciiStrToUnicodeStrS (Measurement.Token, mUnicodeToken, ARRAY_SIZE (mUnicodeToken)); 788 mGaugeString[25] = 0;904 mGaugeString[25] = 0; 789 905 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 )) 794 910 { 795 Duration = GetDuration (&Measurement);796 ElapsedTime = DurationInMicroSeconds ( Duration);911 Duration = GetDuration (&Measurement); 912 ElapsedTime = DurationInMicroSeconds (Duration); 797 913 if (ElapsedTime >= mInterestThreshold) { 798 914 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, 800 921 Index, 801 922 mGaugeString, … … 805 926 ); 806 927 } 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, 808 934 Index, 809 935 mGaugeString, … … 814 940 } 815 941 } 942 816 943 if (ShellGetExecutionBreakFlag ()) { 817 944 Status = EFI_ABORTED; 818 945 break; 819 946 } 947 820 948 Index++; 821 949 } 950 822 951 return Status; 823 952 } … … 835 964 **/ 836 965 VOID 837 ProcessCumulative (838 IN PERF_CUM_DATA 966 ProcessCumulative ( 967 IN PERF_CUM_DATA *CustomCumulativeData OPTIONAL 839 968 ) 840 969 { 841 UINT64 AvgDur;// the computed average duration842 UINT64 843 UINT64 844 UINT64 845 EFI_STRING 846 UINTN 847 EFI_STRING 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; 848 977 849 978 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 ); 853 988 FreePool (StringPtr); 854 989 FreePool (StringPtrUnknown); … … 861 996 if (CumData[TIndex].Count != 0) { 862 997 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 ); 876 1016 } 877 1017 } … … 893 1033 MinDur = 0; 894 1034 } 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 ); 903 1049 } 904 1050 }
Note:
See TracChangeset
for help on using the changeset viewer.