## @ GenCfgOpt.py\r
#\r
# Copyright (c) 2014 - 2015, Intel Corporation. All rights reserved.<BR>\r
-# This program and the accompanying materials are licensed and made available under\r
-# the terms and conditions of the BSD License that accompanies this distribution.\r
-# The full text of the license may be found at\r
-# http://opensource.org/licenses/bsd-license.php.\r
-#\r
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+# SPDX-License-Identifier: BSD-2-Clause-Patent\r
#\r
##\r
\r
**/\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
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
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