# Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.<BR>\r
# Copyright (c) 2015, Hewlett Packard Enterprise Development, L.P.<BR>\r
#\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
-# 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
self.FileName = FileName\r
self.FileLinesList = []\r
try:\r
- with open(FileName, "rb", 0) as fsock:\r
+ with open(FileName, "r") as fsock:\r
self.FileLinesList = fsock.readlines()\r
for index, line in enumerate(self.FileLinesList):\r
if not line.endswith(TAB_LINE_BREAK):\r
def __init__(self, FileName):\r
self.FileLinesList = []\r
try:\r
- with open(FileName, "rb", 0) as fsock:\r
+ with open(FileName, "r") as fsock:\r
self.FileLinesList = fsock.readlines()\r
\r
except:\r
EndPos = CurLine.find(')', StartPos+2)\r
while StartPos != -1 and EndPos != -1 and self._Token not in {TAB_IF_DEF, TAB_IF_N_DEF, TAB_IF, TAB_ELSE_IF}:\r
MacroName = CurLine[StartPos+2: EndPos]\r
- MacorValue = self._GetMacroValue(MacroName)\r
- if MacorValue is not None:\r
- CurLine = CurLine.replace('$(' + MacroName + ')', MacorValue, 1)\r
- if MacorValue.find('$(') != -1:\r
+ MacroValue = self._GetMacroValue(MacroName)\r
+ if MacroValue is not None:\r
+ CurLine = CurLine.replace('$(' + MacroName + ')', MacroValue, 1)\r
+ if MacroValue.find('$(') != -1:\r
PreIndex = StartPos\r
else:\r
- PreIndex = StartPos + len(MacorValue)\r
+ PreIndex = StartPos + len(MacroValue)\r
else:\r
PreIndex = EndPos + 1\r
StartPos = CurLine.find('$(', PreIndex)\r
\r
## _GetNextToken() method\r
#\r
- # Get next token unit before a seperator\r
+ # Get next token unit before a separator\r
# If found, the string value is put into self._Token\r
#\r
# @param self The object pointer\r
StartLine = self.CurrentLineNumber\r
while StartLine == self.CurrentLineNumber:\r
TempChar = self._CurrentChar()\r
- # Try to find the end char that is not a space and not in seperator tuple.\r
+ # Try to find the end char that is not a space and not in separator tuple.\r
# That is, when we got a space or any char in the tuple, we got the end of token.\r
if not str(TempChar).isspace() and TempChar not in SEPARATORS:\r
self._GetOneChar()\r
- # if we happen to meet a seperator as the first char, we must proceed to get it.\r
- # That is, we get a token that is a seperator char. nomally it is the boundary of other tokens.\r
+ # if we happen to meet a separator as the first char, we must proceed to get it.\r
+ # That is, we get a token that is a separator char. normally it is the boundary of other tokens.\r
elif StartPos == self.CurrentOffsetWithinLine and TempChar in SEPARATORS:\r
self._GetOneChar()\r
break\r
\r
## _GetNextGuid() method\r
#\r
- # Get next token unit before a seperator\r
+ # Get next token unit before a separator\r
# If found, the GUID string is put into self._Token\r
#\r
# @param self The object pointer\r
while CurrentLine == self.CurrentLineNumber:\r
\r
TempChar = self._CurrentChar()\r
- # Try to find the end char that is not a space and not in seperator tuple.\r
+ # Try to find the end char that is not a space and not in separator tuple.\r
# That is, when we got a space or any char in the tuple, we got the end of token.\r
if not str(TempChar).isspace() and not TempChar in SEPARATORS:\r
if not self._UndoOneChar():\r
return\r
- # if we happen to meet a seperator as the first char, we must proceed to get it.\r
- # That is, we get a token that is a seperator char. nomally it is the boundary of other tokens.\r
+ # if we happen to meet a separator as the first char, we must proceed to get it.\r
+ # That is, we get a token that is a separator char. normally it is the boundary of other tokens.\r
elif StartPos == self.CurrentOffsetWithinLine and TempChar in SEPARATORS:\r
return\r
else:\r
\r
## _GetNextHexNumber() method\r
#\r
- # Get next HEX data before a seperator\r
+ # Get next HEX data before a separator\r
# If found, the HEX data is put into self._Token\r
#\r
# @param self The object pointer\r
\r
## _GetNextDecimalNumber() method\r
#\r
- # Get next decimal data before a seperator\r
+ # Get next decimal data before a separator\r
# If found, the decimal data is put into self._Token\r
#\r
# @param self The object pointer\r
self.SetPcdLocalation(pcdPair)\r
FileLineTuple = GetRealFileLine(self.FileName, self.CurrentLineNumber)\r
self.Profile.PcdFileLineDict[pcdPair] = FileLineTuple\r
- Obj.Size = long(Size, 0)\r
+ Obj.Size = int(Size, 0)\r
return True\r
\r
if self._IsKeyword("ErasePolarity"):\r
if not self._GetNextDecimalNumber() and not self._GetNextHexNumber():\r
raise Warning.Expected("address", self.FileName, self.CurrentLineNumber)\r
\r
- BsAddress = long(self._Token, 0)\r
+ BsAddress = int(self._Token, 0)\r
Obj.BsBaseAddress = BsAddress\r
\r
if self._IsKeyword("RtBaseAddress"):\r
if not self._GetNextDecimalNumber() and not self._GetNextHexNumber():\r
raise Warning.Expected("address", self.FileName, self.CurrentLineNumber)\r
\r
- RtAddress = long(self._Token, 0)\r
+ RtAddress = int(self._Token, 0)\r
Obj.RtBaseAddress = RtAddress\r
\r
## _GetBlockStatements() method\r
self.SetPcdLocalation(PcdPair)\r
FileLineTuple = GetRealFileLine(self.FileName, self.CurrentLineNumber)\r
self.Profile.PcdFileLineDict[PcdPair] = FileLineTuple\r
- BlockSize = long(BlockSize, 0)\r
+ BlockSize = int(BlockSize, 0)\r
\r
BlockNumber = None\r
if self._IsKeyword("NumBlocks"):\r
if not self._GetNextDecimalNumber() and not self._GetNextHexNumber():\r
raise Warning.Expected("block numbers", self.FileName, self.CurrentLineNumber)\r
\r
- BlockNumber = long(self._Token, 0)\r
+ BlockNumber = int(self._Token, 0)\r
\r
Obj.BlockSizeList.append((BlockSize, BlockNumber, BlockSizePcd))\r
return True\r
Expr += CurCh\r
self._GetOneChar()\r
try:\r
- return long(\r
+ return int(\r
ValueExpression(Expr,\r
self._CollectMacroPcd()\r
)(True), 0)\r
RegionOffsetPcdPattern.match(self._CurrentLine()[self.CurrentOffsetWithinLine:]))\r
if IsRegionPcd:\r
RegionObj.PcdOffset = self._GetNextPcdSettings()\r
- self.Profile.PcdDict[RegionObj.PcdOffset] = "0x%08X" % (RegionObj.Offset + long(theFd.BaseAddress, 0))\r
+ self.Profile.PcdDict[RegionObj.PcdOffset] = "0x%08X" % (RegionObj.Offset + int(theFd.BaseAddress, 0))\r
self.SetPcdLocalation(RegionObj.PcdOffset)\r
self._PcdDict['%s.%s' % (RegionObj.PcdOffset[1], RegionObj.PcdOffset[0])] = "0x%x" % RegionObj.Offset\r
FileLineTuple = GetRealFileLine(self.FileName, self.CurrentLineNumber)\r
if FdfParser._Verify(Name, Value, 'UINT64'):\r
FmpData.MonotonicCount = Value\r
if FmpData.MonotonicCount.upper().startswith('0X'):\r
- FmpData.MonotonicCount = (long)(FmpData.MonotonicCount, 16)\r
+ FmpData.MonotonicCount = int(FmpData.MonotonicCount, 16)\r
else:\r
- FmpData.MonotonicCount = (long)(FmpData.MonotonicCount)\r
+ FmpData.MonotonicCount = int(FmpData.MonotonicCount)\r
if not self._GetNextToken():\r
break\r
else:\r
\r
if not self._IsKeyword("$(NAMED_GUID)"):\r
if not self._GetNextWord():\r
- raise Warning.Expected("$(NAMED_GUID)", self.FileName, self.CurrentLineNumber)\r
+ NamedGuid = self._CurrentLine()[self.CurrentOffsetWithinLine:].split()[0].strip()\r
+ if GlobalData.gGuidPatternEnd.match(NamedGuid):\r
+ self.CurrentOffsetWithinLine += len(NamedGuid)\r
+ self._Token = NamedGuid\r
+ else:\r
+ raise Warning.Expected("$(NAMED_GUID)", self.FileName, self.CurrentLineNumber)\r
if self._Token == 'PCD':\r
if not self._IsToken("("):\r
raise Warning.Expected("'('", self.FileName, self.CurrentLineNumber)\r
#\r
def _GetEfiSection(self, Obj):\r
OldPos = self.GetFileBufferPos()\r
+ EfiSectionObj = EfiSection()\r
if not self._GetNextWord():\r
- return False\r
+ CurrentLine = self._CurrentLine()[self.CurrentOffsetWithinLine:].split()[0].strip()\r
+ if self._Token == '{' and Obj.FvFileType == "RAW" and TAB_SPLIT in CurrentLine:\r
+ if self._IsToken(TAB_VALUE_SPLIT):\r
+ EfiSectionObj.FileExtension = self._GetFileExtension()\r
+ elif self._GetNextToken():\r
+ EfiSectionObj.FileName = self._Token\r
+ EfiSectionObj.SectionType = BINARY_FILE_TYPE_RAW\r
+ Obj.SectionList.append(EfiSectionObj)\r
+ return True\r
+ else:\r
+ return False\r
SectionName = self._Token\r
\r
if SectionName not in {\r
Obj.SectionList.append(FvImageSectionObj)\r
return True\r
\r
- EfiSectionObj = EfiSection()\r
EfiSectionObj.SectionType = SectionName\r
\r
if not self._GetNextToken():\r