public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [PATCH] BaseTools:BaseTools supports to the driver combination.
@ 2019-02-15  3:18 Fan, ZhijuX
  2019-02-15 15:51 ` Carsey, Jaben
  0 siblings, 1 reply; 2+ messages in thread
From: Fan, ZhijuX @ 2019-02-15  3:18 UTC (permalink / raw)
  To: edk2-devel@lists.01.org; +Cc: Gao, Liming, Feng, Bob C

BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=1520

To save the image size without the compression, more than
one drivers can be combined into single one. When more than
one drivers are combined, their depex will be AND together.
Below is the example to combine BootManagerPolicyDxe into
DriverHealthManagerDxe.

Besides this patch, BaseTools also needs to check the module
type and make sure all module type are same. Otherwise,
BaseTools will report the error.
DRIVER INF has the parameter ENTRY_POINT 
LIBRARY INF has the parameter LIBRARY_CLASS 

Cc: Bob Feng <bob.c.feng@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Zhiju.Fan <zhijux.fan@intel.com>
---
 BaseTools/Source/Python/AutoGen/GenC.py | 31 ++++++++++++++++++++++++++-----
 1 file changed, 26 insertions(+), 5 deletions(-)

diff --git a/BaseTools/Source/Python/AutoGen/GenC.py b/BaseTools/Source/Python/AutoGen/GenC.py
index 9700bf8527..93e8d78375 100644
--- a/BaseTools/Source/Python/AutoGen/GenC.py
+++ b/BaseTools/Source/Python/AutoGen/GenC.py
@@ -1455,10 +1455,24 @@ def CreateLibraryDestructorCode(Info, AutoGenC, AutoGenH):
 def CreateModuleEntryPointCode(Info, AutoGenC, AutoGenH):
     if Info.IsLibrary or Info.ModuleType in [SUP_MODULE_USER_DEFINED, SUP_MODULE_SEC]:
         return
+    ModuleEntryPointList = []
+    for Lib in Info.DependentLibraryList:
+        if len(Lib.ModuleEntryPointList) > 0:
+            if Lib.ModuleType == Info.ModuleType:
+                ModuleEntryPointList = ModuleEntryPointList + Lib.ModuleEntryPointList
+            else:
+                EdkLogger.error(
+                    "build",
+                    CODE_ERROR,
+                    "%s \nDriver's ModuleType must be consistent" % Lib,
+                    File=str(Info)
+                )
+    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:
@@ -1468,7 +1482,7 @@ def CreateModuleEntryPointCode(Info, AutoGenC, AutoGenH):
     else:
         UefiSpecVersion = '0x00000000'
     Dict = {
-        'Function'       :   Info.Module.ModuleEntryPointList,
+        'Function'       :   ModuleEntryPointList,
         'PiSpecVersion'  :   PiSpecVersion + 'U',
         'UefiSpecVersion':   UefiSpecVersion + 'U'
     }
@@ -1481,7 +1495,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 == SUP_MODULE_PEI_CORE:
         AutoGenC.Append(gPeiCoreEntryPointString.Replace(Dict))
@@ -1535,11 +1549,18 @@ def CreateModuleEntryPointCode(Info, AutoGenC, AutoGenH):
 def CreateModuleUnloadImageCode(Info, AutoGenC, AutoGenH):
     if Info.IsLibrary or Info.ModuleType in [SUP_MODULE_USER_DEFINED, SUP_MODULE_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.14.1.windows.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] BaseTools:BaseTools supports to the driver combination.
  2019-02-15  3:18 [PATCH] BaseTools:BaseTools supports to the driver combination Fan, ZhijuX
@ 2019-02-15 15:51 ` Carsey, Jaben
  0 siblings, 0 replies; 2+ messages in thread
From: Carsey, Jaben @ 2019-02-15 15:51 UTC (permalink / raw)
  To: Fan, ZhijuX, edk2-devel@lists.01.org; +Cc: Gao, Liming

Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>

> -----Original Message-----
> From: edk2-devel [mailto:edk2-devel-bounces@lists.01.org] On Behalf Of
> Fan, ZhijuX
> Sent: Thursday, February 14, 2019 7:18 PM
> To: edk2-devel@lists.01.org
> Cc: Gao, Liming <liming.gao@intel.com>
> Subject: [edk2] [PATCH] BaseTools:BaseTools supports to the driver
> combination.
> 
> BZ:https://bugzilla.tianocore.org/show_bug.cgi?id=1520
> 
> To save the image size without the compression, more than
> one drivers can be combined into single one. When more than
> one drivers are combined, their depex will be AND together.
> Below is the example to combine BootManagerPolicyDxe into
> DriverHealthManagerDxe.
> 
> Besides this patch, BaseTools also needs to check the module
> type and make sure all module type are same. Otherwise,
> BaseTools will report the error.
> DRIVER INF has the parameter ENTRY_POINT
> LIBRARY INF has the parameter LIBRARY_CLASS
> 
> Cc: Bob Feng <bob.c.feng@intel.com>
> Cc: Liming Gao <liming.gao@intel.com>
> Contributed-under: TianoCore Contribution Agreement 1.1
> Signed-off-by: Zhiju.Fan <zhijux.fan@intel.com>
> ---
>  BaseTools/Source/Python/AutoGen/GenC.py | 31
> ++++++++++++++++++++++++++-----
>  1 file changed, 26 insertions(+), 5 deletions(-)
> 
> diff --git a/BaseTools/Source/Python/AutoGen/GenC.py
> b/BaseTools/Source/Python/AutoGen/GenC.py
> index 9700bf8527..93e8d78375 100644
> --- a/BaseTools/Source/Python/AutoGen/GenC.py
> +++ b/BaseTools/Source/Python/AutoGen/GenC.py
> @@ -1455,10 +1455,24 @@ def CreateLibraryDestructorCode(Info,
> AutoGenC, AutoGenH):
>  def CreateModuleEntryPointCode(Info, AutoGenC, AutoGenH):
>      if Info.IsLibrary or Info.ModuleType in [SUP_MODULE_USER_DEFINED,
> SUP_MODULE_SEC]:
>          return
> +    ModuleEntryPointList = []
> +    for Lib in Info.DependentLibraryList:
> +        if len(Lib.ModuleEntryPointList) > 0:
> +            if Lib.ModuleType == Info.ModuleType:
> +                ModuleEntryPointList = ModuleEntryPointList +
> Lib.ModuleEntryPointList
> +            else:
> +                EdkLogger.error(
> +                    "build",
> +                    CODE_ERROR,
> +                    "%s \nDriver's ModuleType must be consistent" % Lib,
> +                    File=str(Info)
> +                )
> +    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:
> @@ -1468,7 +1482,7 @@ def CreateModuleEntryPointCode(Info, AutoGenC,
> AutoGenH):
>      else:
>          UefiSpecVersion = '0x00000000'
>      Dict = {
> -        'Function'       :   Info.Module.ModuleEntryPointList,
> +        'Function'       :   ModuleEntryPointList,
>          'PiSpecVersion'  :   PiSpecVersion + 'U',
>          'UefiSpecVersion':   UefiSpecVersion + 'U'
>      }
> @@ -1481,7 +1495,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 == SUP_MODULE_PEI_CORE:
>          AutoGenC.Append(gPeiCoreEntryPointString.Replace(Dict))
> @@ -1535,11 +1549,18 @@ def CreateModuleEntryPointCode(Info,
> AutoGenC, AutoGenH):
>  def CreateModuleUnloadImageCode(Info, AutoGenC, AutoGenH):
>      if Info.IsLibrary or Info.ModuleType in [SUP_MODULE_USER_DEFINED,
> SUP_MODULE_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(Dic
> t))
>      else:
> --
> 2.14.1.windows.1
> 
> _______________________________________________
> edk2-devel mailing list
> edk2-devel@lists.01.org
> https://lists.01.org/mailman/listinfo/edk2-devel


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-02-15 15:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-02-15  3:18 [PATCH] BaseTools:BaseTools supports to the driver combination Fan, ZhijuX
2019-02-15 15:51 ` Carsey, Jaben

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox