[AddResetEnd v1] ShellPkg/DpDynamicCommand: Add ResetEnd support in DP command


Zhenhua Yang
 

From: zhenhuay <zhenhua.yang@...>

DP command should be able to parse the FPDT ACPI table and dump
the ResetEnd which was logged at the beginning of the firmware
image execution. So that DP can calculate SEC phase time duration
start from the beginning of firmware image execution.

Cc: Ray Ni <ray.ni@...>
Cc: Zhichao Gao <zhichao.gao@...>
Cc: Star Zeng <star.zeng@...>
Signed-off-by: zhenhuay <zhenhua.yang@...>
---
ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c | 14 ++++++++++++++
ShellPkg/DynamicCommand/DpDynamicCommand/DpTrace.c | 9 +++++++++
ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni | 1 +
ShellPkg/DynamicCommand/DpDynamicCommand/DpInternal.h | 1 +
4 files changed, 25 insertions(+)

diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c b/ShellPkg/Dynam=
icCommand/DpDynamicCommand/Dp.c
index 1799ab176a..512a146da6 100644
--- a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
+++ b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
@@ -57,6 +57,7 @@ UINT8 *mBootPerformanceTable;
UINTN mBootPerformanceTableSize;=0D
BOOLEAN mPeiPhase =3D FALSE;=0D
BOOLEAN mDxePhase =3D FALSE;=0D
+UINT64 mResetEnd =3D 0;=0D
=0D
PERF_SUMMARY_DATA SummaryData =3D { 0 }; ///< Create the SummaryDa=
ta structure and init. to ZERO.=0D
MEASUREMENT_RECORD *mMeasurementList =3D NULL;=0D
@@ -542,6 +543,8 @@ BuildMeasurementList (
{=0D
EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *RecordHeader;=0D
UINT8 *PerformanceTablePtr;=0D
+ UINT8 *BasicBootTablePtr;=0D
+ UINT64 ResetEnd;=0D
UINT16 StartProgressId;=0D
UINTN TableLength;=0D
UINT8 *StartRecordEvent;=0D
@@ -552,6 +555,17 @@ BuildMeasurementList (
return EFI_OUT_OF_RESOURCES;=0D
}=0D
=0D
+ //=0D
+ // Update the ResetEnd which was logged at the beginning of firmware ima=
ge execution=0D
+ //=0D
+ TableLength =3D sizeof (EFI_ACPI_5_0_FPDT_PERFORMANCE_TABLE_HEADER=
);=0D
+ BasicBootTablePtr =3D (mBootPerformanceTable + TableLength);=0D
+ ResetEnd =3D ((EFI_ACPI_5_0_FPDT_FIRMWARE_BASIC_BOOT_RECORD *)B=
asicBootTablePtr)->ResetEnd;=0D
+=0D
+ if (ResetEnd > 0) {=0D
+ mResetEnd =3D ResetEnd;=0D
+ }=0D
+=0D
TableLength =3D sizeof (BOOT_PERFORMANCE_TABLE);=0D
PerformanceTablePtr =3D (mBootPerformanceTable + TableLength);=0D
=0D
diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/DpTrace.c b/ShellPkg/=
DynamicCommand/DpDynamicCommand/DpTrace.c
index 0abb8797ec..9c0a9a06a1 100644
--- a/ShellPkg/DynamicCommand/DpDynamicCommand/DpTrace.c
+++ b/ShellPkg/DynamicCommand/DpDynamicCommand/DpTrace.c
@@ -548,6 +548,15 @@ ProcessPhases (
=0D
Total =3D 0;=0D
=0D
+ // print Reset End if it's valid=0D
+ //=0D
+ if (SecTime > mResetEnd) {=0D
+ SecTime =3D SecTime - mResetEnd; // Calculate sec t=
ime duration start from the beginning of firmware image execution=0D
+ ElapsedTime =3D DurationInMicroSeconds (mResetEnd); // Calculate elaps=
ed time in microseconds=0D
+ Total +=3D DivU64x32 (ElapsedTime, 1000); // Accumulate time=
in milliseconds=0D
+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RESET_END), mDpHii=
Handle, ElapsedTime);=0D
+ }=0D
+=0D
// print SEC phase duration time=0D
//=0D
if (SecTime > 0) {=0D
diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni b/ShellPkg/Dyn=
amicCommand/DpDynamicCommand/Dp.uni
index 8d8700573e..ef2e7708b8 100644
--- a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni
+++ b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni
@@ -41,6 +41,7 @@
#string STR_DP_TIMER_PROPERTIES #language en-US "System Performanc=
e Timer counts %s from 0x%Lx to 0x%Lx\n"=0D
#string STR_DP_VERBOSE_THRESHOLD #language en-US "Measurements less=
than %,Ld microseconds are not displayed.\n"=0D
#string STR_DP_SECTION_PHASES #language en-US "Major Phases"=0D
+#string STR_DP_RESET_END #language en-US " Reset End: =
%L8d (us)\n"=0D
#string STR_DP_SEC_PHASE #language en-US " SEC Phase Durat=
ion: %L8d (us)\n"=0D
#string STR_DP_PHASE_BDSTO #language en-US " BDS Time=
out: %L8d (ms) included in BDS Duration\n"=0D
#string STR_DP_PHASE_DURATION #language en-US "%5a Phase Duratio=
n: %L8d (ms)\n"=0D
diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/DpInternal.h b/ShellP=
kg/DynamicCommand/DpDynamicCommand/DpInternal.h
index 39878c6085..97f47f2960 100644
--- a/ShellPkg/DynamicCommand/DpDynamicCommand/DpInternal.h
+++ b/ShellPkg/DynamicCommand/DpDynamicCommand/DpInternal.h
@@ -28,6 +28,7 @@ extern UINT8 *mBootPerformanceTable;
extern UINTN mBootPerformanceTableLength;=0D
extern MEASUREMENT_RECORD *mMeasurementList;=0D
extern UINTN mMeasurementNum;=0D
+extern UINT64 mResetEnd;=0D
=0D
extern PERF_SUMMARY_DATA SummaryData; ///< Create the SummaryData stru=
cture and init. to ZERO.=0D
=0D
--=20
2.31.1.windows.1


Gao, Zhichao
 

Reviewed-by: Zhichao Gao <zhichao.gao@...>

Thanks,
Zhichao

-----Original Message-----
From: Yang, Zhenhua <zhenhua.yang@...>
Sent: Monday, November 21, 2022 5:35 PM
To: devel@edk2.groups.io
Cc: Ni, Ray <ray.ni@...>; Gao, Zhichao <zhichao.gao@...>; Zeng,
Star <star.zeng@...>
Subject: [AddResetEnd v1] ShellPkg/DpDynamicCommand: Add ResetEnd
support in DP command

From: zhenhuay <zhenhua.yang@...>

DP command should be able to parse the FPDT ACPI table and dump the
ResetEnd which was logged at the beginning of the firmware image
execution. So that DP can calculate SEC phase time duration start from the
beginning of firmware image execution.

Cc: Ray Ni <ray.ni@...>
Cc: Zhichao Gao <zhichao.gao@...>
Cc: Star Zeng <star.zeng@...>
Signed-off-by: zhenhuay <zhenhua.yang@...>
---
ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c | 14
++++++++++++++
ShellPkg/DynamicCommand/DpDynamicCommand/DpTrace.c | 9
+++++++++
ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni | 1 +
ShellPkg/DynamicCommand/DpDynamicCommand/DpInternal.h | 1 +
4 files changed, 25 insertions(+)

diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
index 1799ab176a..512a146da6 100644
--- a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
+++ b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
@@ -57,6 +57,7 @@ UINT8 *mBootPerformanceTable;
UINTN mBootPerformanceTableSize; BOOLEAN mPeiPhase = FALSE;
BOOLEAN mDxePhase = FALSE;+UINT64 mResetEnd = 0;
PERF_SUMMARY_DATA SummaryData = { 0 }; ///< Create the
SummaryData structure and init. to ZERO. MEASUREMENT_RECORD
*mMeasurementList = NULL;@@ -542,6 +543,8 @@ BuildMeasurementList (
{ EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *RecordHeader;
UINT8 *PerformanceTablePtr;+ UINT8
*BasicBootTablePtr;+ UINT64 ResetEnd; UINT16
StartProgressId; UINTN TableLength; UINT8
*StartRecordEvent;@@ -552,6 +555,17 @@ BuildMeasurementList (
return EFI_OUT_OF_RESOURCES; } + //+ // Update the ResetEnd which
was logged at the beginning of firmware image execution+ //+ TableLength
= sizeof (EFI_ACPI_5_0_FPDT_PERFORMANCE_TABLE_HEADER);+
BasicBootTablePtr = (mBootPerformanceTable + TableLength);+ ResetEnd
= ((EFI_ACPI_5_0_FPDT_FIRMWARE_BASIC_BOOT_RECORD
*)BasicBootTablePtr)->ResetEnd;++ if (ResetEnd > 0) {+ mResetEnd =
ResetEnd;+ }+ TableLength = sizeof (BOOT_PERFORMANCE_TABLE);
PerformanceTablePtr = (mBootPerformanceTable + TableLength); diff --git
a/ShellPkg/DynamicCommand/DpDynamicCommand/DpTrace.c
b/ShellPkg/DynamicCommand/DpDynamicCommand/DpTrace.c
index 0abb8797ec..9c0a9a06a1 100644
--- a/ShellPkg/DynamicCommand/DpDynamicCommand/DpTrace.c
+++ b/ShellPkg/DynamicCommand/DpDynamicCommand/DpTrace.c
@@ -548,6 +548,15 @@ ProcessPhases (
Total = 0; + // print Reset End if it's valid+ //+ if (SecTime > mResetEnd) {+
SecTime = SecTime - mResetEnd; // Calculate sec time duration
start from the beginning of firmware image execution+ ElapsedTime =
DurationInMicroSeconds (mResetEnd); // Calculate elapsed time in
microseconds+ Total += DivU64x32 (ElapsedTime, 1000); // Accumulate
time in milliseconds+ ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
(STR_DP_RESET_END), mDpHiiHandle, ElapsedTime);+ }+ // print SEC phase
duration time // if (SecTime > 0) {diff --git
a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni
b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni
index 8d8700573e..ef2e7708b8 100644
--- a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni
+++ b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni
@@ -41,6 +41,7 @@
#string STR_DP_TIMER_PROPERTIES #language en-US "System
Performance Timer counts %s from 0x%Lx to 0x%Lx\n" #string
STR_DP_VERBOSE_THRESHOLD #language en-US "Measurements less
than %,Ld microseconds are not displayed.\n" #string
STR_DP_SECTION_PHASES #language en-US "Major Phases"+#string
STR_DP_RESET_END #language en-US " Reset End: %L8d
(us)\n" #string STR_DP_SEC_PHASE #language en-US " SEC Phase
Duration: %L8d (us)\n" #string STR_DP_PHASE_BDSTO #language
en-US " BDS Timeout: %L8d (ms) included in BDS Duration\n" #string
STR_DP_PHASE_DURATION #language en-US "%5a Phase
Duration: %L8d (ms)\n"diff --git
a/ShellPkg/DynamicCommand/DpDynamicCommand/DpInternal.h
b/ShellPkg/DynamicCommand/DpDynamicCommand/DpInternal.h
index 39878c6085..97f47f2960 100644
--- a/ShellPkg/DynamicCommand/DpDynamicCommand/DpInternal.h
+++ b/ShellPkg/DynamicCommand/DpDynamicCommand/DpInternal.h
@@ -28,6 +28,7 @@ extern UINT8 *mBootPerformanceTable;
extern UINTN mBootPerformanceTableLength; extern
MEASUREMENT_RECORD *mMeasurementList; extern UINTN
mMeasurementNum;+extern UINT64 mResetEnd; extern
PERF_SUMMARY_DATA SummaryData; ///< Create the SummaryData
structure and init. to ZERO. --
2.31.1.windows.1