From: Yonghong Zhu <yonghong.zhu@intel.com>
To: edk2-devel@lists.01.org
Cc: Liming Gao <liming.gao@intel.com>
Subject: [Patch] BaseTools: Enhance tool to generate EFI_HII_IIBT_DUPLICATE image block
Date: Mon, 17 Oct 2016 17:45:33 +0800 [thread overview]
Message-ID: <1476697533-5368-1-git-send-email-yonghong.zhu@intel.com> (raw)
When *.IDF file contains multiple definitions of image which point to the
same image, current build tool generates multiple image blocks which
contain the same image content.
This patch enhance tool to generate EFI_HII_IIBT_DUPLICATE image blocks
for non-first images for such case, to save the HII package size.
Fixes: https://bugzilla.tianocore.org/show_bug.cgi?id=145
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Yonghong Zhu <yonghong.zhu@intel.com>
---
BaseTools/Source/Python/AutoGen/GenC.py | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Python/AutoGen/GenC.py
index 8089e3a..de6eb0e 100644
--- a/BaseTools/Source/Python/AutoGen/GenC.py
+++ b/BaseTools/Source/Python/AutoGen/GenC.py
@@ -1637,10 +1637,11 @@ def CreateIdfFileCode(Info, AutoGenC, StringH, IdfGenCFlag, IdfGenBinBuffer):
PaletteInfoOffset = 0
ImageBuffer = pack('x')
PaletteBuffer = pack('x')
BufferStr = ''
PaletteStr = ''
+ FileDict = {}
for Idf in ImageFiles.ImageFilesDict:
if ImageFiles.ImageFilesDict[Idf]:
for FileObj in ImageFiles.ImageFilesDict[Idf]:
for sourcefile in Info.SourceFileList:
if FileObj.FileName == sourcefile.File:
@@ -1661,10 +1662,23 @@ def CreateIdfFileCode(Info, AutoGenC, StringH, IdfGenCFlag, IdfGenBinBuffer):
if (ValueStartPtr - len(DEFINE_STR + ID)) <= 0:
Line = DEFINE_STR + ' ' + ID + ' ' + DecToHexStr(Index, 4) + '\n'
else:
Line = DEFINE_STR + ' ' + ID + ' ' * (ValueStartPtr - len(DEFINE_STR + ID)) + DecToHexStr(Index, 4) + '\n'
+ if File not in FileDict:
+ FileDict[File] = Index
+ else:
+ DuplicateBlock = pack('B', EFI_HII_IIBT_DUPLICATE)
+ DuplicateBlock += pack('H', FileDict[File])
+ ImageBuffer += DuplicateBlock
+ BufferStr = WriteLine(BufferStr, '// %s: %s: %s' % (DecToHexStr(Index, 4), ID, DecToHexStr(Index, 4)))
+ TempBufferList = AscToHexList(DuplicateBlock)
+ BufferStr = WriteLine(BufferStr, CreateArrayItem(TempBufferList, 16) + '\n')
+ StringH.Append(Line)
+ Index += 1
+ continue
+
TmpFile = open(File.Path, 'rb')
Buffer = TmpFile.read()
TmpFile.close()
if File.Ext.upper() == '.PNG':
TempBuffer = pack('B', EFI_HII_IIBT_IMAGE_PNG)
--
2.6.1.windows.1
next reply other threads:[~2016-10-17 9:45 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-10-17 9:45 Yonghong Zhu [this message]
2016-10-19 1:34 ` [Patch] BaseTools: Enhance tool to generate EFI_HII_IIBT_DUPLICATE image block Gao, Liming
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1476697533-5368-1-git-send-email-yonghong.zhu@intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox