]> git.proxmox.com Git - mirror_edk2.git/blobdiff - IntelFspPkg/Tools/GenCfgOpt.py
Add Dual-FSP support (MemoryInitUpd/SiliconInitUpd)
[mirror_edk2.git] / IntelFspPkg / Tools / GenCfgOpt.py
index 77eaf6481ff4166eaaab7cb90403769d1f5c7db3..a38da70212a8cceee328e6b1667ceef6751ef3a9 100644 (file)
@@ -88,6 +88,48 @@ are permitted provided that the following conditions are met:
 **/\r
 """\r
 \r
+def UpdateMemSiUpdInitOffsetValue (DscFile):\r
+    DscFd        = open(DscFile, "r")\r
+    DscLines     = DscFd.readlines()\r
+    DscFd.close()\r
+\r
+    DscContent = []\r
+    MemUpdInitOffset = 0\r
+    SiUpdInitOffset = 0\r
+    MemUpdInitOffsetValue = 0\r
+    SiUpdInitOffsetValue = 0\r
+\r
+    while len(DscLines):\r
+        DscLine  = DscLines.pop(0)\r
+        DscContent.append(DscLine)\r
+        DscLine = DscLine.strip()\r
+        Match = re.match("^([_a-zA-Z0-9]+).(MemoryInitUpdOffset)\s*\|\s*(0x[0-9A-F]+)\s*\|\s*(\d+|0x[0-9a-fA-F]+)\s*\|\s*(.+)",DscLine)\r
+        if Match:\r
+            MemUpdInitOffsetValue = int(Match.group(5), 0)\r
+        Match = re.match("^\s*([_a-zA-Z0-9]+).(SiliconInitUpdOffset)\s*\|\s*(0x[0-9A-F]+)\s*\|\s*(\d+|0x[0-9a-fA-F]+)\s*\|\s*(.+)",DscLine)\r
+        if Match:\r
+            SiUpdInitOffsetValue = int(Match.group(5), 0)\r
+        Match = re.match("^([_a-zA-Z0-9]+).([_a-zA-Z0-9]+)\s*\|\s*(0x[0-9A-F]+)\s*\|\s*(\d+|0x[0-9a-fA-F]+)\s*\|\s*(0x244450554D454D24)",DscLine)\r
+        if Match:\r
+            MemUpdInitOffset = int(Match.group(3), 0)\r
+        Match = re.match("^([_a-zA-Z0-9]+).([_a-zA-Z0-9]+)\s*\|\s*(0x[0-9A-F]+)\s*\|\s*(\d+|0x[0-9a-fA-F]+)\s*\|\s*(0x244450555F495324)",DscLine)\r
+        if Match:\r
+            SiUpdInitOffset = int(Match.group(3), 0)\r
+\r
+    if MemUpdInitOffsetValue != MemUpdInitOffset or SiUpdInitOffsetValue != SiUpdInitOffset:\r
+        MemUpdInitOffsetStr = "0x%08X" % MemUpdInitOffset\r
+        SiUpdInitOffsetStr = "0x%08X" % SiUpdInitOffset\r
+        DscFd = open(DscFile,"w")\r
+        for DscLine in DscContent:\r
+            Match = re.match("^\s*([_a-zA-Z0-9]+).(MemoryInitUpdOffset)\s*\|\s*(0x[0-9A-F]+)\s*\|\s*(\d+|0x[0-9a-fA-F]+)\s*\|\s*(.+)",DscLine)\r
+            if Match:\r
+                 DscLine = re.sub(r'(?:[^\s]+\s*$)', MemUpdInitOffsetStr + '\n', DscLine)\r
+            Match = re.match("^\s*([_a-zA-Z0-9]+).(SiliconInitUpdOffset)\s*\|\s*(0x[0-9A-F]+)\s*\|\s*(\d+|0x[0-9a-fA-F]+)\s*\|\s*(.+)",DscLine)\r
+            if Match:\r
+                 DscLine = re.sub(r'(?:[^\s]+\s*$)', SiUpdInitOffsetStr + '\n', line)\r
+            DscFd.writelines(DscLine)\r
+        DscFd.close()\r
+\r
 class CLogicalExpression:\r
     def __init__(self):\r
         self.index    = 0\r
@@ -889,6 +931,22 @@ EndList
                 return 256\r
 \r
         TxtBody = []\r
+        for Item in self._CfgItemList:\r
+           if str(Item['cname']) == 'Signature' and Item['length'] == 8:\r
+               Value = int(Item['value'], 16)\r
+               Chars = []\r
+               while Value != 0x0:\r
+                   Chars.append(chr(Value & 0xFF))\r
+                   Value = Value >> 8\r
+               SignatureStr = ''.join(Chars)\r
+               if int(Item['offset']) == 0:\r
+                   TxtBody.append("#define FSP_UPD_SIGNATURE                %s        /* '%s' */\n" % (Item['value'], SignatureStr))\r
+               elif 'MEM' in SignatureStr:\r
+                   TxtBody.append("#define FSP_MEMORY_INIT_UPD_SIGNATURE    %s        /* '%s' */\n" % (Item['value'], SignatureStr))\r
+               else:\r
+                   TxtBody.append("#define FSP_SILICON_INIT_UPD_SIGNATURE   %s        /* '%s' */\n" % (Item['value'], SignatureStr))\r
+        TxtBody.append("\n")\r
+\r
         for Region in ['UPD', 'VPD']:\r
 \r
             # Write  PcdVpdRegionSign and PcdImageRevision\r
@@ -1176,6 +1234,8 @@ def Main():
             print "ERROR: Cannot open DSC file '%s' !" % DscFile\r
             return 2\r
 \r
+        UpdateMemSiUpdInitOffsetValue(DscFile)\r
+\r
         OutFile = ''\r
         if argc > 4:\r
             if sys.argv[4][0] == '-':\r