Date   

Re: 回复: 回复: [edk2-devel] 回复: 回复: 回复: [PATCH v2 01/11] MdePkg, OvmfPkg: Clean up GHCB field offsets and save area

Lendacky, Thomas
 

On 10/27/20 2:57 AM, Dong, Eric wrote:
I agree with Laszlo, we need to care Bisectability first.
Thanks for responding, Eric. I'll submit v3 as previously submitted.

Thanks,
Tom


Thanks,
Eric
-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Lendacky, Thomas
Sent: Tuesday, October 27, 2020 12:34 AM
To: gaoliming <gaoliming@byosoft.com.cn>; devel@edk2.groups.io; lersek@redhat.com; Ni, Ray <ray.ni@intel.com>; Dong, Eric <eric.dong@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
Cc: 'Brijesh Singh' <brijesh.singh@amd.com>; Liu, Zhiguang <zhiguang.liu@intel.com>; Justen, Jordan L <jordan.l.justen@intel.com>; 'Ard Biesheuvel' <ard.biesheuvel@arm.com>
Subject: Re: 回复: 回复: [edk2-devel] 回复: 回复: 回复: [PATCH v2 01/11] MdePkg, OvmfPkg: Clean up GHCB field offsets and save area

On 10/22/20 9:57 PM, gaoliming wrote:
Laszlo:
I agree Bisectability is important. I want to consider the impact and balance the change. Now, this change will update UefiCpuPkg. I also want to collect the feedback from UefiCpuPkg maintainer: Ray and Eric.
Ray/Eric,

Any feedback on this question (specifically for patch #10 of this series, not this patch)? I'd also prefer to maintain bisectability and therefore submit the changes to the UefiCpuPkg and OvmfPkg in the same patch.

Thanks,
Tom


Thanks
Liming
-----邮件原件-----
发件人: bounce+27952+66536+4905953+8761045@groups.io
<bounce+27952+66536+4905953+8761045@groups.io> 代表 Laszlo Ersek
发送时间: 2020年10月22日 21:13
收件人: gaoliming <gaoliming@byosoft.com.cn>; devel@edk2.groups.io;
thomas.lendacky@amd.com
抄送: 'Brijesh Singh' <brijesh.singh@amd.com>; 'Michael D Kinney'
<michael.d.kinney@intel.com>; 'Zhiguang Liu'
<zhiguang.liu@intel.com>; 'Jordan Justen' <jordan.l.justen@intel.com>; 'Ard Biesheuvel'
<ard.biesheuvel@arm.com>
主题: Re: 回复: [edk2-devel] 回复: 回复: 回复: [PATCH v2 01/11] MdePkg,
OvmfPkg: Clean up GHCB field offsets and save area

On 10/22/20 03:25, gaoliming wrote:
Tom:
For the patch in UefiCpuPkg, this changes the library interface.
So, the
consumer and producer code is required to be changed together. There
is no good compatible way to do it. I still prefer to separate them
for the different package. Although the first commit breaks the tree,
your patch is the patch serial, they will be merged together. Its impact should be small.

I really disagree here. Bisectability is way more important, in my
opinion, than avoiding a multi-package patch.

I agree we should avoid multi-package patches as much as we can --
but not more than we can. Bisectability (= keeping the tree buildable
at every commit) is very important, in my opinion.

Thanks,
Laszlo









[PATCH v3 1/1] MdeModulePkg/Gcd: Check memory allocation when initializing memory

Jeff Brasen
 

CoreInitializeMemoryServices was not checking for any existing memory
allocation created in the HOB producer phase. If there are memory
allocations outside of the region covered by the HOB List then Gcd could
select that region for memory which can result in the memory allocation
to not be handled and memory overwrites.

Signed-off-by: Jeff Brasen <jbrasen@nvidia.com>
---
MdeModulePkg/Core/Dxe/Gcd/Gcd.c | 58 +++++++++++++++++++++++++++++++++
1 file changed, 58 insertions(+)

diff --git a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c
index 2d8c076f7113..51b082b7e7eb 100644
--- a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c
+++ b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c
@@ -2097,6 +2097,60 @@ CalculateTotalMemoryBinSizeNeeded (
return TotalSize;
}

+/**
+ Find the largest region in the specified region that is not covered by an existing memory allocation
+
+ @param BaseAddress On input start of the region to check.
+ On output start of the largest free region.
+ @param Length On input size of region to check.
+ On output size of the largest free region.
+ @param MemoryHob Hob pointer for the first memory allocation pointer to check
+**/
+VOID
+FindLargestFreeRegion (
+ IN OUT EFI_PHYSICAL_ADDRESS *BaseAddress,
+ IN OUT UINT64 *Length,
+ IN EFI_HOB_MEMORY_ALLOCATION *MemoryHob
+ )
+{
+ EFI_PHYSICAL_ADDRESS TopAddress;
+ EFI_PHYSICAL_ADDRESS AllocatedTop;
+ EFI_PHYSICAL_ADDRESS LowerBase;
+ UINT64 LowerSize;
+ EFI_PHYSICAL_ADDRESS UpperBase;
+ UINT64 UpperSize;
+
+ TopAddress = *BaseAddress + *Length;
+ while (MemoryHob != NULL) {
+ AllocatedTop = MemoryHob->AllocDescriptor.MemoryBaseAddress + MemoryHob->AllocDescriptor.MemoryLength;
+
+ if ((MemoryHob->AllocDescriptor.MemoryBaseAddress >= *BaseAddress) &&
+ (AllocatedTop <= TopAddress)) {
+ LowerBase = *BaseAddress;
+ LowerSize = MemoryHob->AllocDescriptor.MemoryBaseAddress - *BaseAddress;
+ UpperBase = AllocatedTop;
+ UpperSize = TopAddress - AllocatedTop;
+
+ if (LowerSize != 0) {
+ FindLargestFreeRegion (&LowerBase, &LowerSize, (EFI_HOB_MEMORY_ALLOCATION *) GetNextHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, GET_NEXT_HOB (MemoryHob)));
+ }
+ if (UpperSize != 0) {
+ FindLargestFreeRegion (&UpperBase, &UpperSize, (EFI_HOB_MEMORY_ALLOCATION *) GetNextHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, GET_NEXT_HOB (MemoryHob)));
+ }
+
+ if (UpperSize >= LowerSize) {
+ *Length = UpperSize;
+ *BaseAddress = UpperBase;
+ } else {
+ *Length = LowerSize;
+ *BaseAddress = LowerBase;
+ }
+ return;
+ }
+ MemoryHob = GetNextHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, GET_NEXT_HOB (MemoryHob));
+ }
+}
+
/**
External function. Initializes memory services based on the memory
descriptor HOBs. This function is responsible for priming the memory
@@ -2235,6 +2289,7 @@ CoreInitializeMemoryServices (
Attributes = PhitResourceHob->ResourceAttribute;
BaseAddress = PageAlignAddress (PhitHob->EfiMemoryTop);
Length = PageAlignLength (ResourceHob->PhysicalStart + ResourceHob->ResourceLength - BaseAddress);
+ FindLargestFreeRegion (&BaseAddress, &Length, (EFI_HOB_MEMORY_ALLOCATION *)GetFirstHob (EFI_HOB_TYPE_MEMORY_ALLOCATION));
if (Length < MinimalMemorySizeNeeded) {
//
// If that range is not large enough to intialize the DXE Core, then
@@ -2242,6 +2297,7 @@ CoreInitializeMemoryServices (
//
BaseAddress = PageAlignAddress (PhitHob->EfiFreeMemoryBottom);
Length = PageAlignLength (PhitHob->EfiFreeMemoryTop - BaseAddress);
+ //This region is required to have no memory allocation inside it, skip check for entries in HOB List
if (Length < MinimalMemorySizeNeeded) {
//
// If that range is not large enough to intialize the DXE Core, then
@@ -2249,6 +2305,7 @@ CoreInitializeMemoryServices (
//
BaseAddress = PageAlignAddress (ResourceHob->PhysicalStart);
Length = PageAlignLength ((UINT64)((UINTN)*HobStart - BaseAddress));
+ FindLargestFreeRegion (&BaseAddress, &Length, (EFI_HOB_MEMORY_ALLOCATION *)GetFirstHob (EFI_HOB_TYPE_MEMORY_ALLOCATION));
}
}
break;
@@ -2312,6 +2369,7 @@ CoreInitializeMemoryServices (
//
TestedMemoryBaseAddress = PageAlignAddress (ResourceHob->PhysicalStart);
TestedMemoryLength = PageAlignLength (ResourceHob->PhysicalStart + ResourceHob->ResourceLength - TestedMemoryBaseAddress);
+ FindLargestFreeRegion (&TestedMemoryBaseAddress, &TestedMemoryLength, (EFI_HOB_MEMORY_ALLOCATION *)GetFirstHob (EFI_HOB_TYPE_MEMORY_ALLOCATION));
if (TestedMemoryLength < MinimalMemorySizeNeeded) {
continue;
}
--
2.25.1


[PATCH v3 1/1] MdeModulePkg/XhciDxe: Retry device slot init on failure

Jeff Brasen
 

From: Jon Hunter <jonathanh@nvidia.com>

With some super-speed USB mass storage devices it has been observed
that a USB transaction error may occur when attempting the set the
device address during enumeration.

According the the xHCI specification (section 4.6.5) ...

"A USB Transaction ErrorCompletion Code for an Address Device Command
may be due to a Stall response from a device. Software should issue a
Disable Slot Commandfor the Device Slot then an Enable Slot Command
to recover from this error."

To fix this, retry the device slot initialization if it fails due to a
device error.

Change was verified using a superspeed mass storage device that was occasionally
failing to enumerate in UEFI. With this change this failure to enumerate
was resolved. This failure was also only seen in UEFI and not in the OS.

Signed-off-by: Jon Hunter <jonathanh@nvidia.com>
Signed-off-by: Jeff Brasen <jbrasen@nvidia.com>
---
MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.h | 1 +
MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c | 34 +++++++++++++++++-------
2 files changed, 25 insertions(+), 10 deletions(-)

diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.h b/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.h
index 2f1899502151..3f9cdb1c3609 100644
--- a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.h
+++ b/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.h
@@ -11,6 +11,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
#define _EFI_XHCI_SCHED_H_

#define XHC_URB_SIG SIGNATURE_32 ('U', 'S', 'B', 'R')
+#define XHC_INIT_DEVICE_SLOT_RETRIES 1

//
// Transfer types, used in URB to identify the transfer type
diff --git a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c b/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c
index 00e9cc63d63e..dc36945962a0 100644
--- a/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c
+++ b/MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c
@@ -1717,9 +1717,11 @@ XhcPollPortStatusChange (
EFI_STATUS Status;
UINT8 Speed;
UINT8 SlotId;
+ UINT8 Retries;
USB_DEV_ROUTE RouteChart;

Status = EFI_SUCCESS;
+ Retries = XHC_INIT_DEVICE_SLOT_RETRIES;

if ((PortState->PortChangeStatus & (USB_PORT_STAT_C_CONNECTION | USB_PORT_STAT_C_ENABLE | USB_PORT_STAT_C_OVERCURRENT | USB_PORT_STAT_C_RESET)) == 0) {
return EFI_SUCCESS;
@@ -1761,17 +1763,29 @@ XhcPollPortStatusChange (
} else if ((PortState->PortStatus & USB_PORT_STAT_SUPER_SPEED) != 0) {
Speed = EFI_USB_SPEED_SUPER;
}
- //
- // Execute Enable_Slot cmd for attached device, initialize device context and assign device address.
- //
- SlotId = XhcRouteStringToSlotId (Xhc, RouteChart);
- if ((SlotId == 0) && ((PortState->PortChangeStatus & USB_PORT_STAT_C_RESET) != 0)) {
- if (Xhc->HcCParams.Data.Csz == 0) {
- Status = XhcInitializeDeviceSlot (Xhc, ParentRouteChart, Port, RouteChart, Speed);
- } else {
- Status = XhcInitializeDeviceSlot64 (Xhc, ParentRouteChart, Port, RouteChart, Speed);
+
+ do {
+ //
+ // Execute Enable_Slot cmd for attached device, initialize device context and assign device address.
+ //
+ SlotId = XhcRouteStringToSlotId (Xhc, RouteChart);
+ if ((SlotId == 0) && ((PortState->PortChangeStatus & USB_PORT_STAT_C_RESET) != 0)) {
+ if (Xhc->HcCParams.Data.Csz == 0) {
+ Status = XhcInitializeDeviceSlot (Xhc, ParentRouteChart, Port, RouteChart, Speed);
+ } else {
+ Status = XhcInitializeDeviceSlot64 (Xhc, ParentRouteChart, Port, RouteChart, Speed);
+ }
}
- }
+
+ //
+ // According to the xHCI specification (section 4.6.5), "a USB Transaction
+ // Error Completion Code for an Address Device Command may be due to a Stall
+ // response from a device. Software should issue a Disable Slot Command for
+ // the Device Slot then an Enable Slot Command to recover from this error."
+ // Therefore, retry the device slot initialization if it fails due to a
+ // device error.
+ //
+ } while ((Status == EFI_DEVICE_ERROR) && (Retries-- != 0));
}

return Status;
--
2.25.1


Re: [PATCH] BaseTools: Update the FV Space Information to display decimal and Hex

Bob Feng
 

How about swapping the positions of decimal and hex numbers? I think the 13 in 13%Full is a decimal number, so putting the decimal number outside the square brackets might look more consistent.

SECFV [13%Full] 212992 (0x34000) total, 28400 (0x6ef0) used, 184592 (0x2d110) free

Thanks,
Bob

-----Original Message-----
From: Yunhua Feng <fengyunhua@byosoft.com.cn>
Sent: Wednesday, October 28, 2020 1:51 PM
To: devel@edk2.groups.io
Cc: Feng, Bob C <bob.c.feng@intel.com>; Liming Gao <gaoliming@byosoft.com.cn>; Chen, Christine <yuwei.chen@intel.com>
Subject: [PATCH] BaseTools: Update the FV Space Information to display decimal and Hex

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

Update the FV Space Information to display decimal and Hex

FV Space Information
before format:
SECFV [13%Full] 212992 total, 28400 used, 184592 free Updated format:
SECFV [13%Full] 0x34000 (212992) total, 0x6ef0 (28400) used,
0x2d110 (184592) free

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Yuwei Chen <yuwei.chen@intel.com>
Signed-off-by: Yunhua Feng <fengyunhua@byosoft.com.cn>
---
BaseTools/Source/Python/GenFds/GenFds.py | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/BaseTools/Source/Python/GenFds/GenFds.py b/BaseTools/Source/Python/GenFds/GenFds.py
index d5511f4c40..76a6d0d1d0 100644
--- a/BaseTools/Source/Python/GenFds/GenFds.py
+++ b/BaseTools/Source/Python/GenFds/GenFds.py
@@ -633,7 +633,10 @@ class GenFds(object):
else:
Percentage = str((UsedSizeValue + 0.0) / TotalSizeValue)[0:4].lstrip('0.')

- GenFdsGlobalVariable.InfLogger(Name + ' ' + '[' + Percentage + '%Full] ' + str(TotalSizeValue) + ' total, ' + str(UsedSizeValue) + ' used, ' + str(FreeSizeValue) + ' free')
+ GenFdsGlobalVariable.InfLogger(Name + ' ' + '[' + Percentage + '%Full] '\
+ + hex(TotalSizeValue) + ' (' + str(TotalSizeValue) + ')' + ' total, '\
+ + hex(UsedSizeValue) + ' (' + str(UsedSizeValue) + ')' + ' used, '\
+ + hex(FreeSizeValue) + ' ('
+ + str(FreeSizeValue) + ')' + ' free')

## PreprocessImage()
#
--
2.27.0.windows.1


[PATCH v1 1/1] ArmPkg/ArmGicDxe: fix writes to GICD_IPRIORITYR<n> when ARE enable

Quan Nguyen
 

According to ARM doc IHI 0069F, section 11.9.18, "Accessing the
GICD_IPRIORITYR<n>:", "These registers are always used when affinity
routing is not enabled. When affinity routing is enabled for the
Security state of an interrupt:
* GICR_IPRIORITYR<n> is used instead of GICD_IPRIORITYR<n> where n = 0
to 7 (that is, for SGIs and PPIs)."

The current ArmGicV3 code tries to initialize all the IPRIORITYR
registers to a default state via the Distributor (GICD), so skip
writes to the first eight IPRIORITYR registers when Affinity Routing
is Enabled.

Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
Signed-off-by: Victor Gallardo <Victor@os.amperecomputing.com>
Signed-off-by: Quan Nguyen <quan@os.amperecomputing.com>
---
ArmPkg/Drivers/ArmGic/GicV3/ArmGicV3Dxe.c | 11 +++++++++++
1 file changed, 11 insertions(+)

diff --git a/ArmPkg/Drivers/ArmGic/GicV3/ArmGicV3Dxe.c b/ArmPkg/Drivers/ArmGic/GicV3/ArmGicV3Dxe.c
index d7da1f198d9e..bc543502481b 100644
--- a/ArmPkg/Drivers/ArmGic/GicV3/ArmGicV3Dxe.c
+++ b/ArmPkg/Drivers/ArmGic/GicV3/ArmGicV3Dxe.c
@@ -378,6 +378,7 @@ GicV3DxeInitialize (
UINTN RegShift;
UINT64 CpuTarget;
UINT64 MpId;
+ BOOLEAN AffinityRoutingEnabled = FALSE;

// Make sure the Interrupt Controller Protocol is not already installed in
// the system.
@@ -391,11 +392,21 @@ GicV3DxeInitialize (
// Routing enabled. So ensure that the ARE bit is set.
if (!FeaturePcdGet (PcdArmGicV3WithV2Legacy)) {
MmioOr32 (mGicDistributorBase + ARM_GIC_ICDDCR, ARM_GIC_ICDDCR_ARE);
+ // If Affinity Routing is Enabled, the first 32 interrupts (SGI and PPI)
+ // can be programmed only through Redistributor interface (GICR).
+ // Initializing the GICD_IPRIORITYR registers for these interrupts can be
+ // skipped as the Redistributor will be powered up and initialized
+ // at the appropriate time (e.g. in EL3 by trusted firmware).
+ AffinityRoutingEnabled = TRUE;
}

for (Index = 0; Index < mGicNumInterrupts; Index++) {
GicV3DisableInterruptSource (&gHardwareInterruptV3Protocol, Index);

+ if (AffinityRoutingEnabled && Index < 32) {
+ continue;
+ }
+
// Set Priority
RegOffset = Index / 4;
RegShift = (Index % 4) * 8;
--
2.28.0


Re: [Patch V2] BaseTools: Enable Module Scope Structure Pcd

Bob Feng
 

Liming,

You can verify this patch with Mike's case.

Clone Mike's edk2 repo, and checkout the branch Bug_xxx_CryptoPkg_UseModuleScopedPcds
https://github.com/mdkinney/edk2/tree/Bug_xxx_CryptoPkg_UseModuleScopedPcds

Then build the CryptoPkg.

build -p CryptoPkg\CryptoPkg.dsc -a IA32 -y report.txt

Thanks,
Bob

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of gaoliming
Sent: Tuesday, October 27, 2020 2:20 PM
To: Feng, Bob C <bob.c.feng@intel.com>; devel@edk2.groups.io
Cc: Chen, Christine <yuwei.chen@intel.com>; Kinney, Michael D <michael.d.kinney@intel.com>
Subject: 回复: [edk2-devel] [Patch V2] BaseTools: Enable Module Scope Structure Pcd

Bob:
I will review this change this week. Can you share your test case? I also
want to check the build output.

Thanks
Liming
-----邮件原件-----
发件人: Feng, Bob C <bob.c.feng@intel.com>
发送时间: 2020年10月26日 12:00
收件人: devel@edk2.groups.io; Feng, Bob C <bob.c.feng@intel.com>; Liming
Gao <gaoliming@byosoft.com.cn>
抄送: Chen, Christine <yuwei.chen@intel.com>; Kinney, Michael D
<michael.d.kinney@intel.com>
主题: RE: [edk2-devel] [Patch V2] BaseTools: Enable Module Scope Structure
Pcd

Liming, would you review this patch?

Thanks,
Bob

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Bob Feng
Sent: Thursday, October 15, 2020 6:59 PM
To: devel@edk2.groups.io
Cc: Liming Gao <gaoliming@byosoft.com.cn>; Chen, Christine
<yuwei.chen@intel.com>
Subject: [edk2-devel] [Patch V2] BaseTools: Enable Module Scope Structure
Pcd

This patch is to enable the Module scoped Structure Pcd usage.
User can set structure pcd field value in module scope. For example,
under the [components] section of a dsc file, user can override some
field value for a specific module.

Package/Module.inf{
<PcdsFixedAtBuild>
gUefiTokenSpaceGuid.StructurePcdModule.FieldName | 5
}

Signed-off-by: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Yuwei Chen <yuwei.chen@intel.com>
---
V2: Fixed the incorrect format in build report.
BaseTools/Source/Python/AutoGen/DataPipe.py | 5 +-
.../Source/Python/AutoGen/ModuleAutoGen.py | 4 +-
.../Python/AutoGen/ModuleAutoGenHelper.py | 10 +-
.../Source/Python/AutoGen/PlatformAutoGen.py | 8 +-
.../Python/Workspace/BuildClassObject.py | 12 +
.../Source/Python/Workspace/DscBuildData.py | 243
++++++++++++++++--
BaseTools/Source/Python/build/BuildReport.py | 109 ++++----
7 files changed, 319 insertions(+), 72 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/DataPipe.py
b/BaseTools/Source/Python/AutoGen/DataPipe.py
index 50403fbfb5..86ac2b928d 100755
--- a/BaseTools/Source/Python/AutoGen/DataPipe.py
+++ b/BaseTools/Source/Python/AutoGen/DataPipe.py
@@ -70,13 +70,14 @@ class MemoryDataPipe(DataPipe):
}

#Platform Module Pcds
ModulePcds = {}
for m in PlatformInfo.Platform.Modules:
- m_pcds = PlatformInfo.Platform.Modules[m].Pcds
+ module = PlatformInfo.Platform.Modules[m]
+ m_pcds = module.Pcds
if m_pcds:
- ModulePcds[(m.File,m.Root,m.Arch)] = [PCD_DATA(
+ ModulePcds[module.Guid] = [PCD_DATA(
pcd.TokenCName,pcd.TokenSpaceGuidCName,pcd.Type,
pcd.DatumType,pcd.SkuInfoList,pcd.DefaultValue,

pcd.MaxDatumSize,pcd.UserDefinedDefaultStoresFlag,pcd.validateranges,

pcd.validlists,pcd.expressions,pcd.CustomAttribute,pcd.TokenValue)
for pcd in PlatformInfo.Platform.Modules[m].Pcds.values()]
diff --git a/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py
b/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py
index eebf6e87f5..d70b0d7ae8 100755
--- a/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/ModuleAutoGen.py
@@ -1030,11 +1030,11 @@ class ModuleAutoGen(AutoGen):
# @retval list The list of PCD
#
@cached_property
def ModulePcdList(self):
# apply PCD settings from platform
- RetVal = self.PlatformInfo.ApplyPcdSetting(self.Module,
self.Module.Pcds)
+ RetVal = self.PlatformInfo.ApplyPcdSetting(self,
self.Module.Pcds)

return RetVal
@cached_property
def _PcdComments(self):
ReVal = OrderedListDict()
@@ -1061,11 +1061,11 @@ class ModuleAutoGen(AutoGen):
# skip duplicated PCDs
if Key in self.Module.Pcds or Key in Pcds:
continue
Pcds.add(Key)
PcdsInLibrary[Key] = copy.copy(Library.Pcds[Key])
- RetVal.extend(self.PlatformInfo.ApplyPcdSetting(self.Module,
PcdsInLibrary, Library=Library))
+ RetVal.extend(self.PlatformInfo.ApplyPcdSetting(self,
PcdsInLibrary, Library=Library))
return RetVal

## Get the GUID value mapping
#
# @retval dict The mapping between GUID cname and its
value
diff --git a/BaseTools/Source/Python/AutoGen/ModuleAutoGenHelper.py
b/BaseTools/Source/Python/AutoGen/ModuleAutoGenHelper.py
index 9dd93b9beb..8e60643d1f 100644
--- a/BaseTools/Source/Python/AutoGen/ModuleAutoGenHelper.py
+++ b/BaseTools/Source/Python/AutoGen/ModuleAutoGenHelper.py
@@ -477,12 +477,13 @@ class PlatformInfo(AutoGenInfo):
SkuName = TAB_DEFAULT
ToPcd.SkuInfoList = {
SkuName : SkuInfoClass(SkuName,
self.Platform.SkuIds[SkuName][0], '', '', '', '', '', ToPcd.DefaultValue)
}

- def ApplyPcdSetting(self, Module, Pcds, Library=""):
+ def ApplyPcdSetting(self, Ma, Pcds, Library=""):
# for each PCD in module
+ Module=Ma.Module
for Name, Guid in Pcds:
PcdInModule = Pcds[Name, Guid]
# find out the PCD setting in platform
if (Name, Guid) in self.Pcds:
PcdInPlatform = self.Pcds[Name, Guid]
@@ -505,13 +506,16 @@ class PlatformInfo(AutoGenInfo):
%
(Guid, Name, str(Module)),
File=self.MetaFile
)

# override PCD settings with module specific setting
+ ModuleScopePcds = self.DataPipe.Get("MOL_PCDS")
if Module in self.Platform.Modules:
PlatformModule = self.Platform.Modules[str(Module)]
- for Key in PlatformModule.Pcds:
+ PCD_DATA = ModuleScopePcds.get(Ma.Guid,{})
+ mPcds = {(pcd.TokenCName,pcd.TokenSpaceGuidCName):
pcd for pcd in PCD_DATA}
+ for Key in mPcds:
if self.BuildOptionPcd:
for pcd in self.BuildOptionPcd:
(TokenSpaceGuidCName, TokenCName,
FieldName, pcdvalue, _) = pcd
if (TokenCName, TokenSpaceGuidCName) ==
Key and FieldName =="":
PlatformModule.Pcds[Key].DefaultValue
= pcdvalue
@@ -526,11 +530,11 @@ class PlatformInfo(AutoGenInfo):
if PcdItem in Pcds:
ToPcd = Pcds[PcdItem]
Flag = True
break
if Flag:
- self._OverridePcd(ToPcd, PlatformModule.Pcds[Key],
Module, Msg="DSC Components Module scoped PCD section",
Library=Library)
+ self._OverridePcd(ToPcd, mPcds[Key], Module,
Msg="DSC Components Module scoped PCD section", Library=Library)
# use PCD value to calculate the MaxDatumSize when it is not
specified
for Name, Guid in Pcds:
Pcd = Pcds[Name, Guid]
if Pcd.DatumType == TAB_VOID and not Pcd.MaxDatumSize:
Pcd.MaxSizeUserSet = None
diff --git a/BaseTools/Source/Python/AutoGen/PlatformAutoGen.py
b/BaseTools/Source/Python/AutoGen/PlatformAutoGen.py
index 26ab8e7f36..c7a4cb9a08 100644
--- a/BaseTools/Source/Python/AutoGen/PlatformAutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/PlatformAutoGen.py
@@ -1041,11 +1041,17 @@ class PlatformAutoGen(AutoGen):
TokenNumber += 1
return RetVal

@cached_property
def _MbList(self):
- return [self.BuildDatabase[m, self.Arch, self.BuildTarget,
self.ToolChain] for m in self.Platform.Modules]
+ mlist = []
+ for m in self.Platform.Modules:
+ component = self.Platform.Modules[m]
+ module = self.BuildDatabase[m, self.Arch, self.BuildTarget,
self.ToolChain]
+ module.Guid = component.Guid
+ mlist.append(module)
+ return mlist

@cached_property
def _MaList(self):
for ModuleFile in self.Platform.Modules:
Ma = ModuleAutoGen(
diff --git a/BaseTools/Source/Python/Workspace/BuildClassObject.py
b/BaseTools/Source/Python/Workspace/BuildClassObject.py
index db40e3b10c..ebb65fc2fe 100644
--- a/BaseTools/Source/Python/Workspace/BuildClassObject.py
+++ b/BaseTools/Source/Python/Workspace/BuildClassObject.py
@@ -68,10 +68,11 @@ class PcdClassObject(object):
self.DscRawValueInfo = {}
if IsDsc:
self.DscDefaultValue = Value
self.PcdValueFromComm = ""
self.PcdValueFromFdf = ""
+ self.PcdValueFromComponents = {} #{ModuleGuid:value,
file_path,lineNo}
self.CustomAttribute = {}
self.UserDefinedDefaultStoresFlag = UserDefinedDefaultStoresFlag
self._Capacity = None

@property
@@ -296,10 +297,11 @@ class StructurePcd(PcdClassObject):
self.DefaultValueFromDecInfo = None
self.ValueChain = set()
self.PcdFieldValueFromComm = OrderedDict()
self.PcdFieldValueFromFdf = OrderedDict()
self.DefaultFromDSC=None
+ self.PcdFiledValueFromDscComponent = OrderedDict()
def __repr__(self):
return self.TypeName

def AddDefaultValue (self, FieldName, Value, FileName="",
LineNo=0,DimensionAttr ="-1"):
if DimensionAttr not in self.DefaultValues:
@@ -322,10 +324,16 @@ class StructurePcd(PcdClassObject):
if FieldName in
self.SkuOverrideValues[SkuName][DefaultStoreName][DimensionAttr]:
del
self.SkuOverrideValues[SkuName][DefaultStoreName][DimensionAttr][FieldN
ame]

self.SkuOverrideValues[SkuName][DefaultStoreName][DimensionAttr][FieldN
ame] = [Value.strip(), FileName, LineNo]
return
self.SkuOverrideValues[SkuName][DefaultStoreName][DimensionAttr][FieldN
ame]

+ def AddComponentOverrideValue(self,FieldName, Value, ModuleGuid,
FileName="", LineNo=0, DimensionAttr = '-1'):
+ self.PcdFiledValueFromDscComponent.setdefault(ModuleGuid,
OrderedDict())
+
self.PcdFiledValueFromDscComponent[ModuleGuid].setdefault(DimensionAtt
r,OrderedDict())
+
self.PcdFiledValueFromDscComponent[ModuleGuid][DimensionAttr][FieldNa
me] = [Value.strip(), FileName, LineNo]
+ return
self.PcdFiledValueFromDscComponent[ModuleGuid][DimensionAttr][FieldNa
me]
+
def SetPcdMode (self, PcdMode):
self.PcdMode = PcdMode

def copy(self, PcdObject):
self.TokenCName = PcdObject.TokenCName if
PcdObject.TokenCName else self.TokenCName
@@ -363,10 +371,11 @@ class StructurePcd(PcdClassObject):
self.PcdDefineLineNo = PcdObject.PcdDefineLineNo if
PcdObject.PcdDefineLineNo else self.PcdDefineLineNo
self.PkgPath = PcdObject.PkgPath if PcdObject.PkgPath else
self.PkgPath
self.ValueChain = PcdObject.ValueChain if
PcdObject.ValueChain else self.ValueChain
self.PcdFieldValueFromComm =
PcdObject.PcdFieldValueFromComm if PcdObject.PcdFieldValueFromComm
else self.PcdFieldValueFromComm
self.PcdFieldValueFromFdf = PcdObject.PcdFieldValueFromFdf
if PcdObject.PcdFieldValueFromFdf else self.PcdFieldValueFromFdf
+ self.PcdFiledValueFromDscComponent =
PcdObject.PcdFiledValueFromDscComponent if
PcdObject.PcdFiledValueFromDscComponent else
self.PcdFiledValueFromDscComponent

def __deepcopy__(self,memo):
new_pcd = StructurePcd()
self.sharedcopy(new_pcd)

@@ -381,10 +390,11 @@ class StructurePcd(PcdClassObject):
new_pcd.DefaultValues = CopyDict(self.DefaultValues)
new_pcd.DefaultFromDSC=CopyDict(self.DefaultFromDSC)
new_pcd.SkuOverrideValues = CopyDict(self.SkuOverrideValues)
new_pcd.PcdFieldValueFromComm =
CopyDict(self.PcdFieldValueFromComm)
new_pcd.PcdFieldValueFromFdf =
CopyDict(self.PcdFieldValueFromFdf)
+ new_pcd.PcdFiledValueFromDscComponent =
CopyDict(self.PcdFiledValueFromDscComponent)
new_pcd.ValueChain = {item for item in self.ValueChain}
return new_pcd

LibraryClassObject = namedtuple('LibraryClassObject',
['LibraryClass','SupModList'])

@@ -461,10 +471,12 @@ class ModuleBuildClassObject(object):
self.Includes = []
self.Packages = []
self.Pcds = {}
self.BuildOptions = {}
self.Depex = {}
+ self.StrPcdSet = []
+ self.StrPcdOverallValue = {}

## Convert the class to a string
#
# Convert member MetaFile of the class to a string
#
diff --git a/BaseTools/Source/Python/Workspace/DscBuildData.py
b/BaseTools/Source/Python/Workspace/DscBuildData.py
index 1ed3d9b909..1bb4fdc183 100644
--- a/BaseTools/Source/Python/Workspace/DscBuildData.py
+++ b/BaseTools/Source/Python/Workspace/DscBuildData.py
@@ -753,13 +753,14 @@ class DscBuildData(PlatformBuildClassObject):
ErrorCode, ErrorInfo = ModuleFile.Validate('.inf')
if ErrorCode != 0:
EdkLogger.error('build', ErrorCode, File=self.MetaFile,
Line=LineNo,
ExtraData=ErrorInfo)

+ ModuleBuildData = self._Bdb[ModuleFile, self._Arch,
self._Target, self._Toolchain]
Module = ModuleBuildClassObject()
Module.MetaFile = ModuleFile
-
+ Module.Guid = ModuleBuildData.Guid
# get module private library instance
RecordList = self._RawData[MODEL_EFI_LIBRARY_CLASS,
self._Arch, None, ModuleId]
for Record in RecordList:
LibraryClass = Record[0]
LibraryPath = PathClass(NormPath(Record[1], Macros),
GlobalData.gWorkspace, Arch=self._Arch)
@@ -776,11 +777,11 @@ class DscBuildData(PlatformBuildClassObject):
LibraryClass = 'NULL%d' % self._NullLibraryNumber
EdkLogger.verbose("Found forced library
for %s\n\t%s [%s]" % (ModuleFile, LibraryPath, LibraryClass))
Module.LibraryClasses[LibraryClass] = LibraryPath
if LibraryPath not in self.LibraryInstances:
self.LibraryInstances.append(LibraryPath)
-
+ S_PcdSet = []
# get module private PCD setting
for Type in [MODEL_PCD_FIXED_AT_BUILD,
MODEL_PCD_PATCHABLE_IN_MODULE, \
MODEL_PCD_FEATURE_FLAG,
MODEL_PCD_DYNAMIC, MODEL_PCD_DYNAMIC_EX]:
RecordList = self._RawData[Type, self._Arch, None,
ModuleId]
for TokenSpaceGuid, PcdCName, Setting, Dummy1,
Dummy2, Dummy3, Dummy4, Dummy5 in RecordList:
@@ -790,24 +791,35 @@ class DscBuildData(PlatformBuildClassObject):
if len(TokenList) > 2:
MaxDatumSize = TokenList[2]
else:
MaxDatumSize = ''
TypeString = self._PCD_TYPE_STRING_[Type]
- Pcd = PcdClassObject(
- PcdCName,
- TokenSpaceGuid,
- TypeString,
- '',
- DefaultValue,
- '',
- MaxDatumSize,
- {},
- False,
- None
- )
- Module.Pcds[PcdCName, TokenSpaceGuid] = Pcd

+ TCName,PCName,DimensionAttr,Field =
self.ParsePcdNameStruct(TokenSpaceGuid, PcdCName)
+
+ if ("." in TokenSpaceGuid or "[" in PcdCName):
+
S_PcdSet.append([ TCName,PCName,DimensionAttr,Field,
ModuleBuildData.Guid, "", Dummy5, AnalyzePcdExpression(Setting)[0]])
+ DefaultValue = ''
+ if ( PCName,TCName) not in Module.Pcds:
+ Pcd = PcdClassObject(
+ PCName,
+ TCName,
+ TypeString,
+ '',
+ DefaultValue,
+ '',
+ MaxDatumSize,
+ {},
+ False,
+ None,
+ IsDsc=True)
+ Module.Pcds[PCName, TCName] = Pcd
+
+ Module.StrPcdSet = S_PcdSet
+ for TCName,PCName, _,_,_,_,_,_ in S_PcdSet:
+ if (PCName,TCName) in Module.Pcds:
+ Module.StrPcdOverallValue[(PCName,TCName)] =
Module.Pcds[(PCName,TCName)].DefaultValue, self.MetaFile,Dummy5
# get module private build options
RecordList =
self._RawData[MODEL_META_DATA_BUILD_OPTION, self._Arch, None,
ModuleId]
for ToolChainFamily, ToolChain, Option, Dummy1, Dummy2,
Dummy3, Dummy4, Dummy5 in RecordList:
if (ToolChainFamily, ToolChain) not in
Module.BuildOptions:
Module.BuildOptions[ToolChainFamily, ToolChain] =
Option
@@ -820,11 +832,13 @@ class DscBuildData(PlatformBuildClassObject):
if len(RecordList) != 1:
EdkLogger.error('build', OPTION_UNKNOWN, 'Only
FILE_GUID can be listed in <Defines> section.',
File=self.MetaFile,
ExtraData=str(ModuleFile), Line=LineNo)
ModuleFile = ProcessDuplicatedInf(ModuleFile,
RecordList[0][2], GlobalData.gWorkspace)
ModuleFile.Arch = self._Arch
-
+ Module.Guid = RecordList[0][2]
+ for item in Module.StrPcdSet:
+ item[4] = RecordList[0][2]
self._Modules[ModuleFile] = Module
return self._Modules

## Retrieve all possible library instances used in this platform
@property
@@ -1497,11 +1511,19 @@ class DscBuildData(PlatformBuildClassObject):
EdkLogger.error('build', PARSER_ERROR,
"Pcd (%s.%s) is not declared as
Structure PCD in DEC files. Arch: ['%s']" % (TCName, PCName, self._Arch),
File=self.MetaFile, Line = Dummy5)


S_PcdSet.append([ TCName,PCName,DimensionAttr,Field, SkuName,
default_store, Dummy5, AnalyzePcdExpression(Setting)[0]])
-
+ ModuleScopeOverallValue = {}
+ for m in self.Modules.values():
+ mguid = m.Guid
+ if m.StrPcdSet:
+ S_PcdSet.extend(m.StrPcdSet)
+ mguid = m.StrPcdSet[0][4]
+ for (PCName,TCName) in m.StrPcdOverallValue:
+ Value, dsc_file, lineNo =
m.StrPcdOverallValue[(PCName,TCName)]
+
ModuleScopeOverallValue.setdefault((PCName,TCName),{})[mguid] = Value,
dsc_file, lineNo
# handle pcd value override
StrPcdSet = DscBuildData.GetStructurePcdInfo(S_PcdSet)
S_pcd_set = OrderedDict()
for str_pcd in StrPcdSet:
str_pcd_obj = Pcds.get((str_pcd[1], str_pcd[0]), None)
@@ -1515,10 +1537,15 @@ class DscBuildData(PlatformBuildClassObject):
else:
str_pcd_obj_str.DefaultFromDSC =
{skuname:{defaultstore:
str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.get(defaultstore,
str_pcd_obj.SkuInfoList[skuname].DefaultValue) for defaultstore in
DefaultStores} for skuname in str_pcd_obj.SkuInfoList}
for str_pcd_data in StrPcdSet[str_pcd]:
if str_pcd_data[4] in SkuIds:
str_pcd_obj_str.AddOverrideValue(str_pcd_data[3],
str(str_pcd_data[7]), TAB_DEFAULT if str_pcd_data[4] == TAB_COMMON else
str_pcd_data[4], TAB_DEFAULT_STORES_DEFAULT if str_pcd_data[5] ==
TAB_COMMON else str_pcd_data[5], self.MetaFile.File if self.WorkspaceDir
not in self.MetaFile.File else self.MetaFile.File[len(self.WorkspaceDir)
if
self.WorkspaceDir.endswith(os.path.sep) else len(self.WorkspaceDir)+1:],
LineNo=str_pcd_data[6],DimensionAttr = str_pcd_data[2])
+ elif GlobalData.gGuidPattern.match(str_pcd_data[4]):
+
str_pcd_obj_str.AddComponentOverrideValue(str_pcd_data[3],
str(str_pcd_data[7]), str_pcd_data[4].replace("-","S"), self.MetaFile.File
if
self.WorkspaceDir not in self.MetaFile.File else
self.MetaFile.File[len(self.WorkspaceDir) if
self.WorkspaceDir.endswith(os.path.sep) else len(self.WorkspaceDir)+1:],
LineNo=str_pcd_data[6],DimensionAttr = str_pcd_data[2])
+ PcdComponentValue =
ModuleScopeOverallValue.get((str_pcd_obj_str.TokenCName,str_pcd_obj_str.
TokenSpaceGuidCName))
+ for module_guid in PcdComponentValue:
+
str_pcd_obj_str.PcdValueFromComponents[module_guid.replace("-","S")] =
PcdComponentValue[module_guid]
S_pcd_set[str_pcd[1], str_pcd[0]] = str_pcd_obj_str

# Add the Structure PCD that only defined in DEC, don't have
override in DSC file
for Pcd in self.DecPcds:
if isinstance(self._DecPcds[Pcd], StructurePcd):
@@ -1573,11 +1600,14 @@ class DscBuildData(PlatformBuildClassObject):
if defaultstoreid not in
stru_pcd.SkuOverrideValues[skuid]:

stru_pcd.SkuOverrideValues[skuid][defaultstoreid] =
CopyDict(stru_pcd.SkuOverrideValues[nextskuid][mindefaultstorename])
stru_pcd.ValueChain.add((skuid,
defaultstoreid))
S_pcd_set =
DscBuildData.OverrideByFdf(S_pcd_set,self.WorkspaceDir)
S_pcd_set = DscBuildData.OverrideByComm(S_pcd_set)
+
+ # Create a tool to caculate structure pcd value
Str_Pcd_Values = self.GenerateByteArrayValue(S_pcd_set)
+
if Str_Pcd_Values:
for (skuname, StoreName, PcdGuid, PcdName, PcdValue) in
Str_Pcd_Values:
str_pcd_obj = S_pcd_set.get((PcdName, PcdGuid))
if str_pcd_obj is None:
print(PcdName, PcdGuid)
@@ -1591,10 +1621,18 @@ class DscBuildData(PlatformBuildClassObject):

str_pcd_obj.SkuInfoList[skuname].DefaultStoreDict.update({StoreName:PcdV
alue})
elif str_pcd_obj.Type in
[self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_BUILD],

self._PCD_TYPE_STRING_[MODEL_PCD_PATCHABLE_IN_MODULE]]:
if skuname in (self.SkuIdMgr.SystemSkuId,
TAB_DEFAULT, TAB_COMMON):
str_pcd_obj.DefaultValue = PcdValue
+ else:
+ #Module Scope Structure Pcd
+ moduleguid = skuname.replace("S","-")
+ if
GlobalData.gGuidPattern.match(moduleguid):
+ for component in self.Modules.values():
+ if component.Guid == moduleguid:
+ component.Pcds[(PcdName,
PcdGuid)].DefaultValue = PcdValue
+
else:
if skuname not in str_pcd_obj.SkuInfoList:
nextskuid =
self.SkuIdMgr.GetNextSkuId(skuname)
NoDefault = False
while nextskuid not in str_pcd_obj.SkuInfoList:
@@ -2339,10 +2377,79 @@ class DscBuildData(PlatformBuildClassObject):
else:
CApp = CApp + ' Pcd->%s = %d; // From %s
Line %d Value %s\n' % (FieldName, Value, FieldList[FieldName][1],
FieldList[FieldName][2], FieldList[FieldName][0])
CApp = CApp + "}\n"
return CApp

+ def GenerateModuleScopeValue(self, Pcd):
+ CApp = "// Value in Dsc Module scope \n"
+ for ModuleGuid in Pcd.PcdFiledValueFromDscComponent:
+
+ CApp = CApp + "void Assign_%s_%s_%s_Value(%s *Pcd){\n" %
(Pcd.TokenSpaceGuidCName, Pcd.TokenCName,
ModuleGuid,Pcd.BaseDatumType)
+ CApp = CApp + ' UINT32 FieldSize;\n'
+ CApp = CApp + ' CHAR8 *Value;\n'
+ pcddefaultvalue, file_path,lineNo =
Pcd.PcdValueFromComponents.get(ModuleGuid,(None,None,None))
+
+ if pcddefaultvalue:
+ IsArray = _IsFieldValueAnArray(pcddefaultvalue)
+ if IsArray:
+ try:
+ FieldList = ValueExpressionEx(pcddefaultvalue,
TAB_VOID)(True)
+ except BadExpression:
+ EdkLogger.error("Build", FORMAT_INVALID,
"Invalid value format for %s.%s, from %s Line %s: %s" %
+
(Pcd.TokenSpaceGuidCName, Pcd.TokenCName, file_path, lineNo, FieldList))
+ Value, ValueSize = ParseFieldValue (FieldList)
+
+ if isinstance(Value, str):
+ CApp = CApp + ' Pcd = %s; // From %s Line %s \n' %
(Value, file_path, lineNo)
+ elif IsArray:
+ #
+ # Use memcpy() to copy value into field
+ #
+ CApp = CApp + ' Value = %s; // From %s
Line %s.\n' % (DscBuildData.IntToCString(Value, ValueSize), file_path,
lineNo)
+ CApp = CApp + ' memcpy (Pcd, Value, %d);\n' %
(ValueSize)
+
+
+ PcdFiledValue =
Pcd.PcdFiledValueFromDscComponent.get(ModuleGuid)
+ for index in PcdFiledValue:
+ FieldList = PcdFiledValue[index]
+ if not FieldList:
+ continue
+ for FieldName in FieldList:
+ IsArray =
_IsFieldValueAnArray(FieldList[FieldName][0])
+ if IsArray:
+ try:
+ FieldList[FieldName][0] =
ValueExpressionEx(FieldList[FieldName][0], TAB_VOID, self._GuidDict)(True)
+ except BadExpression:
+ EdkLogger.error('Build',
FORMAT_INVALID, "Invalid value format for %s. From %s Line %d " %
+
(".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldName)),
FieldList[FieldName][1], FieldList[FieldName][2]))
+ except:
+ print("error")
+ try:
+ Value, ValueSize = ParseFieldValue
(FieldList[FieldName][0])
+ except Exception:
+ EdkLogger.error('Build', FORMAT_INVALID,
"Invalid value format for %s. From %s Line %d " %
(".".join((Pcd.TokenSpaceGuidCName, Pcd.TokenCName, FieldName)),
FieldList[FieldName][1], FieldList[FieldName][2]))
+ if isinstance(Value, str):
+ CApp = CApp + ' Pcd->%s = %s; // From %s
Line %d Value %s\n' % (FieldName, Value, FieldList[FieldName][1],
FieldList[FieldName][2], FieldList[FieldName][0])
+ elif IsArray:
+ #
+ # Use memcpy() to copy value into field
+ #
+ CApp = CApp + ' FieldSize =
__FIELD_SIZE(%s, %s);\n' % (Pcd.BaseDatumType, FieldName)
+ CApp = CApp + ' Value = %s; //
From %s Line %d Value %s\n' % (DscBuildData.IntToCString(Value,
ValueSize),
FieldList[FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0])
+ CApp = CApp + '
__STATIC_ASSERT((__FIELD_SIZE(%s, %s) >= %d) || (__FIELD_SIZE(%s, %s) ==
0), "Input buffer exceeds the buffer array"); // From %s Line %d Value
%s\n' %
(Pcd.BaseDatumType, FieldName, ValueSize, Pcd.BaseDatumType, FieldName,
FieldList[FieldName][1], FieldList[FieldName][2], FieldList[FieldName][0])
+ CApp = CApp + ' memcpy (&Pcd->%s, Value,
(FieldSize > 0 && FieldSize < %d) ? FieldSize : %d);\n' % (FieldName,
ValueSize,
ValueSize)
+ else:
+ if '[' in FieldName and ']' in FieldName:
+ Index =
int(FieldName.split('[')[1].split(']')[0])
+ CApp = CApp + ' __STATIC_ASSERT((%d
< __ARRAY_SIZE(Pcd->%s)) || (__ARRAY_SIZE(Pcd->%s) == 0), "array index
exceeds the array number"); // From %s Line %d Index of %s\n' % (Index,
FieldName.split('[')[0], FieldName.split('[')[0], FieldList[FieldName][1],
FieldList[FieldName][2], FieldName)
+ if ValueSize > 4:
+ CApp = CApp + ' Pcd->%s = %dULL; //
From %s Line %d Value %s\n' % (FieldName, Value, FieldList[FieldName][1],
FieldList[FieldName][2], FieldList[FieldName][0])
+ else:
+ CApp = CApp + ' Pcd->%s = %d; //
From %s Line %d Value %s\n' % (FieldName, Value, FieldList[FieldName][1],
FieldList[FieldName][2], FieldList[FieldName][0])
+ CApp = CApp + "}\n"
+ return CApp
+
@staticmethod
def GenerateCommandLineValueStatement(Pcd):
CApp = ' Assign_%s_%s_CommandLine_Value(Pcd);\n' %
(Pcd.TokenSpaceGuidCName, Pcd.TokenCName)
return CApp
def GenerateFdfValue(self,Pcd):
@@ -2412,10 +2519,88 @@ class DscBuildData(PlatformBuildClassObject):
@staticmethod
def GenerateFdfValueStatement(Pcd):
CApp = ' Assign_%s_%s_Fdf_Value(Pcd);\n' %
(Pcd.TokenSpaceGuidCName, Pcd.TokenCName)
return CApp

+ @staticmethod
+ def GenerateModuleValueStatement(module_guid, Pcd):
+ CApp = " Assign_%s_%s_%s_Value(Pcd);\n" %
(Pcd.TokenSpaceGuidCName, Pcd.TokenCName, module_guid)
+ return CApp
+ def GenerateModuleScopeInitializeFunc(self,SkuName, Pcd,
InitByteValue, CApp):
+ for module_guid in Pcd.PcdFiledValueFromDscComponent:
+ CApp = CApp + 'void\n'
+ CApp = CApp + 'Initialize_%s_%s_%s_%s(\n' % (module_guid,
TAB_DEFAULT_STORES_DEFAULT, Pcd.TokenSpaceGuidCName,
Pcd.TokenCName)
+ CApp = CApp + ' void\n'
+ CApp = CApp + ' )\n'
+ CApp = CApp + '{\n'
+ CApp = CApp + ' UINT32 Size;\n'
+ CApp = CApp + ' UINT32 FieldSize;\n'
+ CApp = CApp + ' CHAR8 *Value;\n'
+ CApp = CApp + ' UINT32 OriginalSize;\n'
+ CApp = CApp + ' VOID *OriginalPcd;\n'
+
+ CApp = CApp + ' %s *Pcd; // From %s Line %d \n' %
(Pcd.BaseDatumType,Pcd.PkgPath, Pcd.PcdDefineLineNo)
+
+ CApp = CApp + '\n'
+
+ PcdDefaultValue =
StringToArray(Pcd.DefaultValueFromDec.strip())
+ InitByteValue += '%s.%s.%s.%s|%s|%s\n' % (module_guid,
TAB_DEFAULT_STORES_DEFAULT, Pcd.TokenSpaceGuidCName,
Pcd.TokenCName, Pcd.DatumType, PcdDefaultValue)
+ #
+ # Get current PCD value and size
+ #
+ CApp = CApp + ' OriginalPcd = PcdGetPtr (%s, %s, %s, %s,
&OriginalSize);\n' % (module_guid, TAB_DEFAULT_STORES_DEFAULT,
Pcd.TokenSpaceGuidCName, Pcd.TokenCName)
+
+ #
+ # Determine the size of the PCD. For simple structures,
sizeof(TYPE) provides
+ # the correct value. For structures with a flexible array
member, the flexible
+ # array member is detected, and the size is based on the
highest index used with
+ # the flexible array member. The flexible array member
must be the last field
+ # in a structure. The size formula for this case is:
+ # OFFSET_OF(FlexbleArrayField) + sizeof(FlexibleArray[0]) *
(HighestIndex + 1)
+ #
+ CApp = CApp +
DscBuildData.GenerateSizeStatments(Pcd,SkuName,TAB_DEFAULT_STORES_D
EFAULT)
+ if Pcd.IsArray() and Pcd.Capacity[-1] != "-1":
+ CApp = CApp + ' OriginalSize = OriginalSize < sizeof(%s)
* %d? OriginalSize:sizeof(%s) * %d; \n' %
(Pcd.BaseDatumType,Pcd.PcdArraySize(),Pcd.BaseDatumType,Pcd.PcdArraySiz
e())
+ CApp = CApp + ' Size = sizeof(%s) * %d; \n' %
(Pcd.BaseDatumType,Pcd.PcdArraySize())
+
+ #
+ # Allocate and zero buffer for the PCD
+ # Must handle cases where current value is smaller, larger,
or
same size
+ # Always keep that larger one as the current size
+ #
+ CApp = CApp + ' Size = (OriginalSize > Size ? OriginalSize :
Size);\n'
+ CApp = CApp + ' Pcd = (%s *)malloc (Size);\n' %
(Pcd.BaseDatumType,)
+ CApp = CApp + ' memset (Pcd, 0, Size);\n'
+
+ #
+ # Copy current PCD value into allocated buffer.
+ #
+ CApp = CApp + ' memcpy (Pcd, OriginalPcd, OriginalSize);\n'
+
+ #
+ # Assign field values in PCD
+ #
+ CApp = CApp +
DscBuildData.GenerateDefaultValueAssignStatement(Pcd)
+
+ CApp = CApp + "// SkuName: %s, DefaultStoreName:
STANDARD \n" % self.SkuIdMgr.SystemSkuId
+ CApp = CApp +
DscBuildData.GenerateInitValueStatement(Pcd, self.SkuIdMgr.SystemSkuId,
TAB_DEFAULT_STORES_DEFAULT)
+ CApp = CApp +
DscBuildData.GenerateFdfValueStatement(Pcd)
+ CApp = CApp +
DscBuildData.GenerateCommandLineValueStatement(Pcd)
+ CApp = CApp +
DscBuildData.GenerateModuleValueStatement(module_guid,Pcd)
+ #
+ # Set new PCD value and size
+ #
+ CApp = CApp + ' PcdSetPtr (%s, %s, %s, %s, Size, (void
*)Pcd);\n' % (module_guid, TAB_DEFAULT_STORES_DEFAULT,
Pcd.TokenSpaceGuidCName, Pcd.TokenCName)
+
+ #
+ # Free PCD
+ #
+ CApp = CApp + ' free (Pcd);\n'
+ CApp = CApp + '}\n'
+ CApp = CApp + '\n'
+ return InitByteValue,CApp
+
def GenerateInitializeFunc(self, SkuName, DefaultStore, Pcd,
InitByteValue, CApp):
OverrideValues = {DefaultStore:{}}
if Pcd.SkuOverrideValues:
OverrideValues = Pcd.SkuOverrideValues[SkuName]
if not OverrideValues:
@@ -2584,26 +2769,42 @@ class DscBuildData(PlatformBuildClassObject):
CApp = CApp + '\n'
for Pcd in StructuredPcds.values():
CApp = CApp + self.GenerateArrayAssignment(Pcd)
for PcdName in sorted(StructuredPcds.keys()):
Pcd = StructuredPcds[PcdName]
+
+ #create void void Cal_tocken_cname_Size functions
CApp = CApp + self.GenerateSizeFunction(Pcd)
+
+ #create void Assign_ functions
+
+ # From DEC
CApp = CApp + self.GenerateDefaultValueAssignFunction(Pcd)
+ # From Fdf
CApp = CApp + self.GenerateFdfValue(Pcd)
+ # From CommandLine
CApp = CApp + self.GenerateCommandLineValue(Pcd)
+
+ # From Dsc Global setting
if self.SkuOverrideValuesEmpty(Pcd.SkuOverrideValues) or
Pcd.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_BUILD],

self._PCD_TYPE_STRING_[MODEL_PCD_PATCHABLE_IN_MODULE]]:
CApp = CApp + self.GenerateInitValueFunction(Pcd,
self.SkuIdMgr.SystemSkuId, TAB_DEFAULT_STORES_DEFAULT)
else:
for SkuName in self.SkuIdMgr.SkuOverrideOrder():
if SkuName not in Pcd.SkuOverrideValues:
continue
for DefaultStoreName in
Pcd.SkuOverrideValues[SkuName]:
CApp = CApp +
self.GenerateInitValueFunction(Pcd, SkuName, DefaultStoreName)
+
+ # From Dsc module scope setting
+ CApp = CApp + self.GenerateModuleScopeValue(Pcd)
+
+ #create Initialize_ functions
if self.SkuOverrideValuesEmpty(Pcd.SkuOverrideValues) or
Pcd.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_BUILD],

self._PCD_TYPE_STRING_[MODEL_PCD_PATCHABLE_IN_MODULE]]:
InitByteValue, CApp =
self.GenerateInitializeFunc(self.SkuIdMgr.SystemSkuId,
TAB_DEFAULT_STORES_DEFAULT, Pcd, InitByteValue, CApp)
+ InitByteValue, CApp =
self.GenerateModuleScopeInitializeFunc(self.SkuIdMgr.SystemSkuId,Pcd,InitBy
teValue,CApp)
else:
for SkuName in self.SkuIdMgr.SkuOverrideOrder():
if SkuName not in Pcd.SkuOverrideValues:
continue
for DefaultStoreName in Pcd.DefaultStoreName:
@@ -2616,10 +2817,12 @@ class DscBuildData(PlatformBuildClassObject):
CApp = CApp + ' )\n'
CApp = CApp + '{\n'
for Pcd in StructuredPcds.values():
if self.SkuOverrideValuesEmpty(Pcd.SkuOverrideValues) or
Pcd.Type in [self._PCD_TYPE_STRING_[MODEL_PCD_FIXED_AT_BUILD],
self._PCD_TYPE_STRING_[MODEL_PCD_PATCHABLE_IN_MODULE]]:
CApp = CApp + ' Initialize_%s_%s_%s_%s();\n' %
(self.SkuIdMgr.SystemSkuId, TAB_DEFAULT_STORES_DEFAULT,
Pcd.TokenSpaceGuidCName, Pcd.TokenCName)
+ for ModuleGuid in
Pcd.PcdFiledValueFromDscComponent:
+ CApp += " Initialize_%s_%s_%s_%s();\n" %
(ModuleGuid,TAB_DEFAULT_STORES_DEFAULT ,Pcd.TokenSpaceGuidCName,
Pcd.TokenCName)
else:
for SkuName in self.SkuIdMgr.SkuOverrideOrder():
if SkuName not in self.SkuIdMgr.AvailableSkuIdSet:
continue
for DefaultStoreName in
Pcd.SkuOverrideValues[SkuName]:
@@ -2631,10 +2834,11 @@ class DscBuildData(PlatformBuildClassObject):
if not os.path.exists(self.OutputPath):
os.makedirs(self.OutputPath)
CAppBaseFileName = os.path.join(self.OutputPath,
PcdValueInitName)
SaveFileOnChange(CAppBaseFileName + '.c', CApp, False)

+ # start generating makefile
MakeApp = PcdMakefileHeader
if sys.platform == "win32":
MakeApp = MakeApp + 'APPFILE = %s\%s.exe\n' %
(self.OutputPath, PcdValueInitName) + 'APPNAME = %s\n' %
(PcdValueInitName) + 'OBJECTS = %s\%s.obj %s.obj\n' % (self.OutputPath,
PcdValueInitName, os.path.join(self.OutputPath, PcdValueCommonName)) +
'INC = '
else:
MakeApp = MakeApp + PcdGccMakefile
@@ -2753,19 +2957,22 @@ class DscBuildData(PlatformBuildClassObject):
MakeApp = MakeApp + '\tcp -f %s %s/PcdValueCommon.c\n' %
(PcdValueCommonPath, self.OutputPath)
MakeFileName = os.path.join(self.OutputPath, 'Makefile')
MakeApp += "$(OBJECTS) : %s\n" % MakeFileName
SaveFileOnChange(MakeFileName, MakeApp, False)

+ # start generating input file
InputValueFile = os.path.join(self.OutputPath, 'Input.txt')
OutputValueFile = os.path.join(self.OutputPath, 'Output.txt')
SaveFileOnChange(InputValueFile, InitByteValue, False)

Dest_PcdValueInitExe = PcdValueInitName
if not sys.platform == "win32":
Dest_PcdValueInitExe = os.path.join(self.OutputPath,
PcdValueInitName)
else:
Dest_PcdValueInitExe = os.path.join(self.OutputPath,
PcdValueInitName) +".exe"
+
+ #start building the structure pcd value tool
Messages = ''
if sys.platform == "win32":
MakeCommand = 'nmake -f %s' % (MakeFileName)
returncode, StdOut, StdErr = DscBuildData.ExecuteCommand
(MakeCommand)
Messages = StdOut
@@ -2824,17 +3031,19 @@ class DscBuildData(PlatformBuildClassObject):
if MessageGroup:
EdkLogger.error("build", PCD_STRUCTURE_PCD_ERROR,
"\n".join(MessageGroup) )
else:
EdkLogger.error('Build', COMMAND_FAILURE, 'Can not
execute command: %s\n%s\n%s' % (MakeCommand, StdOut, StdErr))

+ #start executing the structure pcd value tool
if DscBuildData.NeedUpdateOutput(OutputValueFile,
Dest_PcdValueInitExe, InputValueFile):
Command = Dest_PcdValueInitExe + ' -i %s -o %s' %
(InputValueFile, OutputValueFile)
returncode, StdOut, StdErr = DscBuildData.ExecuteCommand
(Command)
EdkLogger.verbose ('%s\n%s\n%s' % (Command, StdOut,
StdErr))
if returncode != 0:
EdkLogger.warn('Build', COMMAND_FAILURE, 'Can not
collect output from command: %s\n%s\n' % (Command, StdOut, StdErr))

+ #start update structure pcd final value
File = open (OutputValueFile, 'r')
FileBuffer = File.readlines()
File.close()

StructurePcdSet = []
diff --git a/BaseTools/Source/Python/build/BuildReport.py
b/BaseTools/Source/Python/build/BuildReport.py
index 8efa869162..d4de07cae2 100644
--- a/BaseTools/Source/Python/build/BuildReport.py
+++ b/BaseTools/Source/Python/build/BuildReport.py
@@ -694,11 +694,11 @@ class ModuleReport(object):
FileWrite(File, "PCI Class Code: %s" %
self.PciClassCode)

FileWrite(File, gSectionSep)

if "PCD" in ReportType:
- GlobalPcdReport.GenerateReport(File, self.ModulePcdSet)
+ GlobalPcdReport.GenerateReport(File,
self.ModulePcdSet,self.FileGuid)

if "LIBRARY" in ReportType:
self.LibraryReport.GenerateReport(File)

if "DEPEX" in ReportType:
@@ -879,11 +879,11 @@ class PcdReport(object):
for (TokenCName, TokenSpaceGuidCName) in
Pa.Platform.Pcds:
DscDefaultValue = Pa.Platform.Pcds[(TokenCName,
TokenSpaceGuidCName)].DscDefaultValue
if DscDefaultValue:
self.DscPcdDefault[(TokenCName,
TokenSpaceGuidCName)] = DscDefaultValue

- def GenerateReport(self, File, ModulePcdSet):
+ def GenerateReport(self, File, ModulePcdSet,module_guid=None):
if not ModulePcdSet:
if self.ConditionalPcds:
self.GenerateReportDetail(File, ModulePcdSet, 1)
if self.UnusedPcds:
IsEmpty = True
@@ -895,11 +895,11 @@ class PcdReport(object):
break
if not IsEmpty:
break
if not IsEmpty:
self.GenerateReportDetail(File, ModulePcdSet, 2)
- self.GenerateReportDetail(File, ModulePcdSet)
+ self.GenerateReportDetail(File, ModulePcdSet,module_guid =
module_guid)

##
# Generate report for PCD information
#
# This function generates report for separate module expression
@@ -911,11 +911,11 @@ class PcdReport(object):
# platform PCD report
# @param ReportySubType 0 means platform/module PCD report, 1
means Conditional
# directives section report, 2 means
Unused Pcds section report
# @param DscOverridePcds Module DSC override PCDs set
#
- def GenerateReportDetail(self, File, ModulePcdSet, ReportSubType =
0):
+ def GenerateReportDetail(self, File, ModulePcdSet, ReportSubType =
0,module_guid=None):
PcdDict = self.AllPcds
if ReportSubType == 1:
PcdDict = self.ConditionalPcds
elif ReportSubType == 2:
PcdDict = self.UnusedPcds
@@ -991,14 +991,16 @@ class PcdReport(object):
if DscDefaultValue:
PcdValue = DscDefaultValue
#The DefaultValue of StructurePcd already be the latest,
no need to update.
if not self.IsStructurePcd(Pcd.TokenCName,
Pcd.TokenSpaceGuidCName):
Pcd.DefaultValue = PcdValue
+ PcdComponentValue = None
if ModulePcdSet is not None:
if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName,
Type) not in ModulePcdSet:
continue
- InfDefaultValue, PcdValue =
ModulePcdSet[Pcd.TokenCName, Pcd.TokenSpaceGuidCName, Type]
+ InfDefaultValue, PcdComponentValue =
ModulePcdSet[Pcd.TokenCName, Pcd.TokenSpaceGuidCName, Type]
+ PcdValue = PcdComponentValue
#The DefaultValue of StructurePcd already be the
latest, no need to update.
if not self.IsStructurePcd(Pcd.TokenCName,
Pcd.TokenSpaceGuidCName):
Pcd.DefaultValue = PcdValue
if InfDefaultValue:
try:
@@ -1079,62 +1081,68 @@ class PcdReport(object):
if self.IsStructurePcd(Pcd.TokenCName,
Pcd.TokenSpaceGuidCName):
IsStructure = True
if TypeName in ('DYNVPD', 'DEXVPD'):
SkuInfoList = Pcd.SkuInfoList
Pcd =
GlobalData.gStructurePcd[self.Arch][(Pcd.TokenCName,
Pcd.TokenSpaceGuidCName)]
+ if ModulePcdSet and
ModulePcdSet.get((Pcd.TokenCName, Pcd.TokenSpaceGuidCName, Type)):
+ InfDefaultValue, PcdComponentValue =
ModulePcdSet[Pcd.TokenCName, Pcd.TokenSpaceGuidCName, Type]
+ DscDefaultValBak = Pcd.DefaultValue
+ Pcd.DefaultValue = PcdComponentValue
+
Pcd.DatumType = Pcd.StructName
if TypeName in ('DYNVPD', 'DEXVPD'):
Pcd.SkuInfoList = SkuInfoList
if Pcd.PcdValueFromComm or
Pcd.PcdFieldValueFromComm:
BuildOptionMatch = True
DecMatch = False
elif Pcd.PcdValueFromFdf or
Pcd.PcdFieldValueFromFdf:
DscDefaultValue = True
DscMatch = True
DecMatch = False
- elif Pcd.SkuOverrideValues:
- DscOverride = False
- if Pcd.DefaultFromDSC:
- DscOverride = True
- else:
- DictLen = 0
- for item in Pcd.SkuOverrideValues:
- DictLen +=
len(Pcd.SkuOverrideValues[item])
- if not DictLen:
- DscOverride = False
+ else:
+ if Pcd.Type in PCD_DYNAMIC_TYPE_SET |
PCD_DYNAMIC_EX_TYPE_SET:
+ DscOverride = False
+ if Pcd.DefaultFromDSC:
+ DscOverride = True
else:
- if not Pcd.SkuInfoList:
- OverrideValues =
Pcd.SkuOverrideValues
- if OverrideValues:
- for Data in
OverrideValues.values():
- Struct =
list(Data.values())
- if Struct:
- DscOverride =
self.ParseStruct(Struct[0])
- break
+ DictLen = 0
+ for item in Pcd.SkuOverrideValues:
+ DictLen +=
len(Pcd.SkuOverrideValues[item])
+ if not DictLen:
+ DscOverride = False
else:
- SkuList =
sorted(Pcd.SkuInfoList.keys())
- for Sku in SkuList:
- SkuInfo =
Pcd.SkuInfoList[Sku]
- if
SkuInfo.DefaultStoreDict:
- DefaultStoreList =
sorted(SkuInfo.DefaultStoreDict.keys())
- for DefaultStore in
DefaultStoreList:
- OverrideValues =
Pcd.SkuOverrideValues[Sku]
- DscOverride =
self.ParseStruct(OverrideValues[DefaultStore])
- if DscOverride:
+ if not Pcd.SkuInfoList:
+ OverrideValues =
Pcd.SkuOverrideValues
+ if OverrideValues:
+ for Data in
OverrideValues.values():
+ Struct =
list(Data.values())
+ if Struct:
+
DscOverride = self.ParseStruct(Struct[0])
break
- if DscOverride:
- break
- if DscOverride:
+ else:
+ SkuList =
sorted(Pcd.SkuInfoList.keys())
+ for Sku in SkuList:
+ SkuInfo =
Pcd.SkuInfoList[Sku]
+ if
SkuInfo.DefaultStoreDict:
+ DefaultStoreList
= sorted(SkuInfo.DefaultStoreDict.keys())
+ for DefaultStore
in DefaultStoreList:
+
OverrideValues = Pcd.SkuOverrideValues[Sku]
+
DscOverride = self.ParseStruct(OverrideValues[DefaultStore])
+ if
DscOverride:
+ break
+ if DscOverride:
+ break
+ if DscOverride:
+ DscDefaultValue = True
+ DscMatch = True
+ DecMatch = False
+ else:
+ DecMatch = True
+ else:
DscDefaultValue = True
DscMatch = True
DecMatch = False
- else:
- DecMatch = True
- else:
- DscDefaultValue = True
- DscMatch = True
- DecMatch = False

#
# Report PCD item according to their override
relationship
#
if Pcd.DatumType == 'BOOLEAN':
@@ -1151,17 +1159,18 @@ class PcdReport(object):
elif InfDefaultValue and InfMatch:
self.PrintPcdValue(File, Pcd, PcdTokenCName,
TypeName, IsStructure, DscMatch, DscDefaultValBak, InfMatch,
InfDefaultValue, DecMatch, DecDefaultValue, '*M')
elif BuildOptionMatch:
self.PrintPcdValue(File, Pcd, PcdTokenCName,
TypeName, IsStructure, DscMatch, DscDefaultValBak, InfMatch,
InfDefaultValue, DecMatch, DecDefaultValue, '*B')
else:
- if DscDefaultValue and DscMatch:
+ if PcdComponentValue:
+ self.PrintPcdValue(File, Pcd, PcdTokenCName,
TypeName, IsStructure, DscMatch, DscDefaultValBak, InfMatch,
PcdComponentValue, DecMatch, DecDefaultValue, '*M', module_guid)
+ elif DscDefaultValue and DscMatch:
if (Pcd.TokenCName, Key, Field) in
self.FdfPcdSet:
self.PrintPcdValue(File, Pcd,
PcdTokenCName, TypeName, IsStructure, DscMatch, DscDefaultValBak,
InfMatch, InfDefaultValue, DecMatch, DecDefaultValue, '*F')
else:
self.PrintPcdValue(File, Pcd,
PcdTokenCName, TypeName, IsStructure, DscMatch, DscDefaultValBak,
InfMatch, InfDefaultValue, DecMatch, DecDefaultValue, '*P')
- else:
- self.PrintPcdValue(File, Pcd, PcdTokenCName,
TypeName, IsStructure, DscMatch, DscDefaultValBak, InfMatch,
InfDefaultValue, DecMatch, DecDefaultValue, '*M')
+

if ModulePcdSet is None:
if IsStructure:
continue
if not TypeName in ('PATCH', 'FLAG', 'FIXED'):
@@ -1263,11 +1272,11 @@ class PcdReport(object):
self.PrintStructureInfo(File, filedvalues)
if DecMatch and IsStructure:
for filedvalues in Pcd.DefaultValues.values():
self.PrintStructureInfo(File, filedvalues)

- def PrintPcdValue(self, File, Pcd, PcdTokenCName, TypeName,
IsStructure, DscMatch, DscDefaultValue, InfMatch, InfDefaultValue,
DecMatch,
DecDefaultValue, Flag = ' '):
+ def PrintPcdValue(self, File, Pcd, PcdTokenCName, TypeName,
IsStructure, DscMatch, DscDefaultValue, InfMatch, InfDefaultValue,
DecMatch,
DecDefaultValue, Flag = ' ',module_guid=None):
if not Pcd.SkuInfoList:
Value = Pcd.DefaultValue
IsByteArray, ArrayList = ByteArrayForamt(Value)
if IsByteArray:
FileWrite(File, ' %-*s : %6s %10s = %s' % (self.MaxLen,
Flag + ' ' + PcdTokenCName, TypeName, '(' + Pcd.DatumType + ')', '{'))
@@ -1286,18 +1295,24 @@ class PcdReport(object):
FiledOverrideFlag = False
if (Pcd.TokenCName,Pcd.TokenSpaceGuidCName) in
GlobalData.gPcdSkuOverrides:
OverrideValues =
GlobalData.gPcdSkuOverrides[(Pcd.TokenCName,Pcd.TokenSpaceGuidCName)
]
else:
OverrideValues = Pcd.SkuOverrideValues
+ FieldOverrideValues = None
if OverrideValues:
for Data in OverrideValues.values():
Struct = list(Data.values())
if Struct:
- OverrideFieldStruct =
self.OverrideFieldValue(Pcd, Struct[0])
- self.PrintStructureInfo(File,
OverrideFieldStruct)
+ FieldOverrideValues = Struct[0]
FiledOverrideFlag = True
break
+ if Pcd.PcdFiledValueFromDscComponent and
module_guid and module_guid.replace("-","S") in
Pcd.PcdFiledValueFromDscComponent:
+ FieldOverrideValues =
Pcd.PcdFiledValueFromDscComponent[module_guid.replace("-","S")]
+ if FieldOverrideValues:
+ OverrideFieldStruct = self.OverrideFieldValue(Pcd,
FieldOverrideValues)
+ self.PrintStructureInfo(File, OverrideFieldStruct)
+
if not FiledOverrideFlag and
(Pcd.PcdFieldValueFromComm or Pcd.PcdFieldValueFromFdf):
OverrideFieldStruct = self.OverrideFieldValue(Pcd,
{})
self.PrintStructureInfo(File, OverrideFieldStruct)
self.PrintPcdDefault(File, Pcd, IsStructure, DscMatch,
DscDefaultValue, InfMatch, InfDefaultValue, DecMatch, DecDefaultValue)
else:
--
2.20.1.windows.1





Re: [PATCH] BaseTools: Limit command line length.

Bob Feng
 

Laszlo,

1) I try to provide more information.
This problem happens because of the commit SHA-1: 05217d210e8da37b47d0be58ec363f7af2fa1c18. This commit changes the compilation command from one command compiles one c file to one command compile multiple c files. That change reduces the compilation time for MSVC toolchain but it increases the length of one compilation command line. Since the build tool can autosave the FLAGS and INC to the response file if the command line length larger than --cmd-len, there is no problem for normal build usage.

But for the case in BZ2528, user append additional string to the compilation command, that is adding another tool to launch the compiler.
<path_to_other_tool>/tool.py <path_to_msvc>/cl.exe ...
So the it's easy to exceed the max length of command line and cause build failure.

This patch is to save the c files in another response file to make the compilation command shorter.

2) "--cmd-len" is still functional.

Thanks,
Bob

-----Original Message-----
From: Laszlo Ersek <lersek@redhat.com>
Sent: Tuesday, October 27, 2020 7:58 PM
To: devel@edk2.groups.io; Liang, MingyueX <mingyuex.liang@intel.com>
Cc: Feng, Bob C <bob.c.feng@intel.com>; Liming Gao <gaoliming@byosoft.com.cn>; Chen, Christine <yuwei.chen@intel.com>; Ard Biesheuvel (ARM address) <ard.biesheuvel@arm.com>
Subject: Re: [edk2-devel] [PATCH] BaseTools: Limit command line length.

(+Ard)

On 10/23/20 05:00, mliang2x wrote:
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2528

Currently, the command line is too long because the CL command is
followed by multiple C files.

Therefore, the number of C files
can be used to determine whether the command line needs to be written
to the file. If the number of C files is greater than one, the command
line is directly written to the file. On the contrary, whether to
write to the file is determined by whether the length of the command
line exceeds the limited length Documents.

Signed-off-by: Mingyue Liang <mingyuex.liang@intel.com>
Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Yuwei Chen <yuwei.chen@intel.com>
---
BaseTools/Source/Python/AutoGen/GenMake.py | 45 +++++++++++++++----
.../Source/Python/AutoGen/IncludesAutoGen.py | 13 +++++-
2 files changed, 49 insertions(+), 9 deletions(-)
(1) I've read both BZ#2528 (up to comment 13), and the above commit message too.

I still don't have the slightest idea what the problem is. Please clarify.

(2) How do this patch (and this issue) relate to the "--cmd-len" option?


The bugzilla ticket says the issue is related to MSVC, and that it was exposed by fixing BZ#1672 ("Enable multiple thread for MSVC compiler").
But, at least superficially, the diffstat and the patch body seem to be more generic. What I really care about is that the gcc command lines should not change. It's annoying to look at a build log and see references to "cc_resp" text files, rather than the actual command lines. My build scripts use "--cmd-len=65536" for that reason -- is this patch going to keep that functional?

Thanks,
Laszlo


diff --git a/BaseTools/Source/Python/AutoGen/GenMake.py
b/BaseTools/Source/Python/AutoGen/GenMake.py
index 0314d0ea34..0cb97dc18d 100755
--- a/BaseTools/Source/Python/AutoGen/GenMake.py
+++ b/BaseTools/Source/Python/AutoGen/GenMake.py
@@ -576,7 +576,8 @@ cleanlib:
EdkLogger.error("build", AUTOGEN_ERROR, "Nothing to build",
ExtraData="[%s]" % str(MyAgo))

- self.ProcessBuildTargetList()
+ self.ProcessBuildTargetList(MyAgo.OutputDir,ToolsDef)
+
self.ParserGenerateFfsCmd()

# Generate macros used to represent input files @@ -866,7
+867,6 @@ cleanlib:
else:
break
SingleCommandLength += len(Str)
-
if SingleCommandLength > GlobalData.gCommandMaxLength:
FlagDict[Tool]['Value'] = True

@@ -890,18 +890,18 @@ cleanlib:
break
else:
break
-
if self._AutoGenObject.ToolChainFamily == 'GCC':
RespDict[Key] = Value.replace('\\', '/')
else:
RespDict[Key] = Value
+
for Target in BuildTargets:
for i, SingleCommand in enumerate(BuildTargets[Target].Commands):
if FlagDict[Flag]['Macro'] in SingleCommand:
BuildTargets[Target].Commands[i] = SingleCommand.replace('$(INC)', '').replace(FlagDict[Flag]['Macro'], RespMacro)
return RespDict

- def ProcessBuildTargetList(self):
+ def ProcessBuildTargetList(self, RespFile, ToolsDef):
#
# Search dependency file list for each source file
#
@@ -1002,6 +1002,7 @@ cleanlib:
self.ObjTargetDict[T.Target.SubDir] = set()
self.ObjTargetDict[T.Target.SubDir].add(NewFile)
for Type in self._AutoGenObject.Targets:
+ resp_file_number = 0
for T in self._AutoGenObject.Targets[Type]:
# Generate related macros if needed
if T.GenFileListMacro and T.FileListMacro not in self.FileListMacros:
@@ -1043,7 +1044,8 @@ cleanlib:
Deps.append("$(%s)" % T.ListFileMacro)

if self._AutoGenObject.BuildRuleFamily == TAB_COMPILER_MSFT and Type == TAB_C_CODE_FILE:
- T, CmdTarget, CmdTargetDict, CmdCppDict = self.ParserCCodeFile(T, Type, CmdSumDict, CmdTargetDict, CmdCppDict, DependencyDict)
+ T, CmdTarget, CmdTargetDict, CmdCppDict = self.ParserCCodeFile(T, Type, CmdSumDict, CmdTargetDict, CmdCppDict, DependencyDict, RespFile, ToolsDef, resp_file_number)
+ resp_file_number += 1
TargetDict = {"target": self.PlaceMacro(T.Target.Path, self.Macros), "cmd": "\n\t".join(T.Commands),"deps": CCodeDeps}
CmdLine = self._BUILD_TARGET_TEMPLATE.Replace(TargetDict).rstrip().replace('\t$(OBJLIST', '$(OBJLIST')
if T.Commands:
@@ -1060,7 +1062,7 @@ cleanlib:
AnnexeTargetDict = {"target": self.PlaceMacro(i.Path, self.Macros), "cmd": "", "deps": self.PlaceMacro(T.Target.Path, self.Macros)}

self.BuildTargetList.append(self._BUILD_TARGET_TEMPLATE.Replace(Annexe
TargetDict))

- def ParserCCodeFile(self, T, Type, CmdSumDict, CmdTargetDict, CmdCppDict, DependencyDict):
+ def ParserCCodeFile(self, T, Type, CmdSumDict, CmdTargetDict, CmdCppDict, DependencyDict, RespFile, ToolsDef, resp_file_number):
if not CmdSumDict:
for item in self._AutoGenObject.Targets[Type]:
CmdSumDict[item.Target.SubDir] = item.Target.BaseName
@@ -1080,6 +1082,7 @@ cleanlib:
CmdCppDict[item.Target.SubDir].append(Path)
if T.Commands:
CommandList = T.Commands[:]
+ SaveFilePath = os.path.join(RespFile, "cc_resp_%s.txt" %
+ resp_file_number)
for Item in CommandList[:]:
SingleCommandList = Item.split()
if len(SingleCommandList) > 0 and self.CheckCCCmd(SingleCommandList):
@@ -1087,19 +1090,45 @@ cleanlib:
if Temp.startswith('/Fo'):
CmdSign = '%s%s' % (Temp.rsplit(TAB_SLASH, 1)[0], TAB_SLASH)
break
- else: continue
+ else:
+ continue
if CmdSign not in list(CmdTargetDict.keys()):
CmdTargetDict[CmdSign] = Item.replace(Temp, CmdSign)
else:
CmdTargetDict[CmdSign] = "%s %s" %
(CmdTargetDict[CmdSign], SingleCommandList[-1])
+
Index = CommandList.index(Item)
CommandList.pop(Index)
if SingleCommandList[-1].endswith("%s%s.c" % (TAB_SLASH, CmdSumDict[CmdSign[3:].rsplit(TAB_SLASH, 1)[0]])):
Cpplist = CmdCppDict[T.Target.SubDir]
Cpplist.insert(0, '$(OBJLIST_%d): ' % list(self.ObjTargetDict.keys()).index(T.Target.SubDir))
- T.Commands[Index] = '%s\n\t%s' % (' \\\n\t'.join(Cpplist), CmdTargetDict[CmdSign])
+ cmdtargetlist = CmdTargetDict[CmdSign].split(" ")
+ # get Source files and Save resp file.
+ c_files = []
+ cmds = []
+ if cmdtargetlist:
+ for item in cmdtargetlist:
+ if item.startswith('$(') or item.startswith('/Fo') or item.startswith('"$('):
+ cmds.append(item)
+ if item.endswith('.c'):
+ c_files.append(item)
+ c_files.insert(0, " ")
+ if len(c_files) > 2:
+ SaveFileOnChange(SaveFilePath," ".join(c_files), False)
+ T.Commands[Index] = '%s\n\t%s $(cc_resp_%s)' % (' \\\n\t'.join(Cpplist), " ".join(cmds), resp_file_number)
+ ToolsDef.append("cc_resp_%s = @%s" %
+ (resp_file_number, SaveFilePath))
+
+ elif len(CmdTargetDict[CmdSign]) > GlobalData.gCommandMaxLength and len(c_files) <=2:
+ SaveFileOnChange(SaveFilePath, " ".join(c_files), False)
+ T.Commands[Index] = '%s\n\t%s $(cc_resp_%s)' % (' \\\n\t'.join(Cpplist), " ".join(cmds), resp_file_number)
+ ToolsDef.append("cc_resp_%s = @%s" %
+ (resp_file_number, SaveFilePath))
+
+ else:
+ T.Commands[Index] = '%s\n\t%s' % ('
+ \\\n\t'.join(Cpplist), CmdTargetDict[CmdSign])
+
else:
T.Commands.pop(Index)
+
return T, CmdSumDict, CmdTargetDict, CmdCppDict

def CheckCCCmd(self, CommandList):
diff --git a/BaseTools/Source/Python/AutoGen/IncludesAutoGen.py
b/BaseTools/Source/Python/AutoGen/IncludesAutoGen.py
index 720d93395a..9f61d49b3a 100644
--- a/BaseTools/Source/Python/AutoGen/IncludesAutoGen.py
+++ b/BaseTools/Source/Python/AutoGen/IncludesAutoGen.py
@@ -203,7 +203,18 @@ ${END}
cc_options = line[len(cc_cmd)+2:].split()
else:
cc_options = line[len(cc_cmd):].split()
- SourceFileAbsPathMap = {os.path.basename(item):item for item in cc_options if not item.startswith("/") and os.path.exists(item)}
+
+ for item in cc_options:
+ if not item.startswith("/"):
+ # if item.startswith("@"):
+ if item.endswith(".txt") and item.startswith("@"):
+ with open(item[1:], "r") as file:
+ source_files = file.readlines()[0].split()
+ SourceFileAbsPathMap = {os.path.basename(file):file for file in source_files if os.path.exists(file)}
+ else:
+ if os.path.exists(item):
+
+ SourceFileAbsPathMap.update({os.path.basename(item): item.strip()})
+
if line in SourceFileAbsPathMap:
current_source = line
if current_source not in ModuleDepDict:


Re: Overriding of linker in ed2 build system

Prabin CA
 

Hi Andrew,

I had edited tools_def.txt file with following changes  (shown diff below)

##################

 # CLANG38 AARCH64 definitions

 ##################

-DEFINE CLANG38_AARCH64_TARGET    = -target aarch64-linux-gnu

+DEFINE CLANG38_AARCH64_TARGET    = -target aarch64-poky-linux

 DEFINE CLANG38_AARCH64_CC_FLAGS  = DEF(GCC_AARCH64_CC_FLAGS) DEF(CLANG38_AARCH64_TARGET) -mcmodel=small DEF(CLANG38_WARNING_OVERRIDES)

 DEFINE CLANG38_AARCH64_DLINK_FLAGS  = DEF(CLANG38_AARCH64_TARGET) DEF(GCC_AARCH64_DLINK_FLAGS) -z common-page-size=0x1000

 

@@ -2767,7 +2767,7 @@ DEFINE CLANG38_AARCH64_DLINK_FLAGS  = DEF(CLANG38_AARCH64_TARGET) DEF(GCC_AARCH6

 *_CLANG38_AARCH64_ASLCC_FLAGS    = DEF(GCC_ASLCC_FLAGS) -fno-lto

 *_CLANG38_AARCH64_ASLDLINK_FLAGS = DEF(CLANG38_AARCH64_TARGET) DEF(GCC_AARCH64_ASLDLINK_FLAGS)

 *_CLANG38_AARCH64_ASM_FLAGS      = DEF(GCC_ASM_FLAGS) DEF(CLANG38_AARCH64_TARGET) $(ARCHASM_FLAGS) $(PLATFORM_FLAGS) -Qunused-arguments

-*_CLANG38_AARCH64_DLINK_FLAGS    = DEF(CLANG38_AARCH64_TARGET) DEF(GCC_AARCH64_DLINK_FLAGS) -z common-page-size=0x1000

+*_CLANG38_AARCH64_DLINK_FLAGS    = DEF(CLANG38_AARCH64_TARGET) DEF(GCC_AARCH64_DLINK_FLAGS) -z common-page-size=0x1000 -fuse-ld=lld

 *_CLANG38_AARCH64_DLINK_XIPFLAGS = -z common-page-size=0x20

 *_CLANG38_AARCH64_DLINK2_FLAGS   = DEF(GCC_DLINK2_FLAGS_COMMON) -Wl,--defsym=PECOFF_HEADER_SIZE=0x228

 

 *_CLANG38_AARCH64_PLATFORM_FLAGS =

Please validate the changes first, now its picking LD from aarch64-poky-linux-ld, But the changes made to DLINK_FLAGS to take LD (-fuse-ld=lld) from clang is not making any effects. Can you suggest if anything I had missed or done in wrong.

Thanks 


回复: [Patch] MdeModulePkg/Core: Support standalone MM in FV2 protocol GetNextFile().

gaoliming
 

Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>

-----邮件原件-----
发件人: Siyuan Fu <siyuan.fu@intel.com>
发送时间: 2020年10月28日 10:57
收件人: devel@edk2.groups.io
抄送: Dandan Bi <dandan.bi@intel.com>; Liming Gao
<gaoliming@byosoft.com.cn>
主题: [Patch] MdeModulePkg/Core: Support standalone MM in FV2 protocol
GetNextFile().

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

The FirmwareVolume2Protocol->GetNextFile() produced by DXE Core can be
used
to search for a file based on the value of *FileType input. However, this
service will always return EFI_NOT_FOUND if the input FileType is set to
EFI_FV_FILETYPE_MM_STANDALONE or
EFI_FV_FILETYPE_MM_CORE_STANDALONE, Which
means user can't use this service to search any standalone MM image in
that
FV.
This patch update the FirmwareVolume2Protocol->GetNextFile() service to
support searching standalone MM module.

Signed-off-by: Siyuan Fu <siyuan.fu@intel.com>
Cc: Dandan Bi <dandan.bi@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
---
MdeModulePkg/Core/Dxe/FwVol/FwVolRead.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/MdeModulePkg/Core/Dxe/FwVol/FwVolRead.c
b/MdeModulePkg/Core/Dxe/FwVol/FwVolRead.c
index 2861cbf676..8dcbbeb5ee 100644
--- a/MdeModulePkg/Core/Dxe/FwVol/FwVolRead.c
+++ b/MdeModulePkg/Core/Dxe/FwVol/FwVolRead.c
@@ -1,7 +1,7 @@
/** @file
Implements functions to read firmware file

-Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2020, Intel Corporation. All rights reserved.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent

**/
@@ -143,9 +143,9 @@ FvGetNextFile (
return EFI_ACCESS_DENIED;
}

- if (*FileType > EFI_FV_FILETYPE_SMM_CORE) {
+ if (*FileType > EFI_FV_FILETYPE_MM_CORE_STANDALONE) {
//
- // File type needs to be in 0 - 0x0D
+ // File type needs to be in 0 - 0x0F
//
return EFI_NOT_FOUND;
}
--
2.19.1.windows.1


回复: [edk2-devel] [PATCH v2] MdeModulePkg/Gcd: Check memory allocation when initializing memory

gaoliming
 

Jeff:
The logic is correct. It handles the memory allocated by creating memory
allocation hob instead of allocating page service.

I add minor comment on below.

-----邮件原件-----
发件人: bounce+27952+66661+4905953+8761045@groups.io
<bounce+27952+66661+4905953+8761045@groups.io> 代表 Jeff Brasen
发送时间: 2020年10月27日 23:53
收件人: devel@edk2.groups.io
抄送: dandan.bi@intel.com; gaoliming@byosoft.com.cn; lersek@redhat.com;
Jeff Brasen <jbrasen@nvidia.com>
主题: [edk2-devel] [PATCH v2] MdeModulePkg/Gcd: Check memory
allocation when initializing memory

CoreInitializeMemoryServices was not checking for any existing memory
allocation created in the HOB producer phase. If there are memory
allocations outside of the region covered by the HOB List then Gcd could
select that region for memory which can result in the memory allocation
to not be handled and memory overwrites.

Signed-off-by: Jeff Brasen <jbrasen@nvidia.com>
---
MdeModulePkg/Core/Dxe/Gcd/Gcd.c | 60
+++++++++++++++++++++++++++++++++
1 file changed, 60 insertions(+)

diff --git a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c
b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c
index 2d8c076f7113..4a22ee96b758 100644
--- a/MdeModulePkg/Core/Dxe/Gcd/Gcd.c
+++ b/MdeModulePkg/Core/Dxe/Gcd/Gcd.c
@@ -2097,6 +2097,62 @@ CalculateTotalMemoryBinSizeNeeded (
return TotalSize;
}

+/**
+ Find the largest region in the specified region that is not covered by
an
existing memory allocation
+
+ @param BaseAddress On input start of the region to check.
+ On output start of the largest free region.
+ @param Length On input size of region to check.
+ On output size of the largest free region.
+ @param MemoryHob Hob pointer for the first memory allocation
pointer to check
+**/
+VOID
+FindLargestFreeRegion (
+ IN OUT EFI_PHYSICAL_ADDRESS *BaseAddress,
+ IN OUT UINT64 *Length,
+ IN EFI_HOB_MEMORY_ALLOCATION *MemoryHob
+ )
+{
+ EFI_PHYSICAL_ADDRESS TopAddress;
+
+ TopAddress = *BaseAddress + *Length;
+ while (MemoryHob != NULL) {
+ EFI_PHYSICAL_ADDRESS AllocatedTop;
+
Please move local variable declaration in the begin of the function.

+ AllocatedTop = MemoryHob->AllocDescriptor.MemoryBaseAddress +
MemoryHob->AllocDescriptor.MemoryLength;
+
+ if ((MemoryHob->AllocDescriptor.MemoryBaseAddress >=
*BaseAddress) &&
+ (AllocatedTop <= TopAddress)) {
+ EFI_PHYSICAL_ADDRESS LowerBase;
+ UINT64 LowerSize;
+ EFI_PHYSICAL_ADDRESS UpperBase;
+ UINT64 UpperSize;
+
Please move local variable declaration in the begin of the function.

With this change, Liming Gao <gaoliming@byosoft.com.cn>

Thanks
Liming
+ LowerBase = *BaseAddress;
+ LowerSize = MemoryHob->AllocDescriptor.MemoryBaseAddress -
*BaseAddress;
+ UpperBase = AllocatedTop;
+ UpperSize = TopAddress - AllocatedTop;
+
+ if (LowerSize != 0) {
+ FindLargestFreeRegion (&LowerBase, &LowerSize,
(EFI_HOB_MEMORY_ALLOCATION *) GetNextHob
(EFI_HOB_TYPE_MEMORY_ALLOCATION, GET_NEXT_HOB (MemoryHob)));
+ }
+ if (UpperSize != 0) {
+ FindLargestFreeRegion (&UpperBase, &UpperSize,
(EFI_HOB_MEMORY_ALLOCATION *) GetNextHob
(EFI_HOB_TYPE_MEMORY_ALLOCATION, GET_NEXT_HOB (MemoryHob)));
+ }
+
+ if (UpperSize >= LowerSize) {
+ *Length = UpperSize;
+ *BaseAddress = UpperBase;
+ } else {
+ *Length = LowerSize;
+ *BaseAddress = LowerBase;
+ }
+ return;
+ }
+ MemoryHob = GetNextHob (EFI_HOB_TYPE_MEMORY_ALLOCATION,
GET_NEXT_HOB (MemoryHob));
+ }
+}
+
/**
External function. Initializes memory services based on the memory
descriptor HOBs. This function is responsible for priming the memory
@@ -2235,6 +2291,7 @@ CoreInitializeMemoryServices (
Attributes = PhitResourceHob->ResourceAttribute;
BaseAddress = PageAlignAddress (PhitHob->EfiMemoryTop);
Length = PageAlignLength (ResourceHob->PhysicalStart +
ResourceHob->ResourceLength - BaseAddress);
+ FindLargestFreeRegion (&BaseAddress, &Length,
(EFI_HOB_MEMORY_ALLOCATION *)GetFirstHob
(EFI_HOB_TYPE_MEMORY_ALLOCATION));
if (Length < MinimalMemorySizeNeeded) {
//
// If that range is not large enough to intialize the DXE Core,
then
@@ -2242,6 +2299,7 @@ CoreInitializeMemoryServices (
//
BaseAddress = PageAlignAddress (PhitHob->EfiFreeMemoryBottom);
Length = PageAlignLength (PhitHob->EfiFreeMemoryTop -
BaseAddress);
+ //This region is required to have no memory allocation inside it,
skip
check for entries in HOB List
if (Length < MinimalMemorySizeNeeded) {
//
// If that range is not large enough to intialize the DXE Core,
then
@@ -2249,6 +2307,7 @@ CoreInitializeMemoryServices (
//
BaseAddress = PageAlignAddress (ResourceHob->PhysicalStart);
Length = PageAlignLength ((UINT64)((UINTN)*HobStart -
BaseAddress));
+ FindLargestFreeRegion (&BaseAddress, &Length,
(EFI_HOB_MEMORY_ALLOCATION *)GetFirstHob
(EFI_HOB_TYPE_MEMORY_ALLOCATION));
}
}
break;
@@ -2312,6 +2371,7 @@ CoreInitializeMemoryServices (
//
TestedMemoryBaseAddress = PageAlignAddress
(ResourceHob->PhysicalStart);
TestedMemoryLength = PageAlignLength
(ResourceHob->PhysicalStart + ResourceHob->ResourceLength -
TestedMemoryBaseAddress);
+ FindLargestFreeRegion (&TestedMemoryBaseAddress,
&TestedMemoryLength, (EFI_HOB_MEMORY_ALLOCATION *)GetFirstHob
(EFI_HOB_TYPE_MEMORY_ALLOCATION));
if (TestedMemoryLength < MinimalMemorySizeNeeded) {
continue;
}
--
2.25.1





[PATCH] BaseTools: Update the FV Space Information to display decimal and Hex

fengyunhua
 

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

Update the FV Space Information to display decimal and Hex

FV Space Information
before format:
SECFV [13%Full] 212992 total, 28400 used, 184592 free
Updated format:
SECFV [13%Full] 0x34000 (212992) total, 0x6ef0 (28400) used,
0x2d110 (184592) free

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Yuwei Chen <yuwei.chen@intel.com>
Signed-off-by: Yunhua Feng <fengyunhua@byosoft.com.cn>
---
BaseTools/Source/Python/GenFds/GenFds.py | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/BaseTools/Source/Python/GenFds/GenFds.py b/BaseTools/Source/Python/GenFds/GenFds.py
index d5511f4c40..76a6d0d1d0 100644
--- a/BaseTools/Source/Python/GenFds/GenFds.py
+++ b/BaseTools/Source/Python/GenFds/GenFds.py
@@ -633,7 +633,10 @@ class GenFds(object):
else:
Percentage = str((UsedSizeValue + 0.0) / TotalSizeValue)[0:4].lstrip('0.')

- GenFdsGlobalVariable.InfLogger(Name + ' ' + '[' + Percentage + '%Full] ' + str(TotalSizeValue) + ' total, ' + str(UsedSizeValue) + ' used, ' + str(FreeSizeValue) + ' free')
+ GenFdsGlobalVariable.InfLogger(Name + ' ' + '[' + Percentage + '%Full] '\
+ + hex(TotalSizeValue) + ' (' + str(TotalSizeValue) + ')' + ' total, '\
+ + hex(UsedSizeValue) + ' (' + str(UsedSizeValue) + ')' + ' used, '\
+ + hex(FreeSizeValue) + ' (' + str(FreeSizeValue) + ')' + ' free')

## PreprocessImage()
#
--
2.27.0.windows.1


回复: [edk2-devel] [PATCH v6 0/6] Extend Last Attempt Status Usage

gaoliming
 

Create PR https://github.com/tianocore/edk2/pull/1054 for this patch set.

-----邮件原件-----
发件人: Kinney, Michael D <michael.d.kinney@intel.com>
发送时间: 2020年10月20日 8:16
收件人: devel@edk2.groups.io; michael.kubacki@outlook.com; Kinney,
Michael D <michael.d.kinney@intel.com>
抄送: Liming Gao <gaoliming@byosoft.com.cn>; Jiang, Guomin
<guomin.jiang@intel.com>; Xu, Wei6 <wei6.xu@intel.com>; Liu, Zhiguang
<zhiguang.liu@intel.com>
主题: RE: [edk2-devel] [PATCH v6 0/6] Extend Last Attempt Status Usage

Series Reviewed-by: Michael D Kinney <michael.d.kinney@intel.com>


-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Michael
Kubacki
Sent: Monday, October 19, 2020 5:00 PM
To: devel@edk2.groups.io
Cc: Liming Gao <gaoliming@byosoft.com.cn>; Kinney, Michael D
<michael.d.kinney@intel.com>; Jiang, Guomin
<guomin.jiang@intel.com>; Xu, Wei6 <wei6.xu@intel.com>; Liu, Zhiguang
<zhiguang.liu@intel.com>
Subject: [edk2-devel] [PATCH v6 0/6] Extend Last Attempt Status Usage

From: Michael Kubacki <michael.kubacki@microsoft.com>

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

This patch series adds more granularity to Last Attempt Status
codes reported during FMP check image and set image operations
that greatly improve precision of the status codes.

The unsuccessful vendor range (0x1000 - 0x4000) was introduced
in UEFI Specification 2.8. At a high-level, two subranges are
defined within that range in this patch series:
1. The FMP Reserved range - reserved for components implemented
in FmpDevicePkg.
2. The FMP Device Library Reserved range - reserved for
FmpDeviceLib instance-specific usage.

The ranges are described in a public header file LastAttemptStatus.h
while the specific codes used within FmpDevicePkg implementation
are defined in a private header file FmpLastAttemptStatus.h.

FmpDeviceLib instances should use the range definition from the
public header file to define Last Attempt Status codes local to
their library instance.

Of note, there's multiple approaches to assigning private status
codes in the FMP Reserved range. For example, individual components
could define their last attempt status codes locally with the
range allocated to the component defined in a package-wide private
header file. However, one goal of the granularity being introduced
is to provide straightforward traceability to an error source.

For that reason, it was chosen to define a constant set of codes at
the package level in FmpLastAttemptStatus.h. For example, if a new
FmpDependencyLib instance is added, it would not be able to reassign
status code values in the pre-existing FMP Dependency range; it
would reuse codes for the same error source and be able to add new
codes onto the range for its usage.

V6 changes:
1. FmpDevicePkg/Library/FmpDeviceLibNull
* Updated FmpDeviceCheckImage() and FmpDeviceSetImage() to call
FmpDeviceCheckImageWithStatus() and
FmpDeviceSetImageWithStatus() respectively.

This is to clearly demonstrate to FmpDeviceLib implementors
that only the *WithStatus() versions need to be implemented.

2. FmpDevicePkg/PrivateInclude/FmpLastAttemptStatus.h
* Updated the block comment above the
FmpDependencyCheckLib definitions to use /// instead of //
to be consistent with the rest of the file.

V5 changes:
1. Fixed an issue where
LAST_ATTEMPT_STATUS_DRIVER_ERROR_INVALID_CERTIFICATE is
changed
to LAST_ATTEMPT_STATUS_DRIVER_ERROR_IMAGE_AUTH_FAILURE
in the
logic to return the last attempt status code in
CheckTheImageInternal().

V4 changes:
1. Simplified range value definitions in LastAttemptStatus.h.
Directly assign the values in the macro definition instead
of using calculations.
2. Adjusted range sizes to leave more room for future expansion.

OLD:
START | END | Usage
------------------------------------------------|
0x1000 | 0x1FFF | FmpDevicePkg |
0x1000 | 0x107F | FmpDxe driver |
0x1080 | 0x109F | FMP dependency Libs |
0x2000 | 0x3FFF | FmpDeviceLib instances |

NEW:
START | END | Usage
----------------------------------------------------------------|
0x1000 | 0x17FF | FmpDevicePkg
|
0x1000 | 0x107F | FmpDxe driver
|
0x1080 | 0x109F | FmpDependencyLib
|
0x10A0 | 0x10BF | FmpDependencyCheckLib
|
0x10C0 | 0x17FF | Unused. Available for future expansion. |
0x1800 | 0x1FFF | FmpDeviceLib instances implementation
|
0x2000 | 0x3FFF | Unused. Available for future expansion. |

3. Broke the single range in v3 for FMP Dependency libraries into
separate ranges.
4. Clarified LastAttemptStatus return values in each function
description.
5. Returned an expected LastAttemptStatus value for some functions
that previously did not return a value.
6. Reverted changes in FmpDxe to call the new FmpDeviceLib APIs
for FmpDeviceCheckImage () and FmpDeviceSetImage (). These will
be added in a future series after impacted platforms in
edk2-platforms are updated to use the new APIs.
7. Instead of directly changing the pre-existing APIs in
FmpDeviceLib to add a LastAttemptStatus parameter, the new
functions were added to the library interface:
* FmpDeviceCheckImageWithStatus ()
* FmpDeviceSetImageWithStatus ()

V3 changes:
1. Enhanced range definitions in LastAttemptStatus.h with more
completeness providing length, min, and max values.
2. Moved the actual Last Attempt Status code assignments to a
private header file PrivateInclude/FmpLastAttemptStatus.h.
3. Changed the value of
LAST_ATTEMPT_STATUS_ERROR_UNSUCCESSFUL_VENDOR_RANGE_MAX
to 0x3FFF instead of 0x4000 even though 0x4000 is defined in
the UEFI specification. The length is 0x4000 but the max
allowed value should be 0x3FFF. This change was made now to
prevent implementation compatibility issues in the future.
4. Included "DEVICE" in the following macro name to clearly
associate it with the FmpDeviceLib library class:
LAST_ATTEMPT_STATUS_DEVICE_LIBRARY_ERROR_xxx
5. Included a map to help the reader better visualize the range
definitions in LastAttemptStatus.h.
6. Included additional documentation describing the enum in
FmpLastAttemptStatus.h. An explicit statement stating that new
codes should be added onto the end of ranges to preserve the
values was added.
7. Simplified error handling logic in FmpDxe for FmpDeviceLib
calls that return Last Attempt Status.
8. V2 had a single memory allocation failure code used for
different memory allocations in CheckFmpDependency () in
FmpDependencyLib. Each potential allocation failure was
assigned a unique code.

V2 changes:
1. Consolidate all previous incremental updates to
LastAttemptStatus.h into one patch (patch 2)
2. Move LastAttemptStatus.h from Include to PrivateInclude
3. Correct patch 1 subject from "FmpDevicePkg" to "MdePkg"

Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Guomin Jiang <guomin.jiang@intel.com>
Cc: Wei6 Xu <wei6.xu@intel.com>
Cc: Zhiguang Liu <zhiguang.liu@intel.com>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>

Michael Kubacki (6):
MdePkg/SystemResourceTable.h: Add vendor range values
FmpDevicePkg: Add Last Attempt Status header files
FmpDevicePkg/FmpDxe: Add check image path Last Attempt Status
capability
FmpDevicePkg/FmpDxe: Improve set image path Last Attempt Status
granularity
FmpDevicePkg: Add Last Attempt Status support to dependency libs
FmpDevicePkg/FmpDeviceLib: Add Last Attempt Status to Check/Set API

FmpDevicePkg/FmpDxe/FmpDxe.c
| 146 +++++++++++++++++---
FmpDevicePkg/Library/FmpDependencyCheckLib/FmpDependencyCheckLib.
c | 39 ++++--
FmpDevicePkg/Library/FmpDependencyCheckLibNull/FmpDependencyCheck
LibNull.c | 14 +-
FmpDevicePkg/Library/FmpDependencyLib/FmpDependencyLib.c
| 93 +++++++++++--
FmpDevicePkg/Library/FmpDeviceLibNull/FmpDeviceLib.c
| 144 ++++++++++++++++++-
FmpDevicePkg/Test/UnitTest/Library/FmpDependencyLib/EvaluateDependen
cyUnitTest.c | 7 +-
FmpDevicePkg/FmpDxe/FmpDxe.h
| 4 +-
FmpDevicePkg/Include/LastAttemptStatus.h
| 81 +++++++++++
FmpDevicePkg/Include/Library/FmpDependencyCheckLib.h
| 8 +-
FmpDevicePkg/Include/Library/FmpDependencyLib.h
| 44 ++++--
FmpDevicePkg/Include/Library/FmpDeviceLib.h
| 121 +++++++++++++++-
FmpDevicePkg/PrivateInclude/FmpLastAttemptStatus.h
| 81 +++++++++++
MdePkg/Include/Guid/SystemResourceTable.h
| 13 ++
13 files changed, 730 insertions(+), 65 deletions(-)
create mode 100644 FmpDevicePkg/Include/LastAttemptStatus.h
create mode 100644
FmpDevicePkg/PrivateInclude/FmpLastAttemptStatus.h

--
2.28.0.windows.1





回复: [edk2-devel] 回复: [edk2-platforms][PATCH v1 1/1] .gitignore: Match contents to edk2

gaoliming
 

Michael:
If no real usage case, I don't suggest to add Build into . gitignore.

Thanks
Liming

-----邮件原件-----
发件人: bounce+27952+66673+4905953+8761045@groups.io
<bounce+27952+66673+4905953+8761045@groups.io> 代表 Michael
Kubacki
发送时间: 2020年10月28日 7:02
收件人: gaoliming <gaoliming@byosoft.com.cn>; devel@edk2.groups.io
抄送: 'Leif Lindholm' <leif@nuviainc.com>; 'Michael D Kinney'
<michael.d.kinney@intel.com>; 'Ard Biesheuvel' <ard.biesheuvel@arm.com>
主题: Re: [edk2-devel] 回复: [edk2-platforms][PATCH v1 1/1] .gitignore:
Match contents to edk2

Hi Liming,

Sorry for the confusion. It appears I was doing a non-standard flow with
a directory link that brought in the Build directory and looking at my
directory later, I didn't see real harm in adding it to the file.

I am fine to remove it in a v2 if you'd like.

Thanks,
Michael

On 10/26/2020 11:24 PM, gaoliming wrote:
Michael:
Do you meet with the case that its output directory is generated into
edk2-platforms\Build?

Thanks
Liming
-----邮件原件-----
发件人: michael.kubacki@outlook.com <michael.kubacki@outlook.com>
发送时间: 2020年10月27日 1:44
收件人: devel@edk2.groups.io
抄送: Leif Lindholm <leif@nuviainc.com>; Michael D Kinney
<michael.d.kinney@intel.com>; Ard Biesheuvel
<ard.biesheuvel@arm.com>;
Liming Gao <gaoliming@byosoft.com.cn>
主题: [edk2-platforms][PATCH v1 1/1] .gitignore: Match contents to edk2

From: Michael Kubacki <michael.kubacki@microsoft.com>

The .gitignore file is currently missing a few key items like the
Build directory. This change updates the contents to match the edk2
file for a similar experience on the two repos.

Cc: Leif Lindholm <leif@nuviainc.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Ard Biesheuvel <ard.biesheuvel@arm.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com>
---
.gitignore | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/.gitignore b/.gitignore
index 58200d4d732e..1dd30c141066 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1 +1,7 @@
+Build/
+.DS_Store
+*_extdep/
+*.pyc
__pycache__/
+tags/
+.vscode/
--
2.28.0.windows.1




[PATCH 2/2] BaseTools: update report map file format

fengyunhua
 

update report map file format

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Yuwei Chen <yuwei.chen@intel.com>
Signed-off-by: Yunhua Feng <fengyunhua@byosoft.com.cn>
---
BaseTools/Source/Python/build/BuildReport.py | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/BaseTools/Source/Python/build/BuildReport.py b/BaseTools/Source/Python/build/BuildReport.py
index 8efa869162..57701ec3e3 100644
--- a/BaseTools/Source/Python/build/BuildReport.py
+++ b/BaseTools/Source/Python/build/BuildReport.py
@@ -60,7 +60,7 @@ gPcdGuidPattern = re.compile(r"PCD\((\w+)[.](\w+)\)")
gOffsetGuidPattern = re.compile(r"(0x[0-9A-Fa-f]+) ([-A-Fa-f0-9]+)")

## Pattern to find module base address and entry point in fixed flash map file
-gModulePattern = r"\n[-\w]+\s*\(([^,]+),\s*BaseAddress=%(Address)s,\s*EntryPoint=%(Address)s\)\s*\(GUID=([-0-9A-Fa-f]+)[^)]*\)"
+gModulePattern = r"\n[-\w]+\s*\(([^,]+),\s*BaseAddress=%(Address)s,\s*EntryPoint=%(Address)s,\s*\w+\)\s*\(GUID=([-0-9A-Fa-f]+)[^)]*\)"
gMapFileItemPattern = re.compile(gModulePattern % {"Address" : "(-?0[xX][0-9A-Fa-f]+)"})

## Pattern to find all module referenced header files in source files
--
2.27.0.windows.1


[PATCH 1/2] BaseTools: Add image type into generate map file

fengyunhua
 

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

For a source-level BIOS debugger the .map files are quite useful with one
major shortcoming: the debugger cannot know, solely from the .map file,
the format (PE/COFF vs. TE) of the image included in the final BIOS ROM

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <gaoliming@byosoft.com.cn>
Cc: Yuwei Chen <yuwei.chen@intel.com>
Signed-off-by: Yunhua Feng <fengyunhua@byosoft.com.cn>
---
BaseTools/Source/C/GenFv/GenFvInternalLib.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/BaseTools/Source/C/GenFv/GenFvInternalLib.c b/BaseTools/Source/C/GenFv/GenFvInternalLib.c
index b5ffed93a9..6e296b8ad6 100644
--- a/BaseTools/Source/C/GenFv/GenFvInternalLib.c
+++ b/BaseTools/Source/C/GenFv/GenFvInternalLib.c
@@ -903,7 +903,12 @@ Returns:
fprintf (FvMapFile, "BaseAddress=0x%010llx, ", (unsigned long long) (ImageBaseAddress + Offset));
}

- fprintf (FvMapFile, "EntryPoint=0x%010llx", (unsigned long long) (ImageBaseAddress + AddressOfEntryPoint));
+ fprintf (FvMapFile, "EntryPoint=0x%010llx, ", (unsigned long long) (ImageBaseAddress + AddressOfEntryPoint));
+ if (!pImageContext->IsTeImage) {
+ fprintf (FvMapFile, "Type=PE");
+ } else {
+ fprintf (FvMapFile, "Type=TE");
+ }
fprintf (FvMapFile, ")\n");

fprintf (FvMapFile, "(GUID=%s", FileGuidName);
--
2.27.0.windows.1


[PATCH 0/2] Add image type information into map file

fengyunhua
 

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=2977
1, Add image type information into map file
2, Update report map file information

Yunhua Feng (2):
BaseTools: Add image type into generate map file
BaseTools: update report map file format

BaseTools/Source/C/GenFv/GenFvInternalLib.c | 7 ++++++-
BaseTools/Source/Python/build/BuildReport.py | 2 +-
2 files changed, 7 insertions(+), 2 deletions(-)

--
2.27.0.windows.1


Re: EmulatorPkg segmentation fault on Linux.

Ali Shirvani
 

Dear Sean,

Thanks for your reply. I have turned off the optimization but I did not succeed.
I want to test the HTTP boot method. According to the documentation, EmulatorPkg is required for testing the HTTP(s) boot method.
Is there any other way for testing HTTP(S) boot?

Regards,
Ali


On Tue, Oct 27, 2020 at 8:00 PM Sean Brogan <spbrogan@...> wrote:
Thanks for reporting the issue.

This issue has been reported but is not yet fixed (from your log it
looks like a match).
https://bugzilla.tianocore.org/show_bug.cgi?id=2639

We attempted to call out this issue in the main readme.rst by putting a
link to the bugs but i am sure it is super easy to miss.
https://github.com/tianocore/edk2/blob/master/ReadMe.rst

Anyway if you want to follow that bug and/or supply a fix that would be
great.  Some have mentioned turning off optimizations might avoid the
issue.

Thanks
Sean





On 10/26/2020 10:33 PM, Ali Shirvani wrote:
> Hello,
>
> I just compiled EmulatorPkg successfully, but when I tried to run it with
> ./Host command, I got following error:
>
>>
>> PeiInstallPeiMemory MemoryBegin 0x41000000, MemoryLength 0x4000000
>> PROGRESS CODE: V03020003 I0
>> Temp Stack : BaseAddress=0x40000000 Length=0x10000
>> Temp Heap  : BaseAddress=0x40010000 Length=0x10000
>> Total temporary memory:    131072 bytes.
>>    temporary memory stack ever used:       65532 bytes.
>>    temporary memory heap used for HobList: 3736 bytes.
>>    temporary memory heap occupied by memory pages: 0 bytes.
>> Old Stack size 65536, New stack size 131072
>> Stack Hob: BaseAddress=0x41000000 Length=0x20000
>> Heap Offset = 0x1010000 Stack Offset = 0x1010000
>> Segmentation fault
>>
>
> The attached is the complete log of `./Host` command.
>
>
>
>
>
>


Re: [PATCH v2 5/5] MdePkg: Fix SmBios.h PROCESSOR_CHARACTERISTIC_FLAGS to be UINT16

Zhiguang Liu
 

Reviewed-by: Zhiguang Liu <zhiguang.liu@intel.com>

-----Original Message-----
From: Rebecca Cran <rebecca@nuviainc.com>
Sent: Wednesday, October 28, 2020 1:30 AM
To: devel@edk2.groups.io
Cc: Rebecca Cran <rebecca@nuviainc.com>; Kinney, Michael D
<michael.d.kinney@intel.com>; Liming Gao <gaoliming@byosoft.com.cn>;
Liu, Zhiguang <zhiguang.liu@intel.com>; Ni, Ray <ray.ni@intel.com>; Gao,
Zhichao <zhichao.gao@intel.com>
Subject: [PATCH v2 5/5] MdePkg: Fix SmBios.h
PROCESSOR_CHARACTERISTIC_FLAGS to be UINT16

The ProcessorCharacteristics is a UINT16 field, so the
PROCESSOR_CHARACTERISTIC_FLAGS bitfield should be UINT16 too.

Signed-off-by: Rebecca Cran <rebecca@nuviainc.com>
---
MdePkg/Include/IndustryStandard/SmBios.h | 22 +++++++++++-----------
1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/MdePkg/Include/IndustryStandard/SmBios.h
b/MdePkg/Include/IndustryStandard/SmBios.h
index c495c48f3b47..1ee01645679a 100644
--- a/MdePkg/Include/IndustryStandard/SmBios.h
+++ b/MdePkg/Include/IndustryStandard/SmBios.h
@@ -862,17 +862,17 @@ typedef struct {
} PROCESSOR_FEATURE_FLAGS;

typedef struct {
- UINT32 ProcessorReserved1 :1;
- UINT32 ProcessorUnknown :1;
- UINT32 Processor64BitCapble :1;
- UINT32 ProcessorMultiCore :1;
- UINT32 ProcessorHardwareThread :1;
- UINT32 ProcessorExecuteProtection :1;
- UINT32 ProcessorEnhancedVirtulization :1;
- UINT32 ProcessorPowerPerformanceCtrl :1;
- UINT32 Processor128bitCapble :1;
- UINT32 ProcessorArm64SocId :1;
- UINT32 ProcessorReserved2 :6;
+ UINT16 ProcessorReserved1 :1;
+ UINT16 ProcessorUnknown :1;
+ UINT16 Processor64BitCapble :1;
+ UINT16 ProcessorMultiCore :1;
+ UINT16 ProcessorHardwareThread :1;
+ UINT16 ProcessorExecuteProtection :1;
+ UINT16 ProcessorEnhancedVirtulization :1;
+ UINT16 ProcessorPowerPerformanceCtrl :1;
+ UINT16 Processor128bitCapble :1;
+ UINT16 ProcessorArm64SocId :1;
+ UINT16 ProcessorReserved2 :6;
} PROCESSOR_CHARACTERISTIC_FLAGS;

typedef struct {
--
2.26.2


Re: [PATCH v2 4/5] MdePkg: Update SmBios.h to add SMBIOS 3.4.0 ARM64 SoC ID field

Zhiguang Liu
 

Reviewed-by: Zhiguang Liu <zhiguang.liu@intel.com>

-----Original Message-----
From: Rebecca Cran <rebecca@nuviainc.com>
Sent: Wednesday, October 28, 2020 1:30 AM
To: devel@edk2.groups.io
Cc: Rebecca Cran <rebecca@nuviainc.com>; Kinney, Michael D
<michael.d.kinney@intel.com>; Liming Gao <gaoliming@byosoft.com.cn>;
Liu, Zhiguang <zhiguang.liu@intel.com>; Ni, Ray <ray.ni@intel.com>; Gao,
Zhichao <zhichao.gao@intel.com>
Subject: [PATCH v2 4/5] MdePkg: Update SmBios.h to add SMBIOS 3.4.0
ARM64 SoC ID field

SMBIOS 3.4.0 defines bit 9 of the Type 4 table Processor Characteristics field
to be the ARM64 SoC ID support. Add it to the
PROCESSOR_CHARACTERISTIC_FLAGS struct bitfield.

Signed-off-by: Rebecca Cran <rebecca@nuviainc.com>
---
MdePkg/Include/IndustryStandard/SmBios.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/MdePkg/Include/IndustryStandard/SmBios.h
b/MdePkg/Include/IndustryStandard/SmBios.h
index f2db11f947d1..c495c48f3b47 100644
--- a/MdePkg/Include/IndustryStandard/SmBios.h
+++ b/MdePkg/Include/IndustryStandard/SmBios.h
@@ -871,7 +871,8 @@ typedef struct {
UINT32 ProcessorEnhancedVirtulization :1;
UINT32 ProcessorPowerPerformanceCtrl :1;
UINT32 Processor128bitCapble :1;
- UINT32 ProcessorReserved2 :7;
+ UINT32 ProcessorArm64SocId :1;
+ UINT32 ProcessorReserved2 :6;
} PROCESSOR_CHARACTERISTIC_FLAGS;

typedef struct {
--
2.26.2


Re: RFC: Universal Payload Interface

Ni, Ray
 

Laszlo,
Thank you for the comments.
Reply inline.

-----Original Message-----
From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Laszlo
Ersek
Sent: Tuesday, October 27, 2020 10:21 PM
To: devel@edk2.groups.io; Ni, Ray <ray.ni@intel.com>
Cc: Zimmer, Vincent <vincent.zimmer@intel.com>; Ma, Maurice
<maurice.ma@intel.com>; Rangarajan, Ravi P <ravi.p.rangarajan@intel.com>;
Dong, Guo <guo.dong@intel.com>; Hau, Tze-ming <tze-ming.hau@intel.com>
Subject: Re: [edk2-devel] RFC: Universal Payload Interface

On 10/23/20 03:18, Ni, Ray wrote:
With the fact that there are many different firmware implementations, we
tried to decouple today's monolithic UEFI firmware binary to two independent
components: bootloader and payload.

(1) "Bootloader" is an extremely loaded word. Regardless of everything
else in this topic, I strongly suggest picking a different name.

We already have "Platform Init" or "PI"; maybe use "Silicon Init" or "SI"?
I am a UEFI guy for many years. So your suggestion "PI" looks very friendly to me.
But I am not sure if the audiences include broader people, like coreboot, SBL developers,
do they like the names.

Personally I am open to any name as long as the concept is not changed: the binary blob
is responsible to initialize the silicon.




(2) What is the *exact* use case (or workflow) that the proposed
interface enables, or improves?
What groups of people (what roles) are supposed to benefit from the
proposed interface?
1. Unified UEFI Payload Binary.
By standardizing the bootloader->payload interface, we keep in mind to move all
platform/silicon specific implementation to bootloader and all the specific info is
passed to payload through the standard interface such that the payload doesn't need
to deal with concrete hardware but just the abstracted info. It gives possibility to create
the unified UEFI payload binary that can run in any platform/silicon (off course, one binary
per one CPU arch). Just like today's UEFI Shell.
It's a huge save on validation side to every company that uses UEFI as boot solution for
hardware.
People may argue maintaining such a binary causes additional overhead. I agree.
But I am optimistic on such direction.
(The code will be still in open source.)

2. Bootloaders
It shows an attitude of EDKII community that it doesn't restrict to use EDKII PEI as the
only acknowledged silicon code execution environment. The standard interface as a promise
allows any compliant bootloader to work with EDKII UEFI Payload.

3. Payloads
I saw different tries to change EDKII DXE environment for different hardware/OS.
It may cause defragmentation of UEFI spec. The standard interface also allows any
compliant payload to be created.


Thanks
Laszlo


Basically, bootloader initializes the silicon hardware and payload prepares
the OS required data and services. Bootloader passes control to payload.

https://universalpayload.github.io/documentation/spec/spec.html defines the
universal interface between bootloader and payload. So that different
bootloaders can work with different payloads, initializing different hardware
and booting different OSes.
The interface document is in very draft phase. Any feedback is welcome.

We also developed the POC code to demonstrate the idea. Please use below
steps to get the code that uses SBL as the bootloader and EDKII UEFI Payload as
the payload. This POC is being developed for QEMU Q35 virtual machine.

1. Run "git clone https://github.com/universalpayload/tools.git payload"

This step downloads the initial tools that will setup the dev environment.

1. Run "py -3 clone_and_build_sbl_with_uefipayload.py" in the "payload"
directory

This script downloads branched SBL
(https://github.com/universalpayload/slimbootloader.git) and edk2
(https://github.com/universalpayload/edk2.git).

Then it builds the firmware binary "SlimBootloader.bin" in "codeworkspace"
directory.

1. Boot QEMU by running "qemu-system-x86_64.exe -machine q35 -pflash
codeworkspace\SlimBootloader.bin -serial file:test.log"

Because the code is under active development, please contact us when you
cannot build or boot successfully.

Besides the SBL, we modified coreboot
(https://github.com/universalpayload/coreboot.git) to let it conform to the
universal interface as a bootloader.
Besides the EDK2 UEFI Payload, we created a payload
(https://github.com/universalpayload/linuxpayload.git) that can boot Linux.

Thanks,
Ray









14221 - 14240 of 80865