summaryrefslogtreecommitdiff
path: root/BaseTools/Source/Python
diff options
context:
space:
mode:
authorMichael D Kinney <michael.d.kinney@intel.com>2026-05-06 05:10:45 +0300
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2026-06-22 18:18:12 +0300
commitadc5e8d00941485ddeb185869eb35dd2de08f711 (patch)
tree6e4b59f8e3d233b431d527114e34e8882738ef67 /BaseTools/Source/Python
parentb9463ca6b6049be80b7d5751dca4a0972eda9b0f (diff)
downloadedk2-adc5e8d00941485ddeb185869eb35dd2de08f711.tar.xz
BaseTools/GenFds: Propagate Xip flag to FV INF via ,XIP suffix
Add Xip attribute to FDF Rule class and parse the Xip keyword in EFI section rules of FDF files. Add XipEnabled attribute to FfsInfStatement that is determined from the applicable FDF Rule's section Xip setting. When generating the FV INF file, append ",XIP" to EFI_FILE_NAME entries for modules whose Rule specifies Xip=TRUE. This enables per-file XIP rebase control in GenFv by communicating which files require XIP rebase directly in the FV INF file format. Signed-off-by: Michael D Kinney <michael.d.kinney@intel.com>
Diffstat (limited to 'BaseTools/Source/Python')
-rw-r--r--BaseTools/Source/Python/CommonDataClass/FdfClass.py1
-rw-r--r--BaseTools/Source/Python/GenFds/FdfParser.py10
-rw-r--r--BaseTools/Source/Python/GenFds/FfsInfStatement.py29
-rw-r--r--BaseTools/Source/Python/GenFds/Fv.py4
4 files changed, 44 insertions, 0 deletions
diff --git a/BaseTools/Source/Python/CommonDataClass/FdfClass.py b/BaseTools/Source/Python/CommonDataClass/FdfClass.py
index c8cfdaae32..f765e0a42a 100644
--- a/BaseTools/Source/Python/CommonDataClass/FdfClass.py
+++ b/BaseTools/Source/Python/CommonDataClass/FdfClass.py
@@ -249,6 +249,7 @@ class RuleClassObject :
self.FvFileType = None # for Ffs File Type
self.KeyStringList = []
self.KeepReloc = None
+ self.Xip = False
## Complex rule data in FDF
#
diff --git a/BaseTools/Source/Python/GenFds/FdfParser.py b/BaseTools/Source/Python/GenFds/FdfParser.py
index c41fcdba7b..d8d09946fd 100644
--- a/BaseTools/Source/Python/GenFds/FdfParser.py
+++ b/BaseTools/Source/Python/GenFds/FdfParser.py
@@ -3900,6 +3900,16 @@ class FdfParser:
raise Warning("Auto alignment can only be used in PE32 or TE section ", self.FileName, self.CurrentLineNumber)
EfiSectionObj.Alignment = self._Token
+ if self._IsKeyword("Xip"):
+ if not self._IsToken(TAB_EQUAL_SPLIT):
+ raise Warning.ExpectedEquals(self.FileName, self.CurrentLineNumber)
+ if not self._GetNextWord():
+ raise Warning.Expected("Xip value (TRUE/FALSE)", self.FileName, self.CurrentLineNumber)
+ XipValue = self._Token.strip().upper()
+ if XipValue not in {"TRUE", "FALSE"}:
+ raise Warning("Invalid Xip value '%s'" % XipValue, self.FileName, self.CurrentLineNumber)
+ EfiSectionObj.Xip = XipValue
+
if self._IsKeyword('RELOCS_STRIPPED') or self._IsKeyword('RELOCS_RETAINED'):
if self._SectionCouldHaveRelocFlag(EfiSectionObj.SectionType):
if self._Token == 'RELOCS_STRIPPED':
diff --git a/BaseTools/Source/Python/GenFds/FfsInfStatement.py b/BaseTools/Source/Python/GenFds/FfsInfStatement.py
index 6c837accee..3dbf3746d8 100644
--- a/BaseTools/Source/Python/GenFds/FfsInfStatement.py
+++ b/BaseTools/Source/Python/GenFds/FfsInfStatement.py
@@ -71,6 +71,31 @@ class FfsInfStatement(FfsInfStatementClassObject):
self.PatchedBinFile = ''
self.MacroDict = {}
self.Depex = False
+ self.XipEnabled = False
+
+ @staticmethod
+ def DetermineXipEnabled(Rule):
+ """Determine whether XIP is enabled based on a Rule object.
+
+ For a RuleComplexFile, scans SectionList for any section with Xip='TRUE'.
+ For a RuleSimpleFile or other rule, checks Rule.Xip directly.
+
+ Args:
+ Rule: A RuleComplexFile or RuleSimpleFile (or similar) object.
+
+ Returns:
+ bool: True if XIP is enabled for this rule, False otherwise.
+ """
+ if isinstance(Rule, RuleComplexFile.RuleComplexFile):
+ for Sect in Rule.SectionList:
+ if hasattr(Sect, 'Xip') and Sect.Xip and Sect.Xip.upper() == 'TRUE':
+ return True
+ elif hasattr(Rule, 'Xip') and Rule.Xip:
+ if isinstance(Rule.Xip, str) and Rule.Xip.upper() == 'TRUE':
+ return True
+ elif Rule.Xip is True:
+ return True
+ return False
## GetFinalTargetSuffixMap() method
#
@@ -489,6 +514,10 @@ class FfsInfStatement(FfsInfStatementClassObject):
Rule = self.__GetRule__()
GenFdsGlobalVariable.VerboseLogger( "Packing binaries from inf file : %s" %self.InfFileName)
#
+ # Determine XIP setting from Rule sections
+ #
+ self.XipEnabled = FfsInfStatement.DetermineXipEnabled(Rule)
+ #
# Convert Fv File Type for PI1.1 SMM driver.
#
if self.ModuleType == SUP_MODULE_DXE_SMM_DRIVER and int(self.PiSpecVersion, 16) >= 0x0001000A:
diff --git a/BaseTools/Source/Python/GenFds/Fv.py b/BaseTools/Source/Python/GenFds/Fv.py
index 16c944a0bd..f522393e6c 100644
--- a/BaseTools/Source/Python/GenFds/Fv.py
+++ b/BaseTools/Source/Python/GenFds/Fv.py
@@ -127,8 +127,12 @@ class FV (object):
FileName = FfsFile.GenFfs(MacroDict, FvParentAddr=BaseAddress, IsMakefile=Flag, FvName=self.UiFvName)
FfsFileList.append(FileName)
if not Flag:
+ XipSuffix = ""
+ if hasattr(FfsFile, 'XipEnabled') and FfsFile.XipEnabled:
+ XipSuffix = ",XIP"
self.FvInfFile.append("EFI_FILE_NAME = " + \
FileName + \
+ XipSuffix + \
TAB_LINE_BREAK)
if not Flag:
FvInfFile = ''.join(self.FvInfFile)