]> git.proxmox.com Git - mirror_edk2.git/commitdiff
BaseTools: Enhance tool to generate EFI_HII_IIBT_DUPLICATE image block
authorYonghong Zhu <yonghong.zhu@intel.com>
Mon, 17 Oct 2016 09:43:45 +0000 (17:43 +0800)
committerYonghong Zhu <yonghong.zhu@intel.com>
Wed, 19 Oct 2016 02:02:31 +0000 (10:02 +0800)
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>
Reviewed-by: Liming Gao <liming.gao@intel.com>
BaseTools/Source/Python/AutoGen/GenC.py

index 8089e3aae3d2d08d0ac67355dfcb79d1598a6200..de6eb0ee789a2bdca9c209b6c13d98c88a4a5617 100644 (file)
@@ -1639,6 +1639,7 @@ def CreateIdfFileCode(Info, AutoGenC, StringH, IdfGenCFlag, IdfGenBinBuffer):
             PaletteBuffer = pack('x')\r
             BufferStr = ''\r
             PaletteStr = ''\r
+            FileDict = {}\r
             for Idf in ImageFiles.ImageFilesDict:\r
                 if ImageFiles.ImageFilesDict[Idf]:\r
                     for FileObj in ImageFiles.ImageFilesDict[Idf]:\r
@@ -1663,6 +1664,19 @@ def CreateIdfFileCode(Info, AutoGenC, StringH, IdfGenCFlag, IdfGenBinBuffer):
                             else:\r
                                 Line = DEFINE_STR + ' ' + ID + ' ' * (ValueStartPtr - len(DEFINE_STR + ID)) + DecToHexStr(Index, 4) + '\n'\r
 \r
+                            if File not in FileDict:\r
+                                FileDict[File] = Index\r
+                            else:\r
+                                DuplicateBlock = pack('B', EFI_HII_IIBT_DUPLICATE)\r
+                                DuplicateBlock += pack('H', FileDict[File])\r
+                                ImageBuffer += DuplicateBlock\r
+                                BufferStr = WriteLine(BufferStr, '// %s: %s: %s' % (DecToHexStr(Index, 4), ID, DecToHexStr(Index, 4)))\r
+                                TempBufferList = AscToHexList(DuplicateBlock)\r
+                                BufferStr = WriteLine(BufferStr, CreateArrayItem(TempBufferList, 16) + '\n')\r
+                                StringH.Append(Line)\r
+                                Index += 1\r
+                                continue\r
+\r
                             TmpFile = open(File.Path, 'rb')\r
                             Buffer = TmpFile.read()\r
                             TmpFile.close()\r