]> git.proxmox.com Git - mirror_edk2.git/blob - ShellPkg/DynamicCommand/DpDynamicCommand/DpProfile.c
ShellPkg/dp: Convert from NULL class library to Dynamic Command
[mirror_edk2.git] / ShellPkg / DynamicCommand / DpDynamicCommand / DpProfile.c
1 /** @file
2 Measured Profiling reporting for the Dp utility.
3
4 Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12 **/
13
14 #include <Library/BaseLib.h>
15 #include <Library/BaseMemoryLib.h>
16 #include <Library/MemoryAllocationLib.h>
17 #include <Library/DebugLib.h>
18 #include <Library/UefiBootServicesTableLib.h>
19 #include <Library/PeCoffGetEntryPointLib.h>
20 #include <Library/PerformanceLib.h>
21 #include <Library/PrintLib.h>
22 #include <Library/HiiLib.h>
23 #include <Library/PcdLib.h>
24
25 #include <Guid/Performance.h>
26
27 #include "Dp.h"
28 #include "Literals.h"
29 #include "DpInternal.h"
30
31 /**
32 Gather and print ALL Profiling Records.
33
34 Displays all "interesting" Profile measurements in order.
35 The number of records displayed is controlled by:
36 - records with a duration less than mInterestThreshold microseconds are not displayed.
37 - No more than Limit records are displayed. A Limit of zero will not limit the output.
38 - If the ExcludeFlag is TRUE, records matching entries in the CumData array are not
39 displayed.
40
41 @pre The mInterestThreshold global variable is set to the shortest duration to be printed.
42 The mGaugeString and mUnicodeToken global arrays are used for temporary string storage.
43 They must not be in use by a calling function.
44
45 @param[in] Limit The number of records to print. Zero is ALL.
46 @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.
47
48 **/
49 VOID
50 DumpAllProfile(
51 IN UINTN Limit,
52 IN BOOLEAN ExcludeFlag
53 )
54 {
55 EFI_STRING StringPtr;
56 EFI_STRING StringPtrUnknown;
57
58 StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
59 StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_PROFILE), NULL);
60
61 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,
62 (StringPtr == NULL) ? StringPtrUnknown: StringPtr);
63 FreePool (StringPtr);
64 FreePool (StringPtrUnknown);
65 }
66
67 /**
68 Gather and print Raw Profile Records.
69
70 All Profile measurements with a duration greater than or equal to
71 mInterestThreshold are printed without interpretation.
72
73 The number of records displayed is controlled by:
74 - records with a duration less than mInterestThreshold microseconds are not displayed.
75 - No more than Limit records are displayed. A Limit of zero will not limit the output.
76 - If the ExcludeFlag is TRUE, records matching entries in the CumData array are not
77 displayed.
78
79 @pre The mInterestThreshold global variable is set to the shortest duration to be printed.
80
81 @param[in] Limit The number of records to print. Zero is ALL.
82 @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.
83
84 **/
85 VOID
86 DumpRawProfile(
87 IN UINTN Limit,
88 IN BOOLEAN ExcludeFlag
89 )
90 {
91 EFI_STRING StringPtr;
92 EFI_STRING StringPtrUnknown;
93
94 StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
95 StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_RAWPROFILE), NULL);
96 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,
97 (StringPtr == NULL) ? StringPtrUnknown: StringPtr);
98 FreePool (StringPtr);
99 FreePool (StringPtrUnknown);
100 }