public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Liming Gao <liming.gao@intel.com>
To: edk2-devel@lists.01.org
Subject: [PATCH staging][BaseToolsOpt 1/4] BaseTools: Merge multiple drivers into one for size and link performance
Date: Thu,  8 Jun 2017 14:55:37 +0800	[thread overview]
Message-ID: <1496904940-11364-2-git-send-email-liming.gao@intel.com> (raw)
In-Reply-To: <1496904940-11364-1-git-send-email-liming.gao@intel.com>

Update BaseTools to support the multiple driver combination. The merge style
reuses the library instance syntax in package.dsc file. The below example is
to combine VirtioGpu and QemuVideoDxe driver into one driver. VirtioGpu driver
entry point will be executed first, QemuVideoDxe entry point will run last.
[Components]
  OvmfPkg/QemuVideoDxe/QemuVideoDxe.inf {
    <LibraryClasses>
      NULL|OvmfPkg/VirtioGpuDxe/VirtioGpu.inf
  }

Notes: When try combining some drivers, the compile failure may happen,
because the same function name are used in the different drivers. Those
drivers are required to be clean up first, then be combined.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Liming Gao <liming.gao@intel.com>
---
 BaseTools/Source/Python/AutoGen/GenC.py | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Python/AutoGen/GenC.py
index 67aaef7..6579457 100644
--- a/BaseTools/Source/Python/AutoGen/GenC.py
+++ b/BaseTools/Source/Python/AutoGen/GenC.py
@@ -1359,10 +1359,17 @@ def CreateLibraryDestructorCode(Info, AutoGenC, AutoGenH):
 def CreateModuleEntryPointCode(Info, AutoGenC, AutoGenH):
     if Info.IsLibrary or Info.ModuleType in ['USER_DEFINED', 'SEC']:
         return
+    
+    ModuleEntryPointList = []
+    for Lib in Info.DependentLibraryList:
+        if len (Lib.ModuleEntryPointList) > 0:
+            ModuleEntryPointList = ModuleEntryPointList + Lib.ModuleEntryPointList
+    ModuleEntryPointList = ModuleEntryPointList + Info.Module.ModuleEntryPointList
+    
     #
     # Module Entry Points
     #
-    NumEntryPoints = len(Info.Module.ModuleEntryPointList)
+    NumEntryPoints = len(ModuleEntryPointList)
     if 'PI_SPECIFICATION_VERSION' in Info.Module.Specification:
         PiSpecVersion = Info.Module.Specification['PI_SPECIFICATION_VERSION']
     else:
@@ -1372,7 +1379,7 @@ def CreateModuleEntryPointCode(Info, AutoGenC, AutoGenH):
     else:
         UefiSpecVersion = '0x00000000'
     Dict = {
-        'Function'       :   Info.Module.ModuleEntryPointList,
+        'Function'       :   ModuleEntryPointList,
         'PiSpecVersion'  :   PiSpecVersion + 'U',
         'UefiSpecVersion':   UefiSpecVersion + 'U'
     }
@@ -1385,7 +1392,7 @@ def CreateModuleEntryPointCode(Info, AutoGenC, AutoGenH):
                   AUTOGEN_ERROR,
                   '%s must have exactly one entry point' % Info.ModuleType,
                   File=str(Info),
-                  ExtraData= ", ".join(Info.Module.ModuleEntryPointList)
+                  ExtraData= ", ".join(ModuleEntryPointList)
                   )
     if Info.ModuleType == 'PEI_CORE':
         AutoGenC.Append(gPeiCoreEntryPointString.Replace(Dict))
@@ -1430,11 +1437,18 @@ def CreateModuleEntryPointCode(Info, AutoGenC, AutoGenH):
 def CreateModuleUnloadImageCode(Info, AutoGenC, AutoGenH):
     if Info.IsLibrary or Info.ModuleType in ['USER_DEFINED', 'SEC']:
         return
+
+    ModuleUnloadImageList = []
+    for Lib in Info.DependentLibraryList:
+        if len (Lib.ModuleUnloadImageList) > 0:
+            ModuleUnloadImageList = ModuleUnloadImageList + Lib.ModuleUnloadImageList
+    ModuleUnloadImageList = ModuleUnloadImageList + Info.Module.ModuleUnloadImageList
+
     #
     # Unload Image Handlers
     #
-    NumUnloadImage = len(Info.Module.ModuleUnloadImageList)
-    Dict = {'Count':str(NumUnloadImage) + 'U', 'Function':Info.Module.ModuleUnloadImageList}
+    NumUnloadImage = len(ModuleUnloadImageList)
+    Dict = {'Count':str(NumUnloadImage) + 'U', 'Function':ModuleUnloadImageList}
     if NumUnloadImage < 2:
         AutoGenC.Append(gUefiUnloadImageString[NumUnloadImage].Replace(Dict))
     else:
-- 
2.8.0.windows.1



  reply	other threads:[~2017-06-08  6:54 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-08  6:55 [PATCH staging][BaseToolsOpt 0/4] Enable multiple driver combination Liming Gao
2017-06-08  6:55 ` Liming Gao [this message]
2017-06-08  6:55 ` [PATCH staging][BaseToolsOpt 2/4] OvmfPkg: Update QemuVideo and VirtioGpuDxe to use NULL as DriverBindingHandle Liming Gao
2017-06-08  6:55 ` [PATCH staging][BaseToolsOpt 3/4] OvmfPkg: Combine QemuVideoDxe and VirtioGpuDxe to one driver Liming Gao
2017-06-08  6:55 ` [PATCH staging][BaseToolsOpt 4/4] Update Readme.MD to include multiple driver combination Liming Gao
2017-06-08 21:03 ` [PATCH staging][BaseToolsOpt 0/4] Enable " Laszlo Ersek
2017-06-10 13:49   ` Gao, Liming
2017-06-12 14:16     ` Laszlo Ersek
2017-06-12 14:48       ` 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=1496904940-11364-2-git-send-email-liming.gao@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