Date   

Re: [PATCH v2 4/7] Platform/ARM/N1Sdp: Enable N1Sdp platform specific configurations

Khasim Mohammed
 

Hi Pierre,

On Wed, Oct 13, 2021 at 02:44 AM, PierreGondois wrote:
Hi Khasim and Deepak,

To check all the required Libraries, Pcds, ... are included correctly,
it is faster to run the CI tests.

The edk2 CI is currently not available for edk2-platforms. I created a
branch that can run the CI on your patch-set at:
https://github.com/PierreARM/edk2-platforms/tree/review/N1Sdp_v2

Can you run the CI and make the required correction ? This patch itself
might not require any but I think some other patches in the serie do.

To run the CI:
-Rebase your master branch and the shared branch on origin/master:
git checkout master && git rebase origin/master
git checkout review/N1Sdp_v2 && git rebase origin/master
-Run the CI
stuart_setup -c .pytool/CISettings.py TOOL_CHAIN_TAG=GCC5
stuart_update -c .pytool/CISettings.py TOOL_CHAIN_TAG=GCC5
stuart_ci_build -c .pytool/CISettings.py TOOL_CHAIN_TAG=GCC5 -a AARCH64
-p N1Sdp

Please let me know if something doesn't works or you have troubles,

If the CI doesn't ask for modifications on this patch, it looks good to me.
I am able to run these tests, it throws few errors for variable names, doxygen style, duplicate GUIDs and coding styles. I will fixes these along with inputs on other patches and post new version this week.

Thanks for the support.

Regards,
Pierre
Regards,
Pierre
On 10/10/21 19:29, Khasim Mohammed via groups.io wrote:
This patch adds PCDs and updates the fdf file for N1Sdp
platform specific configurations.

Signed-off-by: Deepak Pandey <Deepak.Pandey@...>
Signed-off-by: Khasim Syed Mohammed <khasim.mohammed@...>
---
Platform/ARM/N1Sdp/N1SdpPlatform.dec | 98 ++++++++++++++++++++++++++++
Platform/ARM/N1Sdp/N1SdpPlatform.dsc | 28 +++++++-
Platform/ARM/N1Sdp/N1SdpPlatform.fdf | 13 +++-
3 files changed, 136 insertions(+), 3 deletions(-)
create mode 100644 Platform/ARM/N1Sdp/N1SdpPlatform.dec

diff --git a/Platform/ARM/N1Sdp/N1SdpPlatform.dec b/Platform/ARM/N1Sdp/N1SdpPlatform.dec
new file mode 100644
index 0000000000..d56891b985
--- /dev/null
+++ b/Platform/ARM/N1Sdp/N1SdpPlatform.dec
@@ -0,0 +1,98 @@
+## @file
+# Describes the N1Sdp configuration.
+#
+# Copyright (c) 2021, ARM Limited. All rights reserved.<BR>
+#
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+##
+
+[Defines]
+ DEC_SPECIFICATION = 0x0001001A
+ PACKAGE_NAME = N1SdpPlatform
+ PACKAGE_GUID = 29aacb23-61e8-4fe2-8a06-793537cd26e9
+ PACKAGE_VERSION = 0.1
+
+################################################################################
+#
+# Include Section - list of Include Paths that are provided by this package.
+# Comments are used for Keywords and Module Types.
+#
+# Supported Module Types:
+# BASE SEC PEI_CORE PEIM DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SMM_DRIVER DXE_SAL_DRIVER UEFI_DRIVER UEFI_APPLICATION
+#
+################################################################################
+[Includes.common]
+
+[LibraryClasses]
+ ArmPlatformLib|Silicon/ARM/NeoverseN1Soc/Library/PlatformLib/PlatformLib.inf
+
+[Guids.common]
+ gArmN1SdpTokenSpaceGuid = { 0xd8f1624a, 0x98c1, 0x4f64, { 0xa6, 0x41, 0x19, 0x5e, 0xb5, 0x3b, 0x26, 0x0f } }
+
+[PcdsFixedAtBuild]
+ gArmN1SdpTokenSpaceGuid.PcdRamDiskBase|0x88000000|UINT32|0x00000001
+ gArmN1SdpTokenSpaceGuid.PcdRamDiskSize|0x18000000|UINT32|0x00000002
+
+ # PCIe
+ gArmN1SdpTokenSpaceGuid.PcdPcieExpressBaseAddress|0x70000000|UINT32|0x00000007
+
+ # External memory
+ gArmNeoverseN1SocTokenSpaceGuid.PcdExtMemorySpace|0|UINT64|0x00000029
+
+[PcdsFeatureFlag.common]
+ gArmN1SdpTokenSpaceGuid.PcdRamDiskSupported|FALSE|BOOLEAN|0x00000003
+
+[PcdsFixedAtBuild.common]
+ # CoreSight Debug and Trace components
+ # CoreSight ETMs
+ gArmN1SdpTokenSpaceGuid.PcdCsEtm0Base|0x402040000|UINT64|0x0000002D
+ gArmN1SdpTokenSpaceGuid.PcdCsEtm0MaxBase|0x402040FFF|UINT64|0x0000002E
+ gArmN1SdpTokenSpaceGuid.PcdCsEtm1Base|0x402140000|UINT64|0x0000002F
+ gArmN1SdpTokenSpaceGuid.PcdCsEtm1MaxBase|0x402140FFF|UINT64|0x00000030
+ gArmN1SdpTokenSpaceGuid.PcdCsEtm2Base|0x403040000|UINT64|0x00000031
+ gArmN1SdpTokenSpaceGuid.PcdCsEtm2MaxBase|0x403040FFF|UINT64|0x00000032
+ gArmN1SdpTokenSpaceGuid.PcdCsEtm3Base|0x403140000|UINT64|0x00000033
+ gArmN1SdpTokenSpaceGuid.PcdCsEtm3MaxBase|0x403140FFF|UINT64|0x00000034
+
+ # CoreSight TMC (ETRs/ETFs/ETBs)
+ gArmN1SdpTokenSpaceGuid.PcdCsEtf0Base|0x400410000|UINT64|0x00000035
+ gArmN1SdpTokenSpaceGuid.PcdCsEtf0MaxBase|0x400410FFF|UINT64|0x00000036
+ gArmN1SdpTokenSpaceGuid.PcdCsEtf1Base|0x400420000|UINT64|0x00000037
+ gArmN1SdpTokenSpaceGuid.PcdCsEtf1MaxBase|0x400420FFF|UINT64|0x00000038
+ gArmN1SdpTokenSpaceGuid.PcdCsEtf2Base|0x400010000|UINT64|0x00000039
+ gArmN1SdpTokenSpaceGuid.PcdCsEtf2MaxBase|0x400010FFF|UINT64|0x0000003A
+ gArmN1SdpTokenSpaceGuid.PcdCsEtrBase|0x400120000|UINT64|0x00000043
+ gArmN1SdpTokenSpaceGuid.PcdCsEtrMaxBase|0x400120FFF|UINT64|0x00000044
+
+ # CoreSight Dynamic Funnel(s)
+ gArmN1SdpTokenSpaceGuid.PcdCsFunnel0Base|0x4000B0000|UINT64|0x0000003B
+ gArmN1SdpTokenSpaceGuid.PcdCsFunnel0MaxBase|0x4000B0FFF|UINT64|0x0000003C
+ gArmN1SdpTokenSpaceGuid.PcdCsFunnel1Base|0x4000A0000|UINT64|0x0000003D
+ gArmN1SdpTokenSpaceGuid.PcdCsFunnel1MaxBase|0x4000A0FFF|UINT64|0x0000003E
+
+ # CoreSight Dynamic Replicator(s)
+ gArmN1SdpTokenSpaceGuid.PcdCsReplicatorBase|0x400110000|UINT64|0x0000003F
+ gArmN1SdpTokenSpaceGuid.PcdCsReplicatorMaxBase|0x400110FFF|UINT64|0x00000040
+
+ # CoreSight TPIU
+ gArmN1SdpTokenSpaceGuid.PcdCsTpiuBase|0x400130000|UINT64|0x00000041
+ gArmN1SdpTokenSpaceGuid.PcdCsTpiuMaxBase|0x400130FFF|UINT64|0x00000042
+
+ # CoreSight STM and STM Stimulus
+ gArmN1SdpTokenSpaceGuid.PcdCsStmBase|0x400800000|UINT64|0x00000045
+ gArmN1SdpTokenSpaceGuid.PcdCsStmMaxBase|0x400800FFF|UINT64|0x00000046
+ gArmN1SdpTokenSpaceGuid.PcdCsStmStimulusBase|0x4D000000|UINT32|0x00000047
+ gArmN1SdpTokenSpaceGuid.PcdCsStmStimulusSize|0x1000000|UINT32|0x00000048
+
+ # CoreSight Components' Size
+ #
+ # Newton TRMs specify the size for these coresight components as 64K.
+ # The actual size is just 4K though 64K is reserved. Access to the
+ # unmapped reserved region results in a DECERR response.
+ #
+ gArmN1SdpTokenSpaceGuid.PcdCsComponentSize|0x1000|UINT32|0x00000049
+
+ # Remote Chip PCIe
+ gArmN1SdpTokenSpaceGuid.PcdRemotePcieIoTranslation|0x40075200000|UINT64|0x0000004A
+ gArmN1SdpTokenSpaceGuid.PcdRemotePcieMmio32Translation|0x40000000000|UINT64|0x0000004B
+ gArmN1SdpTokenSpaceGuid.PcdRemotePcieMmio64Translation|0x40000000000|UINT64|0x0000004C
diff --git a/Platform/ARM/N1Sdp/N1SdpPlatform.dsc b/Platform/ARM/N1Sdp/N1SdpPlatform.dsc
index 61e7a909f8..d5ada590e1 100644
--- a/Platform/ARM/N1Sdp/N1SdpPlatform.dsc
+++ b/Platform/ARM/N1Sdp/N1SdpPlatform.dsc
@@ -1,8 +1,11 @@
+## @file
+# Component description file specific for N1Sdp
#
-# Copyright (c) 2018 - 2020, ARM Limited. All rights reserved.
+# Copyright (c) 2018 - 2021, ARM Limited. All rights reserved.<BR>
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
#
+##

################################################################################
#
@@ -33,6 +36,9 @@
TimerLib|ArmPkg/Library/ArmArchTimerLib/ArmArchTimerLib.inf
UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf

+ # file explorer library support
+ FileExplorerLib|MdeModulePkg/Library/FileExplorerLib/FileExplorerLib.inf
+
[LibraryClasses.common.SEC]
HobLib|MdePkg/Library/PeiHobLib/PeiHobLib.inf
MemoryAllocationLib|MdePkg/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf
@@ -71,6 +77,9 @@
[LibraryClasses.common.DXE_RUNTIME_DRIVER]
BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf
+!if $(TARGET) != RELEASE
+ DebugLib|MdePkg/Library/DxeRuntimeDebugLibSerialPort/DxeRuntimeDebugLibSerialPort.inf
+!endif

[LibraryClasses.common.UEFI_DRIVER, LibraryClasses.common.UEFI_APPLICATION, LibraryClasses.common.DXE_RUNTIME_DRIVER, LibraryClasses.common.DXE_DRIVER]
PcdLib|MdePkg/Library/DxePcdLib/DxePcdLib.inf
@@ -82,11 +91,16 @@
################################################################################

[PcdsFeatureFlag.common]
+ gArmN1SdpTokenSpaceGuid.PcdRamDiskSupported|TRUE
gEfiMdeModulePkgTokenSpaceGuid.PcdTurnOffUsbLegacySupport|TRUE

[PcdsFixedAtBuild.common]
gArmTokenSpaceGuid.PcdVFPEnabled|1

+ # RAM Disk
+ gArmN1SdpTokenSpaceGuid.PcdRamDiskBase|0x88000000
+ gArmN1SdpTokenSpaceGuid.PcdRamDiskSize|0x18000000
+
# Stacks for MPCores in Normal World
gArmPlatformTokenSpaceGuid.PcdCPUCoresStackBase|0x80000000
gArmPlatformTokenSpaceGuid.PcdCPUCorePrimaryStackSize|0x40000
@@ -99,6 +113,9 @@
# Secondary DDR memory
gArmNeoverseN1SocTokenSpaceGuid.PcdDramBlock2Base|0x8080000000

+ # External memory
+ gArmNeoverseN1SocTokenSpaceGuid.PcdExtMemorySpace|0x40000000000
+
# GIC Base Addresses
gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase|0x2C000000
gArmTokenSpaceGuid.PcdGicDistributorBase|0x30000000
@@ -198,6 +215,9 @@
BaseMemoryLib|MdePkg/Library/BaseMemoryLib/BaseMemoryLib.inf
}

+ # Platform driver
+ Platform/ARM/N1Sdp/Drivers/PlatformDxe/PlatformDxe.inf
+
# Human Interface Support
MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf

@@ -236,6 +256,9 @@
# SATA Controller
MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf

+ # NVMe boot devices
+ MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf
+
# Usb Support
MdeModulePkg/Bus/Pci/UhciDxe/UhciDxe.inf
MdeModulePkg/Bus/Pci/EhciDxe/EhciDxe.inf
@@ -244,3 +267,6 @@
MdeModulePkg/Bus/Usb/UsbKbDxe/UsbKbDxe.inf
MdeModulePkg/Bus/Usb/UsbMassStorageDxe/UsbMassStorageDxe.inf
MdeModulePkg/Bus/Pci/NonDiscoverablePciDeviceDxe/NonDiscoverablePciDeviceDxe.inf
+
+ # RAM Disk
+ MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDxe.inf
diff --git a/Platform/ARM/N1Sdp/N1SdpPlatform.fdf b/Platform/ARM/N1Sdp/N1SdpPlatform.fdf
index c4e1f7b4b8..6b097438ad 100644
--- a/Platform/ARM/N1Sdp/N1SdpPlatform.fdf
+++ b/Platform/ARM/N1Sdp/N1SdpPlatform.fdf
@@ -1,8 +1,10 @@
+## @file
+# FDF file of N1Sdp
#
-# Copyright (c) 2018 - 2020, ARM Limited. All rights reserved.
+# Copyright (c) 2018 - 2021, ARM Limited. All rights reserved.<BR>
#
# SPDX-License-Identifier: BSD-2-Clause-Patent
-#
+##

################################################################################
#
@@ -109,6 +111,9 @@ READ_LOCK_STATUS = TRUE
# SATA Controller
INF MdeModulePkg/Bus/Pci/SataControllerDxe/SataControllerDxe.inf

+ # NVMe boot devices
+ INF MdeModulePkg/Bus/Pci/NvmExpressDxe/NvmExpressDxe.inf
+
# Usb Support
INF MdeModulePkg/Bus/Pci/UhciDxe/UhciDxe.inf
INF MdeModulePkg/Bus/Pci/EhciDxe/EhciDxe.inf
@@ -137,10 +142,14 @@ READ_LOCK_STATUS = TRUE

# FV FileSystem
INF MdeModulePkg/Universal/FvSimpleFileSystemDxe/FvSimpleFileSystemDxe.inf
+ INF MdeModulePkg/Universal/Disk/RamDiskDxe/RamDiskDxe.inf

# UEFI applications
INF ShellPkg/Application/Shell/Shell.inf

+ # Platform driver
+ INF Platform/ARM/N1Sdp/Drivers/PlatformDxe/PlatformDxe.inf
+
# Bds
INF MdeModulePkg/Application/UiApp/UiApp.inf
INF MdeModulePkg/Universal/DevicePathDxe/DevicePathDxe.inf


Update NASM to stable release 2.15.05

Michael D Kinney
 

Hello,

I would like to propose that we update to a newer version of NASM.

https://www.nasm.us/

The most recent stable version is 2.15.05.

https://www.nasm.us/pub/nasm/releasebuilds/2.15.05/

NASM 2.15.05 Documentation:

https://nasm.us/xdoc/2.15.05/html/
https://nasm.us/xdoc/2.15.05/nasmdoc.pdf


The reason to update is to use a version of NASM that supports
newer instructions that will allow the .nasm files with
DB statements for instructions to be updated to use
instruction names. This improves the readability/maintenance
of the .nasm source files:

https://nasm.us/xdoc/2.15.05/html/nasmdocb.html#section-B.1.41

Also, the work on tools such as uncrustify to format source files
require tests to make sure the source format changes do not cause
any functional changes. Compilers support flags for reproducible
builds. NASM 2.15.05 added the --reproducible flag that provides
the same feature for OBJ files produces by NASM.

https://nasm.us/xdoc/2.15.05/html/nasmdoc2.html#section-2.1.34


2.1.34 The --reproducible Option

If this option is given, NASM will not emit information that is
inherently dependent on the NASM version or different from run to
run (such as timestamps) into the output file.

Please let me know if there are any concerns with doing this tool update.
If there are no concerns, I will work on patches required to update
EDK II CI to use NASM 2.15.05 and to update the developer documentation
to require NASM 2.15.05 as the new minimum version.

Thanks,

Mike


Re: [edk2-libc Patch 1/1] AppPkg/Applications/Python: Remove py2.7.2 support from edk2-libc

Michael D Kinney
 

Hi JP,

Can you also update the documentation to remove references to Python 2.x or update for Python 3.x?

For example, the following file has Python 2.x references.

https://github.com/tianocore/edk2-libc/blob/master/AppPkg/Applications/Python/PythonReadMe.txt

Mike

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Jayaprakash, N
Sent: Tuesday, October 19, 2021 8:43 PM
To: devel@edk2.groups.io
Cc: Rebecca Cran <rebecca@...>; Kinney, Michael D <michael.d.kinney@...>; Jayaprakash, N
<n.jayaprakash@...>
Subject: [edk2-devel] [edk2-libc Patch 1/1] AppPkg/Applications/Python: Remove py2.7.2 support from edk2-libc





Re: [PATCH] ShellPkg: Parse I/O APIC and x2APIC structure

Attar, AbdulLateef (Abdul Lateef) <AbdulLateef.Attar@...>
 

[AMD Official Use Only]

Gentle reminder to merge the code.

-----Original Message-----
From: Gao, Zhichao <zhichao.gao@...>
Sent: 09 September 2021 07:54
To: Attar, AbdulLateef (Abdul Lateef) <AbdulLateef.Attar@...>; devel@edk2.groups.io
Cc: Ni, Ray <ray.ni@...>
Subject: RE: [edk2-devel] [PATCH] ShellPkg: Parse I/O APIC and x2APIC structure

[CAUTION: External Email]

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

Thanks,
Zhichao

-----Original Message-----
From: Abdul Lateef Attar <AbdulLateef.Attar@...>
Sent: Tuesday, August 24, 2021 11:30 PM
To: devel@edk2.groups.io
Cc: Ni, Ray <ray.ni@...>; Gao, Zhichao <zhichao.gao@...>;
Abdul Lateef Attar <AbdulLateef.Attar@...>
Subject: [edk2-devel] [PATCH] ShellPkg: Parse I/O APIC and x2APIC
structure

Parse and print the below interrupt structures
- I/O APIC Structure
- Interrupt Source Override Structure
- Processor Local x2APIC Structure
- Local x2APIC NMI Structure

Signed-off-by: Abdul Lateef Attar <AbdulLateef.Attar@...>
---
.../Parsers/Madt/MadtParser.c | 99 +++++++++++++++++++
1 file changed, 99 insertions(+)

diff --git
a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtPars
er.c
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtPars
er.c
index 15aa2392b6..2ba8c9ae52 100644
---
a/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtPars
er.c
+++
b/ShellPkg/Library/UefiShellAcpiViewCommandLib/Parsers/Madt/MadtPars
+++ er.c
@@ -181,6 +181,57 @@ STATIC CONST ACPI_PARSER GicITSParser[] = {
{L"Reserved", 4, 16, L"0x%x", NULL, NULL, NULL, NULL} };

+/**
+ An ACPI_PARSER array describing the IO APIC Structure.
+**/
+STATIC CONST ACPI_PARSER IoApic[] = {
+ {L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL},
+ {L"Length", 1, 1, L"%d", NULL, NULL, NULL, NULL},
+ {L"I/O APIC ID", 1, 2, L"0x%x", NULL, NULL, NULL, NULL},
+ {L"Reserved", 1, 3, L"0x%x", NULL, NULL, NULL, NULL},
+ {L"I/O APIC Address", 4, 4, L"0x%x", NULL, NULL, NULL, NULL},
+ {L"Global System Interrupt Base", 4, 8, L"0x%x", NULL, NULL, NULL,
+NULL} };
+
+/**
+ An ACPI_PARSER array describing the Interrupt Source Override Structure.
+**/
+STATIC CONST ACPI_PARSER InterruptSourceOverride[] = {
+ {L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL},
+ {L"Length", 1, 1, L"%d", NULL, NULL, NULL, NULL},
+ {L"Bus", 1, 2, L"0x%x", NULL, NULL, NULL, NULL},
+ {L"Source", 1, 3, L"0x%x", NULL, NULL, NULL, NULL},
+ {L"Global System Interrupt", 4, 4, L"0x%x", NULL, NULL, NULL,
+NULL},
+ {L"Flags", 2, 8, L"0x%x", NULL, NULL, NULL, NULL} };
+
+
+/**
+ An ACPI_PARSER array describing the Processor Local x2APIC Structure.
+**/
+STATIC CONST ACPI_PARSER ProcessorLocalX2Apic[] = {
+ {L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL},
+ {L"Length", 1, 1, L"%d", NULL, NULL, NULL, NULL},
+ {L"Reserved", 2, 2, L"0x%x", NULL, NULL, NULL, NULL},
+
+ {L"X2APIC ID", 4, 4, L"0x%x", NULL, NULL, NULL, NULL}, {L"Flags",
+ 4, 8, L"0x%x", NULL, NULL, NULL, NULL}, {L"ACPI Processor UID", 4,
+ 12, L"0x%x", NULL, NULL, NULL, NULL} };
+
+/**
+ An ACPI_PARSER array describing the Local x2APIC NMI Structure.
+**/
+STATIC CONST ACPI_PARSER LocalX2ApicNmi[] = {
+ {L"Type", 1, 0, L"0x%x", NULL, NULL, NULL, NULL},
+ {L"Length", 1, 1, L"%d", NULL, NULL, NULL, NULL},
+ {L"Flags", 2, 2, L"0x%x", NULL, NULL, NULL, NULL},
+
+ {L"ACPI Processor UID", 4, 4, L"0x%x", NULL, NULL, NULL, NULL},
+ {L"Local x2APIC LINT#", 1, 8, L"0x%x", NULL, NULL, NULL, NULL},
+ {L"Reserved", 3, 9, L"0x%x%x%x", Dump3Chars, NULL, NULL, NULL} };
+
/**
An ACPI_PARSER array describing the ACPI MADT Table.
**/
@@ -357,6 +408,54 @@ ParseAcpiMadt (
break;
}

+ case EFI_ACPI_6_3_IO_APIC: {
+ ParseAcpi (
+ TRUE,
+ 2,
+ "IO APIC",
+ InterruptContollerPtr,
+ *MadtInterruptControllerLength,
+ PARSER_PARAMS (IoApic)
+ );
+ break;
+ }
+
+ case EFI_ACPI_6_3_INTERRUPT_SOURCE_OVERRIDE: {
+ ParseAcpi (
+ TRUE,
+ 2,
+ "INTERRUPT SOURCE OVERRIDE",
+ InterruptContollerPtr,
+ *MadtInterruptControllerLength,
+ PARSER_PARAMS (InterruptSourceOverride)
+ );
+ break;
+ }
+
+ case EFI_ACPI_6_3_PROCESSOR_LOCAL_X2APIC: {
+ ParseAcpi (
+ TRUE,
+ 2,
+ "PROCESSOR LOCAL X2APIC",
+ InterruptContollerPtr,
+ *MadtInterruptControllerLength,
+ PARSER_PARAMS (ProcessorLocalX2Apic)
+ );
+ break;
+ }
+
+ case EFI_ACPI_6_3_LOCAL_X2APIC_NMI: {
+ ParseAcpi (
+ TRUE,
+ 2,
+ "LOCAL x2APIC NMI",
+ InterruptContollerPtr,
+ *MadtInterruptControllerLength,
+ PARSER_PARAMS (LocalX2ApicNmi)
+ );
+ break;
+ }
+
default: {
IncrementErrorCount ();
Print (
--
2.25.1


[PATCH 6/6] uefi-sct/SctPkg: TCG2 Protocol: add SubmitCommand test

Joseph Hemann
 

From: Joseph Hemann <Joseph.hemann@...>

-add initial TCG2 protocol test for SubmitCommand()
-checkpoint for test function with GET_RANDOM Command

Cc: G Edhaya Chandran <Edhaya.Chandran@...>
Cc: Barton Gao <gaojie@...>
Cc: Carolyn Gjertsen <Carolyn.Gjertsen@...>
Cc: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@...>
Cc: Eric Jin <eric.jin@...>
Cc: Arvin Chen <arvinx.chen@...>
Cc: Supreeth Venkatesh <Supreeth.Venkatesh@...>
Signed-off-by: Joseph Hemann <Joseph.hemann@...>
---
.../EFI/Protocol/TCG2/BlackBoxTest/Guid.c | 4 +
.../EFI/Protocol/TCG2/BlackBoxTest/Guid.h | 10 +
.../TCG2/BlackBoxTest/TCG2ProtocolBBTest.h | 49 +++++
.../TCG2ProtocolBBTestConformance.c | 178 ++++++++++++++++++
.../BlackBoxTest/TCG2ProtocolBBTestMain.c | 10 +
5 files changed, 251 insertions(+)

diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
index 89c4151752cd..b5a4e5c7218e 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
@@ -53,3 +53,7 @@ EFI_GUID gTcg2ConformanceTestAssertionGuid011 = EFI_TEST_TCG2CONFORMANCE_ASSERTI
EFI_GUID gTcg2ConformanceTestAssertionGuid012 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_012_GUID;

EFI_GUID gTcg2ConformanceTestAssertionGuid013 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_013_GUID;
+
+EFI_GUID gTcg2ConformanceTestAssertionGuid014 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_014_GUID;
+
+EFI_GUID gTcg2ConformanceTestAssertionGuid015 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_015_GUID;
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
index 2cb715105529..ccc5a4bef957 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
@@ -90,3 +90,13 @@ extern EFI_GUID gTcg2ConformanceTestAssertionGuid012;
{ 0x45fa1a42, 0x912a, 0x5124, {0x84, 0xf4, 0x41, 0x67, 0xab, 0xb5, 0x89, 0x90 }}

extern EFI_GUID gTcg2ConformanceTestAssertionGuid013;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_014_GUID \
+{ 0x1689bc3a, 0x2298, 0xa116, {0x28, 0x4c, 0xc1, 0xdd, 0xaa, 0xd8, 0xef, 0x51 }}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid014;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_015_GUID \
+{ 0x126a789a, 0x1932, 0x3234, {0x21, 0xab, 0x42, 0x64, 0x8a, 0x7b, 0x63, 0x76 }}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid015;
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
index 69fb358922df..0fdf753f95fa 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
@@ -43,6 +43,9 @@ Abstract:
#define EFI_TCG2_PROTOCOL_TEST_ENTRY_GUID0103 \
{0x907a7878, 0xb294, 0xf147, {0xe9, 0x0a, 0x65, 0x43, 0xab, 0x55, 0x76, 0x46} }

+#define EFI_TCG2_PROTOCOL_TEST_ENTRY_GUID0104 \
+ {0x9087ad78, 0x9ad2, 0x4172, {0x9a, 0xbc, 0x98, 0x23, 0x08, 0xf5, 0x6d, 0x26} }
+
#define EV_POST_CODE 0x01

#define EV_NO_ACTION 0x03
@@ -51,6 +54,39 @@ Abstract:

#define PE_COFF_IMAGE 0x0000000000000010

+// ST_NO_SESSION as definied in Table 19 of TPM Library Part 2: Structures
+#define ST_NO_SESSIONS (UINT16) 0x8001
+
+// TPM_RC_SUCCESS as definied in Table 16 of TPM Library Spec Part 2: Structures
+#define TPM_RC_SUCCESS (UINT32) 0x0000000
+
+// TPM_CC_GetRandom as definied in Table 12 of TPM Library Spec Part 2: Structures
+#define TPM_CC_GetRandom (UINT32) 0x0000017B
+
+#pragma pack(1)
+// TPM2B_DIGEST as definied in Table 73 of TPM Library Spec Part 2: Structures
+typedef struct {
+ UINT16 size;
+ UINT8 digest[8]; // Size of buffer in spec is defined to be variable length but for this test will always be 8
+} TPM2B_DIGEST;
+
+// GetRandomCommand Structure as defined in Sectin 16.1 of TPM Spec Part 3: Commands
+typedef struct {
+ UINT16 Tag;
+ UINT32 CommandSize;
+ UINT32 CommandCode;
+ UINT16 BytesRequested;
+} GET_RANDOM_COMMAND;
+
+// GetRandomResponse Structure as defined in Sectin 16.1 of TPM Spec Part 3: Commands
+typedef struct {
+ UINT16 Tag;
+ UINT32 ResponseSize;
+ UINT32 ResponseCode;
+ TPM2B_DIGEST randomBytes;
+} GET_RANDOM_RESPONSE;
+#pragma
+
EFI_STATUS
EFIAPI
BBTestTCG2ProtocolUnload (
@@ -105,6 +141,12 @@ BBTestHashLogExtendEventConformanceTestCheckpoint4 (
IN EFI_TCG2_PROTOCOL *TCG2
);

+EFI_STATUS
+BBTestSubmitCommandConformanceTestCheckpoint1 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TCG2_PROTOCOL *TCG2
+ );
+
EFI_STATUS
BBTestGetCapabilityConformanceTest (
IN EFI_BB_TEST_PROTOCOL *This,
@@ -129,3 +171,10 @@ BBTestHashLogExtendEventConformanceTest (
IN EFI_HANDLE SupportHandle
);

+EFI_STATUS
+BBTestSubmitCommandConformanceTest (
+ IN EFI_BB_TEST_PROTOCOL *This,
+ IN VOID *ClientInterface,
+ IN EFI_TEST_LEVEL TestLevel,
+ IN EFI_HANDLE SupportHandle
+ );
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
index d3aaf979c087..b764e22116d0 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
@@ -177,6 +177,52 @@ BBTestHashLogExtendEventConformanceTest (
return EFI_SUCCESS;
}

+/**
+ * @brief Entrypoint for SubmitCommand() Function Test.
+ * 1 checkpoint will be tested.
+ * @param This a pointer of EFI_BB_TEST_PROTOCOL
+ * @param ClientInterface A pointer to the interface array under test
+ * @param TestLevel Test "thoroughness" control
+ * @param SupportHandle A handle containing protocols required
+ * @return EFI_SUCCESS
+ * @return EFI_NOT_FOUND
+ */
+
+EFI_STATUS
+BBTestSubmitCommandConformanceTest (
+ IN EFI_BB_TEST_PROTOCOL *This,
+ IN VOID *ClientInterface,
+ IN EFI_TEST_LEVEL TestLevel,
+ IN EFI_HANDLE SupportHandle
+ )
+{
+ EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib;
+ EFI_STATUS Status;
+ EFI_TCG2_PROTOCOL *TCG2;
+
+ //
+ // init
+ //
+ TCG2 = (EFI_TCG2_PROTOCOL*)ClientInterface;
+
+ //
+ // Get the Standard Library Interface
+ //
+ Status = gtBS->HandleProtocol (
+ SupportHandle,
+ &gEfiStandardTestLibraryGuid,
+ (VOID **) &StandardLib
+ );
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+
+ // Test GetRandom TPM Command
+ BBTestSubmitCommandConformanceTestCheckpoint1 (StandardLib, TCG2);
+
+ return EFI_SUCCESS;
+}
+
EFI_STATUS
BBTestGetCapabilityConformanceTestCheckpoint1 (
IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
@@ -837,3 +883,135 @@ BBTestHashLogExtendEventConformanceTestCheckpoint4 (

return EFI_SUCCESS;
}
+
+EFI_STATUS
+BBTestSubmitCommandConformanceTestCheckpoint1 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TCG2_PROTOCOL *TCG2
+ )
+{
+ EFI_TEST_ASSERTION AssertionType;
+ EFI_STATUS Status;
+ GET_RANDOM_RESPONSE CommandResponse;
+ GET_RANDOM_COMMAND CommandInput;
+ int IsNonZero = 0;
+
+ // Build TPM2 GetRandom command for 8 random bytes
+ CommandInput.Tag = SctSwapBytes16(ST_NO_SESSIONS);
+ CommandInput.CommandSize = SctSwapBytes32(sizeof(GET_RANDOM_COMMAND));
+ CommandInput.CommandCode = SctSwapBytes32(TPM_CC_GetRandom);
+ CommandInput.BytesRequested = SctSwapBytes16(8);
+
+ // zero out randomBytes to ensure SubmitCommand returns random bytes
+ SctZeroMem(&CommandResponse, sizeof(GET_RANDOM_RESPONSE));
+
+ Status = TCG2->SubmitCommand (
+ TCG2,
+ sizeof(GET_RANDOM_COMMAND),
+ &CommandInput,
+ sizeof(GET_RANDOM_RESPONSE),
+ &CommandResponse);
+
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+
+ // Verify SubmitCommand returns EFI_SUCCESS
+ if (Status != EFI_SUCCESS) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol SubmitCommand Test: SubmitCommand should return EFI_SUCCESS, Status = %r",
+ Status
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gTcg2ConformanceTestAssertionGuid014,
+ L"TCG2_PROTOCOL.SubmitCommand - SubmitCommand() should return EFI_SUCCESS",
+ L"%a:%d: Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+
+ // Verify SubmitCommand returns correct Response Tag
+ if (SctSwapBytes16(CommandResponse.Tag) != ST_NO_SESSIONS) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol SubmitCommand Test: SubmitCommand should return ST_NO_SESSIONS response Tag"
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ if (SctSwapBytes32(CommandResponse.ResponseCode) != TPM_RC_SUCCESS) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol SubmitCommand Test: SubmitCommand should return Correct ResponseCode, ResponseCode = %x",
+ SctSwapBytes32(CommandResponse.ResponseCode)
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ if (SctSwapBytes32(CommandResponse.ResponseSize) != sizeof(GET_RANDOM_RESPONSE)) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol SubmitCommand Test: SubmitCommand should return Correct ResponseSize, Size = %x",
+ SctSwapBytes32(CommandResponse.ResponseSize)
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ // Check that number of random bytes returned equals amount requested
+ if (SctSwapBytes16(CommandResponse.randomBytes.size) != 8) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol SubmitCommand Test: SubmitCommand should return correct amount of random bytes, Size = %x",
+ SctSwapBytes16(CommandResponse.randomBytes.size)
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ // If random bytes are returned at least one should be non-zero
+ for (int i = 0; i < 8; i++) {
+ if (CommandResponse.randomBytes.digest[i] != 0) {
+ IsNonZero = 1;
+ }
+ }
+
+ if (!IsNonZero) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol SubmitCommand Test: SubmitCommand should return RandomBytes",
+ Status
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gTcg2ConformanceTestAssertionGuid015,
+ L"TCG2_PROTOCOL.SubmitCommand - SubmitCommand() should return EFI_SUCCESS",
+ L"%a:%d: Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ return EFI_SUCCESS;
+}
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c
index 892fce2691c1..419e2a3e5ad2 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c
@@ -65,6 +65,16 @@ EFI_BB_TEST_ENTRY_FIELD gBBTestEntryField[] = {
EFI_TEST_CASE_AUTO,
BBTestHashLogExtendEventConformanceTest
},
+ {
+ EFI_TCG2_PROTOCOL_TEST_ENTRY_GUID0104,
+ L"SubmitCommand_Conf",
+ L"Test the SubmitCommmand API",
+ EFI_TEST_LEVEL_DEFAULT,
+ gSupportProtocolGuid1,
+ EFI_TEST_CASE_AUTO,
+ BBTestSubmitCommandConformanceTest
+ },
+
0
};

--
2.17.1


[PATCH 5/6] uefi-sct/SctPkg: TCG2 Protocol: add GetEventLog test

Joseph Hemann
 

From: Joseph Hemann <Joseph.hemann@...>

-add initial TCG2 protocol test for GetEventLog()
-checkpoint for test function with invalid eventlog format
-checkpoint for test function with valid eventlog format

Cc: G Edhaya Chandran <Edhaya.Chandran@...>
Cc: Barton Gao <gaojie@...>
Cc: Carolyn Gjertsen <Carolyn.Gjertsen@...>
Cc: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@...>
Cc: Eric Jin <eric.jin@...>
Cc: Arvin Chen <arvinx.chen@...>
Cc: Supreeth Venkatesh <Supreeth.Venkatesh@...>
Signed-off-by: Joseph Hemann <Joseph.hemann@...>
---
.../EFI/Protocol/TCG2/BlackBoxTest/Guid.c | 8 +
.../EFI/Protocol/TCG2/BlackBoxTest/Guid.h | 19 ++
.../TCG2/BlackBoxTest/TCG2ProtocolBBTest.h | 14 ++
.../TCG2ProtocolBBTestConformance.c | 204 +++++++++++++++++-
uefi-sct/SctPkg/UEFI/Protocol/TCG2.h | 45 ++++
5 files changed, 289 insertions(+), 1 deletion(-)

diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
index 32438f967d41..89c4151752cd 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
@@ -45,3 +45,11 @@ EFI_GUID gTcg2ConformanceTestAssertionGuid007 = EFI_TEST_TCG2CONFORMANCE_ASSERTI
EFI_GUID gTcg2ConformanceTestAssertionGuid008 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_008_GUID;

EFI_GUID gTcg2ConformanceTestAssertionGuid009 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_009_GUID;
+
+EFI_GUID gTcg2ConformanceTestAssertionGuid010 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_010_GUID;
+
+EFI_GUID gTcg2ConformanceTestAssertionGuid011 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_011_GUID;
+
+EFI_GUID gTcg2ConformanceTestAssertionGuid012 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_012_GUID;
+
+EFI_GUID gTcg2ConformanceTestAssertionGuid013 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_013_GUID;
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
index 27908816bb81..2cb715105529 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
@@ -71,3 +71,22 @@ extern EFI_GUID gTcg2ConformanceTestAssertionGuid008;

extern EFI_GUID gTcg2ConformanceTestAssertionGuid009;

+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_010_GUID \
+{ 0x0363d22f, 0xc66a, 0x4872, {0xa5, 0x46, 0x06, 0x7f, 0x6a, 0x0d, 0xdb, 0xcd }}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid010;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_011_GUID \
+{ 0x9cd6d636, 0x603a, 0x4b78, {0x80, 0xa3, 0xa3, 0xb9, 0xcc, 0x6a, 0x0b, 0x08 }}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid011;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_012_GUID \
+{ 0xfc80408e, 0x9a3c, 0x4054, {0x96, 0xf9, 0x31, 0x23, 0x35, 0xc2, 0x31, 0x35 }}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid012;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_013_GUID \
+{ 0x45fa1a42, 0x912a, 0x5124, {0x84, 0xf4, 0x41, 0x67, 0xab, 0xb5, 0x89, 0x90 }}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid013;
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
index f552e833b42b..69fb358922df 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
@@ -45,6 +45,8 @@ Abstract:

#define EV_POST_CODE 0x01

+#define EV_NO_ACTION 0x03
+
#define EFI_TCG2_EXTEND_ONLY 0x0000000000000001

#define PE_COFF_IMAGE 0x0000000000000010
@@ -91,6 +93,18 @@ BBTestHashLogExtendEventConformanceTestCheckpoint2 (
IN EFI_TCG2_PROTOCOL *TCG2
);

+EFI_STATUS
+BBTestHashLogExtendEventConformanceTestCheckpoint3 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TCG2_PROTOCOL *TCG2
+ );
+
+EFI_STATUS
+BBTestHashLogExtendEventConformanceTestCheckpoint4 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TCG2_PROTOCOL *TCG2
+ );
+
EFI_STATUS
BBTestGetCapabilityConformanceTest (
IN EFI_BB_TEST_PROTOCOL *This,
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
index a3992c4709a6..d3aaf979c087 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
@@ -126,7 +126,7 @@ BBTestGetActivePcrBanksConformanceTest (

/**
* @brief Entrypoint for HashLogExtendEvent() Function Test.
- * 2 checkpoints will be tested.
+ * 4 checkpoints will be tested.
* @param This a pointer of EFI_BB_TEST_PROTOCOL
* @param ClientInterface A pointer to the interface array under test
* @param TestLevel Test "thoroughness" control
@@ -168,6 +168,12 @@ BBTestHashLogExtendEventConformanceTest (
//Test with correct size field
BBTestHashLogExtendEventConformanceTestCheckpoint2 (StandardLib, TCG2);

+ // Test GetEventLog using invalid EventLog Format
+ BBTestHashLogExtendEventConformanceTestCheckpoint3 (StandardLib, TCG2);
+
+ // Test GetEventLog using valid EventLog Format
+ BBTestHashLogExtendEventConformanceTestCheckpoint4 (StandardLib, TCG2);
+
return EFI_SUCCESS;
}

@@ -635,3 +641,199 @@ BBTestHashLogExtendEventConformanceTestCheckpoint2 (

return EFI_SUCCESS;
}
+
+#define EFI_TCG2_INVALID_EVENT_LOG_FORMAT 0x20
+
+EFI_STATUS
+BBTestHashLogExtendEventConformanceTestCheckpoint3 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TCG2_PROTOCOL *TCG2
+ )
+{
+ EFI_TEST_ASSERTION AssertionType;
+ EFI_STATUS Status;
+ EFI_TCG2_EVENT_LOG_FORMAT EventLogFormat;
+ EFI_PHYSICAL_ADDRESS *EventLogLocation;
+ EFI_PHYSICAL_ADDRESS *EventLogLastEntry;
+ BOOLEAN *EventLogTruncated;
+
+ // Ensure Get EventLog returns Invalid Parameter when passed invalid format
+ EventLogFormat = EFI_TCG2_INVALID_EVENT_LOG_FORMAT;
+
+ Status = TCG2->GetEventLog (
+ TCG2,
+ EventLogFormat,
+ EventLogLocation,
+ EventLogLastEntry,
+ EventLogTruncated);
+
+ if (EFI_INVALID_PARAMETER != Status) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ } else {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gTcg2ConformanceTestAssertionGuid010,
+ L"TCG2_PROTOCOL.GetEventLog - GetEventLog() should return EFI_INVALID_PARAMETER when passed in invalid EventLog Format",
+ L"%a:%d: Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+BBTestHashLogExtendEventConformanceTestCheckpoint4 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TCG2_PROTOCOL *TCG2
+ )
+{
+ EFI_TEST_ASSERTION AssertionType;
+ EFI_STATUS Status;
+ EFI_TCG2_EVENT_LOG_FORMAT EventLogFormat;
+ EFI_PHYSICAL_ADDRESS EventLogLocation;
+ EFI_PHYSICAL_ADDRESS EventLogLastEntry;
+ BOOLEAN EventLogTruncated;
+ TCG_PCR_EVENT *EventLogHeader;
+ TCG_EfiSpecIDEventStruct *EventLogHeaderSpecEvent;
+ TCG_PCR_EVENT2 *LastEvent;
+ UINT8 *data = "Spec ID Event03\0\0";
+
+ EventLogFormat = EFI_TCG2_EVENT_LOG_FORMAT_TCG_2;
+
+ // Call GetEventLog with valid EventLogFormat
+ Status = TCG2->GetEventLog (
+ TCG2,
+ EventLogFormat,
+ &EventLogLocation,
+ &EventLogLastEntry,
+ &EventLogTruncated);
+
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+
+ // Verify GetEventLog returns EFI_SUCCESS
+ if (Status != EFI_SUCCESS) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol GetEventLog Test: GetEventLog should return EFI_SUCCESS with valid EventLogFormat, Status = %r",
+ Status
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gTcg2ConformanceTestAssertionGuid011,
+ L"TCG2_PROTOCOL.GetEventLog - GetEventLog() should return EFI_SUCCESS",
+ L"%a:%d: Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ // If GetEventLog doesn't return EFI_SUCCESS abort test
+ if (Status != EFI_SUCCESS) {
+ return Status;
+ }
+
+ EventLogHeader = (TCG_PCR_EVENT *) EventLogLocation;
+ EventLogHeaderSpecEvent = (TCG_EfiSpecIDEventStruct *) EventLogHeader->Event;
+
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+
+
+ // Verify valid eventlog header is returned
+ // Verify EventLogHeader PCR index == 0
+ if (EventLogHeader->PCRIndex != 0) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol GetEventLog Test: EventLogHeader should have PCR index == 0"
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ // Verify EventLogHeader event type = EV_NO_ACTION
+ if (EventLogHeader->EventType != EV_NO_ACTION) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol GetEventLog Test: EventLogHeader should be EventType == EV_NO_ACTION"
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ // Verify EventLog Signature
+ Status = SctStrCmp(EventLogHeaderSpecEvent->signature, data);
+
+ if (Status != EFI_SUCCESS) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol GetEventLog Test: EventLogHeader Signature did not match \'Spec ID Event03\'"
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gTcg2ConformanceTestAssertionGuid012,
+ L"TCG2_PROTOCOL.GetEventLog - GetEventLog() should return correct EventLogHeader",
+ L"%a:%d: Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+
+ // Verify Event recorded in checkpoint2 was recorded in Eventlog
+ LastEvent = (TCG_PCR_EVENT2 *) EventLogLastEntry;
+
+ // Verify Last Event PCR = 16
+ if (LastEvent->PCRIndex != 16) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol GetEventLog Test: PCR Index of Last event should be 16"
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ // Verify last event type = EV_POST_CODE
+ if (LastEvent->EventType != EV_POST_CODE) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol GetEventLog Test: PCR Index of last event should be type EV_POST_CODE"
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gTcg2ConformanceTestAssertionGuid013,
+ L"TCG2_PROTOCOL.GetEventLog - GetEventLog() should record Event from Checkpoint2 as last EventLogEntry",
+ L"%a:%d: Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ return EFI_SUCCESS;
+}
diff --git a/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h b/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h
index 9ece78e0deaf..5f095dffa7eb 100644
--- a/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h
+++ b/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h
@@ -49,6 +49,7 @@ Abstract:
#define EFI_TCG2_EVENT_LOG_FORMAT_TCG_1_2 0x00000001

#define EFI_TCG2_EVENT_LOG_FORMAT_TCG_2 0x00000002
+#define HASH_NUMBER 0x04

typedef struct _EFI_TCG2_PROTOCOL EFI_TCG2_PROTOCOL;

@@ -114,6 +115,50 @@ typedef struct tdEFI_TCG2_EVENT {
UINT8 Event[];
} EFI_TCG2_EVENT;

+typedef struct {
+ UINT16 hashAlg;
+ UINT8 digest[];
+} TPMT_HA;
+
+typedef struct tdTPML_DIGEST_VALUES {
+ UINT32 Count; // number of digests
+ TPMT_HA Digests[HASH_NUMBER]; // Count digests
+} TPML_DIGEST_VALUES;
+
+// This Declaration is for parsing the eventlog header which is defined to be 20 bytes in TCG EFI Protocol Spec
+typedef UINT8 TCG_DIGEST[20];
+
+typedef struct tdTCG_PCR_EVENT2 {
+ TCG_PCRINDEX PCRIndex; // PCRIndex event extended to
+ TCG_EVENTTYPE EventType; // Type of event (see [2])
+ TPML_DIGEST_VALUES Digests; // List of digests extended to //PCRIndex
+ UINT32 EventSize; // Size of the event data
+ UINT8 *Event; // The event data
+} TCG_PCR_EVENT2;
+
+typedef struct tdTCG_PCR_EVENT {
+ UINT32 PCRIndex; // PCRIndex event extended to
+ UINT32 EventType; // Type of event (see EFI specs)
+ TCG_DIGEST Digest; // Value extended into PCRIndex
+ UINT32 EventSize; // Size of the event data
+ UINT8 Event[0]; // The event data
+} TCG_PCR_EVENT;
+// Structure to be added to the Event Log
+
+typedef struct tdTCG_EfiSpecIdEventAlgorithmSize {
+ UINT16 algorithmId;
+ UINT16 digestSize;
+} TCG_EfiSpecIdEventAlgorithmSize;
+
+typedef struct tdTCG_EfiSpecIdEventStruct {
+ UINT8 signature[16];
+ UINT32 platformClass;
+ UINT8 specVersionMinor;
+ UINT8 specVersionMajor;
+ UINT8 specErrata;
+ UINT8 uintnSize;
+} TCG_EfiSpecIDEventStruct;
+
typedef
EFI_STATUS
(EFIAPI * EFI_TCG2_HASH_LOG_EXTEND_EVENT) (
--
2.17.1


[PATCH 4/6] uefi-sct/SctPkg: TCG2 Protocol: add HashLogExtendEvent test

Joseph Hemann
 

From: Joseph Hemann <Joseph.hemann@...>

-add initial TCG2 protocol test for HashLogExtendEvent()
-checkpoint for test of function with invalid parameters
-checkpoint for test of function with valid parameters

Cc: G Edhaya Chandran <Edhaya.Chandran@...>
Cc: Barton Gao <gaojie@...>
Cc: Carolyn Gjertsen <Carolyn.Gjertsen@...>
Cc: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@...>
Cc: Eric Jin <eric.jin@...>
Cc: Arvin Chen <arvinx.chen@...>
Cc: Supreeth Venkatesh <Supreeth.Venkatesh@...>
Signed-off-by: Joseph Hemann <Joseph.hemann@...>
---
.../EFI/Protocol/TCG2/BlackBoxTest/Guid.c | 8 +
.../EFI/Protocol/TCG2/BlackBoxTest/Guid.h | 20 ++
.../TCG2/BlackBoxTest/TCG2ProtocolBBTest.h | 29 ++
.../TCG2ProtocolBBTestConformance.c | 278 ++++++++++++++++++
.../BlackBoxTest/TCG2ProtocolBBTestMain.c | 9 +
5 files changed, 344 insertions(+)

diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
index 0497f08f74f2..32438f967d41 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
@@ -37,3 +37,11 @@ EFI_GUID gTcg2ConformanceTestAssertionGuid003 = EFI_TEST_TCG2CONFORMANCE_ASSERTI
EFI_GUID gTcg2ConformanceTestAssertionGuid004 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_004_GUID;

EFI_GUID gTcg2ConformanceTestAssertionGuid005 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_005_GUID;
+
+EFI_GUID gTcg2ConformanceTestAssertionGuid006 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_006_GUID;
+
+EFI_GUID gTcg2ConformanceTestAssertionGuid007 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_007_GUID;
+
+EFI_GUID gTcg2ConformanceTestAssertionGuid008 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_008_GUID;
+
+EFI_GUID gTcg2ConformanceTestAssertionGuid009 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_009_GUID;
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
index f470255ccdcf..27908816bb81 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
@@ -51,3 +51,23 @@ extern EFI_GUID gTcg2ConformanceTestAssertionGuid004;

extern EFI_GUID gTcg2ConformanceTestAssertionGuid005;

+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_006_GUID \
+{ 0xa8e1b5e6, 0xfc09, 0x461c, {0xb0, 0xe9, 0x2a, 0x49, 0xcd, 0x25, 0xc1, 0x24 }}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid006;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_007_GUID \
+{ 0x26f04a9b, 0x7b7a, 0x4f47, {0xbe, 0xa8, 0xb1, 0xa6, 0x02, 0x65, 0x19, 0x8a }}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid007;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_008_GUID \
+{ 0x4d1d9985, 0x91e2, 0x4948, {0x89, 0x16, 0xbb, 0x98, 0x13, 0x62, 0x39, 0x1d }}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid008;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_009_GUID \
+{ 0xfb59cab7, 0x4f8c, 0x4ded, {0xa4, 0x1c, 0xc8, 0x41, 0x20, 0x1c, 0x37, 0x22 }}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid009;
+
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
index a6773010b64f..f552e833b42b 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
@@ -40,6 +40,15 @@ Abstract:
#define EFI_TCG2_PROTOCOL_TEST_ENTRY_GUID0102 \
{0x847f1ae0, 0xb429, 0x49f1, {0x9e, 0x0c, 0x8f, 0x43, 0xfb, 0x55, 0x34, 0x54} }

+#define EFI_TCG2_PROTOCOL_TEST_ENTRY_GUID0103 \
+ {0x907a7878, 0xb294, 0xf147, {0xe9, 0x0a, 0x65, 0x43, 0xab, 0x55, 0x76, 0x46} }
+
+#define EV_POST_CODE 0x01
+
+#define EFI_TCG2_EXTEND_ONLY 0x0000000000000001
+
+#define PE_COFF_IMAGE 0x0000000000000010
+
EFI_STATUS
EFIAPI
BBTestTCG2ProtocolUnload (
@@ -70,6 +79,18 @@ BBTestGetActivePcrBanksConformanceTestCheckpoint2 (
IN EFI_TCG2_PROTOCOL *TCG2
);

+EFI_STATUS
+BBTestHashLogExtendEventConformanceTestCheckpoint1 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TCG2_PROTOCOL *TCG2
+ );
+
+EFI_STATUS
+BBTestHashLogExtendEventConformanceTestCheckpoint2 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TCG2_PROTOCOL *TCG2
+ );
+
EFI_STATUS
BBTestGetCapabilityConformanceTest (
IN EFI_BB_TEST_PROTOCOL *This,
@@ -86,3 +107,11 @@ BBTestGetActivePcrBanksConformanceTest (
IN EFI_HANDLE SupportHandle
);

+EFI_STATUS
+BBTestHashLogExtendEventConformanceTest (
+ IN EFI_BB_TEST_PROTOCOL *This,
+ IN VOID *ClientInterface,
+ IN EFI_TEST_LEVEL TestLevel,
+ IN EFI_HANDLE SupportHandle
+ );
+
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
index 5277f9433f7e..a3992c4709a6 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
@@ -124,6 +124,53 @@ BBTestGetActivePcrBanksConformanceTest (
return EFI_SUCCESS;
}

+/**
+ * @brief Entrypoint for HashLogExtendEvent() Function Test.
+ * 2 checkpoints will be tested.
+ * @param This a pointer of EFI_BB_TEST_PROTOCOL
+ * @param ClientInterface A pointer to the interface array under test
+ * @param TestLevel Test "thoroughness" control
+ * @param SupportHandle A handle containing protocols required
+ * @return EFI_SUCCESS
+ * @return EFI_NOT_FOUND
+ */
+
+EFI_STATUS
+BBTestHashLogExtendEventConformanceTest (
+ IN EFI_BB_TEST_PROTOCOL *This,
+ IN VOID *ClientInterface,
+ IN EFI_TEST_LEVEL TestLevel,
+ IN EFI_HANDLE SupportHandle
+ )
+{
+ EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib;
+ EFI_STATUS Status;
+ EFI_TCG2_PROTOCOL *TCG2;
+ //
+ // init
+ //
+ TCG2 = (EFI_TCG2_PROTOCOL*)ClientInterface;
+
+ // Get the Standard Library Interface
+ //
+ Status = gtBS->HandleProtocol (
+ SupportHandle,
+ &gEfiStandardTestLibraryGuid,
+ (VOID **) &StandardLib
+ );
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+
+ //Test Using NULL Pointer
+ BBTestHashLogExtendEventConformanceTestCheckpoint1 (StandardLib, TCG2);
+
+ //Test with correct size field
+ BBTestHashLogExtendEventConformanceTestCheckpoint2 (StandardLib, TCG2);
+
+ return EFI_SUCCESS;
+}
+
EFI_STATUS
BBTestGetCapabilityConformanceTestCheckpoint1 (
IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
@@ -357,3 +404,234 @@ BBTestGetActivePcrBanksConformanceTestCheckpoint2 (

return EFI_SUCCESS;
}
+
+EFI_STATUS
+BBTestHashLogExtendEventConformanceTestCheckpoint1 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TCG2_PROTOCOL *TCG2
+ )
+{
+ EFI_TEST_ASSERTION AssertionType;
+ EFI_STATUS Status;
+ UINT64 Flags = 0;
+ EFI_PHYSICAL_ADDRESS DataToHash;
+ UINT64 DataToHashLen;
+ EFI_TCG2_EVENT *EfiTcgEvent;
+ const CHAR16 *EventData = L"TCG2 Protocol Test";
+ const CHAR16 *Str = L"The quick brown fox jumps over the lazy dog";
+ UINT32 EfiTcgEventSize = sizeof(EFI_TCG2_EVENT) + SctStrSize(EventData);
+
+ DataToHash = Str;
+ DataToHashLen = SctStrLen(Str);
+
+ Status = gtBS->AllocatePool (
+ EfiBootServicesData,
+ EfiTcgEventSize,
+ (VOID **)&EfiTcgEvent
+ );
+
+ EfiTcgEvent->Header.HeaderSize = sizeof(EFI_TCG2_EVENT_HEADER);
+ EfiTcgEvent->Header.EventType = EV_POST_CODE;
+ EfiTcgEvent->Header.PCRIndex = 16;
+ EfiTcgEvent->Size = EfiTcgEvent->Header.HeaderSize + SctStrSize(EventData);
+
+ // Ensure HashLogExtendEvent returns Invalid Parameter when passing in NULL DataToHash pointer
+ // EFI Protocol Spec Section 6.6.5 #1
+ Status = TCG2->HashLogExtendEvent (
+ TCG2,
+ Flags,
+ NULL,
+ 0,
+ EfiTcgEvent);
+
+ if (EFI_INVALID_PARAMETER != Status) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ } else {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gTcg2ConformanceTestAssertionGuid004,
+ L"TCG2_PROTOCOL.HashLogExtendEvent - Test with NULL DataToHash Pointer should return EFI_INVALID_PARAMETER",
+ L"%a:%d: Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ // Ensure HashLogExtendEvent returns Invalid Parameter when passing in NULL EfiTcgEvent pointer
+ // EFI Protocol Spec Section 6.6.5 #1
+ Status = TCG2->HashLogExtendEvent (
+ TCG2,
+ Flags,
+ DataToHash,
+ DataToHashLen,
+ NULL);
+
+ if (EFI_INVALID_PARAMETER != Status) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ } else {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gTcg2ConformanceTestAssertionGuid005,
+ L"TCG2_PROTOCOL.HashLogExtendEvent - Test with NULL EfiTcgEvent Pointer should return EFI_INVALID_PARAMETER",
+ L"%a:%d: Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ // Ensure HashLogExtendEvent returns Invalid Parameter when passed in EventSize < HeaderSize + sizeof(UINT32)
+ // EFI Protocol Spec Section 6.6.5 #2
+ EfiTcgEvent->Size = EfiTcgEvent->Header.HeaderSize + sizeof(UINT32) - 1;
+
+ Status = TCG2->HashLogExtendEvent (
+ TCG2,
+ Flags,
+ DataToHash,
+ DataToHashLen,
+ EfiTcgEvent);
+
+ if (EFI_INVALID_PARAMETER != Status) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ } else {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gTcg2ConformanceTestAssertionGuid006,
+ L"TCG2_PROTOCOL.HashLogExtendEvent - Test with Event.Size < Event.Header.HeaderSize + sizeof(UINT32) should return EFI_INVALID_PARAMETER",
+ L"%a:%d: Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ // Ensure HashLogExtendEvent returns Invalid Parameter when passing in PCR Index > 23
+ // EFI Protocol Spec Section 6.6.5 #3
+ EfiTcgEvent->Header.PCRIndex = 24;
+ EfiTcgEvent->Size = EfiTcgEvent->Header.HeaderSize + SctStrSize(EventData);
+
+ Status = TCG2->HashLogExtendEvent (
+ TCG2,
+ Flags,
+ DataToHash,
+ DataToHashLen,
+ EfiTcgEvent);
+
+ if (EFI_INVALID_PARAMETER != Status) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ } else {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gTcg2ConformanceTestAssertionGuid007,
+ L"TCG2_PROTOCOL.HashLogExtendEvent - Test with PCRIndex > 23 should return EFI_INVALID_PARAMETER",
+ L"%a:%d: Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+BBTestHashLogExtendEventConformanceTestCheckpoint2 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TCG2_PROTOCOL *TCG2
+ )
+{
+
+ EFI_TCG2_EVENT *EfiTcgEvent;
+ EFI_TEST_ASSERTION AssertionType;
+ EFI_STATUS Status;
+ UINT64 Flags = 0;
+ EFI_PHYSICAL_ADDRESS DataToHash;
+ UINT64 DataToHashLen;
+ const CHAR16 *Str = L"The quick brown fox jumps over the lazy dog";
+ const CHAR16 *EventData = L"TCG2 Protocol Test";
+ UINT32 EfiTcgEventSize = sizeof(EFI_TCG2_EVENT) + SctStrSize(EventData);
+
+ DataToHash = Str;
+ DataToHashLen = SctStrLen(Str);
+
+ Status = gtBS->AllocatePool (
+ EfiBootServicesData,
+ EfiTcgEventSize,
+ (VOID **)&EfiTcgEvent
+ );
+
+ EfiTcgEvent->Header.HeaderSize = sizeof(EFI_TCG2_EVENT_HEADER);
+ EfiTcgEvent->Header.EventType = EV_POST_CODE;
+ EfiTcgEvent->Header.PCRIndex = 16;
+ EfiTcgEvent->Size = EfiTcgEvent->Header.HeaderSize + SctStrSize(EventData);
+
+ // Perform HashLogExtendEvent over test buffer to PCR 16
+ Status = TCG2->HashLogExtendEvent (
+ TCG2,
+ Flags,
+ DataToHash,
+ DataToHashLen,
+ EfiTcgEvent);
+
+ if (Status != EFI_SUCCESS) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ } else {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gTcg2ConformanceTestAssertionGuid008,
+ L"TCG2_PROTOCOL.HashLogExtendEvent - HashLogExtendEvent() Test: HashLogExtendEvent should return EFI_SUCCESS",
+ L"%a:%d: Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ // Test with valid Parameters but with Flags = PE_COFF_IMAGE
+ // EFI Protocol Spec Section 6.6.5 #4
+ Flags = PE_COFF_IMAGE;
+
+ Status = TCG2->HashLogExtendEvent (
+ TCG2,
+ Flags,
+ DataToHash,
+ DataToHashLen,
+ EfiTcgEvent);
+
+ if (Status != EFI_UNSUPPORTED) {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ } else {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gTcg2ConformanceTestAssertionGuid009,
+ L"TCG2_PROTOCOL.HashLogExtendEvent - HashLogExtendEvent() Test Handling of PE_COFF_IMAGE flag",
+ L"%a:%d: Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ gtBS->FreePool (EfiTcgEvent);
+
+ return EFI_SUCCESS;
+}
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c
index 4e7b15937ebb..892fce2691c1 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c
@@ -56,6 +56,15 @@ EFI_BB_TEST_ENTRY_FIELD gBBTestEntryField[] = {
EFI_TEST_CASE_AUTO,
BBTestGetActivePcrBanksConformanceTest
},
+ {
+ EFI_TCG2_PROTOCOL_TEST_ENTRY_GUID0103,
+ L"HashLogExtendEvent_Conf",
+ L"Test the HashLogExtendEvent API",
+ EFI_TEST_LEVEL_DEFAULT,
+ gSupportProtocolGuid1,
+ EFI_TEST_CASE_AUTO,
+ BBTestHashLogExtendEventConformanceTest
+ },
0
};

--
2.17.1


[PATCH 3/6] uefi-sct/SctPkg: TCG2 Protocol: add GetActivePcrBanks test

Joseph Hemann
 

From: Joseph Hemann <Joseph.hemann@...>

-add initial TCG2 protocol test for GetActivePcrBanks()
-checkpoint for NULL pointer passed for buffer
-checkpoint for test of function with proper input

Cc: G Edhaya Chandran <Edhaya.Chandran@...>
Cc: Barton Gao <gaojie@...>
Cc: Carolyn Gjertsen <Carolyn.Gjertsen@...>
Cc: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@...>
Cc: Eric Jin <eric.jin@...>
Cc: Arvin Chen <arvinx.chen@...>
Cc: Supreeth Venkatesh <Supreeth.Venkatesh@...>
Signed-off-by: Joseph Hemann <Joseph.hemann@...>
---
.../EFI/Protocol/TCG2/BlackBoxTest/Guid.c | 4 +
.../EFI/Protocol/TCG2/BlackBoxTest/Guid.h | 10 ++
.../TCG2/BlackBoxTest/TCG2ProtocolBBTest.h | 23 +++
.../TCG2ProtocolBBTestConformance.c | 140 +++++++++++++++++-
.../BlackBoxTest/TCG2ProtocolBBTestMain.c | 9 ++
5 files changed, 185 insertions(+), 1 deletion(-)

diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
index 206662ee7933..0497f08f74f2 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
@@ -33,3 +33,7 @@ EFI_GUID gTcg2ConformanceTestAssertionGuid001 = EFI_TEST_TCG2CONFORMANCE_ASSERTI
EFI_GUID gTcg2ConformanceTestAssertionGuid002 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_002_GUID;

EFI_GUID gTcg2ConformanceTestAssertionGuid003 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_003_GUID;
+
+EFI_GUID gTcg2ConformanceTestAssertionGuid004 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_004_GUID;
+
+EFI_GUID gTcg2ConformanceTestAssertionGuid005 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_005_GUID;
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
index b675756b9fb7..f470255ccdcf 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
@@ -41,3 +41,13 @@ extern EFI_GUID gTcg2ConformanceTestAssertionGuid002;

extern EFI_GUID gTcg2ConformanceTestAssertionGuid003;

+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_004_GUID \
+{ 0x7a1e79a3, 0x4064, 0x4372, {0xbb, 0x64, 0x55, 0xb8, 0xf2, 0xa5, 0xa3, 0x26 }}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid004;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_005_GUID \
+{ 0xb0e717c4, 0xb1e2, 0x49f7, {0xb2, 0xd7, 0x60, 0x58, 0x97, 0x7d, 0x09, 0x2c }}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid005;
+
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
index 674540182d2d..a6773010b64f 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
@@ -37,6 +37,9 @@ Abstract:
#define EFI_TCG2_PROTOCOL_TEST_ENTRY_GUID0101 \
{0x39ff9c71, 0x4b41, 0x4e5b, {0xae, 0xd7, 0x87, 0xc7, 0x94, 0x18, 0x7d, 0x67} }

+#define EFI_TCG2_PROTOCOL_TEST_ENTRY_GUID0102 \
+ {0x847f1ae0, 0xb429, 0x49f1, {0x9e, 0x0c, 0x8f, 0x43, 0xfb, 0x55, 0x34, 0x54} }
+
EFI_STATUS
EFIAPI
BBTestTCG2ProtocolUnload (
@@ -55,6 +58,18 @@ BBTestGetCapabilityConformanceTestCheckpoint2 (
IN EFI_TCG2_PROTOCOL *TCG2
);

+EFI_STATUS
+BBTestGetActivePcrBanksConformanceTestCheckpoint1 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TCG2_PROTOCOL *TCG2
+ );
+
+EFI_STATUS
+BBTestGetActivePcrBanksConformanceTestCheckpoint2 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TCG2_PROTOCOL *TCG2
+ );
+
EFI_STATUS
BBTestGetCapabilityConformanceTest (
IN EFI_BB_TEST_PROTOCOL *This,
@@ -63,3 +78,11 @@ BBTestGetCapabilityConformanceTest (
IN EFI_HANDLE SupportHandle
);

+EFI_STATUS
+BBTestGetActivePcrBanksConformanceTest (
+ IN EFI_BB_TEST_PROTOCOL *This,
+ IN VOID *ClientInterface,
+ IN EFI_TEST_LEVEL TestLevel,
+ IN EFI_HANDLE SupportHandle
+ );
+
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
index fec542167171..5277f9433f7e 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
@@ -75,6 +75,54 @@ BBTestGetCapabilityConformanceTest (
return EFI_SUCCESS;
}

+/**
+ * @brief Entrypoint for GetActivePcrBanks() Function Test.
+ * 2 checkpoints will be tested.
+ * @param This a pointer of EFI_BB_TEST_PROTOCOL
+ * @param ClientInterface A pointer to the interface array under test
+ * @param TestLevel Test "thoroughness" control
+ * @param SupportHandle A handle containing protocols required
+ * @return EFI_SUCCESS
+ * @return EFI_NOT_FOUND
+ */
+
+EFI_STATUS
+BBTestGetActivePcrBanksConformanceTest (
+ IN EFI_BB_TEST_PROTOCOL *This,
+ IN VOID *ClientInterface,
+ IN EFI_TEST_LEVEL TestLevel,
+ IN EFI_HANDLE SupportHandle
+ )
+{
+ EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib;
+ EFI_STATUS Status;
+ EFI_TCG2_PROTOCOL *TCG2;
+
+ //
+ // init
+ //
+ TCG2 = (EFI_TCG2_PROTOCOL*)ClientInterface;
+
+ //
+ // Get the Standard Library Interface
+ //
+ Status = gtBS->HandleProtocol (
+ SupportHandle,
+ &gEfiStandardTestLibraryGuid,
+ (VOID **) &StandardLib
+ );
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+
+ // Test Using NULL Pointer
+ BBTestGetActivePcrBanksConformanceTestCheckpoint1 (StandardLib, TCG2);
+
+ // Test with correct size field
+ BBTestGetActivePcrBanksConformanceTestCheckpoint2 (StandardLib, TCG2);
+
+ return EFI_SUCCESS;
+}

EFI_STATUS
BBTestGetCapabilityConformanceTestCheckpoint1 (
@@ -181,7 +229,7 @@ BBTestGetCapabilityConformanceTestCheckpoint2 (
AssertionType = EFI_TEST_ASSERTION_FAILED;
}

- EFI_TCG2_EVENT_ALGORITHM_BITMAP HashBitMapAlgos = EFI_TCG2_BOOT_HASH_ALG_SHA256 | EFI_TCG2_BOOT_HASH_ALG_SHA384 | EFI_TCG2_BOOT_HASH_ALG_SHA512;
+ EFI_TCG2_EVENT_ALGORITHM_BITMAP HashBitMapAlgos = EFI_TCG2_BOOT_HASH_ALG_SHA1 | EFI_TCG2_BOOT_HASH_ALG_SHA256 | EFI_TCG2_BOOT_HASH_ALG_SHA384 | EFI_TCG2_BOOT_HASH_ALG_SHA512;

if (!(BootServiceCap.HashAlgorithmBitmap & HashBitMapAlgos)) {
StandardLib->RecordMessage (
@@ -219,3 +267,93 @@ BBTestGetCapabilityConformanceTestCheckpoint2 (
return EFI_SUCCESS;
}

+EFI_STATUS
+BBTestGetActivePcrBanksConformanceTestCheckpoint1 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TCG2_PROTOCOL *TCG2
+ )
+{
+ EFI_TEST_ASSERTION AssertionType;
+ EFI_STATUS Status;
+
+ EFI_TCG2_EVENT_ALGORITHM_BITMAP *ActivePcrBanks = NULL;
+ Status = TCG2->GetActivePcrBanks (
+ TCG2,
+ ActivePcrBanks);
+
+ // Ensure GetCapablity returns Invalid Parameter when passing in NULL pointer
+ if (EFI_INVALID_PARAMETER == Status) {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ } else {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gTcg2ConformanceTestAssertionGuid004,
+ L"TCG2_PROTOCOL.GetActivePcrBanks - GetActivePcrBanks() returns EFI_INVALID_PARAMETER with NULL pointer Passed in",
+ L"%a:%d: Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+BBTestGetActivePcrBanksConformanceTestCheckpoint2 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TCG2_PROTOCOL *TCG2
+ )
+{
+ EFI_TEST_ASSERTION AssertionType;
+ EFI_STATUS Status;
+
+ EFI_TCG2_EVENT_ALGORITHM_BITMAP ActivePcrBanks;
+ Status = TCG2->GetActivePcrBanks (
+ TCG2,
+ &ActivePcrBanks);
+
+ // Ensure GetActivePcrBanks returns EFI_SUCCESS
+ if (Status == EFI_SUCCESS) {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ } else {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol GetActivePcrBanks Test: GetActivePcrBanks should return EFI_SUCCESS",
+ ActivePcrBanks
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ EFI_TCG2_EVENT_ALGORITHM_BITMAP BitMapAlgos = EFI_TCG2_BOOT_HASH_ALG_SHA256 | EFI_TCG2_BOOT_HASH_ALG_SHA384 | EFI_TCG2_BOOT_HASH_ALG_SHA512;
+
+ // Ensure ActivePcrBanks has SHA256/384/512 in its Bitmap
+ if (!(ActivePcrBanks & BitMapAlgos)) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol GetActivePcrBanks Test: GetActiVePcrBanks should have SHA256/384/512 Algorithm in its Bitmap. ActivePcrBanks = %x",
+ ActivePcrBanks
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gTcg2ConformanceTestAssertionGuid005,
+ L"TCG2_PROTOCOL.GetActivePcrBanks - GetActivePcrBanks should return with EFI_SUCCESS and have SHA256/384/512 Algoritms in its Bitmap",
+ L"%a:%d: Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ return EFI_SUCCESS;
+}
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c
index 97da8f58e35f..4e7b15937ebb 100644
--- a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c
@@ -47,6 +47,15 @@ EFI_BB_TEST_ENTRY_FIELD gBBTestEntryField[] = {
EFI_TEST_CASE_AUTO,
BBTestGetCapabilityConformanceTest
},
+ {
+ EFI_TCG2_PROTOCOL_TEST_ENTRY_GUID0102,
+ L"GetActivePcrBanks_Conf",
+ L"Test the GetActivePcrBanks API",
+ EFI_TEST_LEVEL_DEFAULT,
+ gSupportProtocolGuid1,
+ EFI_TEST_CASE_AUTO,
+ BBTestGetActivePcrBanksConformanceTest
+ },
0
};

--
2.17.1


[PATCH 2/6] uefi-sct/SctPkg: TCG2 Protocol: add GetCapability Test

Joseph Hemann
 

From: Joseph Hemann <Joseph.hemann@...>

-implement initial infrastructure for the TCG2 protocol test
including updates to .dsc file, inf file, GUID source files,
update to Category.ini.

-add initial TCG2 protocol test for GetCapability(), as
defined in the TCG EFI Protocol Spec 6.4.4.
-checkpoint for NULL pointer passed for buffer
-checkpoint for validating fields of the struct returned by GetCapabilty()

Cc: G Edhaya Chandran <Edhaya.Chandran@...>
Cc: Barton Gao <gaojie@...>
Cc: Carolyn Gjertsen <Carolyn.Gjertsen@...>
Cc: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@...>
Cc: Eric Jin <eric.jin@...>
Cc: Arvin Chen <arvinx.chen@...>
Cc: Supreeth Venkatesh <Supreeth.Venkatesh@...>
Signed-off-by: Joseph Hemann <Joseph.hemann@...>
---
uefi-sct/SctPkg/CommonGenFramework.sh | 1 +
uefi-sct/SctPkg/Config/Data/Category.ini | 7 +
.../EFI/Protocol/TCG2/BlackBoxTest/Guid.c | 35 +++
.../EFI/Protocol/TCG2/BlackBoxTest/Guid.h | 43 ++++
.../TCG2/BlackBoxTest/TCG2ProtocolBBTest.h | 65 ++++++
.../TCG2/BlackBoxTest/TCG2ProtocolBBTest.inf | 51 ++++
.../TCG2ProtocolBBTestConformance.c | 221 ++++++++++++++++++
.../BlackBoxTest/TCG2ProtocolBBTestMain.c | 102 ++++++++
uefi-sct/SctPkg/UEFI/UEFI_SCT.dsc | 1 +
9 files changed, 526 insertions(+)
create mode 100644 uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
create mode 100644 uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
create mode 100644 uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
create mode 100644 uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.inf
create mode 100644 uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
create mode 100644 uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c

diff --git a/uefi-sct/SctPkg/CommonGenFramework.sh b/uefi-sct/SctPkg/CommonGenFramework.sh
index 779a6a4492b3..997d8ba1638b 100755
--- a/uefi-sct/SctPkg/CommonGenFramework.sh
+++ b/uefi-sct/SctPkg/CommonGenFramework.sh
@@ -210,6 +210,7 @@ then
cp $ProcessorType/DiskIo2BBTest.efi $Framework/Test/ > NUL
cp $ProcessorType/TimeStampBBTest.efi $Framework/Test/ > NUL
cp $ProcessorType/RandomNumberBBTest.efi $Framework/Test/ > NUL
+ cp $ProcessorType/TCG2ProtocolBBTest.efi $Framework/Test/ > NUL
cp $ProcessorType/Hash2BBTest.efi $Framework/Test/ > NUL
cp $ProcessorType/Pkcs7BBTest.efi $Framework/Test/ > NUL
cp $ProcessorType/ConfigKeywordHandlerBBTest.efi $Framework/Test/ > NUL
diff --git a/uefi-sct/SctPkg/Config/Data/Category.ini b/uefi-sct/SctPkg/Config/Data/Category.ini
index af27e362ec8a..c239fe4ba98c 100644
--- a/uefi-sct/SctPkg/Config/Data/Category.ini
+++ b/uefi-sct/SctPkg/Config/Data/Category.ini
@@ -1026,3 +1026,10 @@ InterfaceGuid = 8D59D32B-C655-4AE9-9B15-F25904992A43
Name = IHV\ConsoleSupportTest\AbsolutePointerProtocolTest
Description = Absolute Pointer Protocol Test on IHV Drivers

+[Category Data]
+Revision = 0x00010000
+CategoryGuid = 607f766c-7455-42be-930b-e4d76db2720f
+InterfaceGuid = 607f766c-7455-42be-930b-e4d76db2720f
+Name = TCG2ProtocolTest
+Description =
+
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
new file mode 100644
index 000000000000..206662ee7933
--- /dev/null
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
@@ -0,0 +1,35 @@
+/** @file
+
+ Copyright 2006 - 2013 Unified EFI, Inc.<BR>
+ Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2021, Arm Inc. All rights reserved.<BR>
+
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+/*++
+
+Module Name:
+
+ guid.c
+
+Abstract:
+
+ GUIDs auto-generated for EFI test assertion.
+
+--*/
+
+#include "Efi.h"
+#include "Guid.h"
+
+EFI_GUID gTcg2ConformanceTestAssertionGuid001 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_001_GUID;
+
+EFI_GUID gTcg2ConformanceTestAssertionGuid002 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_002_GUID;
+
+EFI_GUID gTcg2ConformanceTestAssertionGuid003 = EFI_TEST_TCG2CONFORMANCE_ASSERTION_003_GUID;
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
new file mode 100644
index 000000000000..b675756b9fb7
--- /dev/null
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
@@ -0,0 +1,43 @@
+/** @file
+
+ Copyright 2006 - 2016 Unified EFI, Inc.<BR>
+ Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2021, Arm Inc. All rights reserved.<BR>
+
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+/*++
+
+Module Name:
+
+ guid.h
+
+Abstract:
+
+ GUIDs auto-generated for EFI test assertion.
+
+--*/
+
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_001_GUID \
+{ 0xca93b02a, 0xe897, 0x4400, {0x81, 0x38, 0xc8, 0xa8, 0xcb, 0x2f, 0xc1, 0xed }}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid001;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_002_GUID \
+{ 0xda8821d9, 0x3d2c, 0x4698, {0x8c, 0xd5, 0x0f, 0x0c, 0x82, 0x94, 0x1d, 0x0c }}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid002;
+
+#define EFI_TEST_TCG2CONFORMANCE_ASSERTION_003_GUID \
+{ 0xfdee7001, 0x7e28, 0x4e35, {0x99, 0x66, 0x98, 0x0b, 0xeb, 0xba, 0xf1, 0x57 }}
+
+extern EFI_GUID gTcg2ConformanceTestAssertionGuid003;
+
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
new file mode 100644
index 000000000000..674540182d2d
--- /dev/null
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
@@ -0,0 +1,65 @@
+/** @file
+
+ Copyright 2006 - 2017 Unified EFI, Inc.<BR>
+ Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2021, Arm Inc. All rights reserved.<BR>
+
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+/*++
+
+Module Name:
+ TCG2ProtocolBBTest.h
+
+Abstract:
+ head file of test driver of EFI TCG2 Protocol Test
+
+--*/
+
+#include "SctLib.h"
+#include <Library/EfiTestLib.h>
+#include <UEFI/Protocol/TCG2.h>
+#include "Guid.h"
+
+#define EFI_TCG2_TEST_REVISION 0x00010000
+
+//////////////////////////////////////////////////////////////////////////////
+//
+// Entry GUIDs for Function Test
+//
+#define EFI_TCG2_PROTOCOL_TEST_ENTRY_GUID0101 \
+ {0x39ff9c71, 0x4b41, 0x4e5b, {0xae, 0xd7, 0x87, 0xc7, 0x94, 0x18, 0x7d, 0x67} }
+
+EFI_STATUS
+EFIAPI
+BBTestTCG2ProtocolUnload (
+ IN EFI_HANDLE ImageHandle
+ );
+
+EFI_STATUS
+BBTestGetCapabilityConformanceTestCheckpoint1 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TCG2_PROTOCOL *TCG2
+ );
+
+EFI_STATUS
+BBTestGetCapabilityConformanceTestCheckpoint2 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TCG2_PROTOCOL *TCG2
+ );
+
+EFI_STATUS
+BBTestGetCapabilityConformanceTest (
+ IN EFI_BB_TEST_PROTOCOL *This,
+ IN VOID *ClientInterface,
+ IN EFI_TEST_LEVEL TestLevel,
+ IN EFI_HANDLE SupportHandle
+ );
+
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.inf b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.inf
new file mode 100644
index 000000000000..f41d84b32a5c
--- /dev/null
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.inf
@@ -0,0 +1,51 @@
+## @file
+#
+# Copyright 2006 - 2015 Unified EFI, Inc.<BR>
+# Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2021, Arm Inc. All rights reserved.<BR>
+#
+# This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+##
+#/*++
+#
+# Module Name:
+#
+# TCG2ProtocolBBTest.inf
+#
+# Abstract:
+#
+# Component description file for TCG2 Protocol Black-Box Test.
+#
+#--*/
+
+[defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = TCG2ProtocolBBTest
+ FILE_GUID = BD8CB762-3935-434C-AC3F-462244910A2D
+ MODULE_TYPE = UEFI_DRIVER
+ VERSION_STRING = 1.0
+ ENTRY_POINT = InitializeBBTestTCG2Protocol
+
+[sources.common]
+ Guid.c
+ TCG2ProtocolBBTestMain.c
+ TCG2ProtocolBBTestConformance.c
+
+[Packages]
+ MdePkg/MdePkg.dec
+ SctPkg/SctPkg.dec
+ SctPkg/UEFI/UEFI.dec
+
+[LibraryClasses]
+ UefiDriverEntryPoint
+ SctLib
+ EfiTestLib
+
+[Protocols]
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
new file mode 100644
index 000000000000..fec542167171
--- /dev/null
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
@@ -0,0 +1,221 @@
+/** @file
+
+ Copyright 2006 - 2016 Unified EFI, Inc.<BR>
+ Copyright (c) 2021, Arm Inc. All rights reserved.<BR>
+
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+/*++
+
+Module Name:
+
+ TCG2BBTestConformance.c
+
+Abstract:
+
+ for EFI Driver TCG2 Protocol's Basic Test
+
+--*/
+
+#include "TCG2ProtocolBBTest.h"
+
+/**
+ * @brief Entrypoint for GetCapability() Function Test.
+ * 2 checkpoints will be tested.
+ * @param This a pointer of EFI_BB_TEST_PROTOCOL
+ * @param ClientInterface A pointer to the interface array under test
+ * @param TestLevel Test "thoroughness" control
+ * @param SupportHandle A handle containing protocols required
+ * @return EFI_SUCCESS
+ * @return EFI_NOT_FOUND
+ */
+
+EFI_STATUS
+BBTestGetCapabilityConformanceTest (
+ IN EFI_BB_TEST_PROTOCOL *This,
+ IN VOID *ClientInterface,
+ IN EFI_TEST_LEVEL TestLevel,
+ IN EFI_HANDLE SupportHandle
+ )
+{
+ EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib;
+ EFI_STATUS Status;
+ EFI_TCG2_PROTOCOL *TCG2;
+
+ //
+ // init
+ //
+ TCG2 = (EFI_TCG2_PROTOCOL*)ClientInterface;
+
+ //
+ // Get the Standard Library Interface
+ //
+ Status = gtBS->HandleProtocol (
+ SupportHandle,
+ &gEfiStandardTestLibraryGuid,
+ (VOID **) &StandardLib
+ );
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+
+ // Test Using NULL BootCapablity Pointer
+ BBTestGetCapabilityConformanceTestCheckpoint1 (StandardLib, TCG2);
+
+ // Test for validating fields of struct returned by GetCapability()
+ BBTestGetCapabilityConformanceTestCheckpoint2 (StandardLib, TCG2);
+
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+BBTestGetCapabilityConformanceTestCheckpoint1 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TCG2_PROTOCOL *TCG2
+ )
+{
+ EFI_TEST_ASSERTION AssertionType;
+ EFI_STATUS Status;
+ EFI_TCG2_BOOT_SERVICE_CAPABILITY *BootServiceCapPtr = NULL;
+
+ Status = TCG2->GetCapability (
+ TCG2,
+ BootServiceCapPtr);
+
+ // Ensure GetCapablity returns Invalid Parameter when passing in NULL pointer
+ if (EFI_INVALID_PARAMETER == Status) {
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+ } else {
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gTcg2ConformanceTestAssertionGuid001,
+ L"TCG2_PROTOCOL.GetCapability - GetCapability() returns EFI_INVALID_PARAMETER with NULL pointer Capability Struct Passed in",
+ L"%a:%d: Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+BBTestGetCapabilityConformanceTestCheckpoint2 (
+ IN EFI_STANDARD_TEST_LIBRARY_PROTOCOL *StandardLib,
+ IN EFI_TCG2_PROTOCOL *TCG2
+ )
+{
+ EFI_TEST_ASSERTION AssertionType;
+ EFI_STATUS Status;
+ char StructureVersionMajor;
+ char StructureVersionMinor;
+ char ProtocolVersionMajor;
+ char ProtocolVersionMinor;
+ EFI_TCG2_BOOT_SERVICE_CAPABILITY BootServiceCap;
+
+ BootServiceCap.Size = sizeof(EFI_TCG2_BOOT_SERVICE_CAPABILITY);
+
+ Status = TCG2->GetCapability (
+ TCG2,
+ &BootServiceCap);
+
+ AssertionType = EFI_TEST_ASSERTION_PASSED;
+
+ StructureVersionMajor = BootServiceCap.StructureVersion.Major;
+ StructureVersionMinor = BootServiceCap.StructureVersion.Minor;
+
+ // TCG EFI Protocol spec 6.4.4 #4
+ if ((StructureVersionMajor != 1) | (StructureVersionMinor != 1)) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol GetCapablity Test: GetCapabilty should have StructureVersion 1.1"
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ ProtocolVersionMajor = BootServiceCap.ProtocolVersion.Major;
+ ProtocolVersionMinor = BootServiceCap.ProtocolVersion.Minor;
+
+ // TCG EFI Protocol spec 6.4.4 #4
+ if ((ProtocolVersionMajor != 1) | (ProtocolVersionMinor != 1)) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol GetCapablity Test: protocol version must be 1.1"
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ if (!(BootServiceCap.SupportedEventLogs & EFI_TCG2_EVENT_LOG_FORMAT_TCG_2)) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol GetCapablity Test: GetCapabilty must support TCG2 event log format"
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ if (BootServiceCap.NumberOfPcrBanks < 1 ) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol GetCapablity Test: expect at least 1 PCR bank"
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ EFI_TCG2_EVENT_ALGORITHM_BITMAP HashBitMapAlgos = EFI_TCG2_BOOT_HASH_ALG_SHA256 | EFI_TCG2_BOOT_HASH_ALG_SHA384 | EFI_TCG2_BOOT_HASH_ALG_SHA512;
+
+ if (!(BootServiceCap.HashAlgorithmBitmap & HashBitMapAlgos)) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol GetCapablity Test: unexpected hash algorithms reported = %x",
+ BootServiceCap.HashAlgorithmBitmap
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ if (!(BootServiceCap.ActivePcrBanks & HashBitMapAlgos)) {
+ StandardLib->RecordMessage (
+ StandardLib,
+ EFI_VERBOSE_LEVEL_DEFAULT,
+ L"\r\nTCG2 Protocol GetCapablity Test: unexpected active PCR banks reported = %x",
+ BootServiceCap.ActivePcrBanks
+ );
+
+ AssertionType = EFI_TEST_ASSERTION_FAILED;
+ }
+
+ StandardLib->RecordAssertion (
+ StandardLib,
+ AssertionType,
+ gTcg2ConformanceTestAssertionGuid003,
+ L"TCG2_PROTOCOL.GetCapability - GetCapability checks failed",
+ L"%a:%d: Status - %r",
+ __FILE__,
+ (UINTN)__LINE__,
+ Status
+ );
+
+ return EFI_SUCCESS;
+}
+
diff --git a/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c
new file mode 100644
index 000000000000..97da8f58e35f
--- /dev/null
+++ b/uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c
@@ -0,0 +1,102 @@
+/** @file
+
+ Copyright 2006 - 2017 Unified EFI, Inc.<BR>
+ Copyright (c) 2013, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2021, Arm Inc. All rights reserved.<BR>
+
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+/*++
+
+Module Name:
+ TCG2ProtocolBBTestMain.c
+
+Abstract:
+ for EFI TCG2 Protocol Test
+
+--*/
+
+#include "TCG2ProtocolBBTest.h"
+
+EFI_BB_TEST_PROTOCOL_FIELD gBBTestProtocolField = {
+ EFI_TCG2_TEST_REVISION,
+ EFI_TCG2_PROTOCOL_GUID,
+ L"Testing For EFI TCG2 Protocol",
+ L"Total # test cases for the EFI TCG2 Protocol"
+};
+
+EFI_GUID gSupportProtocolGuid1[2] = {
+ EFI_STANDARD_TEST_LIBRARY_GUID,
+ EFI_NULL_GUID
+};
+
+EFI_BB_TEST_ENTRY_FIELD gBBTestEntryField[] = {
+ {
+ EFI_TCG2_PROTOCOL_TEST_ENTRY_GUID0101,
+ L"GetCapability_Conf",
+ L"Test the GetCapablity API",
+ EFI_TEST_LEVEL_DEFAULT,
+ gSupportProtocolGuid1,
+ EFI_TEST_CASE_AUTO,
+ BBTestGetCapabilityConformanceTest
+ },
+ 0
+};
+
+EFI_BB_TEST_PROTOCOL *gBBTestProtocolInterface;
+
+/**
+ * Creates/installs the BlackBox Interface and eminating Entry Point
+ * node list.
+ * @param ImageHandle The test driver image handle
+ * @param SystemTable Pointer to System Table
+ * @return EFI_SUCCESS Indicates the interface was installed
+ * @return EFI_OUT_OF_RESOURCES Indicates space for the new handle could not be allocated
+ * @return EFI_INVALID_PARAMETER: One of the parameters has an invalid value.
+ */
+EFI_STATUS
+EFIAPI
+InitializeBBTestTCG2Protocol (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EfiInitializeTestLib (ImageHandle, SystemTable);
+
+ //
+ // initialize test utility lib
+ //
+ SctInitializeLib (ImageHandle, SystemTable);
+
+ return EfiInitAndInstallBBTestInterface (
+ &ImageHandle,
+ &gBBTestProtocolField,
+ gBBTestEntryField,
+ BBTestTCG2ProtocolUnload,
+ &gBBTestProtocolInterface
+ );
+}
+
+/**
+ * The driver's Unload function
+ * @param ImageHandle The test driver image handle
+ * @return EFI_SUCCESS Indicates the interface was Uninstalled
+*/
+EFI_STATUS
+EFIAPI
+BBTestTCG2ProtocolUnload (
+ IN EFI_HANDLE ImageHandle
+ )
+{
+ return EfiUninstallAndFreeBBTestInterface (
+ ImageHandle,
+ gBBTestProtocolInterface
+ );
+}
diff --git a/uefi-sct/SctPkg/UEFI/UEFI_SCT.dsc b/uefi-sct/SctPkg/UEFI/UEFI_SCT.dsc
index 5b3e5307e8f1..3d3e9704e8db 100644
--- a/uefi-sct/SctPkg/UEFI/UEFI_SCT.dsc
+++ b/uefi-sct/SctPkg/UEFI/UEFI_SCT.dsc
@@ -288,6 +288,7 @@ SctPkg/TestCase/UEFI/EFI/Protocol/StorageSecurityCommand/BlackBoxTest/StorageSec
SctPkg/TestCase/UEFI/EFI/Protocol/AdapterInfo/BlackBoxTest/AdapterInfoProtocolBBTest.inf
SctPkg/TestCase/UEFI/EFI/Protocol/TimeStamp/BlackBoxTest/TimeStampProtocolBBTest.inf
SctPkg/TestCase/UEFI/EFI/Protocol/RandomNumber/BlackBoxTest/RandomNumberBBTest.inf
+SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.inf

SctPkg/TestCase/UEFI/EFI/Protocol/Hash2/BlackBoxTest/Hash2BBTest.inf
SctPkg/TestCase/UEFI/EFI/Protocol/PKCS7Verify/BlackBoxTest/Pkcs7BBTest.inf
--
2.17.1


[PATCH 1/6] uefi-sct/SctPkg: TCG2 Protocol: add header with TCG2 protocol definitions

Joseph Hemann
 

From: Joseph Hemann <Joseph.hemann@...>

Cc: G Edhaya Chandran <Edhaya.Chandran@...>
Cc: Barton Gao <gaojie@...>
Cc: Carolyn Gjertsen <Carolyn.Gjertsen@...>
Cc: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@...>
Cc: Eric Jin <eric.jin@...>
Cc: Arvin Chen <arvinx.chen@...>
Cc: Supreeth Venkatesh <Supreeth.Venkatesh@...>

Signed-off-by: Joseph Hemann <Joseph.hemann@...>
---
uefi-sct/SctPkg/UEFI/Protocol/TCG2.h | 174 +++++++++++++++++++++++++++
1 file changed, 174 insertions(+)
create mode 100644 uefi-sct/SctPkg/UEFI/Protocol/TCG2.h

diff --git a/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h b/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h
new file mode 100644
index 000000000000..9ece78e0deaf
--- /dev/null
+++ b/uefi-sct/SctPkg/UEFI/Protocol/TCG2.h
@@ -0,0 +1,174 @@
+/** @file
+
+ Copyright 2006 - 2016 Unified EFI, Inc.<BR>
+ Copyright (c) 2013 - 2016, Intel Corporation. All rights reserved.<BR>
+ Copyright (c) 2021, Arm Inc. All rights reserved.<BR>
+
+ This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+/*++
+
+Module Name:
+
+ TCG2.h
+
+Abstract:
+
+ EFI TCG Protocol
+
+--*/
+
+
+#ifndef __TCG2_PROTOCOL_H__
+#define __TCG2_PROTOCOL_H__
+
+//
+// Global ID for the TCG2 Protocol
+//
+#define EFI_TCG2_PROTOCOL_GUID \
+ {0x607f766c, 0x7455, 0x42be, {0x93, 0x0b, 0xe4, 0xd7, 0x6d, 0xb2, 0x72, 0x0f}}
+
+// Following defintions come from TCG2 Efi Protocol Spec
+#define EFI_TCG2_BOOT_HASH_ALG_SHA1 0x00000001
+
+#define EFI_TCG2_BOOT_HASH_ALG_SHA256 0x00000002
+
+#define EFI_TCG2_BOOT_HASH_ALG_SHA384 0x00000004
+
+#define EFI_TCG2_BOOT_HASH_ALG_SHA512 0x00000008
+
+#define EFI_TCG2_BOOT_HASH_ALG_SM3_256 0x00000010
+
+#define EFI_TCG2_EVENT_LOG_FORMAT_TCG_1_2 0x00000001
+
+#define EFI_TCG2_EVENT_LOG_FORMAT_TCG_2 0x00000002
+
+typedef struct _EFI_TCG2_PROTOCOL EFI_TCG2_PROTOCOL;
+
+typedef UINT64 EFI_PHYSICAL_ADDRESS;
+
+typedef UINT32 EFI_TCG2_EVENT_LOG_BITMAP;
+
+typedef UINT32 EFI_TCG2_EVENT_LOG_FORMAT;
+
+typedef UINT32 EFI_TCG2_EVENT_ALGORITHM_BITMAP;
+
+typedef UINT32 TCG_PCRINDEX;
+
+typedef UINT32 TCG_EVENTTYPE;
+
+// Following struct defintions come from TCG2 Efi Protocol Spec
+typedef struct {
+ UINT8 Major;
+ UINT8 Minor;
+} EFI_TCG2_VERSION;
+
+typedef struct {
+ UINT8 Size;
+ EFI_TCG2_VERSION StructureVersion;
+ EFI_TCG2_VERSION ProtocolVersion;
+ EFI_TCG2_EVENT_ALGORITHM_BITMAP HashAlgorithmBitmap;
+ EFI_TCG2_EVENT_LOG_BITMAP SupportedEventLogs;
+ BOOLEAN TPMPresentFlag;
+ UINT16 MaxCommandSize;
+ UINT16 MaxResponseSize;
+ UINT32 ManufacturerID;
+ UINT32 NumberOfPcrBanks;
+ EFI_TCG2_EVENT_ALGORITHM_BITMAP ActivePcrBanks;
+} EFI_TCG2_BOOT_SERVICE_CAPABILITY;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TCG2_GET_CAPABILITY) (
+ IN EFI_TCG2_PROTOCOL *This,
+ IN OUT EFI_TCG2_BOOT_SERVICE_CAPABILITY *ProtocolCapability
+);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TCG2_GET_EVENT_LOG) (
+ IN EFI_TCG2_PROTOCOL *This,
+ IN EFI_TCG2_EVENT_LOG_FORMAT EventLogFormat,
+ OUT EFI_PHYSICAL_ADDRESS *EventLogLocation,
+ OUT EFI_PHYSICAL_ADDRESS *EventLogLastEntry,
+ OUT BOOLEAN *EventLogTruncated
+);
+
+typedef struct tdEFI_TCG2_EVENT_HEADER {
+ UINT32 HeaderSize;
+ UINT16 HeaderVersion;
+ TCG_PCRINDEX PCRIndex;
+ TCG_EVENTTYPE EventType;
+} EFI_TCG2_EVENT_HEADER;
+
+typedef struct tdEFI_TCG2_EVENT {
+ UINT32 Size;
+ EFI_TCG2_EVENT_HEADER Header;
+ UINT8 Event[];
+} EFI_TCG2_EVENT;
+
+typedef
+EFI_STATUS
+(EFIAPI * EFI_TCG2_HASH_LOG_EXTEND_EVENT) (
+ IN EFI_TCG2_PROTOCOL *This,
+ IN UINT64 Flags,
+ IN EFI_PHYSICAL_ADDRESS DataToHash,
+ IN UINT64 DataToHashLen,
+ IN EFI_TCG2_EVENT *EfiTcgEvent
+);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TCG2_SUBMIT_COMMAND) (
+ IN EFI_TCG2_PROTOCOL *This,
+ IN UINT32 InputParameterBlockSize,
+ IN UINT8 *InputParameterBlock,
+ IN UINT32 OutputParameterBlockSize,
+ IN UINT8 *OutputParameterBlock
+);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TCG2_GET_ACTIVE_PCR_BANKS) (
+ IN EFI_TCG2_PROTOCOL *This,
+ OUT UINT32 *ActivePcrBanks
+);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TCG2_SET_ACTIVE_PCR_BANKS) (
+ IN EFI_TCG2_PROTOCOL *This,
+ IN UINT32 ActivePcrBanks
+);
+
+typedef
+EFI_STATUS
+(EFIAPI * EFI_TCG2_GET_RESULT_OF_SET_ACTIVE_PCR_BANKS) (
+ IN EFI_TCG2_PROTOCOL *This,
+ OUT UINT32 *OperationPresent,
+ OUT UINT32 *Response
+);
+
+//
+// Interface structure for the TCG2 Protocol
+//
+struct _EFI_TCG2_PROTOCOL {
+ EFI_TCG2_GET_CAPABILITY GetCapability;
+ EFI_TCG2_GET_EVENT_LOG GetEventLog;
+ EFI_TCG2_HASH_LOG_EXTEND_EVENT HashLogExtendEvent;
+ EFI_TCG2_SUBMIT_COMMAND SubmitCommand;
+ EFI_TCG2_GET_ACTIVE_PCR_BANKS GetActivePcrBanks;
+ EFI_TCG2_SET_ACTIVE_PCR_BANKS SetActivePcrBanks;
+ EFI_TCG2_GET_RESULT_OF_SET_ACTIVE_PCR_BANKS GetResultOfSetActivePcrBanks;
+};
+
+extern EFI_GUID gEfiTcg2ProtocolGuid;
+
+#endif
--
2.17.1


[PATCH 0/6] Implementation of TCG2 Protocol test

Joseph Hemann
 

From: Joseph Hemann <Joseph.hemann@...>

This patch series implements a set of SCT tests,
for the TCG2 UEFI protocol as defined in the TCG
EFI Protocol Specification. The series implements
the code for the test, and the infrastructure
needed to run the test from the SCT UI.

Patch 1 adds header file with TCG2 protocol definitions.

Patch 2 implements initial infrastructure for the
TCG2 protocol test including updates to .dsc file,
inf file, GUID source files, update to Category.ini.
It also adds initial TCG2 protocol test for GetCapability().

Patch 3 implements TCG2 protocol test for GetActivePcrBanks().

Patch 4 implements a test for HashLogExtendEvent() by hashing,
and extending data in a test buffer to PCR[16].

Patch 5 implements a test for GetEventLog(), by checking for
the event extended in the test in Patch 4.

Patch 6 tests SubmitCommand(), by submitting a simple command
(GetRandom) to the TPM.

Cc: G Edhaya Chandran <Edhaya.Chandran@...>
Cc: Barton Gao <gaojie@...>
Cc: Carolyn Gjertsen <Carolyn.Gjertsen@...>
Cc: Samer El-Haj-Mahmoud <Samer.El-Haj-Mahmoud@...>
Cc: Eric Jin <eric.jin@...>
Cc: Arvin Chen <arvinx.chen@...>
Cc: Supreeth Venkatesh <Supreeth.Venkatesh@...>

Joseph Hemann (6):
uefi-sct/SctPkg: TCG2 Protocol: add header with TCG2 protocol
definitions
uefi-sct/SctPkg: TCG2 Protocol: add GetCapability Test
uefi-sct/SctPkg: TCG2 Protocol: add GetActivePcrBanks test
uefi-sct/SctPkg: TCG2 Protocol: add HashLogExtendEvent test
uefi-sct/SctPkg: TCG2 Protocol: add GetEventLog test
uefi-sct/SctPkg: TCG2 Protocol: add SubmitCommand test

uefi-sct/SctPkg/CommonGenFramework.sh | 1 +
uefi-sct/SctPkg/Config/Data/Category.ini | 7 +
.../EFI/Protocol/TCG2/BlackBoxTest/Guid.c | 59 +
.../EFI/Protocol/TCG2/BlackBoxTest/Guid.h | 102 ++
.../TCG2/BlackBoxTest/TCG2ProtocolBBTest.h | 180 +++
.../TCG2/BlackBoxTest/TCG2ProtocolBBTest.inf | 51 +
.../TCG2ProtocolBBTestConformance.c | 1017 +++++++++++++++++
.../BlackBoxTest/TCG2ProtocolBBTestMain.c | 130 +++
uefi-sct/SctPkg/UEFI/Protocol/TCG2.h | 219 ++++
uefi-sct/SctPkg/UEFI/UEFI_SCT.dsc | 1 +
10 files changed, 1767 insertions(+)
create mode 100644 uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.c
create mode 100644 uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/Guid.h
create mode 100644 uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.h
create mode 100644 uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTest.inf
create mode 100644 uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestConformance.c
create mode 100644 uefi-sct/SctPkg/TestCase/UEFI/EFI/Protocol/TCG2/BlackBoxTest/TCG2ProtocolBBTestMain.c
create mode 100644 uefi-sct/SctPkg/UEFI/Protocol/TCG2.h

--
2.17.1


Re: [PATCH v1 1/1] ShellPkg: Add comment that ItemPtr is set after validation

Sami Mujawar
 

Hi Chris,

Thanks for adding the comment that clarifies the usage.

Reviewed-by: Sami Mujawar <sami.mujawar@...>

Regards,

Sami Mujawar

On 20/10/2021, 11:47, "Chris Jones" <christopher.jones@...> wrote:

Add a comment to clarify that in Acpiview the ItemPtr is not set until
after the FieldValidator has been called.

Signed-off-by: Chris Jones <christopher.jones@...>
---
ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
index 0b7726b9d5807ad2f5c5447408c4c5451718938b..5e34a70c8baeaaa05ecd797d405f1fc62a44a305 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
@@ -283,7 +283,9 @@ typedef struct AcpiParser {
FNPTR_PRINT_FORMATTER PrintFormatter;

/// Optional pointer which may be set to request the parser to update
- /// a pointer to the field data. If unused this must be set to NULL.
+ /// a pointer to the field data. This value is set after the FieldValidator
+ /// has been called and therefore should not be used by the FieldValidator.
+ /// If unused this must be set to NULL.
VOID** ItemPtr;

/// Optional pointer to a field validator function.
--
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")


[PATCH v1 1/1] ShellPkg: Add comment that ItemPtr is set after validation

Chris Jones
 

Add a comment to clarify that in Acpiview the ItemPtr is not set until
after the FieldValidator has been called.

Signed-off-by: Chris Jones <christopher.jones@...>
---
ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
index 0b7726b9d5807ad2f5c5447408c4c5451718938b..5e34a70c8baeaaa05ecd797d405f1fc62a44a305 100644
--- a/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
+++ b/ShellPkg/Library/UefiShellAcpiViewCommandLib/AcpiParser.h
@@ -283,7 +283,9 @@ typedef struct AcpiParser {
FNPTR_PRINT_FORMATTER PrintFormatter;

/// Optional pointer which may be set to request the parser to update
- /// a pointer to the field data. If unused this must be set to NULL.
+ /// a pointer to the field data. This value is set after the FieldValidator
+ /// has been called and therefore should not be used by the FieldValidator.
+ /// If unused this must be set to NULL.
VOID** ItemPtr;

/// Optional pointer to a field validator function.
--
Guid("CE165669-3EF3-493F-B85D-6190EE5B9759")


Re: [PATCH 1/1] DynamicTablesPkg: Fix void pointer arithmetic

Sami Mujawar
 

Hi Pierre,

Thank you for this fix.

Reviewed-by: Sami Mujawar <sami.mujawar@...>

Regards,

Sami Mujawar


On 14/10/2021 03:59 PM, Pierre.Gondois@... wrote:
From: Pierre Gondois <Pierre.Gondois@...>

Building the DynamicTablesPkg with the additional
-Wpointer-arith flag triggers the following error:
"pointer of type ‘void *’ used in arithmetic
[-Werror=pointer-arith]"

Cast the void pointer to fix the error.

Signed-off-by: Pierre Gondois <Pierre.Gondois@...>
---
.../Common/TableHelperLib/ConfigurationManagerObjectParser.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/DynamicTablesPkg/Library/Common/TableHelperLib/ConfigurationManagerObjectParser.c b/DynamicTablesPkg/Library/Common/TableHelperLib/ConfigurationManagerObjectParser.c
index 2337d47e3fb3..0bdbfbb99c33 100644
--- a/DynamicTablesPkg/Library/Common/TableHelperLib/ConfigurationManagerObjectParser.c
+++ b/DynamicTablesPkg/Library/Common/TableHelperLib/ConfigurationManagerObjectParser.c
@@ -641,7 +641,7 @@ PrintCmObjDesc (
));
}
DEBUG ((DEBUG_ERROR, "\n"));
- Data += Parser[Index].Length;
+ Data = (UINT8*)Data + Parser[Index].Length;
} // for
}
IMPORTANT NOTICE: The contents of this email and any attachments are confidential and may also be privileged. If you are not the intended recipient, please notify the sender immediately and do not disclose the contents to any other person, use it for any purpose, or store or copy the information in any medium. Thank you.


Re: [PATCH] DynamicTablesPkg: Fix unitialized variable use

Sami Mujawar
 

Merged as 37a33f02aa1a..4fdf843c75d2

Thanks.

Regards,

Sami Mujawar

On 20/10/2021 10:40 AM, Sami Mujawar wrote:
Hi Moritz,

Thank you for this fix.

Reviewed-by: Sami Mujawar <sami.mujawar@...>

Regards,

Sami Mujawar

On 20/10/2021 06:21 AM, Moritz Fischer wrote:
In the success case we should return EFI_SUCCESS rather than returning
a potentially unitialized value of Status.

Cc: Sami Mujawar <Sami.Mujawar@...>
Cc: Alexei Fedorov <Alexei.Fedorov@...>
Signed-off-by: Moritz Fischer <moritzf@...>
---
.../Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c
index 0bdb6c24c5bb..e9e1a85ede63 100644
---
a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c
+++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c
@@ -91,7 +91,7 @@ LinkRdNode (
*NewRdNode = RdNode;
}
- return Status;
+ return EFI_SUCCESS;
error_handler:
Status1 = AmlDeleteTree ((AML_NODE_HEADER*)RdNode);


Re: [PATCH] DynamicTablesPkg: Fix unitialized variable use

Sami Mujawar
 

Hi Moritz,

Thank you for this fix.

Reviewed-by: Sami Mujawar <sami.mujawar@...>

Regards,

Sami Mujawar

On 20/10/2021 06:21 AM, Moritz Fischer wrote:
In the success case we should return EFI_SUCCESS rather than returning
a potentially unitialized value of Status.

Cc: Sami Mujawar <Sami.Mujawar@...>
Cc: Alexei Fedorov <Alexei.Fedorov@...>
Signed-off-by: Moritz Fischer <moritzf@...>
---
.../Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c
index 0bdb6c24c5bb..e9e1a85ede63 100644
--- a/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c
+++ b/DynamicTablesPkg/Library/Common/AmlLib/CodeGen/AmlResourceDataCodeGen.c
@@ -91,7 +91,7 @@ LinkRdNode (
*NewRdNode = RdNode;
}
- return Status;
+ return EFI_SUCCESS;
error_handler:
Status1 = AmlDeleteTree ((AML_NODE_HEADER*)RdNode);


Re: [PATCH V2 1/3] MdePkg: Introduce TdProtocol for TD-Guest firmware

Sami Mujawar
 

Hi Jiewen,

Please find my response inline marked [SAMI].

Regards,

Sami Mujawar

On 19/10/2021 03:40 PM, Yao, Jiewen via groups.io wrote:
Good feedback. Thank you very much, Sami.

Response inline.

I proposed some naming change. Please let us know if that is OK.

Thank you
Yao, Jiewen



-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Sami
Mujawar
Sent: Tuesday, October 19, 2021 9:21 PM
To: devel@edk2.groups.io; Xu, Min M <min.m.xu@...>
Cc: Kinney, Michael D <michael.d.kinney@...>; Liming Gao
<gaoliming@...>; Liu, Zhiguang <zhiguang.liu@...>; Yao,
Jiewen <jiewen.yao@...>; Wang, Jian J <jian.j.wang@...>; Lu, Ken
<ken.lu@...>; nd <nd@...>; Joey Gouly <Joey.Gouly@...>
Subject: Re: [edk2-devel] [PATCH V2 1/3] MdePkg: Introduce TdProtocol for TD-
Guest firmware

Hi Min, Jiewen,

Thank you for this patch.

I think the protocol definition can be made architecturally neutral with
a few modifications marked inline as [SAMI].

I am fine with renaming the protocol to either
EFI_TEE_MEASUREMENT_PROTOCOL or EFI_CCAM_PROTOCOL. Similarly, some
of
the data structures, variables, etc. would need renaming as well.

Please let me know if you have any queries.

Regards,

Sami Mujawar

On 08/10/2021 06:21 AM, Min Xu via groups.io wrote:
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3625

If TD-Guest firmware supports measurement and an event is created,
TD-Guest firmware is designed to report the event log with the same data
structure in TCG-Platform-Firmware-Profile specification with
EFI_TCG2_EVENT_LOG_FORMAT_TCG_2 format.

The TD-Guest firmware supports measurement, the TD Guest Firmware is
designed to produce EFI_TD_PROTOCOL with new GUID
EFI_TD_PROTOCOL_GUID
to report event log and provides hash capability.

https://software.intel.com/content/dam/develop/external/us/en/documents/
intel-tdx-guest-hypervisor-communication-interface-1.0-344426-002.pdf
Section 4.3.2 includes the EFI_TD_PROTOCOL.

Cc: Michael D Kinney <michael.d.kinney@...>
Cc: Liming Gao <gaoliming@...>
Cc: Zhiguang Liu <zhiguang.liu@...>
Cc: Jiewen Yao <jiewen.yao@...>
Cc: Jian J Wang <jian.j.wang@...>
Cc: Ken Lu <ken.lu@...>
Reviewed-by: Jiewen Yao <jiewen.yao@...>
Signed-off-by: Min Xu <min.m.xu@...>
---
MdePkg/Include/Protocol/TdProtocol.h | 305
+++++++++++++++++++++++++++
MdePkg/MdePkg.dec | 3 +
2 files changed, 308 insertions(+)
create mode 100644 MdePkg/Include/Protocol/TdProtocol.h

diff --git a/MdePkg/Include/Protocol/TdProtocol.h
b/MdePkg/Include/Protocol/TdProtocol.h
new file mode 100644
index 000000000000..89b09928d33a
--- /dev/null
+++ b/MdePkg/Include/Protocol/TdProtocol.h
@@ -0,0 +1,305 @@
+/** @file
+ If TD-Guest firmware supports measurement and an event is created, TD-
Guest
+ firmware is designed to report the event log with the same data structure
+ in TCG-Platform-Firmware-Profile specification with
+ EFI_TCG2_EVENT_LOG_FORMAT_TCG_2 format.
+
+ The TD-Guest firmware supports measurement, the TD Guest Firmware is
designed
+ to produce EFI_TD_PROTOCOL with new GUID EFI_TD_PROTOCOL_GUID to
report
+ event log and provides hash capability.
+
+Copyright (c) 2020 - 2021, Intel Corporation. All rights reserved.<BR>
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+
+#ifndef TD_PROTOCOL_H_
+#define TD_PROTOCOL_H_
+
+#include <Uefi/UefiBaseType.h>
+#include <IndustryStandard/UefiTcgPlatform.h>
+#include <IndustryStandard/Tpm20.h>
[SAMI] Maybe the Tpm20.h include is not required here. Can you check,
please?
[Jiewen] Right. I don’t think we do need it in this definition.
I feel we just copy it from Tcg2Protocol.h.

+
+
+#define EFI_TD_PROTOCOL_GUID \
+ { 0x96751a3d, 0x72f4, 0x41a6, { 0xa7, 0x94, 0xed, 0x5d, 0x0e, 0x67, 0xae,
0x6b }}
+extern EFI_GUID gEfiTdProtocolGuid;
+
+typedef struct _EFI_TD_PROTOCOL EFI_TD_PROTOCOL;
[SAMI] I think this could be renamed to either
EFI_TEE_MEASUREMENT_PROTOCOL or EFI_CCAM_PROTOCOL. Similarly, the
usage
of _TD_ would need to be replaced accordingly.
[Jiewen] Agree.
I propose "EFI_TD_PROTOCOL"->"EFI_TEE_MEASUREMENT_PROTOCOL"
Also "TD"->"TEE"
[SAMI] Agree.
+
+typedef struct {
+ UINT8 Major;
+ UINT8 Minor;
+} EFI_TD_VERSION;
+
+typedef UINT32 EFI_TD_EVENT_LOG_BITMAP;
+typedef UINT32 EFI_TD_EVENT_LOG_FORMAT;
+typedef UINT32 EFI_TD_EVENT_ALGORITHM_BITMAP;
+typedef UINT32 EFI_TD_MR_INDEX;
+
+#define EFI_TD_EVENT_LOG_FORMAT_TCG_2 0x00000002
+#define EFI_TD_BOOT_HASH_ALG_SHA384 0x00000004
[SAMI] It is good that the values for these macros match that of TCG2. I
believe it should be possible to extend these to add macros for other
algorithms in the future.
[Jiewen] Agree. If we change "TD"->"TEE", we can add other algo based upon real use case.
E.g. EFI_TEE_EVENT_LOG_..., EFI_TEE_MR_INDEX, EFI_TEE_BOOT_HASH_...
[SAMI] Ack.
+
+//
+// This bit is shall be set when an event shall be extended but not logged.
+//
+#define EFI_TD_FLAG_EXTEND_ONLY 0x0000000000000001
+//
+// This bit shall be set when the intent is to measure a PE/COFF image.
+//
+#define EFI_TD_FLAG_PE_COFF_IMAGE 0x0000000000000010
+
+#define MR_INDEX_MRTD 0
+#define MR_INDEX_RTMR0 1
+#define MR_INDEX_RTMR1 2
+#define MR_INDEX_RTMR2 3
+#define MR_INDEX_RTMR3 4
+
[SAMI] I think these indexes could go to a TD specific include file Or
the indexes could be defined generically. May be it would be good to
introduce a PcdMaxMrIndex that is configurable for different
architectures. This may be useful should any asserts/checks are needed
in the code.
[Jiewen] Right. This is TD specific index.
We need rename it to TDX_MR_INDEX_*.

I think we need add new fields in EFI_TD_BOOT_SERVICE_CAPABILITY.

typedef UINT8 EFI_TEE_TYPE; // match https://github.com/tianocore/edk2/blob/master/OvmfPkg/Include/WorkArea.h, NONE = 0, AMD_SEV = 1, INTEL_TDX = 2, we can add more here.
typedef UINT8 EFI_TEE_SUBTYPE; // TEE-type specific subtype.
[SAMI] This is a good idea. If I understand correctly, there is this going to be a new enum definition for the TEE architecture (with NONE =0, AMD_SEV = 1, INTEL_TDX = 2, etc.), and the EFI_TEE_SUBTYPE values would probably be left to be defined by the respective architectures.
As such, the caller can know what event log / index it is using.

E.g. If TeeType is TDX, then the INDEX matches the TDX RTMR.
If TeeType is Realm, then the INDEX matches something else.
[SAMI] Agree.
I am not sure the usage of PcdMaxMrIndex. We SHALL NOT define PCD in a protocol in general.
Would you please share your idea on how to use PcdMaxMrIndex? Then we can have better solution.
[SAMI] The TCG2 protocol definition file has MAX_PCR_INDEX. So, I thought introducing a PCD for MaxMrIndex will provide flexibility for defining the maximum number of measurement registers provided by different architectures.
At this point I don't see a usecase other than for validating that the MaxMrIndex is not exceeded. So, we can drop PcdMaxMrIndex for now.
[/SAMI]

+//
+// This bit shall be set when the intent is to measure a PE/COFF image.
+//
+#define PE_COFF_IMAGE 0x0000000000000010
+
[SAMI] I think this macro is not needed.
[Jiewen] This is to align with TCG2 protocol. I think we need to measurement UEFI image.
Is there any concern to keep it?
[SAMI] I thought EFI_TD_FLAG_PE_COFF_IMAGE above is for the same purpose. So, thought this was duplicate.


+#pragma pack (1)
+
+#define EFI_TD_EVENT_HEADER_VERSION 1
+
+typedef struct {
+ //
+ // Size of the event header itself (sizeof(EFI_TD_EVENT_HEADER)).
+ //
+ UINT32 HeaderSize;
+ //
+ // Header version. For this version of this specification, the value shall be 1.
+ //
+ UINT16 HeaderVersion;
+ //
+ // Index of the MR that shall be extended.
+ //
+ EFI_TD_MR_INDEX MrIndex;
+ //
+ // Type of the event that shall be extended (and optionally logged).
+ //
+ UINT32 EventType;
+} EFI_TD_EVENT_HEADER;
+
+typedef struct {
+ //
+ // Total size of the event including the Size component, the header and the
Event data.
+ //
+ UINT32 Size;
+ EFI_TD_EVENT_HEADER Header;
+ UINT8 Event[1];
+} EFI_TD_EVENT;
+
+#pragma pack()
+
+
+typedef struct {
+ //
+ // Allocated size of the structure
+ //
+ UINT8 Size;
+ //
+ // Version of the EFI_TD_BOOT_SERVICE_CAPABILITY structure itself.
+ // For this version of the protocol, the Major version shall be set to 1
+ // and the Minor version shall be set to 1.
+ //
+ EFI_TD_VERSION StructureVersion;
+ //
+ // Version of the EFI TD protocol.
+ // For this version of the protocol, the Major version shall be set to 1
+ // and the Minor version shall be set to 1.
+ //
+ EFI_TD_VERSION ProtocolVersion;
[SAMI] Should the protocol version be 1.0 (Major.Minor), as this is the
first introduction. Same for the StructureVersion field above.
[Jiewen] Copy/Past from TCG2.
Sure. We can start from 1.0 (not 1.1).

+ //
+ // Supported hash algorithms
+ //
+ EFI_TD_EVENT_ALGORITHM_BITMAP HashAlgorithmBitmap;
+ //
+ // Bitmap of supported event log formats
+ //
+ EFI_TD_EVENT_LOG_BITMAP SupportedEventLogs;
+
+ //
+ // False = TD not present
+ //
+ BOOLEAN TdPresentFlag;
[SAMI] I believe this would need to be renamed to something like
TeePresentFlag or CcaPresentFlag or a suitable alternative.
[Jiewen] Agree. I propose to remove TdPresentFlag.
Add "EFI_TEE_TYPE TeeType;" // 0 - None, 1 - SEV, 2 - TDX, ...
[SAMI] Ack.

+} EFI_TD_BOOT_SERVICE_CAPABILITY;
+
+/**
+ The EFI_TD_PROTOCOL GetCapability function call provides protocol
+ capability information and state information.
+
+ @param[in] This Indicates the calling context
+ @param[in, out] ProtocolCapability The caller allocates memory for a
EFI_TD_BOOT_SERVICE_CAPABILITY
+ structure and sets the size field to the size of the
structure allocated.
+ The callee fills in the fields with the EFI protocol
capability information
+ and the current EFI TD state information up to the
number of fields which
+ fit within the size of the structure passed in.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR The command was unsuccessful.
+ The ProtocolCapability variable will not be populated.
+ @retval EFI_INVALID_PARAMETER One or more of the parameters are
incorrect.
+ The ProtocolCapability variable will not be populated.
+ @retval EFI_BUFFER_TOO_SMALL The ProtocolCapability variable is too
small to hold the full response.
+ It will be partially populated (required Size field will be set).
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TD_GET_CAPABILITY) (
+ IN EFI_TD_PROTOCOL *This,
+ IN OUT EFI_TD_BOOT_SERVICE_CAPABILITY *ProtocolCapability
+ );
+
+/**
+ The EFI_TD_PROTOCOL Get Event Log function call allows a caller to
+ retrieve the address of a given event log and its last entry.
+
+ @param[in] This Indicates the calling context
+ @param[in] EventLogFormat The type of the event log for which the
information is requested.
+ @param[out] EventLogLocation A pointer to the memory address of the
event log.
+ @param[out] EventLogLastEntry If the Event Log contains more than one
entry, this is a pointer to the
+ address of the start of the last entry in the event log in
memory.
+ @param[out] EventLogTruncated If the Event Log is missing at least one
entry because an event would
+ have exceeded the area allocated for events, this value is
set to TRUE.
+ Otherwise, the value will be FALSE and the Event Log will
be complete.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_INVALID_PARAMETER One or more of the parameters are
incorrect
+ (e.g. asking for an event log whose format is not
supported).
+**/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TD_GET_EVENT_LOG) (
+ IN EFI_TD_PROTOCOL *This,
+ IN EFI_TD_EVENT_LOG_FORMAT EventLogFormat,
+ OUT EFI_PHYSICAL_ADDRESS *EventLogLocation,
+ OUT EFI_PHYSICAL_ADDRESS *EventLogLastEntry,
+ OUT BOOLEAN *EventLogTruncated
+ );
+
+/**
+ The EFI_TD_PROTOCOL HashLogExtendEvent function call provides callers
with
+ an opportunity to extend and optionally log events without requiring
+ knowledge of actual TD commands.
+ The extend operation will occur even if this function cannot create an event
+ log entry (e.g. due to the event log being full).
+
+ @param[in] This Indicates the calling context
+ @param[in] Flags Bitmap providing additional information.
+ @param[in] DataToHash Physical address of the start of the data
buffer to be hashed.
+ @param[in] DataToHashLen The length in bytes of the buffer referenced
by DataToHash.
+ @param[in] EfiTdEvent Pointer to data buffer containing information
about the event.
+
+ @retval EFI_SUCCESS Operation completed successfully.
+ @retval EFI_DEVICE_ERROR The command was unsuccessful.
+ @retval EFI_VOLUME_FULL The extend operation occurred, but the
event could not be written to one or more event logs.
+ @retval EFI_INVALID_PARAMETER One or more of the parameters are
incorrect.
+ @retval EFI_UNSUPPORTED The PE/COFF image type is not supported.
+**/
+typedef
+EFI_STATUS
+(EFIAPI * EFI_TD_HASH_LOG_EXTEND_EVENT) (
+ IN EFI_TD_PROTOCOL *This,
+ IN UINT64 Flags,
+ IN EFI_PHYSICAL_ADDRESS DataToHash,
+ IN UINT64 DataToHashLen,
+ IN EFI_TD_EVENT *EfiTdEvent
+ );
+
+/**
+ The EFI_TD_PROTOCOL MapPcrToMrIndex function call provides callers
+ the info on TPM PCR<-> measurement register mapping information.
+
+ In current version, we use below mapping:
+ PCR0 -> MRTD (Index 0)
+ PCR1 -> RTMR0 (Index 1)
+ PCR2~6 -> RTMR1 (Index 2)
+ PCR7 -> RTMR0 (Index 1)
+ PCR8~15 -> RTMR2 (Index 3)
+
[SAMI] I think different architecures may map the PCRs differently. I
think the comment could be reworded to a more generic representation of
the mapping.
Also, I need to check the mailing list if there is a patch that adds the
TD protocol implementaiton, and if it could be made generic as well.
Maybe the protocol implementation would need to use an architecture
specific library that provides the mapping function.
[/SAMI]
[Jiewen] Agree. We should clear up the comment.
The caller shall be generic enough to use this API to get the mapping.
The caller shall NOT make any assumption.
[SAMI] Ack.


+ @param[in] This Indicates the calling context
+ @param[in] PcrIndex TPM PCR index.
+ @param[out] MrIndex Measurement register index.
+
+ @retval EFI_SUCCESS The MR index is returned.
+ @retval EFI_INVALID_PARAMETER The MrIndex is NULL.
+ @retval EFI_UNSUPPORTED The PcrIndex is invalid.
+**/
+typedef
+EFI_STATUS
+(EFIAPI * EFI_TD_MAP_PCR_TO_MR_INDEX) (
+ IN EFI_TD_PROTOCOL *This,
+ IN TCG_PCRINDEX PcrIndex,
+ OUT EFI_TD_MR_INDEX *MrIndex
+ );
+
+struct _EFI_TD_PROTOCOL {
+ EFI_TD_GET_CAPABILITY GetCapability;
+ EFI_TD_GET_EVENT_LOG GetEventLog;
+ EFI_TD_HASH_LOG_EXTEND_EVENT HashLogExtendEvent;
+ EFI_TD_MAP_PCR_TO_MR_INDEX MapPcrToMrIndex;
+};
+
+
+//
+// TD event log
+//
+
+#pragma pack(1)
+
+//
+// Crypto Agile Log Entry Format.
+// It is similar with TCG_PCR_EVENT2 except the field of MrIndex and
PCRIndex.
+//
+typedef struct {
+ EFI_TD_MR_INDEX MrIndex;
+ UINT32 EventType;
+ TPML_DIGEST_VALUES Digests;
+ UINT32 EventSize;
+ UINT8 Event[1];
+} TD_EVENT;
+
+//
+// EFI TD Event Header
+// It is similar with TCG_PCR_EVENT2_HDR except the field of MrIndex and
PCRIndex
+//
+typedef struct {
+ EFI_TD_MR_INDEX MrIndex;
+ UINT32 EventType;
+ TPML_DIGEST_VALUES Digests;
+ UINT32 EventSize;
+} TD_EVENT_HDR;
+
+#pragma pack()
+
+//
+// Log entries after Get Event Log service
+//
+
+
+typedef struct {
+ //
+ // The version of this structure. It shall be set ot 1.
[SAMI] It may be good to define a macro for the events table version,
similar to EFI_TCG2_FINAL_EVENTS_TABLE_VERSION.
[Jiewen] Agree.

+ //
+ UINT64 Version;
+ //
+ // Number of events recorded after invocation of GetEventLog API
+ //
+ UINT64 NumberOfEvents;
+ //
+ // List of events of type TD_EVENT.
+ //
+ //TD_EVENT Event[1];
+} EFI_TD_FINAL_EVENTS_TABLE;
+
+
+#define EFI_TD_FINAL_EVENTS_TABLE_GUID \
+ {0xdd4a4648, 0x2de7, 0x4665, {0x96, 0x4d, 0x21, 0xd9, 0xef, 0x5f, 0xb4,
0x46}}
+
+extern EFI_GUID gEfiTdFinalEventsTableGuid;
+
+#endif
diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec
index 9cdc915ebae9..a31c44d3a689 100644
--- a/MdePkg/MdePkg.dec
+++ b/MdePkg/MdePkg.dec
@@ -1011,6 +1011,9 @@
## Include/Protocol/PcdInfo.h
gGetPcdInfoProtocolGuid = { 0x5be40f57, 0xfa68, 0x4610, { 0xbb, 0xbf,
0xe9, 0xc5, 0xfc, 0xda, 0xd3, 0x65 } }
+ ## Include/Protocol/TdProtocol.h
+ gEfiTdProtocolGuid = { 0x96751a3d, 0x72f4, 0x41a6, { 0xa7, 0x94,
0xed, 0x5d, 0x0e, 0x67, 0xae, 0x6b }}
+
#
# Protocols defined in PI1.0.
#





[PATCH v6] UefiPayloadPkg: Remove SystemTableInfo GUID.

thiyagukb
 

SystemTableInfo GUID is not a Spec defined GUID.
The latest SBL and CBL produces ACPI and SMBIOS table information.
So removing the SystemTableInfo GUID implementation.

Cc: Maurice Ma <maurice.ma@...>
Cc: Guo Dong <guo.dong@...>
Cc: Ray Ni <ray.ni@...>
Cc: Benjamin You <benjamin.you@...>
Cc: Zhiguang Liu <zhiguang.liu@...>

Signed-off-by: Guo Dong <guo.dong@...>
Signed-off-by: Thiyagu Kesavan Balakrishnan <thiyagux.kesavan.balakrishnan@...>
---
UefiPayloadPkg/BlSupportDxe/BlSupportDxe.h | 1 -
UefiPayloadPkg/BlSupportDxe/BlSupportDxe.inf | 1 -
UefiPayloadPkg/Include/Guid/SystemTableInfoGuid.h | 26 --------------------------
UefiPayloadPkg/Include/Library/BlParseLib.h | 25 ++++++++++++++++++++-----
UefiPayloadPkg/Library/CbParseLib/CbParseLib.c | 40 +++++++++++++++++++++++++++++++---------
UefiPayloadPkg/Library/SblParseLib/SblParseLib.c | 42 +++++++++++++++++++++++++++++++++++-------
UefiPayloadPkg/Library/SblParseLib/SblParseLib.inf | 1 -
UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c | 28 ++++++++++------------------
UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h | 1 -
UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf | 1 -
UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf | 1 -
UefiPayloadPkg/UefiPayloadPkg.dec | 1 -
12 files changed, 96 insertions(+), 72 deletions(-)

diff --git a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.h b/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.h
index 3332a30eae..b16ca4cc59 100644
--- a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.h
+++ b/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.h
@@ -20,7 +20,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Library/HobLib.h>

#include <Guid/SmBios.h>
-#include <Guid/SystemTableInfoGuid.h>
#include <Guid/AcpiBoardInfoGuid.h>
#include <Guid/GraphicsInfoHob.h>

diff --git a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.inf b/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.inf
index 1ccb250991..96d85d2b1d 100644
--- a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.inf
+++ b/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.inf
@@ -42,7 +42,6 @@
HobLib

[Guids]
- gUefiSystemTableInfoGuid
gUefiAcpiBoardInfoGuid
gEfiGraphicsInfoHobGuid

diff --git a/UefiPayloadPkg/Include/Guid/SystemTableInfoGuid.h b/UefiPayloadPkg/Include/Guid/SystemTableInfoGuid.h
deleted file mode 100644
index e742dd0ca5..0000000000
--- a/UefiPayloadPkg/Include/Guid/SystemTableInfoGuid.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/** @file
- This file defines the hob structure for system tables like ACPI, SMBIOS tables.
-
- Copyright (c) 2014 - 2019, Intel Corporation. All rights reserved.<BR>
- SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-#ifndef SYSTEM_TABLE_INFO_GUID_H_
-#define SYSTEM_TABLE_INFO_GUID_H_
-
-///
-/// System Table Information GUID
-///
-extern EFI_GUID gUefiSystemTableInfoGuid;
-
-typedef struct {
- UINT8 Revision;
- UINT8 Reserved0[3];
- UINT64 AcpiTableBase;
- UINT32 AcpiTableSize;
- UINT64 SmbiosTableBase;
- UINT32 SmbiosTableSize;
-} SYSTEM_TABLE_INFO;
-
-#endif
diff --git a/UefiPayloadPkg/Include/Library/BlParseLib.h b/UefiPayloadPkg/Include/Library/BlParseLib.h
index 7198e419bd..fb7bb0cb0e 100644
--- a/UefiPayloadPkg/Include/Library/BlParseLib.h
+++ b/UefiPayloadPkg/Include/Library/BlParseLib.h
@@ -13,8 +13,9 @@
#include <Guid/GraphicsInfoHob.h>
#include <Guid/MemoryMapInfoGuid.h>
#include <Guid/SerialPortInfoGuid.h>
-#include <Guid/SystemTableInfoGuid.h>
#include <Guid/AcpiBoardInfoGuid.h>
+#include <UniversalPayload/AcpiTable.h>
+#include <UniversalPayload/SmbiosTable.h>

#define GET_BOOTLOADER_PARAMETER() PcdGet64 (PcdBootloaderParameter)

@@ -55,9 +56,9 @@ ParseMemoryInfo (
);

/**
- Acquire acpi table and smbios table from slim bootloader
+ Acquire SMBIOS table from bootloader.

- @param SystemTableInfo Pointer to the system table info
+ @param SmbiosTable Pointer to the system table info

@retval RETURN_SUCCESS Successfully find out the tables.
@retval RETURN_NOT_FOUND Failed to find the tables.
@@ -65,10 +66,24 @@ ParseMemoryInfo (
**/
RETURN_STATUS
EFIAPI
-ParseSystemTable (
- OUT SYSTEM_TABLE_INFO *SystemTableInfo
+ParseSmbiosTable (
+ OUT UNIVERSAL_PAYLOAD_SMBIOS_TABLE *SmbiosTable
);

+/**
+ Acquire ACPI table from bootloader.
+
+ @param AcpiTableHob Pointer to the ACPI table info.
+
+ @retval RETURN_SUCCESS Successfully find out the tables.
+ @retval RETURN_NOT_FOUND Failed to find the tables.
+
+**/
+RETURN_STATUS
+EFIAPI
+ParseAcpiTableInfo (
+ OUT UNIVERSAL_PAYLOAD_ACPI_TABLE *AcpiTableHob
+ );

/**
Find the serial port information
diff --git a/UefiPayloadPkg/Library/CbParseLib/CbParseLib.c b/UefiPayloadPkg/Library/CbParseLib/CbParseLib.c
index 46314e5566..61c5683260 100644
--- a/UefiPayloadPkg/Library/CbParseLib/CbParseLib.c
+++ b/UefiPayloadPkg/Library/CbParseLib/CbParseLib.c
@@ -410,9 +410,9 @@ ParseMemoryInfo (


/**
- Acquire acpi table and smbios table from coreboot
+ Acquire SMBIOS table from coreboot.

- @param SystemTableInfo Pointer to the system table info
+ @param SmbiosTable Pointer to the SMBIOS table info.

@retval RETURN_SUCCESS Successfully find out the tables.
@retval RETURN_NOT_FOUND Failed to find the tables.
@@ -420,8 +420,8 @@ ParseMemoryInfo (
**/
RETURN_STATUS
EFIAPI
-ParseSystemTable (
- OUT SYSTEM_TABLE_INFO *SystemTableInfo
+ParseSmbiosTable (
+ OUT UNIVERSAL_PAYLOAD_SMBIOS_TABLE *SmbiosTable
)
{
EFI_STATUS Status;
@@ -432,17 +432,39 @@ ParseSystemTable (
if (EFI_ERROR (Status)) {
return EFI_NOT_FOUND;
}
- SystemTableInfo->SmbiosTableBase = (UINT64) (UINTN)MemTable;
- SystemTableInfo->SmbiosTableSize = MemTableSize;
+ SmbiosTable->SmBiosEntryPoint = (UINT64) (UINTN)MemTable;
+
+ return RETURN_SUCCESS;
+}
+
+
+/**
+ Acquire ACPI table from coreboot.
+
+ @param AcpiTableHob Pointer to the ACPI table info.
+
+ @retval RETURN_SUCCESS Successfully find out the tables.
+ @retval RETURN_NOT_FOUND Failed to find the tables.
+
+**/
+
+RETURN_STATUS
+EFIAPI
+ParseAcpiTableInfo (
+ OUT UNIVERSAL_PAYLOAD_ACPI_TABLE *AcpiTableHob
+ )
+{
+ EFI_STATUS Status;
+ VOID *MemTable;
+ UINT32 MemTableSize;

Status = ParseCbMemTable (SIGNATURE_32 ('I', 'P', 'C', 'A'), &MemTable, &MemTableSize);
if (EFI_ERROR (Status)) {
return EFI_NOT_FOUND;
}
- SystemTableInfo->AcpiTableBase = (UINT64) (UINTN)MemTable;
- SystemTableInfo->AcpiTableSize = MemTableSize;
+ AcpiTableHob->Rsdp = (UINT64) (UINTN)MemTable;

- return Status;
+ return RETURN_SUCCESS;
}


diff --git a/UefiPayloadPkg/Library/SblParseLib/SblParseLib.c b/UefiPayloadPkg/Library/SblParseLib/SblParseLib.c
index eeb0dfe74a..e524e1b5f6 100644
--- a/UefiPayloadPkg/Library/SblParseLib/SblParseLib.c
+++ b/UefiPayloadPkg/Library/SblParseLib/SblParseLib.c
@@ -110,9 +110,9 @@ ParseMemoryInfo (
}

/**
- Acquire acpi table and smbios table from slim bootloader
+ Acquire SMBIOS table from slim bootloader.

- @param SystemTableInfo Pointer to the system table info
+ @param SmbiosTable Pointer to the SMBIOS table info.

@retval RETURN_SUCCESS Successfully find out the tables.
@retval RETURN_NOT_FOUND Failed to find the tables.
@@ -120,24 +120,52 @@ ParseMemoryInfo (
**/
RETURN_STATUS
EFIAPI
-ParseSystemTable (
- OUT SYSTEM_TABLE_INFO *SystemTableInfo
+ParseSmbiosTable (
+ OUT UNIVERSAL_PAYLOAD_SMBIOS_TABLE *SmbiosTable
)
{
- SYSTEM_TABLE_INFO *TableInfo;
+ UNIVERSAL_PAYLOAD_SMBIOS_TABLE *TableInfo;

- TableInfo = (SYSTEM_TABLE_INFO *)GetGuidHobDataFromSbl (&gUefiSystemTableInfoGuid);
+ TableInfo = (UNIVERSAL_PAYLOAD_SMBIOS_TABLE *)GetGuidHobDataFromSbl (&gUniversalPayloadSmbiosTableGuid);
if (TableInfo == NULL) {
ASSERT (FALSE);
return RETURN_NOT_FOUND;
}

- CopyMem (SystemTableInfo, TableInfo, sizeof (SYSTEM_TABLE_INFO));
+ SmbiosTable->SmBiosEntryPoint = TableInfo->SmBiosEntryPoint;

return RETURN_SUCCESS;
}


+/**
+ Acquire ACPI table from slim bootloader.
+
+ @param AcpiTableHob Pointer to the ACPI table info.
+
+ @retval RETURN_SUCCESS Successfully find out the tables.
+ @retval RETURN_NOT_FOUND Failed to find the tables.
+
+**/
+RETURN_STATUS
+EFIAPI
+ParseAcpiTableInfo (
+ OUT UNIVERSAL_PAYLOAD_ACPI_TABLE *AcpiTableHob
+ )
+{
+ UNIVERSAL_PAYLOAD_ACPI_TABLE *TableInfo;
+
+ TableInfo = (UNIVERSAL_PAYLOAD_ACPI_TABLE *)GetGuidHobDataFromSbl (&gUniversalPayloadAcpiTableGuid);
+ if (TableInfo == NULL) {
+ ASSERT (FALSE);
+ return RETURN_NOT_FOUND;
+ }
+
+ AcpiTableHob->Rsdp = TableInfo->Rsdp;
+
+ return RETURN_SUCCESS;
+}
+
/**
Find the serial port information

diff --git a/UefiPayloadPkg/Library/SblParseLib/SblParseLib.inf b/UefiPayloadPkg/Library/SblParseLib/SblParseLib.inf
index 535cca58a6..f83a10ccd8 100644
--- a/UefiPayloadPkg/Library/SblParseLib/SblParseLib.inf
+++ b/UefiPayloadPkg/Library/SblParseLib/SblParseLib.inf
@@ -36,7 +36,6 @@
HobLib

[Guids]
- gUefiSystemTableInfoGuid
gUefiSerialPortInfoGuid
gLoaderMemoryMapInfoGuid
gEfiGraphicsInfoHobGuid
diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c
index 9efe01d094..fee5cb90d5 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c
@@ -224,8 +224,6 @@ BuildHobFromBl (
)
{
EFI_STATUS Status;
- SYSTEM_TABLE_INFO SysTableInfo;
- SYSTEM_TABLE_INFO *NewSysTableInfo;
ACPI_BOARD_INFO *AcpiBoardInfo;
EFI_PEI_GRAPHICS_INFO_HOB GfxInfo;
EFI_PEI_GRAPHICS_INFO_HOB *NewGfxInfo;
@@ -274,18 +272,6 @@ BuildHobFromBl (
}


- //
- // Create guid hob for system tables like acpi table and smbios table
- //
- Status = ParseSystemTable(&SysTableInfo);
- ASSERT_EFI_ERROR (Status);
- if (!EFI_ERROR (Status)) {
- NewSysTableInfo = BuildGuidHob (&gUefiSystemTableInfoGuid, sizeof (SYSTEM_TABLE_INFO));
- ASSERT (NewSysTableInfo != NULL);
- CopyMem (NewSysTableInfo, &SysTableInfo, sizeof (SYSTEM_TABLE_INFO));
- DEBUG ((DEBUG_INFO, "Detected Acpi Table at 0x%lx, length 0x%x\n", SysTableInfo.AcpiTableBase, SysTableInfo.AcpiTableSize));
- DEBUG ((DEBUG_INFO, "Detected Smbios Table at 0x%lx, length 0x%x\n", SysTableInfo.SmbiosTableBase, SysTableInfo.SmbiosTableSize));
- }
//
// Creat SmBios table Hob
//
@@ -293,8 +279,11 @@ BuildHobFromBl (
ASSERT (SmBiosTableHob != NULL);
SmBiosTableHob->Header.Revision = UNIVERSAL_PAYLOAD_SMBIOS_TABLE_REVISION;
SmBiosTableHob->Header.Length = sizeof (UNIVERSAL_PAYLOAD_SMBIOS_TABLE);
- SmBiosTableHob->SmBiosEntryPoint = SysTableInfo.SmbiosTableBase;
DEBUG ((DEBUG_INFO, "Create smbios table gUniversalPayloadSmbiosTableGuid guid hob\n"));
+ Status = ParseSmbiosTable(SmBiosTableHob);
+ if (!EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_INFO, "Detected Smbios Table at 0x%lx\n", SmBiosTableHob->SmBiosEntryPoint));
+ }

//
// Creat ACPI table Hob
@@ -303,13 +292,16 @@ BuildHobFromBl (
ASSERT (AcpiTableHob != NULL);
AcpiTableHob->Header.Revision = UNIVERSAL_PAYLOAD_ACPI_TABLE_REVISION;
AcpiTableHob->Header.Length = sizeof (UNIVERSAL_PAYLOAD_ACPI_TABLE);
- AcpiTableHob->Rsdp = SysTableInfo.AcpiTableBase;
- DEBUG ((DEBUG_INFO, "Create smbios table gUniversalPayloadAcpiTableGuid guid hob\n"));
+ DEBUG ((DEBUG_INFO, "Create ACPI table gUniversalPayloadAcpiTableGuid guid hob\n"));
+ Status = ParseAcpiTableInfo(AcpiTableHob);
+ if (!EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_INFO, "Detected ACPI Table at 0x%lx\n", AcpiTableHob->Rsdp));
+ }

//
// Create guid hob for acpi board information
//
- AcpiBoardInfo = BuildHobFromAcpi (SysTableInfo.AcpiTableBase);
+ AcpiBoardInfo = BuildHobFromAcpi (AcpiTableHob->Rsdp);
ASSERT (AcpiBoardInfo != NULL);

//
diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
index 637ed9c20b..716430e3cb 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
+++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
@@ -27,7 +27,6 @@
#include <IndustryStandard/Acpi.h>
#include <IndustryStandard/MemoryMappedConfigurationSpaceAccessTable.h>
#include <Guid/SerialPortInfoGuid.h>
-#include <Guid/SystemTableInfoGuid.h>
#include <Guid/MemoryMapInfoGuid.h>
#include <Guid/AcpiBoardInfoGuid.h>
#include <Guid/GraphicsInfoHob.h>
diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf
index 96e4bb81f4..07a678bd46 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf
+++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf
@@ -59,7 +59,6 @@
[Guids]
gEfiMemoryTypeInformationGuid
gEfiFirmwareFileSystem2Guid
- gUefiSystemTableInfoGuid
gEfiGraphicsInfoHobGuid
gEfiGraphicsDeviceInfoHobGuid
gUefiAcpiBoardInfoGuid
diff --git a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf
index 928bd2e42b..a8576305ad 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf
+++ b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf
@@ -57,7 +57,6 @@
[Guids]
gEfiMemoryTypeInformationGuid
gEfiFirmwareFileSystem2Guid
- gUefiSystemTableInfoGuid
gEfiGraphicsInfoHobGuid
gEfiGraphicsDeviceInfoHobGuid
gUefiAcpiBoardInfoGuid
diff --git a/UefiPayloadPkg/UefiPayloadPkg.dec b/UefiPayloadPkg/UefiPayloadPkg.dec
index e5e8db8863..25f3b978f1 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.dec
+++ b/UefiPayloadPkg/UefiPayloadPkg.dec
@@ -32,7 +32,6 @@
##include/Guid/BootManagerMenu.h
gEdkiiBootManagerMenuFileGuid = { 0xdf939333, 0x42fc, 0x4b2a, { 0xa5, 0x9e, 0xbb, 0xae, 0x82, 0x81, 0xfe, 0xef }}

- gUefiSystemTableInfoGuid = {0x16c8a6d0, 0xfe8a, 0x4082, {0xa2, 0x8, 0xcf, 0x89, 0xc4, 0x29, 0x4, 0x33}}
gUefiAcpiBoardInfoGuid = {0xad3d31b, 0xb3d8, 0x4506, {0xae, 0x71, 0x2e, 0xf1, 0x10, 0x6, 0xd9, 0xf}}
gUefiSerialPortInfoGuid = { 0x6c6872fe, 0x56a9, 0x4403, { 0xbb, 0x98, 0x95, 0x8d, 0x62, 0xde, 0x87, 0xf1 } }
gLoaderMemoryMapInfoGuid = { 0xa1ff7424, 0x7a1a, 0x478e, { 0xa9, 0xe4, 0x92, 0xf3, 0x57, 0xd1, 0x28, 0x32 } }
--
2.33.0.windows.2


[PATCH v5] UefiPayloadPkg: Remove SystemTableInfo GUID.

thiyagukb
 

SystemTableInfo GUID is not a Spec defined GUID.
But the latest SBL uses SystemTableInfo to get ACPI and SMBIOS table information.
So moving the SystemTableInfo GUID implementation to SblParseLib.

Cc: Maurice Ma <maurice.ma@...>
Cc: Guo Dong <guo.dong@...>
Cc: Ray Ni <ray.ni@...>
Cc: Benjamin You <benjamin.you@...>
Cc: Zhiguang Liu <zhiguang.liu@...>

Signed-off-by: Guo Dong <guo.dong@...>
Signed-off-by: Thiyagu Kesavan Balakrishnan <thiyagux.kesavan.balakrishnan@...>
---
UefiPayloadPkg/BlSupportDxe/BlSupportDxe.h | 1 -
UefiPayloadPkg/BlSupportDxe/BlSupportDxe.inf | 1 -
UefiPayloadPkg/Include/Guid/SystemTableInfoGuid.h | 26 --------------------------
UefiPayloadPkg/Include/Library/BlParseLib.h | 25 ++++++++++++++++++++-----
UefiPayloadPkg/Library/CbParseLib/CbParseLib.c | 40 +++++++++++++++++++++++++++++++---------
UefiPayloadPkg/Library/SblParseLib/SblParseLib.c | 42 +++++++++++++++++++++++++++++++++++-------
UefiPayloadPkg/Library/SblParseLib/SblParseLib.inf | 1 -
UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c | 28 ++++++++++------------------
UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h | 1 -
UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf | 1 -
UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf | 1 -
UefiPayloadPkg/UefiPayloadPkg.dec | 1 -
12 files changed, 96 insertions(+), 72 deletions(-)

diff --git a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.h b/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.h
index 3332a30eae..b16ca4cc59 100644
--- a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.h
+++ b/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.h
@@ -20,7 +20,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#include <Library/HobLib.h>

#include <Guid/SmBios.h>
-#include <Guid/SystemTableInfoGuid.h>
#include <Guid/AcpiBoardInfoGuid.h>
#include <Guid/GraphicsInfoHob.h>

diff --git a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.inf b/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.inf
index 1ccb250991..96d85d2b1d 100644
--- a/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.inf
+++ b/UefiPayloadPkg/BlSupportDxe/BlSupportDxe.inf
@@ -42,7 +42,6 @@
HobLib

[Guids]
- gUefiSystemTableInfoGuid
gUefiAcpiBoardInfoGuid
gEfiGraphicsInfoHobGuid

diff --git a/UefiPayloadPkg/Include/Guid/SystemTableInfoGuid.h b/UefiPayloadPkg/Include/Guid/SystemTableInfoGuid.h
deleted file mode 100644
index e742dd0ca5..0000000000
--- a/UefiPayloadPkg/Include/Guid/SystemTableInfoGuid.h
+++ /dev/null
@@ -1,26 +0,0 @@
-/** @file
- This file defines the hob structure for system tables like ACPI, SMBIOS tables.
-
- Copyright (c) 2014 - 2019, Intel Corporation. All rights reserved.<BR>
- SPDX-License-Identifier: BSD-2-Clause-Patent
-
-**/
-
-#ifndef SYSTEM_TABLE_INFO_GUID_H_
-#define SYSTEM_TABLE_INFO_GUID_H_
-
-///
-/// System Table Information GUID
-///
-extern EFI_GUID gUefiSystemTableInfoGuid;
-
-typedef struct {
- UINT8 Revision;
- UINT8 Reserved0[3];
- UINT64 AcpiTableBase;
- UINT32 AcpiTableSize;
- UINT64 SmbiosTableBase;
- UINT32 SmbiosTableSize;
-} SYSTEM_TABLE_INFO;
-
-#endif
diff --git a/UefiPayloadPkg/Include/Library/BlParseLib.h b/UefiPayloadPkg/Include/Library/BlParseLib.h
index 7198e419bd..fb7bb0cb0e 100644
--- a/UefiPayloadPkg/Include/Library/BlParseLib.h
+++ b/UefiPayloadPkg/Include/Library/BlParseLib.h
@@ -13,8 +13,9 @@
#include <Guid/GraphicsInfoHob.h>
#include <Guid/MemoryMapInfoGuid.h>
#include <Guid/SerialPortInfoGuid.h>
-#include <Guid/SystemTableInfoGuid.h>
#include <Guid/AcpiBoardInfoGuid.h>
+#include <UniversalPayload/AcpiTable.h>
+#include <UniversalPayload/SmbiosTable.h>

#define GET_BOOTLOADER_PARAMETER() PcdGet64 (PcdBootloaderParameter)

@@ -55,9 +56,9 @@ ParseMemoryInfo (
);

/**
- Acquire acpi table and smbios table from slim bootloader
+ Acquire SMBIOS table from bootloader.

- @param SystemTableInfo Pointer to the system table info
+ @param SmbiosTable Pointer to the system table info

@retval RETURN_SUCCESS Successfully find out the tables.
@retval RETURN_NOT_FOUND Failed to find the tables.
@@ -65,10 +66,24 @@ ParseMemoryInfo (
**/
RETURN_STATUS
EFIAPI
-ParseSystemTable (
- OUT SYSTEM_TABLE_INFO *SystemTableInfo
+ParseSmbiosTable (
+ OUT UNIVERSAL_PAYLOAD_SMBIOS_TABLE *SmbiosTable
);

+/**
+ Acquire ACPI table from bootloader.
+
+ @param AcpiTableHob Pointer to the ACPI table info.
+
+ @retval RETURN_SUCCESS Successfully find out the tables.
+ @retval RETURN_NOT_FOUND Failed to find the tables.
+
+**/
+RETURN_STATUS
+EFIAPI
+ParseAcpiTableInfo (
+ OUT UNIVERSAL_PAYLOAD_ACPI_TABLE *AcpiTableHob
+ );

/**
Find the serial port information
diff --git a/UefiPayloadPkg/Library/CbParseLib/CbParseLib.c b/UefiPayloadPkg/Library/CbParseLib/CbParseLib.c
index 46314e5566..61c5683260 100644
--- a/UefiPayloadPkg/Library/CbParseLib/CbParseLib.c
+++ b/UefiPayloadPkg/Library/CbParseLib/CbParseLib.c
@@ -410,9 +410,9 @@ ParseMemoryInfo (


/**
- Acquire acpi table and smbios table from coreboot
+ Acquire SMBIOS table from coreboot.

- @param SystemTableInfo Pointer to the system table info
+ @param SmbiosTable Pointer to the SMBIOS table info.

@retval RETURN_SUCCESS Successfully find out the tables.
@retval RETURN_NOT_FOUND Failed to find the tables.
@@ -420,8 +420,8 @@ ParseMemoryInfo (
**/
RETURN_STATUS
EFIAPI
-ParseSystemTable (
- OUT SYSTEM_TABLE_INFO *SystemTableInfo
+ParseSmbiosTable (
+ OUT UNIVERSAL_PAYLOAD_SMBIOS_TABLE *SmbiosTable
)
{
EFI_STATUS Status;
@@ -432,17 +432,39 @@ ParseSystemTable (
if (EFI_ERROR (Status)) {
return EFI_NOT_FOUND;
}
- SystemTableInfo->SmbiosTableBase = (UINT64) (UINTN)MemTable;
- SystemTableInfo->SmbiosTableSize = MemTableSize;
+ SmbiosTable->SmBiosEntryPoint = (UINT64) (UINTN)MemTable;
+
+ return RETURN_SUCCESS;
+}
+
+
+/**
+ Acquire ACPI table from coreboot.
+
+ @param AcpiTableHob Pointer to the ACPI table info.
+
+ @retval RETURN_SUCCESS Successfully find out the tables.
+ @retval RETURN_NOT_FOUND Failed to find the tables.
+
+**/
+
+RETURN_STATUS
+EFIAPI
+ParseAcpiTableInfo (
+ OUT UNIVERSAL_PAYLOAD_ACPI_TABLE *AcpiTableHob
+ )
+{
+ EFI_STATUS Status;
+ VOID *MemTable;
+ UINT32 MemTableSize;

Status = ParseCbMemTable (SIGNATURE_32 ('I', 'P', 'C', 'A'), &MemTable, &MemTableSize);
if (EFI_ERROR (Status)) {
return EFI_NOT_FOUND;
}
- SystemTableInfo->AcpiTableBase = (UINT64) (UINTN)MemTable;
- SystemTableInfo->AcpiTableSize = MemTableSize;
+ AcpiTableHob->Rsdp = (UINT64) (UINTN)MemTable;

- return Status;
+ return RETURN_SUCCESS;
}


diff --git a/UefiPayloadPkg/Library/SblParseLib/SblParseLib.c b/UefiPayloadPkg/Library/SblParseLib/SblParseLib.c
index eeb0dfe74a..e524e1b5f6 100644
--- a/UefiPayloadPkg/Library/SblParseLib/SblParseLib.c
+++ b/UefiPayloadPkg/Library/SblParseLib/SblParseLib.c
@@ -110,9 +110,9 @@ ParseMemoryInfo (
}

/**
- Acquire acpi table and smbios table from slim bootloader
+ Acquire SMBIOS table from slim bootloader.

- @param SystemTableInfo Pointer to the system table info
+ @param SmbiosTable Pointer to the SMBIOS table info.

@retval RETURN_SUCCESS Successfully find out the tables.
@retval RETURN_NOT_FOUND Failed to find the tables.
@@ -120,24 +120,52 @@ ParseMemoryInfo (
**/
RETURN_STATUS
EFIAPI
-ParseSystemTable (
- OUT SYSTEM_TABLE_INFO *SystemTableInfo
+ParseSmbiosTable (
+ OUT UNIVERSAL_PAYLOAD_SMBIOS_TABLE *SmbiosTable
)
{
- SYSTEM_TABLE_INFO *TableInfo;
+ UNIVERSAL_PAYLOAD_SMBIOS_TABLE *TableInfo;

- TableInfo = (SYSTEM_TABLE_INFO *)GetGuidHobDataFromSbl (&gUefiSystemTableInfoGuid);
+ TableInfo = (UNIVERSAL_PAYLOAD_SMBIOS_TABLE *)GetGuidHobDataFromSbl (&gUniversalPayloadSmbiosTableGuid);
if (TableInfo == NULL) {
ASSERT (FALSE);
return RETURN_NOT_FOUND;
}

- CopyMem (SystemTableInfo, TableInfo, sizeof (SYSTEM_TABLE_INFO));
+ SmbiosTable->SmBiosEntryPoint = TableInfo->SmBiosEntryPoint;

return RETURN_SUCCESS;
}


+/**
+ Acquire ACPI table from slim bootloader.
+
+ @param AcpiTableHob Pointer to the ACPI table info.
+
+ @retval RETURN_SUCCESS Successfully find out the tables.
+ @retval RETURN_NOT_FOUND Failed to find the tables.
+
+**/
+RETURN_STATUS
+EFIAPI
+ParseAcpiTableInfo (
+ OUT UNIVERSAL_PAYLOAD_ACPI_TABLE *AcpiTableHob
+ )
+{
+ UNIVERSAL_PAYLOAD_ACPI_TABLE *TableInfo;
+
+ TableInfo = (UNIVERSAL_PAYLOAD_ACPI_TABLE *)GetGuidHobDataFromSbl (&gUniversalPayloadAcpiTableGuid);
+ if (TableInfo == NULL) {
+ ASSERT (FALSE);
+ return RETURN_NOT_FOUND;
+ }
+
+ AcpiTableHob->Rsdp = TableInfo->Rsdp;
+
+ return RETURN_SUCCESS;
+}
+
/**
Find the serial port information

diff --git a/UefiPayloadPkg/Library/SblParseLib/SblParseLib.inf b/UefiPayloadPkg/Library/SblParseLib/SblParseLib.inf
index 535cca58a6..f83a10ccd8 100644
--- a/UefiPayloadPkg/Library/SblParseLib/SblParseLib.inf
+++ b/UefiPayloadPkg/Library/SblParseLib/SblParseLib.inf
@@ -36,7 +36,6 @@
HobLib

[Guids]
- gUefiSystemTableInfoGuid
gUefiSerialPortInfoGuid
gLoaderMemoryMapInfoGuid
gEfiGraphicsInfoHobGuid
diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c
index 9efe01d094..fee5cb90d5 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c
+++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.c
@@ -224,8 +224,6 @@ BuildHobFromBl (
)
{
EFI_STATUS Status;
- SYSTEM_TABLE_INFO SysTableInfo;
- SYSTEM_TABLE_INFO *NewSysTableInfo;
ACPI_BOARD_INFO *AcpiBoardInfo;
EFI_PEI_GRAPHICS_INFO_HOB GfxInfo;
EFI_PEI_GRAPHICS_INFO_HOB *NewGfxInfo;
@@ -274,18 +272,6 @@ BuildHobFromBl (
}


- //
- // Create guid hob for system tables like acpi table and smbios table
- //
- Status = ParseSystemTable(&SysTableInfo);
- ASSERT_EFI_ERROR (Status);
- if (!EFI_ERROR (Status)) {
- NewSysTableInfo = BuildGuidHob (&gUefiSystemTableInfoGuid, sizeof (SYSTEM_TABLE_INFO));
- ASSERT (NewSysTableInfo != NULL);
- CopyMem (NewSysTableInfo, &SysTableInfo, sizeof (SYSTEM_TABLE_INFO));
- DEBUG ((DEBUG_INFO, "Detected Acpi Table at 0x%lx, length 0x%x\n", SysTableInfo.AcpiTableBase, SysTableInfo.AcpiTableSize));
- DEBUG ((DEBUG_INFO, "Detected Smbios Table at 0x%lx, length 0x%x\n", SysTableInfo.SmbiosTableBase, SysTableInfo.SmbiosTableSize));
- }
//
// Creat SmBios table Hob
//
@@ -293,8 +279,11 @@ BuildHobFromBl (
ASSERT (SmBiosTableHob != NULL);
SmBiosTableHob->Header.Revision = UNIVERSAL_PAYLOAD_SMBIOS_TABLE_REVISION;
SmBiosTableHob->Header.Length = sizeof (UNIVERSAL_PAYLOAD_SMBIOS_TABLE);
- SmBiosTableHob->SmBiosEntryPoint = SysTableInfo.SmbiosTableBase;
DEBUG ((DEBUG_INFO, "Create smbios table gUniversalPayloadSmbiosTableGuid guid hob\n"));
+ Status = ParseSmbiosTable(SmBiosTableHob);
+ if (!EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_INFO, "Detected Smbios Table at 0x%lx\n", SmBiosTableHob->SmBiosEntryPoint));
+ }

//
// Creat ACPI table Hob
@@ -303,13 +292,16 @@ BuildHobFromBl (
ASSERT (AcpiTableHob != NULL);
AcpiTableHob->Header.Revision = UNIVERSAL_PAYLOAD_ACPI_TABLE_REVISION;
AcpiTableHob->Header.Length = sizeof (UNIVERSAL_PAYLOAD_ACPI_TABLE);
- AcpiTableHob->Rsdp = SysTableInfo.AcpiTableBase;
- DEBUG ((DEBUG_INFO, "Create smbios table gUniversalPayloadAcpiTableGuid guid hob\n"));
+ DEBUG ((DEBUG_INFO, "Create ACPI table gUniversalPayloadAcpiTableGuid guid hob\n"));
+ Status = ParseAcpiTableInfo(AcpiTableHob);
+ if (!EFI_ERROR (Status)) {
+ DEBUG ((DEBUG_INFO, "Detected ACPI Table at 0x%lx\n", AcpiTableHob->Rsdp));
+ }

//
// Create guid hob for acpi board information
//
- AcpiBoardInfo = BuildHobFromAcpi (SysTableInfo.AcpiTableBase);
+ AcpiBoardInfo = BuildHobFromAcpi (AcpiTableHob->Rsdp);
ASSERT (AcpiBoardInfo != NULL);

//
diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
index 637ed9c20b..716430e3cb 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
+++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.h
@@ -27,7 +27,6 @@
#include <IndustryStandard/Acpi.h>
#include <IndustryStandard/MemoryMappedConfigurationSpaceAccessTable.h>
#include <Guid/SerialPortInfoGuid.h>
-#include <Guid/SystemTableInfoGuid.h>
#include <Guid/MemoryMapInfoGuid.h>
#include <Guid/AcpiBoardInfoGuid.h>
#include <Guid/GraphicsInfoHob.h>
diff --git a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf
index 96e4bb81f4..07a678bd46 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf
+++ b/UefiPayloadPkg/UefiPayloadEntry/UefiPayloadEntry.inf
@@ -59,7 +59,6 @@
[Guids]
gEfiMemoryTypeInformationGuid
gEfiFirmwareFileSystem2Guid
- gUefiSystemTableInfoGuid
gEfiGraphicsInfoHobGuid
gEfiGraphicsDeviceInfoHobGuid
gUefiAcpiBoardInfoGuid
diff --git a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf
index 928bd2e42b..a8576305ad 100644
--- a/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf
+++ b/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf
@@ -57,7 +57,6 @@
[Guids]
gEfiMemoryTypeInformationGuid
gEfiFirmwareFileSystem2Guid
- gUefiSystemTableInfoGuid
gEfiGraphicsInfoHobGuid
gEfiGraphicsDeviceInfoHobGuid
gUefiAcpiBoardInfoGuid
diff --git a/UefiPayloadPkg/UefiPayloadPkg.dec b/UefiPayloadPkg/UefiPayloadPkg.dec
index e5e8db8863..25f3b978f1 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.dec
+++ b/UefiPayloadPkg/UefiPayloadPkg.dec
@@ -32,7 +32,6 @@
##include/Guid/BootManagerMenu.h
gEdkiiBootManagerMenuFileGuid = { 0xdf939333, 0x42fc, 0x4b2a, { 0xa5, 0x9e, 0xbb, 0xae, 0x82, 0x81, 0xfe, 0xef }}

- gUefiSystemTableInfoGuid = {0x16c8a6d0, 0xfe8a, 0x4082, {0xa2, 0x8, 0xcf, 0x89, 0xc4, 0x29, 0x4, 0x33}}
gUefiAcpiBoardInfoGuid = {0xad3d31b, 0xb3d8, 0x4506, {0xae, 0x71, 0x2e, 0xf1, 0x10, 0x6, 0xd9, 0xf}}
gUefiSerialPortInfoGuid = { 0x6c6872fe, 0x56a9, 0x4403, { 0xbb, 0x98, 0x95, 0x8d, 0x62, 0xde, 0x87, 0xf1 } }
gLoaderMemoryMapInfoGuid = { 0xa1ff7424, 0x7a1a, 0x478e, { 0xa9, 0xe4, 0x92, 0xf3, 0x57, 0xd1, 0x28, 0x32 } }
--
2.33.0.windows.2


Re: [PATCH v6 1/3] MdeModulePkg/SortLib: Add QuickSort function on BaseLib

IanX Kuo
 

Hi Liming

The change "PATCH v6 1/3" is the same with "PATCH v3 1/3".

The difference between "v3 to v6" is on "PATCH v6 3/3"


Thanks,
Ian Kuo

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of gaoliming
Sent: Wednesday, October 20, 2021 9:50 AM
To: Kuo, IanX <ianx.kuo@...>; devel@edk2.groups.io
Cc: Chan, Amy <amy.chan@...>; Ni, Ray <ray.ni@...>; Wang, Jian J <jian.j.wang@...>
Subject: 回复: [edk2-devel] [PATCH v6 1/3] MdeModulePkg/SortLib: Add QuickSort function on BaseLib

What new change is made in new version patch?

Thanks
Liming
-----邮件原件-----
发件人: Kuo, IanX <ianx.kuo@...>
发送时间: 2021年10月19日 10:09
收件人: devel@edk2.groups.io; Kuo, IanX <ianx.kuo@...>; Liming Gao
<gaoliming@...>
抄送: Chan, Amy <amy.chan@...>; Ni, Ray <ray.ni@...>; Wang,
Jian J <jian.j.wang@...>
主题: RE: [edk2-devel] [PATCH v6 1/3] MdeModulePkg/SortLib: Add
QuickSort function on BaseLib

@Liming Gao

Sorry to bother you. May I get your help for review by again ?

Thanks,
Ian Kuo

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of IanX
Kuo
Sent: Monday, October 18, 2021 12:21 PM
To: devel@edk2.groups.io
Cc: Chan, Amy <amy.chan@...>; Ni, Ray <ray.ni@...>; Kuo,
IanX <ianx.kuo@...>; Wang, Jian J <jian.j.wang@...>;
Liming Gao <gaoliming@...>
Subject: [edk2-devel] [PATCH v6 1/3] MdeModulePkg/SortLib: Add
QuickSort function on BaseLib

From: IanX Kuo <ianx.kuo@...>

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

Use QuickSort instead of QuickSortWorker

Cc: Ray Ni <ray.ni@...>
Cc: Jian J Wang <jian.j.wang@...>
Cc: Liming Gao <gaoliming@...>
Signed-off-by: IanX Kuo <ianx.kuo@...>
---
.../Library/BaseSortLib/BaseSortLib.c | 115 +----------------
.../Library/UefiSortLib/UefiSortLib.c | 116 +-----------------
2 files changed, 8 insertions(+), 223 deletions(-)

diff --git a/MdeModulePkg/Library/BaseSortLib/BaseSortLib.c
b/MdeModulePkg/Library/BaseSortLib/BaseSortLib.c
index a12c7bc0ec..0903943ee4 100644
--- a/MdeModulePkg/Library/BaseSortLib/BaseSortLib.c
+++ b/MdeModulePkg/Library/BaseSortLib/BaseSortLib.c
@@ -1,7 +1,7 @@
/** @file Library used for sorting routines. - Copyright (c) 2009 -
2018,
Intel Corporation. All rights reserved. <BR>+ Copyright (c) 2009 -
2021,
Intel
Corporation. All rights reserved. <BR> SPDX-License-Identifier:
BSD-2-Clause-Patent **/@@ -13,114 +13,6 @@ #include
<Library/MemoryAllocationLib.h> #include <Library/SortLib.h>
-/**- Worker function for QuickSorting. This function is identical
to
PerformQuickSort,- except that is uses the pre-allocated buffer so
the in place sorting does not need to- allocate and free buffers
constantly.--
Each
element must be equal sized.-- if BufferToSort is NULL, then ASSERT.-
if CompareFunction is NULL, then ASSERT.- if Buffer is NULL, then
ASSERT.-- if Count is < 2 then perform no action.- if Size is < 1 then perform no
action.-- @param[in, out] BufferToSort on call a Buffer of (possibly
sorted)
elements- on return a buffer of
sorted elements- @param[in] Count the number of
elements in the buffer to sort- @param[in] ElementSize Size of
an element in bytes- @param[in] CompareFunction The function to
call to perform the comparison- of
any 2 elements- @param[in] Buffer Buffer of size
ElementSize for use in swapping-**/-VOID-EFIAPI-QuickSortWorker (- IN
OUT VOID *BufferToSort,- IN CONST
UINTN Count,- IN CONST UINTN
ElementSize,- IN SORT_COMPARE
CompareFunction,- IN VOID
*Buffer- )-{- VOID *Pivot;- UINTN LoopCount;-
UINTN NextSwapLocation;-- ASSERT(BufferToSort != NULL);-
ASSERT(CompareFunction != NULL);- ASSERT(Buffer != NULL);-- if
( Count < 2- || ElementSize < 1- ){- return;- }--
NextSwapLocation = 0;-- //- // pick a pivot (we choose last
element)-
//- Pivot = ((UINT8*)BufferToSort+((Count-1)*ElementSize));-- //-
// Now get the pivot such that all on "left" are below it- // and everything
"right" are above it- //- for ( LoopCount = 0- ; LoopCount < Count
-1- ; LoopCount++- ){- //- // if the element is less than
the pivot- //- if
(CompareFunction((VOID*)((UINT8*)BufferToSort+((LoopCount)*ElementSize)
),Pivot) <= 0){- //- // swap- //- CopyMem (Buffer,
(UINT8*)BufferToSort+(NextSwapLocation*ElementSize), ElementSize);-
CopyMem ((UINT8*)BufferToSort+(NextSwapLocation*ElementSize),
(UINT8*)BufferToSort+((LoopCount)*ElementSize), ElementSize);- CopyMem
((UINT8*)BufferToSort+((LoopCount)*ElementSize), Buffer,
ElementSize);-- //- // increment NextSwapLocation- //-
NextSwapLocation++;- }- }- //- // swap pivot to it's final position
(NextSwapLocaiton)- //- CopyMem (Buffer, Pivot, ElementSize);-
CopyMem (Pivot, (UINT8*)BufferToSort+(NextSwapLocation*ElementSize),
ElementSize);- CopyMem
((UINT8*)BufferToSort+(NextSwapLocation*ElementSize), Buffer,
ElementSize);-- //- // Now recurse on 2 paritial lists. neither of
these
will have the 'pivot' element- // IE list is sorted left half, pivot
element,
sorted right half...- //- if (NextSwapLocation >= 2) {-
QuickSortWorker(- BufferToSort,- NextSwapLocation,-
ElementSize,- CompareFunction,- Buffer);- }-- if ((Count -
NextSwapLocation - 1) >= 2) {- QuickSortWorker(- (UINT8
*)BufferToSort + (NextSwapLocation+1) * ElementSize,- Count -
NextSwapLocation - 1,- ElementSize,- CompareFunction,-
Buffer);- }- return;-} /** Function to perform a Quick Sort alogrithm
on
a buffer of comparable elements. @@ -156,12 +48,13 @@ PerformQuickSort
(
Buffer = AllocateZeroPool(ElementSize); ASSERT(Buffer != NULL); -
QuickSortWorker(+ QuickSort ( BufferToSort, Count,
ElementSize, CompareFunction,- Buffer);+ Buffer+ );
FreePool(Buffer); return;diff --git
a/MdeModulePkg/Library/UefiSortLib/UefiSortLib.c
b/MdeModulePkg/Library/UefiSortLib/UefiSortLib.c
index 46dc443638..29d8735c22 100644
--- a/MdeModulePkg/Library/UefiSortLib/UefiSortLib.c
+++ b/MdeModulePkg/Library/UefiSortLib/UefiSortLib.c
@@ -1,7 +1,7 @@
/** @file Library used for sorting routines. - Copyright (c) 2009 -
2014,
Intel Corporation. All rights reserved. <BR>+ Copyright (c) 2009 -
2021,
Intel
Corporation. All rights reserved. <BR> SPDX-License-Identifier:
BSD-2-Clause-Patent **/@@ -29,115 +29,6 @@ STATIC
EFI_UNICODE_COLLATION_PROTOCOL *mUnicodeCollation = NULL;
} \ } -/**- Worker function
for QuickSorting. This function is identical to PerformQuickSort,-
except
that is uses the pre-allocated buffer so the in place sorting does not
need to-
allocate and free buffers constantly.-- Each element must be equal sized.
--
if BufferToSort is NULL, then ASSERT.- if CompareFunction is NULL,
then
ASSERT.- if Buffer is NULL, then ASSERT.-- if Count is < 2 then
perform
no
action.- if Size is < 1 then perform no action.-- @param[in, out]
BufferToSort on call a Buffer of (possibly sorted) elements-
on return a buffer of sorted elements- @param[in] Count the number of
elements in the buffer to sort- @param[in] ElementSize
Size of an element in bytes- @param[in] CompareFunction The
function to call to perform the comparison-
of any 2 elements- @param[in] Buffer Buffer of size
ElementSize for use in swapping-**/-VOID-EFIAPI-QuickSortWorker (- IN
OUT VOID *BufferToSort,- IN CONST
UINTN Count,- IN CONST UINTN
ElementSize,- IN SORT_COMPARE
CompareFunction,- IN VOID
*Buffer- )-{- VOID *Pivot;- UINTN LoopCount;-
UINTN NextSwapLocation;-- ASSERT(BufferToSort != NULL);-
ASSERT(CompareFunction != NULL);- ASSERT(Buffer != NULL);-- if
( Count < 2- || ElementSize < 1- ){- return;- }--
NextSwapLocation = 0;-- //- // pick a pivot (we choose last
element)-
//- Pivot = ((UINT8*)BufferToSort+((Count-1)*ElementSize));-- //-
// Now get the pivot such that all on "left" are below it- // and everything
"right" are above it- //- for ( LoopCount = 0- ; LoopCount < Count
-1- ; LoopCount++- ){- //- // if the element is less than
the pivot- //- if
(CompareFunction((VOID*)((UINT8*)BufferToSort+((LoopCount)*ElementSize)
),Pivot) <= 0){- //- // swap- //- CopyMem (Buffer,
(UINT8*)BufferToSort+(NextSwapLocation*ElementSize), ElementSize);-
CopyMem ((UINT8*)BufferToSort+(NextSwapLocation*ElementSize),
(UINT8*)BufferToSort+((LoopCount)*ElementSize), ElementSize);- CopyMem
((UINT8*)BufferToSort+((LoopCount)*ElementSize), Buffer,
ElementSize);-- //- // increment NextSwapLocation- //-
NextSwapLocation++;- }- }- //- // swap pivot to it's final position
(NextSwapLocaiton)- //- CopyMem (Buffer, Pivot, ElementSize);-
CopyMem (Pivot, (UINT8*)BufferToSort+(NextSwapLocation*ElementSize),
ElementSize);- CopyMem
((UINT8*)BufferToSort+(NextSwapLocation*ElementSize), Buffer,
ElementSize);-- //- // Now recurse on 2 paritial lists. neither of
these
will have the 'pivot' element- // IE list is sorted left half, pivot
element,
sorted right half...- //- if (NextSwapLocation >= 2) {-
QuickSortWorker(- BufferToSort,- NextSwapLocation,-
ElementSize,- CompareFunction,- Buffer);- }-- if ((Count -
NextSwapLocation - 1) >= 2) {- QuickSortWorker(- (UINT8
*)BufferToSort + (NextSwapLocation+1) * ElementSize,- Count -
NextSwapLocation - 1,- ElementSize,- CompareFunction,-
Buffer);- }-- return;-} /** Function to perform a Quick Sort alogrithm
on
a buffer of comparable elements. @@ -173,12 +64,13 @@ PerformQuickSort
(
Buffer = AllocateZeroPool(ElementSize); ASSERT(Buffer != NULL); -
QuickSortWorker(+ QuickSort ( BufferToSort, Count,
ElementSize, CompareFunction,- Buffer);+ Buffer+ );
FreePool(Buffer); return;--
2.30.0.windows.1



-=-=-=-=-=-=
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#82204):
https://edk2.groups.io/g/devel/message/82204
Mute This Topic: https://groups.io/mt/86406843/4830160
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [ianx.kuo@...]
-=-=-=-=-=-=

8501 - 8520 of 90847