]> git.proxmox.com Git - mirror_edk2.git/blobdiff - BaseTools/Source/Python/AutoGen/GenC.py
BaseTools: Enhance BaseTools supports FixedAtBuild usage in VFR file
[mirror_edk2.git] / BaseTools / Source / Python / AutoGen / GenC.py
index 63cfe0422bbcac51def87b3648d7182632f699a2..c1d64cccfdba0b4b4305ced4a81e87c2aa7c09de 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 # Routines for generating AutoGen.h and AutoGen.c\r
 #\r
-# Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>\r
 # This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 # which accompanies this distribution.  The full text of the license may be found at\r
@@ -1960,6 +1960,29 @@ def CreateCode(Info, AutoGenC, AutoGenH, StringH, UniGenCFlag, UniGenBinBuffer,
             GuidMacros.append('#define %s %s' % (Guid, Info.Module.Guids[Guid]))\r
         for Guid, Value in Info.Module.Protocols.items() + Info.Module.Ppis.items():\r
             GuidMacros.append('#define %s %s' % (Guid, Value))\r
+        # supports FixedAtBuild usage in VFR file\r
+        if Info.VfrFileList and Info.ModulePcdList:\r
+            GuidMacros.append('#define %s %s' % ('FixedPcdGetBool(TokenName)', '_PCD_VALUE_##TokenName'))\r
+            GuidMacros.append('#define %s %s' % ('FixedPcdGet8(TokenName)', '_PCD_VALUE_##TokenName'))\r
+            GuidMacros.append('#define %s %s' % ('FixedPcdGet16(TokenName)', '_PCD_VALUE_##TokenName'))\r
+            GuidMacros.append('#define %s %s' % ('FixedPcdGet32(TokenName)', '_PCD_VALUE_##TokenName'))\r
+            GuidMacros.append('#define %s %s' % ('FixedPcdGet64(TokenName)', '_PCD_VALUE_##TokenName'))\r
+            for Pcd in Info.ModulePcdList:\r
+                if Pcd.Type == TAB_PCDS_FIXED_AT_BUILD:\r
+                    TokenCName = Pcd.TokenCName\r
+                    Value = Pcd.DefaultValue\r
+                    if Pcd.DatumType == 'BOOLEAN':\r
+                        BoolValue = Value.upper()\r
+                        if BoolValue == 'TRUE':\r
+                            Value = '1'\r
+                        elif BoolValue == 'FALSE':\r
+                            Value = '0'\r
+                    for PcdItem in GlobalData.MixedPcd:\r
+                        if (Pcd.TokenCName, Pcd.TokenSpaceGuidCName) in GlobalData.MixedPcd[PcdItem]:\r
+                            TokenCName = PcdItem[0]\r
+                            break\r
+                    GuidMacros.append('#define %s %s' % ('_PCD_VALUE_'+TokenCName, Value))\r
+\r
         if GuidMacros:\r
             StringH.Append('\n#ifdef VFRCOMPILE\n%s\n#endif\n' % '\n'.join(GuidMacros))\r
 \r