Date   

[RFC PATCH 0/3] ArmVirtPkg: Disable the TPM 2 platform hierarchy

Stefan Berger
 

This series of patches disables the TPM 2 platform hierarchy.
We just added the same functionality to the OvmfPkg. However, on x86, we
could use the notification mechanism around gEfiDxeSmmReadyToLockProtocolGuid
to indirectly invoke ConfigureTpmPlatformHierarchy(). Since ARM does not
have an SMM mode this series now use direct invocation of this function
at the same place in PlatformBootManagerBeforeConsole() as it is done
on x86.

Regards,
Stefan

Stefan Berger (3):
ArmVirtPkg/TPM: Add a NULL implementation of TpmPlatformHierarchyLib
ArmVirtPkg: Reference new TPM classes in the build system for
compilation
ArmVirtPkg: Disable the TPM2 platform hierarchy

ArmVirtPkg/ArmVirtCloudHv.dsc | 1 +
ArmVirtPkg/ArmVirtPkg.dec | 1 +
ArmVirtPkg/ArmVirtQemu.dsc | 2 ++
ArmVirtPkg/ArmVirtQemuKernel.dsc | 1 +
ArmVirtPkg/ArmVirtXen.dsc | 1 +
.../Include/Library/TpmPlatformHierarchyLib.h | 27 +++++++++++++++++
.../PeiDxeTpmPlatformHierarchyLib.c | 22 ++++++++++++++
.../PeiDxeTpmPlatformHierarchyLib.inf | 30 +++++++++++++++++++
.../PlatformBootManagerLib/PlatformBm.c | 6 ++++
.../PlatformBootManagerLib.inf | 2 ++
10 files changed, 93 insertions(+)
create mode 100644 ArmVirtPkg/Include/Library/TpmPlatformHierarchyLib.h
create mode 100644 ArmVirtPkg/Library/PeiDxeTpmPlatformHierarchyLibNull/PeiDxeTpmPlatformHierarchyLib.c
create mode 100644 ArmVirtPkg/Library/PeiDxeTpmPlatformHierarchyLibNull/PeiDxeTpmPlatformHierarchyLib.inf

--
2.31.1


Re: [edk2-platforms][PATCH V1 1/1] WhitleyOpenBoardPkg/Build: Reduce debug output for default boot.

Nate DeSimone
 

Is it a big increase in messages to have both INFO and LOAD?

-----Original Message-----
From: Oram, Isaac W <isaac.w.oram@intel.com>
Sent: Wednesday, September 8, 2021 3:35 PM
To: devel@edk2.groups.io
Cc: Desimone, Nathaniel L <nathaniel.l.desimone@intel.com>; Chiu, Chasel <chasel.chiu@intel.com>
Subject: [edk2-devel][edk2-platforms][PATCH V1 1/1] WhitleyOpenBoardPkg/Build: Reduce debug output for default boot.

Replace Info with Load, so we still get component loading details

Cc: Isaac Oram <isaac.w.oram@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Chasel Chiu <chasel.chiu@intel.com>
Signed-off-by: Isaac Oram <isaac.w.oram@intel.com>
---
Platform/Intel/WhitleyOpenBoardPkg/PlatformPkg.dsc | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Platform/Intel/WhitleyOpenBoardPkg/PlatformPkg.dsc b/Platform/Intel/WhitleyOpenBoardPkg/PlatformPkg.dsc
index fa41ae923d..64ba4a4dae 100644
--- a/Platform/Intel/WhitleyOpenBoardPkg/PlatformPkg.dsc
+++ b/Platform/Intel/WhitleyOpenBoardPkg/PlatformPkg.dsc
@@ -365,7 +365,7 @@
#

gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x07 # Enable status codes for debug, progress, and errors
- gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x80000042 # Displayed messages: Error, Info, warn
+ gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x80000006 # Displayed messages: Error, Load, Warn

gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress|0x80000000
gUefiCpuPkgTokenSpaceGuid.PcdCpuNumberOfReservedVariableMtrrs|0
--
2.27.0.windows.1


Re: [edk2-platforms][PATCH V1 1/1] MinPlatformPkg/Variable*Lib: Build VariableRead and VariableWrite libs

Nate DeSimone
 

-----Original Message-----
From: Oram, Isaac W <isaac.w.oram@intel.com>
Sent: Wednesday, September 8, 2021 3:30 PM
To: devel@edk2.groups.io
Cc: Chiu, Chasel <chasel.chiu@intel.com>; Desimone, Nathaniel L <nathaniel.l.desimone@intel.com>; Liming Gao <gaoliming@byosoft.com.cn>; Dong, Eric <eric.dong@intel.com>
Subject: [edk2-devel][edk2-platforms][PATCH V1 1/1] MinPlatformPkg/Variable*Lib: Build VariableRead and VariableWrite libs

Add the VariableReadLib and VariableWriteLib instances to Components to ensure build when building MinPlatformPkg.dsc.
Add a NULL library instance that provides the non-functional library instance for VariableReadLib designed for all phase use.

Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Eric Dong <eric.dong@intel.com>
Signed-off-by: Isaac Oram <isaac.w.oram@intel.com>
---
Platform/Intel/MinPlatformPkg/Library/BaseVariableReadLibNull/BaseVariableReadLibNull.c | 75 ++++++++++++++++++++
Platform/Intel/MinPlatformPkg/Library/BaseVariableReadLibNull/BaseVariableReadLibNull.inf | 37 ++++++++++
Platform/Intel/MinPlatformPkg/MinPlatformPkg.dsc | 6 +-
3 files changed, 117 insertions(+), 1 deletion(-)

diff --git a/Platform/Intel/MinPlatformPkg/Library/BaseVariableReadLibNull/BaseVariableReadLibNull.c b/Platform/Intel/MinPlatformPkg/Library/BaseVariableReadLibNull/BaseVariableReadLibNull.c
new file mode 100644
index 0000000000..f276b7b6b4
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Library/BaseVariableReadLibNull/Base
+++ VariableReadLibNull.c
@@ -0,0 +1,75 @@
+/** @file
+ NULL implementation of Variable Read Lib
+
+ This library provides phase agnostic access to the UEFI Variable Services.
+ This is done by implementing a wrapper on top of the phase specific
+ mechanism for reading from UEFI variables. For example, the PEI
+ implementation of this library uses EFI_PEI_READ_ONLY_VARIABLE2_PPI.
+ The DXE implementation accesses the UEFI Runtime Services Table, and
+ the SMM implementation uses EFI_SMM_VARIABLE_PROTOCOL.
+
+ Using this library allows code to be written in a generic manner that
+ can be used in PEI, DXE, or SMM without modification.
+
+ @copyright
+ Copyright 2021 Intel Corporation. <BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent **/
+
+#include <Uefi/UefiBaseType.h>
+
+/**
+ Returns the value of a variable.
+
+ @param[in] VariableName A Null-terminated string that is the name of the vendor's
+ variable.
+ @param[in] VendorGuid A unique identifier for the vendor.
+ @param[out] Attributes If not NULL, a pointer to the memory location to return the
+ attributes bitmask for the variable.
+ @param[in, out] DataSize On input, the size in bytes of the return Data buffer.
+ On output the size of data returned in Data.
+ @param[out] Data The buffer to return the contents of the variable. May be NULL
+ with a zero DataSize in order to determine the size buffer needed.
+
+ @retval EFI_UNSUPPORTED This function is not implemented by this instance of the LibraryClass
+
+**/
+EFI_STATUS
+EFIAPI
+VarLibGetVariable (
+ IN CHAR16 *VariableName,
+ IN EFI_GUID *VendorGuid,
+ OUT UINT32 *Attributes, OPTIONAL
+ IN OUT UINTN *DataSize,
+ OUT VOID *Data OPTIONAL
+ )
+{
+ return EFI_UNSUPPORTED;
+}
+
+/**
+ Enumerates the current variable names.
+
+ @param[in, out] VariableNameSize The size of the VariableName buffer. The size must be large
+ enough to fit input string supplied in VariableName buffer.
+ @param[in, out] VariableName On input, supplies the last VariableName that was returned
+ by GetNextVariableName(). On output, returns the Nullterminated
+ string of the current variable.
+ @param[in, out] VendorGuid On input, supplies the last VendorGuid that was returned by
+ GetNextVariableName(). On output, returns the
+ VendorGuid of the current variable.
+
+ @retval EFI_UNSUPPORTED This function is not implemented by this instance of the LibraryClass
+
+**/
+EFI_STATUS
+EFIAPI
+VarLibGetNextVariableName (
+ IN OUT UINTN *VariableNameSize,
+ IN OUT CHAR16 *VariableName,
+ IN OUT EFI_GUID *VendorGuid
+ )
+{
+ return EFI_UNSUPPORTED;
+}
diff --git a/Platform/Intel/MinPlatformPkg/Library/BaseVariableReadLibNull/BaseVariableReadLibNull.inf b/Platform/Intel/MinPlatformPkg/Library/BaseVariableReadLibNull/BaseVariableReadLibNull.inf
new file mode 100644
index 0000000000..3a397998a9
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Library/BaseVariableReadLibNull/Base
+++ VariableReadLibNull.inf
@@ -0,0 +1,37 @@
+## @file
+# Component description file for NULL implementation of Variable Read
+Lib # # This library provides phase agnostic access to the UEFI
+Variable Services.
+# This is done by implementing a wrapper on top of the phase specific
+mechanism # for reading from UEFI variables. For example, the PEI
+implementation of this # library uses EFI_PEI_READ_ONLY_VARIABLE2_PPI.
+The DXE implementation accesses # the UEFI Runtime Services Table, and
+the SMM implementation uses # EFI_SMM_VARIABLE_PROTOCOL.
+#
+# Using this library allows code to be written in a generic manner that
+can be # used in PEI, DXE, or SMM without modification.
+#
+# @copyright
+# Copyright 2021 Intel Corporation. <BR> # # SPDX-License-Identifier:
+BSD-2-Clause-Patent ##
+
+##
+## NOTICE: This library is also available in MinPlatformPkg. This copy was added
+## for the convience of those that are using an older MinPlatformPkg.
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = BaseVariableReadLibNull
+ FILE_GUID = 5C9E2489-329F-4D2A-90F1-F5CB2A88A3E6
+ VERSION_STRING = 1.0
+ MODULE_TYPE = BASE
+ LIBRARY_CLASS = VariableReadLib
+
+[Packages]
+ MdePkg/MdePkg.dec
+
+[Sources]
+ BaseVariableReadLibNull.c
diff --git a/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dsc b/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dsc
index 07b776cecd..a09f8db3ab 100644
--- a/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dsc
+++ b/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dsc
@@ -74,7 +74,7 @@
FspWrapperApiTestLib|IntelFsp2WrapperPkg/Library/PeiFspWrapperApiTestLib/PeiFspWrapperApiTestLib.inf
FspWrapperHobProcessLib|MinPlatformPkg/FspWrapper/Library/PeiFspWrapperHobProcessLib/PeiFspWrapperHobProcessLib.inf
PlatformSecLib|MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatformSecLib/SecFspWrapperPlatformSecLib.inf
-
+
+ VariableReadLib|MinPlatformPkg/Library/BaseVariableReadLibNull/BaseVar
+ iableReadLibNull.inf
FspWrapperPlatformLib|MinPlatformPkg/FspWrapper/Library/PeiFspWrapperPlatformLib/PeiFspWrapperPlatformLib.inf

BoardInitLib|MinPlatformPkg/PlatformInit/Library/BoardInitLibNull/BoardInitLibNull.inf
@@ -214,5 +214,9 @@
MinPlatformPkg/Tcg/Tcg2PlatformPei/Tcg2PlatformPei.inf
MinPlatformPkg/Tcg/Tcg2PlatformDxe/Tcg2PlatformDxe.inf

+
+ MinPlatformPkg/Library/BaseVariableReadLibNull/BaseVariableReadLibNull
+ .inf
+ MinPlatformPkg/Library/SmmVariableReadLib/StandaloneMmVariableReadLib.
+ inf
+ MinPlatformPkg/Library/SmmVariableWriteLib/StandaloneMmVariableWriteLi
+ b.inf
+
[BuildOptions]
*_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
--
2.27.0.windows.1


Re: [edk2-platforms][PATCH V1 1/1] MinPlatformPkg/Variable*Lib: Build VariableRead and VariableWrite libs

Nate DeSimone
 

Reviewed-by: Nate DeSimone <nathaniel.l.desimone@intel.com>

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Oram, Isaac W
Sent: Wednesday, September 8, 2021 3:30 PM
To: devel@edk2.groups.io
Cc: Chiu, Chasel <chasel.chiu@intel.com>; Desimone, Nathaniel L <nathaniel.l.desimone@intel.com>; Liming Gao <gaoliming@byosoft.com.cn>; Dong, Eric <eric.dong@intel.com>
Subject: [edk2-devel][edk2-platforms][PATCH V1 1/1] MinPlatformPkg/Variable*Lib: Build VariableRead and VariableWrite libs

Add the VariableReadLib and VariableWriteLib instances to Components to ensure build when building MinPlatformPkg.dsc.
Add a NULL library instance that provides the non-functional library instance for VariableReadLib designed for all phase use.

Cc: Chasel Chiu <chasel.chiu@intel.com>
Cc: Nate DeSimone <nathaniel.l.desimone@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Eric Dong <eric.dong@intel.com>
Signed-off-by: Isaac Oram <isaac.w.oram@intel.com>
---
Platform/Intel/MinPlatformPkg/Library/BaseVariableReadLibNull/BaseVariableReadLibNull.c | 75 ++++++++++++++++++++
Platform/Intel/MinPlatformPkg/Library/BaseVariableReadLibNull/BaseVariableReadLibNull.inf | 37 ++++++++++
Platform/Intel/MinPlatformPkg/MinPlatformPkg.dsc | 6 +-
3 files changed, 117 insertions(+), 1 deletion(-)

diff --git a/Platform/Intel/MinPlatformPkg/Library/BaseVariableReadLibNull/BaseVariableReadLibNull.c b/Platform/Intel/MinPlatformPkg/Library/BaseVariableReadLibNull/BaseVariableReadLibNull.c
new file mode 100644
index 0000000000..f276b7b6b4
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Library/BaseVariableReadLibNull/Base
+++ VariableReadLibNull.c
@@ -0,0 +1,75 @@
+/** @file
+ NULL implementation of Variable Read Lib
+
+ This library provides phase agnostic access to the UEFI Variable Services.
+ This is done by implementing a wrapper on top of the phase specific
+ mechanism for reading from UEFI variables. For example, the PEI
+ implementation of this library uses EFI_PEI_READ_ONLY_VARIABLE2_PPI.
+ The DXE implementation accesses the UEFI Runtime Services Table, and
+ the SMM implementation uses EFI_SMM_VARIABLE_PROTOCOL.
+
+ Using this library allows code to be written in a generic manner that
+ can be used in PEI, DXE, or SMM without modification.
+
+ @copyright
+ Copyright 2021 Intel Corporation. <BR>
+
+ SPDX-License-Identifier: BSD-2-Clause-Patent **/
+
+#include <Uefi/UefiBaseType.h>
+
+/**
+ Returns the value of a variable.
+
+ @param[in] VariableName A Null-terminated string that is the name of the vendor's
+ variable.
+ @param[in] VendorGuid A unique identifier for the vendor.
+ @param[out] Attributes If not NULL, a pointer to the memory location to return the
+ attributes bitmask for the variable.
+ @param[in, out] DataSize On input, the size in bytes of the return Data buffer.
+ On output the size of data returned in Data.
+ @param[out] Data The buffer to return the contents of the variable. May be NULL
+ with a zero DataSize in order to determine the size buffer needed.
+
+ @retval EFI_UNSUPPORTED This function is not implemented by this instance of the LibraryClass
+
+**/
+EFI_STATUS
+EFIAPI
+VarLibGetVariable (
+ IN CHAR16 *VariableName,
+ IN EFI_GUID *VendorGuid,
+ OUT UINT32 *Attributes, OPTIONAL
+ IN OUT UINTN *DataSize,
+ OUT VOID *Data OPTIONAL
+ )
+{
+ return EFI_UNSUPPORTED;
+}
+
+/**
+ Enumerates the current variable names.
+
+ @param[in, out] VariableNameSize The size of the VariableName buffer. The size must be large
+ enough to fit input string supplied in VariableName buffer.
+ @param[in, out] VariableName On input, supplies the last VariableName that was returned
+ by GetNextVariableName(). On output, returns the Nullterminated
+ string of the current variable.
+ @param[in, out] VendorGuid On input, supplies the last VendorGuid that was returned by
+ GetNextVariableName(). On output, returns the
+ VendorGuid of the current variable.
+
+ @retval EFI_UNSUPPORTED This function is not implemented by this instance of the LibraryClass
+
+**/
+EFI_STATUS
+EFIAPI
+VarLibGetNextVariableName (
+ IN OUT UINTN *VariableNameSize,
+ IN OUT CHAR16 *VariableName,
+ IN OUT EFI_GUID *VendorGuid
+ )
+{
+ return EFI_UNSUPPORTED;
+}
diff --git a/Platform/Intel/MinPlatformPkg/Library/BaseVariableReadLibNull/BaseVariableReadLibNull.inf b/Platform/Intel/MinPlatformPkg/Library/BaseVariableReadLibNull/BaseVariableReadLibNull.inf
new file mode 100644
index 0000000000..3a397998a9
--- /dev/null
+++ b/Platform/Intel/MinPlatformPkg/Library/BaseVariableReadLibNull/Base
+++ VariableReadLibNull.inf
@@ -0,0 +1,37 @@
+## @file
+# Component description file for NULL implementation of Variable Read
+Lib # # This library provides phase agnostic access to the UEFI
+Variable Services.
+# This is done by implementing a wrapper on top of the phase specific
+mechanism # for reading from UEFI variables. For example, the PEI
+implementation of this # library uses EFI_PEI_READ_ONLY_VARIABLE2_PPI.
+The DXE implementation accesses # the UEFI Runtime Services Table, and
+the SMM implementation uses # EFI_SMM_VARIABLE_PROTOCOL.
+#
+# Using this library allows code to be written in a generic manner that
+can be # used in PEI, DXE, or SMM without modification.
+#
+# @copyright
+# Copyright 2021 Intel Corporation. <BR> # # SPDX-License-Identifier:
+BSD-2-Clause-Patent ##
+
+##
+## NOTICE: This library is also available in MinPlatformPkg. This copy was added
+## for the convience of those that are using an older MinPlatformPkg.
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = BaseVariableReadLibNull
+ FILE_GUID = 5C9E2489-329F-4D2A-90F1-F5CB2A88A3E6
+ VERSION_STRING = 1.0
+ MODULE_TYPE = BASE
+ LIBRARY_CLASS = VariableReadLib
+
+[Packages]
+ MdePkg/MdePkg.dec
+
+[Sources]
+ BaseVariableReadLibNull.c
diff --git a/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dsc b/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dsc
index 07b776cecd..a09f8db3ab 100644
--- a/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dsc
+++ b/Platform/Intel/MinPlatformPkg/MinPlatformPkg.dsc
@@ -74,7 +74,7 @@
FspWrapperApiTestLib|IntelFsp2WrapperPkg/Library/PeiFspWrapperApiTestLib/PeiFspWrapperApiTestLib.inf
FspWrapperHobProcessLib|MinPlatformPkg/FspWrapper/Library/PeiFspWrapperHobProcessLib/PeiFspWrapperHobProcessLib.inf
PlatformSecLib|MinPlatformPkg/FspWrapper/Library/SecFspWrapperPlatformSecLib/SecFspWrapperPlatformSecLib.inf
-
+
+ VariableReadLib|MinPlatformPkg/Library/BaseVariableReadLibNull/BaseVar
+ iableReadLibNull.inf
FspWrapperPlatformLib|MinPlatformPkg/FspWrapper/Library/PeiFspWrapperPlatformLib/PeiFspWrapperPlatformLib.inf

BoardInitLib|MinPlatformPkg/PlatformInit/Library/BoardInitLibNull/BoardInitLibNull.inf
@@ -214,5 +214,9 @@
MinPlatformPkg/Tcg/Tcg2PlatformPei/Tcg2PlatformPei.inf
MinPlatformPkg/Tcg/Tcg2PlatformDxe/Tcg2PlatformDxe.inf

+
+ MinPlatformPkg/Library/BaseVariableReadLibNull/BaseVariableReadLibNull
+ .inf
+ MinPlatformPkg/Library/SmmVariableReadLib/StandaloneMmVariableReadLib.
+ inf
+ MinPlatformPkg/Library/SmmVariableWriteLib/StandaloneMmVariableWriteLi
+ b.inf
+
[BuildOptions]
*_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
--
2.27.0.windows.1


Re: [PATCH] MdeModulePkg/PciBusDxe: Enumerator to check for RCiEP before looking for RP

Bassa, Damian <damian.bassa@...>
 

I was looking for anything that wouldn’t include reading register but only thing that distinguish device PCI_IO_DEVICE instances with root bridge instances is population of BusNumberRanges structure.

This technically could be used since this is populated only for root bridges and not devices but using this would be just confusing since there is no self-explanatory field there.

For my knowledge this is best way to tackle this issue. Please let me know if there are have some other worth exploring ideas.

 

Damian

 

From: Ni, Ray <ray.ni@...>
Sent: Wednesday, September 15, 2021 3:21 PM
To: Bassa, Damian <damian.bassa@...>; Wu, Hao A <hao.a.wu@...>; devel@edk2.groups.io
Subject: RE: [edk2-devel] [PATCH] MdeModulePkg/PciBusDxe: Enumerator to check for RCiEP before looking for RP

 

Extending PciBus to support such case is valid.

 

But can you check if there is other pure software way to detect whether it’s an ECiEP?

 

From: Bassa, Damian <damian.bassa@...>
Sent: Wednesday, September 15, 2021 7:54 PM
To: Wu, Hao A <hao.a.wu@...>; devel@edk2.groups.io; Ni, Ray <ray.ni@...>
Subject: RE: [edk2-devel] [PATCH] MdeModulePkg/PciBusDxe: Enumerator to check for RCiEP before looking for RP

 

Should we consider this workaround? I’m having issues interpreting this part of PCIe spec.

My understanding of this quote is that this capability can exist in but it shouldn’t be considered.

I would assume it’s possible option that it needs to be considered? Is that wrong?

 

Damian

 

 

From: Wu, Hao A <hao.a.wu@...>
Sent: Wednesday, September 8, 2021 9:17 AM
To: Bassa, Damian <damian.bassa@...>; devel@edk2.groups.io; Ni, Ray <ray.ni@...>
Subject: RE: [edk2-devel] [PATCH] MdeModulePkg/PciBusDxe: Enumerator to check for RCiEP before looking for RP

 

Really sorry for the late response.

 

So this is a workaround for RCiEP device that is not compliant to the PCIe spec:

|>  ARI is an optional capability. This capability must be implemented by each

|>  Function in an ARI Device. It is not applicable to a Root Port, a Switch

|>  Downstream Port, an RCiEP, or a Root Complex Event Collector.

 

If this the case, could you help to:

* Add a comment that briefly describe this workaround before the newly added code

* Also mention this workaround information in the commit log message.

* Send out a V2 version of the patch?

Thanks in advance.

 

Hello Ray, please help to raise if you have concern on this.

 

Best Regards,

Hao Wu

 

From: Bassa, Damian <damian.bassa@...>
Sent: Wednesday, September 1, 2021 1:45 AM
To: Wu, Hao A <hao.a.wu@...>; devel@edk2.groups.io; Ni, Ray <ray.ni@...>
Subject: RE: [edk2-devel] [PATCH] MdeModulePkg/PciBusDxe: Enumerator to check for RCiEP before looking for RP

 

It refers to access to the root port device that doesn’t exist in case we are dealing with RCiEP device.

There can be specific case where RCiEP device has ARI extended capability ID (even though it’s unsupported in this case).

In such a case PciSearchDevice goes to CreatePciIoDevice through GatherDeviceInfo. And in this case parent is PCI_IO_DEVICE instance created from CreateRootBridge function, which isn’t valid PCIe device and doesn’t have specific bus, only a range of buses. In that case enumerator tries to use this instance to read operation using default 0 bus number, which isn’t correct.

 

Damian

 

From: Wu, Hao A <hao.a.wu@...>
Sent: Tuesday, August 31, 2021 6:28 AM
To: devel@edk2.groups.io; Wu, Hao A <hao.a.wu@...>; Bassa, Damian <damian.bassa@...>; Ni, Ray <ray.ni@...>
Subject: RE: [edk2-devel] [PATCH] MdeModulePkg/PciBusDxe: Enumerator to check for RCiEP before looking for RP

 

From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Wu, Hao A
Sent: Tuesday, August 31, 2021 12:25 PM
To: devel@edk2.groups.io; Bassa, Damian <damian.bassa@...>
Subject: Re: [edk2-devel] [PATCH] MdeModulePkg/PciBusDxe: Enumerator to check for RCiEP before looking for RP

 

Really sorry,

 

Could you help to provide more information on the below statement?

“undefined parent register accesses”

 

Thanks in advance.

 

Best Regards,

Hao Wu

 

From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Bassa, Damian
Sent: Tuesday, August 24, 2021 11:15 PM
To: devel@edk2.groups.io
Subject: [edk2-devel] [PATCH] MdeModulePkg/PciBusDxe: Enumerator to check for RCiEP before looking for RP

 

Before trying to access parent root port to check ARI capabilities,

enumerator should see if Endpoint device is not Root Complex integrated

to avoid undefined parent register accesses in these cases.

 

Signed-off-by: Damian Bassa damian.bassa@...

 

---

.../Bus/Pci/PciBusDxe/PciEnumeratorSupport.c         | 12 +++++++++++-

1 file changed, 11 insertions(+), 1 deletion(-)

 

diff --git a/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c b/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c

index db1b35f8ef..6451fb8af9 100644

--- a/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c

+++ b/MdeModulePkg/Bus/Pci/PciBusDxe/PciEnumeratorSupport.c

@@ -2153,6 +2153,7 @@ CreatePciIoDevice (

   PCI_IO_DEVICE        *PciIoDevice;

   EFI_PCI_IO_PROTOCOL  *PciIo;

   EFI_STATUS           Status;

+  PCI_REG_PCIE_CAPABILITY Capability;

 

   PciIoDevice = AllocateZeroPool (sizeof (PCI_IO_DEVICE));

   if (PciIoDevice == NULL) {

@@ -2229,7 +2230,16 @@ CreatePciIoDevice (

     return NULL;

   }

 

-  if (PcdGetBool (PcdAriSupport)) {

+  PciIo->Pci.Read (

+                PciIo,

+                EfiPciIoWidthUint16,

+                PciIoDevice->PciExpressCapabilityOffset + OFFSET_OF (PCI_CAPABILITY_PCIEXP, Capability),

+                1,

+                &Capability.Uint16

+                );

+

+  if (PcdGetBool (PcdAriSupport) &&

+    Capability.Bits.DevicePortType != PCIE_DEVICE_PORT_TYPE_ROOT_COMPLEX_INTEGRATED_ENDPOINT) {

     //

     // Check if the device is an ARI device.

     //

--

2.27.0.windows.1

 


Intel Technology Poland sp. z o.o.
ul. Słowackiego 173 | 80-298 Gdańsk | Sąd Rejonowy Gdańsk Północ | VII Wydział Gospodarczy Krajowego Rejestru Sądowego - KRS 101882 | NIP 957-07-52-316 | Kapitał zakładowy 200.000 PLN.

Ta wiadomość wraz z załącznikami jest przeznaczona dla określonego adresata i może zawierać informacje poufne. W razie przypadkowego otrzymania tej wiadomości, prosimy o powiadomienie nadawcy oraz trwałe jej usunięcie; jakiekolwiek przeglądanie lub rozpowszechnianie jest zabronione.
This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). If you are not the intended recipient, please contact the sender and delete all copies; any review or distribution by others is strictly prohibited.

 


Intel Technology Poland sp. z o.o.
ul. Słowackiego 173 | 80-298 Gdańsk | Sąd Rejonowy Gdańsk Północ | VII Wydział Gospodarczy Krajowego Rejestru Sądowego - KRS 101882 | NIP 957-07-52-316 | Kapitał zakładowy 200.000 PLN.

Ta wiadomość wraz z załącznikami jest przeznaczona dla określonego adresata i może zawierać informacje poufne. W razie przypadkowego otrzymania tej wiadomości, prosimy o powiadomienie nadawcy oraz trwałe jej usunięcie; jakiekolwiek przeglądanie lub rozpowszechnianie jest zabronione.
This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). If you are not the intended recipient, please contact the sender and delete all copies; any review or distribution by others is strictly prohibited.


Re: RFC: Add BaseLib/QuickSort in MdePkg

Chan, Amy <amy.chan@...>
 

Just to double confirm, will we have the null instance of QuickSort in MdePkg?

 

Regards,

Amy

 

From: gaoliming <gaoliming@...>
Sent: Thursday, September 16, 2021 10:23 AM
To: 'Andrew Fish' <afish@...>; 'edk2-devel-groups-io' <devel@edk2.groups.io>
Cc: Ni, Ray <ray.ni@...>; Kinney, Michael D <michael.d.kinney@...>; 'Gao, Liming' <liming.gao@...>; Liu, Zhiguang <zhiguang.liu@...>; Wang, Jian J <jian.j.wang@...>; Gao, Zhichao <zhichao.gao@...>; Chan, Amy <amy.chan@...>
Subject:
回复: [edk2-devel] RFC: Add BaseLib/QuickSort in MdePkg

 

Andrew:

 Thanks for your suggestion. I think your idea is better. We add new QuickSort() API to BaseLib, and update SortLib library instance to consume BaseLib QuickSort() API. This way has no change in current SortLib library class. It is the compatible solution.

 

Thanks

Liming

发件人: Andrew Fish <afish@...>
发送时间: 2021916 10:13
收件人: edk2-devel-groups-io <devel@edk2.groups.io>; Liming Gao <gaoliming@...>
抄送: Ni, Ray <ray.ni@...>; Mike Kinney <michael.d.kinney@...>; Gao, Liming <liming.gao@...>; Liu, Zhiguang <zhiguang.liu@...>; Wang, Jian J <jian.j.wang@...>; Gao, Zhichao <zhichao.gao@...>; Chan, Amy <amy.chan@...>
主题: Re: [edk2-devel] RFC: Add BaseLib/QuickSort in MdePkg

 

 

 

On Sep 15, 2021, at 6:26 PM, gaoliming <gaoliming@...> wrote:

 

Ray:

 SortLib has been added since 2015. I would suggest to still keep this library class. To resolve the package dependency, my proposal is to move the library class header file SortLib.h from MdeModulePkg to MdePkg, and still keep the library instance in MdeModulePkg. This proposal has no impact on the existing platform. 

 

 

If we add QuickSort() API to the BaseLib can we not just port the existing MdeModulePkg/SortLib to use QuickSort() in the implementation? Or is there some other way to add the new thing in a backward compatible way.

 

Thanks,

 

Andrew Fish

 

Thanks

Liming

发件人: devel@edk2.groups.io <devel@edk2.groups.io> 代表 Ni, Ray
发送时间:
 2021914 14:15
收件人:
 Kinney, Michael D <michael.d.kinney@...>; Gao, Liming <liming.gao@...>; Liu, Zhiguang <zhiguang.liu@...>; Wang, Jian J <jian.j.wang@...>; Gao, Zhichao <zhichao.gao@...>
抄送:
 devel@edk2.groups.io; Chan, Amy <amy.chan@...>
主题:
 [edk2-devel] RFC: Add BaseLib/QuickSort in MdePkg

 

Hi package maintainers of MdePkg, MdeModulePkg and ShellPkg, community,

 

A commit (UefiCpuPkg/CpuCacheInfoLib: Sort CpuCacheInfo array) to UefiCpuPkg let
UefiCpuPkg depend on MdeModulePkg because the SortLib class and instances are all in MdeModulePkg.

 

UefiCpuPkg depending on MdeModulePkg breaks the rule that “UefiCpuPkg should ONLY depend on MdePkg”.

 

To address this issue, there are two approaches:

  1. Duplicate the sort logic in UefiCpuPkg to not depend on MdeModulePkg/SortLib
  2. Add QuickSort() API to BaseLib in MdePkg.

 

Approach #2 (MdePkg/BaseLib/QuickSort) makes more sense because quick sort is a standard algorithm.

We encourage consumers to update their code to use the quick sort in MdePkg and gradually deprecate today’s MdeModulePkg/SortLib.

 

If you don’t have concerns, I plan to:

  1. “Add QuickSort() to BaseLib” and update all existing consumers to use this API instead.

VOID

EFIAPI

QuickSort (

  IN OUT VOID                   *BufferToSort,

  IN CONST UINTN                Count,

  IN CONST UINTN                ElementSize,

  IN       SORT_COMPARE         CompareFunction

  );

 

  1. “Add new ShellPkg/SortCompareLib”

Background: ShellPkg requires to sort devicepath/string so 3 APIs in UefiSortLib (DevicePathCompare, StringNoCaseCompare, StringCompare) are provided for Shell usage. we can move the 3 APIs to the SortCompareLib and update Shell code to use BaseLib/QuickSort directly, with the sort compare function from SortCompareLib.

 

Any concerns?

 

Thanks,

Ray

 


[PATCH v3 3/3] RFC: OvmfPkg/PlatformPei: stop using cmos for memory detection

Gerd Hoffmann
 

Not needed for qemu 1.7 (released in 2013) and newer.

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3593
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
OvmfPkg/PlatformPei/MemDetect.c | 59 +++------------------------------
1 file changed, 4 insertions(+), 55 deletions(-)

diff --git a/OvmfPkg/PlatformPei/MemDetect.c b/OvmfPkg/PlatformPei/MemDetect.c
index 1d942b12d519..778d150e956b 100644
--- a/OvmfPkg/PlatformPei/MemDetect.c
+++ b/OvmfPkg/PlatformPei/MemDetect.c
@@ -37,7 +37,6 @@ Module Name:
#include <Library/QemuFwCfgSimpleParserLib.h>

#include "Platform.h"
-#include "Cmos.h"

UINT8 mPhysMemAddressWidth;

@@ -295,52 +294,12 @@ GetSystemMemorySizeBelow4gb (
{
EFI_STATUS Status;
UINT64 LowerMemorySize = 0;
- UINT8 Cmos0x34;
- UINT8 Cmos0x35;

Status = ScanOrAdd64BitE820Ram (FALSE, &LowerMemorySize, NULL);
- if (Status == EFI_SUCCESS && LowerMemorySize > 0) {
- return (UINT32)LowerMemorySize;
- }
+ ASSERT_EFI_ERROR (Status);
+ ASSERT (LowerMemorySize > 0);
+ return (UINT32)LowerMemorySize;

- //
- // CMOS 0x34/0x35 specifies the system memory above 16 MB.
- // * CMOS(0x35) is the high byte
- // * CMOS(0x34) is the low byte
- // * The size is specified in 64kb chunks
- // * Since this is memory above 16MB, the 16MB must be added
- // into the calculation to get the total memory size.
- //
-
- Cmos0x34 = (UINT8) CmosRead8 (0x34);
- Cmos0x35 = (UINT8) CmosRead8 (0x35);
-
- return (UINT32) (((UINTN)((Cmos0x35 << 8) + Cmos0x34) << 16) + SIZE_16MB);
-}
-
-
-STATIC
-UINT64
-GetSystemMemorySizeAbove4gb (
- )
-{
- UINT32 Size;
- UINTN CmosIndex;
-
- //
- // CMOS 0x5b-0x5d specifies the system memory above 4GB MB.
- // * CMOS(0x5d) is the most significant size byte
- // * CMOS(0x5c) is the middle size byte
- // * CMOS(0x5b) is the least significant size byte
- // * The size is specified in 64kb chunks
- //
-
- Size = 0;
- for (CmosIndex = 0x5d; CmosIndex >= 0x5b; CmosIndex--) {
- Size = (UINT32) (Size << 8) + (UINT32) CmosRead8 (CmosIndex);
- }
-
- return LShiftU64 (Size, 16);
}


@@ -371,12 +330,9 @@ GetFirstNonAddress (
// If QEMU presents an E820 map, then get the highest exclusive >=4GB RAM
// address from it. This can express an address >= 4GB+1TB.
//
- // Otherwise, get the flat size of the memory above 4GB from the CMOS (which
- // can only express a size smaller than 1TB), and add it to 4GB.
- //
Status = ScanOrAdd64BitE820Ram (FALSE, NULL, &FirstNonAddress);
if (EFI_ERROR (Status)) {
- FirstNonAddress = BASE_4GB + GetSystemMemorySizeAbove4gb ();
+ FirstNonAddress = BASE_4GB;
}

//
@@ -719,7 +675,6 @@ QemuInitializeRam (
)
{
UINT64 LowerMemorySize;
- UINT64 UpperMemorySize;
MTRR_SETTINGS MtrrSettings;
EFI_STATUS Status;

@@ -775,12 +730,6 @@ QemuInitializeRam (
// memory size read from the CMOS.
//
Status = ScanOrAdd64BitE820Ram (TRUE, NULL, NULL);
- if (EFI_ERROR (Status)) {
- UpperMemorySize = GetSystemMemorySizeAbove4gb ();
- if (UpperMemorySize != 0) {
- AddMemoryBaseSizeHob (BASE_4GB, UpperMemorySize);
- }
- }
}

//
--
2.31.1


[PATCH v3 2/3] OvmfPkg/PlatformPei: prefer etc/e820 for memory detection

Gerd Hoffmann
 

Prefer the e820 map provided via qemu firmware config interface
for memory detection. Use rtc cmos only as fallback, which should
be rarely needed these days as qemu supports etc/e820 since 2013.

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3593
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com>
---
OvmfPkg/PlatformPei/MemDetect.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/OvmfPkg/PlatformPei/MemDetect.c b/OvmfPkg/PlatformPei/MemDetect.c
index 500c1d4d5231..1d942b12d519 100644
--- a/OvmfPkg/PlatformPei/MemDetect.c
+++ b/OvmfPkg/PlatformPei/MemDetect.c
@@ -293,9 +293,16 @@ GetSystemMemorySizeBelow4gb (
VOID
)
{
+ EFI_STATUS Status;
+ UINT64 LowerMemorySize = 0;
UINT8 Cmos0x34;
UINT8 Cmos0x35;

+ Status = ScanOrAdd64BitE820Ram (FALSE, &LowerMemorySize, NULL);
+ if (Status == EFI_SUCCESS && LowerMemorySize > 0) {
+ return (UINT32)LowerMemorySize;
+ }
+
//
// CMOS 0x34/0x35 specifies the system memory above 16 MB.
// * CMOS(0x35) is the high byte
@@ -722,7 +729,6 @@ QemuInitializeRam (
// Determine total memory size available
//
LowerMemorySize = GetSystemMemorySizeBelow4gb ();
- UpperMemorySize = GetSystemMemorySizeAbove4gb ();

if (mBootMode == BOOT_ON_S3_RESUME) {
//
@@ -769,8 +775,11 @@ QemuInitializeRam (
// memory size read from the CMOS.
//
Status = ScanOrAdd64BitE820Ram (TRUE, NULL, NULL);
- if (EFI_ERROR (Status) && UpperMemorySize != 0) {
- AddMemoryBaseSizeHob (BASE_4GB, UpperMemorySize);
+ if (EFI_ERROR (Status)) {
+ UpperMemorySize = GetSystemMemorySizeAbove4gb ();
+ if (UpperMemorySize != 0) {
+ AddMemoryBaseSizeHob (BASE_4GB, UpperMemorySize);
+ }
}
}

--
2.31.1


[PATCH v3 1/3] OvmfPkg/PlatformPei: ScanOrAdd64BitE820Ram improvements

Gerd Hoffmann
 

Add a bool parameter to ScanOrAdd64BitE820Ram to explicitly specify
whenever ScanOrAdd64BitE820Ram should add HOBs for high memory (above
4G) or scan only.

Also add a lowmem parameter so ScanOrAdd64BitE820Ram
can report the memory size below 4G.

This allows a more flexible usage of ScanOrAdd64BitE820Ram,
a followup patch will use it for all memory detection.

No functional change.

Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=3593
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com>
---
OvmfPkg/PlatformPei/MemDetect.c | 28 +++++++++++++++++++++-------
1 file changed, 21 insertions(+), 7 deletions(-)

diff --git a/OvmfPkg/PlatformPei/MemDetect.c b/OvmfPkg/PlatformPei/MemDetect.c
index 2c2c4641ec8a..500c1d4d5231 100644
--- a/OvmfPkg/PlatformPei/MemDetect.c
+++ b/OvmfPkg/PlatformPei/MemDetect.c
@@ -200,6 +200,8 @@ QemuUc32BaseInitialization (
STATIC
EFI_STATUS
ScanOrAdd64BitE820Ram (
+ IN BOOLEAN AddHighHob,
+ OUT UINT64 *LowMemory OPTIONAL,
OUT UINT64 *MaxAddress OPTIONAL
)
{
@@ -217,6 +219,9 @@ ScanOrAdd64BitE820Ram (
return EFI_PROTOCOL_ERROR;
}

+ if (LowMemory != NULL) {
+ *LowMemory = 0;
+ }
if (MaxAddress != NULL) {
*MaxAddress = BASE_4GB;
}
@@ -232,9 +237,8 @@ ScanOrAdd64BitE820Ram (
E820Entry.Length,
E820Entry.Type
));
- if (E820Entry.Type == EfiAcpiAddressRangeMemory &&
- E820Entry.BaseAddr >= BASE_4GB) {
- if (MaxAddress == NULL) {
+ if (E820Entry.Type == EfiAcpiAddressRangeMemory) {
+ if (AddHighHob && E820Entry.BaseAddr >= BASE_4GB) {
UINT64 Base;
UINT64 End;

@@ -254,11 +258,12 @@ ScanOrAdd64BitE820Ram (
End
));
}
- } else {
+ }
+ if (MaxAddress || LowMemory) {
UINT64 Candidate;

Candidate = E820Entry.BaseAddr + E820Entry.Length;
- if (Candidate > *MaxAddress) {
+ if (MaxAddress && Candidate > *MaxAddress) {
*MaxAddress = Candidate;
DEBUG ((
DEBUG_VERBOSE,
@@ -267,6 +272,15 @@ ScanOrAdd64BitE820Ram (
*MaxAddress
));
}
+ if (LowMemory && Candidate > *LowMemory && Candidate < BASE_4GB) {
+ *LowMemory = Candidate;
+ DEBUG ((
+ DEBUG_VERBOSE,
+ "%a: LowMemory=0x%Lx\n",
+ __FUNCTION__,
+ *LowMemory
+ ));
+ }
}
}
}
@@ -353,7 +367,7 @@ GetFirstNonAddress (
// Otherwise, get the flat size of the memory above 4GB from the CMOS (which
// can only express a size smaller than 1TB), and add it to 4GB.
//
- Status = ScanOrAdd64BitE820Ram (&FirstNonAddress);
+ Status = ScanOrAdd64BitE820Ram (FALSE, NULL, &FirstNonAddress);
if (EFI_ERROR (Status)) {
FirstNonAddress = BASE_4GB + GetSystemMemorySizeAbove4gb ();
}
@@ -754,7 +768,7 @@ QemuInitializeRam (
// entries. Otherwise, create a single memory HOB with the flat >=4GB
// memory size read from the CMOS.
//
- Status = ScanOrAdd64BitE820Ram (NULL);
+ Status = ScanOrAdd64BitE820Ram (TRUE, NULL, NULL);
if (EFI_ERROR (Status) && UpperMemorySize != 0) {
AddMemoryBaseSizeHob (BASE_4GB, UpperMemorySize);
}
--
2.31.1


[PATCH v3 0/3] OvmfPkg/PlatformPei: prefer etc/e820 for memory detection

Gerd Hoffmann
 

Don't use cmos for memory detection if possible.
qemu provides the etc/e820 firmware config file
as alternative since 2013.

v2:
- fix lowmem detection.
- pick up review tags.
- add rfc patch to completely drop cmos support.

v3:
- fix CI failure.

Gerd Hoffmann (3):
OvmfPkg/PlatformPei: ScanOrAdd64BitE820Ram improvements
OvmfPkg/PlatformPei: prefer etc/e820 for memory detection
RFC: OvmfPkg/PlatformPei: stop using cmos for memory detection

OvmfPkg/PlatformPei/MemDetect.c | 84 +++++++++++----------------------
1 file changed, 28 insertions(+), 56 deletions(-)

--
2.31.1


Re: [PATCH 1/1] ArmPkg/ProcessorSubClassDxe: Fix the format of ProcessorId

Leif Lindholm
 

On Thu, Sep 16, 2021 at 04:45:29 -0600, Rebecca Cran wrote:
Reviewed-by: Rebecca Cran <rebecca@nuviainc.com>


--

Rebecca Cran


On 9/15/21 7:55 AM, Nhi Pham wrote:
According to SMBIOS 3.4, section 7.5.3.3 ARM64-class CPUs, if
SMCCC_ARCH_SOC_ID is supported, the first DWORD is the JEP-106 code and
the second DWORD is the SoC revision value. But in the current
implementation, they are set in reverse. This patch is to correct it.

Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Rebecca Cran <rebecca@nuviainc.com>
Signed-off-by: Nhi Pham <nhi@os.amperecomputing.com>
Acked-by: Leif Lindholm <leif@nuviainc.com>
Pushed as ac6388add4ad.

Thanks!


---
ArmPkg/Universal/Smbios/ProcessorSubClassDxe/SmbiosProcessorArmCommon.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/ArmPkg/Universal/Smbios/ProcessorSubClassDxe/SmbiosProcessorArmCommon.c b/ArmPkg/Universal/Smbios/ProcessorSubClassDxe/SmbiosProcessorArmCommon.c
index 292f10bf97eb..d644cd33d249 100644
--- a/ArmPkg/Universal/Smbios/ProcessorSubClassDxe/SmbiosProcessorArmCommon.c
+++ b/ArmPkg/Universal/Smbios/ProcessorSubClassDxe/SmbiosProcessorArmCommon.c
@@ -2,6 +2,7 @@
Functions for processor information common to ARM and AARCH64.
Copyright (c) 2021, NUVIA Inc. All rights reserved.<BR>
+ Copyright (c) 2021, Ampere Computing LLC. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
@@ -171,7 +172,7 @@ SmbiosGetProcessorId (
if (HasSmcArm64SocId ()) {
SmbiosGetSmcArm64SocId (&Jep106Code, &SocRevision);
- ProcessorId = ((UINT64)Jep106Code << 32) | SocRevision;
+ ProcessorId = ((UINT64)SocRevision << 32) | Jep106Code;
} else {
ProcessorId = ArmReadMidr ();
}


[PATCH v2 3/5] ShellPkg: add a Graph option to the Parser Flags

Joey Gouly
 

From: Marc Moisson-Franckhauser <marc.moisson-franckhauser@arm.com>

Bugzilla: 3378 (https://bugzilla.tianocore.org/show_bug.cgi?id=3378)

This option informs the parser to generate a dot graph of a table.
This can be useful to understand or debug a table, such as the PPTT
table.

Signed-off-by: Joey Gouly <joey.gouly@arm.com>
---
ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h | 2 ++
ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewConfig.h | 3 ++-
ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c | 9 +++++++-
ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c | 24 +++++++++++++++++---
ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.uni | 9 ++++++--
5 files changed, 40 insertions(+), 7 deletions(-)

diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
index b078c0b99335ba28f7589cac6b0a4190d9a6c3b5..9a67fe084327434bf21b37b3089779468edfb0f1 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
@@ -20,11 +20,13 @@
Flags for the parser.
*/
#define PARSE_FLAGS_TRACE BIT0
+#define PARSE_FLAGS_GRAPH BIT1

/**
Helper macros to test parser flags.
*/
#define IS_TRACE_FLAG_SET(Flags) (((Flags) & PARSE_FLAGS_TRACE) != 0)
+#define IS_GRAPH_FLAG_SET(Flags) (((Flags) & PARSE_FLAGS_GRAPH) != 0)

/**
This function increments the ACPI table error counter.
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewConfig.h b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewConfig.h
index 2db4a65415d8f9e70686cb2cc432862ab4e4c2dd..262302a15cbbe04a228fd55e523930fb76bcf6a8 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewConfig.h
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiViewConfig.h
@@ -1,7 +1,7 @@
/** @file
Header file for 'acpiview' configuration.

- Copyright (c) 2016 - 2020, ARM Limited. All rights reserved.<BR>
+ Copyright (c) 2016 - 2021, Arm Limited. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/

@@ -106,6 +106,7 @@ typedef enum {
ReportSelected, ///< Report Selected table.
ReportTableList, ///< Report List of tables.
ReportDumpBinFile, ///< Dump selected table to a file.
+ ReportDotGraph, ///< Create Dot Graph for selected compatible table.
ReportMax,
} EREPORT_OPTION;

diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
index db7b2e2a30525cc85a333b93f5eb97ec3a517b37..1155b2f3f411247c866f635fb666dd76455f18a4 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
@@ -192,6 +192,12 @@ ProcessTableReportOptions (
DumpAcpiTableToFile (TablePtr, Length);
}
break;
+ case ReportDotGraph:
+ if (Signature == SelectedTable->Type) {
+ SelectedTable->Found = TRUE;
+ ParseFlags |= PARSE_FLAGS_GRAPH;
+ }
+ break;
case ReportMax:
// We should never be here.
// This case is only present to prevent compiler warning.
@@ -340,7 +346,8 @@ AcpiView (

ReportOption = GetReportOption ();
if (ReportTableList != ReportOption) {
- if (((ReportSelected == ReportOption) ||
+ if (((ReportSelected == ReportOption) ||
+ (ReportDotGraph == ReportOption) ||
(ReportDumpBinFile == ReportOption)) &&
(!SelectedTable->Found)) {
Print (L"\nRequested ACPI Table not found.\n");
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c
index b30ed3fc8597b229dd15b6ad4f2aab2e3d0ca583..d837b390938f3c3bc5cb90c1161e2feeb1ed6a6b 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.c
@@ -1,7 +1,7 @@
/** @file
Main file for 'acpiview' Shell command function.

- Copyright (c) 2016 - 2020, Arm Limited. All rights reserved.<BR>
+ Copyright (c) 2016 - 2021, Arm Limited. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/

@@ -34,6 +34,7 @@ EFI_HII_HANDLE gShellAcpiViewHiiHandle = NULL;
STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
{L"-q", TypeFlag},
{L"-d", TypeFlag},
+ {L"-g", TypeFlag},
{L"-h", TypeFlag},
{L"-l", TypeFlag},
{L"-s", TypeValue},
@@ -293,6 +294,18 @@ ShellCommandRunAcpiView (
L"-d"
);
ShellStatus = SHELL_INVALID_PARAMETER;
+ } else if (ShellCommandLineGetFlag (Package, L"-g") &&
+ !ShellCommandLineGetFlag (Package, L"-s")) {
+ ShellPrintHiiEx (
+ -1,
+ -1,
+ NULL,
+ STRING_TOKEN (STR_GEN_MISSING_OPTION),
+ gShellAcpiViewHiiHandle,
+ L"acpiview",
+ L"-s",
+ L"-g"
+ );
} else {
// Turn on colour highlighting if requested
SetColourHighlighting (ShellCommandLineGetFlag (Package, L"-h"));
@@ -316,10 +329,15 @@ ShellCommandRunAcpiView (
SelectAcpiTable (SelectedTableName);
SetReportOption (ReportSelected);

- if (ShellCommandLineGetFlag (Package, L"-d")) {
+ if (ShellCommandLineGetFlag (Package, L"-d") ||
+ ShellCommandLineGetFlag (Package, L"-g")) {
// Create a temporary file to check if the media is writable.
CHAR16 FileNameBuffer[MAX_FILE_NAME_LEN];
- SetReportOption (ReportDumpBinFile);
+ if (ShellCommandLineGetFlag (Package, L"-d")) {
+ SetReportOption (ReportDumpBinFile);
+ } else {
+ SetReportOption (ReportDotGraph);
+ }

UnicodeSPrint (
FileNameBuffer,
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.uni b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.uni
index 393110e0ee98d54b3be0309c2d297a121c258570..51f2bea10f7b768e5e67f930237207193cba4246 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.uni
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.uni
@@ -1,6 +1,6 @@
// /**
//
-// Copyright (c) 2016 - 2020, Arm Limited. All rights reserved.<BR>
+// Copyright (c) 2016 - 2021, Arm Limited. All rights reserved.<BR>
// SPDX-License-Identifier: BSD-2-Clause-Patent
//
// Module Name:
@@ -30,7 +30,7 @@
"Display ACPI Table information.\r\n"
".SH SYNOPSIS\r\n"
" \r\n"
-"ACPIVIEW [[-?] | [[[[-l] | [-s AcpiTable [-d]]] [-q] [-h]] [-r Spec]]]\r\n"
+"ACPIVIEW [[-?] | [[[[-l] | [-s AcpiTable [-d] [-g]]] [-q] [-h]] [-r Spec]]]\r\n"
" \r\n"
".SH OPTIONS\r\n"
" \r\n"
@@ -39,6 +39,7 @@
" invocation option.\r\n"
" AcpiTable : The required ACPI Table type.\r\n"
" -d - Generate a binary file dump of the specified AcpiTable.\r\n"
+" -g - Generate a dot graph of the specified AcpiTable.\r\n"
" -q - Quiet. Suppress errors and warnings. Disables consistency checks.\r\n"
" -h - Enable colour highlighting.\r\n"
" -r - Validate that all required ACPI tables are installed\r\n"
@@ -123,6 +124,10 @@
" in the current working directory:\r\n"
" fs0:\> acpiview -s DSDT -d\r\n"
" \r\n"
+" * To save a dot graph in the current working directory\r\n"
+" representing the processor architecture described in the PPTT table:\r\n"
+" fs0:\> acpiview -s PPTT -g\r\n"
+" \r\n"
" * To display contents of all ACPI tables:\r\n"
" fs0:\> acpiview\r\n"
" \r\n"
--
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")


[PATCH v2 0/5] Dot graph generator for PPTT

Joey Gouly
 

This series adds functionality to print a dot graph of a PPTT table.
This helps with understanding and debugging PPTT tables.
The dot graph generator functionality is generic and could be used by
other tables that would benefit from graph output.

Bugzilla: 3378 (https://bugzilla.tianocore.org/show_bug.cgi?id=3378)

The changes can be seen at https://github.com/jgouly/edk2/tree/1484_pptt_dot_graph_v2

Changes since v1:
# Fixed errors found by CI
# Rebased onto latest master branch

Marc Moisson-Franckhauser (5):
ShellPkg: Replace 'Trace' parameter with 'ParseFlags'
ShellPkg: add a helper function for getting a new file name
ShellPkg: add a Graph option to the Parser Flags
ShellPkg: add dot file generator functions
ShellPkg: add PPTT dot file genration

.../UefiShellAcpiViewCommandLib.inf | 4 +-
.../UefiShellAcpiViewCommandLib/AcpiParser.h | 79 +++--
.../AcpiTableParser.h | 6 +-
.../UefiShellAcpiViewCommandLib/AcpiView.h | 25 +-
.../AcpiViewConfig.h | 3 +-
.../DotGenerator.h | 101 +++++++
.../AcpiTableParser.c | 20 +-
.../UefiShellAcpiViewCommandLib/AcpiView.c | 117 +++++--
.../DotGenerator.c | 283 +++++++++++++++++
.../Parsers/Bgrt/BgrtParser.c | 10 +-
.../Parsers/Dbg2/Dbg2Parser.c | 8 +-
.../Parsers/Dsdt/DsdtParser.c | 8 +-
.../Parsers/Facs/FacsParser.c | 10 +-
.../Parsers/Fadt/FadtParser.c | 27 +-
.../Parsers/Gtdt/GtdtParser.c | 8 +-
.../Parsers/Iort/IortParser.c | 8 +-
.../Parsers/Madt/MadtParser.c | 8 +-
.../Parsers/Mcfg/McfgParser.c | 8 +-
.../Parsers/Pptt/PpttParser.c | 285 +++++++++++++++---
.../Parsers/Rsdp/RsdpParser.c | 10 +-
.../Parsers/Slit/SlitParser.c | 8 +-
.../Parsers/Spcr/SpcrParser.c | 8 +-
.../Parsers/Srat/SratParser.c | 8 +-
.../Parsers/Ssdt/SsdtParser.c | 8 +-
.../Parsers/Xsdt/XsdtParser.c | 10 +-
.../UefiShellAcpiViewCommandLib.c | 24 +-
.../UefiShellAcpiViewCommandLib.uni | 9 +-
27 files changed, 914 insertions(+), 189 deletions(-)
create mode 100644 ShellPkg/Library/UefiShellAcpiViewCommandLib/DotGenerator.h
create mode 100644 ShellPkg/Library/UefiShellAcpiViewCommandLib/DotGenerator.c

--
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")


[PATCH v2 1/5] ShellPkg: Replace 'Trace' parameter with 'ParseFlags'

Joey Gouly
 

From: Marc Moisson-Franckhauser <marc.moisson-franckhauser@arm.com>

Bugzilla: 3378 (https://bugzilla.tianocore.org/show_bug.cgi?id=3378)

This is preparation for adding a second flag to the parsers.

Signed-off-by: Joey Gouly <joey.gouly@arm.com>
---
ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h | 77 +++++++++++---------
ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.h | 6 +-
ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.c | 20 ++---
ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c | 28 ++++---
ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Bgrt/BgrtParser.c | 10 +--
ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Dbg2/Dbg2Parser.c | 8 +-
ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Dsdt/DsdtParser.c | 8 +-
ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Facs/FacsParser.c | 10 +--
ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.c | 27 ++++---
ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser.c | 8 +-
ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortParser.c | 8 +-
ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.c | 8 +-
ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Mcfg/McfgParser.c | 8 +-
ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c | 47 +++++++-----
ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Rsdp/RsdpParser.c | 10 +--
ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Slit/SlitParser.c | 8 +-
ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Spcr/SpcrParser.c | 8 +-
ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c | 8 +-
ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Ssdt/SsdtParser.c | 8 +-
ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Xsdt/XsdtParser.c | 10 +--
20 files changed, 179 insertions(+), 146 deletions(-)

diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
index 0b7726b9d5807ad2f5c5447408c4c5451718938b..b078c0b99335ba28f7589cac6b0a4190d9a6c3b5 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
@@ -1,7 +1,7 @@
/** @file
Header file for ACPI parser

- Copyright (c) 2016 - 2020, Arm Limited. All rights reserved.
+ Copyright (c) 2016 - 2021, Arm Limited. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/

@@ -16,6 +16,16 @@
/// that allows us to process the log options.
#define RSDP_TABLE_INFO SIGNATURE_32('R', 'S', 'D', 'P')

+/**
+ Flags for the parser.
+*/
+#define PARSE_FLAGS_TRACE BIT0
+
+/**
+ Helper macros to test parser flags.
+*/
+#define IS_TRACE_FLAG_SET(Flags) (((Flags) & PARSE_FLAGS_TRACE) != 0)
+
/**
This function increments the ACPI table error counter.
**/
@@ -489,7 +499,7 @@ ParseAcpiAest (

This function also performs validation of the ACPI table fields.

- @param [in] Trace If TRUE, trace the ACPI fields.
+ @param [in] ParseFlags Flags describing what the parser needs to do.
@param [in] Ptr Pointer to the start of the buffer.
@param [in] AcpiTableLength Length of the ACPI table.
@param [in] AcpiTableRevision Revision of the ACPI table.
@@ -497,7 +507,7 @@ ParseAcpiAest (
VOID
EFIAPI
ParseAcpiBgrt (
- IN BOOLEAN Trace,
+ IN UINT8 ParseFlags,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
@@ -510,7 +520,7 @@ ParseAcpiBgrt (

This function also performs validation of the ACPI table fields.

- @param [in] Trace If TRUE, trace the ACPI fields.
+ @param [in] ParseFlags Flags describing what the parser needs to do.
@param [in] Ptr Pointer to the start of the buffer.
@param [in] AcpiTableLength Length of the ACPI table.
@param [in] AcpiTableRevision Revision of the ACPI table.
@@ -518,7 +528,7 @@ ParseAcpiBgrt (
VOID
EFIAPI
ParseAcpiDbg2 (
- IN BOOLEAN Trace,
+ IN UINT8 ParseFlags,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
@@ -531,7 +541,7 @@ ParseAcpiDbg2 (
For the DSDT table only the ACPI header fields are parsed and
traced.

- @param [in] Trace If TRUE, trace the ACPI fields.
+ @param [in] ParseFlags Flags describing what the parser needs to do.
@param [in] Ptr Pointer to the start of the buffer.
@param [in] AcpiTableLength Length of the ACPI table.
@param [in] AcpiTableRevision Revision of the ACPI table.
@@ -539,7 +549,7 @@ ParseAcpiDbg2 (
VOID
EFIAPI
ParseAcpiDsdt (
- IN BOOLEAN Trace,
+ IN UINT8 ParseFlags,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
@@ -552,7 +562,7 @@ ParseAcpiDsdt (

This function also performs validation of the ACPI table fields.

- @param [in] Trace If TRUE, trace the ACPI fields.
+ @param [in] ParseFlags Flags describing what the parser needs to do.
@param [in] Ptr Pointer to the start of the buffer.
@param [in] AcpiTableLength Length of the ACPI table.
@param [in] AcpiTableRevision Revision of the ACPI table.
@@ -560,7 +570,7 @@ ParseAcpiDsdt (
VOID
EFIAPI
ParseAcpiFacs (
- IN BOOLEAN Trace,
+ IN UINT8 ParseFlags,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
@@ -573,7 +583,7 @@ ParseAcpiFacs (

This function also performs validation of the ACPI table fields.

- @param [in] Trace If TRUE, trace the ACPI fields.
+ @param [in] ParseFlags Flags describing what the parser needs to do.
@param [in] Ptr Pointer to the start of the buffer.
@param [in] AcpiTableLength Length of the ACPI table.
@param [in] AcpiTableRevision Revision of the ACPI table.
@@ -581,7 +591,7 @@ ParseAcpiFacs (
VOID
EFIAPI
ParseAcpiFadt (
- IN BOOLEAN Trace,
+ IN UINT8 ParseFlags,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
@@ -598,7 +608,7 @@ ParseAcpiFadt (

This function also performs validation of the ACPI table fields.

- @param [in] Trace If TRUE, trace the ACPI fields.
+ @param [in] ParseFlags Flags describing what the parser needs to do.
@param [in] Ptr Pointer to the start of the buffer.
@param [in] AcpiTableLength Length of the ACPI table.
@param [in] AcpiTableRevision Revision of the ACPI table.
@@ -606,7 +616,7 @@ ParseAcpiFadt (
VOID
EFIAPI
ParseAcpiGtdt (
- IN BOOLEAN Trace,
+ IN UINT8 ParseFlags,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
@@ -653,7 +663,7 @@ ParseAcpiHmat (

This function also performs validation of the ACPI table fields.

- @param [in] Trace If TRUE, trace the ACPI fields.
+ @param [in] ParseFlags Flags describing what the parser needs to do.
@param [in] Ptr Pointer to the start of the buffer.
@param [in] AcpiTableLength Length of the ACPI table.
@param [in] AcpiTableRevision Revision of the ACPI table.
@@ -661,7 +671,7 @@ ParseAcpiHmat (
VOID
EFIAPI
ParseAcpiIort (
- IN BOOLEAN Trace,
+ IN UINT8 ParseFlags,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
@@ -682,7 +692,7 @@ ParseAcpiIort (

This function also performs validation of the ACPI table fields.

- @param [in] Trace If TRUE, trace the ACPI fields.
+ @param [in] ParseFlags Flags describing what the parser needs to do.
@param [in] Ptr Pointer to the start of the buffer.
@param [in] AcpiTableLength Length of the ACPI table.
@param [in] AcpiTableRevision Revision of the ACPI table.
@@ -690,7 +700,7 @@ ParseAcpiIort (
VOID
EFIAPI
ParseAcpiMadt (
- IN BOOLEAN Trace,
+ IN UINT8 ParseFlags,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
@@ -703,7 +713,7 @@ ParseAcpiMadt (

This function also performs validation of the ACPI table fields.

- @param [in] Trace If TRUE, trace the ACPI fields.
+ @param [in] ParseFlags Flags describing what the parser needs to do.
@param [in] Ptr Pointer to the start of the buffer.
@param [in] AcpiTableLength Length of the ACPI table.
@param [in] AcpiTableRevision Revision of the ACPI table.
@@ -711,7 +721,7 @@ ParseAcpiMadt (
VOID
EFIAPI
ParseAcpiMcfg (
- IN BOOLEAN Trace,
+ IN UINT8 ParseFlags,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
@@ -746,7 +756,7 @@ ParseAcpiPcct (

This function also performs validation of the ACPI table fields.

- @param [in] Trace If TRUE, trace the ACPI fields.
+ @param [in] ParseFlags Flags describing what the parser needs to do.
@param [in] Ptr Pointer to the start of the buffer.
@param [in] AcpiTableLength Length of the ACPI table.
@param [in] AcpiTableRevision Revision of the ACPI table.
@@ -754,7 +764,7 @@ ParseAcpiPcct (
VOID
EFIAPI
ParseAcpiPptt (
- IN BOOLEAN Trace,
+ IN UINT8 ParseFlags,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
@@ -769,7 +779,7 @@ ParseAcpiPptt (
This function also performs a RAW dump of the ACPI table and
validates the checksum.

- @param [in] Trace If TRUE, trace the ACPI fields.
+ @param [in] ParseFlags Flags describing what the parser needs to do.
@param [in] Ptr Pointer to the start of the buffer.
@param [in] AcpiTableLength Length of the ACPI table.
@param [in] AcpiTableRevision Revision of the ACPI table.
@@ -777,7 +787,7 @@ ParseAcpiPptt (
VOID
EFIAPI
ParseAcpiRsdp (
- IN BOOLEAN Trace,
+ IN UINT8 ParseFlags,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
@@ -793,7 +803,8 @@ ParseAcpiRsdp (
- Relative distance from System Locality at i*N+j is same as
j*N+i

- @param [in] Trace If TRUE, trace the ACPI fields.
+ @param [in] ParseFlags Flags describing what the parser needs to
+ do.
@param [in] Ptr Pointer to the start of the buffer.
@param [in] AcpiTableLength Length of the ACPI table.
@param [in] AcpiTableRevision Revision of the ACPI table.
@@ -801,7 +812,7 @@ ParseAcpiRsdp (
VOID
EFIAPI
ParseAcpiSlit (
- IN BOOLEAN Trace,
+ IN UINT8 ParseFlags,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
@@ -814,7 +825,7 @@ ParseAcpiSlit (

This function also performs validations of the ACPI table fields.

- @param [in] Trace If TRUE, trace the ACPI fields.
+ @param [in] ParseFlags Flags describing what the parser needs to do.
@param [in] Ptr Pointer to the start of the buffer.
@param [in] AcpiTableLength Length of the ACPI table.
@param [in] AcpiTableRevision Revision of the ACPI table.
@@ -822,7 +833,7 @@ ParseAcpiSlit (
VOID
EFIAPI
ParseAcpiSpcr (
- IN BOOLEAN Trace,
+ IN UINT8 ParseFlags,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
@@ -841,7 +852,7 @@ ParseAcpiSpcr (

This function also performs validation of the ACPI table fields.

- @param [in] Trace If TRUE, trace the ACPI fields.
+ @param [in] ParseFlags Flags describing what the parser needs to do.
@param [in] Ptr Pointer to the start of the buffer.
@param [in] AcpiTableLength Length of the ACPI table.
@param [in] AcpiTableRevision Revision of the ACPI table.
@@ -849,7 +860,7 @@ ParseAcpiSpcr (
VOID
EFIAPI
ParseAcpiSrat (
- IN BOOLEAN Trace,
+ IN UINT8 ParseFlags,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
@@ -862,7 +873,7 @@ ParseAcpiSrat (
For the SSDT table only the ACPI header fields are
parsed and traced.

- @param [in] Trace If TRUE, trace the ACPI fields.
+ @param [in] ParseFlags Flags describing what the parser needs to do.
@param [in] Ptr Pointer to the start of the buffer.
@param [in] AcpiTableLength Length of the ACPI table.
@param [in] AcpiTableRevision Revision of the ACPI table.
@@ -870,7 +881,7 @@ ParseAcpiSrat (
VOID
EFIAPI
ParseAcpiSsdt (
- IN BOOLEAN Trace,
+ IN UINT8 ParseFlags,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
@@ -882,7 +893,7 @@ ParseAcpiSsdt (

This function also performs validation of the XSDT table.

- @param [in] Trace If TRUE, trace the ACPI fields.
+ @param [in] ParseFlags Flags describing what the parser needs to do.
@param [in] Ptr Pointer to the start of the buffer.
@param [in] AcpiTableLength Length of the ACPI table.
@param [in] AcpiTableRevision Revision of the ACPI table.
@@ -890,7 +901,7 @@ ParseAcpiSsdt (
VOID
EFIAPI
ParseAcpiXsdt (
- IN BOOLEAN Trace,
+ IN UINT8 ParseFlags,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.h b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.h
index 0ebf79fb653ae3a8190273aee452723c6213eb58..94ce0a4860e5296d99d398480655a8013ab0f240 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.h
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.h
@@ -1,7 +1,7 @@
/** @file
Header file for ACPI table parser

- Copyright (c) 2016 - 2020, Arm Limited. All rights reserved.
+ Copyright (c) 2016 - 2021, Arm Limited. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/

@@ -20,7 +20,7 @@
/**
A function that parses the ACPI table.

- @param [in] Trace If TRUE, trace the ACPI fields.
+ @param [in] ParseFlags Flags describing what the parser needs to do.
@param [in] Ptr Pointer to the start of the buffer.
@param [in] AcpiTableLength Length of the ACPI table.
@param [in] AcpiTableRevision Revision of the ACPI table.
@@ -28,7 +28,7 @@
typedef
VOID
(EFIAPI * PARSE_ACPI_TABLE_PROC) (
- IN BOOLEAN Trace,
+ IN UINT8 ParseFlags,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.c
index 4b618f131eac3957f4070a95e06c8cd157c3223c..ecb5d6339af37397c6ba1ba4c8f0d42a95811bf6 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiTableParser.c
@@ -1,7 +1,7 @@
/** @file
ACPI table parser

- Copyright (c) 2016 - 2020, ARM Limited. All rights reserved.
+ Copyright (c) 2016 - 2021, Arm Limited. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

@par Glossary:
@@ -183,7 +183,7 @@ ProcessAcpiTable (
)
{
EFI_STATUS Status;
- BOOLEAN Trace;
+ UINT8 ParseFlags;
CONST UINT32* AcpiTableSignature;
CONST UINT32* AcpiTableLength;
CONST UINT8* AcpiTableRevision;
@@ -197,13 +197,13 @@ ProcessAcpiTable (
&AcpiTableRevision
);

- Trace = ProcessTableReportOptions (
- *AcpiTableSignature,
- Ptr,
- *AcpiTableLength
- );
+ ParseFlags = ProcessTableReportOptions (
+ *AcpiTableSignature,
+ Ptr,
+ *AcpiTableLength
+ );

- if (Trace) {
+ if (IS_TRACE_FLAG_SET (ParseFlags)) {
DumpRaw (Ptr, *AcpiTableLength);

// Do not process the ACPI table any further if the table length read
@@ -236,14 +236,14 @@ ProcessAcpiTable (
Status = GetParser (*AcpiTableSignature, &ParserProc);
if (EFI_ERROR (Status)) {
// No registered parser found, do default handling.
- if (Trace) {
+ if (IS_TRACE_FLAG_SET (ParseFlags)) {
DumpAcpiHeader (Ptr);
}
return;
}

ParserProc (
- Trace,
+ ParseFlags,
Ptr,
*AcpiTableLength,
*AcpiTableRevision
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
index 9a5b013fb234e2a09a12a690607b5b871dffde72..a4242ba9d99b05d07c829520c4011439445aadb0 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
@@ -1,6 +1,6 @@
/** @file

- Copyright (c) 2016 - 2020, ARM Limited. All rights reserved.
+ Copyright (c) 2016 - 2021, Arm Limited. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

@par Glossary:
@@ -73,9 +73,9 @@ DumpAcpiTableToFile (
@param [in] TablePtr Pointer to the ACPI table data.
@param [in] Length The length fo the ACPI table.

- @retval Returns TRUE if the ACPI table should be traced.
+ @retval Returns the ParseFlags for the ACPI table.
**/
-BOOLEAN
+UINT8
ProcessTableReportOptions (
IN CONST UINT32 Signature,
IN CONST UINT8* TablePtr,
@@ -84,7 +84,7 @@ ProcessTableReportOptions (
{
UINTN OriginalAttribute;
UINT8 *SignaturePtr;
- BOOLEAN Log;
+ UINT8 ParseFlags;
BOOLEAN HighLight;
SELECTED_ACPI_TABLE *SelectedTable;

@@ -93,17 +93,17 @@ ProcessTableReportOptions (
//
OriginalAttribute = 0;
SignaturePtr = (UINT8*)(UINTN)&Signature;
- Log = FALSE;
+ ParseFlags = 0;
HighLight = GetColourHighlighting ();
GetSelectedAcpiTable (&SelectedTable);

switch (GetReportOption ()) {
case ReportAll:
- Log = TRUE;
+ ParseFlags |= PARSE_FLAGS_TRACE;
break;
case ReportSelected:
if (Signature == SelectedTable->Type) {
- Log = TRUE;
+ ParseFlags |= PARSE_FLAGS_TRACE;
SelectedTable->Found = TRUE;
}
break;
@@ -143,7 +143,7 @@ ProcessTableReportOptions (
break;
} // switch

- if (Log) {
+ if (IS_TRACE_FLAG_SET (ParseFlags)) {
if (HighLight) {
OriginalAttribute = gST->ConOut->Mode->Attribute;
gST->ConOut->SetAttribute (
@@ -164,7 +164,7 @@ ProcessTableReportOptions (
}
}

- return Log;
+ return ParseFlags;
}


@@ -196,7 +196,7 @@ AcpiView (
UINT32 RsdpLength;
UINT8 RsdpRevision;
PARSE_ACPI_TABLE_PROC RsdpParserProc;
- BOOLEAN Trace;
+ UINT8 ParseFlags;
SELECTED_ACPI_TABLE *SelectedTable;

//
@@ -249,7 +249,11 @@ AcpiView (
// The RSDP length is 4 bytes starting at offset 20
RsdpLength = *(UINT32*)(RsdpPtr + RSDP_LENGTH_OFFSET);

- Trace = ProcessTableReportOptions (RSDP_TABLE_INFO, RsdpPtr, RsdpLength);
+ ParseFlags = ProcessTableReportOptions (
+ RSDP_TABLE_INFO,
+ RsdpPtr,
+ RsdpLength
+ );

Status = GetParser (RSDP_TABLE_INFO, &RsdpParserProc);
if (EFI_ERROR (Status)) {
@@ -260,7 +264,7 @@ AcpiView (
}

RsdpParserProc (
- Trace,
+ ParseFlags,
RsdpPtr,
RsdpLength,
RsdpRevision
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Bgrt/BgrtParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Bgrt/BgrtParser.c
index 1a180271a4ebe47948b7f0b56d1cb6f81b5fdf13..6bd4c35bec85e038875ce3d9548c9139b1de2755 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Bgrt/BgrtParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Bgrt/BgrtParser.c
@@ -1,7 +1,7 @@
/** @file
BGRT table parser

- Copyright (c) 2017 - 2018, ARM Limited. All rights reserved.
+ Copyright (c) 2017 - 2021, Arm Limited. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

@par Reference(s):
@@ -36,7 +36,7 @@ STATIC CONST ACPI_PARSER BgrtParser[] = {

This function also performs validation of the ACPI table fields.

- @param [in] Trace If TRUE, trace the ACPI fields.
+ @param [in] ParseFlags Flags describing what the parser needs to do.
@param [in] Ptr Pointer to the start of the buffer.
@param [in] AcpiTableLength Length of the ACPI table.
@param [in] AcpiTableRevision Revision of the ACPI table.
@@ -44,18 +44,18 @@ STATIC CONST ACPI_PARSER BgrtParser[] = {
VOID
EFIAPI
ParseAcpiBgrt (
- IN BOOLEAN Trace,
+ IN UINT8 ParseFlags,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
)
{
- if (!Trace) {
+ if (!IS_TRACE_FLAG_SET (ParseFlags)) {
return;
}

ParseAcpi (
- Trace,
+ TRUE,
0,
"BGRT",
Ptr,
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Dbg2/Dbg2Parser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Dbg2/Dbg2Parser.c
index 9df111ecaa7d7a703a13a39c243ed78b9f12ee97..a22f8ab76b84432b2073bea6ca6d8245ea9df7fb 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Dbg2/Dbg2Parser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Dbg2/Dbg2Parser.c
@@ -1,7 +1,7 @@
/** @file
DBG2 table parser

- Copyright (c) 2016 - 2020, ARM Limited. All rights reserved.
+ Copyright (c) 2016 - 2021, Arm Limited. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

@par Reference(s):
@@ -212,7 +212,7 @@ DumpDbgDeviceInfo (

This function also performs validation of the ACPI table fields.

- @param [in] Trace If TRUE, trace the ACPI fields.
+ @param [in] ParseFlags Flags describing what the parser needs to do.
@param [in] Ptr Pointer to the start of the buffer.
@param [in] AcpiTableLength Length of the ACPI table.
@param [in] AcpiTableRevision Revision of the ACPI table.
@@ -220,7 +220,7 @@ DumpDbgDeviceInfo (
VOID
EFIAPI
ParseAcpiDbg2 (
- IN BOOLEAN Trace,
+ IN UINT8 ParseFlags,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
@@ -229,7 +229,7 @@ ParseAcpiDbg2 (
UINT32 Offset;
UINT32 Index;

- if (!Trace) {
+ if (!IS_TRACE_FLAG_SET (ParseFlags)) {
return;
}

diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Dsdt/DsdtParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Dsdt/DsdtParser.c
index 6d43974f54d23fd9990fa7af721c96518bb96a36..609c17ef02d460be66f0c390203cae55ece653e3 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Dsdt/DsdtParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Dsdt/DsdtParser.c
@@ -1,7 +1,7 @@
/** @file
DSDT table parser

- Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.
+ Copyright (c) 2016 - 2021, Arm Limited. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

@par Reference(s):
@@ -20,7 +20,7 @@
For the DSDT table only the ACPI header fields are parsed and
traced.

- @param [in] Trace If TRUE, trace the ACPI fields.
+ @param [in] ParseFlags Flags describing what the parser needs to do.
@param [in] Ptr Pointer to the start of the buffer.
@param [in] AcpiTableLength Length of the ACPI table.
@param [in] AcpiTableRevision Revision of the ACPI table.
@@ -28,13 +28,13 @@
VOID
EFIAPI
ParseAcpiDsdt (
- IN BOOLEAN Trace,
+ IN UINT8 ParseFlags,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
)
{
- if (!Trace) {
+ if (!IS_TRACE_FLAG_SET (ParseFlags)) {
return;
}

diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Facs/FacsParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Facs/FacsParser.c
index d6bea86bdbaa79aa35b86840c809394b3c7a3bf6..d7545b6161eadd24e986a7828910662f2f52b2ec 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Facs/FacsParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Facs/FacsParser.c
@@ -1,7 +1,7 @@
/** @file
FACS table parser

- Copyright (c) 2019, ARM Limited. All rights reserved.
+ Copyright (c) 2019 - 2021, Arm Limited. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

@par Reference(s):
@@ -42,7 +42,7 @@ STATIC CONST ACPI_PARSER FacsParser[] = {

This function also performs validation of the ACPI table fields.

- @param [in] Trace If TRUE, trace the ACPI fields.
+ @param [in] ParseFlags Flags describing what the parser needs to do.
@param [in] Ptr Pointer to the start of the buffer.
@param [in] AcpiTableLength Length of the ACPI table.
@param [in] AcpiTableRevision Revision of the ACPI table.
@@ -50,18 +50,18 @@ STATIC CONST ACPI_PARSER FacsParser[] = {
VOID
EFIAPI
ParseAcpiFacs (
- IN BOOLEAN Trace,
+ IN UINT8 ParseFlags,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
)
{
- if (!Trace) {
+ if (!IS_TRACE_FLAG_SET (ParseFlags)) {
return;
}

ParseAcpi (
- Trace,
+ TRUE,
0,
"FACS",
Ptr,
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.c
index d86718bab67d45fd612bb7ac725b5eb3eeb7dfdc..8d0eb42ec3b361c1727184c542a757e39ef3da5c 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Fadt/FadtParser.c
@@ -1,7 +1,7 @@
/** @file
FADT table parser

- Copyright (c) 2016 - 2020, ARM Limited. All rights reserved.
+ Copyright (c) 2016 - 2021, Arm Limited. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

@par Reference(s):
@@ -198,7 +198,7 @@ STATIC CONST ACPI_PARSER FadtParser[] = {

This function also performs validation of the ACPI table fields.

- @param [in] Trace If TRUE, trace the ACPI fields.
+ @param [in] ParseFlags Flags describing what the parser needs to do.
@param [in] Ptr Pointer to the start of the buffer.
@param [in] AcpiTableLength Length of the ACPI table.
@param [in] AcpiTableRevision Revision of the ACPI table.
@@ -206,7 +206,7 @@ STATIC CONST ACPI_PARSER FadtParser[] = {
VOID
EFIAPI
ParseAcpiFadt (
- IN BOOLEAN Trace,
+ IN UINT8 ParseFlags,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
@@ -219,6 +219,9 @@ ParseAcpiFadt (
UINT32 FacsLength;
UINT8 FacsRevision;
PARSE_ACPI_TABLE_PROC FacsParserProc;
+ BOOLEAN Trace;
+
+ Trace = IS_TRACE_FLAG_SET (ParseFlags);

ParseAcpi (
Trace,
@@ -253,7 +256,7 @@ ParseAcpiFadt (
// if HW_REDUCED_ACPI flag is not set, both FIRMWARE_CTRL and
// X_FIRMWARE_CTRL cannot be zero, and the FACS Table must be
// present.
- if ((Trace) &&
+ if (Trace &&
(Flags != NULL) &&
((*Flags & EFI_ACPI_6_3_HW_REDUCED_ACPI) != EFI_ACPI_6_3_HW_REDUCED_ACPI)) {
IncrementErrorCount ();
@@ -274,11 +277,15 @@ ParseAcpiFadt (
// The FACS version is 1 byte starting at offset 32.
FacsRevision = *(UINT8*)(FirmwareCtrlPtr + FACS_VERSION_OFFSET);

- Trace = ProcessTableReportOptions (
- FacsSignature,
- FirmwareCtrlPtr,
- FacsLength
- );
+ if (ProcessTableReportOptions (
+ FacsSignature,
+ FirmwareCtrlPtr,
+ FacsLength
+ )) {
+ ParseFlags |= PARSE_FLAGS_TRACE;
+ } else {
+ ParseFlags &= ~PARSE_FLAGS_TRACE;
+ }

Status = GetParser (FacsSignature, &FacsParserProc);
if (EFI_ERROR (Status)) {
@@ -289,7 +296,7 @@ ParseAcpiFadt (
}

FacsParserProc (
- Trace,
+ ParseFlags,
FirmwareCtrlPtr,
FacsLength,
FacsRevision
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser.c
index d02fc4929d6fa5e04672276810b19d3f4c62efd2..da93938771bfcf0da146fd46a025addeb05e71cc 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Gtdt/GtdtParser.c
@@ -1,7 +1,7 @@
/** @file
GTDT table parser

- Copyright (c) 2016 - 2020, ARM Limited. All rights reserved.
+ Copyright (c) 2016 - 2021, Arm Limited. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

@par Reference(s):
@@ -254,7 +254,7 @@ DumpWatchdogTimer (

This function also performs validation of the ACPI table fields.

- @param [in] Trace If TRUE, trace the ACPI fields.
+ @param [in] ParseFlags Flags describing what the parser needs to do.
@param [in] Ptr Pointer to the start of the buffer.
@param [in] AcpiTableLength Length of the ACPI table.
@param [in] AcpiTableRevision Revision of the ACPI table.
@@ -262,7 +262,7 @@ DumpWatchdogTimer (
VOID
EFIAPI
ParseAcpiGtdt (
- IN BOOLEAN Trace,
+ IN UINT8 ParseFlags,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
@@ -272,7 +272,7 @@ ParseAcpiGtdt (
UINT32 Offset;
UINT8* TimerPtr;

- if (!Trace) {
+ if (!IS_TRACE_FLAG_SET (ParseFlags)) {
return;
}

diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortParser.c
index f7447947b2308d35d4d2890373778f0fd2f97f9e..2f659349499a02175820ee4faf3a84034c8ced76 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Iort/IortParser.c
@@ -1,7 +1,7 @@
/** @file
IORT table parser

- Copyright (c) 2016 - 2020, ARM Limited. All rights reserved.
+ Copyright (c) 2016 - 2021, Arm Limited. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

@par Reference(s):
@@ -612,7 +612,7 @@ DumpIortNodePmcg (

This function also performs validation of the ACPI table fields.

- @param [in] Trace If TRUE, trace the ACPI fields.
+ @param [in] ParseFlags Flags describing what the parser needs to do.
@param [in] Ptr Pointer to the start of the buffer.
@param [in] AcpiTableLength Length of the ACPI table.
@param [in] AcpiTableRevision Revision of the ACPI table.
@@ -620,7 +620,7 @@ DumpIortNodePmcg (
VOID
EFIAPI
ParseAcpiIort (
- IN BOOLEAN Trace,
+ IN UINT8 ParseFlags,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
@@ -630,7 +630,7 @@ ParseAcpiIort (
UINT32 Index;
UINT8* NodePtr;

- if (!Trace) {
+ if (!IS_TRACE_FLAG_SET (ParseFlags)) {
return;
}

diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.c
index 15aa2392b60cee9e3843c7c560b0ab84e0be4174..a29bf97a3985a74ff888f225eb0e5cfbcbea72b0 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtParser.c
@@ -1,7 +1,7 @@
/** @file
MADT table parser

- Copyright (c) 2016 - 2020, ARM Limited. All rights reserved.
+ Copyright (c) 2016 - 2021, Arm Limited. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

@par Reference(s):
@@ -216,7 +216,7 @@ STATIC CONST ACPI_PARSER MadtInterruptControllerHeaderParser[] = {

This function also performs validation of the ACPI table fields.

- @param [in] Trace If TRUE, trace the ACPI fields.
+ @param [in] ParseFlags Flags describing what the parser needs to do.
@param [in] Ptr Pointer to the start of the buffer.
@param [in] AcpiTableLength Length of the ACPI table.
@param [in] AcpiTableRevision Revision of the ACPI table.
@@ -224,7 +224,7 @@ STATIC CONST ACPI_PARSER MadtInterruptControllerHeaderParser[] = {
VOID
EFIAPI
ParseAcpiMadt (
- IN BOOLEAN Trace,
+ IN UINT8 ParseFlags,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
@@ -236,7 +236,7 @@ ParseAcpiMadt (

GICDCount = 0;

- if (!Trace) {
+ if (!IS_TRACE_FLAG_SET (ParseFlags)) {
return;
}

diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Mcfg/McfgParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Mcfg/McfgParser.c
index 9da4d60e849721ed3b635bfff8a3bd76728c0ade..febf8a2bd92d8e38bdc59a3f97a8c4485cdba5a5 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Mcfg/McfgParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Mcfg/McfgParser.c
@@ -1,7 +1,7 @@
/** @file
MCFG table parser

- Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.
+ Copyright (c) 2016 - 2021, Arm Limited. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

@par Reference(s):
@@ -42,7 +42,7 @@ STATIC CONST ACPI_PARSER PciCfgSpaceBaseAddrParser[] = {

This function also performs validation of the ACPI table fields.

- @param [in] Trace If TRUE, trace the ACPI fields.
+ @param [in] ParseFlags Flags describing what the parser needs to do.
@param [in] Ptr Pointer to the start of the buffer.
@param [in] AcpiTableLength Length of the ACPI table.
@param [in] AcpiTableRevision Revision of the ACPI table.
@@ -50,7 +50,7 @@ STATIC CONST ACPI_PARSER PciCfgSpaceBaseAddrParser[] = {
VOID
EFIAPI
ParseAcpiMcfg (
- IN BOOLEAN Trace,
+ IN UINT8 ParseFlags,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
@@ -60,7 +60,7 @@ ParseAcpiMcfg (
UINT32 PciCfgOffset;
UINT8* PciCfgSpacePtr;

- if (!Trace) {
+ if (!IS_TRACE_FLAG_SET (ParseFlags)) {
return;
}

diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c
index acd2b81bb3258c7322aa10d2c0e0d842d89e358b..538b6a69350d75ccbf36b86fff115255e77437c7 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c
@@ -1,7 +1,7 @@
/** @file
PPTT table parser

- Copyright (c) 2019 - 2020, ARM Limited. All rights reserved.
+ Copyright (c) 2019 - 2021, Arm Limited. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

@par Reference(s):
@@ -241,13 +241,15 @@ STATIC CONST ACPI_PARSER IdStructureParser[] = {
/**
This function parses the Processor Hierarchy Node Structure (Type 0).

- @param [in] Ptr Pointer to the start of the Processor Hierarchy Node
- Structure data.
- @param [in] Length Length of the Processor Hierarchy Node Structure.
+ @param [in] ParseFlags Flags describing what the parser needs to do.
+ @param [in] Ptr Pointer to the start of the Processor Hierarchy Node
+ Structure data.
+ @param [in] Length Length of the Processor Hierarchy Node Structure.
**/
STATIC
VOID
DumpProcessorHierarchyNodeStructure (
+ IN UINT8 ParseFlags,
IN UINT8* Ptr,
IN UINT8 Length
)
@@ -257,7 +259,7 @@ DumpProcessorHierarchyNodeStructure (
CHAR16 Buffer[OUTPUT_FIELD_COLUMN_WIDTH];

Offset = ParseAcpi (
- TRUE,
+ IS_TRACE_FLAG_SET (ParseFlags),
2,
"Processor Hierarchy Node Structure",
Ptr,
@@ -315,18 +317,20 @@ DumpProcessorHierarchyNodeStructure (
/**
This function parses the Cache Type Structure (Type 1).

- @param [in] Ptr Pointer to the start of the Cache Type Structure data.
- @param [in] Length Length of the Cache Type Structure.
+ @param [in] ParseFlags Flags describing what the parser needs to do.
+ @param [in] Ptr Pointer to the start of the Cache Type Structure data.
+ @param [in] Length Length of the Cache Type Structure.
**/
STATIC
VOID
DumpCacheTypeStructure (
+ IN UINT8 ParseFlags,
IN UINT8* Ptr,
IN UINT8 Length
)
{
ParseAcpi (
- TRUE,
+ IS_TRACE_FLAG_SET (ParseFlags),
2,
"Cache Type Structure",
Ptr,
@@ -338,18 +342,20 @@ DumpCacheTypeStructure (
/**
This function parses the ID Structure (Type 2).

- @param [in] Ptr Pointer to the start of the ID Structure data.
- @param [in] Length Length of the ID Structure.
+ @param [in] ParseFlags Flags describing what the parser needs to do.
+ @param [in] Ptr Pointer to the start of the ID Structure data.
+ @param [in] Length Length of the ID Structure.
**/
STATIC
VOID
DumpIDStructure (
+ IN UINT8 ParseFlags,
IN UINT8* Ptr,
- IN UINT8 Length
+ IN UINT8 Length
)
{
ParseAcpi (
- TRUE,
+ IS_TRACE_FLAG_SET (ParseFlags),
2,
"ID Structure",
Ptr,
@@ -370,7 +376,7 @@ DumpIDStructure (

This function also performs validation of the ACPI table fields.

- @param [in] Trace If TRUE, trace the ACPI fields.
+ @param [in] ParseFlags Flags describing what the parser needs to do.
@param [in] Ptr Pointer to the start of the buffer.
@param [in] AcpiTableLength Length of the ACPI table.
@param [in] AcpiTableRevision Revision of the ACPI table.
@@ -378,7 +384,7 @@ DumpIDStructure (
VOID
EFIAPI
ParseAcpiPptt (
- IN BOOLEAN Trace,
+ IN UINT8 ParseFlags,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
@@ -387,12 +393,12 @@ ParseAcpiPptt (
UINT32 Offset;
UINT8* ProcessorTopologyStructurePtr;

- if (!Trace) {
+ if (!IS_TRACE_FLAG_SET (ParseFlags)) {
return;
}

Offset = ParseAcpi (
- TRUE,
+ IS_TRACE_FLAG_SET (ParseFlags),
0,
"PPTT",
Ptr,
@@ -440,24 +446,29 @@ ParseAcpiPptt (
return;
}

- PrintFieldName (2, L"* Structure Offset *");
- Print (L"0x%x\n", Offset);
+ if (IS_TRACE_FLAG_SET (ParseFlags)) {
+ PrintFieldName (2, L"* Structure Offset *");
+ Print (L"0x%x\n", Offset);
+ }

switch (*ProcessorTopologyStructureType) {
case EFI_ACPI_6_2_PPTT_TYPE_PROCESSOR:
DumpProcessorHierarchyNodeStructure (
+ ParseFlags,
ProcessorTopologyStructurePtr,
*ProcessorTopologyStructureLength
);
break;
case EFI_ACPI_6_2_PPTT_TYPE_CACHE:
DumpCacheTypeStructure (
+ ParseFlags,
ProcessorTopologyStructurePtr,
*ProcessorTopologyStructureLength
);
break;
case EFI_ACPI_6_2_PPTT_TYPE_ID:
DumpIDStructure (
+ ParseFlags,
ProcessorTopologyStructurePtr,
*ProcessorTopologyStructureLength
);
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Rsdp/RsdpParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Rsdp/RsdpParser.c
index f4a8732a7db7c437031f2a3d2f266b80eff17b4b..c98bc62719c3aef3381152ff2436cb1a29f98362 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Rsdp/RsdpParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Rsdp/RsdpParser.c
@@ -1,7 +1,7 @@
/** @file
RSDP table parser

- Copyright (c) 2016 - 2019, ARM Limited. All rights reserved.
+ Copyright (c) 2016 - 2021, Arm Limited. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

@par Reference(s):
@@ -110,7 +110,7 @@ STATIC CONST ACPI_PARSER RsdpParser[] = {
This function also performs a RAW dump of the ACPI table and
validates the checksum.

- @param [in] Trace If TRUE, trace the ACPI fields.
+ @param [in] ParseFlags Flags describing what the parser needs to do.
@param [in] Ptr Pointer to the start of the buffer.
@param [in] AcpiTableLength Length of the ACPI table.
@param [in] AcpiTableRevision Revision of the ACPI table.
@@ -118,19 +118,19 @@ STATIC CONST ACPI_PARSER RsdpParser[] = {
VOID
EFIAPI
ParseAcpiRsdp (
- IN BOOLEAN Trace,
+ IN UINT8 ParseFlags,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
)
{
- if (Trace) {
+ if (IS_TRACE_FLAG_SET (ParseFlags)) {
DumpRaw (Ptr, AcpiTableLength);
VerifyChecksum (TRUE, Ptr, AcpiTableLength);
}

ParseAcpi (
- Trace,
+ IS_TRACE_FLAG_SET (ParseFlags),
0,
"RSDP",
Ptr,
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Slit/SlitParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Slit/SlitParser.c
index e4625ee8b13907893a9b6990ecb956baf91cc3b9..20d2fb79a8ea6251b0e31b5370cc400be9e1478f 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Slit/SlitParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Slit/SlitParser.c
@@ -1,7 +1,7 @@
/** @file
SLIT table parser

- Copyright (c) 2016 - 2019, ARM Limited. All rights reserved.
+ Copyright (c) 2016 - 2021, Arm Limited. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

@par Reference(s):
@@ -42,7 +42,7 @@ STATIC CONST ACPI_PARSER SlitParser[] = {
- Relative distance from System Locality at i*N+j is same as
j*N+i

- @param [in] Trace If TRUE, trace the ACPI fields.
+ @param [in] ParseFlags Flags describing what the parser needs to do.
@param [in] Ptr Pointer to the start of the buffer.
@param [in] AcpiTableLength Length of the ACPI table.
@param [in] AcpiTableRevision Revision of the ACPI table.
@@ -50,7 +50,7 @@ STATIC CONST ACPI_PARSER SlitParser[] = {
VOID
EFIAPI
ParseAcpiSlit (
- IN BOOLEAN Trace,
+ IN UINT8 ParseFlags,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
@@ -63,7 +63,7 @@ ParseAcpiSlit (
UINT8* LocalityPtr;
CHAR16 Buffer[80]; // Used for AsciiName param of ParseAcpi

- if (!Trace) {
+ if (!IS_TRACE_FLAG_SET (ParseFlags)) {
return;
}

diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Spcr/SpcrParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Spcr/SpcrParser.c
index 3b06b05dee8c056c6e009b9e485ccd35d4194e95..99cffafa946979b79a06cd28f14257beaa6cafec 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Spcr/SpcrParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Spcr/SpcrParser.c
@@ -1,7 +1,7 @@
/** @file
SPCR table parser

- Copyright (c) 2016 - 2019, ARM Limited. All rights reserved.
+ Copyright (c) 2016 - 2021, Arm Limited. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

@par Reference(s):
@@ -114,7 +114,7 @@ STATIC CONST ACPI_PARSER SpcrParser[] = {

This function also performs validations of the ACPI table fields.

- @param [in] Trace If TRUE, trace the ACPI fields.
+ @param [in] ParseFlags Flags describing what the parser needs to do.
@param [in] Ptr Pointer to the start of the buffer.
@param [in] AcpiTableLength Length of the ACPI table.
@param [in] AcpiTableRevision Revision of the ACPI table.
@@ -122,13 +122,13 @@ STATIC CONST ACPI_PARSER SpcrParser[] = {
VOID
EFIAPI
ParseAcpiSpcr (
- IN BOOLEAN Trace,
+ IN UINT8 ParseFlags,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
)
{
- if (!Trace) {
+ if (!IS_TRACE_FLAG_SET (ParseFlags)) {
return;
}

diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c
index b9b67820b89f7fc5560a1022e976663db7d9df2d..907856368fbe0ad9f140d8f27e51bd9460f35b1a 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Srat/SratParser.c
@@ -1,7 +1,7 @@
/** @file
SRAT table parser

- Copyright (c) 2016 - 2020, ARM Limited. All rights reserved.
+ Copyright (c) 2016 - 2021, Arm Limited. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

@par Reference(s):
@@ -344,7 +344,7 @@ STATIC CONST ACPI_PARSER SratX2ApciAffinityParser[] = {

This function also performs validation of the ACPI table fields.

- @param [in] Trace If TRUE, trace the ACPI fields.
+ @param [in] ParseFlags Flags describing what the parser needs to do.
@param [in] Ptr Pointer to the start of the buffer.
@param [in] AcpiTableLength Length of the ACPI table.
@param [in] AcpiTableRevision Revision of the ACPI table.
@@ -352,7 +352,7 @@ STATIC CONST ACPI_PARSER SratX2ApciAffinityParser[] = {
VOID
EFIAPI
ParseAcpiSrat (
- IN BOOLEAN Trace,
+ IN UINT8 ParseFlags,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
@@ -375,7 +375,7 @@ ParseAcpiSrat (
ApicSapicAffinityIndex = 0;
X2ApicAffinityIndex = 0;

- if (!Trace) {
+ if (!IS_TRACE_FLAG_SET (ParseFlags)) {
return;
}

diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Ssdt/SsdtParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Ssdt/SsdtParser.c
index f18664b8a6879b82dc9c55d9979ca21e01c4fc99..138a3159fb1a6121387f832621d23960c688ce30 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Ssdt/SsdtParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Ssdt/SsdtParser.c
@@ -1,7 +1,7 @@
/** @file
SSDT table parser

- Copyright (c) 2016 - 2018, ARM Limited. All rights reserved.
+ Copyright (c) 2016 - 2021, Arm Limited. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

@par Reference(s):
@@ -20,7 +20,7 @@
For the SSDT table only the ACPI header fields are
parsed and traced.

- @param [in] Trace If TRUE, trace the ACPI fields.
+ @param [in] ParseFlags Flags describing what the parser needs to do.
@param [in] Ptr Pointer to the start of the buffer.
@param [in] AcpiTableLength Length of the ACPI table.
@param [in] AcpiTableRevision Revision of the ACPI table.
@@ -28,13 +28,13 @@
VOID
EFIAPI
ParseAcpiSsdt (
- IN BOOLEAN Trace,
+ IN UINT8 ParseFlags,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
)
{
- if (!Trace) {
+ if (!IS_TRACE_FLAG_SET (ParseFlags)) {
return;
}

diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Xsdt/XsdtParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Xsdt/XsdtParser.c
index e39061f8e2612f2cce4aebf51a511b63b703662b..bbd58d72ad9c676b4843d3b4f1d7c554a5abbd3f 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Xsdt/XsdtParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Xsdt/XsdtParser.c
@@ -1,7 +1,7 @@
/** @file
XSDT table parser

- Copyright (c) 2016 - 2019, ARM Limited. All rights reserved.
+ Copyright (c) 2016 - 2021, Arm Limited. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

@par Reference(s):
@@ -40,7 +40,7 @@ GetAcpiXsdtHeaderInfo (

This function also performs validation of the XSDT table.

- @param [in] Trace If TRUE, trace the ACPI fields.
+ @param [in] ParseFlags Flags describing what the parser needs to do.
@param [in] Ptr Pointer to the start of the buffer.
@param [in] AcpiTableLength Length of the ACPI table.
@param [in] AcpiTableRevision Revision of the ACPI table.
@@ -48,7 +48,7 @@ GetAcpiXsdtHeaderInfo (
VOID
EFIAPI
ParseAcpiXsdt (
- IN BOOLEAN Trace,
+ IN UINT8 ParseFlags,
IN UINT8* Ptr,
IN UINT32 AcpiTableLength,
IN UINT8 AcpiTableRevision
@@ -61,7 +61,7 @@ ParseAcpiXsdt (
CHAR16 Buffer[32];

Offset = ParseAcpi (
- Trace,
+ IS_TRACE_FLAG_SET (ParseFlags),
0,
"XSDT",
Ptr,
@@ -71,7 +71,7 @@ ParseAcpiXsdt (

TableOffset = Offset;

- if (Trace) {
+ if (IS_TRACE_FLAG_SET (ParseFlags)) {
EntryIndex = 0;
TablePointer = (UINT64*)(Ptr + TableOffset);
while (Offset < AcpiTableLength) {
--
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")


[PATCH v2 5/5] ShellPkg: add PPTT dot file genration

Joey Gouly
 

From: Marc Moisson-Franckhauser <marc.moisson-franckhauser@arm.com>

Bugzilla: 3378 (https://bugzilla.tianocore.org/show_bug.cgi?id=3378)

This generates a dot file from the PPTT table that can be used to
visualise the topology of the CPUs and Caches.

Signed-off-by: Joey Gouly <joey.gouly@arm.com>
---
ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c | 240 ++++++++++++++++++--
1 file changed, 218 insertions(+), 22 deletions(-)

diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c
index 538b6a69350d75ccbf36b86fff115255e77437c7..b52bd532b846b9cec0ca315b043beff95df40bd5 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Pptt/PpttParser.c
@@ -15,11 +15,23 @@
#include "AcpiView.h"
#include "AcpiViewConfig.h"
#include "PpttParser.h"
+#include "DotGenerator.h"

// Local variables
STATIC CONST UINT8* ProcessorTopologyStructureType;
STATIC CONST UINT8* ProcessorTopologyStructureLength;
+
STATIC CONST UINT32* NumberOfPrivateResources;
+STATIC CONST UINT32* ProcessorHierarchyParent;
+STATIC CONST EFI_ACPI_6_3_PPTT_STRUCTURE_PROCESSOR_FLAGS* ProcStructFlags;
+STATIC CONST UINT32* NextLevelOfCache;
+STATIC CONST EFI_ACPI_6_3_PPTT_STRUCTURE_CACHE_ATTRIBUTES* CacheAttributes;
+STATIC CONST UINT32* CacheSize;
+
+STATIC CONST UINT8* PpttStartPointer;
+
+STATIC SHELL_FILE_HANDLE mDotFileHandle;
+
STATIC ACPI_DESCRIPTION_HEADER_INFO AcpiHdrInfo;

/**
@@ -198,8 +210,9 @@ STATIC CONST ACPI_PARSER ProcessorHierarchyNodeStructureParser[] = {
{L"Length", 1, 1, L"%d", NULL, NULL, NULL, NULL},
{L"Reserved", 2, 2, L"0x%x", NULL, NULL, NULL, NULL},

- {L"Flags", 4, 4, L"0x%x", NULL, NULL, NULL, NULL},
- {L"Parent", 4, 8, L"0x%x", NULL, NULL, NULL, NULL},
+ {L"Flags", 4, 4, L"0x%x", NULL, (VOID**)&ProcStructFlags, NULL, NULL},
+ {L"Parent", 4, 8, L"0x%x", NULL,
+ (VOID**)&ProcessorHierarchyParent, NULL, NULL},
{L"ACPI Processor ID", 4, 12, L"0x%x", NULL, NULL, NULL, NULL},
{L"Number of private resources", 4, 16, L"%d", NULL,
(VOID**)&NumberOfPrivateResources, NULL, NULL}
@@ -214,11 +227,13 @@ STATIC CONST ACPI_PARSER CacheTypeStructureParser[] = {
{L"Reserved", 2, 2, L"0x%x", NULL, NULL, NULL, NULL},

{L"Flags", 4, 4, L"0x%x", NULL, NULL, NULL, NULL},
- {L"Next Level of Cache", 4, 8, L"0x%x", NULL, NULL, NULL, NULL},
- {L"Size", 4, 12, L"0x%x", NULL, NULL, NULL, NULL},
+ {L"Next Level of Cache", 4, 8, L"0x%x", NULL,
+ (VOID**)&NextLevelOfCache, NULL, NULL},
+ {L"Size", 4, 12, L"0x%x", NULL, (VOID**)&CacheSize, NULL, NULL},
{L"Number of sets", 4, 16, L"%d", NULL, NULL, ValidateCacheNumberOfSets, NULL},
{L"Associativity", 1, 20, L"%d", NULL, NULL, ValidateCacheAssociativity, NULL},
- {L"Attributes", 1, 21, L"0x%x", NULL, NULL, ValidateCacheAttributes, NULL},
+ {L"Attributes", 1, 21, L"0x%x", NULL, (VOID**)&CacheAttributes,
+ ValidateCacheAttributes, NULL},
{L"Line size", 2, 22, L"%d", NULL, NULL, ValidateCacheLineSize, NULL}
};

@@ -257,6 +272,7 @@ DumpProcessorHierarchyNodeStructure (
UINT32 Offset;
UINT32 Index;
CHAR16 Buffer[OUTPUT_FIELD_COLUMN_WIDTH];
+ CONST UINT8* TypePtr;

Offset = ParseAcpi (
IS_TRACE_FLAG_SET (ParseFlags),
@@ -291,26 +307,67 @@ DumpProcessorHierarchyNodeStructure (
return;
}

- Index = 0;
+ if (IS_GRAPH_FLAG_SET (ParseFlags)) {
+ if (ProcStructFlags->ProcessorIsAThread) {
+ UnicodeSPrint(Buffer, sizeof (Buffer), L"Thread");
+ } else if (ProcStructFlags->NodeIsALeaf) {
+ UnicodeSPrint(Buffer, sizeof (Buffer), L"Core");
+ } else if (ProcStructFlags->PhysicalPackage) {
+ UnicodeSPrint(Buffer, sizeof (Buffer), L"Physical\\nPackage");
+ } else {
+ UnicodeSPrint(Buffer, sizeof (Buffer), L"Cluster");
+ }
+
+ DotAddNode (
+ mDotFileHandle,
+ (UINT32)(Ptr - PpttStartPointer),
+ DOT_BOX_SQUARE | DOT_COLOR_BLUE | DOT_BOX_ADD_ID_TO_LABEL,
+ Buffer
+ );
+
+ // Add link to parent node.
+ if (*ProcessorHierarchyParent != 0) {
+ DotAddLink (
+ mDotFileHandle,
+ (UINT32)(Ptr - PpttStartPointer),
+ *ProcessorHierarchyParent,
+ 0x0
+ );
+ }
+ }

// Parse the specified number of private resource references or the Processor
// Hierarchy Node length. Whichever is minimum.
- while (Index < *NumberOfPrivateResources) {
- UnicodeSPrint (
- Buffer,
- sizeof (Buffer),
- L"Private resources [%d]",
- Index
- );
+ for (Index = 0; Index < *NumberOfPrivateResources; Index++) {
+ if (IS_TRACE_FLAG_SET (ParseFlags)) {
+ UnicodeSPrint (
+ Buffer,
+ sizeof (Buffer),
+ L"Private resources [%d]",
+ Index
+ );

- PrintFieldName (4, Buffer);
- Print (
- L"0x%x\n",
- *((UINT32*)(Ptr + Offset))
- );
+ PrintFieldName (4, Buffer);
+ Print (
+ L"0x%x\n",
+ *((UINT32*)(Ptr + Offset))
+ );
+ }
+
+ if (IS_GRAPH_FLAG_SET (ParseFlags)) {
+ TypePtr = PpttStartPointer + *((UINT32*)(Ptr + Offset));
+ if (*TypePtr == EFI_ACPI_6_2_PPTT_TYPE_ID) {
+ continue;
+ }
+ DotAddLink (
+ mDotFileHandle,
+ *((UINT32*)(Ptr + Offset)),
+ (UINT32)(Ptr - PpttStartPointer),
+ DOT_ARROW_RANK_REVERSE
+ );
+ }

Offset += sizeof (UINT32);
- Index++;
}
}

@@ -329,6 +386,8 @@ DumpCacheTypeStructure (
IN UINT8 Length
)
{
+ CHAR16 LabelBuffer[64];
+
ParseAcpi (
IS_TRACE_FLAG_SET (ParseFlags),
2,
@@ -337,6 +396,88 @@ DumpCacheTypeStructure (
Length,
PARSER_PARAMS (CacheTypeStructureParser)
);
+
+ if (IS_GRAPH_FLAG_SET (ParseFlags)) {
+ // Create cache node
+
+ // Start node label with type of cache
+ switch (CacheAttributes->CacheType) {
+ case EFI_ACPI_6_3_CACHE_ATTRIBUTES_CACHE_TYPE_DATA:
+ UnicodeSPrint (
+ LabelBuffer,
+ sizeof (LabelBuffer),
+ L"D-Cache\\n"
+ );
+ break;
+ case EFI_ACPI_6_3_CACHE_ATTRIBUTES_CACHE_TYPE_INSTRUCTION:
+ UnicodeSPrint (
+ LabelBuffer,
+ sizeof (LabelBuffer),
+ L"I-Cache\\n"
+ );
+ break;
+ default:
+ UnicodeSPrint (
+ LabelBuffer,
+ sizeof (LabelBuffer),
+ L"Unified Cache\\n"
+ );
+ }
+
+ // Add size of cache to node label
+ if (((*CacheSize) & 0xfff00000) != 0) {
+ UnicodeSPrint (
+ LabelBuffer,
+ sizeof (LabelBuffer),
+ L"%s%dMiB",
+ LabelBuffer,
+ *CacheSize >> 20
+ );
+ }
+ if ((*CacheSize & 0xffc00) != 0) {
+ UnicodeSPrint (
+ LabelBuffer,
+ sizeof (LabelBuffer),
+ L"%s%dkiB",
+ LabelBuffer,
+ (*CacheSize >> 10) & 0x3ff
+ );
+ }
+ if ((*CacheSize & 0x3ff) != 0) {
+ UnicodeSPrint (
+ LabelBuffer,
+ sizeof (LabelBuffer),
+ L"%s%dB",
+ LabelBuffer,
+ *CacheSize & 0x3ff
+ );
+ }
+ if (*CacheSize == 0) {
+ UnicodeSPrint (
+ LabelBuffer,
+ sizeof (LabelBuffer),
+ L"%s0B",
+ LabelBuffer
+ );
+ }
+
+ //Add node to dot file
+ DotAddNode (
+ mDotFileHandle,
+ (UINT32)(Ptr - PpttStartPointer),
+ DOT_BOX_SQUARE | DOT_COLOR_YELLOW | DOT_BOX_ADD_ID_TO_LABEL,
+ LabelBuffer
+ );
+
+ if (*NextLevelOfCache != 0) {
+ DotAddLink (
+ mDotFileHandle,
+ *NextLevelOfCache,
+ (UINT32)(Ptr - PpttStartPointer),
+ DOT_ARROW_RANK_REVERSE | DOT_COLOR_GRAY
+ );
+ }
+ }
}

/**
@@ -390,13 +531,46 @@ ParseAcpiPptt (
IN UINT8 AcpiTableRevision
)
{
- UINT32 Offset;
- UINT8* ProcessorTopologyStructurePtr;
+ EFI_STATUS Status;
+ UINT32 Offset;
+ UINT8* ProcessorTopologyStructurePtr;
+ CHAR16 Buffer[128];
+ CHAR16 FileNameBuffer[MAX_FILE_NAME_LEN];

- if (!IS_TRACE_FLAG_SET (ParseFlags)) {
+ if (!IS_TRACE_FLAG_SET (ParseFlags) &&
+ !IS_GRAPH_FLAG_SET (ParseFlags)) {
return;
}

+ if (IS_GRAPH_FLAG_SET (ParseFlags)) {
+ Status = GetNewFileName (
+ L"PPTT",
+ L"dot",
+ FileNameBuffer,
+ sizeof (FileNameBuffer)
+ );
+
+ if (EFI_ERROR (Status)) {
+ Print (
+ L"Error: Could not open dot file for PPTT table:\n"
+ L"Could not get a file name."
+ );
+ // Abandonning creation of dot graph by unsetting the flag.
+ // We continue parsing in case trace is set.
+ ParseFlags &= ~PARSE_FLAGS_GRAPH;
+ } else {
+ mDotFileHandle = DotOpenNewFile (FileNameBuffer);
+ if (mDotFileHandle == NULL) {
+ Print (L"ERROR: Could not open dot file for PPTT table.\n");
+ // Abandonning creation of dot graph by unsetting the flag.
+ // We continue parsing in case trace is set.
+ ParseFlags &= ~PARSE_FLAGS_GRAPH;
+ }
+ }
+ }
+
+ PpttStartPointer = Ptr;
+
Offset = ParseAcpi (
IS_TRACE_FLAG_SET (ParseFlags),
0,
@@ -406,6 +580,24 @@ ParseAcpiPptt (
PARSER_PARAMS (PpttParser)
);

+ if (*(AcpiHdrInfo.Revision) < 2 &&
+ IS_GRAPH_FLAG_SET (ParseFlags)) {
+ Print (L"\nWARNING: Dot output may not be consistent for PPTT revisions < 2\n");
+ UnicodeSPrint (
+ Buffer,
+ sizeof (Buffer),
+ L"WARNING: PPTT table revision is %u.\\n" \
+ L"Revisions lower than 2 might lead to incorrect labelling",
+ *(AcpiHdrInfo.Revision)
+ );
+ DotAddNode (
+ mDotFileHandle,
+ 0,
+ DOT_COLOR_RED | DOT_BOX_SQUARE,
+ Buffer
+ );
+ }
+
ProcessorTopologyStructurePtr = Ptr + Offset;

while (Offset < AcpiTableLength) {
@@ -486,4 +678,8 @@ ParseAcpiPptt (
ProcessorTopologyStructurePtr += *ProcessorTopologyStructureLength;
Offset += *ProcessorTopologyStructureLength;
} // while
+
+ if (IS_GRAPH_FLAG_SET (ParseFlags)) {
+ DotCloseFile (mDotFileHandle);
+ }
}
--
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")


[PATCH v2 2/5] ShellPkg: add a helper function for getting a new file name

Joey Gouly
 

From: Marc Moisson-Franckhauser <marc.moisson-franckhauser@arm.com>

Bugzilla: 3378 (https://bugzilla.tianocore.org/show_bug.cgi?id=3378)

This new helper will not overwrite existing files, by appending a number
to the end of the filename.

Signed-off-by: Joey Gouly <joey.gouly@arm.com>
---
ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h | 25 +++++-
ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c | 80 ++++++++++++++++----
2 files changed, 91 insertions(+), 14 deletions(-)

diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h
index d5b95f5ee707de18be1879b3cd235d6c5db11d9f..ae8a67b7681033d66d068341ae489ded67de8b44 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.h
@@ -1,12 +1,13 @@
/** @file
Header file for AcpiView

- Copyright (c) 2016 - 2020, ARM Limited. All rights reserved.
+ Copyright (c) 2016 - 2021, Arm Limited. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
**/

#ifndef ACPIVIEW_H_
#define ACPIVIEW_H_
+#include <Library/ShellLib.h>

/**
A macro to define the max file name length
@@ -23,6 +24,28 @@
**/
#define RSDP_LENGTH_OFFSET 20

+/**
+ This function finds a filename not already used by adding a number in between
+ the BaseFileName and the extension.
+
+ Make sure the buffer FileName is big enough before calling the function. A
+ size of MAX_FILE_NAME_LEN is recommended.
+
+ @param [in] BaseFileName Start of the desired file name.
+ @param [in] Extension Extension of the desired file name
+ (without '.').
+ @param [in, out] FileName Preallocated buffer for the returned file
+ name.
+ @param [in] FileNameBufferLen Size of FileName buffer..
+**/
+EFI_STATUS
+GetNewFileName (
+ IN CONST CHAR16* BaseFileName,
+ IN CONST CHAR16* Extension,
+ IN OUT CHAR16* FileName,
+ IN UINT32 FileNameBufferLen
+ );
+
/**
This function resets the ACPI table error counter to Zero.
**/
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
index a4242ba9d99b05d07c829520c4011439445aadb0..db7b2e2a30525cc85a333b93f5eb97ec3a517b37 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiView.c
@@ -27,8 +27,55 @@
#include "Arm/SbbrValidator.h"
#endif

-STATIC UINT32 mTableCount;
-STATIC UINT32 mBinTableCount;
+STATIC UINT32 mTableCount;
+
+/**
+ This function finds a filename not already used by adding a number in between
+ The BaseFileName and the extension.
+
+ Make sure the buffer FileName is big enough before calling the function. A
+ size of MAX_FILE_NAME_LEN is recommended.
+
+ @param [in] BaseFileName Start of the desired file name.
+ @param [in] Extension Extension of the desired file name
+ (without '.').
+ @param [in, out] FileName Preallocated buffer for the returned file
+ name.
+ @param [in] FileNameBufferLen Size of FileName buffer..
+**/
+EFI_STATUS
+GetNewFileName (
+ IN CONST CHAR16* BaseFileName,
+ IN CONST CHAR16* Extension,
+ IN OUT CHAR16* FileName,
+ IN UINT32 FileNameBufferLen
+ )
+{
+ UINT16 Index;
+ EFI_STATUS Status;
+ SHELL_FILE_HANDLE tmpFileHandle;
+ for (Index = 0; Index <= 99; Index++) {
+ UnicodeSPrint(
+ FileName,
+ FileNameBufferLen,
+ L"%s%02d.%s",
+ BaseFileName,
+ Index,
+ Extension
+ );
+ Status = ShellOpenFileByName (
+ FileName,
+ &tmpFileHandle,
+ EFI_FILE_MODE_READ,
+ 0
+ );
+ if (Status == EFI_NOT_FOUND) {
+ return EFI_SUCCESS;
+ }
+ ShellCloseFile (&tmpFileHandle);
+ }
+ return EFI_OUT_OF_RESOURCES;
+}

/**
This function dumps the ACPI table to a file.
@@ -46,19 +93,27 @@ DumpAcpiTableToFile (
IN CONST UINTN Length
)
{
- CHAR16 FileNameBuffer[MAX_FILE_NAME_LEN];
- UINTN TransferBytes;
- SELECTED_ACPI_TABLE *SelectedTable;
+ CHAR16 FileNameBuffer[MAX_FILE_NAME_LEN];
+ UINTN TransferBytes;
+ EFI_STATUS Status;
+ SELECTED_ACPI_TABLE* SelectedTable;

GetSelectedAcpiTable (&SelectedTable);

- UnicodeSPrint (
- FileNameBuffer,
- sizeof (FileNameBuffer),
- L".\\%s%04d.bin",
- SelectedTable->Name,
- mBinTableCount++
- );
+ Status = GetNewFileName (
+ SelectedTable->Name,
+ L"bin",
+ FileNameBuffer,
+ sizeof (FileNameBuffer)
+ );
+ if (EFI_ERROR (Status)) {
+ Print (
+ L"Error: Could not open bin file for %s table:\n"
+ L"Could not get a file name.",
+ SelectedTable->Name
+ );
+ return FALSE;
+ }

Print (L"Dumping ACPI table to : %s ... ", FileNameBuffer);

@@ -207,7 +262,6 @@ AcpiView (

// Reset Table counts
mTableCount = 0;
- mBinTableCount = 0;

// Reset The error/warning counters
ResetErrorCount ();
--
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")


[PATCH v2 4/5] ShellPkg: add dot file generator functions

Joey Gouly
 

From: Marc Moisson-Franckhauser <marc.moisson-franckhauser@arm.com>

Bugzilla: 3378 (https://bugzilla.tianocore.org/show_bug.cgi?id=3378)

These can be used to generate dot files, that can be used to visualise
graphs in tables, such as PPTT.

Signed-off-by: Joey Gouly <joey.gouly@arm.com>
---
ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf | 4 +-
ShellPkg/Library/UefiShellAcpiViewCommandLib/DotGenerator.h | 101 +++++++
ShellPkg/Library/UefiShellAcpiViewCommandLib/DotGenerator.c | 283 ++++++++++++++++++++
3 files changed, 387 insertions(+), 1 deletion(-)

diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf
index 63fc5a1281a894841dac704484c3d4f9481edb46..ffe4979b3ac5d0120bcf678cf7823afac6674e4f 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/UefiShellAcpiViewCommandLib.inf
@@ -1,7 +1,7 @@
## @file
# Provides Shell 'acpiview' command functions
#
-# Copyright (c) 2016 - 2020, Arm Limited. All rights reserved.<BR>
+# Copyright (c) 2016 - 2021, Arm Limited. All rights reserved.<BR>
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
@@ -27,6 +27,8 @@ [Sources.common]
AcpiView.h
AcpiViewConfig.c
AcpiViewConfig.h
+ DotGenerator.c
+ DotGenerator.h
Parsers/Aest/AestParser.c
Parsers/Bgrt/BgrtParser.c
Parsers/Dbg2/Dbg2Parser.c
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/DotGenerator.h b/ShellPkg/Library/UefiShellAcpiViewCommandLib/DotGenerator.h
new file mode 100644
index 0000000000000000000000000000000000000000..8e196eee75417c0a422023c00b043441076ac599
--- /dev/null
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/DotGenerator.h
@@ -0,0 +1,101 @@
+/** @file
+ Header file for Dot File Generation
+
+ Copyright (c) 2021, Arm Limited. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#ifndef DOT_GENERATOR_H_
+#define DOT_GENERATOR_H_
+
+#include <Protocol/Shell.h>
+
+#define DOT_COLOR_MASK 0b111
+// Flags for color of arrow or node.
+#define DOT_COLOR_BLACK 0b000 // default
+#define DOT_COLOR_GRAY 0b001
+#define DOT_COLOR_BLUE 0b010
+#define DOT_COLOR_YELLOW 0b011
+#define DOT_COLOR_RED 0b100
+
+#define DOT_ARROW_TYPE_MASK 0b1000
+// Flags for style of arrow.
+#define DOT_ARROW_FULL 0b0000 // default
+#define DOT_ARROW_DOTTED 0b1000
+
+// Flag for reversing how the nodes will be ranked and displayed.
+#define DOT_ARROW_RANK_REVERSE 0b10000
+
+#define DOT_BOX_TYPE_MASK 0b1100000
+// Flag for shape of box
+#define DOT_BOX_SQUARE 0b0000000 // default
+#define DOT_BOX_DIAMOND 0b0100000
+
+// Flag for adding the node's ID to the end of the label.
+#define DOT_BOX_ADD_ID_TO_LABEL 0b10000000
+
+// Valid flags for DotAddNode.
+#define DOT_BOX_FLAGS_MASK (DOT_COLOR_MASK |\
+ DOT_BOX_TYPE_MASK |\
+ DOT_BOX_ADD_ID_TO_LABEL)
+// Valid flags for DotAddLink.
+#define DOT_ARROW_FLAGS_MASK (DOT_COLOR_MASK |\
+ DOT_ARROW_TYPE_MASK |\
+ DOT_ARROW_RANK_REVERSE)
+
+
+/**
+ Opens a new dot file and writes a dot directional graph.
+
+ @param [in] FileName Null terminated unicode string.
+**/
+SHELL_FILE_HANDLE
+DotOpenNewFile (
+ IN CHAR16* FileName
+ );
+
+/**
+ Writes a dot graph footer and closes the dot file.
+
+ @param [in] DotFileHandle The handle of the dot file.
+**/
+VOID
+DotCloseFile (
+ SHELL_FILE_HANDLE DotFileHandle
+ );
+
+/**
+ Writes a line in the previously opened dot file describing a
+ new node.
+
+ @param [in] DotFileHandle The handle of the dot file.
+ @param [in] Id A unique identifier for the node.
+ @param [in] Flags Flags describing the node's characteristics.
+ @param [in] Label Label to be shown on the graph node.
+**/
+VOID
+DotAddNode (
+ SHELL_FILE_HANDLE DotFileHandle,
+ IN UINT32 Id,
+ IN UINT16 Flags,
+ IN CONST CHAR16* Label
+ );
+
+/**
+ Writes a line in the previously opened dot file describing a
+ new link between two nodes.
+
+ @param [in] DotFileHandle The handle of the dot file.
+ @param [in] IdSource An identifier for the source node of the link.
+ @param [in] IdTarget An identifier for the target node of the link.
+ @param [in] Flags Flags describing the node's characteristics.
+**/
+VOID
+DotAddLink (
+ SHELL_FILE_HANDLE DotFileHandle,
+ IN UINT32 IdSource,
+ IN UINT32 IdTarget,
+ IN UINT16 Flags
+ );
+
+#endif // DOT_GENERATOR_H_
diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/DotGenerator.c b/ShellPkg/Library/UefiShellAcpiViewCommandLib/DotGenerator.c
new file mode 100644
index 0000000000000000000000000000000000000000..e19b17537ca85babca5cda38025ae95701ff794f
--- /dev/null
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/DotGenerator.c
@@ -0,0 +1,283 @@
+/** @file
+ Dot File Generator
+
+ Copyright (c) 2021, Arm Limited. All rights reserved.
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+**/
+
+#include <Library/BaseLib.h>
+#include <Library/UefiLib.h>
+#include <Library/DebugLib.h>
+#include <Library/PrintLib.h>
+#include "DotGenerator.h"
+#include "AcpiView.h"
+
+#define MAX_DOT_BUFFER_SIZE 128
+
+/**
+ Writes a Null terminated ASCII string to the dot file handle.
+
+ @param [in] DotFileHandle The handle of the dot file.
+ @param [in] String Null terminated ascii string.
+**/
+STATIC
+VOID
+DotWriteFile (
+ SHELL_FILE_HANDLE DotFileHandle,
+ IN CHAR8* String
+ )
+{
+ UINTN TransferBytes;
+ EFI_STATUS Status;
+
+ if (DotFileHandle == NULL) {
+ Print (L"ERROR: Failed to write to dot file\n");
+ ASSERT (0);
+ return;
+ }
+
+ TransferBytes = AsciiStrLen (String);
+ Status = ShellWriteFile (
+ DotFileHandle,
+ &TransferBytes,
+ String
+ );
+ ASSERT_EFI_ERROR (Status);
+ ASSERT (AsciiStrLen (String) == TransferBytes);
+}
+
+/**
+ Writes a new parameter to a previously started parameter list.
+
+ @param [in] DotFileHandle The handle of the dot file.
+ @param [in] Name Null terminated string of the parameter's name.
+ @param [in] Value Null terminated string of the parameter's value.
+ @param [in] Quoted True if value needs to be quoted.
+**/
+STATIC
+VOID
+DotAddParameter (
+ SHELL_FILE_HANDLE DotFileHandle,
+ IN CHAR16* Name,
+ IN CHAR16* Value,
+ IN BOOLEAN Quoted
+ )
+{
+ CHAR8 StringBuffer[MAX_DOT_BUFFER_SIZE];
+
+ ASSERT(DotFileHandle != NULL);
+
+ if (Quoted) {
+ AsciiSPrint (
+ StringBuffer,
+ sizeof (StringBuffer),
+ "[%s=\"%s\"]",
+ Name,
+ Value
+ );
+ } else {
+ AsciiSPrint (
+ StringBuffer,
+ sizeof (StringBuffer),
+ "[%s=%s]",
+ Name,
+ Value
+ );
+ }
+
+ DotWriteFile (DotFileHandle, StringBuffer);
+}
+
+/**
+ Writes the color argument of nodes or links according to flags.
+
+ @param [in] DotFileHandle The handle of the dot file.
+ @param [in] Flags Flags describing the color (one of DOT_COLOR_...)
+**/
+STATIC
+VOID
+WriteColor (
+ SHELL_FILE_HANDLE DotFileHandle,
+ IN UINT16 Flags
+ )
+{
+ ASSERT(DotFileHandle != NULL);
+
+ switch (Flags & DOT_COLOR_MASK) {
+ case DOT_COLOR_GRAY:
+ DotAddParameter (DotFileHandle, L"color", L"gray", FALSE);
+ break;
+ case DOT_COLOR_YELLOW:
+ DotAddParameter (DotFileHandle, L"color", L"yellow", FALSE);
+ break;
+ case DOT_COLOR_BLUE:
+ DotAddParameter (DotFileHandle, L"color", L"blue", FALSE);
+ break;
+ case DOT_COLOR_RED:
+ DotAddParameter (DotFileHandle, L"color", L"red", FALSE);
+ break;
+ case DOT_COLOR_BLACK:
+ default:
+ DotAddParameter (DotFileHandle, L"color", L"black", FALSE);
+ break;
+ }
+}
+
+/**
+ Opens a new dot file and writes a dot directional graph.
+
+ @param [in] FileName Null terminated unicode string.
+**/
+SHELL_FILE_HANDLE
+DotOpenNewFile (
+ IN CHAR16* FileName
+ )
+{
+ SHELL_FILE_HANDLE DotFileHandle;
+ EFI_STATUS Status;
+
+ Status = ShellOpenFileByName (
+ FileName,
+ &DotFileHandle,
+ EFI_FILE_MODE_READ | EFI_FILE_MODE_WRITE | EFI_FILE_MODE_CREATE,
+ 0
+ );
+ if (EFI_ERROR (Status)) {
+ Print (L"ERROR: Couldn't open dot file");
+ return NULL;//Status;
+ }
+ Print (L"Creating DOT Graph in : %s... ", FileName);
+ DotWriteFile (DotFileHandle, "digraph {\n\trankdir=BT\n");
+ return DotFileHandle;
+}
+
+/**
+ Writes a dot graph footer and closes the dot file.
+
+ @param [in] DotFileHandle The handle of the dot file.
+**/
+VOID
+DotCloseFile (
+ SHELL_FILE_HANDLE DotFileHandle
+ )
+{
+ ASSERT(DotFileHandle != NULL);
+
+ DotWriteFile (DotFileHandle, "}\n");
+ ShellCloseFile (&DotFileHandle);
+ Print (L"Done.\n");
+}
+
+/**
+ Writes a line in the previously opened dot file describing a
+ new node.
+
+ @param [in] DotFileHandle The handle of the dot file.
+ @param [in] Id A unique identifier for the node.
+ @param [in] Flags Flags describing the node's characteristics.
+ @param [in] Label Label to be shown on the graph node.
+**/
+VOID
+DotAddNode (
+ SHELL_FILE_HANDLE DotFileHandle,
+ IN UINT32 Id,
+ IN UINT16 Flags,
+ IN CONST CHAR16* Label
+ )
+{
+ CHAR8 LineBuffer[64];
+ CHAR16 LabelBuffer[MAX_DOT_BUFFER_SIZE];
+
+ ASSERT ((Flags & ~DOT_BOX_FLAGS_MASK) == 0);
+ ASSERT(DotFileHandle != NULL);
+
+ AsciiSPrint (
+ LineBuffer,
+ sizeof (LineBuffer),
+ "\tx%x",
+ Id
+ );
+ DotWriteFile (DotFileHandle, LineBuffer);
+
+ switch (Flags & DOT_BOX_TYPE_MASK) {
+ case DOT_BOX_DIAMOND:
+ DotAddParameter (DotFileHandle, L"shape", L"diamond", FALSE);
+ break;
+ case DOT_BOX_SQUARE:
+ default:
+ DotAddParameter (DotFileHandle, L"shape", L"box", FALSE);
+ break;
+ }
+
+ if (Label != NULL) {
+ if ((Flags & DOT_BOX_ADD_ID_TO_LABEL) != 0) {
+ UnicodeSPrint (
+ LabelBuffer,
+ sizeof (LabelBuffer),
+ L"%s\\n0x%x",
+ Label,
+ Id
+ );
+ } else {
+ UnicodeSPrint (
+ LabelBuffer,
+ sizeof (LabelBuffer),
+ L"%s",
+ Label
+ );
+ }
+ DotAddParameter (DotFileHandle, L"label", LabelBuffer, TRUE);
+ }
+
+ WriteColor (DotFileHandle, Flags);
+ DotWriteFile (DotFileHandle, "\n");
+}
+
+/**
+ Writes a line in the previously opened dot file describing a
+ new link between two nodes.
+
+ @param [in] DotFileHandle The handle of the dot file.
+ @param [in] IdSource An identifier for the source node of the link.
+ @param [in] IdTarget An identifier for the target node of the link.
+ @param [in] Flags Flags describing the node's characteristics.
+**/
+VOID
+DotAddLink (
+ SHELL_FILE_HANDLE DotFileHandle,
+ IN UINT32 IdSource,
+ IN UINT32 IdTarget,
+ IN UINT16 Flags
+ )
+{
+ CHAR8 LineBuffer[64];
+
+ ASSERT(DotFileHandle != NULL);
+ ASSERT ((Flags & ~DOT_ARROW_FLAGS_MASK) == 0);
+
+ AsciiSPrint (
+ LineBuffer,
+ sizeof (LineBuffer),
+ "\tx%x -> x%x",
+ IdSource,
+ IdTarget
+ );
+ DotWriteFile (DotFileHandle, LineBuffer);
+
+ if ((Flags & DOT_ARROW_RANK_REVERSE) != 0) {
+ DotAddParameter (DotFileHandle, L"dir", L"back", FALSE);
+ }
+
+ switch (Flags & DOT_ARROW_TYPE_MASK) {
+ case DOT_ARROW_DOTTED:
+ DotAddParameter (DotFileHandle, L"style", L"dotted", FALSE);
+ break;
+ case DOT_ARROW_FULL:
+ default:
+ DotAddParameter (DotFileHandle, L"style", L"solid", FALSE);
+ break;
+ }
+
+ WriteColor (DotFileHandle, Flags);
+ DotWriteFile (DotFileHandle, "\n");
+}
--
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")


Re: [PATCH v2] UefiCpuPkg: SecCoreNative without ResetVector

Marvin Häuser
 

This will also help with PE file alignment in FD, as SecCore no longer needs to be pinned to the very top. Thank you!

Best regards,
Marvin

On 16/09/2021 16:26, Ashraf Ali S wrote:
REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3492

Currently SecCore.inf having the resetvector code under IA32. if the
user wants to use both SecCore and UefiCpuPkg ResetVector it's not
possible, since SecCore and ResetVector(VTF0.INF/ResetVector.inf)
are sharing the same GUID which is BFV. to overcome this issue we can
create the Duplicate version of the SecCore.inf as SecCoreNative.inf
which contains pure SecCore Native functionality without resetvector.
SecCoreNative.inf should have the Unique GUID so that it can be used
along with UefiCpuPkg ResetVector in there implementation.

Cc: Ray Ni <ray.ni@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Cc: Debkumar De <debkumar.de@intel.com>
Cc: Harry Han <harry.han@intel.com>
Cc: Catharine West <catharine.west@intel.com>
Cc: Digant H Solanki <digant.h.solanki@intel.com>
Cc: Sangeetha V <sangeetha.v@intel.com>

Signed-off-by: Ashraf Ali S <ashraf.ali.s@intel.com>
---
UefiCpuPkg/SecCore/SecCoreNative.inf | 80 ++++++++++++++++++++++++++++
UefiCpuPkg/UefiCpuPkg.dsc | 1 +
2 files changed, 81 insertions(+)
create mode 100644 UefiCpuPkg/SecCore/SecCoreNative.inf

diff --git a/UefiCpuPkg/SecCore/SecCoreNative.inf b/UefiCpuPkg/SecCore/SecCoreNative.inf
new file mode 100644
index 0000000000..b528c59879
--- /dev/null
+++ b/UefiCpuPkg/SecCore/SecCoreNative.inf
@@ -0,0 +1,80 @@
+## @file
+# SecCoreNative module that implements the SEC phase.
+#
+# This is the first module taking control after the reset vector.
+# The entry point function is _ModuleEntryPoint in PlatformSecLib.
+# The entry point function starts in 32bit protected mode or 64bit
+# mode depending on how resetvector is implemented, enables
+# temporary memory and calls into SecStartup().
+#
+# Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = SecCoreNative
+ MODULE_UNI_FILE = SecCore.uni
+ FILE_GUID = 43CA74CA-7D29-49A0-B3B9-20F84015B27D
+ MODULE_TYPE = SEC
+ VERSION_STRING = 1.0
+
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64 EBC
+#
+
+[Sources]
+ SecMain.c
+ SecMain.h
+ FindPeiCore.c
+ SecBist.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ UefiCpuPkg/UefiCpuPkg.dec
+
+[LibraryClasses]
+ BaseMemoryLib
+ DebugLib
+ PlatformSecLib
+ PcdLib
+ DebugAgentLib
+ UefiCpuLib
+ PeCoffGetEntryPointLib
+ PeCoffExtraActionLib
+ CpuExceptionHandlerLib
+ ReportStatusCodeLib
+ PeiServicesLib
+ PeiServicesTablePointerLib
+ HobLib
+
+[Ppis]
+ ## SOMETIMES_CONSUMES
+ ## PRODUCES
+ gEfiSecPlatformInformationPpiGuid
+ ## SOMETIMES_CONSUMES
+ ## SOMETIMES_PRODUCES
+ gEfiSecPlatformInformation2PpiGuid
+ gEfiTemporaryRamDonePpiGuid ## PRODUCES
+ ## NOTIFY
+ ## SOMETIMES_CONSUMES
+ gPeiSecPerformancePpiGuid
+ gEfiPeiCoreFvLocationPpiGuid
+ ## CONSUMES
+ gRepublishSecPpiPpiGuid
+
+[Guids]
+ ## SOMETIMES_PRODUCES ## HOB
+ gEfiFirmwarePerformanceGuid
+
+[Pcd]
+ gUefiCpuPkgTokenSpaceGuid.PcdPeiTemporaryRamStackSize ## CONSUMES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdMigrateTemporaryRamFirmwareVolumes ## CONSUMES
+
+[UserExtensions.TianoCore."ExtraFiles"]
+ SecCoreExtra.uni
diff --git a/UefiCpuPkg/UefiCpuPkg.dsc b/UefiCpuPkg/UefiCpuPkg.dsc
index 699c91626b..870b452840 100644
--- a/UefiCpuPkg/UefiCpuPkg.dsc
+++ b/UefiCpuPkg/UefiCpuPkg.dsc
@@ -161,6 +161,7 @@
UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPei.inf
UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationSmm.inf
UefiCpuPkg/SecCore/SecCore.inf
+ UefiCpuPkg/SecCore/SecCoreNative.inf
UefiCpuPkg/SecMigrationPei/SecMigrationPei.inf
UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf
UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf {


[PATCH v2] UefiCpuPkg: SecCoreNative without ResetVector

Ashraf Ali S
 

REF:https://bugzilla.tianocore.org/show_bug.cgi?id=3492

Currently SecCore.inf having the resetvector code under IA32. if the
user wants to use both SecCore and UefiCpuPkg ResetVector it's not
possible, since SecCore and ResetVector(VTF0.INF/ResetVector.inf)
are sharing the same GUID which is BFV. to overcome this issue we can
create the Duplicate version of the SecCore.inf as SecCoreNative.inf
which contains pure SecCore Native functionality without resetvector.
SecCoreNative.inf should have the Unique GUID so that it can be used
along with UefiCpuPkg ResetVector in there implementation.

Cc: Ray Ni <ray.ni@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Cc: Debkumar De <debkumar.de@intel.com>
Cc: Harry Han <harry.han@intel.com>
Cc: Catharine West <catharine.west@intel.com>
Cc: Digant H Solanki <digant.h.solanki@intel.com>
Cc: Sangeetha V <sangeetha.v@intel.com>

Signed-off-by: Ashraf Ali S <ashraf.ali.s@intel.com>
---
UefiCpuPkg/SecCore/SecCoreNative.inf | 80 ++++++++++++++++++++++++++++
UefiCpuPkg/UefiCpuPkg.dsc | 1 +
2 files changed, 81 insertions(+)
create mode 100644 UefiCpuPkg/SecCore/SecCoreNative.inf

diff --git a/UefiCpuPkg/SecCore/SecCoreNative.inf b/UefiCpuPkg/SecCore/SecCoreNative.inf
new file mode 100644
index 0000000000..b528c59879
--- /dev/null
+++ b/UefiCpuPkg/SecCore/SecCoreNative.inf
@@ -0,0 +1,80 @@
+## @file
+# SecCoreNative module that implements the SEC phase.
+#
+# This is the first module taking control after the reset vector.
+# The entry point function is _ModuleEntryPoint in PlatformSecLib.
+# The entry point function starts in 32bit protected mode or 64bit
+# mode depending on how resetvector is implemented, enables
+# temporary memory and calls into SecStartup().
+#
+# Copyright (c) 2021, Intel Corporation. All rights reserved.<BR>
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = SecCoreNative
+ MODULE_UNI_FILE = SecCore.uni
+ FILE_GUID = 43CA74CA-7D29-49A0-B3B9-20F84015B27D
+ MODULE_TYPE = SEC
+ VERSION_STRING = 1.0
+
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES = IA32 X64 EBC
+#
+
+[Sources]
+ SecMain.c
+ SecMain.h
+ FindPeiCore.c
+ SecBist.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ UefiCpuPkg/UefiCpuPkg.dec
+
+[LibraryClasses]
+ BaseMemoryLib
+ DebugLib
+ PlatformSecLib
+ PcdLib
+ DebugAgentLib
+ UefiCpuLib
+ PeCoffGetEntryPointLib
+ PeCoffExtraActionLib
+ CpuExceptionHandlerLib
+ ReportStatusCodeLib
+ PeiServicesLib
+ PeiServicesTablePointerLib
+ HobLib
+
+[Ppis]
+ ## SOMETIMES_CONSUMES
+ ## PRODUCES
+ gEfiSecPlatformInformationPpiGuid
+ ## SOMETIMES_CONSUMES
+ ## SOMETIMES_PRODUCES
+ gEfiSecPlatformInformation2PpiGuid
+ gEfiTemporaryRamDonePpiGuid ## PRODUCES
+ ## NOTIFY
+ ## SOMETIMES_CONSUMES
+ gPeiSecPerformancePpiGuid
+ gEfiPeiCoreFvLocationPpiGuid
+ ## CONSUMES
+ gRepublishSecPpiPpiGuid
+
+[Guids]
+ ## SOMETIMES_PRODUCES ## HOB
+ gEfiFirmwarePerformanceGuid
+
+[Pcd]
+ gUefiCpuPkgTokenSpaceGuid.PcdPeiTemporaryRamStackSize ## CONSUMES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdMigrateTemporaryRamFirmwareVolumes ## CONSUMES
+
+[UserExtensions.TianoCore."ExtraFiles"]
+ SecCoreExtra.uni
diff --git a/UefiCpuPkg/UefiCpuPkg.dsc b/UefiCpuPkg/UefiCpuPkg.dsc
index 699c91626b..870b452840 100644
--- a/UefiCpuPkg/UefiCpuPkg.dsc
+++ b/UefiCpuPkg/UefiCpuPkg.dsc
@@ -161,6 +161,7 @@
UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationPei.inf
UefiCpuPkg/PiSmmCommunication/PiSmmCommunicationSmm.inf
UefiCpuPkg/SecCore/SecCore.inf
+ UefiCpuPkg/SecCore/SecCoreNative.inf
UefiCpuPkg/SecMigrationPei/SecMigrationPei.inf
UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf
UefiCpuPkg/PiSmmCpuDxeSmm/PiSmmCpuDxeSmm.inf {
--
2.30.2.windows.1


Cancelled Event: TianoCore Design Meeting - APAC/NAMO - Friday, September 17, 2021 #cal-cancelled

devel@edk2.groups.io Calendar <noreply@...>
 

Cancelled: TianoCore Design Meeting - APAC/NAMO

This event has been cancelled.

When:
Friday, September 17, 2021
9:30am to 10:30am
(UTC+08:00) Asia/Shanghai

Where:
Microsoft Teams

Organizer: Ray Ni ray.ni@...

Description:

TOPIC

  1. NA

For more info, see here: https://www.tianocore.org/design-meeting/


Microsoft Teams meeting

Join on your computer or mobile app

Click here to join the meeting

Join with a video conferencing device

teams@...

Video Conference ID: 119 715 416 0

Alternate VTC dialing instructions

Learn More | Meeting options

5361 - 5380 of 86113