Revision: 16495
          http://sourceforge.net/p/edk2/code/16495
Author:   vanjeff
Date:     2014-12-10 08:21:46 +0000 (Wed, 10 Dec 2014)
Log Message:
-----------
Sync BaseTool from EDKII trunk r16487.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <[email protected]>
Reviewed-by: Liming Gao <[email protected]>

Revision Links:
--------------
    http://sourceforge.net/p/edk2/code/16487

Modified Paths:
--------------
    branches/UDK2014.SP1/BaseTools/Bin/externals.txt
    branches/UDK2014.SP1/BaseTools/Conf/build_rule.template
    branches/UDK2014.SP1/BaseTools/Conf/tools_def.template
    branches/UDK2014.SP1/BaseTools/Contributions.txt
    branches/UDK2014.SP1/BaseTools/Source/C/GenFw/Elf64Convert.c
    branches/UDK2014.SP1/BaseTools/Source/C/Makefiles/header.makefile
    branches/UDK2014.SP1/BaseTools/Source/Python/AutoGen/AutoGen.py
    branches/UDK2014.SP1/BaseTools/Source/Python/AutoGen/GenC.py
    branches/UDK2014.SP1/BaseTools/Source/Python/AutoGen/GenMake.py
    branches/UDK2014.SP1/BaseTools/Source/Python/AutoGen/UniClassObject.py
    branches/UDK2014.SP1/BaseTools/Source/Python/Common/DataType.py
    branches/UDK2014.SP1/BaseTools/Source/Python/CommonDataClass/DataClass.py
    branches/UDK2014.SP1/BaseTools/Source/Python/Ecc/Check.py
    
branches/UDK2014.SP1/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py
    branches/UDK2014.SP1/BaseTools/Source/Python/GenFds/GuidSection.py
    
branches/UDK2014.SP1/BaseTools/Source/Python/UPT/Parser/InfGuidPpiProtocolSectionParser.py
    
branches/UDK2014.SP1/BaseTools/Source/Python/UPT/PomAdapter/InfPomAlignment.py
    branches/UDK2014.SP1/BaseTools/Source/Python/UPT/Xml/ModuleSurfaceAreaXml.py

Added Paths:
-----------
    branches/UDK2014.SP1/BaseTools/.gitignore
    branches/UDK2014.SP1/BaseTools/Scripts/ConvertMasmToNasm.py

Property Changed:
----------------
    branches/UDK2014.SP1/BaseTools/Bin/

Added: branches/UDK2014.SP1/BaseTools/.gitignore
===================================================================
--- branches/UDK2014.SP1/BaseTools/.gitignore                           (rev 0)
+++ branches/UDK2014.SP1/BaseTools/.gitignore   2014-12-10 08:21:46 UTC (rev 
16495)
@@ -0,0 +1,14 @@
+*.d
+*.o
+*.pyc
+Source/C/VfrCompile/EfiVfrParser.cpp
+Source/C/VfrCompile/EfiVfrParser.h
+Source/C/VfrCompile/Pccts/antlr/antlr
+Source/C/VfrCompile/Pccts/dlg/dlg
+Source/C/VfrCompile/VfrLexer.cpp
+Source/C/VfrCompile/VfrLexer.h
+Source/C/VfrCompile/VfrParser.dlg
+Source/C/VfrCompile/VfrSyntax.cpp
+Source/C/VfrCompile/VfrTokens.h
+Source/C/bin/
+Source/C/libs/

Index: branches/UDK2014.SP1/BaseTools/Bin
===================================================================
--- branches/UDK2014.SP1/BaseTools/Bin  2014-12-10 08:21:05 UTC (rev 16494)
+++ branches/UDK2014.SP1/BaseTools/Bin  2014-12-10 08:21:46 UTC (rev 16495)

Property changes on: branches/UDK2014.SP1/BaseTools/Bin
___________________________________________________________________
Modified: svn:externals
## -1 +1 ##
-Win32  -r29 https://svn.code.sf.net/p/edk2-toolbinaries/code/trunk/Win32
+Win32  -r46 https://svn.code.sf.net/p/edk2-toolbinaries/code/trunk/Win32
Modified: branches/UDK2014.SP1/BaseTools/Bin/externals.txt
===================================================================
--- branches/UDK2014.SP1/BaseTools/Bin/externals.txt    2014-12-10 08:21:05 UTC 
(rev 16494)
+++ branches/UDK2014.SP1/BaseTools/Bin/externals.txt    2014-12-10 08:21:46 UTC 
(rev 16495)
@@ -1 +1 @@
-Win32  -r29 https://svn.code.sf.net/p/edk2-toolbinaries/code/trunk/Win32
+Win32  -r46 https://svn.code.sf.net/p/edk2-toolbinaries/code/trunk/Win32

Modified: branches/UDK2014.SP1/BaseTools/Conf/build_rule.template
===================================================================
--- branches/UDK2014.SP1/BaseTools/Conf/build_rule.template     2014-12-10 
08:21:05 UTC (rev 16494)
+++ branches/UDK2014.SP1/BaseTools/Conf/build_rule.template     2014-12-10 
08:21:46 UTC (rev 16495)
@@ -131,12 +131,34 @@
     <Command.GCC, Command.RVCT>
         # For RVCTCYGWIN CC_FLAGS must be first to work around pathing issues
         "$(CC)" $(CC_FLAGS) -o ${dst} $(INC) ${src}
-        "$(SYMRENAME)" $(SYMRENAME_FLAGS) ${dst}
 
     <Command.ARMGCC, Command.ARMLINUXGCC, command.XCODE>
         "$(CC)" $(CC_FLAGS) -o ${dst} $(INC) ${src}
 
+[C-Code-File.COMMON.IPF]
+    <InputFile>
+        ?.c
+        ?.C
+        ?.cc
+        ?.CC
+        ?.cpp
+        ?.Cpp
+        ?.CPP
 
+    <ExtraDependency>
+        $(MAKE_FILE)
+
+    <OutputFile>
+        $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
+
+    <Command.MSFT, Command.INTEL>
+        "$(CC)" /Fo${dst} $(CC_FLAGS) $(INC) ${src}
+
+    <Command.GCC, Command.RVCT>
+        # For RVCTCYGWIN CC_FLAGS must be first to work around pathing issues
+        "$(CC)" $(CC_FLAGS) -o ${dst} $(INC) ${src}
+        "$(SYMRENAME)" $(SYMRENAME_FLAGS) ${dst}
+
 [C-Header-File]
     <InputFile>
         *.h, *.H

Modified: branches/UDK2014.SP1/BaseTools/Conf/tools_def.template
===================================================================
--- branches/UDK2014.SP1/BaseTools/Conf/tools_def.template      2014-12-10 
08:21:05 UTC (rev 16494)
+++ branches/UDK2014.SP1/BaseTools/Conf/tools_def.template      2014-12-10 
08:21:46 UTC (rev 16495)
@@ -165,25 +165,23 @@
 DEFINE CYGWIN_BINX64           = 
c:/cygwin/opt/tiano/x86_64-pc-mingw64/x86_64-pc-mingw64/bin/
 DEFINE CYGWIN_BINIPF           = c:/cygwin/opt/tiano/gcc/ipf/bin/ia64-pc-elf-
 
-DEFINE GCC44_IA32_PREFIX       = /usr/bin/
-#DEFINE GCC44_IA32_PREFIX       = ENV(HOME)/programs/gcc/4.4/ia32/
-DEFINE GCC44_X64_PREFIX        = /usr/bin/
-#DEFINE GCC44_X64_PREFIX       = ENV(HOME)/programs/gcc/4.4/x64/
+DEFINE GCC44_IA32_PREFIX       = ENV(GCC44_BIN)
+DEFINE GCC44_X64_PREFIX        = ENV(GCC44_BIN)
 
-DEFINE GCC45_IA32_PREFIX       = /usr/bin/
-DEFINE GCC45_X64_PREFIX        = /usr/bin/
+DEFINE GCC45_IA32_PREFIX       = ENV(GCC45_BIN)
+DEFINE GCC45_X64_PREFIX        = ENV(GCC45_BIN)
 
-DEFINE GCC46_IA32_PREFIX       = /usr/bin/
-DEFINE GCC46_X64_PREFIX        = /usr/bin/
+DEFINE GCC46_IA32_PREFIX       = ENV(GCC46_BIN)
+DEFINE GCC46_X64_PREFIX        = ENV(GCC46_BIN)
 
-DEFINE GCC47_IA32_PREFIX       = /usr/bin/
-DEFINE GCC47_X64_PREFIX        = /usr/bin/
+DEFINE GCC47_IA32_PREFIX       = ENV(GCC47_BIN)
+DEFINE GCC47_X64_PREFIX        = ENV(GCC47_BIN)
 
-DEFINE GCC48_IA32_PREFIX       = /usr/bin/
-DEFINE GCC48_X64_PREFIX        = /usr/bin/
+DEFINE GCC48_IA32_PREFIX       = ENV(GCC48_BIN)
+DEFINE GCC48_X64_PREFIX        = ENV(GCC48_BIN)
 
-DEFINE GCC49_IA32_PREFIX       = /usr/bin/
-DEFINE GCC49_X64_PREFIX        = /usr/bin/
+DEFINE GCC49_IA32_PREFIX       = ENV(GCC49_BIN)
+DEFINE GCC49_X64_PREFIX        = ENV(GCC49_BIN)
 
 DEFINE UNIX_IASL_BIN           = ENV(IASL_PREFIX)iasl
 DEFINE WIN_ASL_BIN_DIR         = C:\ASL
@@ -309,38 +307,38 @@
 #                             Required to build platforms or ACPI tables:
 #                               Intel(r) ACPI Compiler v20101013 from
 #                               
http://www.acpica.org/downloads/previous_releases.php
-#   GCC44       -Linux-  Requires:
-#                             GCC 4.4 (Native)
+#   GCC44       -Linux,Windows-  Requires:
+#                             GCC 4.4 targeting x86_64-linux-gnu
 #                        Optional:
 #                             Required to build platforms or ACPI tables:
 #                               Intel(r) ACPI Compiler v20101013 from
 #                               
http://www.acpica.org/downloads/previous_releases.php
-#   GCC45       -Linux-  Requires:
-#                             GCC 4.5 (Native)
+#   GCC45       -Linux,Windows-  Requires:
+#                             GCC 4.5 targeting x86_64-linux-gnu
 #                        Optional:
 #                             Required to build platforms or ACPI tables:
 #                               Intel(r) ACPI Compiler v20101013 from
 #                               
http://www.acpica.org/downloads/previous_releases.php
-#   GCC46       -Linux-  Requires:
-#                             GCC 4.6 (Native)
+#   GCC46       -Linux,Windows-  Requires:
+#                             GCC 4.6 targeting x86_64-linux-gnu or 
arm-linux-gnueabi
 #                        Optional:
 #                             Required to build platforms or ACPI tables:
 #                               Intel(r) ACPI Compiler v20101013 from
 #                               
http://www.acpica.org/downloads/previous_releases.php
-#   GCC47       -Linux-  Requires:
-#                             GCC 4.7 (Native)
+#   GCC47       -Linux,Windows-  Requires:
+#                             GCC 4.7 targeting x86_64-linux-gnu, 
aarch64-linux-gnu, or arm-linux-gnueabi
 #                        Optional:
 #                             Required to build platforms or ACPI tables:
 #                               Intel(r) ACPI Compiler v20101013 from
 #                               
http://www.acpica.org/downloads/previous_releases.php
-#   GCC48       -Linux-  Requires:
-#                             GCC 4.8
+#   GCC48       -Linux,Windows-  Requires:
+#                             GCC 4.8 targeting x86_64-linux-gnu, 
aarch64-linux-gnu, or arm-linux-gnueabi
 #                        Optional:
 #                             Required to build platforms or ACPI tables:
 #                               Intel(r) ACPI Compiler v20101013 from
 #                               
http://www.acpica.org/downloads/previous_releases.php
-#   GCC49       -Linux-  Requires:
-#                             GCC 4.9
+#   GCC49       -Linux,Windows-  Requires:
+#                             GCC 4.9 targeting x86_64-linux-gnu, 
aarch64-linux-gnu, or arm-linux-gnueabi
 #                        Optional:
 #                             Required to build platforms or ACPI tables:
 #                               Intel(r) ACPI Compiler v20101013 from
@@ -3811,7 +3809,7 @@
 *_*_*_OBJCOPY_FLAGS             = objcopy not needed for
 *_*_*_SYMRENAME_PATH            = echo
 *_*_*_SYMRENAME_FLAGS           = Symbol renaming not needed for
-DEBUG_*_*_OBJCOPY_ADDDEBUGFLAG     = 
--add-gnu-debuglink=$(DEBUG_DIR)\$(MODULE_NAME).debug
+DEBUG_*_*_OBJCOPY_ADDDEBUGFLAG     = 
--add-gnu-debuglink=$(DEBUG_DIR)/$(MODULE_NAME).debug
 RELEASE_*_*_OBJCOPY_ADDDEBUGFLAG   =
 
 DEFINE GCC_ALL_CC_FLAGS            = -g -Os -fshort-wchar -fno-strict-aliasing 
-Wall -Werror -Wno-array-bounds -c -include AutoGen.h
@@ -3866,7 +3864,7 @@
 DEFINE GCC46_X64_DLINK_FLAGS         = DEF(GCC45_X64_DLINK_FLAGS)
 DEFINE GCC46_ASM_FLAGS               = DEF(GCC45_ASM_FLAGS)
 DEFINE GCC46_ARM_ASM_FLAGS           = $(ARCHASM_FLAGS) $(PLATFORM_FLAGS) 
DEF(GCC_ASM_FLAGS) -mlittle-endian
-DEFINE GCC46_ARM_CC_FLAGS            = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) 
DEF(GCC44_ALL_CC_FLAGS) DEF(GCC_ARM_CC_FLAGS) -mno-unaligned-access 
-fstack-protector
+DEFINE GCC46_ARM_CC_FLAGS            = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) 
DEF(GCC44_ALL_CC_FLAGS) DEF(GCC_ARM_CC_FLAGS) -fstack-protector
 DEFINE GCC46_ARM_DLINK_FLAGS         = DEF(GCC_ARM_AARCH64_DLINK_COMMON) 
--oformat=elf32-littlearm
 DEFINE GCC46_ARM_ASLDLINK_FLAGS      = DEF(GCC_ARM_AARCH64_ASLDLINK_FLAGS) 
--oformat=elf32-littlearm
 
@@ -3879,7 +3877,7 @@
 DEFINE GCC47_ASM_FLAGS               = DEF(GCC46_ASM_FLAGS)
 DEFINE GCC47_ARM_ASM_FLAGS           = DEF(GCC46_ARM_ASM_FLAGS)
 DEFINE GCC47_AARCH64_ASM_FLAGS       = $(ARCHASM_FLAGS) $(PLATFORM_FLAGS) 
DEF(GCC_ASM_FLAGS) -mlittle-endian
-DEFINE GCC47_ARM_CC_FLAGS            = DEF(GCC46_ARM_CC_FLAGS)
+DEFINE GCC47_ARM_CC_FLAGS            = DEF(GCC46_ARM_CC_FLAGS) 
-mno-unaligned-access
 DEFINE GCC47_AARCH64_CC_FLAGS        = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) 
DEF(GCC44_ALL_CC_FLAGS) DEF(GCC_AARCH64_CC_FLAGS)
 DEFINE GCC47_ARM_DLINK_FLAGS         = DEF(GCC46_ARM_DLINK_FLAGS)
 DEFINE GCC47_AARCH64_DLINK_FLAGS     = DEF(GCC_ARM_AARCH64_DLINK_COMMON)
@@ -3961,7 +3959,7 @@
 *_UNIXGCC_IA32_CC_FLAGS             = DEF(GCC_IA32_CC_FLAGS)
 *_UNIXGCC_IA32_RC_FLAGS             = DEF(GCC_IA32_RC_FLAGS)
 *_UNIXGCC_IA32_OBJCOPY_FLAGS        =
-*_UNIXGCC_IA32_NASM_FLAGS           = -f elf32
+*_UNIXGCC_IA32_NASM_FLAGS           = -f win32
 
 ##################
 # X64 definitions
@@ -3981,7 +3979,7 @@
 *_UNIXGCC_X64_CC_FLAGS              = DEF(GCC_X64_CC_FLAGS)
 *_UNIXGCC_X64_RC_FLAGS              = DEF(GCC_X64_RC_FLAGS)
 *_UNIXGCC_X64_OBJCOPY_FLAGS         =
-*_UNIXGCC_X64_NASM_FLAGS            = -f elf64
+*_UNIXGCC_X64_NASM_FLAGS            = -f win64
 
 ##################
 # IPF definitions
@@ -4014,7 +4012,8 @@
 
####################################################################################
 *_GCC44_*_*_FAMILY               = GCC
 
-*_GCC44_*_MAKE_PATH                    = make
+*_GCC44_*_MAKE_PATH                    = DEF(GCC44_IA32_PREFIX)make
+*_GCC44_*_*_DLL                        = ENV(GCC44_DLL)
 *_GCC44_*_ASL_PATH                     = DEF(UNIX_IASL_BIN)
 
 *_GCC44_*_PP_FLAGS                     = DEF(GCC_PP_FLAGS)
@@ -4081,7 +4080,8 @@
 
####################################################################################
 *_GCC45_*_*_FAMILY               = GCC
 
-*_GCC45_*_MAKE_PATH                    = make
+*_GCC45_*_MAKE_PATH                    = DEF(GCC45_IA32_PREFIX)make
+*_GCC45_*_*_DLL                        = ENV(GCC45_DLL)
 *_GCC45_*_ASL_PATH                     = DEF(UNIX_IASL_BIN)
 
 *_GCC45_*_PP_FLAGS                     = DEF(GCC_PP_FLAGS)
@@ -4148,7 +4148,8 @@
 
####################################################################################
 *_GCC46_*_*_FAMILY               = GCC
 
-*_GCC46_*_MAKE_PATH                    = make
+*_GCC46_*_MAKE_PATH                    = DEF(GCC46_IA32_PREFIX)make
+*_GCC46_*_*_DLL                        = ENV(GCC46_DLL)
 *_GCC46_*_ASL_PATH                     = DEF(UNIX_IASL_BIN)
 
 *_GCC46_*_PP_FLAGS                     = DEF(GCC_PP_FLAGS)
@@ -4245,7 +4246,8 @@
 
####################################################################################
 *_GCC47_*_*_FAMILY               = GCC
 
-*_GCC47_*_MAKE_PATH                    = make
+*_GCC47_*_MAKE_PATH                    = DEF(GCC47_IA32_PREFIX)make
+*_GCC47_*_*_DLL                        = ENV(GCC47_DLL)
 *_GCC47_*_ASL_PATH                     = DEF(UNIX_IASL_BIN)
 
 *_GCC47_*_PP_FLAGS                     = DEF(GCC_PP_FLAGS)
@@ -4367,7 +4369,8 @@
 
####################################################################################
 *_GCC48_*_*_FAMILY               = GCC
 
-*_GCC48_*_MAKE_PATH                    = make
+*_GCC48_*_MAKE_PATH                    = DEF(GCC48_IA32_PREFIX)make
+*_GCC48_*_*_DLL                        = ENV(GCC48_DLL)
 *_GCC48_*_ASL_PATH                     = DEF(UNIX_IASL_BIN)
 
 *_GCC48_*_PP_FLAGS                     = DEF(GCC_PP_FLAGS)
@@ -4489,7 +4492,8 @@
 
####################################################################################
 *_GCC49_*_*_FAMILY               = GCC
 
-*_GCC49_*_MAKE_PATH                    = make
+*_GCC49_*_MAKE_PATH                    = DEF(GCC49_IA32_PREFIX)make
+*_GCC49_*_*_DLL                        = ENV(GCC49_DLL)
 *_GCC49_*_ASL_PATH                     = DEF(UNIX_IASL_BIN)
 
 *_GCC49_*_PP_FLAGS                     = DEF(GCC_PP_FLAGS)
@@ -4649,7 +4653,7 @@
 *_CYGGCC_IA32_CC_FLAGS           = DEF(GCC_IA32_CC_FLAGS)
 *_CYGGCC_IA32_RC_FLAGS           = DEF(GCC_IA32_RC_FLAGS)
 *_CYGGCC_IA32_OBJCOPY_FLAGS      =
-*_CYGGCC_IA32_NASM_FLAGS         = -f elf32
+*_CYGGCC_IA32_NASM_FLAGS         = -f win32
 
 ##################
 # X64 definitions
@@ -4670,7 +4674,7 @@
 *_CYGGCC_X64_CC_FLAGS            = DEF(GCC_X64_CC_FLAGS)
 *_CYGGCC_X64_RC_FLAGS            = DEF(GCC_X64_RC_FLAGS)
 *_CYGGCC_X64_OBJCOPY_FLAGS       =
-*_CYGGCC_X64_NASM_FLAGS          = -f elf64
+*_CYGGCC_X64_NASM_FLAGS          = -f win64
 
 ##################
 # IPF definitions

Modified: branches/UDK2014.SP1/BaseTools/Contributions.txt
===================================================================
--- branches/UDK2014.SP1/BaseTools/Contributions.txt    2014-12-10 08:21:05 UTC 
(rev 16494)
+++ branches/UDK2014.SP1/BaseTools/Contributions.txt    2014-12-10 08:21:46 UTC 
(rev 16495)
@@ -34,9 +34,9 @@
    Contributions using other licenses might be accepted, but further
    review will be required.
 
-=======================================
-= Change Description / Commit Message =
-=======================================
+=====================================================
+= Change Description / Commit Message / Patch Email =
+=====================================================
 
 Your change description should use the standard format for a
 commit message, and must include your "Signed-off-by" signature
@@ -44,8 +44,33 @@
 
 == Sample Change Description / Commit Message =
 
-=== Definitions for sample change description ===
+=== Start of sample patch email message ===
 
+From: Contributor Name <[email protected]>
+Subject: [PATCH] CodeModule: Brief-single-line-summary
+
+Full-commit-message
+
+Contributed-under: TianoCore Contribution Agreement 1.0
+Signed-off-by: Contributor Name <[email protected]>
+---
+
+An extra message for the patch email which will not be considered part
+of the commit message can be added here.
+
+Patch content inline or attached
+
+=== End of sample patch email message ===
+
+=== Notes for sample patch email ===
+
+* The first line of commit message is taken from the email's subject
+  line following [PATCH]. The remaining portion of the commit message
+  is the email's content until the '---' line.
+* git format-patch is one way to create this format
+
+=== Definitions for sample patch email ===
+
 * "CodeModule" is a short idenfier for the affected code.  For
   example MdePkg, or MdeModulePkg UsbBusDxe.
 * "Brief-single-line-summary" is a short summary of the change.
@@ -58,15 +83,6 @@
 * "Signed-off-by" is the contributor's signature identifying them
   by their real/legal name and their email address.
 
-=== Start of sample change description / commit message ===
-CodeModule: Brief-single-line-summary
-
-Full-commit-message
-
-Contributed-under: TianoCore Contribution Agreement 1.0
-Signed-off-by: Contributor Name <[email protected]>
-=== End of sample change description / commit message ===
-
 ========================================
 = TianoCore Contribution Agreement 1.0 =
 ========================================

Added: branches/UDK2014.SP1/BaseTools/Scripts/ConvertMasmToNasm.py
===================================================================
--- branches/UDK2014.SP1/BaseTools/Scripts/ConvertMasmToNasm.py                 
        (rev 0)
+++ branches/UDK2014.SP1/BaseTools/Scripts/ConvertMasmToNasm.py 2014-12-10 
08:21:46 UTC (rev 16495)
@@ -0,0 +1,986 @@
+# @file ConvertMasmToNasm.py
+# This script assists with conversion of MASM assembly syntax to NASM
+#
+#  Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
+#
+#  This program and the accompanying materials
+#  are licensed and made available under the terms and conditions of the BSD 
License
+#  which accompanies this distribution.  The full text of the license may be 
found at
+#  http://opensource.org/licenses/bsd-license.php
+#
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR 
IMPLIED.
+#
+
+#
+# Import Modules
+#
+import os.path
+import re
+import StringIO
+import subprocess
+import sys
+from optparse import OptionParser
+
+
+class UnsupportedConversion(Exception):
+    pass
+
+
+class NoSourceFile(Exception):
+    pass
+
+
+class UnsupportedArch(Exception):
+    unsupported = ('aarch64', 'arm', 'ebc', 'ipf')
+
+
+class CommonUtils:
+
+    # Version and Copyright
+    VersionNumber = "0.01"
+    __version__ = "%prog Version " + VersionNumber
+    __copyright__ = "Copyright (c) 2007 - 2014, Intel Corporation. All rights 
reserved."
+    __usage__ = "%prog [options] source.asm [destination.nasm]"
+
+    def __init__(self, clone=None):
+        if clone is None:
+            (self.Opt, self.Args) = self.ProcessCommandLine()
+        else:
+            (self.Opt, self.Args) = (clone.Opt, clone.Args)
+
+        self.unsupportedSyntaxSeen = False
+        self.src = self.Args[0]
+        assert(os.path.exists(self.src))
+        self.dirmode = os.path.isdir(self.src)
+        srcExt = os.path.splitext(self.src)[1]
+        assert (self.dirmode or srcExt != '.nasm')
+        self.infmode = not self.dirmode and srcExt == '.inf'
+        self.diff = self.Opt.diff
+        self.git = self.Opt.git
+        self.force = self.Opt.force
+
+        if clone is None:
+            self.rootdir = os.getcwd()
+            self.DetectGit()
+        else:
+            self.rootdir = clone.rootdir
+            self.gitdir = clone.gitdir
+            self.gitemail = clone.gitemail
+
+    def ProcessCommandLine(self):
+        Parser = OptionParser(description=self.__copyright__,
+                              version=self.__version__,
+                              prog=sys.argv[0],
+                              usage=self.__usage__
+                              )
+        Parser.add_option("-q", "--quiet", action="store_true", type=None,
+                          help="Disable all messages except FATAL ERRORS.")
+        Parser.add_option("--git", action="store_true", type=None,
+                          help="Use git to create commits for each file 
converted")
+        Parser.add_option("--diff", action="store_true", type=None,
+                          help="Show diff of conversion")
+        Parser.add_option("-f", "--force", action="store_true", type=None,
+                          help="Force conversion even if unsupported")
+
+        (Opt, Args) = Parser.parse_args()
+
+        if not Opt.quiet:
+            print self.__copyright__
+            Parser.print_version()
+
+        return (Opt, Args)
+
+    def RootRelative(self, path):
+        result = path
+        if result.startswith(self.rootdir):
+            result = result[len(self.rootdir):]
+            while len(result) > 0 and result[0] in '/\\':
+                result = result[1:]
+        return result
+
+    def MatchAndSetMo(self, regexp, string):
+        self.mo = regexp.match(string)
+        return self.mo is not None
+
+    def SearchAndSetMo(self, regexp, string):
+        self.mo = regexp.search(string)
+        return self.mo is not None
+
+    def ReplacePreserveSpacing(self, string, find, replace):
+        if len(find) >= len(replace):
+            padded = replace + (' ' * (len(find) - len(replace)))
+            return string.replace(find, padded)
+        elif find.find(replace) >= 0:
+            return string.replace(find, replace)
+        else:
+            lenDiff = len(replace) - len(find)
+            result = string
+            for i in range(lenDiff, -1, -1):
+                padded = find + (' ' * i)
+                result = result.replace(padded, replace)
+            return result
+
+    def DetectGit(self):
+        lastpath = os.path.realpath(self.src)
+        self.gitdir = None
+        while True:
+            path = os.path.split(lastpath)[0]
+            if path == lastpath:
+                return
+            candidate = os.path.join(path, '.git')
+            if os.path.isdir(candidate):
+                self.gitdir = candidate
+                self.gitemail = self.FormatGitEmailAddress()
+                return
+            lastpath = path
+
+    def FormatGitEmailAddress(self):
+        if not self.git or not self.gitdir:
+            return ''
+
+        cmd = ('git', 'config', 'user.name')
+        name = self.RunAndCaptureOutput(cmd).strip()
+        cmd = ('git', 'config', 'user.email')
+        email = self.RunAndCaptureOutput(cmd).strip()
+        if name.find(',') >= 0:
+            name = '"' + name + '"'
+        return name + ' <' + email + '>'
+
+    def RunAndCaptureOutput(self, cmd, checkExitCode=True, pipeIn=None):
+        if pipeIn:
+            subpStdin = subprocess.PIPE
+        else:
+            subpStdin = None
+        p = subprocess.Popen(args=cmd, stdout=subprocess.PIPE, stdin=subpStdin)
+        (stdout, stderr) = p.communicate(pipeIn)
+        if checkExitCode:
+            if p.returncode != 0:
+                print 'command:', ' '.join(cmd)
+                print 'stdout:', stdout
+                print 'stderr:', stderr
+                print 'return:', p.returncode
+            assert p.returncode == 0
+        return stdout
+
+    def FileUpdated(self, path):
+        if not self.git or not self.gitdir:
+            return
+
+        cmd = ('git', 'add', path)
+        self.RunAndCaptureOutput(cmd)
+
+    def FileAdded(self, path):
+        self.FileUpdated(path)
+
+    def RemoveFile(self, path):
+        if not self.git or not self.gitdir:
+            return
+
+        cmd = ('git', 'rm', path)
+        self.RunAndCaptureOutput(cmd)
+
+    def FileConversionFinished(self, pkg, module, src, dst):
+        if not self.git or not self.gitdir:
+            return
+
+        if not self.Opt.quiet:
+            print 'Committing: Conversion of', dst
+
+        prefix = ' '.join(filter(lambda a: a, [pkg, module]))
+        message = ''
+        if self.unsupportedSyntaxSeen:
+            message += 'ERROR! '
+        message += '%s: Convert %s to NASM\n' % (prefix, src)
+        message += '\n'
+        message += 'The %s script was used to convert\n' % sys.argv[0]
+        message += '%s to %s\n' % (src, dst)
+        message += '\n'
+        message += 'Contributed-under: TianoCore Contribution Agreement 1.0\n'
+        message += 'Signed-off-by: %s\n' % self.gitemail
+
+        cmd = ('git', 'commit', '-F', '-')
+        self.RunAndCaptureOutput(cmd, pipeIn=message)
+
+
+class ConvertAsmFile(CommonUtils):
+
+    def __init__(self, src, dst, clone):
+        CommonUtils.__init__(self, clone)
+        self.ConvertAsmFile(src, dst)
+        self.FileAdded(dst)
+        self.RemoveFile(src)
+
+    def ConvertAsmFile(self, inputFile, outputFile=None):
+        self.globals = set()
+        self.unsupportedSyntaxSeen = False
+        self.inputFilename = inputFile
+        if not outputFile:
+            outputFile = os.path.splitext(inputFile)[0] + '.nasm'
+        self.outputFilename = outputFile
+
+        fullSrc = os.path.realpath(inputFile)
+        srcParentDir = os.path.basename(os.path.split(fullSrc)[0])
+        maybeArch = srcParentDir.lower()
+        if maybeArch in UnsupportedArch.unsupported:
+            raise UnsupportedArch
+        self.ia32 = maybeArch == 'ia32'
+        self.x64 = maybeArch == 'x64'
+
+        self.inputFileBase = os.path.basename(self.inputFilename)
+        self.outputFileBase = os.path.basename(self.outputFilename)
+        if self.outputFilename == '-' and not self.diff:
+            self.output = sys.stdout
+        else:
+            self.output = StringIO.StringIO()
+        if not self.Opt.quiet:
+            dirpath, src = os.path.split(self.inputFilename)
+            dirpath = self.RootRelative(dirpath)
+            dst = os.path.basename(self.outputFilename)
+            print 'Converting:', dirpath, src, '->', dst
+        lines = open(self.inputFilename).readlines()
+        self.Convert(lines)
+        if self.outputFilename == '-':
+            if self.diff:
+                sys.stdout.write(self.output.getvalue())
+                self.output.close()
+        else:
+            f = open(self.outputFilename, 'wb')
+            f.write(self.output.getvalue())
+            f.close()
+            self.output.close()
+
+    endOfLineRe = re.compile(r'''
+                                 \s* ( ; .* )? \n $
+                             ''',
+                             re.VERBOSE | re.MULTILINE
+                             )
+    begOfLineRe = re.compile(r'''
+                                 \s*
+                             ''',
+                             re.VERBOSE
+                             )
+
+    def Convert(self, lines):
+        self.proc = None
+        self.anonLabelCount = -1
+        output = self.output
+        self.oldAsmEmptyLineCount = 0
+        self.newAsmEmptyLineCount = 0
+        for line in lines:
+            mo = self.begOfLineRe.search(line)
+            assert mo is not None
+            self.indent = mo.group()
+            lineWithoutBeginning = line[len(self.indent):]
+            mo = self.endOfLineRe.search(lineWithoutBeginning)
+            if mo is None:
+                endOfLine = ''
+            else:
+                endOfLine = mo.group()
+            oldAsm = line[len(self.indent):len(line) - len(endOfLine)]
+            self.originalLine = line.rstrip()
+            if line.strip() == '':
+                self.oldAsmEmptyLineCount += 1
+            self.TranslateAsm(oldAsm, endOfLine)
+            if line.strip() != '':
+                self.oldAsmEmptyLineCount = 0
+
+    procDeclRe = re.compile(r'''
+                                ([\w@][\w@0-9]*) \s+
+                                PROC
+                                (?: \s+ NEAR | FAR )?
+                                (?: \s+ C )?
+                                (?: \s+ (PUBLIC | PRIVATE) )?
+                                (?: \s+ USES ( (?: \s+ \w[\w0-9]* )+ ) )?
+                                \s* $
+                            ''',
+                            re.VERBOSE | re.IGNORECASE
+                            )
+
+    procEndRe = re.compile(r'''
+                               ([\w@][\w@0-9]*) \s+
+                               ENDP
+                               \s* $
+                           ''',
+                           re.VERBOSE | re.IGNORECASE
+                           )
+
+    varAndTypeSubRe = r' (?: [\w@][\w@0-9]* ) (?: \s* : \s* \w+ )? '
+    publicRe = re.compile(r'''
+                              PUBLIC \s+
+                              ( %s (?: \s* , \s* %s )* )
+                              \s* $
+                          ''' % (varAndTypeSubRe, varAndTypeSubRe),
+                          re.VERBOSE | re.IGNORECASE
+                          )
+
+    varAndTypeSubRe = re.compile(varAndTypeSubRe, re.VERBOSE | re.IGNORECASE)
+
+    macroDeclRe = re.compile(r'''
+                                 ([\w@][\w@0-9]*) \s+
+                                 MACRO
+                                 \s* $
+                             ''',
+                             re.VERBOSE | re.IGNORECASE
+                             )
+
+    sectionDeclRe = re.compile(r'''
+                                   ([\w@][\w@0-9]*) \s+
+                                   ( SECTION | ENDS )
+                                   \s* $
+                               ''',
+                               re.VERBOSE | re.IGNORECASE
+                               )
+
+    externRe = re.compile(r'''
+                              EXTE?RN \s+ (?: C \s+ )?
+                              ([\w@][\w@0-9]*) \s* : \s* (\w+)
+                              \s* $
+                           ''',
+                          re.VERBOSE | re.IGNORECASE
+                          )
+
+    externdefRe = re.compile(r'''
+                                 EXTERNDEF \s+ (?: C \s+ )?
+                                 ([\w@][\w@0-9]*) \s* : \s* (\w+)
+                                 \s* $
+                             ''',
+                             re.VERBOSE | re.IGNORECASE
+                             )
+
+    protoRe = re.compile(r'''
+                             ([\w@][\w@0-9]*) \s+
+                             PROTO
+                             (?: \s+ .* )?
+                             \s* $
+                         ''',
+                         re.VERBOSE | re.IGNORECASE
+                         )
+
+    defineDataRe = re.compile(r'''
+                                  ([\w@][\w@0-9]*) \s+
+                                  ( db | dw | dd | dq ) \s+
+                                  ( .*? )
+                                  \s* $
+                              ''',
+                              re.VERBOSE | re.IGNORECASE
+                              )
+
+    equRe = re.compile(r'''
+                           ([\w@][\w@0-9]*) \s+ EQU \s+ (\S.*?)
+                           \s* $
+                       ''',
+                       re.VERBOSE | re.IGNORECASE
+                       )
+
+    ignoreRe = re.compile(r'''
+                              \. (?: const |
+                                     mmx |
+                                     model |
+                                     xmm |
+                                     x?list |
+                                     [3-6]86p?
+                                 ) |
+                              page
+                              (?: \s+ .* )?
+                              \s* $
+                          ''',
+                          re.VERBOSE | re.IGNORECASE
+                          )
+
+    whitespaceRe = re.compile(r'\s+', re.MULTILINE)
+
+    def TranslateAsm(self, oldAsm, endOfLine):
+        assert(oldAsm.strip() == oldAsm)
+
+        endOfLine = endOfLine.replace(self.inputFileBase, self.outputFileBase)
+
+        oldOp = oldAsm.split()
+        if len(oldOp) >= 1:
+            oldOp = oldOp[0]
+        else:
+            oldOp = ''
+
+        if oldAsm == '':
+            newAsm = oldAsm
+            self.EmitAsmWithComment(oldAsm, newAsm, endOfLine)
+        elif oldOp in ('#include', ):
+            newAsm = oldAsm
+            self.EmitLine(oldAsm + endOfLine)
+        elif oldOp.lower() in ('end', 'title', 'text'):
+            newAsm = ''
+            self.EmitAsmWithComment(oldAsm, newAsm, endOfLine)
+        elif oldAsm.lower() == '@@:':
+            self.anonLabelCount += 1
+            self.EmitLine(self.anonLabel(self.anonLabelCount) + ':')
+        elif self.MatchAndSetMo(self.ignoreRe, oldAsm):
+            newAsm = ''
+            self.EmitAsmWithComment(oldAsm, newAsm, endOfLine)
+        elif oldAsm.lower() == 'ret':
+            for i in range(len(self.uses) - 1, -1, -1):
+                register = self.uses[i]
+                self.EmitNewContent('pop     ' + register)
+            newAsm = 'ret'
+            self.EmitAsmWithComment(oldAsm, newAsm, endOfLine)
+            self.uses = tuple()
+        elif oldOp.lower() == 'lea':
+            newAsm = self.ConvertLea(oldAsm)
+            self.EmitAsmWithComment(oldAsm, newAsm, endOfLine)
+        elif oldAsm.lower() == 'end':
+            newAsm = ''
+            self.EmitAsmWithComment(oldAsm, newAsm, endOfLine)
+            self.uses = tuple()
+        elif self.MatchAndSetMo(self.equRe, oldAsm):
+            equ = self.mo.group(1)
+            newAsm = '%%define %s %s' % (equ, self.mo.group(2))
+            self.EmitAsmWithComment(oldAsm, newAsm, endOfLine)
+        elif self.MatchAndSetMo(self.externRe, oldAsm) or \
+                self.MatchAndSetMo(self.protoRe, oldAsm):
+            extern = self.mo.group(1)
+            self.NewGlobal(extern)
+            newAsm = 'extern ' + extern
+            self.EmitAsmWithComment(oldAsm, newAsm, endOfLine)
+        elif self.MatchAndSetMo(self.externdefRe, oldAsm):
+            newAsm = ''
+            self.EmitAsmWithComment(oldAsm, newAsm, endOfLine)
+        elif self.MatchAndSetMo(self.macroDeclRe, oldAsm):
+            newAsm = '%%macro %s 0' % self.mo.group(1)
+            self.EmitAsmWithComment(oldAsm, newAsm, endOfLine)
+        elif oldOp.lower() == 'endm':
+            newAsm = r'%endmacro'
+            self.EmitAsmWithComment(oldAsm, newAsm, endOfLine)
+        elif self.MatchAndSetMo(self.sectionDeclRe, oldAsm):
+            name = self.mo.group(1)
+            ty = self.mo.group(2)
+            if ty.lower() == 'section':
+                newAsm = '.' + name
+            else:
+                newAsm = ''
+            self.EmitAsmWithComment(oldAsm, newAsm, endOfLine)
+        elif self.MatchAndSetMo(self.procDeclRe, oldAsm):
+            proc = self.proc = self.mo.group(1)
+            visibility = self.mo.group(2)
+            if visibility is None:
+                visibility = ''
+            else:
+                visibility = visibility.lower()
+            if visibility != 'private':
+                self.NewGlobal(self.proc)
+                proc = 'ASM_PFX(' + proc + ')'
+                self.EmitNewContent('global ' + proc)
+            newAsm = proc + ':'
+            self.EmitAsmWithComment(oldAsm, newAsm, endOfLine)
+            uses = self.mo.group(3)
+            if uses is not None:
+                uses = filter(None, uses.split())
+            else:
+                uses = tuple()
+            self.uses = uses
+            for register in self.uses:
+                self.EmitNewContent('    push    ' + register)
+        elif self.MatchAndSetMo(self.procEndRe, oldAsm):
+            newAsm = ''
+            self.EmitAsmWithComment(oldAsm, newAsm, endOfLine)
+        elif self.MatchAndSetMo(self.publicRe, oldAsm):
+            publics = re.findall(self.varAndTypeSubRe, self.mo.group(1))
+            publics = map(lambda p: p.split(':')[0].strip(), publics)
+            for i in range(len(publics) - 1):
+                name = publics[i]
+                self.EmitNewContent('global ASM_PFX(%s)' % publics[i])
+                self.NewGlobal(name)
+            name = publics[-1]
+            self.NewGlobal(name)
+            newAsm = 'global ASM_PFX(%s)' % name
+            self.EmitAsmWithComment(oldAsm, newAsm, endOfLine)
+        elif self.MatchAndSetMo(self.defineDataRe, oldAsm):
+            name = self.mo.group(1)
+            ty = self.mo.group(2)
+            value = self.mo.group(3)
+            if value == '?':
+                value = 0
+            newAsm = '%s: %s %s' % (name, ty, value)
+            newAsm = self.CommonConversions(newAsm)
+            self.EmitAsmWithComment(oldAsm, newAsm, endOfLine)
+        else:
+            newAsm = self.CommonConversions(oldAsm)
+            self.EmitAsmWithComment(oldAsm, newAsm, endOfLine)
+
+    def NewGlobal(self, name):
+        regex = re.compile(r'(?<![_\w\d])(?<!ASM_PFX\()(' + re.escape(name) +
+                           r')(?![_\w\d])')
+        self.globals.add(regex)
+
+    def ConvertAnonymousLabels(self, oldAsm):
+        newAsm = oldAsm
+        anonLabel = self.anonLabel(self.anonLabelCount)
+        newAsm = newAsm.replace('@b', anonLabel)
+        newAsm = newAsm.replace('@B', anonLabel)
+        anonLabel = self.anonLabel(self.anonLabelCount + 1)
+        newAsm = newAsm.replace('@f', anonLabel)
+        newAsm = newAsm.replace('@F', anonLabel)
+        return newAsm
+
+    def anonLabel(self, count):
+        return '.%d' % count
+
+    def EmitString(self, string):
+        self.output.write(string)
+
+    def EmitLineWithDiff(self, old, new):
+        newLine = (self.indent + new).rstrip()
+        if self.diff:
+            if old is None:
+                print '+%s' % newLine
+            elif newLine != old:
+                print '-%s' % old
+                print '+%s' % newLine
+            else:
+                print '', newLine
+        if newLine != '':
+            self.newAsmEmptyLineCount = 0
+        self.EmitString(newLine + '\r\n')
+
+    def EmitLine(self, string):
+        self.EmitLineWithDiff(self.originalLine, string)
+
+    def EmitNewContent(self, string):
+        self.EmitLineWithDiff(None, string)
+
+    def EmitAsmReplaceOp(self, oldAsm, oldOp, newOp, endOfLine):
+        newAsm = oldAsm.replace(oldOp, newOp, 1)
+        self.EmitAsmWithComment(oldAsm, newAsm, endOfLine)
+
+    hexNumRe = re.compile(r'0*((?=[\da-f])\d*(?<=\d)[\da-f]*)h', re.IGNORECASE)
+
+    def EmitAsmWithComment(self, oldAsm, newAsm, endOfLine):
+        for glblRe in self.globals:
+            newAsm = glblRe.sub(r'ASM_PFX(\1)', newAsm)
+
+        newAsm = self.hexNumRe.sub(r'0x\1', newAsm)
+
+        newLine = newAsm + endOfLine
+        emitNewLine = ((newLine.strip() != '') or
+                       ((oldAsm + endOfLine).strip() == ''))
+        if emitNewLine and newLine.strip() == '':
+            self.newAsmEmptyLineCount += 1
+            if self.newAsmEmptyLineCount > 1:
+                emitNewLine = False
+        if emitNewLine:
+            self.EmitLine(newLine.rstrip())
+        elif self.diff:
+            print '-%s' % self.originalLine
+
+    leaRe = re.compile(r'''
+                           (lea \s+) ([\w@][\w@0-9]*) \s* , \s* (\S (?:.*\S)?)
+                           \s* $
+                       ''',
+                       re.VERBOSE | re.IGNORECASE
+                       )
+
+    def ConvertLea(self, oldAsm):
+        newAsm = oldAsm
+        if self.MatchAndSetMo(self.leaRe, oldAsm):
+            lea = self.mo.group(1)
+            dst = self.mo.group(2)
+            src = self.mo.group(3)
+            if src.find('[') < 0:
+                src = '[' + src + ']'
+            newAsm = lea + dst + ', ' + src
+        newAsm = self.CommonConversions(newAsm)
+        return newAsm
+
+    ptrRe = re.compile(r'''
+                           (?<! \S )
+                           ([dfq]?word|byte) \s+ (?: ptr ) (\s*)
+                           (?= [[\s] )
+                       ''',
+                       re.VERBOSE | re.IGNORECASE
+                       )
+
+    def ConvertPtr(self, oldAsm):
+        newAsm = oldAsm
+        while self.SearchAndSetMo(self.ptrRe, newAsm):
+            ty = self.mo.group(1)
+            if ty.lower() == 'fword':
+                ty = ''
+            else:
+                ty += self.mo.group(2)
+            newAsm = newAsm[:self.mo.start(0)] + ty + newAsm[self.mo.end(0):]
+        return newAsm
+
+    labelByteRe = re.compile(r'''
+                                 (?: \s+ label \s+ (?: [dfq]?word | byte ) )
+                                 (?! \S )
+                             ''',
+                             re.VERBOSE | re.IGNORECASE
+                             )
+
+    def ConvertLabelByte(self, oldAsm):
+        newAsm = oldAsm
+        if self.SearchAndSetMo(self.labelByteRe, newAsm):
+            newAsm = newAsm[:self.mo.start(0)] + ':' + newAsm[self.mo.end(0):]
+        return newAsm
+
+    unaryBitwiseOpRe = re.compile(r'''
+                                      ( NOT )
+                                      (?= \s+ \S )
+                                  ''',
+                                  re.VERBOSE | re.IGNORECASE
+                                  )
+    binaryBitwiseOpRe = re.compile(r'''
+                                       ( \S \s+ )
+                                       ( AND | OR | SHL | SHR )
+                                       (?= \s+ \S )
+                                   ''',
+                                   re.VERBOSE | re.IGNORECASE
+                                   )
+    bitwiseOpReplacements = {
+        'not': '~',
+        'and': '&',
+        'shl': '<<',
+        'shr': '>>',
+        'or': '|',
+    }
+
+    def ConvertBitwiseOp(self, oldAsm):
+        newAsm = oldAsm
+        while self.SearchAndSetMo(self.binaryBitwiseOpRe, newAsm):
+            prefix = self.mo.group(1)
+            op = self.bitwiseOpReplacements[self.mo.group(2).lower()]
+            newAsm = newAsm[:self.mo.start(0)] + prefix + op + \
+                newAsm[self.mo.end(0):]
+        while self.SearchAndSetMo(self.unaryBitwiseOpRe, newAsm):
+            op = self.bitwiseOpReplacements[self.mo.group(1).lower()]
+            newAsm = newAsm[:self.mo.start(0)] + op + newAsm[self.mo.end(0):]
+        return newAsm
+
+    sectionRe = re.compile(r'''
+                               \. ( code |
+                                    data
+                                  )
+                               (?: \s+ .* )?
+                               \s* $
+                           ''',
+                           re.VERBOSE | re.IGNORECASE
+                           )
+
+    segmentRe = re.compile(r'''
+                               ( code |
+                                 data )
+                               (?: \s+ SEGMENT )
+                               (?: \s+ .* )?
+                               \s* $
+                           ''',
+                           re.VERBOSE | re.IGNORECASE
+                           )
+
+    def ConvertSection(self, oldAsm):
+        newAsm = oldAsm
+        if self.MatchAndSetMo(self.sectionRe, newAsm) or \
+           self.MatchAndSetMo(self.segmentRe, newAsm):
+            name = self.mo.group(1).lower()
+            if name == 'code':
+                if self.x64:
+                    self.EmitLine('DEFAULT REL')
+                name = 'text'
+            newAsm = 'SECTION .' + name
+        return newAsm
+
+    fwordRe = re.compile(r'''
+                             (?<! \S )
+                             fword
+                             (?! \S )
+                         ''',
+                         re.VERBOSE | re.IGNORECASE
+                         )
+
+    def FwordUnsupportedCheck(self, oldAsm):
+        newAsm = oldAsm
+        if self.SearchAndSetMo(self.fwordRe, newAsm):
+            newAsm = self.Unsupported(newAsm, 'fword used')
+        return newAsm
+
+    __common_conversion_routines__ = (
+        ConvertAnonymousLabels,
+        ConvertPtr,
+        FwordUnsupportedCheck,
+        ConvertBitwiseOp,
+        ConvertLabelByte,
+        ConvertSection,
+    )
+
+    def CommonConversions(self, oldAsm):
+        newAsm = oldAsm
+        for conv in self.__common_conversion_routines__:
+            newAsm = conv(self, newAsm)
+        return newAsm
+
+    def Unsupported(self, asm, message=None):
+        if not self.force:
+            raise UnsupportedConversion
+
+        self.unsupportedSyntaxSeen = True
+        newAsm = '%error conversion unsupported'
+        if message:
+            newAsm += '; ' + message
+        newAsm += ': ' + asm
+        return newAsm
+
+
+class ConvertInfFile(CommonUtils):
+
+    def __init__(self, inf, clone):
+        CommonUtils.__init__(self, clone)
+        self.inf = inf
+        self.ScanInfAsmFiles()
+        if self.infmode:
+            self.ConvertInfAsmFiles()
+
+    infSrcRe = re.compile(r'''
+                              \s*
+                              ( [\w@][\w@0-9/]* \.(asm|s) )
+                              \s* (?: \| [^#]* )?
+                              \s* (?: \# .* )?
+                              $
+                          ''',
+                          re.VERBOSE | re.IGNORECASE
+                          )
+
+    def GetInfAsmFileMapping(self):
+        srcToDst = {'order': []}
+        for line in self.lines:
+            line = line.rstrip()
+            if self.MatchAndSetMo(self.infSrcRe, line):
+                src = self.mo.group(1)
+                srcExt = self.mo.group(2)
+                dst = os.path.splitext(src)[0] + '.nasm'
+                if src not in srcToDst:
+                    srcToDst[src] = dst
+                    srcToDst['order'].append(src)
+        return srcToDst
+
+    def ScanInfAsmFiles(self):
+        src = self.inf
+        assert os.path.isfile(src)
+        f = open(src)
+        self.lines = f.readlines()
+        f.close()
+
+        path = os.path.realpath(self.inf)
+        (self.dir, inf) = os.path.split(path)
+        parent = os.path.normpath(self.dir)
+        (lastpath, self.moduleName) = os.path.split(parent)
+        self.packageName = None
+        while True:
+            lastpath = os.path.normpath(lastpath)
+            (parent, basename) = os.path.split(lastpath)
+            if parent == lastpath:
+                break
+            if basename.endswith('Pkg'):
+                self.packageName = basename
+                break
+            lastpath = parent
+
+        self.srcToDst = self.GetInfAsmFileMapping()
+
+        self.dstToSrc = {'order': []}
+        for src in self.srcToDst['order']:
+            srcExt = os.path.splitext(src)[1]
+            dst = self.srcToDst[src]
+            if dst not in self.dstToSrc:
+                self.dstToSrc[dst] = [src]
+                self.dstToSrc['order'].append(dst)
+            else:
+                self.dstToSrc[dst].append(src)
+
+    def __len__(self):
+        return len(self.dstToSrc['order'])
+
+    def __iter__(self):
+        return iter(self.dstToSrc['order'])
+
+    def ConvertInfAsmFiles(self):
+        notConverted = []
+        unsupportedArchCount = 0
+        for dst in self:
+            didSomething = False
+            fileChanged = self.UpdateInfAsmFile(dst)
+            try:
+                self.UpdateInfAsmFile(dst)
+                didSomething = True
+            except UnsupportedConversion:
+                if not self.Opt.quiet:
+                    print 'MASM=>NASM conversion unsupported for', dst
+                notConverted.append(dst)
+            except NoSourceFile:
+                if not self.Opt.quiet:
+                    print 'Source file missing for', reldst
+                notConverted.append(dst)
+            except UnsupportedArch:
+                unsupportedArchCount += 1
+            else:
+                if didSomething:
+                    self.ConversionFinished(dst)
+        if len(notConverted) > 0 and not self.Opt.quiet:
+            for dst in notConverted:
+                reldst = self.RootRelative(dst)
+                print 'Unabled to convert', reldst
+        if unsupportedArchCount > 0 and not self.Opt.quiet:
+            print 'Skipped', unsupportedArchCount, 'files based on 
architecture'
+
+    def UpdateInfAsmFile(self, dst, IgnoreMissingAsm=False):
+        infPath = os.path.split(os.path.realpath(self.inf))[0]
+        asmSrc = os.path.splitext(dst)[0] + '.asm'
+        fullSrc = os.path.join(infPath, asmSrc)
+        fullDst = os.path.join(infPath, dst)
+        srcParentDir = os.path.basename(os.path.split(fullSrc)[0])
+        if srcParentDir.lower() in UnsupportedArch.unsupported:
+            raise UnsupportedArch
+        elif not os.path.exists(fullSrc):
+            if not IgnoreMissingAsm:
+                raise NoSourceFile
+        else:  # not os.path.exists(fullDst):
+            conv = ConvertAsmFile(fullSrc, fullDst, self)
+            self.unsupportedSyntaxSeen = conv.unsupportedSyntaxSeen
+
+        lastLine = ''
+        fileChanged = False
+        for i in range(len(self.lines)):
+            line = self.lines[i].rstrip()
+            updatedLine = line
+            for src in self.dstToSrc[dst]:
+                assert self.srcToDst[src] == dst
+                updatedLine = self.ReplacePreserveSpacing(
+                    updatedLine, src, dst)
+
+            lineChanged = updatedLine != line
+            if lineChanged:
+                if lastLine.strip() == updatedLine.strip():
+                    self.lines[i] = None
+                else:
+                    self.lines[i] = updatedLine + '\r\n'
+
+            if self.diff:
+                if lineChanged:
+                    print '-%s' % line
+                    if self.lines[i] is not None:
+                        print '+%s' % updatedLine
+                else:
+                    print '', line
+
+            fileChanged |= lineChanged
+            if self.lines[i] is not None:
+                lastLine = self.lines[i]
+
+        if fileChanged:
+            self.lines = filter(lambda l: l is not None, self.lines)
+
+        for src in self.dstToSrc[dst]:
+            if not src.endswith('.asm'):
+                fullSrc = os.path.join(infPath, src)
+                if os.path.exists(fullSrc):
+                    self.RemoveFile(fullSrc)
+
+        if fileChanged:
+            f = open(self.inf, 'wb')
+            f.writelines(self.lines)
+            f.close()
+            self.FileUpdated(self.inf)
+
+    def ConversionFinished(self, dst):
+        asmSrc = os.path.splitext(dst)[0] + '.asm'
+        self.FileConversionFinished(
+            self.packageName, self.moduleName, asmSrc, dst)
+
+
+class ConvertInfFiles(CommonUtils):
+
+    def __init__(self, infs, clone):
+        CommonUtils.__init__(self, clone)
+        infs = map(lambda i: ConvertInfFile(i, self), infs)
+        infs = filter(lambda i: len(i) > 0, infs)
+        dstToInfs = {'order': []}
+        for inf in infs:
+            for dst in inf:
+                fulldst = os.path.realpath(os.path.join(inf.dir, dst))
+                pair = (inf, dst)
+                if fulldst in dstToInfs:
+                    dstToInfs[fulldst].append(pair)
+                else:
+                    dstToInfs['order'].append(fulldst)
+                    dstToInfs[fulldst] = [pair]
+
+        notConverted = []
+        unsupportedArchCount = 0
+        for dst in dstToInfs['order']:
+            didSomething = False
+            try:
+                for inf, reldst in dstToInfs[dst]:
+                    inf.UpdateInfAsmFile(reldst, IgnoreMissingAsm=didSomething)
+                    didSomething = True
+            except UnsupportedConversion:
+                if not self.Opt.quiet:
+                    print 'MASM=>NASM conversion unsupported for', reldst
+                notConverted.append(dst)
+            except NoSourceFile:
+                if not self.Opt.quiet:
+                    print 'Source file missing for', reldst
+                notConverted.append(dst)
+            except UnsupportedArch:
+                unsupportedArchCount += 1
+            else:
+                if didSomething:
+                    inf.ConversionFinished(reldst)
+        if len(notConverted) > 0 and not self.Opt.quiet:
+            for dst in notConverted:
+                reldst = self.RootRelative(dst)
+                print 'Unabled to convert', reldst
+        if unsupportedArchCount > 0 and not self.Opt.quiet:
+            print 'Skipped', unsupportedArchCount, 'files based on 
architecture'
+
+
+class ConvertDirectories(CommonUtils):
+
+    def __init__(self, paths, clone):
+        CommonUtils.__init__(self, clone)
+        self.paths = paths
+        self.ConvertInfAndAsmFiles()
+
+    def ConvertInfAndAsmFiles(self):
+        infs = list()
+        for path in self.paths:
+            assert(os.path.exists(path))
+        for path in self.paths:
+            for root, dirs, files in os.walk(path):
+                for d in ('.svn', '.git'):
+                    if d in dirs:
+                        dirs.remove(d)
+                for f in files:
+                    if f.lower().endswith('.inf'):
+                        inf = os.path.realpath(os.path.join(root, f))
+                        infs.append(inf)
+
+        ConvertInfFiles(infs, self)
+
+
+class ConvertAsmApp(CommonUtils):
+
+    def __init__(self):
+        CommonUtils.__init__(self)
+
+        numArgs = len(self.Args)
+        assert(numArgs >= 1)
+        if self.infmode:
+            ConvertInfFiles(self.Args, self)
+        elif self.dirmode:
+            ConvertDirectories(self.Args, self)
+        elif not self.dirmode:
+            assert(numArgs <= 2)
+            src = self.Args[0]
+            if numArgs > 1:
+                dst = self.Args[1]
+            else:
+                dst = None
+            ConvertAsmFile(src, dst, self)
+
+ConvertAsmApp()

Modified: branches/UDK2014.SP1/BaseTools/Source/C/GenFw/Elf64Convert.c
===================================================================
--- branches/UDK2014.SP1/BaseTools/Source/C/GenFw/Elf64Convert.c        
2014-12-10 08:21:05 UTC (rev 16494)
+++ branches/UDK2014.SP1/BaseTools/Source/C/GenFw/Elf64Convert.c        
2014-12-10 08:21:46 UTC (rev 16495)
@@ -710,13 +710,15 @@
             break;
 
           case R_AARCH64_CALL26:
-            if  (Rel->r_addend != 0 ) { /* TODO */
-              Error (NULL, 0, 3000, "Invalid", "AArch64: R_AARCH64_CALL26 Need 
to fixup with addend!.");
-            }
-            break;
-
           case R_AARCH64_JUMP26:
-            if  (Rel->r_addend != 0 ) { /* TODO : AArch64 '-O2' optimisation. 
*/
+            if  (Rel->r_addend != 0 ) {
+              // Some references to static functions sometime start at the 
base of .text + addend.
+              // It is safe to ignore these relocations because they patch a 
`BL` instructions that
+              // contains an offset from the instruction itself and there is 
only a single .text section.
+              // So we check if the symbol is a "section symbol"
+              if (ELF64_ST_TYPE (Sym->st_info) == STT_SECTION) {
+                break;
+              }
               Error (NULL, 0, 3000, "Invalid", "AArch64: R_AARCH64_JUMP26 Need 
to fixup with addend!.");
             }
             break;

Modified: branches/UDK2014.SP1/BaseTools/Source/C/Makefiles/header.makefile
===================================================================
--- branches/UDK2014.SP1/BaseTools/Source/C/Makefiles/header.makefile   
2014-12-10 08:21:05 UTC (rev 16494)
+++ branches/UDK2014.SP1/BaseTools/Source/C/Makefiles/header.makefile   
2014-12-10 08:21:46 UTC (rev 16495)
@@ -39,6 +39,10 @@
 ARCH_INCLUDE = -I $(MAKEROOT)/Include/Arm/
 endif
 
+ifeq ($(ARCH), AARCH64)
+ARCH_INCLUDE = -I $(MAKEROOT)/Include/AArch64/
+endif
+
 INCLUDE = $(TOOL_INCLUDE) -I $(MAKEROOT) -I $(MAKEROOT)/Include/Common -I 
$(MAKEROOT)/Include/ -I $(MAKEROOT)/Include/IndustryStandard -I 
$(MAKEROOT)/Common/ -I .. -I . $(ARCH_INCLUDE) 
 CPPFLAGS = $(INCLUDE)
 ifeq ($(DARWIN),Darwin)

Modified: branches/UDK2014.SP1/BaseTools/Source/Python/AutoGen/AutoGen.py
===================================================================
--- branches/UDK2014.SP1/BaseTools/Source/Python/AutoGen/AutoGen.py     
2014-12-10 08:21:05 UTC (rev 16494)
+++ branches/UDK2014.SP1/BaseTools/Source/Python/AutoGen/AutoGen.py     
2014-12-10 08:21:46 UTC (rev 16495)
@@ -2935,7 +2935,8 @@
     #
     def _GetGuidList(self):
         if self._GuidList == None:
-            self._GuidList = self.Module.Guids
+            self._GuidList = sdict()
+            self._GuidList.update(self.Module.Guids)
             for Library in self.DependentLibraryList:
                 self._GuidList.update(Library.Guids)
                 self.UpdateComments(self._GuidComments, Library.GuidComments)
@@ -2955,7 +2956,8 @@
     #
     def _GetProtocolList(self):
         if self._ProtocolList == None:
-            self._ProtocolList = self.Module.Protocols
+            self._ProtocolList = sdict()
+            self._ProtocolList.update(self.Module.Protocols)
             for Library in self.DependentLibraryList:
                 self._ProtocolList.update(Library.Protocols)
                 self.UpdateComments(self._ProtocolComments, 
Library.ProtocolComments)
@@ -2968,7 +2970,8 @@
     #
     def _GetPpiList(self):
         if self._PpiList == None:
-            self._PpiList = self.Module.Ppis
+            self._PpiList = sdict()
+            self._PpiList.update(self.Module.Ppis)
             for Library in self.DependentLibraryList:
                 self._PpiList.update(Library.Ppis)
                 self.UpdateComments(self._PpiComments, Library.PpiComments)

Modified: branches/UDK2014.SP1/BaseTools/Source/Python/AutoGen/GenC.py
===================================================================
--- branches/UDK2014.SP1/BaseTools/Source/Python/AutoGen/GenC.py        
2014-12-10 08:21:05 UTC (rev 16494)
+++ branches/UDK2014.SP1/BaseTools/Source/Python/AutoGen/GenC.py        
2014-12-10 08:21:46 UTC (rev 16495)
@@ -1550,6 +1550,17 @@
         StringH.Append(gAutoGenHeaderString.Replace({'FileName':FileName}))
         StringH.Append(gAutoGenHPrologueString.Replace({'File':'STRDEFS', 
'Guid':Info.Guid.replace('-','_')}))
         CreateUnicodeStringCode(Info, AutoGenC, StringH, UniGenCFlag, 
UniGenBinBuffer)
+
+        GuidMacros = []
+        for Guid in Info.Module.Guids:
+            if Guid in Info.Module.GetGuidsUsedByPcd():
+                continue
+            GuidMacros.append('#define %s %s' % (Guid, 
Info.Module.Guids[Guid]))
+        for Guid, Value in Info.Module.Protocols.items() + 
Info.Module.Ppis.items():
+            GuidMacros.append('#define %s %s' % (Guid, Value))
+        if GuidMacros:
+            StringH.Append('\n#ifdef VFRCOMPILE\n%s\n#endif\n' % 
'\n'.join(GuidMacros))
+
         StringH.Append("\n#endif\n")
         AutoGenH.Append('#include "%s"\n' % FileName)
 

Modified: branches/UDK2014.SP1/BaseTools/Source/Python/AutoGen/GenMake.py
===================================================================
--- branches/UDK2014.SP1/BaseTools/Source/Python/AutoGen/GenMake.py     
2014-12-10 08:21:05 UTC (rev 16494)
+++ branches/UDK2014.SP1/BaseTools/Source/Python/AutoGen/GenMake.py     
2014-12-10 08:21:46 UTC (rev 16495)
@@ -679,7 +679,8 @@
                     NewFile = self.PlaceMacro(str(F), self.Macros)
                     # In order to use file list macro as dependency
                     if T.GenListFile:
-                        self.ListFileMacros[T.ListFileMacro].append(str(F))
+                        # gnu tools need forward slash path separater, even on 
Windows
+                        
self.ListFileMacros[T.ListFileMacro].append(str(F).replace ('\\', '/'))
                         self.FileListMacros[T.FileListMacro].append(NewFile)
                     elif T.GenFileListMacro:
                         self.FileListMacros[T.FileListMacro].append(NewFile)

Modified: branches/UDK2014.SP1/BaseTools/Source/Python/AutoGen/UniClassObject.py
===================================================================
--- branches/UDK2014.SP1/BaseTools/Source/Python/AutoGen/UniClassObject.py      
2014-12-10 08:21:05 UTC (rev 16494)
+++ branches/UDK2014.SP1/BaseTools/Source/Python/AutoGen/UniClassObject.py      
2014-12-10 08:21:46 UTC (rev 16495)
@@ -1,6 +1,9 @@
 ## @file
 # This file is used to collect all defined strings in multiple uni files
 #
+#
+# Copyright (c) 2014 Hewlett-Packard Development Company, L.P.<BR>
+#
 # Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
 # This program and the accompanying materials
 # are licensed and made available under the terms and conditions of the BSD 
License
@@ -36,10 +39,7 @@
 LF = u'\u000A'
 NULL = u'\u0000'
 TAB = u'\t'
-BACK_SPLASH = u'\\'
-DOBULE_QUOTED_SPLASH = u'\\"'
-SIGLE_QUOTED_SPLASH = u"\\'"
-TAB_BACK_SLASH = u"\\/"
+BACK_SLASH_PLACEHOLDER = u'\u0006'
 
 gIncludePattern = re.compile("^#include +[\"<]+([^\"< >]+)[>\"]+$", 
re.MULTILINE | re.UNICODE)
 
@@ -283,6 +283,20 @@
         FileName = Item[Item.find(u'#include ') + len(u'#include ') 
:Item.find(u' ', len(u'#include '))][1:-1]
         self.LoadUniFile(FileName)
 
+    def StripComments(self, Line):
+        Comment = u'//'
+        CommentPos = Line.find(Comment)
+        while CommentPos >= 0:
+        # if there are non matched quotes before the comment header
+        # then we are in the middle of a string
+        # but we need to ignore the escaped quotes and backslashes.
+            if ((Line.count(u'"', 0, CommentPos) - Line.count(u'\\"', 0, 
CommentPos)) & 1) == 1:
+                CommentPos = Line.find (Comment, CommentPos + 1)
+            else:
+                return Line[:CommentPos]
+        return Line
+                
+
     #
     # Pre-process before parse .uni file
     #
@@ -291,7 +305,7 @@
             EdkLogger.error("Unicode File Parser", FILE_NOT_FOUND, 
ExtraData=File.Path)
 
         try:
-            FileIn = codecs.open(LongFilePath(File.Path), mode='rb', 
encoding='utf-16').readlines()
+            FileIn = codecs.open(LongFilePath(File.Path), mode='rb', 
encoding='utf-16')
         except UnicodeError, X:
             EdkLogger.error("build", FILE_READ_FAILURE, "File read failure: 
%s" % str(X), ExtraData=File.Path);
         except:
@@ -301,42 +315,23 @@
         #
         # Use unique identifier
         #
-        FindFlag = -1
-        LineCount = 0
         for Line in FileIn:
-            Line = FileIn[LineCount]
-            LineCount += 1
             Line = Line.strip()
+            Line = Line.replace(u'\\\\', BACK_SLASH_PLACEHOLDER)
+            Line = self.StripComments(Line)
+
             #
-            # Ignore comment line and empty line
+            # Ignore empty line
             #
-            if Line == u'' or Line.startswith(u'//'):
-                continue
+            if len(Line) == 0: 
+                continue 
             
-            #
-            # Process comment embeded in string define lines
-            #
-            FindFlag = Line.find(u'//')
-            if FindFlag != -1:
-                Line = Line.replace(Line[FindFlag:], u' ')
-                if FileIn[LineCount].strip().startswith('#language'):
-                    Line = Line + FileIn[LineCount]
-                    FileIn[LineCount-1] = Line
-                    FileIn[LineCount] = os.linesep
-                    LineCount -= 1
-                    for Index in xrange (LineCount + 1, len (FileIn) - 1):
-                        if (Index == len(FileIn) -1):
-                            FileIn[Index] = os.linesep
-                        else:
-                            FileIn[Index] = FileIn[Index + 1]
-                    continue
-                              
+                             
             Line = Line.replace(u'/langdef', u'#langdef')
             Line = Line.replace(u'/string', u'#string')
             Line = Line.replace(u'/language', u'#language')
             Line = Line.replace(u'/include', u'#include')
 
-            Line = Line.replace(u'\\\\', u'\u0006')
             Line = Line.replace(UNICODE_WIDE_CHAR, WIDE_CHAR)
             Line = Line.replace(UNICODE_NARROW_CHAR, NARROW_CHAR)
             Line = Line.replace(UNICODE_NON_BREAKING_CHAR, NON_BREAKING_CHAR)
@@ -344,13 +339,11 @@
             Line = Line.replace(u'\\r\\n', CR + LF)
             Line = Line.replace(u'\\n', CR + LF)
             Line = Line.replace(u'\\r', CR)
-            Line = Line.replace(u'\\t', u'\t')
-            Line = Line.replace(u'''\"''', u'''"''')
+            Line = Line.replace(u'\\t', u' ')
             Line = Line.replace(u'\t', u' ')
-            Line = Line.replace(u'\u0006', u'\\')
-            Line = Line.replace(DOBULE_QUOTED_SPLASH, u'"')
-            Line = Line.replace(SIGLE_QUOTED_SPLASH, u"'")
-            Line = Line.replace(TAB_BACK_SLASH, u"/")
+            Line = Line.replace(u'\\"', u'"') 
+            Line = Line.replace(u"\\'", u"'") 
+            Line = Line.replace(BACK_SLASH_PLACEHOLDER, u'\\')
 
 #           if Line.find(u'\\x'):
 #               hex = Line[Line.find(u'\\x') + 2 : Line.find(u'\\x') + 6]

Modified: branches/UDK2014.SP1/BaseTools/Source/Python/Common/DataType.py
===================================================================
--- branches/UDK2014.SP1/BaseTools/Source/Python/Common/DataType.py     
2014-12-10 08:21:05 UTC (rev 16494)
+++ branches/UDK2014.SP1/BaseTools/Source/Python/Common/DataType.py     
2014-12-10 08:21:46 UTC (rev 16495)
@@ -442,6 +442,7 @@
 TAB_IF_DEF = '!ifdef'
 TAB_IF_N_DEF = '!ifndef'
 TAB_IF_EXIST = '!if exist'
+TAB_ERROR = '!ERROR'
 
 #
 # Unknown section

Modified: 
branches/UDK2014.SP1/BaseTools/Source/Python/CommonDataClass/DataClass.py
===================================================================
--- branches/UDK2014.SP1/BaseTools/Source/Python/CommonDataClass/DataClass.py   
2014-12-10 08:21:05 UTC (rev 16494)
+++ branches/UDK2014.SP1/BaseTools/Source/Python/CommonDataClass/DataClass.py   
2014-12-10 08:21:46 UTC (rev 16495)
@@ -86,6 +86,7 @@
 MODEL_META_DATA_CONDITIONAL_STATEMENT_ELSE = 5005
 MODEL_META_DATA_CONDITIONAL_STATEMENT_IFDEF = 5006
 MODEL_META_DATA_CONDITIONAL_STATEMENT_IFNDEF = 5007
+MODEL_META_DATA_CONDITIONAL_STATEMENT_ERROR = 5400
 MODEL_META_DATA_BUILD_OPTION = 5008
 MODEL_META_DATA_COMPONENT = 5009
 MODEL_META_DATA_USER_EXTENSION = 5010
@@ -164,6 +165,7 @@
               ("MODEL_META_DATA_CONDITIONAL_STATEMENT_ELSE", 
MODEL_META_DATA_CONDITIONAL_STATEMENT_ELSE),
               ("MODEL_META_DATA_CONDITIONAL_STATEMENT_IFDEF", 
MODEL_META_DATA_CONDITIONAL_STATEMENT_IFDEF),
               ("MODEL_META_DATA_CONDITIONAL_STATEMENT_IFNDEF", 
MODEL_META_DATA_CONDITIONAL_STATEMENT_IFNDEF),
+              ("MODEL_META_DATA_CONDITIONAL_STATEMENT_ERROR", 
MODEL_META_DATA_CONDITIONAL_STATEMENT_ERROR),
               ("MODEL_META_DATA_COMPONENT_SOURCE_OVERRIDE_PATH", 
MODEL_META_DATA_COMPONENT_SOURCE_OVERRIDE_PATH),
               ("MODEL_META_DATA_BUILD_OPTION", MODEL_META_DATA_BUILD_OPTION),
               ("MODEL_META_DATA_COMPONENT", MODEL_META_DATA_COMPONENT),

Modified: branches/UDK2014.SP1/BaseTools/Source/Python/Ecc/Check.py
===================================================================
--- branches/UDK2014.SP1/BaseTools/Source/Python/Ecc/Check.py   2014-12-10 
08:21:05 UTC (rev 16494)
+++ branches/UDK2014.SP1/BaseTools/Source/Python/Ecc/Check.py   2014-12-10 
08:21:46 UTC (rev 16495)
@@ -63,7 +63,7 @@
     def GeneralCheckNonAcsii(self):
         if EccGlobalData.gConfig.GeneralCheckNonAcsii == '1' or 
EccGlobalData.gConfig.GeneralCheckAll == '1' or EccGlobalData.gConfig.CheckAll 
== '1':
             EdkLogger.quiet("Checking Non-ACSII char in file ...")
-            SqlCommand = """select ID, FullPath, ExtName from File"""
+            SqlCommand = """select ID, FullPath, ExtName from File where 
ExtName in ('.dec', '.inf', '.dsc', 'c', 'h')"""
             RecordSet = EccGlobalData.gDb.TblFile.Exec(SqlCommand)
             for Record in RecordSet:
                 if Record[2].upper() not in 
EccGlobalData.gConfig.BinaryExtList:

Modified: 
branches/UDK2014.SP1/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py
===================================================================
--- 
branches/UDK2014.SP1/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py
        2014-12-10 08:21:05 UTC (rev 16494)
+++ 
branches/UDK2014.SP1/BaseTools/Source/Python/Ecc/MetaFileWorkspace/MetaFileParser.py
        2014-12-10 08:21:46 UTC (rev 16495)
@@ -461,13 +461,14 @@
                                      MODEL_PCD_DYNAMIC_EX,
                                      MODEL_PCD_DYNAMIC]:
                 Line = Content[Index].strip()
-                if Line.startswith(TAB_COMMENT_SPLIT):
+                if Line.startswith(TAB_SPECIAL_COMMENT):
+                    Usage += ' ' + Line[Line.find(TAB_SPECIAL_COMMENT):]
                     continue
+                elif Line.startswith(TAB_COMMENT_SPLIT):
+                    continue
                 elif Line.find(TAB_COMMENT_SPLIT) > 0:
-                    Usage = Line[Line.find(TAB_COMMENT_SPLIT):]
+                    Usage += ' ' + Line[Line.find(TAB_COMMENT_SPLIT):]
                     Line = Line[:Line.find(TAB_COMMENT_SPLIT)]
-                else:
-                    Usage = ''
             else:
             # skip empty, commented, block commented lines
                 Line = CleanString(Content[Index], AllowCppStyleComment=True)
@@ -545,6 +546,7 @@
             # LineBegin=-1, ColumnBegin=-1, LineEnd=-1, ColumnEnd=-1, 
Enabled=-1
             #
             self._ValueList[0] = self._ValueList[0].replace('/', '\\')
+            Usage = Usage.strip()
             for Arch, Platform in self._Scope:
                 self._Store(self._SectionType,
                             self._ValueList[0],
@@ -561,6 +563,7 @@
                             0,
                             Usage
                             )
+            Usage = ''
         if IsFindBlockComment:
             EdkLogger.error("Parser", FORMAT_INVALID, "Open block comments 
(starting with /*) are expected to end with */", 
                             File=self.MetaFile)
@@ -731,6 +734,7 @@
         TAB_ELSE_IF.upper()                         :   
MODEL_META_DATA_CONDITIONAL_STATEMENT_ELSEIF,
         TAB_ELSE.upper()                            :   
MODEL_META_DATA_CONDITIONAL_STATEMENT_ELSE,
         TAB_END_IF.upper()                          :   
MODEL_META_DATA_CONDITIONAL_STATEMENT_ENDIF,
+        TAB_ERROR.upper()                           :   
MODEL_META_DATA_CONDITIONAL_STATEMENT_ERROR,
     }
 
     # Valid names in define section
@@ -1117,6 +1121,7 @@
             MODEL_META_DATA_BUILD_OPTION                    :   
self.__ProcessBuildOption,
             MODEL_UNKNOWN                                   :   self._Skip,
             MODEL_META_DATA_USER_EXTENSION                  :   self._Skip,
+            MODEL_META_DATA_CONDITIONAL_STATEMENT_ERROR     :   self._Skip,
         }
         
         self._RawTable = self._Table
@@ -1152,9 +1157,10 @@
                 # Only catch expression evaluation error here. We need to 
report
                 # the precise number of line on which the error occurred
                 #
-                EdkLogger.error('Parser', FORMAT_INVALID, "Invalid expression: 
%s" % str(Excpt),
-                                File=self._FileWithError, ExtraData=' 
'.join(self._ValueList), 
-                                Line=self._LineIndex+1)
+                pass
+#                 EdkLogger.error('Parser', FORMAT_INVALID, "Invalid 
expression: %s" % str(Excpt),
+#                                 File=self._FileWithError, ExtraData=' 
'.join(self._ValueList),
+#                                 Line=self._LineIndex+1)
             except MacroException, Excpt:
                 EdkLogger.error('Parser', FORMAT_INVALID, str(Excpt),
                                 File=self._FileWithError, ExtraData=' 
'.join(self._ValueList), 
@@ -1809,7 +1815,10 @@
         # Load Fdf file if filename is not None
         #
         if Filename != None:
-            self.LoadFdfFile(Filename)
+            try:
+                self.LoadFdfFile(Filename)
+            except Exception:
+                pass
 
     #
     # Insert a FDF file record into database

Modified: branches/UDK2014.SP1/BaseTools/Source/Python/GenFds/GuidSection.py
===================================================================
--- branches/UDK2014.SP1/BaseTools/Source/Python/GenFds/GuidSection.py  
2014-12-10 08:21:05 UTC (rev 16494)
+++ branches/UDK2014.SP1/BaseTools/Source/Python/GenFds/GuidSection.py  
2014-12-10 08:21:46 UTC (rev 16495)
@@ -159,6 +159,13 @@
                        SecNum     + \
                        '.tmp'
             TempFile = os.path.normpath(TempFile)
+            #
+            # Remove temp file if its time stamp is older than dummy file
+            # Just in case the external tool fails at this time but succeeded 
before
+            # Error should be reported if the external tool does not generate 
a new output based on new input
+            #
+            if os.path.exists(TempFile) and os.path.exists(DummyFile) and 
os.path.getmtime(TempFile) < os.path.getmtime(DummyFile):
+                os.remove(TempFile)
 
             FirstCall = False
             CmdOption = '-e'
@@ -183,6 +190,12 @@
                 FirstCall = False
                 ReturnValue[0] = 0
                 GenFdsGlobalVariable.GuidTool(TempFile, [DummyFile], 
ExternalTool, CmdOption)
+            #
+            # There is external tool which does not follow standard rule which 
return nonzero if tool fails
+            # The output file has to be checked
+            #
+            if not os.path.exists(TempFile):
+                EdkLogger.error("GenFds", COMMAND_FAILURE, 'Fail to call %s, 
no output file was generated' % ExternalTool)
 
             FileHandleIn = open(DummyFile,'rb')
             FileHandleIn.seek(0,2)
@@ -257,6 +270,7 @@
 
         ToolDefinition = 
ToolDefClassObject.ToolDefDict(GenFdsGlobalVariable.ConfDir).ToolsDefTxtDictionary
         ToolPathTmp = None
+        ToolOption = None
         for ToolDef in ToolDefinition.items():
             if self.NameGuid == ToolDef[1]:
                 KeyList = ToolDef[0].split('_')

Modified: 
branches/UDK2014.SP1/BaseTools/Source/Python/UPT/Parser/InfGuidPpiProtocolSectionParser.py
===================================================================
--- 
branches/UDK2014.SP1/BaseTools/Source/Python/UPT/Parser/InfGuidPpiProtocolSectionParser.py
  2014-12-10 08:21:05 UTC (rev 16494)
+++ 
branches/UDK2014.SP1/BaseTools/Source/Python/UPT/Parser/InfGuidPpiProtocolSectionParser.py
  2014-12-10 08:21:46 UTC (rev 16495)
@@ -216,20 +216,11 @@
         #
         for Line in SectionString:
             LineContent = Line[0]
-            LineNo = Line[1]
 
             if LineContent.strip() == '':
                 continue
-            #
-            # Replace with [Defines] section Macro
-            #
-            LineContent = InfExpandMacro(LineContent,
-                                         (FileName, LineContent, LineNo),
-                                         self.FileLocalMacros,
-                                         None)
 
             UserExtensionContent += LineContent + DT.END_OF_LINE
-
             continue
 
         #

Modified: 
branches/UDK2014.SP1/BaseTools/Source/Python/UPT/PomAdapter/InfPomAlignment.py
===================================================================
--- 
branches/UDK2014.SP1/BaseTools/Source/Python/UPT/PomAdapter/InfPomAlignment.py  
    2014-12-10 08:21:05 UTC (rev 16494)
+++ 
branches/UDK2014.SP1/BaseTools/Source/Python/UPT/PomAdapter/InfPomAlignment.py  
    2014-12-10 08:21:46 UTC (rev 16495)
@@ -940,7 +940,7 @@
                     HelpTextObj.SetString(CommentItem.GetHelpStringItem())
                     Pcd.SetHelpTextList(Pcd.GetHelpTextList() + [HelpTextObj])
                 AsBuildPatchPcdList.append(Pcd)
-            else:
+            elif PcdItem[0].upper() == DT.TAB_INF_PCD_EX.upper():
                 PcdItemObj = PcdItem[1]
                 Pcd = CommonObject.PcdObject()
                 Pcd.SetTokenSpaceGuidValue(PcdItemObj.GetTokenSpaceGuidValue())

Modified: 
branches/UDK2014.SP1/BaseTools/Source/Python/UPT/Xml/ModuleSurfaceAreaXml.py
===================================================================
--- 
branches/UDK2014.SP1/BaseTools/Source/Python/UPT/Xml/ModuleSurfaceAreaXml.py    
    2014-12-10 08:21:05 UTC (rev 16494)
+++ 
branches/UDK2014.SP1/BaseTools/Source/Python/UPT/Xml/ModuleSurfaceAreaXml.py    
    2014-12-10 08:21:46 UTC (rev 16495)
@@ -160,7 +160,7 @@
 
         GuiVerElemList = []
         for LibGuidVer in LibGuidVerList:
-            if IsMatchArch(LibGuidVer.GetSupArchList(), SupportArch):
+            if LibGuidVer.GetLibGuid() and 
IsMatchArch(LibGuidVer.GetSupArchList(), SupportArch):
                 GuiVerElem = \
                 CreateXmlElement('GUID', LibGuidVer.GetLibGuid(), [], 
[['Version', LibGuidVer.GetLibVersion()]])
                 GuiVerElemList.append(GuiVerElem)


------------------------------------------------------------------------------
Download BIRT iHub F-Type - The Free Enterprise-Grade BIRT Server
from Actuate! Instantly Supercharge Your Business Reports and Dashboards
with Interactivity, Sharing, Native Excel Exports, App Integration & more
Get technology previously reserved for billion-dollar corporations, FREE
http://pubads.g.doubleclick.net/gampad/clk?id=164703151&iu=/4140/ostg.clktrk
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to