Dp.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /** @file
  2. Header file for 'dp' command functions.
  3. Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
  4. SPDX-License-Identifier: BSD-2-Clause-Patent
  5. **/
  6. #ifndef _DP_H_
  7. #define _DP_H_
  8. #include <Uefi.h>
  9. #include <Guid/Performance.h>
  10. #include <Guid/ExtendedFirmwarePerformance.h>
  11. #include <Guid/FirmwarePerformance.h>
  12. #include <Protocol/HiiPackageList.h>
  13. #include <Protocol/DevicePath.h>
  14. #include <Protocol/LoadedImage.h>
  15. #include <Protocol/UnicodeCollation.h>
  16. #include <Library/BaseLib.h>
  17. #include <Library/BaseMemoryLib.h>
  18. #include <Library/DebugLib.h>
  19. #include <Library/MemoryAllocationLib.h>
  20. #include <Library/ShellLib.h>
  21. #include <Library/UefiLib.h>
  22. #include <Library/UefiRuntimeServicesTableLib.h>
  23. #include <Library/UefiBootServicesTableLib.h>
  24. #include <Library/PcdLib.h>
  25. #include <Library/SortLib.h>
  26. #include <Library/HiiLib.h>
  27. #include <Library/FileHandleLib.h>
  28. #include <Library/UefiHiiServicesLib.h>
  29. #include <Library/PerformanceLib.h>
  30. extern EFI_HII_HANDLE mDpHiiHandle;
  31. #define DP_MAJOR_VERSION 2
  32. #define DP_MINOR_VERSION 5
  33. /**
  34. * The value assigned to DP_DEBUG controls which debug output
  35. * is generated. Set it to ZERO to disable.
  36. **/
  37. #define DP_DEBUG 0
  38. #define DEFAULT_THRESHOLD 1000 ///< One millisecond.
  39. #define DEFAULT_DISPLAYCOUNT 50
  40. #define MAXIMUM_DISPLAYCOUNT 999999 ///< Arbitrary maximum reasonable number.
  41. #define PERF_MAXDUR 0xFFFFFFFFFFFFFFFFULL
  42. /// Determine whether 0 <= C < L. If L == 0, return true regardless of C.
  43. #define WITHIN_LIMIT(C, L) ( ((L) == 0) || ((C) < (L)) )
  44. /// Structure for storing Timer specific information.
  45. typedef struct {
  46. UINT64 StartCount; ///< Value timer is initialized with.
  47. UINT64 EndCount; ///< Value timer has just before it wraps.
  48. UINT32 Frequency; ///< Timer count frequency in KHz.
  49. BOOLEAN CountUp; ///< TRUE if the counter counts up.
  50. } TIMER_INFO;
  51. /** Initialize one PERF_CUM_DATA structure instance for token t.
  52. *
  53. * This parameterized macro takes a single argument, t, which is expected
  54. * to resolve to a pointer to an ASCII string literal. This parameter may
  55. * take any one of the following forms:
  56. * - PERF_INIT_CUM_DATA("Token") A string literal
  57. * - PERF_INIT_CUM_DATA(pointer) A pointer -- CHAR8 *pointer;
  58. * - PERF_INIT_CUM_DATA(array) Address of an array -- CHAR8 array[N];
  59. **/
  60. #define PERF_INIT_CUM_DATA(t) { 0ULL, PERF_MAXDUR, 0ULL, (t), 0U }
  61. typedef struct {
  62. UINT64 Duration; ///< Cumulative duration for this item.
  63. UINT64 MinDur; ///< Smallest duration encountered.
  64. UINT64 MaxDur; ///< Largest duration encountered.
  65. CHAR8 *Name; ///< ASCII name of this item.
  66. UINT32 Count; ///< Total number of measurements accumulated.
  67. } PERF_CUM_DATA;
  68. typedef struct {
  69. UINT32 NumTrace; ///< Number of recorded TRACE performance measurements.
  70. UINT32 NumIncomplete; ///< Number of measurements with no END value.
  71. UINT32 NumSummary; ///< Number of summary section measurements.
  72. UINT32 NumHandles; ///< Number of measurements with handles.
  73. UINT32 NumPEIMs; ///< Number of measurements of PEIMs.
  74. UINT32 NumGlobal; ///< Number of measurements with END value and NULL handle.
  75. } PERF_SUMMARY_DATA;
  76. typedef struct {
  77. CONST VOID *Handle;
  78. CONST CHAR8 *Token; ///< Measured token string name.
  79. CONST CHAR8 *Module; ///< Module string name.
  80. UINT64 StartTimeStamp; ///< Start time point.
  81. UINT64 EndTimeStamp; ///< End time point.
  82. UINT32 Identifier; ///< Identifier.
  83. } MEASUREMENT_RECORD;
  84. typedef struct {
  85. CHAR8 *Name; ///< Measured token string name.
  86. UINT64 CumulativeTime; ///< Accumulated Elapsed Time.
  87. UINT64 MinTime; ///< Minimum Elapsed Time.
  88. UINT64 MaxTime; ///< Maximum Elapsed Time.
  89. UINT32 Count; ///< Number of measurements accumulated.
  90. } PROFILE_RECORD;
  91. /**
  92. Dump performance data.
  93. @param[in] ImageHandle The image handle.
  94. @param[in] SystemTable The system table.
  95. @retval SHELL_SUCCESS Command completed successfully.
  96. @retval SHELL_INVALID_PARAMETER Command usage error.
  97. @retval SHELL_ABORTED The user aborts the operation.
  98. @retval value Unknown error.
  99. **/
  100. SHELL_STATUS
  101. RunDp (
  102. IN EFI_HANDLE ImageHandle,
  103. IN EFI_SYSTEM_TABLE *SystemTable
  104. );
  105. /**
  106. Retrieve HII package list from ImageHandle and publish to HII database.
  107. @param ImageHandle The image handle of the process.
  108. @return HII handle.
  109. **/
  110. EFI_HII_HANDLE
  111. InitializeHiiPackage (
  112. EFI_HANDLE ImageHandle
  113. );
  114. #endif // _DP_H_