Date   

[PATCH v1 1/1] UefiCpuPkg: Coding style bug fix

Paweł Poławski
 

Local variable name overlaped with function name.
Variable name has been updated to remove name duplication.

Cc: Eric Dong <eric.dong@...>
Cc: Ray Ni <ray.ni@...>
Cc: Rahul Kumar <rahul1.kumar@...>

Signed-off-by: Paweł Poławski <ppolawsk@...>
---
UefiCpuPkg/CpuMpPei/CpuBist.c | 40 ++++++++++----------
1 file changed, 20 insertions(+), 20 deletions(-)

diff --git a/UefiCpuPkg/CpuMpPei/CpuBist.c b/UefiCpuPkg/CpuMpPei/CpuBist.c
index 7dc93cd784d4..179063e0d105 100644
--- a/UefiCpuPkg/CpuMpPei/CpuBist.c
+++ b/UefiCpuPkg/CpuMpPei/CpuBist.c
@@ -91,7 +91,7 @@ GetBistInfoFromPpi (
{
EFI_STATUS Status;
EFI_SEC_PLATFORM_INFORMATION2_PPI *SecPlatformInformation2Ppi;
- EFI_SEC_PLATFORM_INFORMATION_RECORD2 *SecPlatformInformation2;
+ EFI_SEC_PLATFORM_INFORMATION_RECORD2 *SecPlatformInformation2Rec2;
UINT64 InformationSize;

Status = PeiServicesLocatePpi (
@@ -108,17 +108,17 @@ GetBistInfoFromPpi (
//
// Get the size of the sec platform information2(BSP/APs' BIST data)
//
- InformationSize = 0;
- SecPlatformInformation2 = NULL;
- Status = SecPlatformInformation2Ppi->PlatformInformation2 (
- PeiServices,
- &InformationSize,
- SecPlatformInformation2
- );
+ InformationSize = 0;
+ SecPlatformInformation2Rec2 = NULL;
+ Status = SecPlatformInformation2Ppi->PlatformInformation2 (
+ PeiServices,
+ &InformationSize,
+ SecPlatformInformation2Rec2
+ );
if (Status == EFI_BUFFER_TOO_SMALL) {
Status = PeiServicesAllocatePool (
(UINTN)InformationSize,
- (VOID **)&SecPlatformInformation2
+ (VOID **)&SecPlatformInformation2Rec2
);
if (Status == EFI_SUCCESS) {
//
@@ -127,10 +127,10 @@ GetBistInfoFromPpi (
Status = SecPlatformInformation2Ppi->PlatformInformation2 (
PeiServices,
&InformationSize,
- SecPlatformInformation2
+ SecPlatformInformation2Rec2
);
if (Status == EFI_SUCCESS) {
- *BistInformationData = SecPlatformInformation2;
+ *BistInformationData = SecPlatformInformation2Rec2;
if (BistInformationSize != NULL) {
*BistInformationSize = InformationSize;
}
@@ -160,7 +160,7 @@ CollectBistDataFromPpi (
{
EFI_STATUS Status;
EFI_PEI_PPI_DESCRIPTOR *SecInformationDescriptor;
- EFI_SEC_PLATFORM_INFORMATION_RECORD2 *SecPlatformInformation2;
+ EFI_SEC_PLATFORM_INFORMATION_RECORD2 *SecPlatformInformation2Rec2;
EFI_SEC_PLATFORM_INFORMATION_RECORD *SecPlatformInformation;
UINTN NumberOfData;
EFI_SEC_PLATFORM_INFORMATION_CPU *CpuInstance;
@@ -186,10 +186,10 @@ CollectBistDataFromPpi (
ASSERT_EFI_ERROR (Status);
PlatformInformationRecord2->NumberOfCpus = (UINT32)NumberOfProcessors;

- SecPlatformInformation2 = NULL;
- SecPlatformInformation = NULL;
- NumberOfData = 0;
- CpuInstance = NULL;
+ SecPlatformInformation2Rec2 = NULL;
+ SecPlatformInformation = NULL;
+ NumberOfData = 0;
+ CpuInstance = NULL;
//
// Get BIST information from Sec Platform Information2 Ppi firstly
//
@@ -197,15 +197,15 @@ CollectBistDataFromPpi (
PeiServices,
&gEfiSecPlatformInformation2PpiGuid,
&SecInformationDescriptor,
- (VOID *)&SecPlatformInformation2,
+ (VOID *)&SecPlatformInformation2Rec2,
NULL
);
if (Status == EFI_SUCCESS) {
//
// Sec Platform Information2 PPI includes BSP/APs' BIST information
//
- NumberOfData = SecPlatformInformation2->NumberOfCpus;
- CpuInstance = SecPlatformInformation2->CpuInstance;
+ NumberOfData = SecPlatformInformation2Rec2->NumberOfCpus;
+ CpuInstance = SecPlatformInformation2Rec2->CpuInstance;
} else {
//
// Otherwise, get BIST information from Sec Platform Information Ppi
@@ -274,7 +274,7 @@ CollectBistDataFromPpi (
(UINTN)BistInformationSize
);

- if (SecPlatformInformation2 != NULL) {
+ if (SecPlatformInformation2Rec2 != NULL) {
if (NumberOfData < NumberOfProcessors) {
//
// Reinstall SecPlatformInformation2 PPI to include new BIST information
--
2.34.3


[PATCH v1 0/1] Coding style violation fix

Paweł Poławski
 

Hello edk2-devel list,

This is my first contribution to the EDK2 project. I was following
upstream howto creating this email / patch. Please let me know
in case I did something the wrong way.

Laszlo Ersek in his email to edk2-devel related to
"CPU count limitation in CpuMpPei BIST processing"
pointed out coding style violation related to local variable
and function name overlap.

This patch addresses mentioned issue.

Best regards,
Pawel

Reference branch: https://github.com/elkoniu/edk2/tree/coding-style-fix

Cc: Eric Dong <eric.dong@...>
Cc: Ray Ni <ray.ni@...>
Cc: Rahul Kumar <rahul1.kumar@...>

Paweł Poławski (1):
UefiCpuPkg: Coding style bug fix

UefiCpuPkg/CpuMpPei/CpuBist.c | 40 ++++++++++----------
1 file changed, 20 insertions(+), 20 deletions(-)

--
2.34.3


Re: [PATCH v2] UefiPayloadPkg: Backward support with python 3.6

Ni, Ray
 

Why use PY 3.6?
Even PY 3.8 is about to be deprecated by Python community.

-----Original Message-----
From: Liu, KasimX <kasimx.liu@...>
Sent: Friday, June 24, 2022 11:48 AM
To: devel@edk2.groups.io
Cc: Liu, KasimX <kasimx.liu@...>; Dong, Guo <guo.dong@...>; Ni, Ray <ray.ni@...>; Lu, James
<james.lu@...>; Guo, Gua <gua.guo@...>
Subject: [PATCH v2] UefiPayloadPkg: Backward support with python 3.6

From: KasimX Liu <kasimx.liu@...>

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

Currently, UniversalPayloadBuild.py don't have support
python3.6, we use python3.6 will encounter f"" failure
use the change to fix it to support python3.6/3.7/3.8.

Cc: Guo Dong <guo.dong@...>
Cc: Ray Ni <ray.ni@...>
Cc: James Lu <james.lu@...>
Reviewed-by: Gua Guo <gua.guo@...>
Signed-off-by: KasimX Liu <kasimx.liu@...>
---
UefiPayloadPkg/UniversalPayloadBuild.py | 33 +++++++++++++++-----
1 file changed, 25 insertions(+), 8 deletions(-)

diff --git a/UefiPayloadPkg/UniversalPayloadBuild.py b/UefiPayloadPkg/UniversalPayloadBuild.py
index c71526e0a6..ab4c977ba5 100644
--- a/UefiPayloadPkg/UniversalPayloadBuild.py
+++ b/UefiPayloadPkg/UniversalPayloadBuild.py
@@ -59,15 +59,15 @@ def BuildUniversalPayload(Args, MacroList):
if Args.Arch == 'X64':

BuildArch = "X64"

ObjCopyFlag = "elf64-x86-64"

- EntryOutputDir = os.path.join(BuildDir, f"{BuildTarget}_{ElfToolChain}",
os.path.normpath("X64/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry/DEBUG/UniversalPayloadEntry.dll"))

+ EntryOutputDir = os.path.join(BuildDir, "{}_{}".format (BuildTarget, ElfToolChain),
os.path.normpath("X64/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry/DEBUG/UniversalPayloadEntry.dll"))

else:

BuildArch = "IA32 -a X64"

ObjCopyFlag = "elf32-i386"

- EntryOutputDir = os.path.join(BuildDir, f"{BuildTarget}_{ElfToolChain}",
os.path.normpath("IA32/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry/DEBUG/UniversalPayloadEntry.dll"))

+ EntryOutputDir = os.path.join(BuildDir, "{}_{}".format (BuildTarget, ElfToolChain),
os.path.normpath("IA32/UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry/DEBUG/UniversalPayloadEntry.dll"))



EntryModuleInf = os.path.normpath("UefiPayloadPkg/UefiPayloadEntry/UniversalPayloadEntry.inf")

DscPath = os.path.normpath("UefiPayloadPkg/UefiPayloadPkg.dsc")

- FvOutputDir = os.path.join(BuildDir, f"{BuildTarget}_{ToolChain}", os.path.normpath("FV/DXEFV.Fv"))

+ FvOutputDir = os.path.join(BuildDir, "{}_{}".format (BuildTarget, ToolChain), os.path.normpath("FV/DXEFV.Fv"))

PayloadReportPath = os.path.join(BuildDir, "UefiUniversalPayload.txt")

ModuleReportPath = os.path.join(BuildDir, "UefiUniversalPayloadEntry.txt")

UpldInfoFile = os.path.join(BuildDir, "UniversalPayloadInfo.bin")

@@ -94,14 +94,14 @@ def BuildUniversalPayload(Args, MacroList):
#

# Building DXE core and DXE drivers as DXEFV.

#

- BuildPayload = f"build -p {DscPath} -b {BuildTarget} -a X64 -t {ToolChain} -y {PayloadReportPath} {Quiet}"

+ BuildPayload = "build -p {} -b {} -a X64 -t {} -y {} {}".format (DscPath, BuildTarget, ToolChain, PayloadReportPath, Quiet)

BuildPayload += Pcds

BuildPayload += Defines

RunCommand(BuildPayload)

#

# Building Universal Payload entry.

#

- BuildModule = f"build -p {DscPath} -b {BuildTarget} -a {BuildArch} -m {EntryModuleInf} -t {ElfToolChain} -y
{ModuleReportPath} {Quiet}"

+ BuildModule = "build -p {} -b {} -a {} -m {} -t {} -y {} {}".format (DscPath, BuildTarget, BuildArch, EntryModuleInf,
ElfToolChain, ModuleReportPath, Quiet)

BuildModule += Pcds

BuildModule += Defines

RunCommand(BuildModule)

@@ -118,9 +118,26 @@ def BuildUniversalPayload(Args, MacroList):
#

# Copy the DXEFV as a section in elf format Universal Payload entry.

#

- remove_section = f'"{LlvmObjcopyPath}" -I {ObjCopyFlag} -O {ObjCopyFlag} --remove-section .upld_info --remove-
section .upld.uefi_fv {EntryOutputDir}'

- add_section = f'"{LlvmObjcopyPath}" -I {ObjCopyFlag} -O {ObjCopyFlag} --add-section .upld_info={UpldInfoFile} --add-
section .upld.uefi_fv={FvOutputDir} {EntryOutputDir}'

- set_section = f'"{LlvmObjcopyPath}" -I {ObjCopyFlag} -O {ObjCopyFlag} --set-section-alignment .upld.upld_info=16 --
set-section-alignment .upld.uefi_fv=16 {EntryOutputDir}'

+ remove_section = '"{}" -I {} -O {} --remove-section .upld_info --remove-section .upld.uefi_fv {}'.format (

+ LlvmObjcopyPath,

+ ObjCopyFlag,

+ ObjCopyFlag,

+ EntryOutputDir

+ )

+ add_section = '"{}" -I {} -O {} --add-section .upld_info={} --add-section .upld.uefi_fv={} {}'.format (

+ LlvmObjcopyPath,

+ ObjCopyFlag,

+ ObjCopyFlag,

+ UpldInfoFile,

+ FvOutputDir,

+ EntryOutputDir

+ )

+ set_section = '"{}" -I {} -O {} --set-section-alignment .upld.upld_info=16 --set-section-alignment .upld.uefi_fv=16
{}'.format (

+ LlvmObjcopyPath,

+ ObjCopyFlag,

+ ObjCopyFlag,

+ EntryOutputDir

+ )

RunCommand(remove_section)

RunCommand(add_section)

RunCommand(set_section)

--
2.32.0.windows.2


Re: BaseTools: Current status of BaseTools/Source/Python

Yuwei Chen
 

Hi Ayush,

The migration is still working in progress.
In order to ensure the normal use of users, the current bug fixes are still based on BaseTools in edk2.
After all the migrations are completed, an official notification will be sent, and the developments and bug fixing works will be transferred to the edk2-basetools repo.

Thanks,
Christine (Yuwei)

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Ayush
Singh
Sent: Saturday, June 11, 2022 11:31 PM
To: edk2-devel-groups-io <devel@edk2.groups.io>
Cc: Michael Kubacki <mikuback@...>
Subject: [edk2-devel] BaseTools: Current status of BaseTools/Source/Python

Hello everyone,

I have been poking around the BaseTools to understand its implementation
since I will have to add Rust build support as a part of my GSoC project. The
`BaseTools/Source/Python` directory contains a README file that states that
the folder was supposed to be removed from the repo on 202102.

It is still present in the repo, but more importantly, it still seems to be getting
commits. Initially, I thought that maybe it was a mirror kind of situation but
the commit history does not match, so I'm not sure.

Can anyone tell me what the current status of migration is, or if it has been
canceled?

Yours Sincerely,
Ayush Singh

[1] https://github.com/tianocore/edk2
[2] https://github.com/tianocore/edk2-basetools




Re: [edk2-rfc] RFC v2: Static Analysis in edk2 CI

Michael D Kinney
 

I have Coverity scan builds running in a GitHub Action and then uploaded to Coverity.

We should be able to configure a GitHub Action to run other analyzers.

Mike

-----Original Message-----
From: rfc@edk2.groups.io <rfc@edk2.groups.io> On Behalf Of Pedro Falcato
Sent: Tuesday, June 14, 2022 1:00 PM
To: rfc@edk2.groups.io; POLUDOV, FELIX <felixp@...>
Cc: Rebecca Cran <rebecca@...>; edk2-devel-groups-io <devel@edk2.groups.io>
Subject: Re: [edk2-rfc] RFC v2: Static Analysis in edk2 CI

(Re-adding devel@ since Felix dropped it)

On Tue, Jun 14, 2022 at 8:59 PM Pedro Falcato <pedro.falcato@...>
wrote:

Just want to note that if we want to go ahead with fuzzing (I detailed a
possible plan to do so in the mailing list a month or so ago) we will
definitely need somewhere to run fuzzing (even if it's Google's syzbot).
Getting somewhere where we can run static analysis, fuzzing just makes
sense IMO (hell, who knows, maybe even CI or something like Gerrit for
mailing list-less code reviews).

On Tue, Jun 14, 2022 at 7:43 PM Felix Polyudov via groups.io <felixp=
ami.com@groups.io> wrote:

Yes, LLVM/CLANG Static Analyzer is another possibility. I've mentioned it
in the first version of the RFC.
CodeChecker (https://codechecker.readthedocs.io/en/latest/) is an open
source front-end for the scan-build and clang-tidy.
It simplifies analyzer configuration and provides web-based report
storage. However, it has to be hosted somewhere.
If somebody has an idea on how edk2 community can host the CodeChecker,
that's definitely an option to consider.





--
Pedro Falcato

--
Pedro Falcato




Re: [PATCH 1/1] BaseTools/Ecc: Fix grammar in Ecc error message

Yuwei Chen
 

Reviewed-by: Yuwei Chen<yuwei.chen@...>

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Rebecca
Cran
Sent: Monday, June 20, 2022 6:07 AM
To: devel@edk2.groups.io; Feng, Bob C <bob.c.feng@...>; Gao, Liming
<gaoliming@...>; Chen, Christine <yuwei.chen@...>
Cc: Rebecca Cran <quic_rcran@...>
Subject: [edk2-devel] [PATCH 1/1] BaseTools/Ecc: Fix grammar in Ecc error
message

Signed-off-by: Rebecca Cran <quic_rcran@...>
---
BaseTools/Source/Python/Ecc/c.py | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/BaseTools/Source/Python/Ecc/c.py
b/BaseTools/Source/Python/Ecc/c.py
index 4a82e5e76003..61ad084fcc5b 100644
--- a/BaseTools/Source/Python/Ecc/c.py
+++ b/BaseTools/Source/Python/Ecc/c.py
@@ -2612,8 +2612,8 @@ def
CheckFunctionHeaderConsistentWithDoxygenComment(FuncModifier,
FuncHeader, Fu


if Tag.find(ParamName) == -1 and ParamName != 'VOID' and
ParamName != 'void':
- ErrorMsgList.append('Line %d : in Comment, <%s> does NOT
consistent with parameter name %s ' % (CommentStartLine, (TagPartList[0] +
' ' + TagPartList[1]).replace('\n', '').replace('\r', ''), ParamName))
- PrintErrorMsg(ERROR_DOXYGEN_CHECK_FUNCTION_HEADER, 'in
Comment, <%s> does NOT consistent with parameter name %s ' %
((TagPartList[0] + ' ' + TagPartList[1]).replace('\n', '').replace('\r', ''),
ParamName), TableName, CommentId)
+ ErrorMsgList.append('Line %d : in Comment, <%s> is NOT
consistent with parameter name %s ' % (CommentStartLine, (TagPartList[0] +
' ' + TagPartList[1]).replace('\n', '').replace('\r', ''), ParamName))
+ PrintErrorMsg(ERROR_DOXYGEN_CHECK_FUNCTION_HEADER, 'in
Comment, <%s> is NOT consistent with parameter name %s ' %
((TagPartList[0] + ' ' + TagPartList[1]).replace('\n', '').replace('\r', ''),
ParamName), TableName, CommentId)
Index += 1

if Index < ParamNumber:
--
2.35.3





FW: help with a build in UDK2014.sp1.P1 environment with vs2012 x86 / python 2.7.3 on Windows 10

Peter Bisping <Peter.Bisping@...>
 

Looking for approval for the attached bounced email from edk2 below
Thanks
Peter

-----Original Message-----
From: edk2-devel-owner@... <edk2-devel-owner@...>
Sent: Thursday, June 23, 2022 2:00 PM
To: Peter Bisping <Peter.Bisping@...>
Subject: help with a build in UDK2014.sp1.P1 environment with vs2012 x86 / python 2.7.3 on Windows 10

CAUTION: This email originated from outside of Western Digital. Do not click on links or open attachments unless you recognize the sender and know that the content is safe.


This list has moved. Please subscribe to the new list at:

https://lists.01.org/mailman/listinfo/edk2-devel


Re: [PATCH v6 0/5] Handling of multiple PCI

Ojeda Leon, Nicolas <ncoleon@...>
 

On Wed, 22 Jun 2022 at 17:35, Ard Biesheuvel <ardb@...> wrote:

On Tue, 21 Jun 2022 at 23:28, Nicolas Ojeda Leon <ncoleon@...> wrote:

Increased control is provided in Ovmf platforms to define and
configure the specifications of multiple PCI host bridges in the
hypervisor. The host propagates this information to the guest,
initially through fw-cfg interface.

In some AWS EC2 platforms, we expose a PCI topology including
several root bridges portraying information about physical
distribution that enables the guest to optimize accesses. Current
PCI driver for Ovmf enables the explicit definition of multiple root
bridges and contains the logic to fix their resources based on
platform-specific PCD entries. However, we need a way to control,
from the hypervisor, how many and which resources each PCI root
bridge can use. For this reason, this patch series introduces a
mechanism to provide PCI host bridges information like bus number
range, attributes, allocation attributes, PIO aperture as well as 32
and 64- bit prefetchable and non-prefetchable MMIO ranges through a
fw-cfg item created by the hypervisor and consumed by the guest
firmware. In order to offer a generic and extensible way to disclose
non-discoverable hardware information from the host to the guest, a
new library called HardwareInfoLib is created in the OvmfPkg. In
essence, this library offers the functionality to parse a generic
BLOB into a list as well as the methods to iterate over such list, including filtering options.
The library is conceived in a generic way so that further hardware
elements can also be described using it. For such purpose the length
of the BLOB is not restricted but instead regarded as a sequence of
header-info elements that allow the parsing during runtime.
Furthermore, specific functionality is provided wrapping
QemuFwCfgReadBytes to extract hardware descriptions, in the
aforementioned format, in a static way so that early in the Pei
stage the library can be used to identify address space requirements.
The core of the library offers enough flexibility to process as many
elements, even from different hardware types (heterogenous), as
needed in a single run. This library is extended for the particular
use case already exposed, PCI host bridges, and this same code
offers an example of how to tailor it for further hardware components.

After acknowledgement from Gerd Hoffmann and fixing all warnings and
errors found by the CI pipeline (via draft pull request), here I
send a new revision of the patches for merging.

---
Notes:
v6:
Prepearation for upstream merge:
- No functional change at all.
- Small changes to fix all builds excercised by CI
(https://github.com/tianocore/edk2/pull/2938)
- Added libraries to furhter platforms as per dependencies requirements
- Explicit casting of some values as required by build and
verification of values when demoting values.
- Arranged added files copyright to the format required.
- Changed HOST_BRIDGE_INFO bitfield member to UINT32 to follow
EDK2 guidelines motivated on build in 32-bit windows systems.
- Added verification of Bus Number range when values provided by
host to make sure Root Bridge is initialized with valid values

v5:
- Removed last 3 patches dealing with pre-populated resources to
encapsulate related changes in more manageable chunks and while
pre-populated changes are finalized.
- Added Acked-by to all commits
- Re-based on top of latest master and refactored changes in
MemDetect.c to adapt to recently created
PlatformInitLib/MemDetect.c

v4:
- Minor modification to use MAX_UINT64 as global invalid base address
when reading PCI host bridge information provided by the host
(Patch 1)
- Refactor PciHostBridgeUtilityGetRootBridges into a thin wrapper that
calls 2 new function: one (BusScan) that performs the legacy bus
scan population process and a new one (HostProvided) that populates
Root Bridges with host provided values. (Patch 5)
- Move code that sets value of PcdPciPreservePopulatedMappings token
based on host-provided fw-cfg file into the function that populates
root bridges with host provided data (Patch 6)
- Restructured base address retrieval to leave PCI Resource Allocation
protocol untouched and instead augment the existing services to
enable base address retrieval before allocation. (Patch 7)
- Use new method to retrieve Root Bridge base addresses before
allocation and use that to handle pre-populated BARs (Patch 8)


Nicolas Ojeda Leon (5):
OvmfPkg/Library: Create base HardwareInfoLib for PCI Host Bridges
Ovmf/HardwareInfoLib: Create Pei lib to parse directly from fw-cfg
Ovmf/HardwareInfoLib: Add Dxe lib to dynamically parse heterogenous
data
Ovmf/PlatformPei: Use host-provided GPA end if available
OvmfPkg/PciHostBridgeUtilityLib: Initialize RootBridges apertures with
spec
Merged as #3000,

Thanks all,
This series appears to have triggered a failure in our CI. Could someone propose a fix please?

https://ci.linaro.org/job/leg-virt-tianocore-edk2-upstream/4563/
Thanks Ard for notifying.

I will post the fix in short, tested build locally and now running the CI pipeline (https://github.com/tianocore/edk2/pull/2938).

Best regards,

Nicolas



Amazon Development Center Germany GmbH
Krausenstr. 38
10117 Berlin
Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss
Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B
Sitz: Berlin
Ust-ID: DE 289 237 879


Re: [PATCH v2 2/2] [edk2-platforms] Silicon/Intel/FitGen: Support to override the MBZ byte in Startup ACM entries for other usages

Oram, Isaac W
 

This code is gratuitous on typecasting and pointer use.

As this change is making the use of these fields more confusing, I would like to see it simplified.

e.g. *(UINT32 *)&FitEntry[FitIndex].Size[0] =

This is introducing possible errors. More correct would be
FitEntry[FitIndex].Size[0] = (UINT8) gFitTableContext.FitEntryNumber;
FitEntry[FitIndex].Size[1] = (UINT8) (gFitTableContext.FitEntryNumber >> 8);
FitEntry[FitIndex].Size[2] = (UINT8) (gFitTableContext.FitEntryNumber >> 16);
FitEntry[FitIndex].Rsvd = 0;

But I think that we can do better by redefining the structs and using unions to make the field use clear.
Or different structs for different entry types would be fine too.

Thanks,
Isaac

-----Original Message-----
From: Lin, Jason1 <jason1.lin@...>
Sent: Thursday, June 23, 2022 7:49 AM
To: devel@edk2.groups.io
Cc: Lin, Jason1 <jason1.lin@...>; Feng, Bob C <bob.c.feng@...>; Gao, Liming <gaoliming@...>; Chen, Christine <yuwei.chen@...>; Oram, Isaac W <isaac.w.oram@...>; Chaganty, Rangasai V <rangasai.v.chaganty@...>; Chiang, Dakota <dakota.chiang@...>
Subject: [PATCH v2 2/2] [edk2-platforms] Silicon/Intel/FitGen: Support to override the MBZ byte in Startup ACM entries for other usages

From: Jason1 Lin <jason1.lin@...>

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

As per FIT BIOS Specification 1.2 Rules, the size bytes (3 bytes)/ reserved byte (1 byte) / CheckSum byte (1 byte) in type 2 are must-be-zero (MBZ).
These bytes could be override for the other usages.
In the future, if these bytes field have other meanings, there would be no need to change the FitGen.

Command:
[-S <StartupAcmAddress StartupAcmSize>|<StartupAcmGuid>] [-I <StartupAcmSizeByte0 StartupAcmSizeByte1 StartupAcmSizeByte2 StartupAcmRsvd StartupAcmChksum>] [-V <StartupAcmVersion>]

With "-I" input the default Type 2 entry version would be 0x200.

Signed-off-by: Jason1 Lin <jason1.lin@...>
Cc: Bob Feng <bob.c.feng@...>
Cc: Liming Gao <gaoliming@...>
Cc: Yuwei Chen <yuwei.chen@...>
Cc: Isaac W Oram <isaac.w.oram@...>
Cc: Rangasai V Chaganty <rangasai.v.chaganty@...>
Cc: Dakota Chiang <dakota.chiang@...>
---
Silicon/Intel/Tools/FitGen/FitGen.c | 105 ++++++++++++++++----
Silicon/Intel/Tools/FitGen/FitGen.h | 2 +-
2 files changed, 88 insertions(+), 19 deletions(-)

diff --git a/Silicon/Intel/Tools/FitGen/FitGen.c b/Silicon/Intel/Tools/FitGen/FitGen.c
index eac8fa8715..bdda8dfd5a 100644
--- a/Silicon/Intel/Tools/FitGen/FitGen.c
+++ b/Silicon/Intel/Tools/FitGen/FitGen.c
@@ -210,6 +210,7 @@ typedef struct {
#define DEFAULT_FIT_TABLE_POINTER_OFFSET 0x40 #define DEFAULT_FIT_ENTRY_VERSION 0x0100+#define STARTUP_ACM_FIT_ENTRY_200_VERSION 0x0200 #define TOP_FLASH_ADDRESS (gFitTableContext.TopFlashAddressRemapValue) @@ -247,6 +248,12 @@ typedef struct {
UINT8 *Buffer; // Used by OptionalModule only UINT32 Size; UINT32 Version; // Used by OptionalModule and PortModule only+ UINT32 MaxSize;+ UINT8 SizeByte0; // Used by S-ACM only+ UINT8 SizeByte1; // Used by S-ACM only+ UINT8 SizeByte2; // Used by S-ACM only+ UINT8 Rsvd; // Used by S-ACM only+ UINT8 ChkSum; // Used by S-ACM only } FIT_TABLE_CONTEXT_ENTRY; typedef struct {@@ -262,7 +269,7 @@ typedef struct {
UINT32 GlobalVersion; UINT32 FitHeaderVersion; FIT_TABLE_CONTEXT_ENTRY StartupAcm[MAX_STARTUP_ACM_ENTRY];- UINT32 StartupAcmVersion;+ UINT32 StartupAcmVersion[MAX_STARTUP_ACM_ENTRY]; FIT_TABLE_CONTEXT_ENTRY DiagnstAcm; UINT32 DiagnstAcmVersion; FIT_TABLE_CONTEXT_ENTRY BiosModule[MAX_BIOS_MODULE_ENTRY];@@ -341,7 +348,7 @@ Returns:
"\t[-L <MicrocodeSlotSize> <MicrocodeFfsGuid>]\n" "\t[-LF <MicrocodeSlotSize>]\n" "\t[-I <BiosInfoGuid>]\n"- "\t[-S <StartupAcmAddress StartupAcmSize>|<StartupAcmGuid>] [-V <StartupAcmVersion>]\n"+ "\t[-S <StartupAcmAddress StartupAcmSize>|<StartupAcmGuid>] [-I <StartupAcmSizeByte0 StartupAcmSizeByte1 StartupAcmSizeByte2 StartupAcmRsvd StartupAcmChksum>] [-V <StartupAcmVersion>]\n" "\t[-U <DiagnstAcmAddress>|<DiagnstAcmGuid>]\n" "\t[-B <BiosModuleAddress BiosModuleSize>] [-B ...] [-V <BiosModuleVersion>]\n" "\t[-M <MicrocodeAddress MicrocodeSize>] [-M ...]|[-U <MicrocodeFv MicrocodeBase>|<MicrocodeRegionOffset MicrocodeRegionSize>|<MicrocodeGuid>] [-V <MicrocodeVersion>]\n"@@ -357,7 +364,13 @@ Returns:
printf ("\tBiosInfoGuid - Guid of BiosInfo Module. If this module exists, StartupAcm/Bios/Microcode can be optional.\n"); printf ("\tStartupAcmAddress - Address of StartupAcm.\n"); printf ("\tStartupAcmSize - Size of StartupAcm.\n");- printf ("\tStartupAcmGuid - Guid of StartupAcm Module, if StartupAcm is in a BiosModule, it will be excluded form that.\n");+ printf ("\tStartupAcmGuid - Guid of StartupAcm Module.\n");+ printf ("\tStartupAcmMaxSize - The maximum size value that could place the StartupAcm in.\n");+ printf ("\tStartupAcmSizeByte0 - The value for Size byte 0 (Override default value).\n");+ printf ("\tStartupAcmSizeByte1 - The value for Size byte 1 (Override default value).\n");+ printf ("\tStartupAcmSizeByte2 - The value for Size byte 2 (Override default value).\n");+ printf ("\tStartupAcmRsvd - The value for Reserved byte (Override default value).\n");+ printf ("\tStartupAcmChkSum - The value for CheckSum byte (Override default value).\n"); printf ("\tDiagnstAcmAddress - Address of DiagnstAcm.\n"); printf ("\tDiagnstAcmGuid - Guid of DiagnstAcm Module, if DiagnstAcm is in a BiosModule, it will be excluded from that.\n"); printf ("\tBiosModuleAddress - Address of BiosModule. User should ensure there is no overlap.\n");@@ -913,6 +926,9 @@ Returns:
UINT32 FileSize; UINT32 Type; UINT32 SubType;+ UINT8 StartupAcmSizeByte0;+ UINT8 StartupAcmSizeByte1;+ UINT8 StartupAcmSizeByte2; UINT8 *MicrocodeFileBuffer; UINT8 *MicrocodeFileBufferRaw; UINT32 MicrocodeFileSize;@@ -1155,9 +1171,12 @@ Returns:
Error (NULL, 0, 0, "-I Parameter incorrect, too many StartupAcm!", NULL); return 0; }+ //+ // NOTE: BIOS INFO structure not support to override the Size/Rsvd/ChkSum byte value.+ // gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Type = FIT_TABLE_TYPE_STARTUP_ACM; gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Address = (UINT32)BiosInfoStruct[BiosInfoIndex].Address;- gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Size = (UINT32)BiosInfoStruct[BiosInfoIndex].Size;+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].MaxSize = (UINT32)BiosInfoStruct[BiosInfoIndex].Size; gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Version = BiosInfoStruct[BiosInfoIndex].Version; gFitTableContext.StartupAcmNumber ++; gFitTableContext.FitEntryNumber ++;@@ -1389,10 +1408,52 @@ Returns:
} gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Type = FIT_TABLE_TYPE_STARTUP_ACM; gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Address = (UINT32) (UINTN) FileBuffer;- gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Size = FileSize;+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].MaxSize = FileSize; //- // 1.1 StartupAcm version+ // 1.1 Support 0x200 StartupAcm Information+ //+ if ((Index + 1 >= argc) ||+ ((strcmp (argv[Index], "-I") != 0) &&+ (strcmp (argv[Index], "-i") != 0)) ) {+ //+ // Bypass+ //+ gFitTableContext.StartupAcmVersion[gFitTableContext.StartupAcmNumber] = gFitTableContext.GlobalVersion;+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Size = 0;+ } else {+ //+ // Should use the multiple StartupACM+ //+ if (Index + 5 >= argc) {+ //+ // Should get five input value, but not sufficient+ //+ Error (NULL, 0, 0, "-I Parameter incorrect, Require five inputs value!", NULL);+ return 0;+ } else {+ //+ // Should assign this as 0x200+ //+ gFitTableContext.StartupAcmVersion[gFitTableContext.StartupAcmNumber] = STARTUP_ACM_FIT_ENTRY_200_VERSION;+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].SizeByte0 = (UINT8)xtoi (argv[Index + 1]);+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].SizeByte1 = (UINT8)xtoi (argv[Index + 2]);+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].SizeByte2 = (UINT8)xtoi (argv[Index + 3]);+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Rsvd = (UINT8)xtoi (argv[Index + 4]);+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].ChkSum = (UINT8)xtoi (argv[Index + 5]);++ StartupAcmSizeByte0 = (UINT32)gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].SizeByte0;+ StartupAcmSizeByte1 = (UINT32)gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].SizeByte1;+ StartupAcmSizeByte2 = (UINT32)gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].SizeByte2;++ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Size = (StartupAcmSizeByte2 << 16) + (StartupAcmSizeByte1 << 8) + (StartupAcmSizeByte0);++ Index += 6;+ }+ }++ //+ // 1.2 StartupAcm version // if ((Index + 1 >= argc) || ((strcmp (argv[Index], "-V") != 0) &&@@ -1400,18 +1461,17 @@ Returns:
// // Bypass //- gFitTableContext.StartupAcmVersion = gFitTableContext.GlobalVersion; } else { // // Get offset from parameter //- gFitTableContext.StartupAcmVersion = xtoi (argv[Index + 1]);+ gFitTableContext.StartupAcmVersion[gFitTableContext.StartupAcmNumber] = xtoi (argv[Index + 1]); Index += 2; } gFitTableContext.StartupAcmNumber ++; gFitTableContext.FitEntryNumber ++;- }+ }; // // 1.5. DiagnosticsAcm@@ -1895,7 +1955,7 @@ Returns:
// Final: Check StartupAcm in BiosModule. // for (Index = 0; Index < (INTN)gFitTableContext.StartupAcmNumber; Index++) {- CheckOverlap (gFitTableContext.StartupAcm[Index].Address, gFitTableContext.StartupAcm[Index].Size);+ CheckOverlap (gFitTableContext.StartupAcm[Index].Address, gFitTableContext.StartupAcm[Index].MaxSize); } FitEntryNumber = gFitTableContext.FitEntryNumber; for (Index = 0; Index < (INTN)gFitTableContext.OptionalModuleNumber; Index++) {@@ -2185,7 +2245,7 @@ Returns:
printf ("Total FIT Entry number: 0x%x\n", gFitTableContext.FitEntryNumber); printf ("FitHeader version: 0x%04x\n", gFitTableContext.FitHeaderVersion); for (Index = 0; Index < gFitTableContext.StartupAcmNumber; Index++) {- printf ("StartupAcm[%d] - (0x%08x, 0x%08x, 0x%04x)\n", Index, gFitTableContext.StartupAcm[Index].Address, gFitTableContext.StartupAcm[Index].Size, gFitTableContext.StartupAcmVersion);+ printf ("StartupAcm[%d] - (0x%08x, 0x%08x, 0x%08x, 0x%04x)\n", Index, gFitTableContext.StartupAcm[Index].Address, gFitTableContext.StartupAcm[Index].Size, gFitTableContext.StartupAcm[Index].MaxSize, gFitTableContext.StartupAcmVersion[Index]); } if (gFitTableContext.DiagnstAcm.Address != 0) { printf ("DiagnosticAcm - (0x%08x, 0x%08x, 0x%04x)\n", gFitTableContext.DiagnstAcm.Address, gFitTableContext.DiagnstAcm.Size, gFitTableContext.DiagnstAcmVersion);@@ -2817,11 +2877,12 @@ Returns:
// for (Index = 0; Index < gFitTableContext.StartupAcmNumber; Index++) { FitEntry[FitIndex].Address = gFitTableContext.StartupAcm[Index].Address;- *(UINT32 *)&FitEntry[FitIndex].Size[0] = 0; //gFitTableContext.StartupAcm.Size / 16;- FitEntry[FitIndex].Version = (UINT16)gFitTableContext.StartupAcmVersion;+ *(UINT32 *)&FitEntry[FitIndex].Size[0] = gFitTableContext.StartupAcm[Index].Size;+ FitEntry[FitIndex].Version = (UINT16)gFitTableContext.StartupAcmVersion[Index]; FitEntry[FitIndex].Type = FIT_TABLE_TYPE_STARTUP_ACM; FitEntry[FitIndex].C_V = 0;- FitEntry[FitIndex].Checksum = 0;+ FitEntry[FitIndex].Rsvd = gFitTableContext.StartupAcm[Index].Rsvd;+ FitEntry[FitIndex].Checksum = gFitTableContext.StartupAcm[Index].ChkSum; FitIndex++; } @@ -3170,8 +3231,16 @@ Returns:
gFitTableContext.MicrocodeNumber ++; break; case FIT_TABLE_TYPE_STARTUP_ACM:- gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Address = (UINT32)FitEntry[FitIndex].Address;- gFitTableContext.StartupAcmVersion = FitEntry[FitIndex].Version;+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Address = (UINT32)FitEntry[FitIndex].Address;+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Type = FitEntry[FitIndex].Type;+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Size = *(UINT32 *)&FitEntry[FitIndex].Size[0];+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].SizeByte0 = *(UINT8 *)&FitEntry[FitIndex].Size[0];+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].SizeByte1 = *(UINT8 *)&FitEntry[FitIndex].Size[1];+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].SizeByte2 = *(UINT8 *)&FitEntry[FitIndex].Size[2];+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Rsvd = FitEntry[FitIndex].Rsvd;+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].ChkSum = FitEntry[FitIndex].Checksum;+ gFitTableContext.StartupAcmVersion[gFitTableContext.StartupAcmNumber] = FitEntry[FitIndex].Version;+ gFitTableContext.StartupAcmNumber ++; break; case FIT_TABLE_TYPE_BIOS_MODULE: gFitTableContext.BiosModule[gFitTableContext.BiosModuleNumber].Address = (UINT32)FitEntry[FitIndex].Address;@@ -3333,13 +3402,13 @@ Returns:
for (Index = 0; Index < (INTN)gFitTableContext.StartupAcmNumber; Index ++) { if (gFitTableContext.StartupAcm[Index].Address != 0) { AcmBuffer = FLASH_TO_MEMORY(gFitTableContext.StartupAcm[Index].Address, FdFileBuffer, FdFileSize);- if ((AcmBuffer < FdFileBuffer) || (AcmBuffer + gFitTableContext.StartupAcm[Index].Size > FdFileBuffer + FdFileSize)) {+ if ((AcmBuffer < FdFileBuffer) || (AcmBuffer + gFitTableContext.StartupAcm[Index].MaxSize > FdFileBuffer + FdFileSize)) { printf ("ACM out of range - can not validate it\n"); AcmBuffer = NULL; } if (AcmBuffer != NULL) {- if (CheckAcm ((ACM_FORMAT *)AcmBuffer, gFitTableContext.StartupAcm[Index].Size)) {+ if (CheckAcm ((ACM_FORMAT *)AcmBuffer, gFitTableContext.StartupAcm[Index].MaxSize)) { DumpAcm ((ACM_FORMAT *)AcmBuffer); } else { Status = STATUS_ERROR;diff --git a/Silicon/Intel/Tools/FitGen/FitGen.h b/Silicon/Intel/Tools/FitGen/FitGen.h
index b7de0a6b2d..80a1423ceb 100644
--- a/Silicon/Intel/Tools/FitGen/FitGen.h
+++ b/Silicon/Intel/Tools/FitGen/FitGen.h
@@ -31,7 +31,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
// Utility version information // #define UTILITY_MAJOR_VERSION 0-#define UTILITY_MINOR_VERSION 65+#define UTILITY_MINOR_VERSION 66 #define UTILITY_DATE __DATE__ //--
2.26.2.windows.1


Re: [PATCH v2 1/2] [edk2-platforms] Silicon/Intel/FitGen: Support multiple Startup ACM Type 2 entries in FitGen tool

Oram, Isaac W
 

Reviewed-by: Isaac Oram <isaac.w.oram@...>

-----Original Message-----
From: Lin, Jason1 <jason1.lin@...>
Sent: Thursday, June 23, 2022 7:45 AM
To: devel@edk2.groups.io
Cc: Lin, Jason1 <jason1.lin@...>; Feng, Bob C <bob.c.feng@...>; Gao, Liming <gaoliming@...>; Chen, Christine <yuwei.chen@...>; Oram, Isaac W <isaac.w.oram@...>; Chaganty, Rangasai V <rangasai.v.chaganty@...>; Chiang, Dakota <dakota.chiang@...>
Subject: [PATCH v2 1/2] [edk2-platforms] Silicon/Intel/FitGen: Support multiple Startup ACM Type 2 entries in FitGen tool

From: Jason1 Lin <jason1.lin@...>

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

Within current FitGen tool there had limitation only allow one S-ACM to generate the Type 2 entry.
This code change is used to support multiple type 2 entries up to 0x20.

Signed-off-by: Jason1 Lin <jason1.lin@...>
Cc: Bob Feng <bob.c.feng@...>
Cc: Liming Gao <gaoliming@...>
Cc: Yuwei Chen <yuwei.chen@...>
Cc: Isaac W Oram <isaac.w.oram@...>
Cc: Rangasai V Chaganty <rangasai.v.chaganty@...>
Cc: Dakota Chiang <dakota.chiang@...>
---
Silicon/Intel/Tools/FitGen/FitGen.c | 89 +++++++++++--------- Silicon/Intel/Tools/FitGen/FitGen.h | 4 +-
2 files changed, 50 insertions(+), 43 deletions(-)

diff --git a/Silicon/Intel/Tools/FitGen/FitGen.c b/Silicon/Intel/Tools/FitGen/FitGen.c
index 4de72ea422..eac8fa8715 100644
--- a/Silicon/Intel/Tools/FitGen/FitGen.c
+++ b/Silicon/Intel/Tools/FitGen/FitGen.c
@@ -2,7 +2,7 @@
This utility is part of build process for IA32/X64 FD. It generates FIT table. -Copyright (c) 2010-2021, Intel Corporation. All rights reserved.<BR>+Copyright (c) 2010-2022, Intel Corporation. All rights reserved.<BR> SPDX-License-Identifier: BSD-2-Clause-Patent **/@@ -204,6 +204,7 @@ typedef struct {
#define MAX_BIOS_MODULE_ENTRY 0x20 #define MAX_MICROCODE_ENTRY 0x20+#define MAX_STARTUP_ACM_ENTRY 0x20 #define MAX_OPTIONAL_ENTRY 0x20 #define MAX_PORT_ENTRY 0x20 @@ -255,11 +256,12 @@ typedef struct {
UINT32 FitEntryNumber; UINT32 BiosModuleNumber; UINT32 MicrocodeNumber;+ UINT32 StartupAcmNumber; UINT32 OptionalModuleNumber; UINT32 PortModuleNumber; UINT32 GlobalVersion; UINT32 FitHeaderVersion;- FIT_TABLE_CONTEXT_ENTRY StartupAcm;+ FIT_TABLE_CONTEXT_ENTRY StartupAcm[MAX_STARTUP_ACM_ENTRY]; UINT32 StartupAcmVersion; FIT_TABLE_CONTEXT_ENTRY DiagnstAcm; UINT32 DiagnstAcmVersion;@@ -1149,14 +1151,15 @@ Returns:
Error (NULL, 0, 0, "-I Parameter incorrect, Header Type unsupported!", NULL); return 0; case FIT_TABLE_TYPE_STARTUP_ACM:- if (gFitTableContext.StartupAcm.Type != 0) {- Error (NULL, 0, 0, "-I Parameter incorrect, Duplicated StartupAcm!", NULL);+ if (gFitTableContext.StartupAcmNumber >= MAX_STARTUP_ACM_ENTRY) {+ Error (NULL, 0, 0, "-I Parameter incorrect, too many StartupAcm!", NULL); return 0; }- gFitTableContext.StartupAcm.Type = FIT_TABLE_TYPE_STARTUP_ACM;- gFitTableContext.StartupAcm.Address = (UINT32)BiosInfoStruct[BiosInfoIndex].Address;- gFitTableContext.StartupAcm.Size = (UINT32)BiosInfoStruct[BiosInfoIndex].Size;- gFitTableContext.StartupAcmVersion = BiosInfoStruct[BiosInfoIndex].Version;+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Type = FIT_TABLE_TYPE_STARTUP_ACM;+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Address = (UINT32)BiosInfoStruct[BiosInfoIndex].Address;+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Size = (UINT32)BiosInfoStruct[BiosInfoIndex].Size;+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Version = BiosInfoStruct[BiosInfoIndex].Version;+ gFitTableContext.StartupAcmNumber ++; gFitTableContext.FitEntryNumber ++; break; case FIT_TABLE_TYPE_DIAGNST_ACM:@@ -1351,16 +1354,15 @@ Returns:
// // 1. StartupAcm //- do {+ while (TRUE) { if ((Index + 1 >= argc) || ((strcmp (argv[Index], "-S") != 0) && (strcmp (argv[Index], "-s") != 0)) ) {- if (BiosInfoExist && (gFitTableContext.StartupAcm.Type == FIT_TABLE_TYPE_STARTUP_ACM)) {- break;+ if (gFitTableContext.StartupAcmNumber == 0) {+ printf ("-S not found. WARNING!\n"); } // Error (NULL, 0, 0, "-S Parameter incorrect, expect -S!", NULL); // return 0;- printf ("-S not found. WARNING!\n"); break; } if (IsGuidData (argv[Index + 1], &Guid)) {@@ -1381,14 +1383,13 @@ Returns:
FileSize = xtoi (argv[Index + 2]); Index += 3; }- if (gFitTableContext.StartupAcm.Type != 0) {- Error (NULL, 0, 0, "-S Parameter incorrect, Duplicated StartupAcm!", NULL);+ if (gFitTableContext.StartupAcmNumber >= MAX_STARTUP_ACM_ENTRY) {+ Error (NULL, 0, 0, "-S Parameter incorrect, too many StartupAcm!", NULL); return 0; }- gFitTableContext.StartupAcm.Type = FIT_TABLE_TYPE_STARTUP_ACM;- gFitTableContext.StartupAcm.Address = (UINT32) (UINTN) FileBuffer;- gFitTableContext.StartupAcm.Size = FileSize;- gFitTableContext.FitEntryNumber ++;+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Type = FIT_TABLE_TYPE_STARTUP_ACM;+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Address = (UINT32) (UINTN) FileBuffer;+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Size = FileSize; // // 1.1 StartupAcm version@@ -1407,7 +1408,10 @@ Returns:
gFitTableContext.StartupAcmVersion = xtoi (argv[Index + 1]); Index += 2; }- } while (FALSE);++ gFitTableContext.StartupAcmNumber ++;+ gFitTableContext.FitEntryNumber ++;+ } // // 1.5. DiagnosticsAcm@@ -1890,7 +1894,9 @@ Returns:
// // Final: Check StartupAcm in BiosModule. //- CheckOverlap (gFitTableContext.StartupAcm.Address, gFitTableContext.StartupAcm.Size);+ for (Index = 0; Index < (INTN)gFitTableContext.StartupAcmNumber; Index++) {+ CheckOverlap (gFitTableContext.StartupAcm[Index].Address, gFitTableContext.StartupAcm[Index].Size);+ } FitEntryNumber = gFitTableContext.FitEntryNumber; for (Index = 0; Index < (INTN)gFitTableContext.OptionalModuleNumber; Index++) { if ((gFitTableContext.OptionalModule[Index].Type == FIT_TABLE_TYPE_BIOS_POLICY) ||@@ -2178,8 +2184,8 @@ Returns:
} printf ("Total FIT Entry number: 0x%x\n", gFitTableContext.FitEntryNumber); printf ("FitHeader version: 0x%04x\n", gFitTableContext.FitHeaderVersion);- if (gFitTableContext.StartupAcm.Address != 0) {- printf ("StartupAcm - (0x%08x, 0x%08x, 0x%04x)\n", gFitTableContext.StartupAcm.Address, gFitTableContext.StartupAcm.Size, gFitTableContext.StartupAcmVersion);+ for (Index = 0; Index < gFitTableContext.StartupAcmNumber; Index++) {+ printf ("StartupAcm[%d] - (0x%08x, 0x%08x, 0x%04x)\n", Index, gFitTableContext.StartupAcm[Index].Address, gFitTableContext.StartupAcm[Index].Size, gFitTableContext.StartupAcmVersion); } if (gFitTableContext.DiagnstAcm.Address != 0) { printf ("DiagnosticAcm - (0x%08x, 0x%08x, 0x%04x)\n", gFitTableContext.DiagnstAcm.Address, gFitTableContext.DiagnstAcm.Size, gFitTableContext.DiagnstAcmVersion);@@ -2809,8 +2815,8 @@ Returns:
// // 4. StartupAcm //- if (gFitTableContext.StartupAcm.Address != 0) {- FitEntry[FitIndex].Address = gFitTableContext.StartupAcm.Address;+ for (Index = 0; Index < gFitTableContext.StartupAcmNumber; Index++) {+ FitEntry[FitIndex].Address = gFitTableContext.StartupAcm[Index].Address; *(UINT32 *)&FitEntry[FitIndex].Size[0] = 0; //gFitTableContext.StartupAcm.Size / 16; FitEntry[FitIndex].Version = (UINT16)gFitTableContext.StartupAcmVersion; FitEntry[FitIndex].Type = FIT_TABLE_TYPE_STARTUP_ACM;@@ -3110,7 +3116,7 @@ GetFitEntryInfo (
Routine Description: - Fill the FIT table information to Fvrecovery+ Get the FIT table information from Fvrecovery Arguments: @@ -3164,8 +3170,8 @@ Returns:
gFitTableContext.MicrocodeNumber ++; break; case FIT_TABLE_TYPE_STARTUP_ACM:- gFitTableContext.StartupAcm.Address = (UINT32)FitEntry[FitIndex].Address;- gFitTableContext.StartupAcmVersion = FitEntry[FitIndex].Version;+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Address = (UINT32)FitEntry[FitIndex].Address;+ gFitTableContext.StartupAcmVersion = FitEntry[FitIndex].Version; break; case FIT_TABLE_TYPE_BIOS_MODULE: gFitTableContext.BiosModule[gFitTableContext.BiosModuleNumber].Address = (UINT32)FitEntry[FitIndex].Address;@@ -3232,6 +3238,7 @@ Returns:
UINT32 FdFileSize; UINT8 *AcmBuffer;+ INTN Index; UINT32 FixedFitLocation; FileBufferRaw = NULL;@@ -3323,22 +3330,23 @@ Returns:
// // Get ACM buffer //- if (gFitTableContext.StartupAcm.Address != 0) {- AcmBuffer = FLASH_TO_MEMORY(gFitTableContext.StartupAcm.Address, FdFileBuffer, FdFileSize);- if ((AcmBuffer < FdFileBuffer) || (AcmBuffer + gFitTableContext.StartupAcm.Size > FdFileBuffer + FdFileSize)) {- printf ("ACM out of range - can not validate it\n");- AcmBuffer = NULL;- }+ for (Index = 0; Index < (INTN)gFitTableContext.StartupAcmNumber; Index ++) {+ if (gFitTableContext.StartupAcm[Index].Address != 0) {+ AcmBuffer = FLASH_TO_MEMORY(gFitTableContext.StartupAcm[Index].Address, FdFileBuffer, FdFileSize);+ if ((AcmBuffer < FdFileBuffer) || (AcmBuffer + gFitTableContext.StartupAcm[Index].Size > FdFileBuffer + FdFileSize)) {+ printf ("ACM out of range - can not validate it\n");+ AcmBuffer = NULL;+ } - if (AcmBuffer != NULL) {- if (CheckAcm ((ACM_FORMAT *)AcmBuffer, gFitTableContext.StartupAcm.Size)) {- DumpAcm ((ACM_FORMAT *)AcmBuffer);- } else {- Status = STATUS_ERROR;- goto exitFunc;+ if (AcmBuffer != NULL) {+ if (CheckAcm ((ACM_FORMAT *)AcmBuffer, gFitTableContext.StartupAcm[Index].Size)) {+ DumpAcm ((ACM_FORMAT *)AcmBuffer);+ } else {+ Status = STATUS_ERROR;+ goto exitFunc;+ } } }- } //@@ -3576,4 +3584,3 @@ Returns:
return u; }-diff --git a/Silicon/Intel/Tools/FitGen/FitGen.h b/Silicon/Intel/Tools/FitGen/FitGen.h
index 5add6a8870..b7de0a6b2d 100644
--- a/Silicon/Intel/Tools/FitGen/FitGen.h
+++ b/Silicon/Intel/Tools/FitGen/FitGen.h
@@ -1,7 +1,7 @@
/**@file Definitions for the FitGen utility. -Copyright (c) 2010-2020, Intel Corporation. All rights reserved.<BR>+Copyright (c) 2010-2022, Intel Corporation. All rights reserved.<BR> SPDX-License-Identifier: BSD-2-Clause-Patent **/@@ -31,7 +31,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
// Utility version information // #define UTILITY_MAJOR_VERSION 0-#define UTILITY_MINOR_VERSION 64+#define UTILITY_MINOR_VERSION 65 #define UTILITY_DATE __DATE__ //--
2.26.2.windows.1


[PATCH v4] UefiPayloadPkg: Add support for logging to CBMEM console

Benjamin Doron
 

Writes TianoCore debug logs into the CBMEM console ringbuffer, from
where the user can retrieve them with the `cbmem` userspace utility.

The intention is to aid in debugging non-fatal issues even in release
builds, or simply make TianoCore's logs available to those interested.
Consequently, MDEPKG_NDEBUG must be masked. As an in-memory debug
logging library, ASSERTs must be non-fatal to be seen, so they neither
dead-loop nor create a breakpoint. It is assumed that ASSERT() neither
enforces fatal conditions nor security integrity, as release builds do
not call DebugAssert() from the ASSERT macro.

More detailed debug logs are produced with the DEBUG_CODE macro, but
this guards other debug-related code throughout the codebase. To avoid
changing behaviour on release builds, this is only set for debug builds.

Tested on QEMU, dumping the appropriate memory region in the UEFI shell
shows the TianoCore log. An improved revision of the debug library used
in several coreboot-related EDK2 forks, including MrChromebox's.
Previous revisions also tested on an Acer Aspire VN7-572G laptop.

Cc: Guo Dong <guo.dong@...>
Cc: Ray Ni <ray.ni@...>
Cc: Maurice Ma <maurice.ma@...>
Cc: Benjamin You <benjamin.you@...>
Cc: Sean Rhodes <sean@...>
Signed-off-by: Benjamin Doron <benjamin.doron00@...>
---
UefiPayloadPkg/Include/Coreboot.h | 13 +
UefiPayloadPkg/Library/CbSerialPortLib/CbSerialPortLib.c | 266 +++++++++=
+++++++++++
UefiPayloadPkg/Library/CbSerialPortLib/CbSerialPortLib.inf | 28 +++
UefiPayloadPkg/UefiPayloadPkg.dsc | 25 +-
4 files changed, 327 insertions(+), 5 deletions(-)

diff --git a/UefiPayloadPkg/Include/Coreboot.h b/UefiPayloadPkg/Include/Cor=
eboot.h
index a3e1109fe84e..2898c07baf3c 100644
--- a/UefiPayloadPkg/Include/Coreboot.h
+++ b/UefiPayloadPkg/Include/Coreboot.h
@@ -199,6 +199,13 @@ struct cb_forward {
UINT64 forward;=0D
};=0D
=0D
+struct cb_cbmem_ref {=0D
+ UINT32 tag;=0D
+ // Field contains size of this struct =3D=3D 0x0010=0D
+ UINT32 size;=0D
+ UINT64 cbmem_addr;=0D
+};=0D
+=0D
#define CB_TAG_FRAMEBUFFER 0x0012=0D
struct cb_framebuffer {=0D
UINT32 tag;=0D
@@ -229,6 +236,12 @@ struct cb_vdat {
=0D
#define CB_TAG_TIMESTAMPS 0x0016=0D
#define CB_TAG_CBMEM_CONSOLE 0x0017=0D
+struct cbmem_console {=0D
+ UINT32 size;=0D
+ UINT32 cursor;=0D
+ UINT8 body[0];=0D
+} __attribute__((packed));=0D
+=0D
#define CB_TAG_MRC_CACHE 0x0018=0D
struct cb_cbmem_tab {=0D
UINT32 tag;=0D
diff --git a/UefiPayloadPkg/Library/CbSerialPortLib/CbSerialPortLib.c b/Uef=
iPayloadPkg/Library/CbSerialPortLib/CbSerialPortLib.c
new file mode 100644
index 000000000000..1b2756166537
--- /dev/null
+++ b/UefiPayloadPkg/Library/CbSerialPortLib/CbSerialPortLib.c
@@ -0,0 +1,266 @@
+/** @file=0D
+ CBMEM console SerialPortLib instance=0D
+=0D
+ Copyright (c) 2022, Baruch Binyamin Doron=0D
+ SPDX-License-Identifier: BSD-2-Clause-Patent=0D
+=0D
+**/=0D
+=0D
+#include <Base.h>=0D
+#include <Coreboot.h>=0D
+=0D
+#include <Library/BaseMemoryLib.h>=0D
+#include <Library/BlParseLib.h>=0D
+#include <Library/SerialPortLib.h>=0D
+=0D
+// Upper nibble contains flags=0D
+#define CBMC_CURSOR_MASK ((1 << 28) - 1)=0D
+#define CBMC_OVERFLOW (1 << 31)=0D
+=0D
+STATIC struct cbmem_console *mCbConsole =3D NULL;=0D
+=0D
+/**=0D
+ Find coreboot record with given Tag.=0D
+ NOTE: This coreboot-specific function definition is absent=0D
+ from the common BlParseLib header.=0D
+=0D
+ @param Tag The tag id to be found=0D
+=0D
+ @retval NULL The Tag is not found.=0D
+ @retval Others The pointer to the record found.=0D
+=0D
+**/=0D
+VOID *=0D
+FindCbTag (=0D
+ IN UINT32 Tag=0D
+ );=0D
+=0D
+/**=0D
+ Initialize the serial device hardware.=0D
+=0D
+ If no initialization is required, then return RETURN_SUCCESS.=0D
+ If the serial device was successfully initialized, then return RETURN_SU=
CCESS.=0D
+ If the serial device could not be initialized, then return RETURN_DEVICE=
_ERROR.=0D
+=0D
+ @retval RETURN_SUCCESS The serial device was initialized.=0D
+ @retval RETURN_DEVICE_ERROR The serial device could not be initialized=
.=0D
+=0D
+**/=0D
+RETURN_STATUS=0D
+EFIAPI=0D
+SerialPortInitialize (=0D
+ VOID=0D
+ )=0D
+{=0D
+ struct cb_cbmem_ref *CbMemRef;=0D
+=0D
+ // The coreboot table contains large structures as references=0D
+ CbMemRef =3D FindCbTag(CB_TAG_CBMEM_CONSOLE);=0D
+ if (CbMemRef =3D=3D NULL) {=0D
+ return RETURN_DEVICE_ERROR;=0D
+ }=0D
+=0D
+ mCbConsole =3D (VOID *)(UINTN)CbMemRef->cbmem_addr; // Support PEI and =
DXE=0D
+ if (mCbConsole =3D=3D NULL) {=0D
+ return RETURN_DEVICE_ERROR;=0D
+ }=0D
+=0D
+ return RETURN_SUCCESS;=0D
+}=0D
+=0D
+/**=0D
+ Write data from buffer to serial device.=0D
+=0D
+ Writes NumberOfBytes data bytes from Buffer to the serial device.=0D
+ The number of bytes actually written to the serial device is returned.=0D
+ If the return value is less than NumberOfBytes, then the write operation=
failed.=0D
+ If Buffer is NULL, then ASSERT().=0D
+ If NumberOfBytes is zero, then return 0.=0D
+=0D
+ @param Buffer Pointer to the data buffer to be written.=0D
+ @param NumberOfBytes Number of bytes to written to the serial device=
.=0D
+=0D
+ @retval 0 NumberOfBytes is 0.=0D
+ @retval >0 The number of bytes written to the serial devic=
e.=0D
+ If this value is less than NumberOfBytes, then =
the write operation failed.=0D
+=0D
+**/=0D
+UINTN=0D
+EFIAPI=0D
+SerialPortWrite (=0D
+ IN UINT8 *Buffer,=0D
+ IN UINTN NumberOfBytes=0D
+ )=0D
+{=0D
+ UINT32 Cursor;=0D
+ UINT32 Flags;=0D
+=0D
+ if (Buffer =3D=3D NULL || NumberOfBytes =3D=3D 0) {=0D
+ return 0;=0D
+ }=0D
+=0D
+ if (mCbConsole =3D=3D NULL) {=0D
+ return 0;=0D
+ }=0D
+=0D
+ Cursor =3D mCbConsole->cursor & CBMC_CURSOR_MASK;=0D
+ Flags =3D mCbConsole->cursor & ~CBMC_CURSOR_MASK;=0D
+ if (Cursor >=3D mCbConsole->size) {=0D
+ // Already overflowed; bail out. TODO: Is this unnecessarily cautious?=
=0D
+ // - Supports old coreboot version with legacy overflow mechanism.=0D
+ return 0;=0D
+ }=0D
+=0D
+ if (Cursor + NumberOfBytes > mCbConsole->size) {=0D
+ // Will overflow, zero cursor and set flag.=0D
+ Cursor =3D 0;=0D
+ Flags |=3D CBMC_OVERFLOW;=0D
+ }=0D
+=0D
+ if (NumberOfBytes > mCbConsole->size) {=0D
+ // This one debug message is longer than the entire buffer. Truncate i=
t.=0D
+ // - TODO: Is this unnecessarily cautious?=0D
+ NumberOfBytes =3D mCbConsole->size;=0D
+ }=0D
+=0D
+ CopyMem (&mCbConsole->body[Cursor], Buffer, NumberOfBytes);=0D
+ Cursor +=3D NumberOfBytes;=0D
+=0D
+ if (Cursor =3D=3D mCbConsole->size) {=0D
+ // Next message will overflow, zero cursor.=0D
+ // - Set flag preemptively. This could not be determined later.=0D
+ Cursor =3D 0;=0D
+ Flags |=3D CBMC_OVERFLOW;=0D
+ }=0D
+=0D
+ mCbConsole->cursor =3D Flags | Cursor;=0D
+=0D
+ return NumberOfBytes;=0D
+}=0D
+=0D
+/**=0D
+ Read data from serial device and save the datas in buffer.=0D
+=0D
+ Reads NumberOfBytes data bytes from a serial device into the buffer=0D
+ specified by Buffer. The number of bytes actually read is returned.=0D
+ If Buffer is NULL, then ASSERT().=0D
+ If NumberOfBytes is zero, then return 0.=0D
+=0D
+ @param Buffer Pointer to the data buffer to store the data re=
ad from the serial device.=0D
+ @param NumberOfBytes Number of bytes which will be read.=0D
+=0D
+ @retval 0 Read data failed, no data is to be read.=0D
+ @retval >0 Actual number of bytes read from serial device.=
=0D
+=0D
+**/=0D
+UINTN=0D
+EFIAPI=0D
+SerialPortRead (=0D
+ OUT UINT8 *Buffer,=0D
+ IN UINTN NumberOfBytes=0D
+)=0D
+{=0D
+ return 0;=0D
+}=0D
+=0D
+/**=0D
+ Polls a serial device to see if there is any data waiting to be read.=0D
+=0D
+ @retval TRUE Data is waiting to be read from the serial devi=
ce.=0D
+ @retval FALSE There is no data waiting to be read from the se=
rial device.=0D
+=0D
+**/=0D
+BOOLEAN=0D
+EFIAPI=0D
+SerialPortPoll (=0D
+ VOID=0D
+ )=0D
+{=0D
+ return FALSE;=0D
+}=0D
+=0D
+/**=0D
+ Sets the control bits on a serial device.=0D
+=0D
+ @param Control Sets the bits of Control that are settable=
.=0D
+=0D
+ @retval RETURN_SUCCESS The new control bits were set on the seria=
l device.=0D
+ @retval RETURN_UNSUPPORTED The serial device does not support this op=
eration.=0D
+ @retval RETURN_DEVICE_ERROR The serial device is not functioning corre=
ctly.=0D
+=0D
+**/=0D
+RETURN_STATUS=0D
+EFIAPI=0D
+SerialPortSetControl (=0D
+ IN UINT32 Control=0D
+ )=0D
+{=0D
+ return RETURN_UNSUPPORTED;=0D
+}=0D
+=0D
+/**=0D
+ Retrieve the status of the control bits on a serial device.=0D
+=0D
+ @param Control A pointer to return the current control si=
gnals from the serial device.=0D
+=0D
+ @retval RETURN_SUCCESS The control bits were read from the serial=
device.=0D
+ @retval RETURN_UNSUPPORTED The serial device does not support this op=
eration.=0D
+ @retval RETURN_DEVICE_ERROR The serial device is not functioning corre=
ctly.=0D
+=0D
+**/=0D
+RETURN_STATUS=0D
+EFIAPI=0D
+SerialPortGetControl (=0D
+ OUT UINT32 *Control=0D
+ )=0D
+{=0D
+ return RETURN_UNSUPPORTED;=0D
+}=0D
+=0D
+/**=0D
+ Sets the baud rate, receive FIFO depth, transmit/receive time out, parit=
y,=0D
+ data bits, and stop bits on a serial device.=0D
+=0D
+ @param BaudRate The requested baud rate. A BaudRate value of 0=
will use the=0D
+ device's default interface speed.=0D
+ On output, the value actually set.=0D
+ @param ReceiveFifoDepth The requested depth of the FIFO on the receive=
side of the=0D
+ serial interface. A ReceiveFifoDepth value of =
0 will use=0D
+ the device's default FIFO depth.=0D
+ On output, the value actually set.=0D
+ @param Timeout The requested time out for a single character =
in microseconds.=0D
+ This timeout applies to both the transmit and =
receive side of the=0D
+ interface. A Timeout value of 0 will use the d=
evice's default time=0D
+ out value.=0D
+ On output, the value actually set.=0D
+ @param Parity The type of parity to use on this serial devic=
e. A Parity value of=0D
+ DefaultParity will use the device's default pa=
rity value.=0D
+ On output, the value actually set.=0D
+ @param DataBits The number of data bits to use on the serial d=
evice. A DataBits=0D
+ value of 0 will use the device's default data =
bit setting.=0D
+ On output, the value actually set.=0D
+ @param StopBits The number of stop bits to use on this serial =
device. A StopBits=0D
+ value of DefaultStopBits will use the device's=
default number of=0D
+ stop bits.=0D
+ On output, the value actually set.=0D
+=0D
+ @retval RETURN_SUCCESS The new attributes were set on the ser=
ial device.=0D
+ @retval RETURN_UNSUPPORTED The serial device does not support thi=
s operation.=0D
+ @retval RETURN_INVALID_PARAMETER One or more of the attributes has an u=
nsupported value.=0D
+ @retval RETURN_DEVICE_ERROR The serial device is not functioning c=
orrectly.=0D
+=0D
+**/=0D
+RETURN_STATUS=0D
+EFIAPI=0D
+SerialPortSetAttributes (=0D
+ IN OUT UINT64 *BaudRate,=0D
+ IN OUT UINT32 *ReceiveFifoDepth,=0D
+ IN OUT UINT32 *Timeout,=0D
+ IN OUT EFI_PARITY_TYPE *Parity,=0D
+ IN OUT UINT8 *DataBits,=0D
+ IN OUT EFI_STOP_BITS_TYPE *StopBits=0D
+ )=0D
+{=0D
+ return RETURN_UNSUPPORTED;=0D
+}=0D
+=0D
diff --git a/UefiPayloadPkg/Library/CbSerialPortLib/CbSerialPortLib.inf b/U=
efiPayloadPkg/Library/CbSerialPortLib/CbSerialPortLib.inf
new file mode 100644
index 000000000000..ec5739beac52
--- /dev/null
+++ b/UefiPayloadPkg/Library/CbSerialPortLib/CbSerialPortLib.inf
@@ -0,0 +1,28 @@
+## @file=0D
+# CBMEM console SerialPortLib instance=0D
+#=0D
+# Copyright (c) 2022, Baruch Binyamin Doron=0D
+# SPDX-License-Identifier: BSD-2-Clause-Patent=0D
+#=0D
+##=0D
+=0D
+[Defines]=0D
+ INF_VERSION =3D 0x00010005=0D
+ BASE_NAME =3D CbSerialPortLib=0D
+ FILE_GUID =3D 0DB3EF12-1426-4086-B012-113184C4CE11=
=0D
+ MODULE_TYPE =3D BASE=0D
+ VERSION_STRING =3D 1.0=0D
+ LIBRARY_CLASS =3D SerialPortLib=0D
+ CONSTRUCTOR =3D SerialPortInitialize=0D
+=0D
+[Packages]=0D
+ MdePkg/MdePkg.dec=0D
+ MdeModulePkg/MdeModulePkg.dec=0D
+ UefiPayloadPkg/UefiPayloadPkg.dec=0D
+=0D
+[LibraryClasses]=0D
+ BaseMemoryLib=0D
+ BlParseLib=0D
+=0D
+[Sources]=0D
+ CbSerialPortLib.c=0D
diff --git a/UefiPayloadPkg/UefiPayloadPkg.dsc b/UefiPayloadPkg/UefiPayload=
Pkg.dsc
index 4d9bbc80c866..0e4248767756 100644
--- a/UefiPayloadPkg/UefiPayloadPkg.dsc
+++ b/UefiPayloadPkg/UefiPayloadPkg.dsc
@@ -37,6 +37,7 @@
DEFINE ABOVE_4G_MEMORY =3D TRUE=0D
DEFINE BOOT_MANAGER_ESCAPE =3D FALSE=0D
DEFINE SD_MMC_TIMEOUT =3D 1000000=0D
+ DEFINE USE_CBMEM_FOR_CONSOLE =3D FALSE=0D
#=0D
# SBL: UEFI payload for Slim Bootloader=0D
# COREBOOT: UEFI payload for coreboot=0D
@@ -121,10 +122,11 @@
=0D
[BuildOptions]=0D
*_*_*_CC_FLAGS =3D -D DISABLE_NEW_DEPRECATED_INTERFACES=
=0D
- GCC:*_UNIXGCC_*_CC_FLAGS =3D -DMDEPKG_NDEBUG=0D
+!if $(USE_CBMEM_FOR_CONSOLE) =3D=3D FALSE=0D
GCC:RELEASE_*_*_CC_FLAGS =3D -DMDEPKG_NDEBUG=0D
INTEL:RELEASE_*_*_CC_FLAGS =3D /D MDEPKG_NDEBUG=0D
MSFT:RELEASE_*_*_CC_FLAGS =3D /D MDEPKG_NDEBUG=0D
+!endif=0D
=0D
[BuildOptions.common.EDKII.DXE_RUNTIME_DRIVER]=0D
GCC:*_*_*_DLINK_FLAGS =3D -z common-page-size=3D0x1000=0D
@@ -231,8 +233,13 @@
TimerLib|UefiPayloadPkg/Library/AcpiTimerLib/AcpiTimerLib.inf=0D
!endif=0D
ResetSystemLib|UefiPayloadPkg/Library/ResetSystemLib/ResetSystemLib.inf=
=0D
+!if $(USE_CBMEM_FOR_CONSOLE) =3D=3D TRUE=0D
+ SerialPortLib|UefiPayloadPkg/Library/CbSerialPortLib/CbSerialPortLib.inf=
=0D
+ PlatformHookLib|MdeModulePkg/Library/BasePlatformHookLibNull/BasePlatfor=
mHookLibNull.inf=0D
+!else=0D
SerialPortLib|MdeModulePkg/Library/BaseSerialPortLib16550/BaseSerialPort=
Lib16550.inf=0D
PlatformHookLib|UefiPayloadPkg/Library/PlatformHookLib/PlatformHookLib.i=
nf=0D
+!endif=0D
PlatformBootManagerLib|UefiPayloadPkg/Library/PlatformBootManagerLib/Pla=
tformBootManagerLib.inf=0D
IoApicLib|PcAtChipsetPkg/Library/BaseIoApicLib/BaseIoApicLib.inf=0D
=0D
@@ -422,10 +429,18 @@
gEfiMdeModulePkgTokenSpaceGuid.PcdBootManagerMenuFile|{ 0x21, 0xaa, 0x2c=
, 0x46, 0x14, 0x76, 0x03, 0x45, 0x83, 0x6e, 0x8a, 0xb6, 0xf4, 0x66, 0x23, 0=
x31 }=0D
gEfiMdePkgTokenSpaceGuid.PcdReportStatusCodePropertyMask|0x7=0D
gEfiMdePkgTokenSpaceGuid.PcdDebugPrintErrorLevel|0x8000004F=0D
-!if $(SOURCE_DEBUG_ENABLE)=0D
- gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x17=0D
+!if $(USE_CBMEM_FOR_CONSOLE) =3D=3D FALSE=0D
+ !if $(SOURCE_DEBUG_ENABLE)=0D
+ gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x17=0D
+ !else=0D
+ gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x2F=0D
+ !endif=0D
!else=0D
- gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x2F=0D
+ !if $(TARGET) =3D=3D DEBUG=0D
+ gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x07=0D
+ !else=0D
+ gEfiMdePkgTokenSpaceGuid.PcdDebugPropertyMask|0x03=0D
+ !endif=0D
!endif=0D
gEfiMdeModulePkgTokenSpaceGuid.PcdMaxSizeNonPopulateCapsule|$(MAX_SIZE_N=
ON_POPULATE_CAPSULE)=0D
#=0D
@@ -471,7 +486,7 @@
gUefiCpuPkgTokenSpaceGuid.PcdCpuApLoopMode=0D
gUefiCpuPkgTokenSpaceGuid.PcdCpuMicrocodePatchAddress=0D
gUefiCpuPkgTokenSpaceGuid.PcdCpuMicrocodePatchRegionSize=0D
-!if $(TARGET) =3D=3D DEBUG=0D
+!if ($(TARGET) =3D=3D DEBUG || $(USE_CBMEM_FOR_CONSOLE) =3D=3D TRUE)=0D
gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseSerial|TRUE=0D
!else=0D
gEfiMdeModulePkgTokenSpaceGuid.PcdStatusCodeUseSerial|FALSE=0D
--=20
2.36.1


[PATCH] Ovmf: Include HardwareInfoLib library classes for IntelTdx

Ojeda Leon, Nicolas
 

Include HardwareInfoLib classes in the IntelTdxX64.dsc for this
platform to use it during build given that PciHostBridgeUtilityLib
depends on it.

Cc: Alexander Graf <graf@...>
Cc: Gerd Hoffmann <kraxel@...>
Cc: Ard Biesheuvel <ardb@...>
Signed-off-by: Nicolas Ojeda Leon <ncoleon@...>
---
OvmfPkg/IntelTdx/IntelTdxX64.dsc | 2 ++
1 file changed, 2 insertions(+)

diff --git a/OvmfPkg/IntelTdx/IntelTdxX64.dsc b/OvmfPkg/IntelTdx/IntelTdxX64.dsc
index a40f7228b9..c662ae8720 100644
--- a/OvmfPkg/IntelTdx/IntelTdxX64.dsc
+++ b/OvmfPkg/IntelTdx/IntelTdxX64.dsc
@@ -164,6 +164,8 @@
LoadLinuxLib|OvmfPkg/Library/LoadLinuxLib/LoadLinuxLib.inf
MemEncryptSevLib|OvmfPkg/Library/BaseMemEncryptSevLib/DxeMemEncryptSevLib.inf
MemEncryptTdxLib|OvmfPkg/Library/BaseMemEncryptTdxLib/BaseMemEncryptTdxLib.inf
+ PeiHardwareInfoLib|OvmfPkg/Library/HardwareInfoLib/PeiHardwareInfoLib.inf
+ DxeHardwareInfoLib|OvmfPkg/Library/HardwareInfoLib/DxeHardwareInfoLib.inf

LockBoxLib|OvmfPkg/Library/LockBoxLib/LockBoxBaseLib.inf
CustomizedDisplayLib|MdeModulePkg/Library/CustomizedDisplayLib/CustomizedDisplayLib.inf
--
2.17.1




Amazon Development Center Germany GmbH
Krausenstr. 38
10117 Berlin
Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss
Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B
Sitz: Berlin
Ust-ID: DE 289 237 879


[PATCH 1/2] ArmVirtPkg: Include DxeHardwareInfoLib library class in dsc

Ojeda Leon, Nicolas
 

Include DxeHardwareInfoLib class in the common ArmVirt.dsc.inc so that
ArmVirt* platforms use it during build given that PciHostBridgeUtilityLib
depends on it.

Cc: Alexander Graf <graf@...>
Cc: Gerd Hoffmann <kraxel@...>
Cc: Ard Biesheuvel <ardb@...>
Signed-off-by: Nicolas Ojeda Leon <ncoleon@...>
---
ArmVirtPkg/ArmVirt.dsc.inc | 1 +
ArmVirtPkg/ArmVirtQemu.dsc | 1 -
2 files changed, 1 insertion(+), 1 deletion(-)

diff --git a/ArmVirtPkg/ArmVirt.dsc.inc b/ArmVirtPkg/ArmVirt.dsc.inc
index f15a3f7f06..4732bd76d6 100644
--- a/ArmVirtPkg/ArmVirt.dsc.inc
+++ b/ArmVirtPkg/ArmVirt.dsc.inc
@@ -144,6 +144,7 @@
PciCapLib|OvmfPkg/Library/BasePciCapLib/BasePciCapLib.inf
PciCapPciSegmentLib|OvmfPkg/Library/BasePciCapPciSegmentLib/BasePciCapPciSegmentLib.inf
PciCapPciIoLib|OvmfPkg/Library/UefiPciCapPciIoLib/UefiPciCapPciIoLib.inf
+ DxeHardwareInfoLib|OvmfPkg/Library/HardwareInfoLib/DxeHardwareInfoLib.inf

# USB Libraries
UefiUsbLib|MdePkg/Library/UefiUsbLib/UefiUsbLib.inf
diff --git a/ArmVirtPkg/ArmVirtQemu.dsc b/ArmVirtPkg/ArmVirtQemu.dsc
index 56eb53911d..9369a88858 100644
--- a/ArmVirtPkg/ArmVirtQemu.dsc
+++ b/ArmVirtPkg/ArmVirtQemu.dsc
@@ -82,7 +82,6 @@
PciHostBridgeLib|OvmfPkg/Fdt/FdtPciHostBridgeLib/FdtPciHostBridgeLib.inf
PciHostBridgeUtilityLib|OvmfPkg/Library/PciHostBridgeUtilityLib/PciHostBridgeUtilityLib.inf
PeiHardwareInfoLib|OvmfPkg/Library/HardwareInfoLib/PeiHardwareInfoLib.inf
- DxeHardwareInfoLib|OvmfPkg/Library/HardwareInfoLib/DxeHardwareInfoLib.inf

!if $(TPM2_ENABLE) == TRUE
Tpm2CommandLib|SecurityPkg/Library/Tpm2CommandLib/Tpm2CommandLib.inf
--
2.17.1




Amazon Development Center Germany GmbH
Krausenstr. 38
10117 Berlin
Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss
Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B
Sitz: Berlin
Ust-ID: DE 289 237 879


[PATCH 0/2] Include HardwareInfoLib in all platforms using

Ojeda Leon, Nicolas
 

In past days, a patch series to support multiple PCI host bridges in Ovmf
was merged which caused an error in ArmVirtQemuKernel.dsc build, part
of the CI pipeline.

These 2 commits aim at fixing this issue by adding the HardwareInfoLib
to all ArmVirt* platofrms as well as for IntelTdx which were missing
this library that now is a dependency of PciHostBridgeUtilityLib.

Nicolas Ojeda Leon (2):
ArmVirtPkg: Include DxeHardwareInfoLib library class in dsc
Ovmf: Include HardwareInfoLib library classes for IntelTdx

ArmVirtPkg/ArmVirt.dsc.inc | 1 +
ArmVirtPkg/ArmVirtQemu.dsc | 1 -
OvmfPkg/IntelTdx/IntelTdxX64.dsc | 2 ++
3 files changed, 3 insertions(+), 1 deletion(-)

--
2.17.1




Amazon Development Center Germany GmbH
Krausenstr. 38
10117 Berlin
Geschaeftsfuehrung: Christian Schlaeger, Jonathan Weiss
Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B
Sitz: Berlin
Ust-ID: DE 289 237 879


[PATCH v2 2/2] [edk2-platforms] Silicon/Intel/FitGen: Support to override the MBZ byte in Startup ACM entries for other usages

Lin, Jason1
 

From: Jason1 Lin <jason1.lin@...>

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

As per FIT BIOS Specification 1.2 Rules, the size bytes (3 bytes)/
reserved byte (1 byte) / CheckSum byte (1 byte) in type 2 are must-be-zero =
(MBZ).
These bytes could be override for the other usages.
In the future, if these bytes field have other meanings, there would be no =
need to change the FitGen.

Command:
[-S <StartupAcmAddress StartupAcmSize>|<StartupAcmGuid>]
[-I <StartupAcmSizeByte0 StartupAcmSizeByte1 StartupAcmSizeByte2 StartupAcm=
Rsvd StartupAcmChksum>]
[-V <StartupAcmVersion>]

With "-I" input the default Type 2 entry version would be 0x200.

Signed-off-by: Jason1 Lin <jason1.lin@...>
Cc: Bob Feng <bob.c.feng@...>
Cc: Liming Gao <gaoliming@...>
Cc: Yuwei Chen <yuwei.chen@...>
Cc: Isaac W Oram <isaac.w.oram@...>
Cc: Rangasai V Chaganty <rangasai.v.chaganty@...>
Cc: Dakota Chiang <dakota.chiang@...>
---
Silicon/Intel/Tools/FitGen/FitGen.c | 105 ++++++++++++++++----
Silicon/Intel/Tools/FitGen/FitGen.h | 2 +-
2 files changed, 88 insertions(+), 19 deletions(-)

diff --git a/Silicon/Intel/Tools/FitGen/FitGen.c b/Silicon/Intel/Tools/FitG=
en/FitGen.c
index eac8fa8715..bdda8dfd5a 100644
--- a/Silicon/Intel/Tools/FitGen/FitGen.c
+++ b/Silicon/Intel/Tools/FitGen/FitGen.c
@@ -210,6 +210,7 @@ typedef struct {
=0D
#define DEFAULT_FIT_TABLE_POINTER_OFFSET 0x40=0D
#define DEFAULT_FIT_ENTRY_VERSION 0x0100=0D
+#define STARTUP_ACM_FIT_ENTRY_200_VERSION 0x0200=0D
=0D
#define TOP_FLASH_ADDRESS (gFitTableContext.TopFlashAddressRemapValue)=0D
=0D
@@ -247,6 +248,12 @@ typedef struct {
UINT8 *Buffer; // Used by OptionalModule only=0D
UINT32 Size;=0D
UINT32 Version; // Used by OptionalModule and PortModule only=0D
+ UINT32 MaxSize;=0D
+ UINT8 SizeByte0; // Used by S-ACM only=0D
+ UINT8 SizeByte1; // Used by S-ACM only=0D
+ UINT8 SizeByte2; // Used by S-ACM only=0D
+ UINT8 Rsvd; // Used by S-ACM only=0D
+ UINT8 ChkSum; // Used by S-ACM only=0D
} FIT_TABLE_CONTEXT_ENTRY;=0D
=0D
typedef struct {=0D
@@ -262,7 +269,7 @@ typedef struct {
UINT32 GlobalVersion;=0D
UINT32 FitHeaderVersion;=0D
FIT_TABLE_CONTEXT_ENTRY StartupAcm[MAX_STARTUP_ACM_ENTRY];=0D
- UINT32 StartupAcmVersion;=0D
+ UINT32 StartupAcmVersion[MAX_STARTUP_ACM_ENTRY];=0D
FIT_TABLE_CONTEXT_ENTRY DiagnstAcm;=0D
UINT32 DiagnstAcmVersion;=0D
FIT_TABLE_CONTEXT_ENTRY BiosModule[MAX_BIOS_MODULE_ENTRY];=0D
@@ -341,7 +348,7 @@ Returns:
"\t[-L <MicrocodeSlotSize> <MicrocodeFfsGuid>]\n"=0D
"\t[-LF <MicrocodeSlotSize>]\n"=0D
"\t[-I <BiosInfoGuid>]\n"=0D
- "\t[-S <StartupAcmAddress StartupAcmSize>|<StartupAcmGuid>] [-V =
<StartupAcmVersion>]\n"=0D
+ "\t[-S <StartupAcmAddress StartupAcmSize>|<StartupAcmGuid>] [-I =
<StartupAcmSizeByte0 StartupAcmSizeByte1 StartupAcmSizeByte2 StartupAcmRsvd=
StartupAcmChksum>] [-V <StartupAcmVersion>]\n"=0D
"\t[-U <DiagnstAcmAddress>|<DiagnstAcmGuid>]\n"=0D
"\t[-B <BiosModuleAddress BiosModuleSize>] [-B ...] [-V <BiosMod=
uleVersion>]\n"=0D
"\t[-M <MicrocodeAddress MicrocodeSize>] [-M ...]|[-U <Microcode=
Fv MicrocodeBase>|<MicrocodeRegionOffset MicrocodeRegionSize>|<MicrocodeGui=
d>] [-V <MicrocodeVersion>]\n"=0D
@@ -357,7 +364,13 @@ Returns:
printf ("\tBiosInfoGuid - Guid of BiosInfo Module. If this mod=
ule exists, StartupAcm/Bios/Microcode can be optional.\n");=0D
printf ("\tStartupAcmAddress - Address of StartupAcm.\n");=0D
printf ("\tStartupAcmSize - Size of StartupAcm.\n");=0D
- printf ("\tStartupAcmGuid - Guid of StartupAcm Module, if Startu=
pAcm is in a BiosModule, it will be excluded form that.\n");=0D
+ printf ("\tStartupAcmGuid - Guid of StartupAcm Module.\n");=0D
+ printf ("\tStartupAcmMaxSize - The maximum size value that could pl=
ace the StartupAcm in.\n");=0D
+ printf ("\tStartupAcmSizeByte0 - The value for Size byte 0 (Override =
default value).\n");=0D
+ printf ("\tStartupAcmSizeByte1 - The value for Size byte 1 (Override =
default value).\n");=0D
+ printf ("\tStartupAcmSizeByte2 - The value for Size byte 2 (Override =
default value).\n");=0D
+ printf ("\tStartupAcmRsvd - The value for Reserved byte (Overrid=
e default value).\n");=0D
+ printf ("\tStartupAcmChkSum - The value for CheckSum byte (Overrid=
e default value).\n");=0D
printf ("\tDiagnstAcmAddress - Address of DiagnstAcm.\n");=0D
printf ("\tDiagnstAcmGuid - Guid of DiagnstAcm Module, if Diagns=
tAcm is in a BiosModule, it will be excluded from that.\n");=0D
printf ("\tBiosModuleAddress - Address of BiosModule. User should e=
nsure there is no overlap.\n");=0D
@@ -913,6 +926,9 @@ Returns:
UINT32 FileSize;=0D
UINT32 Type;=0D
UINT32 SubType;=0D
+ UINT8 StartupAcmSizeByte0;=0D
+ UINT8 StartupAcmSizeByte1;=0D
+ UINT8 StartupAcmSizeByte2;=0D
UINT8 *MicrocodeFileBuffer;=0D
UINT8 *MicrocodeFileBufferRaw;=0D
UINT32 MicrocodeFileSize;=0D
@@ -1155,9 +1171,12 @@ Returns:
Error (NULL, 0, 0, "-I Parameter incorrect, too many StartupAc=
m!", NULL);=0D
return 0;=0D
}=0D
+ //=0D
+ // NOTE: BIOS INFO structure not support to override the Size/Rs=
vd/ChkSum byte value.=0D
+ //=0D
gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].T=
ype =3D FIT_TABLE_TYPE_STARTUP_ACM;=0D
gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].A=
ddress =3D (UINT32)BiosInfoStruct[BiosInfoIndex].Address;=0D
- gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].S=
ize =3D (UINT32)BiosInfoStruct[BiosInfoIndex].Size;=0D
+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].M=
axSize =3D (UINT32)BiosInfoStruct[BiosInfoIndex].Size;=0D
gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].V=
ersion =3D BiosInfoStruct[BiosInfoIndex].Version;=0D
gFitTableContext.StartupAcmNumber ++;=0D
gFitTableContext.FitEntryNumber ++;=0D
@@ -1389,10 +1408,52 @@ Returns:
}=0D
gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Type =
=3D FIT_TABLE_TYPE_STARTUP_ACM;=0D
gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Address=
=3D (UINT32) (UINTN) FileBuffer;=0D
- gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Size =
=3D FileSize;=0D
+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].MaxSize=
=3D FileSize;=0D
=0D
//=0D
- // 1.1 StartupAcm version=0D
+ // 1.1 Support 0x200 StartupAcm Information=0D
+ //=0D
+ if ((Index + 1 >=3D argc) ||=0D
+ ((strcmp (argv[Index], "-I") !=3D 0) &&=0D
+ (strcmp (argv[Index], "-i") !=3D 0)) ) {=0D
+ //=0D
+ // Bypass=0D
+ //=0D
+ gFitTableContext.StartupAcmVersion[gFitTableContext.StartupAcmNumber=
] =3D gFitTableContext.GlobalVersion;=0D
+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Size =
=3D 0;=0D
+ } else {=0D
+ //=0D
+ // Should use the multiple StartupACM=0D
+ //=0D
+ if (Index + 5 >=3D argc) {=0D
+ //=0D
+ // Should get five input value, but not sufficient=0D
+ //=0D
+ Error (NULL, 0, 0, "-I Parameter incorrect, Require five inputs va=
lue!", NULL);=0D
+ return 0;=0D
+ } else {=0D
+ //=0D
+ // Should assign this as 0x200=0D
+ //=0D
+ gFitTableContext.StartupAcmVersion[gFitTableContext.StartupAcmNumb=
er] =3D STARTUP_ACM_FIT_ENTRY_200_VERSION;=0D
+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Siz=
eByte0 =3D (UINT8)xtoi (argv[Index + 1]);=0D
+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Siz=
eByte1 =3D (UINT8)xtoi (argv[Index + 2]);=0D
+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Siz=
eByte2 =3D (UINT8)xtoi (argv[Index + 3]);=0D
+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Rsv=
d =3D (UINT8)xtoi (argv[Index + 4]);=0D
+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Chk=
Sum =3D (UINT8)xtoi (argv[Index + 5]);=0D
+=0D
+ StartupAcmSizeByte0 =3D (UINT32)gFitTableContext.StartupAcm[gFitT=
ableContext.StartupAcmNumber].SizeByte0;=0D
+ StartupAcmSizeByte1 =3D (UINT32)gFitTableContext.StartupAcm[gFitT=
ableContext.StartupAcmNumber].SizeByte1;=0D
+ StartupAcmSizeByte2 =3D (UINT32)gFitTableContext.StartupAcm[gFitT=
ableContext.StartupAcmNumber].SizeByte2;=0D
+=0D
+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Siz=
e =3D (StartupAcmSizeByte2 << 16) + (StartupAcmSizeByte1 << 8) + (Startup=
AcmSizeByte0);=0D
+=0D
+ Index +=3D 6;=0D
+ }=0D
+ }=0D
+=0D
+ //=0D
+ // 1.2 StartupAcm version=0D
//=0D
if ((Index + 1 >=3D argc) ||=0D
((strcmp (argv[Index], "-V") !=3D 0) &&=0D
@@ -1400,18 +1461,17 @@ Returns:
//=0D
// Bypass=0D
//=0D
- gFitTableContext.StartupAcmVersion =3D gFitTableContext.GlobalVersio=
n;=0D
} else {=0D
//=0D
// Get offset from parameter=0D
//=0D
- gFitTableContext.StartupAcmVersion =3D xtoi (argv[Index + 1]);=0D
+ gFitTableContext.StartupAcmVersion[gFitTableContext.StartupAcmNumber=
] =3D xtoi (argv[Index + 1]);=0D
Index +=3D 2;=0D
}=0D
=0D
gFitTableContext.StartupAcmNumber ++;=0D
gFitTableContext.FitEntryNumber ++;=0D
- }=0D
+ };=0D
=0D
//=0D
// 1.5. DiagnosticsAcm=0D
@@ -1895,7 +1955,7 @@ Returns:
// Final: Check StartupAcm in BiosModule.=0D
//=0D
for (Index =3D 0; Index < (INTN)gFitTableContext.StartupAcmNumber; Index=
++) {=0D
- CheckOverlap (gFitTableContext.StartupAcm[Index].Address, gFitTableCon=
text.StartupAcm[Index].Size);=0D
+ CheckOverlap (gFitTableContext.StartupAcm[Index].Address, gFitTableCon=
text.StartupAcm[Index].MaxSize);=0D
}=0D
FitEntryNumber =3D gFitTableContext.FitEntryNumber;=0D
for (Index =3D 0; Index < (INTN)gFitTableContext.OptionalModuleNumber; I=
ndex++) {=0D
@@ -2185,7 +2245,7 @@ Returns:
printf ("Total FIT Entry number: 0x%x\n", gFitTableContext.FitEntryNumbe=
r);=0D
printf ("FitHeader version: 0x%04x\n", gFitTableContext.FitHeaderVersion=
);=0D
for (Index =3D 0; Index < gFitTableContext.StartupAcmNumber; Index++) {=
=0D
- printf ("StartupAcm[%d] - (0x%08x, 0x%08x, 0x%04x)\n", Index, gFitTabl=
eContext.StartupAcm[Index].Address, gFitTableContext.StartupAcm[Index].Size=
, gFitTableContext.StartupAcmVersion);=0D
+ printf ("StartupAcm[%d] - (0x%08x, 0x%08x, 0x%08x, 0x%04x)\n", Index, =
gFitTableContext.StartupAcm[Index].Address, gFitTableContext.StartupAcm[Ind=
ex].Size, gFitTableContext.StartupAcm[Index].MaxSize, gFitTableContext.Star=
tupAcmVersion[Index]);=0D
}=0D
if (gFitTableContext.DiagnstAcm.Address !=3D 0) {=0D
printf ("DiagnosticAcm - (0x%08x, 0x%08x, 0x%04x)\n", gFitTableContext=
.DiagnstAcm.Address, gFitTableContext.DiagnstAcm.Size, gFitTableContext.Dia=
gnstAcmVersion);=0D
@@ -2817,11 +2877,12 @@ Returns:
//=0D
for (Index =3D 0; Index < gFitTableContext.StartupAcmNumber; Index++) {=
=0D
FitEntry[FitIndex].Address =3D gFitTableContext.StartupAcm=
[Index].Address;=0D
- *(UINT32 *)&FitEntry[FitIndex].Size[0] =3D 0; //gFitTableContext.Start=
upAcm.Size / 16;=0D
- FitEntry[FitIndex].Version =3D (UINT16)gFitTableContext.St=
artupAcmVersion;=0D
+ *(UINT32 *)&FitEntry[FitIndex].Size[0] =3D gFitTableContext.StartupAcm=
[Index].Size;=0D
+ FitEntry[FitIndex].Version =3D (UINT16)gFitTableContext.St=
artupAcmVersion[Index];=0D
FitEntry[FitIndex].Type =3D FIT_TABLE_TYPE_STARTUP_ACM;=
=0D
FitEntry[FitIndex].C_V =3D 0;=0D
- FitEntry[FitIndex].Checksum =3D 0;=0D
+ FitEntry[FitIndex].Rsvd =3D gFitTableContext.StartupAcm=
[Index].Rsvd;=0D
+ FitEntry[FitIndex].Checksum =3D gFitTableContext.StartupAcm=
[Index].ChkSum;=0D
FitIndex++;=0D
}=0D
=0D
@@ -3170,8 +3231,16 @@ Returns:
gFitTableContext.MicrocodeNumber ++;=0D
break;=0D
case FIT_TABLE_TYPE_STARTUP_ACM:=0D
- gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Addre=
ss =3D (UINT32)FitEntry[FitIndex].Address;=0D
- gFitTableContext.StartupAcmVersion =
=3D FitEntry[FitIndex].Version;=0D
+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Addre=
ss =3D (UINT32)FitEntry[FitIndex].Address;=0D
+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Type =
=3D FitEntry[FitIndex].Type;=0D
+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Size =
=3D *(UINT32 *)&FitEntry[FitIndex].Size[0];=0D
+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].SizeB=
yte0 =3D *(UINT8 *)&FitEntry[FitIndex].Size[0];=0D
+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].SizeB=
yte1 =3D *(UINT8 *)&FitEntry[FitIndex].Size[1];=0D
+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].SizeB=
yte2 =3D *(UINT8 *)&FitEntry[FitIndex].Size[2];=0D
+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Rsvd =
=3D FitEntry[FitIndex].Rsvd;=0D
+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].ChkSu=
m =3D FitEntry[FitIndex].Checksum;=0D
+ gFitTableContext.StartupAcmVersion[gFitTableContext.StartupAcmNumber=
] =3D FitEntry[FitIndex].Version;=0D
+ gFitTableContext.StartupAcmNumber ++;=0D
break;=0D
case FIT_TABLE_TYPE_BIOS_MODULE:=0D
gFitTableContext.BiosModule[gFitTableContext.BiosModuleNumber].Addre=
ss =3D (UINT32)FitEntry[FitIndex].Address;=0D
@@ -3333,13 +3402,13 @@ Returns:
for (Index =3D 0; Index < (INTN)gFitTableContext.StartupAcmNumber; Ind=
ex ++) {=0D
if (gFitTableContext.StartupAcm[Index].Address !=3D 0) {=0D
AcmBuffer =3D FLASH_TO_MEMORY(gFitTableContext.StartupAcm[Index].A=
ddress, FdFileBuffer, FdFileSize);=0D
- if ((AcmBuffer < FdFileBuffer) || (AcmBuffer + gFitTableContext.St=
artupAcm[Index].Size > FdFileBuffer + FdFileSize)) {=0D
+ if ((AcmBuffer < FdFileBuffer) || (AcmBuffer + gFitTableContext.St=
artupAcm[Index].MaxSize > FdFileBuffer + FdFileSize)) {=0D
printf ("ACM out of range - can not validate it\n");=0D
AcmBuffer =3D NULL;=0D
}=0D
=0D
if (AcmBuffer !=3D NULL) {=0D
- if (CheckAcm ((ACM_FORMAT *)AcmBuffer, gFitTableContext.StartupA=
cm[Index].Size)) {=0D
+ if (CheckAcm ((ACM_FORMAT *)AcmBuffer, gFitTableContext.StartupA=
cm[Index].MaxSize)) {=0D
DumpAcm ((ACM_FORMAT *)AcmBuffer);=0D
} else {=0D
Status =3D STATUS_ERROR;=0D
diff --git a/Silicon/Intel/Tools/FitGen/FitGen.h b/Silicon/Intel/Tools/FitG=
en/FitGen.h
index b7de0a6b2d..80a1423ceb 100644
--- a/Silicon/Intel/Tools/FitGen/FitGen.h
+++ b/Silicon/Intel/Tools/FitGen/FitGen.h
@@ -31,7 +31,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
// Utility version information=0D
//=0D
#define UTILITY_MAJOR_VERSION 0=0D
-#define UTILITY_MINOR_VERSION 65=0D
+#define UTILITY_MINOR_VERSION 66=0D
#define UTILITY_DATE __DATE__=0D
=0D
//=0D
--=20
2.26.2.windows.1


[PATCH v2 1/2] [edk2-platforms] Silicon/Intel/FitGen: Support multiple Startup ACM Type 2 entries in FitGen tool

Lin, Jason1
 

From: Jason1 Lin <jason1.lin@...>

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

Within current FitGen tool there had limitation only allow
one S-ACM to generate the Type 2 entry.
This code change is used to support multiple type 2 entries up to 0x20.

Signed-off-by: Jason1 Lin <jason1.lin@...>
Cc: Bob Feng <bob.c.feng@...>
Cc: Liming Gao <gaoliming@...>
Cc: Yuwei Chen <yuwei.chen@...>
Cc: Isaac W Oram <isaac.w.oram@...>
Cc: Rangasai V Chaganty <rangasai.v.chaganty@...>
Cc: Dakota Chiang <dakota.chiang@...>
---
Silicon/Intel/Tools/FitGen/FitGen.c | 89 +++++++++++---------
Silicon/Intel/Tools/FitGen/FitGen.h | 4 +-
2 files changed, 50 insertions(+), 43 deletions(-)

diff --git a/Silicon/Intel/Tools/FitGen/FitGen.c b/Silicon/Intel/Tools/FitG=
en/FitGen.c
index 4de72ea422..eac8fa8715 100644
--- a/Silicon/Intel/Tools/FitGen/FitGen.c
+++ b/Silicon/Intel/Tools/FitGen/FitGen.c
@@ -2,7 +2,7 @@
This utility is part of build process for IA32/X64 FD.=0D
It generates FIT table.=0D
=0D
-Copyright (c) 2010-2021, Intel Corporation. All rights reserved.<BR>=0D
+Copyright (c) 2010-2022, Intel Corporation. All rights reserved.<BR>=0D
SPDX-License-Identifier: BSD-2-Clause-Patent=0D
=0D
**/=0D
@@ -204,6 +204,7 @@ typedef struct {
=0D
#define MAX_BIOS_MODULE_ENTRY 0x20=0D
#define MAX_MICROCODE_ENTRY 0x20=0D
+#define MAX_STARTUP_ACM_ENTRY 0x20=0D
#define MAX_OPTIONAL_ENTRY 0x20=0D
#define MAX_PORT_ENTRY 0x20=0D
=0D
@@ -255,11 +256,12 @@ typedef struct {
UINT32 FitEntryNumber;=0D
UINT32 BiosModuleNumber;=0D
UINT32 MicrocodeNumber;=0D
+ UINT32 StartupAcmNumber;=0D
UINT32 OptionalModuleNumber;=0D
UINT32 PortModuleNumber;=0D
UINT32 GlobalVersion;=0D
UINT32 FitHeaderVersion;=0D
- FIT_TABLE_CONTEXT_ENTRY StartupAcm;=0D
+ FIT_TABLE_CONTEXT_ENTRY StartupAcm[MAX_STARTUP_ACM_ENTRY];=0D
UINT32 StartupAcmVersion;=0D
FIT_TABLE_CONTEXT_ENTRY DiagnstAcm;=0D
UINT32 DiagnstAcmVersion;=0D
@@ -1149,14 +1151,15 @@ Returns:
Error (NULL, 0, 0, "-I Parameter incorrect, Header Type unsuppor=
ted!", NULL);=0D
return 0;=0D
case FIT_TABLE_TYPE_STARTUP_ACM:=0D
- if (gFitTableContext.StartupAcm.Type !=3D 0) {=0D
- Error (NULL, 0, 0, "-I Parameter incorrect, Duplicated Startup=
Acm!", NULL);=0D
+ if (gFitTableContext.StartupAcmNumber >=3D MAX_STARTUP_ACM_ENTRY=
) {=0D
+ Error (NULL, 0, 0, "-I Parameter incorrect, too many StartupAc=
m!", NULL);=0D
return 0;=0D
}=0D
- gFitTableContext.StartupAcm.Type =3D FIT_TABLE_TYPE_STARTUP_A=
CM;=0D
- gFitTableContext.StartupAcm.Address =3D (UINT32)BiosInfoStruct[B=
iosInfoIndex].Address;=0D
- gFitTableContext.StartupAcm.Size =3D (UINT32)BiosInfoStruct[B=
iosInfoIndex].Size;=0D
- gFitTableContext.StartupAcmVersion =3D BiosInfoStruct[BiosInfoI=
ndex].Version;=0D
+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].T=
ype =3D FIT_TABLE_TYPE_STARTUP_ACM;=0D
+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].A=
ddress =3D (UINT32)BiosInfoStruct[BiosInfoIndex].Address;=0D
+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].S=
ize =3D (UINT32)BiosInfoStruct[BiosInfoIndex].Size;=0D
+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].V=
ersion =3D BiosInfoStruct[BiosInfoIndex].Version;=0D
+ gFitTableContext.StartupAcmNumber ++;=0D
gFitTableContext.FitEntryNumber ++;=0D
break;=0D
case FIT_TABLE_TYPE_DIAGNST_ACM:=0D
@@ -1351,16 +1354,15 @@ Returns:
//=0D
// 1. StartupAcm=0D
//=0D
- do {=0D
+ while (TRUE) {=0D
if ((Index + 1 >=3D argc) ||=0D
((strcmp (argv[Index], "-S") !=3D 0) &&=0D
(strcmp (argv[Index], "-s") !=3D 0)) ) {=0D
- if (BiosInfoExist && (gFitTableContext.StartupAcm.Type =3D=3D FIT_TA=
BLE_TYPE_STARTUP_ACM)) {=0D
- break;=0D
+ if (gFitTableContext.StartupAcmNumber =3D=3D 0) {=0D
+ printf ("-S not found. WARNING!\n");=0D
}=0D
// Error (NULL, 0, 0, "-S Parameter incorrect, expect -S!", NULL);=0D
// return 0;=0D
- printf ("-S not found. WARNING!\n");=0D
break;=0D
}=0D
if (IsGuidData (argv[Index + 1], &Guid)) {=0D
@@ -1381,14 +1383,13 @@ Returns:
FileSize =3D xtoi (argv[Index + 2]);=0D
Index +=3D 3;=0D
}=0D
- if (gFitTableContext.StartupAcm.Type !=3D 0) {=0D
- Error (NULL, 0, 0, "-S Parameter incorrect, Duplicated StartupAcm!",=
NULL);=0D
+ if (gFitTableContext.StartupAcmNumber >=3D MAX_STARTUP_ACM_ENTRY) {=0D
+ Error (NULL, 0, 0, "-S Parameter incorrect, too many StartupAcm!", N=
ULL);=0D
return 0;=0D
}=0D
- gFitTableContext.StartupAcm.Type =3D FIT_TABLE_TYPE_STARTUP_ACM;=0D
- gFitTableContext.StartupAcm.Address =3D (UINT32) (UINTN) FileBuffer;=0D
- gFitTableContext.StartupAcm.Size =3D FileSize;=0D
- gFitTableContext.FitEntryNumber ++;=0D
+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Type =
=3D FIT_TABLE_TYPE_STARTUP_ACM;=0D
+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Address=
=3D (UINT32) (UINTN) FileBuffer;=0D
+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Size =
=3D FileSize;=0D
=0D
//=0D
// 1.1 StartupAcm version=0D
@@ -1407,7 +1408,10 @@ Returns:
gFitTableContext.StartupAcmVersion =3D xtoi (argv[Index + 1]);=0D
Index +=3D 2;=0D
}=0D
- } while (FALSE);=0D
+=0D
+ gFitTableContext.StartupAcmNumber ++;=0D
+ gFitTableContext.FitEntryNumber ++;=0D
+ }=0D
=0D
//=0D
// 1.5. DiagnosticsAcm=0D
@@ -1890,7 +1894,9 @@ Returns:
//=0D
// Final: Check StartupAcm in BiosModule.=0D
//=0D
- CheckOverlap (gFitTableContext.StartupAcm.Address, gFitTableContext.Star=
tupAcm.Size);=0D
+ for (Index =3D 0; Index < (INTN)gFitTableContext.StartupAcmNumber; Index=
++) {=0D
+ CheckOverlap (gFitTableContext.StartupAcm[Index].Address, gFitTableCon=
text.StartupAcm[Index].Size);=0D
+ }=0D
FitEntryNumber =3D gFitTableContext.FitEntryNumber;=0D
for (Index =3D 0; Index < (INTN)gFitTableContext.OptionalModuleNumber; I=
ndex++) {=0D
if ((gFitTableContext.OptionalModule[Index].Type =3D=3D FIT_TABLE_TYPE=
_BIOS_POLICY) ||=0D
@@ -2178,8 +2184,8 @@ Returns:
}=0D
printf ("Total FIT Entry number: 0x%x\n", gFitTableContext.FitEntryNumbe=
r);=0D
printf ("FitHeader version: 0x%04x\n", gFitTableContext.FitHeaderVersion=
);=0D
- if (gFitTableContext.StartupAcm.Address !=3D 0) {=0D
- printf ("StartupAcm - (0x%08x, 0x%08x, 0x%04x)\n", gFitTableContext.St=
artupAcm.Address, gFitTableContext.StartupAcm.Size, gFitTableContext.Startu=
pAcmVersion);=0D
+ for (Index =3D 0; Index < gFitTableContext.StartupAcmNumber; Index++) {=
=0D
+ printf ("StartupAcm[%d] - (0x%08x, 0x%08x, 0x%04x)\n", Index, gFitTabl=
eContext.StartupAcm[Index].Address, gFitTableContext.StartupAcm[Index].Size=
, gFitTableContext.StartupAcmVersion);=0D
}=0D
if (gFitTableContext.DiagnstAcm.Address !=3D 0) {=0D
printf ("DiagnosticAcm - (0x%08x, 0x%08x, 0x%04x)\n", gFitTableContext=
.DiagnstAcm.Address, gFitTableContext.DiagnstAcm.Size, gFitTableContext.Dia=
gnstAcmVersion);=0D
@@ -2809,8 +2815,8 @@ Returns:
//=0D
// 4. StartupAcm=0D
//=0D
- if (gFitTableContext.StartupAcm.Address !=3D 0) {=0D
- FitEntry[FitIndex].Address =3D gFitTableContext.StartupAcm=
.Address;=0D
+ for (Index =3D 0; Index < gFitTableContext.StartupAcmNumber; Index++) {=
=0D
+ FitEntry[FitIndex].Address =3D gFitTableContext.StartupAcm=
[Index].Address;=0D
*(UINT32 *)&FitEntry[FitIndex].Size[0] =3D 0; //gFitTableContext.Start=
upAcm.Size / 16;=0D
FitEntry[FitIndex].Version =3D (UINT16)gFitTableContext.St=
artupAcmVersion;=0D
FitEntry[FitIndex].Type =3D FIT_TABLE_TYPE_STARTUP_ACM;=
=0D
@@ -3110,7 +3116,7 @@ GetFitEntryInfo (
=0D
Routine Description:=0D
=0D
- Fill the FIT table information to Fvrecovery=0D
+ Get the FIT table information from Fvrecovery=0D
=0D
Arguments:=0D
=0D
@@ -3164,8 +3170,8 @@ Returns:
gFitTableContext.MicrocodeNumber ++;=0D
break;=0D
case FIT_TABLE_TYPE_STARTUP_ACM:=0D
- gFitTableContext.StartupAcm.Address =3D (UINT32)FitEntry[FitIndex].A=
ddress;=0D
- gFitTableContext.StartupAcmVersion =3D FitEntry[FitIndex].Version;=
=0D
+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Addre=
ss =3D (UINT32)FitEntry[FitIndex].Address;=0D
+ gFitTableContext.StartupAcmVersion =
=3D FitEntry[FitIndex].Version;=0D
break;=0D
case FIT_TABLE_TYPE_BIOS_MODULE:=0D
gFitTableContext.BiosModule[gFitTableContext.BiosModuleNumber].Addre=
ss =3D (UINT32)FitEntry[FitIndex].Address;=0D
@@ -3232,6 +3238,7 @@ Returns:
UINT32 FdFileSize;=0D
=0D
UINT8 *AcmBuffer;=0D
+ INTN Index;=0D
UINT32 FixedFitLocation;=0D
=0D
FileBufferRaw =3D NULL;=0D
@@ -3323,22 +3330,23 @@ Returns:
//=0D
// Get ACM buffer=0D
//=0D
- if (gFitTableContext.StartupAcm.Address !=3D 0) {=0D
- AcmBuffer =3D FLASH_TO_MEMORY(gFitTableContext.StartupAcm.Address, F=
dFileBuffer, FdFileSize);=0D
- if ((AcmBuffer < FdFileBuffer) || (AcmBuffer + gFitTableContext.Star=
tupAcm.Size > FdFileBuffer + FdFileSize)) {=0D
- printf ("ACM out of range - can not validate it\n");=0D
- AcmBuffer =3D NULL;=0D
- }=0D
+ for (Index =3D 0; Index < (INTN)gFitTableContext.StartupAcmNumber; Ind=
ex ++) {=0D
+ if (gFitTableContext.StartupAcm[Index].Address !=3D 0) {=0D
+ AcmBuffer =3D FLASH_TO_MEMORY(gFitTableContext.StartupAcm[Index].A=
ddress, FdFileBuffer, FdFileSize);=0D
+ if ((AcmBuffer < FdFileBuffer) || (AcmBuffer + gFitTableContext.St=
artupAcm[Index].Size > FdFileBuffer + FdFileSize)) {=0D
+ printf ("ACM out of range - can not validate it\n");=0D
+ AcmBuffer =3D NULL;=0D
+ }=0D
=0D
- if (AcmBuffer !=3D NULL) {=0D
- if (CheckAcm ((ACM_FORMAT *)AcmBuffer, gFitTableContext.StartupAcm=
.Size)) {=0D
- DumpAcm ((ACM_FORMAT *)AcmBuffer);=0D
- } else {=0D
- Status =3D STATUS_ERROR;=0D
- goto exitFunc;=0D
+ if (AcmBuffer !=3D NULL) {=0D
+ if (CheckAcm ((ACM_FORMAT *)AcmBuffer, gFitTableContext.StartupA=
cm[Index].Size)) {=0D
+ DumpAcm ((ACM_FORMAT *)AcmBuffer);=0D
+ } else {=0D
+ Status =3D STATUS_ERROR;=0D
+ goto exitFunc;=0D
+ }=0D
}=0D
}=0D
-=0D
}=0D
=0D
//=0D
@@ -3576,4 +3584,3 @@ Returns:
=0D
return u;=0D
}=0D
-=0D
diff --git a/Silicon/Intel/Tools/FitGen/FitGen.h b/Silicon/Intel/Tools/FitG=
en/FitGen.h
index 5add6a8870..b7de0a6b2d 100644
--- a/Silicon/Intel/Tools/FitGen/FitGen.h
+++ b/Silicon/Intel/Tools/FitGen/FitGen.h
@@ -1,7 +1,7 @@
/**@file=0D
Definitions for the FitGen utility.=0D
=0D
-Copyright (c) 2010-2020, Intel Corporation. All rights reserved.<BR>=0D
+Copyright (c) 2010-2022, Intel Corporation. All rights reserved.<BR>=0D
SPDX-License-Identifier: BSD-2-Clause-Patent=0D
=0D
**/=0D
@@ -31,7 +31,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
// Utility version information=0D
//=0D
#define UTILITY_MAJOR_VERSION 0=0D
-#define UTILITY_MINOR_VERSION 64=0D
+#define UTILITY_MINOR_VERSION 65=0D
#define UTILITY_DATE __DATE__=0D
=0D
//=0D
--=20
2.26.2.windows.1


[PATCH v1 2/2] [edk2-platforms] Silicon/Intel/FitGen: Support to override the MBZ byte in Startup ACM entries for other usages

Lin, Jason1
 

From: Jason1 Lin <jason1.lin@...>

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

As per FIT BIOS Specification 1.2 Rules, the size bytes (3 bytes)/
reserved byte (1 byte) / CheckSum byte (1 byte) in type 2 are must-be-zero =
(MBZ).
These bytes could be override for the other usages.
In the future, if these bytes field have other meanings, there would be no =
need to change the FitGen.

Command:
[-S <StartupAcmAddress StartupAcmSize>|<StartupAcmGuid>]
[-I <StartupAcmSizeByte0 StartupAcmSizeByte1 StartupAcmSizeByte2 StartupAcm=
Rsvd StartupAcmChksum>]
[-V <StartupAcmVersion>]

With "-I" input the default Type 2 entry version would be 0x200.

Signed-off-by: Jason1 Lin <jason1.lin@...>
Cc: Bob Feng <bob.c.feng@...>
Cc: Liming Gao <gaoliming@...>
Cc: Yuwei Chen <yuwei.chen@...>
Cc: Dakota Chiang <dakota.chiang@...>
---
Silicon/Intel/Tools/FitGen/FitGen.c | 105 ++++++++++++++++----
Silicon/Intel/Tools/FitGen/FitGen.h | 2 +-
2 files changed, 88 insertions(+), 19 deletions(-)

diff --git a/Silicon/Intel/Tools/FitGen/FitGen.c b/Silicon/Intel/Tools/FitG=
en/FitGen.c
index eac8fa8715..bdda8dfd5a 100644
--- a/Silicon/Intel/Tools/FitGen/FitGen.c
+++ b/Silicon/Intel/Tools/FitGen/FitGen.c
@@ -210,6 +210,7 @@ typedef struct {
=0D
#define DEFAULT_FIT_TABLE_POINTER_OFFSET 0x40=0D
#define DEFAULT_FIT_ENTRY_VERSION 0x0100=0D
+#define STARTUP_ACM_FIT_ENTRY_200_VERSION 0x0200=0D
=0D
#define TOP_FLASH_ADDRESS (gFitTableContext.TopFlashAddressRemapValue)=0D
=0D
@@ -247,6 +248,12 @@ typedef struct {
UINT8 *Buffer; // Used by OptionalModule only=0D
UINT32 Size;=0D
UINT32 Version; // Used by OptionalModule and PortModule only=0D
+ UINT32 MaxSize;=0D
+ UINT8 SizeByte0; // Used by S-ACM only=0D
+ UINT8 SizeByte1; // Used by S-ACM only=0D
+ UINT8 SizeByte2; // Used by S-ACM only=0D
+ UINT8 Rsvd; // Used by S-ACM only=0D
+ UINT8 ChkSum; // Used by S-ACM only=0D
} FIT_TABLE_CONTEXT_ENTRY;=0D
=0D
typedef struct {=0D
@@ -262,7 +269,7 @@ typedef struct {
UINT32 GlobalVersion;=0D
UINT32 FitHeaderVersion;=0D
FIT_TABLE_CONTEXT_ENTRY StartupAcm[MAX_STARTUP_ACM_ENTRY];=0D
- UINT32 StartupAcmVersion;=0D
+ UINT32 StartupAcmVersion[MAX_STARTUP_ACM_ENTRY];=0D
FIT_TABLE_CONTEXT_ENTRY DiagnstAcm;=0D
UINT32 DiagnstAcmVersion;=0D
FIT_TABLE_CONTEXT_ENTRY BiosModule[MAX_BIOS_MODULE_ENTRY];=0D
@@ -341,7 +348,7 @@ Returns:
"\t[-L <MicrocodeSlotSize> <MicrocodeFfsGuid>]\n"=0D
"\t[-LF <MicrocodeSlotSize>]\n"=0D
"\t[-I <BiosInfoGuid>]\n"=0D
- "\t[-S <StartupAcmAddress StartupAcmSize>|<StartupAcmGuid>] [-V =
<StartupAcmVersion>]\n"=0D
+ "\t[-S <StartupAcmAddress StartupAcmSize>|<StartupAcmGuid>] [-I =
<StartupAcmSizeByte0 StartupAcmSizeByte1 StartupAcmSizeByte2 StartupAcmRsvd=
StartupAcmChksum>] [-V <StartupAcmVersion>]\n"=0D
"\t[-U <DiagnstAcmAddress>|<DiagnstAcmGuid>]\n"=0D
"\t[-B <BiosModuleAddress BiosModuleSize>] [-B ...] [-V <BiosMod=
uleVersion>]\n"=0D
"\t[-M <MicrocodeAddress MicrocodeSize>] [-M ...]|[-U <Microcode=
Fv MicrocodeBase>|<MicrocodeRegionOffset MicrocodeRegionSize>|<MicrocodeGui=
d>] [-V <MicrocodeVersion>]\n"=0D
@@ -357,7 +364,13 @@ Returns:
printf ("\tBiosInfoGuid - Guid of BiosInfo Module. If this mod=
ule exists, StartupAcm/Bios/Microcode can be optional.\n");=0D
printf ("\tStartupAcmAddress - Address of StartupAcm.\n");=0D
printf ("\tStartupAcmSize - Size of StartupAcm.\n");=0D
- printf ("\tStartupAcmGuid - Guid of StartupAcm Module, if Startu=
pAcm is in a BiosModule, it will be excluded form that.\n");=0D
+ printf ("\tStartupAcmGuid - Guid of StartupAcm Module.\n");=0D
+ printf ("\tStartupAcmMaxSize - The maximum size value that could pl=
ace the StartupAcm in.\n");=0D
+ printf ("\tStartupAcmSizeByte0 - The value for Size byte 0 (Override =
default value).\n");=0D
+ printf ("\tStartupAcmSizeByte1 - The value for Size byte 1 (Override =
default value).\n");=0D
+ printf ("\tStartupAcmSizeByte2 - The value for Size byte 2 (Override =
default value).\n");=0D
+ printf ("\tStartupAcmRsvd - The value for Reserved byte (Overrid=
e default value).\n");=0D
+ printf ("\tStartupAcmChkSum - The value for CheckSum byte (Overrid=
e default value).\n");=0D
printf ("\tDiagnstAcmAddress - Address of DiagnstAcm.\n");=0D
printf ("\tDiagnstAcmGuid - Guid of DiagnstAcm Module, if Diagns=
tAcm is in a BiosModule, it will be excluded from that.\n");=0D
printf ("\tBiosModuleAddress - Address of BiosModule. User should e=
nsure there is no overlap.\n");=0D
@@ -913,6 +926,9 @@ Returns:
UINT32 FileSize;=0D
UINT32 Type;=0D
UINT32 SubType;=0D
+ UINT8 StartupAcmSizeByte0;=0D
+ UINT8 StartupAcmSizeByte1;=0D
+ UINT8 StartupAcmSizeByte2;=0D
UINT8 *MicrocodeFileBuffer;=0D
UINT8 *MicrocodeFileBufferRaw;=0D
UINT32 MicrocodeFileSize;=0D
@@ -1155,9 +1171,12 @@ Returns:
Error (NULL, 0, 0, "-I Parameter incorrect, too many StartupAc=
m!", NULL);=0D
return 0;=0D
}=0D
+ //=0D
+ // NOTE: BIOS INFO structure not support to override the Size/Rs=
vd/ChkSum byte value.=0D
+ //=0D
gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].T=
ype =3D FIT_TABLE_TYPE_STARTUP_ACM;=0D
gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].A=
ddress =3D (UINT32)BiosInfoStruct[BiosInfoIndex].Address;=0D
- gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].S=
ize =3D (UINT32)BiosInfoStruct[BiosInfoIndex].Size;=0D
+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].M=
axSize =3D (UINT32)BiosInfoStruct[BiosInfoIndex].Size;=0D
gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].V=
ersion =3D BiosInfoStruct[BiosInfoIndex].Version;=0D
gFitTableContext.StartupAcmNumber ++;=0D
gFitTableContext.FitEntryNumber ++;=0D
@@ -1389,10 +1408,52 @@ Returns:
}=0D
gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Type =
=3D FIT_TABLE_TYPE_STARTUP_ACM;=0D
gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Address=
=3D (UINT32) (UINTN) FileBuffer;=0D
- gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Size =
=3D FileSize;=0D
+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].MaxSize=
=3D FileSize;=0D
=0D
//=0D
- // 1.1 StartupAcm version=0D
+ // 1.1 Support 0x200 StartupAcm Information=0D
+ //=0D
+ if ((Index + 1 >=3D argc) ||=0D
+ ((strcmp (argv[Index], "-I") !=3D 0) &&=0D
+ (strcmp (argv[Index], "-i") !=3D 0)) ) {=0D
+ //=0D
+ // Bypass=0D
+ //=0D
+ gFitTableContext.StartupAcmVersion[gFitTableContext.StartupAcmNumber=
] =3D gFitTableContext.GlobalVersion;=0D
+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Size =
=3D 0;=0D
+ } else {=0D
+ //=0D
+ // Should use the multiple StartupACM=0D
+ //=0D
+ if (Index + 5 >=3D argc) {=0D
+ //=0D
+ // Should get five input value, but not sufficient=0D
+ //=0D
+ Error (NULL, 0, 0, "-I Parameter incorrect, Require five inputs va=
lue!", NULL);=0D
+ return 0;=0D
+ } else {=0D
+ //=0D
+ // Should assign this as 0x200=0D
+ //=0D
+ gFitTableContext.StartupAcmVersion[gFitTableContext.StartupAcmNumb=
er] =3D STARTUP_ACM_FIT_ENTRY_200_VERSION;=0D
+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Siz=
eByte0 =3D (UINT8)xtoi (argv[Index + 1]);=0D
+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Siz=
eByte1 =3D (UINT8)xtoi (argv[Index + 2]);=0D
+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Siz=
eByte2 =3D (UINT8)xtoi (argv[Index + 3]);=0D
+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Rsv=
d =3D (UINT8)xtoi (argv[Index + 4]);=0D
+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Chk=
Sum =3D (UINT8)xtoi (argv[Index + 5]);=0D
+=0D
+ StartupAcmSizeByte0 =3D (UINT32)gFitTableContext.StartupAcm[gFitT=
ableContext.StartupAcmNumber].SizeByte0;=0D
+ StartupAcmSizeByte1 =3D (UINT32)gFitTableContext.StartupAcm[gFitT=
ableContext.StartupAcmNumber].SizeByte1;=0D
+ StartupAcmSizeByte2 =3D (UINT32)gFitTableContext.StartupAcm[gFitT=
ableContext.StartupAcmNumber].SizeByte2;=0D
+=0D
+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Siz=
e =3D (StartupAcmSizeByte2 << 16) + (StartupAcmSizeByte1 << 8) + (Startup=
AcmSizeByte0);=0D
+=0D
+ Index +=3D 6;=0D
+ }=0D
+ }=0D
+=0D
+ //=0D
+ // 1.2 StartupAcm version=0D
//=0D
if ((Index + 1 >=3D argc) ||=0D
((strcmp (argv[Index], "-V") !=3D 0) &&=0D
@@ -1400,18 +1461,17 @@ Returns:
//=0D
// Bypass=0D
//=0D
- gFitTableContext.StartupAcmVersion =3D gFitTableContext.GlobalVersio=
n;=0D
} else {=0D
//=0D
// Get offset from parameter=0D
//=0D
- gFitTableContext.StartupAcmVersion =3D xtoi (argv[Index + 1]);=0D
+ gFitTableContext.StartupAcmVersion[gFitTableContext.StartupAcmNumber=
] =3D xtoi (argv[Index + 1]);=0D
Index +=3D 2;=0D
}=0D
=0D
gFitTableContext.StartupAcmNumber ++;=0D
gFitTableContext.FitEntryNumber ++;=0D
- }=0D
+ };=0D
=0D
//=0D
// 1.5. DiagnosticsAcm=0D
@@ -1895,7 +1955,7 @@ Returns:
// Final: Check StartupAcm in BiosModule.=0D
//=0D
for (Index =3D 0; Index < (INTN)gFitTableContext.StartupAcmNumber; Index=
++) {=0D
- CheckOverlap (gFitTableContext.StartupAcm[Index].Address, gFitTableCon=
text.StartupAcm[Index].Size);=0D
+ CheckOverlap (gFitTableContext.StartupAcm[Index].Address, gFitTableCon=
text.StartupAcm[Index].MaxSize);=0D
}=0D
FitEntryNumber =3D gFitTableContext.FitEntryNumber;=0D
for (Index =3D 0; Index < (INTN)gFitTableContext.OptionalModuleNumber; I=
ndex++) {=0D
@@ -2185,7 +2245,7 @@ Returns:
printf ("Total FIT Entry number: 0x%x\n", gFitTableContext.FitEntryNumbe=
r);=0D
printf ("FitHeader version: 0x%04x\n", gFitTableContext.FitHeaderVersion=
);=0D
for (Index =3D 0; Index < gFitTableContext.StartupAcmNumber; Index++) {=
=0D
- printf ("StartupAcm[%d] - (0x%08x, 0x%08x, 0x%04x)\n", Index, gFitTabl=
eContext.StartupAcm[Index].Address, gFitTableContext.StartupAcm[Index].Size=
, gFitTableContext.StartupAcmVersion);=0D
+ printf ("StartupAcm[%d] - (0x%08x, 0x%08x, 0x%08x, 0x%04x)\n", Index, =
gFitTableContext.StartupAcm[Index].Address, gFitTableContext.StartupAcm[Ind=
ex].Size, gFitTableContext.StartupAcm[Index].MaxSize, gFitTableContext.Star=
tupAcmVersion[Index]);=0D
}=0D
if (gFitTableContext.DiagnstAcm.Address !=3D 0) {=0D
printf ("DiagnosticAcm - (0x%08x, 0x%08x, 0x%04x)\n", gFitTableContext=
.DiagnstAcm.Address, gFitTableContext.DiagnstAcm.Size, gFitTableContext.Dia=
gnstAcmVersion);=0D
@@ -2817,11 +2877,12 @@ Returns:
//=0D
for (Index =3D 0; Index < gFitTableContext.StartupAcmNumber; Index++) {=
=0D
FitEntry[FitIndex].Address =3D gFitTableContext.StartupAcm=
[Index].Address;=0D
- *(UINT32 *)&FitEntry[FitIndex].Size[0] =3D 0; //gFitTableContext.Start=
upAcm.Size / 16;=0D
- FitEntry[FitIndex].Version =3D (UINT16)gFitTableContext.St=
artupAcmVersion;=0D
+ *(UINT32 *)&FitEntry[FitIndex].Size[0] =3D gFitTableContext.StartupAcm=
[Index].Size;=0D
+ FitEntry[FitIndex].Version =3D (UINT16)gFitTableContext.St=
artupAcmVersion[Index];=0D
FitEntry[FitIndex].Type =3D FIT_TABLE_TYPE_STARTUP_ACM;=
=0D
FitEntry[FitIndex].C_V =3D 0;=0D
- FitEntry[FitIndex].Checksum =3D 0;=0D
+ FitEntry[FitIndex].Rsvd =3D gFitTableContext.StartupAcm=
[Index].Rsvd;=0D
+ FitEntry[FitIndex].Checksum =3D gFitTableContext.StartupAcm=
[Index].ChkSum;=0D
FitIndex++;=0D
}=0D
=0D
@@ -3170,8 +3231,16 @@ Returns:
gFitTableContext.MicrocodeNumber ++;=0D
break;=0D
case FIT_TABLE_TYPE_STARTUP_ACM:=0D
- gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Addre=
ss =3D (UINT32)FitEntry[FitIndex].Address;=0D
- gFitTableContext.StartupAcmVersion =
=3D FitEntry[FitIndex].Version;=0D
+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Addre=
ss =3D (UINT32)FitEntry[FitIndex].Address;=0D
+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Type =
=3D FitEntry[FitIndex].Type;=0D
+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Size =
=3D *(UINT32 *)&FitEntry[FitIndex].Size[0];=0D
+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].SizeB=
yte0 =3D *(UINT8 *)&FitEntry[FitIndex].Size[0];=0D
+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].SizeB=
yte1 =3D *(UINT8 *)&FitEntry[FitIndex].Size[1];=0D
+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].SizeB=
yte2 =3D *(UINT8 *)&FitEntry[FitIndex].Size[2];=0D
+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Rsvd =
=3D FitEntry[FitIndex].Rsvd;=0D
+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].ChkSu=
m =3D FitEntry[FitIndex].Checksum;=0D
+ gFitTableContext.StartupAcmVersion[gFitTableContext.StartupAcmNumber=
] =3D FitEntry[FitIndex].Version;=0D
+ gFitTableContext.StartupAcmNumber ++;=0D
break;=0D
case FIT_TABLE_TYPE_BIOS_MODULE:=0D
gFitTableContext.BiosModule[gFitTableContext.BiosModuleNumber].Addre=
ss =3D (UINT32)FitEntry[FitIndex].Address;=0D
@@ -3333,13 +3402,13 @@ Returns:
for (Index =3D 0; Index < (INTN)gFitTableContext.StartupAcmNumber; Ind=
ex ++) {=0D
if (gFitTableContext.StartupAcm[Index].Address !=3D 0) {=0D
AcmBuffer =3D FLASH_TO_MEMORY(gFitTableContext.StartupAcm[Index].A=
ddress, FdFileBuffer, FdFileSize);=0D
- if ((AcmBuffer < FdFileBuffer) || (AcmBuffer + gFitTableContext.St=
artupAcm[Index].Size > FdFileBuffer + FdFileSize)) {=0D
+ if ((AcmBuffer < FdFileBuffer) || (AcmBuffer + gFitTableContext.St=
artupAcm[Index].MaxSize > FdFileBuffer + FdFileSize)) {=0D
printf ("ACM out of range - can not validate it\n");=0D
AcmBuffer =3D NULL;=0D
}=0D
=0D
if (AcmBuffer !=3D NULL) {=0D
- if (CheckAcm ((ACM_FORMAT *)AcmBuffer, gFitTableContext.StartupA=
cm[Index].Size)) {=0D
+ if (CheckAcm ((ACM_FORMAT *)AcmBuffer, gFitTableContext.StartupA=
cm[Index].MaxSize)) {=0D
DumpAcm ((ACM_FORMAT *)AcmBuffer);=0D
} else {=0D
Status =3D STATUS_ERROR;=0D
diff --git a/Silicon/Intel/Tools/FitGen/FitGen.h b/Silicon/Intel/Tools/FitG=
en/FitGen.h
index b7de0a6b2d..80a1423ceb 100644
--- a/Silicon/Intel/Tools/FitGen/FitGen.h
+++ b/Silicon/Intel/Tools/FitGen/FitGen.h
@@ -31,7 +31,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
// Utility version information=0D
//=0D
#define UTILITY_MAJOR_VERSION 0=0D
-#define UTILITY_MINOR_VERSION 65=0D
+#define UTILITY_MINOR_VERSION 66=0D
#define UTILITY_DATE __DATE__=0D
=0D
//=0D
--=20
2.26.2.windows.1


[PATCH v1 1/2] [edk2-platforms] Silicon/Intel/FitGen: Support multiple Startup ACM Type 2 entries in FitGen tool

Lin, Jason1
 

From: Jason1 Lin <jason1.lin@...>

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

Within current FitGen tool there had limitation only allow
one S-ACM to generate the Type 2 entry.
This code change is used to support multiple type 2 entries up to 0x20.

Signed-off-by: Jason1 Lin <jason1.lin@...>
Cc: Bob Feng <bob.c.feng@...>
Cc: Liming Gao <gaoliming@...>
Cc: Yuwei Chen <yuwei.chen@...>
Cc: Dakota Chiang <dakota.chiang@...>
---
Silicon/Intel/Tools/FitGen/FitGen.c | 89 +++++++++++---------
Silicon/Intel/Tools/FitGen/FitGen.h | 4 +-
2 files changed, 50 insertions(+), 43 deletions(-)

diff --git a/Silicon/Intel/Tools/FitGen/FitGen.c b/Silicon/Intel/Tools/FitG=
en/FitGen.c
index 4de72ea422..eac8fa8715 100644
--- a/Silicon/Intel/Tools/FitGen/FitGen.c
+++ b/Silicon/Intel/Tools/FitGen/FitGen.c
@@ -2,7 +2,7 @@
This utility is part of build process for IA32/X64 FD.=0D
It generates FIT table.=0D
=0D
-Copyright (c) 2010-2021, Intel Corporation. All rights reserved.<BR>=0D
+Copyright (c) 2010-2022, Intel Corporation. All rights reserved.<BR>=0D
SPDX-License-Identifier: BSD-2-Clause-Patent=0D
=0D
**/=0D
@@ -204,6 +204,7 @@ typedef struct {
=0D
#define MAX_BIOS_MODULE_ENTRY 0x20=0D
#define MAX_MICROCODE_ENTRY 0x20=0D
+#define MAX_STARTUP_ACM_ENTRY 0x20=0D
#define MAX_OPTIONAL_ENTRY 0x20=0D
#define MAX_PORT_ENTRY 0x20=0D
=0D
@@ -255,11 +256,12 @@ typedef struct {
UINT32 FitEntryNumber;=0D
UINT32 BiosModuleNumber;=0D
UINT32 MicrocodeNumber;=0D
+ UINT32 StartupAcmNumber;=0D
UINT32 OptionalModuleNumber;=0D
UINT32 PortModuleNumber;=0D
UINT32 GlobalVersion;=0D
UINT32 FitHeaderVersion;=0D
- FIT_TABLE_CONTEXT_ENTRY StartupAcm;=0D
+ FIT_TABLE_CONTEXT_ENTRY StartupAcm[MAX_STARTUP_ACM_ENTRY];=0D
UINT32 StartupAcmVersion;=0D
FIT_TABLE_CONTEXT_ENTRY DiagnstAcm;=0D
UINT32 DiagnstAcmVersion;=0D
@@ -1149,14 +1151,15 @@ Returns:
Error (NULL, 0, 0, "-I Parameter incorrect, Header Type unsuppor=
ted!", NULL);=0D
return 0;=0D
case FIT_TABLE_TYPE_STARTUP_ACM:=0D
- if (gFitTableContext.StartupAcm.Type !=3D 0) {=0D
- Error (NULL, 0, 0, "-I Parameter incorrect, Duplicated Startup=
Acm!", NULL);=0D
+ if (gFitTableContext.StartupAcmNumber >=3D MAX_STARTUP_ACM_ENTRY=
) {=0D
+ Error (NULL, 0, 0, "-I Parameter incorrect, too many StartupAc=
m!", NULL);=0D
return 0;=0D
}=0D
- gFitTableContext.StartupAcm.Type =3D FIT_TABLE_TYPE_STARTUP_A=
CM;=0D
- gFitTableContext.StartupAcm.Address =3D (UINT32)BiosInfoStruct[B=
iosInfoIndex].Address;=0D
- gFitTableContext.StartupAcm.Size =3D (UINT32)BiosInfoStruct[B=
iosInfoIndex].Size;=0D
- gFitTableContext.StartupAcmVersion =3D BiosInfoStruct[BiosInfoI=
ndex].Version;=0D
+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].T=
ype =3D FIT_TABLE_TYPE_STARTUP_ACM;=0D
+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].A=
ddress =3D (UINT32)BiosInfoStruct[BiosInfoIndex].Address;=0D
+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].S=
ize =3D (UINT32)BiosInfoStruct[BiosInfoIndex].Size;=0D
+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].V=
ersion =3D BiosInfoStruct[BiosInfoIndex].Version;=0D
+ gFitTableContext.StartupAcmNumber ++;=0D
gFitTableContext.FitEntryNumber ++;=0D
break;=0D
case FIT_TABLE_TYPE_DIAGNST_ACM:=0D
@@ -1351,16 +1354,15 @@ Returns:
//=0D
// 1. StartupAcm=0D
//=0D
- do {=0D
+ while (TRUE) {=0D
if ((Index + 1 >=3D argc) ||=0D
((strcmp (argv[Index], "-S") !=3D 0) &&=0D
(strcmp (argv[Index], "-s") !=3D 0)) ) {=0D
- if (BiosInfoExist && (gFitTableContext.StartupAcm.Type =3D=3D FIT_TA=
BLE_TYPE_STARTUP_ACM)) {=0D
- break;=0D
+ if (gFitTableContext.StartupAcmNumber =3D=3D 0) {=0D
+ printf ("-S not found. WARNING!\n");=0D
}=0D
// Error (NULL, 0, 0, "-S Parameter incorrect, expect -S!", NULL);=0D
// return 0;=0D
- printf ("-S not found. WARNING!\n");=0D
break;=0D
}=0D
if (IsGuidData (argv[Index + 1], &Guid)) {=0D
@@ -1381,14 +1383,13 @@ Returns:
FileSize =3D xtoi (argv[Index + 2]);=0D
Index +=3D 3;=0D
}=0D
- if (gFitTableContext.StartupAcm.Type !=3D 0) {=0D
- Error (NULL, 0, 0, "-S Parameter incorrect, Duplicated StartupAcm!",=
NULL);=0D
+ if (gFitTableContext.StartupAcmNumber >=3D MAX_STARTUP_ACM_ENTRY) {=0D
+ Error (NULL, 0, 0, "-S Parameter incorrect, too many StartupAcm!", N=
ULL);=0D
return 0;=0D
}=0D
- gFitTableContext.StartupAcm.Type =3D FIT_TABLE_TYPE_STARTUP_ACM;=0D
- gFitTableContext.StartupAcm.Address =3D (UINT32) (UINTN) FileBuffer;=0D
- gFitTableContext.StartupAcm.Size =3D FileSize;=0D
- gFitTableContext.FitEntryNumber ++;=0D
+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Type =
=3D FIT_TABLE_TYPE_STARTUP_ACM;=0D
+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Address=
=3D (UINT32) (UINTN) FileBuffer;=0D
+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Size =
=3D FileSize;=0D
=0D
//=0D
// 1.1 StartupAcm version=0D
@@ -1407,7 +1408,10 @@ Returns:
gFitTableContext.StartupAcmVersion =3D xtoi (argv[Index + 1]);=0D
Index +=3D 2;=0D
}=0D
- } while (FALSE);=0D
+=0D
+ gFitTableContext.StartupAcmNumber ++;=0D
+ gFitTableContext.FitEntryNumber ++;=0D
+ }=0D
=0D
//=0D
// 1.5. DiagnosticsAcm=0D
@@ -1890,7 +1894,9 @@ Returns:
//=0D
// Final: Check StartupAcm in BiosModule.=0D
//=0D
- CheckOverlap (gFitTableContext.StartupAcm.Address, gFitTableContext.Star=
tupAcm.Size);=0D
+ for (Index =3D 0; Index < (INTN)gFitTableContext.StartupAcmNumber; Index=
++) {=0D
+ CheckOverlap (gFitTableContext.StartupAcm[Index].Address, gFitTableCon=
text.StartupAcm[Index].Size);=0D
+ }=0D
FitEntryNumber =3D gFitTableContext.FitEntryNumber;=0D
for (Index =3D 0; Index < (INTN)gFitTableContext.OptionalModuleNumber; I=
ndex++) {=0D
if ((gFitTableContext.OptionalModule[Index].Type =3D=3D FIT_TABLE_TYPE=
_BIOS_POLICY) ||=0D
@@ -2178,8 +2184,8 @@ Returns:
}=0D
printf ("Total FIT Entry number: 0x%x\n", gFitTableContext.FitEntryNumbe=
r);=0D
printf ("FitHeader version: 0x%04x\n", gFitTableContext.FitHeaderVersion=
);=0D
- if (gFitTableContext.StartupAcm.Address !=3D 0) {=0D
- printf ("StartupAcm - (0x%08x, 0x%08x, 0x%04x)\n", gFitTableContext.St=
artupAcm.Address, gFitTableContext.StartupAcm.Size, gFitTableContext.Startu=
pAcmVersion);=0D
+ for (Index =3D 0; Index < gFitTableContext.StartupAcmNumber; Index++) {=
=0D
+ printf ("StartupAcm[%d] - (0x%08x, 0x%08x, 0x%04x)\n", Index, gFitTabl=
eContext.StartupAcm[Index].Address, gFitTableContext.StartupAcm[Index].Size=
, gFitTableContext.StartupAcmVersion);=0D
}=0D
if (gFitTableContext.DiagnstAcm.Address !=3D 0) {=0D
printf ("DiagnosticAcm - (0x%08x, 0x%08x, 0x%04x)\n", gFitTableContext=
.DiagnstAcm.Address, gFitTableContext.DiagnstAcm.Size, gFitTableContext.Dia=
gnstAcmVersion);=0D
@@ -2809,8 +2815,8 @@ Returns:
//=0D
// 4. StartupAcm=0D
//=0D
- if (gFitTableContext.StartupAcm.Address !=3D 0) {=0D
- FitEntry[FitIndex].Address =3D gFitTableContext.StartupAcm=
.Address;=0D
+ for (Index =3D 0; Index < gFitTableContext.StartupAcmNumber; Index++) {=
=0D
+ FitEntry[FitIndex].Address =3D gFitTableContext.StartupAcm=
[Index].Address;=0D
*(UINT32 *)&FitEntry[FitIndex].Size[0] =3D 0; //gFitTableContext.Start=
upAcm.Size / 16;=0D
FitEntry[FitIndex].Version =3D (UINT16)gFitTableContext.St=
artupAcmVersion;=0D
FitEntry[FitIndex].Type =3D FIT_TABLE_TYPE_STARTUP_ACM;=
=0D
@@ -3110,7 +3116,7 @@ GetFitEntryInfo (
=0D
Routine Description:=0D
=0D
- Fill the FIT table information to Fvrecovery=0D
+ Get the FIT table information from Fvrecovery=0D
=0D
Arguments:=0D
=0D
@@ -3164,8 +3170,8 @@ Returns:
gFitTableContext.MicrocodeNumber ++;=0D
break;=0D
case FIT_TABLE_TYPE_STARTUP_ACM:=0D
- gFitTableContext.StartupAcm.Address =3D (UINT32)FitEntry[FitIndex].A=
ddress;=0D
- gFitTableContext.StartupAcmVersion =3D FitEntry[FitIndex].Version;=
=0D
+ gFitTableContext.StartupAcm[gFitTableContext.StartupAcmNumber].Addre=
ss =3D (UINT32)FitEntry[FitIndex].Address;=0D
+ gFitTableContext.StartupAcmVersion =
=3D FitEntry[FitIndex].Version;=0D
break;=0D
case FIT_TABLE_TYPE_BIOS_MODULE:=0D
gFitTableContext.BiosModule[gFitTableContext.BiosModuleNumber].Addre=
ss =3D (UINT32)FitEntry[FitIndex].Address;=0D
@@ -3232,6 +3238,7 @@ Returns:
UINT32 FdFileSize;=0D
=0D
UINT8 *AcmBuffer;=0D
+ INTN Index;=0D
UINT32 FixedFitLocation;=0D
=0D
FileBufferRaw =3D NULL;=0D
@@ -3323,22 +3330,23 @@ Returns:
//=0D
// Get ACM buffer=0D
//=0D
- if (gFitTableContext.StartupAcm.Address !=3D 0) {=0D
- AcmBuffer =3D FLASH_TO_MEMORY(gFitTableContext.StartupAcm.Address, F=
dFileBuffer, FdFileSize);=0D
- if ((AcmBuffer < FdFileBuffer) || (AcmBuffer + gFitTableContext.Star=
tupAcm.Size > FdFileBuffer + FdFileSize)) {=0D
- printf ("ACM out of range - can not validate it\n");=0D
- AcmBuffer =3D NULL;=0D
- }=0D
+ for (Index =3D 0; Index < (INTN)gFitTableContext.StartupAcmNumber; Ind=
ex ++) {=0D
+ if (gFitTableContext.StartupAcm[Index].Address !=3D 0) {=0D
+ AcmBuffer =3D FLASH_TO_MEMORY(gFitTableContext.StartupAcm[Index].A=
ddress, FdFileBuffer, FdFileSize);=0D
+ if ((AcmBuffer < FdFileBuffer) || (AcmBuffer + gFitTableContext.St=
artupAcm[Index].Size > FdFileBuffer + FdFileSize)) {=0D
+ printf ("ACM out of range - can not validate it\n");=0D
+ AcmBuffer =3D NULL;=0D
+ }=0D
=0D
- if (AcmBuffer !=3D NULL) {=0D
- if (CheckAcm ((ACM_FORMAT *)AcmBuffer, gFitTableContext.StartupAcm=
.Size)) {=0D
- DumpAcm ((ACM_FORMAT *)AcmBuffer);=0D
- } else {=0D
- Status =3D STATUS_ERROR;=0D
- goto exitFunc;=0D
+ if (AcmBuffer !=3D NULL) {=0D
+ if (CheckAcm ((ACM_FORMAT *)AcmBuffer, gFitTableContext.StartupA=
cm[Index].Size)) {=0D
+ DumpAcm ((ACM_FORMAT *)AcmBuffer);=0D
+ } else {=0D
+ Status =3D STATUS_ERROR;=0D
+ goto exitFunc;=0D
+ }=0D
}=0D
}=0D
-=0D
}=0D
=0D
//=0D
@@ -3576,4 +3584,3 @@ Returns:
=0D
return u;=0D
}=0D
-=0D
diff --git a/Silicon/Intel/Tools/FitGen/FitGen.h b/Silicon/Intel/Tools/FitG=
en/FitGen.h
index 5add6a8870..b7de0a6b2d 100644
--- a/Silicon/Intel/Tools/FitGen/FitGen.h
+++ b/Silicon/Intel/Tools/FitGen/FitGen.h
@@ -1,7 +1,7 @@
/**@file=0D
Definitions for the FitGen utility.=0D
=0D
-Copyright (c) 2010-2020, Intel Corporation. All rights reserved.<BR>=0D
+Copyright (c) 2010-2022, Intel Corporation. All rights reserved.<BR>=0D
SPDX-License-Identifier: BSD-2-Clause-Patent=0D
=0D
**/=0D
@@ -31,7 +31,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
// Utility version information=0D
//=0D
#define UTILITY_MAJOR_VERSION 0=0D
-#define UTILITY_MINOR_VERSION 64=0D
+#define UTILITY_MINOR_VERSION 65=0D
#define UTILITY_DATE __DATE__=0D
=0D
//=0D
--=20
2.26.2.windows.1


Now: TianoCore edk2-test Bug Triage Meeting - 06/23/2022 #cal-notice

Group Notification <noreply@...>
 

TianoCore edk2-test Bug Triage Meeting

When:
06/23/2022
10:00pm to 11:00pm
(UTC+08:00) Asia/Shanghai

Where:
https://armltd.zoom.us/j/93809865843?pwd=dU1hSzk4NHM2RGhaRDRyWWZxUzY5dz09&from=addon

Organizer: Edhaya Chandran Edhaya.Chandran@...

View Event

Description:


[edk2-platforms][PATCH v1 0/1] BoardModulePkg: Fix Boot0000 got overwritten

JamesWang [王家明] <jameswang@...>
 

A simple fix to avoid overwrtiing Boot0000 when mBootMenuFile is not found.

James Wang (1):
BoardModulePkg: Fix Boot0000 got overwritten

Platform/Intel/BoardModulePkg/Library/BoardBdsHookLib/BoardBootOption.c | 18 ++++++++++++------
1 file changed, 12 insertions(+), 6 deletions(-)

--
2.13.2.windows.1
-The information contained in this message may be confidential and proprietary to American Megatrends (AMI). This communication is intended to be read only by the individual or entity to whom it is addressed or by their designee. If the reader of this message is not the intended recipient, you are on notice that any distribution of this message, in any form, is strictly prohibited. Please promptly notify the sender by reply e-mail or by telephone at 770-246-8600, and then delete or destroy all copies of the transmission.

1661 - 1680 of 92312