1. Extend Platform Build Options only for EDK module, or only for EDKII module, or...
authorlgao4 <lgao4@c2973edb-eda0-4c78-bc6a-9341b269661f>
Thu, 28 Jan 2010 01:46:33 +0000 (01:46 +0000)
committerlgao4 <lgao4@c2973edb-eda0-4c78-bc6a-9341b269661f>
Thu, 28 Jan 2010 01:46:33 +0000 (01:46 +0000)
2. Support negative value setting for PCD value.
3. Check whether PCD value is valid for its data type.
4. Correct the generation for patchable PCD in AutoGen code.

git-svn-id: https://edk2-buildtools.svn.sourceforge.net/svnroot/edk2-buildtools/trunk/BaseTools@1819 c2973edb-eda0-4c78-bc6a-9341b269661f

Source/Python/AutoGen/AutoGen.py
Source/Python/AutoGen/GenC.py
Source/Python/Common/BuildToolError.py
Source/Python/Common/DataType.py
Source/Python/Workspace/WorkspaceDatabase.py

index cd9ecdc..4755e31 100755 (executable)
@@ -355,6 +355,8 @@ class PlatformAutoGen(AutoGen):
         self._ToolChainFamily = None\r
         self._BuildRuleFamily = None\r
         self._BuildOption = None          # toolcode : option\r
+        self._EdkBuildOption = None       # edktoolcode : option\r
+        self._EdkIIBuildOption = None     # edkiitoolcode : option\r
         self._PackageList = None\r
         self._ModuleAutoGenList  = None\r
         self._LibraryAutoGenList = None\r
@@ -661,12 +663,24 @@ class PlatformAutoGen(AutoGen):
                 self._BuildRuleFamily = ToolDefinition[TAB_TOD_DEFINES_BUILDRULEFAMILY][self.ToolChain]\r
         return self._BuildRuleFamily\r
 \r
-    ## Return the build options specific to this platform\r
+    ## Return the build options specific for all modules in this platform\r
     def _GetBuildOptions(self):\r
         if self._BuildOption == None:\r
             self._BuildOption = self._ExpandBuildOption(self.Platform.BuildOptions)\r
         return self._BuildOption\r
 \r
+    ## Return the build options specific for EDK modules in this platform\r
+    def _GetEdkBuildOptions(self):\r
+        if self._EdkBuildOption == None:\r
+            self._EdkBuildOption = self._ExpandBuildOption(self.Platform.BuildOptions, EDK_NAME)\r
+        return self._EdkBuildOption\r
+\r
+    ## Return the build options specific for EDKII modules in this platform\r
+    def _GetEdkIIBuildOptions(self):\r
+        if self._EdkIIBuildOption == None:\r
+            self._EdkIIBuildOption = self._ExpandBuildOption(self.Platform.BuildOptions, EDKII_NAME)\r
+        return self._EdkIIBuildOption\r
+\r
     ## Parse build_rule.txt in $(WORKSPACE)/Conf/build_rule.txt\r
     #\r
     #   @retval     BuildRule object\r
@@ -1072,11 +1086,18 @@ class PlatformAutoGen(AutoGen):
     #\r
     #   @retval options     Options expanded\r
     #\r
-    def _ExpandBuildOption(self, Options):\r
+    def _ExpandBuildOption(self, Options, ModuleStyle=None):\r
         BuildOptions = {}\r
         FamilyMatch  = False\r
         FamilyIsNull = True\r
         for Key in Options:\r
+            if ModuleStyle != None and len (Key) > 2:\r
+                # Check Module style is EDK or EDKII.\r
+                # Only append build option for the matched style module.\r
+                if ModuleStyle == EDK_NAME and Key[2] != EDK_NAME:\r
+                    continue\r
+                elif ModuleStyle == EDKII_NAME and Key[2] != EDKII_NAME:\r
+                    continue\r
             Family = Key[0]\r
             Target, Tag, Arch, Tool, Attr = Key[1].split("_")\r
             # if tool chain family doesn't match, skip it\r
@@ -1104,6 +1125,13 @@ class PlatformAutoGen(AutoGen):
             return BuildOptions\r
         \r
         for Key in Options:\r
+            if ModuleStyle != None and len (Key) > 2:\r
+                # Check Module style is EDK or EDKII.\r
+                # Only append build option for the matched style module.\r
+                if ModuleStyle == EDK_NAME and Key[2] != EDK_NAME:\r
+                    continue\r
+                elif ModuleStyle == EDKII_NAME and Key[2] != EDKII_NAME:\r
+                    continue\r
             Family = Key[0]\r
             Target, Tag, Arch, Tool, Attr = Key[1].split("_")\r
             # if tool chain family doesn't match, skip it\r
@@ -1133,7 +1161,11 @@ class PlatformAutoGen(AutoGen):
     #   @retval options     The options appended with build options in platform\r
     #\r
     def ApplyBuildOption(self, Module):\r
-        PlatformOptions = self.BuildOption\r
+        # Get the different options for the different style module\r
+        if Module.AutoGenVersion < 0x00010005:\r
+            PlatformOptions = self.EdkBuildOption\r
+        else:\r
+            PlatformOptions = self.EdkIIBuildOption\r
         ModuleOptions = self._ExpandBuildOption(Module.BuildOptions)\r
         if Module in self.Platform.Modules:\r
             PlatformModule = self.Platform.Modules[str(Module)]\r
@@ -1181,6 +1213,8 @@ class PlatformAutoGen(AutoGen):
     ToolChainFamily     = property(_GetToolChainFamily)\r
     BuildRuleFamily     = property(_GetBuildRuleFamily)\r
     BuildOption         = property(_GetBuildOptions)    # toolcode : option\r
+    EdkBuildOption      = property(_GetEdkBuildOptions)   # edktoolcode : option\r
+    EdkIIBuildOption    = property(_GetEdkIIBuildOptions) # edkiitoolcode : option\r
 \r
     BuildCommand        = property(_GetBuildCommand)\r
     BuildRule           = property(_GetBuildRule)\r
index 0a2bb62..f90dfe4 100644 (file)
@@ -961,9 +961,46 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd):
         Array = ''
         Value = Pcd.DefaultValue\r
         Unicode = False
-        if Pcd.DatumType == 'UINT64':
-            if not Value.endswith('ULL'):
-                Value += 'ULL'
+        ValueNumber = 0
+        if Pcd.DatumType in ['UINT64', 'UINT32', 'UINT16', 'UINT8']:
+            if Value.upper().startswith('0X'):
+                ValueNumber = int (Value, 16)
+            else:
+                ValueNumber = int (Value)
+            if Pcd.DatumType == 'UINT64':
+                if abs (ValueNumber) >= 0x10000000000000000:
+                    EdkLogger.error("build", AUTOGEN_ERROR,
+                                    "Too large PCD value for datum type [%s] of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, Pcd.TokenCName),
+                                    ExtraData="[%s]" % str(Info))
+                if ValueNumber < 0:
+                    ValueNumber = 0x10000000000000000 + ValueNumber
+                    Value = str (ValueNumber)
+                if not Value.endswith('ULL'):
+                    Value += 'ULL'
+            elif Pcd.DatumType == 'UINT32':
+                if abs (ValueNumber) >= 0x100000000:
+                    EdkLogger.error("build", AUTOGEN_ERROR,
+                                    "Too large PCD value for datum type [%s] of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, Pcd.TokenCName),
+                                    ExtraData="[%s]" % str(Info))
+                if ValueNumber < 0:
+                    ValueNumber = 0x100000000 + ValueNumber
+                    Value = str (ValueNumber)
+            elif Pcd.DatumType == 'UINT16':
+                if abs (ValueNumber) >= 0x10000:
+                    EdkLogger.error("build", AUTOGEN_ERROR,
+                                    "Too large PCD value for datum type [%s] of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, Pcd.TokenCName),
+                                    ExtraData="[%s]" % str(Info))
+                if ValueNumber < 0:
+                    ValueNumber = 0x10000 + ValueNumber
+                    Value = str (ValueNumber)
+            elif Pcd.DatumType == 'UINT8':
+                if abs (ValueNumber) >= 0x100:
+                    EdkLogger.error("build", AUTOGEN_ERROR,
+                                    "Too large PCD value for datum type [%s] of PCD %s.%s" % (Pcd.DatumType, Pcd.TokenSpaceGuidCName, Pcd.TokenCName),
+                                    ExtraData="[%s]" % str(Info))
+                if ValueNumber < 0:
+                    ValueNumber = 0x100 + ValueNumber
+                    Value = str (ValueNumber)
         if Pcd.DatumType == 'VOID*':
             if Pcd.MaxDatumSize == None or Pcd.MaxDatumSize == '':
                 EdkLogger.error("build", AUTOGEN_ERROR,
@@ -1021,7 +1058,7 @@ def CreateModulePcdCode(Info, AutoGenC, AutoGenH, Pcd):
                 AutoGenH.Append('#define %s  %s%s\n' %(GetModeName, Type, PcdVariableName))
         elif Pcd.Type == TAB_PCDS_PATCHABLE_IN_MODULE:
             AutoGenH.Append('#define %s  %s\n' %(PcdValueName, Value))
-            AutoGenC.Append('GLOBAL_REMOVE_IF_UNREFERENCED volatile %s %s %s = %s;\n' %(Const, Pcd.DatumType, PcdVariableName, PcdValueName))
+            AutoGenC.Append('volatile %s %s %s = %s;\n' %(Const, Pcd.DatumType, PcdVariableName, PcdValueName))
             AutoGenH.Append('extern volatile %s  %s  %s%s;\n' % (Const, Pcd.DatumType, PcdVariableName, Array))
             AutoGenH.Append('#define %s  %s%s\n' % (GetModeName, Type, PcdVariableName))
         else:
index 982ea93..a49de46 100755 (executable)
@@ -84,7 +84,7 @@ UNKNOWN_ERROR = 0xFFFF
 
 ## Error message of each error code
 gErrorMessage = {
-    FILE_NOT_FOUND          :   "File/directory not found",
+    FILE_NOT_FOUND          :   "File/directory not found in workspace",
     FILE_OPEN_FAILURE       :   "File open failure",
     FILE_WRITE_FAILURE      :   "File write failure",
     FILE_PARSE_FAILURE      :   "File parse failure",
index c2da992..dd33380 100644 (file)
@@ -73,6 +73,8 @@ EDK_COMPONENT_TYPE_BS_DRIVER = 'BS_DRIVER'
 EDK_COMPONENT_TYPE_RT_DRIVER = 'RT_DRIVER'\r
 EDK_COMPONENT_TYPE_SAL_RT_DRIVER = 'SAL_RT_DRIVER'\r
 EDK_COMPONENT_TYPE_APPLICATION = 'APPLICATION'\r
+EDK_NAME   = 'EDK'\r
+EDKII_NAME = 'EDKII'\r
 \r
 BINARY_FILE_TYPE_FW = 'FW'\r
 BINARY_FILE_TYPE_GUID = 'GUID'\r
@@ -230,6 +232,19 @@ TAB_PCDS_DYNAMIC_EBC = TAB_PCDS + TAB_PCDS_DYNAMIC + TAB_SPLIT + TAB_ARCH_EBC
 TAB_PCD_DYNAMIC_TYPE_LIST = [TAB_PCDS_DYNAMIC_DEFAULT_NULL, TAB_PCDS_DYNAMIC_VPD_NULL, TAB_PCDS_DYNAMIC_HII_NULL]\r
 TAB_PCD_DYNAMIC_EX_TYPE_LIST = [TAB_PCDS_DYNAMIC_EX_DEFAULT_NULL, TAB_PCDS_DYNAMIC_EX_VPD_NULL, TAB_PCDS_DYNAMIC_EX_HII_NULL]\r
 \r
+TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_PEI_PAGE_SIZE = 'PcdLoadFixAddressPeiCodePageNumber'\r
+TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_PEI_PAGE_SIZE_DATA_TYPE = 'UINT32'\r
+TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_DXE_PAGE_SIZE = 'PcdLoadFixAddressBootTimeCodePageNumber'\r
+TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_DXE_PAGE_SIZE_DATA_TYPE = 'UINT32'\r
+TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_RUNTIME_PAGE_SIZE = 'PcdLoadFixAddressRuntimeCodePageNumber'\r
+TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_RUNTIME_PAGE_SIZE_DATA_TYPE = 'UINT32'\r
+TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_SMM_PAGE_SIZE = 'PcdLoadFixAddressSmmCodePageNumber'\r
+TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_SMM_PAGE_SIZE_DATA_TYPE = 'UINT32'\r
+TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_LIST = [TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_PEI_PAGE_SIZE, \\r
+                                            TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_DXE_PAGE_SIZE, \\r
+                                            TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_RUNTIME_PAGE_SIZE, \\r
+                                            TAB_PCDS_PATCHABLE_LOAD_FIX_ADDRESS_SMM_PAGE_SIZE]\r
+\r
 TAB_DEPEX = 'Depex'\r
 TAB_DEPEX_COMMON = TAB_DEPEX + TAB_SPLIT + TAB_ARCH_COMMON\r
 TAB_DEPEX_IA32 = TAB_DEPEX + TAB_SPLIT + TAB_ARCH_IA32\r
@@ -338,6 +353,7 @@ TAB_DSC_DEFINES_MAKEFILE_NAME = 'MAKEFILE_NAME'
 TAB_DSC_DEFINES_BS_BASE_ADDRESS = 'BsBaseAddress'\r
 TAB_DSC_DEFINES_RT_BASE_ADDRESS = 'RtBaseAddress'\r
 TAB_DSC_DEFINES_DEFINE = 'DEFINE'\r
+TAB_FIX_LOAD_TOP_MEMORY_ADDRESS = 'FIX_LOAD_TOP_MEMORY_ADDRESS'\r
 \r
 #\r
 # TargetTxt Definitions\r
index 11b6496..9a22ab3 100644 (file)
@@ -134,6 +134,7 @@ class DscBuildData(PlatformBuildClassObject):
         self._LibraryClasses    = None
         self._Pcds              = None
         self._BuildOptions      = None
+        self._LoadFixAddress    = None
 
     ## Get architecture
     def _GetArch(self):
@@ -185,6 +186,8 @@ class DscBuildData(PlatformBuildClassObject):
             elif Name == TAB_DSC_DEFINES_SKUID_IDENTIFIER:
                 if self._SkuName == None:
                     self._SkuName = Record[1]
+            elif Name == TAB_FIX_LOAD_TOP_MEMORY_ADDRESS:
+                self._LoadFixAddress = Record[1]
         # set _Header to non-None in order to avoid database re-querying
         self._Header = 'DUMMY'
 
@@ -309,6 +312,15 @@ class DscBuildData(PlatformBuildClassObject):
                 self._RtBaseAddress = ''
         return self._RtBaseAddress
 
+    ## Retrieve the top address for the load fix address
+    def _GetLoadFixAddress(self):
+        if self._LoadFixAddress == None:
+            if self._Header == None:
+                self._GetHeaderInfo()
+            if self._LoadFixAddress == None:
+                self._LoadFixAddress = ''
+        return self._LoadFixAddress
+
     ## Retrieve [SkuIds] section information
     def _GetSkuIds(self):
         if self._SkuIds == None:
@@ -513,9 +525,18 @@ class DscBuildData(PlatformBuildClassObject):
     def _GetBuildOptions(self):
         if self._BuildOptions == None:
             self._BuildOptions = {}
-            RecordList = self._RawData[MODEL_META_DATA_BUILD_OPTION]
+            #
+            # Retrieve build option for EDKII style module
+            #
+            RecordList = self._RawData[MODEL_META_DATA_BUILD_OPTION, 'COMMON', EDKII_NAME]
+            for ToolChainFamily, ToolChain, Option, Dummy1, Dummy2, Dummy3, Dummy4 in RecordList:
+                self._BuildOptions[ToolChainFamily, ToolChain, EDKII_NAME] = Option
+            #
+            # Retrieve build option for EDK style module
+            #
+            RecordList = self._RawData[MODEL_META_DATA_BUILD_OPTION, 'COMMON', EDK_NAME]     
             for ToolChainFamily, ToolChain, Option, Dummy1, Dummy2, Dummy3, Dummy4 in RecordList:
-                self._BuildOptions[ToolChainFamily, ToolChain] = Option
+                self._BuildOptions[ToolChainFamily, ToolChain, EDK_NAME] = Option
         return self._BuildOptions
 
     ## Retrieve non-dynamic PCD settings
@@ -730,6 +751,7 @@ class DscBuildData(PlatformBuildClassObject):
     MakefileName        = property(_GetMakefileName)
     BsBaseAddress       = property(_GetBsBaseAddress)
     RtBaseAddress       = property(_GetRtBaseAddress)
+    LoadFixAddress      = property(_GetLoadFixAddress)
 
     SkuIds              = property(_GetSkuIds)
     Modules             = property(_GetModules)