diff --git a/BaseTools/Bin/CYGWIN_NT-5.1-i686/BootSectImage b/BaseTools/Bin/CYGWIN_NT-5.1-i686/BootSectImage
new file mode 100644
index 0000000000..4821d24fa7
--- /dev/null
+++ b/BaseTools/Bin/CYGWIN_NT-5.1-i686/BootSectImage
@@ -0,0 +1,29 @@
+#!/usr/bin/env bash
+#python `dirname $0`/RunToolFromSource.py `basename $0` $*
+#exec `dirname $0`/../../../../C/bin/`basename $0` $*
+
+TOOL_BASENAME=`basename $0`
+
+if [ -n "$WORKSPACE" -a -e $WORKSPACE/Conf/BaseToolsCBinaries ]
+then
+ exec $WORKSPACE/Conf/BaseToolsCBinaries/$TOOL_BASENAME
+elif [ -n "$WORKSPACE" -a -e $EDK_TOOLS_PATH/Source/C ]
+then
+ if [ ! -e $EDK_TOOLS_PATH/Source/C/bin/$TOOL_BASENAME ]
+ then
+ echo BaseTools C Tool binary was not found \($TOOL_BASENAME\)
+ echo You may need to run:
+ echo " make -C $EDK_TOOLS_PATH/Source/C"
+ else
+ exec $EDK_TOOLS_PATH/Source/C/bin/$TOOL_BASENAME $*
+ fi
+elif [ -e `dirname $0`/../../Source/C/bin/$TOOL_BASENAME ]
+then
+ exec `dirname $0`/../../Source/C/bin/$TOOL_BASENAME $*
+else
+ echo Unable to find the real \'$TOOL_BASENAME\' to run
+ echo This message was printed by
+ echo " $0"
+ exit -1
+fi
+
diff --git a/BaseTools/Bin/CYGWIN_NT-5.1-i686/BuildEnv b/BaseTools/Bin/CYGWIN_NT-5.1-i686/BuildEnv
new file mode 100644
index 0000000000..2cb8b86a99
--- /dev/null
+++ b/BaseTools/Bin/CYGWIN_NT-5.1-i686/BuildEnv
@@ -0,0 +1,5 @@
+#!/usr/bin/env bash
+#python `dirname $0`/RunToolFromSource.py `basename $0` $*
+PYTHONPATH="`dirname $0`/../../Source/Python" \
+ python "`dirname $0`/../../Source/Python"/`basename $0`/`basename $0`.py $*
+
diff --git a/BaseTools/Bin/CYGWIN_NT-5.1-i686/Ecc b/BaseTools/Bin/CYGWIN_NT-5.1-i686/Ecc
new file mode 100644
index 0000000000..2cb8b86a99
--- /dev/null
+++ b/BaseTools/Bin/CYGWIN_NT-5.1-i686/Ecc
@@ -0,0 +1,5 @@
+#!/usr/bin/env bash
+#python `dirname $0`/RunToolFromSource.py `basename $0` $*
+PYTHONPATH="`dirname $0`/../../Source/Python" \
+ python "`dirname $0`/../../Source/Python"/`basename $0`/`basename $0`.py $*
+
diff --git a/BaseTools/Bin/CYGWIN_NT-5.1-i686/EfiLdrImage b/BaseTools/Bin/CYGWIN_NT-5.1-i686/EfiLdrImage
new file mode 100644
index 0000000000..4821d24fa7
--- /dev/null
+++ b/BaseTools/Bin/CYGWIN_NT-5.1-i686/EfiLdrImage
@@ -0,0 +1,29 @@
+#!/usr/bin/env bash
+#python `dirname $0`/RunToolFromSource.py `basename $0` $*
+#exec `dirname $0`/../../../../C/bin/`basename $0` $*
+
+TOOL_BASENAME=`basename $0`
+
+if [ -n "$WORKSPACE" -a -e $WORKSPACE/Conf/BaseToolsCBinaries ]
+then
+ exec $WORKSPACE/Conf/BaseToolsCBinaries/$TOOL_BASENAME
+elif [ -n "$WORKSPACE" -a -e $EDK_TOOLS_PATH/Source/C ]
+then
+ if [ ! -e $EDK_TOOLS_PATH/Source/C/bin/$TOOL_BASENAME ]
+ then
+ echo BaseTools C Tool binary was not found \($TOOL_BASENAME\)
+ echo You may need to run:
+ echo " make -C $EDK_TOOLS_PATH/Source/C"
+ else
+ exec $EDK_TOOLS_PATH/Source/C/bin/$TOOL_BASENAME $*
+ fi
+elif [ -e `dirname $0`/../../Source/C/bin/$TOOL_BASENAME ]
+then
+ exec `dirname $0`/../../Source/C/bin/$TOOL_BASENAME $*
+else
+ echo Unable to find the real \'$TOOL_BASENAME\' to run
+ echo This message was printed by
+ echo " $0"
+ exit -1
+fi
+
diff --git a/BaseTools/Bin/CYGWIN_NT-5.1-i686/EfiRom b/BaseTools/Bin/CYGWIN_NT-5.1-i686/EfiRom
new file mode 100644
index 0000000000..4821d24fa7
--- /dev/null
+++ b/BaseTools/Bin/CYGWIN_NT-5.1-i686/EfiRom
@@ -0,0 +1,29 @@
+#!/usr/bin/env bash
+#python `dirname $0`/RunToolFromSource.py `basename $0` $*
+#exec `dirname $0`/../../../../C/bin/`basename $0` $*
+
+TOOL_BASENAME=`basename $0`
+
+if [ -n "$WORKSPACE" -a -e $WORKSPACE/Conf/BaseToolsCBinaries ]
+then
+ exec $WORKSPACE/Conf/BaseToolsCBinaries/$TOOL_BASENAME
+elif [ -n "$WORKSPACE" -a -e $EDK_TOOLS_PATH/Source/C ]
+then
+ if [ ! -e $EDK_TOOLS_PATH/Source/C/bin/$TOOL_BASENAME ]
+ then
+ echo BaseTools C Tool binary was not found \($TOOL_BASENAME\)
+ echo You may need to run:
+ echo " make -C $EDK_TOOLS_PATH/Source/C"
+ else
+ exec $EDK_TOOLS_PATH/Source/C/bin/$TOOL_BASENAME $*
+ fi
+elif [ -e `dirname $0`/../../Source/C/bin/$TOOL_BASENAME ]
+then
+ exec `dirname $0`/../../Source/C/bin/$TOOL_BASENAME $*
+else
+ echo Unable to find the real \'$TOOL_BASENAME\' to run
+ echo This message was printed by
+ echo " $0"
+ exit -1
+fi
+
diff --git a/BaseTools/Bin/CYGWIN_NT-5.1-i686/GenCrc32 b/BaseTools/Bin/CYGWIN_NT-5.1-i686/GenCrc32
new file mode 100644
index 0000000000..4821d24fa7
--- /dev/null
+++ b/BaseTools/Bin/CYGWIN_NT-5.1-i686/GenCrc32
@@ -0,0 +1,29 @@
+#!/usr/bin/env bash
+#python `dirname $0`/RunToolFromSource.py `basename $0` $*
+#exec `dirname $0`/../../../../C/bin/`basename $0` $*
+
+TOOL_BASENAME=`basename $0`
+
+if [ -n "$WORKSPACE" -a -e $WORKSPACE/Conf/BaseToolsCBinaries ]
+then
+ exec $WORKSPACE/Conf/BaseToolsCBinaries/$TOOL_BASENAME
+elif [ -n "$WORKSPACE" -a -e $EDK_TOOLS_PATH/Source/C ]
+then
+ if [ ! -e $EDK_TOOLS_PATH/Source/C/bin/$TOOL_BASENAME ]
+ then
+ echo BaseTools C Tool binary was not found \($TOOL_BASENAME\)
+ echo You may need to run:
+ echo " make -C $EDK_TOOLS_PATH/Source/C"
+ else
+ exec $EDK_TOOLS_PATH/Source/C/bin/$TOOL_BASENAME $*
+ fi
+elif [ -e `dirname $0`/../../Source/C/bin/$TOOL_BASENAME ]
+then
+ exec `dirname $0`/../../Source/C/bin/$TOOL_BASENAME $*
+else
+ echo Unable to find the real \'$TOOL_BASENAME\' to run
+ echo This message was printed by
+ echo " $0"
+ exit -1
+fi
+
diff --git a/BaseTools/Bin/CYGWIN_NT-5.1-i686/GenDepex b/BaseTools/Bin/CYGWIN_NT-5.1-i686/GenDepex
new file mode 100644
index 0000000000..bd3141a758
--- /dev/null
+++ b/BaseTools/Bin/CYGWIN_NT-5.1-i686/GenDepex
@@ -0,0 +1,3 @@
+#!/usr/bin/env bash
+PYTHONPATH="`dirname $0`/../../Source/Python" \
+ python "`dirname $0`/../../Source/Python"/AutoGen/`basename $0`.py $*
diff --git a/BaseTools/Bin/CYGWIN_NT-5.1-i686/GenFds b/BaseTools/Bin/CYGWIN_NT-5.1-i686/GenFds
new file mode 100644
index 0000000000..2cb8b86a99
--- /dev/null
+++ b/BaseTools/Bin/CYGWIN_NT-5.1-i686/GenFds
@@ -0,0 +1,5 @@
+#!/usr/bin/env bash
+#python `dirname $0`/RunToolFromSource.py `basename $0` $*
+PYTHONPATH="`dirname $0`/../../Source/Python" \
+ python "`dirname $0`/../../Source/Python"/`basename $0`/`basename $0`.py $*
+
diff --git a/BaseTools/Bin/CYGWIN_NT-5.1-i686/GenFfs b/BaseTools/Bin/CYGWIN_NT-5.1-i686/GenFfs
new file mode 100644
index 0000000000..4821d24fa7
--- /dev/null
+++ b/BaseTools/Bin/CYGWIN_NT-5.1-i686/GenFfs
@@ -0,0 +1,29 @@
+#!/usr/bin/env bash
+#python `dirname $0`/RunToolFromSource.py `basename $0` $*
+#exec `dirname $0`/../../../../C/bin/`basename $0` $*
+
+TOOL_BASENAME=`basename $0`
+
+if [ -n "$WORKSPACE" -a -e $WORKSPACE/Conf/BaseToolsCBinaries ]
+then
+ exec $WORKSPACE/Conf/BaseToolsCBinaries/$TOOL_BASENAME
+elif [ -n "$WORKSPACE" -a -e $EDK_TOOLS_PATH/Source/C ]
+then
+ if [ ! -e $EDK_TOOLS_PATH/Source/C/bin/$TOOL_BASENAME ]
+ then
+ echo BaseTools C Tool binary was not found \($TOOL_BASENAME\)
+ echo You may need to run:
+ echo " make -C $EDK_TOOLS_PATH/Source/C"
+ else
+ exec $EDK_TOOLS_PATH/Source/C/bin/$TOOL_BASENAME $*
+ fi
+elif [ -e `dirname $0`/../../Source/C/bin/$TOOL_BASENAME ]
+then
+ exec `dirname $0`/../../Source/C/bin/$TOOL_BASENAME $*
+else
+ echo Unable to find the real \'$TOOL_BASENAME\' to run
+ echo This message was printed by
+ echo " $0"
+ exit -1
+fi
+
diff --git a/BaseTools/Bin/CYGWIN_NT-5.1-i686/GenFv b/BaseTools/Bin/CYGWIN_NT-5.1-i686/GenFv
new file mode 100644
index 0000000000..4821d24fa7
--- /dev/null
+++ b/BaseTools/Bin/CYGWIN_NT-5.1-i686/GenFv
@@ -0,0 +1,29 @@
+#!/usr/bin/env bash
+#python `dirname $0`/RunToolFromSource.py `basename $0` $*
+#exec `dirname $0`/../../../../C/bin/`basename $0` $*
+
+TOOL_BASENAME=`basename $0`
+
+if [ -n "$WORKSPACE" -a -e $WORKSPACE/Conf/BaseToolsCBinaries ]
+then
+ exec $WORKSPACE/Conf/BaseToolsCBinaries/$TOOL_BASENAME
+elif [ -n "$WORKSPACE" -a -e $EDK_TOOLS_PATH/Source/C ]
+then
+ if [ ! -e $EDK_TOOLS_PATH/Source/C/bin/$TOOL_BASENAME ]
+ then
+ echo BaseTools C Tool binary was not found \($TOOL_BASENAME\)
+ echo You may need to run:
+ echo " make -C $EDK_TOOLS_PATH/Source/C"
+ else
+ exec $EDK_TOOLS_PATH/Source/C/bin/$TOOL_BASENAME $*
+ fi
+elif [ -e `dirname $0`/../../Source/C/bin/$TOOL_BASENAME ]
+then
+ exec `dirname $0`/../../Source/C/bin/$TOOL_BASENAME $*
+else
+ echo Unable to find the real \'$TOOL_BASENAME\' to run
+ echo This message was printed by
+ echo " $0"
+ exit -1
+fi
+
diff --git a/BaseTools/Bin/CYGWIN_NT-5.1-i686/GenFw b/BaseTools/Bin/CYGWIN_NT-5.1-i686/GenFw
new file mode 100644
index 0000000000..4821d24fa7
--- /dev/null
+++ b/BaseTools/Bin/CYGWIN_NT-5.1-i686/GenFw
@@ -0,0 +1,29 @@
+#!/usr/bin/env bash
+#python `dirname $0`/RunToolFromSource.py `basename $0` $*
+#exec `dirname $0`/../../../../C/bin/`basename $0` $*
+
+TOOL_BASENAME=`basename $0`
+
+if [ -n "$WORKSPACE" -a -e $WORKSPACE/Conf/BaseToolsCBinaries ]
+then
+ exec $WORKSPACE/Conf/BaseToolsCBinaries/$TOOL_BASENAME
+elif [ -n "$WORKSPACE" -a -e $EDK_TOOLS_PATH/Source/C ]
+then
+ if [ ! -e $EDK_TOOLS_PATH/Source/C/bin/$TOOL_BASENAME ]
+ then
+ echo BaseTools C Tool binary was not found \($TOOL_BASENAME\)
+ echo You may need to run:
+ echo " make -C $EDK_TOOLS_PATH/Source/C"
+ else
+ exec $EDK_TOOLS_PATH/Source/C/bin/$TOOL_BASENAME $*
+ fi
+elif [ -e `dirname $0`/../../Source/C/bin/$TOOL_BASENAME ]
+then
+ exec `dirname $0`/../../Source/C/bin/$TOOL_BASENAME $*
+else
+ echo Unable to find the real \'$TOOL_BASENAME\' to run
+ echo This message was printed by
+ echo " $0"
+ exit -1
+fi
+
diff --git a/BaseTools/Bin/CYGWIN_NT-5.1-i686/GenPage b/BaseTools/Bin/CYGWIN_NT-5.1-i686/GenPage
new file mode 100644
index 0000000000..4821d24fa7
--- /dev/null
+++ b/BaseTools/Bin/CYGWIN_NT-5.1-i686/GenPage
@@ -0,0 +1,29 @@
+#!/usr/bin/env bash
+#python `dirname $0`/RunToolFromSource.py `basename $0` $*
+#exec `dirname $0`/../../../../C/bin/`basename $0` $*
+
+TOOL_BASENAME=`basename $0`
+
+if [ -n "$WORKSPACE" -a -e $WORKSPACE/Conf/BaseToolsCBinaries ]
+then
+ exec $WORKSPACE/Conf/BaseToolsCBinaries/$TOOL_BASENAME
+elif [ -n "$WORKSPACE" -a -e $EDK_TOOLS_PATH/Source/C ]
+then
+ if [ ! -e $EDK_TOOLS_PATH/Source/C/bin/$TOOL_BASENAME ]
+ then
+ echo BaseTools C Tool binary was not found \($TOOL_BASENAME\)
+ echo You may need to run:
+ echo " make -C $EDK_TOOLS_PATH/Source/C"
+ else
+ exec $EDK_TOOLS_PATH/Source/C/bin/$TOOL_BASENAME $*
+ fi
+elif [ -e `dirname $0`/../../Source/C/bin/$TOOL_BASENAME ]
+then
+ exec `dirname $0`/../../Source/C/bin/$TOOL_BASENAME $*
+else
+ echo Unable to find the real \'$TOOL_BASENAME\' to run
+ echo This message was printed by
+ echo " $0"
+ exit -1
+fi
+
diff --git a/BaseTools/Bin/CYGWIN_NT-5.1-i686/GenSec b/BaseTools/Bin/CYGWIN_NT-5.1-i686/GenSec
new file mode 100644
index 0000000000..4821d24fa7
--- /dev/null
+++ b/BaseTools/Bin/CYGWIN_NT-5.1-i686/GenSec
@@ -0,0 +1,29 @@
+#!/usr/bin/env bash
+#python `dirname $0`/RunToolFromSource.py `basename $0` $*
+#exec `dirname $0`/../../../../C/bin/`basename $0` $*
+
+TOOL_BASENAME=`basename $0`
+
+if [ -n "$WORKSPACE" -a -e $WORKSPACE/Conf/BaseToolsCBinaries ]
+then
+ exec $WORKSPACE/Conf/BaseToolsCBinaries/$TOOL_BASENAME
+elif [ -n "$WORKSPACE" -a -e $EDK_TOOLS_PATH/Source/C ]
+then
+ if [ ! -e $EDK_TOOLS_PATH/Source/C/bin/$TOOL_BASENAME ]
+ then
+ echo BaseTools C Tool binary was not found \($TOOL_BASENAME\)
+ echo You may need to run:
+ echo " make -C $EDK_TOOLS_PATH/Source/C"
+ else
+ exec $EDK_TOOLS_PATH/Source/C/bin/$TOOL_BASENAME $*
+ fi
+elif [ -e `dirname $0`/../../Source/C/bin/$TOOL_BASENAME ]
+then
+ exec `dirname $0`/../../Source/C/bin/$TOOL_BASENAME $*
+else
+ echo Unable to find the real \'$TOOL_BASENAME\' to run
+ echo This message was printed by
+ echo " $0"
+ exit -1
+fi
+
diff --git a/BaseTools/Bin/CYGWIN_NT-5.1-i686/GenVtf b/BaseTools/Bin/CYGWIN_NT-5.1-i686/GenVtf
new file mode 100644
index 0000000000..4821d24fa7
--- /dev/null
+++ b/BaseTools/Bin/CYGWIN_NT-5.1-i686/GenVtf
@@ -0,0 +1,29 @@
+#!/usr/bin/env bash
+#python `dirname $0`/RunToolFromSource.py `basename $0` $*
+#exec `dirname $0`/../../../../C/bin/`basename $0` $*
+
+TOOL_BASENAME=`basename $0`
+
+if [ -n "$WORKSPACE" -a -e $WORKSPACE/Conf/BaseToolsCBinaries ]
+then
+ exec $WORKSPACE/Conf/BaseToolsCBinaries/$TOOL_BASENAME
+elif [ -n "$WORKSPACE" -a -e $EDK_TOOLS_PATH/Source/C ]
+then
+ if [ ! -e $EDK_TOOLS_PATH/Source/C/bin/$TOOL_BASENAME ]
+ then
+ echo BaseTools C Tool binary was not found \($TOOL_BASENAME\)
+ echo You may need to run:
+ echo " make -C $EDK_TOOLS_PATH/Source/C"
+ else
+ exec $EDK_TOOLS_PATH/Source/C/bin/$TOOL_BASENAME $*
+ fi
+elif [ -e `dirname $0`/../../Source/C/bin/$TOOL_BASENAME ]
+then
+ exec `dirname $0`/../../Source/C/bin/$TOOL_BASENAME $*
+else
+ echo Unable to find the real \'$TOOL_BASENAME\' to run
+ echo This message was printed by
+ echo " $0"
+ exit -1
+fi
+
diff --git a/BaseTools/Bin/CYGWIN_NT-5.1-i686/GnuGenBootSector b/BaseTools/Bin/CYGWIN_NT-5.1-i686/GnuGenBootSector
new file mode 100644
index 0000000000..4821d24fa7
--- /dev/null
+++ b/BaseTools/Bin/CYGWIN_NT-5.1-i686/GnuGenBootSector
@@ -0,0 +1,29 @@
+#!/usr/bin/env bash
+#python `dirname $0`/RunToolFromSource.py `basename $0` $*
+#exec `dirname $0`/../../../../C/bin/`basename $0` $*
+
+TOOL_BASENAME=`basename $0`
+
+if [ -n "$WORKSPACE" -a -e $WORKSPACE/Conf/BaseToolsCBinaries ]
+then
+ exec $WORKSPACE/Conf/BaseToolsCBinaries/$TOOL_BASENAME
+elif [ -n "$WORKSPACE" -a -e $EDK_TOOLS_PATH/Source/C ]
+then
+ if [ ! -e $EDK_TOOLS_PATH/Source/C/bin/$TOOL_BASENAME ]
+ then
+ echo BaseTools C Tool binary was not found \($TOOL_BASENAME\)
+ echo You may need to run:
+ echo " make -C $EDK_TOOLS_PATH/Source/C"
+ else
+ exec $EDK_TOOLS_PATH/Source/C/bin/$TOOL_BASENAME $*
+ fi
+elif [ -e `dirname $0`/../../Source/C/bin/$TOOL_BASENAME ]
+then
+ exec `dirname $0`/../../Source/C/bin/$TOOL_BASENAME $*
+else
+ echo Unable to find the real \'$TOOL_BASENAME\' to run
+ echo This message was printed by
+ echo " $0"
+ exit -1
+fi
+
diff --git a/BaseTools/Bin/CYGWIN_NT-5.1-i686/LzmaCompress b/BaseTools/Bin/CYGWIN_NT-5.1-i686/LzmaCompress
new file mode 100644
index 0000000000..4821d24fa7
--- /dev/null
+++ b/BaseTools/Bin/CYGWIN_NT-5.1-i686/LzmaCompress
@@ -0,0 +1,29 @@
+#!/usr/bin/env bash
+#python `dirname $0`/RunToolFromSource.py `basename $0` $*
+#exec `dirname $0`/../../../../C/bin/`basename $0` $*
+
+TOOL_BASENAME=`basename $0`
+
+if [ -n "$WORKSPACE" -a -e $WORKSPACE/Conf/BaseToolsCBinaries ]
+then
+ exec $WORKSPACE/Conf/BaseToolsCBinaries/$TOOL_BASENAME
+elif [ -n "$WORKSPACE" -a -e $EDK_TOOLS_PATH/Source/C ]
+then
+ if [ ! -e $EDK_TOOLS_PATH/Source/C/bin/$TOOL_BASENAME ]
+ then
+ echo BaseTools C Tool binary was not found \($TOOL_BASENAME\)
+ echo You may need to run:
+ echo " make -C $EDK_TOOLS_PATH/Source/C"
+ else
+ exec $EDK_TOOLS_PATH/Source/C/bin/$TOOL_BASENAME $*
+ fi
+elif [ -e `dirname $0`/../../Source/C/bin/$TOOL_BASENAME ]
+then
+ exec `dirname $0`/../../Source/C/bin/$TOOL_BASENAME $*
+else
+ echo Unable to find the real \'$TOOL_BASENAME\' to run
+ echo This message was printed by
+ echo " $0"
+ exit -1
+fi
+
diff --git a/BaseTools/Bin/CYGWIN_NT-5.1-i686/RunBinToolFromBuildDir b/BaseTools/Bin/CYGWIN_NT-5.1-i686/RunBinToolFromBuildDir
new file mode 100644
index 0000000000..4821d24fa7
--- /dev/null
+++ b/BaseTools/Bin/CYGWIN_NT-5.1-i686/RunBinToolFromBuildDir
@@ -0,0 +1,29 @@
+#!/usr/bin/env bash
+#python `dirname $0`/RunToolFromSource.py `basename $0` $*
+#exec `dirname $0`/../../../../C/bin/`basename $0` $*
+
+TOOL_BASENAME=`basename $0`
+
+if [ -n "$WORKSPACE" -a -e $WORKSPACE/Conf/BaseToolsCBinaries ]
+then
+ exec $WORKSPACE/Conf/BaseToolsCBinaries/$TOOL_BASENAME
+elif [ -n "$WORKSPACE" -a -e $EDK_TOOLS_PATH/Source/C ]
+then
+ if [ ! -e $EDK_TOOLS_PATH/Source/C/bin/$TOOL_BASENAME ]
+ then
+ echo BaseTools C Tool binary was not found \($TOOL_BASENAME\)
+ echo You may need to run:
+ echo " make -C $EDK_TOOLS_PATH/Source/C"
+ else
+ exec $EDK_TOOLS_PATH/Source/C/bin/$TOOL_BASENAME $*
+ fi
+elif [ -e `dirname $0`/../../Source/C/bin/$TOOL_BASENAME ]
+then
+ exec `dirname $0`/../../Source/C/bin/$TOOL_BASENAME $*
+else
+ echo Unable to find the real \'$TOOL_BASENAME\' to run
+ echo This message was printed by
+ echo " $0"
+ exit -1
+fi
+
diff --git a/BaseTools/Bin/CYGWIN_NT-5.1-i686/RunToolFromSource b/BaseTools/Bin/CYGWIN_NT-5.1-i686/RunToolFromSource
new file mode 100644
index 0000000000..2cb8b86a99
--- /dev/null
+++ b/BaseTools/Bin/CYGWIN_NT-5.1-i686/RunToolFromSource
@@ -0,0 +1,5 @@
+#!/usr/bin/env bash
+#python `dirname $0`/RunToolFromSource.py `basename $0` $*
+PYTHONPATH="`dirname $0`/../../Source/Python" \
+ python "`dirname $0`/../../Source/Python"/`basename $0`/`basename $0`.py $*
+
diff --git a/BaseTools/Bin/CYGWIN_NT-5.1-i686/Split b/BaseTools/Bin/CYGWIN_NT-5.1-i686/Split
new file mode 100644
index 0000000000..4821d24fa7
--- /dev/null
+++ b/BaseTools/Bin/CYGWIN_NT-5.1-i686/Split
@@ -0,0 +1,29 @@
+#!/usr/bin/env bash
+#python `dirname $0`/RunToolFromSource.py `basename $0` $*
+#exec `dirname $0`/../../../../C/bin/`basename $0` $*
+
+TOOL_BASENAME=`basename $0`
+
+if [ -n "$WORKSPACE" -a -e $WORKSPACE/Conf/BaseToolsCBinaries ]
+then
+ exec $WORKSPACE/Conf/BaseToolsCBinaries/$TOOL_BASENAME
+elif [ -n "$WORKSPACE" -a -e $EDK_TOOLS_PATH/Source/C ]
+then
+ if [ ! -e $EDK_TOOLS_PATH/Source/C/bin/$TOOL_BASENAME ]
+ then
+ echo BaseTools C Tool binary was not found \($TOOL_BASENAME\)
+ echo You may need to run:
+ echo " make -C $EDK_TOOLS_PATH/Source/C"
+ else
+ exec $EDK_TOOLS_PATH/Source/C/bin/$TOOL_BASENAME $*
+ fi
+elif [ -e `dirname $0`/../../Source/C/bin/$TOOL_BASENAME ]
+then
+ exec `dirname $0`/../../Source/C/bin/$TOOL_BASENAME $*
+else
+ echo Unable to find the real \'$TOOL_BASENAME\' to run
+ echo This message was printed by
+ echo " $0"
+ exit -1
+fi
+
diff --git a/BaseTools/Bin/CYGWIN_NT-5.1-i686/TargetTool b/BaseTools/Bin/CYGWIN_NT-5.1-i686/TargetTool
new file mode 100644
index 0000000000..2cb8b86a99
--- /dev/null
+++ b/BaseTools/Bin/CYGWIN_NT-5.1-i686/TargetTool
@@ -0,0 +1,5 @@
+#!/usr/bin/env bash
+#python `dirname $0`/RunToolFromSource.py `basename $0` $*
+PYTHONPATH="`dirname $0`/../../Source/Python" \
+ python "`dirname $0`/../../Source/Python"/`basename $0`/`basename $0`.py $*
+
diff --git a/BaseTools/Bin/CYGWIN_NT-5.1-i686/TianoCompress b/BaseTools/Bin/CYGWIN_NT-5.1-i686/TianoCompress
new file mode 100644
index 0000000000..4821d24fa7
--- /dev/null
+++ b/BaseTools/Bin/CYGWIN_NT-5.1-i686/TianoCompress
@@ -0,0 +1,29 @@
+#!/usr/bin/env bash
+#python `dirname $0`/RunToolFromSource.py `basename $0` $*
+#exec `dirname $0`/../../../../C/bin/`basename $0` $*
+
+TOOL_BASENAME=`basename $0`
+
+if [ -n "$WORKSPACE" -a -e $WORKSPACE/Conf/BaseToolsCBinaries ]
+then
+ exec $WORKSPACE/Conf/BaseToolsCBinaries/$TOOL_BASENAME
+elif [ -n "$WORKSPACE" -a -e $EDK_TOOLS_PATH/Source/C ]
+then
+ if [ ! -e $EDK_TOOLS_PATH/Source/C/bin/$TOOL_BASENAME ]
+ then
+ echo BaseTools C Tool binary was not found \($TOOL_BASENAME\)
+ echo You may need to run:
+ echo " make -C $EDK_TOOLS_PATH/Source/C"
+ else
+ exec $EDK_TOOLS_PATH/Source/C/bin/$TOOL_BASENAME $*
+ fi
+elif [ -e `dirname $0`/../../Source/C/bin/$TOOL_BASENAME ]
+then
+ exec `dirname $0`/../../Source/C/bin/$TOOL_BASENAME $*
+else
+ echo Unable to find the real \'$TOOL_BASENAME\' to run
+ echo This message was printed by
+ echo " $0"
+ exit -1
+fi
+
diff --git a/BaseTools/Bin/CYGWIN_NT-5.1-i686/Trim b/BaseTools/Bin/CYGWIN_NT-5.1-i686/Trim
new file mode 100644
index 0000000000..2cb8b86a99
--- /dev/null
+++ b/BaseTools/Bin/CYGWIN_NT-5.1-i686/Trim
@@ -0,0 +1,5 @@
+#!/usr/bin/env bash
+#python `dirname $0`/RunToolFromSource.py `basename $0` $*
+PYTHONPATH="`dirname $0`/../../Source/Python" \
+ python "`dirname $0`/../../Source/Python"/`basename $0`/`basename $0`.py $*
+
diff --git a/BaseTools/Bin/CYGWIN_NT-5.1-i686/VfrCompile b/BaseTools/Bin/CYGWIN_NT-5.1-i686/VfrCompile
new file mode 100644
index 0000000000..4821d24fa7
--- /dev/null
+++ b/BaseTools/Bin/CYGWIN_NT-5.1-i686/VfrCompile
@@ -0,0 +1,29 @@
+#!/usr/bin/env bash
+#python `dirname $0`/RunToolFromSource.py `basename $0` $*
+#exec `dirname $0`/../../../../C/bin/`basename $0` $*
+
+TOOL_BASENAME=`basename $0`
+
+if [ -n "$WORKSPACE" -a -e $WORKSPACE/Conf/BaseToolsCBinaries ]
+then
+ exec $WORKSPACE/Conf/BaseToolsCBinaries/$TOOL_BASENAME
+elif [ -n "$WORKSPACE" -a -e $EDK_TOOLS_PATH/Source/C ]
+then
+ if [ ! -e $EDK_TOOLS_PATH/Source/C/bin/$TOOL_BASENAME ]
+ then
+ echo BaseTools C Tool binary was not found \($TOOL_BASENAME\)
+ echo You may need to run:
+ echo " make -C $EDK_TOOLS_PATH/Source/C"
+ else
+ exec $EDK_TOOLS_PATH/Source/C/bin/$TOOL_BASENAME $*
+ fi
+elif [ -e `dirname $0`/../../Source/C/bin/$TOOL_BASENAME ]
+then
+ exec `dirname $0`/../../Source/C/bin/$TOOL_BASENAME $*
+else
+ echo Unable to find the real \'$TOOL_BASENAME\' to run
+ echo This message was printed by
+ echo " $0"
+ exit -1
+fi
+
diff --git a/BaseTools/Bin/CYGWIN_NT-5.1-i686/VolInfo b/BaseTools/Bin/CYGWIN_NT-5.1-i686/VolInfo
new file mode 100644
index 0000000000..4821d24fa7
--- /dev/null
+++ b/BaseTools/Bin/CYGWIN_NT-5.1-i686/VolInfo
@@ -0,0 +1,29 @@
+#!/usr/bin/env bash
+#python `dirname $0`/RunToolFromSource.py `basename $0` $*
+#exec `dirname $0`/../../../../C/bin/`basename $0` $*
+
+TOOL_BASENAME=`basename $0`
+
+if [ -n "$WORKSPACE" -a -e $WORKSPACE/Conf/BaseToolsCBinaries ]
+then
+ exec $WORKSPACE/Conf/BaseToolsCBinaries/$TOOL_BASENAME
+elif [ -n "$WORKSPACE" -a -e $EDK_TOOLS_PATH/Source/C ]
+then
+ if [ ! -e $EDK_TOOLS_PATH/Source/C/bin/$TOOL_BASENAME ]
+ then
+ echo BaseTools C Tool binary was not found \($TOOL_BASENAME\)
+ echo You may need to run:
+ echo " make -C $EDK_TOOLS_PATH/Source/C"
+ else
+ exec $EDK_TOOLS_PATH/Source/C/bin/$TOOL_BASENAME $*
+ fi
+elif [ -e `dirname $0`/../../Source/C/bin/$TOOL_BASENAME ]
+then
+ exec `dirname $0`/../../Source/C/bin/$TOOL_BASENAME $*
+else
+ echo Unable to find the real \'$TOOL_BASENAME\' to run
+ echo This message was printed by
+ echo " $0"
+ exit -1
+fi
+
diff --git a/BaseTools/Bin/CYGWIN_NT-5.1-i686/armcc_wrapper.py b/BaseTools/Bin/CYGWIN_NT-5.1-i686/armcc_wrapper.py
new file mode 100755
index 0000000000..69fd2d5441
--- /dev/null
+++ b/BaseTools/Bin/CYGWIN_NT-5.1-i686/armcc_wrapper.py
@@ -0,0 +1,93 @@
+#!/usr/bin/env python
+#
+# Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
+#
+# 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.
+#
+
+#
+# ARMCC tools do not support cygwin paths. Ths script converts cygwin paths to DOS paths
+# in any arguments.
+#
+# armcc_wrapper.py ToolToExec [command line to convert]
+#
+# anthing with the / will be converted via cygpath cygwin call or manually.
+# -I/cygpath/c/example is a special case as you can not pass -I to cygpath
+#
+# ExceptionList if a tool takes an argument with a / add it to the exception list
+#
+import sys
+import os
+import subprocess
+import pipes
+
+#
+# Convert using cygpath command line tool
+# Currently not used, but just in case we need it in the future
+#
+def ConvertCygPathToDosViacygpath(CygPath):
+ p = subprocess.Popen("cygpath -m " + pipes.quote(CygPath), shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT, close_fds=True)
+ return p.stdout.read().strip()
+
+#
+#
+#
+def ConvertCygPathToDos(CygPath):
+ if CygPath.find("/cygdrive/") == 0:
+ # convert /cygdrive/c/Xyz to c:/Xyz
+ DosPath = CygPath[10] + ':' + CygPath[11:]
+ else:
+ DosPath = CygPath
+
+ # pipes.quote will add the extra \\ for us.
+ return DosPath.replace('/','\\')
+
+
+# we receive our options as a list, but we will be passing them to the shell as a line
+# this means we have to requote things as they will get one round of unquoting.
+# we can't set "shell=False" because we are running commands from the PATH and
+# if you don't use the shell you don't get a PATH search.
+def main(argv):
+
+ # use 1st argument as name of tool to call
+ Command = pipes.quote(sys.argv[1]);
+
+ ExceptionList = ["/interwork"]
+
+ for arg in argv:
+ if arg.find('/') == -1:
+ # if we don't need to convert just add to the command line
+ Command = Command + ' ' + pipes.quote(arg)
+ elif arg in ExceptionList:
+ # if it is in the list, then don't do a cygpath
+ # assembler stuff after --apcs has the /.
+ Command = Command + ' ' + pipes.quote(arg)
+ else:
+ if ((arg[0] == '-') and (arg[1] == 'I' or arg[1] == 'i')):
+ CygPath = arg[0] + arg[1] + ConvertCygPathToDos(arg[2:])
+ else:
+ CygPath = ConvertCygPathToDos(arg)
+
+ Command = Command + ' ' + pipes.quote(CygPath)
+
+ # call the real tool with the converted paths
+ return subprocess.call(Command, shell=True)
+
+
+if __name__ == "__main__":
+ try:
+ ret = main(sys.argv[2:])
+
+ except:
+ print "exiting: exception from " + sys.argv[0]
+ ret = 2
+
+ sys.exit(ret)
+
diff --git a/BaseTools/Bin/CYGWIN_NT-5.1-i686/build b/BaseTools/Bin/CYGWIN_NT-5.1-i686/build
new file mode 100644
index 0000000000..2cb8b86a99
--- /dev/null
+++ b/BaseTools/Bin/CYGWIN_NT-5.1-i686/build
@@ -0,0 +1,5 @@
+#!/usr/bin/env bash
+#python `dirname $0`/RunToolFromSource.py `basename $0` $*
+PYTHONPATH="`dirname $0`/../../Source/Python" \
+ python "`dirname $0`/../../Source/Python"/`basename $0`/`basename $0`.py $*
+
diff --git a/BaseTools/Bin/CYGWIN_NT-5.1-i686/fpd2dsc b/BaseTools/Bin/CYGWIN_NT-5.1-i686/fpd2dsc
new file mode 100644
index 0000000000..2cb8b86a99
--- /dev/null
+++ b/BaseTools/Bin/CYGWIN_NT-5.1-i686/fpd2dsc
@@ -0,0 +1,5 @@
+#!/usr/bin/env bash
+#python `dirname $0`/RunToolFromSource.py `basename $0` $*
+PYTHONPATH="`dirname $0`/../../Source/Python" \
+ python "`dirname $0`/../../Source/Python"/`basename $0`/`basename $0`.py $*
+
diff --git a/BaseTools/Bin/CYGWIN_NT-5.1-i686/msa2inf b/BaseTools/Bin/CYGWIN_NT-5.1-i686/msa2inf
new file mode 100644
index 0000000000..2cb8b86a99
--- /dev/null
+++ b/BaseTools/Bin/CYGWIN_NT-5.1-i686/msa2inf
@@ -0,0 +1,5 @@
+#!/usr/bin/env bash
+#python `dirname $0`/RunToolFromSource.py `basename $0` $*
+PYTHONPATH="`dirname $0`/../../Source/Python" \
+ python "`dirname $0`/../../Source/Python"/`basename $0`/`basename $0`.py $*
+
diff --git a/BaseTools/Bin/CYGWIN_NT-5.1-i686/spd2dec b/BaseTools/Bin/CYGWIN_NT-5.1-i686/spd2dec
new file mode 100644
index 0000000000..2cb8b86a99
--- /dev/null
+++ b/BaseTools/Bin/CYGWIN_NT-5.1-i686/spd2dec
@@ -0,0 +1,5 @@
+#!/usr/bin/env bash
+#python `dirname $0`/RunToolFromSource.py `basename $0` $*
+PYTHONPATH="`dirname $0`/../../Source/Python" \
+ python "`dirname $0`/../../Source/Python"/`basename $0`/`basename $0`.py $*
+
diff --git a/BaseTools/Bin/Darwin-i386/Arm/DEBUG_XCODE31/CompilerIntrinsicsLib.lib b/BaseTools/Bin/Darwin-i386/Arm/DEBUG_XCODE31/CompilerIntrinsicsLib.lib
new file mode 100644
index 0000000000..79964fe1b6
Binary files /dev/null and b/BaseTools/Bin/Darwin-i386/Arm/DEBUG_XCODE31/CompilerIntrinsicsLib.lib differ
diff --git a/BaseTools/Bin/Darwin-i386/Arm/DEBUG_XCODE32/CompilerIntrinsicsLib.lib b/BaseTools/Bin/Darwin-i386/Arm/DEBUG_XCODE32/CompilerIntrinsicsLib.lib
new file mode 100644
index 0000000000..79964fe1b6
Binary files /dev/null and b/BaseTools/Bin/Darwin-i386/Arm/DEBUG_XCODE32/CompilerIntrinsicsLib.lib differ
diff --git a/BaseTools/Bin/Darwin-i386/Arm/RELEASE_XCODE31/CompilerIntrinsicsLib.lib b/BaseTools/Bin/Darwin-i386/Arm/RELEASE_XCODE31/CompilerIntrinsicsLib.lib
new file mode 100644
index 0000000000..c82c915b8e
Binary files /dev/null and b/BaseTools/Bin/Darwin-i386/Arm/RELEASE_XCODE31/CompilerIntrinsicsLib.lib differ
diff --git a/BaseTools/Bin/Darwin-i386/Arm/RELEASE_XCODE32/CompilerIntrinsicsLib.lib b/BaseTools/Bin/Darwin-i386/Arm/RELEASE_XCODE32/CompilerIntrinsicsLib.lib
new file mode 100644
index 0000000000..c82c915b8e
Binary files /dev/null and b/BaseTools/Bin/Darwin-i386/Arm/RELEASE_XCODE32/CompilerIntrinsicsLib.lib differ
diff --git a/BaseTools/Bin/Win32/Arm/DEBUG_RVCT31/CompilerIntrinsicsLib.lib b/BaseTools/Bin/Win32/Arm/DEBUG_RVCT31/CompilerIntrinsicsLib.lib
new file mode 100644
index 0000000000..90dd1193b7
Binary files /dev/null and b/BaseTools/Bin/Win32/Arm/DEBUG_RVCT31/CompilerIntrinsicsLib.lib differ
diff --git a/BaseTools/Bin/Win32/Arm/RELEASE_RVCT31/CompilerIntrinsicsLib.lib b/BaseTools/Bin/Win32/Arm/RELEASE_RVCT31/CompilerIntrinsicsLib.lib
new file mode 100644
index 0000000000..fbce5c0e70
Binary files /dev/null and b/BaseTools/Bin/Win32/Arm/RELEASE_RVCT31/CompilerIntrinsicsLib.lib differ
diff --git a/BaseTools/Bin/Win32/BPDG.exe b/BaseTools/Bin/Win32/BPDG.exe
new file mode 100644
index 0000000000..fc5c09a66b
Binary files /dev/null and b/BaseTools/Bin/Win32/BPDG.exe differ
diff --git a/BaseTools/Bin/Win32/BootSectImage.exe b/BaseTools/Bin/Win32/BootSectImage.exe
new file mode 100755
index 0000000000..a2c13ce8db
Binary files /dev/null and b/BaseTools/Bin/Win32/BootSectImage.exe differ
diff --git a/BaseTools/Bin/Win32/Common.PyUtility.pyd b/BaseTools/Bin/Win32/Common.PyUtility.pyd
new file mode 100644
index 0000000000..5bb57d91e0
Binary files /dev/null and b/BaseTools/Bin/Win32/Common.PyUtility.pyd differ
diff --git a/BaseTools/Bin/Win32/EfiCompressor.pyd b/BaseTools/Bin/Win32/EfiCompressor.pyd
new file mode 100755
index 0000000000..e0d0ae60be
Binary files /dev/null and b/BaseTools/Bin/Win32/EfiCompressor.pyd differ
diff --git a/BaseTools/Bin/Win32/EfiLdrImage.exe b/BaseTools/Bin/Win32/EfiLdrImage.exe
new file mode 100755
index 0000000000..d918320749
Binary files /dev/null and b/BaseTools/Bin/Win32/EfiLdrImage.exe differ
diff --git a/BaseTools/Bin/Win32/EfiRom.exe b/BaseTools/Bin/Win32/EfiRom.exe
new file mode 100755
index 0000000000..3b8930c8de
Binary files /dev/null and b/BaseTools/Bin/Win32/EfiRom.exe differ
diff --git a/BaseTools/Bin/Win32/Eot.EfiCompressor.pyd b/BaseTools/Bin/Win32/Eot.EfiCompressor.pyd
new file mode 100644
index 0000000000..0729100b99
Binary files /dev/null and b/BaseTools/Bin/Win32/Eot.EfiCompressor.pyd differ
diff --git a/BaseTools/Bin/Win32/Eot.LzmaCompressor.pyd b/BaseTools/Bin/Win32/Eot.LzmaCompressor.pyd
new file mode 100644
index 0000000000..d792a7e9fb
Binary files /dev/null and b/BaseTools/Bin/Win32/Eot.LzmaCompressor.pyd differ
diff --git a/BaseTools/Bin/Win32/Fpd2Dsc.exe b/BaseTools/Bin/Win32/Fpd2Dsc.exe
new file mode 100755
index 0000000000..9cfeea5de2
Binary files /dev/null and b/BaseTools/Bin/Win32/Fpd2Dsc.exe differ
diff --git a/BaseTools/Bin/Win32/GenBootSector.exe b/BaseTools/Bin/Win32/GenBootSector.exe
new file mode 100755
index 0000000000..c6895aca1f
Binary files /dev/null and b/BaseTools/Bin/Win32/GenBootSector.exe differ
diff --git a/BaseTools/Bin/Win32/GenCrc32.exe b/BaseTools/Bin/Win32/GenCrc32.exe
new file mode 100755
index 0000000000..cb484d0d5f
Binary files /dev/null and b/BaseTools/Bin/Win32/GenCrc32.exe differ
diff --git a/BaseTools/Bin/Win32/GenDepex.exe b/BaseTools/Bin/Win32/GenDepex.exe
new file mode 100755
index 0000000000..6c01edb036
Binary files /dev/null and b/BaseTools/Bin/Win32/GenDepex.exe differ
diff --git a/BaseTools/Bin/Win32/GenFds.exe b/BaseTools/Bin/Win32/GenFds.exe
new file mode 100755
index 0000000000..17139fa7b1
Binary files /dev/null and b/BaseTools/Bin/Win32/GenFds.exe differ
diff --git a/BaseTools/Bin/Win32/GenFfs.exe b/BaseTools/Bin/Win32/GenFfs.exe
new file mode 100755
index 0000000000..610e275763
Binary files /dev/null and b/BaseTools/Bin/Win32/GenFfs.exe differ
diff --git a/BaseTools/Bin/Win32/GenFv.exe b/BaseTools/Bin/Win32/GenFv.exe
new file mode 100755
index 0000000000..18dca5c76e
Binary files /dev/null and b/BaseTools/Bin/Win32/GenFv.exe differ
diff --git a/BaseTools/Bin/Win32/GenFw.exe b/BaseTools/Bin/Win32/GenFw.exe
new file mode 100755
index 0000000000..a99d6b88bf
Binary files /dev/null and b/BaseTools/Bin/Win32/GenFw.exe differ
diff --git a/BaseTools/Bin/Win32/GenPage.exe b/BaseTools/Bin/Win32/GenPage.exe
new file mode 100755
index 0000000000..40e154e2a5
Binary files /dev/null and b/BaseTools/Bin/Win32/GenPage.exe differ
diff --git a/BaseTools/Bin/Win32/GenPatchPcdTable.exe b/BaseTools/Bin/Win32/GenPatchPcdTable.exe
new file mode 100755
index 0000000000..0163b10f37
Binary files /dev/null and b/BaseTools/Bin/Win32/GenPatchPcdTable.exe differ
diff --git a/BaseTools/Bin/Win32/GenSec.exe b/BaseTools/Bin/Win32/GenSec.exe
new file mode 100755
index 0000000000..45af0ab7dc
Binary files /dev/null and b/BaseTools/Bin/Win32/GenSec.exe differ
diff --git a/BaseTools/Bin/Win32/GenVtf.exe b/BaseTools/Bin/Win32/GenVtf.exe
new file mode 100755
index 0000000000..4e1567cd2d
Binary files /dev/null and b/BaseTools/Bin/Win32/GenVtf.exe differ
diff --git a/BaseTools/Bin/Win32/ImportTool.bat b/BaseTools/Bin/Win32/ImportTool.bat
new file mode 100755
index 0000000000..d896216c4c
--- /dev/null
+++ b/BaseTools/Bin/Win32/ImportTool.bat
@@ -0,0 +1,53 @@
+@REM
+@REM Copyright (c) 2008, Intel Corporation. All rights reserved.
+@REM This program and the accompanying materials
+@REM are licensed and made available under the terms and conditions of the BSD License
+@REM which accompanies this distribution. The full text of the license may be found at
+@REM http://opensource.org/licenses/bsd-license.php
+@REM
+@REM THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+@REM WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+@REM
+
+@echo off
+@if /I "%1"=="-h" goto Usage
+@if /I "%1"=="-help" goto Usage
+@if /I "%1"=="--help" goto Usage
+@if /I "%1"=="/h" goto Usage
+@if /I "%1"=="/help" goto Usage
+@if /I "%1"=="/?" goto Usage
+
+set IMPORT_TOOL=%~dp0Trim.exe
+if NOT exist %IMPORT_TOOL% (
+ echo.
+ echo !!! Trim.exe was not found. Please make sure that it is in the same directory as this script!
+ echo.
+ goto End
+)
+
+if '%*'=='' (
+ set FILE_LIST=*.c
+) else (
+ set FILE_LIST=%*
+)
+
+for /r %%i in (%FILE_LIST%) do (
+ echo Converting ... %%i
+ %IMPORT_TOOL% -8 -o %%i %%i
+)
+goto End
+
+:Usage
+ echo.
+ echo Usage: "%0 [-h | -help | --help | /h | /help | /?] [files]"
+ echo.
+ echo files File list or file pattern with wildcard, like "*.c *.h",
+ echo seperated by space. If not specified, defaul to *.c.
+echo.
+
+:End
+set FILE_LIST=
+set IMPORT_TOOL=
+
+@echo on
+
diff --git a/BaseTools/Bin/Win32/LzmaCompress.exe b/BaseTools/Bin/Win32/LzmaCompress.exe
new file mode 100755
index 0000000000..3d3fae05ac
Binary files /dev/null and b/BaseTools/Bin/Win32/LzmaCompress.exe differ
diff --git a/BaseTools/Bin/Win32/MigrationMsa2Inf.exe b/BaseTools/Bin/Win32/MigrationMsa2Inf.exe
new file mode 100755
index 0000000000..c4ad8c23cf
Binary files /dev/null and b/BaseTools/Bin/Win32/MigrationMsa2Inf.exe differ
diff --git a/BaseTools/Bin/Win32/PatchPcdValue.exe b/BaseTools/Bin/Win32/PatchPcdValue.exe
new file mode 100755
index 0000000000..afcaccfc66
Binary files /dev/null and b/BaseTools/Bin/Win32/PatchPcdValue.exe differ
diff --git a/BaseTools/Bin/Win32/Spd2Dec.exe b/BaseTools/Bin/Win32/Spd2Dec.exe
new file mode 100755
index 0000000000..239f9465f1
Binary files /dev/null and b/BaseTools/Bin/Win32/Spd2Dec.exe differ
diff --git a/BaseTools/Bin/Win32/Split.exe b/BaseTools/Bin/Win32/Split.exe
new file mode 100755
index 0000000000..8eb1351f5e
Binary files /dev/null and b/BaseTools/Bin/Win32/Split.exe differ
diff --git a/BaseTools/Bin/Win32/TargetTool.exe b/BaseTools/Bin/Win32/TargetTool.exe
new file mode 100755
index 0000000000..cdfb75e4fc
Binary files /dev/null and b/BaseTools/Bin/Win32/TargetTool.exe differ
diff --git a/BaseTools/Bin/Win32/TianoCompress.exe b/BaseTools/Bin/Win32/TianoCompress.exe
new file mode 100755
index 0000000000..0c76d2d3b2
Binary files /dev/null and b/BaseTools/Bin/Win32/TianoCompress.exe differ
diff --git a/BaseTools/Bin/Win32/Trim.exe b/BaseTools/Bin/Win32/Trim.exe
new file mode 100755
index 0000000000..6ad1ce7bf9
Binary files /dev/null and b/BaseTools/Bin/Win32/Trim.exe differ
diff --git a/BaseTools/Bin/Win32/VfrCompile.exe b/BaseTools/Bin/Win32/VfrCompile.exe
new file mode 100755
index 0000000000..2c4c1d7e54
Binary files /dev/null and b/BaseTools/Bin/Win32/VfrCompile.exe differ
diff --git a/BaseTools/Bin/Win32/VolInfo.exe b/BaseTools/Bin/Win32/VolInfo.exe
new file mode 100755
index 0000000000..8286eadfa1
Binary files /dev/null and b/BaseTools/Bin/Win32/VolInfo.exe differ
diff --git a/BaseTools/Bin/Win32/_hashlib.pyd b/BaseTools/Bin/Win32/_hashlib.pyd
new file mode 100755
index 0000000000..8023eacb8d
Binary files /dev/null and b/BaseTools/Bin/Win32/_hashlib.pyd differ
diff --git a/BaseTools/Bin/Win32/_socket.pyd b/BaseTools/Bin/Win32/_socket.pyd
new file mode 100755
index 0000000000..1255c1b7c0
Binary files /dev/null and b/BaseTools/Bin/Win32/_socket.pyd differ
diff --git a/BaseTools/Bin/Win32/_sqlite3.pyd b/BaseTools/Bin/Win32/_sqlite3.pyd
new file mode 100755
index 0000000000..ad05f52139
Binary files /dev/null and b/BaseTools/Bin/Win32/_sqlite3.pyd differ
diff --git a/BaseTools/Bin/Win32/_ssl.pyd b/BaseTools/Bin/Win32/_ssl.pyd
new file mode 100755
index 0000000000..4c1d3b4c45
Binary files /dev/null and b/BaseTools/Bin/Win32/_ssl.pyd differ
diff --git a/BaseTools/Bin/Win32/build.exe b/BaseTools/Bin/Win32/build.exe
new file mode 100755
index 0000000000..f2a949571c
Binary files /dev/null and b/BaseTools/Bin/Win32/build.exe differ
diff --git a/BaseTools/Bin/Win32/msvcr71.dll b/BaseTools/Bin/Win32/msvcr71.dll
new file mode 100644
index 0000000000..9d9e0286c4
Binary files /dev/null and b/BaseTools/Bin/Win32/msvcr71.dll differ
diff --git a/BaseTools/Bin/Win32/pyexpat.pyd b/BaseTools/Bin/Win32/pyexpat.pyd
new file mode 100755
index 0000000000..7b93757919
Binary files /dev/null and b/BaseTools/Bin/Win32/pyexpat.pyd differ
diff --git a/BaseTools/Bin/Win32/python25.dll b/BaseTools/Bin/Win32/python25.dll
new file mode 100755
index 0000000000..3e971eea3a
Binary files /dev/null and b/BaseTools/Bin/Win32/python25.dll differ
diff --git a/BaseTools/Bin/Win32/select.pyd b/BaseTools/Bin/Win32/select.pyd
new file mode 100755
index 0000000000..7babc50645
Binary files /dev/null and b/BaseTools/Bin/Win32/select.pyd differ
diff --git a/BaseTools/Bin/Win32/sqlite3.dll b/BaseTools/Bin/Win32/sqlite3.dll
new file mode 100755
index 0000000000..c99ef993cf
Binary files /dev/null and b/BaseTools/Bin/Win32/sqlite3.dll differ
diff --git a/BaseTools/BinWrappers/Darwin-i386 b/BaseTools/BinWrappers/Darwin-i386
new file mode 120000
index 0000000000..6de8e478db
--- /dev/null
+++ b/BaseTools/BinWrappers/Darwin-i386
@@ -0,0 +1 @@
+PosixLike
\ No newline at end of file
diff --git a/BaseTools/BinWrappers/Darwin-x86_64 b/BaseTools/BinWrappers/Darwin-x86_64
new file mode 120000
index 0000000000..6de8e478db
--- /dev/null
+++ b/BaseTools/BinWrappers/Darwin-x86_64
@@ -0,0 +1 @@
+PosixLike
\ No newline at end of file
diff --git a/BaseTools/BinWrappers/Linux-i686 b/BaseTools/BinWrappers/Linux-i686
new file mode 120000
index 0000000000..6de8e478db
--- /dev/null
+++ b/BaseTools/BinWrappers/Linux-i686
@@ -0,0 +1 @@
+PosixLike
\ No newline at end of file
diff --git a/BaseTools/BinWrappers/Linux-x86_64 b/BaseTools/BinWrappers/Linux-x86_64
new file mode 120000
index 0000000000..6de8e478db
--- /dev/null
+++ b/BaseTools/BinWrappers/Linux-x86_64
@@ -0,0 +1 @@
+PosixLike
\ No newline at end of file
diff --git a/BaseTools/BinWrappers/PosixLike/BPDG b/BaseTools/BinWrappers/PosixLike/BPDG
new file mode 120000
index 0000000000..af6c748b1a
--- /dev/null
+++ b/BaseTools/BinWrappers/PosixLike/BPDG
@@ -0,0 +1 @@
+RunToolFromSource
\ No newline at end of file
diff --git a/BaseTools/BinWrappers/PosixLike/BootSectImage b/BaseTools/BinWrappers/PosixLike/BootSectImage
new file mode 120000
index 0000000000..0993e62324
--- /dev/null
+++ b/BaseTools/BinWrappers/PosixLike/BootSectImage
@@ -0,0 +1 @@
+RunBinToolFromBuildDir
\ No newline at end of file
diff --git a/BaseTools/BinWrappers/PosixLike/BuildEnv b/BaseTools/BinWrappers/PosixLike/BuildEnv
new file mode 120000
index 0000000000..af6c748b1a
--- /dev/null
+++ b/BaseTools/BinWrappers/PosixLike/BuildEnv
@@ -0,0 +1 @@
+RunToolFromSource
\ No newline at end of file
diff --git a/BaseTools/BinWrappers/PosixLike/Ecc b/BaseTools/BinWrappers/PosixLike/Ecc
new file mode 120000
index 0000000000..af6c748b1a
--- /dev/null
+++ b/BaseTools/BinWrappers/PosixLike/Ecc
@@ -0,0 +1 @@
+RunToolFromSource
\ No newline at end of file
diff --git a/BaseTools/BinWrappers/PosixLike/EfiLdrImage b/BaseTools/BinWrappers/PosixLike/EfiLdrImage
new file mode 120000
index 0000000000..0993e62324
--- /dev/null
+++ b/BaseTools/BinWrappers/PosixLike/EfiLdrImage
@@ -0,0 +1 @@
+RunBinToolFromBuildDir
\ No newline at end of file
diff --git a/BaseTools/BinWrappers/PosixLike/EfiRom b/BaseTools/BinWrappers/PosixLike/EfiRom
new file mode 120000
index 0000000000..0993e62324
--- /dev/null
+++ b/BaseTools/BinWrappers/PosixLike/EfiRom
@@ -0,0 +1 @@
+RunBinToolFromBuildDir
\ No newline at end of file
diff --git a/BaseTools/BinWrappers/PosixLike/GenCrc32 b/BaseTools/BinWrappers/PosixLike/GenCrc32
new file mode 120000
index 0000000000..0993e62324
--- /dev/null
+++ b/BaseTools/BinWrappers/PosixLike/GenCrc32
@@ -0,0 +1 @@
+RunBinToolFromBuildDir
\ No newline at end of file
diff --git a/BaseTools/BinWrappers/PosixLike/GenDepex b/BaseTools/BinWrappers/PosixLike/GenDepex
new file mode 100755
index 0000000000..bd3141a758
--- /dev/null
+++ b/BaseTools/BinWrappers/PosixLike/GenDepex
@@ -0,0 +1,3 @@
+#!/usr/bin/env bash
+PYTHONPATH="`dirname $0`/../../Source/Python" \
+ python "`dirname $0`/../../Source/Python"/AutoGen/`basename $0`.py $*
diff --git a/BaseTools/BinWrappers/PosixLike/GenFds b/BaseTools/BinWrappers/PosixLike/GenFds
new file mode 120000
index 0000000000..af6c748b1a
--- /dev/null
+++ b/BaseTools/BinWrappers/PosixLike/GenFds
@@ -0,0 +1 @@
+RunToolFromSource
\ No newline at end of file
diff --git a/BaseTools/BinWrappers/PosixLike/GenFfs b/BaseTools/BinWrappers/PosixLike/GenFfs
new file mode 120000
index 0000000000..0993e62324
--- /dev/null
+++ b/BaseTools/BinWrappers/PosixLike/GenFfs
@@ -0,0 +1 @@
+RunBinToolFromBuildDir
\ No newline at end of file
diff --git a/BaseTools/BinWrappers/PosixLike/GenFv b/BaseTools/BinWrappers/PosixLike/GenFv
new file mode 120000
index 0000000000..0993e62324
--- /dev/null
+++ b/BaseTools/BinWrappers/PosixLike/GenFv
@@ -0,0 +1 @@
+RunBinToolFromBuildDir
\ No newline at end of file
diff --git a/BaseTools/BinWrappers/PosixLike/GenFw b/BaseTools/BinWrappers/PosixLike/GenFw
new file mode 120000
index 0000000000..0993e62324
--- /dev/null
+++ b/BaseTools/BinWrappers/PosixLike/GenFw
@@ -0,0 +1 @@
+RunBinToolFromBuildDir
\ No newline at end of file
diff --git a/BaseTools/BinWrappers/PosixLike/GenPage b/BaseTools/BinWrappers/PosixLike/GenPage
new file mode 120000
index 0000000000..0993e62324
--- /dev/null
+++ b/BaseTools/BinWrappers/PosixLike/GenPage
@@ -0,0 +1 @@
+RunBinToolFromBuildDir
\ No newline at end of file
diff --git a/BaseTools/BinWrappers/PosixLike/GenPatchPcdTable b/BaseTools/BinWrappers/PosixLike/GenPatchPcdTable
new file mode 120000
index 0000000000..af6c748b1a
--- /dev/null
+++ b/BaseTools/BinWrappers/PosixLike/GenPatchPcdTable
@@ -0,0 +1 @@
+RunToolFromSource
\ No newline at end of file
diff --git a/BaseTools/BinWrappers/PosixLike/GenSec b/BaseTools/BinWrappers/PosixLike/GenSec
new file mode 120000
index 0000000000..0993e62324
--- /dev/null
+++ b/BaseTools/BinWrappers/PosixLike/GenSec
@@ -0,0 +1 @@
+RunBinToolFromBuildDir
\ No newline at end of file
diff --git a/BaseTools/BinWrappers/PosixLike/GenVtf b/BaseTools/BinWrappers/PosixLike/GenVtf
new file mode 120000
index 0000000000..0993e62324
--- /dev/null
+++ b/BaseTools/BinWrappers/PosixLike/GenVtf
@@ -0,0 +1 @@
+RunBinToolFromBuildDir
\ No newline at end of file
diff --git a/BaseTools/BinWrappers/PosixLike/GnuGenBootSector b/BaseTools/BinWrappers/PosixLike/GnuGenBootSector
new file mode 120000
index 0000000000..0993e62324
--- /dev/null
+++ b/BaseTools/BinWrappers/PosixLike/GnuGenBootSector
@@ -0,0 +1 @@
+RunBinToolFromBuildDir
\ No newline at end of file
diff --git a/BaseTools/BinWrappers/PosixLike/LzmaCompress b/BaseTools/BinWrappers/PosixLike/LzmaCompress
new file mode 120000
index 0000000000..0993e62324
--- /dev/null
+++ b/BaseTools/BinWrappers/PosixLike/LzmaCompress
@@ -0,0 +1 @@
+RunBinToolFromBuildDir
\ No newline at end of file
diff --git a/BaseTools/BinWrappers/PosixLike/PatchPcdValue b/BaseTools/BinWrappers/PosixLike/PatchPcdValue
new file mode 120000
index 0000000000..af6c748b1a
--- /dev/null
+++ b/BaseTools/BinWrappers/PosixLike/PatchPcdValue
@@ -0,0 +1 @@
+RunToolFromSource
\ No newline at end of file
diff --git a/BaseTools/BinWrappers/PosixLike/RunBinToolFromBuildDir b/BaseTools/BinWrappers/PosixLike/RunBinToolFromBuildDir
new file mode 100755
index 0000000000..4821d24fa7
--- /dev/null
+++ b/BaseTools/BinWrappers/PosixLike/RunBinToolFromBuildDir
@@ -0,0 +1,29 @@
+#!/usr/bin/env bash
+#python `dirname $0`/RunToolFromSource.py `basename $0` $*
+#exec `dirname $0`/../../../../C/bin/`basename $0` $*
+
+TOOL_BASENAME=`basename $0`
+
+if [ -n "$WORKSPACE" -a -e $WORKSPACE/Conf/BaseToolsCBinaries ]
+then
+ exec $WORKSPACE/Conf/BaseToolsCBinaries/$TOOL_BASENAME
+elif [ -n "$WORKSPACE" -a -e $EDK_TOOLS_PATH/Source/C ]
+then
+ if [ ! -e $EDK_TOOLS_PATH/Source/C/bin/$TOOL_BASENAME ]
+ then
+ echo BaseTools C Tool binary was not found \($TOOL_BASENAME\)
+ echo You may need to run:
+ echo " make -C $EDK_TOOLS_PATH/Source/C"
+ else
+ exec $EDK_TOOLS_PATH/Source/C/bin/$TOOL_BASENAME $*
+ fi
+elif [ -e `dirname $0`/../../Source/C/bin/$TOOL_BASENAME ]
+then
+ exec `dirname $0`/../../Source/C/bin/$TOOL_BASENAME $*
+else
+ echo Unable to find the real \'$TOOL_BASENAME\' to run
+ echo This message was printed by
+ echo " $0"
+ exit -1
+fi
+
diff --git a/BaseTools/BinWrappers/PosixLike/RunToolFromSource b/BaseTools/BinWrappers/PosixLike/RunToolFromSource
new file mode 100755
index 0000000000..2cb8b86a99
--- /dev/null
+++ b/BaseTools/BinWrappers/PosixLike/RunToolFromSource
@@ -0,0 +1,5 @@
+#!/usr/bin/env bash
+#python `dirname $0`/RunToolFromSource.py `basename $0` $*
+PYTHONPATH="`dirname $0`/../../Source/Python" \
+ python "`dirname $0`/../../Source/Python"/`basename $0`/`basename $0`.py $*
+
diff --git a/BaseTools/BinWrappers/PosixLike/Split b/BaseTools/BinWrappers/PosixLike/Split
new file mode 120000
index 0000000000..0993e62324
--- /dev/null
+++ b/BaseTools/BinWrappers/PosixLike/Split
@@ -0,0 +1 @@
+RunBinToolFromBuildDir
\ No newline at end of file
diff --git a/BaseTools/BinWrappers/PosixLike/TargetTool b/BaseTools/BinWrappers/PosixLike/TargetTool
new file mode 120000
index 0000000000..af6c748b1a
--- /dev/null
+++ b/BaseTools/BinWrappers/PosixLike/TargetTool
@@ -0,0 +1 @@
+RunToolFromSource
\ No newline at end of file
diff --git a/BaseTools/BinWrappers/PosixLike/TianoCompress b/BaseTools/BinWrappers/PosixLike/TianoCompress
new file mode 120000
index 0000000000..0993e62324
--- /dev/null
+++ b/BaseTools/BinWrappers/PosixLike/TianoCompress
@@ -0,0 +1 @@
+RunBinToolFromBuildDir
\ No newline at end of file
diff --git a/BaseTools/BinWrappers/PosixLike/Trim b/BaseTools/BinWrappers/PosixLike/Trim
new file mode 120000
index 0000000000..af6c748b1a
--- /dev/null
+++ b/BaseTools/BinWrappers/PosixLike/Trim
@@ -0,0 +1 @@
+RunToolFromSource
\ No newline at end of file
diff --git a/BaseTools/BinWrappers/PosixLike/VfrCompile b/BaseTools/BinWrappers/PosixLike/VfrCompile
new file mode 120000
index 0000000000..0993e62324
--- /dev/null
+++ b/BaseTools/BinWrappers/PosixLike/VfrCompile
@@ -0,0 +1 @@
+RunBinToolFromBuildDir
\ No newline at end of file
diff --git a/BaseTools/BinWrappers/PosixLike/VolInfo b/BaseTools/BinWrappers/PosixLike/VolInfo
new file mode 120000
index 0000000000..0993e62324
--- /dev/null
+++ b/BaseTools/BinWrappers/PosixLike/VolInfo
@@ -0,0 +1 @@
+RunBinToolFromBuildDir
\ No newline at end of file
diff --git a/BaseTools/BinWrappers/PosixLike/build b/BaseTools/BinWrappers/PosixLike/build
new file mode 120000
index 0000000000..af6c748b1a
--- /dev/null
+++ b/BaseTools/BinWrappers/PosixLike/build
@@ -0,0 +1 @@
+RunToolFromSource
\ No newline at end of file
diff --git a/BaseTools/BinWrappers/PosixLike/fpd2dsc b/BaseTools/BinWrappers/PosixLike/fpd2dsc
new file mode 120000
index 0000000000..af6c748b1a
--- /dev/null
+++ b/BaseTools/BinWrappers/PosixLike/fpd2dsc
@@ -0,0 +1 @@
+RunToolFromSource
\ No newline at end of file
diff --git a/BaseTools/BinWrappers/PosixLike/msa2inf b/BaseTools/BinWrappers/PosixLike/msa2inf
new file mode 120000
index 0000000000..af6c748b1a
--- /dev/null
+++ b/BaseTools/BinWrappers/PosixLike/msa2inf
@@ -0,0 +1 @@
+RunToolFromSource
\ No newline at end of file
diff --git a/BaseTools/BinWrappers/PosixLike/spd2dec b/BaseTools/BinWrappers/PosixLike/spd2dec
new file mode 120000
index 0000000000..af6c748b1a
--- /dev/null
+++ b/BaseTools/BinWrappers/PosixLike/spd2dec
@@ -0,0 +1 @@
+RunToolFromSource
\ No newline at end of file
diff --git a/BaseTools/BuildEnv b/BaseTools/BuildEnv
new file mode 100755
index 0000000000..ca8a5781f6
--- /dev/null
+++ b/BaseTools/BuildEnv
@@ -0,0 +1,254 @@
+#
+# Copyright (c) 2006 - 2007, Intel Corporation. All rights reserved.
+# 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.
+
+#
+# Setup the environment for unix-like systems running a bash-like shell.
+# This file must be "sourced" not merely executed. For example: ". edksetup.sh"
+#
+
+SetWorkspace() {
+
+ #
+ # If WORKSPACE is already set, then we can return right now
+ #
+ if [ -n "$WORKSPACE" ]
+ then
+ return 0
+ fi
+
+ if [ ! ${BASH_SOURCE[0]} -ef ./BaseTools/BuildEnv ]
+ then
+ echo Run this script from the base of your tree. For example:
+ echo " cd /Path/To/Edk/Root"
+ echo " . BaseTools/BuildEnv"
+ return 1
+ fi
+
+ #
+ # Set $WORKSPACE
+ #
+ export WORKSPACE=`pwd`
+
+ return 0
+
+}
+
+RestorePreviousConfiguration() {
+ #
+ # Restore previous configuration
+ #
+ PREVIOUS_CONF_FILE=Conf/BuildEnv.sh
+ if [ -e $PREVIOUS_CONF_FILE ]
+ then
+ echo Loading previous configuration from \$WORKSPACE/$PREVIOUS_CONF_FILE
+ . $WORKSPACE/$PREVIOUS_CONF_FILE
+ fi
+}
+
+GenerateShellCodeToSetVariable() {
+ VARIABLE=$1
+ OUTPUT_FILE=$2
+ VAR_VALUE="echo \${${VARIABLE}}"
+ VAR_VALUE=`eval $VAR_VALUE`
+ echo "if [ -z \"\$${VARIABLE}\" ]" >> $OUTPUT_FILE
+ echo "then" >> $OUTPUT_FILE
+ echo " export ${VARIABLE}=${VAR_VALUE}" >> $OUTPUT_FILE
+ echo "fi" >> $OUTPUT_FILE
+}
+
+GenerateShellCodeToUpdatePath() {
+ OUTPUT_FILE=$1
+ echo "if [ -e $EDK_TOOLS_PATH_BIN ]" >> $OUTPUT_FILE
+ echo "then" >> $OUTPUT_FILE
+ echo " if [ "\${PATH/$EDK_TOOLS_PATH_BIN/}" == "\$PATH" ]" >> $OUTPUT_FILE
+ echo " then" >> $OUTPUT_FILE
+ echo " export PATH=$EDK_TOOLS_PATH_BIN:\$PATH" >> $OUTPUT_FILE
+ echo " fi" >> $OUTPUT_FILE
+ echo "fi" >> $OUTPUT_FILE
+}
+
+StoreCurrentConfiguration() {
+ #
+ # Write configuration to a shell script to allow for configuration to be
+ # easily reloaded.
+ #
+ OUTPUT_FILE=Conf/BuildEnv.sh
+ #echo Storing current configuration into \$WORKSPACE/$OUTPUT_FILE
+ OUTPUT_FILE=$WORKSPACE/$OUTPUT_FILE
+ echo "# Auto-generated by ${BASH_SOURCE[0]}" > $OUTPUT_FILE
+ GenerateShellCodeToSetVariable WORKSPACE $OUTPUT_FILE
+ GenerateShellCodeToSetVariable EDK_TOOLS_PATH $OUTPUT_FILE
+ GenerateShellCodeToUpdatePath $OUTPUT_FILE
+}
+
+SetEdkToolsPath() {
+
+ #
+ # If EDK_TOOLS_PATH is already set, then we can return right now
+ #
+ if [ -n "$EDK_TOOLS_PATH" ]
+ then
+ return 0
+ fi
+
+ #
+ # Try $WORKSPACE/Conf/EdkTools
+ #
+ if [ -e $WORKSPACE/Conf/EdkTools ]
+ then
+ export EDK_TOOLS_PATH=$WORKSPACE/Conf/EdkTools
+ return 0
+ fi
+
+ #
+ # Try $WORKSPACE/Conf/BaseToolsSource
+ #
+ if [ -e $WORKSPACE/Conf/BaseToolsSource ]
+ then
+ export EDK_TOOLS_PATH=$WORKSPACE/Conf/BaseToolsSource
+ return 0
+ fi
+
+ #
+ # Try $WORKSPACE/BaseTools
+ #
+ if [ -e $WORKSPACE/BaseTools ]
+ then
+ export EDK_TOOLS_PATH=$WORKSPACE/BaseTools
+ return 0
+ fi
+
+ echo "Unable to determine EDK_TOOLS_PATH"
+ echo
+ echo "You may need to download the 'BaseTools' from buildtools.tianocore.org."
+ echo "After downloading, either create a symbolic link to the source at"
+ echo "\$WORKSPACE/Conf/BaseToolsSource, or set the EDK_TOOLS_PATH environment"
+ echo "variable."
+
+}
+
+GetBaseToolsBinSubDir() {
+ #
+ # Figure out a uniq directory name from the uname command
+ #
+ UNAME_DIRNAME=`uname -sm`
+ UNAME_DIRNAME=${UNAME_DIRNAME// /-}
+ UNAME_DIRNAME=${UNAME_DIRNAME//\//-}
+ echo $UNAME_DIRNAME
+}
+
+GetEdkToolsPathBinDirectory() {
+ #
+ # Figure out a uniq directory name from the uname command
+ #
+ BIN_SUB_DIR=`GetBaseToolsBinSubDir`
+
+ if [ -e $EDK_TOOLS_PATH/BinWrappers/$BIN_SUB_DIR ]
+ then
+ EDK_TOOLS_PATH_BIN=$EDK_TOOLS_PATH/BinWrappers/$BIN_SUB_DIR
+ else
+ EDK_TOOLS_PATH_BIN=$EDK_TOOLS_PATH/Bin/$BIN_SUB_DIR
+ fi
+
+ echo $EDK_TOOLS_PATH_BIN
+}
+
+AddEdkToolsToPath() {
+
+ #
+ # If EDK_TOOLS_PATH is not set, then we cannot update PATH
+ #
+ if [ -z "$EDK_TOOLS_PATH" ]
+ then
+ return 1
+ fi
+
+ EDK_TOOLS_PATH_BIN=`GetEdkToolsPathBinDirectory`
+
+ if [ ! -e $EDK_TOOLS_PATH_BIN ]
+ then
+ echo "Unable to find expected bin path under \$EDK_TOOLS_PATH!"
+ echo "> $EDK_TOOLS_PATH_BIN"
+ return 1
+ fi
+
+ if [ "${PATH/$EDK_TOOLS_PATH_BIN/}" == "$PATH" ]
+ then
+ export PATH=$EDK_TOOLS_PATH_BIN:$PATH
+ return 0
+ fi
+
+}
+
+CopySingleTemplateFile() {
+
+ SRC_FILENAME=Conf/$1.template
+ DST_FILENAME=Conf/$1.txt
+
+ if [ -e $WORKSPACE/$DST_FILENAME ]
+ then
+ return
+ fi
+
+ echo "Copying \$EDK_TOOLS_PATH/$SRC_FILENAME"
+ echo " to \$WORKSPACE/$DST_FILENAME"
+ SRC_FILENAME=$EDK_TOOLS_PATH/$SRC_FILENAME
+ DST_FILENAME=$WORKSPACE/$DST_FILENAME
+ cp $SRC_FILENAME $DST_FILENAME
+
+}
+
+CopyTemplateFiles() {
+
+ CopySingleTemplateFile build_rule
+ CopySingleTemplateFile FrameworkDatabase
+ CopySingleTemplateFile tools_def
+ CopySingleTemplateFile target
+
+}
+
+ScriptMain() {
+
+ SetWorkspace
+ if [ -z $WORKSPACE ]
+ then
+ echo "Failure setting WORKSPACE"
+ return 1
+ fi
+
+ RestorePreviousConfiguration
+
+ SetEdkToolsPath
+ if [ -z $EDK_TOOLS_PATH ]
+ then
+ return 1
+ fi
+
+ AddEdkToolsToPath
+ if [ $? -ne 0 ]
+ then
+ echo "Failure adding EDK Tools into PATH!"
+ return 1
+ fi
+
+ StoreCurrentConfiguration
+
+ echo WORKSPACE: $WORKSPACE
+ echo EDK_TOOLS_PATH: $EDK_TOOLS_PATH
+
+ CopyTemplateFiles
+
+}
+
+#
+# Run the main function
+#
+ScriptMain
+
diff --git a/BaseTools/BuildNotes.txt b/BaseTools/BuildNotes.txt
new file mode 100644
index 0000000000..05bbd7ca9f
--- /dev/null
+++ b/BaseTools/BuildNotes.txt
@@ -0,0 +1,84 @@
+Intel(R) Platform Innovation Framework for EFI
+BuildTools Project, BaseTools Sub-Project
+Root Package 1.00
+2007-08-31
+
+Intel is a trademark or registered trademark of Intel Corporation or its
+subsidiaries in the United States and other countries.
+* Other names and brands may be claimed as the property of others.
+Copyright (c) 2007, Intel Corporation. All rights reserved.
+
+-------------------------------------------------------------------------------
+Quick Start
+-----------
+
+Windows:
+ a) Set the PYTHON_FREEZER_PATH to the cx_Freeze installation directory
+ b) Go to the /BaseTools and run "toolsetup" script
+
+Unix-like:
+ a) make -C /BaseTools
+ b) Look over https://edk2.tianocore.org/step-by-step-instructions.html
+ for a helpful step-by-step guide for building 'Hello World' on
+ various operating systems with edk2.
+
+Supported build targets (toolsetup)
+-----------------------------------
+
+build(or none) - Incremental Build of all C based tools. This is the default target
+rebuild - Clean all generated files and directories during build, and rebuild all tools
+
+-------------------------------------------------------------------------------
+Tools in Python
+---------------
+* Convert Python source to exe file
+
+ The tools written in Python can be converted into executable program which can
+ be executed without installing a Python interpreter. (Generally it is easier
+ to run the scripts from their source on operating systems other than Windows.)
+
+ For Windows and Linux, the conversion tool package is called cx_Freeze, its
+ home page is:
+
+ http://sourceforge.net/projects/cx-freeze/
+
+ If you have installed cx_Freeze at c:\cx_Freeze-3.0.3. Use following command
+ lines to convert MyBuild.py to MyBuild.exe (note this is an example, there is
+ no MyBuild Python project in the BaseTools\Python tree.
+
+ set PYTHONPATH=\Source\Python
+ c:\cx_Freeze-3.0.3\FreezePython.exe --include-modules=encodings.cp437,encodings.gbk,encodings.utf_16,encodings.utf_16_le,encodings.utf_8 --install-dir=.\mybuild MyBuild.py
+
+ The generated .exe (and .dll) files are put in "mybuild" subdirectory.
+
+ The following is a real example with the BuildTools/trunk/BaseTools project
+ installed in: C:\Work\BaseTools
+
+
+ C:\Work\BaseTools\Source\Python> set PYTHONPATH=C:\Work\BaseTools\Source\Python
+ C:\Work\BaseTools\Source\Python> c:\cx_Freeze-3.0.3\FreezePython.exe --include-modules=encodings.cp437,encodings.gbk,encodings.utf_16,encodings.utf_16_le,encodings.utf_8 --install-dir=C:\Work\BaseTools\Bin\Win32 build\build.py
+
+---------------
+* Execute tools written in Python without conversion
+
+Unix-like systems:
+
+The edk2/edksetup.sh script will setup everything which is needed to
+run the scripts from their source.
+
+Windows:
+
+ The tools written in Python can be executed directly from its source directory
+as long as the Python interpreter (Python 2.5) has been installed. Before the execution,
+please make sure the environment variable PYTHONPATH is set to
+
+ /BaseTools/Source/Python
+
+ There're four tools written in Python. The entrance file of each tool is listed
+below.
+
+ build /BaseTools/Source/Python/build/build.py
+ GenFds /BaseTools/Source/Python/GenFds/GenFds.py
+ Trim /BaseTools/Source/Python/Trim/Trim.py
+ MigrationMsa2Inf /BaseTools/Source/Python/MigrationMsa2Inf/MigrationMsa2Inf.py
+
diff --git a/BaseTools/Conf/FrameworkDatabase.template b/BaseTools/Conf/FrameworkDatabase.template
new file mode 100644
index 0000000000..6d88349d26
--- /dev/null
+++ b/BaseTools/Conf/FrameworkDatabase.template
@@ -0,0 +1,28 @@
+
+
+
+ FrameworkDatabase
+ DD6913E0-3E4E-4B83-8838-57EE7FB71DD1
+ 0.3
+ The Framework Module Development Packaging System Database
+
+ This Database tracks all packages and archives installed in this workspace.
+
+ Copyright (c) 2007 - 2009, Intel Corporation. All rights reserved.
+
+ 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.
+
+ FRAMEWORK_PACKAGING_SPECIFICATION 0x00090000
+
+
+ MdePkg/MdePkg.dec
+ MdeModulePkg/MdeModulePkg.dec
+ IntelFrameworkPkg/IntelFrameworkPkg.dec
+ IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec
+
+
diff --git a/BaseTools/Conf/ReadMe.txt b/BaseTools/Conf/ReadMe.txt
new file mode 100644
index 0000000000..0e5e39d36b
--- /dev/null
+++ b/BaseTools/Conf/ReadMe.txt
@@ -0,0 +1,9 @@
+This directory contains the template files for the next generation of the
+EDK II Build infrastructure. These files will be copied into the WORKSPACE's
+Conf directory if and only if the target files do not exist.
+
+These files may be updated frequently.
+
+The XMLSchema directory contains the EDK II Packaging XML definitions. The
+schema may change in the future. It differs somewhat from the early versions
+of the XML Schema.
\ No newline at end of file
diff --git a/BaseTools/Conf/XMLSchema/DistributionPackage.xsd b/BaseTools/Conf/XMLSchema/DistributionPackage.xsd
new file mode 100644
index 0000000000..b7cda67cda
--- /dev/null
+++ b/BaseTools/Conf/XMLSchema/DistributionPackage.xsd
@@ -0,0 +1,2818 @@
+
+
+
+
+
+ This schema defines the UEFI/PI
+ Distribution Package description (PKG) file. It describes the content
+ of:
+ 1) Package descriptions with
+ definitions and headers.
+ 2) Modules in either source or binary
+ format. (Note that Binary format is for FFS leaf section file types
+ only, complete FFS files cannot be distributed using this distribution
+ format.)
+ 3) The distribution of custom tools
+ used to modify the binary images to create UEFI/PI compliant images.
+ 4) Finally, it can be used to
+ distribute other miscellaneous content that is not specific to UEFI/PI
+ images.
+ The Package Surface Area describes the
+ content of packages, while the Module Surface Area provides information
+ relevant to source and/or binary distributions.
+
+
+
+
+
+ This header contains (legal)
+ information usually required for distributing both binary and/or
+ source code.
+
+
+
+
+ The list of packages in this
+ distribution.
+ Packages are groups of files
+ and/or modules that are similar in nature.
+ Packages are uniquely identified
+ by a package GUID and a package version.
+ A package can declare public
+ mappings of C names to GUID values.
+ A package can provide header
+ files for library classes and/or other industry standard
+ definitions.
+ A package can also declare
+ public mappings of platform configuration database (PCD)
+ "knobs" to control features and operation of
+ modules within a platform.
+ Finally, a package lists the
+ library instances and/or modules that are provided in a
+ distribution package.
+
+
+
+
+ The listing of UEFI/PI compliant
+ modules in this distribution that are NOT part of a Package. Every
+ module that is provided as part of a package needs to be described
+ in a PackageSurfaceArea.Modules section.
+ The ModuleSurfaceArea section
+ describes how each module in a distribution is coded, or, in the
+ case of a binary module distribution, how it was built.
+ UEFI/PI compliant libraries and
+ modules are uniquely identified by the Module's GUID and version
+ number.
+ This section will typically be
+ used for modules that don't require any additional files that
+ would be included in a package. For example, the Enhanced FAT
+ driver binary does not need to have a package description, as no
+ additional files are provided.
+
+
+
+
+ This section is for distributing
+ vendor specific executable tools, tool source code and/or
+ configuration files. These tools are primarily for manipulating
+ code and/or binary images.
+ Tools in this section
+ can:
+ 1) Parse build meta-data files
+ to create source code files and build scripts.
+ 2) Modify image files to conform
+ to UEFI/PI specifications.
+ 3) Generate binary files from
+ certain types of text/unicode files.
+ 4) Generate PCI Option Roms or
+ Firmware Device images.
+ 5) Implement external
+ encoding/decoding/signature/GUIDed tools.
+ 6) Distribution Package
+ create/install/remove tools.
+
+
+
+
+ The list of miscellaneous files
+ in this distribution. Any files that are not listed in either the
+ Package, Module or Tools sections can be listed here. This section
+ can be used to distribute specifications for packages and modules
+ that are not "industry standards" such as a
+ specification for a chipset or a video device.
+
+
+
+
+ The UserExtensions section is
+ used to disseminate processing instructions that may be custom to
+ the content provided by the distribution. This section contains
+ information that is common to all aspects of this disribution.
+
+
+
+
+
+
+
+
+
+
+
+ This section defines the content of
+ the UEIF/PI compliant Distribution Package Header. This is the only
+ required element of a UEFI/PI compliant distribution package.
+
+
+
+
+
+
+ This is the User Interface Name
+ for this Distribution Package.
+ Each Distribution Package is
+ uniquely identified by it's GUID and Version number.
+
+
+
+
+
+
+
+ The reference name of
+ the Distribution Package file. This single word name can
+ be used by tools as a keyword or for directory and/or file
+ creation.
+ White space and special
+ characters (dash and underscore characters may be used)
+ are not permitted in this name.
+
+
+
+
+
+
+
+
+ This 128-bit GUID and the
+ Version attribute uniquely identify this Distribution Package.
+ Backward compatible releases of
+ a distribution package need only change the version number, while
+ non-backward compatible changes require the GUID to change
+ (resetting the version number to 1.0 is optional.)
+
+
+
+
+
+
+
+ This value, along with
+ the GUID, is used to uniquely identify this object. The
+ higher the number, the more recent the content.
+
+
+
+
+
+
+
+
+
+ A string identifying who created
+ this distribution package.
+
+
+
+
+ The date and time this
+ distribution was created. The format is: YYYY-MM-DDThh:mm:ss, for
+ example: 2001-01-31T13:30:00 (note the T character separator
+ between the calendar date and the time.
+
+
+
+
+ The copyright for this file that
+ is generated by the creator of the distribution. If a derivative
+ work is generated from an existing distribution, then the existing
+ copyright must be maintained, and additional copyrights may be
+ appended to the end of this element. It may also be the primary
+ copyright for all code provided in the Distribution Package.
+
+
+
+
+
+ A license that describes any
+ restrictions on the use of this distribution. If a derivative work
+ is allowed by the original license and a derivative work is
+ generated from an existing distribution, then the existing license
+ must be maintained, and additional licenses may be appended to the
+ end of this element. It may also be the primary license for all
+ code provided in the distribution file. Alternatively, this may
+ point to a filename that contains the License. The file (included
+ in the content zip file) will be stored in the same location as
+ the distribution package's .pkg file.
+
+
+
+
+ A one line description of the
+ Distribution Package.
+
+
+
+
+ A complete description of the
+ Distribution Package. This description may include the release
+ name of the file, the version of the file, and a complete
+ description of the file contents and/or features including a
+ description of the updates since the previous file release.
+
+
+
+
+
+ The packaging utilities will use
+ this MD5 sum value of the included ZIP file containing files
+ and/or code. If this element is not present, then installation
+ tools should assume that the content is correct, or that other
+ methods may be needed to verify content.
+
+
+
+
+ This version of this XML Schema
+ is 1.0
+
+
+
+
+
+ If set to true, all content within
+ this Distribution Package should NOT be modified. The default
+ permits modification of all content.
+
+
+
+
+ If set to true, then the content
+ can be repackaged into another distribution package. The default
+ prohibits repackaging the Distribution content.
+
+
+
+
+
+
+
+
+ A package is a collection of related
+ objects - Includes, Libraries and Modules.
+ Each package is uniquely identified by
+ it's GUID and Version number. Backward compatible releases of a package
+ need only change the version number, while non-backward compatible
+ changes require the GUID to change (resetting the version number to 1.0
+ is optional.)
+
+
+
+
+
+
+
+
+
+ This is the User Interface
+ Name for this package.
+
+
+
+
+
+
+ This is a single
+ word BaseName of the package. This BaseName can be
+ used by tools as a keyword and for directory/file
+ creation.
+
+
+
+
+
+
+
+
+ This GUID and the Version
+ attribute uniquely identify a given package.
+
+
+
+
+
+
+
+ This value, along
+ with the GUID, is used to uniquely identify this
+ object.
+ Backward
+ compatible changes must make sure this number is
+ incremented from the most recent version.
+ Non-backward compatible changes require a new GUID,
+ and the version can be reset.
+
+
+
+
+
+
+
+
+ If the package requires a
+ different copyright than the distribution package, this
+ element can list one or more copyright lines.
+
+
+
+
+
+ If the package requires
+ licenses that are different from the distribution package
+ license, this element can contain one or more license text
+ paragraphs (or license filenames.)
+
+
+
+
+ A one line description of
+ this package.
+
+
+
+
+ A complete description of
+ a package. This description may include the release name of
+ the package, the version of the package, and a complete
+ description of the package contents and/or features
+ including a description of the updates since the previous
+ package’s release.
+
+
+
+
+ This element is the
+ location (in the ZIP file) for the root directory of a
+ package.
+
+
+
+
+
+
+
+
+
+ The term cloned is used here to
+ indicate that this package as been copied and modified to a
+ completely different package. An example might be for a new
+ generation of chipsets that have few or no elements in common with
+ the original.
+
+
+
+
+
+ This GUID and the Version
+ attribute uniquely identify the Package that this Package
+ was copied from.
+
+
+
+
+
+
+ This value, along
+ with the GUID, is used to uniquely identify the
+ package that this package was cloned from.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Library Classes are public
+ interfaces that can be used by modules. One or more library
+ instances can implement a library class, however only one library
+ instance can be linked to an individual module. This provides the
+ platform integrator with the flexibility of choosing one library
+ instance's implementation over a different library instance.
+
+
+
+
+
+
+
+
+
+ The header file
+ provides definitions and function prototypes for a
+ library class. Modules can be coded against these
+ functions, using the definitions in this header,
+ without concerning themselves about the libraries'
+ implementation details. This is a PackagePath relative
+ path and filename for the include file.
+
+
+
+
+
+
+
+
+ This GUID and
+ the Version attribute uniquely identify the
+ Recommended Library Instance.
+
+
+
+
+
+
+
+ This
+ value, along with the GUID, is used to
+ uniquely identify this object. If this
+ value is not specified, then any version
+ of the library instance is recommended.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ The single word name
+ of the Library Class that module developers will use to
+ identify a library class dependency.
+
+
+
+
+
+
+
+
+
+
+
+
+ This section is used to list
+ header files for industry standards not under the auspices of
+ UEFI.org. For example, headers that contain definitions and data
+ structures for the USB specifications.
+
+
+
+
+
+
+
+
+ The package relative
+ path and filename (in the content zip file) of the
+ industry standard include file.
+
+
+
+
+
+
+
+
+
+
+
+
+
+ All top level header files that
+ are included by a package that are not listed above. They cannot
+ be:
+ 1) Local to a module (module
+ specific.)
+ 2) An industry standard header.
+ 3) A library class header.
+
+
+
+
+
+
+
+
+
+ This is the Package
+ relative path and filename location within the content
+ ZIP file.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ This section lists the
+ Module Surface Area for all modules provided with this
+ package.
+
+
+
+
+
+
+
+
+
+ This section defines the mapping
+ of GUID C names to GUID values as a Registry Format GUID.
+ Modules that use these GUIDs
+ must specify their dependency on this package.
+
+
+
+
+
+ Individual GUID
+ Declarations
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ This section defines the mapping
+ of Protocol C names to GUID values as a Registry Format GUID.
+ Modules that use these Protocols
+ must specify their dependency on this package.
+
+
+
+
+
+ Individual Protocol
+ Declarations
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ This section defines the mapping
+ of Ppi C names to GUID values as a Registry Format GUID.
+ Modules that use these Ppis must
+ specify their dependency on this package.
+
+
+
+
+
+ Individual PPI
+ Declarations
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ This section is used to declare
+ platform configuration knobs that are defined by this package.
+ Modules that use these PCD
+ values must specify their dependency on this package.
+
+
+
+
+
+
+
+
+
+ Specifies the C name
+ of the Token Space GUID of which this PCD Entry is a
+ member. This C name should also be listed in the GUIDs
+ section, (specified above,) where the C name is
+ assigned to a GUID value.
+
+
+
+
+ Specifies the 32-bit
+ token value for this PCD Entry. The Token number must
+ be unique to the Token Space that declares the PCD.
+ The minLength of 3
+ is required to handle the "0x" prefix to the hex
+ number.
+
+
+
+
+
+
+
+
+
+
+
+ A string that
+ contains the data type of this PCD Entry. PCD data
+ types are restricted to the following set:UINT8,
+ UINT16, UINT32, UINT64, VOID*, BOOLEAN.
+
+
+
+
+
+ A string that
+ contains one or more PCD Item types separated by
+ spaces. The PCD Item types are restricted to
+ FeaturePcd, FixedPcd, PatchPcd, Pcd and/or PcdEx.
+
+
+
+
+
+
+ This is a
+ recommended maximum data size for VOID* data types,
+ the actual value should be defined by the Platform
+ Integrator. It is not required for the other data
+ types.
+ The minLength of 3
+ is required to handle the "0x" prefix to the hex
+ number.
+
+
+
+
+
+
+
+
+
+
+
+
+ Valid Error messages
+ that may be implemented in a module for the PCD Entry.
+ Only One Error Number per PcdError, (multiple
+ ErrorMessage entries are permitted) and multiple
+ PcdError elements are permitted.
+
+
+
+
+
+ One of the
+ following types of comparisons, which must be
+ able to evaluate to either true or false.
+
+
+
+
+ The PCD
+ Value must be space separated list of values.
+ Values are restricted to the data type of this
+ PCD.
+
+
+
+
+
+
+
+
+
+
+
+ The PCD must
+ be within a specifed range of numeric values.
+ Restricted to C style Relational, Equality and
+ Logicial Operators and parenthesis are valid.
+ Only the CName for this PCD is permitted in
+ the ValidValueRange expression. All other
+ values must be numeric.
+ LValue (op
+ RValue)+
+
+
+
+
+ A in-fix
+ logical expression using C style logical
+ operators.
+
+
+
+
+
+ A hexadecimal
+ value for the error message as defined by
+ specifications.
+ The minLength
+ of 3 is required to handle the "0x" prefix to
+ the hex number.
+
+
+
+
+
+
+
+
+
+
+ This string
+ should be defined by specifications. There are
+ pre-defined error number ranges in the UEFI/PI
+ specificaiton.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ This section is used to describe
+ any PCD interdependencies or relationships.
+
+
+
+
+
+ This entry must used
+ TokenSpaceGuidCName.PcdCname for every named PCD. Restricted
+ to Relational, Equality and Logical Operators (NOT, AND, OR,
+ GT, GE, EQ, LE, LT and XOR) and parenthesis are valid. Only
+ the TokenSpaceGuidCName.PcdCname us permitted to name PCDs
+ in the expression. All other values must be numeric.
+ LValue (op RValue)+
+
+
+
+
+
+
+
+
+
+ This section contains files that
+ are not part of the code distributed with this package.
+
+
+
+
+
+
+ Only required if different
+ from the Package Copyright.
+
+
+
+
+ Only required if different
+ from the Package License.
+
+
+
+
+ A one line description of
+ this section's content.
+
+
+
+
+ A complete description of
+ the files in this section.
+
+
+
+
+ This is the PackagePath
+ relative path and filename location within the ZIP file.
+
+
+
+
+
+
+
+ If true, used by
+ installation tools to ensure that a file that must
+ be executable has the correct properties to permit
+ execution.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ This section is used for any
+ processing instructions that may be custom to the content provided
+ by this package that are common to this package.
+
+
+
+
+
+
+
+
+ This is a single word
+ identifier for grouping similar content that does not fit into
+ previously defined sections or other sections of the
+ Distribution.
+
+
+
+
+ This can be used to
+ differentiate multiple sections with a grouping.
+ For example, a PRE_PROCESS
+ Identifier might indicate specific steps and tools required
+ before processing module content, while a different
+ UserExtensions section with a POST_PROCESS Identifier might
+ describe steps that need to be executed after operations on
+ the modules in this package.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Each module is uniquely identified by
+ it's GUID and Version number. Backward compatible releases of a module
+ need only change the version number, while non-backward compatible
+ changes require the GUID to change (resetting the version number to 1.0
+ is optional.)
+
+
+
+
+
+
+
+
+
+ This is the User Interface
+ Name for this Module.
+
+
+
+
+
+
+ This is a single
+ word BaseName that will be used to create a module
+ meta-data file.
+ This name should
+ also be used to create output file names and
+ directories.
+
+
+
+
+
+
+
+
+ This GUID and the Version
+ attribute uniquely identify a given Module.
+
+
+
+
+
+
+
+ This value, along
+ with the GUID, is used to uniquely identify this
+ object.
+ Backward
+ compatible changes must make sure this number is
+ incremented from the most recent version.
+ Non-backward compatible changes require a new GUID,
+ and the version can be reset.
+
+
+
+
+
+
+
+
+ This is only required if
+ the Copyright is different from either the Package or
+ Distribution copyright.
+
+
+
+
+ This is only required if
+ the license is different from either the Package or
+ Distribution license.
+
+
+
+
+ A brief text description
+ of the module.
+
+
+
+
+ A complete description of
+ the module contents and/or features including a description
+ of the updates since the previous module release.
+
+
+
+
+
+
+
+
+
+
+ List general information about a
+ module, including the Supported Architectures, this module's type,
+ specifications the module is coded against, and other
+ informational content.
+
+
+
+
+
+ One of the Enumerated
+ module types that limit the use of a module.
+
+
+
+
+
+ For stand-alone modules
+ that are NOT part of any package, this is the path to the
+ root of the module as listed in the ZIP file. For modules
+ included in a package, this is the location, relative to the
+ root of the package (PackagePath) this module belongs to.
+
+
+
+
+
+ This element is only
+ required for the PEIM that produces the PCD PPI or the DXE
+ Driver that produces the PCD Protocol.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ This is a list of other
+ specifications that this module is written against. These
+ entries can be used in #define statements (depending on the
+ build system implementation, they may be autogenerated.)
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Different firmware
+ execution paths may be taken based on a given state of the
+ hardware, firmware, or through feature settings. A BootMode
+ may be declared (PRODUCES) or discovered (CONSUMES) based on
+ these states and feature settings. The supported boot modes
+ map to the PI specification Boot Modes. The boot modes
+ listed with Recovery are to indicate that the BootMode is
+ valid during a recovery boot.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ The module
+ always supports the given boot modes.
+
+
+
+
+
+ The module may
+ support a given mode on some execution paths.
+
+
+
+
+
+ The module will
+ change the boot mode.
+
+
+
+
+ The module will
+ change the boot mode on some exection paths.
+
+
+
+
+
+
+
+
+
+
+
+
+
+ The functions that make up
+ the Event, Timer, and Task Priority Services are used during
+ preboot to create, close, signal, and wait for events; to
+ set timers; and to raise and restore task priority levels as
+ defined in the UEFI specification. GUIDed events should be
+ listed in the Guids section.
+
+
+
+
+
+
+
+
+
+
+ The module will
+ register a notification function and calls the
+ function when it is signaled.
+
+
+
+
+ The module will
+ register a notification function and calls the
+ function when it is signaled on some execution
+ paths.
+
+
+
+
+ The module will
+ signal all events in an event group.
+
+
+
+
+
+ The module will
+ signal all events in an event group under some
+ execution paths.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ This is a list of
+ non-GUIDed Hand Off Blocks (HOBs) produced or consumed by
+ this module.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ A HOB must be
+ present in the system.
+
+
+
+
+ If present, the
+ HOB will be used.
+
+
+
+
+ The HOB is
+ always produced by the module.
+
+
+
+
+ The HOB may be
+ produced by the module under some execution paths.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ This section may be included for
+ Modules that are copied from a different module.
+
+
+
+
+
+
+ This GUID and the Version
+ attribute uniquely identify the Module that this Module was
+ copied from.
+
+
+
+
+
+
+ This value, along
+ with the GUID, is used to uniquely identify this
+ object.
+
+
+
+
+
+
+
+
+
+
+
+
+
+ A list of the different Library
+ Classes consumed by a driver, core and/or application module, or
+ produced by a Library module.
+
+
+
+
+
+
+
+
+ Used by tools to
+ identify different instances of libraries that provide
+ the library class. This keyword identifies the library
+ class this module needs to be linked against.
+
+
+
+
+
+
+
+
+ This GUID and
+ the Version attribute uniquely identify the
+ recommended Library Instance for this module .
+
+
+
+
+
+
+
+ This
+ value, along with the GUID, is used to
+ uniquely identify this object.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Library instances
+ can provide code for a library class, or may require
+ other library instances themselves. Since different
+ execution paths in a library (or module) may need
+ different library classes based on some setting,
+ library classes may not alway be required.
+
+
+
+
+
+
+
+
+
+
+
+
+
+ A FeatureFlag
+ attribute must evaluate to either true or false - it may
+ be a fixed value of true or false, a C name or an in-fix
+ expression.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ This is the module
+ relative (ModuleProperties.Path) path and filename location
+ within the ZIP file.
+
+
+
+
+
+
+ The Family
+ attribute is used to restrict usage to a given
+ family of compilers, such as GCC or MSFT. Since not
+ all code processing tools use the same syntax,
+ especially for assembly, this field can be used to
+ identify different syntax.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ This is the module
+ relative (ModuleProperties.Path) path and filename
+ location within the ZIP file.
+
+
+
+
+
+
+
+
+ Binary
+ file distribution is limited to UEFI/PI
+ FFS leaf section file types.
+
+
+
+
+
+
+
+ A
+ UEFI/PI FFS Leaf section file type, not
+ a raw PE32 file.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ This section
+ contains information about how the module was coded,
+ such as Compiler Tools, Flags, PCDs (only PatchPcd
+ and/or PcdEx) and Library Class Instances used to
+ build the binary.
+
+
+
+
+
+
+ The element is
+ the Patchable PCD Value that was used during the
+ build.
+
+
+
+
+
+
+
+ The
+ minLength of 3 is required to handle the
+ "0x" prefix to the hex number.
+
+
+
+
+
+
+
+
+
+
+
+
+ This
+ field is required if the Pcd Datum Type is
+ VOID*
+ The
+ minLength of 3 is required to handle the
+ "0x" prefix to the hex number.
+
+
+
+
+
+
+
+
+
+
+
+ The
+ minLength of 3 is required to handle the
+ "0x" prefix to the hex number.
+
+
+
+
+
+
+
+
+
+
+
+ Error
+ information implemented by the module.
+
+
+
+
+
+
+ The
+ minLength of 3 is required to handle the
+ "0x" prefix to the hex number.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ The element is
+ the DynamicEx PCD Value that was used during the
+ build.
+
+
+
+
+
+
+ The
+ minLength of 3 is required to handle the
+ "0x" prefix to the hex number.
+
+
+
+
+
+
+
+
+
+
+
+
+ This
+ field is required if the Pcd Datum Type is
+ VOID*
+
+
+
+
+
+
+
+
+
+
+
+ Error
+ information implemented by the module.
+
+
+
+
+
+
+ The
+ minLength of 3 is required to handle the
+ "0x" prefix to the hex number.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ This is the
+ actual library instance that was used to link
+ against the module.
+
+
+
+
+
+ This
+ GUID and the Version attribute uniquely
+ identify the actual Library Instance
+ linked in this module.
+
+
+
+
+
+
+ This
+ value, along with the GUID, is used to
+ uniquely identify this object.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Any
+ description of OS, Tool, and flags for the
+ individual tool can go in this section.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ This GUID and the
+ Version attribute uniquely identify Package that this
+ Module depends on.
+
+
+
+
+
+
+ This value,
+ along with the GUID, is used to uniquely
+ identify this object. If the version attribute
+ is not specified, the most recent version of
+ the package can be used.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Only valid for
+ Variable GUID types.
+ This can be either a Hex Array or
+ Unicode Data.
+
+
+
+
+
+
+
+
+
+ The module does
+ not install the GUID, and the GUID must be present
+ for the module to execute.
+
+
+
+
+ The module does
+ not install the GUID, however, the GUID will be
+ used if it is present.
+
+
+
+
+ The module
+ always installs the GUID.
+
+
+
+
+ The Module will
+ install the GUID under certain execution paths.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ A listing of protocols required
+ or produced by this module.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ A listing of PPIs required or
+ produced by this module.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ These elements specify
+ additional information about the module. This area may be used by
+ tools to generate code.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ This section describes how a
+ platform is coded with respect to the platform configuration
+ knobs.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ This is the PEI dependency
+ expression for a Dependency Section.
+
+
+
+
+
+ An in-fix expression, of C
+ identifiers and TRUE, FALSE, AND, OR, NOT, BEFORE, and AFTER
+ as well as parenthesis () in the in-fix notation. The
+ operators are restricted to grammar defined in the PI
+ specification.
+
+
+
+
+
+
+
+
+
+
+ This is the DXE dependency
+ expression for a Dependency Section.
+
+
+
+
+
+ An in-fix expression, of C
+ identifiers and TRUE, FALSE, AND, OR, NOT, BEFORE, and AFTER
+ as well as parenthesis () in the in-fix notation. The
+ operators are restricted to grammar defined in the PI
+ specification.
+
+
+
+
+
+
+
+
+
+
+ This is the SMM dependency
+ expression for a Dependency Section.
+
+
+
+
+
+ An in-fix expression, of C
+ identifiers and TRUE, FALSE, AND, OR, NOT, BEFORE, and AFTER
+ as well as parenthesis () in the in-fix notation. The
+ operators are restricted to grammar defined in the PI
+ specification.
+
+
+
+
+
+
+
+
+
+
+
+ This section is used to provide
+ comments and/or list auxiliary files, such as pdb or map files.
+
+
+
+
+
+
+
+ This is the path and
+ filename location within the ZIP file.
+
+
+
+
+
+
+ If true, used by
+ installation tools to ensure that a file that must
+ be executable has the correct properties to permit
+ execution.
+
+
+
+
+
+
+
+
+
+
+
+
+
+ This section is used for any
+ processing instructions that may be custom to the content provided
+ by the distribution that are common to module.
+ The content is vendor specific.
+ The content can be plain text as
+ well as any user-defined, properly formatted XML structure.
+
+
+
+
+
+ This is a single word
+ identifier for grouping similar content. For example,
+ ReferenceBuild might be used to identify non-PI compliant
+ build steps, with two different UserExtensions sections, one
+ with an Identifier of Prebuild, and another of PostBuild. Both
+ UserExtensions sections would use the same UserId.
+
+
+
+
+
+ This can be any string used
+ to differentiate or identify this section from other
+ UserExtensions sections.
+ For example, a PRE_PROCESS
+ Identifier might indicate specific steps and tools required
+ before processing module content, while a different
+ UserExtensions section with a POST_PROCESS Identifier might
+ describe steps that need to be executed after operations on
+ this module.
+
+
+
+
+
+
+
+
+
+
+ This attribute is used when the
+ binaries are distributed for this module and no code generation from
+ source files is required. If set, then the BinaryFiles section
+ should be used, and any files listed in the SourceFiles section do
+ not have to be built. Additionally, the AsBuilt section for each
+ binary file must be included.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ This is the User Interface
+ Name for this Tools Distribution.
+
+
+
+
+ This is only required if
+ the Copyright is different from the Distribution Package
+ copyright.
+
+
+
+
+ This is only required if
+ the License is different from the Distribution Package
+ license.
+
+
+
+
+ This is only required if
+ the Abstract is different from the Distribution Package
+ Abstract.
+
+
+
+
+ This is only required if
+ the Description is different from the Distribution Package
+ Description.
+
+
+
+
+
+
+
+ This is the path and filename
+ location within the ZIP file.
+
+
+
+
+
+
+ This is required for
+ tools that execute; it should not be used for
+ configuration files.
+
+
+
+
+ If true, used by
+ installation tools to ensure that a file that must be
+ executable has the correct properties to permit execution.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ This section contains a list of files
+ that are not part of the code distributed with modules, packages or
+ tools.
+
+
+
+
+
+
+
+
+ The User interface name
+ for this content.
+
+
+
+
+ This is only required if
+ the Copyright is different from the Distribution Package
+ Copyright.
+
+
+
+
+ This is only required if
+ the License is different from the Distribution Package
+ License.
+
+
+
+
+
+
+
+
+
+ This is the path and filename
+ location within the ZIP file.
+
+
+
+
+
+
+ If true, used by
+ installation tools to ensure that a file that must be
+ executable has the correct properties to permit execution.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ This is a single word identifier
+ for grouping similar content. For example, ReferenceBuild might be
+ used to identify non-PI compliant build steps, with two different
+ UserExtensions sections, one with an Identifier of Prebuild, and
+ another of PostBuild. Both UserExtensions sections would use the
+ same UserId.
+
+
+
+
+ This can be any string used to
+ differentiate or identify this section from other UserExtensions
+ sections.
+ For example, a PRE_PROCESS
+ Identifier might indicate specific steps and tools required before
+ processing distribution package content, while a different
+ UserExtensions section with a POST_PROCESS Identifier might describe
+ steps that need to be executed after operations on this content.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Any processor architecture not
+ listed above. The Architecture must be a target architecture of one
+ or more compiler tool chains.
+
+
+
+
+
+
+
+
+
+
+
+
+ Any other family of build
+ utilities for which compiler tools exist.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ The following module types are defined
+ by specifications.
+ Module types for components and
+ libraries defined for this distribution mechanism.
+
+
+
+
+ Use of this module is not
+ restricted.
+
+
+
+
+ This module is only applicable to
+ the DXE core.
+
+
+
+
+ This module is only applicable to
+ a DXE driver.
+
+
+
+
+ This module is only applicable to
+ a DXE runtime driver.
+
+
+
+
+ This module is only applicable to
+ an IPF DXE runtime driver.
+
+
+
+
+ This module is only applicable to
+ a DXE SMM driver.
+
+
+
+
+ This module is only applicable to
+ the PEI core.
+
+
+
+
+ This module is only valid for PEI
+ modules.
+
+
+
+
+ This module is only applicable to
+ Security phase.
+
+
+
+
+ This module is only valid for UEFI
+ drivers.
+
+
+
+
+ This module is only valid for UEFI
+ runtime drivers.
+
+
+
+
+ This module is only valid for UEFI
+ applications.
+
+
+
+
+ This content is restricted to a
+ specific implementation.
+
+
+
+
+
+
+
+ The following data types are defined
+ by the PCD specification (or PCD section of the UEFI/PI specifications.)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ The Feature PCD is a binary,
+ evaluating to either true or false. This is used during build to
+ include/exclude content. It can also be used during execution to
+ force execution paths within drivers, or to enable/disable features
+ within a driver for a given platform.
+
+
+
+
+ The Fixed PCD is a #define value
+ that is set at build time.
+
+
+
+
+ The Patch PCD is a #define that is
+ set at build time, and that can be modified within a binary file.
+ Additional information, such as the offset location of the value,
+ along with it's length may need to be provided.
+
+
+
+
+ This PCD type has an overloaded
+ definition. Prior to build, the platform integrator may choose to
+ implement a PCD as Fixed, Patchable or a Dynamic PCD. If the
+ platform integrator choose to use the PCD as dynamic, then a PCD
+ driver is required in the platform (PEI/DXE/both) to track the PCD
+ in some sort of 'database' of these items. For Dynamic PCDs, the
+ PcdGet* must pass in the token space guid and the token number to
+ retrieve data (PcdSet* also needs these values.)
+
+
+
+
+ The PCD can only be used as
+ Dynamic, and the platform firmware must contain a driver to maintain
+ a 'database' of these items. For Dynamic PCDs, the PcdGet* must pass
+ in the token space guid and the token number to retrieve data
+ (PcdSet* also needs these values.)
+
+
+
+
+
+
+
+
+
+ A GUID must contain five different
+ Hexadecimal character sets that are separated by a dash (-) character.
+
+
+
+
+
+
+
+
+
+ The EDK II build system supports
+ workstations running one of the following supported operating systems.
+ This is the OS for the developer's workstation, not the target platform.
+
+
+
+
+
+ For Windows 2003, Windows XP and
+ Windows Vista.
+
+
+
+
+ For Windows 2003, Windows XP and
+ Windows Vista.
+
+
+
+
+
+
+
+
+ Typically, this is used for
+ Windows Batch files.
+
+
+
+
+ Typically use for shell scripts -
+ valid for any Linux and Mac OS/X.
+
+
+
+
+
+
+
diff --git a/BaseTools/Conf/XMLSchema/FarManifest.xsd b/BaseTools/Conf/XMLSchema/FarManifest.xsd
new file mode 100644
index 0000000000..6e8c34ae9a
--- /dev/null
+++ b/BaseTools/Conf/XMLSchema/FarManifest.xsd
@@ -0,0 +1,174 @@
+
+
+
+
+
+
+ The Framework Archive File Format is defined as a Java Archive file, with a special xml file called FrameworkArchiveManifest.xml at the top of the archive. The FrameworkArchiveManifest.xml must be an instance of this schema.
+
+
+
+
+
+ This schema defines the Framework Archive Manifest.
+
+
+
+
+
+
+
+
+ The list of packages in this FAR.
+
+
+
+
+
+
+ Extra contents that are not part of any Package. These file paths are WORKSPACE relative. If a file exists in the workspace at this location, then the user should be asked whether to overwrite. When the user removes the far, these should be removed also, unless they have been modified (per md5sum).
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ This is the name of the .spd or file that describes the package. It must exist in the directory identified by DefaultPath.
+
+
+
+
+
+
+
+
+ This is the default installation location within the workspace. This also serves as the location within the far itself of the package root. The Contents of the pacakage will be found there. The user may choose some other location within the workspace to install the package, as long as it does not overlap a package that is already installed.
+
+
+
+
+
+
+ This is the list of files that belong to the package. They are specified by relative path from the root of the pacakge.
+
+
+
+
+
+
+
+
+
+
+
+ The FarFilename is used to build up the Contents list. It has an md5sum attribute for keeping track of whether the file is changed after it is installed. The Md5sum can also be used to check the integrity of a far before it is installed into the workspace.
+
+
+
+
+
+
+ The purpose of this element is to allow Guids to be assigned to or used by other elements in the schema.
+
+
+
+
+
+
+ This tag allows us to specify a tree of files all having a common root. All the files specified are relative to that common root.
+
+
+
+
+
+
+
+
+
+
+ Definitions and rules for creating, installing, updating and removing fars within the workspace.
+
+
+ 1. A module m is said to depend upon a package p, iff there exists a tuple (PackageGuid, PackageVerion) in the set m->PackageDependencies for which p->Guid==PackageGuid, and if PackageVersion is not empty, then p->Version== PackageVersion.
+
+
+ 2. A far f is said to depend on a far g, iff there is a module in a package in f that depends on a package in g.
+
+
+ 3. A far f is said to depend on a package p, iff there is a module m contained in f that depends on p.
+
+
+ 4. A far f may be installed into the workspace w, iff for each module m in f, m's dependencies are met by the packages in w or f.
+
+
+ a. It is supported to "partially" install a far. A partial installation of a far means that 1 or more packages are installed into the workspace from the far. For each package p in f, p's dependencies must be satisfied by a package in the workspace.
+
+
+ 5. A far f may be removed from the workspace w, iff for each module m in w, and for each package p in f, m does not depend on p.
+
+
+ a. It is supported to "partially" remove a far. In this case, one or more of the packages in the far can be removed, provided that for each package p in the workspace w, there does not exist a module m such that m depends on p.
+
+
+ 6. When installing a far f into workspace w, for each package p in f, allow the user to install in p's default location, or choose a new location l (which must be unoccupied) within the workspace. Record this location l in the database. Each package p in f will be recorded in the database, associated with the GUID of f, as well as the actual install location l. (So we will know which far each package belongs to.)
+
+
+ 7. When installing a far f into workspace w, if there exists a package p in w, and p is in f, then the user must be prompted to choose a location that does not collide with the location of p in workspace w. We will end up with two instances of p in w at two distinct locations. Alternately, the user may elect to partially install the far, leaving out the redundant package.
+
+
+ 8. A far f may replace a far g in the workspace w, iff for each module m contained in w, if m depends on a package p, and p is only contained in g, then there must exist a package q in f, such that m depends on q. The net effect is that g is removed and f is installed, in one operation. The normal rules for installing f still apply--the dependencies of the modules of f must be satisfied. After the replacement, it must be the case that all the modules dependencies in the workspace are satisfied. Note that it is possible to backrev a package in this way.
+
+
+ (If we find that the replace is not permitted, then the user may install f and keep g. Next, he could _port_ every module m in w that depends on g, to f and eventually remove g.)
+
+
+ 9. A special case of the above rule is that a far f may be reinstalled into the workspace. (This would allow the user to get a fresh copy, or change the location in the workspace where one or more of the packages of f are installed.)
+
+
+ 10. When a far f is removed from the workspace w, for each package p in f, we will remove p from w.
+
+
+ 11. If a package p belongs to a far f, then it is legal to remove p from the workspace w iff, there does not exist a module m in w such that m depends on p.
+
+
+ 12. When a far f is removed from the workspace, the we will remove all the files in f from the workspace tree. If a file has been modified from the original as installed from the far (per md5sum) then the user should be asked if he is "sure" he wants to remove it.
+
+
+ 13. When a far is created, a GUID is generated and assigned to the far. If a far is created from the same components at a later time, it would have a different GUID.
+
+
+ 14. If a package p is marked with p->RePackage==false, then p may not be added to a far.
+
+
+ 15. A far f is identical to a far g, iff f->Guid == g->Guid.
+
+
+ 17. A far f may be installed into the workspace w, iff there is no far g in w such that f->Guid==g->Guid. In that case, it is called "updating" the far in the workspace. The user may select some subset of packages to reinstall or update, to ensure that the files in the workspace are correct.
+
+
+
diff --git a/BaseTools/Conf/XMLSchema/FrameworkDataAttributes.xsd b/BaseTools/Conf/XMLSchema/FrameworkDataAttributes.xsd
new file mode 100644
index 0000000000..eeb48d9a8a
--- /dev/null
+++ b/BaseTools/Conf/XMLSchema/FrameworkDataAttributes.xsd
@@ -0,0 +1,180 @@
+
+
+
+
+ This schema defines EFI and Framework Attribute. Only attributeGroups are specified in this file.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/BaseTools/Conf/XMLSchema/FrameworkDataElements.xsd b/BaseTools/Conf/XMLSchema/FrameworkDataElements.xsd
new file mode 100644
index 0000000000..e094c1b626
--- /dev/null
+++ b/BaseTools/Conf/XMLSchema/FrameworkDataElements.xsd
@@ -0,0 +1,728 @@
+
+
+
+
+ This schema defines EFI and Framework Data Elements
+
+
+
+
+
+
+ Abstract is valid for all Description Files
+ This section is required. This is a single sentence to describe the module and will be used in sample files as the abstract data in the header comment section.
+
+
+
+
+ BootModes is valid for all Description Files
+ This is a list of BootModes Supported by the Module
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ This is a list of DataHubRecord elements.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ The default setting of a PCD entry.
+
+
+
+
+
+
+
+
+
+ This section is used to describe the DXE or PEI Dependency code
+
+
+
+
+
+
+
+
+
+
+ This section is required for new modules and libraries and must contain more information than the Abstract.
+
+
+
+
+ Multiple Filenames may be specified, and they may also be scoped to a specific Architecture.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ This is a list of MSA Events
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Module has an event that is waiting to be signaled. Event is named by GUID.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ This is a child of MSA files.
+
+
+
+
+
+
+
+
+
+
+
+ Driver Module
+
+
+
+
+
+
+ Library Module
+
+
+
+
+
+
+ Allow multiple entries for DriverBinding, ComponentName, DriverConfig and DriverDiag elements. For ComponentName, DriverConfig and/or DriverDiag - you must have a 1:1 mapping to DriverBinding if the element is defined.
+ Permit User Defined Extern Tags
+
+
+
+
+
+
+
+
+ Module Call Backs
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Describe the valid content of a filename This should extend PathAndFilename - Variable names not allowed here!
+
+
+
+
+
+
+
+
+
+
+
+ This is a list of Filenames
+
+
+
+
+
+
+
+
+
+ This is a child of PackageSurfaceArea (SPD)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Describe the valid content of a GUID element in and MSA file.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Describe the list of a HiiPackage elements
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Used in MSA files. This defines what class of library is being supported = produced (library module) or consumed by a module.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ This section defines what Classes of Library that this library supports. A Library may belong to multiple different library classes.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Describe the valid EFI Phase that the Module is designed to execute under.
+
+
+
+
+
+ MsaFiles is a child of Surface Area Package Description (SPD) files
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ This tag is used in the Module Surface Area Description File (MSA) to track package dependencies for a module.
+ Attributes to PackageName include Required: Usage PackageGuid PackageVesion, Optional: FeatureFlag
+
+
+
+
+
+
+
+
+
+
+
+
+
+ PackageHeaders is a child of PackageSurfaceArea (SPD)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ This tag is used in the Framework Package Database File to track all packages (SPD files) installed in a workspace. (Database)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Child of Module Surface Area Description (MSA)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ PcdDeclaratins is a child of Package Surface Area Description (SPD)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ This tag is used in the Framework Package Database File to track all DISTRIBUTION packages (FAR files) installed in a workspace. (Database)
+
+
+
+
+
+
+
+
+
+ PpiDeclarations is a child of PackageSurfaceArea (SPD)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Provide for one or more Ppi or PpiNotify sections.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ProtocolDeclarations is a child of PackageSurfaceArea (SPD)
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ If either Protocol or ProtocolNotify sections are needed, one or more of them should be specified within this section
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ Multiple Filenames may be specified, and they may also be scoped to a specific Architecture.
+
+
+
+
+
+
+
+
+
+ This is list of System Table elements.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ An MSA FILE list of EFI Variables described by string pair.
+
+
+
+
+
+ This is an EFI Variable Entry
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/BaseTools/Conf/XMLSchema/FrameworkDataTypes.xsd b/BaseTools/Conf/XMLSchema/FrameworkDataTypes.xsd
new file mode 100644
index 0000000000..9a46a02a2e
--- /dev/null
+++ b/BaseTools/Conf/XMLSchema/FrameworkDataTypes.xsd
@@ -0,0 +1,581 @@
+
+
+
+
+ This schema defines EFI and Framework Data Types. Only simpleType are specified in this file.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/BaseTools/Conf/XMLSchema/FrameworkHeaders.xsd b/BaseTools/Conf/XMLSchema/FrameworkHeaders.xsd
new file mode 100644
index 0000000000..e2745af378
--- /dev/null
+++ b/BaseTools/Conf/XMLSchema/FrameworkHeaders.xsd
@@ -0,0 +1,93 @@
+
+
+
+
+
+
+ This is the header for the Framework Package Database (DB) file.
+ The Guid MUST change if backward compatibility breaks caused by a new release of XML Schema.
+ The Version will change if a minor change to XML Schema has been made, but backward compatiblity is maintained.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ This is the header for the Framework Archive Manifest file.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ This header is for the Module Surface Area Description (MSA) files
+ The Guid MUST change if the Module changes break backward compatibility.
+ The Version MUST change if the Module changes, however, backward compatiblity is maintained.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ This head is for the Surface Area Package Description file (SPD)
+ The Guid MUST change when the contents of the file undergo MAJOR FUNCTIONALITY changes.
+ The Version MUST change when the contents of the file undergo MINOR FUNCTIONALITY changes.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/BaseTools/Conf/XMLSchema/NamingConvention.xsd b/BaseTools/Conf/XMLSchema/NamingConvention.xsd
new file mode 100644
index 0000000000..8a76639777
--- /dev/null
+++ b/BaseTools/Conf/XMLSchema/NamingConvention.xsd
@@ -0,0 +1,186 @@
+
+
+
+
+ This schema defines various data types and naming conventions including: base name, filename and directory naming conventions. These are all simple data types.
+
+
+
+ C_Names must start with either an underscore (_) character followed by one or more alpha characters, followed by any combination of underscore or alphanumeric characters.
+
+
+
+
+
+
+
+ This defines what a Filename is: Alphanumeric characters and optional underscore (_) or dash (-) characters, followed by a optional dot and more alphanumeric characters.
+
+
+
+
+
+
+
+ The GUID data was a union of GuidType1 and GuidType2; standardizing on GuidType2.
+
+
+
+
+
+ This defines the minimum specification for a GUID Array which is 8 Hex Digits - 4 Hex Digits - 4 Hex Digits - 8 Hex Bytes, the last 16 Hex Digits can be enclosed in sqiggle {} brackets.
+
+
+
+
+
+
+
+ A GUID must contain five different Hexadecimal character sets that are separated by a dash (-) character.
+
+
+
+
+
+
+
+ Define a Hex 64 Bit Value to be 0x[a-f0-9]{16}
+
+
+
+
+
+
+
+ Define a Hex Address, 0x[a-fA-F0-9]{1,16}
+
+
+
+
+
+
+
+ Define a Hex Byte Value to be 0x[a-f0-9]{2}
+
+
+
+
+
+
+
+ Define a Hex Value to be 0x[a-f0-9]+
+
+
+
+
+
+
+
+ Define a Hex Diget to be 0x[a-f0-9]
+
+
+
+
+
+
+
+ Define a Hex Double Word Value to be 0x[a-f0-9]{8}
+
+
+
+
+
+
+
+ Define a Hex Word Value to be 0x[a-f0-9]{4}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ This describes the normal text of a paragraph that can be used in a license or description tag.
+
+
+
+
+
+ Naming convention for a path and file name
+
+
+
+
+
+ Limit Polarity vaild values to 0 and 1
+
+
+
+
+
+
+
+ This data type requires two or more words
+
+
+
+
+
+
+
+ This data type is used for ToolCommand, ToolChainFamily and TagName.
+
+
+
+
+
+
+
+ Definition of a UpperCase Name, which can be any combination of upper case characters followed by zero or more underscore and/or uppercase alphanumeric characters
+
+
+
+
+
+
+
+ Definition of a Version Number, which is one or more strings of decimal digits separated by dots.
+
+ The algorithm to compare two versions A and B is as follows. if A==B, then A is the same version as B. Otherwise, say A is a1.a2.a3...an and B is b1.b2.b3...bn. For the first pair (ai, bi), for i less than n and i less than m, where ai is not equal to bi, if ai is less than bi, then A is less than B. If ai is greater than bi, then A is greater than B.
+
+
+
+
+
+
+
+
+ Define Zero as a vaild value
+
+
+
+
+
+
diff --git a/BaseTools/Conf/XMLSchema/SurfaceArea.xsd b/BaseTools/Conf/XMLSchema/SurfaceArea.xsd
new file mode 100644
index 0000000000..c941be81e7
--- /dev/null
+++ b/BaseTools/Conf/XMLSchema/SurfaceArea.xsd
@@ -0,0 +1,82 @@
+
+
+
+
+
+
+ This describes the valid content of a FrameworkDatabase (DB) File.
+
+
+
+
+
+
+
+
+
+
+
+
+ This describes the valid content for a Module Surface Area Description (MSA) file.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ This describes the valid content for a Package Surface Area Description (SPD) file.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/BaseTools/Conf/XMLSchema/SurfaceArea.xsdconfig b/BaseTools/Conf/XMLSchema/SurfaceArea.xsdconfig
new file mode 100644
index 0000000000..5d86b98fe7
--- /dev/null
+++ b/BaseTools/Conf/XMLSchema/SurfaceArea.xsdconfig
@@ -0,0 +1,16 @@
+
+
+
+
+ org.tianocore
+
+
+
diff --git a/BaseTools/Conf/XMLSchema/WorkspaceContent.xsd b/BaseTools/Conf/XMLSchema/WorkspaceContent.xsd
new file mode 100644
index 0000000000..1c9491a5e6
--- /dev/null
+++ b/BaseTools/Conf/XMLSchema/WorkspaceContent.xsd
@@ -0,0 +1,409 @@
+
+
+
+
+ This document covers the
+ WorkspaceContent.xml file that tracks what has been installed into an EDK
+ II development WORKSPACE.
+
+
+
+ This file describes the distributions,
+ packages, stand-alone (non-package) modules and miscellaneous files that
+ have been installed in THIS WORKSPACE. Additionally, any tools that are
+ installed as part of a distribution are tracked (tools are not required
+ to be installed within a WORKSPACE.)
+
+
+
+
+
+ This section tracks required
+ information about this WORKSPACE.
+
+
+
+
+ The list of UEFI/PI distribution
+ packages that have been installed in this WORKSPACE.
+
+
+
+
+
+
+
+
+
+
+
+
+ This User Interface Name can be
+ entered during initialization of a WORKSPACE to permit a developer
+ to uniquely identify a WORKSPACE.
+ This value can be used by report
+ generators.
+
+
+
+
+ When the WORKSPACE is first
+ initialized, this is the absolute path to the WORKSPACE. If the
+ user moves or re-names the directory, the RmPkg tool will need to
+ verify the content of this WORKSPACE before removing any content.
+
+
+
+
+
+ The date and time of the last
+ Package Installation or Removal. The format is:
+ YYYY-MM-DDThh:mm:ss, for example: 2001-01-31T13:30:00 (note the T
+ character separator between the calendar date and the time.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ The User Interface Name of
+ the module.
+
+
+
+
+
+
+ The BaseName is
+ used to create files and folders during a build, and
+ is used by packaging tools as a keyword to create
+ the INF file.
+
+
+
+
+
+
+
+
+ This is the GUID of the
+ module. Backward compatible versions of a module can use the
+ same GUID, however the version attribute must be changed
+ (incrementally.) Non-backward compatible versions of a
+ module must also provide a new GUID, while resetting the
+ version attribute is optional.
+
+
+
+
+ This is the WORKSPACE
+ relative path that the Module was installed in.
+
+
+
+
+
+ This is filename of the
+ INF file created in the InstalledFolder (listed above)
+ during installation.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ The User Interface Name of the
+ distribution.
+
+
+
+
+
+
+ This is the actual
+ BaseName used during the installation. Since users may
+ change the Distribution Package's default BaseName (used
+ to create the PKG and MANIFEST files) this is the real
+ name used to create the files.
+
+
+
+
+
+
+
+
+ This is the GUID of the
+ distribution, backward compatible versions of a distribution can
+ use the same GUID, however the version attribute must be changed
+ (incrementally.) Non-backward compatible versions of a
+ distribution must also provide a new GUID, while resetting the
+ version attribute is optional.
+
+
+
+
+ This is the filename of the XML
+ distribution package surface area (PKG) file that was stored in
+ the Conf/Pkgs folder of the WORKSPACE for this distribution
+ package.
+
+
+
+
+ This is the filename of the
+ distribution package manifest (.manifest) file that was created
+ and stored in the Conf/Pkgs folder of the WORKSPACE for this
+ distribution package. The InstallPkg tool must create this file
+ using the extracted locations of the content zip file (or,
+ alternatively, the user can create the file by redirecting the
+ output of the zip -Tv Contents.zip.)
+
+
+
+
+
+ This section tracks information
+ and content that is not associated with either packages or
+ modules, or is not required for building packages or modules.
+
+
+
+
+
+ If set to true, all content
+ within this distribution package should NOT be
+ modified.
+
+
+
+
+ If set to true, then the
+ content can be repackaged into another distribution
+ package.
+
+
+
+
+ If set to true, then either
+ the distribution or one of its packages has a user extensions
+ section that modified the tools_def.txt file.
+
+
+
+
+
+ This is used to identify a
+ distribution that provides tools that may or may not be
+ installed in a WORKSPACE.
+
+
+
+
+ This is used to identify a
+ distribution that provides miscellaneous files that must be
+ installed in a WORKSPACE.
+
+
+
+
+ This is used to identify a
+ distribution that has a UserExtensions section at the
+ Distribution, Package or Module level that uses an Identifier
+ other than BuildOptions, ToolsDef or DistributionPackage.
+
+
+
+
+
+
+
+ This section tracks individual
+ packages (collections of related items.) Each package listed in
+ this section must have a DEC file associated with it.
+
+
+
+
+
+
+
+
+
+ The User Interface
+ Name of the package.
+
+
+
+
+
+
+ The BaseName
+ is used to create files and folders during a
+ build, and is used by packaging tools as a
+ keyword to create the DEC file.
+
+
+
+
+
+
+
+
+
+ This is the GUID of
+ the package, backward compatible versions of a package
+ can use the same GUID, however the version attribute
+ must be changed (incrementally.) Non-backward
+ compatible versions of a package must also provide a
+ new GUID, while resetting the version attribute is
+ optional.
+
+
+
+
+ This is used to
+ track the actual installation location, relative to
+ the WORKSPACE. During an installation, the user may be
+ presented with an option to relocate package content
+ from the ZIP portion of the archive into a different
+ location.
+ Any installation tools must modify
+ this value if the location is different from the
+ default location.
+ Any removal tools must check this
+ value to locate correctly, the items that will be
+ removed.
+
+
+
+
+ This is the filename
+ of the package declaration (DEC) filename created
+ during installation in the InstalledFolder listed
+ above.
+
+
+
+
+ This section is used
+ to track the actual installation location, relative to
+ the WORKSPACE. Every module that is part of this
+ package must be listed here. During an installation,
+ the user may be presented with an option to relocate
+ module content from the ZIP portion of the archive
+ into a different location, the installation tools must
+ modify this value if the location is different from
+ the default location. Any removal tools must check
+ this value to locate correctly, the items that will be
+ removed.
+ The name of any INF
+ files that were created during the installation of a
+ distribution must also be listed in this section.
+
+
+
+
+
+
+
+
+
+
+
+ This section is used to record
+ distribution packages that contain modules that are not part of a
+ package. Modules that are part of packages are listed under the
+ Package element of the PackageList section.
+ Module only distribution will
+ typically be for binary only modules, like the enhanced FAT
+ driver.
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ A Registry format GUID must contain
+ five different Hexadecimal character sets that are separated by a dash
+ (-) character.
+
+
+
+
+
+
+
diff --git a/BaseTools/Conf/build_rule.template b/BaseTools/Conf/build_rule.template
new file mode 100644
index 0000000000..7c765d46b0
--- /dev/null
+++ b/BaseTools/Conf/build_rule.template
@@ -0,0 +1,533 @@
+#
+# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.
+# Portions copyright (c) 2008 - 2010, Apple Inc. All rights reserved.
+# 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.
+#
+
+## Syntax
+#
+# "*" is used to indicate that the source files will be processed at the same time.
+# "?" is used to indicate that the source files will be processed one by one.
+#
+# "[" [.][.][, [.][.]] "]"
+# ]>
+# (?|*). [(\n|,) (?|*).]
+#
+# ]>
+#
+#
+#
+#
+#
+# ]>
+#
+# []
+#
+# is the MODULE_TYPE in EDK2 or COMPONENT_TYPE in EDK.
+# Missing will cause an exception and break build.
+# Missing will cause that related build target won't be generated but
+# won't break build.
+#
+
+## Placeholders for string substitution
+#
+# ${src} Source file(s) to be built (full path)
+# ${s_path} Source file directory (absolute path)
+# ${s_dir} Source file relative directory within a module
+# (Note: ${s_dir} is always equals to "." if source file is given in absolute path.)
+# ${s_name} Source file name without path
+# ${s_base} Source file name without extension and path
+# ${s_ext} Source file extension
+#
+# ${dst} Destination file(s) built from ${src} (full path)
+# ${d_path} Destination file directory (absolute path)
+# ${d_name} Destination file name without path
+# ${d_base} Destination file name without extension and path
+# ${d_ext} Destination file extension
+#
+# (+) Directory separator
+#
+
+## Macro
+# $(WORKSPACE) Workspace directory
+# $(OUTPUT_DIR) Directory for intermediate files for building a module
+# $(DEBUG_DIR) Directory for files used to debug a module
+# $(BUILD_DIR) All files for building a platform will be put in this directory
+# $(BIN_DIR) Common directory for executable files
+# $(FV_DIR) Directory to store flash image files
+# $(INC) Search path of current module
+# $(INC_LIST) A file containing search pathes of current module
+# $(LIBS) Static library files of current module
+# $(_FLAGS) Tools flags of current module
+# $(MODULE_NAME) Current module name
+# $(MODULE_TYPE) Current module type
+# $(MODULE_GUID) Current module guid
+# $(ARCH) Architecture of current module
+# $(TOOLCHAIN) Toolchain used to build current module
+# $(TARGET) Target of current module (DEBUG/RELEASE)
+# $() Path of tool
+# $(EDK_TOOLS_PATH) Path of build tools
+# $() File list of each file type
+# (Note: The macro name is derived from file type name. For example,
+# C-Code-File will have C_CODE_FILES macro.)
+# $() Macro point to a file containing list of files of a file type
+# (
+# Note: The macro and file name are derived from file type name.
+# For example, C-Code-File will have C_CODE_FILES_LIST macro pointing
+# to $(OUTPUT_DIR)/c_code_files.lst. The list file and macro name
+# will be generated only when this macro is used in command line.
+# This is intended to get over the long command line limitation.
+# )
+#
+# $(CP) copy command
+# $(MV) move command
+# $(RM) delete command
+# $(MD) create dir command
+# $(RD) remove dir command
+#
+
+## Reserved File-Type
+#
+# Don't change following names of file types and their associated files,
+# which are also used in tools' code
+#
+# C-Code-File
+# C-Header-File
+# Dynamic-Library-File
+# Static-Library-File
+# Visual-Form-Representation-File
+# Unicode-Text-File
+#
+
+[C-Code-File]
+
+ ?.c
+ ?.C
+ ?.cc
+ ?.CC
+ ?.cpp
+ ?.Cpp
+ ?.CPP
+
+
+ $(MAKE_FILE)
+
+
+ $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
+
+
+ "$(CC)" /Fo${dst} $(CC_FLAGS) $(INC) ${src}
+
+
+ # For RVCTCYGWIN CC_FLAGS must be first to work around pathing issues
+ "$(CC)" $(CC_FLAGS) -o ${dst} $(INC) ${src}
+ "$(SYMRENAME)" $(SYMRENAME_FLAGS) ${dst}
+
+
+ "$(CC)" $(CC_FLAGS) -o ${dst} $(INC) ${src}
+
+
+[C-Header-File]
+
+ *.h, *.H
+
+
+
+
+
+
+[Assembly-Code-File.COMMON.COMMON]
+
+ ?.asm, ?.Asm, ?.ASM
+
+
+ ?.S, ?.s
+
+
+ $(MAKE_FILE)
+
+
+ $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
+
+
+ "$(PP)" $(PP_FLAGS) $(INC) ${src} > ${d_path}(+)${s_base}.i
+ Trim --source-code --convert-hex -o ${d_path}(+)${s_base}.iii ${d_path}(+)${s_base}.i
+ "$(ASM)" /Fo${dst} $(ASM_FLAGS) /I${s_path} $(INC) ${d_path}(+)${s_base}.iii
+
+
+ "$(PP)" $(PP_FLAGS) $(INC) ${src} > ${d_path}(+)${s_base}.i
+ Trim --source-code -o ${d_path}(+)${s_base}.iii ${d_path}(+)${s_base}.i
+ # For RVCTCYGWIN ASM_FLAGS must be first to work around pathing issues
+ "$(ASM)" $(ASM_FLAGS) -o ${dst} $(INC) ${d_path}(+)${s_base}.iii
+
+[Assembly-Code-File.COMMON.IPF]
+
+ ?.s
+
+
+ $(MAKE_FILE)
+
+
+ $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
+
+
+ "$(PP)" $(PP_FLAGS) $(INC) ${src} > ${d_path}(+)${s_base}.i
+ Trim --source-code -o ${d_path}(+)${s_base}.iii ${d_path}(+)${s_base}.i
+ # For RVCTCYGWIN ASM_FLAGS must be first to work around pathing issues
+ "$(ASM)" $(ASM_FLAGS) -o ${dst} ${d_path}(+)${s_base}.iii
+
+[Visual-Form-Representation-File]
+
+ ?.vfr
+ ?.Vfr
+ ?.VFR
+
+
+ $(MAKE_FILE)
+
+
+ $(DEBUG_DIR)(+)${s_dir}(+)${s_base}.c
+
+
+ -$(MD) $(OUTPUT_DIR)(+)${s_dir} > NUL 2>&1
+ "$(VFRPP)" $(VFRPP_FLAGS) $(INC) ${src} > $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.i
+ -$(MD) ${d_path} > NUL 2>&1
+ "$(VFR)" $(VFR_FLAGS) --output-directory ${d_path} $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.i
+
+[Object-File]
+
+ *.obj
+ *.o
+
+
+ $(OUTPUT_DIR)(+)$(MODULE_NAME).lib
+
+
+ "$(SLINK)" $(SLINK_FLAGS) /OUT:${dst} @$(OBJECT_FILES_LIST)
+
+
+ "$(SLINK)" -cr ${dst} $(SLINK_FLAGS) @$(OBJECT_FILES_LIST)
+
+
+ "$(SLINK)" $(SLINK_FLAGS) ${dst} --via $(OBJECT_FILES_LIST)
+
+
+ # $(OBJECT_FILES_LIST) has wrong paths for cygwin
+ "$(SLINK)" $(SLINK_FLAGS) ${dst} $(OBJECT_FILES)
+
+
+ "$(SLINK)" $(SLINK_FLAGS) ${dst} -filelist $(OBJECT_FILES_LIST)
+
+[Static-Library-File]
+
+ *.lib
+
+
+ $(MAKE_FILE)
+
+
+ $(DEBUG_DIR)(+)$(MODULE_NAME).dll
+
+
+ "$(DLINK)" /OUT:${dst} $(DLINK_FLAGS) $(DLINK_SPATH) @$(STATIC_LIBRARY_FILES_LIST)
+
+
+ "$(DLINK)" -o ${dst} $(DLINK_FLAGS) -\( $(DLINK_SPATH) @$(STATIC_LIBRARY_FILES_LIST) -\) $(DLINK2_FLAGS)
+ "$(OBJCOPY)" $(OBJCOPY_FLAGS) ${dst}
+
+
+ "$(DLINK)" -o ${dst} $(DLINK_FLAGS) -( $(DLINK_SPATH) $(STATIC_LIBRARY_FILES) -) $(DLINK2_FLAGS)
+
+
+ "$(DLINK)" $(DLINK_FLAGS) -o ${dst} $(DLINK_SPATH) --via $(STATIC_LIBRARY_FILES_LIST) $(DLINK2_FLAGS)
+
+
+ #$(STATIC_LIBRARY_FILES_LIST) has wrong paths for cygwin
+ "$(DLINK)" $(DLINK_FLAGS) -o ${dst} $(DLINK_SPATH) $(STATIC_LIBRARY_FILES) $(DLINK2_FLAGS)
+
+
+ "$(DLINK)" $(DLINK_FLAGS) -o ${dst} $(DLINK_SPATH) -filelist $(STATIC_LIBRARY_FILES_LIST) $(DLINK2_FLAGS)
+
+
+[Static-Library-File.USER_DEFINED]
+
+ *.lib
+
+
+ $(MAKE_FILE)
+
+
+ $(DEBUG_DIR)(+)$(MODULE_NAME)
+
+
+ "$(DLINK)" $(DLINK_FLAGS) $(DLINK_SPATH) @$(STATIC_LIBRARY_FILES_LIST)
+
+
+ "$(DLINK)" $(DLINK_FLAGS) -\( $(DLINK_SPATH) @$(STATIC_LIBRARY_FILES_LIST) -\) $(DLINK2_FLAGS)
+
+
+ "$(DLINK)" $(DLINK_FLAGS) -( $(DLINK_SPATH) $(STATIC_LIBRARY_FILES) -) $(DLINK2_FLAGS)
+
+
+ "$(DLINK)" $(DLINK_FLAGS) -o ${dst} $(DLINK_SPATH) --via $(STATIC_LIBRARY_FILES_LIST) $(DLINK2_FLAGS)
+
+
+ #$(STATIC_LIBRARY_FILES_LIST) has the wrong paths for cygwin
+ "$(DLINK)" $(DLINK_FLAGS) -o ${dst} $(DLINK_SPATH) $(STATIC_LIBRARY_FILES) $(DLINK2_FLAGS)
+
+
+ "$(DLINK)" -o ${dst} $(DLINK_FLAGS) $(DLINK_SPATH) -filelist $(STATIC_LIBRARY_FILES_LIST) $(DLINK2_FLAGS)
+
+
+[Dynamic-Library-File]
+
+ ?.dll
+
+
+ $(DEBUG_DIR)(+)$(MODULE_NAME).efi
+
+
+ "$(GENFW)" -e $(MODULE_TYPE) -o ${dst} ${src} $(GENFW_FLAGS)
+ $(CP) ${dst} $(OUTPUT_DIR)
+ $(CP) ${dst} $(BIN_DIR)
+ -$(CP) $(DEBUG_DIR)(+)*.map $(OUTPUT_DIR)
+
+
+ $(OBJCOPY) --only-keep-debug ${src} $(BIN_DIR)(+)$(MODULE_NAME).debug
+ $(OBJCOPY) --strip-unneeded ${src}
+ $(OBJCOPY) --add-gnu-debuglink=$(BIN_DIR)(+)$(MODULE_NAME).debug ${src}
+ "$(GENFW)" -e $(MODULE_TYPE) -o ${dst} ${src} $(GENFW_FLAGS)
+ $(CP) ${dst} $(OUTPUT_DIR)
+ $(CP) ${dst} $(BIN_DIR)
+ -$(CP) $(DEBUG_DIR)(+)*.map $(OUTPUT_DIR)
+
+
+ # tool to convert Mach-O to PE/COFF
+ "$(MTOC)" -subsystem $(MODULE_TYPE) $(MTOC_FLAGS) ${src} $(DEBUG_DIR)(+)$(MODULE_NAME).pecoff
+ # create symbol file for GDB debug
+ -$(DSYMUTIL) ${src}
+ "$(GENFW)" -e $(MODULE_TYPE) -o ${dst} $(DEBUG_DIR)(+)$(MODULE_NAME).pecoff $(GENFW_FLAGS)
+ $(CP) ${dst} $(OUTPUT_DIR)
+ $(CP) ${dst} $(BIN_DIR)
+ -$(CP) $(DEBUG_DIR)(+)*.map $(OUTPUT_DIR)
+
+[Dependency-Expression-File]
+
+ ?.dxs, ?.Dxs, ?.DXS
+
+
+ $(OUTPUT_DIR)(+)$(MODULE_NAME).depex
+
+
+ $(MAKE_FILE)
+
+
+ "$(PP)" $(APP_FLAGS) $(INC) ${src} > $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.i
+ Trim --source-code -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iii $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.i
+ GenDepex -t $(MODULE_TYPE) -o ${dst} $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iii
+
+[Acpi-Source-Language-File]
+
+ ?.asl, ?.Asl, ?.ASL
+
+
+ $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.aml
+
+
+ $(MAKE_FILE)
+
+
+ Trim --asl-file -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.i -i $(INC_LIST) ${src}
+ "$(ASLPP)" $(ASLPP_FLAGS) $(INC) /I${s_path} $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.i > $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iii
+ Trim --source-code -l -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iiii $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iii
+ "$(ASL)" $(ASL_FLAGS) $(ASL_OUTFLAGS)${dst} $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iiii
+
+
+ Trim --asl-file -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.i -i $(INC_LIST) ${src}
+ "$(ASLPP)" $(ASLPP_FLAGS) $(INC) -I${s_path} $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.i > $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iii
+ "$(ASL)" $(ASL_FLAGS) $(ASL_OUTFLAGS)${dst} $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.iii
+
+[C-Code-File.AcpiTable]
+
+ ?.c
+
+
+ $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.acpi
+
+
+ $(MAKE_FILE)
+
+
+ "$(ASLCC)" /Fo$(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj $(ASLCC_FLAGS) $(INC) ${src}
+ "$(ASLDLINK)" /OUT:$(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(ASLDLINK_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
+ "$(GENFW)" -o ${dst} -c $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(GENFW_FLAGS)
+
+
+ "$(ASLCC)" -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj $(CC_FLAGS) $(ASLCC_FLAGS) $(INC) ${src}
+ "$(ASLDLINK)" -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(ASLDLINK_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
+ "$(GENFW)" -o ${dst} -c $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(GENFW_FLAGS)
+
+[Acpi-Table-Code-File]
+
+ ?.aslc, ?.act
+
+
+ $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.acpi
+
+
+ $(MAKE_FILE)
+
+
+ "$(ASLCC)" /Fo$(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj $(ASLCC_FLAGS) $(INC) ${src}
+ "$(ASLDLINK)" /OUT:$(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(ASLDLINK_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
+ "$(GENFW)" -o ${dst} -c $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(GENFW_FLAGS)
+
+
+ "$(ASLCC)" -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj $(CC_FLAGS) $(ASLCC_FLAGS) $(INC) ${src}
+ "$(ASLDLINK)" -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(ASLDLINK_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
+ "$(GENFW)" -o ${dst} -c $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(GENFW_FLAGS)
+
+
+ "$(ASLCC)" -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj $(ASLCC_FLAGS) $(INC) ${src}
+ "$(ASLDLINK)" -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(ASLDLINK_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
+ "$(MTOC)" -subsystem $(MODULE_TYPE) $(MTOC_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.dll $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.efi
+ "$(GENFW)" -o ${dst} -c $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.efi $(GENFW_FLAGS)
+
+
+[Masm16-Code-File]
+
+ ?.asm16, ?.Asm16, ?.ASM16
+
+
+ $(MAKE_FILE)
+
+
+ $(OUTPUT_DIR)(+)${s_base}.com
+
+
+ cd $(OUTPUT_DIR)(+)${s_dir}
+ "$(ASM16)" /nologo /c /omf $(INC) /Fo$(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj ${src}
+ "$(ASMLINK)" $(ASMLINK_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj,${dst},,,,
+
+
+ "$(PP)" $(PP_FLAGS) $(INC) ${src} > ${d_path}(+)${s_base}.i
+ Trim --source-code -o ${d_path}(+)${s_base}.iii ${d_path}(+)${s_base}.i
+ "$(ASM)" -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj $(ASM_FLAGS) $(INC) ${d_path}(+)${s_base}.iii
+ "$(DLINK)" -o ${dst} $(DLINK_FLAGS) -( $(DLINK_SPATH) $(LIBS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj -)
+
+
+ "$(PP)" $(PP_FLAGS) $(INC) ${src} > ${d_path}(+)${s_base}.i
+ Trim --source-code -o ${d_path}(+)${s_base}.iii ${d_path}(+)${s_base}.i
+ "$(ASM)" -o $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj $(ASM_FLAGS) $(INC) ${d_path}(+)${s_base}.iii
+ "$(SLINK)" $(SLINK_FLAGS) $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.slib $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.obj
+ otool -t $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.slib | hex2bin.py ${dst}
+
+
+[Microcode-File.USER_DEFINED, Microcode-File.Microcode]
+
+ ?.txt, ?.TXT, ?.Txt, ?.mut, ?.inc
+
+
+ $(OUTPUT_DIR)(+)${s_base}.mcb
+
+
+ "$(GENFW)" -o ${dst} -m ${src} $(GENFW_FLAGS)
+
+[Microcode-Binary-File]
+
+ *.mcb
+
+
+ $(MAKE_FILE)
+
+
+ $(OUTPUT_DIR)(+)$(MODULE_NAME).bin
+
+
+ "$(GENFW)" -o ${dst} -j $(MICROCODE_BINARY_FILES) $(GENFW_FLAGS)
+ -$(CP) ${dst} $(BIN_DIR)
+
+[EFI-Image-File]
+
+ ?.efi, ?.Efi, ?.EFI
+
+
+
+
+
+[Unicode-Text-File]
+
+ *.uni, *.Uni, *.UNI
+
+
+ $(DEBUG_DIR)(+)AutoGen.c
+ $(DEBUG_DIR)(+)$(MODULE_NAME)StrDefs.h
+
+
+
+[Efi-Image.UEFI_OPTIONROM]
+
+ ?.efi, ?.EFI, ?.Efi
+
+
+ $(BIN_DIR)(+)$(MODULE_NAME).rom
+
+
+ $(OPTROM) -i $(PCI_DEVICE_ID) -f $(PCI_VENDOR_ID) -l $(PCI_CLASS_CODE) -r $(PCI_REVISION) -o $dst $(OPTROM_FLAGS) $src
+
+[Unicode-Text-File.UEFI_HII]
+
+ *.uni, *.Uni, *.UNI
+
+
+ $(OUTPUT_DIR)(+)$(MODULE_NAME)StrDefs.hpk
+ $(DEBUG_DIR)(+)$(MODULE_NAME)StrDefs.h
+
+
+
+[Visual-Form-Representation-File.UEFI_HII]
+
+ ?.vfr
+ ?.Vfr
+ ?.VFR
+
+
+ $(MAKE_FILE)
+
+
+ $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.hpk
+
+
+ -$(MD) $(OUTPUT_DIR)(+)${s_dir} > NUL 2>&1
+ "$(VFRPP)" $(VFRPP_FLAGS) $(INC) ${src} > $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.i
+ -$(MD) $(OUTPUT_DIR)(+)${s_dir} > NUL 2>&1
+ "$(VFR)" $(VFR_FLAGS) --create-ifr-package --output-directory $(OUTPUT_DIR)(+)${s_dir} $(OUTPUT_DIR)(+)${s_dir}(+)${s_base}.i
+
+[Hii-Binary-Package.UEFI_HII]
+
+ *.hpk
+
+
+ $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.lib
+
+
+ $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc
+
+
+ "$(GENFW)" -o $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc -g $(MODULE_GUID) --hiipackage $(HII_BINARY_PACKAGES) $(GENFW_FLAGS)
+ "$(RC)" /Fo${dst} $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc
+
+
+ "$(GENFW)" -o $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc -g $(MODULE_GUID) --hiibinpackage $(HII_BINARY_PACKAGES) $(GENFW_FLAGS)
+ "$(RC)" $(RC_FLAGS) $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc ${dst}
+
+
+ GenFw -o $(OUTPUT_DIR)(+)$(MODULE_NAME)hii.rc -g $(MODULE_GUID) --hiibinpackage $(HII_BINARY_PACKAGES)
+
+
diff --git a/BaseTools/Conf/target.template b/BaseTools/Conf/target.template
new file mode 100644
index 0000000000..3c4c50ff1e
--- /dev/null
+++ b/BaseTools/Conf/target.template
@@ -0,0 +1,69 @@
+#
+# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
+#
+# 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.
+#
+#
+# ALL Paths are Relative to WORKSPACE
+
+# Separate multiple LIST entries with a SINGLE SPACE character, do not use comma characters.
+# Un-set an option by either commenting out the line, or not setting a value.
+
+#
+# PROPERTY Type Use Description
+# ---------------- -------- -------- -----------------------------------------------------------
+# ACTIVE_PLATFORM Filename Recommended Specify the WORKSPACE relative Path and Filename
+# of the platform description file that will be used for the
+# build. This line is required if and only if the current
+# working directory does not contain one or more description
+# files.
+ACTIVE_PLATFORM = Nt32Pkg/Nt32Pkg.dsc
+
+# TARGET List Optional Zero or more of the following: DEBUG, RELEASE,
+# UserDefined; separated by a space character.
+# If the line is missing or no value is specified, all
+# valid targets specified in the platform description file
+# will attempt to be built. The following line will build all
+# platform targets.
+TARGET = DEBUG
+
+# TARGET_ARCH List Optional What kind of architecture is the binary being target for.
+# One, or more, of the following, IA32, IPF, X64, EBC or ARM.
+# Multiple values can be specified on a single line, using
+# space charaters to separate the values. These are used
+# during the parsing of an platform description file,
+# restricting the build output target(s.)
+# The Build Target ARCH is determined by a logical AND of:
+# platform BuildOptions: tag
+# If not specified, then all valid architectures specified
+# in the platform file, for which tools are available, will be
+# built.
+TARGET_ARCH = IA32
+
+# TOOL_DEFINITION_FILE Filename Optional Specify the name of the filename to use for specifying
+# the tools to use for the build. If not specified,
+# tools_def.txt will be used for the build. This file
+# MUST be located in the WORKSPACE/Conf directory.
+TOOL_CHAIN_CONF = Conf/tools_def.txt
+
+# TAGNAME List Optional Specify the name(s) of the tools_def.txt TagName to use.
+# If not specified, all applicable TagName tools will be
+# used for the build. The list uses space character separation.
+TOOL_CHAIN_TAG = MYTOOLS
+
+# MAX_CONCURRENT_THREAD_NUMBER NUMBER Optional The number of concurrent threads. Recommend to set this
+# value to one more than the number of your compurter
+# cores or CPUs. Less than 2 means disable multithread build.
+MAX_CONCURRENT_THREAD_NUMBER = 1
+
+# Build rules definition
+#
+#
+BUILD_RULE_CONF = Conf/build_rule.txt
+
diff --git a/BaseTools/Conf/tools_def.template b/BaseTools/Conf/tools_def.template
new file mode 100644
index 0000000000..f54d507783
--- /dev/null
+++ b/BaseTools/Conf/tools_def.template
@@ -0,0 +1,3587 @@
+#
+# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
+# Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.
+#
+# 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.
+#
+
+IDENTIFIER = Default TOOL_CHAIN_CONF
+
+# common path macros
+DEFINE VS2003_BIN = C:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\bin
+DEFINE VS2003_DLL = C:\Program Files\Microsoft Visual Studio .NET 2003\Common7\IDE
+
+DEFINE VS2005_BIN = C:\Program Files\Microsoft Visual Studio 8\Vc\bin
+DEFINE VS2005_DLL = C:\Program Files\Microsoft Visual Studio 8\Common7\IDE;DEF(VS2005_BIN)
+DEFINE VS2005_BINX64 = C:\Program Files\Microsoft Visual Studio 8\Vc\bin\x86_amd64
+DEFINE VS2005_BIN64 = C:\Program Files\Microsoft Visual Studio 8\Vc\bin\x86_ia64
+
+DEFINE VS2005x86_BIN = C:\Program Files (x86)\Microsoft Visual Studio 8\Vc\bin
+DEFINE VS2005x86_DLL = C:\Program Files (x86)\Microsoft Visual Studio 8\Common7\IDE;DEF(VS2005x86_BIN)
+DEFINE VS2005x86_BINX64 = DEF(VS2005x86_BIN)\x86_amd64
+DEFINE VS2005x86_BIN64 = DEF(VS2005x86_BIN)\x86_ia64
+
+DEFINE VS2008_BIN = C:\Program Files\Microsoft Visual Studio 9.0\Vc\bin
+DEFINE VS2008_DLL = C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE;DEF(VS2008_BIN)
+DEFINE VS2008_BINX64 = DEF(VS2008_BIN)\x86_amd64
+DEFINE VS2008_BIN64 = DEF(VS2008_BIN)\x86_ia64
+
+DEFINE VS2008x86_BIN = C:\Program Files (x86)\Microsoft Visual Studio 9.0\Vc\bin
+DEFINE VS2008x86_DLL = C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE;DEF(VS2008x86_BIN)
+DEFINE VS2008x86_BINX64 = DEF(VS2008x86_BIN)\x86_amd64
+DEFINE VS2008x86_BIN64 = DEF(VS2008x86_BIN)\x86_ia64
+
+DEFINE WINSDK_VERSION = v6.0A
+DEFINE WINSDK_BIN = c:\Program Files\Microsoft SDKs\Windows\DEF(WINSDK_VERSION)\bin
+DEFINE WINSDKx86_BIN = c:\Program Files (x86)\Microsoft SDKs\Windows\DEF(WINSDK_VERSION)\bin
+
+# These defines are needed for certain Microsoft Visual Studio tools that
+# are used by other toolchains. An example is that ICC on Windows normally
+# uses Microsoft's nmake.exe.
+
+# Some MS_VS_BIN options: DEF(VS2003_BIN), DEF(VS2005_BIN), DEF(VS2005x86_BIN)
+DEFINE MS_VS_BIN = DEF(VS2005_BIN)
+# Some MS_VS_DLL options: DEF(VS2003_DLL), DEF(VS2005_DLL), DEF(VS2005x86_DLL)
+DEFINE MS_VS_DLL = DEF(VS2005_DLL)
+
+DEFINE WINDDK_BIN16 = C:\WINDDK\3790.1830\bin\bin16
+DEFINE WINDDK_BIN32 = C:\WINDDK\3790.1830\bin\x86
+DEFINE WINDDK_BINX64 = C:\WINDDK\3790.1830\bin\win64\x86\amd64
+DEFINE WINDDK_BIN64 = C:\WINDDK\3790.1830\bin\win64\x86
+
+# NOTE: The Intel C++ Compiler for Windows requires one of the Microsoft C compiler
+# tool chains for the linker and nmake commands.
+# This configuration assumes a Windows 2003 Server DDK installation.
+DEFINE ICC_VERSION = 9.1
+#DEFINE ICC_VERSION = 10.1.021
+DEFINE ICC_BIN32 = C:\Program Files\Intel\Compiler\C++\DEF(ICC_VERSION)\IA32\Bin
+DEFINE ICC_ASM32 = C:\Program Files\Intel\Compiler\C++\DEF(ICC_VERSION)\IA32\Bin
+DEFINE ICC_BIN32x86 = C:\Program Files (x86)\Intel\Compiler\C++\DEF(ICC_VERSION)\IA32\Bin
+DEFINE ICC_ASM32x86 = C:\Program Files (x86)\Intel\Compiler\C++\DEF(ICC_VERSION)\IA32\Bin
+
+DEFINE ICC_BINX64 = C:\Program Files\Intel\Compiler\C++\DEF(ICC_VERSION)\EM64T\Bin
+DEFINE ICC_ASMX64 = C:\Program Files\Intel\Compiler\C++\DEF(ICC_VERSION)\EM64T\Bin
+DEFINE ICC_BINX64x86 = C:\Program Files (x86)\Intel\Compiler\C++\DEF(ICC_VERSION)\EM64T\Bin
+DEFINE ICC_ASMX64x86 = C:\Program Files (x86)\Intel\Compiler\C++\DEF(ICC_VERSION)\EM64T\Bin
+
+DEFINE ICC_BIN64 = C:\Program Files\Intel\Compiler\C++\DEF(ICC_VERSION)\Itanium\Bin
+DEFINE ICC_BIN64x86 = C:\Program Files (x86)\Intel\Compiler\C++\DEF(ICC_VERSION)\Itanium\Bin
+
+
+# Note: The Intel C++ Compiler 11.1 uses different installation path from previous versions
+# We use "ICC11" tag for ICC 11.1 while "ICC" tag is dedicated for eariler versions
+#
+DEFINE ICC11_VERSION = 11.1
+DEFINE ICC11_BUILD = 067
+DEFINE ICC11_BIN32 = C:\Program Files\Intel\Compiler\DEF(ICC11_VERSION)\DEF(ICC11_BUILD)\bin\ia32
+DEFINE ICC11_ASM32 = C:\Program Files\Intel\Compiler\DEF(ICC11_VERSION)\DEF(ICC11_BUILD)\bin\ia32
+DEFINE ICC11_BIN32x86 = C:\Program Files (x86)\Intel\Compiler\DEF(ICC11_VERSION)\DEF(ICC11_BUILD)\bin\ia32
+DEFINE ICC11_ASM32x86 = C:\Program Files (x86)\Intel\Compiler\DEF(ICC11_VERSION)\DEF(ICC11_BUILD)\bin\ia32
+
+DEFINE ICC11_BINX64 = C:\Program Files\Intel\Compiler\DEF(ICC11_VERSION)\DEF(ICC11_BUILD)\bin\ia32_intel64
+DEFINE ICC11_ASMX64 = C:\Program Files\Intel\Compiler\DEF(ICC11_VERSION)\DEF(ICC11_BUILD)\bin\ia32_intel64
+DEFINE ICC11_BINX64x86 = C:\Program Files (x86)\Intel\Compiler\DEF(ICC11_VERSION)\DEF(ICC11_BUILD)\bin\intel64
+DEFINE ICC11_ASMX64x86 = C:\Program Files (x86)\Intel\Compiler\DEF(ICC11_VERSION)\DEF(ICC11_BUILD)\bin\intel64
+
+DEFINE ICC11_BIN64 = C:\Program Files\Intel\Compiler\DEF(ICC11_VERSION)\DEF(ICC11_BUILD)\bin\ia32_ia64
+DEFINE ICC11_BIN64x86 = C:\Program Files (x86)\Intel\Compiler\DEF(ICC11_VERSION)\DEF(ICC11_BUILD)\bin\ia32_ia64
+
+DEFINE EBC_BIN = C:\Program Files\Intel\EBC\Bin
+DEFINE EBC_BINx86 = C:\Program Files (x86)\Intel\EBC\Bin
+
+DEFINE ELFGCC_BIN = /usr/bin
+
+#
+# Option 1: Hard coded full path to compiler suite
+DEFINE UNIXGCC_IA32_PETOOLS_PREFIX = /opt/tiano/i386-tiano-pe/i386-tiano-pe/bin/
+DEFINE UNIXGCC_X64_PETOOLS_PREFIX = /opt/tiano/x86_64-pc-mingw64/x86_64-pc-mingw64/bin/
+DEFINE UNIXGCC_IPF_PETOOLS_PREFIX = /opt/tiano/ia64-pc-elf/ia64-pc-elf/bin/
+#
+# Option 2: Use an environment variable
+#DEFINE UNIXGCC_IA32_PETOOLS_PREFIX = ENV(IA32_PETOOLS_PREFIX)
+#DEFINE UNIXGCC_X64_PETOOLS_PREFIX = ENV(X64_PETOOLS_PREFIX)
+#
+# Option 3: Install the compiler suite into your default paths
+#DEFINE UNIXGCC_IA32_PETOOLS_PREFIX = i386-pc-mingw32-
+#DEFINE UNIXGCC_X64_PETOOLS_PREFIX = x86_64-pc-mingw32-
+#
+# Option 4: Create links under the BaseTools/Bin/gcc/ARCH directory
+# Links needed: gcc, ar & ld
+#DEFINE UNIXGCC_IA32_PETOOLS_PREFIX = ENV(WORKSPACE)/BaseTools/Bin/gcc/Ia32/
+#DEFINE UNIXGCC_X64_PETOOLS_PREFIX = ENV(WORKSPACE)/BaseTools/Bin/gcc/X64/
+#
+# Option 5: Install programs under user's home directory
+#DEFINE UNIXGCC_IA32_PETOOLS_PREFIX = ENV(HOME)/programs/gcc/ia32/bin/i686-pc-mingw32-
+#DEFINE UNIXGCC_X64_PETOOLS_PREFIX = ENV(HOME)/programs/gcc/x64/bin/x86_64-pc-mingw32-
+#
+
+DEFINE CYGWIN_BIN = c:/cygwin/bin
+DEFINE CYGWIN_BINIA32 = c:/cygwin/opt/tiano/i386-tiano-pe/i386-tiano-pe/bin/
+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 GCC45_IA32_PREFIX = /usr/bin/
+DEFINE GCC45_X64_PREFIX = /usr/bin/
+
+DEFINE UNIX_IASL_BIN = /usr/bin/iasl
+#DEFINE UNIX_IASL_BIN = $(HOME)/programs/iasl
+DEFINE WIN_ASL_BIN_DIR = C:\ASL
+DEFINE WIN_IASL_BIN = DEF(WIN_ASL_BIN_DIR)\iasl.exe
+DEFINE WIN_ASL_BIN = DEF(WIN_ASL_BIN_DIR)\asl.exe
+
+DEFINE IASL_FLAGS =
+DEFINE IASL_OUTFLAGS = -p
+DEFINE MS_ASL_OUTFLAGS = /Fo=
+DEFINE MS_ASL_FLAGS =
+
+DEFINE DEFAULT_WIN_ASL_BIN = DEF(WIN_IASL_BIN)
+DEFINE DEFAULT_WIN_ASL_FLAGS = DEF(IASL_FLAGS)
+DEFINE DEFAULT_WIN_ASL_OUTFLAGS = DEF(IASL_OUTFLAGS)
+#DEFINE DEFAULT_WIN_ASL_BIN = DEF(WIN_ASL_BIN)
+#DEFINE DEFAULT_WIN_ASL_FLAGS = DEF(MS_ASL_FLAGS)
+#DEFINE DEFAULT_WIN_ASL_OUTFLAGS = DEF(MS_ASL_OUTFLAGS)
+
+DEFINE MSFT_ASLPP_FLAGS = /nologo /E /C /FIAutoGen.h
+DEFINE MSFT_ASLCC_FLAGS = /nologo /c /FIAutoGen.h /TC /Dmain=ReferenceAcpiTable
+DEFINE MSFT_ASLDLINK_FLAGS = /NODEFAULTLIB /ENTRY:ReferenceAcpiTable /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER
+
+DEFINE ICC_WIN_ASLPP_FLAGS = /nologo /E /C /FIAutoGen.h
+DEFINE ICC_WIN_ASLCC_FLAGS = /nologo /c /FIAutoGen.h /TC /Dmain=ReferenceAcpiTable
+DEFINE ICC_WIN_ASLDLINK_FLAGS = /NODEFAULTLIB /ENTRY:ReferenceAcpiTable /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /NODEFAULTLIB:libmmt /NODEFAULTLIB:libirc
+
+DEFINE IPHONE_TOOLS = /Developer/Platforms/iPhoneOS.platform/Developer
+DEFINE RVCT31_TOOLS_PATH = c:/Program Files/ARM/RVCT/Programs/3.1/569/win_32-pentium
+DEFINE RVCT31CYGWIN_TOOLS_PATH = /cygdrive/c/Program Files/ARM/RVCT/Programs/3.1/569/win_32-pentium
+
+DEFINE SOURCERY_TOOLS = c:/Program Files/CodeSourcery/Sourcery G++ Lite/bin
+DEFINE SOURCERY_CYGWIN_TOOLS = /cygdrive/c/Program Files/CodeSourcery/Sourcery G++ Lite/bin
+
+####################################################################################
+#
+# format: TARGET_TOOLCHAIN_ARCH_COMMANDTYPE_ATTRIBUTE =
+# priority:
+# TARGET_TOOLCHAIN_ARCH_COMMANDTYPE_ATTRIBUTE (Highest)
+# ******_TOOLCHAIN_ARCH_COMMANDTYPE_ATTRIBUTE
+# TARGET_*********_ARCH_COMMANDTYPE_ATTRIBUTE
+# ******_*********_ARCH_COMMANDTYPE_ATTRIBUTE
+# TARGET_TOOLCHAIN_****_COMMANDTYPE_ATTRIBUTE
+# ******_TOOLCHAIN_****_COMMANDTYPE_ATTRIBUTE
+# TARGET_*********_****_COMMANDTYPE_ATTRIBUTE
+# ******_*********_****_COMMANDTYPE_ATTRIBUTE
+# TARGET_TOOLCHAIN_ARCH_***********_ATTRIBUTE
+# ******_TOOLCHAIN_ARCH_***********_ATTRIBUTE
+# TARGET_*********_ARCH_***********_ATTRIBUTE
+# ******_*********_ARCH_***********_ATTRIBUTE
+# TARGET_TOOLCHAIN_****_***********_ATTRIBUTE
+# ******_TOOLCHAIN_****_***********_ATTRIBUTE
+# TARGET_*********_****_***********_ATTRIBUTE
+# ******_*********_****_***********_ATTRIBUTE (Lowest)
+#
+####################################################################################
+####################################################################################
+#
+# Supported Tool Chains
+# =====================
+# VS2003 - win32 - Microsoft Visual Studio .NET 2003, Intel EBC, Intel ASL
+# VS2005 - win32 - Microsoft Visual Studio 2005 Team Suite Edition, Intel EBC, Intel ASL (also compatible with VS 2005 Express, Standard, and Pro)
+# VS2008 - win32 - Microsoft Visual Studio 2008 Team Suite with Intel ASL
+# DDK3790 - win32 - Microsoft Windows DDK 3790.1830, Intel EBC, Intel ASL
+# UNIXGCC - UNIX GCC, No EBC, Intel ASL
+# GCC44 - Linux - GCC 4.4 (Native), No EBC, Intel ASL
+# ELFGCC - Linux ELF GCC, No EBC, Intel ASL
+# CYGGCC - win32 - CygWin GCC, Intel EBC, Intel ASL
+# ICC - win32 - Intel C Compiler V9.1, Intel EBC, Intel ASL
+# ICC11 - win32 - Intel C Compiler V11.1, Intel EBC, Intel ASL
+# MYTOOLS - win32 - VS2008 for IA32/X64, WINDDK 3790.1830 for IPF, Intel EBC, Intel ASL
+# VS2003xASL - win32 - Microsoft Visual Studio .NET 2003, Intel EBC, Microsoft ASL
+# VS2005xASL - win32 - Microsoft Visual Studio 2005 Team Suite Edition, Intel EBC, Microsoft ASL
+# VS2008xASL - win32 - Microsoft Visual Studio 2008 Team Suite with Microsoft ASL
+# DDK3790xASL - win32 - Microsoft Windows DDK 3790.1830, Intel EBC, Microsoft ASL
+# CYGGCCxASL - win32 - CygWin GCC, Intel EBC, Microsoft ASL
+# ICCxASL - win32 - Intel C Compiler V9.1, Intel EBC, Microsoft ASL
+# ICC11xASL - win32 - Intel C Compiler V11.1, Intel EBC, Microsoft ASL
+# VS2005x86 - win64 - Microsoft Visual Studio 2005 Team Suite Edition (x86), Intel EBC, Intel ASL (also compatible with VS 2005 Express, Standard, and Pro)
+# VS2008x86 - win64 - Microsoft Visual Studio 2008 (x86) w/ Intel ASL
+# ICCx86 - win64 - Intel C Compiler V9.1 (x86), Intel EBC, Intel ASL
+# ICC11x86 - win64 - Intel C Compiler V11.1 (x86), Intel EBC, Intel ASL
+# VS2005x86xASL - win64 - Microsoft Visual Studio 2005 Team Suite Edition (x86), Intel EBC, Microsoft ASL (also compatible with VS 2005 Express, Standard, and Pro)
+# VS2008x86xASL - win64 - Microsoft Visual Studio 2008 (x86) w/ Microsoft ASL
+# ICCx86xASL - win64 - Intel C Compiler V9.1 (x86), Intel EBC, Microsoft ASL
+# ICC11x86xASL - win64 - Intel C Compiler V11.1 (x86), Intel EBC, Microsoft ASL
+# CYGGCCx86 - win64 - CygWin GCC (x86), Intel EBC (x86), Intel ASL
+# CYGGCCx86xASL - win64 - CygWin GCC (x86), Intel EBC (x86), Microsoft ASL
+# * Commented out - All versions of VS2005 use the same standard install directory
+#
+####################################################################################
+####################################################################################
+#
+# Supported Tool Chain Family
+# ===========================
+# MSFT - Microsoft
+# GCC - GNU GCC
+# INTEL - INTEL
+####################################################################################
+####################################################################################
+#
+# Intel EFI Byte Code Compiler (Template)
+#
+####################################################################################
+# *_*_EBC_*_FAMILY = INTEL
+#
+# *_*_EBC_PP_PATH = C:\Program Files\Intel\EBC\Bin\iec.exe
+# *_*_EBC_CC_PATH = C:\Program Files\Intel\EBC\Bin\iec.exe
+# *_*_EBC_SLINK_PATH = C:\Program Files\Intel\EBC\Bin\link.exe
+#
+# *_*_EBC_SLINK_FLAGS = /lib /NOLOGO /MACHINE:EBC
+# *_*_EBC_PP_FLAGS = /nologo /E /TC /FI$(DEST_DIR_DEBUG)/AutoGen.h
+# *_*_EBC_CC_FLAGS = /nologo /FAcs /c /W3 /WX /FI$(DEST_DIR_DEBUG)/AutoGen.h
+# *_*_EBC_DLINK_FLAGS = "C:\Program Files\Intel\EBC\Lib\EbcLib.lib" /NOLOGO /MACHINE:EBC /OPT:REF /NODEFAULTLIB /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER
+#
+####################################################################################
+#
+# Intel ACPI Source Language Compiler (Template)
+#
+####################################################################################
+# *_*_*_ASL_FAMILY = INTEL
+#
+# *_*_*_ASL_PATH = C:\ASL\iasl.exe
+#
+####################################################################################
+#
+# Microsoft ACPI Source Language Compiler (Template)
+#
+####################################################################################
+# *_*_*_ASL_FAMILY = MSFT
+#
+# *_*_*_ASL_PATH = C:\ASL\asl.exe
+#
+####################################################################################
+
+
+####################################################################################
+#
+# Microsoft Visual Studio .NET 2003 (IA-32 only, with Link Time Code Generation)
+# And Intel ACPI Compiler
+#
+####################################################################################
+# VS2003 - Microsoft Visual Studio .NET 2003 and Intel ACPI Source Language Compiler (iasl.exe)
+*_VS2003_*_*_FAMILY = MSFT
+
+##################
+# ASL definitions
+##################
+*_VS2003_*_ASL_PATH = DEF(DEFAULT_WIN_ASL_BIN)
+*_VS2003_*_ASL_FLAGS = DEF(DEFAULT_WIN_ASL_FLAGS)
+*_VS2003_*_ASL_OUTFLAGS = DEF(DEFAULT_WIN_ASL_OUTFLAGS)
+*_VS2003_*_ASLCC_FLAGS = DEF(MSFT_ASLCC_FLAGS)
+*_VS2003_*_ASLPP_FLAGS = DEF(MSFT_ASLPP_FLAGS)
+*_VS2003_*_ASLDLINK_FLAGS = DEF(MSFT_ASLDLINK_FLAGS)
+
+##################
+# IA32 definitions
+##################
+*_VS2003_IA32_*_DLL = DEF(VS2003_DLL)
+
+*_VS2003_IA32_MAKE_PATH = DEF(VS2003_BIN)\nmake.exe
+*_VS2003_IA32_CC_PATH = DEF(VS2003_BIN)\cl.exe
+*_VS2003_IA32_VFRPP_PATH = DEF(VS2003_BIN)\cl.exe
+*_VS2003_IA32_SLINK_PATH = DEF(VS2003_BIN)\lib.exe
+*_VS2003_IA32_DLINK_PATH = DEF(VS2003_BIN)\link.exe
+*_VS2003_IA32_APP_PATH = DEF(VS2003_BIN)\cl.exe
+*_VS2003_IA32_PP_PATH = DEF(VS2003_BIN)\cl.exe
+*_VS2003_IA32_ASM_PATH = DEF(VS2003_BIN)\ml.exe
+*_VS2003_IA32_ASM16_PATH = DEF(VS2003_BIN)\ml.exe
+*_VS2003_IA32_ASLCC_PATH = DEF(VS2003_BIN)\cl.exe
+*_VS2003_IA32_ASLPP_PATH = DEF(VS2003_BIN)\cl.exe
+*_VS2003_IA32_ASLDLINK_PATH = DEF(VS2003_BIN)\link.exe
+*_VS2003_IA32_RC_PATH = DEF(VS2003_BIN)\rc.exe
+
+ *_VS2003_IA32_MAKE_FLAGS = /nologo
+ *_VS2003_IA32_APP_FLAGS = /nologo /E /TC
+ *_VS2003_IA32_PP_FLAGS = /nologo /E /TC /FIAutoGen.h
+ *_VS2003_IA32_VFRPP_FLAGS = /nologo /E /TC /DVFRCOMPILE /FI$(MODULE_NAME)StrDefs.h
+ DEBUG_VS2003_IA32_CC_FLAGS = /nologo /c /WX /W4 /Gs32768 /Gy /D UNICODE /O1ib2 /GL /FIAutoGen.h /EHs-c- /GR- /GF /GX- /Zi /Gm
+RELEASE_VS2003_IA32_CC_FLAGS = /nologo /c /WX /W4 /Gs32768 /Gy /D UNICODE /O1ib2 /GL /FIAutoGen.h /EHs-c- /GR- /GF /GX-
+ DEBUG_VS2003_IA32_ASM_FLAGS = /nologo /c /WX /W3 /coff /Cx /Zd /Zi
+RELEASE_VS2003_IA32_ASM_FLAGS = /nologo /c /WX /W3 /coff /Cx /Zd
+ *_VS2003_IA32_SLINK_FLAGS = /nologo /LTCG
+ DEBUG_VS2003_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:I386 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
+RELEASE_VS2003_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4078 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:I386 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.data=.text /MERGE:.rdata=.text
+
+##################
+# EBC definitions
+##################
+*_VS2003_EBC_*_FAMILY = INTEL
+
+*_VS2003_EBC_MAKE_PATH = DEF(VS2003_BIN)\nmake.exe
+*_VS2003_EBC_PP_PATH = DEF(EBC_BIN)\iec.exe
+*_VS2003_EBC_VFRPP_PATH = DEF(EBC_BIN)\iec.exe
+*_VS2003_EBC_CC_PATH = DEF(EBC_BIN)\iec.exe
+*_VS2003_EBC_SLINK_PATH = DEF(EBC_BIN)\link.exe
+*_VS2003_EBC_DLINK_PATH = DEF(EBC_BIN)\link.exe
+*_VS2003_EBC_RC_PATH = DEF(VS2003_BIN)\rc.exe
+
+*_VS2003_EBC_MAKE_FLAGS = /nologo
+*_VS2003_EBC_PP_FLAGS = /nologo /E /TC /FIAutoGen.h
+*_VS2003_EBC_CC_FLAGS = /nologo /c /WX /W3 /FIAutoGen.h /D$(MODULE_ENTRY_POINT)=$(ARCH_ENTRY_POINT)
+*_VS2003_EBC_VFRPP_FLAGS = /nologo /E /TC /DVFRCOMPILE /FI$(MODULE_NAME)StrDefs.h
+*_VS2003_EBC_SLINK_FLAGS = /lib /NOLOGO /MACHINE:EBC
+*_VS2003_EBC_DLINK_FLAGS = "C:\Program Files\Intel\EBC\Lib\EbcLib.lib" /NOLOGO /NODEFAULTLIB /MACHINE:EBC /OPT:REF /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /MAP
+
+####################################################################################
+#
+# Microsoft Visual Studio .NET 2003 and Microsoft ACPI compiler
+#
+####################################################################################
+# VS2003xASL - Microsoft Visual Studio .NET 2003 and Microsoft ACPI Source Language Compiler (asl.exe)
+*_VS2003xASL_*_*_FAMILY = MSFT
+
+##################
+# ASL definitions
+##################
+*_VS2003xASL_*_ASL_PATH = DEF(WIN_ASL_BIN)
+*_VS2003xASL_*_ASL_FLAGS =
+*_VS2003xASL_*_ASL_OUTFLAGS = DEF(MS_ASL_OUTFLAGS)
+*_VS2003xASL_*_ASLCC_FLAGS = DEF(MSFT_ASLCC_FLAGS)
+*_VS2003xASL_*_ASLPP_FLAGS = DEF(MSFT_ASLPP_FLAGS)
+*_VS2003xASL_*_ASLDLINK_FLAGS = DEF(MSFT_ASLDLINK_FLAGS)
+
+##################
+# IA32 definitions
+##################
+*_VS2003xASL_IA32_*_DLL = DEF(VS2003_DLL)
+
+*_VS2003xASL_IA32_MAKE_PATH = DEF(VS2003_BIN)\nmake.exe
+*_VS2003xASL_IA32_CC_PATH = DEF(VS2003_BIN)\cl.exe
+*_VS2003xASL_IA32_VFRPP_PATH = DEF(VS2003_BIN)\cl.exe
+*_VS2003xASL_IA32_SLINK_PATH = DEF(VS2003_BIN)\lib.exe
+*_VS2003xASL_IA32_DLINK_PATH = DEF(VS2003_BIN)\link.exe
+*_VS2003xASL_IA32_APP_PATH = DEF(VS2003_BIN)\cl.exe
+*_VS2003xASL_IA32_PP_PATH = DEF(VS2003_BIN)\cl.exe
+*_VS2003xASL_IA32_ASM_PATH = DEF(VS2003_BIN)\ml.exe
+*_VS2003xASL_IA32_ASLCC_PATH = DEF(VS2003_BIN)\cl.exe
+*_VS2003xASL_IA32_ASLPP_PATH = DEF(VS2003_BIN)\cl.exe
+*_VS2003xASL_IA32_ASLDLINK_PATH = DEF(VS2003_BIN)\link.exe
+*_VS2003xASL_IA32_RC_PATH = DEF(VS2003_BIN)\rc.exe
+
+
+ *_VS2003xASL_IA32_MAKE_FLAGS = /nologo
+ *_VS2003xASL_IA32_APP_FLAGS = /nologo /E /TC
+ *_VS2003xASL_IA32_PP_FLAGS = /nologo /E /TC /FIAutoGen.h
+ *_VS2003xASL_IA32_VFRPP_FLAGS = /nologo /E /TC /DVFRCOMPILE /FI$(MODULE_NAME)StrDefs.h
+ DEBUG_VS2003xASL_IA32_CC_FLAGS = /nologo /c /WX /W4 /Gs32768 /Gy /D UNICODE /O1ib2 /GL /FIAutoGen.h /EHs-c- /GR- /GF /GX- /Zi /Gm
+RELEASE_VS2003xASL_IA32_CC_FLAGS = /nologo /c /WX /W4 /Gs32768 /Gy /D UNICODE /O1ib2 /GL /FIAutoGen.h /EHs-c- /GR- /GF /GX-
+ DEBUG_VS2003xASL_IA32_ASM_FLAGS = /nologo /c /WX /W3 /coff /Cx /Zd /Zi
+RELEASE_VS2003xASL_IA32_ASM_FLAGS = /nologo /c /WX /W3 /coff /Cx /Zd
+ *_VS2003xASL_IA32_SLINK_FLAGS = /nologo /LTCG
+ DEBUG_VS2003xASL_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:I386 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
+RELEASE_VS2003xASL_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4078 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:I386 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.data=.text /MERGE:.rdata=.text
+
+##################
+# EBC definitions
+##################
+*_VS2003xASL_EBC_*_FAMILY = INTEL
+
+*_VS2003xASL_EBC_MAKE_PATH = DEF(VS2003_BIN)\nmake.exe
+*_VS2003xASL_EBC_PP_PATH = DEF(EBC_BIN)\iec.exe
+*_VS2003xASL_EBC_VFRPP_PATH = DEF(EBC_BIN)\iec.exe
+*_VS2003xASL_EBC_CC_PATH = DEF(EBC_BIN)\iec.exe
+*_VS2003xASL_EBC_SLINK_PATH = DEF(EBC_BIN)\link.exe
+*_VS2003xASL_EBC_DLINK_PATH = DEF(EBC_BIN)\link.exe
+*_VS2003xASL_EBC_RC_PATH = DEF(VS2003_BIN)\rc.exe
+
+*_VS2003xASL_EBC_MAKE_FLAGS = /nologo
+*_VS2003xASL_EBC_PP_FLAGS = /nologo /E /TC /FIAutoGen.h
+*_VS2003xASL_EBC_CC_FLAGS = /nologo /c /WX /W3 /FIAutoGen.h /D$(MODULE_ENTRY_POINT)=$(ARCH_ENTRY_POINT)
+*_VS2003xASL_EBC_VFRPP_FLAGS = /nologo /E /TC /DVFRCOMPILE /FI$(MODULE_NAME)StrDefs.h
+*_VS2003xASL_EBC_SLINK_FLAGS = /lib /NOLOGO /MACHINE:EBC
+*_VS2003xASL_EBC_DLINK_FLAGS = "C:\Program Files\Intel\EBC\Lib\EbcLib.lib" /NOLOGO /NODEFAULTLIB /MACHINE:EBC /OPT:REF /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /MAP
+
+####################################################################################
+#
+# Microsoft Visual Studio 2005
+#
+# VS2005 - Microsoft Visual Studio 2005 All Edition, including Standard, Professional, Express, TeamSuite
+# ASL - Intel ACPI Source Language Compiler
+####################################################################################
+# VS2005 - Microsoft Visual Studio 2005 ALL Edition, including Standard, Professional, Express, TeamSuite
+*_VS2005_*_*_FAMILY = MSFT
+
+*_VS2005_*_MAKE_PATH = DEF(VS2005_BIN)\nmake.exe
+*_VS2005_*_MAKE_FLAGS = /nologo
+*_VS2005_*_RC_PATH = DEF(VS2005_BIN)\rc.exe
+
+*_VS2005_*_SLINK_FLAGS = /NOLOGO /LTCG
+*_VS2005_*_APP_FLAGS = /nologo /E /TC
+*_VS2005_*_PP_FLAGS = /nologo /E /TC /FIAutoGen.h
+*_VS2005_*_VFRPP_FLAGS = /nologo /E /TC /DVFRCOMPILE /FI$(MODULE_NAME)StrDefs.h
+
+*_VS2005_*_ASM16_PATH = DEF(VS2005_BIN)\ml.exe
+
+##################
+# ASL definitions
+##################
+*_VS2005_*_ASL_PATH = DEF(DEFAULT_WIN_ASL_BIN)
+*_VS2005_*_ASL_FLAGS = DEF(DEFAULT_WIN_ASL_FLAGS)
+*_VS2005_*_ASL_OUTFLAGS = DEF(DEFAULT_WIN_ASL_OUTFLAGS)
+*_VS2005_*_ASLCC_FLAGS = DEF(MSFT_ASLCC_FLAGS)
+*_VS2005_*_ASLPP_FLAGS = DEF(MSFT_ASLPP_FLAGS)
+*_VS2005_*_ASLDLINK_FLAGS = DEF(MSFT_ASLDLINK_FLAGS)
+
+##################
+# IA32 definitions
+##################
+*_VS2005_IA32_*_DLL = DEF(VS2005_DLL)
+
+*_VS2005_IA32_MAKE_PATH = DEF(VS2005_BIN)\nmake.exe
+*_VS2005_IA32_CC_PATH = DEF(VS2005_BIN)\cl.exe
+*_VS2005_IA32_VFRPP_PATH = DEF(VS2005_BIN)\cl.exe
+*_VS2005_IA32_SLINK_PATH = DEF(VS2005_BIN)\lib.exe
+*_VS2005_IA32_DLINK_PATH = DEF(VS2005_BIN)\link.exe
+*_VS2005_IA32_APP_PATH = DEF(VS2005_BIN)\cl.exe
+*_VS2005_IA32_PP_PATH = DEF(VS2005_BIN)\cl.exe
+*_VS2005_IA32_ASM_PATH = DEF(VS2005_BIN)\ml.exe
+*_VS2005_IA32_ASLCC_PATH = DEF(VS2005_BIN)\cl.exe
+*_VS2005_IA32_ASLPP_PATH = DEF(VS2005_BIN)\cl.exe
+*_VS2005_IA32_ASLDLINK_PATH = DEF(VS2005_BIN)\link.exe
+
+ *_VS2005_IA32_MAKE_FLAGS = /nologo
+ DEBUG_VS2005_IA32_CC_FLAGS = /nologo /c /WX /GS- /W4 /Gs32768 /D UNICODE /O1ib2 /GL /FIAutoGen.h /EHs-c- /GR- /GF /Gy /Zi /Gm
+RELEASE_VS2005_IA32_CC_FLAGS = /nologo /c /WX /GS- /W4 /Gs32768 /D UNICODE /O1ib2 /GL /FIAutoGen.h /EHs-c- /GR- /GF
+ DEBUG_VS2005_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Cx /coff /Zd /Zi
+RELEASE_VS2005_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Cx /coff /Zd
+ DEBUG_VS2005_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:I386 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
+RELEASE_VS2005_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:I386 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.data=.text /MERGE:.rdata=.text
+
+##################
+# X64 definitions
+##################
+*_VS2005_X64_*_DLL = DEF(VS2005_DLL)
+
+*_VS2005_X64_CC_PATH = DEF(VS2005_BINX64)\cl.exe
+*_VS2005_X64_PP_PATH = DEF(VS2005_BINX64)\cl.exe
+*_VS2005_X64_APP_PATH = DEF(VS2005_BINX64)\cl.exe
+*_VS2005_X64_VFRPP_PATH = DEF(VS2005_BINX64)\cl.exe
+*_VS2005_X64_ASM_PATH = DEF(VS2005_BINX64)\ml64.exe
+*_VS2005_X64_SLINK_PATH = DEF(VS2005_BINX64)\lib.exe
+*_VS2005_X64_DLINK_PATH = DEF(VS2005_BINX64)\link.exe
+*_VS2005_X64_ASLCC_PATH = DEF(VS2005_BINX64)\cl.exe
+*_VS2005_X64_ASLPP_PATH = DEF(VS2005_BINX64)\cl.exe
+*_VS2005_X64_ASLDLINK_PATH = DEF(VS2005_BINX64)\link.exe
+
+
+ DEBUG_VS2005_X64_CC_FLAGS = /nologo /c /WX /GS- /X /W4 /Gs32768 /D UNICODE /O1ib2s /GL /Gy /FIAutoGen.h /EHs-c- /GR- /GF /Zi /Gm
+RELEASE_VS2005_X64_CC_FLAGS = /nologo /c /WX /GS- /X /W4 /Gs32768 /D UNICODE /O1ib2s /GL /Gy /FIAutoGen.h /EHs-c- /GR- /GF
+ DEBUG_VS2005_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd /Zi
+RELEASE_VS2005_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd
+ DEBUG_VS2005_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:AMD64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
+RELEASE_VS2005_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:AMD64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.data=.text /MERGE:.rdata=.text
+
+##################
+# IPF definitions
+##################
+*_VS2005_IPF_*_DLL = DEF(VS2005_DLL)
+
+*_VS2005_IPF_PP_PATH = DEF(VS2005_BIN64)\cl.exe
+*_VS2005_IPF_APP_PATH = DEF(VS2005_BIN64)\cl.exe
+*_VS2005_IPF_VFRPP_PATH = DEF(VS2005_BIN64)\cl.exe
+*_VS2005_IPF_CC_PATH = DEF(VS2005_BIN64)\cl.exe
+*_VS2005_IPF_ASM_PATH = DEF(VS2005_BIN64)\ias.exe
+*_VS2005_IPF_SLINK_PATH = DEF(VS2005_BIN64)\lib.exe
+*_VS2005_IPF_DLINK_PATH = DEF(VS2005_BIN64)\link.exe
+*_VS2005_IPF_ASLCC_PATH = DEF(VS2005_BIN64)\cl.exe
+*_VS2005_IPF_ASLPP_PATH = DEF(VS2005_BIN64)\cl.exe
+*_VS2005_IPF_ASLDLINK_PATH = DEF(VS2005_BIN64)\link.exe
+
+ DEBUG_VS2005_IPF_CC_FLAGS = /nologo /c /WX /GS- /X /W4 /EHs-c- /GR- /Gy /Os /GL /FIAutoGen.h /QIPF_fr32 /Zi
+RELEASE_VS2005_IPF_CC_FLAGS = /nologo /c /WX /GS- /X /W4 /EHs-c- /GR- /Gy /Os /GL /FIAutoGen.h /QIPF_fr32
+ DEBUG_VS2005_IPF_ASM_FLAGS = -N us -X explicit -M ilp64 -N so -W4 -d debug
+RELEASE_VS2005_IPF_ASM_FLAGS = -N us -X explicit -M ilp64 -N so -W4
+ DEBUG_VS2005_IPF_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /LTCG /DLL /OPT:REF,ICF /IGNORE:4001 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:IA64 /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MAP:$(DEBUG_DIR)/$(BASE_NAME).map /PDB:$(DEBUG_DIR)/$(BASE_NAME).pdb /DEBUG
+RELEASE_VS2005_IPF_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /LTCG /DLL /OPT:REF,ICF /IGNORE:4001 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:IA64 /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MAP:$(DEBUG_DIR)/$(BASE_NAME).map /PDB:$(DEBUG_DIR)/$(BASE_NAME).pdb
+
+##################
+# EBC definitions
+##################
+*_VS2005_EBC_*_FAMILY = INTEL
+
+*_VS2005_EBC_MAKE_PATH = DEF(VS2005_BIN)\nmake.exe
+*_VS2005_EBC_PP_PATH = DEF(EBC_BIN)\iec.exe
+*_VS2005_EBC_VFRPP_PATH = DEF(EBC_BIN)\iec.exe
+*_VS2005_EBC_CC_PATH = DEF(EBC_BIN)\iec.exe
+*_VS2005_EBC_SLINK_PATH = DEF(EBC_BIN)\link.exe
+*_VS2005_EBC_DLINK_PATH = DEF(EBC_BIN)\link.exe
+
+*_VS2005_EBC_MAKE_FLAGS = /nologo
+*_VS2005_EBC_PP_FLAGS = /nologo /E /TC /FIAutoGen.h
+*_VS2005_EBC_CC_FLAGS = /nologo /c /WX /W3 /FIAutoGen.h /D$(MODULE_ENTRY_POINT)=$(ARCH_ENTRY_POINT)
+*_VS2005_EBC_VFRPP_FLAGS = /nologo /E /TC /DVFRCOMPILE /FI$(MODULE_NAME)StrDefs.h
+*_VS2005_EBC_SLINK_FLAGS = /lib /NOLOGO /MACHINE:EBC
+*_VS2005_EBC_DLINK_FLAGS = "C:\Program Files\Intel\EBC\Lib\EbcLib.lib" /NOLOGO /NODEFAULTLIB /MACHINE:EBC /OPT:REF /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /MAP
+
+####################################################################################
+#
+# Microsoft Visual Studio 2005
+#
+# VS2005 - Microsoft Visual Studio 2005 All Edition, including Standard, Professional, Express, TeamSuite
+# ASL - Microsoft ACPI Source Language Compiler (asl.exe)
+####################################################################################
+# VS2005xASL - Microsoft Visual Studio 2005 ALL Edition, including Standard, Professional, Express, TeamSuite
+*_VS2005xASL_*_*_FAMILY = MSFT
+
+*_VS2005xASL_*_MAKE_PATH = DEF(VS2005_BIN)\nmake.exe
+*_VS2005xASL_*_MAKE_FLAG = /nologo
+*_VS2005xASL_*_RC_PATH = DEF(VS2005_BIN)\rc.exe
+
+*_VS2005xASL_*_SLINK_FLAGS = /NOLOGO /LTCG
+*_VS2005xASL_*_APP_FLAGS = /nologo /E /TC
+*_VS2005xASL_*_PP_FLAGS = /nologo /E /TC /FIAutoGen.h
+*_VS2005xASL_*_VFRPP_FLAGS = /nologo /E /TC /DVFRCOMPILE /FI$(MODULE_NAME)StrDefs.h
+
+*_VS2005xASL_*_ASM16_PATH = DEF(VS2005_BIN)\ml.exe
+
+##################
+# ASL definitions
+##################
+*_VS2005xASL_*_ASL_PATH = DEF(WIN_ASL_BIN)
+*_VS2005xASL_*_ASL_FLAGS =
+*_VS2005xASL_*_ASL_OUTFLAGS = DEF(MS_ASL_OUTFLAGS)
+*_VS2005xASL_*_ASLCC_FLAGS = DEF(MSFT_ASLCC_FLAGS)
+*_VS2005xASL_*_ASLPP_FLAGS = DEF(MSFT_ASLPP_FLAGS)
+*_VS2005xASL_*_ASLDLINK_FLAGS = DEF(MSFT_ASLDLINK_FLAGS)
+
+##################
+# IA32 definitions
+##################
+*_VS2005xASL_IA32_*_DLL = DEF(VS2005_DLL)
+
+*_VS2005xASL_IA32_MAKE_PATH = DEF(VS2005_BIN)\nmake.exe
+*_VS2005xASL_IA32_CC_PATH = DEF(VS2005_BIN)\cl.exe
+*_VS2005xASL_IA32_VFRPP_PATH = DEF(VS2005_BIN)\cl.exe
+*_VS2005xASL_IA32_SLINK_PATH = DEF(VS2005_BIN)\lib.exe
+*_VS2005xASL_IA32_DLINK_PATH = DEF(VS2005_BIN)\link.exe
+*_VS2005xASL_IA32_APP_PATH = DEF(VS2005_BIN)\cl.exe
+*_VS2005xASL_IA32_PP_PATH = DEF(VS2005_BIN)\cl.exe
+*_VS2005xASL_IA32_ASM_PATH = DEF(VS2005_BIN)\ml.exe
+*_VS2005xASL_IA32_ASLCC_PATH = DEF(VS2005_BIN)\cl.exe
+*_VS2005xASL_IA32_ASLPP_PATH = DEF(VS2005_BIN)\cl.exe
+*_VS2005xASL_IA32_ASLDLINK_PATH = DEF(VS2005_BIN)\link.exe
+
+ *_VS2005xASL_IA32_MAKE_FLAGS = /nologo
+ DEBUG_VS2005xASL_IA32_CC_FLAGS = /nologo /c /WX /GS- /W4 /Gs32768 /D UNICODE /O1ib2 /GL /FIAutoGen.h /EHs-c- /GR- /GF /Gy /Zi /Gm
+RELEASE_VS2005xASL_IA32_CC_FLAGS = /nologo /c /WX /GS- /W4 /Gs32768 /D UNICODE /O1ib2 /GL /FIAutoGen.h /EHs-c- /GR- /GF
+ DEBUG_VS2005xASL_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Cx /coff /Zd /Zi
+RELEASE_VS2005xASL_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Cx /coff /Zd
+ DEBUG_VS2005xASL_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:I386 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
+RELEASE_VS2005xASL_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:I386 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.data=.text /MERGE:.rdata=.text
+
+##################
+# X64 definitions
+##################
+*_VS2005xASL_X64_*_DLL = DEF(VS2005_DLL)
+
+*_VS2005xASL_X64_CC_PATH = DEF(VS2005_BINX64)\cl.exe
+*_VS2005xASL_X64_PP_PATH = DEF(VS2005_BINX64)\cl.exe
+*_VS2005xASL_X64_APP_PATH = DEF(VS2005_BINX64)\cl.exe
+*_VS2005xASL_X64_VFRPP_PATH = DEF(VS2005_BINX64)\cl.exe
+*_VS2005xASL_X64_ASM_PATH = DEF(VS2005_BINX64)\ml64.exe
+*_VS2005xASL_X64_SLINK_PATH = DEF(VS2005_BINX64)\lib.exe
+*_VS2005xASL_X64_DLINK_PATH = DEF(VS2005_BINX64)\link.exe
+*_VS2005xASL_X64_ASLCC_PATH = DEF(VS2005_BINX64)\cl.exe
+*_VS2005xASL_X64_ASLPP_PATH = DEF(VS2005_BINX64)\cl.exe
+*_VS2005xASL_X64_ASLDLINK_PATH = DEF(VS2005_BINX64)\link.exe
+
+
+ DEBUG_VS2005xASL_X64_CC_FLAGS = /nologo /c /WX /GS- /X /W4 /Gs32768 /D UNICODE /O1ib2s /GL /Gy /FIAutoGen.h /EHs-c- /GR- /GF /Zi /Gm
+RELEASE_VS2005xASL_X64_CC_FLAGS = /nologo /c /WX /GS- /X /W4 /Gs32768 /D UNICODE /O1ib2s /GL /Gy /FIAutoGen.h /EHs-c- /GR- /GF
+ DEBUG_VS2005xASL_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd /Zi
+RELEASE_VS2005xASL_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd
+ DEBUG_VS2005xASL_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:AMD64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
+RELEASE_VS2005xASL_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:AMD64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.data=.text /MERGE:.rdata=.text
+
+##################
+# IPF definitions
+##################
+*_VS2005xASL_IPF_*_DLL = DEF(VS2005_DLL)
+
+*_VS2005xASL_IPF_PP_PATH = DEF(VS2005_BIN64)\cl.exe
+*_VS2005xASL_IPF_APP_PATH = DEF(VS2005_BIN64)\cl.exe
+*_VS2005xASL_IPF_VFRPP_PATH = DEF(VS2005_BIN64)\cl.exe
+*_VS2005xASL_IPF_CC_PATH = DEF(VS2005_BIN64)\cl.exe
+*_VS2005xASL_IPF_ASM_PATH = DEF(VS2005_BIN64)\ias.exe
+*_VS2005xASL_IPF_SLINK_PATH = DEF(VS2005_BIN64)\lib.exe
+*_VS2005xASL_IPF_DLINK_PATH = DEF(VS2005_BIN64)\link.exe
+*_VS2005xASL_IPF_ASLCC_PATH = DEF(VS2005_BIN64)\cl.exe
+*_VS2005xASL_IPF_ASLPP_PATH = DEF(VS2005_BIN64)\cl.exe
+*_VS2005xASL_IPF_ASLDLINK_PATH = DEF(VS2005_BIN64)\link.exe
+
+ DEBUG_VS2005xASL_IPF_CC_FLAGS = /nologo /c /WX /GS- /X /W4 /EHs-c- /GR- /Gy /Os /GL /FIAutoGen.h /QIPF_fr32 /Zi
+RELEASE_VS2005xASL_IPF_CC_FLAGS = /nologo /c /WX /GS- /X /W4 /EHs-c- /GR- /Gy /Os /GL /FIAutoGen.h /QIPF_fr32
+ DEBUG_VS2005xASL_IPF_ASM_FLAGS = -N us -X explicit -M ilp64 -N so -W4 -d debug
+RELEASE_VS2005xASL_IPF_ASM_FLAGS = -N us -X explicit -M ilp64 -N so -W4
+ DEBUG_VS2005xASL_IPF_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /LTCG /DLL /OPT:REF,ICF /IGNORE:4001 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:IA64 /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MAP:$(DEBUG_DIR)/$(BASE_NAME).map /PDB:$(DEBUG_DIR)/$(BASE_NAME).pdb /DEBUG
+RELEASE_VS2005xASL_IPF_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /LTCG /DLL /OPT:REF,ICF /IGNORE:4001 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:IA64 /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MAP:$(DEBUG_DIR)/$(BASE_NAME).map /PDB:$(DEBUG_DIR)/$(BASE_NAME).pdb
+
+##################
+# EBC definitions
+##################
+*_VS2005xASL_EBC_*_FAMILY = INTEL
+
+*_VS2005xASL_EBC_MAKE_PATH = DEF(VS2005_BIN)\nmake.exe
+*_VS2005xASL_EBC_PP_PATH = DEF(EBC_BIN)\iec.exe
+*_VS2005xASL_EBC_VFRPP_PATH = DEF(EBC_BIN)\iec.exe
+*_VS2005xASL_EBC_CC_PATH = DEF(EBC_BIN)\iec.exe
+*_VS2005xASL_EBC_SLINK_PATH = DEF(EBC_BIN)\link.exe
+*_VS2005xASL_EBC_DLINK_PATH = DEF(EBC_BIN)\link.exe
+
+*_VS2005xASL_EBC_MAKE_FLAGS = /nologo
+*_VS2005xASL_EBC_PP_FLAGS = /nologo /E /TC /FIAutoGen.h
+*_VS2005xASL_EBC_CC_FLAGS = /nologo /c /WX /W3 /FIAutoGen.h /D$(MODULE_ENTRY_POINT)=$(ARCH_ENTRY_POINT)
+*_VS2005xASL_EBC_VFRPP_FLAGS = /nologo /E /TC /DVFRCOMPILE /FI$(MODULE_NAME)StrDefs.h
+*_VS2005xASL_EBC_SLINK_FLAGS = /lib /NOLOGO /MACHINE:EBC
+*_VS2005xASL_EBC_DLINK_FLAGS = "C:\Program Files\Intel\EBC\Lib\EbcLib.lib" /NOLOGO /NODEFAULTLIB /MACHINE:EBC /OPT:REF /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /MAP
+
+####################################################################################
+#
+# Microsoft Visual Studio 2005 (x86)
+#
+# VS2005 - Microsoft Visual Studio 2005 All Edition, including Standard, Professional, Express, TeamSuite
+# ASL - Intel ACPI Source Language Compiler
+####################################################################################
+# VS2005x86 - Microsoft Visual Studio 2005 ALL Edition, including Standard, Professional, Express, TeamSuite
+*_VS2005x86_*_*_FAMILY = MSFT
+
+*_VS2005x86_*_MAKE_PATH = DEF(VS2005x86_BIN)\nmake.exe
+*_VS2005x86_*_MAKE_FLAGS = /nologo
+*_VS2005x86_*_RC_PATH = DEF(VS2005x86_BIN)\rc.exe
+
+*_VS2005x86_*_SLINK_FLAGS = /NOLOGO /LTCG
+*_VS2005x86_*_APP_FLAGS = /nologo /E /TC
+*_VS2005x86_*_PP_FLAGS = /nologo /E /TC /FIAutoGen.h
+*_VS2005x86_*_VFRPP_FLAGS = /nologo /E /TC /DVFRCOMPILE /FI$(MODULE_NAME)StrDefs.h
+
+*_VS2005x86_*_ASM16_PATH = DEF(VS2005x86_BIN)\ml.exe
+
+##################
+# ASL definitions
+##################
+*_VS2005x86_*_ASL_PATH = DEF(DEFAULT_WIN_ASL_BIN)
+*_VS2005x86_*_ASL_FLAGS = DEF(DEFAULT_WIN_ASL_FLAGS)
+*_VS2005x86_*_ASL_OUTFLAGS = DEF(DEFAULT_WIN_ASL_OUTFLAGS)
+*_VS2005x86_*_ASLCC_FLAGS = DEF(MSFT_ASLCC_FLAGS)
+*_VS2005x86_*_ASLPP_FLAGS = DEF(MSFT_ASLPP_FLAGS)
+*_VS2005x86_*_ASLDLINK_FLAGS = DEF(MSFT_ASLDLINK_FLAGS)
+
+##################
+# IA32 definitions
+##################
+*_VS2005x86_IA32_*_DLL = DEF(VS2005x86_DLL)
+
+*_VS2005x86_IA32_MAKE_PATH = DEF(VS2005x86_BIN)\nmake.exe
+*_VS2005x86_IA32_CC_PATH = DEF(VS2005x86_BIN)\cl.exe
+*_VS2005x86_IA32_VFRPP_PATH = DEF(VS2005x86_BIN)\cl.exe
+*_VS2005x86_IA32_SLINK_PATH = DEF(VS2005x86_BIN)\lib.exe
+*_VS2005x86_IA32_DLINK_PATH = DEF(VS2005x86_BIN)\link.exe
+*_VS2005x86_IA32_APP_PATH = DEF(VS2005x86_BIN)\cl.exe
+*_VS2005x86_IA32_PP_PATH = DEF(VS2005x86_BIN)\cl.exe
+*_VS2005x86_IA32_ASM_PATH = DEF(VS2005x86_BIN)\ml.exe
+*_VS2005x86_IA32_ASLCC_PATH = DEF(VS2005x86_BIN)\cl.exe
+*_VS2005x86_IA32_ASLPP_PATH = DEF(VS2005x86_BIN)\cl.exe
+*_VS2005x86_IA32_ASLDLINK_PATH = DEF(VS2005x86_BIN)\link.exe
+
+ *_VS2005x86_IA32_MAKE_FLAGS = /nologo
+ DEBUG_VS2005x86_IA32_CC_FLAGS = /nologo /c /WX /GS- /W4 /Gs32768 /D UNICODE /O1ib2 /GL /FIAutoGen.h /EHs-c- /GR- /GF /Gy /Zi /Gm
+RELEASE_VS2005x86_IA32_CC_FLAGS = /nologo /c /WX /GS- /W4 /Gs32768 /D UNICODE /O1ib2 /GL /FIAutoGen.h /EHs-c- /GR- /GF
+ DEBUG_VS2005x86_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Cx /coff /Zd /Zi
+RELEASE_VS2005x86_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Cx /coff /Zd
+ DEBUG_VS2005x86_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:I386 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
+RELEASE_VS2005x86_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:I386 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.data=.text /MERGE:.rdata=.text
+
+##################
+# X64 definitions
+##################
+*_VS2005x86_X64_*_DLL = DEF(VS2005x86_DLL)
+
+*_VS2005x86_X64_CC_PATH = DEF(VS2005x86_BINX64)\cl.exe
+*_VS2005x86_X64_PP_PATH = DEF(VS2005x86_BINX64)\cl.exe
+*_VS2005x86_X64_APP_PATH = DEF(VS2005x86_BINX64)\cl.exe
+*_VS2005x86_X64_VFRPP_PATH = DEF(VS2005x86_BINX64)\cl.exe
+*_VS2005x86_X64_ASM_PATH = DEF(VS2005x86_BINX64)\ml64.exe
+*_VS2005x86_X64_SLINK_PATH = DEF(VS2005x86_BINX64)\lib.exe
+*_VS2005x86_X64_DLINK_PATH = DEF(VS2005x86_BINX64)\link.exe
+*_VS2005x86_X64_ASLCC_PATH = DEF(VS2005x86_BINX64)\cl.exe
+*_VS2005x86_X64_ASLPP_PATH = DEF(VS2005x86_BINX64)\cl.exe
+*_VS2005x86_X64_ASLDLINK_PATH = DEF(VS2005x86_BINX64)\link.exe
+
+
+ DEBUG_VS2005x86_X64_CC_FLAGS = /nologo /c /WX /GS- /X /W4 /Gs32768 /D UNICODE /O1ib2s /GL /Gy /FIAutoGen.h /EHs-c- /GR- /GF /Zi /Gm
+RELEASE_VS2005x86_X64_CC_FLAGS = /nologo /c /WX /GS- /X /W4 /Gs32768 /D UNICODE /O1ib2s /GL /Gy /FIAutoGen.h /EHs-c- /GR- /GF
+ DEBUG_VS2005x86_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd /Zi
+RELEASE_VS2005x86_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd
+ DEBUG_VS2005x86_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:AMD64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
+RELEASE_VS2005x86_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:AMD64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.data=.text /MERGE:.rdata=.text
+
+##################
+# IPF definitions
+##################
+*_VS2005x86_IPF_*_DLL = DEF(VS2005x86_DLL)
+
+*_VS2005x86_IPF_PP_PATH = DEF(VS2005x86_BIN64)\cl.exe
+*_VS2005x86_IPF_APP_PATH = DEF(VS2005x86_BIN64)\cl.exe
+*_VS2005x86_IPF_VFRPP_PATH = DEF(VS2005x86_BIN64)\cl.exe
+*_VS2005x86_IPF_CC_PATH = DEF(VS2005x86_BIN64)\cl.exe
+*_VS2005x86_IPF_ASM_PATH = DEF(VS2005x86_BIN64)\ias.exe
+*_VS2005x86_IPF_SLINK_PATH = DEF(VS2005x86_BIN64)\lib.exe
+*_VS2005x86_IPF_DLINK_PATH = DEF(VS2005x86_BIN64)\link.exe
+*_VS2005x86_IPF_ASLCC_PATH = DEF(VS2005x86_BIN64)\cl.exe
+*_VS2005x86_IPF_ASLPP_PATH = DEF(VS2005x86_BIN64)\cl.exe
+*_VS2005x86_IPF_ASLDLINK_PATH = DEF(VS2005x86_BIN64)\link.exe
+
+ DEBUG_VS2005x86_IPF_CC_FLAGS = /nologo /c /WX /GS- /X /W4 /EHs-c- /GR- /Gy /Os /GL /FIAutoGen.h /QIPF_fr32 /Zi
+RELEASE_VS2005x86_IPF_CC_FLAGS = /nologo /c /WX /GS- /X /W4 /EHs-c- /GR- /Gy /Os /GL /FIAutoGen.h /QIPF_fr32
+ DEBUG_VS2005x86_IPF_ASM_FLAGS = -N us -X explicit -M ilp64 -N so -W4 -d debug
+RELEASE_VS2005x86_IPF_ASM_FLAGS = -N us -X explicit -M ilp64 -N so -W4
+ DEBUG_VS2005x86_IPF_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /LTCG /DLL /OPT:REF,ICF /IGNORE:4001 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:IA64 /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MAP:$(DEBUG_DIR)/$(BASE_NAME).map /PDB:$(DEBUG_DIR)/$(BASE_NAME).pdb /DEBUG
+RELEASE_VS2005x86_IPF_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /LTCG /DLL /OPT:REF,ICF /IGNORE:4001 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:IA64 /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MAP:$(DEBUG_DIR)/$(BASE_NAME).map /PDB:$(DEBUG_DIR)/$(BASE_NAME).pdb
+
+##################
+# EBC definitions
+##################
+*_VS2005x86_EBC_*_FAMILY = INTEL
+
+*_VS2005x86_EBC_MAKE_PATH = DEF(VS2005x86_BIN)\nmake.exe
+*_VS2005x86_EBC_PP_PATH = DEF(EBC_BINx86)\iec.exe
+*_VS2005x86_EBC_VFRPP_PATH = DEF(EBC_BINx86)\iec.exe
+*_VS2005x86_EBC_CC_PATH = DEF(EBC_BINx86)\iec.exe
+*_VS2005x86_EBC_SLINK_PATH = DEF(EBC_BINx86)\link.exe
+*_VS2005x86_EBC_DLINK_PATH = DEF(EBC_BINx86)\link.exe
+
+*_VS2005x86_EBC_MAKE_FLAGS = /nologo
+*_VS2005x86_EBC_PP_FLAGS = /nologo /E /TC /FIAutoGen.h
+*_VS2005x86_EBC_CC_FLAGS = /nologo /c /WX /W3 /FIAutoGen.h /D$(MODULE_ENTRY_POINT)=$(ARCH_ENTRY_POINT)
+*_VS2005x86_EBC_VFRPP_FLAGS = /nologo /E /TC /DVFRCOMPILE /FI$(MODULE_NAME)StrDefs.h
+*_VS2005x86_EBC_SLINK_FLAGS = /lib /NOLOGO /MACHINE:EBC
+*_VS2005x86_EBC_DLINK_FLAGS = "C:\Program Files (x86)\Intel\EBC\Lib\EbcLib.lib" /NOLOGO /NODEFAULTLIB /MACHINE:EBC /OPT:REF /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /MAP
+
+####################################################################################
+#
+# Microsoft Visual Studio 2005 (x86)
+#
+# VS2005 - Microsoft Visual Studio 2005 All Edition, including Standard, Professional, Express, TeamSuite
+# ASL - Microsoft ACPI Source Language Compiler
+####################################################################################
+# VS2005x86xASL - Microsoft Visual Studio 2005 ALL Edition, including Standard, Professional, Express, TeamSuite
+*_VS2005x86xASL_*_*_FAMILY = MSFT
+
+*_VS2005x86xASL_*_MAKE_PATH = DEF(VS2005x86_BIN)\nmake.exe
+*_VS2005x86xASL_*_MAKE_FLAGS = /nologo
+*_VS2005x86xASL_*_RC_PATH = DEF(VS2005x86_BIN)\rc.exe
+
+*_VS2005x86xASL_*_SLINK_FLAGS = /NOLOGO /LTCG
+*_VS2005x86xASL_*_APP_FLAGS = /nologo /E /TC
+*_VS2005x86xASL_*_PP_FLAGS = /nologo /E /TC /FIAutoGen.h
+*_VS2005x86xASL_*_VFRPP_FLAGS = /nologo /E /TC /DVFRCOMPILE /FI$(MODULE_NAME)StrDefs.h
+
+*_VS2005x86xASL_*_ASM16_PATH = DEF(VS2005x86_BIN)\ml.exe
+
+##################
+# ASL definitions
+##################
+*_VS2005x86xASL_*_ASL_PATH = DEF(WIN_ASL_BIN)
+*_VS2005x86xASL_*_ASL_FLAGS =
+*_VS2005x86xASL_*_ASL_OUTFLAGS = DEF(MS_ASL_OUTFLAGS)
+*_VS2005x86xASL_*_ASLCC_FLAGS = DEF(MSFT_ASLCC_FLAGS)
+*_VS2005x86xASL_*_ASLPP_FLAGS = DEF(MSFT_ASLPP_FLAGS)
+*_VS2005x86xASL_*_ASLDLINK_FLAGS = DEF(MSFT_ASLDLINK_FLAGS)
+
+##################
+# IA32 definitions
+##################
+*_VS2005x86xASL_IA32_*_DLL = DEF(VS2005x86_DLL)
+
+*_VS2005x86xASL_IA32_MAKE_PATH = DEF(VS2005x86_BIN)\nmake.exe
+*_VS2005x86xASL_IA32_CC_PATH = DEF(VS2005x86_BIN)\cl.exe
+*_VS2005x86xASL_IA32_VFRPP_PATH = DEF(VS2005x86_BIN)\cl.exe
+*_VS2005x86xASL_IA32_SLINK_PATH = DEF(VS2005x86_BIN)\lib.exe
+*_VS2005x86xASL_IA32_DLINK_PATH = DEF(VS2005x86_BIN)\link.exe
+*_VS2005x86xASL_IA32_APP_PATH = DEF(VS2005x86_BIN)\cl.exe
+*_VS2005x86xASL_IA32_PP_PATH = DEF(VS2005x86_BIN)\cl.exe
+*_VS2005x86xASL_IA32_ASM_PATH = DEF(VS2005x86_BIN)\ml.exe
+*_VS2005x86xASL_IA32_ASLCC_PATH = DEF(VS2005x86_BIN)\cl.exe
+*_VS2005x86xASL_IA32_ASLPP_PATH = DEF(VS2005x86_BIN)\cl.exe
+*_VS2005x86xASL_IA32_ASLDLINK_PATH = DEF(VS2005x86_BIN)\link.exe
+
+ *_VS2005x86xASL_IA32_MAKE_FLAGS = /nologo
+ DEBUG_VS2005x86xASL_IA32_CC_FLAGS = /nologo /c /WX /GS- /W4 /Gs32768 /D UNICODE /O1ib2 /GL /FIAutoGen.h /EHs-c- /GR- /GF /Gy /Zi /Gm
+RELEASE_VS2005x86xASL_IA32_CC_FLAGS = /nologo /c /WX /GS- /W4 /Gs32768 /D UNICODE /O1ib2 /GL /FIAutoGen.h /EHs-c- /GR- /GF
+ DEBUG_VS2005x86xASL_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Cx /coff /Zd /Zi
+RELEASE_VS2005x86xASL_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Cx /coff /Zd
+ DEBUG_VS2005x86xASL_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:I386 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
+RELEASE_VS2005x86xASL_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:I386 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.data=.text /MERGE:.rdata=.text
+
+##################
+# X64 definitions
+##################
+*_VS2005x86xASL_X64_*_DLL = DEF(VS2005x86_DLL)
+
+*_VS2005x86xASL_X64_CC_PATH = DEF(VS2005x86_BINX64)\cl.exe
+*_VS2005x86xASL_X64_PP_PATH = DEF(VS2005x86_BINX64)\cl.exe
+*_VS2005x86xASL_X64_APP_PATH = DEF(VS2005x86_BINX64)\cl.exe
+*_VS2005x86xASL_X64_VFRPP_PATH = DEF(VS2005x86_BINX64)\cl.exe
+*_VS2005x86xASL_X64_ASM_PATH = DEF(VS2005x86_BINX64)\ml64.exe
+*_VS2005x86xASL_X64_SLINK_PATH = DEF(VS2005x86_BINX64)\lib.exe
+*_VS2005x86xASL_X64_DLINK_PATH = DEF(VS2005x86_BINX64)\link.exe
+*_VS2005x86xASL_X64_ASLCC_PATH = DEF(VS2005x86_BINX64)\cl.exe
+*_VS2005x86xASL_X64_ASLPP_PATH = DEF(VS2005x86_BINX64)\cl.exe
+*_VS2005x86xASL_X64_ASLDLINK_PATH = DEF(VS2005x86_BINX64)\link.exe
+
+
+ DEBUG_VS2005x86xASL_X64_CC_FLAGS = /nologo /c /WX /GS- /X /W4 /Gs32768 /D UNICODE /O1ib2s /GL /Gy /FIAutoGen.h /EHs-c- /GR- /GF /Zi /Gm
+RELEASE_VS2005x86xASL_X64_CC_FLAGS = /nologo /c /WX /GS- /X /W4 /Gs32768 /D UNICODE /O1ib2s /GL /Gy /FIAutoGen.h /EHs-c- /GR- /GF
+ DEBUG_VS2005x86xASL_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd /Zi
+RELEASE_VS2005x86xASL_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd
+ DEBUG_VS2005x86xASL_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:AMD64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
+RELEASE_VS2005x86xASL_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:AMD64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.data=.text /MERGE:.rdata=.text
+
+##################
+# IPF definitions
+##################
+*_VS2005x86xASL_IPF_*_DLL = DEF(VS2005x86_DLL)
+
+*_VS2005x86xASL_IPF_PP_PATH = DEF(VS2005x86_BIN64)\cl.exe
+*_VS2005x86xASL_IPF_APP_PATH = DEF(VS2005x86_BIN64)\cl.exe
+*_VS2005x86xASL_IPF_VFRPP_PATH = DEF(VS2005x86_BIN64)\cl.exe
+*_VS2005x86xASL_IPF_CC_PATH = DEF(VS2005x86_BIN64)\cl.exe
+*_VS2005x86xASL_IPF_ASM_PATH = DEF(VS2005x86_BIN64)\ias.exe
+*_VS2005x86xASL_IPF_SLINK_PATH = DEF(VS2005x86_BIN64)\lib.exe
+*_VS2005x86xASL_IPF_DLINK_PATH = DEF(VS2005x86_BIN64)\link.exe
+*_VS2005x86xASL_IPF_ASLCC_PATH = DEF(VS2005x86_BIN64)\cl.exe
+*_VS2005x86xASL_IPF_ASLPP_PATH = DEF(VS2005x86_BIN64)\cl.exe
+*_VS2005x86xASL_IPF_ASLDLINK_PATH = DEF(VS2005x86_BIN64)\link.exe
+
+ DEBUG_VS2005x86xASL_IPF_CC_FLAGS = /nologo /c /WX /GS- /X /W4 /EHs-c- /GR- /Gy /Os /GL /FIAutoGen.h /QIPF_fr32 /Zi
+RELEASE_VS2005x86xASL_IPF_CC_FLAGS = /nologo /c /WX /GS- /X /W4 /EHs-c- /GR- /Gy /Os /GL /FIAutoGen.h /QIPF_fr32
+ DEBUG_VS2005x86xASL_IPF_ASM_FLAGS = -N us -X explicit -M ilp64 -N so -W4 -d debug
+RELEASE_VS2005x86xASL_IPF_ASM_FLAGS = -N us -X explicit -M ilp64 -N so -W4
+ DEBUG_VS2005x86xASL_IPF_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /LTCG /DLL /OPT:REF,ICF /IGNORE:4001 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:IA64 /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MAP:$(DEBUG_DIR)/$(BASE_NAME).map /PDB:$(DEBUG_DIR)/$(BASE_NAME).pdb /DEBUG
+RELEASE_VS2005x86xASL_IPF_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /LTCG /DLL /OPT:REF,ICF /IGNORE:4001 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:IA64 /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MAP:$(DEBUG_DIR)/$(BASE_NAME).map /PDB:$(DEBUG_DIR)/$(BASE_NAME).pdb
+
+##################
+# EBC definitions
+##################
+*_VS2005x86xASL_EBC_*_FAMILY = INTEL
+
+*_VS2005x86xASL_EBC_MAKE_PATH = DEF(VS2005x86_BIN)\nmake.exe
+*_VS2005x86xASL_EBC_PP_PATH = DEF(EBC_BINx86)\iec.exe
+*_VS2005x86xASL_EBC_VFRPP_PATH = DEF(EBC_BINx86)\iec.exe
+*_VS2005x86xASL_EBC_CC_PATH = DEF(EBC_BINx86)\iec.exe
+*_VS2005x86xASL_EBC_SLINK_PATH = DEF(EBC_BINx86)\link.exe
+*_VS2005x86xASL_EBC_DLINK_PATH = DEF(EBC_BINx86)\link.exe
+
+*_VS2005x86xASL_EBC_MAKE_FLAGS = /nologo
+*_VS2005x86xASL_EBC_PP_FLAGS = /nologo /E /TC /FIAutoGen.h
+*_VS2005x86xASL_EBC_CC_FLAGS = /nologo /c /WX /W3 /FIAutoGen.h /D$(MODULE_ENTRY_POINT)=$(ARCH_ENTRY_POINT)
+*_VS2005x86xASL_EBC_VFRPP_FLAGS = /nologo /E /TC /DVFRCOMPILE /FI$(MODULE_NAME)StrDefs.h
+*_VS2005x86xASL_EBC_SLINK_FLAGS = /lib /NOLOGO /MACHINE:EBC
+*_VS2005x86xASL_EBC_DLINK_FLAGS = "C:\Program Files (x86)\Intel\EBC\Lib\EbcLib.lib" /NOLOGO /NODEFAULTLIB /MACHINE:EBC /OPT:REF /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /MAP
+
+
+
+####################################################################################
+#
+# Microsoft Visual Studio 2008
+#
+# VS2008 - Microsoft Visual Studio 2005 All Edition, including Standard, Professional, Express, TeamSuite
+# ASL - Intel ACPI Source Language Compiler
+####################################################################################
+# VS2008 - Microsoft Visual Studio 2008 ALL Edition, including Standard, Professional, Express, TeamSuite
+*_VS2008_*_*_FAMILY = MSFT
+
+*_VS2008_*_MAKE_PATH = DEF(VS2008_BIN)\nmake.exe
+*_VS2008_*_MAKE_FLAGS = /nologo
+*_VS2008_*_RC_PATH = DEF(WINSDK_BIN)\rc.exe
+
+*_VS2008_*_SLINK_FLAGS = /NOLOGO /LTCG
+*_VS2008_*_APP_FLAGS = /nologo /E /TC
+*_VS2008_*_PP_FLAGS = /nologo /E /TC /FIAutoGen.h
+*_VS2008_*_VFRPP_FLAGS = /nologo /E /TC /DVFRCOMPILE /FI$(MODULE_NAME)StrDefs.h
+
+*_VS2008_*_ASM16_PATH = DEF(VS2008_BIN)\ml.exe
+
+##################
+# ASL definitions
+##################
+*_VS2008_*_ASL_PATH = DEF(DEFAULT_WIN_ASL_BIN)
+*_VS2008_*_ASL_FLAGS = DEF(DEFAULT_WIN_ASL_FLAGS)
+*_VS2008_*_ASL_OUTFLAGS = DEF(DEFAULT_WIN_ASL_OUTFLAGS)
+*_VS2008_*_ASLCC_FLAGS = DEF(MSFT_ASLCC_FLAGS)
+*_VS2008_*_ASLPP_FLAGS = DEF(MSFT_ASLPP_FLAGS)
+*_VS2008_*_ASLDLINK_FLAGS = DEF(MSFT_ASLDLINK_FLAGS)
+
+##################
+# IA32 definitions
+##################
+*_VS2008_IA32_*_DLL = DEF(VS2008_DLL)
+
+*_VS2008_IA32_MAKE_PATH = DEF(VS2008_BIN)\nmake.exe
+*_VS2008_IA32_CC_PATH = DEF(VS2008_BIN)\cl.exe
+*_VS2008_IA32_VFRPP_PATH = DEF(VS2008_BIN)\cl.exe
+*_VS2008_IA32_SLINK_PATH = DEF(VS2008_BIN)\lib.exe
+*_VS2008_IA32_DLINK_PATH = DEF(VS2008_BIN)\link.exe
+*_VS2008_IA32_APP_PATH = DEF(VS2008_BIN)\cl.exe
+*_VS2008_IA32_PP_PATH = DEF(VS2008_BIN)\cl.exe
+*_VS2008_IA32_ASM_PATH = DEF(VS2008_BIN)\ml.exe
+*_VS2008_IA32_ASLCC_PATH = DEF(VS2008_BIN)\cl.exe
+*_VS2008_IA32_ASLPP_PATH = DEF(VS2008_BIN)\cl.exe
+*_VS2008_IA32_ASLDLINK_PATH = DEF(VS2008_BIN)\link.exe
+
+ *_VS2008_IA32_MAKE_FLAGS = /nologo
+ DEBUG_VS2008_IA32_CC_FLAGS = /nologo /c /WX /GS- /W4 /Gs32768 /D UNICODE /O1ib2 /GL /FIAutoGen.h /EHs-c- /GR- /GF /Gy /Zi /Gm
+RELEASE_VS2008_IA32_CC_FLAGS = /nologo /c /WX /GS- /W4 /Gs32768 /D UNICODE /O1ib2 /GL /FIAutoGen.h /EHs-c- /GR- /GF
+ DEBUG_VS2008_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Cx /coff /Zd /Zi
+RELEASE_VS2008_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Cx /coff /Zd
+ DEBUG_VS2008_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:I386 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
+RELEASE_VS2008_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:I386 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.data=.text /MERGE:.rdata=.text
+
+##################
+# X64 definitions
+##################
+*_VS2008_X64_*_DLL = DEF(VS2008_DLL)
+
+*_VS2008_X64_CC_PATH = DEF(VS2008_BINX64)\cl.exe
+*_VS2008_X64_PP_PATH = DEF(VS2008_BINX64)\cl.exe
+*_VS2008_X64_APP_PATH = DEF(VS2008_BINX64)\cl.exe
+*_VS2008_X64_VFRPP_PATH = DEF(VS2008_BINX64)\cl.exe
+*_VS2008_X64_ASM_PATH = DEF(VS2008_BINX64)\ml64.exe
+*_VS2008_X64_SLINK_PATH = DEF(VS2008_BINX64)\lib.exe
+*_VS2008_X64_DLINK_PATH = DEF(VS2008_BINX64)\link.exe
+*_VS2008_X64_ASLCC_PATH = DEF(VS2008_BINX64)\cl.exe
+*_VS2008_X64_ASLPP_PATH = DEF(VS2008_BINX64)\cl.exe
+*_VS2008_X64_ASLDLINK_PATH = DEF(VS2008_BINX64)\link.exe
+
+
+ DEBUG_VS2008_X64_CC_FLAGS = /nologo /c /WX /GS- /X /W4 /Gs32768 /D UNICODE /O1ib2s /GL /Gy /FIAutoGen.h /EHs-c- /GR- /GF /Zi /Gm
+RELEASE_VS2008_X64_CC_FLAGS = /nologo /c /WX /GS- /X /W4 /Gs32768 /D UNICODE /O1ib2s /GL /Gy /FIAutoGen.h /EHs-c- /GR- /GF
+ DEBUG_VS2008_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd /Zi
+RELEASE_VS2008_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd
+ DEBUG_VS2008_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:AMD64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
+RELEASE_VS2008_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:AMD64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.data=.text /MERGE:.rdata=.text
+
+##################
+# IPF definitions
+##################
+*_VS2008_IPF_*_DLL = DEF(VS2008_DLL)
+
+*_VS2008_IPF_PP_PATH = DEF(VS2008_BIN64)\cl.exe
+*_VS2008_IPF_APP_PATH = DEF(VS2008_BIN64)\cl.exe
+*_VS2008_IPF_VFRPP_PATH = DEF(VS2008_BIN64)\cl.exe
+*_VS2008_IPF_CC_PATH = DEF(VS2008_BIN64)\cl.exe
+*_VS2008_IPF_ASM_PATH = DEF(VS2008_BIN64)\ias.exe
+*_VS2008_IPF_SLINK_PATH = DEF(VS2008_BIN64)\lib.exe
+*_VS2008_IPF_DLINK_PATH = DEF(VS2008_BIN64)\link.exe
+*_VS2008_IPF_ASLCC_PATH = DEF(VS2008_BIN64)\cl.exe
+*_VS2008_IPF_ASLPP_PATH = DEF(VS2008_BIN64)\cl.exe
+*_VS2008_IPF_ASLDLINK_PATH = DEF(VS2008_BIN64)\link.exe
+
+ DEBUG_VS2008_IPF_CC_FLAGS = /nologo /c /WX /GS- /X /W4 /EHs-c- /GR- /Gy /Os /GL /FIAutoGen.h /QIPF_fr32 /Zi
+RELEASE_VS2008_IPF_CC_FLAGS = /nologo /c /WX /GS- /X /W4 /EHs-c- /GR- /Gy /Os /GL /FIAutoGen.h /QIPF_fr32
+ DEBUG_VS2008_IPF_ASM_FLAGS = -N us -X explicit -M ilp64 -N so -W4 -d debug
+RELEASE_VS2008_IPF_ASM_FLAGS = -N us -X explicit -M ilp64 -N so -W4
+ DEBUG_VS2008_IPF_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /LTCG /DLL /OPT:REF,ICF /IGNORE:4001 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:IA64 /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MAP:$(DEBUG_DIR)/$(BASE_NAME).map /PDB:$(DEBUG_DIR)/$(BASE_NAME).pdb /DEBUG
+RELEASE_VS2008_IPF_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /LTCG /DLL /OPT:REF,ICF /IGNORE:4001 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:IA64 /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MAP:$(DEBUG_DIR)/$(BASE_NAME).map /PDB:$(DEBUG_DIR)/$(BASE_NAME).pdb
+
+##################
+# EBC definitions
+##################
+*_VS2008_EBC_*_FAMILY = INTEL
+
+*_VS2008_EBC_MAKE_PATH = DEF(VS2008_BIN)\nmake.exe
+*_VS2008_EBC_PP_PATH = DEF(EBC_BIN)\iec.exe
+*_VS2008_EBC_VFRPP_PATH = DEF(EBC_BIN)\iec.exe
+*_VS2008_EBC_CC_PATH = DEF(EBC_BIN)\iec.exe
+*_VS2008_EBC_SLINK_PATH = DEF(EBC_BIN)\link.exe
+*_VS2008_EBC_DLINK_PATH = DEF(EBC_BIN)\link.exe
+
+*_VS2008_EBC_MAKE_FLAGS = /nologo
+*_VS2008_EBC_PP_FLAGS = /nologo /E /TC /FIAutoGen.h
+*_VS2008_EBC_CC_FLAGS = /nologo /c /WX /W3 /FIAutoGen.h /D$(MODULE_ENTRY_POINT)=$(ARCH_ENTRY_POINT)
+*_VS2008_EBC_VFRPP_FLAGS = /nologo /E /TC /DVFRCOMPILE /FI$(MODULE_NAME)StrDefs.h
+*_VS2008_EBC_SLINK_FLAGS = /lib /NOLOGO /MACHINE:EBC
+*_VS2008_EBC_DLINK_FLAGS = "C:\Program Files\Intel\EBC\Lib\EbcLib.lib" /NOLOGO /NODEFAULTLIB /MACHINE:EBC /OPT:REF /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /MAP
+
+####################################################################################
+#
+# Microsoft Visual Studio 2008
+#
+# VS2008 - Microsoft Visual Studio 2008 All Edition, including Standard, Professional, Express, TeamSuite
+# ASL - Microsoft ACPI Source Language Compiler (asl.exe)
+####################################################################################
+# VS2008xASL - Microsoft Visual Studio 2008 ALL Edition, including Standard, Professional, Express, TeamSuite
+*_VS2008xASL_*_*_FAMILY = MSFT
+
+*_VS2008xASL_*_MAKE_PATH = DEF(VS2008_BIN)\nmake.exe
+*_VS2008xASL_*_MAKE_FLAG = /nologo
+*_VS2008xASL_*_RC_PATH = DEF(WINSDK_BIN)\rc.exe
+
+*_VS2008xASL_*_SLINK_FLAGS = /NOLOGO /LTCG
+*_VS2008xASL_*_APP_FLAGS = /nologo /E /TC
+*_VS2008xASL_*_PP_FLAGS = /nologo /E /TC /FIAutoGen.h
+*_VS2008xASL_*_VFRPP_FLAGS = /nologo /E /TC /DVFRCOMPILE /FI$(MODULE_NAME)StrDefs.h
+
+*_VS2008xASL_*_ASM16_PATH = DEF(VS2008_BIN)\ml.exe
+
+##################
+# ASL definitions
+##################
+*_VS2008xASL_*_ASL_PATH = DEF(WIN_ASL_BIN)
+*_VS2008xASL_*_ASL_FLAGS =
+*_VS2008xASL_*_ASL_OUTFLAGS = DEF(MS_ASL_OUTFLAGS)
+*_VS2008xASL_*_ASLCC_FLAGS = DEF(MSFT_ASLCC_FLAGS)
+*_VS2008xASL_*_ASLPP_FLAGS = DEF(MSFT_ASLPP_FLAGS)
+*_VS2008xASL_*_ASLDLINK_FLAGS = DEF(MSFT_ASLDLINK_FLAGS)
+
+##################
+# IA32 definitions
+##################
+*_VS2008xASL_IA32_*_DLL = DEF(VS2008_DLL)
+
+*_VS2008xASL_IA32_MAKE_PATH = DEF(VS2008_BIN)\nmake.exe
+*_VS2008xASL_IA32_CC_PATH = DEF(VS2008_BIN)\cl.exe
+*_VS2008xASL_IA32_VFRPP_PATH = DEF(VS2008_BIN)\cl.exe
+*_VS2008xASL_IA32_SLINK_PATH = DEF(VS2008_BIN)\lib.exe
+*_VS2008xASL_IA32_DLINK_PATH = DEF(VS2008_BIN)\link.exe
+*_VS2008xASL_IA32_APP_PATH = DEF(VS2008_BIN)\cl.exe
+*_VS2008xASL_IA32_PP_PATH = DEF(VS2008_BIN)\cl.exe
+*_VS2008xASL_IA32_ASM_PATH = DEF(VS2008_BIN)\ml.exe
+*_VS2008xASL_IA32_ASLCC_PATH = DEF(VS2008_BIN)\cl.exe
+*_VS2008xASL_IA32_ASLPP_PATH = DEF(VS2008_BIN)\cl.exe
+*_VS2008xASL_IA32_ASLDLINK_PATH = DEF(VS2008_BIN)\link.exe
+
+ *_VS2008xASL_IA32_MAKE_FLAGS = /nologo
+ DEBUG_VS2008xASL_IA32_CC_FLAGS = /nologo /c /WX /GS- /W4 /Gs32768 /D UNICODE /O1ib2 /GL /FIAutoGen.h /EHs-c- /GR- /GF /Gy /Zi /Gm
+RELEASE_VS2008xASL_IA32_CC_FLAGS = /nologo /c /WX /GS- /W4 /Gs32768 /D UNICODE /O1ib2 /GL /FIAutoGen.h /EHs-c- /GR- /GF
+ DEBUG_VS2008xASL_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Cx /coff /Zd /Zi
+RELEASE_VS2008xASL_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Cx /coff /Zd
+ DEBUG_VS2008xASL_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:I386 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
+RELEASE_VS2008xASL_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:I386 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.data=.text /MERGE:.rdata=.text
+
+##################
+# X64 definitions
+##################
+*_VS2008xASL_X64_*_DLL = DEF(VS2008_DLL)
+
+*_VS2008xASL_X64_CC_PATH = DEF(VS2008_BINX64)\cl.exe
+*_VS2008xASL_X64_PP_PATH = DEF(VS2008_BINX64)\cl.exe
+*_VS2008xASL_X64_APP_PATH = DEF(VS2008_BINX64)\cl.exe
+*_VS2008xASL_X64_VFRPP_PATH = DEF(VS2008_BINX64)\cl.exe
+*_VS2008xASL_X64_ASM_PATH = DEF(VS2008_BINX64)\ml64.exe
+*_VS2008xASL_X64_SLINK_PATH = DEF(VS2008_BINX64)\lib.exe
+*_VS2008xASL_X64_DLINK_PATH = DEF(VS2008_BINX64)\link.exe
+*_VS2008xASL_X64_ASLCC_PATH = DEF(VS2008_BINX64)\cl.exe
+*_VS2008xASL_X64_ASLPP_PATH = DEF(VS2008_BINX64)\cl.exe
+*_VS2008xASL_X64_ASLDLINK_PATH = DEF(VS2008_BINX64)\link.exe
+
+
+ DEBUG_VS2008xASL_X64_CC_FLAGS = /nologo /c /WX /GS- /X /W4 /Gs32768 /D UNICODE /O1ib2s /GL /Gy /FIAutoGen.h /EHs-c- /GR- /GF /Zi /Gm
+RELEASE_VS2008xASL_X64_CC_FLAGS = /nologo /c /WX /GS- /X /W4 /Gs32768 /D UNICODE /O1ib2s /GL /Gy /FIAutoGen.h /EHs-c- /GR- /GF
+ DEBUG_VS2008xASL_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd /Zi
+RELEASE_VS2008xASL_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd
+ DEBUG_VS2008xASL_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:AMD64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
+RELEASE_VS2008xASL_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:AMD64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.data=.text /MERGE:.rdata=.text
+
+##################
+# IPF definitions
+##################
+*_VS2008xASL_IPF_*_DLL = DEF(VS2008_DLL)
+
+*_VS2008xASL_IPF_PP_PATH = DEF(VS2008_BIN64)\cl.exe
+*_VS2008xASL_IPF_APP_PATH = DEF(VS2008_BIN64)\cl.exe
+*_VS2008xASL_IPF_VFRPP_PATH = DEF(VS2008_BIN64)\cl.exe
+*_VS2008xASL_IPF_CC_PATH = DEF(VS2008_BIN64)\cl.exe
+*_VS2008xASL_IPF_ASM_PATH = DEF(VS2008_BIN64)\ias.exe
+*_VS2008xASL_IPF_SLINK_PATH = DEF(VS2008_BIN64)\lib.exe
+*_VS2008xASL_IPF_DLINK_PATH = DEF(VS2008_BIN64)\link.exe
+*_VS2008xASL_IPF_ASLCC_PATH = DEF(VS2008_BIN64)\cl.exe
+*_VS2008xASL_IPF_ASLPP_PATH = DEF(VS2008_BIN64)\cl.exe
+*_VS2008xASL_IPF_ASLDLINK_PATH = DEF(VS2008_BIN64)\link.exe
+
+ DEBUG_VS2008xASL_IPF_CC_FLAGS = /nologo /c /WX /GS- /X /W4 /EHs-c- /GR- /Gy /Os /GL /FIAutoGen.h /QIPF_fr32 /Zi
+RELEASE_VS2008xASL_IPF_CC_FLAGS = /nologo /c /WX /GS- /X /W4 /EHs-c- /GR- /Gy /Os /GL /FIAutoGen.h /QIPF_fr32
+ DEBUG_VS2008xASL_IPF_ASM_FLAGS = -N us -X explicit -M ilp64 -N so -W4 -d debug
+RELEASE_VS2008xASL_IPF_ASM_FLAGS = -N us -X explicit -M ilp64 -N so -W4
+ DEBUG_VS2008xASL_IPF_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /LTCG /DLL /OPT:REF,ICF /IGNORE:4001 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:IA64 /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MAP:$(DEBUG_DIR)/$(BASE_NAME).map /PDB:$(DEBUG_DIR)/$(BASE_NAME).pdb /DEBUG
+RELEASE_VS2008xASL_IPF_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /LTCG /DLL /OPT:REF,ICF /IGNORE:4001 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:IA64 /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MAP:$(DEBUG_DIR)/$(BASE_NAME).map /PDB:$(DEBUG_DIR)/$(BASE_NAME).pdb
+
+##################
+# EBC definitions
+##################
+*_VS2008xASL_EBC_*_FAMILY = INTEL
+
+*_VS2008xASL_EBC_MAKE_PATH = DEF(VS2008_BIN)\nmake.exe
+*_VS2008xASL_EBC_PP_PATH = DEF(EBC_BIN)\iec.exe
+*_VS2008xASL_EBC_VFRPP_PATH = DEF(EBC_BIN)\iec.exe
+*_VS2008xASL_EBC_CC_PATH = DEF(EBC_BIN)\iec.exe
+*_VS2008xASL_EBC_SLINK_PATH = DEF(EBC_BIN)\link.exe
+*_VS2008xASL_EBC_DLINK_PATH = DEF(EBC_BIN)\link.exe
+
+*_VS2008xASL_EBC_MAKE_FLAGS = /nologo
+*_VS2008xASL_EBC_PP_FLAGS = /nologo /E /TC /FIAutoGen.h
+*_VS2008xASL_EBC_CC_FLAGS = /nologo /c /WX /W3 /FIAutoGen.h /D$(MODULE_ENTRY_POINT)=$(ARCH_ENTRY_POINT)
+*_VS2008xASL_EBC_VFRPP_FLAGS = /nologo /E /TC /DVFRCOMPILE /FI$(MODULE_NAME)StrDefs.h
+*_VS2008xASL_EBC_SLINK_FLAGS = /lib /NOLOGO /MACHINE:EBC
+*_VS2008xASL_EBC_DLINK_FLAGS = "C:\Program Files\Intel\EBC\Lib\EbcLib.lib" /NOLOGO /NODEFAULTLIB /MACHINE:EBC /OPT:REF /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /MAP
+
+
+####################################################################################
+# VS2008x86 - Microsoft Visual Studio 2008 (x86) with Intel ASL
+# ASL - Intel ACPI Source Language Compiler (iasl.exe)
+####################################################################################
+# VS2008x86 - Microsoft Visual Studio 2008 (x86) ALL Edition with Intel ASL
+*_VS2008x86_*_*_FAMILY = MSFT
+
+*_VS2008x86_*_MAKE_PATH = DEF(VS2008x86_BIN)\nmake.exe
+*_VS2008x86_*_MAKE_FLAG = /nologo
+*_VS2008x86_*_RC_PATH = DEF(WINSDK_BIN)\rc.exe
+
+*_VS2008x86_*_MAKE_FLAGS = /nologo
+*_VS2008x86_*_SLINK_FLAGS = /NOLOGO /LTCG
+*_VS2008x86_*_APP_FLAGS = /nologo /E /TC
+*_VS2008x86_*_PP_FLAGS = /nologo /E /TC /FIAutoGen.h
+*_VS2008x86_*_VFRPP_FLAGS = /nologo /E /TC /DVFRCOMPILE /FI$(MODULE_NAME)StrDefs.h
+
+*_VS2008x86_*_ASM16_PATH = DEF(VS2008x86_BIN)\ml.exe
+
+##################
+# ASL definitions
+##################
+*_VS2008x86_*_ASL_PATH = DEF(WIN_IASL_BIN)
+*_VS2008x86_*_ASL_FLAGS = DEF(DEFAULT_WIN_ASL_FLAGS)
+*_VS2008x86_*_ASL_OUTFLAGS = DEF(DEFAULT_WIN_ASL_OUTFLAGS)
+*_VS2008x86_*_ASLCC_FLAGS = DEF(MSFT_ASLCC_FLAGS)
+*_VS2008x86_*_ASLPP_FLAGS = DEF(MSFT_ASLPP_FLAGS)
+*_VS2008x86_*_ASLDLINK_FLAGS = DEF(MSFT_ASLDLINK_FLAGS)
+
+##################
+# IA32 definitions
+##################
+*_VS2008x86_IA32_*_DLL = DEF(VS2008x86_DLL)
+
+*_VS2008x86_IA32_MAKE_PATH = DEF(VS2008x86_BIN)\nmake.exe
+*_VS2008x86_IA32_CC_PATH = DEF(VS2008x86_BIN)\cl.exe
+*_VS2008x86_IA32_VFRPP_PATH = DEF(VS2008x86_BIN)\cl.exe
+*_VS2008x86_IA32_ASLCC_PATH = DEF(VS2008x86_BIN)\cl.exe
+*_VS2008x86_IA32_ASLPP_PATH = DEF(VS2008x86_BIN)\cl.exe
+*_VS2008x86_IA32_SLINK_PATH = DEF(VS2008x86_BIN)\lib.exe
+*_VS2008x86_IA32_DLINK_PATH = DEF(VS2008x86_BIN)\link.exe
+*_VS2008x86_IA32_ASLDLINK_PATH= DEF(VS2008x86_BIN)\link.exe
+*_VS2008x86_IA32_APP_PATH = DEF(VS2008x86_BIN)\cl.exe
+*_VS2008x86_IA32_PP_PATH = DEF(VS2008x86_BIN)\cl.exe
+*_VS2008x86_IA32_ASM_PATH = DEF(VS2008x86_BIN)\ml.exe
+
+ *_VS2008x86_IA32_MAKE_FLAGS = /nologo
+ DEBUG_VS2008x86_IA32_CC_FLAGS = /nologo /c /WX /GS- /W4 /Gs32768 /D UNICODE /O1ib2 /GL /FIAutoGen.h /EHs-c- /GR- /GF /Gy /Zi /Gm
+RELEASE_VS2008x86_IA32_CC_FLAGS = /nologo /c /WX /GS- /W4 /Gs32768 /D UNICODE /O1ib2 /GL /FIAutoGen.h /EHs-c- /GR- /GF
+ DEBUG_VS2008x86_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Cx /coff /Zd /Zi
+RELEASE_VS2008x86_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Cx /coff /Zd
+ DEBUG_VS2008x86_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /MACHINE:I386 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
+RELEASE_VS2008x86_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /MACHINE:I386 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.data=.text /MERGE:.rdata=.text
+
+##################
+# X64 definitions
+##################
+*_VS2008x86_X64_*_DLL = DEF(VS2008x86_DLL)
+
+*_VS2008x86_X64_CC_PATH = DEF(VS2008x86_BINX64)\cl.exe
+*_VS2008x86_X64_PP_PATH = DEF(VS2008x86_BINX64)\cl.exe
+*_VS2008x86_X64_APP_PATH = DEF(VS2008x86_BINX64)\cl.exe
+*_VS2008x86_X64_VFRPP_PATH = DEF(VS2008x86_BINX64)\cl.exe
+*_VS2008x86_X64_ASLCC_PATH = DEF(VS2008x86_BINX64)\cl.exe
+*_VS2008x86_X64_ASLPP_PATH = DEF(VS2008x86_BINX64)\cl.exe
+*_VS2008x86_X64_ASM_PATH = DEF(VS2008x86_BINX64)\ml64.exe
+*_VS2008x86_X64_SLINK_PATH = DEF(VS2008x86_BINX64)\lib.exe
+*_VS2008x86_X64_DLINK_PATH = DEF(VS2008x86_BINX64)\link.exe
+*_VS2008x86_X64_ASLDLINK_PATH = DEF(VS2008x86_BINX64)\link.exe
+
+ DEBUG_VS2008x86_X64_CC_FLAGS = /nologo /c /WX /GS- /X /W4 /Gs32768 /D UNICODE /O1ib2s /GL /Gy /FIAutoGen.h /EHs-c- /GR- /GF /Zi /Gm
+RELEASE_VS2008x86_X64_CC_FLAGS = /nologo /c /WX /GS- /X /W4 /Gs32768 /D UNICODE /O1ib2s /GL /Gy /FIAutoGen.h /EHs-c- /GR- /GF
+ DEBUG_VS2008x86_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd /Zi
+RELEASE_VS2008x86_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd
+ DEBUG_VS2008x86_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /Machine:AMD64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
+RELEASE_VS2008x86_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /Machine:AMD64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.data=.text /MERGE:.rdata=.text
+
+##################
+# IPF definitions
+##################
+*_VS2008x86_IPF_*_DLL = DEF(VS2008x86_DLL)
+
+*_VS2008x86_IPF_PP_PATH = DEF(VS2008x86_BIN64)\cl.exe
+*_VS2008x86_IPF_APP_PATH = DEF(VS2008x86_BIN64)\cl.exe
+*_VS2008x86_IPF_VFRPP_PATH = DEF(VS2008x86_BIN64)\cl.exe
+*_VS2008x86_IPF_ASLCC_PATH = DEF(VS2008x86_BIN64)\cl.exe
+*_VS2008x86_IPF_ASLPP_PATH = DEF(VS2008x86_BIN64)\cl.exe
+*_VS2008x86_IPF_CC_PATH = DEF(VS2008x86_BIN64)\cl.exe
+*_VS2008x86_IPF_ASM_PATH = DEF(VS2008x86_BIN64)\ias.exe
+*_VS2008x86_IPF_SLINK_PATH = DEF(VS2008x86_BIN64)\lib.exe
+*_VS2008x86_IPF_DLINK_PATH = DEF(VS2008x86_BIN64)\link.exe
+*_VS2008x86_IPF_ASLDLINK_PATH = DEF(VS2008x86_BIN64)\link.exe
+
+ DEBUG_VS2008x86_IPF_CC_FLAGS = /nologo /c /WX /GS- /X /W4 /EHs-c- /GR- /Gy /Os /GL /FIAutoGen.h /QIPF_fr32 /Zi
+RELEASE_VS2008x86_IPF_CC_FLAGS = /nologo /c /WX /GS- /X /W4 /EHs-c- /GR- /Gy /Os /GL /FIAutoGen.h /QIPF_fr32
+ DEBUG_VS2008x86_IPF_ASM_FLAGS = -N us -X explicit -M ilp64 -N so -W4 -d debug
+RELEASE_VS2008x86_IPF_ASM_FLAGS = -N us -X explicit -M ilp64 -N so -W4
+ DEBUG_VS2008x86_IPF_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /LTCG /DLL /OPT:REF,ICF /IGNORE:4001 /MAP /ALIGN:32 /MACHINE:IA64 /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MAP:$(DEBUG_DIR)/$(BASE_NAME).map /PDB:$(DEBUG_DIR)/$(BASE_NAME).pdb /DEBUG
+RELEASE_VS2008x86_IPF_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /LTCG /DLL /OPT:REF,ICF /IGNORE:4001 /MAP /ALIGN:32 /MACHINE:IA64 /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MAP:$(DEBUG_DIR)/$(BASE_NAME).map /PDB:$(DEBUG_DIR)/$(BASE_NAME).pdb
+
+
+####################################################################################
+# VS2008x86xASL - Microsoft Visual Studio 2008 with Microsoft ASL
+# ASL - Microsoft ACPI Source Language Compiler (asl.exe)
+####################################################################################
+*_VS2008x86xASL_*_*_FAMILY = MSFT
+
+*_VS2008x86xASL_*_MAKE_PATH = DEF(VS2008x86_BIN)\nmake.exe
+*_VS2008x86xASL_*_MAKE_FLAG = /nologo
+*_VS2008x86xASL_*_RC_PATH = DEF(WINSDK_BIN)\rc.exe
+
+*_VS2008x86xASL_*_MAKE_FLAGS = /nologo
+*_VS2008x86xASL_*_SLINK_FLAGS = /NOLOGO /LTCG
+*_VS2008x86xASL_*_APP_FLAGS = /nologo /E /TC
+*_VS2008x86xASL_*_PP_FLAGS = /nologo /E /TC /FIAutoGen.h
+*_VS2008x86xASL_*_VFRPP_FLAGS = /nologo /E /TC /DVFRCOMPILE /FI$(MODULE_NAME)StrDefs.h
+
+*_VS2008x86xASL_*_ASM16_PATH = DEF(VS2008x86_BIN)\ml.exe
+
+##################
+# ASL definitions
+##################
+*_VS2008x86xASL_*_ASL_PATH = DEF(WIN_ASL_BIN)
+*_VS2008x86xASL_*_ASL_FLAGS = DEF(MS_ASL_FLAGS)
+*_VS2008x86xASL_*_ASL_OUTFLAGS = DEF(MS_ASL_OUTFLAGS)
+*_VS2008x86xASL_*_ASLCC_FLAGS = DEF(MSFT_ASLCC_FLAGS)
+*_VS2008x86xASL_*_ASLPP_FLAGS = DEF(MSFT_ASLPP_FLAGS)
+*_VS2008x86xASL_*_ASLDLINK_FLAGS = DEF(MSFT_ASLDLINK_FLAGS)
+
+##################
+# IA32 definitions
+##################
+*_VS2008x86xASL_IA32_*_DLL = DEF(VS2008x86_DLL)
+
+*_VS2008x86xASL_IA32_MAKE_PATH = DEF(VS2008x86_BIN)\nmake.exe
+*_VS2008x86xASL_IA32_CC_PATH = DEF(VS2008x86_BIN)\cl.exe
+*_VS2008x86xASL_IA32_VFRPP_PATH = DEF(VS2008x86_BIN)\cl.exe
+*_VS2008x86xASL_IA32_ASLCC_PATH = DEF(VS2008x86_BIN)\cl.exe
+*_VS2008x86xASL_IA32_ASLPP_PATH = DEF(VS2008x86_BIN)\cl.exe
+*_VS2008x86xASL_IA32_SLINK_PATH = DEF(VS2008x86_BIN)\lib.exe
+*_VS2008x86xASL_IA32_DLINK_PATH = DEF(VS2008x86_BIN)\link.exe
+*_VS2008x86xASL_IA32_ASLDLINK_PATH= DEF(VS2008x86_BIN)\link.exe
+*_VS2008x86xASL_IA32_APP_PATH = DEF(VS2008x86_BIN)\cl.exe
+*_VS2008x86xASL_IA32_PP_PATH = DEF(VS2008x86_BIN)\cl.exe
+*_VS2008x86xASL_IA32_ASM_PATH = DEF(VS2008x86_BIN)\ml.exe
+
+ *_VS2008x86xASL_IA32_MAKE_FLAGS = /nologo
+ DEBUG_VS2008x86xASL_IA32_CC_FLAGS = /nologo /c /WX /GS- /W4 /Gs32768 /D UNICODE /O1ib2 /GL /FIAutoGen.h /EHs-c- /GR- /GF /Gy /Zi /Gm
+RELEASE_VS2008x86xASL_IA32_CC_FLAGS = /nologo /c /WX /GS- /W4 /Gs32768 /D UNICODE /O1ib2 /GL /FIAutoGen.h /EHs-c- /GR- /GF
+ DEBUG_VS2008x86xASL_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Cx /coff /Zd /Zi
+RELEASE_VS2008x86xASL_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Cx /coff /Zd
+ DEBUG_VS2008x86xASL_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /MACHINE:I386 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
+RELEASE_VS2008x86xASL_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /MACHINE:I386 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.data=.text /MERGE:.rdata=.text
+
+##################
+# X64 definitions
+##################
+*_VS2008x86xASL_X64_*_DLL = DEF(VS2008x86_DLL)
+
+*_VS2008x86xASL_X64_CC_PATH = DEF(VS2008x86_BINX64)\cl.exe
+*_VS2008x86xASL_X64_PP_PATH = DEF(VS2008x86_BINX64)\cl.exe
+*_VS2008x86xASL_X64_APP_PATH = DEF(VS2008x86_BINX64)\cl.exe
+*_VS2008x86xASL_X64_VFRPP_PATH = DEF(VS2008x86_BINX64)\cl.exe
+*_VS2008x86xASL_X64_ASLCC_PATH = DEF(VS2008x86_BINX64)\cl.exe
+*_VS2008x86xASL_X64_ASLPP_PATH = DEF(VS2008x86_BINX64)\cl.exe
+*_VS2008x86xASL_X64_ASM_PATH = DEF(VS2008x86_BINX64)\ml64.exe
+*_VS2008x86xASL_X64_SLINK_PATH = DEF(VS2008x86_BINX64)\lib.exe
+*_VS2008x86xASL_X64_DLINK_PATH = DEF(VS2008x86_BINX64)\link.exe
+*_VS2008x86xASL_X64_ASLDLINK_PATH = DEF(VS2008x86_BINX64)\link.exe
+
+ DEBUG_VS2008x86xASL_X64_CC_FLAGS = /nologo /c /WX /GS- /X /W4 /Gs32768 /D UNICODE /O1ib2s /GL /Gy /FIAutoGen.h /EHs-c- /GR- /GF /Zi /Gm
+RELEASE_VS2008x86xASL_X64_CC_FLAGS = /nologo /c /WX /GS- /X /W4 /Gs32768 /D UNICODE /O1ib2s /GL /Gy /FIAutoGen.h /EHs-c- /GR- /GF
+ DEBUG_VS2008x86xASL_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd /Zi
+RELEASE_VS2008x86xASL_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd
+ DEBUG_VS2008x86xASL_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /Machine:AMD64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
+RELEASE_VS2008x86xASL_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /Machine:AMD64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.data=.text /MERGE:.rdata=.text
+
+##################
+# IPF definitions
+##################
+*_VS2008x86xASL_IPF_*_DLL = DEF(VS2008x86_DLL)
+
+*_VS2008x86xASL_IPF_PP_PATH = DEF(VS2008x86_BIN64)\cl.exe
+*_VS2008x86xASL_IPF_APP_PATH = DEF(VS2008x86_BIN64)\cl.exe
+*_VS2008x86xASL_IPF_VFRPP_PATH = DEF(VS2008x86_BIN64)\cl.exe
+*_VS2008x86xASL_IPF_ASLCC_PATH = DEF(VS2008x86_BIN64)\cl.exe
+*_VS2008x86xASL_IPF_ASLPP_PATH = DEF(VS2008x86_BIN64)\cl.exe
+*_VS2008x86xASL_IPF_CC_PATH = DEF(VS2008x86_BIN64)\cl.exe
+*_VS2008x86xASL_IPF_ASM_PATH = DEF(VS2008x86_BIN64)\ias.exe
+*_VS2008x86xASL_IPF_SLINK_PATH = DEF(VS2008x86_BIN64)\lib.exe
+*_VS2008x86xASL_IPF_DLINK_PATH = DEF(VS2008x86_BIN64)\link.exe
+*_VS2008x86xASL_IPF_ASLDLINK_PATH = DEF(VS2008x86_BIN64)\link.exe
+
+ DEBUG_VS2008x86xASL_IPF_CC_FLAGS = /nologo /c /WX /GS- /X /W4 /EHs-c- /GR- /Gy /Os /GL /FIAutoGen.h /QIPF_fr32 /Zi
+RELEASE_VS2008x86xASL_IPF_CC_FLAGS = /nologo /c /WX /GS- /X /W4 /EHs-c- /GR- /Gy /Os /GL /FIAutoGen.h /QIPF_fr32
+ DEBUG_VS2008x86xASL_IPF_ASM_FLAGS = -N us -X explicit -M ilp64 -N so -W4 -d debug
+RELEASE_VS2008x86xASL_IPF_ASM_FLAGS = -N us -X explicit -M ilp64 -N so -W4
+ DEBUG_VS2008x86xASL_IPF_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /LTCG /DLL /OPT:REF,ICF /IGNORE:4001 /MAP /ALIGN:32 /MACHINE:IA64 /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MAP:$(DEBUG_DIR)/$(BASE_NAME).map /PDB:$(DEBUG_DIR)/$(BASE_NAME).pdb /DEBUG
+RELEASE_VS2008x86xASL_IPF_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /LTCG /DLL /OPT:REF,ICF /IGNORE:4001 /MAP /ALIGN:32 /MACHINE:IA64 /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MAP:$(DEBUG_DIR)/$(BASE_NAME).map /PDB:$(DEBUG_DIR)/$(BASE_NAME).pdb
+
+
+####################################################################################
+#
+# Microsoft Device Driver Kit 3790.1830 (IA-32, X64, Itanium, with Link Time Code Generation)
+# And Intel ACPI Compiler
+#
+####################################################################################
+# DDK3790 - Microsoft Windows DDK 3790.1830
+# ASL - Intel ACPI Source Language Compiler (iasl.exe)
+*_DDK3790_*_*_FAMILY = MSFT
+
+*_DDK3790_*_MAKE_PATH = DEF(WINDDK_BIN32)\nmake.exe
+*_DDK3790_*_MAKE_FLAGS = /nologo
+*_DDK3790_*_RC_PATH = DEF(WINDDK_BIN32)\rc.exe
+
+*_DDK3790_*_PP_FLAGS = /nologo /E /TC /FIAutoGen.h
+*_DDK3790_*_APP_FLAGS = /nologo /E /TC
+*_DDK3790_*_SLINK_FLAGS = /nologo /LTCG
+*_DDK3790_*_VFRPP_FLAGS = /nologo /E /TC /DVFRCOMPILE /FI$(MODULE_NAME)StrDefs.h
+
+*_DDK3790_*_ASM16_PATH = DEF(WINDDK_BIN32)\ml.exe
+
+##################
+# ASL definitions
+##################
+*_DDK3790_*_ASL_PATH = DEF(DEFAULT_WIN_ASL_BIN)
+*_DDK3790_*_ASL_FLAGS = DEF(DEFAULT_WIN_ASL_FLAGS)
+*_DDK3790_*_ASL_OUTFLAGS = DEF(DEFAULT_WIN_ASL_OUTFLAGS)
+*_DDK3790_*_ASLCC_FLAGS = DEF(MSFT_ASLCC_FLAGS)
+*_DDK3790_*_ASLPP_FLAGS = DEF(MSFT_ASLPP_FLAGS)
+*_DDK3790_*_ASLDLINK_FLAGS = DEF(MSFT_ASLDLINK_FLAGS)
+
+##################
+# IA32 definitions
+##################
+*_DDK3790_IA32_CC_PATH = DEF(WINDDK_BIN32)\cl.exe
+*_DDK3790_IA32_SLINK_PATH = DEF(WINDDK_BIN32)\lib.exe
+*_DDK3790_IA32_DLINK_PATH = DEF(WINDDK_BIN32)\link.exe
+*_DDK3790_IA32_PP_PATH = DEF(WINDDK_BIN32)\cl.exe
+*_DDK3790_IA32_VFRPP_PATH = DEF(WINDDK_BIN32)\cl.exe
+*_DDK3790_IA32_APP_PATH = DEF(WINDDK_BIN32)\cl.exe
+*_DDK3790_IA32_ASM_PATH = DEF(WINDDK_BIN32)\ml.exe
+*_DDK3790_IA32_ASLCC_PATH = DEF(WINDDK_BIN32)\cl.exe
+*_DDK3790_IA32_ASLPP_PATH = DEF(WINDDK_BIN32)\cl.exe
+*_DDK3790_IA32_ASLDLINK_PATH = DEF(WINDDK_BIN32)\link.exe
+
+ DEBUG_DDK3790_IA32_CC_FLAGS = /nologo /c /WX /W4 /Gy /Gs32768 /D UNICODE /O1ib2 /GL /FIAutoGen.h /EHs-c- /GR- /GF /Zi /Gm
+RELEASE_DDK3790_IA32_CC_FLAGS = /nologo /c /WX /W4 /Gy /Gs32768 /D UNICODE /O1ib2 /GL /FIAutoGen.h /EHs-c- /GR- /GF
+ DEBUG_DDK3790_IA32_ASM_FLAGS = /nologo /c /WX /W3 /coff /Cx /Zd /Zi
+RELEASE_DDK3790_IA32_ASM_FLAGS = /nologo /c /WX /W3 /coff /Cx /Zd
+ DEBUG_DDK3790_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:I386 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
+RELEASE_DDK3790_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4078 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:I386 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.data=.text /MERGE:.rdata=.text
+
+##################
+# x64 definitions
+##################
+*_DDK3790_X64_CC_PATH = DEF(WINDDK_BINX64)\cl.exe
+*_DDK3790_X64_SLINK_PATH = DEF(WINDDK_BINX64)\lib.exe
+*_DDK3790_X64_DLINK_PATH = DEF(WINDDK_BINX64)\link.exe
+*_DDK3790_X64_PP_PATH = DEF(WINDDK_BINX64)\cl.exe
+*_DDK3790_X64_VFRPP_PATH = DEF(WINDDK_BINX64)\cl.exe
+*_DDK3790_X64_APP_PATH = DEF(WINDDK_BINX64)\cl.exe
+*_DDK3790_X64_ASM_PATH = DEF(WINDDK_BINX64)\ml64.exe
+*_DDK3790_X64_ASLCC_PATH = DEF(WINDDK_BINX64)\cl.exe
+*_DDK3790_X64_ASLPP_PATH = DEF(WINDDK_BINX64)\cl.exe
+*_DDK3790_X64_ASLDLINK_PATH = DEF(WINDDK_BINX64)\link.exe
+
+ DEBUG_DDK3790_X64_CC_FLAGS = /nologo /c /WX /GS- /X /W4 /Gs32768 /D UNICODE /O1ib2s /GL /Gy /FIAutoGen.h /EHs-c- /GR- /GF /Zi /Gm
+RELEASE_DDK3790_X64_CC_FLAGS = /nologo /c /WX /GS- /X /W4 /Gs32768 /D UNICODE /O1ib2s /GL /Gy /FIAutoGen.h /EHs-c- /GR- /GF
+ DEBUG_DDK3790_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd /Zi
+RELEASE_DDK3790_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd
+ DEBUG_DDK3790_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:AMD64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
+RELEASE_DDK3790_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4078 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:AMD64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.data=.text /MERGE:.rdata=.text
+
+##################
+# IPF definitions
+##################
+*_DDK3790_IPF_CC_PATH = DEF(WINDDK_BIN64)\cl.exe
+*_DDK3790_IPF_SLINK_PATH = DEF(WINDDK_BIN64)\lib.exe
+*_DDK3790_IPF_DLINK_PATH = DEF(WINDDK_BIN64)\link.exe
+*_DDK3790_IPF_PP_PATH = DEF(WINDDK_BIN64)\cl.exe
+*_DDK3790_IPF_VFRPP_PATH = DEF(WINDDK_BIN64)\cl.exe
+*_DDK3790_IPF_APP_PATH = DEF(WINDDK_BIN64)\cl.exe
+*_DDK3790_IPF_ASM_PATH = DEF(WINDDK_BIN64)\ias.exe
+*_DDK3790_IPF_ASLCC_PATH = DEF(WINDDK_BIN64)\cl.exe
+*_DDK3790_IPF_ASLPP_PATH = DEF(WINDDK_BIN64)\cl.exe
+*_DDK3790_IPF_ASLDLINK_PATH = DEF(WINDDK_BIN64)\link.exe
+
+
+ DEBUG_DDK3790_IPF_CC_FLAGS = /nologo /c /WX /GS- /X /W4 /EHs-c- /GR- /Gy /Os /GL /FIAutoGen.h /QIPF_fr32 /Zi
+RELEASE_DDK3790_IPF_CC_FLAGS = /nologo /c /WX /GS- /X /W4 /EHs-c- /GR- /Gy /Os /GL /FIAutoGen.h /QIPF_fr32
+ DEBUG_DDK3790_IPF_ASM_FLAGS = -N us -X explicit -M ilp64 -N so -W4 -d debug
+RELEASE_DDK3790_IPF_ASM_FLAGS = -N us -X explicit -M ilp64 -N so -W4
+ DEBUG_DDK3790_IPF_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /LTCG /DLL /OPT:REF,ICF /IGNORE:4001 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:IA64 /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MAP:$(DEST_DIR_DEBUG)/$(BASE_NAME).map /PDB:$(DEST_DIR_DEBUG)/$(BASE_NAME).pdb /DEBUG
+RELEASE_DDK3790_IPF_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /LTCG /DLL /OPT:REF,ICF /IGNORE:4001 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:IA64 /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MAP:$(DEST_DIR_DEBUG)/$(BASE_NAME).map /PDB:$(DEST_DIR_DEBUG)/$(BASE_NAME).pdb
+
+##################
+# EBC definitions
+##################
+*_DDK3790_EBC_*_FAMILY = INTEL
+
+*_DDK3790_EBC_PP_PATH = DEF(EBC_BIN)\iec.exe
+*_DDK3790_EBC_CC_PATH = DEF(EBC_BIN)\iec.exe
+*_DDK3790_EBC_DLINK_PATH = DEF(EBC_BIN)\link.exe
+*_DDK3790_EBC_SLINK_PATH = DEF(EBC_BIN)\link.exe
+*_DDK3790_EBC_VFRPP_PATH = DEF(EBC_BIN)\iec.exe
+
+*_DDK3790_EBC_CC_FLAGS = /nologo /c /WX /W3 /FIAutoGen.h /D$(MODULE_ENTRY_POINT)=$(ARCH_ENTRY_POINT)
+*_DDK3790_EBC_SLINK_FLAGS = /lib /NOLOGO /MACHINE:EBC
+*_DDK3790_EBC_DLINK_FLAGS = "C:\Program Files\Intel\EBC\Lib\EbcLib.lib" /NOLOGO /NODEFAULTLIB /MACHINE:EBC /OPT:REF /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER
+
+####################################################################################
+#
+# Microsoft Device Driver Kit 3790.1830 (IA-32, X64, Itanium, with Link Time Code Generation)
+# And Microsoft ACPI Compiler
+#
+####################################################################################
+# DDK3790xASL - Microsoft Windows DDK 3790.1830
+# ASL - Microsoft ACPI Source Language Compiler (asl.exe)
+*_DDK3790xASL_*_*_FAMILY = MSFT
+
+*_DDK3790xASL_*_MAKE_PATH = DEF(WINDDK_BIN32)\nmake.exe
+*_DDK3790xASL_*_MAKE_FLAGS = /nologo
+*_DDK3790xASL_*_RC_PATH = DEF(WINDDK_BIN32)\rc.exe
+
+*_DDK3790xASL_*_PP_FLAGS = /nologo /E /TC /FIAutoGen.h
+*_DDK3790xASL_*_APP_FLAGS = /nologo /E /TC
+*_DDK3790xASL_*_SLINK_FLAGS = /nologo /LTCG
+*_DDK3790xASL_*_VFRPP_FLAGS = /nologo /E /TC /DVFRCOMPILE /FI$(MODULE_NAME)StrDefs.h
+
+*_DDK3790xASL_*_ASM16_PATH = DEF(WINDDK_BIN32)\ml.exe
+
+##################
+# ASL definitions
+##################
+*_DDK3790xASL_*_ASL_PATH = DEF(WIN_ASL_BIN)
+*_DDK3790xASL_*_ASL_FLAGS =
+*_DDK3790xASL_*_ASL_OUTFLAGS = DEF(MS_ASL_OUTFLAGS)
+*_DDK3790xASL_*_ASLCC_FLAGS = DEF(MSFT_ASLCC_FLAGS)
+*_DDK3790xASL_*_ASLPP_FLAGS = DEF(MSFT_ASLPP_FLAGS)
+*_DDK3790xASL_*_ASLDLINK_FLAGS = DEF(MSFT_ASLDLINK_FLAGS)
+
+##################
+# IA32 definitions
+##################
+*_DDK3790xASL_IA32_CC_PATH = DEF(WINDDK_BIN32)\cl.exe
+*_DDK3790xASL_IA32_SLINK_PATH = DEF(WINDDK_BIN32)\lib.exe
+*_DDK3790xASL_IA32_DLINK_PATH = DEF(WINDDK_BIN32)\link.exe
+*_DDK3790xASL_IA32_PP_PATH = DEF(WINDDK_BIN32)\cl.exe
+*_DDK3790xASL_IA32_VFRPP_PATH = DEF(WINDDK_BIN32)\cl.exe
+*_DDK3790xASL_IA32_APP_PATH = DEF(WINDDK_BIN32)\cl.exe
+*_DDK3790xASL_IA32_ASM_PATH = DEF(WINDDK_BIN32)\ml.exe
+*_DDK3790xASL_IA32_ASLCC_PATH = DEF(WINDDK_BIN32)\cl.exe
+*_DDK3790xASL_IA32_ASLPP_PATH = DEF(WINDDK_BIN32)\cl.exe
+*_DDK3790xASL_IA32_ASLDLINK_PATH = DEF(WINDDK_BIN32)\link.exe
+
+ DEBUG_DDK3790xASL_IA32_CC_FLAGS = /nologo /c /WX /W4 /Gy /Gs32768 /D UNICODE /O1ib2 /GL /FIAutoGen.h /EHs-c- /GR- /GF /Zi /Gm
+RELEASE_DDK3790xASL_IA32_CC_FLAGS = /nologo /c /WX /W4 /Gy /Gs32768 /D UNICODE /O1ib2 /GL /FIAutoGen.h /EHs-c- /GR- /GF
+ DEBUG_DDK3790xASL_IA32_ASM_FLAGS = /nologo /c /WX /W3 /coff /Cx /Zd /Zi
+RELEASE_DDK3790xASL_IA32_ASM_FLAGS = /nologo /c /WX /W3 /coff /Cx /Zd
+ DEBUG_DDK3790xASL_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:I386 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
+RELEASE_DDK3790xASL_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4078 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:I386 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.data=.text /MERGE:.rdata=.text
+
+##################
+# x64 definitions
+##################
+*_DDK3790xASL_X64_CC_PATH = DEF(WINDDK_BINX64)\cl.exe
+*_DDK3790xASL_X64_SLINK_PATH = DEF(WINDDK_BINX64)\lib.exe
+*_DDK3790xASL_X64_DLINK_PATH = DEF(WINDDK_BINX64)\link.exe
+*_DDK3790xASL_X64_PP_PATH = DEF(WINDDK_BINX64)\cl.exe
+*_DDK3790xASL_X64_VFRPP_PATH = DEF(WINDDK_BINX64)\cl.exe
+*_DDK3790xASL_X64_APP_PATH = DEF(WINDDK_BINX64)\cl.exe
+*_DDK3790xASL_X64_ASM_PATH = DEF(WINDDK_BINX64)\ml64.exe
+*_DDK3790xASL_X64_ASLCC_PATH = DEF(WINDDK_BINX64)\cl.exe
+*_DDK3790xASL_X64_ASLPP_PATH = DEF(WINDDK_BINX64)\cl.exe
+*_DDK3790xASL_X64_ASLDLINK_PATH = DEF(WINDDK_BINX64)\link.exe
+
+ DEBUG_DDK3790xASL_X64_CC_FLAGS = /nologo /c /WX /GS- /X /W4 /Gs32768 /D UNICODE /O1ib2s /GL /Gy /FIAutoGen.h /EHs-c- /GR- /GF /Zi /Gm
+RELEASE_DDK3790xASL_X64_CC_FLAGS = /nologo /c /WX /GS- /X /W4 /Gs32768 /D UNICODE /O1ib2s /GL /Gy /FIAutoGen.h /EHs-c- /GR- /GF
+ DEBUG_DDK3790xASL_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd /Zi
+RELEASE_DDK3790xASL_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd
+ DEBUG_DDK3790xASL_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:AMD64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
+RELEASE_DDK3790xASL_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4078 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:AMD64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.data=.text /MERGE:.rdata=.text
+
+##################
+# IPF definitions
+##################
+*_DDK3790xASL_IPF_CC_PATH = DEF(WINDDK_BIN64)\cl.exe
+*_DDK3790xASL_IPF_SLINK_PATH = DEF(WINDDK_BIN64)\lib.exe
+*_DDK3790xASL_IPF_DLINK_PATH = DEF(WINDDK_BIN64)\link.exe
+*_DDK3790xASL_IPF_PP_PATH = DEF(WINDDK_BIN64)\cl.exe
+*_DDK3790xASL_IPF_VFRPP_PATH = DEF(WINDDK_BIN64)\cl.exe
+*_DDK3790xASL_IPF_APP_PATH = DEF(WINDDK_BIN64)\cl.exe
+*_DDK3790xASL_IPF_ASM_PATH = DEF(WINDDK_BIN64)\ias.exe
+*_DDK3790xASL_IPF_ASLCC_PATH = DEF(WINDDK_BIN64)\cl.exe
+*_DDK3790xASL_IPF_ASLPP_PATH = DEF(WINDDK_BIN64)\cl.exe
+*_DDK3790xASL_IPF_ASLDLINK_PATH = DEF(WINDDK_BIN64)\link.exe
+
+
+ DEBUG_DDK3790xASL_IPF_CC_FLAGS = /nologo /c /WX /GS- /X /W4 /EHs-c- /GR- /Gy /Os /GL /FIAutoGen.h /QIPF_fr32 /Zi
+RELEASE_DDK3790xASL_IPF_CC_FLAGS = /nologo /c /WX /GS- /X /W4 /EHs-c- /GR- /Gy /Os /GL /FIAutoGen.h /QIPF_fr32
+ DEBUG_DDK3790xASL_IPF_ASM_FLAGS = -N us -X explicit -M ilp64 -N so -W4 -d debug
+RELEASE_DDK3790xASL_IPF_ASM_FLAGS = -N us -X explicit -M ilp64 -N so -W4
+ DEBUG_DDK3790xASL_IPF_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /LTCG /DLL /OPT:REF,ICF /IGNORE:4001 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:IA64 /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MAP:$(DEST_DIR_DEBUG)/$(BASE_NAME).map /PDB:$(DEST_DIR_DEBUG)/$(BASE_NAME).pdb /DEBUG
+RELEASE_DDK3790xASL_IPF_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /LTCG /DLL /OPT:REF,ICF /IGNORE:4001 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:IA64 /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MAP:$(DEST_DIR_DEBUG)/$(BASE_NAME).map /PDB:$(DEST_DIR_DEBUG)/$(BASE_NAME).pdb
+
+##################
+# EBC definitions
+##################
+*_DDK3790xASL_EBC_*_FAMILY = INTEL
+
+*_DDK3790xASL_EBC_PP_PATH = DEF(EBC_BIN)\iec.exe
+*_DDK3790xASL_EBC_CC_PATH = DEF(EBC_BIN)\iec.exe
+*_DDK3790xASL_EBC_DLINK_PATH = DEF(EBC_BIN)\link.exe
+*_DDK3790xASL_EBC_SLINK_PATH = DEF(EBC_BIN)\link.exe
+*_DDK3790xASL_EBC_VFRPP_PATH = DEF(EBC_BIN)\iec.exe
+
+*_DDK3790xASL_EBC_CC_FLAGS = /nologo /c /WX /W3 /FIAutoGen.h /D$(MODULE_ENTRY_POINT)=$(ARCH_ENTRY_POINT)
+*_DDK3790xASL_EBC_SLINK_FLAGS = /lib /NOLOGO /MACHINE:EBC
+*_DDK3790xASL_EBC_DLINK_FLAGS = "C:\Program Files\Intel\EBC\Lib\EbcLib.lib" /NOLOGO /NODEFAULTLIB /MACHINE:EBC /OPT:REF /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER
+
+
+####################################################################################
+# GCC Common
+####################################################################################
+
+*_*_*_OBJCOPY_PATH = echo
+*_*_*_OBJCOPY_FLAGS = objcopy not needed for
+*_*_*_SYMRENAME_PATH = echo
+*_*_*_SYMRENAME_FLAGS = Symbol renaming not needed for
+
+DEFINE GCC_ALL_CC_FLAGS = -g -Os -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-missing-braces -Wno-array-bounds -c -include AutoGen.h
+DEFINE GCC_IA32_CC_FLAGS = DEF(GCC_ALL_CC_FLAGS) -m32 -malign-double -freorder-blocks -freorder-blocks-and-partition -O2 -mno-stack-arg-probe
+DEFINE GCC_X64_CC_FLAGS = DEF(GCC_ALL_CC_FLAGS) -mno-red-zone -Wno-address -mno-stack-arg-probe
+DEFINE GCC_IPF_CC_FLAGS = DEF(GCC_ALL_CC_FLAGS) -minline-int-divide-min-latency
+DEFINE GCC_DLINK_FLAGS_COMMON = -nostdlib --pie
+DEFINE GCC_IA32_X64_DLINK_COMMON = DEF(GCC_DLINK_FLAGS_COMMON) --gc-sections
+DEFINE GCC_IA32_X64_ASLDLINK_FLAGS = DEF(GCC_IA32_X64_DLINK_COMMON) --entry _ReferenceAcpiTable -u $(IMAGE_ENTRY_POINT)
+DEFINE GCC_IA32_X64_DLINK_FLAGS = DEF(GCC_IA32_X64_DLINK_COMMON) --entry _$(IMAGE_ENTRY_POINT) --file-alignment 0x20 --section-alignment 0x20 -Map $(DEST_DIR_DEBUG)/$(BASE_NAME).map
+DEFINE GCC_IPF_DLINK_FLAGS = -nostdlib -O2 --gc-sections --dll -static --entry $(IMAGE_ENTRY_POINT) --undefined $(IMAGE_ENTRY_POINT) -Map $(DEST_DIR_DEBUG)/$(BASE_NAME).map
+DEFINE GCC_IPF_OBJCOPY_FLAGS = -I elf64-ia64-little -O efi-bsdrv-ia64
+DEFINE GCC_IPF_SYMRENAME_FLAGS = --redefine-sym memcpy=CopyMem
+DEFINE GCC_ASM_FLAGS = -c -x assembler -imacros $(DEST_DIR_DEBUG)/AutoGen.h
+DEFINE GCC_PP_FLAGS = -E -x assembler-with-cpp -include $(DEST_DIR_DEBUG)/AutoGen.h
+DEFINE GCC_VFRPP_FLAGS = -x c -E -P -DVFRCOMPILE --include $(DEST_DIR_DEBUG)/$(MODULE_NAME)StrDefs.h
+DEFINE GCC_ASLPP_FLAGS = -x c -E -P
+DEFINE GCC_ASLCC_FLAGS = -x c
+DEFINE GCC_WINDRES_FLAGS = -J rc -O coff
+DEFINE GCC_IA32_RC_FLAGS = -I binary -O elf32-i386 -B i386 --rename-section .data=.hii
+DEFINE GCC_X64_RC_FLAGS = -I binary -O elf64-x86-64 -B i386 --rename-section .data=.hii
+DEFINE GCC_IPF_RC_FLAGS = -I binary -O elf64-ia64-little -B ia64 --rename-section .data=.hii
+
+DEFINE GCC44_ALL_CC_FLAGS = -g -fshort-wchar -fno-stack-protector -fno-strict-aliasing -Wall -Werror -Wno-missing-braces -Wno-array-bounds -ffunction-sections -fdata-sections -c -include AutoGen.h -DSTRING_ARRAY_NAME=$(BASE_NAME)Strings
+DEFINE GCC44_IA32_CC_FLAGS = DEF(GCC44_ALL_CC_FLAGS) -m32 -malign-double -D EFI32
+DEFINE GCC44_X64_CC_FLAGS = DEF(GCC44_ALL_CC_FLAGS) -m64 "-DEFIAPI=__attribute__((ms_abi))" -DNO_BUILTIN_VA_FUNCS -mno-red-zone -Wno-address -mcmodel=large
+DEFINE GCC44_IA32_X64_DLINK_COMMON = -nostdlib -n -q --gc-sections
+DEFINE GCC44_IA32_X64_ASLDLINK_FLAGS = DEF(GCC44_IA32_X64_DLINK_COMMON) --entry ReferenceAcpiTable -u ReferenceAcpiTable
+DEFINE GCC44_IA32_X64_DLINK_FLAGS = DEF(GCC44_IA32_X64_DLINK_COMMON) --entry $(IMAGE_ENTRY_POINT) -u $(IMAGE_ENTRY_POINT) -Map $(DEST_DIR_DEBUG)/$(BASE_NAME).map
+DEFINE GCC44_X64_DLINK_FLAGS = DEF(GCC44_IA32_X64_DLINK_FLAGS) -melf_x86_64 --oformat=elf64-x86-64 --script=$(EDK_TOOLS_PATH)/Scripts/gcc4.4-ld-script
+DEFINE GCC44_ASM_FLAGS = DEF(GCC_ASM_FLAGS)
+
+DEFINE GCC45_IA32_CC_FLAGS = DEF(GCC44_IA32_CC_FLAGS)
+DEFINE GCC45_X64_CC_FLAGS = DEF(GCC44_X64_CC_FLAGS)
+DEFINE GCC45_IA32_X64_DLINK_COMMON = DEF(GCC44_IA32_X64_DLINK_COMMON)
+DEFINE GCC45_IA32_X64_ASLDLINK_FLAGS = DEF(GCC44_IA32_X64_ASLDLINK_FLAGS)
+DEFINE GCC45_IA32_X64_DLINK_FLAGS = DEF(GCC44_IA32_X64_DLINK_FLAGS)
+DEFINE GCC45_X64_DLINK_FLAGS = DEF(GCC44_X64_DLINK_FLAGS)
+DEFINE GCC45_ASM_FLAGS = DEF(GCC44_ASM_FLAGS)
+
+####################################################################################
+#
+# Unix GCC And Intel Linux ACPI Compiler
+#
+####################################################################################
+# UNIXGCC - UNIX GCC
+# ASL - Intel Linux ACPI Source Language Compiler (iasl)
+*_UNIXGCC_*_*_FAMILY = GCC
+
+*_UNIXGCC_*_MAKE_PATH = make
+*_UNIXGCC_*_ASL_PATH = DEF(UNIX_IASL_BIN)
+
+*_UNIXGCC_IA32_DLINK_FLAGS = DEF(GCC_IA32_X64_DLINK_FLAGS) --image-base=0
+*_UNIXGCC_X64_DLINK_FLAGS = DEF(GCC_IA32_X64_DLINK_FLAGS) --image-base=0
+*_UNIXGCC_IA32_ASLDLINK_FLAGS = DEF(GCC_IA32_X64_ASLDLINK_FLAGS)
+*_UNIXGCC_X64_ASLDLINK_FLAGS = DEF(GCC_IA32_X64_ASLDLINK_FLAGS)
+*_UNIXGCC_*_ASM_FLAGS = DEF(GCC_ASM_FLAGS)
+*_UNIXGCC_*_PP_FLAGS = DEF(GCC_PP_FLAGS)
+*_UNIXGCC_*_ASLPP_FLAGS = DEF(GCC_ASLPP_FLAGS)
+*_UNIXGCC_*_ASLCC_FLAGS = DEF(GCC_ASLCC_FLAGS)
+*_UNIXGCC_*_VFRPP_FLAGS = DEF(GCC_VFRPP_FLAGS)
+*_UNIXGCC_*_APP_FLAGS =
+*_UNIXGCC_*_ASL_FLAGS = DEF(IASL_FLAGS)
+*_UNIXGCC_*_ASL_OUTFLAGS = DEF(IASL_OUTFLAGS)
+
+##################
+# IA32 definitions
+##################
+*_UNIXGCC_IA32_OBJCOPY_PATH = DEF(UNIXGCC_IA32_PETOOLS_PREFIX)objcopy
+*_UNIXGCC_IA32_PP_PATH = DEF(UNIXGCC_IA32_PETOOLS_PREFIX)gcc
+*_UNIXGCC_IA32_CC_PATH = DEF(UNIXGCC_IA32_PETOOLS_PREFIX)gcc
+*_UNIXGCC_IA32_SLINK_PATH = DEF(UNIXGCC_IA32_PETOOLS_PREFIX)ar
+*_UNIXGCC_IA32_DLINK_PATH = DEF(UNIXGCC_IA32_PETOOLS_PREFIX)ld
+*_UNIXGCC_IA32_ASLPP_PATH = DEF(UNIXGCC_IA32_PETOOLS_PREFIX)gcc
+*_UNIXGCC_IA32_ASLCC_PATH = DEF(UNIXGCC_IA32_PETOOLS_PREFIX)gcc
+*_UNIXGCC_IA32_ASLDLINK_PATH = DEF(UNIXGCC_IA32_PETOOLS_PREFIX)ld
+*_UNIXGCC_IA32_ASM_PATH = DEF(UNIXGCC_IA32_PETOOLS_PREFIX)gcc
+*_UNIXGCC_IA32_VFRPP_PATH = DEF(UNIXGCC_IA32_PETOOLS_PREFIX)gcc
+*_UNIXGCC_IA32_RC_PATH = DEF(UNIXGCC_IA32_PETOOLS_PREFIX)objcopy
+
+*_UNIXGCC_IA32_CC_FLAGS = DEF(GCC_IA32_CC_FLAGS)
+*_UNIXGCC_IA32_RC_FLAGS = DEF(GCC_IA32_RC_FLAGS)
+*_UNIXGCC_IA32_OBJCOPY_FLAGS =
+
+##################
+# X64 definitions
+##################
+*_UNIXGCC_X64_CC_PATH = DEF(UNIXGCC_X64_PETOOLS_PREFIX)gcc
+*_UNIXGCC_X64_ASLCC_PATH = DEF(UNIXGCC_X64_PETOOLS_PREFIX)gcc
+*_UNIXGCC_X64_SLINK_PATH = DEF(UNIXGCC_X64_PETOOLS_PREFIX)ar
+*_UNIXGCC_X64_DLINK_PATH = DEF(UNIXGCC_X64_PETOOLS_PREFIX)ld
+*_UNIXGCC_X64_ASLDLINK_PATH = DEF(UNIXGCC_X64_PETOOLS_PREFIX)ld
+*_UNIXGCC_X64_ASM_PATH = DEF(UNIXGCC_X64_PETOOLS_PREFIX)gcc
+*_UNIXGCC_X64_PP_PATH = DEF(UNIXGCC_X64_PETOOLS_PREFIX)gcc
+*_UNIXGCC_X64_ASLPP_PATH = DEF(UNIXGCC_X64_PETOOLS_PREFIX)gcc
+*_UNIXGCC_X64_VFRPP_PATH = DEF(UNIXGCC_X64_PETOOLS_PREFIX)gcc
+*_UNIXGCC_X64_RC_PATH = DEF(UNIXGCC_X64_PETOOLS_PREFIX)objcopy
+*_UNIXGCC_X64_OBJCOPY_PATH = DEF(UNIXGCC_X64_PETOOLS_PREFIX)objcopy
+
+*_UNIXGCC_X64_CC_FLAGS = DEF(GCC_X64_CC_FLAGS)
+*_UNIXGCC_X64_RC_FLAGS = DEF(GCC_X64_RC_FLAGS)
+*_UNIXGCC_X64_OBJCOPY_FLAGS =
+
+##################
+# IPF definitions
+##################
+*_UNIXGCC_IPF_CC_PATH = DEF(UNIXGCC_IPF_PETOOLS_PREFIX)gcc
+*_UNIXGCC_IPF_ASLCC_PATH = DEF(UNIXGCC_IPF_PETOOLS_PREFIX)gcc
+*_UNIXGCC_IPF_SLINK_PATH = DEF(UNIXGCC_IPF_PETOOLS_PREFIX)ar
+*_UNIXGCC_IPF_DLINK_PATH = DEF(UNIXGCC_IPF_PETOOLS_PREFIX)ld
+*_UNIXGCC_IPF_ASLDLINK_PATH = DEF(UNIXGCC_IPF_PETOOLS_PREFIX)ld
+*_UNIXGCC_IPF_ASM_PATH = DEF(UNIXGCC_IPF_PETOOLS_PREFIX)gcc
+*_UNIXGCC_IPF_PP_PATH = DEF(UNIXGCC_IPF_PETOOLS_PREFIX)gcc
+*_UNIXGCC_IPF_ASLPP_PATH = DEF(UNIXGCC_IPF_PETOOLS_PREFIX)gcc
+*_UNIXGCC_IPF_VFRPP_PATH = DEF(UNIXGCC_IPF_PETOOLS_PREFIX)gcc
+*_UNIXGCC_IPF_OBJCOPY_PATH = DEF(UNIXGCC_IPF_PETOOLS_PREFIX)objcopy
+*_UNIXGCC_IPF_SYMRENAME_PATH = DEF(UNIXGCC_IPF_PETOOLS_PREFIX)objcopy
+*_UNIXGCC_IPF_RC_PATH = DEF(UNIXGCC_IPF_PETOOLS_PREFIX)objcopy
+
+*_UNIXGCC_IPF_CC_FLAGS = DEF(GCC_IPF_CC_FLAGS)
+*_UNIXGCC_IPF_DLINK_FLAGS = DEF(GCC_IPF_DLINK_FLAGS)
+*_UNIXGCC_IPF_OBJCOPY_FLAGS = DEF(GCC_IPF_OBJCOPY_FLAGS)
+*_UNIXGCC_IPF_SYMRENAME_FLAGS = DEF(GCC_IPF_SYMRENAME_FLAGS)
+*_UNIXGCC_IPF_RC_FLAGS = DEF(GCC_IPF_RC_FLAGS)
+
+
+####################################################################################
+#
+# GCC 4.4 - This configuration is used to compile under Linux to produce
+# PE/COFF binaries using GCC 4.4.
+#
+####################################################################################
+*_GCC44_*_*_FAMILY = GCC
+
+*_GCC44_*_MAKE_PATH = make
+*_GCC44_*_ASL_PATH = DEF(UNIX_IASL_BIN)
+
+*_GCC44_*_PP_FLAGS = DEF(GCC_PP_FLAGS)
+*_GCC44_*_ASLPP_FLAGS = DEF(GCC_ASLPP_FLAGS)
+*_GCC44_*_ASLCC_FLAGS = DEF(GCC_ASLCC_FLAGS)
+*_GCC44_*_VFRPP_FLAGS = DEF(GCC_VFRPP_FLAGS)
+*_GCC44_*_APP_FLAGS =
+*_GCC44_*_ASL_FLAGS = DEF(IASL_FLAGS)
+*_GCC44_*_ASL_OUTFLAGS = DEF(IASL_OUTFLAGS)
+
+##################
+# GCC44 IA32 definitions
+##################
+*_GCC44_IA32_CC_PATH = DEF(GCC44_IA32_PREFIX)gcc
+*_GCC44_IA32_SLINK_PATH = DEF(GCC44_IA32_PREFIX)ar
+*_GCC44_IA32_DLINK_PATH = DEF(GCC44_IA32_PREFIX)ld
+*_GCC44_IA32_ASLDLINK_PATH = DEF(GCC44_IA32_PREFIX)ld
+*_GCC44_IA32_ASM_PATH = DEF(GCC44_IA32_PREFIX)gcc
+*_GCC44_IA32_PP_PATH = DEF(GCC44_IA32_PREFIX)gcc
+*_GCC44_IA32_VFRPP_PATH = DEF(GCC44_IA32_PREFIX)gcc
+*_GCC44_IA32_ASLCC_PATH = DEF(GCC44_IA32_PREFIX)gcc
+*_GCC44_IA32_ASLPP_PATH = DEF(GCC44_IA32_PREFIX)gcc
+*_GCC44_IA32_RC_PATH = DEF(GCC44_IA32_PREFIX)objcopy
+
+*_GCC44_IA32_ASLCC_FLAGS = DEF(GCC_ASLCC_FLAGS) -m32
+*_GCC44_IA32_ASLDLINK_FLAGS = DEF(GCC44_IA32_X64_ASLDLINK_FLAGS) -m elf_i386
+*_GCC44_IA32_ASM_FLAGS = DEF(GCC44_ASM_FLAGS) -m32 --32 -march=i386
+*_GCC44_IA32_CC_FLAGS = DEF(GCC44_IA32_CC_FLAGS) -Os
+*_GCC44_IA32_DLINK_FLAGS = DEF(GCC44_IA32_X64_DLINK_FLAGS) -m elf_i386 --oformat=elf32-i386
+*_GCC44_IA32_RC_FLAGS = DEF(GCC_IA32_RC_FLAGS)
+
+##################
+# GCC44 X64 definitions
+##################
+*_GCC44_X64_CC_PATH = DEF(GCC44_X64_PREFIX)gcc
+*_GCC44_X64_SLINK_PATH = DEF(GCC44_X64_PREFIX)ar
+*_GCC44_X64_DLINK_PATH = DEF(GCC44_X64_PREFIX)ld
+*_GCC44_X64_ASLDLINK_PATH = DEF(GCC44_X64_PREFIX)ld
+*_GCC44_X64_ASM_PATH = DEF(GCC44_X64_PREFIX)gcc
+*_GCC44_X64_PP_PATH = DEF(GCC44_X64_PREFIX)gcc
+*_GCC44_X64_VFRPP_PATH = DEF(GCC44_X64_PREFIX)gcc
+*_GCC44_X64_ASLCC_PATH = DEF(GCC44_X64_PREFIX)gcc
+*_GCC44_X64_ASLPP_PATH = DEF(GCC44_X64_PREFIX)gcc
+*_GCC44_X64_RC_PATH = DEF(GCC44_X64_PREFIX)objcopy
+
+*_GCC44_X64_ASLCC_FLAGS = DEF(GCC_ASLCC_FLAGS) -m64
+*_GCC44_X64_ASLDLINK_FLAGS = DEF(GCC44_IA32_X64_ASLDLINK_FLAGS) -m elf_x86_64
+*_GCC44_X64_ASM_FLAGS = DEF(GCC44_ASM_FLAGS) -m64 --64 -melf_x86_64
+*_GCC44_X64_CC_FLAGS = DEF(GCC44_X64_CC_FLAGS)
+*_GCC44_X64_DLINK_FLAGS = DEF(GCC44_X64_DLINK_FLAGS)
+*_GCC44_X64_RC_FLAGS = DEF(GCC_X64_RC_FLAGS)
+
+
+####################################################################################
+#
+# GCC 4.5 - This configuration is used to compile under Linux to produce
+# PE/COFF binaries using GCC 4.5.
+#
+####################################################################################
+*_GCC45_*_*_FAMILY = GCC
+
+*_GCC45_*_MAKE_PATH = make
+*_GCC45_*_ASL_PATH = DEF(UNIX_IASL_BIN)
+
+*_GCC45_*_PP_FLAGS = DEF(GCC_PP_FLAGS)
+*_GCC45_*_ASLPP_FLAGS = DEF(GCC_ASLPP_FLAGS)
+*_GCC45_*_ASLCC_FLAGS = DEF(GCC_ASLCC_FLAGS)
+*_GCC45_*_VFRPP_FLAGS = DEF(GCC_VFRPP_FLAGS)
+*_GCC45_*_APP_FLAGS =
+*_GCC45_*_ASL_FLAGS = DEF(IASL_FLAGS)
+*_GCC45_*_ASL_OUTFLAGS = DEF(IASL_OUTFLAGS)
+
+##################
+# GCC45 IA32 definitions
+##################
+*_GCC45_IA32_CC_PATH = DEF(GCC45_IA32_PREFIX)gcc
+*_GCC45_IA32_SLINK_PATH = DEF(GCC45_IA32_PREFIX)ar
+*_GCC45_IA32_DLINK_PATH = DEF(GCC45_IA32_PREFIX)ld
+*_GCC45_IA32_ASLDLINK_PATH = DEF(GCC45_IA32_PREFIX)ld
+*_GCC45_IA32_ASM_PATH = DEF(GCC45_IA32_PREFIX)gcc
+*_GCC45_IA32_PP_PATH = DEF(GCC45_IA32_PREFIX)gcc
+*_GCC45_IA32_VFRPP_PATH = DEF(GCC45_IA32_PREFIX)gcc
+*_GCC45_IA32_ASLCC_PATH = DEF(GCC45_IA32_PREFIX)gcc
+*_GCC45_IA32_ASLPP_PATH = DEF(GCC45_IA32_PREFIX)gcc
+*_GCC45_IA32_RC_PATH = DEF(GCC45_IA32_PREFIX)objcopy
+
+*_GCC45_IA32_ASLCC_FLAGS = DEF(GCC_ASLCC_FLAGS) -m32
+*_GCC45_IA32_ASLDLINK_FLAGS = DEF(GCC45_IA32_X64_ASLDLINK_FLAGS) -m elf_i386
+*_GCC45_IA32_ASM_FLAGS = DEF(GCC45_ASM_FLAGS) -m32 --32 -march=i386
+*_GCC45_IA32_CC_FLAGS = DEF(GCC45_IA32_CC_FLAGS) -Os
+*_GCC45_IA32_DLINK_FLAGS = DEF(GCC45_IA32_X64_DLINK_FLAGS) -m elf_i386 --oformat=elf32-i386
+*_GCC45_IA32_RC_FLAGS = DEF(GCC_IA32_RC_FLAGS)
+
+##################
+# GCC45 X64 definitions
+##################
+*_GCC45_X64_CC_PATH = DEF(GCC45_X64_PREFIX)gcc
+*_GCC45_X64_SLINK_PATH = DEF(GCC45_X64_PREFIX)ar
+*_GCC45_X64_DLINK_PATH = DEF(GCC45_X64_PREFIX)ld
+*_GCC45_X64_ASLDLINK_PATH = DEF(GCC45_X64_PREFIX)ld
+*_GCC45_X64_ASM_PATH = DEF(GCC45_X64_PREFIX)gcc
+*_GCC45_X64_PP_PATH = DEF(GCC45_X64_PREFIX)gcc
+*_GCC45_X64_VFRPP_PATH = DEF(GCC45_X64_PREFIX)gcc
+*_GCC45_X64_ASLCC_PATH = DEF(GCC45_X64_PREFIX)gcc
+*_GCC45_X64_ASLPP_PATH = DEF(GCC45_X64_PREFIX)gcc
+*_GCC45_X64_RC_PATH = DEF(GCC45_X64_PREFIX)objcopy
+
+*_GCC45_X64_ASLCC_FLAGS = DEF(GCC_ASLCC_FLAGS) -m64
+*_GCC45_X64_ASLDLINK_FLAGS = DEF(GCC45_IA32_X64_ASLDLINK_FLAGS) -m elf_x86_64
+*_GCC45_X64_ASM_FLAGS = DEF(GCC45_ASM_FLAGS) -m64 --64 -melf_x86_64
+*_GCC45_X64_CC_FLAGS = DEF(GCC45_X64_CC_FLAGS)
+*_GCC45_X64_DLINK_FLAGS = DEF(GCC45_X64_DLINK_FLAGS)
+*_GCC45_X64_RC_FLAGS = DEF(GCC_X64_RC_FLAGS)
+
+
+####################################################################################
+#
+# Cygwin GCC And Intel ACPI Compiler
+#
+####################################################################################
+# CYGGCC - CygWin GCC
+# ASL - Intel ACPI Source Language Compiler (iasl.exe)
+*_CYGGCC_*_*_FAMILY = GCC
+
+*_CYGGCC_*_*_DLL = DEF(CYGWIN_BIN)
+*_CYGGCC_*_MAKE_PATH = DEF(MS_VS_BIN)\nmake.exe
+*_CYGGCC_*_ASL_PATH = DEF(DEFAULT_WIN_ASL_BIN)
+
+*_CYGGCC_IA32_DLINK_FLAGS = DEF(GCC_IA32_X64_DLINK_FLAGS) --image-base=0
+*_CYGGCC_X64_DLINK_FLAGS = DEF(GCC_IA32_X64_DLINK_FLAGS) --image-base=0
+*_CYGGCC_IA32_ASLDLINK_FLAGS = DEF(GCC_IA32_X64_ASLDLINK_FLAGS)
+*_CYGGCC_X64_ASLDLINK_FLAGS = DEF(GCC_IA32_X64_ASLDLINK_FLAGS)
+*_CYGGCC_*_MAKE_FLAGS = /nologo
+*_CYGGCC_*_ASM_FLAGS = DEF(GCC_ASM_FLAGS)
+*_CYGGCC_*_PP_FLAGS = DEF(GCC_PP_FLAGS)
+*_CYGGCC_*_ASLPP_FLAGS = DEF(GCC_ASLPP_FLAGS)
+*_CYGGCC_*_ASLCC_FLAGS = DEF(GCC_ASLCC_FLAGS)
+*_CYGGCC_*_VFRPP_FLAGS = DEF(GCC_VFRPP_FLAGS)
+*_CYGGCC_*_APP_FLAGS =
+*_CYGGCC_*_ASL_FLAGS = DEF(DEFAULT_WIN_ASL_FLAGS)
+*_CYGGCC_*_ASL_OUTFLAGS = DEF(DEFAULT_WIN_ASL_OUTFLAGS)
+
+##################
+# IA32 definitions
+##################
+*_CYGGCC_IA32_CC_PATH = DEF(CYGWIN_BINIA32)gcc
+*_CYGGCC_IA32_SLINK_PATH = DEF(CYGWIN_BINIA32)ar
+*_CYGGCC_IA32_DLINK_PATH = DEF(CYGWIN_BINIA32)ld
+*_CYGGCC_IA32_ASM_PATH = DEF(CYGWIN_BINIA32)gcc
+*_CYGGCC_IA32_PP_PATH = DEF(CYGWIN_BINIA32)gcc
+*_CYGGCC_IA32_APP_PATH = DEF(CYGWIN_BINIA32)gcc
+*_CYGGCC_IA32_VFRPP_PATH = DEF(CYGWIN_BINIA32)gcc
+*_CYGGCC_IA32_ASLCC_PATH = DEF(CYGWIN_BINIA32)gcc
+*_CYGGCC_IA32_ASLPP_PATH = DEF(CYGWIN_BINIA32)gcc
+*_CYGGCC_IA32_ASLDLINK_PATH = DEF(CYGWIN_BINIA32)ld
+*_CYGGCC_IA32_RC_PATH = DEF(CYGWIN_BINIA32)objcopy
+*_CYGGCC_IA32_OBJCOPY_PATH = DEF(CYGWIN_BINIA32)objcopy
+
+*_CYGGCC_IA32_CC_FLAGS = DEF(GCC_IA32_CC_FLAGS)
+*_CYGGCC_IA32_RC_FLAGS = DEF(GCC_IA32_RC_FLAGS)
+*_CYGGCC_IA32_OBJCOPY_FLAGS =
+
+##################
+# X64 definitions
+##################
+*_CYGGCC_X64_CC_PATH = DEF(CYGWIN_BINX64)gcc
+*_CYGGCC_X64_SLINK_PATH = DEF(CYGWIN_BINX64)ar
+*_CYGGCC_X64_DLINK_PATH = DEF(CYGWIN_BINX64)ld
+*_CYGGCC_X64_ASM_PATH = DEF(CYGWIN_BINX64)gcc
+*_CYGGCC_X64_PP_PATH = DEF(CYGWIN_BINX64)gcc
+*_CYGGCC_X64_APP_PATH = DEF(CYGWIN_BINX64)gcc
+*_CYGGCC_X64_VFRPP_PATH = DEF(CYGWIN_BINX64)gcc
+*_CYGGCC_X64_ASLCC_PATH = DEF(CYGWIN_BINX64)gcc
+*_CYGGCC_X64_ASLPP_PATH = DEF(CYGWIN_BINX64)gcc
+*_CYGGCC_X64_ASLDLINK_PATH = DEF(CYGWIN_BINX64)ld
+*_CYGGCC_X64_RC_PATH = DEF(CYGWIN_BINX64)objcopy
+*_CYGGCC_X64_OBJCOPY_PATH = DEF(CYGWIN_BINX64)objcopy
+
+*_CYGGCC_X64_CC_FLAGS = DEF(GCC_X64_CC_FLAGS)
+*_CYGGCC_X64_RC_FLAGS = DEF(GCC_X64_RC_FLAGS)
+*_CYGGCC_X64_OBJCOPY_FLAGS =
+
+##################
+# IPF definitions
+##################
+*_CYGGCC_IPF_CC_PATH = DEF(CYGWIN_BINIPF)gcc
+*_CYGGCC_IPF_SLINK_PATH = DEF(CYGWIN_BINIPF)ar
+*_CYGGCC_IPF_DLINK_PATH = DEF(CYGWIN_BINIPF)ld
+*_CYGGCC_IPF_ASLDLINK_PATH = DEF(CYGWIN_BINIPF)ld
+*_CYGGCC_IPF_ASM_PATH = DEF(CYGWIN_BINIPF)gcc
+*_CYGGCC_IPF_PP_PATH = DEF(CYGWIN_BINIPF)gcc
+*_CYGGCC_IPF_VFRPP_PATH = DEF(CYGWIN_BINIPF)gcc
+*_CYGGCC_IPF_ASLCC_PATH = DEF(CYGWIN_BINIPF)gcc
+*_CYGGCC_IPF_ASLPP_PATH = DEF(CYGWIN_BINIPF)gcc
+*_CYGGCC_IPF_OBJCOPY_PATH = DEF(CYGWIN_BINIPF)objcopy
+*_CYGGCC_IPF_SYMRENAME_PATH = DEF(CYGWIN_BINIPF)objcopy
+*_CYGGCC_IPF_RC_PATH = DEF(CYGWIN_BINIPF)objcopy
+
+*_CYGGCC_IPF_CC_FLAGS = DEF(GCC_IPF_CC_FLAGS)
+*_CYGGCC_IPF_DLINK_FLAGS = DEF(GCC_IPF_DLINK_FLAGS)
+*_CYGGCC_IPF_OBJCOPY_FLAGS = DEF(GCC_IPF_OBJCOPY_FLAGS)
+*_CYGGCC_IPF_SYMRENAME_FLAGS = DEF(GCC_IPF_SYMRENAME_FLAGS)
+*_CYGGCC_IPF_RC_FLAGS = DEF(GCC_IPF_RC_FLAGS)
+
+##################
+# EBC definitions
+##################
+*_CYGGCC_EBC_*_FAMILY = INTEL
+
+*_CYGGCC_EBC_PP_PATH = DEF(EBC_BIN)\iec.exe
+*_CYGGCC_EBC_CC_PATH = DEF(EBC_BIN)\iec.exe
+*_CYGGCC_EBC_DLINK_PATH = DEF(EBC_BIN)\link.exe
+*_CYGGCC_EBC_SLINK_PATH = DEF(EBC_BIN)\link.exe
+*_CYGGCC_EBC_VFRPP_PATH = DEF(EBC_BIN)\iec.exe
+*_CYGGCC_EBC_RC_PATH = DEF(MS_VS_BIN)\rc.exe
+
+*_CYGGCC_EBC_CC_FLAGS = /nologo /c /WX /W3 /FIAutoGen.h /D$(MODULE_ENTRY_POINT)=$(ARCH_ENTRY_POINT)
+*_CYGGCC_EBC_SLINK_FLAGS = /lib /NOLOGO /MACHINE:EBC
+*_CYGGCC_EBC_DLINK_FLAGS = "C:\Program Files\Intel\EBC\Lib\EbcLib.lib" /NOLOGO /NODEFAULTLIB /MACHINE:EBC /OPT:REF /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER
+
+####################################################################################
+#
+# Cygwin GCC And Microsoft ACPI Compiler
+#
+####################################################################################
+# CYGGCCxASL - CygWin GCC
+# ASL - Microsoft ACPI Source Language Compiler (asl.exe)
+*_CYGGCCxASL_*_*_FAMILY = GCC
+
+*_CYGGCCxASL_*_*_DLL = DEF(CYGWIN_BIN)
+*_CYGGCCxASL_*_MAKE_PATH = DEF(MS_VS_BIN)\nmake.exe
+
+*_CYGGCCxASL_*_MAKE_FLAGS = /nologo
+*_CYGGCCxASL_*_PP_FLAGS = -E -x assembler-with-cpp -include AutoGen.h
+*_CYGGCCxASL_*_DLINK_FLAGS = -nostdlib -O2 --gc-sections --dll --export-all-symbols --entry _$(IMAGE_ENTRY_POINT) --file-alignment 0x20 --section-alignment 0x20
+*_CYGGCCxASL_*_ASM_FLAGS = -c -x assembler -imacros AutoGen.h
+*_CYGGCCxASL_*_APP_FLAGS = -E -x assembler
+*_CYGGCCxASL_*_VFRPP_FLAGS = -x c -E -P -DVFRCOMPILE --include $(MODULE_NAME)StrDefs.h
+
+##################
+# ASL definitions
+##################
+*_CYGGCCxASL_*_ASL_PATH = DEF(WIN_ASL_BIN)
+*_CYGGCCxASL_*_ASL_FLAGS =
+*_CYGGCCxASL_*_ASL_OUTFLAGS = DEF(MS_ASL_OUTFLAGS)
+*_CYGGCCxASL_*_ASLCC_FLAGS = DEF(MSFT_ASLCC_FLAGS)
+*_CYGGCCxASL_*_ASLPP_FLAGS = DEF(MSFT_ASLPP_FLAGS)
+*_CYGGCCxASL_*_ASLDLINK_FLAGS = DEF(MSFT_ASLDLINK_FLAGS)
+
+##################
+# IA32 definitions
+##################
+*_CYGGCCxASL_IA32_CC_PATH = DEF(CYGWIN_BINIA32)gcc
+*_CYGGCCxASL_IA32_SLINK_PATH = DEF(CYGWIN_BINIA32)ar
+*_CYGGCCxASL_IA32_DLINK_PATH = DEF(CYGWIN_BINIA32)ld
+*_CYGGCCxASL_IA32_ASM_PATH = DEF(CYGWIN_BINIA32)gcc
+*_CYGGCCxASL_IA32_PP_PATH = DEF(CYGWIN_BINIA32)gcc
+*_CYGGCCxASL_IA32_APP_PATH = DEF(CYGWIN_BINIA32)gcc
+*_CYGGCCxASL_IA32_VFRPP_PATH = DEF(CYGWIN_BINIA32)gcc
+*_CYGGCCxASL_IA32_ASLCC_PATH = DEF(CYGWIN_BINIA32)gcc
+*_CYGGCCxASL_IA32_ASLPP_PATH = DEF(CYGWIN_BINIA32)gcc
+*_CYGGCCxASL_IA32_ASLDLINK_PATH = DEF(CYGWIN_BINIA32)ld
+*_CYGGCCxASL_IA32_RC_PATH = DEF(CYGWIN_BINIA32)objcopy
+
+*_CYGGCCxASL_IA32_CC_FLAGS = DEF(GCC_IA32_CC_FLAGS)
+*_CYGGCCxASL_IA32_RC_FLAGS = DEF(GCC_IA32_RC_FLAGS)
+
+##################
+# X64 definitions
+##################
+*_CYGGCCxASL_X64_CC_PATH = DEF(CYGWIN_BINX64)gcc
+*_CYGGCCxASL_X64_SLINK_PATH = DEF(CYGWIN_BINX64)ar
+*_CYGGCCxASL_X64_DLINK_PATH = DEF(CYGWIN_BINX64)ld
+*_CYGGCCxASL_X64_ASM_PATH = DEF(CYGWIN_BINX64)gcc
+*_CYGGCCxASL_X64_PP_PATH = DEF(CYGWIN_BINX64)gcc
+*_CYGGCCxASL_X64_APP_PATH = DEF(CYGWIN_BINX64)gcc
+*_CYGGCCxASL_X64_VFRPP_PATH = DEF(CYGWIN_BINX64)gcc
+*_CYGGCCxASL_X64_ASLCC_PATH = DEF(CYGWIN_BINX64)gcc
+*_CYGGCCxASL_X64_ASLPP_PATH = DEF(CYGWIN_BINX64)gcc
+*_CYGGCCxASL_X64_ASLDLINK_PATH = DEF(CYGWIN_BINX64)ld
+*_CYGGCCxASL_X64_RC_PATH = DEF(CYGWIN_BINX64)objcopy
+
+*_CYGGCCxASL_X64_CC_FLAGS = DEF(GCC_X64_CC_FLAGS)
+*_CYGGCCxASL_X64_RC_FLAGS = DEF(GCC_X64_RC_FLAGS)
+
+##################
+# IPF definitions
+##################
+*_CYGGCCxASL_IPF_CC_PATH = DEF(CYGWIN_BINIPF)gcc
+*_CYGGCCxASL_IPF_SLINK_PATH = DEF(CYGWIN_BINIPF)ar
+*_CYGGCCxASL_IPF_DLINK_PATH = DEF(CYGWIN_BINIPF)ld
+*_CYGGCCxASL_IPF_ASLDLINK_PATH = DEF(CYGWIN_BINIPF)ld
+*_CYGGCCxASL_IPF_ASM_PATH = DEF(CYGWIN_BINIPF)gcc
+*_CYGGCCxASL_IPF_PP_PATH = DEF(CYGWIN_BINIPF)gcc
+*_CYGGCCxASL_IPF_VFRPP_PATH = DEF(CYGWIN_BINIPF)gcc
+*_CYGGCCxASL_IPF_ASLCC_PATH = DEF(CYGWIN_BINIPF)gcc
+*_CYGGCCxASL_IPF_ASLPP_PATH = DEF(CYGWIN_BINIPF)gcc
+*_CYGGCCxASL_IPF_OBJCOPY_PATH = DEF(CYGWIN_BINIPF)objcopy
+*_CYGGCCxASL_IPF_SYMRENAME_PATH = DEF(CYGWIN_BINIPF)objcopy
+*_CYGGCCxASL_IPF_RC_PATH = DEF(CYGWIN_BINIPF)objcopy
+
+*_CYGGCCxASL_IPF_CC_FLAGS = DEF(GCC_IPF_CC_FLAGS)
+*_CYGGCCxASL_IPF_DLINK_FLAGS = DEF(GCC_IPF_DLINK_FLAGS)
+*_CYGGCCxASL_IPF_OBJCOPY_FLAGS = DEF(GCC_IPF_OBJCOPY_FLAGS)
+*_CYGGCCxASL_IPF_SYMRENAME_FLAGS = DEF(GCC_IPF_SYMRENAME_FLAGS)
+*_CYGGCCxASL_IPF_RC_FLAGS = DEF(GCC_IPF_RC_FLAGS)
+
+##################
+# EBC definitions
+##################
+*_CYGGCCxASL_EBC_*_FAMILY = INTEL
+
+*_CYGGCCxASL_EBC_PP_PATH = DEF(EBC_BIN)\iec.exe
+*_CYGGCCxASL_EBC_CC_PATH = DEF(EBC_BIN)\iec.exe
+*_CYGGCCxASL_EBC_DLINK_PATH = DEF(EBC_BIN)\link.exe
+*_CYGGCCxASL_EBC_SLINK_PATH = DEF(EBC_BIN)\link.exe
+*_CYGGCCxASL_EBC_VFRPP_PATH = DEF(EBC_BIN)\iec.exe
+*_CYGGCCxASL_EBC_RC_PATH = DEF(MS_VS_BIN)\rc.exe
+
+*_CYGGCCxASL_EBC_CC_FLAGS = /nologo /c /WX /W3 /FIAutoGen.h /D$(MODULE_ENTRY_POINT)=$(ARCH_ENTRY_POINT)
+*_CYGGCCxASL_EBC_SLINK_FLAGS = /lib /NOLOGO /MACHINE:EBC
+*_CYGGCCxASL_EBC_DLINK_FLAGS = "C:\Program Files\Intel\EBC\Lib\EbcLib.lib" /NOLOGO /NODEFAULTLIB /MACHINE:EBC /OPT:REF /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER
+
+####################################################################################
+#
+# Elf GCC - This configuration is used to compile on Linux boxes to produce elf
+# binaries.
+#
+####################################################################################
+# ELFGCC - Linux ELF GCC
+*_ELFGCC_*_*_FAMILY = GCC
+*_ELFGCC_*_MAKE_PATH = make
+
+*_ELFGCC_*_PP_FLAGS = -E -x assembler-with-cpp -include AutoGen.h
+*_ELFGCC_*_VFRPP_FLAGS = -x c -E -P -DVFRCOMPILE --include $(MODULE_NAME)StrDefs.h
+
+##################
+# ASL definitions
+##################
+*_ELFGCC_*_ASL_PATH = DEF(UNIX_IASL_BIN)
+*_ELFGCC_*_ASL_FLAGS = DEF(IASL_FLAGS)
+*_ELFGCC_*_ASL_OUTFLAGS = DEF(IASL_OUTFLAGS)
+*_ELFGCC_*_ASLPP_FLAGS = -x c -E -P
+*_ELFGCC_*_ASLCC_FLAGS = -x c
+*_ELFGCC_*_ASLDLINK_FLAGS = DEF(GCC_DLINK_FLAGS_COMMON) --entry _ReferenceAcpiTable
+
+##################
+# IA32 definitions
+##################
+*_ELFGCC_IA32_OBJCOPY_PATH = DEF(ELFGCC_BIN)/objcopy
+*_ELFGCC_IA32_CC_PATH = DEF(ELFGCC_BIN)/gcc
+*_ELFGCC_IA32_SLINK_PATH = DEF(ELFGCC_BIN)/ar
+*_ELFGCC_IA32_DLINK_PATH = DEF(ELFGCC_BIN)/ld
+*_ELFGCC_IA32_ASM_PATH = DEF(ELFGCC_BIN)/gcc
+*_ELFGCC_IA32_PP_PATH = DEF(ELFGCC_BIN)/gcc
+*_ELFGCC_IA32_VFRPP_PATH = DEF(ELFGCC_BIN)/gcc
+*_ELFGCC32_IA32_ASLCC_PATH = DEF(ELFGCC_BIN)/gcc
+*_ELFGCC32_IA32_ASLPP_PATH = DEF(ELFGCC_BIN)/gcc
+*_ELFGCC32_IA32_ASLDLINK_PATH = DEF(ELFGCC_BIN)/ld
+*_ELFGCC_IA32_RC_PATH = DEF(ELFGCC_BIN)/objcopy
+
+*_ELFGCC_IA32_CC_FLAGS = -m32 -g -fshort-wchar -fno-strict-aliasing -Wall -malign-double -c -include $(DEST_DIR_DEBUG)/AutoGen.h -DSTRING_ARRAY_NAME=$(BASE_NAME)Strings
+*_ELFGCC_IA32_SLINK_FLAGS =
+*_ELFGCC_IA32_DLINK_FLAGS = -melf_i386 -nostdlib --shared --entry $(IMAGE_ENTRY_POINT) -u $(IMAGE_ENTRY_POINT)
+#*_ELFGCC_IA32_DLINK_FLAGS = -melf_i386 -nostdlib -n -q -Ttext 0x220 --entry $(IMAGE_ENTRY_POINT) -u $(IMAGE_ENTRY_POINT)
+*_ELFGCC_IA32_ASM_FLAGS = -m32 -c -x assembler -imacros $(DEST_DIR_DEBUG)/AutoGen.h
+*_ELFGCC_IA32_PP_FLAGS = -m32 -E -x assembler-with-cpp -include $(DEST_DIR_DEBUG)/AutoGen.h
+*_ELFGCC_IA32_VFRPP_FLAGS = -x c -E -P -DVFRCOMPILE --include $(DEST_DIR_DEBUG)/$(MODULE_NAME)StrDefs.h
+*_ELFGCC_IA32_RC_FLAGS = DEF(GCC_IA32_RC_FLAGS)
+*_ELFGCC_IA32_OBJCOPY_FLAGS =
+
+##################
+# X64 definitions
+##################
+*_ELFGCC_X64_CC_PATH = DEF(ELFGCC_BIN)/gcc
+*_ELFGCC_X64_ASLCC_PATH = DEF(ELFGCC_BIN)/gcc
+*_ELFGCC_X64_SLINK_PATH = DEF(ELFGCC_BIN)/ar
+*_ELFGCC_X64_DLINK_PATH = DEF(ELFGCC_BIN)/ld
+*_ELFGCC_X64_ASLDLINK_PATH = DEF(ELFGCC_BIN)/ld
+*_ELFGCC_X64_ASM_PATH = DEF(ELFGCC_BIN)/gcc
+*_ELFGCC_X64_PP_PATH = DEF(ELFGCC_BIN)/gcc
+*_ELFGCC_X64_ASLPP_PATH = DEF(ELFGCC_BIN)/gcc
+*_ELFGCC_X64_VFRPP_PATH = DEF(ELFGCC_BIN)/gcc
+*_ELFGCC_X64_RC_PATH = DEF(ELFGCC_BIN)/objcopy
+
+*_ELFGCC_X64_CC_FLAGS = -Os -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-missing-braces -Wno-address -Wno-array-bounds -c -include AutoGen.h -D_EFI_P64
+*_ELFGCC_X64_DLINK_FLAGS = -nostdlib --shared --entry $(IMAGE_ENTRY_POINT) -u $(IMAGE_ENTRY_POINT)
+*_ELFGCC_X64_SLINK_FLAGS =
+*_ELFGCC_X64_ASM_FLAGS = -c -x assembler -imacros $(DEST_DIR_DEBUG)/AutoGen.h
+*_ELFGCC_X64_PP_FLAGS = -E -x assembler-with-cpp -include $(DEST_DIR_DEBUG)/AutoGen.h
+*_ELFGCC_X64_VFRPP_FLAGS = -x c -E -P -DVFRCOMPILE --include $(DEST_DIR_DEBUG)/$(MODULE_NAME)StrDefs.h
+*_ELFGCC_X64_RC_FLAGS = DEF(GCC_X64_RC_FLAGS)
+
+##################
+# IPF definitions
+##################
+*_ELFGCC_IPF_CC_PATH = DEF(ELFGCC_BIN)/gcc
+*_ELFGCC_IPF_ASLCC_PATH = DEF(ELFGCC_BIN)/gcc
+*_ELFGCC_IPF_SLINK_PATH = DEF(ELFGCC_BIN)/ar
+*_ELFGCC_IPF_DLINK_PATH = DEF(ELFGCC_BIN)/ld
+*_ELFGCC_IPF_ASLDLINK_PATH = DEF(ELFGCC_BIN)/ld
+*_ELFGCC_IPF_ASM_PATH = DEF(ELFGCC_BIN)/gcc
+*_ELFGCC_IPF_PP_PATH = DEF(ELFGCC_BIN)/gcc
+*_ELFGCC_IPF_ASLPP_PATH = DEF(ELFGCC_BIN)/gcc
+*_ELFGCC_IPF_VFRPP_PATH = DEF(ELFGCC_BIN)/gcc
+*_ELFGCC_IPF_RC_PATH = DEF(ELFGCC_BIN)/objcopy
+
+*_ELFGCC_IPF_CC_FLAGS = -Os -fshort-wchar -Wall -Werror -c -include AutoGen.h -D_EFI_P64
+*_ELFGCC_IPF_DLINK_FLAGS = -nostdlib --shared --entry $(IMAGE_ENTRY_POINT) -u $(IMAGE_ENTRY_POINT)
+*_ELFGCC_IPF_SLINK_FLAGS =
+*_ELFGCC_IPF_ASM_FLAGS = -c -x assembler -imacros $(DEST_DIR_DEBUG)/AutoGen.h
+*_ELFGCC_IPF_PP_FLAGS = -E -x assembler-with-cpp -include $(DEST_DIR_DEBUG)/AutoGen.h
+*_ELFGCC_IPF_VFRPP_FLAGS = -x c -E -P -DVFRCOMPILE --include $(DEST_DIR_DEBUG)/$(MODULE_NAME)StrDefs.h
+*_ELFGCC_IPF_RC_FLAGS = DEF(GCC_IPF_RC_FLAGS)
+
+####################################################################################
+#
+# Intel(R) C++ Compiler Version 9.1
+#
+# IPF - Intel(R) C++ Compiler for Itanium(R)Version 9.1 Build 20060928 Package ID: W_CC_C_9.1.032
+# ASL - Intel ACPI Source Language Compiler
+#
+####################################################################################
+# ICC - Intel C Compiler V9.1
+*_ICC_*_*_FAMILY = INTEL
+
+*_ICC_*_MAKE_PATH = DEF(MS_VS_BIN)\nmake.exe
+*_ICC_*_RC_PATH = DEF(MS_VS_BIN)\rc.exe
+
+*_ICC_*_MAKE_FLAGS = /nologo
+*_ICC_*_VFRPP_FLAGS = /nologo /E /TC /DVFRCOMPILE /FI$(MODULE_NAME)StrDefs.h
+*_ICC_*_APP_FLAGS = /nologo /E /TC
+*_ICC_*_PP_FLAGS = /nologo /E /TC /FIAutoGen.h
+
+*_ICC_*_ASM16_PATH = DEF(MS_VS_BIN)\ml.exe
+
+##################
+# ASL definitions
+##################
+*_ICC_*_ASL_PATH = DEF(DEFAULT_WIN_ASL_BIN)
+*_ICC_*_ASL_FLAGS = DEF(DEFAULT_WIN_ASL_FLAGS)
+*_ICC_*_ASL_OUTFLAGS = DEF(DEFAULT_WIN_ASL_OUTFLAGS)
+*_ICC_*_ASLCC_FLAGS = DEF(ICC_WIN_ASLCC_FLAGS)
+*_ICC_*_ASLPP_FLAGS = DEF(ICC_WIN_ASLPP_FLAGS)
+*_ICC_*_ASLDLINK_FLAGS = DEF(ICC_WIN_ASLDLINK_FLAGS)
+
+##################
+# IA32 definitions
+##################
+*_ICC_IA32_CC_PATH = DEF(ICC_BIN32)\icl.exe
+*_ICC_IA32_SLINK_PATH = DEF(ICC_BIN32)\xilib.exe
+# xilib.exe needs lib.exe from Visual Studio
+*_ICC_IA32_SLINK_DLL = DEF(MS_VS_BIN)
+*_ICC_IA32_DLINK_PATH = DEF(ICC_BIN32)\xilink.exe
+*_ICC_IA32_PP_PATH = DEF(ICC_BIN32)\icl.exe
+*_ICC_IA32_VFRPP_PATH = DEF(ICC_BIN32)\icl.exe
+*_ICC_IA32_APP_PATH = DEF(ICC_BIN32)\icl.exe
+*_ICC_IA32_ASM_PATH = DEF(MS_VS_BIN)\ml.exe
+*_ICC_IA32_ASM_DLL = DEF(MS_VS_DLL)
+*_ICC_IA32_ASLCC_PATH = DEF(ICC_BIN32)\icl.exe
+*_ICC_IA32_ASLPP_PATH = DEF(ICC_BIN32)\icl.exe
+*_ICC_IA32_ASLDLINK_PATH = DEF(ICC_BIN32)\xilink.exe
+
+ DEBUG_ICC_IA32_CC_FLAGS = /nologo /c /WX /W4 /Gy /Gs32768 /D UNICODE /O1ib2 /GL /DEFI_FIRMWARE_VENDOR=L\"INTEL\" /FIAutoGen.h /EHs-c- /GF /Zi /Gm
+RELEASE_ICC_IA32_CC_FLAGS = /nologo /c /WX /W4 /Gy /Gs32768 /D UNICODE /O1ib2 /GL /DEFI_FIRMWARE_VENDOR=L\"INTEL\" /FIAutoGen.h /EHs-c- /GF
+ DEBUG_ICC_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Zd /Zi
+RELEASE_ICC_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Zd
+ *_ICC_IA32_SLINK_FLAGS = /nologo
+ DEBUG_ICC_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:I386 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
+RELEASE_ICC_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:I386 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.data=.text /MERGE:.rdata=.text
+
+##################
+# X64 definitions
+##################
+*_ICC_X64_CC_PATH = DEF(ICC_BINX64)\icl.exe
+*_ICC_X64_SLINK_PATH = DEF(ICC_BINX64)\xilib.exe
+# xilib.exe needs lib.exe from Visual Studio
+*_ICC_X64_SLINK_DLL = DEF(MS_VS_BIN)
+*_ICC_X64_DLINK_PATH = DEF(ICC_BINX64)\xilink.exe
+*_ICC_X64_PP_PATH = DEF(ICC_BINX64)\icl.exe
+*_ICC_X64_VFRPP_PATH = DEF(ICC_BINX64)\icl.exe
+*_ICC_X64_APP_PATH = DEF(ICC_BINX64)\icl.exe
+*_ICC_X64_ASM_PATH = DEF(WINDDK_BINX64)\ml64.exe
+*_ICC_X64_ASM_DLL = DEF(MS_VS_DLL)
+*_ICC_X64_ASLCC_PATH = DEF(ICC_BINX64)\icl.exe
+*_ICC_X64_ASLPP_PATH = DEF(ICC_BINX64)\icl.exe
+*_ICC_X64_ASLDLINK_PATH = DEF(ICC_BINX64)\xilink.exe
+
+ DEBUG_ICC_X64_CC_FLAGS = /nologo /c /WX /GS- /X /W4 /Gs32768 /D UNICODE /O1ib2s /GL /Gy /FI$(DEST_DIR_DEBUG)/AutoGen.h /Zi /Gm /EHs-c- /GF
+RELEASE_ICC_X64_CC_FLAGS = /nologo /c /WX /GS- /X /W4 /Gs32768 /D UNICODE /O1ib2s /GL /Gy /FI$(DEST_DIR_DEBUG)/AutoGen.h /EHs-c- /GF
+ DEBUG_ICC_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd /Zi
+RELEASE_ICC_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd
+ DEBUG_ICC_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:AMD64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:CONSOLE /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
+RELEASE_ICC_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:AMD64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:CONSOLE /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.data=.text /MERGE:.rdata=.text
+ *_ICC_X64_SLINK_FLAGS = /nologo /LTCG
+
+
+##################
+# IPF definitions
+##################
+*_ICC_IPF_CC_PATH = DEF(ICC_BIN64)\icl.exe
+# icl.exe needs cl.exe from Visual Studio
+*_ICC_IPF_CC_DLL = DEF(MS_VS_BIN)
+*_ICC_IPF_SLINK_PATH = DEF(ICC_BIN64)\xilib.exe
+# xilib.exe needs lib.exe from Visual Studio
+*_ICC_IPF_SLINK_DLL = DEF(MS_VS_BIN);DEF(MS_VS_DLL)
+*_ICC_IPF_DLINK_PATH = DEF(ICC_BIN64)\xilink.exe
+*_ICC_IPF_PP_PATH = DEF(ICC_BIN64)\icl.exe
+*_ICC_IPF_VFRPP_PATH = DEF(ICC_BIN64)\icl.exe
+*_ICC_IPF_APP_PATH = DEF(ICC_BIN64)\icl.exe
+*_ICC_IPF_ASM_PATH = DEF(ICC_BIN64)\ias.exe
+*_ICC_IPF_ASLCC_PATH = DEF(ICC_BIN64)\icl.exe
+*_ICC_IPF_ASLPP_PATH = DEF(ICC_BIN64)\icl.exe
+*_ICC_IPF_ASLDLINK_PATH = DEF(ICC_BIN64)\xilink.exe
+
+ DEBUG_ICC_IPF_CC_FLAGS = /nologo /c /WX /W4 /GX /Gy /Od /FI$(DEST_DIR_DEBUG)/AutoGen.h /QIA64_fr32 /GF /Zi
+RELEASE_ICC_IPF_CC_FLAGS = /nologo /c /WX /W4 /GX /Gy /Od /FI$(DEST_DIR_DEBUG)/AutoGen.h /QIA64_fr32 /GF
+ DEBUG_ICC_IPF_ASM_FLAGS = -N us -X explicit -M ilp64 -N so -W3 -d debug -F COFF32
+RELEASE_ICC_IPF_ASM_FLAGS = -N us -X explicit -M ilp64 -N so -W3 -F COFF32
+ DEBUG_ICC_IPF_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /LTCG /DLL /OPT:REF,ICF /IGNORE:4001 /MAP /ALIGN:64 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:IA64 /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MAP:$(DEST_DIR_DEBUG)/$(BASE_NAME).map /PDB:$(DEST_DIR_DEBUG)/$(BASE_NAME).pdb /DEBUG
+RELEASE_ICC_IPF_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /LTCG /DLL /OPT:REF,ICF /IGNORE:4001 /MAP /ALIGN:64 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:IA64 /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MAP:$(DEST_DIR_DEBUG)/$(BASE_NAME).map /PDB:$(DEST_DIR_DEBUG)/$(BASE_NAME).pdb
+ *_ICC_IPF_SLINK_FLAGS = /nologo
+
+##################
+# EBC definitions
+##################
+*_ICC_EBC_*_FAMILY = INTEL
+
+*_ICC_EBC_MAKE_PATH = DEF(MS_VS_BIN)\nmake.exe
+*_ICC_EBC_PP_PATH = DEF(EBC_BIN)\iec.exe
+*_ICC_EBC_VFRPP_PATH = DEF(EBC_BIN)\iec.exe
+*_ICC_EBC_CC_PATH = DEF(EBC_BIN)\iec.exe
+*_ICC_EBC_SLINK_PATH = DEF(EBC_BIN)\link.exe
+*_ICC_EBC_DLINK_PATH = DEF(EBC_BIN)\link.exe
+
+*_ICC_EBC_MAKE_FLAGS = /nologo
+*_ICC_EBC_PP_FLAGS = /nologo /E /TC /FIAutoGen.h
+*_ICC_EBC_CC_FLAGS = /nologo /c /WX /W3 /FIAutoGen.h /D$(MODULE_ENTRY_POINT)=$(ARCH_ENTRY_POINT)
+*_ICC_EBC_VFRPP_FLAGS = /nologo /E /TC /DVFRCOMPILE /FI$(MODULE_NAME)StrDefs.h
+*_ICC_EBC_SLINK_FLAGS = /lib /NOLOGO /MACHINE:EBC
+*_ICC_EBC_DLINK_FLAGS = "C:\Program Files\Intel\EBC\Lib\EbcLib.lib" /NOLOGO /NODEFAULTLIB /MACHINE:EBC /OPT:REF /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /MAP
+
+####################################################################################
+#
+# Intel(R) C++ Compiler Version 9.1
+#
+# IPF - Intel(R) C++ Compiler for Itanium(R)Version 9.1 Build 20060928 Package ID: W_CC_C_9.1.032
+# ASL - Microsoft ACPI Source Language Compiler
+#
+####################################################################################
+# ICCxASL - Intel C Compiler V9.1
+*_ICCxASL_*_*_FAMILY = INTEL
+
+*_ICCxASL_*_MAKE_PATH = DEF(MS_VS_BIN)\nmake.exe
+*_ICCxASL_*_RC_PATH = DEF(MS_VS_BIN)\rc.exe
+
+*_ICCxASL_*_MAKE_FLAGS = /nologo
+*_ICCxASL_*_VFRPP_FLAGS = /nologo /E /TC /DVFRCOMPILE /FI$(MODULE_NAME)StrDefs.h
+*_ICCxASL_*_APP_FLAGS = /nologo /E /TC
+*_ICCxASL_*_PP_FLAGS = /nologo /E /TC /FIAutoGen.h
+
+*_ICCxASL_*_ASM16_PATH = DEF(MS_VS_BIN)\ml.exe
+
+##################
+# ASL definitions
+##################
+*_ICCxASL_*_ASL_PATH = DEF(DEFAULT_WIN_ASL_BIN)
+*_ICCxASL_*_ASL_FLAGS = DEF(DEFAULT_WIN_ASL_FLAGS)
+*_ICCxASL_*_ASL_OUTFLAGS = DEF(DEFAULT_WIN_ASL_OUTFLAGS)
+*_ICCxASL_*_ASLCC_FLAGS = DEF(ICC_WIN_ASLCC_FLAGS)
+*_ICCxASL_*_ASLPP_FLAGS = DEF(ICC_WIN_ASLPP_FLAGS)
+*_ICCxASL_*_ASLDLINK_FLAGS = DEF(ICC_WIN_ASLDLINK_FLAGS)
+
+##################
+# IA32 definitions
+##################
+*_ICCxASL_IA32_CC_PATH = DEF(ICC_BIN32)\icl.exe
+*_ICCxASL_IA32_SLINK_PATH = DEF(ICC_BIN32)\xilib.exe
+# xilib.exe needs lib.exe from Visual Studio
+*_ICCxASL_IA32_SLINK_DLL = DEF(MS_VS_BIN)
+*_ICCxASL_IA32_DLINK_PATH = DEF(ICC_BIN32)\xilink.exe
+*_ICCxASL_IA32_PP_PATH = DEF(ICC_BIN32)\icl.exe
+*_ICCxASL_IA32_VFRPP_PATH = DEF(ICC_BIN32)\icl.exe
+*_ICCxASL_IA32_APP_PATH = DEF(ICC_BIN32)\icl.exe
+*_ICCxASL_IA32_ASM_PATH = DEF(MS_VS_BIN)\ml.exe
+*_ICCxASL_IA32_ASM_DLL = DEF(MS_VS_DLL)
+*_ICCxASL_IA32_ASLCC_PATH = DEF(ICC_BIN32)\icl.exe
+*_ICCxASL_IA32_ASLPP_PATH = DEF(ICC_BIN32)\icl.exe
+*_ICCxASL_IA32_ASLDLINK_PATH = DEF(ICC_BIN32)\xilink.exe
+
+ DEBUG_ICCxASL_IA32_CC_FLAGS = /nologo /c /WX /W4 /Gy /Gs32768 /D UNICODE /O1ib2 /GL /DEFI_FIRMWARE_VENDOR=L\"INTEL\" /FIAutoGen.h /EHs-c- /GF /Zi /Gm
+RELEASE_ICCxASL_IA32_CC_FLAGS = /nologo /c /WX /W4 /Gy /Gs32768 /D UNICODE /O1ib2 /GL /DEFI_FIRMWARE_VENDOR=L\"INTEL\" /FIAutoGen.h /EHs-c- /GF
+ DEBUG_ICCxASL_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Zd /Zi
+RELEASE_ICCxASL_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Zd
+ *_ICCxASL_IA32_SLINK_FLAGS = /nologo
+ DEBUG_ICCxASL_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:I386 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
+RELEASE_ICCxASL_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:I386 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.data=.text /MERGE:.rdata=.text
+
+##################
+# X64 definitions
+##################
+*_ICCxASL_X64_CC_PATH = DEF(ICC_BINX64)\icl.exe
+*_ICCxASL_X64_SLINK_PATH = DEF(ICC_BINX64)\xilib.exe
+# xilib.exe needs lib.exe from Visual Studio
+*_ICCxASL_X64_SLINK_DLL = DEF(MS_VS_BIN)
+*_ICCxASL_X64_DLINK_PATH = DEF(ICC_BINX64)\xilink.exe
+*_ICCxASL_X64_PP_PATH = DEF(ICC_BINX64)\icl.exe
+*_ICCxASL_X64_VFRPP_PATH = DEF(ICC_BINX64)\icl.exe
+*_ICCxASL_X64_APP_PATH = DEF(ICC_BINX64)\icl.exe
+*_ICCxASL_X64_ASM_PATH = DEF(WINDDK_BINX64)\ml64.exe
+*_ICCxASL_X64_ASM_DLL = DEF(MS_VS_DLL)
+*_ICCxASL_X64_ASLCC_PATH = DEF(ICC_BINX64)\icl.exe
+*_ICCxASL_X64_ASLPP_PATH = DEF(ICC_BINX64)\icl.exe
+*_ICCxASL_X64_ASLDLINK_PATH = DEF(ICC_BINX64)\xilink.exe
+
+ DEBUG_ICCxASL_X64_CC_FLAGS = /nologo /c /WX /GS- /X /W4 /Gs32768 /D UNICODE /O1ib2s /GL /Gy /FI$(DEST_DIR_DEBUG)/AutoGen.h /Zi /Gm /EHs-c- /GF
+RELEASE_ICCxASL_X64_CC_FLAGS = /nologo /c /WX /GS- /X /W4 /Gs32768 /D UNICODE /O1ib2s /GL /Gy /FI$(DEST_DIR_DEBUG)/AutoGen.h /EHs-c- /GF
+ DEBUG_ICCxASL_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd /Zi
+RELEASE_ICCxASL_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd
+ DEBUG_ICCxASL_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:AMD64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:CONSOLE /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
+RELEASE_ICCxASL_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:AMD64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:CONSOLE /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.data=.text /MERGE:.rdata=.text
+ *_ICCxASL_X64_SLINK_FLAGS = /nologo /LTCG
+
+
+##################
+# IPF definitions
+##################
+*_ICCxASL_IPF_CC_PATH = DEF(ICC_BIN64)\icl.exe
+# icl.exe needs cl.exe from Visual Studio
+*_ICCxASL_IPF_CC_DLL = DEF(MS_VS_BIN)
+*_ICCxASL_IPF_SLINK_PATH = DEF(ICC_BIN64)\xilib.exe
+# xilib.exe needs lib.exe from Visual Studio
+*_ICCxASL_IPF_SLINK_DLL = DEF(MS_VS_BIN);DEF(MS_VS_DLL)
+*_ICCxASL_IPF_DLINK_PATH = DEF(ICC_BIN64)\xilink.exe
+*_ICCxASL_IPF_PP_PATH = DEF(ICC_BIN64)\icl.exe
+*_ICCxASL_IPF_VFRPP_PATH = DEF(ICC_BIN64)\icl.exe
+*_ICCxASL_IPF_APP_PATH = DEF(ICC_BIN64)\icl.exe
+*_ICCxASL_IPF_ASM_PATH = DEF(ICC_BIN64)\ias.exe
+*_ICCxASL_IPF_ASLCC_PATH = DEF(ICC_BIN64)\icl.exe
+*_ICCxASL_IPF_ASLPP_PATH = DEF(ICC_BIN64)\icl.exe
+*_ICCxASL_IPF_ASLDLINK_PATH = DEF(ICC_BIN64)\xilink.exe
+
+ DEBUG_ICCxASL_IPF_CC_FLAGS = /nologo /c /WX /W4 /GX /Gy /Od /FI$(DEST_DIR_DEBUG)/AutoGen.h /QIA64_fr32 /GF /Zi
+RELEASE_ICCxASL_IPF_CC_FLAGS = /nologo /c /WX /W4 /GX /Gy /Od /FI$(DEST_DIR_DEBUG)/AutoGen.h /QIA64_fr32 /GF
+ DEBUG_ICCxASL_IPF_ASM_FLAGS = -N us -X explicit -M ilp64 -N so -W3 -d debug -F COFF32
+RELEASE_ICCxASL_IPF_ASM_FLAGS = -N us -X explicit -M ilp64 -N so -W3 -F COFF32
+ DEBUG_ICCxASL_IPF_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /LTCG /DLL /OPT:REF,ICF /IGNORE:4001 /MAP /ALIGN:64 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:IA64 /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MAP:$(DEST_DIR_DEBUG)/$(BASE_NAME).map /PDB:$(DEST_DIR_DEBUG)/$(BASE_NAME).pdb /DEBUG
+RELEASE_ICCxASL_IPF_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /LTCG /DLL /OPT:REF,ICF /IGNORE:4001 /MAP /ALIGN:64 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:IA64 /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MAP:$(DEST_DIR_DEBUG)/$(BASE_NAME).map /PDB:$(DEST_DIR_DEBUG)/$(BASE_NAME).pdb
+ *_ICCxASL_IPF_SLINK_FLAGS = /nologo
+
+##################
+# EBC definitions
+##################
+*_ICCxASL_EBC_*_FAMILY = INTEL
+
+*_ICCxASL_EBC_MAKE_PATH = DEF(MS_VS_BIN)\nmake.exe
+*_ICCxASL_EBC_PP_PATH = DEF(EBC_BIN)\iec.exe
+*_ICCxASL_EBC_VFRPP_PATH = DEF(EBC_BIN)\iec.exe
+*_ICCxASL_EBC_CC_PATH = DEF(EBC_BIN)\iec.exe
+*_ICCxASL_EBC_SLINK_PATH = DEF(EBC_BIN)\link.exe
+*_ICCxASL_EBC_DLINK_PATH = DEF(EBC_BIN)\link.exe
+
+*_ICCxASL_EBC_MAKE_FLAGS = /nologo
+*_ICCxASL_EBC_PP_FLAGS = /nologo /E /TC /FIAutoGen.h
+*_ICCxASL_EBC_CC_FLAGS = /nologo /c /WX /W3 /FIAutoGen.h /D$(MODULE_ENTRY_POINT)=$(ARCH_ENTRY_POINT)
+*_ICCxASL_EBC_VFRPP_FLAGS = /nologo /E /TC /DVFRCOMPILE /FI$(MODULE_NAME)StrDefs.h
+*_ICCxASL_EBC_SLINK_FLAGS = /lib /NOLOGO /MACHINE:EBC
+*_ICCxASL_EBC_DLINK_FLAGS = "C:\Program Files\Intel\EBC\Lib\EbcLib.lib" /NOLOGO /NODEFAULTLIB /MACHINE:EBC /OPT:REF /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /MAP
+
+
+####################################################################################
+#
+# Intel(R) C++ Compiler Version 9.1 x86 (32-bit on 64-bit OS)
+#
+# ICCx86 - Intel(R) C++ Compiler for Itanium(R)Version 9.1 Build 20060928 Package ID: W_CC_C_9.1.032
+# ASL - Intel ACPI Source Language Compiler
+#
+####################################################################################
+# ICCx86 - Intel C Compiler V9.1
+*_ICCx86_*_*_FAMILY = INTEL
+
+*_ICCx86_*_MAKE_PATH = DEF(VS2005x86_BIN)\nmake.exe
+*_ICCx86_*_RC_PATH = DEF(VS2005x86_BIN)\rc.exe
+
+*_ICCx86_*_MAKE_FLAGS = /nologo
+*_ICCx86_*_VFRPP_FLAGS = /nologo /E /TC /DVFRCOMPILE /FI$(MODULE_NAME)StrDefs.h
+*_ICCx86_*_APP_FLAGS = /nologo /E /TC
+*_ICCx86_*_PP_FLAGS = /nologo /E /TC /FIAutoGen.h
+
+*_ICCx86_*_ASM16_PATH = DEF(VS2005x86_BIN)\ml.exe
+
+##################
+# ASL definitions
+##################
+*_ICCx86_*_ASL_PATH = DEF(DEFAULT_WIN_ASL_BIN)
+*_ICCx86_*_ASL_FLAGS = DEF(DEFAULT_WIN_ASL_FLAGS)
+*_ICCx86_*_ASL_OUTFLAGS = DEF(DEFAULT_WIN_ASL_OUTFLAGS)
+*_ICCx86_*_ASLCC_FLAGS = DEF(ICC_WIN_ASLCC_FLAGS)
+*_ICCx86_*_ASLPP_FLAGS = DEF(ICC_WIN_ASLPP_FLAGS)
+*_ICCx86_*_ASLDLINK_FLAGS = DEF(ICC_WIN_ASLDLINK_FLAGS)
+
+##################
+# IA32 definitions
+##################
+*_ICCx86_IA32_CC_PATH = DEF(ICC_BIN32x86)\icl.exe
+*_ICCx86_IA32_SLINK_PATH = DEF(ICC_BIN32x86)\xilib.exe
+# xilib.exe needs lib.exe from Visual Studio
+*_ICCx86_IA32_SLINK_DLL = DEF(VS2005x86_BIN)
+*_ICCx86_IA32_DLINK_PATH = DEF(ICC_BIN32x86)\xilink.exe
+*_ICCx86_IA32_PP_PATH = DEF(ICC_BIN32x86)\icl.exe
+*_ICCx86_IA32_VFRPP_PATH = DEF(ICC_BIN32x86)\icl.exe
+*_ICCx86_IA32_APP_PATH = DEF(ICC_BIN32x86)\icl.exe
+*_ICCx86_IA32_ASM_PATH = DEF(VS2005x86_BIN)\ml.exe
+*_ICCx86_IA32_ASM_DLL = DEF(VS2005x86_DLL)
+*_ICCx86_IA32_ASLCC_PATH = DEF(ICC_BIN32x86)\icl.exe
+*_ICCx86_IA32_ASLPP_PATH = DEF(ICC_BIN32x86)\icl.exe
+*_ICCx86_IA32_ASLDLINK_PATH = DEF(ICC_BIN32x86)\xilink.exe
+
+ DEBUG_ICCx86_IA32_CC_FLAGS = /nologo /c /WX /W4 /Gy /Gs32768 /D UNICODE /O1ib2 /GL /DEFI_FIRMWARE_VENDOR=L\"INTEL\" /FIAutoGen.h /EHs-c- /GF /Zi /Gm
+RELEASE_ICCx86_IA32_CC_FLAGS = /nologo /c /WX /W4 /Gy /Gs32768 /D UNICODE /O1ib2 /GL /DEFI_FIRMWARE_VENDOR=L\"INTEL\" /FIAutoGen.h /EHs-c- /GF
+ DEBUG_ICCx86_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Zd /Zi
+RELEASE_ICCx86_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Zd
+ *_ICCx86_IA32_SLINK_FLAGS = /nologo
+ DEBUG_ICCx86_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:I386 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
+RELEASE_ICCx86_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:I386 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.data=.text /MERGE:.rdata=.text
+
+##################
+# X64 definitions
+##################
+*_ICCx86_X64_CC_PATH = DEF(ICC_BINX64x86)\icl.exe
+*_ICCx86_X64_SLINK_PATH = DEF(ICC_BINX64x86)\xilib.exe
+# xilib.exe needs lib.exe from Visual Studio
+*_ICCx86_X64_SLINK_DLL = DEF(VS2005x86_BIN)
+*_ICCx86_X64_DLINK_PATH = DEF(ICC_BINX64x86)\xilink.exe
+*_ICCx86_X64_PP_PATH = DEF(ICC_BINX64x86)\icl.exe
+*_ICCx86_X64_VFRPP_PATH = DEF(ICC_BINX64x86)\icl.exe
+*_ICCx86_X64_APP_PATH = DEF(ICC_BINX64x86)\icl.exe
+*_ICCx86_X64_ASM_PATH = DEF(WINDDK_BINX64)\ml64.exe
+*_ICCx86_X64_ASM_DLL = DEF(VS2005x86_DLL)
+*_ICCx86_X64_ASLCC_PATH = DEF(ICC_BINX64x86)\icl.exe
+*_ICCx86_X64_ASLPP_PATH = DEF(ICC_BINX64x86)\icl.exe
+*_ICCx86_X64_ASLDLINK_PATH = DEF(ICC_BINX64x86)\xilink.exe
+
+ DEBUG_ICCx86_X64_CC_FLAGS = /nologo /c /WX /GS- /X /W4 /Gs32768 /D UNICODE /O1ib2s /GL /Gy /FI$(DEST_DIR_DEBUG)/AutoGen.h /Zi /Gm /EHs-c- /GF
+RELEASE_ICCx86_X64_CC_FLAGS = /nologo /c /WX /GS- /X /W4 /Gs32768 /D UNICODE /O1ib2s /GL /Gy /FI$(DEST_DIR_DEBUG)/AutoGen.h /EHs-c- /GF
+ DEBUG_ICCx86_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd /Zi
+RELEASE_ICCx86_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd
+ DEBUG_ICCx86_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:AMD64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:CONSOLE /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
+RELEASE_ICCx86_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:AMD64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:CONSOLE /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.data=.text /MERGE:.rdata=.text
+ *_ICCx86_X64_SLINK_FLAGS = /nologo /LTCG
+
+
+##################
+# IPF definitions
+##################
+*_ICCx86_IPF_CC_PATH = DEF(ICC_BIN64x86)\icl.exe
+# icl.exe needs cl.exe from Visual Studio
+*_ICCx86_IPF_CC_DLL = DEF(VS2005x86_BIN)
+*_ICCx86_IPF_SLINK_PATH = DEF(ICC_BIN64x86)\xilib.exe
+# xilib.exe needs lib.exe from Visual Studio
+*_ICCx86_IPF_SLINK_DLL = DEF(VS2005x86_BIN);DEF(VS2005x86_DLL)
+*_ICCx86_IPF_DLINK_PATH = DEF(ICC_BIN64x86)\xilink.exe
+*_ICCx86_IPF_PP_PATH = DEF(ICC_BIN64x86)\icl.exe
+*_ICCx86_IPF_VFRPP_PATH = DEF(ICC_BIN64x86)\icl.exe
+*_ICCx86_IPF_APP_PATH = DEF(ICC_BIN64x86)\icl.exe
+*_ICCx86_IPF_ASM_PATH = DEF(ICC_BIN64x86)\ias.exe
+*_ICCx86_IPF_ASLCC_PATH = DEF(ICC_BIN64x86)\icl.exe
+*_ICCx86_IPF_ASLPP_PATH = DEF(ICC_BIN64x86)\icl.exe
+*_ICCx86_IPF_ASLDLINK_PATH = DEF(ICC_BIN64x86)\xilink.exe
+
+ DEBUG_ICCx86_IPF_CC_FLAGS = /nologo /c /WX /W4 /GX /Gy /Od /FI$(DEST_DIR_DEBUG)/AutoGen.h /QIA64_fr32 /GF /Zi
+RELEASE_ICCx86_IPF_CC_FLAGS = /nologo /c /WX /W4 /GX /Gy /Od /FI$(DEST_DIR_DEBUG)/AutoGen.h /QIA64_fr32 /GF
+ DEBUG_ICCx86_IPF_ASM_FLAGS = -N us -X explicit -M ilp64 -N so -W3 -d debug -F COFF32
+RELEASE_ICCx86_IPF_ASM_FLAGS = -N us -X explicit -M ilp64 -N so -W3 -F COFF32
+ DEBUG_ICCx86_IPF_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /LTCG /DLL /OPT:REF,ICF /IGNORE:4001 /MAP /ALIGN:64 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:IA64 /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MAP:$(DEST_DIR_DEBUG)/$(BASE_NAME).map /PDB:$(DEST_DIR_DEBUG)/$(BASE_NAME).pdb /DEBUG
+RELEASE_ICCx86_IPF_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /LTCG /DLL /OPT:REF,ICF /IGNORE:4001 /MAP /ALIGN:64 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:IA64 /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MAP:$(DEST_DIR_DEBUG)/$(BASE_NAME).map /PDB:$(DEST_DIR_DEBUG)/$(BASE_NAME).pdb
+ *_ICCx86_IPF_SLINK_FLAGS = /nologo
+
+##################
+# EBC definitions
+##################
+*_ICCx86_EBC_*_FAMILY = INTEL
+
+*_ICCx86_EBC_MAKE_PATH = DEF(VS2005x86_BIN)\nmake.exe
+*_ICCx86_EBC_PP_PATH = DEF(EBC_BINx86)\iec.exe
+*_ICCx86_EBC_VFRPP_PATH = DEF(EBC_BINx86)\iec.exe
+*_ICCx86_EBC_CC_PATH = DEF(EBC_BINx86)\iec.exe
+*_ICCx86_EBC_SLINK_PATH = DEF(EBC_BINx86)\link.exe
+*_ICCx86_EBC_DLINK_PATH = DEF(EBC_BINx86)\link.exe
+
+*_ICCx86_EBC_MAKE_FLAGS = /nologo
+*_ICCx86_EBC_PP_FLAGS = /nologo /E /TC /FIAutoGen.h
+*_ICCx86_EBC_CC_FLAGS = /nologo /c /WX /W3 /FIAutoGen.h /D$(MODULE_ENTRY_POINT)=$(ARCH_ENTRY_POINT)
+*_ICCx86_EBC_VFRPP_FLAGS = /nologo /E /TC /DVFRCOMPILE /FI$(MODULE_NAME)StrDefs.h
+*_ICCx86_EBC_SLINK_FLAGS = /lib /NOLOGO /MACHINE:EBC
+*_ICCx86_EBC_DLINK_FLAGS = "C:\Program Files (x86)\Intel\EBC\Lib\EbcLib.lib" /NOLOGO /NODEFAULTLIB /MACHINE:EBC /OPT:REF /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /MAP
+
+
+####################################################################################
+#
+# Intel(R) C++ Compiler Version 9.1 x86 (32-bit on 64-bit OS)
+#
+# ICCx86xASL - Intel(R) C++ Compiler for Itanium(R)Version 9.1 Build 20060928 Package ID: W_CC_C_9.1.032
+# ASL - Microsoft ACPI Source Language Compiler
+#
+####################################################################################
+# ICCx86xASL - Intel C Compiler V9.1
+*_ICCx86xASL_*_*_FAMILY = INTEL
+
+*_ICCx86xASL_*_MAKE_PATH = DEF(VS2005x86_BIN)\nmake.exe
+*_ICCx86xASL_*_RC_PATH = DEF(VS2005x86_BIN)\rc.exe
+
+*_ICCx86xASL_*_MAKE_FLAGS = /nologo
+*_ICCx86xASL_*_VFRPP_FLAGS = /nologo /E /TC /DVFRCOMPILE /FI$(MODULE_NAME)StrDefs.h
+*_ICCx86xASL_*_APP_FLAGS = /nologo /E /TC
+*_ICCx86xASL_*_PP_FLAGS = /nologo /E /TC /FIAutoGen.h
+
+*_ICCx86ASL_*_ASM16_PATH = DEF(VS2005x86_BIN)\ml.exe
+
+##################
+# ASL definitions
+##################
+*_ICCx86xASL_*_ASL_PATH = DEF(WIN_ASL_BIN)
+*_ICCx86xASL_*_ASL_FLAGS =
+*_ICCx86xASL_*_ASL_OUTFLAGS = DEF(MS_ASL_OUTFLAGS)
+*_ICCx86xASL_*_ASLCC_FLAGS = DEF(ICC_WIN_ASLCC_FLAGS)
+*_ICCx86xASL_*_ASLPP_FLAGS = DEF(ICC_WIN_ASLPP_FLAGS)
+*_ICCx86xASL_*_ASLDLINK_FLAGS = DEF(ICC_WIN_ASLDLINK_FLAGS)
+
+##################
+# IA32 definitions
+##################
+*_ICCx86xASL_IA32_CC_PATH = DEF(ICC_BIN32x86)\icl.exe
+*_ICCx86xASL_IA32_SLINK_PATH = DEF(ICC_BIN32x86)\xilib.exe
+# xilib.exe needs lib.exe from Visual Studio
+*_ICCx86xASL_IA32_SLINK_DLL = DEF(VS2005x86_BIN)
+*_ICCx86xASL_IA32_DLINK_PATH = DEF(ICC_BIN32x86)\xilink.exe
+*_ICCx86xASL_IA32_PP_PATH = DEF(ICC_BIN32x86)\icl.exe
+*_ICCx86xASL_IA32_VFRPP_PATH = DEF(ICC_BIN32x86)\icl.exe
+*_ICCx86xASL_IA32_APP_PATH = DEF(ICC_BIN32x86)\icl.exe
+*_ICCx86xASL_IA32_ASM_PATH = DEF(VS2005x86_BIN)\ml.exe
+*_ICCx86xASL_IA32_ASM_DLL = DEF(VS2005x86_DLL)
+*_ICCx86xASL_IA32_ASLCC_PATH = DEF(ICC_BIN32x86)\icl.exe
+*_ICCx86xASL_IA32_ASLPP_PATH = DEF(ICC_BIN32x86)\icl.exe
+*_ICCx86xASL_IA32_ASLDLINK_PATH = DEF(ICC_BIN32x86)\xilink.exe
+
+ DEBUG_ICCx86xASL_IA32_CC_FLAGS = /nologo /c /WX /W4 /Gy /Gs32768 /D UNICODE /O1ib2 /GL /DEFI_FIRMWARE_VENDOR=L\"INTEL\" /FIAutoGen.h /EHs-c- /GF /Zi /Gm
+RELEASE_ICCx86xASL_IA32_CC_FLAGS = /nologo /c /WX /W4 /Gy /Gs32768 /D UNICODE /O1ib2 /GL /DEFI_FIRMWARE_VENDOR=L\"INTEL\" /FIAutoGen.h /EHs-c- /GF
+ DEBUG_ICCx86xASL_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Zd /Zi
+RELEASE_ICCx86xASL_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Zd
+ *_ICCx86xASL_IA32_SLINK_FLAGS = /nologo
+ DEBUG_ICCx86xASL_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:I386 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
+RELEASE_ICCx86xASL_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:I386 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.data=.text /MERGE:.rdata=.text
+
+##################
+# X64 definitions
+##################
+*_ICCx86xASL_X64_CC_PATH = DEF(ICC_BINX64x86)\icl.exe
+*_ICCx86xASL_X64_SLINK_PATH = DEF(ICC_BINX64x86)\xilib.exe
+# xilib.exe needs lib.exe from Visual Studio
+*_ICCx86xASL_X64_SLINK_DLL = DEF(VS2005x86_BIN)
+*_ICCx86xASL_X64_DLINK_PATH = DEF(ICC_BINX64x86)\xilink.exe
+*_ICCx86xASL_X64_PP_PATH = DEF(ICC_BINX64x86)\icl.exe
+*_ICCx86xASL_X64_VFRPP_PATH = DEF(ICC_BINX64x86)\icl.exe
+*_ICCx86xASL_X64_APP_PATH = DEF(ICC_BINX64x86)\icl.exe
+*_ICCx86xASL_X64_ASM_PATH = DEF(WINDDK_BINX64)\ml64.exe
+*_ICCx86xASL_X64_ASM_DLL = DEF(VS2005x86_DLL)
+*_ICCx86xASL_X64_ASLCC_PATH = DEF(ICC_BINX64x86)\icl.exe
+*_ICCx86xASL_X64_ASLPP_PATH = DEF(ICC_BINX64x86)\icl.exe
+*_ICCx86xASL_X64_ASLDLINK_PATH = DEF(ICC_BINX64x86)\xilink.exe
+
+ DEBUG_ICCx86xASL_X64_CC_FLAGS = /nologo /c /WX /GS- /X /W4 /Gs32768 /D UNICODE /O1ib2s /GL /Gy /FI$(DEST_DIR_DEBUG)/AutoGen.h /Zi /Gm /EHs-c- /GF
+RELEASE_ICCx86xASL_X64_CC_FLAGS = /nologo /c /WX /GS- /X /W4 /Gs32768 /D UNICODE /O1ib2s /GL /Gy /FI$(DEST_DIR_DEBUG)/AutoGen.h /EHs-c- /GF
+ DEBUG_ICCx86xASL_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd /Zi
+RELEASE_ICCx86xASL_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd
+ DEBUG_ICCx86xASL_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:AMD64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:CONSOLE /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
+RELEASE_ICCx86xASL_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:AMD64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:CONSOLE /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.data=.text /MERGE:.rdata=.text
+ *_ICCx86xASL_X64_SLINK_FLAGS = /nologo /LTCG
+
+
+##################
+# IPF definitions
+##################
+*_ICCx86xASL_IPF_CC_PATH = DEF(ICC_BIN64x86)\icl.exe
+# icl.exe needs cl.exe from Visual Studio
+*_ICCx86xASL_IPF_CC_DLL = DEF(VS2005x86_BIN)
+*_ICCx86xASL_IPF_SLINK_PATH = DEF(ICC_BIN64x86)\xilib.exe
+# xilib.exe needs lib.exe from Visual Studio
+*_ICCx86xASL_IPF_SLINK_DLL = DEF(VS2005x86_BIN);DEF(VS2005x86_DLL)
+*_ICCx86xASL_IPF_DLINK_PATH = DEF(ICC_BIN64x86)\xilink.exe
+*_ICCx86xASL_IPF_PP_PATH = DEF(ICC_BIN64x86)\icl.exe
+*_ICCx86xASL_IPF_VFRPP_PATH = DEF(ICC_BIN64x86)\icl.exe
+*_ICCx86xASL_IPF_APP_PATH = DEF(ICC_BIN64x86)\icl.exe
+*_ICCx86xASL_IPF_ASM_PATH = DEF(ICC_BIN64x86)\ias.exe
+*_ICCx86xASL_IPF_ASLCC_PATH = DEF(ICC_BIN64x86)\icl.exe
+*_ICCx86xASL_IPF_ASLPP_PATH = DEF(ICC_BIN64x86)\icl.exe
+*_ICCx86xASL_IPF_ASLDLINK_PATH = DEF(ICC_BIN64x86)\xilink.exe
+
+ DEBUG_ICCx86xASL_IPF_CC_FLAGS = /nologo /c /WX /W4 /GX /Gy /Od /FI$(DEST_DIR_DEBUG)/AutoGen.h /QIA64_fr32 /GF /Zi
+RELEASE_ICCx86xASL_IPF_CC_FLAGS = /nologo /c /WX /W4 /GX /Gy /Od /FI$(DEST_DIR_DEBUG)/AutoGen.h /QIA64_fr32 /GF
+ DEBUG_ICCx86xASL_IPF_ASM_FLAGS = -N us -X explicit -M ilp64 -N so -W3 -d debug -F COFF32
+RELEASE_ICCx86xASL_IPF_ASM_FLAGS = -N us -X explicit -M ilp64 -N so -W3 -F COFF32
+ DEBUG_ICCx86xASL_IPF_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /LTCG /DLL /OPT:REF,ICF /IGNORE:4001 /MAP /ALIGN:64 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:IA64 /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MAP:$(DEST_DIR_DEBUG)/$(BASE_NAME).map /PDB:$(DEST_DIR_DEBUG)/$(BASE_NAME).pdb /DEBUG
+RELEASE_ICCx86xASL_IPF_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /LTCG /DLL /OPT:REF,ICF /IGNORE:4001 /MAP /ALIGN:64 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:IA64 /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MAP:$(DEST_DIR_DEBUG)/$(BASE_NAME).map /PDB:$(DEST_DIR_DEBUG)/$(BASE_NAME).pdb
+ *_ICCx86xASL_IPF_SLINK_FLAGS = /nologo
+
+##################
+# EBC definitions
+##################
+*_ICCx86xASL_EBC_*_FAMILY = INTEL
+
+*_ICCx86xASL_EBC_MAKE_PATH = DEF(VS2005x86_BIN)\nmake.exe
+*_ICCx86xASL_EBC_PP_PATH = DEF(EBC_BINx86)\iec.exe
+*_ICCx86xASL_EBC_VFRPP_PATH = DEF(EBC_BINx86)\iec.exe
+*_ICCx86xASL_EBC_CC_PATH = DEF(EBC_BINx86)\iec.exe
+*_ICCx86xASL_EBC_SLINK_PATH = DEF(EBC_BINx86)\link.exe
+*_ICCx86xASL_EBC_DLINK_PATH = DEF(EBC_BINx86)\link.exe
+
+*_ICCx86xASL_EBC_MAKE_FLAGS = /nologo
+*_ICCx86xASL_EBC_PP_FLAGS = /nologo /E /TC /FIAutoGen.h
+*_ICCx86xASL_EBC_CC_FLAGS = /nologo /c /WX /W3 /FIAutoGen.h /D$(MODULE_ENTRY_POINT)=$(ARCH_ENTRY_POINT)
+*_ICCx86xASL_EBC_VFRPP_FLAGS = /nologo /E /TC /DVFRCOMPILE /FI$(MODULE_NAME)StrDefs.h
+*_ICCx86xASL_EBC_SLINK_FLAGS = /lib /NOLOGO /MACHINE:EBC
+*_ICCx86xASL_EBC_DLINK_FLAGS = "C:\Program Files (x86)\Intel\EBC\Lib\EbcLib.lib" /NOLOGO /NODEFAULTLIB /MACHINE:EBC /OPT:REF /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /MAP
+
+
+####################################################################################
+#
+# Intel(R) C++ Compiler Version 11.1
+# IA32 - Intel(R) C++ Compiler for applications running on IA32 (Version 11.1 Build 065 Package ID: w_cproc_p_11.1.065_ia32)
+# X64 - Intel(R) C++ Compiler for applications running on Intel(R) 64 (Version 11.1 Build 065 Package ID: w_cproc_p_11.1.065_intel64)
+# IPF - Intel(R) C++ Compiler for applications running on IA-64 (Version 11.1 Build 065 Package ID: w_cproc_p_11.1.065_ia64)
+# ASL - Intel ACPI Source Language Compiler
+#
+####################################################################################
+# ICC11 - Intel C Compiler V11.1
+*_ICC11_*_*_FAMILY = INTEL
+
+*_ICC11_*_MAKE_PATH = DEF(MS_VS_BIN)\nmake.exe
+*_ICC11_*_RC_PATH = DEF(MS_VS_BIN)\rc.exe
+
+*_ICC11_*_MAKE_FLAGS = /nologo
+*_ICC11_*_VFRPP_FLAGS = /nologo /E /TC /DVFRCOMPILE /FI$(MODULE_NAME)StrDefs.h
+*_ICC11_*_APP_FLAGS = /nologo /E /TC
+*_ICC11_*_PP_FLAGS = /nologo /E /TC /FIAutoGen.h
+
+*_ICC11_*_ASM16_PATH = DEF(MS_VS_BIN)\ml.exe
+
+##################
+# ASL definitions
+##################
+*_ICC11_*_ASL_PATH = DEF(DEFAULT_WIN_ASL_BIN)
+*_ICC11_*_ASL_FLAGS = DEF(DEFAULT_WIN_ASL_FLAGS)
+*_ICC11_*_ASL_OUTFLAGS = DEF(DEFAULT_WIN_ASL_OUTFLAGS)
+*_ICC11_*_ASLCC_FLAGS = DEF(ICC_WIN_ASLCC_FLAGS)
+*_ICC11_*_ASLPP_FLAGS = DEF(ICC_WIN_ASLPP_FLAGS)
+*_ICC11_*_ASLDLINK_FLAGS = DEF(ICC_WIN_ASLDLINK_FLAGS)
+
+##################
+# IA32 definitions
+##################
+*_ICC11_IA32_CC_PATH = DEF(ICC11_BIN32)\icl.exe
+*_ICC11_IA32_SLINK_PATH = DEF(ICC11_BIN32)\xilib.exe
+# xilib.exe needs lib.exe from Visual Studio
+*_ICC11_IA32_SLINK_DLL = DEF(MS_VS_BIN)
+*_ICC11_IA32_DLINK_PATH = DEF(ICC11_BIN32)\xilink.exe
+*_ICC11_IA32_PP_PATH = DEF(ICC11_BIN32)\icl.exe
+*_ICC11_IA32_VFRPP_PATH = DEF(ICC11_BIN32)\icl.exe
+*_ICC11_IA32_APP_PATH = DEF(ICC11_BIN32)\icl.exe
+*_ICC11_IA32_ASM_PATH = DEF(MS_VS_BIN)\ml.exe
+*_ICC11_IA32_ASM_DLL = DEF(MS_VS_DLL)
+*_ICC11_IA32_ASLCC_PATH = DEF(ICC11_BIN32)\icl.exe
+*_ICC11_IA32_ASLPP_PATH = DEF(ICC11_BIN32)\icl.exe
+*_ICC11_IA32_ASLDLINK_PATH = DEF(ICC11_BIN32)\xilink.exe
+
+ DEBUG_ICC11_IA32_CC_FLAGS = /nologo /c /WX /W4 /Gy /Gs32768 /D UNICODE /O1ib2 /GL /DEFI_FIRMWARE_VENDOR=L\"INTEL\" /FIAutoGen.h /EHs-c- /GF /Zi /Gm
+RELEASE_ICC11_IA32_CC_FLAGS = /nologo /c /WX /W4 /Gy /Gs32768 /D UNICODE /O1ib2 /GL /DEFI_FIRMWARE_VENDOR=L\"INTEL\" /FIAutoGen.h /EHs-c- /GF
+ DEBUG_ICC11_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Zd /Zi
+RELEASE_ICC11_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Zd
+ *_ICC11_IA32_SLINK_FLAGS = /nologo
+ DEBUG_ICC11_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:I386 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
+RELEASE_ICC11_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:I386 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.data=.text /MERGE:.rdata=.text
+
+##################
+# X64 definitions
+##################
+*_ICC11_X64_CC_PATH = DEF(ICC11_BINX64)\icl.exe
+*_ICC11_X64_SLINK_PATH = DEF(ICC11_BINX64)\xilib.exe
+# xilib.exe needs lib.exe from Visual Studio
+*_ICC11_X64_SLINK_DLL = DEF(MS_VS_BIN)
+*_ICC11_X64_DLINK_PATH = DEF(ICC11_BINX64)\xilink.exe
+*_ICC11_X64_PP_PATH = DEF(ICC11_BINX64)\icl.exe
+*_ICC11_X64_VFRPP_PATH = DEF(ICC11_BINX64)\icl.exe
+*_ICC11_X64_APP_PATH = DEF(ICC11_BINX64)\icl.exe
+*_ICC11_X64_ASM_PATH = DEF(WINDDK_BINX64)\ml64.exe
+*_ICC11_X64_ASM_DLL = DEF(MS_VS_DLL)
+*_ICC11_X64_ASLCC_PATH = DEF(ICC11_BINX64)\icl.exe
+*_ICC11_X64_ASLPP_PATH = DEF(ICC11_BINX64)\icl.exe
+*_ICC11_X64_ASLDLINK_PATH = DEF(ICC11_BINX64)\xilink.exe
+
+ DEBUG_ICC11_X64_CC_FLAGS = /nologo /c /WX /GS- /X /W4 /Gs32768 /D UNICODE /O1ib2s /GL /Gy /FI$(DEST_DIR_DEBUG)/AutoGen.h /Zi /Gm /EHs-c- /GF
+RELEASE_ICC11_X64_CC_FLAGS = /nologo /c /WX /GS- /X /W4 /Gs32768 /D UNICODE /O1ib2s /GL /Gy /FI$(DEST_DIR_DEBUG)/AutoGen.h /EHs-c- /GF
+ DEBUG_ICC11_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd /Zi
+RELEASE_ICC11_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd
+ DEBUG_ICC11_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:AMD64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:CONSOLE /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
+RELEASE_ICC11_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:AMD64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:CONSOLE /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.data=.text /MERGE:.rdata=.text
+ *_ICC11_X64_SLINK_FLAGS = /nologo /LTCG
+
+
+##################
+# IPF definitions
+##################
+*_ICC11_IPF_CC_PATH = DEF(ICC11_BIN64)\icl.exe
+# icl.exe needs cl.exe from Visual Studio
+*_ICC11_IPF_CC_DLL = DEF(MS_VS_BIN)
+*_ICC11_IPF_SLINK_PATH = DEF(ICC11_BIN64)\xilib.exe
+# xilib.exe needs lib.exe from Visual Studio
+*_ICC11_IPF_SLINK_DLL = DEF(MS_VS_BIN);DEF(MS_VS_DLL)
+*_ICC11_IPF_DLINK_PATH = DEF(ICC11_BIN64)\xilink.exe
+*_ICC11_IPF_PP_PATH = DEF(ICC11_BIN64)\icl.exe
+*_ICC11_IPF_VFRPP_PATH = DEF(ICC11_BIN64)\icl.exe
+*_ICC11_IPF_APP_PATH = DEF(ICC11_BIN64)\icl.exe
+*_ICC11_IPF_ASM_PATH = DEF(ICC11_BIN64)\ias.exe
+*_ICC11_IPF_ASLCC_PATH = DEF(ICC11_BIN64)\icl.exe
+*_ICC11_IPF_ASLPP_PATH = DEF(ICC11_BIN64)\icl.exe
+*_ICC11_IPF_ASLDLINK_PATH = DEF(ICC11_BIN64)\xilink.exe
+
+ DEBUG_ICC11_IPF_CC_FLAGS = /nologo /c /WX /W4 /GX /Gy /Od /FI$(DEST_DIR_DEBUG)/AutoGen.h /QIA64_fr32 /GF /Qfreestanding /Zi
+RELEASE_ICC11_IPF_CC_FLAGS = /nologo /c /WX /W4 /GX /Gy /Od /FI$(DEST_DIR_DEBUG)/AutoGen.h /QIA64_fr32 /GF /Qfreestanding
+ DEBUG_ICC11_IPF_ASM_FLAGS = -N us -X explicit -M ilp64 -N so -W3 -d debug -F COFF32
+RELEASE_ICC11_IPF_ASM_FLAGS = -N us -X explicit -M ilp64 -N so -W3 -F COFF32
+ DEBUG_ICC11_IPF_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /LTCG /DLL /OPT:REF,ICF /IGNORE:4001 /MAP /ALIGN:64 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:IA64 /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MAP:$(DEST_DIR_DEBUG)/$(BASE_NAME).map /PDB:$(DEST_DIR_DEBUG)/$(BASE_NAME).pdb /DEBUG
+RELEASE_ICC11_IPF_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /LTCG /DLL /OPT:REF,ICF /IGNORE:4001 /MAP /ALIGN:64 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:IA64 /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MAP:$(DEST_DIR_DEBUG)/$(BASE_NAME).map /PDB:$(DEST_DIR_DEBUG)/$(BASE_NAME).pdb
+ *_ICC11_IPF_SLINK_FLAGS = /nologo
+
+##################
+# EBC definitions
+##################
+*_ICC11_EBC_*_FAMILY = INTEL
+
+*_ICC11_EBC_MAKE_PATH = DEF(MS_VS_BIN)\nmake.exe
+*_ICC11_EBC_PP_PATH = DEF(EBC_BIN)\iec.exe
+*_ICC11_EBC_VFRPP_PATH = DEF(EBC_BIN)\iec.exe
+*_ICC11_EBC_CC_PATH = DEF(EBC_BIN)\iec.exe
+*_ICC11_EBC_SLINK_PATH = DEF(EBC_BIN)\link.exe
+*_ICC11_EBC_DLINK_PATH = DEF(EBC_BIN)\link.exe
+
+*_ICC11_EBC_MAKE_FLAGS = /nologo
+*_ICC11_EBC_PP_FLAGS = /nologo /E /TC /FIAutoGen.h
+*_ICC11_EBC_CC_FLAGS = /nologo /c /WX /W3 /FIAutoGen.h /D$(MODULE_ENTRY_POINT)=$(ARCH_ENTRY_POINT)
+*_ICC11_EBC_VFRPP_FLAGS = /nologo /E /TC /DVFRCOMPILE /FI$(MODULE_NAME)StrDefs.h
+*_ICC11_EBC_SLINK_FLAGS = /lib /NOLOGO /MACHINE:EBC
+*_ICC11_EBC_DLINK_FLAGS = "C:\Program Files\Intel\EBC\Lib\EbcLib.lib" /NOLOGO /NODEFAULTLIB /MACHINE:EBC /OPT:REF /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /MAP
+
+####################################################################################
+#
+# Intel(R) C++ Compiler Version 11.1
+#
+# IA32 - Intel(R) C++ Compiler for applications running on IA32 (Version 11.1 Build 065 Package ID: w_cproc_p_11.1.065_ia32)
+# X64 - Intel(R) C++ Compiler for applications running on Intel(R) 64 (Version 11.1 Build 065 Package ID: w_cproc_p_11.1.065_intel64)
+# IPF - Intel(R) C++ Compiler for applications running on IA-64 (Version 11.1 Build 065 Package ID: w_cproc_p_11.1.065_ia64)
+# ASL - Microsoft ACPI Source Language Compiler
+#
+####################################################################################
+# ICC11xASL - Intel C Compiler V11.1
+*_ICC11xASL_*_*_FAMILY = INTEL
+
+*_ICC11xASL_*_MAKE_PATH = DEF(MS_VS_BIN)\nmake.exe
+*_ICC11xASL_*_RC_PATH = DEF(MS_VS_BIN)\rc.exe
+
+*_ICC11xASL_*_MAKE_FLAGS = /nologo
+*_ICC11xASL_*_VFRPP_FLAGS = /nologo /E /TC /DVFRCOMPILE /FI$(MODULE_NAME)StrDefs.h
+*_ICC11xASL_*_APP_FLAGS = /nologo /E /TC
+*_ICC11xASL_*_PP_FLAGS = /nologo /E /TC /FIAutoGen.h
+
+*_ICC11xASL_*_ASM16_PATH = DEF(MS_VS_BIN)\ml.exe
+
+##################
+# ASL definitions
+##################
+*_ICC11xASL_*_ASL_PATH = DEF(DEFAULT_WIN_ASL_BIN)
+*_ICC11xASL_*_ASL_FLAGS = DEF(DEFAULT_WIN_ASL_FLAGS)
+*_ICC11xASL_*_ASL_OUTFLAGS = DEF(DEFAULT_WIN_ASL_OUTFLAGS)
+*_ICC11xASL_*_ASLCC_FLAGS = DEF(ICC_WIN_ASLCC_FLAGS)
+*_ICC11xASL_*_ASLPP_FLAGS = DEF(ICC_WIN_ASLPP_FLAGS)
+*_ICC11xASL_*_ASLDLINK_FLAGS = DEF(ICC_WIN_ASLDLINK_FLAGS)
+
+##################
+# IA32 definitions
+##################
+*_ICC11xASL_IA32_CC_PATH = DEF(ICC11_BIN32)\icl.exe
+*_ICC11xASL_IA32_SLINK_PATH = DEF(ICC11_BIN32)\xilib.exe
+# xilib.exe needs lib.exe from Visual Studio
+*_ICC11xASL_IA32_SLINK_DLL = DEF(MS_VS_BIN)
+*_ICC11xASL_IA32_DLINK_PATH = DEF(ICC11_BIN32)\xilink.exe
+*_ICC11xASL_IA32_PP_PATH = DEF(ICC11_BIN32)\icl.exe
+*_ICC11xASL_IA32_VFRPP_PATH = DEF(ICC11_BIN32)\icl.exe
+*_ICC11xASL_IA32_APP_PATH = DEF(ICC11_BIN32)\icl.exe
+*_ICC11xASL_IA32_ASM_PATH = DEF(MS_VS_BIN)\ml.exe
+*_ICC11xASL_IA32_ASM_DLL = DEF(MS_VS_DLL)
+*_ICC11xASL_IA32_ASLCC_PATH = DEF(ICC11_BIN32)\icl.exe
+*_ICC11xASL_IA32_ASLPP_PATH = DEF(ICC11_BIN32)\icl.exe
+*_ICC11xASL_IA32_ASLDLINK_PATH = DEF(ICC11_BIN32)\xilink.exe
+
+ DEBUG_ICC11xASL_IA32_CC_FLAGS = /nologo /c /WX /W4 /Gy /Gs32768 /D UNICODE /O1ib2 /GL /DEFI_FIRMWARE_VENDOR=L\"INTEL\" /FIAutoGen.h /EHs-c- /GF /Zi /Gm
+RELEASE_ICC11xASL_IA32_CC_FLAGS = /nologo /c /WX /W4 /Gy /Gs32768 /D UNICODE /O1ib2 /GL /DEFI_FIRMWARE_VENDOR=L\"INTEL\" /FIAutoGen.h /EHs-c- /GF
+ DEBUG_ICC11xASL_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Zd /Zi
+RELEASE_ICC11xASL_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Zd
+ *_ICC11xASL_IA32_SLINK_FLAGS = /nologo
+ DEBUG_ICC11xASL_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:I386 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
+RELEASE_ICC11xASL_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:I386 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.data=.text /MERGE:.rdata=.text
+
+##################
+# X64 definitions
+##################
+*_ICC11xASL_X64_CC_PATH = DEF(ICC11_BINX64)\icl.exe
+*_ICC11xASL_X64_SLINK_PATH = DEF(ICC11_BINX64)\xilib.exe
+# xilib.exe needs lib.exe from Visual Studio
+*_ICC11xASL_X64_SLINK_DLL = DEF(MS_VS_BIN)
+*_ICC11xASL_X64_DLINK_PATH = DEF(ICC11_BINX64)\xilink.exe
+*_ICC11xASL_X64_PP_PATH = DEF(ICC11_BINX64)\icl.exe
+*_ICC11xASL_X64_VFRPP_PATH = DEF(ICC11_BINX64)\icl.exe
+*_ICC11xASL_X64_APP_PATH = DEF(ICC11_BINX64)\icl.exe
+*_ICC11xASL_X64_ASM_PATH = DEF(WINDDK_BINX64)\ml64.exe
+*_ICC11xASL_X64_ASM_DLL = DEF(MS_VS_DLL)
+*_ICC11xASL_X64_ASLCC_PATH = DEF(ICC11_BINX64)\icl.exe
+*_ICC11xASL_X64_ASLPP_PATH = DEF(ICC11_BINX64)\icl.exe
+*_ICC11xASL_X64_ASLDLINK_PATH = DEF(ICC11_BINX64)\xilink.exe
+
+ DEBUG_ICC11xASL_X64_CC_FLAGS = /nologo /c /WX /GS- /X /W4 /Gs32768 /D UNICODE /O1ib2s /GL /Gy /FI$(DEST_DIR_DEBUG)/AutoGen.h /Zi /Gm /EHs-c- /GF
+RELEASE_ICC11xASL_X64_CC_FLAGS = /nologo /c /WX /GS- /X /W4 /Gs32768 /D UNICODE /O1ib2s /GL /Gy /FI$(DEST_DIR_DEBUG)/AutoGen.h /EHs-c- /GF
+ DEBUG_ICC11xASL_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd /Zi
+RELEASE_ICC11xASL_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd
+ DEBUG_ICC11xASL_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:AMD64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:CONSOLE /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
+RELEASE_ICC11xASL_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:AMD64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:CONSOLE /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.data=.text /MERGE:.rdata=.text
+ *_ICC11xASL_X64_SLINK_FLAGS = /nologo /LTCG
+
+
+##################
+# IPF definitions
+##################
+*_ICC11xASL_IPF_CC_PATH = DEF(ICC11_BIN64)\icl.exe
+# icl.exe needs cl.exe from Visual Studio
+*_ICC11xASL_IPF_CC_DLL = DEF(MS_VS_BIN)
+*_ICC11xASL_IPF_SLINK_PATH = DEF(ICC11_BIN64)\xilib.exe
+# xilib.exe needs lib.exe from Visual Studio
+*_ICC11xASL_IPF_SLINK_DLL = DEF(MS_VS_BIN);DEF(MS_VS_DLL)
+*_ICC11xASL_IPF_DLINK_PATH = DEF(ICC11_BIN64)\xilink.exe
+*_ICC11xASL_IPF_PP_PATH = DEF(ICC11_BIN64)\icl.exe
+*_ICC11xASL_IPF_VFRPP_PATH = DEF(ICC11_BIN64)\icl.exe
+*_ICC11xASL_IPF_APP_PATH = DEF(ICC11_BIN64)\icl.exe
+*_ICC11xASL_IPF_ASM_PATH = DEF(ICC11_BIN64)\ias.exe
+*_ICC11xASL_IPF_ASLCC_PATH = DEF(ICC11_BIN64)\icl.exe
+*_ICC11xASL_IPF_ASLPP_PATH = DEF(ICC11_BIN64)\icl.exe
+*_ICC11xASL_IPF_ASLDLINK_PATH = DEF(ICC11_BIN64)\xilink.exe
+
+ DEBUG_ICC11xASL_IPF_CC_FLAGS = /nologo /c /WX /W4 /GX /Gy /Od /FI$(DEST_DIR_DEBUG)/AutoGen.h /QIA64_fr32 /GF /Qfreestanding /Zi
+RELEASE_ICC11xASL_IPF_CC_FLAGS = /nologo /c /WX /W4 /GX /Gy /Od /FI$(DEST_DIR_DEBUG)/AutoGen.h /QIA64_fr32 /GF /Qfreestanding
+ DEBUG_ICC11xASL_IPF_ASM_FLAGS = -N us -X explicit -M ilp64 -N so -W3 -d debug -F COFF32
+RELEASE_ICC11xASL_IPF_ASM_FLAGS = -N us -X explicit -M ilp64 -N so -W3 -F COFF32
+ DEBUG_ICC11xASL_IPF_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /LTCG /DLL /OPT:REF,ICF /IGNORE:4001 /MAP /ALIGN:64 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:IA64 /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MAP:$(DEST_DIR_DEBUG)/$(BASE_NAME).map /PDB:$(DEST_DIR_DEBUG)/$(BASE_NAME).pdb /DEBUG
+RELEASE_ICC11xASL_IPF_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /LTCG /DLL /OPT:REF,ICF /IGNORE:4001 /MAP /ALIGN:64 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:IA64 /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MAP:$(DEST_DIR_DEBUG)/$(BASE_NAME).map /PDB:$(DEST_DIR_DEBUG)/$(BASE_NAME).pdb
+ *_ICC11xASL_IPF_SLINK_FLAGS = /nologo
+
+##################
+# EBC definitions
+##################
+*_ICC11xASL_EBC_*_FAMILY = INTEL
+
+*_ICC11xASL_EBC_MAKE_PATH = DEF(MS_VS_BIN)\nmake.exe
+*_ICC11xASL_EBC_PP_PATH = DEF(EBC_BIN)\iec.exe
+*_ICC11xASL_EBC_VFRPP_PATH = DEF(EBC_BIN)\iec.exe
+*_ICC11xASL_EBC_CC_PATH = DEF(EBC_BIN)\iec.exe
+*_ICC11xASL_EBC_SLINK_PATH = DEF(EBC_BIN)\link.exe
+*_ICC11xASL_EBC_DLINK_PATH = DEF(EBC_BIN)\link.exe
+
+*_ICC11xASL_EBC_MAKE_FLAGS = /nologo
+*_ICC11xASL_EBC_PP_FLAGS = /nologo /E /TC /FIAutoGen.h
+*_ICC11xASL_EBC_CC_FLAGS = /nologo /c /WX /W3 /FIAutoGen.h /D$(MODULE_ENTRY_POINT)=$(ARCH_ENTRY_POINT)
+*_ICC11xASL_EBC_VFRPP_FLAGS = /nologo /E /TC /DVFRCOMPILE /FI$(MODULE_NAME)StrDefs.h
+*_ICC11xASL_EBC_SLINK_FLAGS = /lib /NOLOGO /MACHINE:EBC
+*_ICC11xASL_EBC_DLINK_FLAGS = "C:\Program Files\Intel\EBC\Lib\EbcLib.lib" /NOLOGO /NODEFAULTLIB /MACHINE:EBC /OPT:REF /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /MAP
+
+
+####################################################################################
+#
+# Intel(R) C++ Compiler Version 11.1 x86 (32-bit on 64-bit OS)
+#
+# IA32 - Intel(R) C++ Compiler for applications running on IA32 (Version 11.1 Build 065 Package ID: w_cproc_p_11.1.065_ia32)
+# X64 - Intel(R) C++ Compiler for applications running on Intel(R) 64 (Version 11.1 Build 065 Package ID: w_cproc_p_11.1.065_intel64)
+# IPF - Intel(R) C++ Compiler for applications running on IA-64 (Version 11.1 Build 065 Package ID: w_cproc_p_11.1.065_ia64)
+# ASL - Intel ACPI Source Language Compiler
+#
+####################################################################################
+# ICC11x86 - Intel C Compiler V11.1
+*_ICC11x86_*_*_FAMILY = INTEL
+
+*_ICC11x86_*_MAKE_PATH = DEF(VS2005x86_BIN)\nmake.exe
+*_ICC11x86_*_RC_PATH = DEF(VS2005x86_BIN)\rc.exe
+
+*_ICC11x86_*_MAKE_FLAGS = /nologo
+*_ICC11x86_*_VFRPP_FLAGS = /nologo /E /TC /DVFRCOMPILE /FI$(MODULE_NAME)StrDefs.h
+*_ICC11x86_*_APP_FLAGS = /nologo /E /TC
+*_ICC11x86_*_PP_FLAGS = /nologo /E /TC /FIAutoGen.h
+
+*_ICC11x86_*_ASM16_PATH = DEF(VS2005x86_BIN)\ml.exe
+
+##################
+# ASL definitions
+##################
+*_ICC11x86_*_ASL_PATH = DEF(DEFAULT_WIN_ASL_BIN)
+*_ICC11x86_*_ASL_FLAGS = DEF(DEFAULT_WIN_ASL_FLAGS)
+*_ICC11x86_*_ASL_OUTFLAGS = DEF(DEFAULT_WIN_ASL_OUTFLAGS)
+*_ICC11x86_*_ASLCC_FLAGS = DEF(ICC_WIN_ASLCC_FLAGS)
+*_ICC11x86_*_ASLPP_FLAGS = DEF(ICC_WIN_ASLPP_FLAGS)
+*_ICC11x86_*_ASLDLINK_FLAGS = DEF(ICC_WIN_ASLDLINK_FLAGS)
+
+##################
+# IA32 definitions
+##################
+*_ICC11x86_IA32_CC_PATH = DEF(ICC11_BIN32x86)\icl.exe
+*_ICC11x86_IA32_SLINK_PATH = DEF(ICC11_BIN32x86)\xilib.exe
+# xilib.exe needs lib.exe from Visual Studio
+*_ICC11x86_IA32_SLINK_DLL = DEF(VS2005x86_BIN)
+*_ICC11x86_IA32_DLINK_PATH = DEF(ICC11_BIN32x86)\xilink.exe
+*_ICC11x86_IA32_PP_PATH = DEF(ICC11_BIN32x86)\icl.exe
+*_ICC11x86_IA32_VFRPP_PATH = DEF(ICC11_BIN32x86)\icl.exe
+*_ICC11x86_IA32_APP_PATH = DEF(ICC11_BIN32x86)\icl.exe
+*_ICC11x86_IA32_ASM_PATH = DEF(VS2005x86_BIN)\ml.exe
+*_ICC11x86_IA32_ASM_DLL = DEF(VS2005x86_DLL)
+*_ICC11x86_IA32_ASLCC_PATH = DEF(ICC11_BIN32x86)\icl.exe
+*_ICC11x86_IA32_ASLPP_PATH = DEF(ICC11_BIN32x86)\icl.exe
+*_ICC11x86_IA32_ASLDLINK_PATH = DEF(ICC11_BIN32x86)\xilink.exe
+
+ DEBUG_ICC11x86_IA32_CC_FLAGS = /nologo /c /WX /W4 /Gy /Gs32768 /D UNICODE /O1ib2 /GL /DEFI_FIRMWARE_VENDOR=L\"INTEL\" /FIAutoGen.h /EHs-c- /GF /Zi /Gm
+RELEASE_ICC11x86_IA32_CC_FLAGS = /nologo /c /WX /W4 /Gy /Gs32768 /D UNICODE /O1ib2 /GL /DEFI_FIRMWARE_VENDOR=L\"INTEL\" /FIAutoGen.h /EHs-c- /GF
+ DEBUG_ICC11x86_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Zd /Zi
+RELEASE_ICC11x86_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Zd
+ *_ICC11x86_IA32_SLINK_FLAGS = /nologo
+ DEBUG_ICC11x86_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:I386 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
+RELEASE_ICC11x86_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:I386 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.data=.text /MERGE:.rdata=.text
+
+##################
+# X64 definitions
+##################
+*_ICC11x86_X64_CC_PATH = DEF(ICC11_BINX64x86)\icl.exe
+*_ICC11x86_X64_SLINK_PATH = DEF(ICC11_BINX64x86)\xilib.exe
+# xilib.exe needs lib.exe from Visual Studio
+*_ICC11x86_X64_SLINK_DLL = DEF(VS2005x86_BIN)
+*_ICC11x86_X64_DLINK_PATH = DEF(ICC11_BINX64x86)\xilink.exe
+*_ICC11x86_X64_PP_PATH = DEF(ICC11_BINX64x86)\icl.exe
+*_ICC11x86_X64_VFRPP_PATH = DEF(ICC11_BINX64x86)\icl.exe
+*_ICC11x86_X64_APP_PATH = DEF(ICC11_BINX64x86)\icl.exe
+*_ICC11x86_X64_ASM_PATH = DEF(WINDDK_BINX64)\ml64.exe
+*_ICC11x86_X64_ASM_DLL = DEF(VS2005x86_DLL)
+*_ICC11x86_X64_ASLCC_PATH = DEF(ICC11_BINX64x86)\icl.exe
+*_ICC11x86_X64_ASLPP_PATH = DEF(ICC11_BINX64x86)\icl.exe
+*_ICC11x86_X64_ASLDLINK_PATH = DEF(ICC11_BINX64x86)\xilink.exe
+
+ DEBUG_ICC11x86_X64_CC_FLAGS = /nologo /c /WX /GS- /X /W4 /Gs32768 /D UNICODE /O1ib2s /GL /Gy /FI$(DEST_DIR_DEBUG)/AutoGen.h /Zi /Gm /EHs-c- /GF
+RELEASE_ICC11x86_X64_CC_FLAGS = /nologo /c /WX /GS- /X /W4 /Gs32768 /D UNICODE /O1ib2s /GL /Gy /FI$(DEST_DIR_DEBUG)/AutoGen.h /EHs-c- /GF
+ DEBUG_ICC11x86_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd /Zi
+RELEASE_ICC11x86_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd
+ DEBUG_ICC11x86_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:AMD64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:CONSOLE /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
+RELEASE_ICC11x86_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:AMD64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:CONSOLE /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.data=.text /MERGE:.rdata=.text
+ *_ICC11x86_X64_SLINK_FLAGS = /nologo /LTCG
+
+
+##################
+# IPF definitions
+##################
+*_ICC11x86_IPF_CC_PATH = DEF(ICC11_BIN64x86)\icl.exe
+# icl.exe needs cl.exe from Visual Studio
+*_ICC11x86_IPF_CC_DLL = DEF(VS2005x86_BIN)
+*_ICC11x86_IPF_SLINK_PATH = DEF(ICC11_BIN64x86)\xilib.exe
+# xilib.exe needs lib.exe from Visual Studio
+*_ICC11x86_IPF_SLINK_DLL = DEF(VS2005x86_BIN);DEF(VS2005x86_DLL)
+*_ICC11x86_IPF_DLINK_PATH = DEF(ICC11_BIN64x86)\xilink.exe
+*_ICC11x86_IPF_PP_PATH = DEF(ICC11_BIN64x86)\icl.exe
+*_ICC11x86_IPF_VFRPP_PATH = DEF(ICC11_BIN64x86)\icl.exe
+*_ICC11x86_IPF_APP_PATH = DEF(ICC11_BIN64x86)\icl.exe
+*_ICC11x86_IPF_ASM_PATH = DEF(ICC11_BIN64x86)\ias.exe
+*_ICC11x86_IPF_ASLCC_PATH = DEF(ICC11_BIN64x86)\icl.exe
+*_ICC11x86_IPF_ASLPP_PATH = DEF(ICC11_BIN64x86)\icl.exe
+*_ICC11x86_IPF_ASLDLINK_PATH = DEF(ICC11_BIN64x86)\xilink.exe
+
+ DEBUG_ICC11x86_IPF_CC_FLAGS = /nologo /c /WX /W4 /GX /Gy /Od /FI$(DEST_DIR_DEBUG)/AutoGen.h /QIA64_fr32 /GF /Qfreestanding /Zi
+RELEASE_ICC11x86_IPF_CC_FLAGS = /nologo /c /WX /W4 /GX /Gy /Od /FI$(DEST_DIR_DEBUG)/AutoGen.h /QIA64_fr32 /GF /Qfreestanding
+ DEBUG_ICC11x86_IPF_ASM_FLAGS = -N us -X explicit -M ilp64 -N so -W3 -d debug -F COFF32
+RELEASE_ICC11x86_IPF_ASM_FLAGS = -N us -X explicit -M ilp64 -N so -W3 -F COFF32
+ DEBUG_ICC11x86_IPF_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /LTCG /DLL /OPT:REF,ICF /IGNORE:4001 /MAP /ALIGN:64 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:IA64 /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MAP:$(DEST_DIR_DEBUG)/$(BASE_NAME).map /PDB:$(DEST_DIR_DEBUG)/$(BASE_NAME).pdb /DEBUG
+RELEASE_ICC11x86_IPF_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /LTCG /DLL /OPT:REF,ICF /IGNORE:4001 /MAP /ALIGN:64 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:IA64 /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MAP:$(DEST_DIR_DEBUG)/$(BASE_NAME).map /PDB:$(DEST_DIR_DEBUG)/$(BASE_NAME).pdb
+ *_ICC11x86_IPF_SLINK_FLAGS = /nologo
+
+##################
+# EBC definitions
+##################
+*_ICC11x86_EBC_*_FAMILY = INTEL
+
+*_ICC11x86_EBC_MAKE_PATH = DEF(VS2005x86_BIN)\nmake.exe
+*_ICC11x86_EBC_PP_PATH = DEF(EBC_BINx86)\iec.exe
+*_ICC11x86_EBC_VFRPP_PATH = DEF(EBC_BINx86)\iec.exe
+*_ICC11x86_EBC_CC_PATH = DEF(EBC_BINx86)\iec.exe
+*_ICC11x86_EBC_SLINK_PATH = DEF(EBC_BINx86)\link.exe
+*_ICC11x86_EBC_DLINK_PATH = DEF(EBC_BINx86)\link.exe
+
+*_ICC11x86_EBC_MAKE_FLAGS = /nologo
+*_ICC11x86_EBC_PP_FLAGS = /nologo /E /TC /FIAutoGen.h
+*_ICC11x86_EBC_CC_FLAGS = /nologo /c /WX /W3 /FIAutoGen.h /D$(MODULE_ENTRY_POINT)=$(ARCH_ENTRY_POINT)
+*_ICC11x86_EBC_VFRPP_FLAGS = /nologo /E /TC /DVFRCOMPILE /FI$(MODULE_NAME)StrDefs.h
+*_ICC11x86_EBC_SLINK_FLAGS = /lib /NOLOGO /MACHINE:EBC
+*_ICC11x86_EBC_DLINK_FLAGS = "C:\Program Files (x86)\Intel\EBC\Lib\EbcLib.lib" /NOLOGO /NODEFAULTLIB /MACHINE:EBC /OPT:REF /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /MAP
+
+
+####################################################################################
+#
+# Intel(R) C++ Compiler Version 11.1 x86 (32-bit on 64-bit OS)
+#
+# IA32 - Intel(R) C++ Compiler for applications running on IA32 (Version 11.1 Build 065 Package ID: w_cproc_p_11.1.065_ia32)
+# X64 - Intel(R) C++ Compiler for applications running on Intel(R) 64 (Version 11.1 Build 065 Package ID: w_cproc_p_11.1.065_intel64)
+# IPF - Intel(R) C++ Compiler for applications running on IA-64 (Version 11.1 Build 065 Package ID: w_cproc_p_11.1.065_ia64)
+# ASL - Microsoft ACPI Source Language Compiler
+#
+####################################################################################
+# ICC11x86xASL - Intel C Compiler V11.1
+*_ICC11x86xASL_*_*_FAMILY = INTEL
+
+*_ICC11x86xASL_*_MAKE_PATH = DEF(VS2005x86_BIN)\nmake.exe
+*_ICC11x86xASL_*_RC_PATH = DEF(VS2005x86_BIN)\rc.exe
+
+*_ICC11x86xASL_*_MAKE_FLAGS = /nologo
+*_ICC11x86xASL_*_VFRPP_FLAGS = /nologo /E /TC /DVFRCOMPILE /FI$(MODULE_NAME)StrDefs.h
+*_ICC11x86xASL_*_APP_FLAGS = /nologo /E /TC
+*_ICC11x86xASL_*_PP_FLAGS = /nologo /E /TC /FIAutoGen.h
+
+*_ICC11x86xASL_*_ASM16_PATH = DEF(VS2005x86_BIN)\ml.exe
+
+##################
+# ASL definitions
+##################
+*_ICC11x86xASL_*_ASL_PATH = DEF(WIN_ASL_BIN)
+*_ICC11x86xASL_*_ASL_FLAGS =
+*_ICC11x86xASL_*_ASL_OUTFLAGS = DEF(MS_ASL_OUTFLAGS)
+*_ICC11x86xASL_*_ASLCC_FLAGS = DEF(ICC_WIN_ASLCC_FLAGS)
+*_ICC11x86xASL_*_ASLPP_FLAGS = DEF(ICC_WIN_ASLPP_FLAGS)
+*_ICC11x86xASL_*_ASLDLINK_FLAGS = DEF(ICC_WIN_ASLDLINK_FLAGS)
+
+##################
+# IA32 definitions
+##################
+*_ICC11x86xASL_IA32_CC_PATH = DEF(ICC11_BIN32x86)\icl.exe
+*_ICC11x86xASL_IA32_SLINK_PATH = DEF(ICC11_BIN32x86)\xilib.exe
+# xilib.exe needs lib.exe from Visual Studio
+*_ICC11x86xASL_IA32_SLINK_DLL = DEF(VS2005x86_BIN)
+*_ICC11x86xASL_IA32_DLINK_PATH = DEF(ICC11_BIN32x86)\xilink.exe
+*_ICC11x86xASL_IA32_PP_PATH = DEF(ICC11_BIN32x86)\icl.exe
+*_ICC11x86xASL_IA32_VFRPP_PATH = DEF(ICC11_BIN32x86)\icl.exe
+*_ICC11x86xASL_IA32_APP_PATH = DEF(ICC11_BIN32x86)\icl.exe
+*_ICC11x86xASL_IA32_ASM_PATH = DEF(VS2005x86_BIN)\ml.exe
+*_ICC11x86xASL_IA32_ASM_DLL = DEF(VS2005x86_DLL)
+*_ICC11x86xASL_IA32_ASLCC_PATH = DEF(ICC11_BIN32x86)\icl.exe
+*_ICC11x86xASL_IA32_ASLPP_PATH = DEF(ICC11_BIN32x86)\icl.exe
+*_ICC11x86xASL_IA32_ASLDLINK_PATH = DEF(ICC11_BIN32x86)\xilink.exe
+
+ DEBUG_ICC11x86xASL_IA32_CC_FLAGS = /nologo /c /WX /W4 /Gy /Gs32768 /D UNICODE /O1ib2 /GL /DEFI_FIRMWARE_VENDOR=L\"INTEL\" /FIAutoGen.h /EHs-c- /GF /Zi /Gm
+RELEASE_ICC11x86xASL_IA32_CC_FLAGS = /nologo /c /WX /W4 /Gy /Gs32768 /D UNICODE /O1ib2 /GL /DEFI_FIRMWARE_VENDOR=L\"INTEL\" /FIAutoGen.h /EHs-c- /GF
+ DEBUG_ICC11x86xASL_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Zd /Zi
+RELEASE_ICC11x86xASL_IA32_ASM_FLAGS = /nologo /c /WX /W3 /Zd
+ *_ICC11x86xASL_IA32_SLINK_FLAGS = /nologo
+ DEBUG_ICC11x86xASL_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:I386 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
+RELEASE_ICC11x86xASL_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:I386 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.data=.text /MERGE:.rdata=.text
+
+##################
+# X64 definitions
+##################
+*_ICC11x86xASL_X64_CC_PATH = DEF(ICC11_BINX64x86)\icl.exe
+*_ICC11x86xASL_X64_SLINK_PATH = DEF(ICC11_BINX64x86)\xilib.exe
+# xilib.exe needs lib.exe from Visual Studio
+*_ICC11x86xASL_X64_SLINK_DLL = DEF(VS2005x86_BIN)
+*_ICC11x86xASL_X64_DLINK_PATH = DEF(ICC11_BINX64x86)\xilink.exe
+*_ICC11x86xASL_X64_PP_PATH = DEF(ICC11_BINX64x86)\icl.exe
+*_ICC11x86xASL_X64_VFRPP_PATH = DEF(ICC11_BINX64x86)\icl.exe
+*_ICC11x86xASL_X64_APP_PATH = DEF(ICC11_BINX64x86)\icl.exe
+*_ICC11x86xASL_X64_ASM_PATH = DEF(WINDDK_BINX64)\ml64.exe
+*_ICC11x86xASL_X64_ASM_DLL = DEF(VS2005x86_DLL)
+*_ICC11x86xASL_X64_ASLCC_PATH = DEF(ICC11_BINX64x86)\icl.exe
+*_ICC11x86xASL_X64_ASLPP_PATH = DEF(ICC11_BINX64x86)\icl.exe
+*_ICC11x86xASL_X64_ASLDLINK_PATH = DEF(ICC11_BINX64x86)\xilink.exe
+
+ DEBUG_ICC11x86xASL_X64_CC_FLAGS = /nologo /c /WX /GS- /X /W4 /Gs32768 /D UNICODE /O1ib2s /GL /Gy /FI$(DEST_DIR_DEBUG)/AutoGen.h /Zi /Gm /EHs-c- /GF
+RELEASE_ICC11x86xASL_X64_CC_FLAGS = /nologo /c /WX /GS- /X /W4 /Gs32768 /D UNICODE /O1ib2s /GL /Gy /FI$(DEST_DIR_DEBUG)/AutoGen.h /EHs-c- /GF
+ DEBUG_ICC11x86xASL_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd /Zi
+RELEASE_ICC11x86xASL_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd
+ DEBUG_ICC11x86xASL_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:AMD64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:CONSOLE /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
+RELEASE_ICC11x86xASL_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:AMD64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:CONSOLE /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.data=.text /MERGE:.rdata=.text
+ *_ICC11x86xASL_X64_SLINK_FLAGS = /nologo /LTCG
+
+
+##################
+# IPF definitions
+##################
+*_ICC11x86xASL_IPF_CC_PATH = DEF(ICC11_BIN64x86)\icl.exe
+# icl.exe needs cl.exe from Visual Studio
+*_ICC11x86xASL_IPF_CC_DLL = DEF(VS2005x86_BIN)
+*_ICC11x86xASL_IPF_SLINK_PATH = DEF(ICC11_BIN64x86)\xilib.exe
+# xilib.exe needs lib.exe from Visual Studio
+*_ICC11x86xASL_IPF_SLINK_DLL = DEF(VS2005x86_BIN);DEF(VS2005x86_DLL)
+*_ICC11x86xASL_IPF_DLINK_PATH = DEF(ICC11_BIN64x86)\xilink.exe
+*_ICC11x86xASL_IPF_PP_PATH = DEF(ICC11_BIN64x86)\icl.exe
+*_ICC11x86xASL_IPF_VFRPP_PATH = DEF(ICC11_BIN64x86)\icl.exe
+*_ICC11x86xASL_IPF_APP_PATH = DEF(ICC11_BIN64x86)\icl.exe
+*_ICC11x86xASL_IPF_ASM_PATH = DEF(ICC11_BIN64x86)\ias.exe
+*_ICC11x86xASL_IPF_ASLCC_PATH = DEF(ICC11_BIN64x86)\icl.exe
+*_ICC11x86xASL_IPF_ASLPP_PATH = DEF(ICC11_BIN64x86)\icl.exe
+*_ICC11x86xASL_IPF_ASLDLINK_PATH = DEF(ICC11_BIN64x86)\xilink.exe
+
+ DEBUG_ICC11x86xASL_IPF_CC_FLAGS = /nologo /c /WX /W4 /GX /Gy /Od /FI$(DEST_DIR_DEBUG)/AutoGen.h /QIA64_fr32 /GF /Qfreestanding /Zi
+RELEASE_ICC11x86xASL_IPF_CC_FLAGS = /nologo /c /WX /W4 /GX /Gy /Od /FI$(DEST_DIR_DEBUG)/AutoGen.h /QIA64_fr32 /GF /Qfreestanding
+ DEBUG_ICC11x86xASL_IPF_ASM_FLAGS = -N us -X explicit -M ilp64 -N so -W3 -d debug -F COFF32
+RELEASE_ICC11x86xASL_IPF_ASM_FLAGS = -N us -X explicit -M ilp64 -N so -W3 -F COFF32
+ DEBUG_ICC11x86xASL_IPF_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /LTCG /DLL /OPT:REF,ICF /IGNORE:4001 /MAP /ALIGN:64 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:IA64 /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MAP:$(DEST_DIR_DEBUG)/$(BASE_NAME).map /PDB:$(DEST_DIR_DEBUG)/$(BASE_NAME).pdb /DEBUG
+RELEASE_ICC11x86xASL_IPF_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /LTCG /DLL /OPT:REF,ICF /IGNORE:4001 /MAP /ALIGN:64 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:IA64 /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MAP:$(DEST_DIR_DEBUG)/$(BASE_NAME).map /PDB:$(DEST_DIR_DEBUG)/$(BASE_NAME).pdb
+ *_ICC11x86xASL_IPF_SLINK_FLAGS = /nologo
+
+##################
+# EBC definitions
+##################
+*_ICC11x86xASL_EBC_*_FAMILY = INTEL
+
+*_ICC11x86xASL_EBC_MAKE_PATH = DEF(VS2005x86_BIN)\nmake.exe
+*_ICC11x86xASL_EBC_PP_PATH = DEF(EBC_BINx86)\iec.exe
+*_ICC11x86xASL_EBC_VFRPP_PATH = DEF(EBC_BINx86)\iec.exe
+*_ICC11x86xASL_EBC_CC_PATH = DEF(EBC_BINx86)\iec.exe
+*_ICC11x86xASL_EBC_SLINK_PATH = DEF(EBC_BINx86)\link.exe
+*_ICC11x86xASL_EBC_DLINK_PATH = DEF(EBC_BINx86)\link.exe
+
+*_ICC11x86xASL_EBC_MAKE_FLAGS = /nologo
+*_ICC11x86xASL_EBC_PP_FLAGS = /nologo /E /TC /FIAutoGen.h
+*_ICC11x86xASL_EBC_CC_FLAGS = /nologo /c /WX /W3 /FIAutoGen.h /D$(MODULE_ENTRY_POINT)=$(ARCH_ENTRY_POINT)
+*_ICC11x86xASL_EBC_VFRPP_FLAGS = /nologo /E /TC /DVFRCOMPILE /FI$(MODULE_NAME)StrDefs.h
+*_ICC11x86xASL_EBC_SLINK_FLAGS = /lib /NOLOGO /MACHINE:EBC
+*_ICC11x86xASL_EBC_DLINK_FLAGS = "C:\Program Files (x86)\Intel\EBC\Lib\EbcLib.lib" /NOLOGO /NODEFAULTLIB /MACHINE:EBC /OPT:REF /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /MAP
+
+
+####################################################################################
+#
+# MYTOOLS
+# IA32 - Microsoft Visual Studio 2008 Team Suite
+# X64 - Microsoft Visual Studio 2008 Team Suite
+# IPF - Microsoft Windows DDK 3790.1830
+# EBC - Intel EFI Byte Code Compiler
+#
+####################################################################################
+# MYTOOLS - Settings compatible with previous versions of tools_def.template
+*_MYTOOLS_*_*_FAMILY = MSFT
+
+##################
+# ASL definitions
+##################
+*_MYTOOLS_*_ASL_PATH = DEF(DEFAULT_WIN_ASL_BIN)
+*_MYTOOLS_*_ASL_FLAGS = DEF(DEFAULT_WIN_ASL_FLAGS)
+*_MYTOOLS_*_ASL_OUTFLAGS = DEF(DEFAULT_WIN_ASL_OUTFLAGS)
+*_MYTOOLS_*_ASLCC_FLAGS = DEF(MSFT_ASLCC_FLAGS)
+*_MYTOOLS_*_ASLPP_FLAGS = DEF(MSFT_ASLPP_FLAGS)
+*_MYTOOLS_*_ASLDLINK_FLAGS = DEF(MSFT_ASLDLINK_FLAGS)
+
+
+*_MYTOOLS_*_MAKE_FLAGS = /nologo
+*_MYTOOLS_*_VFRPP_FLAGS = /nologo /E /TC /DVFRCOMPILE /FI$(MODULE_NAME)StrDefs.h
+*_MYTOOLS_*_APP_FLAGS = /nologo /E /TC
+*_MYTOOLS_*_PP_FLAGS = /nologo /E /TC /FIAutoGen.h
+*_MYTOOLS_*_SLINK_FLAGS = /nologo /LTCG
+
+*_MYTOOLS_*_ASM16_PATH = DEF(VS2008_BIN)\ml.exe
+
+##################
+# IA32 definitions
+##################
+*_MYTOOLS_IA32_*_DLL = DEF(VS2008_DLL)
+
+*_MYTOOLS_IA32_MAKE_PATH = DEF(VS2008_BIN)\nmake.exe
+*_MYTOOLS_IA32_CC_PATH = DEF(VS2008_BIN)\cl.exe
+*_MYTOOLS_IA32_SLINK_PATH = DEF(VS2008_BIN)\lib.exe
+*_MYTOOLS_IA32_DLINK_PATH = DEF(VS2008_BIN)\link.exe
+*_MYTOOLS_IA32_PP_PATH = DEF(VS2008_BIN)\cl.exe
+*_MYTOOLS_IA32_VFRPP_PATH = DEF(VS2008_BIN)\cl.exe
+*_MYTOOLS_IA32_APP_PATH = DEF(VS2008_BIN)\cl.exe
+*_MYTOOLS_IA32_ASM_PATH = DEF(VS2008_BIN)\ml.exe
+*_MYTOOLS_IA32_ASLCC_PATH = DEF(VS2008_BIN)\cl.exe
+*_MYTOOLS_IA32_ASLPP_PATH = DEF(VS2008_BIN)\cl.exe
+*_MYTOOLS_IA32_ASLDLINK_PATH = DEF(VS2008_BIN)\link.exe
+*_MYTOOLS_IA32_RC_PATH = DEF(WINSDK_BIN)\rc.exe
+
+ DEBUG_MYTOOLS_IA32_CC_FLAGS = /nologo /c /WX /GS- /W4 /Gs32768 /Gy /D UNICODE /O1ib2 /GL /FIAutoGen.h /EHs-c- /GR- /GF /Zi /Gm
+RELEASE_MYTOOLS_IA32_CC_FLAGS = /nologo /c /WX /GS- /W4 /Gs32768 /Gy /D UNICODE /O1ib2 /GL /FIAutoGen.h /EHs-c- /GR- /GF
+ DEBUG_MYTOOLS_IA32_ASM_FLAGS = /nologo /c /WX /W3 /coff /Cx /Zd /Zi
+RELEASE_MYTOOLS_IA32_ASM_FLAGS = /nologo /c /WX /W3 /coff /Cx /Zd
+ DEBUG_MYTOOLS_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:I386 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG /PDB:$(DEBUG_DIR)/$(BASE_NAME).pdb
+RELEASE_MYTOOLS_IA32_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:I386 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.data=.text /MERGE:.rdata=.text /PDB:$(DEBUG_DIR)/$(BASE_NAME).pdb
+
+##################
+# x64 definitions
+##################
+*_MYTOOLS_X64_*_DLL = DEF(VS2008_DLL)
+
+*_MYTOOLS_X64_MAKE_PATH = DEF(VS2008_BIN)\nmake.exe
+*_MYTOOLS_X64_CC_PATH = DEF(VS2008_BINX64)\cl.exe
+*_MYTOOLS_X64_SLINK_PATH = DEF(VS2008_BINX64)\lib.exe
+*_MYTOOLS_X64_DLINK_PATH = DEF(VS2008_BINX64)\link.exe
+*_MYTOOLS_X64_PP_PATH = DEF(VS2008_BINX64)\cl.exe
+*_MYTOOLS_X64_VFRPP_PATH = DEF(VS2008_BINX64)\cl.exe
+*_MYTOOLS_X64_APP_PATH = DEF(VS2008_BINX64)\cl.exe
+*_MYTOOLS_X64_ASM_PATH = DEF(VS2008_BINX64)\ml64.exe
+*_MYTOOLS_X64_ASLCC_PATH = DEF(VS2008_BINX64)\cl.exe
+*_MYTOOLS_X64_ASLPP_PATH = DEF(VS2008_BINX64)\cl.exe
+*_MYTOOLS_X64_ASLDLINK_PATH = DEF(VS2008_BINX64)\link.exe
+*_MYTOOLS_X64_RC_PATH = DEF(WINSDK_BIN)\rc.exe
+
+ DEBUG_MYTOOLS_X64_CC_FLAGS = /nologo /c /WX /GS- /W4 /Gs32768 /Gy /D UNICODE /O1ib2 /GL /FIAutoGen.h /EHs-c- /GR- /GF /Zi /Gm
+RELEASE_MYTOOLS_X64_CC_FLAGS = /nologo /c /WX /GS- /W4 /Gs32768 /Gy /D UNICODE /O1ib2 /GL /FIAutoGen.h /EHs-c- /GR- /GF
+ DEBUG_MYTOOLS_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd /Zi
+RELEASE_MYTOOLS_X64_ASM_FLAGS = /nologo /c /WX /W3 /Cx /Zd
+ DEBUG_MYTOOLS_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:AMD64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /DEBUG
+RELEASE_MYTOOLS_X64_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /IGNORE:4001 /IGNORE:4254 /OPT:REF /OPT:ICF=10 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /Machine:AMD64 /LTCG /DLL /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MERGE:.data=.text /MERGE:.rdata=.text
+
+##################
+# IPF definitions
+##################
+*_MYTOOLS_IPF_MAKE_PATH = DEF(WINDDK_BIN32)\nmake.exe
+*_MYTOOLS_IPF_CC_PATH = DEF(WINDDK_BIN64)\cl.exe
+*_MYTOOLS_IPF_SLINK_PATH = DEF(WINDDK_BIN64)\lib.exe
+*_MYTOOLS_IPF_DLINK_PATH = DEF(WINDDK_BIN64)\link.exe
+*_MYTOOLS_IPF_PP_PATH = DEF(WINDDK_BIN64)\cl.exe
+*_MYTOOLS_IPF_VFRPP_PATH = DEF(WINDDK_BIN64)\cl.exe
+*_MYTOOLS_IPF_APP_PATH = DEF(WINDDK_BIN64)\cl.exe
+*_MYTOOLS_IPF_ASM_PATH = DEF(WINDDK_BIN64)\ias.exe
+*_MYTOOLS_IPF_ASLCC_PATH = DEF(WINDDK_BIN64)\cl.exe
+*_MYTOOLS_IPF_ASLPP_PATH = DEF(WINDDK_BIN64)\cl.exe
+*_MYTOOLS_IPF_ASLDLINK_PATH = DEF(WINDDK_BIN64)\link.exe
+*_MYTOOLS_IPF_RC_PATH = DEF(WINDDK_BIN32)\rc.exe
+
+ *_MYTOOLS_IPF_ASM_OUTPUT = "-o "
+ DEBUG_MYTOOLS_IPF_CC_FLAGS = /nologo /c /WX /GS- /X /W4 /Gy /Ox /GL /FIAutoGen.h /EHs-c- /GR- /GF /Zx /QIPF_fr32 /Zi
+RELEASE_MYTOOLS_IPF_CC_FLAGS = /nologo /c /WX /GS- /X /W4 /Gy /Ox /GL /FIAutoGen.h /EHs-c- /GR- /GF /Zx /QIPF_fr32
+ DEBUG_MYTOOLS_IPF_ASM_FLAGS = -N us -X explicit -M ilp64 -N so -W4 -d debug
+RELEASE_MYTOOLS_IPF_ASM_FLAGS = -N us -X explicit -M ilp64 -N so -W4
+ DEBUG_MYTOOLS_IPF_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /LTCG /DLL /OPT:REF /OPT:ICF=10 /IGNORE:4001 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:IA64 /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MAP:$(DEST_DIR_DEBUG)/$(BASE_NAME).map /PDB:$(DEBUG_DIR)/$(BASE_NAME).pdb /DEBUG
+RELEASE_MYTOOLS_IPF_DLINK_FLAGS = /NOLOGO /NODEFAULTLIB /LTCG /DLL /OPT:REF /OPT:ICF=10 /IGNORE:4001 /MAP /ALIGN:32 /SECTION:.xdata,D /SECTION:.pdata,D /MACHINE:IA64 /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /SAFESEH:NO /BASE:0 /DRIVER /MAP:$(DEST_DIR_DEBUG)/$(BASE_NAME).map /PDB:$(DEBUG_DIR)/$(BASE_NAME).pdb
+ *_MYTOOLS_IPF_SLINK_FLAGS = /nologo /LTCG
+
+##################
+# EBC definitions
+##################
+*_MYTOOLS_EBC_*_FAMILY = INTEL
+
+*_MYTOOLS_EBC_MAKE_PATH = DEF(VS2005_BIN)\nmake.exe
+*_MYTOOLS_EBC_PP_PATH = DEF(EBC_BIN)\iec.exe
+*_MYTOOLS_EBC_VFRPP_PATH = DEF(EBC_BIN)\iec.exe
+*_MYTOOLS_EBC_CC_PATH = DEF(EBC_BIN)\iec.exe
+*_MYTOOLS_EBC_SLINK_PATH = DEF(EBC_BIN)\link.exe
+*_MYTOOLS_EBC_DLINK_PATH = DEF(EBC_BIN)\link.exe
+*_MYTOOLS_EBC_RC_PATH = DEF(VS2005_BIN)\rc.exe
+
+*_MYTOOLS_EBC_MAKE_FLAGS = /nologo
+*_MYTOOLS_EBC_PP_FLAGS = /nologo /E /TC /FIAutoGen.h
+*_MYTOOLS_EBC_CC_FLAGS = /nologo /c /WX /W3 /FIAutoGen.h /D$(MODULE_ENTRY_POINT)=$(ARCH_ENTRY_POINT)
+*_MYTOOLS_EBC_VFRPP_FLAGS = /nologo /E /TC /DVFRCOMPILE /FI$(MODULE_NAME)StrDefs.h
+*_MYTOOLS_EBC_SLINK_FLAGS = /lib /NOLOGO /MACHINE:EBC
+*_MYTOOLS_EBC_DLINK_FLAGS = "C:\Program Files\Intel\EBC\Lib\EbcLib.lib" /NOLOGO /NODEFAULTLIB /MACHINE:EBC /OPT:REF /ENTRY:$(IMAGE_ENTRY_POINT) /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER /MAP
+
+
+####################################################################################
+#
+# Xcode Support for building on Mac OS X (Snow Leopard)
+#
+####################################################################################
+# XCODE32 - Xcode 3.2 Tools (Snow Leopard)
+*_XCODE32_*_*_FAMILY = GCC
+*_XCODE32_*_*_BUILDRULEFAMILY = XCODE
+
+
+*_XCODE32_*_ASL_PATH = /usr/bin/iasl
+
+*_XCODE32_*_MAKE_PATH = make
+
+*_XCODE32_*_DSYMUTIL_PATH = /usr/bin/dsymutil
+
+# This tool needs to be installed seperatly from Xcode 3.2
+*_XCODE32_*_MTOC_PATH = /usr/local/bin/mtoc
+
+ DEBUG_XCODE32_*_MTOC_FLAGS = -align 0x20 -d $(DEBUG_DIR)/$(MODULE_NAME).dll
+RELEASE_XCODE32_*_MTOC_FLAGS = -align 0x20
+
+##################
+# IA32 definitions
+##################
+*_XCODE32_IA32_CC_PATH = gcc
+*_XCODE32_IA32_SLINK_PATH = libtool
+*_XCODE32_IA32_DLINK_PATH = ld
+*_XCODE32_IA32_ASM_PATH = as
+*_XCODE32_IA32_PP_PATH = gcc
+*_XCODE32_IA32_VFRPP_PATH = gcc
+*_XCODE32_IA32_ASL_PATH = iasl
+*_XCODE32_IA32_ASLCC_PATH = gcc
+*_XCODE32_IA32_ASLPP_PATH = gcc
+*_XCODE32_IA32_ASLDLINK_PATH = ld
+
+ DEBUG_XCODE32_IA32_DLINK_FLAGS = -arch i386 -u _$(IMAGE_ENTRY_POINT) -e _$(IMAGE_ENTRY_POINT) -preload -segalign 0x20 -pie -all_load -dead_strip -seg1addr 0x240 -read_only_relocs suppress -map $(DEST_DIR_DEBUG)/$(BASE_NAME).map
+RELEASE_XCODE32_IA32_DLINK_FLAGS = -arch i386 -u _$(IMAGE_ENTRY_POINT) -e _$(IMAGE_ENTRY_POINT) -preload -segalign 0x20 -pie -all_load -dead_strip -seg1addr 0x220 -read_only_relocs suppress -map $(DEST_DIR_DEBUG)/$(BASE_NAME).map
+*_XCODE32_IA32_SLINK_FLAGS = -static -o
+ DEBUG_XCODE32_IA32_ASM_FLAGS = -arch i386 -g
+RELEASE_XCODE32_IA32_ASM_FLAGS = -arch i386
+*_XCODE32_IA32_PP_FLAGS = -arch i386 -E -x assembler-with-cpp -include $(DEST_DIR_DEBUG)/AutoGen.h
+*_XCODE32_IA32_VFRPP_FLAGS = -arch i386 -x c -E -P -DVFRCOMPILE --include $(DEST_DIR_DEBUG)/$(MODULE_NAME)StrDefs.h
+ DEBUG_XCODE32_IA32_CC_FLAGS = -arch i386 -save-temps -g -O0 -combine -mms-bitfields -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-missing-braces -c -include AutoGen.h -mdynamic-no-pic -fno-stack-protector
+RELEASE_XCODE32_IA32_CC_FLAGS = -arch i386 -Oz -combine -mms-bitfields -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-missing-braces -fomit-frame-pointer -c -include AutoGen.h -mdynamic-no-pic -fno-stack-protector
+
+*_XCODE32_IA32_ASLCC_FLAGS = -arch i386 -x c -save-temps -g -O0 -mms-bitfields -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-missing-braces -c -include AutoGen.h -mdynamic-no-pic
+*_XCODE32_IA32_ASLDLINK_FLAGS = -arch i386 -e _main -preload -segalign 0x20 -pie -seg1addr 0x220 -read_only_relocs suppress -map $(DEST_DIR_DEBUG)/$(BASE_NAME).map
+*_XCODE32_IA32_ASLPP_FLAGS = -arch i386 -x c -E
+*_XCODE32_IA32_ASL_FLAGS =
+
+##################
+# X64 definitions - still a work in progress. This tool chain does not produce
+# the correct ABI, it is just used to compile the code....
+##################
+*_XCODE32_X64_CC_PATH = gcc-4.2
+*_XCODE32_X64_SLINK_PATH = libtool
+*_XCODE32_X64_DLINK_PATH = ld
+*_XCODE32_X64_ASM_PATH = as
+*_XCODE32_X64_PP_PATH = gcc-4.2
+*_XCODE32_X64_VFRPP_PATH = gcc-4.2
+*_XCODE32_X64_ASL_PATH = iasl
+*_XCODE32_X64_ASLCC_PATH = gcc
+*_XCODE32_X64_ASLPP_PATH = gcc
+*_XCODE32_X64_ASLDLINK_PATH = ld
+
+*_XCODE32_X64_DLINK_FLAGS = -arch x86_64 -u _$(IMAGE_ENTRY_POINT) -e _$(IMAGE_ENTRY_POINT) -preload -segalign 0x20 -pie -seg1addr 0x240 -read_only_relocs suppress -map $(DEST_DIR_DEBUG)/$(BASE_NAME).map
+*_XCODE32_X64_SLINK_FLAGS = -static -o
+
+ DEBUG_XCODE32_X64_ASM_FLAGS = -arch x86_64 -g
+RELEASE_XCODE32_X64_ASM_FLAGS = -arch x86_64
+*_XCODE32_X64_PP_FLAGS = -arch x86_64 -E -x assembler-with-cpp -include $(DEST_DIR_DEBUG)/AutoGen.h
+*_XCODE32_X64_VFRPP_FLAGS = -arch x86_64 -x c -E -P -DVFRCOMPILE --include $(DEST_DIR_DEBUG)/$(MODULE_NAME)StrDefs.h
+
+ DEBUG_XCODE32_X64_CC_FLAGS = -arch x86_64 -save-temps -g -O0 -combine -mms-bitfields -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-missing-braces -Wno-address -fomit-frame-pointer -static -c -include AutoGen.h -fno-stack-protector
+RELEASE_XCODE32_X64_CC_FLAGS = -arch x86_64 -Oz -combine -mms-bitfields -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-missing-braces -Wno-address -fomit-frame-pointer -static -c -include AutoGen.h -fno-stack-protector
+
+##################
+# ARM definitions - (Assumes iPhone SDK installed on Snow Leopard)
+##################
+
+*_XCODE32_ARM_ARCHCC_FLAGS = -arch armv7 -march=armv7 -mthumb
+*_XCODE32_ARM_ARCHASM_FLAGS = -arch armv7
+*_XCODE32_ARM_ARCHDLINK_FLAGS = -arch armv7
+*_XCODE32_ARM_PLATFORM_FLAGS =
+
+*_XCODE32_ARM_CC_PATH = DEF(IPHONE_TOOLS)/usr/bin/gcc
+*_XCODE32_ARM_SLINK_PATH = DEF(IPHONE_TOOLS)/usr/bin/libtool
+*_XCODE32_ARM_DLINK_PATH = ld
+*_XCODE32_ARM_ASM_PATH = DEF(IPHONE_TOOLS)/usr/bin/as
+*_XCODE32_ARM_PP_PATH = DEF(IPHONE_TOOLS)/usr/bin/gcc
+*_XCODE32_ARM_VFRPP_PATH = DEF(IPHONE_TOOLS)/usr/bin/gcc
+
+ DEBUG_XCODE32_ARM_DLINK_FLAGS = $(ARCHDLINK_FLAGS) -u _$(IMAGE_ENTRY_POINT) -e _$(IMAGE_ENTRY_POINT) -preload -segalign 0x20 -pie -all_load -dead_strip -seg1addr 0x220 -read_only_relocs suppress -map $(DEST_DIR_DEBUG)/$(BASE_NAME).map
+RELEASE_XCODE32_ARM_DLINK_FLAGS = $(ARCHDLINK_FLAGS) -u _$(IMAGE_ENTRY_POINT) -e _$(IMAGE_ENTRY_POINT) -preload -segalign 0x20 -pie -all_load -dead_strip -seg1addr 0x220 -read_only_relocs suppress -map $(DEST_DIR_DEBUG)/$(BASE_NAME).map
+
+*_XCODE32_ARM_SLINK_FLAGS = -static -o
+
+ DEBUG_XCODE32_ARM_ASM_FLAGS = $(ARCHASM_FLAGS) -g
+RELEASE_XCODE32_ARM_ASM_FLAGS = $(ARCHASM_FLAGS)
+*_XCODE32_ARM_PP_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) -E -x assembler-with-cpp -include $(DEST_DIR_DEBUG)/AutoGen.h
+*_XCODE32_ARM_VFRPP_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) -x c -E -P -DVFRCOMPILE --include $(DEST_DIR_DEBUG)/$(MODULE_NAME)StrDefs.h
+
+ DEBUG_XCODE32_ARM_CC_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) -mthumb-interwork -g -Oz -mabi=aapcs -mapcs -fno-short-enums -save-temps -combine -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-missing-braces -fomit-frame-pointer -c -include AutoGen.h -fno-stack-protector
+RELEASE_XCODE32_ARM_CC_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) -mthumb-interwork -Oz -mabi=aapcs -mapcs -fno-short-enums -save-temps -combine -fshort-wchar -fno-strict-aliasing -Wall -Werror -Wno-missing-braces -fomit-frame-pointer -c -include AutoGen.h -fno-stack-protector
+
+
+####################################################################################
+#
+# ARM Tools
+#
+####################################################################################
+# RVCT31 - Tools from ARM
+
+*_RVCT31_*_*_FAMILY = RVCT
+
+#
+# Use default values, or override in DSC file
+#
+*_RVCT31_ARM_ARCHCC_FLAGS = --thumb --cpu 7-A
+*_RVCT31_ARM_ARCHASM_FLAGS = --cpu 7-A
+*_RVCT31_ARM_ARCHDLINK_FLAGS =
+*_RVCT31_ARM_PLATFORM_FLAGS =
+
+ DEBUG_RVCT31_ARM_DLINK_FLAGS = $(ARCHDLINK_FLAGS) --entry $(IMAGE_ENTRY_POINT) --ro-base 0 --no_scanlib --reloc --no_exceptions --datacompressor off --strict --symbols --map --list $(DEST_DIR_DEBUG)/$(BASE_NAME).map --diag_style=ide
+RELEASE_RVCT31_ARM_DLINK_FLAGS = $(ARCHDLINK_FLAGS) --entry $(IMAGE_ENTRY_POINT) --ro-base 0 --no_scanlib --reloc --no_exceptions --datacompressor off --strict --symbols --map --list $(DEST_DIR_DEBUG)/$(BASE_NAME).map --diag_style=ide
+
+
+*_RVCT31_ARM_ASM_FLAGS = $(ARCHASM_FLAGS) --apcs /interwork --diag_style=ide
+*_RVCT31_ARM_PP_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) -E --diag_style=ide
+*_RVCT31_ARM_VFRPP_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) -E -DVFRCOMPILE --preinclude $(DEST_DIR_DEBUG)/$(MODULE_NAME)StrDefs.h
+*_RVCT31_ARM_MAKE_PATH = nmake
+*_RVCT31_ARM_SLINK_FLAGS = --partial --diag_style=ide -o
+ DEBUG_RVCT31_ARM_CC_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) --c90 -g -Ospace -c --no_autoinline --asm --gnu --apcs /interwork --signed_chars --no_unaligned_access --split_sections --enum_is_int --preinclude AutoGen.h --diag_warning 167 --diag_style=ide
+RELEASE_RVCT31_ARM_CC_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) --c90 -Ospace -c --no_autoinline --asm --gnu --apcs /interwork --signed_chars --no_unaligned_access --split_sections --enum_is_int --preinclude AutoGen.h --diag_warning 167 --diag_style=ide
+
+##################
+# ARM definitions
+##################
+*_RVCT31_ARM_CC_PATH = DEF(RVCT31_TOOLS_PATH)/armcc
+*_RVCT31_ARM_SLINK_PATH = DEF(RVCT31_TOOLS_PATH)/armlink
+*_RVCT31_ARM_DLINK_PATH = DEF(RVCT31_TOOLS_PATH)/armlink
+*_RVCT31_ARM_ASM_PATH = DEF(RVCT31_TOOLS_PATH)/armasm
+*_RVCT31_ARM_PP_PATH = DEF(RVCT31_TOOLS_PATH)/armcc
+*_RVCT31_ARM_VFRPP_PATH = DEF(RVCT31_TOOLS_PATH)/armcc
+*_RVCT31_ARM_FROMELF_PATH = DEF(RVCT31_TOOLS_PATH)/fromelf
+
+####################################################################################
+#
+# ARM Tools & Cygwin
+#
+####################################################################################
+# ARMCYGWIN - Tools from ARM in a Cygwin environment
+
+*_RVCT31CYGWIN_*_*_FAMILY = RVCT
+*_RVCT31CYGWIN_*_*_BUILDRULEFAMILY = RVCTCYGWIN
+
+*_RVCT31CYGWIN_ARM_CCPATH_FLAG = DEF(RVCT31CYGWIN_TOOLS_PATH)/armcc
+*_RVCT31CYGWIN_ARM_SLINKPATH_FLAG = DEF(RVCT31CYGWIN_TOOLS_PATH)/armlink
+*_RVCT31CYGWIN_ARM_DLINKPATH_FLAG = DEF(RVCT31CYGWIN_TOOLS_PATH)/armlink
+*_RVCT31CYGWIN_ARM_ASMPATH_FLAG = DEF(RVCT31CYGWIN_TOOLS_PATH)/armasm
+*_RVCT31CYGWIN_ARM_PPPATH_FLAG = DEF(RVCT31CYGWIN_TOOLS_PATH)/armcc
+*_RVCT31CYGWIN_ARM_VFRPPPATH_FLAG = DEF(RVCT31CYGWIN_TOOLS_PATH)/armcc
+*_RVCT31CYGWIN_ARM_FROMELFPATH_FLAG = DEF(RVCT31CYGWIN_TOOLS_PATH)/fromelf
+
+
+#
+# Use default values, or override in DSC file
+#
+*_RVCT31CYGWIN_ARM_ARCHCC_FLAGS = --thumb --cpu 7-A
+*_RVCT31CYGWIN_ARM_ARCHASM_FLAGS = --cpu 7-A
+*_RVCT31CYGWIN_ARM_ARCHDLINK_FLAGS =
+*_RVCT31CYGWIN_ARM_PLATFORM_FLAGS =
+
+ DEBUG_RVCT31CYGWIN_ARM_DLINK_FLAGS = "$(DLINKPATH_FLAG)" $(ARCHDLINK_FLAGS) --entry $(IMAGE_ENTRY_POINT) --ro-base 0 --no_scanlib --reloc --no_exceptions --datacompressor off --strict --symbols --map --list `cygpath -m $(DEST_DIR_DEBUG)/$(BASE_NAME).map` --diag_style=ide
+RELEASE_RVCT31CYGWIN_ARM_DLINK_FLAGS = "$(DLINKPATH_FLAG)" $(ARCHDLINK_FLAGS) --entry $(IMAGE_ENTRY_POINT) --ro-base 0 --no_scanlib --reloc --no_exceptions --datacompressor off --strict --symbols --map --list `cygpath -m $(DEST_DIR_DEBUG)/$(BASE_NAME).map` --diag_style=ide
+
+*_RVCT31CYGWIN_ARM_ASM_FLAGS = "$(ASMPATH_FLAG)" $(ARCHASM_FLAGS) --apcs /interwork --diag_style=ide
+*_RVCT31CYGWIN_ARM_PP_FLAGS = "$(CCPATH_FLAG)" $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) -E --diag_style=ide
+*_RVCT31CYGWIN_ARM_VFRPP_FLAGS = "$(CCPATH_FLAG)" $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) -E -DVFRCOMPILE --preinclude `cygpath -m $(DEST_DIR_DEBUG)/$(MODULE_NAME)StrDefs.h`
+*_RVCT31CYGWIN_ARM_MAKE_PATH = make
+*_RVCT31CYGWIN_ARM_SLINK_FLAGS = "$(SLINKPATH_FLAG)" --partial --diag_style=ide -o
+ DEBUG_RVCT31CYGWIN_ARM_CC_FLAGS = "$(CCPATH_FLAG)" $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) --c90 -c -g -Ospace --no_autoinline --asm --gnu --apcs /interwork --signed_chars --no_unaligned_access --split_sections --preinclude AutoGen.h --diag_warning 167 --diag_style=ide
+RELEASE_RVCT31CYGWIN_ARM_CC_FLAGS = "$(CCPATH_FLAG)" $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) --c90 -c -Ospace --no_autoinline --asm --gnu --apcs /interwork --signed_chars --no_unaligned_access --split_sections --preinclude AutoGen.h --diag_warning 167 --diag_style=ide
+
+##################
+# ARM definitions
+##################
+*_RVCT31CYGWIN_ARM_CC_PATH = ENV(WORKSPACE)/BaseTools/Bin/CYGWIN_NT-5.1-i686/armcc_wrapper.py
+*_RVCT31CYGWIN_ARM_SLINK_PATH = ENV(WORKSPACE)/BaseTools/Bin/CYGWIN_NT-5.1-i686/armcc_wrapper.py
+*_RVCT31CYGWIN_ARM_DLINK_PATH = ENV(WORKSPACE)/BaseTools/Bin/CYGWIN_NT-5.1-i686/armcc_wrapper.py
+*_RVCT31CYGWIN_ARM_ASM_PATH = ENV(WORKSPACE)/BaseTools/Bin/CYGWIN_NT-5.1-i686/armcc_wrapper.py
+*_RVCT31CYGWIN_ARM_PP_PATH = ENV(WORKSPACE)/BaseTools/Bin/CYGWIN_NT-5.1-i686/armcc_wrapper.py
+*_RVCT31CYGWIN_ARM_VFRPP_PATH = ENV(WORKSPACE)/BaseTools/Bin/CYGWIN_NT-5.1-i686/armcc_wrapper.py
+*_RVCT31CYGWIN_ARM_FROMELF_PATH = ENV(WORKSPACE)/BaseTools/Bin/CYGWIN_NT-5.1-i686/armcc_wrapper.py
+
+####################################################################################
+#
+# ARM GCC (www.codesourcery.com)
+#
+####################################################################################
+# ARMGCC - ARM version of the GCC cross compiler
+
+*_ARMGCC_*_*_FAMILY = GCC
+*_ARMGCC_*_*_BUILDRULEFAMILY = ARMGCC
+
+*_ARMGCC_*_MAKE_PATH = DEF(SOURCERY_TOOLS)/cs-make
+*_ARMGCC_*_MAKE_FLAGS = --no-print-directory
+
+##################
+# ASL definitions
+##################
+*_ARMGCC_*_ASL_PATH = DEF(UNIX_IASL_BIN)
+*_ARMGCC_*_ASL_FLAGS = DEF(IASL_FLAGS)
+*_ARMGCC_*_ASL_OUTFLAGS = DEF(IASL_OUTFLAGS)
+*_ARMGCC_*_ASLPP_FLAGS = -x c -E -P
+*_ARMGCC_*_ASLCC_FLAGS = -x c
+*_ARMGCC_*_ASLDLINK_FLAGS = DEF(GCC_DLINK_FLAGS_COMMON) --entry _ReferenceAcpiTable
+
+##################
+# ARM definitions
+##################
+
+*_ARMGCC_ARM_ASLCC_PATH = DEF(SOURCERY_TOOLS)/arm-none-eabi-gcc
+*_ARMGCC_ARM_ASLDLINK_PATH = DEF(SOURCERY_TOOLS)/arm-none-eabi-ld
+*_ARMGCC_ARM_ASLPP_PATH = DEF(SOURCERY_TOOLS)/arm-none-eabi-gcc
+
+*_ARMGCC_ARM_CC_PATH = DEF(SOURCERY_TOOLS)/arm-none-eabi-gcc
+*_ARMGCC_ARM_SLINK_PATH = DEF(SOURCERY_TOOLS)/arm-none-eabi-ar
+*_ARMGCC_ARM_DLINK_PATH = DEF(SOURCERY_TOOLS)/arm-none-eabi-ld
+*_ARMGCC_ARM_ASM_PATH = DEF(SOURCERY_TOOLS)/arm-none-eabi-as
+*_ARMGCC_ARM_PP_PATH = DEF(SOURCERY_TOOLS)/arm-none-eabi-gcc
+*_ARMGCC_ARM_VFRPP_PATH = DEF(SOURCERY_TOOLS)/arm-none-eabi-gcc
+
+#
+# Use default values, or override in DSC file
+#
+*_ARMGCC_ARM_ARCHCC_FLAGS = -march=armv7-a -mthumb
+*_ARMGCC_ARM_ARCHASM_FLAGS = -march=armv7-a
+*_ARMGCC_ARM_ARCHDLINK_FLAGS =
+*_ARMGCC_ARM_PLATFORM_FLAGS = -march=armv7-a
+
+ DEBUG_ARMGCC_ARM_ASM_FLAGS = $(ARCHASM_FLAGS) -mlittle-endian -g
+RELEASE_ARMGCC_ARM_ASM_FLAGS = $(ARCHASM_FLAGS) -mlittle-endian
+
+*_ARMGCC_ARM_PP_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) -E -x assembler-with-cpp -include $(DEST_DIR_DEBUG)/AutoGen.h
+*_ARMGCC_ARM_VFRPP_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) -x c -E -P -DVFRCOMPILE --include $(DEST_DIR_DEBUG)/$(MODULE_NAME)StrDefs.h
+
+*_ARMGCC_ARM_SLINK_FLAGS = -rc
+*_ARMGCC_ARM_DLINK_FLAGS = $(ARCHDLINK_FLAGS) --oformat=elf32-littlearm -nostdlib -u $(IMAGE_ENTRY_POINT) -e $(IMAGE_ENTRY_POINT) -Map $(DEST_DIR_DEBUG)/$(BASE_NAME).map
+#
+# Had to remove --emit-relocs to get compile working. Images don't work correctly (linked at 0, no relocations)
+# --emit-relocs
+#
+
+ DEBUG_ARMGCC_ARM_CC_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) -mfpu=fpa -mlittle-endian -g -O2 -mabi=aapcs -mapcs -fno-short-enums -save-temps -combine -fsigned-char -fshort-wchar -fno-strict-aliasing -ffunction-sections -fdata-sections -Wall -Werror -Wno-missing-braces -fomit-frame-pointer -c -include AutoGen.h
+RELEASE_ARMGCC_ARM_CC_FLAGS = $(ARCHCC_FLAGS) $(PLATFORM_FLAGS) -mfpu=fpa -mlittle-endian -O2 -mabi=aapcs -mapcs -fno-short-enums -save-temps -combine -fsigned-char -fshort-wchar -fno-strict-aliasing -ffunction-sections -fdata-sections -Wall -Werror -Wno-missing-braces -fomit-frame-pointer -c -include AutoGen.h
+
+#################
+# ASM 16 linker defintions
+#################
+*_*_*_ASMLINK_PATH = DEF(WINDDK_BIN16)\link16.exe
+*_*_*_ASMLINK_FLAGS = /nologo /tiny
+
+##################
+# VfrCompiler definitions
+##################
+*_*_*_VFR_PATH = VfrCompile
+*_*_*_VFR_FLAGS = -l -n
+
+##################
+# OptionRom tool definitions
+##################
+*_*_*_OPTROM_PATH = EfiRom
+*_*_*_OPTROM_FLAGS = -e
+
+##################
+# GenFw tool definitions
+##################
+*_*_*_GENFW_PATH = GenFw
+*_*_*_GENFW_FLAGS =
+
+##################
+# Asl Compiler definitions
+##################
+*_*_*_ASLCC_FLAGS = /nologo /c /FIAutoGen.h /TC /Dmain=ReferenceAcpiTable
+*_*_*_ASLDLINK_FLAGS = /NODEFAULTLIB /ENTRY:ReferenceAcpiTable /SUBSYSTEM:EFI_BOOT_SERVICE_DRIVER
+*_*_*_ASLPP_FLAGS = /nologo /EP /C
+*_*_*_ASL_FLAGS =
+
+##################
+# LzmaCompress tool definitions
+##################
+*_*_*_LZMA_PATH = LzmaCompress
+*_*_*_LZMA_GUID = EE4E5898-3914-4259-9D6E-DC7BD79403CF
+
+##################
+# TianoCompress tool definitions
+##################
+*_*_*_TIANO_PATH = TianoCompress
+*_*_*_TIANO_GUID = A31280AD-481E-41B6-95E8-127F4C984779
+
+##################
+# BPDG tool definitions
+##################
+*_*_*_VPDTOOL_PATH = BPDG
+*_*_*_VPDTOOL_GUID = 8C3D856A-9BE6-468E-850A-24F7A8D38E08
diff --git a/BaseTools/GNUmakefile b/BaseTools/GNUmakefile
new file mode 100644
index 0000000000..a3fa905c90
--- /dev/null
+++ b/BaseTools/GNUmakefile
@@ -0,0 +1,35 @@
+## @file
+# Windows makefile for Base Tools project build.
+#
+# Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.
+# 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.
+#
+
+all: subdirs
+
+LANGUAGES = C Python
+
+SOURCE_SUBDIRS := $(patsubst %,Source/%,$(sort $(LANGUAGES)))
+SUBDIRS := $(SOURCE_SUBDIRS) Tests
+CLEAN_SUBDIRS := $(patsubst %,%-clean,$(sort $(SUBDIRS)))
+
+.PHONY: subdirs $(SUBDIRS)
+subdirs: $(SUBDIRS)
+$(SUBDIRS):
+ $(MAKE) -C $@
+
+.PHONY: $(CLEAN_SUBDIRS)
+$(CLEAN_SUBDIRS):
+ -$(MAKE) -C $(@:-clean=) clean
+
+clean: $(CLEAN_SUBDIRS)
+
+test:
+ @$(MAKE) -C Tests
+
diff --git a/BaseTools/Makefile b/BaseTools/Makefile
new file mode 100644
index 0000000000..294c532732
--- /dev/null
+++ b/BaseTools/Makefile
@@ -0,0 +1,34 @@
+## @file
+# Windows makefile for Base Tools project build.
+#
+# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.
+# 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.
+#
+
+SUBDIRS = Source\C Source\Python
+
+all: c python
+
+c :
+ @Source\C\Makefiles\NmakeSubdirs.bat all Source\C
+
+python:
+ @Source\C\Makefiles\NmakeSubdirs.bat all Source\Python
+
+subdirs: $(SUBDIRS)
+ @Source\C\Makefiles\NmakeSubdirs.bat all $**
+
+.PHONY: clean
+clean:
+ @Source\C\Makefiles\NmakeSubdirs.bat clean $(SUBDIRS)
+
+.PHONY: cleanall
+cleanall:
+ @Source\C\Makefiles\NmakeSubdirs.bat cleanall $(SUBDIRS)
+
diff --git a/BaseTools/ReadMe.txt b/BaseTools/ReadMe.txt
new file mode 100644
index 0000000000..37691e98fd
--- /dev/null
+++ b/BaseTools/ReadMe.txt
@@ -0,0 +1,170 @@
+This directory contains the next generation of EDK II build tools and template files.
+Templates are located in the Conf directory, while the tools executables for
+Microsoft Windows 32-bit Operating Systems are located in the Bin\Win32 directory, other
+directory contatins tools source.
+
+1. Build step to generate the binary tools.
+
+=== Windows/Visual Studio Notes ===
+
+To build the BaseTools, you should run the standard vsvars32.bat script.
+
+In addition to this, you should set the following environment variables:
+
+ * EDK_TOOLS_PATH - Path to the BaseTools sub directory under the edk2 tree
+ * BASE_TOOLS_PATH - The directory where the BaseTools source is located.
+ (It is the same directory where this README.txt is located.)
+ * PYTHON_FREEZER_PATH - Path to where the python freezer tool is installed
+
+After this, you can run the toolsetup.bat file, which is in the same
+directory as this file. It should setup the remainder of the environment,
+and build the tools if necessary.
+
+Please also refer to the 'BuildNotes.txt' file for more information on
+building under Windows.
+
+=== Unix-like operating systems ===
+
+To build on Unix-like operating systems, you only need to type 'make' in
+the base directory of the project.
+
+=== Ubuntu Notes ===
+
+On Ubuntu, the following command should install all the necessary build
+packages to build all the C BaseTools:
+
+ sudo apt-get install build-essentials uuid-dev
+
+=== Python sqlite3 module ===
+On Windows, the cx_freeze will not copy the sqlite3.dll to the frozen
+binary directory (the same directory as build.exe and GenFds.exe).
+Please copy it manually from \DLLs.
+
+The Python distributed with most recent Linux will have sqlite3 module
+built in. If not, please install sqlit3 package separately.
+
+2. The binary tools will be updated only after passing developer testing.
+
+Current state of the tools is Proto-Type - not all tool functions have been implemented
+and there may be bugs in these tools. These tools are under constant development at
+this time.
+
+3. Tool usage introduction.
+BaseTools Simple Usage:
+1) Change the directory to the EDK2 root directory, where the edksetup.bat is
+2) Run "edksetup.bat NewBuild"
+3) Set the ACTIVE_PLATFORM to your desired platform description file
+ (%WORKSPACE%\Conf\target.txt)
+4) To build platform, run "build" command in non-module directory
+5) To build module individually, run "build" command in module directory, i.e. where the
+ *.inf file is
+
+Notes:
+1) The tree structure generated by build tools is similar to Ant build system.
+2) Makefile can be called directly by nmake for both top level platform and module. But
+ after you call "nmake cleanall", you have to call "build" command to rebuild platform
+ or modules because the AutoGen.* files have been be removed. The "makefile" itself
+ cannot generate AutoGen.* files. Only "build" command can.
+3) All .exe binary file including C and python tools are generated from:
+ r1911 \BaseTools\Source\.
+
+Brief usage for Migration Tool MigrationMsa2Inf.exe:
+1. Command line format:
+ MigrationMsa2Inf [options]
+2. Input Files:
+ A syntactically valid MSA file
+3. Output Files:
+ An extended INF file with possible auto-generated EntryPoint.c, CommonHeader.h/CommonHeader.txt, depending on options and module contents.
+4. Prerequisite:
+ a. The workspace directory must be specified either by environment variable or -w option.
+ b. The Framework Database file must exist to specify the available packages in current workspace.
+ Two possible locations are: (The first location overrides the second)
+ $(WORKSPACE)\Tools\Conf\FrameworkDatabase.db
+ $(WORKSPACE)\Conf\FrameworkDatabase.db.
+ The field in FrameworkDatabase.db lists all available packages in current workspace.
+ One example:
+
+ MdePkg/MdePkg.nspd
+ MdeModulePkg/MdeModulePkg.spd
+ IntelFrameworkPkg/IntelFrameworkPkg.spd
+
+ The package list in FrameworkDatabase.db is important to the final quality of migration:
+ (1) It suggests the new package location: Translate package dependency Guid in MSA to Workspace relative path.
+ If the package dependency Guid cannot be found in current workspace a warning message is raised.
+ (2) It collects the Protocol/Guid/Ppi GuidCName a package contains.
+ The GuidCName acts as "clue" to add e.g. #include in CommonHeader.h
+
+5. Example:
+ WORKSAPCE has already been set: $(WORKSPACE) = c:\work\EdkII.
+
+ a. MigrationMsa2Inf -f c:\work\EdkII\Nt32Pkg\WinNtThunkDxe\WinNtThunk.msa -o c:\work\EdkII\Nt32Pkg\WinNtThunkDxe\WinNtThunk.inf
+ b. MigrationMsa2Inf -f c:\work\EdkII\Nt32Pkg\WinNtThunkDxe\WinNtThunk.msa -a
+ Example a & b are equivalent to migrate WinNtThunk driver from EDKII to EDKII' code base.
+
+ c. MigrationMsa2Inf -f c:\work\EdkII\Nt32Pkg\WinNtThunkDxe\WinNtThunk.msa -a -c
+ The extra "-c" option performs several hardcode mapping due to the naming change in EDKII':
+ OldMdePkg Guid -> MdePkgGuid,
+ EdkModulePkg Guid -> MdeModulePkgGuid,
+ EdkGraphicsLib -> GraphicsLib
+ HiiLib -> HiiLibFramework
+ ...
+
+ d. MigrationMsa2Inf -f c:\work\EdkII\Nt32Pkg\WinNtThunkDxe\WinNtThunk.msa -m
+ The extra "-m" option suppresses the generation of "CommonHeader.h" and leave all C files intact.
+ Instead, it generates "CommonHeader.txt". Developers can manually copy its content to a local common header file in a module.
+
+6. Known Limitations:
+ a. Tool does not handle Exit Boot Services Callback & Virtual Address Changed Event. Developers need to handle it manually.
+ b. The #include is based on library class naming convention: The header filename for "AbcLib" class are "AbcLib.h" by convention.
+ c. The #include , and are added based on gGuidCName listed in MSA.
+ If a GuidCName cannot map to a package Guid/Protocol/Ppi header file, a warning message is raised.
+ If a module uses the definition in a pakcage Guid/Protocol/Ppi header file without list its associative GuidCName, the build will beak. Developer needs to manually add the include statement.
+ d. The [Depex] sections are generated from DXS files with Guid Macro translated to Guid CName by naming convention, etc.
+ If tool fails to "guess" the Guid CName from Guid Macro, it will leave the GuidMacro in [Depex] section for manual resolution.
+ e. When tool generates [Sources] section, the modifiers for source files are lost. (Need to add proper tool chain, etc)
+ f. When tool generates [LibraryClasses] section, the recommended library instances are lost. (No impact to build)
+
+7. Pyton Source
+ BaseTools\Source\Python\MigrationMsa2Inf
+
+Brief usage for Migration Tool Spd2Dec.exe:
+1. Command line format:
+ Spd2Dec [options] input_filename
+2. Input File:
+ A syntactically valid SPD file
+3. Output Files:
+ A DEC file whose syntax confirms to DEC spec.
+
+4. Example:
+ a. Spd2Dec -o c:\work\EdkII\Nt32Pkg\Nt32.spd c:\work\EdkII\Nt32Pkg\Nt32.dec
+ b. Spd2Dec -a c:\work\EdkII\Nt32Pkg\Nt32.spd
+ Example a & b are equivalent to migrate Nt32 package SPD file from EDKII to EDKII' snytax.
+
+6. Pyton Source
+ BaseTools\Source\Python\spd2dec
+
+Brief usage for Migration Tool Fpd2Dsc.exe:
+1. Command line format:
+ Fpd2Dsc [options] input_filename
+2. Input File:
+ A syntactically valid FPD file
+3. Output Files:
+ A DSC file which syntax confirms to DSC spec.
+4. Prerequisite:
+ a. The workspace directory must be specified either by environment variable or -w option.
+
+5. Example:
+ WORKSAPCE has already been set: $(WORKSPACE) = c:\work\EdkII.
+
+ a. Fpd2Dsc -o c:\work\EdkII\Nt32Pkg\Nt32.dsc c:\work\EdkII\Nt32Pkg\Nt32.fpd
+ b. Fpd2Dsc -a c:\work\EdkII\Nt32Pkg\Nt32.fpd
+ Example a & b are equivalent to migrate Nt32 platform description file from EDKII to EDKII' snytax.
+
+6. Known Limitations:
+ a. Tool does not handle Libraries Section since no related info in original FPD file. Developers need to handle it manually in the output DSC file.
+ b. If MSA file which is corresponds to module guid could not be found in currect workspace, tool will dump the module guid.
+
+7. Pyton Source
+ BaseTools\Source\Python\fpd2dsc
+
+4-Mar-2010
diff --git a/BaseTools/Scripts/gcc4.4-ld-script b/BaseTools/Scripts/gcc4.4-ld-script
new file mode 100644
index 0000000000..bb5b7d16c3
--- /dev/null
+++ b/BaseTools/Scripts/gcc4.4-ld-script
@@ -0,0 +1,43 @@
+/* OUTPUT_FORMAT(efi-bsdrv-x86_64) */
+SECTIONS
+{
+ /* . = 0 + SIZEOF_HEADERS; */
+ . = 0x280;
+ .text ALIGN(0x20) :
+ {
+ *(.text .stub .text.* .gnu.linkonce.t.*)
+ . = ALIGN(0x20);
+ } =0x90909090
+ .data ALIGN(0x20) :
+ {
+ *(
+ .rodata .rodata.* .gnu.linkonce.r.*
+ .data .data.* .gnu.linkonce.d.*
+ )
+ . = ALIGN(0x20);
+ }
+ .bss ALIGN(0x20) :
+ {
+ *(.bss .bss.*)
+ . = ALIGN(0x20);
+ }
+ .got ALIGN(0x20) :
+ {
+ *(.got .got.*)
+ . = ALIGN(0x20);
+ }
+ .rela ALIGN(0x20) :
+ {
+ *(.rela .rela.*)
+ }
+ /DISCARD/ : {
+ *(.note.GNU-stack) *(.gnu_debuglink)
+ *(.interp)
+ *(.dynsym)
+ *(.dynstr)
+ *(.dynamic)
+ *(.hash)
+ *(.comment)
+ }
+}
+
diff --git a/BaseTools/Source/C/BootSectImage/GNUmakefile b/BaseTools/Source/C/BootSectImage/GNUmakefile
new file mode 100644
index 0000000000..7703928dfc
--- /dev/null
+++ b/BaseTools/Source/C/BootSectImage/GNUmakefile
@@ -0,0 +1,22 @@
+## @file
+# Windows makefile for 'BootSectImage' module build.
+#
+# Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.
+# 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.
+#
+ARCH ?= IA32
+MAKEROOT ?= ..
+
+APPNAME = BootSectImage
+
+LIBS = -lCommon
+
+OBJECTS = bootsectimage.o
+
+include $(MAKEROOT)/Makefiles/app.makefile
diff --git a/BaseTools/Source/C/BootSectImage/Makefile b/BaseTools/Source/C/BootSectImage/Makefile
new file mode 100644
index 0000000000..5e27af5a87
--- /dev/null
+++ b/BaseTools/Source/C/BootSectImage/Makefile
@@ -0,0 +1,22 @@
+## @file
+# Windows makefile for 'BootSectImage' module build.
+#
+# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.
+# 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.
+#
+!INCLUDE ..\Makefiles\ms.common
+
+APPNAME = BootSectImage
+
+LIBS = $(LIB_PATH)\Common.lib
+
+OBJECTS = BootSectImage.obj
+
+!INCLUDE ..\Makefiles\ms.app
+
diff --git a/BaseTools/Source/C/BootSectImage/bootsectimage.c b/BaseTools/Source/C/BootSectImage/bootsectimage.c
new file mode 100644
index 0000000000..0d0a3cbf77
--- /dev/null
+++ b/BaseTools/Source/C/BootSectImage/bootsectimage.c
@@ -0,0 +1,950 @@
+/** @file
+
+Abstract:
+ Patch the BPB information in boot sector image file.
+ Patch the MBR code in MBR image file.
+
+Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
+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.
+
+**/
+
+#include
+#include
+#include "fat.h"
+#include "mbr.h"
+#include "EfiUtilityMsgs.h"
+#include "ParseInf.h"
+
+#define DEBUG_WARN 0x1
+#define DEBUG_ERROR 0x2
+
+//
+// Utility Name
+//
+#define UTILITY_NAME "BootSectImage"
+
+//
+// Utility version information
+//
+#define UTILITY_MAJOR_VERSION 0
+#define UTILITY_MINOR_VERSION 1
+
+void
+Version (
+ void
+ )
+/*++
+
+Routine Description:
+
+ Displays the standard utility information to SDTOUT
+
+Arguments:
+
+ None
+
+Returns:
+
+ None
+
+--*/
+{
+ printf ("%s v%d.%d - Utility to break a file into two pieces at the specified offset.\n", UTILITY_NAME, UTILITY_MAJOR_VERSION, UTILITY_MINOR_VERSION);
+ printf ("Copyright (c) 1999-2010 Intel Corporation. All rights reserved.\n");
+}
+
+void
+Usage (
+ void
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ Version();
+ printf ("\nUsage: \n\
+ BootSectImage\n\
+ [-f, --force force patch even if the FAT type of SrcImage and DstImage mismatch]\n\
+ [-m, --mbr process MBR instead of boot sector]\n\
+ [-p, --parse parse SrcImageFile]\n\
+ [-o, --output DstImage]\n\
+ [-g, --patch patch DstImage using data from SrcImageFile]\n\
+ [-v, --verbose]\n\
+ [--version]\n\
+ [-q, --quiet disable all messages except fatal errors]\n\
+ [-d, --debug[#]\n\
+ [-h, --help]\n\
+ [SrcImageFile]\n");
+}
+
+int WriteToFile (
+ void *BootSector,
+ char *FileName
+ )
+/*++
+Routine Description:
+ Write 512 bytes boot sector to file.
+
+Arguments:
+ BootSector - point to a buffer containing 512 bytes boot sector to write
+ FileName - file to write to
+
+Return:
+ int - number of bytes wrote,
+ 512 indicates write successful
+ 0 indicates write failure
+--*/
+{
+ FILE *FileHandle;
+ int result;
+
+ FileHandle = fopen (FileName, "r+b");
+ if (FileHandle == NULL) {
+ DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "Open file: %s", FileName);
+ return 0;
+ }
+ fseek (FileHandle, 0, SEEK_SET);
+
+ result = fwrite (BootSector, 1, 512, FileHandle);
+ if (result != 512) {
+ DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "Write file: %s", FileName);
+ result = 0;
+ }
+
+ fclose (FileHandle);
+ return result;
+}
+
+int ReadFromFile (
+ void *BootSector,
+ char *FileName
+ )
+/*++
+Routine Description:
+ Read first 512 bytes from file.
+
+Arguments:
+ BootSector - point to a buffer receiving the first 512 bytes data from file
+ FileName - file to read from
+
+Return:
+ int - number of bytes read,
+ 512 indicates read successful
+ 0 indicates read failure
+--*/
+{
+ FILE *FileHandle;
+ int result;
+
+ FileHandle = fopen (FileName, "rb");
+ if (FileHandle == NULL) {
+ DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "ERROR: E0001: Error opening file: %s", FileName);
+ return 0;
+ }
+
+ result = fread (BootSector, 1, 512, FileHandle);
+ if (result != 512) {
+ DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "ERROR: E0004: Error reading file: %s", FileName);
+ result = 0;
+ }
+
+ fclose (FileHandle);
+ return result;
+}
+
+char *
+FatTypeToString (
+ IN FAT_TYPE FatType
+ )
+/*++
+Routine Description:
+ Convert enum type of FatType to string
+--*/
+{
+ switch (FatType) {
+ case FatTypeFat12:
+ return "FAT12";
+ case FatTypeFat16:
+ return "FAT16";
+ case FatTypeFat32:
+ return "FAT32";
+ default:
+ break;
+ }
+ return "FAT Unknown";
+}
+
+FAT_TYPE
+GetFatType (
+ IN FAT_BPB_STRUCT *FatBpb
+ )
+/*++
+Routine Description:
+ Determine the FAT type according to BIOS Paramater Block (BPB) data
+
+Arguments:
+ FatBpb - BIOS Parameter Block (BPB) data, 512 Bytes
+
+Return:
+ FatTypeUnknown - Cannot determine the FAT type
+ FatTypeFat12 - FAT12
+ FatTypeFat16 - FAT16
+ FatTypeFat32 - FAT32
+--*/
+{
+ FAT_TYPE FatType;
+ UINTN RootDirSectors;
+ UINTN FATSz;
+ UINTN TotSec;
+ UINTN DataSec;
+ UINTN CountOfClusters;
+ CHAR8 FilSysType[9];
+
+ FatType = FatTypeUnknown;
+
+ //
+ // Simple check
+ //
+ if (FatBpb->Fat12_16.Signature != FAT_BS_SIGNATURE) {
+ DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "ERROR: E3003: FAT - Signature Invalid - %04x, expected: %04x",
+ FatBpb->Fat12_16.Signature, FAT_BS_SIGNATURE);
+ return FatTypeUnknown;
+ }
+
+ //
+ // Check according to FAT spec
+ //
+ if ((FatBpb->Fat12_16.BS_jmpBoot[0] != FAT_BS_JMP1) &&
+ (FatBpb->Fat12_16.BS_jmpBoot[0] != FAT_BS_JMP2)) {
+ DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "ERROR: E3003: FAT - BS_jmpBoot - %02x, expected: %02x or %02x",
+ FatBpb->Fat12_16.BS_jmpBoot[0], FAT_BS_JMP1, FAT_BS_JMP2);
+ return FatTypeUnknown;
+ }
+
+ if ((FatBpb->Fat12_16.BPB_BytsPerSec != 512) &&
+ (FatBpb->Fat12_16.BPB_BytsPerSec != 1024) &&
+ (FatBpb->Fat12_16.BPB_BytsPerSec != 2048) &&
+ (FatBpb->Fat12_16.BPB_BytsPerSec != 4096)) {
+ DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "ERROR: E3003: FAT - BPB_BytsPerSec - %04x, expected: %04x, %04x, %04x, or %04x",
+ FatBpb->Fat12_16.BPB_BytsPerSec, 512, 1024, 2048, 4096);
+ return FatTypeUnknown;
+ }
+ if (FatBpb->Fat12_16.BPB_BytsPerSec != 512) {
+ DebugMsg (NULL, 0, DEBUG_WARN, NULL, "ERROR: E3003: FAT - BPB_BytsPerSec - %04x, expected: %04x",
+ FatBpb->Fat12_16.BPB_BytsPerSec, 512);
+ }
+ if ((FatBpb->Fat12_16.BPB_SecPerClus != 1) &&
+ (FatBpb->Fat12_16.BPB_SecPerClus != 2) &&
+ (FatBpb->Fat12_16.BPB_SecPerClus != 4) &&
+ (FatBpb->Fat12_16.BPB_SecPerClus != 8) &&
+ (FatBpb->Fat12_16.BPB_SecPerClus != 16) &&
+ (FatBpb->Fat12_16.BPB_SecPerClus != 32) &&
+ (FatBpb->Fat12_16.BPB_SecPerClus != 64) &&
+ (FatBpb->Fat12_16.BPB_SecPerClus != 128)) {
+ DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "ERROR: E3003: FAT - BPB_SecPerClus - %02x, expected: %02x, %02x, %02x, %02x, %02x, %02x, %02x, or %02x",
+ FatBpb->Fat12_16.BPB_BytsPerSec, 1, 2, 4, 8, 16, 32, 64, 128);
+ return FatTypeUnknown;
+ }
+ if (FatBpb->Fat12_16.BPB_BytsPerSec * FatBpb->Fat12_16.BPB_SecPerClus > 32 * 1024) {
+ DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "ERROR: E3003: FAT - BPB_BytsPerSec * BPB_SecPerClus - %08x, expected: <= %08x",
+ FatBpb->Fat12_16.BPB_BytsPerSec * FatBpb->Fat12_16.BPB_SecPerClus, 32 * 1024);
+ return FatTypeUnknown;
+ }
+ if (FatBpb->Fat12_16.BPB_RsvdSecCnt == 0) {
+ DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "ERROR: E3003: FAT - BPB_RsvdSecCnt - %04x, expected: Non-Zero Value",
+ FatBpb->Fat12_16.BPB_RsvdSecCnt);
+ return FatTypeUnknown;
+ }
+ if (FatBpb->Fat12_16.BPB_NumFATs != 2) {
+ DebugMsg (NULL, 0, DEBUG_WARN, NULL, "ERROR: E3003: FAT - BPB_NumFATs - %02x, expected: %02x",
+ FatBpb->Fat12_16.BPB_NumFATs, 2);
+ }
+ if ((FatBpb->Fat12_16.BPB_Media != 0xF0) &&
+ (FatBpb->Fat12_16.BPB_Media != 0xF8) &&
+ (FatBpb->Fat12_16.BPB_Media != 0xF9) &&
+ (FatBpb->Fat12_16.BPB_Media != 0xFA) &&
+ (FatBpb->Fat12_16.BPB_Media != 0xFB) &&
+ (FatBpb->Fat12_16.BPB_Media != 0xFC) &&
+ (FatBpb->Fat12_16.BPB_Media != 0xFD) &&
+ (FatBpb->Fat12_16.BPB_Media != 0xFE) &&
+ (FatBpb->Fat12_16.BPB_Media != 0xFF)) {
+ DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "ERROR: E3003: FAT - BPB_Media - %02x, expected: %02x, %02x, %02x, %02x, %02x, %02x, %02x, %02x, or %02x",
+ FatBpb->Fat12_16.BPB_Media, 0xF0, 0xF8, 0xF9, 0xFA, 0xFB, 0xFC, 0xFD, 0xFE, 0xFF);
+ return FatTypeUnknown;
+ }
+
+ //
+ // Algo in FAT spec
+ //
+ RootDirSectors = ((FatBpb->Fat12_16.BPB_RootEntCnt * sizeof(FAT_DIRECTORY_ENTRY)) +
+ (FatBpb->Fat12_16.BPB_BytsPerSec - 1)) /
+ FatBpb->Fat12_16.BPB_BytsPerSec;
+
+ if (FatBpb->Fat12_16.BPB_FATSz16 != 0) {
+ FATSz = FatBpb->Fat12_16.BPB_FATSz16;
+ } else {
+ FATSz = FatBpb->Fat32.BPB_FATSz32;
+ }
+ if (FATSz == 0) {
+ DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "ERROR: E3003: FAT - BPB_FATSz16, BPB_FATSz32 - 0, expected: Non-Zero Value");
+ return FatTypeUnknown;
+ }
+
+ if (FatBpb->Fat12_16.BPB_TotSec16 != 0) {
+ TotSec = FatBpb->Fat12_16.BPB_TotSec16;
+ } else {
+ TotSec = FatBpb->Fat12_16.BPB_TotSec32;
+ }
+ if (TotSec == 0) {
+ DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "ERROR: E3003: FAT - BPB_TotSec16, BPB_TotSec32 - 0, expected: Non-Zero Value");
+ return FatTypeUnknown;
+ }
+
+ DataSec = TotSec - (
+ FatBpb->Fat12_16.BPB_RsvdSecCnt +
+ FatBpb->Fat12_16.BPB_NumFATs * FATSz +
+ RootDirSectors
+ );
+
+ CountOfClusters = DataSec / FatBpb->Fat12_16.BPB_SecPerClus;
+
+ if (CountOfClusters < FAT_MAX_FAT12_CLUSTER) {
+ FatType = FatTypeFat12;
+ } else if (CountOfClusters < FAT_MAX_FAT16_CLUSTER) {
+ FatType = FatTypeFat16;
+ } else {
+ FatType = FatTypeFat32;
+ }
+ //
+ // Check according to FAT spec
+ //
+ if (((FatType == FatTypeFat12) || (FatType == FatTypeFat16)) &&
+ (FatBpb->Fat12_16.BPB_RsvdSecCnt != 1)) {
+ DebugMsg (NULL, 0, DEBUG_WARN, NULL, "ERROR: E3003: FAT12_16 - BPB_RsvdSecCnt - %04x, expected: %04x",
+ FatBpb->Fat12_16.BPB_RsvdSecCnt, 1);
+ }
+ if ((FatType == FatTypeFat32) &&
+ (FatBpb->Fat12_16.BPB_RsvdSecCnt != 32)) {
+ DebugMsg (NULL, 0, DEBUG_WARN, NULL, "ERROR: E3003: FAT32 - BPB_RsvdSecCnt - %04x, expected: %04x",
+ FatBpb->Fat12_16.BPB_RsvdSecCnt, 32);
+ }
+ if ((FatType == FatTypeFat16) &&
+ (FatBpb->Fat12_16.BPB_RootEntCnt != 512)) {
+ printf ("WARNING: FAT16: BPB_RootEntCnt - %04x, expected - %04x\n",
+ FatBpb->Fat12_16.BPB_RootEntCnt, 512);
+ }
+ if ((FatType == FatTypeFat32) &&
+ (FatBpb->Fat12_16.BPB_RootEntCnt != 0)) {
+ DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "ERROR: E3003: FAT32 - BPB_RootEntCnt - %04x, expected: %04x",
+ FatBpb->Fat12_16.BPB_RootEntCnt, 0);
+ return FatTypeUnknown;
+ }
+ if ((FatType == FatTypeFat32) &&
+ (FatBpb->Fat12_16.BPB_TotSec16 != 0)) {
+ DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "ERROR: E3003: FAT32 - BPB_TotSec16 - %04x, expected: %04x",
+ FatBpb->Fat12_16.BPB_TotSec16, 0);
+ return FatTypeUnknown;
+ }
+ if ((FatType == FatTypeFat32) &&
+ (FatBpb->Fat12_16.BPB_FATSz16 != 0)) {
+ DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "ERROR: E3003: FAT32 - BPB_FATSz16 - %04x, expected: %04x",
+ FatBpb->Fat12_16.BPB_FATSz16, 0);
+ return FatTypeUnknown;
+ }
+ if ((FatType == FatTypeFat32) &&
+ (FatBpb->Fat12_16.BPB_TotSec32 == 0)) {
+ DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "ERROR: E3003: FAT32 - BPB_TotSec32 - %04x, expected: Non-Zero",
+ (unsigned) FatBpb->Fat12_16.BPB_TotSec32);
+ return FatTypeUnknown;
+ }
+ if ((FatType == FatTypeFat32) &&
+ (FatBpb->Fat32.BPB_FATSz32 == 0)) {
+ DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "ERROR: E3003: FAT32 - BPB_FATSz32 - %08x, expected: Non-Zero",
+ (unsigned) FatBpb->Fat32.BPB_FATSz32);
+ return FatTypeUnknown;
+ }
+ if ((FatType == FatTypeFat32) &&
+ (FatBpb->Fat32.BPB_FSVer != 0)) {
+ DebugMsg (NULL, 0, DEBUG_WARN, NULL, "ERROR: E3003: FAT32 - BPB_FSVer - %08x, expected: %04x",
+ FatBpb->Fat32.BPB_FSVer, 0);
+ }
+ if ((FatType == FatTypeFat32) &&
+ (FatBpb->Fat32.BPB_RootClus != 2)) {
+ DebugMsg (NULL, 0, DEBUG_WARN, NULL, "ERROR: E3003: FAT32 - BPB_RootClus - %08x, expected: %04x",
+ (unsigned) FatBpb->Fat32.BPB_RootClus, 2);
+ }
+ if ((FatType == FatTypeFat32) &&
+ (FatBpb->Fat32.BPB_FSInfo != 1)) {
+ DebugMsg (NULL, 0, DEBUG_WARN, NULL, "ERROR: E3003: FAT32 - BPB_FSInfo - %08x, expected: %04x",
+ FatBpb->Fat32.BPB_FSInfo, 1);
+ }
+ if ((FatType == FatTypeFat32) &&
+ (FatBpb->Fat32.BPB_BkBootSec != 6)) {
+ DebugMsg (NULL, 0, DEBUG_WARN, NULL, "ERROR: E3003: FAT32 - BPB_BkBootSec - %08x, expected: %04x",
+ FatBpb->Fat32.BPB_BkBootSec, 6);
+ }
+ if ((FatType == FatTypeFat32) &&
+ ((*(UINT32 *)FatBpb->Fat32.BPB_Reserved != 0) ||
+ (*((UINT32 *)FatBpb->Fat32.BPB_Reserved + 1) != 0) ||
+ (*((UINT32 *)FatBpb->Fat32.BPB_Reserved + 2) != 0))) {
+ DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "ERROR: E3003: FAT32 - BPB_Reserved - %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x, expected: 0",
+ FatBpb->Fat32.BPB_Reserved[0],
+ FatBpb->Fat32.BPB_Reserved[1],
+ FatBpb->Fat32.BPB_Reserved[2],
+ FatBpb->Fat32.BPB_Reserved[3],
+ FatBpb->Fat32.BPB_Reserved[4],
+ FatBpb->Fat32.BPB_Reserved[5],
+ FatBpb->Fat32.BPB_Reserved[6],
+ FatBpb->Fat32.BPB_Reserved[7],
+ FatBpb->Fat32.BPB_Reserved[8],
+ FatBpb->Fat32.BPB_Reserved[9],
+ FatBpb->Fat32.BPB_Reserved[10],
+ FatBpb->Fat32.BPB_Reserved[11]);
+ return FatTypeUnknown;
+ }
+ if (((FatType == FatTypeFat12) || (FatType == FatTypeFat16)) &&
+ (FatBpb->Fat12_16.BS_Reserved1 != 0)) {
+ DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "ERROR: E3003: FAT12_16 - BS_Reserved1 - %02x, expected: 0\n",
+ FatBpb->Fat12_16.BS_Reserved1);
+ return FatTypeUnknown;
+ }
+ if ((FatType == FatTypeFat32) &&
+ (FatBpb->Fat32.BS_Reserved1 != 0)) {
+ DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "ERROR: E3003: FAT32 - BS_Reserved1 - %02x, expected: 0\n",
+ FatBpb->Fat32.BS_Reserved1);
+ return FatTypeUnknown;
+ }
+ if (((FatType == FatTypeFat12) || (FatType == FatTypeFat16)) &&
+ (FatBpb->Fat12_16.BS_BootSig != FAT_BS_BOOTSIG)) {
+ DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "ERROR: E3003: FAT12_16 - BS_BootSig - %02x, expected: %02x\n",
+ FatBpb->Fat12_16.BS_BootSig, FAT_BS_BOOTSIG);
+ return FatTypeUnknown;
+ }
+ if ((FatType == FatTypeFat32) &&
+ (FatBpb->Fat32.BS_BootSig != FAT_BS_BOOTSIG)) {
+ DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "ERROR: E3003: FAT32 - BS_BootSig - %02x, expected: %02x\n",
+ FatBpb->Fat32.BS_BootSig, FAT_BS_BOOTSIG);
+ return FatTypeUnknown;
+ }
+
+ if ((FatType == FatTypeFat12) || (FatType == FatTypeFat16)) {
+ memcpy (FilSysType, FatBpb->Fat12_16.BS_FilSysType, 8);
+ FilSysType[8] = 0;
+ if ((FatType == FatTypeFat12) &&
+ (strcmp (FilSysType, FAT12_FILSYSTYPE) != 0) &&
+ (strcmp (FilSysType, FAT_FILSYSTYPE) != 0)) {
+ DebugMsg (NULL, 0, DEBUG_WARN, NULL, "ERROR: E3003: FAT12 - BS_FilSysType - %s, expected: %s, or %s\n",
+ FilSysType, FAT12_FILSYSTYPE, FAT_FILSYSTYPE);
+ }
+ if ((FatType == FatTypeFat16) &&
+ (strcmp (FilSysType, FAT16_FILSYSTYPE) != 0) &&
+ (strcmp (FilSysType, FAT_FILSYSTYPE) != 0)) {
+ DebugMsg (NULL, 0, DEBUG_WARN, NULL, "ERROR: E3003: FAT16 - BS_FilSysType - %s, expected: %s, or %s\n",
+ FilSysType, FAT16_FILSYSTYPE, FAT_FILSYSTYPE);
+ }
+ }
+ if (FatType == FatTypeFat32) {
+ memcpy (FilSysType, FatBpb->Fat32.BS_FilSysType, 8);
+ FilSysType[8] = 0;
+ if (strcmp (FilSysType, FAT32_FILSYSTYPE) != 0) {
+ DebugMsg (NULL, 0, DEBUG_WARN, NULL, "ERROR: E3003: FAT32 - BS_FilSysType - %s, expected: %s\n",
+ FilSysType, FAT32_FILSYSTYPE);
+ }
+ }
+
+ //
+ // pass all check, get FAT type
+ //
+ return FatType;
+}
+
+
+void
+ParseBootSector (
+ char *FileName
+ )
+{
+ FAT_BPB_STRUCT FatBpb;
+ FAT_TYPE FatType;
+
+ if (ReadFromFile ((void *)&FatBpb, FileName) == 0) {
+ return ;
+ }
+
+ FatType = GetFatType (&FatBpb);
+ if (FatType <= FatTypeUnknown || FatType >= FatTypeMax) {
+ printf ("ERROR: E3002: Unknown FAT Type!\n");
+ return;
+ }
+
+ printf ("\nBoot Sector %s:\n", FatTypeToString (FatType));
+ printf ("\n");
+ printf (" Offset Title Data\n");
+ printf ("==================================================================\n");
+ printf (" 0 JMP instruction %02x %02x %02x\n",
+ FatBpb.Fat12_16.BS_jmpBoot[0],
+ FatBpb.Fat12_16.BS_jmpBoot[1],
+ FatBpb.Fat12_16.BS_jmpBoot[2]);
+ printf (" 3 OEM %c%c%c%c%c%c%c%c\n",
+ FatBpb.Fat12_16.BS_OEMName[0],
+ FatBpb.Fat12_16.BS_OEMName[1],
+ FatBpb.Fat12_16.BS_OEMName[2],
+ FatBpb.Fat12_16.BS_OEMName[3],
+ FatBpb.Fat12_16.BS_OEMName[4],
+ FatBpb.Fat12_16.BS_OEMName[5],
+ FatBpb.Fat12_16.BS_OEMName[6],
+ FatBpb.Fat12_16.BS_OEMName[7]);
+ printf ("\n");
+ printf ("BIOS Parameter Block\n");
+ printf (" B Bytes per sector %04x\n", FatBpb.Fat12_16.BPB_BytsPerSec);
+ printf (" D Sectors per cluster %02x\n", FatBpb.Fat12_16.BPB_SecPerClus);
+ printf (" E Reserved sectors %04x\n", FatBpb.Fat12_16.BPB_RsvdSecCnt);
+ printf (" 10 Number of FATs %02x\n", FatBpb.Fat12_16.BPB_NumFATs);
+ printf (" 11 Root entries %04x\n", FatBpb.Fat12_16.BPB_RootEntCnt);
+ printf (" 13 Sectors (under 32MB) %04x\n", FatBpb.Fat12_16.BPB_TotSec16);
+ printf (" 15 Media descriptor %02x\n", FatBpb.Fat12_16.BPB_Media);
+ printf (" 16 Sectors per FAT (small vol.) %04x\n", FatBpb.Fat12_16.BPB_FATSz16);
+ printf (" 18 Sectors per track %04x\n", FatBpb.Fat12_16.BPB_SecPerTrk);
+ printf (" 1A Heads %04x\n", FatBpb.Fat12_16.BPB_NumHeads);
+ printf (" 1C Hidden sectors %08x\n", (unsigned) FatBpb.Fat12_16.BPB_HiddSec);
+ printf (" 20 Sectors (over 32MB) %08x\n", (unsigned) FatBpb.Fat12_16.BPB_TotSec32);
+ printf ("\n");
+ if (FatType != FatTypeFat32) {
+ printf (" 24 BIOS drive %02x\n", FatBpb.Fat12_16.BS_DrvNum);
+ printf (" 25 (Unused) %02x\n", FatBpb.Fat12_16.BS_Reserved1);
+ printf (" 26 Ext. boot signature %02x\n", FatBpb.Fat12_16.BS_BootSig);
+ printf (" 27 Volume serial number %08x\n", (unsigned) FatBpb.Fat12_16.BS_VolID);
+ printf (" 2B Volume lable %c%c%c%c%c%c%c%c%c%c%c\n",
+ FatBpb.Fat12_16.BS_VolLab[0],
+ FatBpb.Fat12_16.BS_VolLab[1],
+ FatBpb.Fat12_16.BS_VolLab[2],
+ FatBpb.Fat12_16.BS_VolLab[3],
+ FatBpb.Fat12_16.BS_VolLab[4],
+ FatBpb.Fat12_16.BS_VolLab[5],
+ FatBpb.Fat12_16.BS_VolLab[6],
+ FatBpb.Fat12_16.BS_VolLab[7],
+ FatBpb.Fat12_16.BS_VolLab[8],
+ FatBpb.Fat12_16.BS_VolLab[9],
+ FatBpb.Fat12_16.BS_VolLab[10]);
+ printf (" 36 File system %c%c%c%c%c%c%c%c\n",
+ FatBpb.Fat12_16.BS_FilSysType[0],
+ FatBpb.Fat12_16.BS_FilSysType[1],
+ FatBpb.Fat12_16.BS_FilSysType[2],
+ FatBpb.Fat12_16.BS_FilSysType[3],
+ FatBpb.Fat12_16.BS_FilSysType[4],
+ FatBpb.Fat12_16.BS_FilSysType[5],
+ FatBpb.Fat12_16.BS_FilSysType[6],
+ FatBpb.Fat12_16.BS_FilSysType[7]);
+ printf ("\n");
+ } else {
+ printf ("FAT32 Section\n");
+ printf (" 24 Sectors per FAT (large vol.) %08x\n", (unsigned) FatBpb.Fat32.BPB_FATSz32);
+ printf (" 28 Flags %04x\n", FatBpb.Fat32.BPB_ExtFlags);
+ printf (" 2A Version %04x\n", FatBpb.Fat32.BPB_FSVer);
+ printf (" 2C Root dir 1st cluster %08x\n", (unsigned) FatBpb.Fat32.BPB_RootClus);
+ printf (" 30 FSInfo sector %04x\n", FatBpb.Fat32.BPB_FSInfo);
+ printf (" 32 Backup boot sector %04x\n", FatBpb.Fat32.BPB_BkBootSec);
+ printf (" 34 (Reserved) %02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x%02x\n",
+ FatBpb.Fat32.BPB_Reserved[0],
+ FatBpb.Fat32.BPB_Reserved[1],
+ FatBpb.Fat32.BPB_Reserved[2],
+ FatBpb.Fat32.BPB_Reserved[3],
+ FatBpb.Fat32.BPB_Reserved[4],
+ FatBpb.Fat32.BPB_Reserved[5],
+ FatBpb.Fat32.BPB_Reserved[6],
+ FatBpb.Fat32.BPB_Reserved[7],
+ FatBpb.Fat32.BPB_Reserved[8],
+ FatBpb.Fat32.BPB_Reserved[9],
+ FatBpb.Fat32.BPB_Reserved[10],
+ FatBpb.Fat32.BPB_Reserved[11]);
+ printf ("\n");
+ printf (" 40 BIOS drive %02x\n", FatBpb.Fat32.BS_DrvNum);
+ printf (" 41 (Unused) %02x\n", FatBpb.Fat32.BS_Reserved1);
+ printf (" 42 Ext. boot signature %02x\n", FatBpb.Fat32.BS_BootSig);
+ printf (" 43 Volume serial number %08x\n", (unsigned) FatBpb.Fat32.BS_VolID);
+ printf (" 47 Volume lable %c%c%c%c%c%c%c%c%c%c%c\n",
+ FatBpb.Fat32.BS_VolLab[0],
+ FatBpb.Fat32.BS_VolLab[1],
+ FatBpb.Fat32.BS_VolLab[2],
+ FatBpb.Fat32.BS_VolLab[3],
+ FatBpb.Fat32.BS_VolLab[4],
+ FatBpb.Fat32.BS_VolLab[5],
+ FatBpb.Fat32.BS_VolLab[6],
+ FatBpb.Fat32.BS_VolLab[7],
+ FatBpb.Fat32.BS_VolLab[8],
+ FatBpb.Fat32.BS_VolLab[9],
+ FatBpb.Fat32.BS_VolLab[10]);
+ printf (" 52 File system %c%c%c%c%c%c%c%c\n",
+ FatBpb.Fat32.BS_FilSysType[0],
+ FatBpb.Fat32.BS_FilSysType[1],
+ FatBpb.Fat32.BS_FilSysType[2],
+ FatBpb.Fat32.BS_FilSysType[3],
+ FatBpb.Fat32.BS_FilSysType[4],
+ FatBpb.Fat32.BS_FilSysType[5],
+ FatBpb.Fat32.BS_FilSysType[6],
+ FatBpb.Fat32.BS_FilSysType[7]);
+ printf ("\n");
+ }
+ printf (" 1FE Signature %04x\n", FatBpb.Fat12_16.Signature);
+ printf ("\n");
+
+
+ return ;
+}
+
+void
+PatchBootSector (
+ char *DestFileName,
+ char *SourceFileName,
+ BOOLEAN ForcePatch
+ )
+/*++
+Routine Description:
+ Patch destination file according to the information from source file.
+ Only patch BPB data but leave boot code un-touched.
+
+Arguments:
+ DestFileName - Destination file to patch
+ SourceFileName - Source file where patch from
+--*/
+{
+ FAT_BPB_STRUCT DestFatBpb;
+ FAT_BPB_STRUCT SourceFatBpb;
+ FAT_TYPE DestFatType;
+ FAT_TYPE SourceFatType;
+ CHAR8 VolLab[11];
+ CHAR8 FilSysType[8];
+
+ if (ReadFromFile ((void *)&DestFatBpb, DestFileName) == 0) {
+ return ;
+ }
+ if (ReadFromFile ((void *)&SourceFatBpb, SourceFileName) == 0) {
+ return ;
+ }
+
+ DestFatType = GetFatType (&DestFatBpb);
+ SourceFatType = GetFatType (&SourceFatBpb);
+
+ if (DestFatType != SourceFatType) {
+ //
+ // FAT type mismatch
+ //
+ if (ForcePatch) {
+ DebugMsg (NULL, 0, DEBUG_WARN, NULL, "ERROR: E3004: FAT type mismatch: Source - %s, Dest - %s",
+ FatTypeToString(SourceFatType), FatTypeToString(DestFatType));
+ } else {
+ DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "ERROR: E3004: FAT type mismatch: Source - %s, Dest - %s",
+ FatTypeToString(SourceFatType), FatTypeToString(DestFatType));
+ return ;
+ }
+ }
+
+ if (SourceFatType <= FatTypeUnknown || SourceFatType >= FatTypeMax) {
+ DebugMsg (NULL, 0, DEBUG_ERROR, NULL, "ERROR: E3002: Unknown FAT Type!\n");
+ return;
+ }
+
+ //
+ // Copy BPB/boot data (excluding BS_jmpBoot, BS_OEMName, BootCode and Signature) from SourceFatBpb to DestFatBpb
+ //
+ printf ("Patching %s BPB: ", FatTypeToString (SourceFatType));
+ if (SourceFatType != FatTypeFat32) {
+ memcpy (
+ &DestFatBpb.Fat12_16.BPB_BytsPerSec,
+ &SourceFatBpb.Fat12_16.BPB_BytsPerSec,
+ ((UINTN)&DestFatBpb.Fat12_16.Reserved - (UINTN)&DestFatBpb.Fat12_16.BPB_BytsPerSec)
+ );
+ } else {
+ memcpy (
+ &DestFatBpb.Fat32.BPB_BytsPerSec,
+ &SourceFatBpb.Fat32.BPB_BytsPerSec,
+ ((UINTN)&DestFatBpb.Fat32.Reserved - (UINTN)&DestFatBpb.Fat32.BPB_BytsPerSec)
+ );
+ }
+
+ //
+ // Set BS_VolLab and BS_FilSysType of DestFatBpb
+ //
+ // BS_VolLab BS_FilSysType
+ // FAT12: EFI FAT12 FAT12
+ // FAT16: EFI FAT16 FAT16
+ // FAT32: EFI FAT32 FAT32
+ //
+ if (SourceFatType == FatTypeFat32) {
+ memcpy (VolLab, "EFI FAT32 ", sizeof(VolLab));
+ memcpy (FilSysType, FAT32_FILSYSTYPE, sizeof(FilSysType));
+ } else if (SourceFatType == FatTypeFat16) {
+ memcpy (VolLab, "EFI FAT16 ", sizeof(VolLab));
+ memcpy (FilSysType, FAT16_FILSYSTYPE, sizeof(FilSysType));
+ } else {
+ memcpy (VolLab, "EFI FAT12 ", sizeof(VolLab));
+ memcpy (FilSysType, FAT12_FILSYSTYPE, sizeof(FilSysType));
+ }
+ if (SourceFatType != FatTypeFat32) {
+ memcpy (DestFatBpb.Fat12_16.BS_VolLab, VolLab, sizeof(VolLab));
+ memcpy (DestFatBpb.Fat12_16.BS_FilSysType, FilSysType, sizeof(FilSysType));
+ } else {
+ memcpy (DestFatBpb.Fat32.BS_VolLab, VolLab, sizeof(VolLab));
+ memcpy (DestFatBpb.Fat32.BS_FilSysType, FilSysType, sizeof(FilSysType));
+ }
+
+ //
+ // Set Signature of DestFatBpb to 55AA
+ //
+ DestFatBpb.Fat12_16.Signature = FAT_BS_SIGNATURE;
+
+ //
+ // Write DestFatBpb
+ //
+ if (WriteToFile ((void *)&DestFatBpb, DestFileName)) {
+ printf ("successful!\n");
+ } else {
+ printf ("failed!\n");
+ }
+
+ return ;
+}
+
+void
+ParseMbr (
+ char *FileName
+ )
+{
+ MASTER_BOOT_RECORD Mbr;
+
+ if (ReadFromFile ((void *)&Mbr, FileName) == 0) {
+ return ;
+ }
+
+ printf ("\nMaster Boot Record:\n");
+ printf ("\n");
+ printf (" Offset Title Value\n");
+ printf ("==================================================================\n");
+ printf (" 0 Master bootstrap loader code (not list)\n");
+ printf (" 1B8 Windows disk signature %08x\n", (unsigned) Mbr.UniqueMbrSignature);
+ printf ("\n");
+ printf ("Partition Table Entry #1\n");
+ printf (" 1BE 80 = active partition %02x\n", Mbr.PartitionRecord[0].BootIndicator);
+ printf (" 1BF Start head %02x\n", Mbr.PartitionRecord[0].StartHead);
+ printf (" 1C0 Start sector %02x\n", Mbr.PartitionRecord[0].StartSector);
+ printf (" 1C1 Start cylinder %02x\n", Mbr.PartitionRecord[0].StartTrack);
+ printf (" 1C2 Partition type indicator %02x\n", Mbr.PartitionRecord[0].OSType);
+ printf (" 1C3 End head %02x\n", Mbr.PartitionRecord[0].EndHead);
+ printf (" 1C4 End sector %02x\n", Mbr.PartitionRecord[0].EndSector);
+ printf (" 1C5 End cylinder %02x\n", Mbr.PartitionRecord[0].EndTrack);
+ printf (" 1C6 Sectors preceding partition %08x\n", (unsigned) Mbr.PartitionRecord[0].StartingLBA);
+ printf (" 1CA Sectors in partition %08x\n", (unsigned) Mbr.PartitionRecord[0].SizeInLBA);
+ printf ("\n");
+ printf ("Partition Table Entry #2\n");
+ printf (" 1CE 80 = active partition %02x\n", Mbr.PartitionRecord[1].BootIndicator);
+ printf (" 1CF Start head %02x\n", Mbr.PartitionRecord[1].StartHead);
+ printf (" 1D0 Start sector %02x\n", Mbr.PartitionRecord[1].StartSector);
+ printf (" 1D1 Start cylinder %02x\n", Mbr.PartitionRecord[1].StartTrack);
+ printf (" 1D2 Partition type indicator %02x\n", Mbr.PartitionRecord[1].OSType);
+ printf (" 1D3 End head %02x\n", Mbr.PartitionRecord[1].EndHead);
+ printf (" 1D4 End sector %02x\n", Mbr.PartitionRecord[1].EndSector);
+ printf (" 1D5 End cylinder %02x\n", Mbr.PartitionRecord[1].EndTrack);
+ printf (" 1D6 Sectors preceding partition %08x\n", (unsigned) Mbr.PartitionRecord[1].StartingLBA);
+ printf (" 1DA Sectors in partition %08x\n", (unsigned) Mbr.PartitionRecord[1].SizeInLBA);
+ printf ("\n");
+ printf ("Partition Table Entry #3\n");
+ printf (" 1DE 80 = active partition %02x\n", Mbr.PartitionRecord[2].BootIndicator);
+ printf (" 1DF Start head %02x\n", Mbr.PartitionRecord[2].StartHead);
+ printf (" 1E0 Start sector %02x\n", Mbr.PartitionRecord[2].StartSector);
+ printf (" 1E1 Start cylinder %02x\n", Mbr.PartitionRecord[2].StartTrack);
+ printf (" 1E2 Partition type indicator %02x\n", Mbr.PartitionRecord[2].OSType);
+ printf (" 1E3 End head %02x\n", Mbr.PartitionRecord[2].EndHead);
+ printf (" 1E4 End sector %02x\n", Mbr.PartitionRecord[2].EndSector);
+ printf (" 1E5 End cylinder %02x\n", Mbr.PartitionRecord[2].EndTrack);
+ printf (" 1E6 Sectors preceding partition %08x\n", (unsigned) Mbr.PartitionRecord[2].StartingLBA);
+ printf (" 1EA Sectors in partition %08x\n", (unsigned) Mbr.PartitionRecord[2].SizeInLBA);
+ printf ("\n");
+ printf ("Partition Table Entry #4\n");
+ printf (" 1EE 80 = active partition %02x\n", Mbr.PartitionRecord[3].BootIndicator);
+ printf (" 1EF Start head %02x\n", Mbr.PartitionRecord[3].StartHead);
+ printf (" 1F0 Start sector %02x\n", Mbr.PartitionRecord[3].StartSector);
+ printf (" 1F1 Start cylinder %02x\n", Mbr.PartitionRecord[3].StartTrack);
+ printf (" 1F2 Partition type indicator %02x\n", Mbr.PartitionRecord[3].OSType);
+ printf (" 1F3 End head %02x\n", Mbr.PartitionRecord[3].EndHead);
+ printf (" 1F4 End sector %02x\n", Mbr.PartitionRecord[3].EndSector);
+ printf (" 1F5 End cylinder %02x\n", Mbr.PartitionRecord[3].EndTrack);
+ printf (" 1F6 Sectors preceding partition %08x\n", (unsigned) Mbr.PartitionRecord[3].StartingLBA);
+ printf (" 1FA Sectors in partition %08x\n", (unsigned) Mbr.PartitionRecord[3].SizeInLBA);
+ printf ("\n");
+ printf (" 1FE Signature %04x\n", Mbr.Signature);
+ printf ("\n");
+
+ return ;
+}
+
+void
+PatchMbr (
+ char *DestFileName,
+ char *SourceFileName
+ )
+{
+ MASTER_BOOT_RECORD DestMbr;
+ MASTER_BOOT_RECORD SourceMbr;
+
+ if (ReadFromFile ((void *)&DestMbr, DestFileName) == 0) {
+ return ;
+ }
+ if (ReadFromFile ((void *)&SourceMbr, SourceFileName) == 0) {
+ return ;
+ }
+
+ if (SourceMbr.Signature != MBR_SIGNATURE) {
+ printf ("ERROR: E3000: Invalid MBR!\n");
+ return;
+ }
+
+ printf ("Patching MBR:\n");
+ memcpy (
+ &DestMbr.PartitionRecord[0],
+ &SourceMbr.PartitionRecord[0],
+ sizeof(DestMbr.PartitionRecord)
+ );
+
+ DestMbr.Signature = MBR_SIGNATURE;
+
+
+ if (WriteToFile ((void *)&DestMbr, DestFileName)) {
+ printf ("\tsuccessful!\n");
+ }
+
+ return ;
+}
+
+
+int
+main (
+ int argc,
+ char *argv[]
+ )
+{
+ char *SrcImage;
+ char *DstImage;
+ BOOLEAN ForcePatch; // -f
+ BOOLEAN ProcessMbr; // -m
+ BOOLEAN DoParse; // -p SrcImage or -g SrcImage DstImage
+ BOOLEAN Verbose; // -v
+ UINT64 LogLevel;
+ EFI_STATUS EfiStatus;
+
+ SrcImage = DstImage = NULL;
+ ForcePatch = FALSE;
+ ProcessMbr = FALSE;
+ DoParse = TRUE;
+ Verbose = FALSE;
+
+ SetUtilityName ("bootsectimage");
+
+ argc--; argv++;
+
+ if (argc == 0) {
+ Usage ();
+ return -1;
+ }
+
+ while (argc != 0) {
+ if (strcmp (*argv, "-f") == 0 || strcmp (*argv, "--force") == 0) {
+ ForcePatch = TRUE;
+ } else if (strcmp (*argv, "-p") == 0 || strcmp (*argv, "--parse") == 0) {
+ DoParse = TRUE;
+ argc--; argv++;
+ if (argc < 1) {
+ Usage ();
+ return -1;
+ }
+ SrcImage = *argv;
+ } else if (strcmp (*argv, "-g") == 0 || strcmp (*argv, "--patch") == 0) {
+ DoParse = FALSE;
+ argc--; argv++;
+ if (argc < 2) {
+ Usage ();
+ return -1;
+ }
+ SrcImage = *argv;
+ argc--; argv++;
+ DstImage = *argv;
+ } else if (strcmp (*argv, "-m") == 0 || strcmp (*argv, "--mbr") == 0) {
+ ProcessMbr = TRUE;
+ } else if (strcmp (*argv, "-v") == 0 || strcmp (*argv, "--verbose") == 0) {
+ Verbose = TRUE;
+ } else if ((stricmp (*argv, "-d") == 0) || (stricmp (*argv, "--debug") == 0)) {
+ argc--; argv++;
+ if (argc < 1) {
+ Usage ();
+ return -1;
+ }
+ EfiStatus = AsciiStringToUint64 (*argv, FALSE, &LogLevel);
+ if (EFI_ERROR (EfiStatus)) {
+ Error (NULL, 0, 1003, "Invalid option value", "%s = %s", "--debug", *argv);
+ return 1;
+ }
+ if (LogLevel > 9) {
+ Error (NULL, 0, 1003, "Invalid option value", "Debug Level range is 0-9, currnt input level is %d", (int) LogLevel);
+ return 1;
+ }
+ SetPrintLevel (LogLevel);
+ DebugMsg (NULL, 0, 9, "Debug Mode Set", "Debug Output Mode Level %s is set!", *argv);
+ } else {
+ Usage ();
+ return -1;
+ }
+
+ argc--; argv++;
+ }
+
+ if (ForcePatch && DoParse) {
+ printf ("ERROR: E1002: Conflicting options: -f, -p. Cannot apply force(-f) to parse(-p)!\n");
+ Usage ();
+ return -1;
+ }
+ if (ForcePatch && !DoParse && ProcessMbr) {
+ printf ("ERROR: E1002: Conflicting options: -f, -g -m. Cannot apply force(-f) to processing MBR (-g -m)!\n");
+ Usage ();
+ return -1;
+ }
+
+ if (Verbose) {
+ SetPrintLevel (VERBOSE_LOG_LEVEL);
+ } else {
+ SetPrintLevel (KEY_LOG_LEVEL);
+ }
+
+ if (DoParse) {
+ if (ProcessMbr) {
+ ParseMbr (SrcImage);
+ } else {
+ ParseBootSector (SrcImage);
+ }
+ } else {
+ if (ProcessMbr) {
+ PatchMbr (DstImage, SrcImage);
+ } else {
+ PatchBootSector (DstImage, SrcImage, ForcePatch);
+ }
+ }
+
+ return 0;
+}
+
diff --git a/BaseTools/Source/C/BootSectImage/fat.h b/BaseTools/Source/C/BootSectImage/fat.h
new file mode 100644
index 0000000000..5827d18bb2
--- /dev/null
+++ b/BaseTools/Source/C/BootSectImage/fat.h
@@ -0,0 +1,152 @@
+/** @file
+
+ Fat file system structure and definition.
+
+Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.
+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.
+
+**/
+
+#ifndef _FAT_BPB_H_
+#define _FAT_BPB_H_
+
+#include "CommonLib.h"
+
+#pragma pack(1)
+
+typedef struct {
+ //
+ // Fat common field
+ //
+ UINT8 BS_jmpBoot[3];
+ CHAR8 BS_OEMName[8];
+ UINT16 BPB_BytsPerSec;
+ UINT8 BPB_SecPerClus;
+ UINT16 BPB_RsvdSecCnt;
+ UINT8 BPB_NumFATs;
+ UINT16 BPB_RootEntCnt;
+ UINT16 BPB_TotSec16;
+ UINT8 BPB_Media;
+ UINT16 BPB_FATSz16;
+ UINT16 BPB_SecPerTrk;
+ UINT16 BPB_NumHeads;
+ UINT32 BPB_HiddSec;
+ UINT32 BPB_TotSec32;
+
+ //
+ // Fat12/16 specific field
+ //
+ UINT8 BS_DrvNum;
+ UINT8 BS_Reserved1;
+ UINT8 BS_BootSig;
+ UINT32 BS_VolID;
+ CHAR8 BS_VolLab[11];
+ CHAR8 BS_FilSysType[8];
+
+ //
+ // Boot Code and Data
+ //
+ UINT8 Reserved[448];
+
+ //
+ // Fat common signature - 0xAA55
+ //
+ UINT16 Signature;
+} FAT12_16_BPB_STRUCT;
+
+typedef struct {
+ //
+ // Fat common field
+ //
+ UINT8 BS_jmpBoot[3];
+ CHAR8 BS_OEMName[8];
+ UINT16 BPB_BytsPerSec;
+ UINT8 BPB_SecPerClus;
+ UINT16 BPB_RsvdSecCnt;
+ UINT8 BPB_NumFATs;
+ UINT16 BPB_RootEntCnt;
+ UINT16 BPB_TotSec16;
+ UINT8 BPB_Media;
+ UINT16 BPB_FATSz16;
+ UINT16 BPB_SecPerTrk;
+ UINT16 BPB_NumHeads;
+ UINT32 BPB_HiddSec;
+ UINT32 BPB_TotSec32;
+
+ //
+ // Fat32 specific field
+ //
+ UINT32 BPB_FATSz32;
+ UINT16 BPB_ExtFlags;
+ UINT16 BPB_FSVer;
+ UINT32 BPB_RootClus;
+ UINT16 BPB_FSInfo;
+ UINT16 BPB_BkBootSec;
+ UINT8 BPB_Reserved[12];
+ UINT8 BS_DrvNum;
+ UINT8 BS_Reserved1;
+ UINT8 BS_BootSig;
+ UINT32 BS_VolID;
+ CHAR8 BS_VolLab[11];
+ CHAR8 BS_FilSysType[8];
+
+ //
+ // Boot Code and Data
+ //
+ UINT8 Reserved[420];
+
+ //
+ // Fat common signature - 0xAA55
+ //
+ UINT16 Signature;
+} FAT32_BPB_STRUCT;
+
+typedef union {
+ FAT12_16_BPB_STRUCT Fat12_16;
+ FAT32_BPB_STRUCT Fat32;
+} FAT_BPB_STRUCT;
+
+typedef enum {
+ FatTypeUnknown,
+ FatTypeFat12,
+ FatTypeFat16,
+ FatTypeFat32,
+ FatTypeMax
+} FAT_TYPE;
+
+typedef struct {
+ CHAR8 DIR_Name[11];
+ UINT8 DIR_Attr;
+ UINT8 DIR_NTRes;
+ UINT8 DIR_CrtTimeTenth;
+ UINT16 DIR_CrtTime;
+ UINT16 DIR_CrtDate;
+ UINT16 DIR_LstAccDate;
+ UINT16 DIR_FstClusHI;
+ UINT16 DIR_WrtTime;
+ UINT16 DIR_WrtDate;
+ UINT16 DIR_FstClusLO;
+ UINT32 DIR_FileSize;
+} FAT_DIRECTORY_ENTRY;
+
+#pragma pack()
+
+#define FAT_MAX_FAT12_CLUSTER 0xFF5
+#define FAT_MAX_FAT16_CLUSTER 0xFFF5
+
+#define FAT_BS_SIGNATURE 0xAA55
+#define FAT_BS_BOOTSIG 0x29
+#define FAT_BS_JMP1 0xEB
+#define FAT_BS_JMP2 0xE9
+#define FAT_FILSYSTYPE "FAT "
+#define FAT12_FILSYSTYPE "FAT12 "
+#define FAT16_FILSYSTYPE "FAT16 "
+#define FAT32_FILSYSTYPE "FAT32 "
+
+#endif
diff --git a/BaseTools/Source/C/BootSectImage/mbr.h b/BaseTools/Source/C/BootSectImage/mbr.h
new file mode 100644
index 0000000000..36d157da24
--- /dev/null
+++ b/BaseTools/Source/C/BootSectImage/mbr.h
@@ -0,0 +1,58 @@
+/** @file
+
+ MBR Partition Entry and Table structure defintions.
+
+Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.
+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.
+
+**/
+
+#ifndef _MBR_H_
+#define _MBR_H_
+
+#include "CommonLib.h"
+
+#pragma pack(1)
+
+#define MAX_MBR_PARTITIONS 4
+
+//
+// MBR Partition Entry
+//
+typedef struct {
+ UINT8 BootIndicator;
+ UINT8 StartHead;
+ UINT8 StartSector;
+ UINT8 StartTrack;
+ UINT8 OSType;
+ UINT8 EndHead;
+ UINT8 EndSector;
+ UINT8 EndTrack;
+ UINT32 StartingLBA;
+ UINT32 SizeInLBA;
+} MBR_PARTITION_RECORD;
+
+//
+// MBR Partition table
+//
+typedef struct {
+ UINT8 BootCode[440];
+ UINT32 UniqueMbrSignature;
+ UINT16 Unknown;
+ MBR_PARTITION_RECORD PartitionRecord[MAX_MBR_PARTITIONS];
+ UINT16 Signature;
+} MASTER_BOOT_RECORD;
+
+#pragma pack()
+
+#define MBR_SIGNATURE 0xAA55
+#define EXTENDED_DOS_PARTITION 0x05
+#define EXTENDED_WINDOWS_PARTITION 0x0F
+
+#endif
diff --git a/BaseTools/Source/C/Common/BasePeCoff.c b/BaseTools/Source/C/Common/BasePeCoff.c
new file mode 100644
index 0000000000..4a3f92fb15
--- /dev/null
+++ b/BaseTools/Source/C/Common/BasePeCoff.c
@@ -0,0 +1,1445 @@
+/** @file
+
+ Functions to get info and load PE/COFF image.
+
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.
+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.
+
+**/
+
+#include
+#include
+#include
+#include "PeCoffLib.h"
+
+typedef union {
+ VOID *Header;
+ EFI_IMAGE_OPTIONAL_HEADER32 *Optional32;
+ EFI_IMAGE_OPTIONAL_HEADER64 *Optional64;
+} EFI_IMAGE_OPTIONAL_HEADER_POINTER;
+
+STATIC
+RETURN_STATUS
+PeCoffLoaderGetPeHeader (
+ IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext,
+ OUT EFI_IMAGE_OPTIONAL_HEADER_UNION **PeHdr,
+ OUT EFI_TE_IMAGE_HEADER **TeHdr
+ );
+
+STATIC
+RETURN_STATUS
+PeCoffLoaderCheckImageType (
+ IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext,
+ IN EFI_IMAGE_OPTIONAL_HEADER_UNION *PeHdr,
+ IN EFI_TE_IMAGE_HEADER *TeHdr
+ );
+
+STATIC
+VOID *
+PeCoffLoaderImageAddress (
+ IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext,
+ IN UINTN Address
+ );
+
+RETURN_STATUS
+PeCoffLoaderRelocateIa32Image (
+ IN UINT16 *Reloc,
+ IN OUT CHAR8 *Fixup,
+ IN OUT CHAR8 **FixupData,
+ IN UINT64 Adjust
+ );
+
+RETURN_STATUS
+PeCoffLoaderRelocateX64Image (
+ IN UINT16 *Reloc,
+ IN OUT CHAR8 *Fixup,
+ IN OUT CHAR8 **FixupData,
+ IN UINT64 Adjust
+ );
+
+RETURN_STATUS
+PeCoffLoaderRelocateIpfImage (
+ IN UINT16 *Reloc,
+ IN OUT CHAR8 *Fixup,
+ IN OUT CHAR8 **FixupData,
+ IN UINT64 Adjust
+ );
+
+RETURN_STATUS
+PeCoffLoaderRelocateArmImage (
+ IN UINT16 **Reloc,
+ IN OUT CHAR8 *Fixup,
+ IN OUT CHAR8 **FixupData,
+ IN UINT64 Adjust
+ );
+
+STATIC
+RETURN_STATUS
+PeCoffLoaderGetPeHeader (
+ IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext,
+ OUT EFI_IMAGE_OPTIONAL_HEADER_UNION **PeHdr,
+ OUT EFI_TE_IMAGE_HEADER **TeHdr
+ )
+/*++
+
+Routine Description:
+
+ Retrieves the PE or TE Header from a PE/COFF or TE image
+
+Arguments:
+
+ ImageContext - The context of the image being loaded
+
+ PeHdr - The buffer in which to return the PE header
+
+ TeHdr - The buffer in which to return the TE header
+
+Returns:
+
+ RETURN_SUCCESS if the PE or TE Header is read,
+ Otherwise, the error status from reading the PE/COFF or TE image using the ImageRead function.
+
+--*/
+{
+ RETURN_STATUS Status;
+ EFI_IMAGE_DOS_HEADER DosHdr;
+ UINTN Size;
+
+ ImageContext->IsTeImage = FALSE;
+ //
+ // Read the DOS image headers
+ //
+ Size = sizeof (EFI_IMAGE_DOS_HEADER);
+ Status = ImageContext->ImageRead (
+ ImageContext->Handle,
+ 0,
+ &Size,
+ &DosHdr
+ );
+ if (RETURN_ERROR (Status)) {
+ ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ;
+ return Status;
+ }
+
+ ImageContext->PeCoffHeaderOffset = 0;
+ if (DosHdr.e_magic == EFI_IMAGE_DOS_SIGNATURE) {
+ //
+ // DOS image header is present, so read the PE header after the DOS image header
+ //
+ ImageContext->PeCoffHeaderOffset = DosHdr.e_lfanew;
+ }
+ //
+ // Get the PE/COFF Header pointer
+ //
+ *PeHdr = (EFI_IMAGE_OPTIONAL_HEADER_UNION *) ((UINTN)ImageContext->Handle + ImageContext->PeCoffHeaderOffset);
+ if ((*PeHdr)->Pe32.Signature != EFI_IMAGE_NT_SIGNATURE) {
+ //
+ // Check the PE/COFF Header Signature. If not, then try to get a TE header
+ //
+ *TeHdr = (EFI_TE_IMAGE_HEADER *)*PeHdr;
+ if ((*TeHdr)->Signature != EFI_TE_IMAGE_HEADER_SIGNATURE) {
+ return RETURN_UNSUPPORTED;
+ }
+ ImageContext->IsTeImage = TRUE;
+ }
+
+ return RETURN_SUCCESS;
+}
+
+STATIC
+RETURN_STATUS
+PeCoffLoaderCheckImageType (
+ IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext,
+ IN EFI_IMAGE_OPTIONAL_HEADER_UNION *PeHdr,
+ IN EFI_TE_IMAGE_HEADER *TeHdr
+ )
+/*++
+
+Routine Description:
+
+ Checks the PE or TE header of a PE/COFF or TE image to determine if it supported
+
+Arguments:
+
+ ImageContext - The context of the image being loaded
+
+ PeHdr - The buffer in which to return the PE header
+
+ TeHdr - The buffer in which to return the TE header
+
+Returns:
+
+ RETURN_SUCCESS if the PE/COFF or TE image is supported
+ RETURN_UNSUPPORTED of the PE/COFF or TE image is not supported.
+
+--*/
+{
+ //
+ // See if the machine type is supported.
+ // We support a native machine type (IA-32/Itanium-based)
+ //
+ if (ImageContext->IsTeImage == FALSE) {
+ ImageContext->Machine = PeHdr->Pe32.FileHeader.Machine;
+ } else {
+ ImageContext->Machine = TeHdr->Machine;
+ }
+
+ if (ImageContext->Machine != EFI_IMAGE_MACHINE_IA32 && \
+ ImageContext->Machine != EFI_IMAGE_MACHINE_IA64 && \
+ ImageContext->Machine != EFI_IMAGE_MACHINE_X64 && \
+ ImageContext->Machine != EFI_IMAGE_MACHINE_ARMT && \
+ ImageContext->Machine != EFI_IMAGE_MACHINE_EBC) {
+ if (ImageContext->Machine == IMAGE_FILE_MACHINE_ARM) {
+ //
+ // There are two types of ARM images. Pure ARM and ARM/Thumb.
+ // If we see the ARM say it is the ARM/Thumb so there is only
+ // a single machine type we need to check for ARM.
+ //
+ ImageContext->Machine = EFI_IMAGE_MACHINE_ARMT;
+ if (ImageContext->IsTeImage == FALSE) {
+ PeHdr->Pe32.FileHeader.Machine = ImageContext->Machine;
+ } else {
+ TeHdr->Machine = ImageContext->Machine;
+ }
+
+ } else {
+ //
+ // unsupported PeImage machine type
+ //
+ return RETURN_UNSUPPORTED;
+ }
+ }
+
+ //
+ // See if the image type is supported. We support EFI Applications,
+ // EFI Boot Service Drivers, EFI Runtime Drivers and EFI SAL Drivers.
+ //
+ if (ImageContext->IsTeImage == FALSE) {
+ ImageContext->ImageType = PeHdr->Pe32.OptionalHeader.Subsystem;
+ } else {
+ ImageContext->ImageType = (UINT16) (TeHdr->Subsystem);
+ }
+
+ if (ImageContext->ImageType != EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION && \
+ ImageContext->ImageType != EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER && \
+ ImageContext->ImageType != EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER && \
+ ImageContext->ImageType != EFI_IMAGE_SUBSYSTEM_SAL_RUNTIME_DRIVER) {
+ //
+ // upsupported PeImage subsystem type
+ //
+ return RETURN_UNSUPPORTED;
+ }
+
+ return RETURN_SUCCESS;
+}
+
+RETURN_STATUS
+EFIAPI
+PeCoffLoaderGetImageInfo (
+ IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
+ )
+/*++
+
+Routine Description:
+
+ Retrieves information on a PE/COFF image
+
+Arguments:
+
+ This - Calling context
+ ImageContext - The context of the image being loaded
+
+Returns:
+
+ RETURN_SUCCESS - The information on the PE/COFF image was collected.
+ RETURN_INVALID_PARAMETER - ImageContext is NULL.
+ RETURN_UNSUPPORTED - The PE/COFF image is not supported.
+ Otherwise - The error status from reading the PE/COFF image using the
+ ImageContext->ImageRead() function
+
+--*/
+{
+ RETURN_STATUS Status;
+ EFI_IMAGE_OPTIONAL_HEADER_UNION *PeHdr;
+ EFI_TE_IMAGE_HEADER *TeHdr;
+ EFI_IMAGE_DATA_DIRECTORY *DebugDirectoryEntry;
+ UINTN Size;
+ UINTN Index;
+ UINTN DebugDirectoryEntryRva;
+ UINTN DebugDirectoryEntryFileOffset;
+ UINTN SectionHeaderOffset;
+ EFI_IMAGE_SECTION_HEADER SectionHeader;
+ EFI_IMAGE_DEBUG_DIRECTORY_ENTRY DebugEntry;
+ EFI_IMAGE_OPTIONAL_HEADER_POINTER OptionHeader;
+
+ PeHdr = NULL;
+ TeHdr = NULL;
+ DebugDirectoryEntry = NULL;
+ DebugDirectoryEntryRva = 0;
+
+ if (NULL == ImageContext) {
+ return RETURN_INVALID_PARAMETER;
+ }
+ //
+ // Assume success
+ //
+ ImageContext->ImageError = IMAGE_ERROR_SUCCESS;
+
+ Status = PeCoffLoaderGetPeHeader (ImageContext, &PeHdr, &TeHdr);
+ if (RETURN_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Verify machine type
+ //
+ Status = PeCoffLoaderCheckImageType (ImageContext, PeHdr, TeHdr);
+ if (RETURN_ERROR (Status)) {
+ return Status;
+ }
+ OptionHeader.Header = (VOID *) &(PeHdr->Pe32.OptionalHeader);
+
+ //
+ // Retrieve the base address of the image
+ //
+ if (!(ImageContext->IsTeImage)) {
+ if (PeHdr->Pe32.OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
+ ImageContext->ImageAddress = (PHYSICAL_ADDRESS) OptionHeader.Optional32->ImageBase;
+ } else {
+ ImageContext->ImageAddress = (PHYSICAL_ADDRESS) OptionHeader.Optional64->ImageBase;
+ }
+ } else {
+ ImageContext->ImageAddress = (PHYSICAL_ADDRESS) (TeHdr->ImageBase + TeHdr->StrippedSize - sizeof (EFI_TE_IMAGE_HEADER));
+ }
+ //
+ // Initialize the alternate destination address to 0 indicating that it
+ // should not be used.
+ //
+ ImageContext->DestinationAddress = 0;
+
+ //
+ // Initialize the codeview pointer.
+ //
+ ImageContext->CodeView = NULL;
+ ImageContext->PdbPointer = NULL;
+
+ //
+ // Three cases with regards to relocations:
+ // - Image has base relocs, RELOCS_STRIPPED==0 => image is relocatable
+ // - Image has no base relocs, RELOCS_STRIPPED==1 => Image is not relocatable
+ // - Image has no base relocs, RELOCS_STRIPPED==0 => Image is relocatable but
+ // has no base relocs to apply
+ // Obviously having base relocations with RELOCS_STRIPPED==1 is invalid.
+ //
+ // Look at the file header to determine if relocations have been stripped, and
+ // save this info in the image context for later use.
+ //
+ if ((!(ImageContext->IsTeImage)) && ((PeHdr->Pe32.FileHeader.Characteristics & EFI_IMAGE_FILE_RELOCS_STRIPPED) != 0)) {
+ ImageContext->RelocationsStripped = TRUE;
+ } else if ((ImageContext->IsTeImage) && (TeHdr->DataDirectory[0].Size == 0)) {
+ ImageContext->RelocationsStripped = TRUE;
+ } else {
+ ImageContext->RelocationsStripped = FALSE;
+ }
+
+ if (!(ImageContext->IsTeImage)) {
+
+ if (PeHdr->Pe32.OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
+ ImageContext->ImageSize = (UINT64) OptionHeader.Optional32->SizeOfImage;
+ ImageContext->SectionAlignment = OptionHeader.Optional32->SectionAlignment;
+ ImageContext->SizeOfHeaders = OptionHeader.Optional32->SizeOfHeaders;
+
+ //
+ // Modify ImageSize to contain .PDB file name if required and initialize
+ // PdbRVA field...
+ //
+ if (OptionHeader.Optional32->NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_DEBUG) {
+ DebugDirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *) &(OptionHeader.Optional32->DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]);
+ DebugDirectoryEntryRva = DebugDirectoryEntry->VirtualAddress;
+ }
+ } else {
+ ImageContext->ImageSize = (UINT64) OptionHeader.Optional64->SizeOfImage;
+ ImageContext->SectionAlignment = OptionHeader.Optional64->SectionAlignment;
+ ImageContext->SizeOfHeaders = OptionHeader.Optional64->SizeOfHeaders;
+
+ //
+ // Modify ImageSize to contain .PDB file name if required and initialize
+ // PdbRVA field...
+ //
+ if (OptionHeader.Optional64->NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_DEBUG) {
+ DebugDirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *) &(OptionHeader.Optional64->DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]);
+ DebugDirectoryEntryRva = DebugDirectoryEntry->VirtualAddress;
+ }
+ }
+
+ if (DebugDirectoryEntryRva != 0) {
+ //
+ // Determine the file offset of the debug directory... This means we walk
+ // the sections to find which section contains the RVA of the debug
+ // directory
+ //
+ DebugDirectoryEntryFileOffset = 0;
+
+ SectionHeaderOffset = (UINTN)(
+ ImageContext->PeCoffHeaderOffset +
+ sizeof (UINT32) +
+ sizeof (EFI_IMAGE_FILE_HEADER) +
+ PeHdr->Pe32.FileHeader.SizeOfOptionalHeader
+ );
+
+ for (Index = 0; Index < PeHdr->Pe32.FileHeader.NumberOfSections; Index++) {
+ //
+ // Read section header from file
+ //
+ Size = sizeof (EFI_IMAGE_SECTION_HEADER);
+ Status = ImageContext->ImageRead (
+ ImageContext->Handle,
+ SectionHeaderOffset,
+ &Size,
+ &SectionHeader
+ );
+ if (RETURN_ERROR (Status)) {
+ ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ;
+ return Status;
+ }
+
+ if (DebugDirectoryEntryRva >= SectionHeader.VirtualAddress &&
+ DebugDirectoryEntryRva < SectionHeader.VirtualAddress + SectionHeader.Misc.VirtualSize) {
+ DebugDirectoryEntryFileOffset =
+ DebugDirectoryEntryRva - SectionHeader.VirtualAddress + SectionHeader.PointerToRawData;
+ break;
+ }
+
+ SectionHeaderOffset += sizeof (EFI_IMAGE_SECTION_HEADER);
+ }
+
+ if (DebugDirectoryEntryFileOffset != 0) {
+ for (Index = 0; Index < DebugDirectoryEntry->Size; Index += sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY)) {
+ //
+ // Read next debug directory entry
+ //
+ Size = sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY);
+ Status = ImageContext->ImageRead (
+ ImageContext->Handle,
+ DebugDirectoryEntryFileOffset + Index,
+ &Size,
+ &DebugEntry
+ );
+ if (RETURN_ERROR (Status)) {
+ ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ;
+ return Status;
+ }
+
+ if (DebugEntry.Type == EFI_IMAGE_DEBUG_TYPE_CODEVIEW) {
+ ImageContext->DebugDirectoryEntryRva = (UINT32) (DebugDirectoryEntryRva + Index);
+ if (DebugEntry.RVA == 0 && DebugEntry.FileOffset != 0) {
+ ImageContext->ImageSize += DebugEntry.SizeOfData;
+ }
+
+ return RETURN_SUCCESS;
+ }
+ }
+ }
+ }
+ } else {
+ ImageContext->ImageSize = 0;
+ ImageContext->SectionAlignment = 4096;
+ ImageContext->SizeOfHeaders = sizeof (EFI_TE_IMAGE_HEADER) + (UINTN) TeHdr->BaseOfCode - (UINTN) TeHdr->StrippedSize;
+
+ DebugDirectoryEntry = &TeHdr->DataDirectory[1];
+ DebugDirectoryEntryRva = DebugDirectoryEntry->VirtualAddress;
+ SectionHeaderOffset = (UINTN) (sizeof (EFI_TE_IMAGE_HEADER));
+
+ DebugDirectoryEntryFileOffset = 0;
+
+ for (Index = 0; Index < TeHdr->NumberOfSections;) {
+ //
+ // Read section header from file
+ //
+ Size = sizeof (EFI_IMAGE_SECTION_HEADER);
+ Status = ImageContext->ImageRead (
+ ImageContext->Handle,
+ SectionHeaderOffset,
+ &Size,
+ &SectionHeader
+ );
+ if (RETURN_ERROR (Status)) {
+ ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ;
+ return Status;
+ }
+
+ if (DebugDirectoryEntryRva >= SectionHeader.VirtualAddress &&
+ DebugDirectoryEntryRva < SectionHeader.VirtualAddress + SectionHeader.Misc.VirtualSize) {
+ DebugDirectoryEntryFileOffset = DebugDirectoryEntryRva -
+ SectionHeader.VirtualAddress +
+ SectionHeader.PointerToRawData +
+ sizeof (EFI_TE_IMAGE_HEADER) -
+ TeHdr->StrippedSize;
+
+ //
+ // File offset of the debug directory was found, if this is not the last
+ // section, then skip to the last section for calculating the image size.
+ //
+ if (Index < (UINTN) TeHdr->NumberOfSections - 1) {
+ SectionHeaderOffset += (TeHdr->NumberOfSections - 1 - Index) * sizeof (EFI_IMAGE_SECTION_HEADER);
+ Index = TeHdr->NumberOfSections - 1;
+ continue;
+ }
+ }
+
+ //
+ // In Te image header there is not a field to describe the ImageSize.
+ // Actually, the ImageSize equals the RVA plus the VirtualSize of
+ // the last section mapped into memory (Must be rounded up to
+ // a mulitple of Section Alignment). Per the PE/COFF specification, the
+ // section headers in the Section Table must appear in order of the RVA
+ // values for the corresponding sections. So the ImageSize can be determined
+ // by the RVA and the VirtualSize of the last section header in the
+ // Section Table.
+ //
+ if ((++Index) == (UINTN) TeHdr->NumberOfSections) {
+ ImageContext->ImageSize = (SectionHeader.VirtualAddress + SectionHeader.Misc.VirtualSize +
+ ImageContext->SectionAlignment - 1) & ~(ImageContext->SectionAlignment - 1);
+ }
+
+ SectionHeaderOffset += sizeof (EFI_IMAGE_SECTION_HEADER);
+ }
+
+ if (DebugDirectoryEntryFileOffset != 0) {
+ for (Index = 0; Index < DebugDirectoryEntry->Size; Index += sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY)) {
+ //
+ // Read next debug directory entry
+ //
+ Size = sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY);
+ Status = ImageContext->ImageRead (
+ ImageContext->Handle,
+ DebugDirectoryEntryFileOffset,
+ &Size,
+ &DebugEntry
+ );
+ if (RETURN_ERROR (Status)) {
+ ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ;
+ return Status;
+ }
+
+ if (DebugEntry.Type == EFI_IMAGE_DEBUG_TYPE_CODEVIEW) {
+ ImageContext->DebugDirectoryEntryRva = (UINT32) (DebugDirectoryEntryRva + Index);
+ return RETURN_SUCCESS;
+ }
+ }
+ }
+ }
+
+ return RETURN_SUCCESS;
+}
+
+STATIC
+VOID *
+PeCoffLoaderImageAddress (
+ IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext,
+ IN UINTN Address
+ )
+/*++
+
+Routine Description:
+
+ Converts an image address to the loaded address
+
+Arguments:
+
+ ImageContext - The context of the image being loaded
+
+ Address - The address to be converted to the loaded address
+
+Returns:
+
+ NULL if the address can not be converted, otherwise, the converted address
+
+--*/
+{
+ if (Address >= ImageContext->ImageSize) {
+ ImageContext->ImageError = IMAGE_ERROR_INVALID_IMAGE_ADDRESS;
+ return NULL;
+ }
+
+ return (UINT8 *) ((UINTN) ImageContext->ImageAddress + Address);
+}
+
+RETURN_STATUS
+EFIAPI
+PeCoffLoaderRelocateImage (
+ IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
+ )
+/*++
+
+Routine Description:
+
+ Relocates a PE/COFF image in memory
+
+Arguments:
+
+ This - Calling context
+
+ ImageContext - Contains information on the loaded image to relocate
+
+Returns:
+
+ RETURN_SUCCESS if the PE/COFF image was relocated
+ RETURN_LOAD_ERROR if the image is not a valid PE/COFF image
+ RETURN_UNSUPPORTED not support
+
+--*/
+{
+ RETURN_STATUS Status;
+ EFI_IMAGE_OPTIONAL_HEADER_UNION *PeHdr;
+ EFI_TE_IMAGE_HEADER *TeHdr;
+ EFI_IMAGE_DATA_DIRECTORY *RelocDir;
+ UINT64 Adjust;
+ EFI_IMAGE_BASE_RELOCATION *RelocBase;
+ EFI_IMAGE_BASE_RELOCATION *RelocBaseEnd;
+ UINT16 *Reloc;
+ UINT16 *RelocEnd;
+ CHAR8 *Fixup;
+ CHAR8 *FixupBase;
+ UINT16 *F16;
+ UINT32 *F32;
+ CHAR8 *FixupData;
+ PHYSICAL_ADDRESS BaseAddress;
+ UINT16 MachineType;
+ EFI_IMAGE_OPTIONAL_HEADER_POINTER OptionHeader;
+
+ PeHdr = NULL;
+ TeHdr = NULL;
+ //
+ // Assume success
+ //
+ ImageContext->ImageError = IMAGE_ERROR_SUCCESS;
+
+ //
+ // If there are no relocation entries, then we are done
+ //
+ if (ImageContext->RelocationsStripped) {
+ return RETURN_SUCCESS;
+ }
+
+ //
+ // Use DestinationAddress field of ImageContext as the relocation address even if it is 0.
+ //
+ BaseAddress = ImageContext->DestinationAddress;
+
+ if (!(ImageContext->IsTeImage)) {
+ PeHdr = (EFI_IMAGE_OPTIONAL_HEADER_UNION *)((UINTN)ImageContext->ImageAddress +
+ ImageContext->PeCoffHeaderOffset);
+ OptionHeader.Header = (VOID *) &(PeHdr->Pe32.OptionalHeader);
+ if (PeHdr->Pe32.OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
+ Adjust = (UINT64) BaseAddress - OptionHeader.Optional32->ImageBase;
+ OptionHeader.Optional32->ImageBase = (UINT32) BaseAddress;
+ MachineType = ImageContext->Machine;
+ //
+ // Find the relocation block
+ //
+ // Per the PE/COFF spec, you can't assume that a given data directory
+ // is present in the image. You have to check the NumberOfRvaAndSizes in
+ // the optional header to verify a desired directory entry is there.
+ //
+ if (OptionHeader.Optional32->NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC) {
+ RelocDir = &OptionHeader.Optional32->DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC];
+ RelocBase = PeCoffLoaderImageAddress (ImageContext, RelocDir->VirtualAddress);
+ RelocBaseEnd = PeCoffLoaderImageAddress (
+ ImageContext,
+ RelocDir->VirtualAddress + RelocDir->Size - 1
+ );
+ } else {
+ //
+ // Set base and end to bypass processing below.
+ //
+ RelocBase = RelocBaseEnd = 0;
+ }
+ } else {
+ Adjust = (UINT64) BaseAddress - OptionHeader.Optional64->ImageBase;
+ OptionHeader.Optional64->ImageBase = BaseAddress;
+ MachineType = ImageContext->Machine;
+ //
+ // Find the relocation block
+ //
+ // Per the PE/COFF spec, you can't assume that a given data directory
+ // is present in the image. You have to check the NumberOfRvaAndSizes in
+ // the optional header to verify a desired directory entry is there.
+ //
+ if (OptionHeader.Optional64->NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC) {
+ RelocDir = &OptionHeader.Optional64->DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC];
+ RelocBase = PeCoffLoaderImageAddress (ImageContext, RelocDir->VirtualAddress);
+ RelocBaseEnd = PeCoffLoaderImageAddress (
+ ImageContext,
+ RelocDir->VirtualAddress + RelocDir->Size - 1
+ );
+ } else {
+ //
+ // Set base and end to bypass processing below.
+ //
+ RelocBase = RelocBaseEnd = 0;
+ }
+ }
+ } else {
+ TeHdr = (EFI_TE_IMAGE_HEADER *) (UINTN) (ImageContext->ImageAddress);
+ Adjust = (UINT64) (BaseAddress - TeHdr->ImageBase);
+ TeHdr->ImageBase = (UINT64) (BaseAddress);
+ MachineType = TeHdr->Machine;
+
+ //
+ // Find the relocation block
+ //
+ RelocDir = &TeHdr->DataDirectory[0];
+ RelocBase = (EFI_IMAGE_BASE_RELOCATION *)(UINTN)(
+ ImageContext->ImageAddress +
+ RelocDir->VirtualAddress +
+ sizeof(EFI_TE_IMAGE_HEADER) -
+ TeHdr->StrippedSize
+ );
+ RelocBaseEnd = (EFI_IMAGE_BASE_RELOCATION *) ((UINTN) RelocBase + (UINTN) RelocDir->Size - 1);
+ }
+
+ //
+ // Run the relocation information and apply the fixups
+ //
+ FixupData = ImageContext->FixupData;
+ while (RelocBase < RelocBaseEnd) {
+
+ Reloc = (UINT16 *) ((CHAR8 *) RelocBase + sizeof (EFI_IMAGE_BASE_RELOCATION));
+ RelocEnd = (UINT16 *) ((CHAR8 *) RelocBase + RelocBase->SizeOfBlock);
+ if (!(ImageContext->IsTeImage)) {
+ FixupBase = PeCoffLoaderImageAddress (ImageContext, RelocBase->VirtualAddress);
+ } else {
+ FixupBase = (CHAR8 *)(UINTN)(ImageContext->ImageAddress +
+ RelocBase->VirtualAddress +
+ sizeof(EFI_TE_IMAGE_HEADER) -
+ TeHdr->StrippedSize
+ );
+ }
+
+ if ((CHAR8 *) RelocEnd < (CHAR8 *) ((UINTN) ImageContext->ImageAddress) ||
+ (CHAR8 *) RelocEnd > (CHAR8 *)((UINTN)ImageContext->ImageAddress +
+ (UINTN)ImageContext->ImageSize)) {
+ ImageContext->ImageError = IMAGE_ERROR_FAILED_RELOCATION;
+ return RETURN_LOAD_ERROR;
+ }
+
+ //
+ // Run this relocation record
+ //
+ while (Reloc < RelocEnd) {
+
+ Fixup = FixupBase + (*Reloc & 0xFFF);
+ switch ((*Reloc) >> 12) {
+ case EFI_IMAGE_REL_BASED_ABSOLUTE:
+ break;
+
+ case EFI_IMAGE_REL_BASED_HIGH:
+ F16 = (UINT16 *) Fixup;
+ *F16 = (UINT16) (*F16 + ((UINT16) ((UINT32) Adjust >> 16)));
+ if (FixupData != NULL) {
+ *(UINT16 *) FixupData = *F16;
+ FixupData = FixupData + sizeof (UINT16);
+ }
+ break;
+
+ case EFI_IMAGE_REL_BASED_LOW:
+ F16 = (UINT16 *) Fixup;
+ *F16 = (UINT16) (*F16 + (UINT16) Adjust);
+ if (FixupData != NULL) {
+ *(UINT16 *) FixupData = *F16;
+ FixupData = FixupData + sizeof (UINT16);
+ }
+ break;
+
+ case EFI_IMAGE_REL_BASED_HIGHLOW:
+ F32 = (UINT32 *) Fixup;
+ *F32 = *F32 + (UINT32) Adjust;
+ if (FixupData != NULL) {
+ FixupData = ALIGN_POINTER (FixupData, sizeof (UINT32));
+ *(UINT32 *) FixupData = *F32;
+ FixupData = FixupData + sizeof (UINT32);
+ }
+ break;
+
+ case EFI_IMAGE_REL_BASED_HIGHADJ:
+ //
+ // Return the same EFI_UNSUPPORTED return code as
+ // PeCoffLoaderRelocateImageEx() returns if it does not recognize
+ // the relocation type.
+ //
+ ImageContext->ImageError = IMAGE_ERROR_FAILED_RELOCATION;
+ return RETURN_UNSUPPORTED;
+
+ default:
+ switch (MachineType) {
+ case EFI_IMAGE_MACHINE_IA32:
+ Status = PeCoffLoaderRelocateIa32Image (Reloc, Fixup, &FixupData, Adjust);
+ break;
+ case EFI_IMAGE_MACHINE_ARMT:
+ Status = PeCoffLoaderRelocateArmImage (&Reloc, Fixup, &FixupData, Adjust);
+ break;
+ case EFI_IMAGE_MACHINE_X64:
+ Status = PeCoffLoaderRelocateX64Image (Reloc, Fixup, &FixupData, Adjust);
+ break;
+ case EFI_IMAGE_MACHINE_IA64:
+ Status = PeCoffLoaderRelocateIpfImage (Reloc, Fixup, &FixupData, Adjust);
+ break;
+ default:
+ Status = RETURN_UNSUPPORTED;
+ break;
+ }
+ if (RETURN_ERROR (Status)) {
+ ImageContext->ImageError = IMAGE_ERROR_FAILED_RELOCATION;
+ return Status;
+ }
+ }
+
+ //
+ // Next relocation record
+ //
+ Reloc += 1;
+ }
+
+ //
+ // Next reloc block
+ //
+ RelocBase = (EFI_IMAGE_BASE_RELOCATION *) RelocEnd;
+ }
+
+ return RETURN_SUCCESS;
+}
+
+RETURN_STATUS
+EFIAPI
+PeCoffLoaderLoadImage (
+ IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
+ )
+/*++
+
+Routine Description:
+
+ Loads a PE/COFF image into memory
+
+Arguments:
+
+ This - Calling context
+
+ ImageContext - Contains information on image to load into memory
+
+Returns:
+
+ RETURN_SUCCESS if the PE/COFF image was loaded
+ RETURN_BUFFER_TOO_SMALL if the caller did not provide a large enough buffer
+ RETURN_LOAD_ERROR if the image is a runtime driver with no relocations
+ RETURN_INVALID_PARAMETER if the image address is invalid
+
+--*/
+{
+ RETURN_STATUS Status;
+ EFI_IMAGE_OPTIONAL_HEADER_UNION *PeHdr;
+ EFI_TE_IMAGE_HEADER *TeHdr;
+ PE_COFF_LOADER_IMAGE_CONTEXT CheckContext;
+ EFI_IMAGE_SECTION_HEADER *FirstSection;
+ EFI_IMAGE_SECTION_HEADER *Section;
+ UINTN NumberOfSections;
+ UINTN Index;
+ CHAR8 *Base;
+ CHAR8 *End;
+ CHAR8 *MaxEnd;
+ EFI_IMAGE_DATA_DIRECTORY *DirectoryEntry;
+ EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *DebugEntry;
+ UINTN Size;
+ UINT32 TempDebugEntryRva;
+ EFI_IMAGE_OPTIONAL_HEADER_POINTER OptionHeader;
+
+ PeHdr = NULL;
+ TeHdr = NULL;
+ OptionHeader.Header = NULL;
+ //
+ // Assume success
+ //
+ ImageContext->ImageError = IMAGE_ERROR_SUCCESS;
+
+ //
+ // Copy the provided context info into our local version, get what we
+ // can from the original image, and then use that to make sure everything
+ // is legit.
+ //
+ CopyMem (&CheckContext, ImageContext, sizeof (PE_COFF_LOADER_IMAGE_CONTEXT));
+
+ Status = PeCoffLoaderGetImageInfo (&CheckContext);
+ if (RETURN_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Make sure there is enough allocated space for the image being loaded
+ //
+ if (ImageContext->ImageSize < CheckContext.ImageSize) {
+ ImageContext->ImageError = IMAGE_ERROR_INVALID_IMAGE_SIZE;
+ return RETURN_BUFFER_TOO_SMALL;
+ }
+
+ //
+ // If there's no relocations, then make sure it's not a runtime driver,
+ // and that it's being loaded at the linked address.
+ //
+ if (CheckContext.RelocationsStripped) {
+ //
+ // If the image does not contain relocations and it is a runtime driver
+ // then return an error.
+ //
+ if (CheckContext.ImageType == EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER) {
+ ImageContext->ImageError = IMAGE_ERROR_INVALID_SUBSYSTEM;
+ return RETURN_LOAD_ERROR;
+ }
+ //
+ // If the image does not contain relocations, and the requested load address
+ // is not the linked address, then return an error.
+ //
+ if (CheckContext.ImageAddress != ImageContext->ImageAddress) {
+ ImageContext->ImageError = IMAGE_ERROR_INVALID_IMAGE_ADDRESS;
+ return RETURN_INVALID_PARAMETER;
+ }
+ }
+ //
+ // Make sure the allocated space has the proper section alignment
+ //
+ if (!(ImageContext->IsTeImage)) {
+ if ((ImageContext->ImageAddress & (CheckContext.SectionAlignment - 1)) != 0) {
+ ImageContext->ImageError = IMAGE_ERROR_INVALID_SECTION_ALIGNMENT;
+ return RETURN_INVALID_PARAMETER;
+ }
+ }
+ //
+ // Read the entire PE/COFF or TE header into memory
+ //
+ if (!(ImageContext->IsTeImage)) {
+ Status = ImageContext->ImageRead (
+ ImageContext->Handle,
+ 0,
+ &ImageContext->SizeOfHeaders,
+ (VOID *) (UINTN) ImageContext->ImageAddress
+ );
+
+ PeHdr = (EFI_IMAGE_OPTIONAL_HEADER_UNION *)
+ ((UINTN)ImageContext->ImageAddress + ImageContext->PeCoffHeaderOffset);
+
+ OptionHeader.Header = (VOID *) &(PeHdr->Pe32.OptionalHeader);
+
+ FirstSection = (EFI_IMAGE_SECTION_HEADER *) (
+ (UINTN)ImageContext->ImageAddress +
+ ImageContext->PeCoffHeaderOffset +
+ sizeof(UINT32) +
+ sizeof(EFI_IMAGE_FILE_HEADER) +
+ PeHdr->Pe32.FileHeader.SizeOfOptionalHeader
+ );
+ NumberOfSections = (UINTN) (PeHdr->Pe32.FileHeader.NumberOfSections);
+ } else {
+ Status = ImageContext->ImageRead (
+ ImageContext->Handle,
+ 0,
+ &ImageContext->SizeOfHeaders,
+ (VOID *) (UINTN) ImageContext->ImageAddress
+ );
+
+ TeHdr = (EFI_TE_IMAGE_HEADER *) (UINTN) (ImageContext->ImageAddress);
+
+ FirstSection = (EFI_IMAGE_SECTION_HEADER *) (
+ (UINTN)ImageContext->ImageAddress +
+ sizeof(EFI_TE_IMAGE_HEADER)
+ );
+ NumberOfSections = (UINTN) (TeHdr->NumberOfSections);
+
+ }
+
+ if (RETURN_ERROR (Status)) {
+ ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ;
+ return RETURN_LOAD_ERROR;
+ }
+
+ //
+ // Load each section of the image
+ //
+ Section = FirstSection;
+ for (Index = 0, MaxEnd = NULL; Index < NumberOfSections; Index++) {
+
+ //
+ // Compute sections address
+ //
+ Base = PeCoffLoaderImageAddress (ImageContext, Section->VirtualAddress);
+ End = PeCoffLoaderImageAddress (
+ ImageContext,
+ Section->VirtualAddress + Section->Misc.VirtualSize - 1
+ );
+ if (ImageContext->IsTeImage) {
+ Base = (CHAR8 *) ((UINTN) Base + sizeof (EFI_TE_IMAGE_HEADER) - (UINTN) TeHdr->StrippedSize);
+ End = (CHAR8 *) ((UINTN) End + sizeof (EFI_TE_IMAGE_HEADER) - (UINTN) TeHdr->StrippedSize);
+ }
+
+ if (End > MaxEnd) {
+ MaxEnd = End;
+ }
+ //
+ // If the base start or end address resolved to 0, then fail.
+ //
+ if ((Base == NULL) || (End == NULL)) {
+ ImageContext->ImageError = IMAGE_ERROR_SECTION_NOT_LOADED;
+ return RETURN_LOAD_ERROR;
+ }
+
+ //
+ // Read the section
+ //
+ Size = (UINTN) Section->Misc.VirtualSize;
+ if ((Size == 0) || (Size > Section->SizeOfRawData)) {
+ Size = (UINTN) Section->SizeOfRawData;
+ }
+
+ if (Section->SizeOfRawData) {
+ if (!(ImageContext->IsTeImage)) {
+ Status = ImageContext->ImageRead (
+ ImageContext->Handle,
+ Section->PointerToRawData,
+ &Size,
+ Base
+ );
+ } else {
+ Status = ImageContext->ImageRead (
+ ImageContext->Handle,
+ Section->PointerToRawData + sizeof (EFI_TE_IMAGE_HEADER) - (UINTN) TeHdr->StrippedSize,
+ &Size,
+ Base
+ );
+ }
+
+ if (RETURN_ERROR (Status)) {
+ ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ;
+ return Status;
+ }
+ }
+
+ //
+ // If raw size is less then virt size, zero fill the remaining
+ //
+
+ if (Size < Section->Misc.VirtualSize) {
+ ZeroMem (Base + Size, Section->Misc.VirtualSize - Size);
+ }
+
+ //
+ // Next Section
+ //
+ Section += 1;
+ }
+
+ //
+ // Get image's entry point
+ //
+ if (!(ImageContext->IsTeImage)) {
+ ImageContext->EntryPoint = (PHYSICAL_ADDRESS) (UINTN) PeCoffLoaderImageAddress (
+ ImageContext,
+ PeHdr->Pe32.OptionalHeader.AddressOfEntryPoint
+ );
+ } else {
+ ImageContext->EntryPoint = (PHYSICAL_ADDRESS) (
+ (UINTN)ImageContext->ImageAddress +
+ (UINTN)TeHdr->AddressOfEntryPoint +
+ (UINTN)sizeof(EFI_TE_IMAGE_HEADER) -
+ (UINTN) TeHdr->StrippedSize
+ );
+ }
+
+ //
+ // Determine the size of the fixup data
+ //
+ // Per the PE/COFF spec, you can't assume that a given data directory
+ // is present in the image. You have to check the NumberOfRvaAndSizes in
+ // the optional header to verify a desired directory entry is there.
+ //
+ if (!(ImageContext->IsTeImage)) {
+ if (PeHdr->Pe32.OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
+ if (OptionHeader.Optional32->NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC) {
+ DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)
+ &OptionHeader.Optional32->DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC];
+ ImageContext->FixupDataSize = DirectoryEntry->Size / sizeof (UINT16) * sizeof (UINTN);
+ } else {
+ ImageContext->FixupDataSize = 0;
+ }
+ } else {
+ if (OptionHeader.Optional64->NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC) {
+ DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)
+ &OptionHeader.Optional64->DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC];
+ ImageContext->FixupDataSize = DirectoryEntry->Size / sizeof (UINT16) * sizeof (UINTN);
+ } else {
+ ImageContext->FixupDataSize = 0;
+ }
+ }
+ } else {
+ DirectoryEntry = &TeHdr->DataDirectory[0];
+ ImageContext->FixupDataSize = DirectoryEntry->Size / sizeof (UINT16) * sizeof (UINTN);
+ }
+ //
+ // Consumer must allocate a buffer for the relocation fixup log.
+ // Only used for runtime drivers.
+ //
+ ImageContext->FixupData = NULL;
+
+ //
+ // Load the Codeview info if present
+ //
+ if (ImageContext->DebugDirectoryEntryRva != 0) {
+ if (!(ImageContext->IsTeImage)) {
+ DebugEntry = PeCoffLoaderImageAddress (
+ ImageContext,
+ ImageContext->DebugDirectoryEntryRva
+ );
+ } else {
+ DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *)(UINTN)(
+ ImageContext->ImageAddress +
+ ImageContext->DebugDirectoryEntryRva +
+ sizeof(EFI_TE_IMAGE_HEADER) -
+ TeHdr->StrippedSize
+ );
+ }
+
+ if (DebugEntry != NULL) {
+ TempDebugEntryRva = DebugEntry->RVA;
+ if (DebugEntry->RVA == 0 && DebugEntry->FileOffset != 0) {
+ Section--;
+ if ((UINTN) Section->SizeOfRawData < Section->Misc.VirtualSize) {
+ TempDebugEntryRva = Section->VirtualAddress + Section->Misc.VirtualSize;
+ } else {
+ TempDebugEntryRva = Section->VirtualAddress + Section->SizeOfRawData;
+ }
+ }
+
+ if (TempDebugEntryRva != 0) {
+ if (!(ImageContext->IsTeImage)) {
+ ImageContext->CodeView = PeCoffLoaderImageAddress (ImageContext, TempDebugEntryRva);
+ } else {
+ ImageContext->CodeView = (VOID *)(
+ (UINTN)ImageContext->ImageAddress +
+ (UINTN)TempDebugEntryRva +
+ (UINTN)sizeof(EFI_TE_IMAGE_HEADER) -
+ (UINTN) TeHdr->StrippedSize
+ );
+ }
+
+ if (ImageContext->CodeView == NULL) {
+ ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ;
+ return RETURN_LOAD_ERROR;
+ }
+
+ if (DebugEntry->RVA == 0) {
+ Size = DebugEntry->SizeOfData;
+ if (!(ImageContext->IsTeImage)) {
+ Status = ImageContext->ImageRead (
+ ImageContext->Handle,
+ DebugEntry->FileOffset,
+ &Size,
+ ImageContext->CodeView
+ );
+ } else {
+ Status = ImageContext->ImageRead (
+ ImageContext->Handle,
+ DebugEntry->FileOffset + sizeof (EFI_TE_IMAGE_HEADER) - TeHdr->StrippedSize,
+ &Size,
+ ImageContext->CodeView
+ );
+ //
+ // Should we apply fix up to this field according to the size difference between PE and TE?
+ // Because now we maintain TE header fields unfixed, this field will also remain as they are
+ // in original PE image.
+ //
+ }
+
+ if (RETURN_ERROR (Status)) {
+ ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ;
+ return RETURN_LOAD_ERROR;
+ }
+
+ DebugEntry->RVA = TempDebugEntryRva;
+ }
+
+ switch (*(UINT32 *) ImageContext->CodeView) {
+ case CODEVIEW_SIGNATURE_NB10:
+ ImageContext->PdbPointer = (CHAR8 *) ImageContext->CodeView + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY);
+ break;
+
+ case CODEVIEW_SIGNATURE_RSDS:
+ ImageContext->PdbPointer = (CHAR8 *) ImageContext->CodeView + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY);
+ break;
+
+ case CODEVIEW_SIGNATURE_MTOC:
+ ImageContext->PdbPointer = (CHAR8 *) ImageContext->CodeView + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_MTOC_ENTRY);
+
+ default:
+ break;
+ }
+ }
+ }
+ }
+
+ return Status;
+}
+
+/**
+ Returns a pointer to the PDB file name for a raw PE/COFF image that is not
+ loaded into system memory with the PE/COFF Loader Library functions.
+
+ Returns the PDB file name for the PE/COFF image specified by Pe32Data. If
+ the PE/COFF image specified by Pe32Data is not a valid, then NULL is
+ returned. If the PE/COFF image specified by Pe32Data does not contain a
+ debug directory entry, then NULL is returned. If the debug directory entry
+ in the PE/COFF image specified by Pe32Data does not contain a PDB file name,
+ then NULL is returned.
+ If Pe32Data is NULL, then return NULL.
+
+ @param Pe32Data Pointer to the PE/COFF image that is loaded in system
+ memory.
+
+ @return The PDB file name for the PE/COFF image specified by Pe32Data or NULL
+ if it cannot be retrieved.
+
+**/
+VOID *
+EFIAPI
+PeCoffLoaderGetPdbPointer (
+ IN VOID *Pe32Data
+ )
+{
+ EFI_IMAGE_DOS_HEADER *DosHdr;
+ EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr;
+ EFI_IMAGE_DATA_DIRECTORY *DirectoryEntry;
+ EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *DebugEntry;
+ UINTN DirCount;
+ VOID *CodeViewEntryPointer;
+ INTN TEImageAdjust;
+ UINT32 NumberOfRvaAndSizes;
+ UINT16 Magic;
+ EFI_IMAGE_SECTION_HEADER *SectionHeader;
+ UINT32 Index, Index1;
+
+ if (Pe32Data == NULL) {
+ return NULL;
+ }
+
+ TEImageAdjust = 0;
+ DirectoryEntry = NULL;
+ DebugEntry = NULL;
+ NumberOfRvaAndSizes = 0;
+ Index = 0;
+ Index1 = 0;
+ SectionHeader = NULL;
+
+ DosHdr = (EFI_IMAGE_DOS_HEADER *)Pe32Data;
+ if (EFI_IMAGE_DOS_SIGNATURE == DosHdr->e_magic) {
+ //
+ // DOS image header is present, so read the PE header after the DOS image header.
+ //
+ Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN) Pe32Data + (UINTN) ((DosHdr->e_lfanew) & 0x0ffff));
+ } else {
+ //
+ // DOS image header is not present, so PE header is at the image base.
+ //
+ Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)Pe32Data;
+ }
+
+ if (EFI_TE_IMAGE_HEADER_SIGNATURE == Hdr.Te->Signature) {
+ if (Hdr.Te->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress != 0) {
+ DirectoryEntry = &Hdr.Te->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG];
+ TEImageAdjust = sizeof (EFI_TE_IMAGE_HEADER) - Hdr.Te->StrippedSize;
+
+ //
+ // Get the DebugEntry offset in the raw data image.
+ //
+ SectionHeader = (EFI_IMAGE_SECTION_HEADER *) (Hdr.Te + 1);
+ Index = Hdr.Te->NumberOfSections;
+ for (Index1 = 0; Index1 < Index; Index1 ++) {
+ if ((DirectoryEntry->VirtualAddress >= SectionHeader[Index1].VirtualAddress) &&
+ (DirectoryEntry->VirtualAddress < (SectionHeader[Index1].VirtualAddress + SectionHeader[Index1].Misc.VirtualSize))) {
+ DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *)((UINTN) Hdr.Te +
+ DirectoryEntry->VirtualAddress -
+ SectionHeader [Index1].VirtualAddress +
+ SectionHeader [Index1].PointerToRawData +
+ TEImageAdjust);
+ break;
+ }
+ }
+ }
+ } else if (EFI_IMAGE_NT_SIGNATURE == Hdr.Pe32->Signature) {
+ //
+ // NOTE: We use Machine field to identify PE32/PE32+, instead of Magic.
+ // It is due to backward-compatibility, for some system might
+ // generate PE32+ image with PE32 Magic.
+ //
+ switch (Hdr.Pe32->FileHeader.Machine) {
+ case EFI_IMAGE_MACHINE_IA32:
+ case EFI_IMAGE_MACHINE_ARMT:
+ //
+ // Assume PE32 image with IA32 Machine field.
+ //
+ Magic = EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC;
+ break;
+ case EFI_IMAGE_MACHINE_X64:
+ case EFI_IMAGE_MACHINE_IPF:
+ //
+ // Assume PE32+ image with X64 or IPF Machine field
+ //
+ Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC;
+ break;
+ default:
+ //
+ // For unknow Machine field, use Magic in optional Header
+ //
+ Magic = Hdr.Pe32->OptionalHeader.Magic;
+ }
+
+ SectionHeader = (EFI_IMAGE_SECTION_HEADER *) (
+ (UINT8 *) Hdr.Pe32 +
+ sizeof (UINT32) +
+ sizeof (EFI_IMAGE_FILE_HEADER) +
+ Hdr.Pe32->FileHeader.SizeOfOptionalHeader
+ );
+ Index = Hdr.Pe32->FileHeader.NumberOfSections;
+
+ if (EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC == Magic) {
+ //
+ // Use PE32 offset get Debug Directory Entry
+ //
+ NumberOfRvaAndSizes = Hdr.Pe32->OptionalHeader.NumberOfRvaAndSizes;
+ DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]);
+ } else if (Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) {
+ //
+ // Use PE32+ offset get Debug Directory Entry
+ //
+ NumberOfRvaAndSizes = Hdr.Pe32Plus->OptionalHeader.NumberOfRvaAndSizes;
+ DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32Plus->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]);
+ }
+
+ if (NumberOfRvaAndSizes <= EFI_IMAGE_DIRECTORY_ENTRY_DEBUG || DirectoryEntry->VirtualAddress == 0) {
+ DirectoryEntry = NULL;
+ DebugEntry = NULL;
+ } else {
+ //
+ // Get the DebugEntry offset in the raw data image.
+ //
+ for (Index1 = 0; Index1 < Index; Index1 ++) {
+ if ((DirectoryEntry->VirtualAddress >= SectionHeader[Index1].VirtualAddress) &&
+ (DirectoryEntry->VirtualAddress < (SectionHeader[Index1].VirtualAddress + SectionHeader[Index1].Misc.VirtualSize))) {
+ DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *) (
+ (UINTN) Pe32Data +
+ DirectoryEntry->VirtualAddress -
+ SectionHeader[Index1].VirtualAddress +
+ SectionHeader[Index1].PointerToRawData);
+ break;
+ }
+ }
+ }
+ } else {
+ return NULL;
+ }
+
+ if (NULL == DebugEntry || NULL == DirectoryEntry) {
+ return NULL;
+ }
+
+ //
+ // Scan the directory to find the debug entry.
+ //
+ for (DirCount = 0; DirCount < DirectoryEntry->Size; DirCount += sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY), DebugEntry++) {
+ if (EFI_IMAGE_DEBUG_TYPE_CODEVIEW == DebugEntry->Type) {
+ if (DebugEntry->SizeOfData > 0) {
+ //
+ // Get the DebugEntry offset in the raw data image.
+ //
+ CodeViewEntryPointer = NULL;
+ for (Index1 = 0; Index1 < Index; Index1 ++) {
+ if ((DebugEntry->RVA >= SectionHeader[Index1].VirtualAddress) &&
+ (DebugEntry->RVA < (SectionHeader[Index1].VirtualAddress + SectionHeader[Index1].Misc.VirtualSize))) {
+ CodeViewEntryPointer = (VOID *) (
+ ((UINTN)Pe32Data) +
+ (UINTN) DebugEntry->RVA -
+ SectionHeader[Index1].VirtualAddress +
+ SectionHeader[Index1].PointerToRawData +
+ (UINTN)TEImageAdjust);
+ break;
+ }
+ }
+ if (Index1 >= Index) {
+ //
+ // Can't find CodeViewEntryPointer in raw PE/COFF image.
+ //
+ continue;
+ }
+ switch (* (UINT32 *) CodeViewEntryPointer) {
+ case CODEVIEW_SIGNATURE_NB10:
+ return (VOID *) ((CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY));
+ case CODEVIEW_SIGNATURE_RSDS:
+ return (VOID *) ((CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY));
+ case CODEVIEW_SIGNATURE_MTOC:
+ return (VOID *) ((CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_MTOC_ENTRY));
+ default:
+ break;
+ }
+ }
+ }
+ }
+
+ return NULL;
+}
+
+
+RETURN_STATUS
+EFIAPI
+PeCoffLoaderGetEntryPoint (
+ IN VOID *Pe32Data,
+ OUT VOID **EntryPoint,
+ OUT VOID **BaseOfImage
+ )
+{
+ EFI_IMAGE_DOS_HEADER *DosHdr;
+ EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr;
+
+ DosHdr = (EFI_IMAGE_DOS_HEADER *)Pe32Data;
+ if (DosHdr->e_magic == EFI_IMAGE_DOS_SIGNATURE) {
+ //
+ // DOS image header is present, so read the PE header after the DOS image header.
+ //
+ Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN) Pe32Data + (UINTN) ((DosHdr->e_lfanew) & 0x0ffff));
+ } else {
+ //
+ // DOS image header is not present, so PE header is at the image base.
+ //
+ Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)Pe32Data;
+ }
+
+ //
+ // Calculate the entry point relative to the start of the image.
+ // AddressOfEntryPoint is common for PE32 & PE32+
+ //
+ if (Hdr.Te->Signature == EFI_TE_IMAGE_HEADER_SIGNATURE) {
+ *BaseOfImage = (VOID *)(UINTN)(Hdr.Te->ImageBase + Hdr.Te->StrippedSize - sizeof (EFI_TE_IMAGE_HEADER));
+ *EntryPoint = (VOID *)((UINTN)*BaseOfImage + (Hdr.Te->AddressOfEntryPoint & 0x0ffffffff) + sizeof(EFI_TE_IMAGE_HEADER) - Hdr.Te->StrippedSize);
+ return RETURN_SUCCESS;
+ } else if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE) {
+ *EntryPoint = (VOID *)(UINTN)Hdr.Pe32->OptionalHeader.AddressOfEntryPoint;
+ if (Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
+ *BaseOfImage = (VOID *)(UINTN)Hdr.Pe32->OptionalHeader.ImageBase;
+ } else {
+ *BaseOfImage = (VOID *)(UINTN)Hdr.Pe32Plus->OptionalHeader.ImageBase;
+ }
+ *EntryPoint = (VOID *)(UINTN)((UINTN)*EntryPoint + (UINTN)*BaseOfImage);
+ return RETURN_SUCCESS;
+ }
+
+ return RETURN_UNSUPPORTED;
+}
diff --git a/BaseTools/Source/C/Common/BinderFuncs.c b/BaseTools/Source/C/Common/BinderFuncs.c
new file mode 100644
index 0000000000..5ee55480bd
--- /dev/null
+++ b/BaseTools/Source/C/Common/BinderFuncs.c
@@ -0,0 +1,87 @@
+/** @file
+
+Copyright (c) 1999 - 2008, Intel Corporation. All rights reserved.
+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.
+
+Module Name:
+
+ BinderFuncs.c
+
+Abstract:
+
+ Binder function implementations for ANSI C libraries.
+
+**/
+
+#include "BinderFuncs.h"
+#include "CommonLib.h"
+#include
+#include
+
+//
+// Binder Function Implementations
+//
+
+VOID *
+CommonLibBinderAllocate (
+ IN UINTN Size
+ )
+{
+ return (VOID *) malloc (Size);
+}
+
+VOID
+CommonLibBinderFree (
+ IN VOID *Pointer
+ )
+{
+ free (Pointer);
+}
+
+VOID
+CommonLibBinderCopyMem (
+ IN VOID *Destination,
+ IN VOID *Source,
+ IN UINTN Length
+ )
+{
+ memmove (Destination, Source, Length);
+}
+
+VOID
+CommonLibBinderSetMem (
+ IN VOID *Destination,
+ IN UINTN Length,
+ IN UINT8 Value
+ )
+{
+ memset (Destination, Value, Length);
+}
+
+INTN
+CommonLibBinderCompareMem (
+ IN VOID *MemOne,
+ IN VOID *MemTwo,
+ IN UINTN Length
+ )
+{
+ return memcmp (MemOne, MemTwo, Length);
+}
+
+BOOLEAN
+CommonLibBinderCompareGuid (
+ IN EFI_GUID *Guid1,
+ IN EFI_GUID *Guid2
+ )
+{
+ return CompareGuid (Guid1, Guid2) ? FALSE : TRUE;
+}
+
+
+
diff --git a/BaseTools/Source/C/Common/BinderFuncs.h b/BaseTools/Source/C/Common/BinderFuncs.h
new file mode 100644
index 0000000000..48dc82eb70
--- /dev/null
+++ b/BaseTools/Source/C/Common/BinderFuncs.h
@@ -0,0 +1,75 @@
+/** @file
+
+Copyright (c) 1999 - 2008, Intel Corporation. All rights reserved.
+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.
+
+Module Name:
+
+ BinderFuncs.h
+
+Abstract:
+
+ Prototypes for binder functions that allow common code to be
+ written which then links to implementation of these functions
+ which is appropriate for the specific environment that they
+ are running under.
+
+**/
+
+#ifndef BinderFuncs_h_INCLUDED
+#define BinderFuncs_h_INCLUDED
+
+#include "Common/UefiBaseTypes.h"
+
+//
+// Binder Function Prototypes
+//
+// These binding functions must be implemented externally as appropriate for
+// the environment that the code will be running under.
+//
+
+VOID *
+CommonLibBinderAllocate (
+ IN UINTN Size
+ );
+
+VOID
+CommonLibBinderFree (
+ IN VOID *Pointer
+ );
+
+VOID
+CommonLibBinderCopyMem (
+ IN VOID *Destination,
+ IN VOID *Source,
+ IN UINTN Length
+ );
+
+VOID
+CommonLibBinderSetMem (
+ IN VOID *Destination,
+ IN UINTN Length,
+ IN UINT8 Value
+ );
+
+INTN
+CommonLibBinderCompareMem (
+ IN VOID *MemOne,
+ IN VOID *MemTwo,
+ IN UINTN Length
+ );
+
+BOOLEAN
+CommonLibBinderCompareGuid (
+ IN EFI_GUID *Guid1,
+ IN EFI_GUID *Guid2
+ );
+
+#endif // #ifndef CommonLibs_h_INCLUDED
+
diff --git a/BaseTools/Source/C/Common/CommonLib.c b/BaseTools/Source/C/Common/CommonLib.c
new file mode 100644
index 0000000000..cb72e2723f
--- /dev/null
+++ b/BaseTools/Source/C/Common/CommonLib.c
@@ -0,0 +1,584 @@
+/** @file
+
+Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.
+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.
+
+Module Name:
+
+ CommonLib.c
+
+Abstract:
+
+ Common basic Library Functions
+
+**/
+
+#include
+#include
+#include
+#include
+#include "CommonLib.h"
+#include "EfiUtilityMsgs.h"
+
+VOID
+PeiZeroMem (
+ IN VOID *Buffer,
+ IN UINTN Size
+ )
+/*++
+
+Routine Description:
+
+ Set Buffer to zero for Size bytes.
+
+Arguments:
+
+ Buffer - Memory to set.
+
+ Size - Number of bytes to set
+
+Returns:
+
+ None
+
+--*/
+{
+ INT8 *Ptr;
+
+ Ptr = Buffer;
+ while (Size--) {
+ *(Ptr++) = 0;
+ }
+}
+
+VOID
+PeiCopyMem (
+ IN VOID *Destination,
+ IN VOID *Source,
+ IN UINTN Length
+ )
+/*++
+
+Routine Description:
+
+ Copy Length bytes from Source to Destination.
+
+Arguments:
+
+ Destination - Target of copy
+
+ Source - Place to copy from
+
+ Length - Number of bytes to copy
+
+Returns:
+
+ None
+
+--*/
+{
+ CHAR8 *Destination8;
+ CHAR8 *Source8;
+
+ Destination8 = Destination;
+ Source8 = Source;
+ while (Length--) {
+ *(Destination8++) = *(Source8++);
+ }
+}
+
+VOID
+ZeroMem (
+ IN VOID *Buffer,
+ IN UINTN Size
+ )
+{
+ PeiZeroMem (Buffer, Size);
+}
+
+VOID
+CopyMem (
+ IN VOID *Destination,
+ IN VOID *Source,
+ IN UINTN Length
+ )
+{
+ PeiCopyMem (Destination, Source, Length);
+}
+
+INTN
+CompareGuid (
+ IN EFI_GUID *Guid1,
+ IN EFI_GUID *Guid2
+ )
+/*++
+
+Routine Description:
+
+ Compares to GUIDs
+
+Arguments:
+
+ Guid1 - guid to compare
+ Guid2 - guid to compare
+
+Returns:
+ = 0 if Guid1 == Guid2
+ != 0 if Guid1 != Guid2
+
+--*/
+{
+ INT32 *g1;
+ INT32 *g2;
+ INT32 r;
+
+ //
+ // Compare 32 bits at a time
+ //
+ g1 = (INT32 *) Guid1;
+ g2 = (INT32 *) Guid2;
+
+ r = g1[0] - g2[0];
+ r |= g1[1] - g2[1];
+ r |= g1[2] - g2[2];
+ r |= g1[3] - g2[3];
+
+ return r;
+}
+
+
+EFI_STATUS
+GetFileImage (
+ IN CHAR8 *InputFileName,
+ OUT CHAR8 **InputFileImage,
+ OUT UINT32 *BytesRead
+ )
+/*++
+
+Routine Description:
+
+ This function opens a file and reads it into a memory buffer. The function
+ will allocate the memory buffer and returns the size of the buffer.
+
+Arguments:
+
+ InputFileName The name of the file to read.
+ InputFileImage A pointer to the memory buffer.
+ BytesRead The size of the memory buffer.
+
+Returns:
+
+ EFI_SUCCESS The function completed successfully.
+ EFI_INVALID_PARAMETER One of the input parameters was invalid.
+ EFI_ABORTED An error occurred.
+ EFI_OUT_OF_RESOURCES No resource to complete operations.
+
+--*/
+{
+ FILE *InputFile;
+ UINT32 FileSize;
+
+ //
+ // Verify input parameters.
+ //
+ if (InputFileName == NULL || strlen (InputFileName) == 0 || InputFileImage == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+ //
+ // Open the file and copy contents into a memory buffer.
+ //
+ //
+ // Open the file
+ //
+ InputFile = fopen (InputFileName, "rb");
+ if (InputFile == NULL) {
+ Error (NULL, 0, 0001, "Error opening the input file", InputFileName);
+ return EFI_ABORTED;
+ }
+ //
+ // Go to the end so that we can determine the file size
+ //
+ if (fseek (InputFile, 0, SEEK_END)) {
+ Error (NULL, 0, 0004, "Error reading the input file", InputFileName);
+ fclose (InputFile);
+ return EFI_ABORTED;
+ }
+ //
+ // Get the file size
+ //
+ FileSize = ftell (InputFile);
+ if (FileSize == -1) {
+ Error (NULL, 0, 0003, "Error parsing the input file", InputFileName);
+ fclose (InputFile);
+ return EFI_ABORTED;
+ }
+ //
+ // Allocate a buffer
+ //
+ *InputFileImage = malloc (FileSize);
+ if (*InputFileImage == NULL) {
+ fclose (InputFile);
+ return EFI_OUT_OF_RESOURCES;
+ }
+ //
+ // Reset to the beginning of the file
+ //
+ if (fseek (InputFile, 0, SEEK_SET)) {
+ Error (NULL, 0, 0004, "Error reading the input file", InputFileName);
+ fclose (InputFile);
+ free (*InputFileImage);
+ *InputFileImage = NULL;
+ return EFI_ABORTED;
+ }
+ //
+ // Read all of the file contents.
+ //
+ *BytesRead = fread (*InputFileImage, sizeof (UINT8), FileSize, InputFile);
+ if (*BytesRead != sizeof (UINT8) * FileSize) {
+ Error (NULL, 0, 0004, "Error reading the input file", InputFileName);
+ fclose (InputFile);
+ free (*InputFileImage);
+ *InputFileImage = NULL;
+ return EFI_ABORTED;
+ }
+ //
+ // Close the file
+ //
+ fclose (InputFile);
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+PutFileImage (
+ IN CHAR8 *OutputFileName,
+ IN CHAR8 *OutputFileImage,
+ IN UINT32 BytesToWrite
+ )
+/*++
+
+Routine Description:
+
+ This function opens a file and writes OutputFileImage into the file.
+
+Arguments:
+
+ OutputFileName The name of the file to write.
+ OutputFileImage A pointer to the memory buffer.
+ BytesToWrite The size of the memory buffer.
+
+Returns:
+
+ EFI_SUCCESS The function completed successfully.
+ EFI_INVALID_PARAMETER One of the input parameters was invalid.
+ EFI_ABORTED An error occurred.
+ EFI_OUT_OF_RESOURCES No resource to complete operations.
+
+--*/
+{
+ FILE *OutputFile;
+ UINT32 BytesWrote;
+
+ //
+ // Verify input parameters.
+ //
+ if (OutputFileName == NULL || strlen (OutputFileName) == 0 || OutputFileImage == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+ //
+ // Open the file and copy contents into a memory buffer.
+ //
+ //
+ // Open the file
+ //
+ OutputFile = fopen (OutputFileName, "wb");
+ if (OutputFile == NULL) {
+ Error (NULL, 0, 0001, "Error opening the output file", OutputFileName);
+ return EFI_ABORTED;
+ }
+
+ //
+ // Write all of the file contents.
+ //
+ BytesWrote = fwrite (OutputFileImage, sizeof (UINT8), BytesToWrite, OutputFile);
+ if (BytesWrote != sizeof (UINT8) * BytesToWrite) {
+ Error (NULL, 0, 0002, "Error writing the output file", OutputFileName);
+ fclose (OutputFile);
+ return EFI_ABORTED;
+ }
+ //
+ // Close the file
+ //
+ fclose (OutputFile);
+
+ return EFI_SUCCESS;
+}
+
+UINT8
+CalculateChecksum8 (
+ IN UINT8 *Buffer,
+ IN UINTN Size
+ )
+/*++
+
+Routine Description:
+
+ This function calculates the value needed for a valid UINT8 checksum
+
+Arguments:
+
+ Buffer Pointer to buffer containing byte data of component.
+ Size Size of the buffer
+
+Returns:
+
+ The 8 bit checksum value needed.
+
+--*/
+{
+ return (UINT8) (0x100 - CalculateSum8 (Buffer, Size));
+}
+
+UINT8
+CalculateSum8 (
+ IN UINT8 *Buffer,
+ IN UINTN Size
+ )
+/*++
+
+Routine Description::
+
+ This function calculates the UINT8 sum for the requested region.
+
+Arguments:
+
+ Buffer Pointer to buffer containing byte data of component.
+ Size Size of the buffer
+
+Returns:
+
+ The 8 bit checksum value needed.
+
+--*/
+{
+ UINTN Index;
+ UINT8 Sum;
+
+ Sum = 0;
+
+ //
+ // Perform the byte sum for buffer
+ //
+ for (Index = 0; Index < Size; Index++) {
+ Sum = (UINT8) (Sum + Buffer[Index]);
+ }
+
+ return Sum;
+}
+
+UINT16
+CalculateChecksum16 (
+ IN UINT16 *Buffer,
+ IN UINTN Size
+ )
+/*++
+
+Routine Description::
+
+ This function calculates the value needed for a valid UINT16 checksum
+
+Arguments:
+
+ Buffer Pointer to buffer containing byte data of component.
+ Size Size of the buffer
+
+Returns:
+
+ The 16 bit checksum value needed.
+
+--*/
+{
+ return (UINT16) (0x10000 - CalculateSum16 (Buffer, Size));
+}
+
+UINT16
+CalculateSum16 (
+ IN UINT16 *Buffer,
+ IN UINTN Size
+ )
+/*++
+
+Routine Description:
+
+ This function calculates the UINT16 sum for the requested region.
+
+Arguments:
+
+ Buffer Pointer to buffer containing byte data of component.
+ Size Size of the buffer
+
+Returns:
+
+ The 16 bit checksum
+
+--*/
+{
+ UINTN Index;
+ UINT16 Sum;
+
+ Sum = 0;
+
+ //
+ // Perform the word sum for buffer
+ //
+ for (Index = 0; Index < Size; Index++) {
+ Sum = (UINT16) (Sum + Buffer[Index]);
+ }
+
+ return (UINT16) Sum;
+}
+
+EFI_STATUS
+PrintGuid (
+ IN EFI_GUID *Guid
+ )
+/*++
+
+Routine Description:
+
+ This function prints a GUID to STDOUT.
+
+Arguments:
+
+ Guid Pointer to a GUID to print.
+
+Returns:
+
+ EFI_SUCCESS The GUID was printed.
+ EFI_INVALID_PARAMETER The input was NULL.
+
+--*/
+{
+ if (Guid == NULL) {
+ Error (NULL, 0, 2000, "Invalid parameter", "PrintGuidToBuffer() called with a NULL value");
+ return EFI_INVALID_PARAMETER;
+ }
+
+ printf (
+ "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x\n",
+ (unsigned) Guid->Data1,
+ Guid->Data2,
+ Guid->Data3,
+ Guid->Data4[0],
+ Guid->Data4[1],
+ Guid->Data4[2],
+ Guid->Data4[3],
+ Guid->Data4[4],
+ Guid->Data4[5],
+ Guid->Data4[6],
+ Guid->Data4[7]
+ );
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+PrintGuidToBuffer (
+ IN EFI_GUID *Guid,
+ IN OUT UINT8 *Buffer,
+ IN UINT32 BufferLen,
+ IN BOOLEAN Uppercase
+ )
+/*++
+
+Routine Description:
+
+ This function prints a GUID to a buffer
+
+Arguments:
+
+ Guid - Pointer to a GUID to print.
+ Buffer - Pointer to a user-provided buffer to print to
+ BufferLen - Size of the Buffer
+ Uppercase - If use upper case.
+
+Returns:
+
+ EFI_SUCCESS The GUID was printed.
+ EFI_INVALID_PARAMETER The input was NULL.
+ EFI_BUFFER_TOO_SMALL The input buffer was not big enough
+
+--*/
+{
+ if (Guid == NULL) {
+ Error (NULL, 0, 2000, "Invalid parameter", "PrintGuidToBuffer() called with a NULL value");
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (BufferLen < PRINTED_GUID_BUFFER_SIZE) {
+ Error (NULL, 0, 2000, "Invalid parameter", "PrintGuidToBuffer() called with invalid buffer size");
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ if (Uppercase) {
+ sprintf (
+ (CHAR8 *)Buffer,
+ "%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X",
+ (unsigned) Guid->Data1,
+ Guid->Data2,
+ Guid->Data3,
+ Guid->Data4[0],
+ Guid->Data4[1],
+ Guid->Data4[2],
+ Guid->Data4[3],
+ Guid->Data4[4],
+ Guid->Data4[5],
+ Guid->Data4[6],
+ Guid->Data4[7]
+ );
+ } else {
+ sprintf (
+ (CHAR8 *)Buffer,
+ "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
+ (unsigned) Guid->Data1,
+ Guid->Data2,
+ Guid->Data3,
+ Guid->Data4[0],
+ Guid->Data4[1],
+ Guid->Data4[2],
+ Guid->Data4[3],
+ Guid->Data4[4],
+ Guid->Data4[5],
+ Guid->Data4[6],
+ Guid->Data4[7]
+ );
+ }
+
+ return EFI_SUCCESS;
+}
+
+#ifdef __GNUC__
+
+size_t _filelength(int fd)
+{
+ struct stat stat_buf;
+ fstat(fd, &stat_buf);
+ return stat_buf.st_size;
+}
+
+#ifndef __CYGWIN__
+char *strlwr(char *s)
+{
+ char *p = s;
+ for(;*s;s++) {
+ *s = tolower(*s);
+ }
+ return p;
+}
+#endif
+#endif
diff --git a/BaseTools/Source/C/Common/CommonLib.h b/BaseTools/Source/C/Common/CommonLib.h
new file mode 100644
index 0000000000..f407e6d1e9
--- /dev/null
+++ b/BaseTools/Source/C/Common/CommonLib.h
@@ -0,0 +1,172 @@
+/** @file
+
+Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.
+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.
+
+Module Name:
+
+ CommonLib.h
+
+Abstract:
+
+ Common library assistance routines.
+
+**/
+
+#ifndef _EFI_COMMON_LIB_H
+#define _EFI_COMMON_LIB_H
+
+#include
+#define PRINTED_GUID_BUFFER_SIZE 37 // including null-termination
+//
+// Function declarations
+//
+VOID
+PeiZeroMem (
+ IN VOID *Buffer,
+ IN UINTN Size
+ )
+;
+
+VOID
+PeiCopyMem (
+ IN VOID *Destination,
+ IN VOID *Source,
+ IN UINTN Length
+ )
+;
+
+VOID
+ZeroMem (
+ IN VOID *Buffer,
+ IN UINTN Size
+ )
+;
+
+VOID
+CopyMem (
+ IN VOID *Destination,
+ IN VOID *Source,
+ IN UINTN Length
+ )
+;
+
+INTN
+CompareGuid (
+ IN EFI_GUID *Guid1,
+ IN EFI_GUID *Guid2
+ )
+;
+
+EFI_STATUS
+GetFileImage (
+ IN CHAR8 *InputFileName,
+ OUT CHAR8 **InputFileImage,
+ OUT UINT32 *BytesRead
+ )
+;
+
+EFI_STATUS
+PutFileImage (
+ IN CHAR8 *OutputFileName,
+ IN CHAR8 *OutputFileImage,
+ IN UINT32 BytesToWrite
+ )
+;
+/*++
+
+Routine Description:
+
+ This function opens a file and writes OutputFileImage into the file.
+
+Arguments:
+
+ OutputFileName The name of the file to write.
+ OutputFileImage A pointer to the memory buffer.
+ BytesToWrite The size of the memory buffer.
+
+Returns:
+
+ EFI_SUCCESS The function completed successfully.
+ EFI_INVALID_PARAMETER One of the input parameters was invalid.
+ EFI_ABORTED An error occurred.
+ EFI_OUT_OF_RESOURCES No resource to complete operations.
+
+**/
+
+UINT8
+CalculateChecksum8 (
+ IN UINT8 *Buffer,
+ IN UINTN Size
+ )
+;
+
+UINT8
+CalculateSum8 (
+ IN UINT8 *Buffer,
+ IN UINTN Size
+ )
+;
+
+UINT16
+CalculateChecksum16 (
+ IN UINT16 *Buffer,
+ IN UINTN Size
+ )
+;
+
+UINT16
+CalculateSum16 (
+ IN UINT16 *Buffer,
+ IN UINTN Size
+ )
+;
+
+EFI_STATUS
+PrintGuid (
+ IN EFI_GUID *Guid
+ )
+;
+
+#define PRINTED_GUID_BUFFER_SIZE 37 // including null-termination
+EFI_STATUS
+PrintGuidToBuffer (
+ IN EFI_GUID *Guid,
+ IN OUT UINT8 *Buffer,
+ IN UINT32 BufferLen,
+ IN BOOLEAN Uppercase
+ )
+;
+
+#define ASSERT(x) assert(x)
+
+#ifdef __GNUC__
+#include
+#include
+#define stricmp strcasecmp
+#define _stricmp strcasecmp
+#define strnicmp strncasecmp
+#define strcmpi strcasecmp
+size_t _filelength(int fd);
+#ifndef __CYGWIN__
+char *strlwr(char *s);
+#endif
+#endif
+
+//
+// On windows, mkdir only has one parameter.
+// On unix, it has two parameters
+//
+#if defined(__GNUC__)
+#define mkdir(dir, perm) mkdir(dir, perm)
+#else
+#define mkdir(dir, perm) mkdir(dir)
+#endif
+
+#endif
diff --git a/BaseTools/Source/C/Common/Compress.h b/BaseTools/Source/C/Common/Compress.h
new file mode 100644
index 0000000000..11245b1178
--- /dev/null
+++ b/BaseTools/Source/C/Common/Compress.h
@@ -0,0 +1,95 @@
+/** @file
+
+Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.
+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.
+
+Module Name:
+
+ Compress.h
+
+Abstract:
+
+ Header file for compression routine.
+ Providing both EFI and Tiano Compress algorithms.
+
+**/
+
+#ifndef _COMPRESS_H_
+#define _COMPRESS_H_
+
+#include
+#include
+
+#include "CommonLib.h"
+#include
+/*++
+
+Routine Description:
+
+ Tiano compression routine.
+
+--*/
+EFI_STATUS
+TianoCompress (
+ IN UINT8 *SrcBuffer,
+ IN UINT32 SrcSize,
+ IN UINT8 *DstBuffer,
+ IN OUT UINT32 *DstSize
+ )
+;
+
+/*++
+
+Routine Description:
+
+ Efi compression routine.
+
+--*/
+EFI_STATUS
+EfiCompress (
+ IN UINT8 *SrcBuffer,
+ IN UINT32 SrcSize,
+ IN UINT8 *DstBuffer,
+ IN OUT UINT32 *DstSize
+ )
+;
+
+/*++
+
+Routine Description:
+
+ The compression routine.
+
+Arguments:
+
+ SrcBuffer - The buffer storing the source data
+ SrcSize - The size of source data
+ DstBuffer - The buffer to store the compressed data
+ DstSize - On input, the size of DstBuffer; On output,
+ the size of the actual compressed data.
+
+Returns:
+
+ EFI_BUFFER_TOO_SMALL - The DstBuffer is too small. In this case,
+ DstSize contains the size needed.
+ EFI_SUCCESS - Compression is successful.
+ EFI_OUT_OF_RESOURCES - No resource to complete function.
+ EFI_INVALID_PARAMETER - Parameter supplied is wrong.
+
+--*/
+typedef
+EFI_STATUS
+(*COMPRESS_FUNCTION) (
+ IN UINT8 *SrcBuffer,
+ IN UINT32 SrcSize,
+ IN UINT8 *DstBuffer,
+ IN OUT UINT32 *DstSize
+ );
+
+#endif
diff --git a/BaseTools/Source/C/Common/Crc32.c b/BaseTools/Source/C/Common/Crc32.c
new file mode 100644
index 0000000000..8e5915dd0e
--- /dev/null
+++ b/BaseTools/Source/C/Common/Crc32.c
@@ -0,0 +1,326 @@
+/** @file
+
+Copyright (c) 2004, Intel Corporation. All rights reserved.
+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.
+
+Module Name:
+
+ crc32.c
+
+Abstract:
+
+ CalcuateCrc32 routine.
+
+**/
+
+#include
+#include "Crc32.h"
+
+UINT32 mCrcTable[256] = {
+ 0x00000000,
+ 0x77073096,
+ 0xEE0E612C,
+ 0x990951BA,
+ 0x076DC419,
+ 0x706AF48F,
+ 0xE963A535,
+ 0x9E6495A3,
+ 0x0EDB8832,
+ 0x79DCB8A4,
+ 0xE0D5E91E,
+ 0x97D2D988,
+ 0x09B64C2B,
+ 0x7EB17CBD,
+ 0xE7B82D07,
+ 0x90BF1D91,
+ 0x1DB71064,
+ 0x6AB020F2,
+ 0xF3B97148,
+ 0x84BE41DE,
+ 0x1ADAD47D,
+ 0x6DDDE4EB,
+ 0xF4D4B551,
+ 0x83D385C7,
+ 0x136C9856,
+ 0x646BA8C0,
+ 0xFD62F97A,
+ 0x8A65C9EC,
+ 0x14015C4F,
+ 0x63066CD9,
+ 0xFA0F3D63,
+ 0x8D080DF5,
+ 0x3B6E20C8,
+ 0x4C69105E,
+ 0xD56041E4,
+ 0xA2677172,
+ 0x3C03E4D1,
+ 0x4B04D447,
+ 0xD20D85FD,
+ 0xA50AB56B,
+ 0x35B5A8FA,
+ 0x42B2986C,
+ 0xDBBBC9D6,
+ 0xACBCF940,
+ 0x32D86CE3,
+ 0x45DF5C75,
+ 0xDCD60DCF,
+ 0xABD13D59,
+ 0x26D930AC,
+ 0x51DE003A,
+ 0xC8D75180,
+ 0xBFD06116,
+ 0x21B4F4B5,
+ 0x56B3C423,
+ 0xCFBA9599,
+ 0xB8BDA50F,
+ 0x2802B89E,
+ 0x5F058808,
+ 0xC60CD9B2,
+ 0xB10BE924,
+ 0x2F6F7C87,
+ 0x58684C11,
+ 0xC1611DAB,
+ 0xB6662D3D,
+ 0x76DC4190,
+ 0x01DB7106,
+ 0x98D220BC,
+ 0xEFD5102A,
+ 0x71B18589,
+ 0x06B6B51F,
+ 0x9FBFE4A5,
+ 0xE8B8D433,
+ 0x7807C9A2,
+ 0x0F00F934,
+ 0x9609A88E,
+ 0xE10E9818,
+ 0x7F6A0DBB,
+ 0x086D3D2D,
+ 0x91646C97,
+ 0xE6635C01,
+ 0x6B6B51F4,
+ 0x1C6C6162,
+ 0x856530D8,
+ 0xF262004E,
+ 0x6C0695ED,
+ 0x1B01A57B,
+ 0x8208F4C1,
+ 0xF50FC457,
+ 0x65B0D9C6,
+ 0x12B7E950,
+ 0x8BBEB8EA,
+ 0xFCB9887C,
+ 0x62DD1DDF,
+ 0x15DA2D49,
+ 0x8CD37CF3,
+ 0xFBD44C65,
+ 0x4DB26158,
+ 0x3AB551CE,
+ 0xA3BC0074,
+ 0xD4BB30E2,
+ 0x4ADFA541,
+ 0x3DD895D7,
+ 0xA4D1C46D,
+ 0xD3D6F4FB,
+ 0x4369E96A,
+ 0x346ED9FC,
+ 0xAD678846,
+ 0xDA60B8D0,
+ 0x44042D73,
+ 0x33031DE5,
+ 0xAA0A4C5F,
+ 0xDD0D7CC9,
+ 0x5005713C,
+ 0x270241AA,
+ 0xBE0B1010,
+ 0xC90C2086,
+ 0x5768B525,
+ 0x206F85B3,
+ 0xB966D409,
+ 0xCE61E49F,
+ 0x5EDEF90E,
+ 0x29D9C998,
+ 0xB0D09822,
+ 0xC7D7A8B4,
+ 0x59B33D17,
+ 0x2EB40D81,
+ 0xB7BD5C3B,
+ 0xC0BA6CAD,
+ 0xEDB88320,
+ 0x9ABFB3B6,
+ 0x03B6E20C,
+ 0x74B1D29A,
+ 0xEAD54739,
+ 0x9DD277AF,
+ 0x04DB2615,
+ 0x73DC1683,
+ 0xE3630B12,
+ 0x94643B84,
+ 0x0D6D6A3E,
+ 0x7A6A5AA8,
+ 0xE40ECF0B,
+ 0x9309FF9D,
+ 0x0A00AE27,
+ 0x7D079EB1,
+ 0xF00F9344,
+ 0x8708A3D2,
+ 0x1E01F268,
+ 0x6906C2FE,
+ 0xF762575D,
+ 0x806567CB,
+ 0x196C3671,
+ 0x6E6B06E7,
+ 0xFED41B76,
+ 0x89D32BE0,
+ 0x10DA7A5A,
+ 0x67DD4ACC,
+ 0xF9B9DF6F,
+ 0x8EBEEFF9,
+ 0x17B7BE43,
+ 0x60B08ED5,
+ 0xD6D6A3E8,
+ 0xA1D1937E,
+ 0x38D8C2C4,
+ 0x4FDFF252,
+ 0xD1BB67F1,
+ 0xA6BC5767,
+ 0x3FB506DD,
+ 0x48B2364B,
+ 0xD80D2BDA,
+ 0xAF0A1B4C,
+ 0x36034AF6,
+ 0x41047A60,
+ 0xDF60EFC3,
+ 0xA867DF55,
+ 0x316E8EEF,
+ 0x4669BE79,
+ 0xCB61B38C,
+ 0xBC66831A,
+ 0x256FD2A0,
+ 0x5268E236,
+ 0xCC0C7795,
+ 0xBB0B4703,
+ 0x220216B9,
+ 0x5505262F,
+ 0xC5BA3BBE,
+ 0xB2BD0B28,
+ 0x2BB45A92,
+ 0x5CB36A04,
+ 0xC2D7FFA7,
+ 0xB5D0CF31,
+ 0x2CD99E8B,
+ 0x5BDEAE1D,
+ 0x9B64C2B0,
+ 0xEC63F226,
+ 0x756AA39C,
+ 0x026D930A,
+ 0x9C0906A9,
+ 0xEB0E363F,
+ 0x72076785,
+ 0x05005713,
+ 0x95BF4A82,
+ 0xE2B87A14,
+ 0x7BB12BAE,
+ 0x0CB61B38,
+ 0x92D28E9B,
+ 0xE5D5BE0D,
+ 0x7CDCEFB7,
+ 0x0BDBDF21,
+ 0x86D3D2D4,
+ 0xF1D4E242,
+ 0x68DDB3F8,
+ 0x1FDA836E,
+ 0x81BE16CD,
+ 0xF6B9265B,
+ 0x6FB077E1,
+ 0x18B74777,
+ 0x88085AE6,
+ 0xFF0F6A70,
+ 0x66063BCA,
+ 0x11010B5C,
+ 0x8F659EFF,
+ 0xF862AE69,
+ 0x616BFFD3,
+ 0x166CCF45,
+ 0xA00AE278,
+ 0xD70DD2EE,
+ 0x4E048354,
+ 0x3903B3C2,
+ 0xA7672661,
+ 0xD06016F7,
+ 0x4969474D,
+ 0x3E6E77DB,
+ 0xAED16A4A,
+ 0xD9D65ADC,
+ 0x40DF0B66,
+ 0x37D83BF0,
+ 0xA9BCAE53,
+ 0xDEBB9EC5,
+ 0x47B2CF7F,
+ 0x30B5FFE9,
+ 0xBDBDF21C,
+ 0xCABAC28A,
+ 0x53B39330,
+ 0x24B4A3A6,
+ 0xBAD03605,
+ 0xCDD70693,
+ 0x54DE5729,
+ 0x23D967BF,
+ 0xB3667A2E,
+ 0xC4614AB8,
+ 0x5D681B02,
+ 0x2A6F2B94,
+ 0xB40BBE37,
+ 0xC30C8EA1,
+ 0x5A05DF1B,
+ 0x2D02EF8D
+};
+
+EFI_STATUS
+CalculateCrc32 (
+ IN UINT8 *Data,
+ IN UINTN DataSize,
+ IN OUT UINT32 *CrcOut
+ )
+/*++
+
+Routine Description:
+
+ The CalculateCrc32 routine.
+
+Arguments:
+
+ Data - The buffer contaning the data to be processed
+ DataSize - The size of data to be processed
+ CrcOut - A pointer to the caller allocated UINT32 that on
+ contains the CRC32 checksum of Data
+
+Returns:
+
+ EFI_SUCCESS - Calculation is successful.
+ EFI_INVALID_PARAMETER - Data / CrcOut = NULL, or DataSize = 0
+
+--*/
+{
+ UINT32 Crc;
+ UINTN Index;
+ UINT8 *Ptr;
+
+ if ((DataSize == 0) || (Data == NULL) || (CrcOut == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Crc = 0xffffffff;
+ for (Index = 0, Ptr = Data; Index < DataSize; Index++, Ptr++) {
+ Crc = (Crc >> 8) ^ mCrcTable[(UINT8) Crc ^ *Ptr];
+ }
+
+ *CrcOut = Crc ^ 0xffffffff;
+
+ return EFI_SUCCESS;
+}
diff --git a/BaseTools/Source/C/Common/Crc32.h b/BaseTools/Source/C/Common/Crc32.h
new file mode 100644
index 0000000000..760327f99c
--- /dev/null
+++ b/BaseTools/Source/C/Common/Crc32.h
@@ -0,0 +1,54 @@
+/** @file
+
+Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.
+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.
+
+Module Name:
+
+ Crc32.h
+
+Abstract:
+
+ Header file for CalcuateCrc32 routine
+
+**/
+
+#ifndef _CRC32_H
+#define _CRC32_H
+
+#include
+
+EFI_STATUS
+CalculateCrc32 (
+ IN UINT8 *Data,
+ IN UINTN DataSize,
+ IN OUT UINT32 *CrcOut
+ )
+/*++
+
+Routine Description:
+
+ The CalculateCrc32 routine.
+
+Arguments:
+
+ Data - The buffer contaning the data to be processed
+ DataSize - The size of data to be processed
+ CrcOut - A pointer to the caller allocated UINT32 that on
+ contains the CRC32 checksum of Data
+
+Returns:
+
+ EFI_SUCCESS - Calculation is successful.
+ EFI_INVALID_PARAMETER - Data / CrcOut = NULL, or DataSize = 0
+
+--*/
+;
+
+#endif
diff --git a/BaseTools/Source/C/Common/Decompress.c b/BaseTools/Source/C/Common/Decompress.c
new file mode 100644
index 0000000000..a12fc595a7
--- /dev/null
+++ b/BaseTools/Source/C/Common/Decompress.c
@@ -0,0 +1,982 @@
+/** @file
+
+Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.
+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.
+
+Module Name:
+
+ Decompress.c
+
+Abstract:
+
+ Decompressor. Algorithm Ported from OPSD code (Decomp.asm)
+ for Efi and Tiano compress algorithm.
+
+--*/
+
+#include
+#include
+#include "Decompress.h"
+
+//
+// Decompression algorithm begins here
+//
+#define BITBUFSIZ 32
+#define MAXMATCH 256
+#define THRESHOLD 3
+#define CODE_BIT 16
+#define BAD_TABLE - 1
+
+//
+// C: Char&Len Set; P: Position Set; T: exTra Set
+//
+#define NC (0xff + MAXMATCH + 2 - THRESHOLD)
+#define CBIT 9
+#define EFIPBIT 4
+#define MAXPBIT 5
+#define TBIT 5
+#define MAXNP ((1U << MAXPBIT) - 1)
+#define NT (CODE_BIT + 3)
+#if NT > MAXNP
+#define NPT NT
+#else
+#define NPT MAXNP
+#endif
+
+typedef struct {
+ UINT8 *mSrcBase; // Starting address of compressed data
+ UINT8 *mDstBase; // Starting address of decompressed data
+ UINT32 mOutBuf;
+ UINT32 mInBuf;
+
+ UINT16 mBitCount;
+ UINT32 mBitBuf;
+ UINT32 mSubBitBuf;
+ UINT16 mBlockSize;
+ UINT32 mCompSize;
+ UINT32 mOrigSize;
+
+ UINT16 mBadTableFlag;
+
+ UINT16 mLeft[2 * NC - 1];
+ UINT16 mRight[2 * NC - 1];
+ UINT8 mCLen[NC];
+ UINT8 mPTLen[NPT];
+ UINT16 mCTable[4096];
+ UINT16 mPTTable[256];
+} SCRATCH_DATA;
+
+STATIC UINT16 mPbit = EFIPBIT;
+
+STATIC
+VOID
+FillBuf (
+ IN SCRATCH_DATA *Sd,
+ IN UINT16 NumOfBits
+ )
+/*++
+
+Routine Description:
+
+ Shift mBitBuf NumOfBits left. Read in NumOfBits of bits from source.
+
+Arguments:
+
+ Sd - The global scratch data
+ NumOfBit - The number of bits to shift and read.
+
+Returns: (VOID)
+
+--*/
+{
+ Sd->mBitBuf = (UINT32) (Sd->mBitBuf << NumOfBits);
+
+ while (NumOfBits > Sd->mBitCount) {
+
+ Sd->mBitBuf |= (UINT32) (Sd->mSubBitBuf << (NumOfBits = (UINT16) (NumOfBits - Sd->mBitCount)));
+
+ if (Sd->mCompSize > 0) {
+ //
+ // Get 1 byte into SubBitBuf
+ //
+ Sd->mCompSize--;
+ Sd->mSubBitBuf = 0;
+ Sd->mSubBitBuf = Sd->mSrcBase[Sd->mInBuf++];
+ Sd->mBitCount = 8;
+
+ } else {
+ //
+ // No more bits from the source, just pad zero bit.
+ //
+ Sd->mSubBitBuf = 0;
+ Sd->mBitCount = 8;
+
+ }
+ }
+
+ Sd->mBitCount = (UINT16) (Sd->mBitCount - NumOfBits);
+ Sd->mBitBuf |= Sd->mSubBitBuf >> Sd->mBitCount;
+}
+
+STATIC
+UINT32
+GetBits (
+ IN SCRATCH_DATA *Sd,
+ IN UINT16 NumOfBits
+ )
+/*++
+
+Routine Description:
+
+ Get NumOfBits of bits out from mBitBuf. Fill mBitBuf with subsequent
+ NumOfBits of bits from source. Returns NumOfBits of bits that are
+ popped out.
+
+Arguments:
+
+ Sd - The global scratch data.
+ NumOfBits - The number of bits to pop and read.
+
+Returns:
+
+ The bits that are popped out.
+
+--*/
+{
+ UINT32 OutBits;
+
+ OutBits = (UINT32) (Sd->mBitBuf >> (BITBUFSIZ - NumOfBits));
+
+ FillBuf (Sd, NumOfBits);
+
+ return OutBits;
+}
+
+STATIC
+UINT16
+MakeTable (
+ IN SCRATCH_DATA *Sd,
+ IN UINT16 NumOfChar,
+ IN UINT8 *BitLen,
+ IN UINT16 TableBits,
+ OUT UINT16 *Table
+ )
+/*++
+
+Routine Description:
+
+ Creates Huffman Code mapping table according to code length array.
+
+Arguments:
+
+ Sd - The global scratch data
+ NumOfChar - Number of symbols in the symbol set
+ BitLen - Code length array
+ TableBits - The width of the mapping table
+ Table - The table
+
+Returns:
+
+ 0 - OK.
+ BAD_TABLE - The table is corrupted.
+
+--*/
+{
+ UINT16 Count[17];
+ UINT16 Weight[17];
+ UINT16 Start[18];
+ UINT16 *Pointer;
+ UINT16 Index3;
+ UINT16 Index;
+ UINT16 Len;
+ UINT16 Char;
+ UINT16 JuBits;
+ UINT16 Avail;
+ UINT16 NextCode;
+ UINT16 Mask;
+
+ for (Index = 1; Index <= 16; Index++) {
+ Count[Index] = 0;
+ }
+
+ for (Index = 0; Index < NumOfChar; Index++) {
+ Count[BitLen[Index]]++;
+ }
+
+ Start[1] = 0;
+
+ for (Index = 1; Index <= 16; Index++) {
+ Start[Index + 1] = (UINT16) (Start[Index] + (Count[Index] << (16 - Index)));
+ }
+
+ if (Start[17] != 0) {
+ /*(1U << 16)*/
+ return (UINT16) BAD_TABLE;
+ }
+
+ JuBits = (UINT16) (16 - TableBits);
+
+ for (Index = 1; Index <= TableBits; Index++) {
+ Start[Index] >>= JuBits;
+ Weight[Index] = (UINT16) (1U << (TableBits - Index));
+ }
+
+ while (Index <= 16) {
+ Weight[Index] = (UINT16) (1U << (16 - Index));
+ Index++;
+ }
+
+ Index = (UINT16) (Start[TableBits + 1] >> JuBits);
+
+ if (Index != 0) {
+ Index3 = (UINT16) (1U << TableBits);
+ while (Index != Index3) {
+ Table[Index++] = 0;
+ }
+ }
+
+ Avail = NumOfChar;
+ Mask = (UINT16) (1U << (15 - TableBits));
+
+ for (Char = 0; Char < NumOfChar; Char++) {
+
+ Len = BitLen[Char];
+ if (Len == 0) {
+ continue;
+ }
+
+ NextCode = (UINT16) (Start[Len] + Weight[Len]);
+
+ if (Len <= TableBits) {
+
+ for (Index = Start[Len]; Index < NextCode; Index++) {
+ Table[Index] = Char;
+ }
+
+ } else {
+
+ Index3 = Start[Len];
+ Pointer = &Table[Index3 >> JuBits];
+ Index = (UINT16) (Len - TableBits);
+
+ while (Index != 0) {
+ if (*Pointer == 0) {
+ Sd->mRight[Avail] = Sd->mLeft[Avail] = 0;
+ *Pointer = Avail++;
+ }
+
+ if (Index3 & Mask) {
+ Pointer = &Sd->mRight[*Pointer];
+ } else {
+ Pointer = &Sd->mLeft[*Pointer];
+ }
+
+ Index3 <<= 1;
+ Index--;
+ }
+
+ *Pointer = Char;
+
+ }
+
+ Start[Len] = NextCode;
+ }
+ //
+ // Succeeds
+ //
+ return 0;
+}
+
+STATIC
+UINT32
+DecodeP (
+ IN SCRATCH_DATA *Sd
+ )
+/*++
+
+Routine Description:
+
+ Decodes a position value.
+
+Arguments:
+
+ Sd - the global scratch data
+
+Returns:
+
+ The position value decoded.
+
+--*/
+{
+ UINT16 Val;
+ UINT32 Mask;
+ UINT32 Pos;
+
+ Val = Sd->mPTTable[Sd->mBitBuf >> (BITBUFSIZ - 8)];
+
+ if (Val >= MAXNP) {
+ Mask = 1U << (BITBUFSIZ - 1 - 8);
+
+ do {
+
+ if (Sd->mBitBuf & Mask) {
+ Val = Sd->mRight[Val];
+ } else {
+ Val = Sd->mLeft[Val];
+ }
+
+ Mask >>= 1;
+ } while (Val >= MAXNP);
+ }
+ //
+ // Advance what we have read
+ //
+ FillBuf (Sd, Sd->mPTLen[Val]);
+
+ Pos = Val;
+ if (Val > 1) {
+ Pos = (UINT32) ((1U << (Val - 1)) + GetBits (Sd, (UINT16) (Val - 1)));
+ }
+
+ return Pos;
+}
+
+STATIC
+UINT16
+ReadPTLen (
+ IN SCRATCH_DATA *Sd,
+ IN UINT16 nn,
+ IN UINT16 nbit,
+ IN UINT16 Special
+ )
+/*++
+
+Routine Description:
+
+ Reads code lengths for the Extra Set or the Position Set
+
+Arguments:
+
+ Sd - The global scratch data
+ nn - Number of symbols
+ nbit - Number of bits needed to represent nn
+ Special - The special symbol that needs to be taken care of
+
+Returns:
+
+ 0 - OK.
+ BAD_TABLE - Table is corrupted.
+
+--*/
+{
+ UINT16 Number;
+ UINT16 CharC;
+ UINT16 Index;
+ UINT32 Mask;
+
+ Number = (UINT16) GetBits (Sd, nbit);
+
+ if (Number == 0) {
+ CharC = (UINT16) GetBits (Sd, nbit);
+
+ for (Index = 0; Index < 256; Index++) {
+ Sd->mPTTable[Index] = CharC;
+ }
+
+ for (Index = 0; Index < nn; Index++) {
+ Sd->mPTLen[Index] = 0;
+ }
+
+ return 0;
+ }
+
+ Index = 0;
+
+ while (Index < Number) {
+
+ CharC = (UINT16) (Sd->mBitBuf >> (BITBUFSIZ - 3));
+
+ if (CharC == 7) {
+ Mask = 1U << (BITBUFSIZ - 1 - 3);
+ while (Mask & Sd->mBitBuf) {
+ Mask >>= 1;
+ CharC += 1;
+ }
+ }
+
+ FillBuf (Sd, (UINT16) ((CharC < 7) ? 3 : CharC - 3));
+
+ Sd->mPTLen[Index++] = (UINT8) CharC;
+
+ if (Index == Special) {
+ CharC = (UINT16) GetBits (Sd, 2);
+ CharC--;
+ while ((INT16) (CharC) >= 0) {
+ Sd->mPTLen[Index++] = 0;
+ CharC--;
+ }
+ }
+ }
+
+ while (Index < nn) {
+ Sd->mPTLen[Index++] = 0;
+ }
+
+ return MakeTable (Sd, nn, Sd->mPTLen, 8, Sd->mPTTable);
+}
+
+STATIC
+VOID
+ReadCLen (
+ SCRATCH_DATA *Sd
+ )
+/*++
+
+Routine Description:
+
+ Reads code lengths for Char&Len Set.
+
+Arguments:
+
+ Sd - the global scratch data
+
+Returns: (VOID)
+
+--*/
+{
+ UINT16 Number;
+ UINT16 CharC;
+ UINT16 Index;
+ UINT32 Mask;
+
+ Number = (UINT16) GetBits (Sd, CBIT);
+
+ if (Number == 0) {
+ CharC = (UINT16) GetBits (Sd, CBIT);
+
+ for (Index = 0; Index < NC; Index++) {
+ Sd->mCLen[Index] = 0;
+ }
+
+ for (Index = 0; Index < 4096; Index++) {
+ Sd->mCTable[Index] = CharC;
+ }
+
+ return ;
+ }
+
+ Index = 0;
+ while (Index < Number) {
+
+ CharC = Sd->mPTTable[Sd->mBitBuf >> (BITBUFSIZ - 8)];
+ if (CharC >= NT) {
+ Mask = 1U << (BITBUFSIZ - 1 - 8);
+
+ do {
+
+ if (Mask & Sd->mBitBuf) {
+ CharC = Sd->mRight[CharC];
+ } else {
+ CharC = Sd->mLeft[CharC];
+ }
+
+ Mask >>= 1;
+
+ } while (CharC >= NT);
+ }
+ //
+ // Advance what we have read
+ //
+ FillBuf (Sd, Sd->mPTLen[CharC]);
+
+ if (CharC <= 2) {
+
+ if (CharC == 0) {
+ CharC = 1;
+ } else if (CharC == 1) {
+ CharC = (UINT16) (GetBits (Sd, 4) + 3);
+ } else if (CharC == 2) {
+ CharC = (UINT16) (GetBits (Sd, CBIT) + 20);
+ }
+
+ CharC--;
+ while ((INT16) (CharC) >= 0) {
+ Sd->mCLen[Index++] = 0;
+ CharC--;
+ }
+
+ } else {
+
+ Sd->mCLen[Index++] = (UINT8) (CharC - 2);
+
+ }
+ }
+
+ while (Index < NC) {
+ Sd->mCLen[Index++] = 0;
+ }
+
+ MakeTable (Sd, NC, Sd->mCLen, 12, Sd->mCTable);
+
+ return ;
+}
+
+STATIC
+UINT16
+DecodeC (
+ SCRATCH_DATA *Sd
+ )
+/*++
+
+Routine Description:
+
+ Decode a character/length value.
+
+Arguments:
+
+ Sd - The global scratch data.
+
+Returns:
+
+ The value decoded.
+
+--*/
+{
+ UINT16 Index2;
+ UINT32 Mask;
+
+ if (Sd->mBlockSize == 0) {
+ //
+ // Starting a new block
+ //
+ Sd->mBlockSize = (UINT16) GetBits (Sd, 16);
+ Sd->mBadTableFlag = ReadPTLen (Sd, NT, TBIT, 3);
+ if (Sd->mBadTableFlag != 0) {
+ return 0;
+ }
+
+ ReadCLen (Sd);
+
+ Sd->mBadTableFlag = ReadPTLen (Sd, MAXNP, mPbit, (UINT16) (-1));
+ if (Sd->mBadTableFlag != 0) {
+ return 0;
+ }
+ }
+
+ Sd->mBlockSize--;
+ Index2 = Sd->mCTable[Sd->mBitBuf >> (BITBUFSIZ - 12)];
+
+ if (Index2 >= NC) {
+ Mask = 1U << (BITBUFSIZ - 1 - 12);
+
+ do {
+ if (Sd->mBitBuf & Mask) {
+ Index2 = Sd->mRight[Index2];
+ } else {
+ Index2 = Sd->mLeft[Index2];
+ }
+
+ Mask >>= 1;
+ } while (Index2 >= NC);
+ }
+ //
+ // Advance what we have read
+ //
+ FillBuf (Sd, Sd->mCLen[Index2]);
+
+ return Index2;
+}
+
+STATIC
+VOID
+Decode (
+ SCRATCH_DATA *Sd
+ )
+/*++
+
+Routine Description:
+
+ Decode the source data and put the resulting data into the destination buffer.
+
+Arguments:
+
+ Sd - The global scratch data
+
+Returns: (VOID)
+
+ --*/
+{
+ UINT16 BytesRemain;
+ UINT32 DataIdx;
+ UINT16 CharC;
+
+ BytesRemain = (UINT16) (-1);
+
+ DataIdx = 0;
+
+ for (;;) {
+ CharC = DecodeC (Sd);
+ if (Sd->mBadTableFlag != 0) {
+ return ;
+ }
+
+ if (CharC < 256) {
+ //
+ // Process an Original character
+ //
+ Sd->mDstBase[Sd->mOutBuf++] = (UINT8) CharC;
+ if (Sd->mOutBuf >= Sd->mOrigSize) {
+ return ;
+ }
+
+ } else {
+ //
+ // Process a Pointer
+ //
+ CharC = (UINT16) (CharC - (UINT8_MAX + 1 - THRESHOLD));
+
+ BytesRemain = CharC;
+
+ DataIdx = Sd->mOutBuf - DecodeP (Sd) - 1;
+
+ BytesRemain--;
+ while ((INT16) (BytesRemain) >= 0) {
+ Sd->mDstBase[Sd->mOutBuf++] = Sd->mDstBase[DataIdx++];
+ if (Sd->mOutBuf >= Sd->mOrigSize) {
+ return ;
+ }
+
+ BytesRemain--;
+ }
+ }
+ }
+
+ return ;
+}
+
+EFI_STATUS
+GetInfo (
+ IN VOID *Source,
+ IN UINT32 SrcSize,
+ OUT UINT32 *DstSize,
+ OUT UINT32 *ScratchSize
+ )
+/*++
+
+Routine Description:
+
+ The implementation of EFI_DECOMPRESS_PROTOCOL.GetInfo().
+
+Arguments:
+
+ Source - The source buffer containing the compressed data.
+ SrcSize - The size of source buffer
+ DstSize - The size of destination buffer.
+ ScratchSize - The size of scratch buffer.
+
+Returns:
+
+ EFI_SUCCESS - The size of destination buffer and the size of scratch buffer are successull retrieved.
+ EFI_INVALID_PARAMETER - The source data is corrupted
+
+--*/
+{
+ UINT8 *Src;
+
+ *ScratchSize = sizeof (SCRATCH_DATA);
+
+ Src = Source;
+ if (SrcSize < 8) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ *DstSize = Src[4] + (Src[5] << 8) + (Src[6] << 16) + (Src[7] << 24);
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+Decompress (
+ IN VOID *Source,
+ IN UINT32 SrcSize,
+ IN OUT VOID *Destination,
+ IN UINT32 DstSize,
+ IN OUT VOID *Scratch,
+ IN UINT32 ScratchSize
+ )
+/*++
+
+Routine Description:
+
+ The implementation Efi and Tiano Decompress().
+
+Arguments:
+
+ Source - The source buffer containing the compressed data.
+ SrcSize - The size of source buffer
+ Destination - The destination buffer to store the decompressed data
+ DstSize - The size of destination buffer.
+ Scratch - The buffer used internally by the decompress routine. This buffer is needed to store intermediate data.
+ ScratchSize - The size of scratch buffer.
+
+Returns:
+
+ EFI_SUCCESS - Decompression is successfull
+ EFI_INVALID_PARAMETER - The source data is corrupted
+
+--*/
+{
+ UINT32 Index;
+ UINT32 CompSize;
+ UINT32 OrigSize;
+ EFI_STATUS Status;
+ SCRATCH_DATA *Sd;
+ UINT8 *Src;
+ UINT8 *Dst;
+
+ Status = EFI_SUCCESS;
+ Src = Source;
+ Dst = Destination;
+
+ if (ScratchSize < sizeof (SCRATCH_DATA)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Sd = (SCRATCH_DATA *) Scratch;
+
+ if (SrcSize < 8) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ CompSize = Src[0] + (Src[1] << 8) + (Src[2] << 16) + (Src[3] << 24);
+ OrigSize = Src[4] + (Src[5] << 8) + (Src[6] << 16) + (Src[7] << 24);
+
+ if (SrcSize < CompSize + 8) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (DstSize != OrigSize) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Src = Src + 8;
+
+ for (Index = 0; Index < sizeof (SCRATCH_DATA); Index++) {
+ ((UINT8 *) Sd)[Index] = 0;
+ }
+
+ Sd->mSrcBase = Src;
+ Sd->mDstBase = Dst;
+ Sd->mCompSize = CompSize;
+ Sd->mOrigSize = OrigSize;
+
+ //
+ // Fill the first BITBUFSIZ bits
+ //
+ FillBuf (Sd, BITBUFSIZ);
+
+ //
+ // Decompress it
+ //
+ Decode (Sd);
+
+ if (Sd->mBadTableFlag != 0) {
+ //
+ // Something wrong with the source
+ //
+ Status = EFI_INVALID_PARAMETER;
+ }
+
+ return Status;
+}
+
+EFI_STATUS
+EfiGetInfo (
+ IN VOID *Source,
+ IN UINT32 SrcSize,
+ OUT UINT32 *DstSize,
+ OUT UINT32 *ScratchSize
+ )
+/*++
+
+Routine Description:
+
+ The implementation Efi Decompress GetInfo().
+
+Arguments:
+
+ Source - The source buffer containing the compressed data.
+ SrcSize - The size of source buffer
+ DstSize - The size of destination buffer.
+ ScratchSize - The size of scratch buffer.
+
+Returns:
+
+ EFI_SUCCESS - The size of destination buffer and the size of scratch buffer are successull retrieved.
+ EFI_INVALID_PARAMETER - The source data is corrupted
+
+--*/
+{
+ return GetInfo (Source, SrcSize, DstSize, ScratchSize);
+}
+
+EFI_STATUS
+TianoGetInfo (
+ IN VOID *Source,
+ IN UINT32 SrcSize,
+ OUT UINT32 *DstSize,
+ OUT UINT32 *ScratchSize
+ )
+/*++
+
+Routine Description:
+
+ The implementation Tiano Decompress GetInfo().
+
+Arguments:
+
+ Source - The source buffer containing the compressed data.
+ SrcSize - The size of source buffer
+ DstSize - The size of destination buffer.
+ ScratchSize - The size of scratch buffer.
+
+Returns:
+
+ EFI_SUCCESS - The size of destination buffer and the size of scratch buffer are successull retrieved.
+ EFI_INVALID_PARAMETER - The source data is corrupted
+
+--*/
+{
+ return GetInfo (Source, SrcSize, DstSize, ScratchSize);
+}
+
+EFI_STATUS
+EfiDecompress (
+ IN VOID *Source,
+ IN UINT32 SrcSize,
+ IN OUT VOID *Destination,
+ IN UINT32 DstSize,
+ IN OUT VOID *Scratch,
+ IN UINT32 ScratchSize
+ )
+/*++
+
+Routine Description:
+
+ The implementation of Efi Decompress().
+
+Arguments:
+
+ Source - The source buffer containing the compressed data.
+ SrcSize - The size of source buffer
+ Destination - The destination buffer to store the decompressed data
+ DstSize - The size of destination buffer.
+ Scratch - The buffer used internally by the decompress routine. This buffer is needed to store intermediate data.
+ ScratchSize - The size of scratch buffer.
+
+Returns:
+
+ EFI_SUCCESS - Decompression is successfull
+ EFI_INVALID_PARAMETER - The source data is corrupted
+
+--*/
+{
+ mPbit = EFIPBIT;
+ return Decompress (Source, SrcSize, Destination, DstSize, Scratch, ScratchSize);
+}
+
+EFI_STATUS
+TianoDecompress (
+ IN VOID *Source,
+ IN UINT32 SrcSize,
+ IN OUT VOID *Destination,
+ IN UINT32 DstSize,
+ IN OUT VOID *Scratch,
+ IN UINT32 ScratchSize
+ )
+/*++
+
+Routine Description:
+
+ The implementation of Tiano Decompress().
+
+Arguments:
+
+ Source - The source buffer containing the compressed data.
+ SrcSize - The size of source buffer
+ Destination - The destination buffer to store the decompressed data
+ DstSize - The size of destination buffer.
+ Scratch - The buffer used internally by the decompress routine. This buffer is needed to store intermediate data.
+ ScratchSize - The size of scratch buffer.
+
+Returns:
+
+ EFI_SUCCESS - Decompression is successfull
+ EFI_INVALID_PARAMETER - The source data is corrupted
+
+--*/
+{
+ mPbit = MAXPBIT;
+ return Decompress (Source, SrcSize, Destination, DstSize, Scratch, ScratchSize);
+}
+
+EFI_STATUS
+Extract (
+ IN VOID *Source,
+ IN UINT32 SrcSize,
+ OUT VOID **Destination,
+ OUT UINT32 *DstSize,
+ IN UINTN Algorithm
+ )
+{
+ VOID *Scratch;
+ UINT32 ScratchSize;
+ EFI_STATUS Status;
+
+ Status = EFI_SUCCESS;
+ switch (Algorithm) {
+ case 0:
+ *Destination = (VOID *)malloc(SrcSize);
+ if (*Destination != NULL) {
+ memcpy(*Destination, Source, SrcSize);
+ } else {
+ Status = EFI_OUT_OF_RESOURCES;
+ }
+ break;
+ case 1:
+ Status = EfiGetInfo(Source, SrcSize, DstSize, &ScratchSize);
+ if (Status == EFI_SUCCESS) {
+ Scratch = (VOID *)malloc(ScratchSize);
+ *Destination = (VOID *)malloc(*DstSize);
+ if (Scratch != NULL && *Destination != NULL) {
+ Status = EfiDecompress(Source, SrcSize, *Destination, *DstSize, Scratch, ScratchSize);
+ } else {
+ Status = EFI_OUT_OF_RESOURCES;
+ }
+ }
+ break;
+ case 2:
+ Status = TianoGetInfo(Source, SrcSize, DstSize, &ScratchSize);
+ if (Status == EFI_SUCCESS) {
+ Scratch = (VOID *)malloc(ScratchSize);
+ *Destination = (VOID *)malloc(*DstSize);
+ if (Scratch != NULL && *Destination != NULL) {
+ Status = TianoDecompress(Source, SrcSize, *Destination, *DstSize, Scratch, ScratchSize);
+ } else {
+ Status = EFI_OUT_OF_RESOURCES;
+ }
+ }
+ break;
+ default:
+ Status = EFI_INVALID_PARAMETER;
+ }
+
+ return Status;
+}
+
+
diff --git a/BaseTools/Source/C/Common/Decompress.h b/BaseTools/Source/C/Common/Decompress.h
new file mode 100644
index 0000000000..b5c978855c
--- /dev/null
+++ b/BaseTools/Source/C/Common/Decompress.h
@@ -0,0 +1,172 @@
+/** @file
+
+Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.
+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.
+
+Module Name:
+
+ Decompress.h
+
+Abstract:
+
+ Header file for compression routine
+
+**/
+
+#ifndef _EFI_DECOMPRESS_H
+#define _EFI_DECOMPRESS_H
+
+#include
+
+EFI_STATUS
+EfiGetInfo (
+ IN VOID *Source,
+ IN UINT32 SrcSize,
+ OUT UINT32 *DstSize,
+ OUT UINT32 *ScratchSize
+ );
+/**
+
+Routine Description:
+
+ The implementation Efi Decompress GetInfo().
+
+Arguments:
+
+ Source - The source buffer containing the compressed data.
+ SrcSize - The size of source buffer
+ DstSize - The size of destination buffer.
+ ScratchSize - The size of scratch buffer.
+
+Returns:
+
+ EFI_SUCCESS - The size of destination buffer and the size of scratch buffer are successull retrieved.
+ EFI_INVALID_PARAMETER - The source data is corrupted
+
+**/
+
+EFI_STATUS
+EfiDecompress (
+ IN VOID *Source,
+ IN UINT32 SrcSize,
+ IN OUT VOID *Destination,
+ IN UINT32 DstSize,
+ IN OUT VOID *Scratch,
+ IN UINT32 ScratchSize
+ );
+/**
+
+Routine Description:
+
+ The implementation of Efi Decompress().
+
+Arguments:
+
+ Source - The source buffer containing the compressed data.
+ SrcSize - The size of source buffer
+ Destination - The destination buffer to store the decompressed data
+ DstSize - The size of destination buffer.
+ Scratch - The buffer used internally by the decompress routine. This buffer is needed to store intermediate data.
+ ScratchSize - The size of scratch buffer.
+
+Returns:
+
+ EFI_SUCCESS - Decompression is successfull
+ EFI_INVALID_PARAMETER - The source data is corrupted
+
+**/
+
+EFI_STATUS
+TianoGetInfo (
+ IN VOID *Source,
+ IN UINT32 SrcSize,
+ OUT UINT32 *DstSize,
+ OUT UINT32 *ScratchSize
+ );
+/**
+
+Routine Description:
+
+ The implementation Tiano Decompress GetInfo().
+
+Arguments:
+
+ Source - The source buffer containing the compressed data.
+ SrcSize - The size of source buffer
+ DstSize - The size of destination buffer.
+ ScratchSize - The size of scratch buffer.
+
+Returns:
+
+ EFI_SUCCESS - The size of destination buffer and the size of scratch buffer are successull retrieved.
+ EFI_INVALID_PARAMETER - The source data is corrupted
+
+**/
+
+EFI_STATUS
+TianoDecompress (
+ IN VOID *Source,
+ IN UINT32 SrcSize,
+ IN OUT VOID *Destination,
+ IN UINT32 DstSize,
+ IN OUT VOID *Scratch,
+ IN UINT32 ScratchSize
+ );
+/**
+
+Routine Description:
+
+ The implementation of Tiano Decompress().
+
+Arguments:
+
+ Source - The source buffer containing the compressed data.
+ SrcSize - The size of source buffer
+ Destination - The destination buffer to store the decompressed data
+ DstSize - The size of destination buffer.
+ Scratch - The buffer used internally by the decompress routine. This buffer is needed to store intermediate data.
+ ScratchSize - The size of scratch buffer.
+
+Returns:
+
+ EFI_SUCCESS - Decompression is successfull
+ EFI_INVALID_PARAMETER - The source data is corrupted
+
+**/
+
+typedef
+EFI_STATUS
+(*GETINFO_FUNCTION) (
+ IN VOID *Source,
+ IN UINT32 SrcSize,
+ OUT UINT32 *DstSize,
+ OUT UINT32 *ScratchSize
+ );
+
+typedef
+EFI_STATUS
+(*DECOMPRESS_FUNCTION) (
+ IN VOID *Source,
+ IN UINT32 SrcSize,
+ IN OUT VOID *Destination,
+ IN UINT32 DstSize,
+ IN OUT VOID *Scratch,
+ IN UINT32 ScratchSize
+ );
+
+EFI_STATUS
+Extract (
+ IN VOID *Source,
+ IN UINT32 SrcSize,
+ OUT VOID **Destination,
+ OUT UINT32 *DstSize,
+ IN UINTN Algorithm
+ );
+
+#endif
diff --git a/BaseTools/Source/C/Common/EfiCompress.c b/BaseTools/Source/C/Common/EfiCompress.c
new file mode 100644
index 0000000000..ed491ae36d
--- /dev/null
+++ b/BaseTools/Source/C/Common/EfiCompress.c
@@ -0,0 +1,1598 @@
+/** @file
+
+Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.
+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.
+
+Module Name:
+
+ EfiCompress.c
+
+Abstract:
+
+ Compression routine. The compression algorithm is a mixture of
+ LZ77 and Huffman coding. LZ77 transforms the source data into a
+ sequence of Original Characters and Pointers to repeated strings.
+ This sequence is further divided into Blocks and Huffman codings
+ are applied to each Block.
+
+**/
+
+#include "Compress.h"
+
+
+//
+// Macro Definitions
+//
+
+#undef UINT8_MAX
+typedef INT16 NODE;
+#define UINT8_MAX 0xff
+#define UINT8_BIT 8
+#define THRESHOLD 3
+#define INIT_CRC 0
+#define WNDBIT 13
+#define WNDSIZ (1U << WNDBIT)
+#define MAXMATCH 256
+#define PERC_FLAG 0x8000U
+#define CODE_BIT 16
+#define NIL 0
+#define MAX_HASH_VAL (3 * WNDSIZ + (WNDSIZ / 512 + 1) * UINT8_MAX)
+#define HASH(p, c) ((p) + ((c) << (WNDBIT - 9)) + WNDSIZ * 2)
+#define CRCPOLY 0xA001
+#define UPDATE_CRC(c) mCrc = mCrcTable[(mCrc ^ (c)) & 0xFF] ^ (mCrc >> UINT8_BIT)
+
+//
+// C: the Char&Len Set; P: the Position Set; T: the exTra Set
+//
+
+#define NC (UINT8_MAX + MAXMATCH + 2 - THRESHOLD)
+#define CBIT 9
+#define NP (WNDBIT + 1)
+#define PBIT 4
+#define NT (CODE_BIT + 3)
+#define TBIT 5
+#if NT > NP
+ #define NPT NT
+#else
+ #define NPT NP
+#endif
+
+//
+// Function Prototypes
+//
+
+STATIC
+VOID
+PutDword(
+ IN UINT32 Data
+ );
+
+STATIC
+EFI_STATUS
+AllocateMemory (
+ );
+
+STATIC
+VOID
+FreeMemory (
+ );
+
+STATIC
+VOID
+InitSlide (
+ );
+
+STATIC
+NODE
+Child (
+ IN NODE q,
+ IN UINT8 c
+ );
+
+STATIC
+VOID
+MakeChild (
+ IN NODE q,
+ IN UINT8 c,
+ IN NODE r
+ );
+
+STATIC
+VOID
+Split (
+ IN NODE Old
+ );
+
+STATIC
+VOID
+InsertNode (
+ );
+
+STATIC
+VOID
+DeleteNode (
+ );
+
+STATIC
+VOID
+GetNextMatch (
+ );
+
+STATIC
+EFI_STATUS
+Encode (
+ );
+
+STATIC
+VOID
+CountTFreq (
+ );
+
+STATIC
+VOID
+WritePTLen (
+ IN INT32 n,
+ IN INT32 nbit,
+ IN INT32 Special
+ );
+
+STATIC
+VOID
+WriteCLen (
+ );
+
+STATIC
+VOID
+EncodeC (
+ IN INT32 c
+ );
+
+STATIC
+VOID
+EncodeP (
+ IN UINT32 p
+ );
+
+STATIC
+VOID
+SendBlock (
+ );
+
+STATIC
+VOID
+Output (
+ IN UINT32 c,
+ IN UINT32 p
+ );
+
+STATIC
+VOID
+HufEncodeStart (
+ );
+
+STATIC
+VOID
+HufEncodeEnd (
+ );
+
+STATIC
+VOID
+MakeCrcTable (
+ );
+
+STATIC
+VOID
+PutBits (
+ IN INT32 n,
+ IN UINT32 x
+ );
+
+STATIC
+INT32
+FreadCrc (
+ OUT UINT8 *p,
+ IN INT32 n
+ );
+
+STATIC
+VOID
+InitPutBits (
+ );
+
+STATIC
+VOID
+CountLen (
+ IN INT32 i
+ );
+
+STATIC
+VOID
+MakeLen (
+ IN INT32 Root
+ );
+
+STATIC
+VOID
+DownHeap (
+ IN INT32 i
+ );
+
+STATIC
+VOID
+MakeCode (
+ IN INT32 n,
+ IN UINT8 Len[],
+ OUT UINT16 Code[]
+ );
+
+STATIC
+INT32
+MakeTree (
+ IN INT32 NParm,
+ IN UINT16 FreqParm[],
+ OUT UINT8 LenParm[],
+ OUT UINT16 CodeParm[]
+ );
+
+
+//
+// Global Variables
+//
+
+STATIC UINT8 *mSrc, *mDst, *mSrcUpperLimit, *mDstUpperLimit;
+
+STATIC UINT8 *mLevel, *mText, *mChildCount, *mBuf, mCLen[NC], mPTLen[NPT], *mLen;
+STATIC INT16 mHeap[NC + 1];
+STATIC INT32 mRemainder, mMatchLen, mBitCount, mHeapSize, mN;
+STATIC UINT32 mBufSiz = 0, mOutputPos, mOutputMask, mSubBitBuf, mCrc;
+STATIC UINT32 mCompSize, mOrigSize;
+
+STATIC UINT16 *mFreq, *mSortPtr, mLenCnt[17], mLeft[2 * NC - 1], mRight[2 * NC - 1],
+ mCrcTable[UINT8_MAX + 1], mCFreq[2 * NC - 1],mCCode[NC],
+ mPFreq[2 * NP - 1], mPTCode[NPT], mTFreq[2 * NT - 1];
+
+STATIC NODE mPos, mMatchPos, mAvail, *mPosition, *mParent, *mPrev, *mNext = NULL;
+
+
+//
+// functions
+//
+
+EFI_STATUS
+EfiCompress (
+ IN UINT8 *SrcBuffer,
+ IN UINT32 SrcSize,
+ IN UINT8 *DstBuffer,
+ IN OUT UINT32 *DstSize
+ )
+/*++
+
+Routine Description:
+
+ The main compression routine.
+
+Arguments:
+
+ SrcBuffer - The buffer storing the source data
+ SrcSize - The size of source data
+ DstBuffer - The buffer to store the compressed data
+ DstSize - On input, the size of DstBuffer; On output,
+ the size of the actual compressed data.
+
+Returns:
+
+ EFI_BUFFER_TOO_SMALL - The DstBuffer is too small. In this case,
+ DstSize contains the size needed.
+ EFI_SUCCESS - Compression is successful.
+
+--*/
+{
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ //
+ // Initializations
+ //
+ mBufSiz = 0;
+ mBuf = NULL;
+ mText = NULL;
+ mLevel = NULL;
+ mChildCount = NULL;
+ mPosition = NULL;
+ mParent = NULL;
+ mPrev = NULL;
+ mNext = NULL;
+
+
+ mSrc = SrcBuffer;
+ mSrcUpperLimit = mSrc + SrcSize;
+ mDst = DstBuffer;
+ mDstUpperLimit = mDst + *DstSize;
+
+ PutDword(0L);
+ PutDword(0L);
+
+ MakeCrcTable ();
+
+ mOrigSize = mCompSize = 0;
+ mCrc = INIT_CRC;
+
+ //
+ // Compress it
+ //
+
+ Status = Encode();
+ if (EFI_ERROR (Status)) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ //
+ // Null terminate the compressed data
+ //
+ if (mDst < mDstUpperLimit) {
+ *mDst++ = 0;
+ }
+
+ //
+ // Fill in compressed size and original size
+ //
+ mDst = DstBuffer;
+ PutDword(mCompSize+1);
+ PutDword(mOrigSize);
+
+ //
+ // Return
+ //
+
+ if (mCompSize + 1 + 8 > *DstSize) {
+ *DstSize = mCompSize + 1 + 8;
+ return EFI_BUFFER_TOO_SMALL;
+ } else {
+ *DstSize = mCompSize + 1 + 8;
+ return EFI_SUCCESS;
+ }
+
+}
+
+STATIC
+VOID
+PutDword(
+ IN UINT32 Data
+ )
+/*++
+
+Routine Description:
+
+ Put a dword to output stream
+
+Arguments:
+
+ Data - the dword to put
+
+Returns: (VOID)
+
+--*/
+{
+ if (mDst < mDstUpperLimit) {
+ *mDst++ = (UINT8)(((UINT8)(Data )) & 0xff);
+ }
+
+ if (mDst < mDstUpperLimit) {
+ *mDst++ = (UINT8)(((UINT8)(Data >> 0x08)) & 0xff);
+ }
+
+ if (mDst < mDstUpperLimit) {
+ *mDst++ = (UINT8)(((UINT8)(Data >> 0x10)) & 0xff);
+ }
+
+ if (mDst < mDstUpperLimit) {
+ *mDst++ = (UINT8)(((UINT8)(Data >> 0x18)) & 0xff);
+ }
+}
+
+STATIC
+EFI_STATUS
+AllocateMemory ()
+/*++
+
+Routine Description:
+
+ Allocate memory spaces for data structures used in compression process
+
+Argements: (VOID)
+
+Returns:
+
+ EFI_SUCCESS - Memory is allocated successfully
+ EFI_OUT_OF_RESOURCES - Allocation fails
+
+--*/
+{
+ UINT32 i;
+
+ mText = malloc (WNDSIZ * 2 + MAXMATCH);
+ for (i = 0 ; i < WNDSIZ * 2 + MAXMATCH; i ++) {
+ mText[i] = 0;
+ }
+
+ mLevel = malloc ((WNDSIZ + UINT8_MAX + 1) * sizeof(*mLevel));
+ mChildCount = malloc ((WNDSIZ + UINT8_MAX + 1) * sizeof(*mChildCount));
+ mPosition = malloc ((WNDSIZ + UINT8_MAX + 1) * sizeof(*mPosition));
+ mParent = malloc (WNDSIZ * 2 * sizeof(*mParent));
+ mPrev = malloc (WNDSIZ * 2 * sizeof(*mPrev));
+ mNext = malloc ((MAX_HASH_VAL + 1) * sizeof(*mNext));
+
+ mBufSiz = 16 * 1024U;
+ while ((mBuf = malloc(mBufSiz)) == NULL) {
+ mBufSiz = (mBufSiz / 10U) * 9U;
+ if (mBufSiz < 4 * 1024U) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ }
+ mBuf[0] = 0;
+
+ return EFI_SUCCESS;
+}
+
+VOID
+FreeMemory ()
+/*++
+
+Routine Description:
+
+ Called when compression is completed to free memory previously allocated.
+
+Arguments: (VOID)
+
+Returns: (VOID)
+
+--*/
+{
+ if (mText) {
+ free (mText);
+ }
+
+ if (mLevel) {
+ free (mLevel);
+ }
+
+ if (mChildCount) {
+ free (mChildCount);
+ }
+
+ if (mPosition) {
+ free (mPosition);
+ }
+
+ if (mParent) {
+ free (mParent);
+ }
+
+ if (mPrev) {
+ free (mPrev);
+ }
+
+ if (mNext) {
+ free (mNext);
+ }
+
+ if (mBuf) {
+ free (mBuf);
+ }
+
+ return;
+}
+
+
+STATIC
+VOID
+InitSlide ()
+/*++
+
+Routine Description:
+
+ Initialize String Info Log data structures
+
+Arguments: (VOID)
+
+Returns: (VOID)
+
+--*/
+{
+ NODE i;
+
+ for (i = WNDSIZ; i <= WNDSIZ + UINT8_MAX; i++) {
+ mLevel[i] = 1;
+ mPosition[i] = NIL; /* sentinel */
+ }
+ for (i = WNDSIZ; i < WNDSIZ * 2; i++) {
+ mParent[i] = NIL;
+ }
+ mAvail = 1;
+ for (i = 1; i < WNDSIZ - 1; i++) {
+ mNext[i] = (NODE)(i + 1);
+ }
+
+ mNext[WNDSIZ - 1] = NIL;
+ for (i = WNDSIZ * 2; i <= MAX_HASH_VAL; i++) {
+ mNext[i] = NIL;
+ }
+}
+
+
+STATIC
+NODE
+Child (
+ IN NODE q,
+ IN UINT8 c
+ )
+/*++
+
+Routine Description:
+
+ Find child node given the parent node and the edge character
+
+Arguments:
+
+ q - the parent node
+ c - the edge character
+
+Returns:
+
+ The child node (NIL if not found)
+
+--*/
+{
+ NODE r;
+
+ r = mNext[HASH(q, c)];
+ mParent[NIL] = q; /* sentinel */
+ while (mParent[r] != q) {
+ r = mNext[r];
+ }
+
+ return r;
+}
+
+STATIC
+VOID
+MakeChild (
+ IN NODE q,
+ IN UINT8 c,
+ IN NODE r
+ )
+/*++
+
+Routine Description:
+
+ Create a new child for a given parent node.
+
+Arguments:
+
+ q - the parent node
+ c - the edge character
+ r - the child node
+
+Returns: (VOID)
+
+--*/
+{
+ NODE h, t;
+
+ h = (NODE)HASH(q, c);
+ t = mNext[h];
+ mNext[h] = r;
+ mNext[r] = t;
+ mPrev[t] = r;
+ mPrev[r] = h;
+ mParent[r] = q;
+ mChildCount[q]++;
+}
+
+STATIC
+VOID
+Split (
+ NODE Old
+ )
+/*++
+
+Routine Description:
+
+ Split a node.
+
+Arguments:
+
+ Old - the node to split
+
+Returns: (VOID)
+
+--*/
+{
+ NODE New, t;
+
+ New = mAvail;
+ mAvail = mNext[New];
+ mChildCount[New] = 0;
+ t = mPrev[Old];
+ mPrev[New] = t;
+ mNext[t] = New;
+ t = mNext[Old];
+ mNext[New] = t;
+ mPrev[t] = New;
+ mParent[New] = mParent[Old];
+ mLevel[New] = (UINT8)mMatchLen;
+ mPosition[New] = mPos;
+ MakeChild(New, mText[mMatchPos + mMatchLen], Old);
+ MakeChild(New, mText[mPos + mMatchLen], mPos);
+}
+
+STATIC
+VOID
+InsertNode ()
+/*++
+
+Routine Description:
+
+ Insert string info for current position into the String Info Log
+
+Arguments: (VOID)
+
+Returns: (VOID)
+
+--*/
+{
+ NODE q, r, j, t;
+ UINT8 c, *t1, *t2;
+
+ if (mMatchLen >= 4) {
+
+ //
+ // We have just got a long match, the target tree
+ // can be located by MatchPos + 1. Travese the tree
+ // from bottom up to get to a proper starting point.
+ // The usage of PERC_FLAG ensures proper node deletion
+ // in DeleteNode() later.
+ //
+
+ mMatchLen--;
+ r = (INT16)((mMatchPos + 1) | WNDSIZ);
+ while ((q = mParent[r]) == NIL) {
+ r = mNext[r];
+ }
+ while (mLevel[q] >= mMatchLen) {
+ r = q; q = mParent[q];
+ }
+ t = q;
+ while (mPosition[t] < 0) {
+ mPosition[t] = mPos;
+ t = mParent[t];
+ }
+ if (t < WNDSIZ) {
+ mPosition[t] = (NODE)(mPos | PERC_FLAG);
+ }
+ } else {
+
+ //
+ // Locate the target tree
+ //
+
+ q = (INT16)(mText[mPos] + WNDSIZ);
+ c = mText[mPos + 1];
+ if ((r = Child(q, c)) == NIL) {
+ MakeChild(q, c, mPos);
+ mMatchLen = 1;
+ return;
+ }
+ mMatchLen = 2;
+ }
+
+ //
+ // Traverse down the tree to find a match.
+ // Update Position value along the route.
+ // Node split or creation is involved.
+ //
+
+ for ( ; ; ) {
+ if (r >= WNDSIZ) {
+ j = MAXMATCH;
+ mMatchPos = r;
+ } else {
+ j = mLevel[r];
+ mMatchPos = (NODE)(mPosition[r] & ~PERC_FLAG);
+ }
+ if (mMatchPos >= mPos) {
+ mMatchPos -= WNDSIZ;
+ }
+ t1 = &mText[mPos + mMatchLen];
+ t2 = &mText[mMatchPos + mMatchLen];
+ while (mMatchLen < j) {
+ if (*t1 != *t2) {
+ Split(r);
+ return;
+ }
+ mMatchLen++;
+ t1++;
+ t2++;
+ }
+ if (mMatchLen >= MAXMATCH) {
+ break;
+ }
+ mPosition[r] = mPos;
+ q = r;
+ if ((r = Child(q, *t1)) == NIL) {
+ MakeChild(q, *t1, mPos);
+ return;
+ }
+ mMatchLen++;
+ }
+ t = mPrev[r];
+ mPrev[mPos] = t;
+ mNext[t] = mPos;
+ t = mNext[r];
+ mNext[mPos] = t;
+ mPrev[t] = mPos;
+ mParent[mPos] = q;
+ mParent[r] = NIL;
+
+ //
+ // Special usage of 'next'
+ //
+ mNext[r] = mPos;
+
+}
+
+STATIC
+VOID
+DeleteNode ()
+/*++
+
+Routine Description:
+
+ Delete outdated string info. (The Usage of PERC_FLAG
+ ensures a clean deletion)
+
+Arguments: (VOID)
+
+Returns: (VOID)
+
+--*/
+{
+ NODE q, r, s, t, u;
+
+ if (mParent[mPos] == NIL) {
+ return;
+ }
+
+ r = mPrev[mPos];
+ s = mNext[mPos];
+ mNext[r] = s;
+ mPrev[s] = r;
+ r = mParent[mPos];
+ mParent[mPos] = NIL;
+ if (r >= WNDSIZ || --mChildCount[r] > 1) {
+ return;
+ }
+ t = (NODE)(mPosition[r] & ~PERC_FLAG);
+ if (t >= mPos) {
+ t -= WNDSIZ;
+ }
+ s = t;
+ q = mParent[r];
+ while ((u = mPosition[q]) & PERC_FLAG) {
+ u &= ~PERC_FLAG;
+ if (u >= mPos) {
+ u -= WNDSIZ;
+ }
+ if (u > s) {
+ s = u;
+ }
+ mPosition[q] = (INT16)(s | WNDSIZ);
+ q = mParent[q];
+ }
+ if (q < WNDSIZ) {
+ if (u >= mPos) {
+ u -= WNDSIZ;
+ }
+ if (u > s) {
+ s = u;
+ }
+ mPosition[q] = (INT16)(s | WNDSIZ | PERC_FLAG);
+ }
+ s = Child(r, mText[t + mLevel[r]]);
+ t = mPrev[s];
+ u = mNext[s];
+ mNext[t] = u;
+ mPrev[u] = t;
+ t = mPrev[r];
+ mNext[t] = s;
+ mPrev[s] = t;
+ t = mNext[r];
+ mPrev[t] = s;
+ mNext[s] = t;
+ mParent[s] = mParent[r];
+ mParent[r] = NIL;
+ mNext[r] = mAvail;
+ mAvail = r;
+}
+
+STATIC
+VOID
+GetNextMatch ()
+/*++
+
+Routine Description:
+
+ Advance the current position (read in new data if needed).
+ Delete outdated string info. Find a match string for current position.
+
+Arguments: (VOID)
+
+Returns: (VOID)
+
+--*/
+{
+ INT32 n;
+
+ mRemainder--;
+ if (++mPos == WNDSIZ * 2) {
+ memmove(&mText[0], &mText[WNDSIZ], WNDSIZ + MAXMATCH);
+ n = FreadCrc(&mText[WNDSIZ + MAXMATCH], WNDSIZ);
+ mRemainder += n;
+ mPos = WNDSIZ;
+ }
+ DeleteNode();
+ InsertNode();
+}
+
+STATIC
+EFI_STATUS
+Encode ()
+/*++
+
+Routine Description:
+
+ The main controlling routine for compression process.
+
+Arguments: (VOID)
+
+Returns:
+
+ EFI_SUCCESS - The compression is successful
+ EFI_OUT_0F_RESOURCES - Not enough memory for compression process
+
+--*/
+{
+ EFI_STATUS Status;
+ INT32 LastMatchLen;
+ NODE LastMatchPos;
+
+ Status = AllocateMemory();
+ if (EFI_ERROR(Status)) {
+ FreeMemory();
+ return Status;
+ }
+
+ InitSlide();
+
+ HufEncodeStart();
+
+ mRemainder = FreadCrc(&mText[WNDSIZ], WNDSIZ + MAXMATCH);
+
+ mMatchLen = 0;
+ mPos = WNDSIZ;
+ InsertNode();
+ if (mMatchLen > mRemainder) {
+ mMatchLen = mRemainder;
+ }
+ while (mRemainder > 0) {
+ LastMatchLen = mMatchLen;
+ LastMatchPos = mMatchPos;
+ GetNextMatch();
+ if (mMatchLen > mRemainder) {
+ mMatchLen = mRemainder;
+ }
+
+ if (mMatchLen > LastMatchLen || LastMatchLen < THRESHOLD) {
+
+ //
+ // Not enough benefits are gained by outputting a pointer,
+ // so just output the original character
+ //
+
+ Output(mText[mPos - 1], 0);
+ } else {
+
+ //
+ // Outputting a pointer is beneficial enough, do it.
+ //
+
+ Output(LastMatchLen + (UINT8_MAX + 1 - THRESHOLD),
+ (mPos - LastMatchPos - 2) & (WNDSIZ - 1));
+ while (--LastMatchLen > 0) {
+ GetNextMatch();
+ }
+ if (mMatchLen > mRemainder) {
+ mMatchLen = mRemainder;
+ }
+ }
+ }
+
+ HufEncodeEnd();
+ FreeMemory();
+ return EFI_SUCCESS;
+}
+
+STATIC
+VOID
+CountTFreq ()
+/*++
+
+Routine Description:
+
+ Count the frequencies for the Extra Set
+
+Arguments: (VOID)
+
+Returns: (VOID)
+
+--*/
+{
+ INT32 i, k, n, Count;
+
+ for (i = 0; i < NT; i++) {
+ mTFreq[i] = 0;
+ }
+ n = NC;
+ while (n > 0 && mCLen[n - 1] == 0) {
+ n--;
+ }
+ i = 0;
+ while (i < n) {
+ k = mCLen[i++];
+ if (k == 0) {
+ Count = 1;
+ while (i < n && mCLen[i] == 0) {
+ i++;
+ Count++;
+ }
+ if (Count <= 2) {
+ mTFreq[0] = (UINT16)(mTFreq[0] + Count);
+ } else if (Count <= 18) {
+ mTFreq[1]++;
+ } else if (Count == 19) {
+ mTFreq[0]++;
+ mTFreq[1]++;
+ } else {
+ mTFreq[2]++;
+ }
+ } else {
+ mTFreq[k + 2]++;
+ }
+ }
+}
+
+STATIC
+VOID
+WritePTLen (
+ IN INT32 n,
+ IN INT32 nbit,
+ IN INT32 Special
+ )
+/*++
+
+Routine Description:
+
+ Outputs the code length array for the Extra Set or the Position Set.
+
+Arguments:
+
+ n - the number of symbols
+ nbit - the number of bits needed to represent 'n'
+ Special - the special symbol that needs to be take care of
+
+Returns: (VOID)
+
+--*/
+{
+ INT32 i, k;
+
+ while (n > 0 && mPTLen[n - 1] == 0) {
+ n--;
+ }
+ PutBits(nbit, n);
+ i = 0;
+ while (i < n) {
+ k = mPTLen[i++];
+ if (k <= 6) {
+ PutBits(3, k);
+ } else {
+ PutBits(k - 3, (1U << (k - 3)) - 2);
+ }
+ if (i == Special) {
+ while (i < 6 && mPTLen[i] == 0) {
+ i++;
+ }
+ PutBits(2, (i - 3) & 3);
+ }
+ }
+}
+
+STATIC
+VOID
+WriteCLen ()
+/*++
+
+Routine Description:
+
+ Outputs the code length array for Char&Length Set
+
+Arguments: (VOID)
+
+Returns: (VOID)
+
+--*/
+{
+ INT32 i, k, n, Count;
+
+ n = NC;
+ while (n > 0 && mCLen[n - 1] == 0) {
+ n--;
+ }
+ PutBits(CBIT, n);
+ i = 0;
+ while (i < n) {
+ k = mCLen[i++];
+ if (k == 0) {
+ Count = 1;
+ while (i < n && mCLen[i] == 0) {
+ i++;
+ Count++;
+ }
+ if (Count <= 2) {
+ for (k = 0; k < Count; k++) {
+ PutBits(mPTLen[0], mPTCode[0]);
+ }
+ } else if (Count <= 18) {
+ PutBits(mPTLen[1], mPTCode[1]);
+ PutBits(4, Count - 3);
+ } else if (Count == 19) {
+ PutBits(mPTLen[0], mPTCode[0]);
+ PutBits(mPTLen[1], mPTCode[1]);
+ PutBits(4, 15);
+ } else {
+ PutBits(mPTLen[2], mPTCode[2]);
+ PutBits(CBIT, Count - 20);
+ }
+ } else {
+ PutBits(mPTLen[k + 2], mPTCode[k + 2]);
+ }
+ }
+}
+
+STATIC
+VOID
+EncodeC (
+ IN INT32 c
+ )
+{
+ PutBits(mCLen[c], mCCode[c]);
+}
+
+STATIC
+VOID
+EncodeP (
+ IN UINT32 p
+ )
+{
+ UINT32 c, q;
+
+ c = 0;
+ q = p;
+ while (q) {
+ q >>= 1;
+ c++;
+ }
+ PutBits(mPTLen[c], mPTCode[c]);
+ if (c > 1) {
+ PutBits(c - 1, p & (0xFFFFU >> (17 - c)));
+ }
+}
+
+STATIC
+VOID
+SendBlock ()
+/*++
+
+Routine Description:
+
+ Huffman code the block and output it.
+
+Argument: (VOID)
+
+Returns: (VOID)
+
+--*/
+{
+ UINT32 i, k, Flags, Root, Pos, Size;
+ Flags = 0;
+
+ Root = MakeTree(NC, mCFreq, mCLen, mCCode);
+ Size = mCFreq[Root];
+ PutBits(16, Size);
+ if (Root >= NC) {
+ CountTFreq();
+ Root = MakeTree(NT, mTFreq, mPTLen, mPTCode);
+ if (Root >= NT) {
+ WritePTLen(NT, TBIT, 3);
+ } else {
+ PutBits(TBIT, 0);
+ PutBits(TBIT, Root);
+ }
+ WriteCLen();
+ } else {
+ PutBits(TBIT, 0);
+ PutBits(TBIT, 0);
+ PutBits(CBIT, 0);
+ PutBits(CBIT, Root);
+ }
+ Root = MakeTree(NP, mPFreq, mPTLen, mPTCode);
+ if (Root >= NP) {
+ WritePTLen(NP, PBIT, -1);
+ } else {
+ PutBits(PBIT, 0);
+ PutBits(PBIT, Root);
+ }
+ Pos = 0;
+ for (i = 0; i < Size; i++) {
+ if (i % UINT8_BIT == 0) {
+ Flags = mBuf[Pos++];
+ } else {
+ Flags <<= 1;
+ }
+ if (Flags & (1U << (UINT8_BIT - 1))) {
+ EncodeC(mBuf[Pos++] + (1U << UINT8_BIT));
+ k = mBuf[Pos++] << UINT8_BIT;
+ k += mBuf[Pos++];
+ EncodeP(k);
+ } else {
+ EncodeC(mBuf[Pos++]);
+ }
+ }
+ for (i = 0; i < NC; i++) {
+ mCFreq[i] = 0;
+ }
+ for (i = 0; i < NP; i++) {
+ mPFreq[i] = 0;
+ }
+}
+
+
+STATIC
+VOID
+Output (
+ IN UINT32 c,
+ IN UINT32 p
+ )
+/*++
+
+Routine Description:
+
+ Outputs an Original Character or a Pointer
+
+Arguments:
+
+ c - The original character or the 'String Length' element of a Pointer
+ p - The 'Position' field of a Pointer
+
+Returns: (VOID)
+
+--*/
+{
+ STATIC UINT32 CPos;
+
+ if ((mOutputMask >>= 1) == 0) {
+ mOutputMask = 1U << (UINT8_BIT - 1);
+ if (mOutputPos >= mBufSiz - 3 * UINT8_BIT) {
+ SendBlock();
+ mOutputPos = 0;
+ }
+ CPos = mOutputPos++;
+ mBuf[CPos] = 0;
+ }
+ mBuf[mOutputPos++] = (UINT8) c;
+ mCFreq[c]++;
+ if (c >= (1U << UINT8_BIT)) {
+ mBuf[CPos] |= mOutputMask;
+ mBuf[mOutputPos++] = (UINT8)(p >> UINT8_BIT);
+ mBuf[mOutputPos++] = (UINT8) p;
+ c = 0;
+ while (p) {
+ p >>= 1;
+ c++;
+ }
+ mPFreq[c]++;
+ }
+}
+
+STATIC
+VOID
+HufEncodeStart ()
+{
+ INT32 i;
+
+ for (i = 0; i < NC; i++) {
+ mCFreq[i] = 0;
+ }
+ for (i = 0; i < NP; i++) {
+ mPFreq[i] = 0;
+ }
+ mOutputPos = mOutputMask = 0;
+ InitPutBits();
+ return;
+}
+
+STATIC
+VOID
+HufEncodeEnd ()
+{
+ SendBlock();
+
+ //
+ // Flush remaining bits
+ //
+ PutBits(UINT8_BIT - 1, 0);
+
+ return;
+}
+
+
+STATIC
+VOID
+MakeCrcTable ()
+{
+ UINT32 i, j, r;
+
+ for (i = 0; i <= UINT8_MAX; i++) {
+ r = i;
+ for (j = 0; j < UINT8_BIT; j++) {
+ if (r & 1) {
+ r = (r >> 1) ^ CRCPOLY;
+ } else {
+ r >>= 1;
+ }
+ }
+ mCrcTable[i] = (UINT16)r;
+ }
+}
+
+STATIC
+VOID
+PutBits (
+ IN INT32 n,
+ IN UINT32 x
+ )
+/*++
+
+Routine Description:
+
+ Outputs rightmost n bits of x
+
+Argments:
+
+ n - the rightmost n bits of the data is used
+ x - the data
+
+Returns: (VOID)
+
+--*/
+{
+ UINT8 Temp;
+
+ if (n < mBitCount) {
+ mSubBitBuf |= x << (mBitCount -= n);
+ } else {
+
+ Temp = (UINT8)(mSubBitBuf | (x >> (n -= mBitCount)));
+ if (mDst < mDstUpperLimit) {
+ *mDst++ = Temp;
+ }
+ mCompSize++;
+
+ if (n < UINT8_BIT) {
+ mSubBitBuf = x << (mBitCount = UINT8_BIT - n);
+ } else {
+
+ Temp = (UINT8)(x >> (n - UINT8_BIT));
+ if (mDst < mDstUpperLimit) {
+ *mDst++ = Temp;
+ }
+ mCompSize++;
+
+ mSubBitBuf = x << (mBitCount = 2 * UINT8_BIT - n);
+ }
+ }
+}
+
+STATIC
+INT32
+FreadCrc (
+ OUT UINT8 *p,
+ IN INT32 n
+ )
+/*++
+
+Routine Description:
+
+ Read in source data
+
+Arguments:
+
+ p - the buffer to hold the data
+ n - number of bytes to read
+
+Returns:
+
+ number of bytes actually read
+
+--*/
+{
+ INT32 i;
+
+ for (i = 0; mSrc < mSrcUpperLimit && i < n; i++) {
+ *p++ = *mSrc++;
+ }
+ n = i;
+
+ p -= n;
+ mOrigSize += n;
+ while (--i >= 0) {
+ UPDATE_CRC(*p++);
+ }
+ return n;
+}
+
+
+STATIC
+VOID
+InitPutBits ()
+{
+ mBitCount = UINT8_BIT;
+ mSubBitBuf = 0;
+}
+
+STATIC
+VOID
+CountLen (
+ IN INT32 i
+ )
+/*++
+
+Routine Description:
+
+ Count the number of each code length for a Huffman tree.
+
+Arguments:
+
+ i - the top node
+
+Returns: (VOID)
+
+--*/
+{
+ STATIC INT32 Depth = 0;
+
+ if (i < mN) {
+ mLenCnt[(Depth < 16) ? Depth : 16]++;
+ } else {
+ Depth++;
+ CountLen(mLeft [i]);
+ CountLen(mRight[i]);
+ Depth--;
+ }
+}
+
+STATIC
+VOID
+MakeLen (
+ IN INT32 Root
+ )
+/*++
+
+Routine Description:
+
+ Create code length array for a Huffman tree
+
+Arguments:
+
+ Root - the root of the tree
+
+--*/
+{
+ INT32 i, k;
+ UINT32 Cum;
+
+ for (i = 0; i <= 16; i++) {
+ mLenCnt[i] = 0;
+ }
+ CountLen(Root);
+
+ //
+ // Adjust the length count array so that
+ // no code will be generated longer than its designated length
+ //
+
+ Cum = 0;
+ for (i = 16; i > 0; i--) {
+ Cum += mLenCnt[i] << (16 - i);
+ }
+ while (Cum != (1U << 16)) {
+ mLenCnt[16]--;
+ for (i = 15; i > 0; i--) {
+ if (mLenCnt[i] != 0) {
+ mLenCnt[i]--;
+ mLenCnt[i+1] += 2;
+ break;
+ }
+ }
+ Cum--;
+ }
+ for (i = 16; i > 0; i--) {
+ k = mLenCnt[i];
+ while (--k >= 0) {
+ mLen[*mSortPtr++] = (UINT8)i;
+ }
+ }
+}
+
+STATIC
+VOID
+DownHeap (
+ IN INT32 i
+ )
+{
+ INT32 j, k;
+
+ //
+ // priority queue: send i-th entry down heap
+ //
+
+ k = mHeap[i];
+ while ((j = 2 * i) <= mHeapSize) {
+ if (j < mHeapSize && mFreq[mHeap[j]] > mFreq[mHeap[j + 1]]) {
+ j++;
+ }
+ if (mFreq[k] <= mFreq[mHeap[j]]) {
+ break;
+ }
+ mHeap[i] = mHeap[j];
+ i = j;
+ }
+ mHeap[i] = (INT16)k;
+}
+
+STATIC
+VOID
+MakeCode (
+ IN INT32 n,
+ IN UINT8 Len[],
+ OUT UINT16 Code[]
+ )
+/*++
+
+Routine Description:
+
+ Assign code to each symbol based on the code length array
+
+Arguments:
+
+ n - number of symbols
+ Len - the code length array
+ Code - stores codes for each symbol
+
+Returns: (VOID)
+
+--*/
+{
+ INT32 i;
+ UINT16 Start[18];
+
+ Start[1] = 0;
+ for (i = 1; i <= 16; i++) {
+ Start[i + 1] = (UINT16)((Start[i] + mLenCnt[i]) << 1);
+ }
+ for (i = 0; i < n; i++) {
+ Code[i] = Start[Len[i]]++;
+ }
+}
+
+STATIC
+INT32
+MakeTree (
+ IN INT32 NParm,
+ IN UINT16 FreqParm[],
+ OUT UINT8 LenParm[],
+ OUT UINT16 CodeParm[]
+ )
+/*++
+
+Routine Description:
+
+ Generates Huffman codes given a frequency distribution of symbols
+
+Arguments:
+
+ NParm - number of symbols
+ FreqParm - frequency of each symbol
+ LenParm - code length for each symbol
+ CodeParm - code for each symbol
+
+Returns:
+
+ Root of the Huffman tree.
+
+--*/
+{
+ INT32 i, j, k, Avail;
+
+ //
+ // make tree, calculate len[], return root
+ //
+
+ mN = NParm;
+ mFreq = FreqParm;
+ mLen = LenParm;
+ Avail = mN;
+ mHeapSize = 0;
+ mHeap[1] = 0;
+ for (i = 0; i < mN; i++) {
+ mLen[i] = 0;
+ if (mFreq[i]) {
+ mHeap[++mHeapSize] = (INT16)i;
+ }
+ }
+ if (mHeapSize < 2) {
+ CodeParm[mHeap[1]] = 0;
+ return mHeap[1];
+ }
+ for (i = mHeapSize / 2; i >= 1; i--) {
+
+ //
+ // make priority queue
+ //
+ DownHeap(i);
+ }
+ mSortPtr = CodeParm;
+ do {
+ i = mHeap[1];
+ if (i < mN) {
+ *mSortPtr++ = (UINT16)i;
+ }
+ mHeap[1] = mHeap[mHeapSize--];
+ DownHeap(1);
+ j = mHeap[1];
+ if (j < mN) {
+ *mSortPtr++ = (UINT16)j;
+ }
+ k = Avail++;
+ mFreq[k] = (UINT16)(mFreq[i] + mFreq[j]);
+ mHeap[1] = (INT16)k;
+ DownHeap(1);
+ mLeft[k] = (UINT16)i;
+ mRight[k] = (UINT16)j;
+ } while (mHeapSize > 1);
+
+ mSortPtr = CodeParm;
+ MakeLen(k);
+ MakeCode(NParm, LenParm, CodeParm);
+
+ //
+ // return root
+ //
+ return k;
+}
+
diff --git a/BaseTools/Source/C/Common/EfiUtilityMsgs.c b/BaseTools/Source/C/Common/EfiUtilityMsgs.c
new file mode 100644
index 0000000000..dc9b0ffaa2
--- /dev/null
+++ b/BaseTools/Source/C/Common/EfiUtilityMsgs.c
@@ -0,0 +1,914 @@
+/** @file
+
+Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.
+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.
+
+Module Name:
+
+ EfiUtilityMsgs.c
+
+Abstract:
+
+ EFI tools utility functions to display warning, error, and informational
+ messages.
+
+--*/
+
+#include
+#include
+#include
+#include
+#include
+
+#include "EfiUtilityMsgs.h"
+
+//
+// Declare module globals for keeping track of the the utility's
+// name and other settings.
+//
+STATIC STATUS mStatus = STATUS_SUCCESS;
+STATIC CHAR8 mUtilityName[50] = { 0 };
+STATIC UINT64 mPrintLogLevel = INFO_LOG_LEVEL;
+STATIC CHAR8 *mSourceFileName = NULL;
+STATIC UINT32 mSourceFileLineNum = 0;
+STATIC UINT32 mErrorCount = 0;
+STATIC UINT32 mWarningCount = 0;
+STATIC UINT32 mMaxErrors = 0;
+STATIC UINT32 mMaxWarnings = 0;
+STATIC UINT32 mMaxWarningsPlusErrors = 0;
+STATIC INT8 mPrintLimitsSet = 0;
+
+STATIC
+VOID
+PrintLimitExceeded (
+ VOID
+ );
+
+VOID
+Error (
+ CHAR8 *FileName,
+ UINT32 LineNumber,
+ UINT32 MessageCode,
+ CHAR8 *Text,
+ CHAR8 *MsgFmt,
+ ...
+ )
+/*++
+
+Routine Description:
+ Prints an error message.
+
+Arguments:
+ All arguments are optional, though the printed message may be useless if
+ at least something valid is not specified.
+
+ FileName - name of the file or application. If not specified, then the
+ utilty name (as set by the utility calling SetUtilityName()
+ earlier) is used. Otherwise "Unknown utility" is used.
+
+ LineNumber - the line number of error, typically used by parsers. If the
+ utility is not a parser, then 0 should be specified. Otherwise
+ the FileName and LineNumber info can be used to cause
+ MS Visual Studio to jump to the error.
+
+ MessageCode - an application-specific error code that can be referenced in
+ other documentation.
+
+ Text - the text in question, typically used by parsers.
+
+ MsgFmt - the format string for the error message. Can contain formatting
+ controls for use with the varargs.
+
+Returns:
+ None.
+
+Notes:
+ We print the following (similar to the Warn() and Debug()
+ W
+ Typical error/warning message format:
+
+ bin\VfrCompile.cpp(330) : error C2660: 'AddVfrDataStructField' : function does not take 2 parameters
+
+ BUGBUG -- these three utility functions are almost identical, and
+ should be modified to share code.
+
+ Visual Studio does not find error messages with:
+
+ " error :"
+ " error 1:"
+ " error c1:"
+ " error 1000:"
+ " error c100:"
+
+ It does find:
+ " error c1000:"
+--*/
+{
+ va_list List;
+ //
+ // If limits have been set, then check that we have not exceeded them
+ //
+ if (mPrintLimitsSet) {
+ //
+ // See if we've exceeded our total count
+ //
+ if (mMaxWarningsPlusErrors != 0) {
+ if (mErrorCount + mWarningCount > mMaxWarningsPlusErrors) {
+ PrintLimitExceeded ();
+ return ;
+ }
+ }
+ //
+ // See if we've exceeded our error count
+ //
+ if (mMaxErrors != 0) {
+ if (mErrorCount > mMaxErrors) {
+ PrintLimitExceeded ();
+ return ;
+ }
+ }
+ }
+
+ mErrorCount++;
+ va_start (List, MsgFmt);
+ PrintMessage ("ERROR", FileName, LineNumber, MessageCode, Text, MsgFmt, List);
+ va_end (List);
+}
+
+VOID
+ParserError (
+ UINT32 MessageCode,
+ CHAR8 *Text,
+ CHAR8 *MsgFmt,
+ ...
+ )
+/*++
+
+Routine Description:
+ Print a parser error, using the source file name and line number
+ set by a previous call to SetParserPosition().
+
+Arguments:
+ MessageCode - application-specific error code
+ Text - text to print in the error message
+ MsgFmt - format string to print at the end of the error message
+
+Returns:
+ NA
+
+--*/
+{
+ va_list List;
+ //
+ // If limits have been set, then check them
+ //
+ if (mPrintLimitsSet) {
+ //
+ // See if we've exceeded our total count
+ //
+ if (mMaxWarningsPlusErrors != 0) {
+ if (mErrorCount + mWarningCount > mMaxWarningsPlusErrors) {
+ PrintLimitExceeded ();
+ return ;
+ }
+ }
+ //
+ // See if we've exceeded our error count
+ //
+ if (mMaxErrors != 0) {
+ if (mErrorCount > mMaxErrors) {
+ PrintLimitExceeded ();
+ return ;
+ }
+ }
+ }
+
+ mErrorCount++;
+ va_start (List, MsgFmt);
+ PrintMessage ("ERROR", mSourceFileName, mSourceFileLineNum, MessageCode, Text, MsgFmt, List);
+ va_end (List);
+}
+
+VOID
+ParserWarning (
+ UINT32 ErrorCode,
+ CHAR8 *OffendingText,
+ CHAR8 *MsgFmt,
+ ...
+ )
+/*++
+
+Routine Description:
+ Print a parser warning, using the source file name and line number
+ set by a previous call to SetParserPosition().
+
+Arguments:
+ ErrorCode - application-specific error code
+ OffendingText - text to print in the warning message
+ MsgFmt - format string to print at the end of the warning message
+
+Returns:
+ NA
+
+--*/
+{
+ va_list List;
+ //
+ // If limits have been set, then check them
+ //
+ if (mPrintLimitsSet) {
+ //
+ // See if we've exceeded our total count
+ //
+ if (mMaxWarningsPlusErrors != 0) {
+ if (mErrorCount + mWarningCount > mMaxWarningsPlusErrors) {
+ PrintLimitExceeded ();
+ return ;
+ }
+ }
+ //
+ // See if we've exceeded our warning count
+ //
+ if (mMaxWarnings != 0) {
+ if (mWarningCount > mMaxWarnings) {
+ PrintLimitExceeded ();
+ return ;
+ }
+ }
+ }
+
+ mWarningCount++;
+ va_start (List, MsgFmt);
+ PrintMessage ("WARNING", mSourceFileName, mSourceFileLineNum, ErrorCode, OffendingText, MsgFmt, List);
+ va_end (List);
+ //
+ // Don't set warning status accordingly
+ //
+ // if (mStatus < STATUS_WARNING) {
+ // mStatus = STATUS_WARNING;
+ // }
+}
+
+VOID
+Warning (
+ CHAR8 *FileName,
+ UINT32 LineNumber,
+ UINT32 MessageCode,
+ CHAR8 *Text,
+ CHAR8 *MsgFmt,
+ ...
+ )
+/*++
+
+Routine Description:
+ Print a warning message.
+
+Arguments:
+ FileName - name of the file where the warning was detected, or the name
+ of the application that detected the warning
+
+ LineNumber - the line number where the warning was detected (parsers).
+ 0 should be specified if the utility is not a parser.
+
+ MessageCode - an application-specific warning code that can be referenced in
+ other documentation.
+
+ Text - the text in question (parsers)
+
+ MsgFmt - the format string for the warning message. Can contain formatting
+ controls for use with varargs.
+
+Returns:
+ None.
+
+--*/
+{
+ va_list List;
+
+ //
+ // Current Print Level not output warning information.
+ //
+ if (WARNING_LOG_LEVEL < mPrintLogLevel) {
+ return;
+ }
+ //
+ // If limits have been set, then check them
+ //
+ if (mPrintLimitsSet) {
+ //
+ // See if we've exceeded our total count
+ //
+ if (mMaxWarningsPlusErrors != 0) {
+ if (mErrorCount + mWarningCount > mMaxWarningsPlusErrors) {
+ PrintLimitExceeded ();
+ return ;
+ }
+ }
+ //
+ // See if we've exceeded our warning count
+ //
+ if (mMaxWarnings != 0) {
+ if (mWarningCount > mMaxWarnings) {
+ PrintLimitExceeded ();
+ return ;
+ }
+ }
+ }
+
+ mWarningCount++;
+ va_start (List, MsgFmt);
+ PrintMessage ("WARNING", FileName, LineNumber, MessageCode, Text, MsgFmt, List);
+ va_end (List);
+}
+
+VOID
+DebugMsg (
+ CHAR8 *FileName,
+ UINT32 LineNumber,
+ UINT64 MsgLevel,
+ CHAR8 *Text,
+ CHAR8 *MsgFmt,
+ ...
+ )
+/*++
+
+Routine Description:
+ Print a Debug message.
+
+Arguments:
+ FileName - typically the name of the utility printing the debug message, but
+ can be the name of a file being parsed.
+
+ LineNumber - the line number in FileName (parsers)
+
+ MsgLevel - Debug message print level (0~9)
+
+ Text - the text in question (parsers)
+
+ MsgFmt - the format string for the debug message. Can contain formatting
+ controls for use with varargs.
+
+Returns:
+ None.
+
+--*/
+{
+ va_list List;
+ //
+ // If the debug level is less than current print level, then do nothing.
+ //
+ if (MsgLevel < mPrintLogLevel) {
+ return ;
+ }
+
+ va_start (List, MsgFmt);
+ PrintMessage ("DEBUG", FileName, LineNumber, 0, Text, MsgFmt, List);
+ va_end (List);
+}
+
+VOID
+PrintMessage (
+ CHAR8 *Type,
+ CHAR8 *FileName,
+ UINT32 LineNumber,
+ UINT32 MessageCode,
+ CHAR8 *Text,
+ CHAR8 *MsgFmt,
+ va_list List
+ )
+/*++
+
+Routine Description:
+ Worker routine for all the utility printing services. Prints the message in
+ a format that Visual Studio will find when scanning build outputs for
+ errors or warnings.
+
+Arguments:
+ Type - "warning" or "error" string to insert into the message to be
+ printed. The first character of this string (converted to uppercase)
+ is used to preceed the MessageCode value in the output string.
+
+ FileName - name of the file where the warning was detected, or the name
+ of the application that detected the warning
+
+ LineNumber - the line number where the warning was detected (parsers).
+ 0 should be specified if the utility is not a parser.
+
+ MessageCode - an application-specific warning code that can be referenced in
+ other documentation.
+
+ Text - part of the message to print
+
+ MsgFmt - the format string for the message. Can contain formatting
+ controls for use with varargs.
+ List - the variable list.
+
+Returns:
+ None.
+
+Notes:
+ If FileName == NULL then this utility will use the string passed into SetUtilityName().
+
+ LineNumber is only used if the caller is a parser, in which case FileName refers to the
+ file being parsed.
+
+ Text and MsgFmt are both optional, though it would be of little use calling this function with
+ them both NULL.
+
+ Output will typically be of the form:
+ () : : :
+
+ Parser (LineNumber != 0)
+ VfrCompile.cpp(330) : error E2660: AddVfrDataStructField : function does not take 2 parameters
+ Generic utility (LineNumber == 0)
+ UtilityName : error E1234 : Text string : MsgFmt string and args
+
+--*/
+{
+ CHAR8 Line[MAX_LINE_LEN];
+ CHAR8 Line2[MAX_LINE_LEN];
+ CHAR8 *Cptr;
+ struct tm *NewTime;
+ time_t CurrentTime;
+
+ //
+ // init local variable
+ //
+ Line[0] = '\0';
+ Line2[0] = '\0';
+
+ //
+ // If given a filename, then add it (and the line number) to the string.
+ // If there's no filename, then use the program name if provided.
+ //
+ if (FileName != NULL) {
+ Cptr = FileName;
+ } else {
+ Cptr = NULL;
+ }
+
+ if (strcmp (Type, "DEBUG") == 0) {
+ //
+ // Debug Message requires current time.
+ //
+ time (&CurrentTime);
+ NewTime = localtime (&CurrentTime);
+ fprintf (stdout, "%04d-%02d-%02d %02d:%02d:%02d",
+ NewTime->tm_year + 1900,
+ NewTime->tm_mon + 1,
+ NewTime->tm_mday,
+ NewTime->tm_hour,
+ NewTime->tm_min,
+ NewTime->tm_sec
+ );
+ if (Cptr != NULL) {
+ sprintf (Line, ": %s", Cptr);
+ if (LineNumber != 0) {
+ sprintf (Line2, "(%u)", (unsigned) LineNumber);
+ strcat (Line, Line2);
+ }
+ }
+ } else {
+ //
+ // Error and Warning Information.
+ //
+ if (Cptr != NULL) {
+ if (mUtilityName[0] != '\0') {
+ fprintf (stdout, "%s...\n", mUtilityName);
+ }
+ sprintf (Line, "%s", Cptr);
+ if (LineNumber != 0) {
+ sprintf (Line2, "(%u)", (unsigned) LineNumber);
+ strcat (Line, Line2);
+ }
+ } else {
+ if (mUtilityName[0] != '\0') {
+ sprintf (Line, "%s", mUtilityName);
+ }
+ }
+
+ if (strcmp (Type, "ERROR") == 0) {
+ //
+ // Set status accordingly for ERROR information.
+ //
+ if (mStatus < STATUS_ERROR) {
+ mStatus = STATUS_ERROR;
+ }
+ }
+ }
+
+ //
+ // Have to print an error code or Visual Studio won't find the
+ // message for you. It has to be decimal digits too.
+ //
+ if (MessageCode != 0) {
+ sprintf (Line2, ": %s %04u", Type, (unsigned) MessageCode);
+ } else {
+ sprintf (Line2, ": %s", Type);
+ }
+ strcat (Line, Line2);
+ fprintf (stdout, "%s", Line);
+ //
+ // If offending text was provided, then print it
+ //
+ if (Text != NULL) {
+ fprintf (stdout, ": %s", Text);
+ }
+ fprintf (stdout, "\n");
+
+ //
+ // Print formatted message if provided
+ //
+ if (MsgFmt != NULL) {
+ vsprintf (Line2, MsgFmt, List);
+ fprintf (stdout, " %s\n", Line2);
+ }
+
+}
+
+STATIC
+VOID
+PrintSimpleMessage (
+ CHAR8 *MsgFmt,
+ va_list List
+ )
+/*++
+Routine Description:
+ Print message into stdout.
+
+Arguments:
+ MsgFmt - the format string for the message. Can contain formatting
+ controls for use with varargs.
+ List - the variable list.
+
+Returns:
+ None.
+--*/
+{
+ CHAR8 Line[MAX_LINE_LEN];
+ //
+ // Print formatted message if provided
+ //
+ if (MsgFmt != NULL) {
+ vsprintf (Line, MsgFmt, List);
+ fprintf (stdout, "%s\n", Line);
+ }
+}
+
+VOID
+ParserSetPosition (
+ CHAR8 *SourceFileName,
+ UINT32 LineNum
+ )
+/*++
+
+Routine Description:
+ Set the position in a file being parsed. This can be used to
+ print error messages deeper down in a parser.
+
+Arguments:
+ SourceFileName - name of the source file being parsed
+ LineNum - line number of the source file being parsed
+
+Returns:
+ NA
+
+--*/
+{
+ mSourceFileName = SourceFileName;
+ mSourceFileLineNum = LineNum;
+}
+
+VOID
+SetUtilityName (
+ CHAR8 *UtilityName
+ )
+/*++
+
+Routine Description:
+ All printed error/warning/debug messages follow the same format, and
+ typically will print a filename or utility name followed by the error
+ text. However if a filename is not passed to the print routines, then
+ they'll print the utility name if you call this function early in your
+ app to set the utility name.
+
+Arguments:
+ UtilityName - name of the utility, which will be printed with all
+ error/warning/debug messags.
+
+Returns:
+ NA
+
+--*/
+{
+ //
+ // Save the name of the utility in our local variable. Make sure its
+ // length does not exceed our buffer.
+ //
+ if (UtilityName != NULL) {
+ if (strlen (UtilityName) >= sizeof (mUtilityName)) {
+ Error (UtilityName, 0, 0, "application error", "utility name length exceeds internal buffer size");
+ strncpy (mUtilityName, UtilityName, sizeof (mUtilityName) - 1);
+ mUtilityName[sizeof (mUtilityName) - 1] = 0;
+ return ;
+ } else {
+ strcpy (mUtilityName, UtilityName);
+ }
+ } else {
+ Error (NULL, 0, 0, "application error", "SetUtilityName() called with NULL utility name");
+ }
+}
+
+STATUS
+GetUtilityStatus (
+ VOID
+ )
+/*++
+
+Routine Description:
+ When you call Error() or Warning(), this module keeps track of it and
+ sets a local mStatus to STATUS_ERROR or STATUS_WARNING. When the utility
+ exits, it can call this function to get the status and use it as a return
+ value.
+
+Arguments:
+ None.
+
+Returns:
+ Worst-case status reported, as defined by which print function was called.
+
+--*/
+{
+ return mStatus;
+}
+
+VOID
+SetPrintLevel (
+ UINT64 LogLevel
+ )
+/*++
+
+Routine Description:
+ Set the printing message Level. This is used by the PrintMsg() function
+ to determine when/if a message should be printed.
+
+Arguments:
+ LogLevel - 0~50 to specify the different level message.
+
+Returns:
+ NA
+
+--*/
+{
+ mPrintLogLevel = LogLevel;
+}
+
+VOID
+VerboseMsg (
+ CHAR8 *MsgFmt,
+ ...
+ )
+/*++
+
+Routine Description:
+ Print a verbose level message.
+
+Arguments:
+ MsgFmt - the format string for the message. Can contain formatting
+ controls for use with varargs.
+ List - the variable list.
+
+Returns:
+ NA
+
+--*/
+{
+ va_list List;
+ //
+ // If the debug level is less than current print level, then do nothing.
+ //
+ if (VERBOSE_LOG_LEVEL < mPrintLogLevel) {
+ return ;
+ }
+
+ va_start (List, MsgFmt);
+ PrintSimpleMessage (MsgFmt, List);
+ va_end (List);
+}
+
+VOID
+NormalMsg (
+ CHAR8 *MsgFmt,
+ ...
+ )
+/*++
+
+Routine Description:
+ Print a default level message.
+
+Arguments:
+ MsgFmt - the format string for the message. Can contain formatting
+ controls for use with varargs.
+ List - the variable list.
+
+Returns:
+ NA
+
+--*/
+{
+ va_list List;
+ //
+ // If the debug level is less than current print level, then do nothing.
+ //
+ if (INFO_LOG_LEVEL < mPrintLogLevel) {
+ return ;
+ }
+
+ va_start (List, MsgFmt);
+ PrintSimpleMessage (MsgFmt, List);
+ va_end (List);
+}
+
+VOID
+KeyMsg (
+ CHAR8 *MsgFmt,
+ ...
+ )
+/*++
+
+Routine Description:
+ Print a key level message.
+
+Arguments:
+ MsgFmt - the format string for the message. Can contain formatting
+ controls for use with varargs.
+ List - the variable list.
+
+Returns:
+ NA
+
+--*/
+{
+ va_list List;
+ //
+ // If the debug level is less than current print level, then do nothing.
+ //
+ if (KEY_LOG_LEVEL < mPrintLogLevel) {
+ return ;
+ }
+
+ va_start (List, MsgFmt);
+ PrintSimpleMessage (MsgFmt, List);
+ va_end (List);
+}
+
+VOID
+SetPrintLimits (
+ UINT32 MaxErrors,
+ UINT32 MaxWarnings,
+ UINT32 MaxWarningsPlusErrors
+ )
+/*++
+
+Routine Description:
+ Set the limits of how many errors, warnings, and errors+warnings
+ we will print.
+
+Arguments:
+ MaxErrors - maximum number of error messages to print
+ MaxWarnings - maximum number of warning messages to print
+ MaxWarningsPlusErrors
+ - maximum number of errors+warnings to print
+
+Returns:
+ NA
+
+--*/
+{
+ mMaxErrors = MaxErrors;
+ mMaxWarnings = MaxWarnings;
+ mMaxWarningsPlusErrors = MaxWarningsPlusErrors;
+ mPrintLimitsSet = 1;
+}
+
+STATIC
+VOID
+PrintLimitExceeded (
+ VOID
+ )
+{
+ STATIC INT8 mPrintLimitExceeded = 0;
+ //
+ // If we've already printed the message, do nothing. Otherwise
+ // temporarily increase our print limits so we can pass one
+ // more message through.
+ //
+ if (mPrintLimitExceeded == 0) {
+ mPrintLimitExceeded++;
+ mMaxErrors++;
+ mMaxWarnings++;
+ mMaxWarningsPlusErrors++;
+ Error (NULL, 0, 0, "error/warning print limit exceeded", NULL);
+ mMaxErrors--;
+ mMaxWarnings--;
+ mMaxWarningsPlusErrors--;
+ }
+}
+
+#if 0
+VOID
+TestUtilityMessages (
+ VOID
+ )
+{
+ CHAR8 *ArgStr = "ArgString";
+ int ArgInt;
+
+ ArgInt = 0x12345678;
+ //
+ // Test without setting utility name
+ //
+ fprintf (stdout, "* Testing without setting utility name\n");
+ fprintf (stdout, "** Test debug message not printed\n");
+ DebugMsg (NULL, 0, 0x00000001, NULL, NULL);
+ fprintf (stdout, "** Test warning with two strings and two args\n");
+ Warning (NULL, 0, 1234, "Text1", "Text2 %s 0x%X", ArgStr, ArgInt);
+ fprintf (stdout, "** Test error with two strings and two args\n");
+ Warning (NULL, 0, 1234, "Text1", "Text2 %s 0x%X", ArgStr, ArgInt);
+ fprintf (stdout, "** Test parser warning with nothing\n");
+ ParserWarning (0, NULL, NULL);
+ fprintf (stdout, "** Test parser error with nothing\n");
+ ParserError (0, NULL, NULL);
+ //
+ // Test with utility name set now
+ //
+ fprintf (stdout, "** Testingin with utility name set\n");
+ SetUtilityName ("MyUtilityName");
+ //
+ // Test debug prints
+ //
+ SetDebugMsgMask (2);
+ fprintf (stdout, "** Test debug message with one string\n");
+ DebugMsg (NULL, 0, 0x00000002, "Text1", NULL);
+ fprintf (stdout, "** Test debug message with one string\n");
+ DebugMsg (NULL, 0, 0x00000002, NULL, "Text2");
+ fprintf (stdout, "** Test debug message with two strings\n");
+ DebugMsg (NULL, 0, 0x00000002, "Text1", "Text2");
+ fprintf (stdout, "** Test debug message with two strings and two args\n");
+ DebugMsg (NULL, 0, 0x00000002, "Text1", "Text2 %s 0x%X", ArgStr, ArgInt);
+ //
+ // Test warning prints
+ //
+ fprintf (stdout, "** Test warning with no strings\n");
+ Warning (NULL, 0, 1234, NULL, NULL);
+ fprintf (stdout, "** Test warning with one string\n");
+ Warning (NULL, 0, 1234, "Text1", NULL);
+ fprintf (stdout, "** Test warning with one string\n");
+ Warning (NULL, 0, 1234, NULL, "Text2");
+ fprintf (stdout, "** Test warning with two strings and two args\n");
+ Warning (NULL, 0, 1234, "Text1", "Text2 %s 0x%X", ArgStr, ArgInt);
+ //
+ // Test error prints
+ //
+ fprintf (stdout, "** Test error with no strings\n");
+ Error (NULL, 0, 1234, NULL, NULL);
+ fprintf (stdout, "** Test error with one string\n");
+ Error (NULL, 0, 1234, "Text1", NULL);
+ fprintf (stdout, "** Test error with one string\n");
+ Error (NULL, 0, 1234, NULL, "Text2");
+ fprintf (stdout, "** Test error with two strings and two args\n");
+ Error (NULL, 0, 1234, "Text1", "Text2 %s 0x%X", ArgStr, ArgInt);
+ //
+ // Test parser prints
+ //
+ fprintf (stdout, "** Test parser errors\n");
+ ParserSetPosition (__FILE__, __LINE__ + 1);
+ ParserError (1234, NULL, NULL);
+ ParserSetPosition (__FILE__, __LINE__ + 1);
+ ParserError (1234, "Text1", NULL);
+ ParserSetPosition (__FILE__, __LINE__ + 1);
+ ParserError (1234, NULL, "Text2");
+ ParserSetPosition (__FILE__, __LINE__ + 1);
+ ParserError (1234, "Text1", "Text2");
+ ParserSetPosition (__FILE__, __LINE__ + 1);
+ ParserError (1234, "Text1", "Text2 %s 0x%X", ArgStr, ArgInt);
+
+ fprintf (stdout, "** Test parser warnings\n");
+ ParserSetPosition (__FILE__, __LINE__ + 1);
+ ParserWarning (4321, NULL, NULL);
+ ParserSetPosition (__FILE__, __LINE__ + 1);
+ ParserWarning (4321, "Text1", NULL);
+ ParserSetPosition (__FILE__, __LINE__ + 1);
+ ParserWarning (4321, NULL, "Text2");
+ ParserSetPosition (__FILE__, __LINE__ + 1);
+ ParserWarning (4321, "Text1", "Text2");
+ ParserSetPosition (__FILE__, __LINE__ + 1);
+ ParserWarning (4321, "Text1", "Text2 %s 0x%X", ArgStr, ArgInt);
+}
+#endif
diff --git a/BaseTools/Source/C/Common/EfiUtilityMsgs.h b/BaseTools/Source/C/Common/EfiUtilityMsgs.h
new file mode 100644
index 0000000000..35cb1802fe
--- /dev/null
+++ b/BaseTools/Source/C/Common/EfiUtilityMsgs.h
@@ -0,0 +1,177 @@
+/** @file
+
+Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.
+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.
+
+Module Name:
+
+ EfiUtilityMsgs.h
+
+Abstract:
+
+ Defines and prototypes for common EFI utility error and debug messages.
+
+**/
+
+#ifndef _EFI_UTILITY_MSGS_H_
+#define _EFI_UTILITY_MSGS_H_
+
+#include
+
+//
+// Log message print Level
+//
+#define VERBOSE_LOG_LEVEL 15
+#define WARNING_LOG_LEVEL 15
+#define INFO_LOG_LEVEL 20
+#define KEY_LOG_LEVEL 40
+#define ERROR_LOG_LEVLE 50
+
+//
+// Status codes returned by EFI utility programs and functions
+//
+#define STATUS_SUCCESS 0
+#define STATUS_WARNING 1
+#define STATUS_ERROR 2
+#define VOID void
+
+typedef int STATUS;
+
+#define MAX_LINE_LEN 0x200
+#define MAXIMUM_INPUT_FILE_NUM 10
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+//
+// When we call Error() or Warning(), the module keeps track of the worst
+// case reported. GetUtilityStatus() will get the worst-case results, which
+// can be used as the return value from the app.
+//
+STATUS
+GetUtilityStatus (
+ VOID
+ );
+
+//
+// If someone prints an error message and didn't specify a source file name,
+// then we print the utility name instead. However they must tell us the
+// utility name early on via this function.
+//
+VOID
+SetUtilityName (
+ CHAR8 *ProgramName
+ )
+;
+
+VOID
+PrintMessage (
+ CHAR8 *Type,
+ CHAR8 *FileName,
+ UINT32 LineNumber,
+ UINT32 MessageCode,
+ CHAR8 *Text,
+ CHAR8 *MsgFmt,
+ va_list List
+ );
+
+VOID
+Error (
+ CHAR8 *FileName,
+ UINT32 LineNumber,
+ UINT32 ErrorCode,
+ CHAR8 *OffendingText,
+ CHAR8 *MsgFmt,
+ ...
+ )
+;
+
+VOID
+Warning (
+ CHAR8 *FileName,
+ UINT32 LineNumber,
+ UINT32 WarningCode,
+ CHAR8 *OffendingText,
+ CHAR8 *MsgFmt,
+ ...
+ )
+;
+
+VOID
+DebugMsg (
+ CHAR8 *FileName,
+ UINT32 LineNumber,
+ UINT64 MsgLevel,
+ CHAR8 *OffendingText,
+ CHAR8 *MsgFmt,
+ ...
+ )
+;
+
+VOID
+VerboseMsg (
+ CHAR8 *MsgFmt,
+ ...
+ );
+
+VOID
+NormalMsg (
+ CHAR8 *MsgFmt,
+ ...
+ );
+
+VOID
+KeyMsg (
+ CHAR8 *MsgFmt,
+ ...
+ );
+
+VOID
+SetPrintLevel (
+ UINT64 LogLevel
+ );
+
+VOID
+ParserSetPosition (
+ CHAR8 *SourceFileName,
+ UINT32 LineNum
+ )
+;
+
+VOID
+ParserError (
+ UINT32 ErrorCode,
+ CHAR8 *OffendingText,
+ CHAR8 *MsgFmt,
+ ...
+ )
+;
+
+VOID
+ParserWarning (
+ UINT32 ErrorCode,
+ CHAR8 *OffendingText,
+ CHAR8 *MsgFmt,
+ ...
+ )
+;
+
+VOID
+SetPrintLimits (
+ UINT32 NumErrors,
+ UINT32 NumWarnings,
+ UINT32 NumWarningsPlusErrors
+ )
+;
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif // #ifndef _EFI_UTILITY_MSGS_H_
diff --git a/BaseTools/Source/C/Common/FirmwareVolumeBuffer.c b/BaseTools/Source/C/Common/FirmwareVolumeBuffer.c
new file mode 100644
index 0000000000..c8586b4078
--- /dev/null
+++ b/BaseTools/Source/C/Common/FirmwareVolumeBuffer.c
@@ -0,0 +1,1667 @@
+/** @file
+
+Copyright (c) 1999 - 2008, Intel Corporation. All rights reserved.
+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.
+
+Module Name:
+
+ FirmwareVolumeBuffer.c
+
+Abstract:
+
+ EFI Firmware Volume routines which work on a Fv image in buffers.
+
+**/
+
+#include "FirmwareVolumeBufferLib.h"
+#include "BinderFuncs.h"
+
+//
+// Local macros
+//
+#define EFI_TEST_FFS_ATTRIBUTES_BIT(FvbAttributes, TestAttributes, Bit) \
+ ( \
+ (BOOLEAN) ( \
+ (FvbAttributes & EFI_FVB2_ERASE_POLARITY) ? (((~TestAttributes) & Bit) == Bit) : ((TestAttributes & Bit) == Bit) \
+ ) \
+ )
+
+
+//
+// Local prototypes
+//
+
+STATIC
+UINT16
+FvBufCalculateChecksum16 (
+ IN UINT16 *Buffer,
+ IN UINTN Size
+ );
+
+STATIC
+UINT8
+FvBufCalculateChecksum8 (
+ IN UINT8 *Buffer,
+ IN UINTN Size
+ );
+
+//
+// Procedures start
+//
+
+EFI_STATUS
+FvBufRemoveFileNew (
+ IN OUT VOID *Fv,
+ IN EFI_GUID *Name
+ )
+/*++
+
+Routine Description:
+
+ Clears out all files from the Fv buffer in memory
+
+Arguments:
+
+ SourceFv - Address of the Fv in memory, this firmware volume volume will
+ be modified, if SourceFfsFile exists
+ SourceFfsFile - Input FFS file to replace
+
+Returns:
+
+ EFI_SUCCESS
+ EFI_NOT_FOUND
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_FFS_FILE_HEADER* FileToRm;
+ UINTN FileToRmLength;
+
+ Status = FvBufFindFileByName(
+ Fv,
+ Name,
+ (VOID **)&FileToRm
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ FileToRmLength = FvBufExpand3ByteSize (FileToRm->Size);
+
+ CommonLibBinderSetMem (
+ FileToRm,
+ FileToRmLength,
+ (((EFI_FIRMWARE_VOLUME_HEADER*)Fv)->Attributes & EFI_FVB2_ERASE_POLARITY)
+ ? 0xFF : 0
+ );
+
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+FvBufRemoveFile (
+ IN OUT VOID *Fv,
+ IN EFI_GUID *Name
+ )
+/*++
+
+Routine Description:
+
+ Clears out all files from the Fv buffer in memory
+
+Arguments:
+
+ SourceFv - Address of the Fv in memory, this firmware volume volume will
+ be modified, if SourceFfsFile exists
+ SourceFfsFile - Input FFS file to replace
+
+Returns:
+
+ EFI_SUCCESS
+ EFI_NOT_FOUND
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_FFS_FILE_HEADER *NextFile;
+ EFI_FIRMWARE_VOLUME_HEADER *TempFv;
+ UINTN FileKey;
+ UINTN FvLength;
+
+ Status = FvBufFindFileByName(
+ Fv,
+ Name,
+ NULL
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Status = FvBufGetSize (Fv, &FvLength);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ TempFv = NULL;
+ Status = FvBufDuplicate (Fv, (VOID **)&TempFv);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Status = FvBufClearAllFiles (TempFv);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ // TempFv has been allocated. It must now be freed
+ // before returning.
+
+ FileKey = 0;
+ while (TRUE) {
+
+ Status = FvBufFindNextFile (Fv, &FileKey, (VOID **)&NextFile);
+ if (Status == EFI_NOT_FOUND) {
+ break;
+ } else if (EFI_ERROR (Status)) {
+ CommonLibBinderFree (TempFv);
+ return Status;
+ }
+
+ if (CommonLibBinderCompareGuid (Name, &NextFile->Name)) {
+ continue;
+ }
+ else {
+ Status = FvBufAddFile (TempFv, NextFile);
+ if (EFI_ERROR (Status)) {
+ CommonLibBinderFree (TempFv);
+ return Status;
+ }
+ }
+ }
+
+ CommonLibBinderCopyMem (Fv, TempFv, FvLength);
+ CommonLibBinderFree (TempFv);
+
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+FvBufChecksumFile (
+ IN OUT VOID *FfsFile
+ )
+/*++
+
+Routine Description:
+
+ Clears out all files from the Fv buffer in memory
+
+Arguments:
+
+ SourceFfsFile - Input FFS file to update the checksum for
+
+Returns:
+
+ EFI_SUCCESS
+ EFI_NOT_FOUND
+
+--*/
+{
+ EFI_FFS_FILE_HEADER* File = (EFI_FFS_FILE_HEADER*)FfsFile;
+ EFI_FFS_FILE_STATE StateBackup;
+ UINT32 FileSize;
+
+ FileSize = FvBufExpand3ByteSize (File->Size);
+
+ //
+ // Fill in checksums and state, they must be 0 for checksumming.
+ //
+ File->IntegrityCheck.Checksum.Header = 0;
+ File->IntegrityCheck.Checksum.File = 0;
+ StateBackup = File->State;
+ File->State = 0;
+
+ File->IntegrityCheck.Checksum.Header =
+ FvBufCalculateChecksum8 (
+ (UINT8 *) File,
+ sizeof (EFI_FFS_FILE_HEADER)
+ );
+
+ if (File->Attributes & FFS_ATTRIB_CHECKSUM) {
+ File->IntegrityCheck.Checksum.File = FvBufCalculateChecksum8 (
+ (VOID*)(File + 1),
+ FileSize - sizeof (EFI_FFS_FILE_HEADER)
+ );
+ } else {
+ File->IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM;
+ }
+
+ File->State = StateBackup;
+
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+FvBufChecksumHeader (
+ IN OUT VOID *Fv
+ )
+/*++
+
+Routine Description:
+
+ Clears out all files from the Fv buffer in memory
+
+Arguments:
+
+ SourceFv - Address of the Fv in memory, this firmware volume volume will
+ be modified, if SourceFfsFile exists
+ SourceFfsFile - Input FFS file to replace
+
+Returns:
+
+ EFI_SUCCESS
+ EFI_NOT_FOUND
+
+--*/
+{
+ EFI_FIRMWARE_VOLUME_HEADER* FvHeader = (EFI_FIRMWARE_VOLUME_HEADER*)Fv;
+
+ FvHeader->Checksum = 0;
+ FvHeader->Checksum =
+ FvBufCalculateChecksum16 (
+ (UINT16*) FvHeader,
+ FvHeader->HeaderLength / sizeof (UINT16)
+ );
+
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+FvBufDuplicate (
+ IN VOID *SourceFv,
+ IN OUT VOID **DestinationFv
+ )
+/*++
+
+Routine Description:
+
+ Clears out all files from the Fv buffer in memory
+
+Arguments:
+
+ SourceFv - Address of the Fv in memory
+ DestinationFv - Output for destination Fv
+ DestinationFv == NULL - invalid parameter
+ *DestinationFv == NULL - memory will be allocated
+ *DestinationFv != NULL - this address will be the destination
+
+Returns:
+
+ EFI_SUCCESS
+
+--*/
+{
+ EFI_STATUS Status;
+ UINTN size;
+
+ if (DestinationFv == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = FvBufGetSize (SourceFv, &size);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ if (*DestinationFv == NULL) {
+ *DestinationFv = CommonLibBinderAllocate (size);
+ }
+
+ CommonLibBinderCopyMem (*DestinationFv, SourceFv, size);
+
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+FvBufExtend (
+ IN VOID **Fv,
+ IN UINTN Size
+ )
+/*++
+
+Routine Description:
+
+ Extends a firmware volume by the given number of bytes.
+
+ BUGBUG: Does not handle the case where the firmware volume has a
+ VTF (Volume Top File). The VTF will not be moved to the
+ end of the extended FV.
+
+Arguments:
+
+ Fv - Source and destination firmware volume.
+ Note: The original firmware volume buffer is freed!
+
+ Size - The minimum size that the firmware volume is to be extended by.
+ The FV may be extended more than this size.
+
+Returns:
+
+ EFI_SUCCESS
+
+--*/
+{
+ EFI_STATUS Status;
+ UINTN OldSize;
+ UINTN NewSize;
+ UINTN BlockCount;
+ VOID* NewFv;
+
+ EFI_FIRMWARE_VOLUME_HEADER* hdr;
+ EFI_FV_BLOCK_MAP_ENTRY* blk;
+
+ Status = FvBufGetSize (*Fv, &OldSize);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Locate the block map in the fv header
+ //
+ hdr = (EFI_FIRMWARE_VOLUME_HEADER*)*Fv;
+ blk = hdr->BlockMap;
+
+ //
+ // Calculate the number of blocks needed to achieve the requested
+ // size extension
+ //
+ BlockCount = ((Size + (blk->Length - 1)) / blk->Length);
+
+ //
+ // Calculate the new size from the number of blocks that will be added
+ //
+ NewSize = OldSize + (BlockCount * blk->Length);
+
+ NewFv = CommonLibBinderAllocate (NewSize);
+ if (NewFv == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ //
+ // Copy the old data
+ //
+ CommonLibBinderCopyMem (NewFv, *Fv, OldSize);
+
+ //
+ // Free the old fv buffer
+ //
+ CommonLibBinderFree (*Fv);
+
+ //
+ // Locate the block map in the new fv header
+ //
+ hdr = (EFI_FIRMWARE_VOLUME_HEADER*)NewFv;
+ hdr->FvLength = NewSize;
+ blk = hdr->BlockMap;
+
+ //
+ // Update the block map for the new fv
+ //
+ blk->NumBlocks += (UINT32)BlockCount;
+
+ //
+ // Update the FV header checksum
+ //
+ FvBufChecksumHeader (NewFv);
+
+ //
+ // Clear out the new area of the FV
+ //
+ CommonLibBinderSetMem (
+ (UINT8*)NewFv + OldSize,
+ (NewSize - OldSize),
+ (hdr->Attributes & EFI_FVB2_ERASE_POLARITY) ? 0xFF : 0
+ );
+
+ //
+ // Set output with new fv that was created
+ //
+ *Fv = NewFv;
+
+ return EFI_SUCCESS;
+
+}
+
+
+EFI_STATUS
+FvBufClearAllFiles (
+ IN OUT VOID *Fv
+ )
+/*++
+
+Routine Description:
+
+ Clears out all files from the Fv buffer in memory
+
+Arguments:
+
+ Fv - Address of the Fv in memory
+
+Returns:
+
+ EFI_SUCCESS
+
+--*/
+
+{
+ EFI_FIRMWARE_VOLUME_HEADER *hdr = (EFI_FIRMWARE_VOLUME_HEADER*)Fv;
+ EFI_STATUS Status;
+ UINTN size = 0;
+
+ Status = FvBufGetSize (Fv, &size);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ CommonLibBinderSetMem(
+ (UINT8*)hdr + hdr->HeaderLength,
+ size - hdr->HeaderLength,
+ (hdr->Attributes & EFI_FVB2_ERASE_POLARITY) ? 0xFF : 0
+ );
+
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+FvBufGetSize (
+ IN VOID *Fv,
+ OUT UINTN *Size
+ )
+/*++
+
+Routine Description:
+
+ Clears out all files from the Fv buffer in memory
+
+Arguments:
+
+ Fv - Address of the Fv in memory
+
+Returns:
+
+ EFI_SUCCESS
+
+--*/
+
+{
+ EFI_FIRMWARE_VOLUME_HEADER *hdr = (EFI_FIRMWARE_VOLUME_HEADER*)Fv;
+ EFI_FV_BLOCK_MAP_ENTRY *blk = hdr->BlockMap;
+
+ *Size = 0;
+
+ while (blk->Length != 0 || blk->NumBlocks != 0) {
+ *Size = *Size + (blk->Length * blk->NumBlocks);
+ if (*Size >= 0x40000000) {
+ // If size is greater than 1GB, then assume it is corrupted
+ return EFI_VOLUME_CORRUPTED;
+ }
+ blk++;
+ }
+
+ if (*Size == 0) {
+ // If size is 0, then assume the volume is corrupted
+ return EFI_VOLUME_CORRUPTED;
+ }
+
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+FvBufAddFile (
+ IN OUT VOID *Fv,
+ IN VOID *File
+ )
+/*++
+
+Routine Description:
+
+ Adds a new FFS file
+
+Arguments:
+
+ Fv - Address of the Fv in memory
+ File - FFS file to add to Fv
+
+Returns:
+
+ EFI_SUCCESS
+
+--*/
+{
+ EFI_FIRMWARE_VOLUME_HEADER *hdr = (EFI_FIRMWARE_VOLUME_HEADER*)Fv;
+
+ EFI_FFS_FILE_HEADER *fhdr = NULL;
+ EFI_FVB_ATTRIBUTES FvbAttributes;
+ UINTN offset;
+ UINTN fsize;
+ UINTN newSize;
+ UINTN clearLoop;
+
+ EFI_STATUS Status;
+ UINTN fvSize;
+
+ Status = FvBufGetSize (Fv, &fvSize);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ FvbAttributes = hdr->Attributes;
+ newSize = FvBufExpand3ByteSize (((EFI_FFS_FILE_HEADER*)File)->Size);
+
+ for(
+ offset = (UINTN)ALIGN_POINTER (hdr->HeaderLength, 8);
+ offset + newSize <= fvSize;
+ offset = (UINTN)ALIGN_POINTER (offset, 8)
+ ) {
+
+ fhdr = (EFI_FFS_FILE_HEADER*) ((UINT8*)hdr + offset);
+
+ if (EFI_TEST_FFS_ATTRIBUTES_BIT(
+ FvbAttributes,
+ fhdr->State,
+ EFI_FILE_HEADER_VALID
+ )
+ ) {
+ // BUGBUG: Need to make sure that the new file does not already
+ // exist.
+
+ fsize = FvBufExpand3ByteSize (fhdr->Size);
+ if (fsize == 0 || (offset + fsize > fvSize)) {
+ return EFI_VOLUME_CORRUPTED;
+ }
+
+ offset = offset + fsize;
+ continue;
+ }
+
+ clearLoop = 0;
+ while ((clearLoop < newSize) &&
+ (((UINT8*)fhdr)[clearLoop] ==
+ (UINT8)((hdr->Attributes & EFI_FVB2_ERASE_POLARITY) ? 0xFF : 0)
+ )
+ ) {
+ clearLoop++;
+ }
+
+ //
+ // We found a place in the FV which is empty and big enough for
+ // the new file
+ //
+ if (clearLoop >= newSize) {
+ break;
+ }
+
+ offset = offset + 1; // Make some forward progress
+ }
+
+ if (offset + newSize > fvSize) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ CommonLibBinderCopyMem (fhdr, File, newSize);
+
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+FvBufAddFileWithExtend (
+ IN OUT VOID **Fv,
+ IN VOID *File
+ )
+/*++
+
+Routine Description:
+
+ Adds a new FFS file. Extends the firmware volume if needed.
+
+Arguments:
+
+ Fv - Source and destination firmware volume.
+ Note: If the FV is extended, then the original firmware volume
+ buffer is freed!
+
+ Size - The minimum size that the firmware volume is to be extended by.
+ The FV may be extended more than this size.
+
+Returns:
+
+ EFI_SUCCESS
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_FFS_FILE_HEADER* NewFile;
+
+ NewFile = (EFI_FFS_FILE_HEADER*)File;
+
+ //
+ // Try to add to the capsule volume
+ //
+ Status = FvBufAddFile (*Fv, NewFile);
+ if (Status == EFI_OUT_OF_RESOURCES) {
+ //
+ // Try to extend the capsule volume by the size of the file
+ //
+ Status = FvBufExtend (Fv, FvBufExpand3ByteSize (NewFile->Size));
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Now, try to add the file again
+ //
+ Status = FvBufAddFile (*Fv, NewFile);
+ }
+
+ return Status;
+}
+
+
+EFI_STATUS
+FvBufAddVtfFile (
+ IN OUT VOID *Fv,
+ IN VOID *File
+ )
+/*++
+
+Routine Description:
+
+ Adds a new FFS VFT (Volume Top File) file. In other words, adds the
+ file to the end of the firmware volume.
+
+Arguments:
+
+ Fv - Address of the Fv in memory
+ File - FFS file to add to Fv
+
+Returns:
+
+ EFI_SUCCESS
+
+--*/
+{
+ EFI_STATUS Status;
+
+ EFI_FIRMWARE_VOLUME_HEADER *hdr = (EFI_FIRMWARE_VOLUME_HEADER*)Fv;
+
+ EFI_FFS_FILE_HEADER* NewFile;
+ UINTN NewFileSize;
+
+ UINT8 erasedUint8;
+ UINTN clearLoop;
+
+ EFI_FFS_FILE_HEADER *LastFile;
+ UINTN LastFileSize;
+
+ UINTN fvSize;
+ UINTN Key;
+
+ Status = FvBufGetSize (Fv, &fvSize);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ erasedUint8 = (UINT8)((hdr->Attributes & EFI_FVB2_ERASE_POLARITY) ? 0xFF : 0);
+ NewFileSize = FvBufExpand3ByteSize (((EFI_FFS_FILE_HEADER*)File)->Size);
+
+ if (NewFileSize != (UINTN)ALIGN_POINTER (NewFileSize, 8)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Find the last file in the FV
+ //
+ Key = 0;
+ LastFile = NULL;
+ LastFileSize = 0;
+ do {
+ Status = FvBufFindNextFile (Fv, &Key, (VOID **)&LastFile);
+ LastFileSize = FvBufExpand3ByteSize (((EFI_FFS_FILE_HEADER*)File)->Size);
+ } while (!EFI_ERROR (Status));
+
+ //
+ // If no files were found, then we start at the beginning of the FV
+ //
+ if (LastFile == NULL) {
+ LastFile = (EFI_FFS_FILE_HEADER*)((UINT8*)hdr + hdr->HeaderLength);
+ }
+
+ //
+ // We want to put the new file (VTF) at the end of the FV
+ //
+ NewFile = (EFI_FFS_FILE_HEADER*)((UINT8*)hdr + (fvSize - NewFileSize));
+
+ //
+ // Check to see if there is enough room for the VTF after the last file
+ // found in the FV
+ //
+ if ((UINT8*)NewFile < ((UINT8*)LastFile + LastFileSize)) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ //
+ // Loop to determine if the end of the FV is empty
+ //
+ clearLoop = 0;
+ while ((clearLoop < NewFileSize) &&
+ (((UINT8*)NewFile)[clearLoop] == erasedUint8)
+ ) {
+ clearLoop++;
+ }
+
+ //
+ // Check to see if there was not enough room for the file
+ //
+ if (clearLoop < NewFileSize) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ CommonLibBinderCopyMem (NewFile, File, NewFileSize);
+
+ return EFI_SUCCESS;
+}
+
+
+VOID
+FvBufCompact3ByteSize (
+ OUT VOID* SizeDest,
+ IN UINT32 Size
+ )
+/*++
+
+Routine Description:
+
+ Expands the 3 byte size commonly used in Firmware Volume data structures
+
+Arguments:
+
+ Size - Address of the 3 byte array representing the size
+
+Returns:
+
+ UINT32
+
+--*/
+{
+ ((UINT8*)SizeDest)[0] = (UINT8)Size;
+ ((UINT8*)SizeDest)[1] = (UINT8)(Size >> 8);
+ ((UINT8*)SizeDest)[2] = (UINT8)(Size >> 16);
+}
+
+UINT32
+FvBufExpand3ByteSize (
+ IN VOID* Size
+ )
+/*++
+
+Routine Description:
+
+ Expands the 3 byte size commonly used in Firmware Volume data structures
+
+Arguments:
+
+ Size - Address of the 3 byte array representing the size
+
+Returns:
+
+ UINT32
+
+--*/
+{
+ return (((UINT8*)Size)[2] << 16) +
+ (((UINT8*)Size)[1] << 8) +
+ ((UINT8*)Size)[0];
+}
+
+EFI_STATUS
+FvBufFindNextFile (
+ IN VOID *Fv,
+ IN OUT UINTN *Key,
+ OUT VOID **File
+ )
+/*++
+
+Routine Description:
+
+ Iterates through the files contained within the firmware volume
+
+Arguments:
+
+ Fv - Address of the Fv in memory
+ Key - Should be 0 to get the first file. After that, it should be
+ passed back in without modifying it's contents to retrieve
+ subsequent files.
+ File - Output file pointer
+ File == NULL - invalid parameter
+ otherwise - *File will be update to the location of the file
+
+Returns:
+
+ EFI_SUCCESS
+ EFI_NOT_FOUND
+ EFI_VOLUME_CORRUPTED
+
+--*/
+{
+ EFI_FIRMWARE_VOLUME_HEADER *hdr = (EFI_FIRMWARE_VOLUME_HEADER*)Fv;
+
+ EFI_FFS_FILE_HEADER *fhdr = NULL;
+ EFI_FVB_ATTRIBUTES FvbAttributes;
+ UINTN fsize;
+
+ EFI_STATUS Status;
+ UINTN fvSize;
+
+ if (Fv == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = FvBufGetSize (Fv, &fvSize);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ if (*Key == 0) {
+ *Key = hdr->HeaderLength;
+ }
+
+ FvbAttributes = hdr->Attributes;
+
+ for(
+ *Key = (UINTN)ALIGN_POINTER (*Key, 8);
+ (*Key + sizeof (*fhdr)) < fvSize;
+ *Key = (UINTN)ALIGN_POINTER (*Key, 8)
+ ) {
+
+ fhdr = (EFI_FFS_FILE_HEADER*) ((UINT8*)hdr + *Key);
+ fsize = FvBufExpand3ByteSize (fhdr->Size);
+
+ if (!EFI_TEST_FFS_ATTRIBUTES_BIT(
+ FvbAttributes,
+ fhdr->State,
+ EFI_FILE_HEADER_VALID
+ ) ||
+ EFI_TEST_FFS_ATTRIBUTES_BIT(
+ FvbAttributes,
+ fhdr->State,
+ EFI_FILE_HEADER_INVALID
+ )
+ ) {
+ *Key = *Key + 1; // Make some forward progress
+ continue;
+ } else if(
+ EFI_TEST_FFS_ATTRIBUTES_BIT(
+ FvbAttributes,
+ fhdr->State,
+ EFI_FILE_MARKED_FOR_UPDATE
+ ) ||
+ EFI_TEST_FFS_ATTRIBUTES_BIT(
+ FvbAttributes,
+ fhdr->State,
+ EFI_FILE_DELETED
+ )
+ ) {
+ *Key = *Key + fsize;
+ continue;
+ } else if (EFI_TEST_FFS_ATTRIBUTES_BIT(
+ FvbAttributes,
+ fhdr->State,
+ EFI_FILE_DATA_VALID
+ )
+ ) {
+ *File = (UINT8*)hdr + *Key;
+ *Key = *Key + fsize;
+ return EFI_SUCCESS;
+ }
+
+ *Key = *Key + 1; // Make some forward progress
+ }
+
+ return EFI_NOT_FOUND;
+}
+
+
+EFI_STATUS
+FvBufFindFileByName (
+ IN VOID *Fv,
+ IN EFI_GUID *Name,
+ OUT VOID **File
+ )
+/*++
+
+Routine Description:
+
+ Searches the Fv for a file by its name
+
+Arguments:
+
+ Fv - Address of the Fv in memory
+ Name - Guid filename to search for in the firmware volume
+ File - Output file pointer
+ File == NULL - Only determine if the file exists, based on return
+ value from the function call.
+ otherwise - *File will be update to the location of the file
+
+Returns:
+
+ EFI_SUCCESS
+ EFI_NOT_FOUND
+ EFI_VOLUME_CORRUPTED
+
+--*/
+{
+ EFI_STATUS Status;
+ UINTN Key;
+ EFI_FFS_FILE_HEADER *NextFile;
+
+ Key = 0;
+ while (TRUE) {
+ Status = FvBufFindNextFile (Fv, &Key, (VOID **)&NextFile);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ if (CommonLibBinderCompareGuid (Name, &NextFile->Name)) {
+ if (File != NULL) {
+ *File = NextFile;
+ }
+ return EFI_SUCCESS;
+ }
+ }
+
+ return EFI_NOT_FOUND;
+}
+
+
+EFI_STATUS
+FvBufFindFileByType (
+ IN VOID *Fv,
+ IN EFI_FV_FILETYPE Type,
+ OUT VOID **File
+ )
+/*++
+
+Routine Description:
+
+ Searches the Fv for a file by its type
+
+Arguments:
+
+ Fv - Address of the Fv in memory
+ Type - FFS FILE type to search for
+ File - Output file pointer
+ (File == NULL) -> Only determine if the file exists, based on return
+ value from the function call.
+ otherwise -> *File will be update to the location of the file
+
+Returns:
+
+ EFI_SUCCESS
+ EFI_NOT_FOUND
+ EFI_VOLUME_CORRUPTED
+
+--*/
+{
+ EFI_STATUS Status;
+ UINTN Key;
+ EFI_FFS_FILE_HEADER *NextFile;
+
+ Key = 0;
+ while (TRUE) {
+ Status = FvBufFindNextFile (Fv, &Key, (VOID **)&NextFile);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ if (Type == NextFile->Type) {
+ if (File != NULL) {
+ *File = NextFile;
+ }
+ return EFI_SUCCESS;
+ }
+ }
+
+ return EFI_NOT_FOUND;
+}
+
+
+EFI_STATUS
+FvBufGetFileRawData (
+ IN VOID* FfsFile,
+ OUT VOID** RawData,
+ OUT UINTN* RawDataSize
+ )
+/*++
+
+Routine Description:
+
+ Searches the requested file for raw data.
+
+ This routine either returns all the payload of a EFI_FV_FILETYPE_RAW file,
+ or finds the EFI_SECTION_RAW section within the file and returns its data.
+
+Arguments:
+
+ FfsFile - Address of the FFS file in memory
+ RawData - Pointer to the raw data within the file
+ (This is NOT allocated. It is within the file.)
+ RawDataSize - Size of the raw data within the file
+
+Returns:
+
+ EFI_STATUS
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_FFS_FILE_HEADER* File;
+ EFI_RAW_SECTION* Section;
+
+ File = (EFI_FFS_FILE_HEADER*)FfsFile;
+
+ //
+ // Is the file type == EFI_FV_FILETYPE_RAW?
+ //
+ if (File->Type == EFI_FV_FILETYPE_RAW) {
+ //
+ // Raw filetypes don't have sections, so we just return the raw data
+ //
+ *RawData = (VOID*)(File + 1);
+ *RawDataSize = FvBufExpand3ByteSize (File->Size) - sizeof (*File);
+ return EFI_SUCCESS;
+ }
+
+ //
+ // Within the file, we now need to find the EFI_SECTION_RAW section.
+ //
+ Status = FvBufFindSectionByType (File, EFI_SECTION_RAW, (VOID **)&Section);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ *RawData = (VOID*)(Section + 1);
+ *RawDataSize =
+ FvBufExpand3ByteSize (Section->Size) - sizeof (*Section);
+
+ return EFI_SUCCESS;
+
+}
+
+
+EFI_STATUS
+FvBufPackageFreeformRawFile (
+ IN EFI_GUID* Filename,
+ IN VOID* RawData,
+ IN UINTN RawDataSize,
+ OUT VOID** FfsFile
+ )
+/*++
+
+Routine Description:
+
+ Packages up a FFS file containing the input raw data.
+
+ The file created will have a type of EFI_FV_FILETYPE_FREEFORM, and will
+ contain one EFI_FV_FILETYPE_RAW section.
+
+Arguments:
+
+ RawData - Pointer to the raw data to be packed
+ RawDataSize - Size of the raw data to be packed
+ FfsFile - Address of the packaged FFS file.
+ Note: The called must deallocate this memory!
+
+Returns:
+
+ EFI_STATUS
+
+--*/
+{
+ EFI_FFS_FILE_HEADER* NewFile;
+ UINT32 NewFileSize;
+ EFI_RAW_SECTION* NewSection;
+ UINT32 NewSectionSize;
+
+ //
+ // The section size is the DataSize + the size of the section header
+ //
+ NewSectionSize = (UINT32)sizeof (EFI_RAW_SECTION) + (UINT32)RawDataSize;
+
+ //
+ // The file size is the size of the file header + the section size
+ //
+ NewFileSize = sizeof (EFI_FFS_FILE_HEADER) + NewSectionSize;
+
+ //
+ // Try to allocate a buffer to build the new FFS file in
+ //
+ NewFile = CommonLibBinderAllocate (NewFileSize);
+ if (NewFile == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ CommonLibBinderSetMem (NewFile, NewFileSize, 0);
+
+ //
+ // The NewSection follow right after the FFS file header
+ //
+ NewSection = (EFI_RAW_SECTION*)(NewFile + 1);
+ FvBufCompact3ByteSize (NewSection->Size, NewSectionSize);
+ NewSection->Type = EFI_SECTION_RAW;
+
+ //
+ // Copy the actual file data into the buffer
+ //
+ CommonLibBinderCopyMem (NewSection + 1, RawData, RawDataSize);
+
+ //
+ // Initialize the FFS file header
+ //
+ CommonLibBinderCopyMem (&NewFile->Name, Filename, sizeof (EFI_GUID));
+ FvBufCompact3ByteSize (NewFile->Size, NewFileSize);
+ NewFile->Type = EFI_FV_FILETYPE_FREEFORM;
+ NewFile->Attributes = 0;
+ NewFile->IntegrityCheck.Checksum.Header =
+ FvBufCalculateChecksum8 ((UINT8*)NewFile, sizeof (*NewFile));
+ NewFile->IntegrityCheck.Checksum.File = FFS_FIXED_CHECKSUM;
+ NewFile->State = (UINT8)~( EFI_FILE_HEADER_CONSTRUCTION |
+ EFI_FILE_HEADER_VALID |
+ EFI_FILE_DATA_VALID
+ );
+
+ *FfsFile = NewFile;
+
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+FvBufFindNextSection (
+ IN VOID *SectionsStart,
+ IN UINTN TotalSectionsSize,
+ IN OUT UINTN *Key,
+ OUT VOID **Section
+ )
+/*++
+
+Routine Description:
+
+ Iterates through the sections contained within a given array of sections
+
+Arguments:
+
+ SectionsStart - Address of the start of the FFS sections array
+ TotalSectionsSize - Total size of all the sections
+ Key - Should be 0 to get the first section. After that, it should be
+ passed back in without modifying it's contents to retrieve
+ subsequent files.
+ Section - Output section pointer
+ (Section == NULL) -> invalid parameter
+ otherwise -> *Section will be update to the location of the file
+
+Returns:
+
+ EFI_SUCCESS
+ EFI_NOT_FOUND
+ EFI_VOLUME_CORRUPTED
+
+--*/
+{
+ EFI_COMMON_SECTION_HEADER *sectionHdr;
+ UINTN sectionSize;
+
+ *Key = (UINTN)ALIGN_POINTER (*Key, 4); // Sections are DWORD aligned
+
+ if ((*Key + sizeof (*sectionHdr)) > TotalSectionsSize) {
+ return EFI_NOT_FOUND;
+ }
+
+ sectionHdr = (EFI_COMMON_SECTION_HEADER*)((UINT8*)SectionsStart + *Key);
+ sectionSize = FvBufExpand3ByteSize (sectionHdr->Size);
+
+ if (sectionSize < sizeof (EFI_COMMON_SECTION_HEADER)) {
+ return EFI_NOT_FOUND;
+ }
+
+ if ((*Key + sectionSize) > TotalSectionsSize) {
+ return EFI_NOT_FOUND;
+ }
+
+ *Section = (UINT8*)sectionHdr;
+ *Key = *Key + sectionSize;
+ return EFI_SUCCESS;
+
+}
+
+
+EFI_STATUS
+FvBufCountSections (
+ IN VOID* FfsFile,
+ IN UINTN* Count
+ )
+/*++
+
+Routine Description:
+
+ Searches the FFS file and counts the number of sections found.
+ The sections are NOT recursed.
+
+Arguments:
+
+ FfsFile - Address of the FFS file in memory
+ Count - The location to store the section count in
+
+Returns:
+
+ EFI_SUCCESS
+ EFI_NOT_FOUND
+ EFI_VOLUME_CORRUPTED
+
+--*/
+{
+ EFI_STATUS Status;
+ UINTN Key;
+ VOID* SectionStart;
+ UINTN TotalSectionsSize;
+ EFI_COMMON_SECTION_HEADER* NextSection;
+
+ SectionStart = (VOID*)((UINTN)FfsFile + sizeof (EFI_FFS_FILE_HEADER));
+ TotalSectionsSize =
+ FvBufExpand3ByteSize (((EFI_FFS_FILE_HEADER*)FfsFile)->Size) -
+ sizeof (EFI_FFS_FILE_HEADER);
+ Key = 0;
+ *Count = 0;
+ while (TRUE) {
+ Status = FvBufFindNextSection (
+ SectionStart,
+ TotalSectionsSize,
+ &Key,
+ (VOID **)&NextSection
+ );
+ if (Status == EFI_NOT_FOUND) {
+ return EFI_SUCCESS;
+ } else if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Increment the section counter
+ //
+ *Count += 1;
+
+ }
+
+ return EFI_NOT_FOUND;
+}
+
+
+EFI_STATUS
+FvBufFindSectionByType (
+ IN VOID *FfsFile,
+ IN UINT8 Type,
+ OUT VOID **Section
+ )
+/*++
+
+Routine Description:
+
+ Searches the FFS file for a section by its type
+
+Arguments:
+
+ FfsFile - Address of the FFS file in memory
+ Type - FFS FILE section type to search for
+ Section - Output section pointer
+ (Section == NULL) -> Only determine if the section exists, based on return
+ value from the function call.
+ otherwise -> *Section will be update to the location of the file
+
+Returns:
+
+ EFI_SUCCESS
+ EFI_NOT_FOUND
+ EFI_VOLUME_CORRUPTED
+
+--*/
+{
+ EFI_STATUS Status;
+ UINTN Key;
+ VOID* SectionStart;
+ UINTN TotalSectionsSize;
+ EFI_COMMON_SECTION_HEADER* NextSection;
+
+ SectionStart = (VOID*)((UINTN)FfsFile + sizeof (EFI_FFS_FILE_HEADER));
+ TotalSectionsSize =
+ FvBufExpand3ByteSize (((EFI_FFS_FILE_HEADER*)FfsFile)->Size) -
+ sizeof (EFI_FFS_FILE_HEADER);
+ Key = 0;
+ while (TRUE) {
+ Status = FvBufFindNextSection (
+ SectionStart,
+ TotalSectionsSize,
+ &Key,
+ (VOID **)&NextSection
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ if (Type == NextSection->Type) {
+ if (Section != NULL) {
+ *Section = NextSection;
+ }
+ return EFI_SUCCESS;
+ }
+ }
+
+ return EFI_NOT_FOUND;
+}
+
+
+EFI_STATUS
+FvBufShrinkWrap (
+ IN VOID *Fv
+ )
+/*++
+
+Routine Description:
+
+ Shrinks a firmware volume (in place) to provide a minimal FV.
+
+ BUGBUG: Does not handle the case where the firmware volume has a
+ VTF (Volume Top File). The VTF will not be moved to the
+ end of the extended FV.
+
+Arguments:
+
+ Fv - Firmware volume.
+
+Returns:
+
+ EFI_SUCCESS
+
+--*/
+{
+ EFI_STATUS Status;
+ UINTN OldSize;
+ UINT32 BlockCount;
+ UINT32 NewBlockSize = 128;
+ UINTN Key;
+ EFI_FFS_FILE_HEADER* FileIt;
+ VOID* EndOfLastFile;
+
+ EFI_FIRMWARE_VOLUME_HEADER* FvHdr;
+
+ Status = FvBufGetSize (Fv, &OldSize);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Status = FvBufUnifyBlockSizes (Fv, NewBlockSize);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Locate the block map in the fv header
+ //
+ FvHdr = (EFI_FIRMWARE_VOLUME_HEADER*)Fv;
+
+ //
+ // Find the end of the last file
+ //
+ Key = 0;
+ EndOfLastFile = (UINT8*)FvHdr + FvHdr->FvLength;
+ while (!EFI_ERROR (FvBufFindNextFile (Fv, &Key, (VOID **)&FileIt))) {
+ EndOfLastFile =
+ (VOID*)((UINT8*)FileIt + FvBufExpand3ByteSize (FileIt->Size));
+ }
+
+ //
+ // Set the BlockCount to have the minimal number of blocks for the Fv.
+ //
+ BlockCount = (UINT32)((UINTN)EndOfLastFile - (UINTN)Fv);
+ BlockCount = BlockCount + NewBlockSize - 1;
+ BlockCount = BlockCount / NewBlockSize;
+
+ //
+ // Adjust the block count to shrink the Fv in place.
+ //
+ FvHdr->BlockMap[0].NumBlocks = BlockCount;
+ FvHdr->FvLength = BlockCount * NewBlockSize;
+
+ //
+ // Update the FV header checksum
+ //
+ FvBufChecksumHeader (Fv);
+
+ return EFI_SUCCESS;
+
+}
+
+
+EFI_STATUS
+FvBufUnifyBlockSizes (
+ IN OUT VOID *Fv,
+ IN UINTN BlockSize
+ )
+/*++
+
+Routine Description:
+
+ Searches the FFS file for a section by its type
+
+Arguments:
+
+ Fv - Address of the Fv in memory
+ BlockSize - The size of the blocks to convert the Fv to. If the total size
+ of the Fv is not evenly divisible by this size, then
+ EFI_INVALID_PARAMETER will be returned.
+
+Returns:
+
+ EFI_SUCCESS
+ EFI_NOT_FOUND
+ EFI_VOLUME_CORRUPTED
+
+--*/
+{
+ EFI_FIRMWARE_VOLUME_HEADER *hdr = (EFI_FIRMWARE_VOLUME_HEADER*)Fv;
+ EFI_FV_BLOCK_MAP_ENTRY *blk = hdr->BlockMap;
+ UINT32 Size;
+
+ Size = 0;
+
+ //
+ // Scan through the block map list, performing error checking, and adding
+ // up the total Fv size.
+ //
+ while( blk->Length != 0 ||
+ blk->NumBlocks != 0
+ ) {
+ Size = Size + (blk->Length * blk->NumBlocks);
+ blk++;
+ if ((UINT8*)blk > ((UINT8*)hdr + hdr->HeaderLength)) {
+ return EFI_VOLUME_CORRUPTED;
+ }
+ }
+
+ //
+ // Make sure that the Fv size is a multiple of the new block size.
+ //
+ if ((Size % BlockSize) != 0) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Zero out the entire block map.
+ //
+ CommonLibBinderSetMem (
+ &hdr->BlockMap,
+ (UINTN)blk - (UINTN)&hdr->BlockMap,
+ 0
+ );
+
+ //
+ // Write out the single block map entry.
+ //
+ hdr->BlockMap[0].Length = (UINT32)BlockSize;
+ hdr->BlockMap[0].NumBlocks = Size / (UINT32)BlockSize;
+
+ return EFI_SUCCESS;
+}
+
+STATIC
+UINT16
+FvBufCalculateSum16 (
+ IN UINT16 *Buffer,
+ IN UINTN Size
+ )
+/*++
+
+Routine Description:
+
+ This function calculates the UINT16 sum for the requested region.
+
+Arguments:
+
+ Buffer Pointer to buffer containing byte data of component.
+ Size Size of the buffer
+
+Returns:
+
+ The 16 bit checksum
+
+--*/
+{
+ UINTN Index;
+ UINT16 Sum;
+
+ Sum = 0;
+
+ //
+ // Perform the word sum for buffer
+ //
+ for (Index = 0; Index < Size; Index++) {
+ Sum = (UINT16) (Sum + Buffer[Index]);
+ }
+
+ return (UINT16) Sum;
+}
+
+
+STATIC
+UINT16
+FvBufCalculateChecksum16 (
+ IN UINT16 *Buffer,
+ IN UINTN Size
+ )
+/*++
+
+Routine Description::
+
+ This function calculates the value needed for a valid UINT16 checksum
+
+Arguments:
+
+ Buffer Pointer to buffer containing byte data of component.
+ Size Size of the buffer
+
+Returns:
+
+ The 16 bit checksum value needed.
+
+--*/
+{
+ return (UINT16)(0x10000 - FvBufCalculateSum16 (Buffer, Size));
+}
+
+
+STATIC
+UINT8
+FvBufCalculateSum8 (
+ IN UINT8 *Buffer,
+ IN UINTN Size
+ )
+/*++
+
+Description:
+
+ This function calculates the UINT8 sum for the requested region.
+
+Input:
+
+ Buffer Pointer to buffer containing byte data of component.
+ Size Size of the buffer
+
+Return:
+
+ The 8 bit checksum value needed.
+
+--*/
+{
+ UINTN Index;
+ UINT8 Sum;
+
+ Sum = 0;
+
+ //
+ // Perform the byte sum for buffer
+ //
+ for (Index = 0; Index < Size; Index++) {
+ Sum = (UINT8) (Sum + Buffer[Index]);
+ }
+
+ return Sum;
+}
+
+
+STATIC
+UINT8
+FvBufCalculateChecksum8 (
+ IN UINT8 *Buffer,
+ IN UINTN Size
+ )
+/*++
+
+Description:
+
+ This function calculates the value needed for a valid UINT8 checksum
+
+Input:
+
+ Buffer Pointer to buffer containing byte data of component.
+ Size Size of the buffer
+
+Return:
+
+ The 8 bit checksum value needed.
+
+--*/
+{
+ return (UINT8)(0x100 - FvBufCalculateSum8 (Buffer, Size));
+}
+
+
diff --git a/BaseTools/Source/C/Common/FirmwareVolumeBufferLib.h b/BaseTools/Source/C/Common/FirmwareVolumeBufferLib.h
new file mode 100644
index 0000000000..12c64f6172
--- /dev/null
+++ b/BaseTools/Source/C/Common/FirmwareVolumeBufferLib.h
@@ -0,0 +1,166 @@
+/** @file
+
+Copyright (c) 1999 - 2008, Intel Corporation. All rights reserved.
+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.
+
+Module Name:
+
+ FirmwareVolumeBufferLib.h
+
+Abstract:
+
+ EFI Firmware Volume routines which work on a Fv image in buffers.
+
+**/
+
+#ifndef FirmwareVolumeBuffer_h_INCLUDED
+#define FirmwareVolumeBuffer_h_INCLUDED
+
+#include "Common/UefiBaseTypes.h"
+#include "Common/PiFirmwareFile.h"
+#include "Common/PiFirmwareVolume.h"
+
+EFI_STATUS
+FvBufAddFile (
+ IN OUT VOID *Fv,
+ IN VOID *File
+ );
+
+EFI_STATUS
+FvBufAddFileWithExtend (
+ IN OUT VOID **Fv,
+ IN VOID *File
+ );
+
+EFI_STATUS
+FvBufAddVtfFile (
+ IN OUT VOID *Fv,
+ IN VOID *File
+ );
+
+EFI_STATUS
+FvBufChecksumFile (
+ IN OUT VOID *FfsFile
+ );
+
+EFI_STATUS
+FvBufChecksumHeader (
+ IN OUT VOID *Fv
+ );
+
+EFI_STATUS
+FvBufClearAllFiles (
+ IN OUT VOID *Fv
+ );
+
+VOID
+FvBufCompact3ByteSize (
+ OUT VOID* SizeDest,
+ IN UINT32 Size
+ );
+
+EFI_STATUS
+FvBufCountSections (
+ IN VOID* FfsFile,
+ IN UINTN* Count
+ );
+
+EFI_STATUS
+FvBufDuplicate (
+ IN VOID *SourceFv,
+ IN OUT VOID **DestinationFv
+ );
+
+UINT32
+FvBufExpand3ByteSize (
+ IN VOID* Size
+ );
+
+EFI_STATUS
+FvBufExtend (
+ IN VOID **Fv,
+ IN UINTN Size
+ );
+
+EFI_STATUS
+FvBufFindFileByName (
+ IN VOID *Fv,
+ IN EFI_GUID *Name,
+ OUT VOID **File
+ );
+
+EFI_STATUS
+FvBufFindFileByType (
+ IN VOID *Fv,
+ IN EFI_FV_FILETYPE Type,
+ OUT VOID **File
+ );
+
+EFI_STATUS
+FvBufFindNextFile (
+ IN VOID *Fv,
+ IN OUT UINTN *Key,
+ OUT VOID **File
+ );
+
+EFI_STATUS
+FvBufFindNextSection (
+ IN VOID *SectionsStart,
+ IN UINTN TotalSectionsSize,
+ IN OUT UINTN *Key,
+ OUT VOID **Section
+ );
+
+EFI_STATUS
+FvBufFindSectionByType (
+ IN VOID *FfsFile,
+ IN UINT8 Type,
+ OUT VOID **Section
+ );
+
+EFI_STATUS
+FvBufGetFileRawData (
+ IN VOID* FfsFile,
+ OUT VOID** RawData,
+ OUT UINTN* RawDataSize
+ );
+
+EFI_STATUS
+FvBufGetSize (
+ IN VOID *Fv,
+ OUT UINTN *Size
+ );
+
+EFI_STATUS
+FvBufPackageFreeformRawFile (
+ IN EFI_GUID* Filename,
+ IN VOID* RawData,
+ IN UINTN RawDataSize,
+ OUT VOID** FfsFile
+ );
+
+EFI_STATUS
+FvBufRemoveFile (
+ IN OUT VOID *Fv,
+ IN EFI_GUID *Name
+ );
+
+EFI_STATUS
+FvBufUnifyBlockSizes (
+ IN OUT VOID *Fv,
+ IN UINTN BlockSize
+ );
+
+EFI_STATUS
+FvBufShrinkWrap (
+ IN VOID *Fv
+ );
+
+#endif // #ifndef FirmwareVolumeBuffer_h_INCLUDED
+
diff --git a/BaseTools/Source/C/Common/FvLib.c b/BaseTools/Source/C/Common/FvLib.c
new file mode 100644
index 0000000000..1b289d83cd
--- /dev/null
+++ b/BaseTools/Source/C/Common/FvLib.c
@@ -0,0 +1,851 @@
+/** @file
+
+Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.
+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.
+
+Module Name:
+
+ FvLib.c
+
+Abstract:
+
+ These functions assist in parsing and manipulating a Firmware Volume.
+
+**/
+
+//
+// Include files
+//
+#include "FvLib.h"
+#include "CommonLib.h"
+#include "EfiUtilityMsgs.h"
+
+//
+// Module global variables
+//
+EFI_FIRMWARE_VOLUME_HEADER *mFvHeader = NULL;
+UINT32 mFvLength = 0;
+
+//
+// External function implementations
+//
+EFI_STATUS
+InitializeFvLib (
+ IN VOID *Fv,
+ IN UINT32 FvLength
+ )
+/*++
+
+Routine Description:
+
+ This initializes the FV lib with a pointer to the FV and length. It does not
+ verify the FV in any way.
+
+Arguments:
+
+ Fv Buffer containing the FV.
+ FvLength Length of the FV
+
+Returns:
+
+ EFI_SUCCESS Function Completed successfully.
+ EFI_INVALID_PARAMETER A required parameter was NULL.
+
+--*/
+{
+ //
+ // Verify input arguments
+ //
+ if (Fv == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ mFvHeader = (EFI_FIRMWARE_VOLUME_HEADER *) Fv;
+ mFvLength = FvLength;
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+GetFvHeader (
+ OUT EFI_FIRMWARE_VOLUME_HEADER **FvHeader,
+ OUT UINT32 *FvLength
+ )
+/*++
+
+Routine Description:
+
+ This function returns a pointer to the current FV and the size.
+
+Arguments:
+
+ FvHeader Pointer to the FV buffer.
+ FvLength Length of the FV
+
+Returns:
+
+ EFI_SUCCESS Function Completed successfully.
+ EFI_INVALID_PARAMETER A required parameter was NULL.
+ EFI_ABORTED The library needs to be initialized.
+
+--*/
+{
+ //
+ // Verify library has been initialized.
+ //
+ if (mFvHeader == NULL || mFvLength == 0) {
+ return EFI_ABORTED;
+ }
+ //
+ // Verify input arguments
+ //
+ if (FvHeader == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ *FvHeader = mFvHeader;
+ *FvLength = mFvLength;
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+GetNextFile (
+ IN EFI_FFS_FILE_HEADER *CurrentFile,
+ OUT EFI_FFS_FILE_HEADER **NextFile
+ )
+/*++
+
+Routine Description:
+
+ This function returns the next file. If the current file is NULL, it returns
+ the first file in the FV. If the function returns EFI_SUCCESS and the file
+ pointer is NULL, then there are no more files in the FV.
+
+Arguments:
+
+ CurrentFile Pointer to the current file, must be within the current FV.
+ NextFile Pointer to the next file in the FV.
+
+Returns:
+
+ EFI_SUCCESS Function completed successfully.
+ EFI_INVALID_PARAMETER A required parameter was NULL or is out of range.
+ EFI_ABORTED The library needs to be initialized.
+
+--*/
+{
+ EFI_STATUS Status;
+
+ //
+ // Verify library has been initialized.
+ //
+ if (mFvHeader == NULL || mFvLength == 0) {
+ return EFI_ABORTED;
+ }
+ //
+ // Verify input arguments
+ //
+ if (NextFile == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+ //
+ // Verify FV header
+ //
+ Status = VerifyFv (mFvHeader);
+ if (EFI_ERROR (Status)) {
+ return EFI_ABORTED;
+ }
+ //
+ // Get first file
+ //
+ if (CurrentFile == NULL) {
+ CurrentFile = (EFI_FFS_FILE_HEADER *) ((UINTN) mFvHeader + mFvHeader->HeaderLength);
+
+ //
+ // Verify file is valid
+ //
+ Status = VerifyFfsFile (CurrentFile);
+ if (EFI_ERROR (Status)) {
+ //
+ // no files in this FV
+ //
+ *NextFile = NULL;
+ return EFI_SUCCESS;
+ } else {
+ //
+ // Verify file is in this FV.
+ //
+ if ((UINTN) CurrentFile + GetLength (CurrentFile->Size) > (UINTN) mFvHeader + mFvLength) {
+ *NextFile = NULL;
+ return EFI_SUCCESS;
+ }
+
+ *NextFile = CurrentFile;
+ return EFI_SUCCESS;
+ }
+ }
+ //
+ // Verify current file is in range
+ //
+ if (((UINTN) CurrentFile < (UINTN) mFvHeader + mFvHeader->HeaderLength) ||
+ ((UINTN) CurrentFile + GetLength (CurrentFile->Size) > (UINTN) mFvHeader + mFvLength)
+ ) {
+ return EFI_INVALID_PARAMETER;
+ }
+ //
+ // Get next file, compensate for 8 byte alignment if necessary.
+ //
+ *NextFile = (EFI_FFS_FILE_HEADER *) ((((UINTN) CurrentFile - (UINTN) mFvHeader + GetLength (CurrentFile->Size) + 0x07) & (-1 << 3)) + (UINT8 *) mFvHeader);
+
+ //
+ // Verify file is in this FV.
+ //
+ if (((UINTN) *NextFile + sizeof (EFI_FFS_FILE_HEADER) >= (UINTN) mFvHeader + mFvLength) ||
+ ((UINTN) *NextFile + GetLength ((*NextFile)->Size) > (UINTN) mFvHeader + mFvLength)
+ ) {
+ *NextFile = NULL;
+ return EFI_SUCCESS;
+ }
+ //
+ // Verify file is valid
+ //
+ Status = VerifyFfsFile (*NextFile);
+ if (EFI_ERROR (Status)) {
+ //
+ // no more files in this FV
+ //
+ *NextFile = NULL;
+ return EFI_SUCCESS;
+ }
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+GetFileByName (
+ IN EFI_GUID *FileName,
+ OUT EFI_FFS_FILE_HEADER **File
+ )
+/*++
+
+Routine Description:
+
+ Find a file by name. The function will return NULL if the file is not found.
+
+Arguments:
+
+ FileName The GUID file name of the file to search for.
+ File Return pointer. In the case of an error, contents are undefined.
+
+Returns:
+
+ EFI_SUCCESS The function completed successfully.
+ EFI_ABORTED An error was encountered.
+ EFI_INVALID_PARAMETER One of the parameters was NULL.
+
+--*/
+{
+ EFI_FFS_FILE_HEADER *CurrentFile;
+ EFI_STATUS Status;
+ CHAR8 FileGuidString[80];
+
+ //
+ // Verify library has been initialized.
+ //
+ if (mFvHeader == NULL || mFvLength == 0) {
+ return EFI_ABORTED;
+ }
+ //
+ // Verify input parameters
+ //
+ if (FileName == NULL || File == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+ //
+ // File Guid String Name
+ //
+ PrintGuidToBuffer (FileName, (UINT8 *)FileGuidString, sizeof (FileGuidString), TRUE);
+ //
+ // Verify FV header
+ //
+ Status = VerifyFv (mFvHeader);
+ if (EFI_ERROR (Status)) {
+ return EFI_ABORTED;
+ }
+ //
+ // Get the first file
+ //
+ Status = GetNextFile (NULL, &CurrentFile);
+ if (EFI_ERROR (Status)) {
+ Error (NULL, 0, 0003, "error parsing FV image", "FFS file with Guid %s can't be found", FileGuidString);
+ return EFI_ABORTED;
+ }
+ //
+ // Loop as long as we have a valid file
+ //
+ while (CurrentFile) {
+ if (!CompareGuid (&CurrentFile->Name, FileName)) {
+ *File = CurrentFile;
+ return EFI_SUCCESS;
+ }
+
+ Status = GetNextFile (CurrentFile, &CurrentFile);
+ if (EFI_ERROR (Status)) {
+ Error (NULL, 0, 0003, "error parsing FV image", "FFS file with Guid %s can't be found", FileGuidString);
+ return EFI_ABORTED;
+ }
+ }
+ //
+ // File not found in this FV.
+ //
+ *File = NULL;
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+GetFileByType (
+ IN EFI_FV_FILETYPE FileType,
+ IN UINTN Instance,
+ OUT EFI_FFS_FILE_HEADER **File
+ )
+/*++
+
+Routine Description:
+
+ Find a file by type and instance. An instance of 1 is the first instance.
+ The function will return NULL if a matching file cannot be found.
+ File type EFI_FV_FILETYPE_ALL means any file type is valid.
+
+Arguments:
+
+ FileType Type of file to search for.
+ Instance Instace of the file type to return.
+ File Return pointer. In the case of an error, contents are undefined.
+
+Returns:
+
+ EFI_SUCCESS The function completed successfully.
+ EFI_ABORTED An error was encountered.
+ EFI_INVALID_PARAMETER One of the parameters was NULL.
+
+--*/
+{
+ EFI_FFS_FILE_HEADER *CurrentFile;
+ EFI_STATUS Status;
+ UINTN FileCount;
+
+ //
+ // Verify library has been initialized.
+ //
+ if (mFvHeader == NULL || mFvLength == 0) {
+ return EFI_ABORTED;
+ }
+ //
+ // Verify input parameters
+ //
+ if (File == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+ //
+ // Verify FV header
+ //
+ Status = VerifyFv (mFvHeader);
+ if (EFI_ERROR (Status)) {
+ return EFI_ABORTED;
+ }
+ //
+ // Initialize the number of matching files found.
+ //
+ FileCount = 0;
+
+ //
+ // Get the first file
+ //
+ Status = GetNextFile (NULL, &CurrentFile);
+ if (EFI_ERROR (Status)) {
+ Error (NULL, 0, 0003, "error parsing FV image", "FFS file with FileType 0x%x can't be found", FileType);
+ return EFI_ABORTED;
+ }
+ //
+ // Loop as long as we have a valid file
+ //
+ while (CurrentFile) {
+ if (FileType == EFI_FV_FILETYPE_ALL || CurrentFile->Type == FileType) {
+ FileCount++;
+ }
+
+ if (FileCount == Instance) {
+ *File = CurrentFile;
+ return EFI_SUCCESS;
+ }
+
+ Status = GetNextFile (CurrentFile, &CurrentFile);
+ if (EFI_ERROR (Status)) {
+ Error (NULL, 0, 0003, "error parsing FV image", "FFS file with FileType 0x%x can't be found", FileType);
+ return EFI_ABORTED;
+ }
+ }
+
+ *File = NULL;
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+SearchSectionByType (
+ IN EFI_FILE_SECTION_POINTER FirstSection,
+ IN UINT8 *SearchEnd,
+ IN EFI_SECTION_TYPE SectionType,
+ IN OUT UINTN *StartIndex,
+ IN UINTN Instance,
+ OUT EFI_FILE_SECTION_POINTER *Section
+ )
+/*++
+
+Routine Description:
+
+ Helper function to search a sequence of sections from the section pointed
+ by FirstSection to SearchEnd for the Instance-th section of type SectionType.
+ The current counter is saved in StartIndex and when the section is found, it's
+ saved in Section. GUID-defined sections, if special processing is not required,
+ are searched recursively in a depth-first manner.
+
+Arguments:
+
+ FirstSection The first section to start searching from.
+ SearchEnd The end address to stop search.
+ SectionType The type of section to search.
+ StartIndex The current counter is saved.
+ Instance The requested n-th section number.
+ Section The found section returned.
+
+Returns:
+
+ EFI_SUCCESS The function completed successfully.
+ EFI_NOT_FOUND The section is not found.
+--*/
+{
+ EFI_FILE_SECTION_POINTER CurrentSection;
+ EFI_FILE_SECTION_POINTER InnerSection;
+ EFI_STATUS Status;
+ UINTN SectionSize;
+
+ CurrentSection = FirstSection;
+
+ while ((UINTN) CurrentSection.CommonHeader < (UINTN) SearchEnd) {
+ if (CurrentSection.CommonHeader->Type == SectionType) {
+ (*StartIndex)++;
+ }
+
+ if (*StartIndex == Instance) {
+ *Section = CurrentSection;
+ return EFI_SUCCESS;
+ }
+ //
+ // If the requesting section is not GUID-defined and
+ // we find a GUID-defined section that doesn't need
+ // special processing, go ahead to search the requesting
+ // section inside the GUID-defined section.
+ //
+ if (SectionType != EFI_SECTION_GUID_DEFINED &&
+ CurrentSection.CommonHeader->Type == EFI_SECTION_GUID_DEFINED &&
+ !(CurrentSection.GuidDefinedSection->Attributes & EFI_GUIDED_SECTION_PROCESSING_REQUIRED)) {
+ InnerSection.CommonHeader = (EFI_COMMON_SECTION_HEADER *)
+ ((UINTN) CurrentSection.CommonHeader + CurrentSection.GuidDefinedSection->DataOffset);
+ SectionSize = CurrentSection.CommonHeader->Size[0] +
+ (CurrentSection.CommonHeader->Size[1] << 8) +
+ (CurrentSection.CommonHeader->Size[2] << 16);
+ Status = SearchSectionByType (
+ InnerSection,
+ (UINT8 *) ((UINTN) CurrentSection.CommonHeader + SectionSize),
+ SectionType,
+ StartIndex,
+ Instance,
+ Section
+ );
+ if (!EFI_ERROR (Status)) {
+ return EFI_SUCCESS;
+ }
+ }
+ //
+ // Find next section (including compensating for alignment issues.
+ //
+ CurrentSection.CommonHeader = (EFI_COMMON_SECTION_HEADER *) ((((UINTN) CurrentSection.CommonHeader) + GetLength (CurrentSection.CommonHeader->Size) + 0x03) & (-1 << 2));
+ }
+
+ return EFI_NOT_FOUND;
+}
+
+EFI_STATUS
+GetSectionByType (
+ IN EFI_FFS_FILE_HEADER *File,
+ IN EFI_SECTION_TYPE SectionType,
+ IN UINTN Instance,
+ OUT EFI_FILE_SECTION_POINTER *Section
+ )
+/*++
+
+Routine Description:
+
+ Find a section in a file by type and instance. An instance of 1 is the first
+ instance. The function will return NULL if a matching section cannot be found.
+ GUID-defined sections, if special processing is not needed, are handled in a
+ depth-first manner.
+
+Arguments:
+
+ File The file to search.
+ SectionType Type of file to search for.
+ Instance Instace of the section to return.
+ Section Return pointer. In the case of an error, contents are undefined.
+
+Returns:
+
+ EFI_SUCCESS The function completed successfully.
+ EFI_ABORTED An error was encountered.
+ EFI_INVALID_PARAMETER One of the parameters was NULL.
+ EFI_NOT_FOUND No found.
+--*/
+{
+ EFI_FILE_SECTION_POINTER CurrentSection;
+ EFI_STATUS Status;
+ UINTN SectionCount;
+
+ //
+ // Verify input parameters
+ //
+ if (File == NULL || Instance == 0) {
+ return EFI_INVALID_PARAMETER;
+ }
+ //
+ // Verify FFS header
+ //
+ Status = VerifyFfsFile (File);
+ if (EFI_ERROR (Status)) {
+ Error (NULL, 0, 0006, "invalid FFS file", NULL);
+ return EFI_ABORTED;
+ }
+ //
+ // Initialize the number of matching sections found.
+ //
+ SectionCount = 0;
+
+ //
+ // Get the first section
+ //
+ CurrentSection.CommonHeader = (EFI_COMMON_SECTION_HEADER *) ((UINTN) File + sizeof (EFI_FFS_FILE_HEADER));
+
+ //
+ // Depth-first manner to find section file.
+ //
+ Status = SearchSectionByType (
+ CurrentSection,
+ (UINT8 *) ((UINTN) File + GetLength (File->Size)),
+ SectionType,
+ &SectionCount,
+ Instance,
+ Section
+ );
+
+ if (!EFI_ERROR (Status)) {
+ return EFI_SUCCESS;
+ } else {
+ //
+ // Section not found
+ //
+ (*Section).Code16Section = NULL;
+ return EFI_NOT_FOUND;
+ }
+}
+//
+// will not parse compressed sections
+//
+EFI_STATUS
+VerifyFv (
+ IN EFI_FIRMWARE_VOLUME_HEADER *FvHeader
+ )
+/*++
+
+Routine Description:
+
+ Verify the current pointer points to a valid FV header.
+
+Arguments:
+
+ FvHeader Pointer to an alleged FV file.
+
+Returns:
+
+ EFI_SUCCESS The FV header is valid.
+ EFI_VOLUME_CORRUPTED The FV header is not valid.
+ EFI_INVALID_PARAMETER A required parameter was NULL.
+ EFI_ABORTED Operation aborted.
+
+--*/
+{
+ UINT16 Checksum;
+
+ //
+ // Verify input parameters
+ //
+ if (FvHeader == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (FvHeader->Signature != EFI_FVH_SIGNATURE) {
+ Error (NULL, 0, 0006, "invalid FV header signature", NULL);
+ return EFI_VOLUME_CORRUPTED;
+ }
+ //
+ // Verify header checksum
+ //
+ Checksum = CalculateSum16 ((UINT16 *) FvHeader, FvHeader->HeaderLength / sizeof (UINT16));
+
+ if (Checksum != 0) {
+ Error (NULL, 0, 0006, "invalid FV header checksum", NULL);
+ return EFI_ABORTED;
+ }
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+VerifyFfsFile (
+ IN EFI_FFS_FILE_HEADER *FfsHeader
+ )
+/*++
+
+Routine Description:
+
+ Verify the current pointer points to a FFS file header.
+
+Arguments:
+
+ FfsHeader Pointer to an alleged FFS file.
+
+Returns:
+
+ EFI_SUCCESS The Ffs header is valid.
+ EFI_NOT_FOUND This "file" is the beginning of free space.
+ EFI_VOLUME_CORRUPTED The Ffs header is not valid.
+ EFI_ABORTED The erase polarity is not known.
+
+--*/
+{
+ BOOLEAN ErasePolarity;
+ EFI_STATUS Status;
+ EFI_FFS_FILE_HEADER BlankHeader;
+ UINT8 Checksum;
+ UINT32 FileLength;
+ UINT8 SavedChecksum;
+ UINT8 SavedState;
+ UINT8 FileGuidString[80];
+ //
+ // Verify library has been initialized.
+ //
+ if (mFvHeader == NULL || mFvLength == 0) {
+ return EFI_ABORTED;
+ }
+ //
+ // Verify FV header
+ //
+ Status = VerifyFv (mFvHeader);
+ if (EFI_ERROR (Status)) {
+ return EFI_ABORTED;
+ }
+ //
+ // Get the erase polarity.
+ //
+ Status = GetErasePolarity (&ErasePolarity);
+ if (EFI_ERROR (Status)) {
+ return EFI_ABORTED;
+ }
+ //
+ // Check if we have free space
+ //
+ if (ErasePolarity) {
+ memset (&BlankHeader, -1, sizeof (EFI_FFS_FILE_HEADER));
+ } else {
+ memset (&BlankHeader, 0, sizeof (EFI_FFS_FILE_HEADER));
+ }
+
+ if (memcmp (&BlankHeader, FfsHeader, sizeof (EFI_FFS_FILE_HEADER)) == 0) {
+ return EFI_NOT_FOUND;
+ }
+ //
+ // Convert the GUID to a string so we can at least report which file
+ // if we find an error.
+ //
+ PrintGuidToBuffer (&FfsHeader->Name, FileGuidString, sizeof (FileGuidString), TRUE);
+ //
+ // Verify file header checksum
+ //
+ SavedState = FfsHeader->State;
+ FfsHeader->State = 0;
+ SavedChecksum = FfsHeader->IntegrityCheck.Checksum.File;
+ FfsHeader->IntegrityCheck.Checksum.File = 0;
+ Checksum = CalculateSum8 ((UINT8 *) FfsHeader, sizeof (EFI_FFS_FILE_HEADER));
+ FfsHeader->State = SavedState;
+ FfsHeader->IntegrityCheck.Checksum.File = SavedChecksum;
+ if (Checksum != 0) {
+ Error (NULL, 0, 0006, "invalid FFS file header checksum", "Ffs file with Guid %s", FileGuidString);
+ return EFI_ABORTED;
+ }
+ //
+ // Verify file checksum
+ //
+ if (FfsHeader->Attributes & FFS_ATTRIB_CHECKSUM) {
+ //
+ // Verify file data checksum
+ //
+ FileLength = GetLength (FfsHeader->Size);
+ Checksum = CalculateSum8 ((UINT8 *) (FfsHeader + 1), FileLength - sizeof (EFI_FFS_FILE_HEADER));
+ Checksum = Checksum + FfsHeader->IntegrityCheck.Checksum.File;
+ if (Checksum != 0) {
+ Error (NULL, 0, 0006, "invalid FFS file checksum", "Ffs file with Guid %s", FileGuidString);
+ return EFI_ABORTED;
+ }
+ } else {
+ //
+ // File does not have a checksum
+ // Verify contents are 0xAA as spec'd
+ //
+ if (FfsHeader->IntegrityCheck.Checksum.File != FFS_FIXED_CHECKSUM) {
+ Error (NULL, 0, 0006, "invalid fixed FFS file header checksum", "Ffs file with Guid %s", FileGuidString);
+ return EFI_ABORTED;
+ }
+ }
+
+ return EFI_SUCCESS;
+}
+
+UINT32
+GetLength (
+ UINT8 *ThreeByteLength
+ )
+/*++
+
+Routine Description:
+
+ Converts a three byte length value into a UINT32.
+
+Arguments:
+
+ ThreeByteLength Pointer to the first of the 3 byte length.
+
+Returns:
+
+ UINT32 Size of the section
+
+--*/
+{
+ UINT32 Length;
+
+ if (ThreeByteLength == NULL) {
+ return 0;
+ }
+
+ Length = *((UINT32 *) ThreeByteLength);
+ Length = Length & 0x00FFFFFF;
+
+ return Length;
+}
+
+EFI_STATUS
+GetErasePolarity (
+ OUT BOOLEAN *ErasePolarity
+ )
+/*++
+
+Routine Description:
+
+ This function returns with the FV erase polarity. If the erase polarity
+ for a bit is 1, the function return TRUE.
+
+Arguments:
+
+ ErasePolarity A pointer to the erase polarity.
+
+Returns:
+
+ EFI_SUCCESS The function completed successfully.
+ EFI_INVALID_PARAMETER One of the input parameters was invalid.
+ EFI_ABORTED Operation aborted.
+
+--*/
+{
+ EFI_STATUS Status;
+
+ //
+ // Verify library has been initialized.
+ //
+ if (mFvHeader == NULL || mFvLength == 0) {
+ return EFI_ABORTED;
+ }
+ //
+ // Verify FV header
+ //
+ Status = VerifyFv (mFvHeader);
+ if (EFI_ERROR (Status)) {
+ return EFI_ABORTED;
+ }
+ //
+ // Verify input parameters.
+ //
+ if (ErasePolarity == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (mFvHeader->Attributes & EFI_FVB2_ERASE_POLARITY) {
+ *ErasePolarity = TRUE;
+ } else {
+ *ErasePolarity = FALSE;
+ }
+
+ return EFI_SUCCESS;
+}
+
+UINT8
+GetFileState (
+ IN BOOLEAN ErasePolarity,
+ IN EFI_FFS_FILE_HEADER *FfsHeader
+ )
+/*++
+
+Routine Description:
+
+ This function returns a the highest state bit in the FFS that is set.
+ It in no way validate the FFS file.
+
+Arguments:
+
+ ErasePolarity The erase polarity for the file state bits.
+ FfsHeader Pointer to a FFS file.
+
+Returns:
+
+ UINT8 The hightest set state of the file.
+
+--*/
+{
+ UINT8 FileState;
+ UINT8 HighestBit;
+
+ FileState = FfsHeader->State;
+
+ if (ErasePolarity) {
+ FileState = (UINT8)~FileState;
+ }
+
+ HighestBit = 0x80;
+ while (HighestBit != 0 && (HighestBit & FileState) == 0) {
+ HighestBit >>= 1;
+ }
+
+ return HighestBit;
+}
diff --git a/BaseTools/Source/C/Common/FvLib.h b/BaseTools/Source/C/Common/FvLib.h
new file mode 100644
index 0000000000..7815baae3f
--- /dev/null
+++ b/BaseTools/Source/C/Common/FvLib.h
@@ -0,0 +1,178 @@
+/** @file
+
+Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.
+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.
+
+Module Name:
+
+ FvLib.h
+
+Abstract:
+
+ These functions assist in parsing and manipulating a Firmware Volume.
+
+**/
+
+#ifndef _EFI_FV_LIB_H
+#define _EFI_FV_LIB_H
+
+//
+// Include files
+//
+#include
+
+#include
+#include
+#include
+
+EFI_STATUS
+InitializeFvLib (
+ IN VOID *Fv,
+ IN UINT32 FvLength
+ )
+;
+
+EFI_STATUS
+GetFvHeader (
+ OUT EFI_FIRMWARE_VOLUME_HEADER **FvHeader,
+ OUT UINT32 *FvLength
+ )
+;
+
+EFI_STATUS
+GetNextFile (
+ IN EFI_FFS_FILE_HEADER *CurrentFile,
+ OUT EFI_FFS_FILE_HEADER **NextFile
+ )
+;
+
+EFI_STATUS
+GetFileByName (
+ IN EFI_GUID *FileName,
+ OUT EFI_FFS_FILE_HEADER **File
+ )
+;
+
+EFI_STATUS
+GetFileByType (
+ IN EFI_FV_FILETYPE FileType,
+ IN UINTN Instance,
+ OUT EFI_FFS_FILE_HEADER **File
+ )
+;
+
+EFI_STATUS
+GetSectionByType (
+ IN EFI_FFS_FILE_HEADER *File,
+ IN EFI_SECTION_TYPE SectionType,
+ IN UINTN Instance,
+ OUT EFI_FILE_SECTION_POINTER *Section
+ )
+;
+//
+// will not parse compressed sections
+//
+EFI_STATUS
+VerifyFv (
+ IN EFI_FIRMWARE_VOLUME_HEADER *FvHeader
+ )
+;
+
+EFI_STATUS
+VerifyFfsFile (
+ IN EFI_FFS_FILE_HEADER *FfsHeader
+ )
+;
+
+/*++
+
+Routine Description:
+
+ Verify the current pointer points to a FFS file header.
+
+Arguments:
+
+ FfsHeader Pointer to an alleged FFS file.
+
+Returns:
+
+ EFI_SUCCESS The Ffs header is valid.
+ EFI_NOT_FOUND This "file" is the beginning of free space.
+ EFI_VOLUME_CORRUPTED The Ffs header is not valid.
+
+--*/
+UINT32
+GetLength (
+ UINT8 *ThreeByteLength
+ )
+;
+
+/*++
+
+Routine Description:
+
+ Converts a three byte length value into a UINT32.
+
+Arguments:
+
+ ThreeByteLength Pointer to the first of the 3 byte length.
+
+Returns:
+
+ UINT32 Size of the section
+
+--*/
+EFI_STATUS
+GetErasePolarity (
+ OUT BOOLEAN *ErasePolarity
+ )
+;
+
+/*++
+
+Routine Description:
+
+ This function returns with the FV erase polarity. If the erase polarity
+ for a bit is 1, the function return TRUE.
+
+Arguments:
+
+ ErasePolarity A pointer to the erase polarity.
+
+Returns:
+
+ EFI_SUCCESS The function completed successfully.
+ EFI_INVALID_PARAMETER One of the input parameters was invalid.
+
+--*/
+UINT8
+GetFileState (
+ IN BOOLEAN ErasePolarity,
+ IN EFI_FFS_FILE_HEADER *FfsHeader
+ )
+;
+
+/*++
+
+Routine Description:
+
+ This function returns a the highest state bit in the FFS that is set.
+ It in no way validate the FFS file.
+
+Arguments:
+
+ ErasePolarity The erase polarity for the file state bits.
+ FfsHeader Pointer to a FFS file.
+
+Returns:
+
+ UINT8 The hightest set state of the file.
+
+--*/
+#endif
diff --git a/BaseTools/Source/C/Common/GNUmakefile b/BaseTools/Source/C/Common/GNUmakefile
new file mode 100644
index 0000000000..1aade7f7b8
--- /dev/null
+++ b/BaseTools/Source/C/Common/GNUmakefile
@@ -0,0 +1,40 @@
+## @file
+# Windows makefile for 'Common' module build.
+#
+# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.
+# 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.
+#
+ARCH ?= IA32
+MAKEROOT ?= ..
+
+# VPATH = ..
+
+LIBNAME = Common
+
+OBJECTS = \
+ BasePeCoff.o \
+ BinderFuncs.o \
+ CommonLib.o \
+ Crc32.o \
+ Decompress.o \
+ EfiCompress.o \
+ EfiUtilityMsgs.o \
+ FirmwareVolumeBuffer.o \
+ FvLib.o \
+ MemoryFile.o \
+ MyAlloc.o \
+ OsPath.o \
+ ParseGuidedSectionTools.o \
+ ParseInf.o \
+ PeCoffLoaderEx.o \
+ SimpleFileParsing.o \
+ StringFuncs.o \
+ TianoCompress.o
+
+include $(MAKEROOT)/Makefiles/lib.makefile
diff --git a/BaseTools/Source/C/Common/Makefile b/BaseTools/Source/C/Common/Makefile
new file mode 100644
index 0000000000..41119b11ab
--- /dev/null
+++ b/BaseTools/Source/C/Common/Makefile
@@ -0,0 +1,42 @@
+## @file
+# Windows makefile for 'Common' module build.
+#
+# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.
+# 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.
+#
+!INCLUDE ..\Makefiles\ms.common
+
+# VPATH = ..
+
+LIBNAME = Common
+
+OBJECTS = \
+ BasePeCoff.obj \
+ BinderFuncs.obj \
+ CommonLib.obj \
+ Crc32.obj \
+ Decompress.obj \
+ EfiCompress.obj \
+ EfiUtilityMsgs.obj \
+ FirmwareVolumeBuffer.obj \
+ FvLib.obj \
+ MemoryFile.obj \
+ MyAlloc.obj \
+ OsPath.obj \
+ ParseGuidedSectionTools.obj \
+ ParseInf.obj \
+ PeCoffLoaderEx.obj \
+ SimpleFileParsing.obj \
+ StringFuncs.obj \
+ TianoCompress.obj
+
+!INCLUDE ..\Makefiles\ms.lib
+
+
+
diff --git a/BaseTools/Source/C/Common/MemoryFile.c b/BaseTools/Source/C/Common/MemoryFile.c
new file mode 100644
index 0000000000..a93a505788
--- /dev/null
+++ b/BaseTools/Source/C/Common/MemoryFile.c
@@ -0,0 +1,260 @@
+/** @file
+
+Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.
+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.
+
+Module Name:
+
+ MemoryFile.c
+
+Abstract:
+
+ This contains some useful functions for accessing files.
+
+**/
+
+#include
+#include
+#include
+#include
+#include "CommonLib.h"
+#include "MemoryFile.h"
+
+
+//
+// Local (static) function prototypes
+//
+STATIC
+VOID
+CheckMemoryFileState (
+ IN EFI_HANDLE InputMemoryFile
+ );
+
+//
+// Function implementations
+//
+
+EFI_STATUS
+GetMemoryFile (
+ IN CHAR8 *InputFileName,
+ OUT EFI_HANDLE *OutputMemoryFile
+ )
+/*++
+
+Routine Description:
+
+ This opens a file, reads it into memory and returns a memory file
+ object.
+
+Arguments:
+
+ InputFile Memory file image.
+ OutputMemoryFile Handle to memory file
+
+Returns:
+
+ EFI_STATUS
+ OutputMemoryFile is valid if !EFI_ERROR
+
+--*/
+{
+ EFI_STATUS Status;
+ CHAR8 *InputFileImage;
+ UINT32 BytesRead;
+ MEMORY_FILE *NewMemoryFile;
+
+ Status = GetFileImage (InputFileName, &InputFileImage, &BytesRead);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ NewMemoryFile = malloc (sizeof (*NewMemoryFile));
+ if (NewMemoryFile == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ NewMemoryFile->FileImage = InputFileImage;
+ NewMemoryFile->CurrentFilePointer = InputFileImage;
+ NewMemoryFile->Eof = InputFileImage + BytesRead;
+
+ *OutputMemoryFile = (EFI_HANDLE)NewMemoryFile;
+
+ CheckMemoryFileState (*OutputMemoryFile);
+
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+FreeMemoryFile (
+ IN EFI_HANDLE InputMemoryFile
+ )
+/*++
+
+Routine Description:
+
+ Frees all memory associated with the input memory file.
+
+Arguments:
+
+ InputMemoryFile Handle to memory file
+
+Returns:
+
+ EFI_STATUS
+
+--*/
+{
+ MEMORY_FILE *MemoryFile;
+
+ CheckMemoryFileState (InputMemoryFile);
+
+ MemoryFile = (MEMORY_FILE*)InputMemoryFile;
+
+ free (MemoryFile->FileImage);
+
+ //
+ // Invalidate state of MEMORY_FILE structure to catch invalid usage.
+ //
+ memset (MemoryFile, 0xcc, sizeof (*MemoryFile));
+ MemoryFile->Eof -= 1;
+
+ free (MemoryFile);
+
+ return EFI_SUCCESS;
+}
+
+
+CHAR8 *
+ReadMemoryFileLine (
+ IN EFI_HANDLE InputMemoryFile
+ )
+/*++
+
+Routine Description:
+
+ This function reads a line from the memory file. The newline characters
+ are stripped and a null terminated string is returned.
+
+ If the string pointer returned is non-NULL, then the caller must free the
+ memory associated with this string.
+
+Arguments:
+
+ InputMemoryFile Handle to memory file
+
+Returns:
+
+ NULL if error or EOF
+ NULL character termincated string otherwise (MUST BE FREED BY CALLER)
+
+--*/
+{
+ CHAR8 *EndOfLine;
+ UINTN CharsToCopy;
+ MEMORY_FILE *InputFile;
+ UINTN BytesToEof;
+ CHAR8 *OutputString;
+
+ //
+ // Verify input parameters are not null
+ //
+ CheckMemoryFileState (InputMemoryFile);
+
+ InputFile = (MEMORY_FILE*)InputMemoryFile;
+
+ //
+ // Check for end of file condition
+ //
+ if (InputFile->CurrentFilePointer >= InputFile->Eof) {
+ return NULL;
+ }
+
+ //
+ // Determine the number of bytes remaining until the EOF
+ //
+ BytesToEof = InputFile->Eof - InputFile->CurrentFilePointer;
+
+ //
+ // Find the next newline char
+ //
+ EndOfLine = memchr (InputFile->CurrentFilePointer, '\n', BytesToEof);
+
+ //
+ // Determine the number of characters to copy.
+ //
+ if (EndOfLine == 0) {
+ //
+ // If no newline found, copy to the end of the file.
+ //
+ CharsToCopy = InputFile->Eof - InputFile->CurrentFilePointer;
+ } else {
+ //
+ // Newline found in the file.
+ //
+ CharsToCopy = EndOfLine - InputFile->CurrentFilePointer;
+ }
+
+ OutputString = malloc (CharsToCopy);
+ if (OutputString == NULL) {
+ return NULL;
+ }
+
+ //
+ // Copy the line.
+ //
+ memcpy (OutputString, InputFile->CurrentFilePointer, CharsToCopy);
+
+ //
+ // Add the null termination over the 0x0D
+ //
+ if (OutputString[CharsToCopy - 1] == '\r') {
+
+ OutputString[CharsToCopy - 1] = '\0';
+
+ } else {
+
+ OutputString[CharsToCopy] = '\0';
+
+ }
+
+ //
+ // Increment the current file pointer (include the 0x0A)
+ //
+ InputFile->CurrentFilePointer += CharsToCopy + 1;
+ CheckMemoryFileState (InputMemoryFile);
+
+ //
+ // Return the string
+ //
+ return OutputString;
+}
+
+
+STATIC
+VOID
+CheckMemoryFileState (
+ IN EFI_HANDLE InputMemoryFile
+ )
+{
+ MEMORY_FILE *MemoryFile;
+
+ assert (InputMemoryFile != NULL);
+
+ MemoryFile = (MEMORY_FILE*)InputMemoryFile;
+
+ assert (MemoryFile->FileImage != NULL);
+ assert (MemoryFile->CurrentFilePointer != NULL);
+ assert (MemoryFile->Eof != NULL);
+ assert (MemoryFile->Eof >= MemoryFile->FileImage);
+ assert (MemoryFile->CurrentFilePointer >= MemoryFile->FileImage);
+ assert (MemoryFile->CurrentFilePointer <= MemoryFile->Eof);
+}
+
+
diff --git a/BaseTools/Source/C/Common/MemoryFile.h b/BaseTools/Source/C/Common/MemoryFile.h
new file mode 100644
index 0000000000..baab40baa2
--- /dev/null
+++ b/BaseTools/Source/C/Common/MemoryFile.h
@@ -0,0 +1,122 @@
+/** @file
+
+Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.
+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.
+
+Module Name:
+
+ MemoryFile.h
+
+Abstract:
+
+ Header file for helper functions useful for accessing files.
+
+**/
+
+#ifndef _EFI_MEMORY_FILE_H
+#define _EFI_MEMORY_FILE_H
+
+#include
+#include
+#include
+
+#ifndef _MAX_PATH
+#define _MAX_PATH 500
+#endif
+
+//
+// Common data structures
+//
+typedef struct {
+ CHAR8 *FileImage;
+ CHAR8 *Eof;
+ CHAR8 *CurrentFilePointer;
+} MEMORY_FILE;
+
+
+//
+// Functions declarations
+//
+
+EFI_STATUS
+GetMemoryFile (
+ IN CHAR8 *InputFileName,
+ OUT EFI_HANDLE *OutputMemoryFile
+ )
+;
+/**
+
+Routine Description:
+
+ This opens a file, reads it into memory and returns a memory file
+ object.
+
+Arguments:
+
+ InputFile Memory file image.
+ OutputMemoryFile Handle to memory file
+
+Returns:
+
+ EFI_STATUS
+ OutputMemoryFile is valid if !EFI_ERROR
+
+**/
+
+
+EFI_STATUS
+FreeMemoryFile (
+ IN EFI_HANDLE InputMemoryFile
+ )
+;
+/**
+
+Routine Description:
+
+ Frees all memory associated with the input memory file.
+
+Arguments:
+
+ InputMemoryFile Handle to memory file
+
+Returns:
+
+ EFI_STATUS
+
+**/
+
+
+CHAR8 *
+ReadMemoryFileLine (
+ IN EFI_HANDLE InputMemoryFile
+ )
+;
+/**
+
+Routine Description:
+
+ This function reads a line from the memory file. The newline characters
+ are stripped and a null terminated string is returned.
+
+ If the string pointer returned is non-NULL, then the caller must free the
+ memory associated with this string.
+
+Arguments:
+
+ InputMemoryFile Handle to memory file
+
+Returns:
+
+ NULL if error or EOF
+ NULL character termincated string otherwise (MUST BE FREED BY CALLER)
+
+**/
+
+
+#endif
diff --git a/BaseTools/Source/C/Common/MyAlloc.c b/BaseTools/Source/C/Common/MyAlloc.c
new file mode 100644
index 0000000000..7b0493aaa0
--- /dev/null
+++ b/BaseTools/Source/C/Common/MyAlloc.c
@@ -0,0 +1,516 @@
+/** @file
+
+Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.
+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.
+
+Module Name:
+
+ MyAlloc.c
+
+Abstract:
+
+ File for memory allocation tracking functions.
+
+**/
+
+#include "MyAlloc.h"
+
+#if USE_MYALLOC
+//
+// Get back to original alloc/free calls.
+//
+#undef malloc
+#undef calloc
+#undef realloc
+#undef free
+//
+// Start of allocation list.
+//
+STATIC MY_ALLOC_STRUCT *MyAllocData = NULL;
+
+//
+//
+//
+STATIC UINT32 MyAllocHeadMagik = MYALLOC_HEAD_MAGIK;
+STATIC UINT32 MyAllocTailMagik = MYALLOC_TAIL_MAGIK;
+
+//
+// ////////////////////////////////////////////////////////////////////////////
+//
+//
+VOID
+MyCheck (
+ BOOLEAN Final,
+ UINT8 File[],
+ UINTN Line
+ )
+// *++
+// Description:
+//
+// Check for corruptions in the allocated memory chain. If a corruption
+// is detection program operation stops w/ an exit(1) call.
+//
+// Parameters:
+//
+// Final := When FALSE, MyCheck() returns if the allocated memory chain
+// has not been corrupted. When TRUE, MyCheck() returns if there
+// are no un-freed allocations. If there are un-freed allocations,
+// they are displayed and exit(1) is called.
+//
+//
+// File := Set to __FILE__ by macro expansion.
+//
+// Line := Set to __LINE__ by macro expansion.
+//
+// Returns:
+//
+// n/a
+//
+// --*/
+//
+{
+ MY_ALLOC_STRUCT *Tmp;
+
+ //
+ // Check parameters.
+ //
+ if (File == NULL || Line == 0) {
+ printf (
+ "\nMyCheck(Final=%u, File=%s, Line=%u)"
+ "Invalid parameter(s).\n",
+ Final,
+ File,
+ (unsigned)Line
+ );
+
+ exit (1);
+ }
+
+ if (strlen ((CHAR8 *)File) == 0) {
+ printf (
+ "\nMyCheck(Final=%u, File=%s, Line=%u)"
+ "Invalid parameter.\n",
+ Final,
+ File,
+ (unsigned)Line
+ );
+
+ exit (1);
+ }
+ //
+ // Check structure contents.
+ //
+ for (Tmp = MyAllocData; Tmp != NULL; Tmp = Tmp->Next) {
+ if (memcmp(Tmp->Buffer, &MyAllocHeadMagik, sizeof MyAllocHeadMagik) ||
+ memcmp(&Tmp->Buffer[Tmp->Size + sizeof(UINT32)], &MyAllocTailMagik, sizeof MyAllocTailMagik)) {
+ break;
+ }
+ }
+ //
+ // If Tmp is not NULL, the structure is corrupt.
+ //
+ if (Tmp != NULL) {
+ printf (
+ "\nMyCheck(Final=%u, File=%s, Line=%u)""\nStructure corrupted!"
+ "\nFile=%s, Line=%u, nSize=%u, Head=%xh, Tail=%xh\n",
+ Final,
+ File,
+ (unsigned)Line,
+ Tmp->File,
+ (unsigned) Tmp->Line,
+ (unsigned) Tmp->Size,
+ (unsigned) *(UINT32 *) (Tmp->Buffer),
+ (unsigned) *(UINT32 *) (&Tmp->Buffer[Tmp->Size + sizeof (UINT32)])
+ );
+
+ exit (1);
+ }
+ //
+ // If Final is TRUE, display the state of the structure chain.
+ //
+ if (Final) {
+ if (MyAllocData != NULL) {
+ printf (
+ "\nMyCheck(Final=%u, File=%s, Line=%u)"
+ "\nSome allocated items have not been freed.\n",
+ Final,
+ File,
+ (unsigned)Line
+ );
+
+ for (Tmp = MyAllocData; Tmp != NULL; Tmp = Tmp->Next) {
+ printf (
+ "File=%s, Line=%u, nSize=%u, Head=%xh, Tail=%xh\n",
+ Tmp->File,
+ (unsigned) Tmp->Line,
+ (unsigned) Tmp->Size,
+ (unsigned) *(UINT32 *) (Tmp->Buffer),
+ (unsigned) *(UINT32 *) (&Tmp->Buffer[Tmp->Size + sizeof (UINT32)])
+ );
+ }
+ }
+ }
+}
+//
+// ////////////////////////////////////////////////////////////////////////////
+//
+//
+VOID *
+MyAlloc (
+ UINTN Size,
+ UINT8 File[],
+ UINTN Line
+ )
+// *++
+// Description:
+//
+// Allocate a new link in the allocation chain along with enough storage
+// for the File[] string, requested Size and alignment overhead. If
+// memory cannot be allocated or the allocation chain has been corrupted,
+// exit(1) will be called.
+//
+// Parameters:
+//
+// Size := Number of bytes (UINT8) requested by the called.
+// Size cannot be zero.
+//
+// File := Set to __FILE__ by macro expansion.
+//
+// Line := Set to __LINE__ by macro expansion.
+//
+// Returns:
+//
+// Pointer to the caller's buffer.
+//
+// --*/
+//
+{
+ MY_ALLOC_STRUCT *Tmp;
+ UINTN Len;
+
+ //
+ // Check for invalid parameters.
+ //
+ if (Size == 0 || File == NULL || Line == 0) {
+ printf (
+ "\nMyAlloc(Size=%u, File=%s, Line=%u)"
+ "\nInvalid parameter(s).\n",
+ (unsigned)Size,
+ File,
+ (unsigned)Line
+ );
+
+ exit (1);
+ }
+
+ Len = strlen ((CHAR8 *)File);
+ if (Len == 0) {
+ printf (
+ "\nMyAlloc(Size=%u, File=%s, Line=%u)"
+ "\nInvalid parameter.\n",
+ (unsigned)Size,
+ File,
+ (unsigned)Line
+ );
+
+ exit (1);
+ }
+ //
+ // Check the allocation list for corruption.
+ //
+ MyCheck (0, (UINT8 *)__FILE__, __LINE__);
+
+ //
+ // Allocate a new entry.
+ //
+ Tmp = calloc (
+ 1,
+ sizeof (MY_ALLOC_STRUCT) + Len + 1 + sizeof (UINT64) + Size + (sizeof MyAllocHeadMagik) + (sizeof MyAllocTailMagik)
+ );
+
+ if (Tmp == NULL) {
+ printf (
+ "\nMyAlloc(Size=%u, File=%s, Line=%u)"
+ "\nOut of memory.\n",
+ (unsigned)Size,
+ File,
+ (unsigned)Line
+ );
+
+ exit (1);
+ }
+ //
+ // Fill in the new entry.
+ //
+ Tmp->File = ((UINT8 *) Tmp) + sizeof (MY_ALLOC_STRUCT);
+ strcpy ((CHAR8 *)Tmp->File, (CHAR8 *)File);
+ Tmp->Line = Line;
+ Tmp->Size = Size;
+ Tmp->Buffer = (UINT8 *) (((UINTN) Tmp + Len + 9) &~7);
+
+ memcpy (Tmp->Buffer, &MyAllocHeadMagik, sizeof MyAllocHeadMagik);
+
+ memcpy (
+ &Tmp->Buffer[Size + sizeof (UINT32)],
+ &MyAllocTailMagik,
+ sizeof MyAllocTailMagik
+ );
+
+ Tmp->Next = MyAllocData;
+ Tmp->Cksum = (UINTN) Tmp + (UINTN) (Tmp->Next) + Tmp->Line + Tmp->Size + (UINTN) (Tmp->File) + (UINTN) (Tmp->Buffer);
+
+ MyAllocData = Tmp;
+
+ return Tmp->Buffer + sizeof (UINT32);
+}
+//
+// ////////////////////////////////////////////////////////////////////////////
+//
+//
+VOID *
+MyRealloc (
+ VOID *Ptr,
+ UINTN Size,
+ UINT8 File[],
+ UINTN Line
+ )
+// *++
+// Description:
+//
+// This does a MyAlloc(), memcpy() and MyFree(). There is no optimization
+// for shrinking or expanding buffers. An invalid parameter will cause
+// MyRealloc() to fail with a call to exit(1).
+//
+// Parameters:
+//
+// Ptr := Pointer to the caller's buffer to be re-allocated.
+//
+// Size := Size of new buffer. Size cannot be zero.
+//
+// File := Set to __FILE__ by macro expansion.
+//
+// Line := Set to __LINE__ by macro expansion.
+//
+// Returns:
+//
+// Pointer to new caller's buffer.
+//
+// --*/
+//
+{
+ MY_ALLOC_STRUCT *Tmp;
+ VOID *Buffer;
+
+ //
+ // Check for invalid parameter(s).
+ //
+ if (Size == 0 || File == NULL || Line == 0) {
+ printf (
+ "\nMyRealloc(Ptr=%p, Size=%u, File=%s, Line=%u)"
+ "\nInvalid parameter(s).\n",
+ Ptr,
+ (unsigned)Size,
+ File,
+ (unsigned)Line
+ );
+
+ exit (1);
+ }
+
+ if (strlen ((CHAR8 *)File) == 0) {
+ printf (
+ "\nMyRealloc(Ptr=%p, Size=%u, File=%s, Line=%u)"
+ "\nInvalid parameter.\n",
+ Ptr,
+ (unsigned)Size,
+ File,
+ (unsigned)Line
+ );
+
+ exit (1);
+ }
+ //
+ // Find existing buffer in allocation list.
+ //
+ if (Ptr == NULL) {
+ Tmp = NULL;
+ } else if (&MyAllocData->Buffer[sizeof (UINT32)] == Ptr) {
+ Tmp = MyAllocData;
+ } else {
+ for (Tmp = MyAllocData;; Tmp = Tmp->Next) {
+ if (Tmp->Next == NULL) {
+ printf (
+ "\nMyRealloc(Ptr=%p, Size=%u, File=%s, Line=%u)"
+ "\nCould not find buffer.\n",
+ Ptr,
+ (unsigned)Size,
+ File,
+ (unsigned)Line
+ );
+
+ exit (1);
+ }
+
+ Tmp = Tmp->Next;
+ }
+ }
+ //
+ // Allocate new buffer, copy old data, free old buffer.
+ //
+ Buffer = MyAlloc (Size, File, Line);
+
+ if (Buffer != NULL && Tmp != NULL) {
+ memcpy (
+ Buffer,
+ &Tmp->Buffer[sizeof (UINT32)],
+ ((Size <= Tmp->Size) ? Size : Tmp->Size)
+ );
+
+ MyFree (Ptr, (UINT8 *)__FILE__, __LINE__);
+ }
+
+ return Buffer;
+}
+//
+// ////////////////////////////////////////////////////////////////////////////
+//
+//
+VOID
+MyFree (
+ VOID *Ptr,
+ UINT8 File[],
+ UINTN Line
+ )
+// *++
+// Description:
+//
+// Release a previously allocated buffer. Invalid parameters will cause
+// MyFree() to fail with an exit(1) call.
+//
+// Parameters:
+//
+// Ptr := Pointer to the caller's buffer to be freed.
+// A NULL pointer will be ignored.
+//
+// File := Set to __FILE__ by macro expansion.
+//
+// Line := Set to __LINE__ by macro expansion.
+//
+// Returns:
+//
+// n/a
+//
+// --*/
+//
+{
+ MY_ALLOC_STRUCT *Tmp;
+ MY_ALLOC_STRUCT *Tmp2;
+
+ //
+ // Check for invalid parameter(s).
+ //
+ if (File == NULL || Line == 0) {
+ printf (
+ "\nMyFree(Ptr=%p, File=%s, Line=%u)"
+ "\nInvalid parameter(s).\n",
+ Ptr,
+ File,
+ (unsigned)Line
+ );
+
+ exit (1);
+ }
+
+ if (strlen ((CHAR8 *)File) == 0) {
+ printf (
+ "\nMyFree(Ptr=%p, File=%s, Line=%u)"
+ "\nInvalid parameter.\n",
+ Ptr,
+ File,
+ (unsigned)Line
+ );
+
+ exit (1);
+ }
+ //
+ // Freeing NULL is always valid.
+ //
+ if (Ptr == NULL) {
+ return ;
+ }
+ //
+ // Fail if nothing is allocated.
+ //
+ if (MyAllocData == NULL) {
+ printf (
+ "\nMyFree(Ptr=%p, File=%s, Line=%u)"
+ "\nCalled before memory allocated.\n",
+ Ptr,
+ File,
+ (unsigned)Line
+ );
+
+ exit (1);
+ }
+ //
+ // Check for corrupted allocation list.
+ //
+ MyCheck (0, (UINT8 *)__FILE__, __LINE__);
+
+ //
+ // Need special check for first item in list.
+ //
+ if (&MyAllocData->Buffer[sizeof (UINT32)] == Ptr) {
+ //
+ // Unlink first item in list.
+ //
+ Tmp = MyAllocData;
+ MyAllocData = MyAllocData->Next;
+ } else {
+ //
+ // Walk list looking for matching item.
+ //
+ for (Tmp = MyAllocData;; Tmp = Tmp->Next) {
+ //
+ // Fail if end of list is reached.
+ //
+ if (Tmp->Next == NULL) {
+ printf (
+ "\nMyFree(Ptr=%p, File=%s, Line=%u)\n"
+ "\nNot found.\n",
+ Ptr,
+ File,
+ (unsigned)Line
+ );
+
+ exit (1);
+ }
+ //
+ // Leave loop when match is found.
+ //
+ if (&Tmp->Next->Buffer[sizeof (UINT32)] == Ptr) {
+ break;
+ }
+ }
+ //
+ // Unlink item from list.
+ //
+ Tmp2 = Tmp->Next;
+ Tmp->Next = Tmp->Next->Next;
+ Tmp = Tmp2;
+ }
+ //
+ // Release item.
+ //
+ free (Tmp);
+}
+
+#endif /* USE_MYALLOC */
+
+/* eof - MyAlloc.c */
diff --git a/BaseTools/Source/C/Common/MyAlloc.h b/BaseTools/Source/C/Common/MyAlloc.h
new file mode 100644
index 0000000000..217beb1484
--- /dev/null
+++ b/BaseTools/Source/C/Common/MyAlloc.h
@@ -0,0 +1,222 @@
+/** @file
+
+Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.
+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.
+
+Module Name:
+
+ MyAlloc.h
+
+Abstract:
+
+ Header file for memory allocation tracking functions.
+
+**/
+
+#ifndef _MYALLOC_H_
+#define _MYALLOC_H_
+
+#include
+#include
+#include
+
+#include
+
+//
+// Default operation is to use the memory allocation tracking functions.
+// To over-ride add "#define USE_MYALLOC 0" to your program header and/or
+// source files as needed. Or, just do not include this header file in
+// your project.
+//
+#ifndef USE_MYALLOC
+#define USE_MYALLOC 1
+#endif
+
+#if USE_MYALLOC
+//
+// Replace C library allocation routines with MyAlloc routines.
+//
+#define malloc(size) MyAlloc ((size), __FILE__, __LINE__)
+#define calloc(count, size) MyAlloc ((count) * (size), __FILE__, __LINE__)
+#define realloc(ptr, size) MyRealloc ((ptr), (size), __FILE__, __LINE__)
+#define free(ptr) MyFree ((ptr), __FILE__, __LINE__)
+#define alloc_check(final) MyCheck ((final), __FILE__, __LINE__)
+
+//
+// Structure for checking/tracking memory allocations.
+//
+typedef struct MyAllocStruct {
+ UINTN Cksum;
+ struct MyAllocStruct *Next;
+ UINTN Line;
+ UINTN Size;
+ UINT8 *File;
+ UINT8 *Buffer;
+} MY_ALLOC_STRUCT;
+//
+// Cksum := (UINTN)This + (UINTN)Next + Line + Size + (UINTN)File +
+// (UINTN)Buffer;
+//
+// Next := Pointer to next allocation structure in the list.
+//
+// Line := __LINE__
+//
+// Size := Size of allocation request.
+//
+// File := Pointer to __FILE__ string stored immediately following
+// MY_ALLOC_STRUCT in memory.
+//
+// Buffer := Pointer to UINT32 aligned storage immediately following
+// the NULL terminated __FILE__ string. This is UINT32
+// aligned because the underflow signature is 32-bits and
+// this will place the first caller address on a 64-bit
+// boundary.
+//
+//
+// Signatures used to check for buffer overflow/underflow conditions.
+//
+#define MYALLOC_HEAD_MAGIK 0xBADFACED
+#define MYALLOC_TAIL_MAGIK 0xDEADBEEF
+
+VOID
+MyCheck (
+ BOOLEAN Final,
+ UINT8 File[],
+ UINTN Line
+ )
+;
+//
+// *++
+// Description:
+//
+// Check for corruptions in the allocated memory chain. If a corruption
+// is detection program operation stops w/ an exit(1) call.
+//
+// Parameters:
+//
+// Final := When FALSE, MyCheck() returns if the allocated memory chain
+// has not been corrupted. When TRUE, MyCheck() returns if there
+// are no un-freed allocations. If there are un-freed allocations,
+// they are displayed and exit(1) is called.
+//
+//
+// File := Set to __FILE__ by macro expansion.
+//
+// Line := Set to __LINE__ by macro expansion.
+//
+// Returns:
+//
+// n/a
+//
+// --*/
+//
+VOID *
+MyAlloc (
+ UINTN Size,
+ UINT8 File[],
+ UINTN Line
+ )
+;
+//
+// *++
+// Description:
+//
+// Allocate a new link in the allocation chain along with enough storage
+// for the File[] string, requested Size and alignment overhead. If
+// memory cannot be allocated or the allocation chain has been corrupted,
+// exit(1) will be called.
+//
+// Parameters:
+//
+// Size := Number of bytes (UINT8) requested by the called.
+// Size cannot be zero.
+//
+// File := Set to __FILE__ by macro expansion.
+//
+// Line := Set to __LINE__ by macro expansion.
+//
+// Returns:
+//
+// Pointer to the caller's buffer.
+//
+// --*/
+//
+VOID *
+MyRealloc (
+ VOID *Ptr,
+ UINTN Size,
+ UINT8 File[],
+ UINTN Line
+ )
+;
+//
+// *++
+// Description:
+//
+// This does a MyAlloc(), memcpy() and MyFree(). There is no optimization
+// for shrinking or expanding buffers. An invalid parameter will cause
+// MyRealloc() to fail with a call to exit(1).
+//
+// Parameters:
+//
+// Ptr := Pointer to the caller's buffer to be re-allocated.
+// Ptr cannot be NULL.
+//
+// Size := Size of new buffer. Size cannot be zero.
+//
+// File := Set to __FILE__ by macro expansion.
+//
+// Line := Set to __LINE__ by macro expansion.
+//
+// Returns:
+//
+// Pointer to new caller's buffer.
+//
+// --*/
+//
+VOID
+MyFree (
+ VOID *Ptr,
+ UINT8 File[],
+ UINTN Line
+ )
+;
+//
+// *++
+// Description:
+//
+// Release a previously allocated buffer. Invalid parameters will cause
+// MyFree() to fail with an exit(1) call.
+//
+// Parameters:
+//
+// Ptr := Pointer to the caller's buffer to be freed.
+// A NULL pointer will be ignored.
+//
+// File := Set to __FILE__ by macro expansion.
+//
+// Line := Set to __LINE__ by macro expansion.
+//
+// Returns:
+//
+// n/a
+//
+// --*/
+//
+#else /* USE_MYALLOC */
+
+//
+// Nothing to do when USE_MYALLOC is zero.
+//
+#define alloc_check(final)
+
+#endif /* USE_MYALLOC */
+#endif /* _MYALLOC_H_ */
+
+/* eof - MyAlloc.h */
diff --git a/BaseTools/Source/C/Common/OsPath.c b/BaseTools/Source/C/Common/OsPath.c
new file mode 100644
index 0000000000..419c8f8b8c
--- /dev/null
+++ b/BaseTools/Source/C/Common/OsPath.c
@@ -0,0 +1,307 @@
+/** @file
+
+Copyright (c) 2007 - 2008, Intel Corporation. All rights reserved.
+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.
+
+Module Name:
+
+ StringFuncs.c
+
+Abstract:
+
+ Functions useful to operate file directories by parsing file path.
+
+**/
+
+#include
+#include
+#include
+#include "OsPath.h"
+
+//
+// Functions implementations
+//
+
+#if 0
+ //
+ // BUGBUG: Not fully implemented yet.
+ //
+CHAR8*
+OsPathDirName (
+ IN CHAR8 *FilePath
+ )
+/*++
+
+Routine Description:
+
+ This function returns the directory path which contains the particular path.
+ Some examples:
+ "a/b/c" -> "a/b"
+ "a/b/c/" -> "a/b"
+ "a" -> "."
+ "." -> ".."
+ "/" -> NULL
+
+ This function does not check for the existence of the file.
+
+ The caller must free the string returned.
+
+Arguments:
+
+ FilePath Path name of file to get the parent directory for.
+
+Returns:
+
+ NULL if error
+
+--*/
+{
+ CHAR8 *Return;
+ CHAR8 *Pos;
+ CHAR8 Char;
+ UINTN Length;
+ INTN Offset;
+
+ Length = strlen (FilePath);
+
+ if (Length == 0) {
+ return NULL;
+ }
+
+ //
+ // Check for the root directory case
+ //
+ if (
+ (Length == 3 && isalpha (FilePath[0]) && (strcmp(FilePath + 1, ":\\") == 0)) ||
+ (strcmp(FilePath, "/") == 0)
+ ) {
+ return NULL;
+ }
+
+ //
+ // If the path ends with a path separator, then just append ".."
+ //
+ Char = FilePath[Length - 1];
+ if (Char == '/' || Char == '\\') {
+ return OsPathJoin (FilePath, "..");
+ }
+
+ //
+ //
+ //
+ for (Offset = Length; Offset > 0; Offset--) {
+ if ((Return[Offset] == '/') || (Return[Offset] == '\\')) {
+ Return[Offset] = '\0';
+ return Return;
+ }
+ }
+}
+#endif
+
+
+#if 0
+ //
+ // BUGBUG: Not fully implemented yet.
+ //
+VOID
+OsPathNormPathInPlace (
+ IN CHAR8 *Path
+ )
+/*++
+
+Routine Description:
+
+ This function returns the directory path which contains the particular path.
+ Some examples:
+ "a/b/../c" -> "a/c"
+ "a/b//c" -> "a/b/c"
+ "a/./b" -> "a/b"
+
+ This function does not check for the existence of the file.
+
+Arguments:
+
+ Path Path name of file to normalize
+
+Returns:
+
+ The string is altered in place.
+
+--*/
+{
+ CHAR8 *Pos;
+ INTN Offset;
+ BOOLEAN TryAgain;
+ UINTN Length;
+ UINTN Remaining;
+ UINTN SubLength;
+
+ do {
+ TryAgain = FALSE;
+ Length = strlen (Path);
+
+ for (Offset = 0; Offset < Length; Offset++) {
+ Remaining = Length - Offset;
+
+ //
+ // Collapse '//' -> '/'
+ //
+ if (
+ (Remaining >= 2) &&
+ ((Offset > 0) || (Path[0] != '\\')) &&
+ IsDirSep (Path[Offset]) && IsDirSep (Path[Offset + 1])
+ ) {
+ memmove (&Path[Offset], &Path[Offset + 1], Remaining);
+ TryAgain = TRUE;
+ break;
+ }
+
+ //
+ // Collapse '/./' -> '/'
+ //
+ if ((Remaining >= 3) && IsDirSep (Path[Offset]) &&
+ (Path[Offset + 1] == '.') && IsDirSep (Path[Offset + 2])
+ ) {
+ memmove (&Path[Offset], &Path[Offset + 1], Remaining);
+ TryAgain = TRUE;
+ break;
+ }
+
+ //
+ // Collapse 'a/../b' -> 'b'
+ //
+ // BUGBUG: Not implemented yet
+
+ }
+
+ } while (TryAgain);
+
+ Return = CloneString (FilePath);
+ if (Return == NULL) {
+ return NULL;
+ }
+
+ Length = strlen (Return);
+
+ //
+ // Check for the root directory case
+ //
+ if (
+ (Length == 3 && isalpha (Return[0]) && (strcmp(Return + 1, ":\\") == 0)) ||
+ (strcmp(Return, "/") == 0)
+ ) {
+ free (Return);
+ return NULL;
+ }
+
+ //
+ //
+ //
+ for (Offset = Length; Offset > 0; Offset--) {
+ if ((Return[Offset] == '/') || (Return[Offset] == '\\')) {
+ Return[Offset] = '\0';
+ return Return;
+ }
+ }
+}
+#endif
+
+
+CHAR8*
+OsPathPeerFilePath (
+ IN CHAR8 *OldPath,
+ IN CHAR8 *Peer
+ )
+/*++
+
+Routine Description:
+
+ This function replaces the final portion of a path with an alternative
+ 'peer' filename. For example:
+ "a/b/../c", "peer" -> "a/b/../peer"
+ "a/b/", "peer" -> "a/b/peer"
+ "/a", "peer" -> "/peer"
+ "a", "peer" -> "peer"
+
+ This function does not check for the existence of the file.
+
+Arguments:
+
+ OldPath Path name of replace the final segment
+ Peer The new path name to concatinate to become the peer path
+
+Returns:
+
+ A CHAR8* string, which must be freed by the caller
+
+--*/
+{
+ CHAR8 *Result;
+ INTN Offset;
+
+ Result = (CHAR8 *) malloc (strlen (OldPath) + strlen (Peer) + 1);
+ if (Result == NULL) {
+ return NULL;
+ }
+
+ strcpy (Result, OldPath);
+
+ //
+ // Search for the last '/' or '\' in the string. If found, replace
+ // everything following it with Peer
+ //
+ for (Offset = strlen (Result); Offset >= 0; Offset--) {
+ if ((Result[Offset] == '/') || (Result[Offset] == '\\')) {
+ Result[Offset + 1] = '\0';
+ strcat (Result, Peer);
+ return Result;
+ }
+ }
+
+ //
+ // Neither a '/' nor a '\' was found. Therefore, we simply return Peer.
+ //
+ strcpy (Result, Peer);
+ return Result;
+}
+
+
+BOOLEAN
+OsPathExists (
+ IN CHAR8 *InputFileName
+ )
+/*++
+
+Routine Description:
+
+ Checks if a file exists
+
+Arguments:
+
+ InputFileName The name of the file to check for existence
+
+Returns:
+
+ TRUE The file exists
+ FALSE The file does not exist
+
+--*/
+{
+ FILE *InputFile;
+ InputFile = fopen (InputFileName, "rb");
+ if (InputFile == NULL) {
+ return FALSE;
+ } else {
+ fclose (InputFile);
+ return TRUE;
+ }
+}
+
+
+
diff --git a/BaseTools/Source/C/Common/OsPath.h b/BaseTools/Source/C/Common/OsPath.h
new file mode 100644
index 0000000000..9e7df070c5
--- /dev/null
+++ b/BaseTools/Source/C/Common/OsPath.h
@@ -0,0 +1,146 @@
+/** @file
+
+Copyright (c) 2007 - 2008, Intel Corporation. All rights reserved.
+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.
+
+Module Name:
+
+ OsPath.h
+
+Abstract:
+
+ Header file for helper functions useful to operate file directories
+ by parsing file path.
+
+**/
+
+#ifndef _EFI_OS_PATH_H
+#define _EFI_OS_PATH_H
+
+#include
+
+//
+// Functions declarations
+//
+
+CHAR8*
+OsPathDirName (
+ IN CHAR8 *FilePath
+ )
+;
+/**
+
+Routine Description:
+
+ This function returns the directory path which contains the particular path.
+ Some examples:
+ "a/b/c" -> "a/b"
+ "a/b/c/" -> "a/b"
+ "a" -> "."
+ "." -> ".."
+ "/" -> NULL
+
+ This function does not check for the existence of the file.
+
+ The caller must free the string returned.
+
+Arguments:
+
+ FilePath Path name of file to get the parent directory for.
+
+Returns:
+
+ NULL if error
+
+**/
+
+
+VOID
+OsPathNormPathInPlace (
+ IN CHAR8 *Path
+ )
+;
+/**
+
+Routine Description:
+
+ This function returns the directory path which contains the particular path.
+ Some examples:
+ "a/b/../c" -> "a/c"
+ "a/b//c" -> "a/b/c"
+ "a/./b" -> "a/b"
+
+ This function does not check for the existence of the file.
+
+Arguments:
+
+ Path Path name of file to normalize
+
+Returns:
+
+ The string is altered in place.
+
+**/
+
+
+CHAR8*
+OsPathPeerFilePath (
+ IN CHAR8 *OldPath,
+ IN CHAR8 *Peer
+ )
+;
+/**
+
+Routine Description:
+
+ This function replaces the final portion of a path with an alternative
+ 'peer' filename. For example:
+ "a/b/../c", "peer" -> "a/b/../peer"
+ "a/b/", "peer" -> "a/b/peer"
+ "/a", "peer" -> "/peer"
+ "a", "peer" -> "peer"
+
+ This function does not check for the existence of the file.
+
+Arguments:
+
+ OldPath Path name of replace the final segment
+ Peer The new path name to concatinate to become the peer path
+
+Returns:
+
+ A CHAR8* string, which must be freed by the caller
+
+**/
+
+
+BOOLEAN
+OsPathExists (
+ IN CHAR8 *InputFileName
+ )
+;
+/**
+
+Routine Description:
+
+ Checks if a file exists
+
+Arguments:
+
+ InputFileName The name of the file to check for existence
+
+Returns:
+
+ TRUE The file exists
+ FALSE The file does not exist
+
+**/
+
+
+#endif
diff --git a/BaseTools/Source/C/Common/ParseGuidedSectionTools.c b/BaseTools/Source/C/Common/ParseGuidedSectionTools.c
new file mode 100644
index 0000000000..8ddfd00b7e
--- /dev/null
+++ b/BaseTools/Source/C/Common/ParseGuidedSectionTools.c
@@ -0,0 +1,211 @@
+/** @file
+
+Copyright (c) 2007 - 2008, Intel Corporation. All rights reserved.
+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.
+
+Module Name:
+
+ ParseGuidedSectionTools.c
+
+Abstract:
+
+ Helper functions for parsing GuidedSectionTools.txt
+
+**/
+
+#include
+#include
+#include
+#include
+#include "MemoryFile.h"
+#include "CommonLib.h"
+#include "EfiUtilityMsgs.h"
+#include "ParseInf.h"
+#include "ParseGuidedSectionTools.h"
+#include "StringFuncs.h"
+
+
+//
+// Local types / structures
+//
+
+typedef struct _GUID_SEC_TOOL_ENTRY {
+ EFI_GUID Guid;
+ CHAR8* Name;
+ CHAR8* Path;
+ struct _GUID_SEC_TOOL_ENTRY *Next;
+} GUID_SEC_TOOL_ENTRY;
+
+//
+// Functin Implementation
+//
+
+EFI_HANDLE
+ParseGuidedSectionToolsFile (
+ IN CHAR8 *InputFile
+ )
+/*++
+
+Routine Description:
+
+ This function parses the tools_def.txt file. It returns a
+ EFI_HANDLE object which can be used for the other library
+ functions and should be passed to FreeParsedGuidedSectionToolsHandle
+ to free resources when the tools_def.txt information is no
+ longer needed.
+
+Arguments:
+
+ InputFile Path name of file to read
+
+Returns:
+
+ NULL if error parsing
+ A non-NULL EFI_HANDLE otherwise
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_HANDLE MemoryFile;
+ EFI_HANDLE ParsedGuidedSectionTools;
+
+ Status = GetMemoryFile (InputFile, &MemoryFile);
+ if (EFI_ERROR (Status)) {
+ return NULL;
+ }
+
+ ParsedGuidedSectionTools = ParseGuidedSectionToolsMemoryFile (MemoryFile);
+
+ FreeMemoryFile (MemoryFile);
+
+ return ParsedGuidedSectionTools;
+}
+
+
+EFI_HANDLE
+ParseGuidedSectionToolsMemoryFile (
+ IN EFI_HANDLE InputFile
+ )
+/*++
+
+Routine Description:
+
+ This function parses the tools_def.txt file. It returns a
+ EFI_HANDLE object which can be used for the other library
+ functions and should be passed to FreeParsedGuidedSectionToolsHandle
+ to free resources when the tools_def.txt information is no
+ longer needed.
+
+Arguments:
+
+ InputFile Memory file image.
+
+Returns:
+
+ NULL if error or EOF
+ InputBuffer otherwise
+
+--*/
+{
+ EFI_STATUS Status;
+ CHAR8 *NextLine;
+ STRING_LIST *Tool;
+ EFI_GUID Guid;
+ GUID_SEC_TOOL_ENTRY *FirstGuidTool;
+ GUID_SEC_TOOL_ENTRY *LastGuidTool;
+ GUID_SEC_TOOL_ENTRY *NewGuidTool;
+
+ FirstGuidTool = NULL;
+ LastGuidTool = NULL;
+
+ while (TRUE) {
+ NextLine = ReadMemoryFileLine (InputFile);
+ if (NextLine == NULL) {
+ break;
+ }
+
+ Status = StripInfDscStringInPlace (NextLine);
+ if (EFI_ERROR (Status)) {
+ break;
+ }
+
+ if (NextLine[0] == '\0') {
+ continue;
+ }
+
+ Tool = SplitStringByWhitespace (NextLine);
+ if ((Tool != NULL) &&
+ (Tool->Count == 3)
+ ) {
+ Status = StringToGuid (Tool->Strings[0], &Guid);
+ if (!EFI_ERROR (Status)) {
+ NewGuidTool = malloc (sizeof (GUID_SEC_TOOL_ENTRY));
+ if (NewGuidTool != NULL) {
+ memcpy (&(NewGuidTool->Guid), &Guid, sizeof (Guid));
+ NewGuidTool->Name = CloneString(Tool->Strings[1]);
+ NewGuidTool->Path = CloneString(Tool->Strings[2]);
+ NewGuidTool->Next = NULL;
+ }
+ if (FirstGuidTool == NULL) {
+ FirstGuidTool = NewGuidTool;
+ } else {
+ LastGuidTool->Next = NewGuidTool;
+ }
+ LastGuidTool = NewGuidTool;
+ }
+ FreeStringList (Tool);
+ }
+ }
+
+ return FirstGuidTool;
+}
+
+
+CHAR8*
+LookupGuidedSectionToolPath (
+ IN EFI_HANDLE ParsedGuidedSectionToolsHandle,
+ IN EFI_GUID *SectionGuid
+ )
+/*++
+
+Routine Description:
+
+ This function looks up the appropriate tool to use for extracting
+ a GUID defined FV section.
+
+Arguments:
+
+ ParsedGuidedSectionToolsHandle A parsed GUID section tools handle.
+ SectionGuid The GUID for the section.
+
+Returns:
+
+ NULL - if no tool is found or there is another error
+ Non-NULL - The tool to use to access the section contents. (The caller
+ must free the memory associated with this string.)
+
+--*/
+{
+ GUID_SEC_TOOL_ENTRY *GuidTool;
+
+ GuidTool = (GUID_SEC_TOOL_ENTRY*)ParsedGuidedSectionToolsHandle;
+ if (GuidTool == NULL) {
+ return NULL;
+ }
+
+ for ( ; GuidTool != NULL; GuidTool = GuidTool->Next) {
+ if (CompareGuid (&(GuidTool->Guid), SectionGuid) == 0) {
+ return CloneString (GuidTool->Path);
+ }
+ }
+
+ return NULL;
+}
+
+
diff --git a/BaseTools/Source/C/Common/ParseGuidedSectionTools.h b/BaseTools/Source/C/Common/ParseGuidedSectionTools.h
new file mode 100644
index 0000000000..b4c55974e3
--- /dev/null
+++ b/BaseTools/Source/C/Common/ParseGuidedSectionTools.h
@@ -0,0 +1,133 @@
+/** @file
+
+Copyright (c) 2007 - 2008, Intel Corporation. All rights reserved.
+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.
+
+Module Name:
+
+ ParseGuidedSectionTools.h
+
+Abstract:
+
+ Header file for helper functions for parsing GuidedSectionTools.txt
+
+**/
+
+#ifndef _EFI_PARSE_GUIDED_SECTION_TOOLS_H
+#define _EFI_PARSE_GUIDED_SECTION_TOOLS_H
+
+#include
+
+//
+// Functions declarations
+//
+
+EFI_HANDLE
+ParseGuidedSectionToolsFile (
+ IN CHAR8 *InputFile
+ )
+;
+/**
+
+Routine Description:
+
+ This function parses the tools_def.txt file. It returns a
+ EFI_HANDLE object which can be used for the other library
+ functions and should be passed to FreeParsedToolsDefHandle
+ to free resources when the tools_def.txt information is no
+ longer needed.
+
+Arguments:
+
+ InputFile Path name of file to read
+
+Returns:
+
+ NULL if error parsing
+ A non-NULL EFI_HANDLE otherwise
+
+**/
+
+
+EFI_HANDLE
+ParseGuidedSectionToolsMemoryFile (
+ IN EFI_HANDLE InputFile
+ )
+;
+/**
+
+Routine Description:
+
+ This function parses the tools_def.txt file. It returns a
+ EFI_HANDLE object which can be used for the other library
+ functions and should be passed to FreeParsedToolsDefHandle
+ to free resources when the tools_def.txt information is no
+ longer needed.
+
+Arguments:
+
+ InputFile Memory file image.
+
+Returns:
+
+ NULL if error parsing
+ A non-NULL EFI_HANDLE otherwise
+
+**/
+
+CHAR8*
+LookupGuidedSectionToolPath (
+ IN EFI_HANDLE ParsedGuidedSectionToolsHandle,
+ IN EFI_GUID *SectionGuid
+ )
+;
+/**
+
+Routine Description:
+
+ This function looks up the appropriate tool to use for extracting
+ a GUID defined FV section.
+
+Arguments:
+
+ ParsedGuidedSectionToolsHandle A parsed GUID section tools handle.
+ SectionGuid The GUID for the section.
+
+Returns:
+
+ NULL - if no tool is found or there is another error
+ Non-NULL - The tool to use to access the section contents. (The caller
+ must free the memory associated with this string.)
+
+**/
+
+EFI_STATUS
+FreeParsedGuidedSectionToolsHandle (
+ IN EFI_HANDLE ParsedGuidedSectionToolsHandle
+ )
+;
+/**
+
+Routine Description:
+
+ Frees resources that were allocated by ParseGuidedSectionToolsFile.
+ After freeing these resources, the information that was parsed
+ is no longer accessible.
+
+Arguments:
+
+ ParsedToolDefHandle Handle returned from ParseGuidedSectionToolsFile
+
+Returns:
+
+ EFI_STATUS
+
+**/
+
+#endif
diff --git a/BaseTools/Source/C/Common/ParseInf.c b/BaseTools/Source/C/Common/ParseInf.c
new file mode 100644
index 0000000000..bbccb61732
--- /dev/null
+++ b/BaseTools/Source/C/Common/ParseInf.c
@@ -0,0 +1,689 @@
+/** @file
+
+Copyright (c) 2004 - 2010, Intel Corporation. All rights reserved.
+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.
+
+Module Name:
+
+ ParseInf.c
+
+Abstract:
+
+ This contains some useful functions for parsing INF files.
+
+--*/
+
+#include
+#include
+#include
+#include
+#include "EfiUtilityMsgs.h"
+#include "ParseInf.h"
+
+CHAR8 *
+ReadLine (
+ IN MEMORY_FILE *InputFile,
+ IN OUT CHAR8 *InputBuffer,
+ IN UINTN MaxLength
+ )
+/*++
+
+Routine Description:
+
+ This function reads a line, stripping any comments.
+ The function reads a string from the input stream argument and stores it in
+ the input string. ReadLine reads characters from the current file position
+ to and including the first newline character, to the end of the stream, or
+ until the number of characters read is equal to MaxLength - 1, whichever
+ comes first. The newline character, if read, is replaced with a \0.
+
+Arguments:
+
+ InputFile Memory file image.
+ InputBuffer Buffer to read into, must be _MAX_PATH size.
+ MaxLength The maximum size of the input buffer.
+
+Returns:
+
+ NULL if error or EOF
+ InputBuffer otherwise
+
+--*/
+{
+ CHAR8 *CharPtr;
+ CHAR8 *EndOfLine;
+ UINTN CharsToCopy;
+
+ //
+ // Verify input parameters are not null
+ //
+ assert (InputBuffer);
+ assert (InputFile->FileImage);
+ assert (InputFile->Eof);
+ assert (InputFile->CurrentFilePointer);
+
+ //
+ // Check for end of file condition
+ //
+ if (InputFile->CurrentFilePointer >= InputFile->Eof) {
+ return NULL;
+ }
+ //
+ // Find the next newline char
+ //
+ EndOfLine = strchr (InputFile->CurrentFilePointer, '\n');
+
+ //
+ // Determine the number of characters to copy.
+ //
+ if (EndOfLine == 0) {
+ //
+ // If no newline found, copy to the end of the file.
+ //
+ CharsToCopy = InputFile->Eof - InputFile->CurrentFilePointer;
+ } else if (EndOfLine >= InputFile->Eof) {
+ //
+ // If the newline found was beyond the end of file, copy to the eof.
+ //
+ CharsToCopy = InputFile->Eof - InputFile->CurrentFilePointer;
+ } else {
+ //
+ // Newline found in the file.
+ //
+ CharsToCopy = EndOfLine - InputFile->CurrentFilePointer;
+ }
+ //
+ // If the end of line is too big for the current buffer, set it to the max
+ // size of the buffer (leaving room for the \0.
+ //
+ if (CharsToCopy > MaxLength - 1) {
+ CharsToCopy = MaxLength - 1;
+ }
+ //
+ // Copy the line.
+ //
+ memcpy (InputBuffer, InputFile->CurrentFilePointer, CharsToCopy);
+
+ //
+ // Add the null termination over the 0x0D
+ //
+ if (InputBuffer[CharsToCopy - 1] == '\r') {
+
+ InputBuffer[CharsToCopy - 1] = '\0';
+
+ } else {
+
+ InputBuffer[CharsToCopy] = '\0';
+
+ }
+
+ //
+ // Increment the current file pointer (include the 0x0A)
+ //
+ InputFile->CurrentFilePointer += CharsToCopy + 1;
+
+ //
+ // Strip any comments
+ //
+ CharPtr = strstr (InputBuffer, "//");
+ if (CharPtr != 0) {
+ CharPtr[0] = 0;
+ }
+ //
+ // Return the string
+ //
+ return InputBuffer;
+}
+
+BOOLEAN
+FindSection (
+ IN MEMORY_FILE *InputFile,
+ IN CHAR8 *Section
+ )
+/*++
+
+Routine Description:
+
+ This function parses a file from the beginning to find a section.
+ The section string may be anywhere within a line.
+
+Arguments:
+
+ InputFile Memory file image.
+ Section Section to search for
+
+Returns:
+
+ FALSE if error or EOF
+ TRUE if section found
+
+--*/
+{
+ CHAR8 InputBuffer[_MAX_PATH];
+ CHAR8 *CurrentToken;
+
+ //
+ // Verify input is not NULL
+ //
+ assert (InputFile->FileImage);
+ assert (InputFile->Eof);
+ assert (InputFile->CurrentFilePointer);
+ assert (Section);
+
+ //
+ // Rewind to beginning of file
+ //
+ InputFile->CurrentFilePointer = InputFile->FileImage;
+
+ //
+ // Read lines until the section is found
+ //
+ while (InputFile->CurrentFilePointer < InputFile->Eof) {
+ //
+ // Read a line
+ //
+ ReadLine (InputFile, InputBuffer, _MAX_PATH);
+
+ //
+ // Check if the section is found
+ //
+ CurrentToken = strstr (InputBuffer, Section);
+ if (CurrentToken != NULL) {
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+EFI_STATUS
+FindToken (
+ IN MEMORY_FILE *InputFile,
+ IN CHAR8 *Section,
+ IN CHAR8 *Token,
+ IN UINTN Instance,
+ OUT CHAR8 *Value
+ )
+/*++
+
+Routine Description:
+
+ Finds a token value given the section and token to search for.
+
+Arguments:
+
+ InputFile Memory file image.
+ Section The section to search for, a string within [].
+ Token The token to search for, e.g. EFI_PEIM_RECOVERY, followed by an = in the INF file.
+ Instance The instance of the token to search for. Zero is the first instance.
+ Value The string that holds the value following the =. Must be _MAX_PATH in size.
+
+Returns:
+
+ EFI_SUCCESS Value found.
+ EFI_ABORTED Format error detected in INF file.
+ EFI_INVALID_PARAMETER Input argument was null.
+ EFI_LOAD_ERROR Error reading from the file.
+ EFI_NOT_FOUND Section/Token/Value not found.
+
+--*/
+{
+ CHAR8 InputBuffer[_MAX_PATH];
+ CHAR8 *CurrentToken;
+ BOOLEAN ParseError;
+ BOOLEAN ReadError;
+ UINTN Occurrance;
+
+ //
+ // Check input parameters
+ //
+ if (InputFile->FileImage == NULL ||
+ InputFile->Eof == NULL ||
+ InputFile->CurrentFilePointer == NULL ||
+ Section == NULL ||
+ strlen (Section) == 0 ||
+ Token == NULL ||
+ strlen (Token) == 0 ||
+ Value == NULL
+ ) {
+ return EFI_INVALID_PARAMETER;
+ }
+ //
+ // Initialize error codes
+ //
+ ParseError = FALSE;
+ ReadError = FALSE;
+
+ //
+ // Initialize our instance counter for the search token
+ //
+ Occurrance = 0;
+
+ if (FindSection (InputFile, Section)) {
+ //
+ // Found the desired section, find and read the desired token
+ //
+ do {
+ //
+ // Read a line from the file
+ //
+ if (ReadLine (InputFile, InputBuffer, _MAX_PATH) == NULL) {
+ //
+ // Error reading from input file
+ //
+ ReadError = TRUE;
+ break;
+ }
+ //
+ // Get the first non-whitespace string
+ //
+ CurrentToken = strtok (InputBuffer, " \t\n");
+ if (CurrentToken == NULL) {
+ //
+ // Whitespace line found (or comment) so continue
+ //
+ CurrentToken = InputBuffer;
+ continue;
+ }
+ //
+ // Make sure we have not reached the end of the current section
+ //
+ if (CurrentToken[0] == '[') {
+ break;
+ }
+ //
+ // Compare the current token with the desired token
+ //
+ if (strcmp (CurrentToken, Token) == 0) {
+ //
+ // Found it
+ //
+ //
+ // Check if it is the correct instance
+ //
+ if (Instance == Occurrance) {
+ //
+ // Copy the contents following the =
+ //
+ CurrentToken = strtok (NULL, "= \t\n");
+ if (CurrentToken == NULL) {
+ //
+ // Nothing found, parsing error
+ //
+ ParseError = TRUE;
+ } else {
+ //
+ // Copy the current token to the output value
+ //
+ strcpy (Value, CurrentToken);
+ return EFI_SUCCESS;
+ }
+ } else {
+ //
+ // Increment the occurrance found
+ //
+ Occurrance++;
+ }
+ }
+ } while (
+ !ParseError &&
+ !ReadError &&
+ InputFile->CurrentFilePointer < InputFile->Eof &&
+ CurrentToken[0] != '[' &&
+ Occurrance <= Instance
+ );
+ }
+ //
+ // Distinguish between read errors and INF file format errors.
+ //
+ if (ReadError) {
+ return EFI_LOAD_ERROR;
+ }
+
+ if (ParseError) {
+ return EFI_ABORTED;
+ }
+
+ return EFI_NOT_FOUND;
+}
+
+EFI_STATUS
+StringToGuid (
+ IN CHAR8 *AsciiGuidBuffer,
+ OUT EFI_GUID *GuidBuffer
+ )
+/*++
+
+Routine Description:
+
+ Converts a string to an EFI_GUID. The string must be in the
+ xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx format.
+
+Arguments:
+
+ AsciiGuidBuffer - pointer to ascii string
+ GuidBuffer - pointer to destination Guid
+
+Returns:
+
+ EFI_ABORTED Could not convert the string
+ EFI_SUCCESS The string was successfully converted
+ EFI_INVALID_PARAMETER Input parameter is invalid.
+
+--*/
+{
+ INT32 Index;
+ unsigned Data1;
+ unsigned Data2;
+ unsigned Data3;
+ unsigned Data4[8];
+
+ if (AsciiGuidBuffer == NULL || GuidBuffer == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+ //
+ // Check Guid Format strictly xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
+ //
+ for (Index = 0; AsciiGuidBuffer[Index] != '\0' && Index < 37; Index ++) {
+ if (Index == 8 || Index == 13 || Index == 18 || Index == 23) {
+ if (AsciiGuidBuffer[Index] != '-') {
+ break;
+ }
+ } else {
+ if (((AsciiGuidBuffer[Index] >= '0') && (AsciiGuidBuffer[Index] <= '9')) ||
+ ((AsciiGuidBuffer[Index] >= 'a') && (AsciiGuidBuffer[Index] <= 'f')) ||
+ ((AsciiGuidBuffer[Index] >= 'A') && (AsciiGuidBuffer[Index] <= 'F'))) {
+ continue;
+ } else {
+ break;
+ }
+ }
+ }
+
+ if (Index < 36 || AsciiGuidBuffer[36] != '\0') {
+ Error (NULL, 0, 1003, "Invalid option value", "Incorrect GUID \"%s\"\n Correct Format \"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\"", AsciiGuidBuffer);
+ return EFI_ABORTED;
+ }
+
+ //
+ // Scan the guid string into the buffer
+ //
+ Index = sscanf (
+ AsciiGuidBuffer,
+ "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
+ &Data1,
+ &Data2,
+ &Data3,
+ &Data4[0],
+ &Data4[1],
+ &Data4[2],
+ &Data4[3],
+ &Data4[4],
+ &Data4[5],
+ &Data4[6],
+ &Data4[7]
+ );
+
+ //
+ // Verify the correct number of items were scanned.
+ //
+ if (Index != 11) {
+ Error (NULL, 0, 1003, "Invalid option value", "Incorrect GUID \"%s\"\n Correct Format \"xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx\"", AsciiGuidBuffer);
+ return EFI_ABORTED;
+ }
+ //
+ // Copy the data into our GUID.
+ //
+ GuidBuffer->Data1 = (UINT32) Data1;
+ GuidBuffer->Data2 = (UINT16) Data2;
+ GuidBuffer->Data3 = (UINT16) Data3;
+ GuidBuffer->Data4[0] = (UINT8) Data4[0];
+ GuidBuffer->Data4[1] = (UINT8) Data4[1];
+ GuidBuffer->Data4[2] = (UINT8) Data4[2];
+ GuidBuffer->Data4[3] = (UINT8) Data4[3];
+ GuidBuffer->Data4[4] = (UINT8) Data4[4];
+ GuidBuffer->Data4[5] = (UINT8) Data4[5];
+ GuidBuffer->Data4[6] = (UINT8) Data4[6];
+ GuidBuffer->Data4[7] = (UINT8) Data4[7];
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+AsciiStringToUint64 (
+ IN CONST CHAR8 *AsciiString,
+ IN BOOLEAN IsHex,
+ OUT UINT64 *ReturnValue
+ )
+/*++
+
+Routine Description:
+
+ Converts a null terminated ascii string that represents a number into a
+ UINT64 value. A hex number may be preceeded by a 0x, but may not be
+ succeeded by an h. A number without 0x or 0X is considered to be base 10
+ unless the IsHex input is true.
+
+Arguments:
+
+ AsciiString The string to convert.
+ IsHex Force the string to be treated as a hex number.
+ ReturnValue The return value.
+
+Returns:
+
+ EFI_SUCCESS Number successfully converted.
+ EFI_ABORTED Invalid character encountered.
+
+--*/
+{
+ UINT8 Index;
+ UINT64 Value;
+ CHAR8 CurrentChar;
+
+ //
+ // Initialize the result
+ //
+ Value = 0;
+ Index = 0;
+
+ //
+ // Check input paramter
+ //
+ if (AsciiString == NULL || ReturnValue == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+ while (AsciiString[Index] == ' ') {
+ Index ++;
+ }
+
+ //
+ // Add each character to the result
+ //
+
+ //
+ // Skip first two chars only if the string starts with '0x' or '0X'
+ //
+ if (AsciiString[Index] == '0' && (AsciiString[Index + 1] == 'x' || AsciiString[Index + 1] == 'X')) {
+ IsHex = TRUE;
+ Index += 2;
+ }
+ if (IsHex) {
+ //
+ // Convert the hex string.
+ //
+ for (; AsciiString[Index] != '\0'; Index++) {
+ CurrentChar = AsciiString[Index];
+ if (CurrentChar == ' ') {
+ break;
+ }
+ //
+ // Verify Hex string
+ //
+ if (isxdigit ((int)CurrentChar) == 0) {
+ return EFI_ABORTED;
+ }
+ //
+ // Add hex value
+ //
+ Value *= 16;
+ if (CurrentChar >= '0' && CurrentChar <= '9') {
+ Value += CurrentChar - '0';
+ } else if (CurrentChar >= 'a' && CurrentChar <= 'f') {
+ Value += CurrentChar - 'a' + 10;
+ } else if (CurrentChar >= 'A' && CurrentChar <= 'F') {
+ Value += CurrentChar - 'A' + 10;
+ }
+ }
+
+ *ReturnValue = Value;
+ } else {
+ //
+ // Convert dec string is a number
+ //
+ for (; Index < strlen (AsciiString); Index++) {
+ CurrentChar = AsciiString[Index];
+ if (CurrentChar == ' ') {
+ break;
+ }
+ //
+ // Verify Dec string
+ //
+ if (isdigit ((int)CurrentChar) == 0) {
+ return EFI_ABORTED;
+ }
+ //
+ // Add dec value
+ //
+ Value = Value * 10;
+ Value += CurrentChar - '0';
+ }
+
+ *ReturnValue = Value;
+ }
+
+ return EFI_SUCCESS;
+}
+
+CHAR8 *
+ReadLineInStream (
+ IN FILE *InputFile,
+ IN OUT CHAR8 *InputBuffer
+ )
+/*++
+
+Routine Description:
+
+ This function reads a line, stripping any comments.
+ // BUGBUG: This is obsolete once genmake goes away...
+
+Arguments:
+
+ InputFile Stream pointer.
+ InputBuffer Buffer to read into, must be _MAX_PATH size.
+
+Returns:
+
+ NULL if error or EOF
+ InputBuffer otherwise
+
+--*/
+{
+ CHAR8 *CharPtr;
+
+ //
+ // Verify input parameters are not null
+ //
+ assert (InputFile);
+ assert (InputBuffer);
+
+ //
+ // Read a line
+ //
+ if (fgets (InputBuffer, _MAX_PATH, InputFile) == NULL) {
+ return NULL;
+ }
+ //
+ // Strip any comments
+ //
+ CharPtr = strstr (InputBuffer, "//");
+ if (CharPtr != 0) {
+ CharPtr[0] = 0;
+ }
+
+ CharPtr = strstr (InputBuffer, "#");
+ if (CharPtr != 0) {
+ CharPtr[0] = 0;
+ }
+ //
+ // Return the string
+ //
+ return InputBuffer;
+}
+
+BOOLEAN
+FindSectionInStream (
+ IN FILE *InputFile,
+ IN CHAR8 *Section
+ )
+/*++
+
+Routine Description:
+
+ This function parses a stream file from the beginning to find a section.
+ The section string may be anywhere within a line.
+ // BUGBUG: This is obsolete once genmake goes away...
+
+Arguments:
+
+ InputFile Stream pointer.
+ Section Section to search for
+
+Returns:
+
+ FALSE if error or EOF
+ TRUE if section found
+
+--*/
+{
+ CHAR8 InputBuffer[_MAX_PATH];
+ CHAR8 *CurrentToken;
+
+ //
+ // Verify input is not NULL
+ //
+ assert (InputFile);
+ assert (Section);
+
+ //
+ // Rewind to beginning of file
+ //
+ if (fseek (InputFile, 0, SEEK_SET) != 0) {
+ return FALSE;
+ }
+ //
+ // Read lines until the section is found
+ //
+ while (feof (InputFile) == 0) {
+ //
+ // Read a line
+ //
+ ReadLineInStream (InputFile, InputBuffer);
+
+ //
+ // Check if the section is found
+ //
+ CurrentToken = strstr (InputBuffer, Section);
+ if (CurrentToken != NULL) {
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
diff --git a/BaseTools/Source/C/Common/ParseInf.h b/BaseTools/Source/C/Common/ParseInf.h
new file mode 100644
index 0000000000..88ded8760e
--- /dev/null
+++ b/BaseTools/Source/C/Common/ParseInf.h
@@ -0,0 +1,230 @@
+/** @file
+
+Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.
+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.
+
+Module Name:
+
+ ParseInf.h
+
+Abstract:
+
+ Header file for helper functions useful for parsing INF files.
+
+**/
+
+#ifndef _EFI_PARSE_INF_H
+#define _EFI_PARSE_INF_H
+
+#include
+#include
+#include
+#include
+
+#ifndef _MAX_PATH
+#define _MAX_PATH 500
+#endif
+
+
+//
+// Functions declarations
+//
+CHAR8 *
+ReadLine (
+ IN MEMORY_FILE *InputFile,
+ IN OUT CHAR8 *InputBuffer,
+ IN UINTN MaxLength
+ )
+;
+
+/*++
+
+Routine Description:
+
+ This function reads a line, stripping any comments.
+ The function reads a string from the input stream argument and stores it in
+ the input string. ReadLine reads characters from the current file position
+ to and including the first newline character, to the end of the stream, or
+ until the number of characters read is equal to MaxLength - 1, whichever
+ comes first. The newline character, if read, is replaced with a \0.
+
+Arguments:
+
+ InputFile Memory file image.
+ InputBuffer Buffer to read into, must be _MAX_PATH size.
+ MaxLength The maximum size of the input buffer.
+
+Returns:
+
+ NULL if error or EOF
+ InputBuffer otherwise
+
+--*/
+BOOLEAN
+FindSection (
+ IN MEMORY_FILE *InputFile,
+ IN CHAR8 *Section
+ )
+;
+
+/*++
+
+Routine Description:
+
+ This function parses a file from the beginning to find a section.
+ The section string may be anywhere within a line.
+
+Arguments:
+
+ InputFile Memory file image.
+ Section Section to search for
+
+Returns:
+
+ FALSE if error or EOF
+ TRUE if section found
+
+--*/
+EFI_STATUS
+FindToken (
+ IN MEMORY_FILE *InputFile,
+ IN CHAR8 *Section,
+ IN CHAR8 *Token,
+ IN UINTN Instance,
+ OUT CHAR8 *Value
+ )
+;
+
+/*++
+
+Routine Description:
+
+ Finds a token value given the section and token to search for.
+
+Arguments:
+
+ InputFile Memory file image.
+ Section The section to search for, a string within [].
+ Token The token to search for, e.g. EFI_PEIM_RECOVERY, followed by an = in the INF file.
+ Instance The instance of the token to search for. Zero is the first instance.
+ Value The string that holds the value following the =. Must be _MAX_PATH in size.
+
+Returns:
+
+ EFI_SUCCESS Value found.
+ EFI_ABORTED Format error detected in INF file.
+ EFI_INVALID_PARAMETER Input argument was null.
+ EFI_LOAD_ERROR Error reading from the file.
+ EFI_NOT_FOUND Section/Token/Value not found.
+
+--*/
+EFI_STATUS
+StringToGuid (
+ IN CHAR8 *AsciiGuidBuffer,
+ OUT EFI_GUID *GuidBuffer
+ )
+;
+
+/*++
+
+Routine Description:
+
+ Converts a string to an EFI_GUID. The string must be in the
+ xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx format.
+
+Arguments:
+
+ GuidBuffer - pointer to destination Guid
+ AsciiGuidBuffer - pointer to ascii string
+
+Returns:
+
+ EFI_ABORTED Could not convert the string
+ EFI_SUCCESS The string was successfully converted
+
+--*/
+EFI_STATUS
+AsciiStringToUint64 (
+ IN CONST CHAR8 *AsciiString,
+ IN BOOLEAN IsHex,
+ OUT UINT64 *ReturnValue
+ )
+;
+
+/*++
+
+Routine Description:
+
+ Converts a null terminated ascii string that represents a number into a
+ UINT64 value. A hex number may be preceeded by a 0x, but may not be
+ succeeded by an h. A number without 0x or 0X is considered to be base 10
+ unless the IsHex input is true.
+
+Arguments:
+
+ AsciiString The string to convert.
+ IsHex Force the string to be treated as a hex number.
+ ReturnValue The return value.
+
+Returns:
+
+ EFI_SUCCESS Number successfully converted.
+ EFI_ABORTED Invalid character encountered.
+
+--*/
+CHAR8 *
+ReadLineInStream (
+ IN FILE *InputFile,
+ IN OUT CHAR8 *InputBuffer
+ )
+;
+
+/*++
+
+Routine Description:
+
+ This function reads a line, stripping any comments.
+
+Arguments:
+
+ InputFile Stream pointer.
+ InputBuffer Buffer to read into, must be _MAX_PATH size.
+
+Returns:
+
+ NULL if error or EOF
+ InputBuffer otherwise
+
+--*/
+BOOLEAN
+FindSectionInStream (
+ IN FILE *InputFile,
+ IN CHAR8 *Section
+ )
+;
+
+/*++
+
+Routine Description:
+
+ This function parses a stream file from the beginning to find a section.
+ The section string may be anywhere within a line.
+
+Arguments:
+
+ InputFile Stream pointer.
+ Section Section to search for
+
+Returns:
+
+ FALSE if error or EOF
+ TRUE if section found
+
+--*/
+#endif
diff --git a/BaseTools/Source/C/Common/PeCoffLib.h b/BaseTools/Source/C/Common/PeCoffLib.h
new file mode 100644
index 0000000000..31c6f0fca1
--- /dev/null
+++ b/BaseTools/Source/C/Common/PeCoffLib.h
@@ -0,0 +1,181 @@
+/** @file
+ Function prototypes and defines on Memory Only PE COFF loader
+
+ Copyright (c) 2006, Intel Corporation. All rights reserved.
+ 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.
+
+ Module Name: PeCoffLib.h
+
+**/
+
+#ifndef __BASE_PE_COFF_LIB_H__
+#define __BASE_PE_COFF_LIB_H__
+
+//
+// Return status codes from the PE/COFF Loader services
+// BUGBUG: Find where used and see if can be replaced by RETURN_STATUS codes
+//
+#define IMAGE_ERROR_SUCCESS 0
+#define IMAGE_ERROR_IMAGE_READ 1
+#define IMAGE_ERROR_INVALID_PE_HEADER_SIGNATURE 2
+#define IMAGE_ERROR_INVALID_MACHINE_TYPE 3
+#define IMAGE_ERROR_INVALID_SUBSYSTEM 4
+#define IMAGE_ERROR_INVALID_IMAGE_ADDRESS 5
+#define IMAGE_ERROR_INVALID_IMAGE_SIZE 6
+#define IMAGE_ERROR_INVALID_SECTION_ALIGNMENT 7
+#define IMAGE_ERROR_SECTION_NOT_LOADED 8
+#define IMAGE_ERROR_FAILED_RELOCATION 9
+#define IMAGE_ERROR_FAILED_ICACHE_FLUSH 10
+
+
+//
+// PE/COFF Loader Read Function passed in by caller
+//
+typedef
+RETURN_STATUS
+(EFIAPI *PE_COFF_LOADER_READ_FILE) (
+ IN VOID *FileHandle,
+ IN UINTN FileOffset,
+ IN OUT UINTN *ReadSize,
+ OUT VOID *Buffer
+ );
+
+//
+// Context structure used while PE/COFF image is being loaded and relocated
+//
+typedef struct {
+ PHYSICAL_ADDRESS ImageAddress;
+ UINT64 ImageSize;
+ PHYSICAL_ADDRESS DestinationAddress;
+ PHYSICAL_ADDRESS EntryPoint;
+ PE_COFF_LOADER_READ_FILE ImageRead;
+ VOID *Handle;
+ VOID *FixupData;
+ UINT32 SectionAlignment;
+ UINT32 PeCoffHeaderOffset;
+ UINT32 DebugDirectoryEntryRva;
+ VOID *CodeView;
+ CHAR8 *PdbPointer;
+ UINTN SizeOfHeaders;
+ UINT32 ImageCodeMemoryType;
+ UINT32 ImageDataMemoryType;
+ UINT32 ImageError;
+ UINTN FixupDataSize;
+ UINT16 Machine;
+ UINT16 ImageType;
+ BOOLEAN RelocationsStripped;
+ BOOLEAN IsTeImage;
+} PE_COFF_LOADER_IMAGE_CONTEXT;
+
+
+/**
+ Retrieves information on a PE/COFF image
+
+ @param ImageContext The context of the image being loaded
+
+ @retval EFI_SUCCESS The information on the PE/COFF image was collected.
+ @retval EFI_INVALID_PARAMETER ImageContext is NULL.
+ @retval EFI_UNSUPPORTED The PE/COFF image is not supported.
+ @retval Otherwise The error status from reading the PE/COFF image using the
+ ImageContext->ImageRead() function
+
+**/
+RETURN_STATUS
+EFIAPI
+PeCoffLoaderGetImageInfo (
+ IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
+ )
+;
+
+/**
+ Relocates a PE/COFF image in memory
+
+ @param ImageContext Contains information on the loaded image to relocate
+
+ @retval EFI_SUCCESS if the PE/COFF image was relocated
+ @retval EFI_LOAD_ERROR if the image is not a valid PE/COFF image
+ @retval EFI_UNSUPPORTED not support
+
+**/
+RETURN_STATUS
+EFIAPI
+PeCoffLoaderRelocateImage (
+ IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
+ )
+;
+
+/**
+ Loads a PE/COFF image into memory
+
+ @param ImageContext Contains information on image to load into memory
+
+ @retval EFI_SUCCESS if the PE/COFF image was loaded
+ @retval EFI_BUFFER_TOO_SMALL if the caller did not provide a large enough buffer
+ @retval EFI_LOAD_ERROR if the image is a runtime driver with no relocations
+ @retval EFI_INVALID_PARAMETER if the image address is invalid
+
+**/
+RETURN_STATUS
+EFIAPI
+PeCoffLoaderLoadImage (
+ IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
+ )
+;
+
+VOID *
+EFIAPI
+PeCoffLoaderGetPdbPointer (
+ IN VOID *Pe32Data
+ )
+;
+
+RETURN_STATUS
+EFIAPI
+PeCoffLoaderGetEntryPoint (
+ IN VOID *Pe32Data,
+ OUT VOID **EntryPoint,
+ OUT VOID **BaseOfImage
+ )
+;
+
+//
+// These functions are used by the ARM PE/COFF relocation code and by
+// the ELF to PE/COFF converter so that is why they are public
+//
+
+/**
+ Pass in a pointer to an ARM MOVT or MOVW immediate instruciton and
+ return the immediate data encoded in the instruction
+
+ @param Instruction Pointer to ARM MOVT or MOVW immediate instruction
+
+ @return Immediate address encoded in the instruction
+
+**/
+UINT16
+ThumbMovtImmediateAddress (
+ IN UINT16 *Instruction
+ );
+
+/**
+ Update an ARM MOVT or MOVW immediate instruction immediate data.
+
+ @param Instruction Pointer to ARM MOVT or MOVW immediate instruction
+ @param Address New addres to patch into the instruction
+
+**/
+VOID
+ThumbMovtImmediatePatch (
+ IN OUT UINT16 *Instruction,
+ IN UINT16 Address
+ );
+
+
+
+#endif
diff --git a/BaseTools/Source/C/Common/PeCoffLoaderEx.c b/BaseTools/Source/C/Common/PeCoffLoaderEx.c
new file mode 100644
index 0000000000..5d827cefe4
--- /dev/null
+++ b/BaseTools/Source/C/Common/PeCoffLoaderEx.c
@@ -0,0 +1,435 @@
+/** @file
+
+Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.
+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.
+
+Module Name:
+
+ PeCoffLoaderEx.c
+
+Abstract:
+
+ IA32, X64 and IPF Specific relocation fixups
+
+Revision History
+
+--*/
+
+#include
+#include
+#include "PeCoffLib.h"
+
+#define EXT_IMM64(Value, Address, Size, InstPos, ValPos) \
+ Value |= (((UINT64)((*(Address) >> InstPos) & (((UINT64)1 << Size) - 1))) << ValPos)
+
+#define INS_IMM64(Value, Address, Size, InstPos, ValPos) \
+ *(UINT32*)Address = (*(UINT32*)Address & ~(((1 << Size) - 1) << InstPos)) | \
+ ((UINT32)((((UINT64)Value >> ValPos) & (((UINT64)1 << Size) - 1))) << InstPos)
+
+#define IMM64_IMM7B_INST_WORD_X 3
+#define IMM64_IMM7B_SIZE_X 7
+#define IMM64_IMM7B_INST_WORD_POS_X 4
+#define IMM64_IMM7B_VAL_POS_X 0
+
+#define IMM64_IMM9D_INST_WORD_X 3
+#define IMM64_IMM9D_SIZE_X 9
+#define IMM64_IMM9D_INST_WORD_POS_X 18
+#define IMM64_IMM9D_VAL_POS_X 7
+
+#define IMM64_IMM5C_INST_WORD_X 3
+#define IMM64_IMM5C_SIZE_X 5
+#define IMM64_IMM5C_INST_WORD_POS_X 13
+#define IMM64_IMM5C_VAL_POS_X 16
+
+#define IMM64_IC_INST_WORD_X 3
+#define IMM64_IC_SIZE_X 1
+#define IMM64_IC_INST_WORD_POS_X 12
+#define IMM64_IC_VAL_POS_X 21
+
+#define IMM64_IMM41a_INST_WORD_X 1
+#define IMM64_IMM41a_SIZE_X 10
+#define IMM64_IMM41a_INST_WORD_POS_X 14
+#define IMM64_IMM41a_VAL_POS_X 22
+
+#define IMM64_IMM41b_INST_WORD_X 1
+#define IMM64_IMM41b_SIZE_X 8
+#define IMM64_IMM41b_INST_WORD_POS_X 24
+#define IMM64_IMM41b_VAL_POS_X 32
+
+#define IMM64_IMM41c_INST_WORD_X 2
+#define IMM64_IMM41c_SIZE_X 23
+#define IMM64_IMM41c_INST_WORD_POS_X 0
+#define IMM64_IMM41c_VAL_POS_X 40
+
+#define IMM64_SIGN_INST_WORD_X 3
+#define IMM64_SIGN_SIZE_X 1
+#define IMM64_SIGN_INST_WORD_POS_X 27
+#define IMM64_SIGN_VAL_POS_X 63
+
+RETURN_STATUS
+PeCoffLoaderRelocateIa32Image (
+ IN UINT16 *Reloc,
+ IN OUT CHAR8 *Fixup,
+ IN OUT CHAR8 **FixupData,
+ IN UINT64 Adjust
+ )
+/*++
+
+Routine Description:
+
+ Performs an IA-32 specific relocation fixup
+
+Arguments:
+
+ Reloc - Pointer to the relocation record
+
+ Fixup - Pointer to the address to fix up
+
+ FixupData - Pointer to a buffer to log the fixups
+
+ Adjust - The offset to adjust the fixup
+
+Returns:
+
+ EFI_UNSUPPORTED - Unsupported now
+
+--*/
+{
+ return RETURN_UNSUPPORTED;
+}
+
+RETURN_STATUS
+PeCoffLoaderRelocateIpfImage (
+ IN UINT16 *Reloc,
+ IN OUT CHAR8 *Fixup,
+ IN OUT CHAR8 **FixupData,
+ IN UINT64 Adjust
+ )
+/*++
+
+Routine Description:
+
+ Performs an Itanium-based specific relocation fixup
+
+Arguments:
+
+ Reloc - Pointer to the relocation record
+
+ Fixup - Pointer to the address to fix up
+
+ FixupData - Pointer to a buffer to log the fixups
+
+ Adjust - The offset to adjust the fixup
+
+Returns:
+
+ Status code
+
+--*/
+{
+ UINT64 *F64;
+ UINT64 FixupVal;
+
+ switch ((*Reloc) >> 12) {
+
+ case EFI_IMAGE_REL_BASED_DIR64:
+ F64 = (UINT64 *) Fixup;
+ *F64 = *F64 + (UINT64) Adjust;
+ if (*FixupData != NULL) {
+ *FixupData = ALIGN_POINTER(*FixupData, sizeof(UINT64));
+ *(UINT64 *)(*FixupData) = *F64;
+ *FixupData = *FixupData + sizeof(UINT64);
+ }
+ break;
+
+ case EFI_IMAGE_REL_BASED_IA64_IMM64:
+
+ //
+ // Align it to bundle address before fixing up the
+ // 64-bit immediate value of the movl instruction.
+ //
+
+ Fixup = (CHAR8 *)((UINTN) Fixup & (UINTN) ~(15));
+ FixupVal = (UINT64)0;
+
+ //
+ // Extract the lower 32 bits of IMM64 from bundle
+ //
+ EXT_IMM64(FixupVal,
+ (UINT32 *)Fixup + IMM64_IMM7B_INST_WORD_X,
+ IMM64_IMM7B_SIZE_X,
+ IMM64_IMM7B_INST_WORD_POS_X,
+ IMM64_IMM7B_VAL_POS_X
+ );
+
+ EXT_IMM64(FixupVal,
+ (UINT32 *)Fixup + IMM64_IMM9D_INST_WORD_X,
+ IMM64_IMM9D_SIZE_X,
+ IMM64_IMM9D_INST_WORD_POS_X,
+ IMM64_IMM9D_VAL_POS_X
+ );
+
+ EXT_IMM64(FixupVal,
+ (UINT32 *)Fixup + IMM64_IMM5C_INST_WORD_X,
+ IMM64_IMM5C_SIZE_X,
+ IMM64_IMM5C_INST_WORD_POS_X,
+ IMM64_IMM5C_VAL_POS_X
+ );
+
+ EXT_IMM64(FixupVal,
+ (UINT32 *)Fixup + IMM64_IC_INST_WORD_X,
+ IMM64_IC_SIZE_X,
+ IMM64_IC_INST_WORD_POS_X,
+ IMM64_IC_VAL_POS_X
+ );
+
+ EXT_IMM64(FixupVal,
+ (UINT32 *)Fixup + IMM64_IMM41a_INST_WORD_X,
+ IMM64_IMM41a_SIZE_X,
+ IMM64_IMM41a_INST_WORD_POS_X,
+ IMM64_IMM41a_VAL_POS_X
+ );
+
+ //
+ // Update 64-bit address
+ //
+ FixupVal += Adjust;
+
+ //
+ // Insert IMM64 into bundle
+ //
+ INS_IMM64(FixupVal,
+ ((UINT32 *)Fixup + IMM64_IMM7B_INST_WORD_X),
+ IMM64_IMM7B_SIZE_X,
+ IMM64_IMM7B_INST_WORD_POS_X,
+ IMM64_IMM7B_VAL_POS_X
+ );
+
+ INS_IMM64(FixupVal,
+ ((UINT32 *)Fixup + IMM64_IMM9D_INST_WORD_X),
+ IMM64_IMM9D_SIZE_X,
+ IMM64_IMM9D_INST_WORD_POS_X,
+ IMM64_IMM9D_VAL_POS_X
+ );
+
+ INS_IMM64(FixupVal,
+ ((UINT32 *)Fixup + IMM64_IMM5C_INST_WORD_X),
+ IMM64_IMM5C_SIZE_X,
+ IMM64_IMM5C_INST_WORD_POS_X,
+ IMM64_IMM5C_VAL_POS_X
+ );
+
+ INS_IMM64(FixupVal,
+ ((UINT32 *)Fixup + IMM64_IC_INST_WORD_X),
+ IMM64_IC_SIZE_X,
+ IMM64_IC_INST_WORD_POS_X,
+ IMM64_IC_VAL_POS_X
+ );
+
+ INS_IMM64(FixupVal,
+ ((UINT32 *)Fixup + IMM64_IMM41a_INST_WORD_X),
+ IMM64_IMM41a_SIZE_X,
+ IMM64_IMM41a_INST_WORD_POS_X,
+ IMM64_IMM41a_VAL_POS_X
+ );
+
+ INS_IMM64(FixupVal,
+ ((UINT32 *)Fixup + IMM64_IMM41b_INST_WORD_X),
+ IMM64_IMM41b_SIZE_X,
+ IMM64_IMM41b_INST_WORD_POS_X,
+ IMM64_IMM41b_VAL_POS_X
+ );
+
+ INS_IMM64(FixupVal,
+ ((UINT32 *)Fixup + IMM64_IMM41c_INST_WORD_X),
+ IMM64_IMM41c_SIZE_X,
+ IMM64_IMM41c_INST_WORD_POS_X,
+ IMM64_IMM41c_VAL_POS_X
+ );
+
+ INS_IMM64(FixupVal,
+ ((UINT32 *)Fixup + IMM64_SIGN_INST_WORD_X),
+ IMM64_SIGN_SIZE_X,
+ IMM64_SIGN_INST_WORD_POS_X,
+ IMM64_SIGN_VAL_POS_X
+ );
+
+ F64 = (UINT64 *) Fixup;
+ if (*FixupData != NULL) {
+ *FixupData = ALIGN_POINTER(*FixupData, sizeof(UINT64));
+ *(UINT64 *)(*FixupData) = *F64;
+ *FixupData = *FixupData + sizeof(UINT64);
+ }
+ break;
+
+ default:
+ return RETURN_UNSUPPORTED;
+ }
+
+ return RETURN_SUCCESS;
+}
+
+RETURN_STATUS
+PeCoffLoaderRelocateX64Image (
+ IN UINT16 *Reloc,
+ IN OUT CHAR8 *Fixup,
+ IN OUT CHAR8 **FixupData,
+ IN UINT64 Adjust
+ )
+/**
+ Performs an x64 specific relocation fixup
+
+ @param Reloc Pointer to the relocation record
+ @param Fixup Pointer to the address to fix up
+ @param FixupData Pointer to a buffer to log the fixups
+ @param Adjust The offset to adjust the fixup
+
+ @retval RETURN_SUCCESS Success to perform relocation
+ @retval RETURN_UNSUPPORTED Unsupported.
+**/
+{
+ UINT64 *F64;
+
+ switch ((*Reloc) >> 12) {
+
+ case EFI_IMAGE_REL_BASED_DIR64:
+ F64 = (UINT64 *) Fixup;
+ *F64 = *F64 + (UINT64) Adjust;
+ if (*FixupData != NULL) {
+ *FixupData = ALIGN_POINTER(*FixupData, sizeof(UINT64));
+ *(UINT64 *)(*FixupData) = *F64;
+ *FixupData = *FixupData + sizeof(UINT64);
+ }
+ break;
+
+ default:
+ return RETURN_UNSUPPORTED;
+ }
+
+ return RETURN_SUCCESS;
+}
+
+/**
+ Pass in a pointer to an ARM MOVT or MOVW immediate instruciton and
+ return the immediate data encoded in the instruction
+
+ @param Instruction Pointer to ARM MOVT or MOVW immediate instruction
+
+ @return Immediate address encoded in the instruction
+
+**/
+UINT16
+ThumbMovtImmediateAddress (
+ IN UINT16 *Instruction
+ )
+{
+ UINT32 Movt;
+ UINT16 Address;
+
+ // Thumb2 is two 16-bit instructions working together. Not a single 32-bit instruction
+ // Example MOVT R0, #0 is 0x0000f2c0 or 0xf2c0 0x0000
+ Movt = (*Instruction << 16) | (*(Instruction + 1));
+
+ // imm16 = imm4:i:imm3:imm8
+ // imm4 -> Bit19:Bit16
+ // i -> Bit26
+ // imm3 -> Bit14:Bit12
+ // imm8 -> Bit7:Bit0
+ Address = (UINT16)(Movt & 0x000000ff); // imm8
+ Address |= (UINT16)((Movt >> 4) & 0x0000f700); // imm4 imm3
+ Address |= (((Movt & BIT26) != 0) ? BIT11 : 0); // i
+ return Address;
+}
+
+
+/**
+ Update an ARM MOVT or MOVW immediate instruction immediate data.
+
+ @param Instruction Pointer to ARM MOVT or MOVW immediate instruction
+ @param Address New addres to patch into the instruction
+**/
+VOID
+ThumbMovtImmediatePatch (
+ IN OUT UINT16 *Instruction,
+ IN UINT16 Address
+ )
+{
+ UINT16 Patch;
+
+ // First 16-bit chunk of instruciton
+ Patch = ((Address >> 12) & 0x000f); // imm4
+ Patch |= (((Address & BIT11) != 0) ? BIT10 : 0); // i
+ *Instruction = (*Instruction & ~0x040f) | Patch;
+
+ // Second 16-bit chunk of instruction
+ Patch = Address & 0x000000ff; // imm8
+ Patch |= ((Address << 4) & 0x00007000); // imm3
+ Instruction++;
+ *Instruction = (*Instruction & ~0x70ff) | Patch;
+}
+
+/**
+ Performs an ARM-based specific relocation fixup and is a no-op on other
+ instruction sets.
+
+ @param Reloc Pointer to the relocation record.
+ @param Fixup Pointer to the address to fix up.
+ @param FixupData Pointer to a buffer to log the fixups.
+ @param Adjust The offset to adjust the fixup.
+
+ @return Status code.
+
+**/
+RETURN_STATUS
+PeCoffLoaderRelocateArmImage (
+ IN UINT16 **Reloc,
+ IN OUT CHAR8 *Fixup,
+ IN OUT CHAR8 **FixupData,
+ IN UINT64 Adjust
+ )
+{
+ UINT16 *Fixup16;
+ UINT16 FixupVal;
+ UINT16 *Addend;
+
+ Fixup16 = (UINT16 *) Fixup;
+
+ switch ((**Reloc) >> 12) {
+ case EFI_IMAGE_REL_BASED_ARM_THUMB_MOVW:
+ FixupVal = ThumbMovtImmediateAddress (Fixup16) + (UINT16)Adjust;
+ ThumbMovtImmediatePatch (Fixup16, FixupVal);
+
+ if (*FixupData != NULL) {
+ *FixupData = ALIGN_POINTER (*FixupData, sizeof (UINT16));
+ *(UINT16 *)*FixupData = *Fixup16;
+ *FixupData = *FixupData + sizeof (UINT16);
+ }
+ break;
+
+ case EFI_IMAGE_REL_BASED_ARM_THUMB_MOVT:
+ // For MOVT you need to know the lower 16-bits do do the math
+ // So this relocation entry is really two entries.
+ *Reloc = *Reloc + 1;
+ Addend = *Reloc;
+ FixupVal = (UINT16)(((ThumbMovtImmediateAddress (Fixup16) << 16) + Adjust + *Addend) >> 16);
+ ThumbMovtImmediatePatch (Fixup16, FixupVal);
+
+ if (*FixupData != NULL) {
+ *FixupData = ALIGN_POINTER (*FixupData, sizeof (UINT16));
+ *(UINT16 *)*FixupData = *Fixup16;
+ *FixupData = *FixupData + sizeof (UINT16);
+ }
+ break;
+
+ default:
+ return RETURN_UNSUPPORTED;
+ }
+
+ return RETURN_SUCCESS;
+}
diff --git a/BaseTools/Source/C/Common/SimpleFileParsing.c b/BaseTools/Source/C/Common/SimpleFileParsing.c
new file mode 100644
index 0000000000..0f6151819c
--- /dev/null
+++ b/BaseTools/Source/C/Common/SimpleFileParsing.c
@@ -0,0 +1,1443 @@
+/** @file
+
+Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.
+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.
+
+Module Name:
+
+ SimpleFileParsing.c
+
+Abstract:
+
+ Generic but simple file parsing routines.
+
+--*/
+
+#include
+#include
+#include
+#include
+
+#include "EfiUtilityMsgs.h"
+#include "SimpleFileParsing.h"
+
+#ifndef MAX_PATH
+#define MAX_PATH 255
+#endif
+//
+// just in case we get in an endless loop.
+//
+#define MAX_NEST_DEPTH 20
+//
+// number of wchars
+//
+#define MAX_STRING_IDENTIFIER_NAME 100
+
+#define T_CHAR_SPACE ' '
+#define T_CHAR_NULL 0
+#define T_CHAR_CR '\r'
+#define T_CHAR_TAB '\t'
+#define T_CHAR_LF '\n'
+#define T_CHAR_SLASH '/'
+#define T_CHAR_BACKSLASH '\\'
+#define T_CHAR_DOUBLE_QUOTE '"'
+#define T_CHAR_LC_X 'x'
+#define T_CHAR_0 '0'
+#define T_CHAR_STAR '*'
+
+//
+// We keep a linked list of these for the source files we process
+//
+typedef struct _SOURCE_FILE {
+ FILE *Fptr;
+ CHAR8 *FileBuffer;
+ CHAR8 *FileBufferPtr;
+ UINTN FileSize;
+ CHAR8 FileName[MAX_PATH];
+ UINTN LineNum;
+ BOOLEAN EndOfFile;
+ BOOLEAN SkipToHash;
+ struct _SOURCE_FILE *Previous;
+ struct _SOURCE_FILE *Next;
+ CHAR8 ControlCharacter;
+} SOURCE_FILE;
+
+typedef struct {
+ CHAR8 *FileBufferPtr;
+} FILE_POSITION;
+
+//
+// Keep all our module globals in this structure
+//
+STATIC struct {
+ SOURCE_FILE SourceFile;
+ BOOLEAN VerboseFile;
+ BOOLEAN VerboseToken;
+} mGlobals;
+
+STATIC
+UINTN
+t_strcmp (
+ CHAR8 *Buffer,
+ CHAR8 *Str
+ );
+
+STATIC
+UINTN
+t_strncmp (
+ CHAR8 *Str1,
+ CHAR8 *Str2,
+ INTN Len
+ );
+
+STATIC
+UINTN
+t_strlen (
+ CHAR8 *Str
+ );
+
+STATIC
+VOID
+RewindFile (
+ SOURCE_FILE *SourceFile
+ );
+
+STATIC
+BOOLEAN
+IsWhiteSpace (
+ SOURCE_FILE *SourceFile
+ );
+
+STATIC
+UINTN
+SkipWhiteSpace (
+ SOURCE_FILE *SourceFile
+ );
+
+STATIC
+BOOLEAN
+EndOfFile (
+ SOURCE_FILE *SourceFile
+ );
+
+STATIC
+VOID
+PreprocessFile (
+ SOURCE_FILE *SourceFile
+ );
+
+STATIC
+CHAR8 *
+t_strcpy (
+ CHAR8 *Dest,
+ CHAR8 *Src
+ );
+
+STATIC
+STATUS
+ProcessIncludeFile (
+ SOURCE_FILE *SourceFile,
+ SOURCE_FILE *ParentSourceFile
+ );
+
+STATIC
+STATUS
+ProcessFile (
+ SOURCE_FILE *SourceFile
+ );
+
+STATIC
+STATUS
+GetFilePosition (
+ FILE_POSITION *Fpos
+ );
+
+STATIC
+STATUS
+SetFilePosition (
+ FILE_POSITION *Fpos
+ );
+
+STATUS
+SFPInit (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+Arguments:
+ None.
+
+Returns:
+ STATUS_SUCCESS always
+
+--*/
+{
+ memset ((VOID *) &mGlobals, 0, sizeof (mGlobals));
+ return STATUS_SUCCESS;
+}
+
+UINTN
+SFPGetLineNumber (
+ VOID
+ )
+/*++
+
+Routine Description:
+ Return the line number of the file we're parsing. Used
+ for error reporting purposes.
+
+Arguments:
+ None.
+
+Returns:
+ The line number, or 0 if no file is being processed
+
+--*/
+{
+ return mGlobals.SourceFile.LineNum;
+}
+
+CHAR8 *
+SFPGetFileName (
+ VOID
+ )
+/*++
+
+Routine Description:
+ Return the name of the file we're parsing. Used
+ for error reporting purposes.
+
+Arguments:
+ None.
+
+Returns:
+ A pointer to the file name. Null if no file is being
+ processed.
+
+--*/
+{
+ if (mGlobals.SourceFile.FileName[0]) {
+ return mGlobals.SourceFile.FileName;
+ }
+
+ return NULL;
+}
+
+STATUS
+SFPOpenFile (
+ CHAR8 *FileName
+ )
+/*++
+
+Routine Description:
+ Open a file for parsing.
+
+Arguments:
+ FileName - name of the file to parse
+
+Returns:
+
+
+--*/
+{
+ STATUS Status;
+ t_strcpy (mGlobals.SourceFile.FileName, FileName);
+ Status = ProcessIncludeFile (&mGlobals.SourceFile, NULL);
+ return Status;
+}
+
+BOOLEAN
+SFPIsToken (
+ CHAR8 *Str
+ )
+/*++
+
+Routine Description:
+ Check to see if the specified token is found at
+ the current position in the input file.
+
+Arguments:
+ Str - the token to look for
+
+Returns:
+ TRUE - the token is next
+ FALSE - the token is not next
+
+Notes:
+ We do a simple string comparison on this function. It is
+ the responsibility of the caller to ensure that the token
+ is not a subset of some other token.
+
+ The file pointer is advanced past the token in the input file.
+
+--*/
+{
+ UINTN Len;
+ SkipWhiteSpace (&mGlobals.SourceFile);
+ if (EndOfFile (&mGlobals.SourceFile)) {
+ return FALSE;
+ }
+
+ if ((Len = t_strcmp (mGlobals.SourceFile.FileBufferPtr, Str)) > 0) {
+ mGlobals.SourceFile.FileBufferPtr += Len;
+ if (mGlobals.VerboseToken) {
+ printf ("Token: '%s'\n", Str);
+ }
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+BOOLEAN
+SFPIsKeyword (
+ CHAR8 *Str
+ )
+/*++
+
+Routine Description:
+ Check to see if the specified keyword is found at
+ the current position in the input file.
+
+Arguments:
+ Str - keyword to look for
+
+Returns:
+ TRUE - the keyword is next
+ FALSE - the keyword is not next
+
+Notes:
+ A keyword is defined as a "special" string that has a non-alphanumeric
+ character following it.
+
+--*/
+{
+ UINTN Len;
+ SkipWhiteSpace (&mGlobals.SourceFile);
+ if (EndOfFile (&mGlobals.SourceFile)) {
+ return FALSE;
+ }
+
+ if ((Len = t_strcmp (mGlobals.SourceFile.FileBufferPtr, Str)) > 0) {
+ if (isalnum ((int)mGlobals.SourceFile.FileBufferPtr[Len])) {
+ return FALSE;
+ }
+
+ mGlobals.SourceFile.FileBufferPtr += Len;
+ if (mGlobals.VerboseToken) {
+ printf ("Token: '%s'\n", Str);
+ }
+
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+BOOLEAN
+SFPGetNextToken (
+ CHAR8 *Str,
+ UINTN Len
+ )
+/*++
+
+Routine Description:
+ Get the next token from the input stream.
+
+Arguments:
+ Str - pointer to a copy of the next token
+ Len - size of buffer pointed to by Str
+
+Returns:
+ TRUE - next token successfully returned
+ FALSE - otherwise
+
+Notes:
+ Preceeding white space is ignored.
+ The parser's buffer pointer is advanced past the end of the
+ token.
+
+--*/
+{
+ UINTN Index;
+ CHAR8 TempChar;
+
+ SkipWhiteSpace (&mGlobals.SourceFile);
+ if (EndOfFile (&mGlobals.SourceFile)) {
+ return FALSE;
+ }
+ //
+ // Have to have enough string for at least one char and a null-terminator
+ //
+ if (Len < 2) {
+ return FALSE;
+ }
+ //
+ // Look at the first character. If it's an identifier, then treat it
+ // as such
+ //
+ TempChar = mGlobals.SourceFile.FileBufferPtr[0];
+ if (((TempChar >= 'a') && (TempChar <= 'z')) || ((TempChar >= 'A') && (TempChar <= 'Z')) || (TempChar == '_')) {
+ Str[0] = TempChar;
+ mGlobals.SourceFile.FileBufferPtr++;
+ Index = 1;
+ while (!EndOfFile (&mGlobals.SourceFile) && (Index < Len)) {
+ TempChar = mGlobals.SourceFile.FileBufferPtr[0];
+ if (((TempChar >= 'a') && (TempChar <= 'z')) ||
+ ((TempChar >= 'A') && (TempChar <= 'Z')) ||
+ ((TempChar >= '0') && (TempChar <= '9')) ||
+ (TempChar == '_')
+ ) {
+ Str[Index] = mGlobals.SourceFile.FileBufferPtr[0];
+ mGlobals.SourceFile.FileBufferPtr++;
+ Index++;
+ } else {
+ //
+ // Invalid character for symbol name, so break out
+ //
+ break;
+ }
+ }
+ //
+ // Null terminate and return success
+ //
+ Str[Index] = 0;
+ return TRUE;
+ } else if ((TempChar == ')') || (TempChar == '(') || (TempChar == '*')) {
+ Str[0] = mGlobals.SourceFile.FileBufferPtr[0];
+ mGlobals.SourceFile.FileBufferPtr++;
+ Str[1] = 0;
+ return TRUE;
+ } else {
+ //
+ // Everything else is white-space (or EOF) separated
+ //
+ Index = 0;
+ while (!EndOfFile (&mGlobals.SourceFile) && (Index < Len)) {
+ if (IsWhiteSpace (&mGlobals.SourceFile)) {
+ if (Index > 0) {
+ Str[Index] = 0;
+ return TRUE;
+ }
+
+ return FALSE;
+ } else {
+ Str[Index] = mGlobals.SourceFile.FileBufferPtr[0];
+ mGlobals.SourceFile.FileBufferPtr++;
+ Index++;
+ }
+ }
+ //
+ // See if we just ran out of file contents, but did find a token
+ //
+ if ((Index > 0) && EndOfFile (&mGlobals.SourceFile)) {
+ Str[Index] = 0;
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+BOOLEAN
+SFPGetGuidToken (
+ CHAR8 *Str,
+ UINT32 Len
+ )
+/*++
+
+Routine Description:
+ Parse a GUID from the input stream. Stop when you discover white space.
+
+Arguments:
+ Str - pointer to a copy of the next token
+ Len - size of buffer pointed to by Str
+
+Returns:
+ TRUE - GUID string returned successfully
+ FALSE - otherwise
+
+--*/
+{
+ UINT32 Index;
+ SkipWhiteSpace (&mGlobals.SourceFile);
+ if (EndOfFile (&mGlobals.SourceFile)) {
+ return FALSE;
+ }
+
+ Index = 0;
+ while (!EndOfFile (&mGlobals.SourceFile) && (Index < Len)) {
+ if (IsWhiteSpace (&mGlobals.SourceFile)) {
+ if (Index > 0) {
+ Str[Index] = 0;
+ return TRUE;
+ }
+
+ return FALSE;
+ } else {
+ Str[Index] = mGlobals.SourceFile.FileBufferPtr[0];
+ mGlobals.SourceFile.FileBufferPtr++;
+ Index++;
+ }
+ }
+
+ return FALSE;
+}
+
+BOOLEAN
+SFPSkipToToken (
+ CHAR8 *Str
+ )
+{
+ UINTN Len;
+ CHAR8 *SavePos;
+ Len = t_strlen (Str);
+ SavePos = mGlobals.SourceFile.FileBufferPtr;
+ SkipWhiteSpace (&mGlobals.SourceFile);
+ while (!EndOfFile (&mGlobals.SourceFile)) {
+ if (t_strncmp (Str, mGlobals.SourceFile.FileBufferPtr, Len) == 0) {
+ mGlobals.SourceFile.FileBufferPtr += Len;
+ return TRUE;
+ }
+
+ mGlobals.SourceFile.FileBufferPtr++;
+ SkipWhiteSpace (&mGlobals.SourceFile);
+ }
+
+ mGlobals.SourceFile.FileBufferPtr = SavePos;
+ return FALSE;
+}
+
+BOOLEAN
+SFPGetNumber (
+ UINTN *Value
+ )
+/*++
+
+Routine Description:
+ Check the token at the current file position for a numeric value.
+ May be either decimal or hex.
+
+Arguments:
+ Value - pointer where to store the value
+
+Returns:
+ FALSE - current token is not a number
+ TRUE - current token is a number
+
+--*/
+{
+ unsigned Val;
+
+ SkipWhiteSpace (&mGlobals.SourceFile);
+ if (EndOfFile (&mGlobals.SourceFile)) {
+ return FALSE;
+ }
+
+ if (isdigit ((int)mGlobals.SourceFile.FileBufferPtr[0])) {
+ //
+ // Check for hex value
+ //
+ if ((mGlobals.SourceFile.FileBufferPtr[0] == T_CHAR_0) && (mGlobals.SourceFile.FileBufferPtr[1] == T_CHAR_LC_X)) {
+ if (!isxdigit ((int)mGlobals.SourceFile.FileBufferPtr[2])) {
+ return FALSE;
+ }
+
+ mGlobals.SourceFile.FileBufferPtr += 2;
+ sscanf (mGlobals.SourceFile.FileBufferPtr, "%x", &Val);
+ *Value = (UINT32) Val;
+ while (isxdigit ((int)mGlobals.SourceFile.FileBufferPtr[0])) {
+ mGlobals.SourceFile.FileBufferPtr++;
+ }
+
+ return TRUE;
+ } else {
+ *Value = atoi (mGlobals.SourceFile.FileBufferPtr);
+ while (isdigit ((int)mGlobals.SourceFile.FileBufferPtr[0])) {
+ mGlobals.SourceFile.FileBufferPtr++;
+ }
+
+ return TRUE;
+ }
+ } else {
+ return FALSE;
+ }
+}
+
+STATUS
+SFPCloseFile (
+ VOID
+ )
+/*++
+
+Routine Description:
+ Close the file being parsed.
+
+Arguments:
+ None.
+
+Returns:
+ STATUS_SUCCESS - the file was closed
+ STATUS_ERROR - no file is currently open
+
+--*/
+{
+ if (mGlobals.SourceFile.FileBuffer != NULL) {
+ free (mGlobals.SourceFile.FileBuffer);
+ memset (&mGlobals.SourceFile, 0, sizeof (mGlobals.SourceFile));
+ return STATUS_SUCCESS;
+ }
+
+ return STATUS_ERROR;
+}
+
+STATIC
+STATUS
+ProcessIncludeFile (
+ SOURCE_FILE *SourceFile,
+ SOURCE_FILE *ParentSourceFile
+ )
+/*++
+
+Routine Description:
+
+ Given a source file, open the file and parse it
+
+Arguments:
+
+ SourceFile - name of file to parse
+ ParentSourceFile - for error reporting purposes, the file that #included SourceFile.
+
+Returns:
+
+ Standard status.
+
+--*/
+{
+ STATIC UINTN NestDepth = 0;
+ CHAR8 FoundFileName[MAX_PATH];
+ STATUS Status;
+
+ Status = STATUS_SUCCESS;
+ NestDepth++;
+ //
+ // Print the file being processed. Indent so you can tell the include nesting
+ // depth.
+ //
+ if (mGlobals.VerboseFile) {
+ fprintf (stdout, "%*cProcessing file '%s'\n", (int)NestDepth * 2, ' ', SourceFile->FileName);
+ fprintf (stdout, "Parent source file = '%s'\n", ParentSourceFile->FileName);
+ }
+
+ //
+ // Make sure we didn't exceed our maximum nesting depth
+ //
+ if (NestDepth > MAX_NEST_DEPTH) {
+ Error (NULL, 0, 3001, "Not Supported", "%s exceeeds max nesting depth (%u)", SourceFile->FileName, (unsigned) NestDepth);
+ Status = STATUS_ERROR;
+ goto Finish;
+ }
+ //
+ // Try to open the file locally, and if that fails try along our include paths.
+ //
+ strcpy (FoundFileName, SourceFile->FileName);
+ if ((SourceFile->Fptr = fopen (FoundFileName, "rb")) == NULL) {
+ return STATUS_ERROR;
+ }
+ //
+ // Process the file found
+ //
+ ProcessFile (SourceFile);
+Finish:
+ //
+ // Close open files and return status
+ //
+ if (SourceFile->Fptr != NULL) {
+ fclose (SourceFile->Fptr);
+ SourceFile->Fptr = NULL;
+ }
+
+ return Status;
+}
+
+STATIC
+STATUS
+ProcessFile (
+ SOURCE_FILE *SourceFile
+ )
+/*++
+
+Routine Description:
+
+ Given a source file that's been opened, read the contents into an internal
+ buffer and pre-process it to remove comments.
+
+Arguments:
+
+ SourceFile - structure containing info on the file to process
+
+Returns:
+
+ Standard status.
+
+--*/
+{
+ //
+ // Get the file size, and then read the entire thing into memory.
+ // Allocate extra space for a terminator character.
+ //
+ fseek (SourceFile->Fptr, 0, SEEK_END);
+ SourceFile->FileSize = ftell (SourceFile->Fptr);
+ if (mGlobals.VerboseFile) {
+ printf ("FileSize = %u (0x%X)\n", (unsigned) SourceFile->FileSize, (unsigned) SourceFile->FileSize);
+ }
+
+ fseek (SourceFile->Fptr, 0, SEEK_SET);
+ SourceFile->FileBuffer = (CHAR8 *) malloc (SourceFile->FileSize + sizeof (CHAR8 ));
+ if (SourceFile->FileBuffer == NULL) {
+ Error (NULL, 0, 4001, "Resource: memory cannot be allocated", NULL);
+ return STATUS_ERROR;
+ }
+
+ fread ((VOID *) SourceFile->FileBuffer, SourceFile->FileSize, 1, SourceFile->Fptr);
+ SourceFile->FileBuffer[(SourceFile->FileSize / sizeof (CHAR8 ))] = T_CHAR_NULL;
+ //
+ // Pre-process the file to replace comments with spaces
+ //
+ PreprocessFile (SourceFile);
+ SourceFile->LineNum = 1;
+ return STATUS_SUCCESS;
+}
+
+STATIC
+VOID
+PreprocessFile (
+ SOURCE_FILE *SourceFile
+ )
+/*++
+
+Routine Description:
+ Preprocess a file to replace all carriage returns with NULLs so
+ we can print lines (as part of error messages) from the file to the screen.
+
+Arguments:
+ SourceFile - structure that we use to keep track of an input file.
+
+Returns:
+ Nothing.
+
+--*/
+{
+ BOOLEAN InComment;
+ BOOLEAN SlashSlashComment;
+ int LineNum;
+
+ RewindFile (SourceFile);
+ InComment = FALSE;
+ SlashSlashComment = FALSE;
+ while (!EndOfFile (SourceFile)) {
+ //
+ // If a line-feed, then no longer in a comment if we're in a // comment
+ //
+ if (SourceFile->FileBufferPtr[0] == T_CHAR_LF) {
+ SourceFile->FileBufferPtr++;
+ SourceFile->LineNum++;
+ if (InComment && SlashSlashComment) {
+ InComment = FALSE;
+ SlashSlashComment = FALSE;
+ }
+ } else if (SourceFile->FileBufferPtr[0] == T_CHAR_CR) {
+ //
+ // Replace all carriage returns with a NULL so we can print stuff
+ //
+ SourceFile->FileBufferPtr[0] = 0;
+ SourceFile->FileBufferPtr++;
+ //
+ // Check for */ comment end
+ //
+ } else if (InComment &&
+ !SlashSlashComment &&
+ (SourceFile->FileBufferPtr[0] == T_CHAR_STAR) &&
+ (SourceFile->FileBufferPtr[1] == T_CHAR_SLASH)
+ ) {
+ SourceFile->FileBufferPtr[0] = T_CHAR_SPACE;
+ SourceFile->FileBufferPtr++;
+ SourceFile->FileBufferPtr[0] = T_CHAR_SPACE;
+ SourceFile->FileBufferPtr++;
+ InComment = FALSE;
+ } else if (InComment) {
+ SourceFile->FileBufferPtr[0] = T_CHAR_SPACE;
+ SourceFile->FileBufferPtr++;
+ //
+ // Check for // comments
+ //
+ } else if ((SourceFile->FileBufferPtr[0] == T_CHAR_SLASH) && (SourceFile->FileBufferPtr[1] == T_CHAR_SLASH)) {
+ InComment = TRUE;
+ SlashSlashComment = TRUE;
+ //
+ // Check for /* comment start
+ //
+ } else if ((SourceFile->FileBufferPtr[0] == T_CHAR_SLASH) && (SourceFile->FileBufferPtr[1] == T_CHAR_STAR)) {
+ SourceFile->FileBufferPtr[0] = T_CHAR_SPACE;
+ SourceFile->FileBufferPtr++;
+ SourceFile->FileBufferPtr[0] = T_CHAR_SPACE;
+ SourceFile->FileBufferPtr++;
+ SlashSlashComment = FALSE;
+ InComment = TRUE;
+ } else {
+ SourceFile->FileBufferPtr++;
+ }
+ }
+ //
+ // Could check for end-of-file and still in a comment, but
+ // should not be necessary. So just restore the file pointers.
+ //
+ RewindFile (SourceFile);
+ //
+ // Dump the reformatted file if verbose mode
+ //
+ if (mGlobals.VerboseFile) {
+ LineNum = 1;
+ printf ("%04d: ", LineNum);
+ while (!EndOfFile (SourceFile)) {
+ if (SourceFile->FileBufferPtr[0] == T_CHAR_LF) {
+ printf ("'\n%04d: '", ++LineNum);
+ } else {
+ printf ("%c", SourceFile->FileBufferPtr[0]);
+ }
+
+ SourceFile->FileBufferPtr++;
+ }
+
+ printf ("'\n");
+ printf ("FileSize = %u (0x%X)\n", (unsigned)SourceFile->FileSize, (unsigned)SourceFile->FileSize);
+ RewindFile (SourceFile);
+ }
+}
+
+BOOLEAN
+SFPGetQuotedString (
+ CHAR8 *Str,
+ INTN Length
+ )
+/*++
+
+Routine Description:
+ Retrieve a quoted-string from the input file.
+
+Arguments:
+ Str - pointer to a copy of the quoted string parsed
+ Length - size of buffer pointed to by Str
+
+Returns:
+ TRUE - next token in input stream was a quoted string, and
+ the string value was returned in Str
+ FALSE - otherwise
+
+--*/
+{
+ SkipWhiteSpace (&mGlobals.SourceFile);
+ if (EndOfFile (&mGlobals.SourceFile)) {
+ return FALSE;
+ }
+
+ if (mGlobals.SourceFile.FileBufferPtr[0] == T_CHAR_DOUBLE_QUOTE) {
+ mGlobals.SourceFile.FileBufferPtr++;
+ while (Length > 0) {
+ if (EndOfFile (&mGlobals.SourceFile)) {
+ return FALSE;
+ }
+ //
+ // Check for closing quote
+ //
+ if (mGlobals.SourceFile.FileBufferPtr[0] == T_CHAR_DOUBLE_QUOTE) {
+ mGlobals.SourceFile.FileBufferPtr++;
+ *Str = 0;
+ return TRUE;
+ }
+
+ *Str = mGlobals.SourceFile.FileBufferPtr[0];
+ Str++;
+ Length--;
+ mGlobals.SourceFile.FileBufferPtr++;
+ }
+ }
+ //
+ // First character was not a quote, or the input string length was
+ // insufficient to contain the quoted string, so return failure code.
+ //
+ return FALSE;
+}
+
+BOOLEAN
+SFPIsEOF (
+ VOID
+ )
+/*++
+
+Routine Description:
+ Return TRUE of FALSE to indicate whether or not we've reached the end of the
+ file we're parsing.
+
+Arguments:
+ NA
+
+Returns:
+ TRUE - EOF reached
+ FALSE - otherwise
+
+--*/
+{
+ SkipWhiteSpace (&mGlobals.SourceFile);
+ return EndOfFile (&mGlobals.SourceFile);
+}
+
+#if 0
+STATIC
+CHAR8 *
+GetQuotedString (
+ SOURCE_FILE *SourceFile,
+ BOOLEAN Optional
+ )
+{
+ CHAR8 *String;
+ CHAR8 *Start;
+ CHAR8 *Ptr;
+ UINTN Len;
+ BOOLEAN PreviousBackslash;
+
+ if (SourceFile->FileBufferPtr[0] != T_CHAR_DOUBLE_QUOTE) {
+ if (Optional == FALSE) {
+ Error (SourceFile->FileName, SourceFile->LineNum, 0, "expected quoted string", "%S", SourceFile->FileBufferPtr);
+ }
+
+ return NULL;
+ }
+
+ Len = 0;
+ SourceFile->FileBufferPtr++;
+ Start = Ptr = SourceFile->FileBufferPtr;
+ PreviousBackslash = FALSE;
+ while (!EndOfFile (SourceFile)) {
+ if ((SourceFile->FileBufferPtr[0] == T_CHAR_DOUBLE_QUOTE) && (PreviousBackslash == FALSE)) {
+ break;
+ } else if (SourceFile->FileBufferPtr[0] == T_CHAR_CR) {
+ Warning (SourceFile->FileName, SourceFile->LineNum, 0, "carriage return found in quoted string", "%S", Start);
+ PreviousBackslash = FALSE;
+ } else if (SourceFile->FileBufferPtr[0] == T_CHAR_BACKSLASH) {
+ PreviousBackslash = TRUE;
+ } else {
+ PreviousBackslash = FALSE;
+ }
+
+ SourceFile->FileBufferPtr++;
+ Len++;
+ }
+
+ if (SourceFile->FileBufferPtr[0] != T_CHAR_DOUBLE_QUOTE) {
+ Warning (SourceFile->FileName, SourceFile->LineNum, 0, "missing closing quote on string", "%S", Start);
+ } else {
+ SourceFile->FileBufferPtr++;
+ }
+ //
+ // Now allocate memory for the string and save it off
+ //
+ String = (CHAR8 *) malloc ((Len + 1) * sizeof (CHAR8 ));
+ if (String == NULL) {
+ Error (NULL, 0, 4001, "Resource: memory cannot be allocated", NULL);
+ return NULL;
+ }
+ //
+ // Copy the string from the file buffer to the local copy.
+ // We do no reformatting of it whatsoever at this point.
+ //
+ Ptr = String;
+ while (Len > 0) {
+ *Ptr = *Start;
+ Start++;
+ Ptr++;
+ Len--;
+ }
+
+ *Ptr = 0;
+ return String;
+}
+#endif
+STATIC
+BOOLEAN
+EndOfFile (
+ SOURCE_FILE *SourceFile
+ )
+{
+ //
+ // The file buffer pointer will typically get updated before the End-of-file flag in the
+ // source file structure, so check it first.
+ //
+ if (SourceFile->FileBufferPtr >= SourceFile->FileBuffer + SourceFile->FileSize / sizeof (CHAR8 )) {
+ SourceFile->EndOfFile = TRUE;
+ return TRUE;
+ }
+
+ if (SourceFile->EndOfFile) {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+#if 0
+STATIC
+VOID
+ProcessTokenInclude (
+ SOURCE_FILE *SourceFile
+ )
+{
+ CHAR8 IncludeFileName[MAX_PATH];
+ CHAR8 *To;
+ UINTN Len;
+ BOOLEAN ReportedError;
+ SOURCE_FILE IncludedSourceFile;
+
+ ReportedError = FALSE;
+ if (SkipWhiteSpace (SourceFile) == 0) {
+ Warning (SourceFile->FileName, SourceFile->LineNum, 0, "expected whitespace following #include keyword", NULL);
+ }
+ //
+ // Should be quoted file name
+ //
+ if (SourceFile->FileBufferPtr[0] != T_CHAR_DOUBLE_QUOTE) {
+ Error (SourceFile->FileName, SourceFile->LineNum, 0, "expected quoted include file name", NULL);
+ goto FailDone;
+ }
+
+ SourceFile->FileBufferPtr++;
+ //
+ // Copy the filename as ascii to our local string
+ //
+ To = IncludeFileName;
+ Len = 0;
+ while (!EndOfFile (SourceFile)) {
+ if ((SourceFile->FileBufferPtr[0] == T_CHAR_CR) || (SourceFile->FileBufferPtr[0] == T_CHAR_LF)) {
+ Error (SourceFile->FileName, SourceFile->LineNum, 0, "end-of-line found in quoted include file name", NULL);
+ goto FailDone;
+ }
+
+ if (SourceFile->FileBufferPtr[0] == T_CHAR_DOUBLE_QUOTE) {
+ SourceFile->FileBufferPtr++;
+ break;
+ }
+ //
+ // If too long, then report the error once and process until the closing quote
+ //
+ Len++;
+ if (!ReportedError && (Len >= sizeof (IncludeFileName))) {
+ Error (SourceFile->FileName, SourceFile->LineNum, 0, "length of include file name exceeds limit", NULL);
+ ReportedError = TRUE;
+ }
+
+ if (!ReportedError) {
+ *To = (CHAR8 ) SourceFile->FileBufferPtr[0];
+ To++;
+ }
+
+ SourceFile->FileBufferPtr++;
+ }
+
+ if (!ReportedError) {
+ *To = 0;
+ memset ((CHAR8 *) &IncludedSourceFile, 0, sizeof (SOURCE_FILE));
+ strcpy (IncludedSourceFile.FileName, IncludeFileName);
+ ProcessIncludeFile (&IncludedSourceFile, SourceFile);
+ }
+
+ return ;
+FailDone:
+ //
+ // Error recovery -- skip to next #
+ //
+ SourceFile->SkipToHash = TRUE;
+}
+#endif
+STATIC
+BOOLEAN
+IsWhiteSpace (
+ SOURCE_FILE *SourceFile
+ )
+{
+ switch (*SourceFile->FileBufferPtr) {
+ case T_CHAR_NULL:
+ case T_CHAR_CR:
+ case T_CHAR_SPACE:
+ case T_CHAR_TAB:
+ case T_CHAR_LF:
+ return TRUE;
+
+ default:
+ return FALSE;
+ }
+}
+
+UINTN
+SkipWhiteSpace (
+ SOURCE_FILE *SourceFile
+ )
+{
+ UINTN Count;
+
+ Count = 0;
+ while (!EndOfFile (SourceFile)) {
+ Count++;
+ switch (*SourceFile->FileBufferPtr) {
+ case T_CHAR_NULL:
+ case T_CHAR_CR:
+ case T_CHAR_SPACE:
+ case T_CHAR_TAB:
+ SourceFile->FileBufferPtr++;
+ break;
+
+ case T_CHAR_LF:
+ SourceFile->FileBufferPtr++;
+ SourceFile->LineNum++;
+ break;
+
+ default:
+ return Count - 1;
+ }
+ }
+ //
+ // Some tokens require trailing whitespace. If we're at the end of the
+ // file, then we count that as well.
+ //
+ if ((Count == 0) && (EndOfFile (SourceFile))) {
+ Count++;
+ }
+
+ return Count;
+}
+
+STATIC
+UINTN
+t_strcmp (
+ CHAR8 *Buffer,
+ CHAR8 *Str
+ )
+/*++
+
+Routine Description:
+ Compare two strings for equality. The string pointed to by 'Buffer' may or may not be null-terminated,
+ so only compare up to the length of Str.
+
+Arguments:
+ Buffer - pointer to first (possibly not null-terminated) string
+ Str - pointer to null-terminated string to compare to Buffer
+
+Returns:
+ Number of bytes matched if exact match
+ 0 if Buffer does not start with Str
+
+--*/
+{
+ UINTN Len;
+
+ Len = 0;
+ while (*Str && (*Str == *Buffer)) {
+ Buffer++;
+ Str++;
+ Len++;
+ }
+
+ if (*Str) {
+ return 0;
+ }
+
+ return Len;
+}
+
+STATIC
+UINTN
+t_strlen (
+ CHAR8 *Str
+ )
+{
+ UINTN Len;
+ Len = 0;
+ while (*Str) {
+ Len++;
+ Str++;
+ }
+
+ return Len;
+}
+
+STATIC
+UINTN
+t_strncmp (
+ CHAR8 *Str1,
+ CHAR8 *Str2,
+ INTN Len
+ )
+{
+ while (Len > 0) {
+ if (*Str1 != *Str2) {
+ return Len;
+ }
+
+ Len--;
+ Str1++;
+ Str2++;
+ }
+
+ return 0;
+}
+
+STATIC
+CHAR8 *
+t_strcpy (
+ CHAR8 *Dest,
+ CHAR8 *Src
+ )
+{
+ CHAR8 *SaveDest;
+ SaveDest = Dest;
+ while (*Src) {
+ *Dest = *Src;
+ Dest++;
+ Src++;
+ }
+
+ *Dest = 0;
+ return SaveDest;
+}
+
+STATIC
+VOID
+RewindFile (
+ SOURCE_FILE *SourceFile
+ )
+{
+ SourceFile->LineNum = 1;
+ SourceFile->FileBufferPtr = SourceFile->FileBuffer;
+ SourceFile->EndOfFile = 0;
+}
+
+STATIC
+UINT32
+GetHexChars (
+ CHAR8 *Buffer,
+ UINT32 BufferLen
+ )
+{
+ UINT32 Len;
+ Len = 0;
+ while (!EndOfFile (&mGlobals.SourceFile) && (BufferLen > 0)) {
+ if (isxdigit ((int)mGlobals.SourceFile.FileBufferPtr[0])) {
+ *Buffer = mGlobals.SourceFile.FileBufferPtr[0];
+ Buffer++;
+ Len++;
+ BufferLen--;
+ mGlobals.SourceFile.FileBufferPtr++;
+ } else {
+ break;
+ }
+ }
+ //
+ // Null terminate if we can
+ //
+ if ((Len > 0) && (BufferLen > 0)) {
+ *Buffer = 0;
+ }
+
+ return Len;
+}
+
+BOOLEAN
+SFPGetGuid (
+ INTN GuidStyle,
+ EFI_GUID *Value
+ )
+/*++
+
+Routine Description:
+ Parse a GUID from the input stream. Stop when you discover white space.
+
+Arguments:
+ GuidStyle - Style of the following GUID token
+ Value - pointer to EFI_GUID struct for output
+
+Returns:
+ TRUE - GUID string parsed successfully
+ FALSE - otherwise
+
+ GUID styles
+ Style[0] 12345678-1234-5678-AAAA-BBBBCCCCDDDD
+
+--*/
+{
+ unsigned Value32;
+ UINT32 Index;
+ FILE_POSITION FPos;
+ CHAR8 TempString[20];
+ CHAR8 TempString2[3];
+ CHAR8 *From;
+ CHAR8 *To;
+ UINT32 Len;
+ BOOLEAN Status;
+
+ Status = FALSE;
+ //
+ // Skip white space, then start parsing
+ //
+ SkipWhiteSpace (&mGlobals.SourceFile);
+ GetFilePosition (&FPos);
+ if (EndOfFile (&mGlobals.SourceFile)) {
+ return FALSE;
+ }
+
+ if (GuidStyle == PARSE_GUID_STYLE_5_FIELDS) {
+ //
+ // Style[0] 12345678-1234-5678-AAAA-BBBBCCCCDDDD
+ //
+ Len = GetHexChars (TempString, sizeof (TempString));
+ if ((Len == 0) || (Len > 8)) {
+ goto Done;
+ }
+
+ sscanf (TempString, "%x", &Value32);
+ Value->Data1 = Value32;
+ //
+ // Next two UINT16 fields
+ //
+ if (mGlobals.SourceFile.FileBufferPtr[0] != '-') {
+ goto Done;
+ }
+
+ mGlobals.SourceFile.FileBufferPtr++;
+ Len = GetHexChars (TempString, sizeof (TempString));
+ if ((Len == 0) || (Len > 4)) {
+ goto Done;
+ }
+
+ sscanf (TempString, "%x", &Value32);
+ Value->Data2 = (UINT16) Value32;
+
+ if (mGlobals.SourceFile.FileBufferPtr[0] != '-') {
+ goto Done;
+ }
+
+ mGlobals.SourceFile.FileBufferPtr++;
+ Len = GetHexChars (TempString, sizeof (TempString));
+ if ((Len == 0) || (Len > 4)) {
+ goto Done;
+ }
+
+ sscanf (TempString, "%x", &Value32);
+ Value->Data3 = (UINT16) Value32;
+ //
+ // Parse the "AAAA" as two bytes
+ //
+ if (mGlobals.SourceFile.FileBufferPtr[0] != '-') {
+ goto Done;
+ }
+
+ mGlobals.SourceFile.FileBufferPtr++;
+ Len = GetHexChars (TempString, sizeof (TempString));
+ if ((Len == 0) || (Len > 4)) {
+ goto Done;
+ }
+
+ sscanf (TempString, "%x", &Value32);
+ Value->Data4[0] = (UINT8) (Value32 >> 8);
+ Value->Data4[1] = (UINT8) Value32;
+ if (mGlobals.SourceFile.FileBufferPtr[0] != '-') {
+ goto Done;
+ }
+
+ mGlobals.SourceFile.FileBufferPtr++;
+ //
+ // Read the last 6 bytes of the GUID
+ //
+ //
+ Len = GetHexChars (TempString, sizeof (TempString));
+ if ((Len == 0) || (Len > 12)) {
+ goto Done;
+ }
+ //
+ // Insert leading 0's to make life easier
+ //
+ if (Len != 12) {
+ From = TempString + Len - 1;
+ To = TempString + 11;
+ TempString[12] = 0;
+ while (From >= TempString) {
+ *To = *From;
+ To--;
+ From--;
+ }
+
+ while (To >= TempString) {
+ *To = '0';
+ To--;
+ }
+ }
+ //
+ // Now parse each byte
+ //
+ TempString2[2] = 0;
+ for (Index = 0; Index < 6; Index++) {
+ //
+ // Copy the two characters from the input string to something
+ // we can parse.
+ //
+ TempString2[0] = TempString[Index * 2];
+ TempString2[1] = TempString[Index * 2 + 1];
+ sscanf (TempString2, "%x", &Value32);
+ Value->Data4[Index + 2] = (UINT8) Value32;
+ }
+
+ Status = TRUE;
+ } else {
+ //
+ // Unsupported GUID style
+ //
+ return FALSE;
+ }
+
+Done:
+ if (Status == FALSE) {
+ SetFilePosition (&FPos);
+ }
+
+ return Status;
+}
+
+STATIC
+STATUS
+GetFilePosition (
+ FILE_POSITION *Fpos
+ )
+{
+ Fpos->FileBufferPtr = mGlobals.SourceFile.FileBufferPtr;
+ return STATUS_SUCCESS;
+}
+
+STATIC
+STATUS
+SetFilePosition (
+ FILE_POSITION *Fpos
+ )
+{
+ //
+ // Should check range of pointer
+ //
+ mGlobals.SourceFile.FileBufferPtr = Fpos->FileBufferPtr;
+ return STATUS_SUCCESS;
+}
diff --git a/BaseTools/Source/C/Common/SimpleFileParsing.h b/BaseTools/Source/C/Common/SimpleFileParsing.h
new file mode 100644
index 0000000000..d871eb7fe3
--- /dev/null
+++ b/BaseTools/Source/C/Common/SimpleFileParsing.h
@@ -0,0 +1,117 @@
+/** @file
+
+Copyright (c) 2004 - 2008, Intel Corporation. All rights reserved.
+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.
+
+Module Name:
+
+ SimpleFileParsing.h
+
+Abstract:
+
+ Function prototypes and defines for the simple file parsing routines.
+
+**/
+
+#ifndef _SIMPLE_FILE_PARSING_H_
+#define _SIMPLE_FILE_PARSING_H_
+
+#include
+
+STATUS
+SFPInit (
+ VOID
+ )
+;
+
+STATUS
+SFPOpenFile (
+ CHAR8 *FileName
+ )
+;
+
+BOOLEAN
+SFPIsKeyword (
+ CHAR8 *Str
+ )
+;
+
+BOOLEAN
+SFPIsToken (
+ CHAR8 *Str
+ )
+;
+
+BOOLEAN
+SFPGetNextToken (
+ CHAR8 *Str,
+ UINTN Len
+ )
+;
+
+BOOLEAN
+SFPGetGuidToken (
+ CHAR8 *Str,
+ UINT32 Len
+ )
+;
+
+#define PARSE_GUID_STYLE_5_FIELDS 0
+
+BOOLEAN
+SFPGetGuid (
+ INTN GuidStyle,
+ EFI_GUID *Value
+ )
+;
+
+BOOLEAN
+SFPSkipToToken (
+ CHAR8 *Str
+ )
+;
+
+BOOLEAN
+SFPGetNumber (
+ UINTN *Value
+ )
+;
+
+BOOLEAN
+SFPGetQuotedString (
+ CHAR8 *Str,
+ INTN Length
+ )
+;
+
+BOOLEAN
+SFPIsEOF (
+ VOID
+ )
+;
+
+STATUS
+SFPCloseFile (
+ VOID
+ )
+;
+
+UINTN
+SFPGetLineNumber (
+ VOID
+ )
+;
+
+CHAR8 *
+SFPGetFileName (
+ VOID
+ )
+;
+
+#endif // #ifndef _SIMPLE_FILE_PARSING_H_
diff --git a/BaseTools/Source/C/Common/StringFuncs.c b/BaseTools/Source/C/Common/StringFuncs.c
new file mode 100644
index 0000000000..bccb0b2d34
--- /dev/null
+++ b/BaseTools/Source/C/Common/StringFuncs.c
@@ -0,0 +1,426 @@
+/** @file
+
+Copyright (c) 2007 - 2008, Intel Corporation. All rights reserved.
+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.
+
+Module Name:
+
+ StringFuncs.c
+
+Abstract:
+
+ Function prototypes and defines for string routines.
+
+**/
+
+#include
+#include
+#include "StringFuncs.h"
+
+//
+// Functions implementations
+//
+
+CHAR8*
+CloneString (
+ IN CHAR8 *String
+ )
+/*++
+
+Routine Description:
+
+ Allocates a new string and copies 'String' to clone it
+
+Arguments:
+
+ String The string to clone
+
+Returns:
+
+ CHAR8* - NULL if there are not enough resources
+
+--*/
+{
+ CHAR8* NewString;
+
+ NewString = malloc (strlen (String) + 1);
+ if (NewString != NULL) {
+ strcpy (NewString, String);
+ }
+
+ return NewString;
+}
+
+
+EFI_STATUS
+StripInfDscStringInPlace (
+ IN CHAR8 *String
+ )
+/*++
+
+Routine Description:
+
+ Remove all comments, leading and trailing whitespace from the string.
+
+Arguments:
+
+ String The string to 'strip'
+
+Returns:
+
+ EFI_STATUS
+
+--*/
+{
+ CHAR8 *Pos;
+
+ if (String == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Remove leading whitespace
+ //
+ for (Pos = String; isspace ((int)*Pos); Pos++) {
+ }
+ if (Pos != String) {
+ memmove (String, Pos, strlen (Pos) + 1);
+ }
+
+ //
+ // Comment BUGBUGs!
+ //
+ // What about strings? Comment characters are okay in strings.
+ // What about multiline comments?
+ //
+
+ Pos = (CHAR8 *) strstr (String, "//");
+ if (Pos != NULL) {
+ *Pos = '\0';
+ }
+
+ Pos = (CHAR8 *) strchr (String, '#');
+ if (Pos != NULL) {
+ *Pos = '\0';
+ }
+
+ //
+ // Remove trailing whitespace
+ //
+ for (Pos = String + strlen (String);
+ ((Pos - 1) >= String) && (isspace ((int)*(Pos - 1)));
+ Pos--
+ ) {
+ }
+ *Pos = '\0';
+
+ return EFI_SUCCESS;
+}
+
+
+STRING_LIST*
+SplitStringByWhitespace (
+ IN CHAR8 *String
+ )
+/*++
+
+Routine Description:
+
+ Creates and returns a 'split' STRING_LIST by splitting the string
+ on whitespace boundaries.
+
+Arguments:
+
+ String The string to 'split'
+
+Returns:
+
+ EFI_STATUS
+
+--*/
+{
+ CHAR8 *Pos;
+ CHAR8 *EndOfSubString;
+ CHAR8 *EndOfString;
+ STRING_LIST *Output;
+ UINTN Item;
+
+ String = CloneString (String);
+ if (String == NULL) {
+ return NULL;
+ }
+ EndOfString = String + strlen (String);
+
+ Output = NewStringList ();
+
+ for (Pos = String, Item = 0; Pos < EndOfString; Item++) {
+ while (isspace ((int)*Pos)) {
+ Pos++;
+ }
+
+ for (EndOfSubString=Pos;
+ (*EndOfSubString != '\0') && !isspace ((int)*EndOfSubString);
+ EndOfSubString++
+ ) {
+ }
+
+ if (EndOfSubString == Pos) {
+ break;
+ }
+
+ *EndOfSubString = '\0';
+
+ AppendCopyOfStringToList (&Output, Pos);
+
+ Pos = EndOfSubString + 1;
+ }
+
+ free (String);
+ return Output;
+}
+
+
+STRING_LIST*
+NewStringList (
+ )
+/*++
+
+Routine Description:
+
+ Creates a new STRING_LIST with 0 strings.
+
+Returns:
+
+ STRING_LIST* - Null if there is not enough resources to create the object.
+
+--*/
+{
+ STRING_LIST *NewList;
+ NewList = AllocateStringListStruct (0);
+ if (NewList != NULL) {
+ NewList->Count = 0;
+ }
+ return NewList;
+}
+
+
+EFI_STATUS
+AppendCopyOfStringToList (
+ IN OUT STRING_LIST **StringList,
+ IN CHAR8 *String
+ )
+/*++
+
+Routine Description:
+
+ Adds String to StringList. A new copy of String is made before it is
+ added to StringList.
+
+Returns:
+
+ EFI_STATUS
+
+--*/
+{
+ STRING_LIST *OldList;
+ STRING_LIST *NewList;
+ CHAR8 *NewString;
+
+ OldList = *StringList;
+ NewList = AllocateStringListStruct (OldList->Count + 1);
+ if (NewList == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ NewString = CloneString (String);
+ if (NewString == NULL) {
+ free (NewList);
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ memcpy (
+ NewList->Strings,
+ OldList->Strings,
+ sizeof (OldList->Strings[0]) * OldList->Count
+ );
+ NewList->Count = OldList->Count + 1;
+ NewList->Strings[OldList->Count] = NewString;
+
+ *StringList = NewList;
+ free (OldList);
+
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+RemoveLastStringFromList (
+ IN STRING_LIST *StringList
+ )
+/*++
+
+Routine Description:
+
+ Removes the last string from StringList and frees the memory associated
+ with it.
+
+Arguments:
+
+ StringList The string list to remove the string from
+
+Returns:
+
+ EFI_STATUS
+
+--*/
+{
+ if (StringList->Count == 0) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ free (StringList->Strings[StringList->Count - 1]);
+ StringList->Count--;
+ return EFI_SUCCESS;
+}
+
+
+STRING_LIST*
+AllocateStringListStruct (
+ IN UINTN StringCount
+ )
+/*++
+
+Routine Description:
+
+ Allocates a STRING_LIST structure that can store StringCount strings.
+
+Arguments:
+
+ StringCount The number of strings that need to be stored
+
+Returns:
+
+ EFI_STATUS
+
+--*/
+{
+ return malloc (OFFSET_OF(STRING_LIST, Strings[StringCount + 1]));
+}
+
+
+VOID
+FreeStringList (
+ IN STRING_LIST *StringList
+ )
+/*++
+
+Routine Description:
+
+ Frees all memory associated with StringList.
+
+Arguments:
+
+ StringList The string list to free
+
+Returns:
+
+ VOID
+--*/
+{
+ while (StringList->Count > 0) {
+ RemoveLastStringFromList (StringList);
+ }
+
+ free (StringList);
+}
+
+
+CHAR8*
+StringListToString (
+ IN STRING_LIST *StringList
+ )
+/*++
+
+Routine Description:
+
+ Generates a string that represents the STRING_LIST
+
+Arguments:
+
+ StringList The string list to convert to a string
+
+Returns:
+
+ CHAR8* - The string list represented with a single string. The returned
+ string must be freed by the caller.
+
+--*/
+{
+ UINTN Count;
+ UINTN Length;
+ CHAR8 *NewString;
+
+ Length = 2;
+ for (Count = 0; Count < StringList->Count; Count++) {
+ if (Count > 0) {
+ Length += 2;
+ }
+ Length += strlen (StringList->Strings[Count]) + 2;
+ }
+
+ NewString = malloc (Length + 1);
+ if (NewString == NULL) {
+ return NewString;
+ }
+ NewString[0] = '\0';
+
+ strcat (NewString, "[");
+ for (Count = 0; Count < StringList->Count; Count++) {
+ if (Count > 0) {
+ strcat (NewString, ", ");
+ }
+ strcat (NewString, "\"");
+ strcat (NewString, StringList->Strings[Count]);
+ strcat (NewString, "\"");
+ }
+ strcat (NewString, "]");
+
+ return NewString;
+}
+
+
+VOID
+PrintStringList (
+ IN STRING_LIST *StringList
+ )
+/*++
+
+Routine Description:
+
+ Prints out the string list
+
+Arguments:
+
+ StringList The string list to print
+
+Returns:
+
+ EFI_STATUS
+
+--*/
+{
+ CHAR8* String;
+ String = StringListToString (StringList);
+ if (String != NULL) {
+ printf ("%s", String);
+ free (String);
+ }
+}
+
+
diff --git a/BaseTools/Source/C/Common/StringFuncs.h b/BaseTools/Source/C/Common/StringFuncs.h
new file mode 100644
index 0000000000..2c764115e5
--- /dev/null
+++ b/BaseTools/Source/C/Common/StringFuncs.h
@@ -0,0 +1,257 @@
+/**
+
+Copyright (c) 2007 - 2008, Intel Corporation. All rights reserved.
+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.
+
+Module Name:
+
+ StringFuncs.h
+
+Abstract:
+
+ String routines implementation.
+
+**/
+
+#ifndef _EFI_STRING_FUNCS_H
+#define _EFI_STRING_FUNCS_H
+
+#include
+#include
+#include
+
+//
+// Common data structures
+//
+typedef struct {
+ UINTN Count;
+ //
+ // Actually this array can be 0 or more items (based on Count)
+ //
+ CHAR8* Strings[1];
+} STRING_LIST;
+
+
+//
+// Functions declarations
+//
+
+CHAR8*
+CloneString (
+ IN CHAR8 *String
+ )
+;
+/**
+
+Routine Description:
+
+ Allocates a new string and copies 'String' to clone it
+
+Arguments:
+
+ String The string to clone
+
+Returns:
+
+ CHAR8* - NULL if there are not enough resources
+
+**/
+
+
+EFI_STATUS
+StripInfDscStringInPlace (
+ IN CHAR8 *String
+ )
+;
+/**
+
+Routine Description:
+
+ Remove all comments, leading and trailing whitespace from the string.
+
+Arguments:
+
+ Strin The string to 'strip'
+
+Returns:
+
+ EFI_STATUS
+
+**/
+
+
+STRING_LIST*
+SplitStringByWhitespace (
+ IN CHAR8 *String
+ )
+;
+/**
+
+Routine Description:
+
+ Creates and returns a 'split' STRING_LIST by splitting the string
+ on whitespace boundaries.
+
+Arguments:
+
+ String The string to 'split'
+
+Returns:
+
+ EFI_STATUS
+
+**/
+
+
+STRING_LIST*
+NewStringList (
+ )
+;
+/**
+
+Routine Description:
+
+ Creates a new STRING_LIST with 0 strings.
+
+Returns:
+
+ STRING_LIST* - Null if there is not enough resources to create the object.
+
+**/
+
+
+EFI_STATUS
+AppendCopyOfStringToList (
+ IN OUT STRING_LIST **StringList,
+ IN CHAR8 *String
+ )
+;
+/**
+
+Routine Description:
+
+ Adds String to StringList. A new copy of String is made before it is
+ added to StringList.
+
+Returns:
+
+ EFI_STATUS
+
+**/
+
+
+EFI_STATUS
+RemoveLastStringFromList (
+ IN STRING_LIST *StringList
+ )
+;
+/**
+
+Routine Description:
+
+ Removes the last string from StringList and frees the memory associated
+ with it.
+
+Arguments:
+
+ StringList The string list to remove the string from
+
+Returns:
+
+ EFI_STATUS
+
+**/
+
+
+STRING_LIST*
+AllocateStringListStruct (
+ IN UINTN StringCount
+ )
+;
+/**
+
+Routine Description:
+
+ Allocates a STRING_LIST structure that can store StringCount strings.
+
+Arguments:
+
+ StringCount The number of strings that need to be stored
+
+Returns:
+
+ EFI_STATUS
+
+**/
+
+
+VOID
+FreeStringList (
+ IN STRING_LIST *StringList
+ )
+;
+/**
+
+Routine Description:
+
+ Frees all memory associated with StringList.
+
+Arguments:
+
+ StringList The string list to free
+
+Returns:
+
+ EFI_STATUS
+
+**/
+
+
+CHAR8*
+StringListToString (
+ IN STRING_LIST *StringList
+ )
+;
+/**
+
+Routine Description:
+
+ Generates a string that represents the STRING_LIST
+
+Arguments:
+
+ StringList The string list to convert to a string
+
+Returns:
+
+ CHAR8* - The string list represented with a single string. The returned
+ string must be freed by the caller.
+
+**/
+
+
+VOID
+PrintStringList (
+ IN STRING_LIST *StringList
+ )
+;
+/**
+
+Routine Description:
+
+ Prints out the string list
+
+Arguments:
+
+ StringList The string list to print
+
+**/
+
+
+#endif
diff --git a/BaseTools/Source/C/Common/TianoCompress.c b/BaseTools/Source/C/Common/TianoCompress.c
new file mode 100644
index 0000000000..a34f1d2a7d
--- /dev/null
+++ b/BaseTools/Source/C/Common/TianoCompress.c
@@ -0,0 +1,1753 @@
+/** @file
+
+Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.
+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.
+
+Module Name:
+
+ TianoCompress.c
+
+Abstract:
+
+ Compression routine. The compression algorithm is a mixture of
+ LZ77 and Huffman coding. LZ77 transforms the source data into a
+ sequence of Original Characters and Pointers to repeated strings.
+ This sequence is further divided into Blocks and Huffman codings
+ are applied to each Block.
+
+**/
+
+#include "Compress.h"
+
+//
+// Macro Definitions
+//
+#undef UINT8_MAX
+typedef INT32 NODE;
+#define UINT8_MAX 0xff
+#define UINT8_BIT 8
+#define THRESHOLD 3
+#define INIT_CRC 0
+#define WNDBIT 19
+#define WNDSIZ (1U << WNDBIT)
+#define MAXMATCH 256
+#define BLKSIZ (1U << 14) // 16 * 1024U
+#define PERC_FLAG 0x80000000U
+#define CODE_BIT 16
+#define NIL 0
+#define MAX_HASH_VAL (3 * WNDSIZ + (WNDSIZ / 512 + 1) * UINT8_MAX)
+#define HASH(p, c) ((p) + ((c) << (WNDBIT - 9)) + WNDSIZ * 2)
+#define CRCPOLY 0xA001
+#define UPDATE_CRC(c) mCrc = mCrcTable[(mCrc ^ (c)) & 0xFF] ^ (mCrc >> UINT8_BIT)
+
+//
+// C: the Char&Len Set; P: the Position Set; T: the exTra Set
+//
+#define NC (UINT8_MAX + MAXMATCH + 2 - THRESHOLD)
+#define CBIT 9
+#define NP (WNDBIT + 1)
+#define PBIT 5
+#define NT (CODE_BIT + 3)
+#define TBIT 5
+#if NT > NP
+#define NPT NT
+#else
+#define NPT NP
+#endif
+//
+// Function Prototypes
+//
+
+STATIC
+VOID
+PutDword(
+ IN UINT32 Data
+ );
+
+STATIC
+EFI_STATUS
+AllocateMemory (
+ VOID
+ );
+
+STATIC
+VOID
+FreeMemory (
+ VOID
+ );
+
+STATIC
+VOID
+InitSlide (
+ VOID
+ );
+
+STATIC
+NODE
+Child (
+ IN NODE NodeQ,
+ IN UINT8 CharC
+ );
+
+STATIC
+VOID
+MakeChild (
+ IN NODE NodeQ,
+ IN UINT8 CharC,
+ IN NODE NodeR
+ );
+
+STATIC
+VOID
+Split (
+ IN NODE Old
+ );
+
+STATIC
+VOID
+InsertNode (
+ VOID
+ );
+
+STATIC
+VOID
+DeleteNode (
+ VOID
+ );
+
+STATIC
+VOID
+GetNextMatch (
+ VOID
+ );
+
+STATIC
+EFI_STATUS
+Encode (
+ VOID
+ );
+
+STATIC
+VOID
+CountTFreq (
+ VOID
+ );
+
+STATIC
+VOID
+WritePTLen (
+ IN INT32 Number,
+ IN INT32 nbit,
+ IN INT32 Special
+ );
+
+STATIC
+VOID
+WriteCLen (
+ VOID
+ );
+
+STATIC
+VOID
+EncodeC (
+ IN INT32 Value
+ );
+
+STATIC
+VOID
+EncodeP (
+ IN UINT32 Value
+ );
+
+STATIC
+VOID
+SendBlock (
+ VOID
+ );
+
+STATIC
+VOID
+Output (
+ IN UINT32 c,
+ IN UINT32 p
+ );
+
+STATIC
+VOID
+HufEncodeStart (
+ VOID
+ );
+
+STATIC
+VOID
+HufEncodeEnd (
+ VOID
+ );
+
+STATIC
+VOID
+MakeCrcTable (
+ VOID
+ );
+
+STATIC
+VOID
+PutBits (
+ IN INT32 Number,
+ IN UINT32 Value
+ );
+
+STATIC
+INT32
+FreadCrc (
+ OUT UINT8 *Pointer,
+ IN INT32 Number
+ );
+
+STATIC
+VOID
+InitPutBits (
+ VOID
+ );
+
+STATIC
+VOID
+CountLen (
+ IN INT32 Index
+ );
+
+STATIC
+VOID
+MakeLen (
+ IN INT32 Root
+ );
+
+STATIC
+VOID
+DownHeap (
+ IN INT32 Index
+ );
+
+STATIC
+VOID
+MakeCode (
+ IN INT32 Number,
+ IN UINT8 Len[ ],
+ OUT UINT16 Code[]
+ );
+
+STATIC
+INT32
+MakeTree (
+ IN INT32 NParm,
+ IN UINT16 FreqParm[],
+ OUT UINT8 LenParm[ ],
+ OUT UINT16 CodeParm[]
+ );
+
+//
+// Global Variables
+//
+STATIC UINT8 *mSrc, *mDst, *mSrcUpperLimit, *mDstUpperLimit;
+
+STATIC UINT8 *mLevel, *mText, *mChildCount, *mBuf, mCLen[NC], mPTLen[NPT], *mLen;
+STATIC INT16 mHeap[NC + 1];
+STATIC INT32 mRemainder, mMatchLen, mBitCount, mHeapSize, mN;
+STATIC UINT32 mBufSiz = 0, mOutputPos, mOutputMask, mSubBitBuf, mCrc;
+STATIC UINT32 mCompSize, mOrigSize;
+
+STATIC UINT16 *mFreq, *mSortPtr, mLenCnt[17], mLeft[2 * NC - 1], mRight[2 * NC - 1], mCrcTable[UINT8_MAX + 1],
+ mCFreq[2 * NC - 1], mCCode[NC], mPFreq[2 * NP - 1], mPTCode[NPT], mTFreq[2 * NT - 1];
+
+STATIC NODE mPos, mMatchPos, mAvail, *mPosition, *mParent, *mPrev, *mNext = NULL;
+
+//
+// functions
+//
+EFI_STATUS
+TianoCompress (
+ IN UINT8 *SrcBuffer,
+ IN UINT32 SrcSize,
+ IN UINT8 *DstBuffer,
+ IN OUT UINT32 *DstSize
+ )
+/*++
+
+Routine Description:
+
+ The internal implementation of [Efi/Tiano]Compress().
+
+Arguments:
+
+ SrcBuffer - The buffer storing the source data
+ SrcSize - The size of source data
+ DstBuffer - The buffer to store the compressed data
+ DstSize - On input, the size of DstBuffer; On output,
+ the size of the actual compressed data.
+ Version - The version of de/compression algorithm.
+ Version 1 for UEFI 2.0 de/compression algorithm.
+ Version 2 for Tiano de/compression algorithm.
+
+Returns:
+
+ EFI_BUFFER_TOO_SMALL - The DstBuffer is too small. In this case,
+ DstSize contains the size needed.
+ EFI_SUCCESS - Compression is successful.
+ EFI_OUT_OF_RESOURCES - No resource to complete function.
+ EFI_INVALID_PARAMETER - Parameter supplied is wrong.
+
+--*/
+{
+ EFI_STATUS Status;
+
+ //
+ // Initializations
+ //
+ mBufSiz = 0;
+ mBuf = NULL;
+ mText = NULL;
+ mLevel = NULL;
+ mChildCount = NULL;
+ mPosition = NULL;
+ mParent = NULL;
+ mPrev = NULL;
+ mNext = NULL;
+
+ mSrc = SrcBuffer;
+ mSrcUpperLimit = mSrc + SrcSize;
+ mDst = DstBuffer;
+ mDstUpperLimit = mDst +*DstSize;
+
+ PutDword (0L);
+ PutDword (0L);
+
+ MakeCrcTable ();
+
+ mOrigSize = mCompSize = 0;
+ mCrc = INIT_CRC;
+
+ //
+ // Compress it
+ //
+ Status = Encode ();
+ if (EFI_ERROR (Status)) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ //
+ // Null terminate the compressed data
+ //
+ if (mDst < mDstUpperLimit) {
+ *mDst++ = 0;
+ }
+ //
+ // Fill in compressed size and original size
+ //
+ mDst = DstBuffer;
+ PutDword (mCompSize + 1);
+ PutDword (mOrigSize);
+
+ //
+ // Return
+ //
+ if (mCompSize + 1 + 8 > *DstSize) {
+ *DstSize = mCompSize + 1 + 8;
+ return EFI_BUFFER_TOO_SMALL;
+ } else {
+ *DstSize = mCompSize + 1 + 8;
+ return EFI_SUCCESS;
+ }
+
+}
+
+STATIC
+VOID
+PutDword (
+ IN UINT32 Data
+ )
+/*++
+
+Routine Description:
+
+ Put a dword to output stream
+
+Arguments:
+
+ Data - the dword to put
+
+Returns: (VOID)
+
+--*/
+{
+ if (mDst < mDstUpperLimit) {
+ *mDst++ = (UINT8) (((UINT8) (Data)) & 0xff);
+ }
+
+ if (mDst < mDstUpperLimit) {
+ *mDst++ = (UINT8) (((UINT8) (Data >> 0x08)) & 0xff);
+ }
+
+ if (mDst < mDstUpperLimit) {
+ *mDst++ = (UINT8) (((UINT8) (Data >> 0x10)) & 0xff);
+ }
+
+ if (mDst < mDstUpperLimit) {
+ *mDst++ = (UINT8) (((UINT8) (Data >> 0x18)) & 0xff);
+ }
+}
+
+STATIC
+EFI_STATUS
+AllocateMemory (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Allocate memory spaces for data structures used in compression process
+
+Argements:
+ VOID
+
+Returns:
+
+ EFI_SUCCESS - Memory is allocated successfully
+ EFI_OUT_OF_RESOURCES - Allocation fails
+
+--*/
+{
+ UINT32 Index;
+
+ mText = malloc (WNDSIZ * 2 + MAXMATCH);
+ for (Index = 0; Index < WNDSIZ * 2 + MAXMATCH; Index++) {
+ mText[Index] = 0;
+ }
+
+ mLevel = malloc ((WNDSIZ + UINT8_MAX + 1) * sizeof (*mLevel));
+ mChildCount = malloc ((WNDSIZ + UINT8_MAX + 1) * sizeof (*mChildCount));
+ mPosition = malloc ((WNDSIZ + UINT8_MAX + 1) * sizeof (*mPosition));
+ mParent = malloc (WNDSIZ * 2 * sizeof (*mParent));
+ mPrev = malloc (WNDSIZ * 2 * sizeof (*mPrev));
+ mNext = malloc ((MAX_HASH_VAL + 1) * sizeof (*mNext));
+
+ mBufSiz = BLKSIZ;
+ mBuf = malloc (mBufSiz);
+ while (mBuf == NULL) {
+ mBufSiz = (mBufSiz / 10U) * 9U;
+ if (mBufSiz < 4 * 1024U) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ mBuf = malloc (mBufSiz);
+ }
+
+ mBuf[0] = 0;
+
+ return EFI_SUCCESS;
+}
+
+VOID
+FreeMemory (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Called when compression is completed to free memory previously allocated.
+
+Arguments: (VOID)
+
+Returns: (VOID)
+
+--*/
+{
+ if (mText != NULL) {
+ free (mText);
+ }
+
+ if (mLevel != NULL) {
+ free (mLevel);
+ }
+
+ if (mChildCount != NULL) {
+ free (mChildCount);
+ }
+
+ if (mPosition != NULL) {
+ free (mPosition);
+ }
+
+ if (mParent != NULL) {
+ free (mParent);
+ }
+
+ if (mPrev != NULL) {
+ free (mPrev);
+ }
+
+ if (mNext != NULL) {
+ free (mNext);
+ }
+
+ if (mBuf != NULL) {
+ free (mBuf);
+ }
+
+ return ;
+}
+
+STATIC
+VOID
+InitSlide (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Initialize String Info Log data structures
+
+Arguments: (VOID)
+
+Returns: (VOID)
+
+--*/
+{
+ NODE Index;
+
+ for (Index = WNDSIZ; Index <= WNDSIZ + UINT8_MAX; Index++) {
+ mLevel[Index] = 1;
+ mPosition[Index] = NIL; /* sentinel */
+ }
+
+ for (Index = WNDSIZ; Index < WNDSIZ * 2; Index++) {
+ mParent[Index] = NIL;
+ }
+
+ mAvail = 1;
+ for (Index = 1; Index < WNDSIZ - 1; Index++) {
+ mNext[Index] = (NODE) (Index + 1);
+ }
+
+ mNext[WNDSIZ - 1] = NIL;
+ for (Index = WNDSIZ * 2; Index <= MAX_HASH_VAL; Index++) {
+ mNext[Index] = NIL;
+ }
+}
+
+STATIC
+NODE
+Child (
+ IN NODE NodeQ,
+ IN UINT8 CharC
+ )
+/*++
+
+Routine Description:
+
+ Find child node given the parent node and the edge character
+
+Arguments:
+
+ NodeQ - the parent node
+ CharC - the edge character
+
+Returns:
+
+ The child node (NIL if not found)
+
+--*/
+{
+ NODE NodeR;
+
+ NodeR = mNext[HASH (NodeQ, CharC)];
+ //
+ // sentinel
+ //
+ mParent[NIL] = NodeQ;
+ while (mParent[NodeR] != NodeQ) {
+ NodeR = mNext[NodeR];
+ }
+
+ return NodeR;
+}
+
+STATIC
+VOID
+MakeChild (
+ IN NODE Parent,
+ IN UINT8 CharC,
+ IN NODE Child
+ )
+/*++
+
+Routine Description:
+
+ Create a new child for a given parent node.
+
+Arguments:
+
+ Parent - the parent node
+ CharC - the edge character
+ Child - the child node
+
+Returns: (VOID)
+
+--*/
+{
+ NODE Node1;
+ NODE Node2;
+
+ Node1 = (NODE) HASH (Parent, CharC);
+ Node2 = mNext[Node1];
+ mNext[Node1] = Child;
+ mNext[Child] = Node2;
+ mPrev[Node2] = Child;
+ mPrev[Child] = Node1;
+ mParent[Child] = Parent;
+ mChildCount[Parent]++;
+}
+
+STATIC
+VOID
+Split (
+ NODE Old
+ )
+/*++
+
+Routine Description:
+
+ Split a node.
+
+Arguments:
+
+ Old - the node to split
+
+Returns: (VOID)
+
+--*/
+{
+ NODE New;
+ NODE TempNode;
+
+ New = mAvail;
+ mAvail = mNext[New];
+ mChildCount[New] = 0;
+ TempNode = mPrev[Old];
+ mPrev[New] = TempNode;
+ mNext[TempNode] = New;
+ TempNode = mNext[Old];
+ mNext[New] = TempNode;
+ mPrev[TempNode] = New;
+ mParent[New] = mParent[Old];
+ mLevel[New] = (UINT8) mMatchLen;
+ mPosition[New] = mPos;
+ MakeChild (New, mText[mMatchPos + mMatchLen], Old);
+ MakeChild (New, mText[mPos + mMatchLen], mPos);
+}
+
+STATIC
+VOID
+InsertNode (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Insert string info for current position into the String Info Log
+
+Arguments: (VOID)
+
+Returns: (VOID)
+
+--*/
+{
+ NODE NodeQ;
+ NODE NodeR;
+ NODE Index2;
+ NODE NodeT;
+ UINT8 CharC;
+ UINT8 *t1;
+ UINT8 *t2;
+
+ if (mMatchLen >= 4) {
+ //
+ // We have just got a long match, the target tree
+ // can be located by MatchPos + 1. Travese the tree
+ // from bottom up to get to a proper starting point.
+ // The usage of PERC_FLAG ensures proper node deletion
+ // in DeleteNode() later.
+ //
+ mMatchLen--;
+ NodeR = (NODE) ((mMatchPos + 1) | WNDSIZ);
+ NodeQ = mParent[NodeR];
+ while (NodeQ == NIL) {
+ NodeR = mNext[NodeR];
+ NodeQ = mParent[NodeR];
+ }
+
+ while (mLevel[NodeQ] >= mMatchLen) {
+ NodeR = NodeQ;
+ NodeQ = mParent[NodeQ];
+ }
+
+ NodeT = NodeQ;
+ while (mPosition[NodeT] < 0) {
+ mPosition[NodeT] = mPos;
+ NodeT = mParent[NodeT];
+ }
+
+ if (NodeT < WNDSIZ) {
+ mPosition[NodeT] = (NODE) (mPos | (UINT32) PERC_FLAG);
+ }
+ } else {
+ //
+ // Locate the target tree
+ //
+ NodeQ = (NODE) (mText[mPos] + WNDSIZ);
+ CharC = mText[mPos + 1];
+ NodeR = Child (NodeQ, CharC);
+ if (NodeR == NIL) {
+ MakeChild (NodeQ, CharC, mPos);
+ mMatchLen = 1;
+ return ;
+ }
+
+ mMatchLen = 2;
+ }
+ //
+ // Traverse down the tree to find a match.
+ // Update Position value along the route.
+ // Node split or creation is involved.
+ //
+ for (;;) {
+ if (NodeR >= WNDSIZ) {
+ Index2 = MAXMATCH;
+ mMatchPos = NodeR;
+ } else {
+ Index2 = mLevel[NodeR];
+ mMatchPos = (NODE) (mPosition[NodeR] & (UINT32)~PERC_FLAG);
+ }
+
+ if (mMatchPos >= mPos) {
+ mMatchPos -= WNDSIZ;
+ }
+
+ t1 = &mText[mPos + mMatchLen];
+ t2 = &mText[mMatchPos + mMatchLen];
+ while (mMatchLen < Index2) {
+ if (*t1 != *t2) {
+ Split (NodeR);
+ return ;
+ }
+
+ mMatchLen++;
+ t1++;
+ t2++;
+ }
+
+ if (mMatchLen >= MAXMATCH) {
+ break;
+ }
+
+ mPosition[NodeR] = mPos;
+ NodeQ = NodeR;
+ NodeR = Child (NodeQ, *t1);
+ if (NodeR == NIL) {
+ MakeChild (NodeQ, *t1, mPos);
+ return ;
+ }
+
+ mMatchLen++;
+ }
+
+ NodeT = mPrev[NodeR];
+ mPrev[mPos] = NodeT;
+ mNext[NodeT] = mPos;
+ NodeT = mNext[NodeR];
+ mNext[mPos] = NodeT;
+ mPrev[NodeT] = mPos;
+ mParent[mPos] = NodeQ;
+ mParent[NodeR] = NIL;
+
+ //
+ // Special usage of 'next'
+ //
+ mNext[NodeR] = mPos;
+
+}
+
+STATIC
+VOID
+DeleteNode (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Delete outdated string info. (The Usage of PERC_FLAG
+ ensures a clean deletion)
+
+Arguments: (VOID)
+
+Returns: (VOID)
+
+--*/
+{
+ NODE NodeQ;
+ NODE NodeR;
+ NODE NodeS;
+ NODE NodeT;
+ NODE NodeU;
+
+ if (mParent[mPos] == NIL) {
+ return ;
+ }
+
+ NodeR = mPrev[mPos];
+ NodeS = mNext[mPos];
+ mNext[NodeR] = NodeS;
+ mPrev[NodeS] = NodeR;
+ NodeR = mParent[mPos];
+ mParent[mPos] = NIL;
+ if (NodeR >= WNDSIZ) {
+ return ;
+ }
+
+ mChildCount[NodeR]--;
+ if (mChildCount[NodeR] > 1) {
+ return ;
+ }
+
+ NodeT = (NODE) (mPosition[NodeR] & (UINT32)~PERC_FLAG);
+ if (NodeT >= mPos) {
+ NodeT -= WNDSIZ;
+ }
+
+ NodeS = NodeT;
+ NodeQ = mParent[NodeR];
+ NodeU = mPosition[NodeQ];
+ while (NodeU & (UINT32) PERC_FLAG) {
+ NodeU &= (UINT32)~PERC_FLAG;
+ if (NodeU >= mPos) {
+ NodeU -= WNDSIZ;
+ }
+
+ if (NodeU > NodeS) {
+ NodeS = NodeU;
+ }
+
+ mPosition[NodeQ] = (NODE) (NodeS | WNDSIZ);
+ NodeQ = mParent[NodeQ];
+ NodeU = mPosition[NodeQ];
+ }
+
+ if (NodeQ < WNDSIZ) {
+ if (NodeU >= mPos) {
+ NodeU -= WNDSIZ;
+ }
+
+ if (NodeU > NodeS) {
+ NodeS = NodeU;
+ }
+
+ mPosition[NodeQ] = (NODE) (NodeS | WNDSIZ | (UINT32) PERC_FLAG);
+ }
+
+ NodeS = Child (NodeR, mText[NodeT + mLevel[NodeR]]);
+ NodeT = mPrev[NodeS];
+ NodeU = mNext[NodeS];
+ mNext[NodeT] = NodeU;
+ mPrev[NodeU] = NodeT;
+ NodeT = mPrev[NodeR];
+ mNext[NodeT] = NodeS;
+ mPrev[NodeS] = NodeT;
+ NodeT = mNext[NodeR];
+ mPrev[NodeT] = NodeS;
+ mNext[NodeS] = NodeT;
+ mParent[NodeS] = mParent[NodeR];
+ mParent[NodeR] = NIL;
+ mNext[NodeR] = mAvail;
+ mAvail = NodeR;
+}
+
+STATIC
+VOID
+GetNextMatch (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Advance the current position (read in new data if needed).
+ Delete outdated string info. Find a match string for current position.
+
+Arguments: (VOID)
+
+Returns: (VOID)
+
+--*/
+{
+ INT32 Number;
+
+ mRemainder--;
+ mPos++;
+ if (mPos == WNDSIZ * 2) {
+ memmove (&mText[0], &mText[WNDSIZ], WNDSIZ + MAXMATCH);
+ Number = FreadCrc (&mText[WNDSIZ + MAXMATCH], WNDSIZ);
+ mRemainder += Number;
+ mPos = WNDSIZ;
+ }
+
+ DeleteNode ();
+ InsertNode ();
+}
+
+STATIC
+EFI_STATUS
+Encode (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ The main controlling routine for compression process.
+
+Arguments: (VOID)
+
+Returns:
+
+ EFI_SUCCESS - The compression is successful
+ EFI_OUT_0F_RESOURCES - Not enough memory for compression process
+
+--*/
+{
+ EFI_STATUS Status;
+ INT32 LastMatchLen;
+ NODE LastMatchPos;
+
+ Status = AllocateMemory ();
+ if (EFI_ERROR (Status)) {
+ FreeMemory ();
+ return Status;
+ }
+
+ InitSlide ();
+
+ HufEncodeStart ();
+
+ mRemainder = FreadCrc (&mText[WNDSIZ], WNDSIZ + MAXMATCH);
+
+ mMatchLen = 0;
+ mPos = WNDSIZ;
+ InsertNode ();
+ if (mMatchLen > mRemainder) {
+ mMatchLen = mRemainder;
+ }
+
+ while (mRemainder > 0) {
+ LastMatchLen = mMatchLen;
+ LastMatchPos = mMatchPos;
+ GetNextMatch ();
+ if (mMatchLen > mRemainder) {
+ mMatchLen = mRemainder;
+ }
+
+ if (mMatchLen > LastMatchLen || LastMatchLen < THRESHOLD) {
+ //
+ // Not enough benefits are gained by outputting a pointer,
+ // so just output the original character
+ //
+ Output (mText[mPos - 1], 0);
+
+ } else {
+
+ if (LastMatchLen == THRESHOLD) {
+ if (((mPos - LastMatchPos - 2) & (WNDSIZ - 1)) > (1U << 11)) {
+ Output (mText[mPos - 1], 0);
+ continue;
+ }
+ }
+ //
+ // Outputting a pointer is beneficial enough, do it.
+ //
+ Output (
+ LastMatchLen + (UINT8_MAX + 1 - THRESHOLD),
+ (mPos - LastMatchPos - 2) & (WNDSIZ - 1)
+ );
+ LastMatchLen--;
+ while (LastMatchLen > 0) {
+ GetNextMatch ();
+ LastMatchLen--;
+ }
+
+ if (mMatchLen > mRemainder) {
+ mMatchLen = mRemainder;
+ }
+ }
+ }
+
+ HufEncodeEnd ();
+ FreeMemory ();
+ return EFI_SUCCESS;
+}
+
+STATIC
+VOID
+CountTFreq (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Count the frequencies for the Extra Set
+
+Arguments: (VOID)
+
+Returns: (VOID)
+
+--*/
+{
+ INT32 Index;
+ INT32 Index3;
+ INT32 Number;
+ INT32 Count;
+
+ for (Index = 0; Index < NT; Index++) {
+ mTFreq[Index] = 0;
+ }
+
+ Number = NC;
+ while (Number > 0 && mCLen[Number - 1] == 0) {
+ Number--;
+ }
+
+ Index = 0;
+ while (Index < Number) {
+ Index3 = mCLen[Index++];
+ if (Index3 == 0) {
+ Count = 1;
+ while (Index < Number && mCLen[Index] == 0) {
+ Index++;
+ Count++;
+ }
+
+ if (Count <= 2) {
+ mTFreq[0] = (UINT16) (mTFreq[0] + Count);
+ } else if (Count <= 18) {
+ mTFreq[1]++;
+ } else if (Count == 19) {
+ mTFreq[0]++;
+ mTFreq[1]++;
+ } else {
+ mTFreq[2]++;
+ }
+ } else {
+ mTFreq[Index3 + 2]++;
+ }
+ }
+}
+
+STATIC
+VOID
+WritePTLen (
+ IN INT32 Number,
+ IN INT32 nbit,
+ IN INT32 Special
+ )
+/*++
+
+Routine Description:
+
+ Outputs the code length array for the Extra Set or the Position Set.
+
+Arguments:
+
+ Number - the number of symbols
+ nbit - the number of bits needed to represent 'n'
+ Special - the special symbol that needs to be take care of
+
+Returns: (VOID)
+
+--*/
+{
+ INT32 Index;
+ INT32 Index3;
+
+ while (Number > 0 && mPTLen[Number - 1] == 0) {
+ Number--;
+ }
+
+ PutBits (nbit, Number);
+ Index = 0;
+ while (Index < Number) {
+ Index3 = mPTLen[Index++];
+ if (Index3 <= 6) {
+ PutBits (3, Index3);
+ } else {
+ PutBits (Index3 - 3, (1U << (Index3 - 3)) - 2);
+ }
+
+ if (Index == Special) {
+ while (Index < 6 && mPTLen[Index] == 0) {
+ Index++;
+ }
+
+ PutBits (2, (Index - 3) & 3);
+ }
+ }
+}
+
+STATIC
+VOID
+WriteCLen (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Outputs the code length array for Char&Length Set
+
+Arguments: (VOID)
+
+Returns: (VOID)
+
+--*/
+{
+ INT32 Index;
+ INT32 Index3;
+ INT32 Number;
+ INT32 Count;
+
+ Number = NC;
+ while (Number > 0 && mCLen[Number - 1] == 0) {
+ Number--;
+ }
+
+ PutBits (CBIT, Number);
+ Index = 0;
+ while (Index < Number) {
+ Index3 = mCLen[Index++];
+ if (Index3 == 0) {
+ Count = 1;
+ while (Index < Number && mCLen[Index] == 0) {
+ Index++;
+ Count++;
+ }
+
+ if (Count <= 2) {
+ for (Index3 = 0; Index3 < Count; Index3++) {
+ PutBits (mPTLen[0], mPTCode[0]);
+ }
+ } else if (Count <= 18) {
+ PutBits (mPTLen[1], mPTCode[1]);
+ PutBits (4, Count - 3);
+ } else if (Count == 19) {
+ PutBits (mPTLen[0], mPTCode[0]);
+ PutBits (mPTLen[1], mPTCode[1]);
+ PutBits (4, 15);
+ } else {
+ PutBits (mPTLen[2], mPTCode[2]);
+ PutBits (CBIT, Count - 20);
+ }
+ } else {
+ PutBits (mPTLen[Index3 + 2], mPTCode[Index3 + 2]);
+ }
+ }
+}
+
+STATIC
+VOID
+EncodeC (
+ IN INT32 Value
+ )
+{
+ PutBits (mCLen[Value], mCCode[Value]);
+}
+
+STATIC
+VOID
+EncodeP (
+ IN UINT32 Value
+ )
+{
+ UINT32 Index;
+ UINT32 NodeQ;
+
+ Index = 0;
+ NodeQ = Value;
+ while (NodeQ) {
+ NodeQ >>= 1;
+ Index++;
+ }
+
+ PutBits (mPTLen[Index], mPTCode[Index]);
+ if (Index > 1) {
+ PutBits (Index - 1, Value & (0xFFFFFFFFU >> (32 - Index + 1)));
+ }
+}
+
+STATIC
+VOID
+SendBlock (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Huffman code the block and output it.
+
+Arguments:
+ (VOID)
+
+Returns:
+ (VOID)
+
+--*/
+{
+ UINT32 Index;
+ UINT32 Index2;
+ UINT32 Index3;
+ UINT32 Flags;
+ UINT32 Root;
+ UINT32 Pos;
+ UINT32 Size;
+ Flags = 0;
+
+ Root = MakeTree (NC, mCFreq, mCLen, mCCode);
+ Size = mCFreq[Root];
+ PutBits (16, Size);
+ if (Root >= NC) {
+ CountTFreq ();
+ Root = MakeTree (NT, mTFreq, mPTLen, mPTCode);
+ if (Root >= NT) {
+ WritePTLen (NT, TBIT, 3);
+ } else {
+ PutBits (TBIT, 0);
+ PutBits (TBIT, Root);
+ }
+
+ WriteCLen ();
+ } else {
+ PutBits (TBIT, 0);
+ PutBits (TBIT, 0);
+ PutBits (CBIT, 0);
+ PutBits (CBIT, Root);
+ }
+
+ Root = MakeTree (NP, mPFreq, mPTLen, mPTCode);
+ if (Root >= NP) {
+ WritePTLen (NP, PBIT, -1);
+ } else {
+ PutBits (PBIT, 0);
+ PutBits (PBIT, Root);
+ }
+
+ Pos = 0;
+ for (Index = 0; Index < Size; Index++) {
+ if (Index % UINT8_BIT == 0) {
+ Flags = mBuf[Pos++];
+ } else {
+ Flags <<= 1;
+ }
+
+ if (Flags & (1U << (UINT8_BIT - 1))) {
+ EncodeC (mBuf[Pos++] + (1U << UINT8_BIT));
+ Index3 = mBuf[Pos++];
+ for (Index2 = 0; Index2 < 3; Index2++) {
+ Index3 <<= UINT8_BIT;
+ Index3 += mBuf[Pos++];
+ }
+
+ EncodeP (Index3);
+ } else {
+ EncodeC (mBuf[Pos++]);
+ }
+ }
+
+ for (Index = 0; Index < NC; Index++) {
+ mCFreq[Index] = 0;
+ }
+
+ for (Index = 0; Index < NP; Index++) {
+ mPFreq[Index] = 0;
+ }
+}
+
+STATIC
+VOID
+Output (
+ IN UINT32 CharC,
+ IN UINT32 Pos
+ )
+/*++
+
+Routine Description:
+
+ Outputs an Original Character or a Pointer
+
+Arguments:
+
+ CharC - The original character or the 'String Length' element of a Pointer
+ Pos - The 'Position' field of a Pointer
+
+Returns: (VOID)
+
+--*/
+{
+ STATIC UINT32 CPos;
+
+ if ((mOutputMask >>= 1) == 0) {
+ mOutputMask = 1U << (UINT8_BIT - 1);
+ //
+ // Check the buffer overflow per outputing UINT8_BIT symbols
+ // which is an Original Character or a Pointer. The biggest
+ // symbol is a Pointer which occupies 5 bytes.
+ //
+ if (mOutputPos >= mBufSiz - 5 * UINT8_BIT) {
+ SendBlock ();
+ mOutputPos = 0;
+ }
+
+ CPos = mOutputPos++;
+ mBuf[CPos] = 0;
+ }
+
+ mBuf[mOutputPos++] = (UINT8) CharC;
+ mCFreq[CharC]++;
+ if (CharC >= (1U << UINT8_BIT)) {
+ mBuf[CPos] |= mOutputMask;
+ mBuf[mOutputPos++] = (UINT8) (Pos >> 24);
+ mBuf[mOutputPos++] = (UINT8) (Pos >> 16);
+ mBuf[mOutputPos++] = (UINT8) (Pos >> (UINT8_BIT));
+ mBuf[mOutputPos++] = (UINT8) Pos;
+ CharC = 0;
+ while (Pos) {
+ Pos >>= 1;
+ CharC++;
+ }
+
+ mPFreq[CharC]++;
+ }
+}
+
+STATIC
+VOID
+HufEncodeStart (
+ VOID
+ )
+{
+ INT32 Index;
+
+ for (Index = 0; Index < NC; Index++) {
+ mCFreq[Index] = 0;
+ }
+
+ for (Index = 0; Index < NP; Index++) {
+ mPFreq[Index] = 0;
+ }
+
+ mOutputPos = mOutputMask = 0;
+ InitPutBits ();
+ return ;
+}
+
+STATIC
+VOID
+HufEncodeEnd (
+ VOID
+ )
+{
+ SendBlock ();
+
+ //
+ // Flush remaining bits
+ //
+ PutBits (UINT8_BIT - 1, 0);
+
+ return ;
+}
+
+STATIC
+VOID
+MakeCrcTable (
+ VOID
+ )
+{
+ UINT32 Index;
+ UINT32 Index2;
+ UINT32 Temp;
+
+ for (Index = 0; Index <= UINT8_MAX; Index++) {
+ Temp = Index;
+ for (Index2 = 0; Index2 < UINT8_BIT; Index2++) {
+ if (Temp & 1) {
+ Temp = (Temp >> 1) ^ CRCPOLY;
+ } else {
+ Temp >>= 1;
+ }
+ }
+
+ mCrcTable[Index] = (UINT16) Temp;
+ }
+}
+
+STATIC
+VOID
+PutBits (
+ IN INT32 Number,
+ IN UINT32 Value
+ )
+/*++
+
+Routine Description:
+
+ Outputs rightmost n bits of x
+
+Arguments:
+
+ Number - the rightmost n bits of the data is used
+ x - the data
+
+Returns: (VOID)
+
+--*/
+{
+ UINT8 Temp;
+
+ while (Number >= mBitCount) {
+ //
+ // Number -= mBitCount should never equal to 32
+ //
+ Temp = (UINT8) (mSubBitBuf | (Value >> (Number -= mBitCount)));
+ if (mDst < mDstUpperLimit) {
+ *mDst++ = Temp;
+ }
+
+ mCompSize++;
+ mSubBitBuf = 0;
+ mBitCount = UINT8_BIT;
+ }
+
+ mSubBitBuf |= Value << (mBitCount -= Number);
+}
+
+STATIC
+INT32
+FreadCrc (
+ OUT UINT8 *Pointer,
+ IN INT32 Number
+ )
+/*++
+
+Routine Description:
+
+ Read in source data
+
+Arguments:
+
+ Pointer - the buffer to hold the data
+ Number - number of bytes to read
+
+Returns:
+
+ number of bytes actually read
+
+--*/
+{
+ INT32 Index;
+
+ for (Index = 0; mSrc < mSrcUpperLimit && Index < Number; Index++) {
+ *Pointer++ = *mSrc++;
+ }
+
+ Number = Index;
+
+ Pointer -= Number;
+ mOrigSize += Number;
+ Index--;
+ while (Index >= 0) {
+ UPDATE_CRC (*Pointer++);
+ Index--;
+ }
+
+ return Number;
+}
+
+STATIC
+VOID
+InitPutBits (
+ VOID
+ )
+{
+ mBitCount = UINT8_BIT;
+ mSubBitBuf = 0;
+}
+
+STATIC
+VOID
+CountLen (
+ IN INT32 Index
+ )
+/*++
+
+Routine Description:
+
+ Count the number of each code length for a Huffman tree.
+
+Arguments:
+
+ Index - the top node
+
+Returns: (VOID)
+
+--*/
+{
+ STATIC INT32 Depth = 0;
+
+ if (Index < mN) {
+ mLenCnt[(Depth < 16) ? Depth : 16]++;
+ } else {
+ Depth++;
+ CountLen (mLeft[Index]);
+ CountLen (mRight[Index]);
+ Depth--;
+ }
+}
+
+STATIC
+VOID
+MakeLen (
+ IN INT32 Root
+ )
+/*++
+
+Routine Description:
+
+ Create code length array for a Huffman tree
+
+Arguments:
+
+ Root - the root of the tree
+
+Returns:
+
+ VOID
+
+--*/
+{
+ INT32 Index;
+ INT32 Index3;
+ UINT32 Cum;
+
+ for (Index = 0; Index <= 16; Index++) {
+ mLenCnt[Index] = 0;
+ }
+
+ CountLen (Root);
+
+ //
+ // Adjust the length count array so that
+ // no code will be generated longer than its designated length
+ //
+ Cum = 0;
+ for (Index = 16; Index > 0; Index--) {
+ Cum += mLenCnt[Index] << (16 - Index);
+ }
+
+ while (Cum != (1U << 16)) {
+ mLenCnt[16]--;
+ for (Index = 15; Index > 0; Index--) {
+ if (mLenCnt[Index] != 0) {
+ mLenCnt[Index]--;
+ mLenCnt[Index + 1] += 2;
+ break;
+ }
+ }
+
+ Cum--;
+ }
+
+ for (Index = 16; Index > 0; Index--) {
+ Index3 = mLenCnt[Index];
+ Index3--;
+ while (Index3 >= 0) {
+ mLen[*mSortPtr++] = (UINT8) Index;
+ Index3--;
+ }
+ }
+}
+
+STATIC
+VOID
+DownHeap (
+ IN INT32 Index
+ )
+{
+ INT32 Index2;
+ INT32 Index3;
+
+ //
+ // priority queue: send Index-th entry down heap
+ //
+ Index3 = mHeap[Index];
+ Index2 = 2 * Index;
+ while (Index2 <= mHeapSize) {
+ if (Index2 < mHeapSize && mFreq[mHeap[Index2]] > mFreq[mHeap[Index2 + 1]]) {
+ Index2++;
+ }
+
+ if (mFreq[Index3] <= mFreq[mHeap[Index2]]) {
+ break;
+ }
+
+ mHeap[Index] = mHeap[Index2];
+ Index = Index2;
+ Index2 = 2 * Index;
+ }
+
+ mHeap[Index] = (INT16) Index3;
+}
+
+STATIC
+VOID
+MakeCode (
+ IN INT32 Number,
+ IN UINT8 Len[ ],
+ OUT UINT16 Code[]
+ )
+/*++
+
+Routine Description:
+
+ Assign code to each symbol based on the code length array
+
+Arguments:
+
+ Number - number of symbols
+ Len - the code length array
+ Code - stores codes for each symbol
+
+Returns: (VOID)
+
+--*/
+{
+ INT32 Index;
+ UINT16 Start[18];
+
+ Start[1] = 0;
+ for (Index = 1; Index <= 16; Index++) {
+ Start[Index + 1] = (UINT16) ((Start[Index] + mLenCnt[Index]) << 1);
+ }
+
+ for (Index = 0; Index < Number; Index++) {
+ Code[Index] = Start[Len[Index]]++;
+ }
+}
+
+STATIC
+INT32
+MakeTree (
+ IN INT32 NParm,
+ IN UINT16 FreqParm[],
+ OUT UINT8 LenParm[ ],
+ OUT UINT16 CodeParm[]
+ )
+/*++
+
+Routine Description:
+
+ Generates Huffman codes given a frequency distribution of symbols
+
+Arguments:
+
+ NParm - number of symbols
+ FreqParm - frequency of each symbol
+ LenParm - code length for each symbol
+ CodeParm - code for each symbol
+
+Returns:
+
+ Root of the Huffman tree.
+
+--*/
+{
+ INT32 Index;
+ INT32 Index2;
+ INT32 Index3;
+ INT32 Avail;
+
+ //
+ // make tree, calculate len[], return root
+ //
+ mN = NParm;
+ mFreq = FreqParm;
+ mLen = LenParm;
+ Avail = mN;
+ mHeapSize = 0;
+ mHeap[1] = 0;
+ for (Index = 0; Index < mN; Index++) {
+ mLen[Index] = 0;
+ if (mFreq[Index]) {
+ mHeapSize++;
+ mHeap[mHeapSize] = (INT16) Index;
+ }
+ }
+
+ if (mHeapSize < 2) {
+ CodeParm[mHeap[1]] = 0;
+ return mHeap[1];
+ }
+
+ for (Index = mHeapSize / 2; Index >= 1; Index--) {
+ //
+ // make priority queue
+ //
+ DownHeap (Index);
+ }
+
+ mSortPtr = CodeParm;
+ do {
+ Index = mHeap[1];
+ if (Index < mN) {
+ *mSortPtr++ = (UINT16) Index;
+ }
+
+ mHeap[1] = mHeap[mHeapSize--];
+ DownHeap (1);
+ Index2 = mHeap[1];
+ if (Index2 < mN) {
+ *mSortPtr++ = (UINT16) Index2;
+ }
+
+ Index3 = Avail++;
+ mFreq[Index3] = (UINT16) (mFreq[Index] + mFreq[Index2]);
+ mHeap[1] = (INT16) Index3;
+ DownHeap (1);
+ mLeft[Index3] = (UINT16) Index;
+ mRight[Index3] = (UINT16) Index2;
+ } while (mHeapSize > 1);
+
+ mSortPtr = CodeParm;
+ MakeLen (Index3);
+ MakeCode (NParm, LenParm, CodeParm);
+
+ //
+ // return root
+ //
+ return Index3;
+}
diff --git a/BaseTools/Source/C/Common/WinNtInclude.h b/BaseTools/Source/C/Common/WinNtInclude.h
new file mode 100644
index 0000000000..bd33e3dd2a
--- /dev/null
+++ b/BaseTools/Source/C/Common/WinNtInclude.h
@@ -0,0 +1,73 @@
+/** @file
+
+Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.
+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.
+
+Module Name:
+ WinNtInclude.h
+
+Abstract:
+ Include file for the WinNt Library
+
+**/
+
+#ifndef __WIN_NT_INCLUDE_H__
+#define __WIN_NT_INCLUDE_H__
+
+#define GUID _WINNT_DUP_GUID_____
+#define _LIST_ENTRY _WINNT_DUP_LIST_ENTRY_FORWARD
+#define LIST_ENTRY _WINNT_DUP_LIST_ENTRY
+#define InterlockedIncrement _WINNT_DUP_InterlockedIncrement
+#define InterlockedDecrement _WINNT_DUP_InterlockedDecrement
+#define InterlockedCompareExchange64 _WINNT_DUP_InterlockedCompareExchange64
+#undef UNALIGNED
+#undef CONST
+#undef VOID
+
+#ifndef __GNUC__
+#include "windows.h"
+
+//
+// Win32 include files do not compile clean with /W4, so we use the warning
+// pragma to suppress the warnings for Win32 only. This way our code can stil
+// compile at /W4 (highest warning level) with /WX (warnings cause build
+// errors).
+//
+#pragma warning(disable : 4115)
+#pragma warning(disable : 4201)
+#pragma warning(disable : 4214)
+#pragma warning(disable : 4028)
+#pragma warning(disable : 4133)
+
+//
+// Set the warnings back on as the EFI code must be /W4.
+//
+#pragma warning(default : 4115)
+#pragma warning(default : 4201)
+#pragma warning(default : 4214)
+
+#endif
+
+#undef GUID
+#undef _LIST_ENTRY
+#undef LIST_ENTRY
+#undef InterlockedIncrement
+#undef InterlockedDecrement
+#undef InterlockedCompareExchange64
+#undef InterlockedCompareExchangePointer
+
+#define VOID void
+
+//
+// Prevent collisions with Windows API name macros that deal with Unicode/Not issues
+//
+#undef LoadImage
+#undef CreateEvent
+
+#endif
diff --git a/BaseTools/Source/C/EfiLdrImage/EfiLdrImage.c b/BaseTools/Source/C/EfiLdrImage/EfiLdrImage.c
new file mode 100644
index 0000000000..a92f76dbb0
--- /dev/null
+++ b/BaseTools/Source/C/EfiLdrImage/EfiLdrImage.c
@@ -0,0 +1,329 @@
+/** @file
+
+Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
+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.
+
+Module Name:
+
+ efildrimage.c
+
+Abstract:
+
+ Creates and EFILDR image.
+ This tool combines several PE Image files together using following format denoted as EBNF:
+ FILE := EFILDR_HEADER
+ EFILDR_IMAGE +
+ +
+ The order of EFILDR_IMAGE is same as the order of placing PeImageFileContent.
+
+Revision History
+
+**/
+
+
+#include
+#include
+#include
+#include "ParseInf.h"
+#include "CommonLib.h"
+#include "EfiUtilityMsgs.h"
+
+#define MAX_PE_IMAGES 63
+#define FILE_TYPE_FIXED_LOADER 0
+#define FILE_TYPE_RELOCATABLE_PE_IMAGE 1
+
+typedef struct {
+ UINT32 CheckSum;
+ UINT32 Offset;
+ UINT32 Length;
+ UINT8 FileName[52];
+} EFILDR_IMAGE;
+
+typedef struct {
+ UINT32 Signature;
+ UINT32 HeaderCheckSum;
+ UINT32 FileLength;
+ UINT32 NumberOfImages;
+} EFILDR_HEADER;
+
+//
+// Utility Name
+//
+#define UTILITY_NAME "EfiLdrImage"
+
+//
+// Utility version information
+//
+#define UTILITY_MAJOR_VERSION 0
+#define UTILITY_MINOR_VERSION 1
+
+void
+Version (
+ void
+ )
+/*++
+
+Routine Description:
+
+ Displays the standard utility information to SDTOUT
+
+Arguments:
+
+ None
+
+Returns:
+
+ None
+
+--*/
+{
+ printf ("%s v%d.%d -Utility to break a file into two pieces at the request offset.\n", UTILITY_NAME, UTILITY_MAJOR_VERSION, UTILITY_MINOR_VERSION);
+ printf ("Copyright (c) 1999-2010 Intel Corporation. All rights reserved.\n");
+}
+
+VOID
+Usage (
+ VOID
+ )
+{
+ printf ("Usage: EfiLdrImage -o OutImage LoaderImage PeImage1 PeImage2 ... PeImageN\n");
+ exit (1);
+}
+
+EFI_STATUS
+CountVerboseLevel (
+ IN CONST CHAR8* VerboseLevelString,
+ IN CONST UINT64 Length,
+ OUT UINT64 *ReturnValue
+)
+{
+ UINT64 i = 0;
+ for (;i < Length; ++i) {
+ if (VerboseLevelString[i] != 'v' && VerboseLevelString[i] != 'V') {
+ return EFI_ABORTED;
+ }
+ ++(*ReturnValue);
+ }
+
+ return EFI_SUCCESS;
+}
+
+UINT64
+FCopyFile (
+ FILE *in,
+ FILE *out
+ )
+/*++
+Routine Description:
+ Write all the content of input file to output file.
+
+Arguments:
+ in - input file pointer
+ out - output file pointer
+
+Return:
+ UINT64 : file size of input file
+--*/
+{
+ UINT32 filesize, offset, length;
+ CHAR8 Buffer[8*1024];
+
+ fseek (in, 0, SEEK_END);
+ filesize = ftell(in);
+
+ fseek (in, 0, SEEK_SET);
+
+ offset = 0;
+ while (offset < filesize) {
+ length = sizeof(Buffer);
+ if (filesize-offset < length) {
+ length = filesize-offset;
+ }
+
+ fread (Buffer, length, 1, in);
+ fwrite (Buffer, length, 1, out);
+ offset += length;
+ }
+
+ return filesize;
+}
+
+
+int
+main (
+ int argc,
+ char *argv[]
+ )
+/*++
+
+Routine Description:
+
+
+Arguments:
+
+
+Returns:
+
+
+--*/
+{
+ UINT64 i;
+ UINT64 filesize;
+ FILE *fpIn, *fpOut;
+ EFILDR_HEADER EfiLdrHeader;
+ EFILDR_IMAGE EfiLdrImage[MAX_PE_IMAGES];
+ CHAR8* OutputFileName = NULL;
+ CHAR8* InputFileNames[MAX_PE_IMAGES + 1];
+ UINT8 InputFileCount = 0;
+ BOOLEAN QuietFlag = FALSE;
+ UINT64 DebugLevel = 0;
+ UINT64 VerboseLevel = 0;
+ EFI_STATUS Status = EFI_SUCCESS;
+
+ SetUtilityName (UTILITY_NAME);
+
+ if (argc == 1) {
+ Usage();
+ return STATUS_ERROR;
+ }
+
+ argc --;
+ argv ++;
+
+ if ((stricmp (argv[0], "-h") == 0) || (stricmp (argv[0], "--help") == 0)) {
+ Usage();
+ return STATUS_SUCCESS;
+ }
+
+ if (stricmp (argv[0], "--version") == 0) {
+ Version();
+ return STATUS_SUCCESS;
+ }
+
+ while (argc > 0) {
+
+ if ((stricmp (argv[0], "-o") == 0) || (stricmp (argv[0], "--output") == 0)) {
+ OutputFileName = argv[1];
+ if (OutputFileName == NULL) {
+ Error (NULL, 0, 1003, "Invalid option value", "Output file can't be null");
+ return STATUS_ERROR;
+ }
+ argc -= 2;
+ argv += 2;
+ continue;
+ }
+
+ if ((stricmp (argv[0], "-q") == 0) || (stricmp (argv[0], "--quiet") == 0)) {
+ QuietFlag = TRUE;
+ argc --;
+ argv ++;
+ continue;
+ }
+
+ if ((strlen(argv[0]) >= 2 && argv[0][0] == '-' && (argv[0][1] == 'v' || argv[0][1] == 'V')) || (stricmp (argv[0], "--verbose") == 0)) {
+ VerboseLevel = 1;
+ if (strlen(argv[0]) > 2) {
+ Status = CountVerboseLevel (&argv[0][2], strlen(argv[0]) - 2, &VerboseLevel);
+ if (EFI_ERROR (Status)) {
+ Error (NULL, 0, 1003, "Invalid option value", argv[0]);
+ return STATUS_ERROR;
+ }
+ }
+
+ argc --;
+ argv ++;
+ continue;
+ }
+
+ if ((stricmp (argv[0], "-d") == 0) || (stricmp (argv[0], "--debug") == 0)) {
+ Status = AsciiStringToUint64 (argv[1], FALSE, &DebugLevel);
+ if (EFI_ERROR (Status)) {
+ Error (NULL, 0, 1003, "Invalid option value", "%s = %s", argv[0], argv[1]);
+ return STATUS_ERROR;
+ }
+ argc -= 2;
+ argv += 2;
+ continue;
+ }
+ //
+ // Don't recognize the parameter, should be regarded as the input file name.
+ //
+ InputFileNames[InputFileCount] = argv[0];
+ InputFileCount++;
+ argc--;
+ argv++;
+ }
+
+ if (InputFileCount == 0) {
+ Error (NULL, 0, 1001, "Missing option", "No input file");
+ return STATUS_ERROR;
+ }
+ //
+ // Open output file for write
+ //
+ if (OutputFileName == NULL) {
+ Error (NULL, 0, 1001, "Missing option", "No output file");
+ return STATUS_ERROR;
+ }
+
+ fpOut = fopen(OutputFileName, "w+b");
+ if (!fpOut) {
+ Error (NULL, 0, 0001, "Could not open output file", OutputFileName);
+ return STATUS_ERROR;
+ }
+
+ memset (&EfiLdrHeader, 0, sizeof (EfiLdrHeader));
+ memset (&EfiLdrImage, 0, sizeof (EFILDR_IMAGE) * (InputFileCount));
+
+ memcpy (&EfiLdrHeader.Signature, "EFIL", 4);
+ EfiLdrHeader.FileLength = sizeof(EFILDR_HEADER) + sizeof(EFILDR_IMAGE)*(InputFileCount);
+
+ //
+ // Skip the file header first
+ //
+ fseek (fpOut, EfiLdrHeader.FileLength, SEEK_SET);
+
+ //
+ // copy all the input files to the output file
+ //
+ for(i=0;i
+# 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.
+#
+ARCH ?= IA32
+MAKEROOT ?= ..
+
+APPNAME = EfiLdrImage
+
+LIBS = -lCommon
+
+OBJECTS = EfiLdrImage.o
+
+include $(MAKEROOT)/Makefiles/app.makefile
diff --git a/BaseTools/Source/C/EfiLdrImage/Makefile b/BaseTools/Source/C/EfiLdrImage/Makefile
new file mode 100644
index 0000000000..a3c9ef1f0a
--- /dev/null
+++ b/BaseTools/Source/C/EfiLdrImage/Makefile
@@ -0,0 +1,22 @@
+## @file
+# Windows makefile for 'EfiLdrImage' module build.
+#
+# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.
+# 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.
+#
+!INCLUDE ..\Makefiles\ms.common
+
+APPNAME = EfiLdrImage
+
+LIBS = $(LIB_PATH)\Common.lib
+
+OBJECTS = EfiLdrImage.obj
+
+!INCLUDE ..\Makefiles\ms.app
+
diff --git a/BaseTools/Source/C/EfiRom/EfiRom.c b/BaseTools/Source/C/EfiRom/EfiRom.c
new file mode 100644
index 0000000000..4642f441b4
--- /dev/null
+++ b/BaseTools/Source/C/EfiRom/EfiRom.c
@@ -0,0 +1,1547 @@
+/** @file
+
+Copyright (c) 1999 - 2010, Intel Corporation. All rights reserved.
+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.
+
+Module Name:
+
+ EfiRom.c
+
+Abstract:
+
+ Utility program to create an EFI option ROM image from binary and
+ EFI PE32 files.
+
+**/
+
+#include "EfiUtilityMsgs.h"
+#include "ParseInf.h"
+#include "EfiRom.h"
+
+UINT64 DebugLevel = 0;
+
+int
+main (
+ int Argc,
+ char *Argv[]
+ )
+/*++
+
+Routine Description:
+
+ Given an EFI image filename, create a ROM-able image by creating an option
+ ROM header and PCI data structure, filling them in, and then writing the
+ option ROM header + PCI data structure + EFI image out to the output file.
+
+Arguments:
+
+ Argc - standard C main() argument count
+
+ Argv - standard C main() argument list
+
+Returns:
+
+ 0 success
+ non-zero otherwise
+
+--*/
+{
+ CHAR8 *Ext;
+ FILE *FptrOut;
+ UINT32 Status;
+ FILE_LIST *FList;
+ UINT32 TotalSize;
+ UINT32 Size;
+ CHAR8 *Ptr0;
+
+ SetUtilityName(UTILITY_NAME);
+
+ Status = STATUS_SUCCESS;
+ FptrOut = NULL;
+
+ //
+ // Parse the command line arguments
+ //
+ if (ParseCommandLine (Argc, Argv, &mOptions)) {
+ return STATUS_ERROR;
+ }
+
+ if (mOptions.Quiet) {
+ SetPrintLevel(40);
+ } else if (mOptions.Verbose) {
+ SetPrintLevel(15);
+ } else if (mOptions.Debug) {
+ SetPrintLevel(DebugLevel);
+ }
+
+ if (mOptions.Verbose) {
+ VerboseMsg("%s tool start.\n", UTILITY_NAME);
+ }
+
+ //
+ // If dumping an image, then do that and quit
+ //
+ if (mOptions.DumpOption == 1) {
+ if (mOptions.FileList != NULL) {
+ if ((Ptr0 = strstr ((CONST CHAR8 *) mOptions.FileList->FileName, DEFAULT_OUTPUT_EXTENSION)) != NULL) {
+ DumpImage (mOptions.FileList);
+ goto BailOut;
+ } else {
+ Error (NULL, 0, 1002, "No PciRom input file", "No *.rom input file");
+ goto BailOut;
+ }
+ }
+ }
+ //
+ // Determine the output filename. Either what they specified on
+ // the command line, or the first input filename with a different extension.
+ //
+ if (!mOptions.OutFileName[0]) {
+ strcpy (mOptions.OutFileName, mOptions.FileList->FileName);
+ //
+ // Find the last . on the line and replace the filename extension with
+ // the default
+ //
+ for (Ext = mOptions.OutFileName + strlen (mOptions.OutFileName) - 1;
+ (Ext >= mOptions.OutFileName) && (*Ext != '.') && (*Ext != '\\');
+ Ext--
+ )
+ ;
+ //
+ // If dot here, then insert extension here, otherwise append
+ //
+ if (*Ext != '.') {
+ Ext = mOptions.OutFileName + strlen (mOptions.OutFileName);
+ }
+
+ strcpy (Ext, DEFAULT_OUTPUT_EXTENSION);
+ }
+ //
+ // Make sure we don't have the same filename for input and output files
+ //
+ for (FList = mOptions.FileList; FList != NULL; FList = FList->Next) {
+ if (stricmp (mOptions.OutFileName, FList->FileName) == 0) {
+ Status = STATUS_ERROR;
+ Error (NULL, 0, 1002, "Invalid input paramter", "Input and output file names must be different - %s = %s.", FList->FileName, mOptions.OutFileName);
+ goto BailOut;
+ }
+ }
+ //
+ // Now open our output file
+ //
+ if ((FptrOut = fopen (mOptions.OutFileName, "wb")) == NULL) {
+ Error (NULL, 0, 0001, "Error opening file", "Error opening file %s", mOptions.OutFileName);
+ goto BailOut;
+ }
+ //
+ // Process all our files
+ //
+ TotalSize = 0;
+ for (FList = mOptions.FileList; FList != NULL; FList = FList->Next) {
+ Size = 0;
+ if ((FList->FileFlags & FILE_FLAG_EFI) != 0) {
+ if (mOptions.Verbose) {
+ VerboseMsg("Processing EFI file %s\n", FList->FileName);
+ }
+
+ Status = ProcessEfiFile (FptrOut, FList, mOptions.VendId, mOptions.DevId, &Size);
+ } else if ((FList->FileFlags & FILE_FLAG_BINARY) !=0 ) {
+ if (mOptions.Verbose) {
+ VerboseMsg("Processing binary file %s\n", FList->FileName);
+ }
+
+ Status = ProcessBinFile (FptrOut, FList, &Size);
+ } else {
+ Error (NULL, 0, 2000, "Invalid parameter", "File type not specified, it must be either an EFI or binary file: %s.", FList->FileName);
+ Status = STATUS_ERROR;
+ }
+
+ if (mOptions.Verbose) {
+ VerboseMsg(" Output size = 0x%X\n", (unsigned) Size);
+ }
+
+ if (Status != STATUS_SUCCESS) {
+ break;
+ }
+
+ TotalSize += Size;
+ }
+ //
+ // Check total size
+ //
+ if (TotalSize > MAX_OPTION_ROM_SIZE) {
+ Error (NULL, 0, 2000, "Invalid paramter", "Option ROM image size exceeds limit of 0x%X bytes.", MAX_OPTION_ROM_SIZE);
+ Status = STATUS_ERROR;
+ }
+
+BailOut:
+ if (Status == STATUS_SUCCESS) {
+ if (FptrOut != NULL) {
+ fclose (FptrOut);
+ }
+ //
+ // Clean up our file list
+ //
+ while (mOptions.FileList != NULL) {
+ FList = mOptions.FileList->Next;
+ free (mOptions.FileList);
+ mOptions.FileList = FList;
+ }
+ }
+
+ if (mOptions.Verbose) {
+ VerboseMsg("%s tool done with return code is 0x%x.\n", UTILITY_NAME, GetUtilityStatus ());
+ }
+
+ return GetUtilityStatus ();
+}
+
+static
+int
+ProcessBinFile (
+ FILE *OutFptr,
+ FILE_LIST *InFile,
+ UINT32 *Size
+ )
+/*++
+
+Routine Description:
+
+ Process a binary input file.
+
+Arguments:
+
+ OutFptr - file pointer to output binary ROM image file we're creating
+ InFile - structure contains information on the binary file to process
+ Size - pointer to where to return the size added to the output file
+
+Returns:
+
+ 0 - successful
+
+--*/
+{
+ FILE *InFptr;
+ UINT32 TotalSize;
+ UINT32 FileSize;
+ UINT8 *Buffer;
+ UINT32 Status;
+ PCI_EXPANSION_ROM_HEADER *RomHdr;
+ PCI_DATA_STRUCTURE *PciDs23;
+ PCI_3_0_DATA_STRUCTURE *PciDs30;
+ UINT32 Index;
+ UINT8 ByteCheckSum;
+
+ PciDs23 = NULL;
+ PciDs30 = NULL;
+ Status = STATUS_SUCCESS;
+
+ //
+ // Try to open the input file
+ //
+ if ((InFptr = fopen (InFile->FileName, "rb")) == NULL) {
+ Error (NULL, 0, 0001, "Error opening file", InFile->FileName);
+ return STATUS_ERROR;
+ }
+ //
+ // Seek to the end of the input file and get the file size. Then allocate
+ // a buffer to read it in to.
+ //
+ fseek (InFptr, 0, SEEK_END);
+ FileSize = ftell (InFptr);
+ if (mOptions.Verbose) {
+ VerboseMsg(" File size = 0x%X\n", (unsigned) FileSize);
+ }
+
+ fseek (InFptr, 0, SEEK_SET);
+ Buffer = (UINT8 *) malloc (FileSize);
+ if (Buffer == NULL) {
+ Error (NULL, 0, 4003, "Resource", "memory cannot be allocated!");
+ Status = STATUS_ERROR;
+ goto BailOut;
+ }
+
+ if (fread (Buffer, FileSize, 1, InFptr) != 1) {
+ Error (NULL, 0, 2000, "Invalid", "Failed to read all bytes from input file.");
+ Status = STATUS_ERROR;
+ goto BailOut;
+ }
+ //
+ // Total size must be an even multiple of 512 bytes, and can't exceed
+ // the option ROM image size.
+ //
+ TotalSize = FileSize;
+ if (TotalSize & 0x1FF) {
+ TotalSize = (TotalSize + 0x200) &~0x1ff;
+ }
+
+ if (TotalSize > MAX_OPTION_ROM_SIZE) {
+ Error (NULL, 0, 3001, "Invalid", "Option ROM image %s size exceeds limit of 0x%X bytes.", InFile->FileName, MAX_OPTION_ROM_SIZE);
+ Status = STATUS_ERROR;
+ goto BailOut;
+ }
+ //
+ // Return the size to the caller so they can keep track of the running total.
+ //
+ *Size = TotalSize;
+
+ //
+ // Crude check to make sure it's a legitimate ROM image
+ //
+ RomHdr = (PCI_EXPANSION_ROM_HEADER *) Buffer;
+ if (RomHdr->Signature != PCI_EXPANSION_ROM_HEADER_SIGNATURE) {
+ Error (NULL, 0, 2000, "Invalid parameter", "ROM image file has an invalid ROM signature.");
+ Status = STATUS_ERROR;
+ goto BailOut;
+ }
+ //
+ // Make sure the pointer to the PCI data structure is within the size of the image.
+ // Then check it for valid signature.
+ //
+ if ((RomHdr->PcirOffset > FileSize) || (RomHdr->PcirOffset == 0)) {
+ Error (NULL, 0, 2000, "Invalid parameter", "Invalid PCI data structure offset.");
+ Status = STATUS_ERROR;
+ goto BailOut;
+ }
+
+ //
+ // Check the header is conform to PCI2.3 or PCI3.0
+ //
+ if (mOptions.Pci23 == 1) {
+ PciDs23 = (PCI_DATA_STRUCTURE *) (Buffer + RomHdr->PcirOffset);
+ if (PciDs23->Signature != PCI_DATA_STRUCTURE_SIGNATURE) {
+ Error (NULL, 0, 2000, "Invalid parameter", "PCI data structure has an invalid signature.");
+ Status = STATUS_ERROR;
+ goto BailOut;
+ }
+ } else {
+ //
+ // Default setting is PCI3.0 header
+ //
+ PciDs30 = (PCI_3_0_DATA_STRUCTURE *)(Buffer + RomHdr->PcirOffset);
+ if (PciDs30->Signature != PCI_DATA_STRUCTURE_SIGNATURE) {
+ Error (NULL, 0, 2000, "Invalid parameter", "PCI data structure has an invalid signature.");
+ Status = STATUS_ERROR;
+ goto BailOut;
+ }
+ }
+
+ //
+ // ReSet Option Rom size
+ //
+ if (mOptions.Pci23 == 1) {
+ PciDs23->ImageLength = (UINT16) (TotalSize / 512);
+ } else {
+ PciDs30->ImageLength = (UINT16) (TotalSize / 512);
+ }
+
+ //
+ // If this is the last image, then set the LAST bit unless requested not
+ // to via the command-line -n argument. Otherwise, make sure you clear it.
+ //
+ if ((InFile->Next == NULL) && (mOptions.NoLast == 0)) {
+ if (mOptions.Pci23 == 1) {
+ PciDs23->Indicator = INDICATOR_LAST;
+ } else {
+ PciDs30->Indicator = INDICATOR_LAST;
+ }
+ } else {
+ if (mOptions.Pci23 == 1) {
+ PciDs23->Indicator = 0;
+ } else {
+ PciDs30->Indicator = 0;
+ }
+ }
+
+ ByteCheckSum = 0;
+ for (Index = 0; Index < FileSize - 1; Index++) {
+ ByteCheckSum = (UINT8) (ByteCheckSum + Buffer[Index]);
+ }
+
+ Buffer[FileSize - 1] = (UINT8) ((~ByteCheckSum) + 1);
+ if (mOptions.Verbose) {
+ VerboseMsg(" Checksum = %02x\n\n", Buffer[FileSize - 1]);
+ }
+
+ //
+ // Now copy the input file contents out to the output file
+ //
+ if (fwrite (Buffer, FileSize, 1, OutFptr) != 1) {
+ Error (NULL, 0, 0005, "Failed to write all file bytes to output file.", NULL);
+ Status = STATUS_ERROR;
+ goto BailOut;
+ }
+
+ TotalSize -= FileSize;
+ //
+ // Pad the rest of the image to make it a multiple of 512 bytes
+ //
+ while (TotalSize > 0) {
+ putc (~0, OutFptr);
+ TotalSize--;
+ }
+
+BailOut:
+ if (InFptr != NULL) {
+ fclose (InFptr);
+ }
+
+ if (Buffer != NULL) {
+ free (Buffer);
+ }
+ //
+ // Print the file name if errors occurred
+ //
+ if (Status != STATUS_SUCCESS) {
+ Error (NULL, 0, 0003, "Error", "Error parsing file: %s", InFile->FileName);
+ }
+
+ return Status;
+}
+
+static
+int
+ProcessEfiFile (
+ FILE *OutFptr,
+ FILE_LIST *InFile,
+ UINT16 VendId,
+ UINT16 DevId,
+ UINT32 *Size
+ )
+/*++
+
+Routine Description:
+
+ Process a PE32 EFI file.
+
+Arguments:
+
+ OutFptr - file pointer to output binary ROM image file we're creating
+ InFile - structure contains information on the PE32 file to process
+ VendId - vendor ID as required in the option ROM header
+ DevId - device ID as required in the option ROM header
+ Size - pointer to where to return the size added to the output file
+
+Returns:
+
+ 0 - successful
+
+--*/
+{
+ UINT32 Status;
+ FILE *InFptr;
+ EFI_PCI_EXPANSION_ROM_HEADER RomHdr;
+ PCI_DATA_STRUCTURE PciDs23;
+ PCI_3_0_DATA_STRUCTURE PciDs30;
+ UINT32 FileSize;
+ UINT32 CompressedFileSize;
+ UINT8 *Buffer;
+ UINT8 *CompressedBuffer;
+ UINT8 *TempBufferPtr;
+ UINT32 TotalSize;
+ UINT32 HeaderSize;
+ UINT16 MachineType;
+ UINT16 SubSystem;
+ UINT32 HeaderPadBytes;
+
+ //
+ // Try to open the input file
+ //
+ if ((InFptr = fopen (InFile->FileName, "rb")) == NULL) {
+ Error (NULL, 0, 0001, "Open file error", "Error opening file: %s", InFile->FileName);
+ return STATUS_ERROR;
+ }
+ //
+ // Initialize our buffer pointers to null.
+ //
+ Buffer = NULL;
+ CompressedBuffer = NULL;
+
+ //
+ // Double-check the file to make sure it's what we expect it to be
+ //
+ Status = CheckPE32File (InFptr, &MachineType, &SubSystem);
+ if (Status != STATUS_SUCCESS) {
+ goto BailOut;
+ }
+ //
+ // Seek to the end of the input file and get the file size
+ //
+ fseek (InFptr, 0, SEEK_END);
+ FileSize = ftell (InFptr);
+
+ //
+ // Get the size of the headers we're going to put in front of the image. The
+ // EFI header must be aligned on a 4-byte boundary, so pad accordingly.
+ //
+ if (sizeof (RomHdr) & 0x03) {
+ HeaderPadBytes = 4 - (sizeof (RomHdr) & 0x03);
+ } else {
+ HeaderPadBytes = 0;
+ }
+
+ //
+ // For Pci3.0 to use the different data structure.
+ //
+ if (mOptions.Pci23 == 1) {
+ HeaderSize = sizeof (PCI_DATA_STRUCTURE) + HeaderPadBytes + sizeof (EFI_PCI_EXPANSION_ROM_HEADER);
+ } else {
+ HeaderSize = sizeof (PCI_3_0_DATA_STRUCTURE) + HeaderPadBytes + sizeof (EFI_PCI_EXPANSION_ROM_HEADER);
+ }
+
+ if (mOptions.Verbose) {
+ VerboseMsg(" File size = 0x%X\n", (unsigned) FileSize);
+ }
+ //
+ // Allocate memory for the entire file (in case we have to compress), then
+ // seek back to the beginning of the file and read it into our buffer.
+ //
+ Buffer = (UINT8 *) malloc (FileSize);
+ if (Buffer == NULL) {
+ Error (NULL, 0, 4001, "Resource", "memory cannot be allocated!");
+ Status = STATUS_ERROR;
+ goto BailOut;
+ }
+
+ fseek (InFptr, 0, SEEK_SET);
+ if (fread (Buffer, FileSize, 1, InFptr) != 1) {
+ Error (NULL, 0, 0004, "Error reading file", "File %s", InFile->FileName);
+ Status = STATUS_ERROR;
+ goto BailOut;
+ }
+ //
+ // Now determine the size of the final output file. It's either the header size
+ // plus the file's size, or the header size plus the compressed file size.
+ //
+ if ((InFile->FileFlags & FILE_FLAG_COMPRESS) != 0) {
+ //
+ // Allocate a buffer into which we can compress the image, compress it,
+ // and use that size as the new size.
+ //
+ CompressedBuffer = (UINT8 *) malloc (FileSize);
+ if (CompressedBuffer == NULL) {
+ Error (NULL, 0, 4001, "Resource", "memory cannot be allocated!");
+ Status = STATUS_ERROR;
+ goto BailOut;
+ }
+
+ CompressedFileSize = FileSize;
+ Status = EfiCompress (Buffer, FileSize, CompressedBuffer, &CompressedFileSize);
+ if (Status != STATUS_SUCCESS) {
+ Error (NULL, 0, 0007, "Error compressing file!", NULL);
+ goto BailOut;
+ }
+ //
+ // Now compute the size, then swap buffer pointers.
+ //
+ if (mOptions.Verbose) {
+ VerboseMsg(" Comp size = 0x%X\n", (unsigned) CompressedFileSize);
+ }
+
+ TotalSize = CompressedFileSize + HeaderSize;
+ FileSize = CompressedFileSize;
+ TempBufferPtr = Buffer;
+ Buffer = CompressedBuffer;
+ CompressedBuffer = TempBufferPtr;
+ } else {
+ TotalSize = FileSize + HeaderSize;
+ }
+ //
+ // Total size must be an even multiple of 512 bytes
+ //
+ if (TotalSize & 0x1FF) {
+ TotalSize = (TotalSize + 0x200) &~0x1ff;
+ }
+ //
+ // Check size
+ //
+ if (TotalSize > MAX_OPTION_ROM_SIZE) {
+ Error (NULL, 0, 2000, "Invalid", "Option ROM image %s size exceeds limit of 0x%X bytes.", InFile->FileName, MAX_OPTION_ROM_SIZE);
+ Status = STATUS_ERROR;
+ goto BailOut;
+ }
+ //
+ // Return the size to the caller so they can keep track of the running total.
+ //
+ *Size = TotalSize;
+
+ //
+ // Now fill in the ROM header. These values come from chapter 18 of the
+ // EFI 1.02 specification.
+ //
+ memset (&RomHdr, 0, sizeof (RomHdr));
+ RomHdr.Signature = PCI_EXPANSION_ROM_HEADER_SIGNATURE;
+ RomHdr.InitializationSize = (UINT16) (TotalSize / 512);
+ RomHdr.EfiSignature = EFI_PCI_EXPANSION_ROM_HEADER_EFISIGNATURE;
+ RomHdr.EfiSubsystem = SubSystem;
+ RomHdr.EfiMachineType = MachineType;
+ RomHdr.EfiImageHeaderOffset = (UINT16) HeaderSize;
+ RomHdr.PcirOffset = (UINT16) (sizeof (RomHdr) + HeaderPadBytes);
+ //
+ // Set image as compressed or not
+ //
+ if (InFile->FileFlags & FILE_FLAG_COMPRESS) {
+ RomHdr.CompressionType = EFI_PCI_EXPANSION_ROM_HEADER_COMPRESSED;
+ }
+ //
+ // Fill in the PCI data structure
+ //
+ if (mOptions.Pci23 == 1) {
+ memset (&PciDs23, 0, sizeof (PCI_DATA_STRUCTURE));
+ } else {
+ memset (&PciDs30, 0, sizeof (PCI_3_0_DATA_STRUCTURE));
+ }
+
+ if (mOptions.Pci23 == 1) {
+ PciDs23.Signature = PCI_DATA_STRUCTURE_SIGNATURE;
+ PciDs23.VendorId = VendId;
+ PciDs23.DeviceId = DevId;
+ PciDs23.Length = (UINT16) sizeof (PCI_DATA_STRUCTURE);
+ PciDs23.Revision = 0;
+ //
+ // Class code and code revision from the command line (optional)
+ //
+ PciDs23.ClassCode[0] = (UINT8) InFile->ClassCode;
+ PciDs23.ClassCode[1] = (UINT8) (InFile->ClassCode >> 8);
+ PciDs23.ClassCode[2] = (UINT8) (InFile->ClassCode >> 16);
+ PciDs23.ImageLength = RomHdr.InitializationSize;
+ PciDs23.CodeRevision = InFile->CodeRevision;
+ PciDs23.CodeType = PCI_CODE_TYPE_EFI_IMAGE;
+ } else {
+ PciDs30.Signature = PCI_DATA_STRUCTURE_SIGNATURE;
+ PciDs30.VendorId = VendId;
+ PciDs30.DeviceId = DevId;
+ PciDs30.DeviceListOffset = 0; // to be fixed
+ PciDs30.Length = (UINT16) sizeof (PCI_3_0_DATA_STRUCTURE);
+ PciDs30.Revision = 0x3;
+ //
+ // Class code and code revision from the command line (optional)
+ //
+ PciDs30.ClassCode[0] = (UINT8) InFile->ClassCode;
+ PciDs30.ClassCode[1] = (UINT8) (InFile->ClassCode >> 8);
+ PciDs30.ClassCode[2] = (UINT8) (InFile->ClassCode >> 16);
+ PciDs30.ImageLength = RomHdr.InitializationSize;
+ PciDs30.CodeRevision = InFile->CodeRevision;
+ PciDs30.CodeType = PCI_CODE_TYPE_EFI_IMAGE;
+ PciDs30.MaxRuntimeImageLength = 0; // to be fixed
+ PciDs30.ConfigUtilityCodeHeaderOffset = 0; // to be fixed
+ PciDs30.DMTFCLPEntryPointOffset = 0; // to be fixed
+ }
+ //
+ // If this is the last image, then set the LAST bit unless requested not
+ // to via the command-line -n argument.
+ //
+ if ((InFile->Next == NULL) && (mOptions.NoLast == 0)) {
+ if (mOptions.Pci23 == 1) {
+ PciDs23.Indicator = INDICATOR_LAST;
+ } else {
+ PciDs30.Indicator = INDICATOR_LAST;}
+ } else {
+ if (mOptions.Pci23 == 1) {
+ PciDs23.Indicator = 0;
+ } else {
+ PciDs30.Indicator = 0;
+ }
+ }
+ //
+ // Write the ROM header to the output file
+ //
+ if (fwrite (&RomHdr, sizeof (RomHdr), 1, OutFptr) != 1) {
+ Error (NULL, 0, 0002, "Failed to write ROM header to output file!", NULL);
+ Status = STATUS_ERROR;
+ goto BailOut;
+ }
+
+ //
+ // Write pad bytes to align the PciDs
+ //
+ while (HeaderPadBytes > 0) {
+ if (putc (0, OutFptr) == EOF) {
+ Error (NULL, 0, 0002, "Failed to write ROM header pad bytes to output file!", NULL);
+ Status = STATUS_ERROR;
+ goto BailOut;
+ }
+
+ HeaderPadBytes--;
+ }
+ //
+ // Write the PCI data structure header to the output file
+ //
+ if (mOptions.Pci23 == 1) {
+ if (fwrite (&PciDs23, sizeof (PciDs23), 1, OutFptr) != 1) {
+ Error (NULL, 0, 0002, "Failed to write PCI ROM header to output file!", NULL);
+ Status = STATUS_ERROR;
+ goto BailOut;
+ }
+ } else {
+ if (fwrite (&PciDs30, sizeof (PciDs30), 1, OutFptr) != 1) {
+ Error (NULL, 0, 0002, "Failed to write PCI ROM header to output file!", NULL);
+ Status = STATUS_ERROR;
+ goto BailOut;
+ }
+ }
+ //
+ // Keep track of how many bytes left to write
+ //
+ TotalSize -= HeaderSize;
+
+ //
+ // Now dump the input file's contents to the output file
+ //
+ if (fwrite (Buffer, FileSize, 1, OutFptr) != 1) {
+ Error (NULL, 0, 0002, "Failed to write all file bytes to output file!", NULL);
+ Status = STATUS_ERROR;
+ goto BailOut;
+ }
+
+ TotalSize -= FileSize;
+ //
+ // Pad the rest of the image to make it a multiple of 512 bytes
+ //
+ while (TotalSize > 0) {
+ if (putc (~0, OutFptr) == EOF) {
+ Error (NULL, 0, 2000, "Failed to write trailing pad bytes output file!", NULL);
+ Status = STATUS_ERROR;
+ goto BailOut;
+ }
+
+ TotalSize--;
+ }
+
+BailOut:
+ if (InFptr != NULL) {
+ fclose (InFptr);
+ }
+ //
+ // Free up our buffers
+ //
+ if (Buffer != NULL) {
+ free (Buffer);
+ }
+
+ if (CompressedBuffer != NULL) {
+ free (CompressedBuffer);
+ }
+ //
+ // Print the file name if errors occurred
+ //
+ if (Status != STATUS_SUCCESS) {
+ Error (NULL, 0, 0003, "Error parsing", "Error parsing file: %s", InFile->FileName);
+ }
+
+ return Status;
+}
+
+static
+int
+CheckPE32File (
+ FILE *Fptr,
+ UINT16 *MachineType,
+ UINT16 *SubSystem
+ )
+/*++
+
+Routine Description:
+
+ Given a file pointer to a supposed PE32 image file, verify that it is indeed a
+ PE32 image file, and then return the machine type in the supplied pointer.
+
+Arguments:
+
+ Fptr File pointer to the already-opened PE32 file
+ MachineType Location to stuff the machine type of the PE32 file. This is needed
+ because the image may be Itanium-based, IA32, or EBC.
+
+Returns:
+
+ 0 success
+ non-zero otherwise
+
+--*/
+{
+ EFI_IMAGE_DOS_HEADER DosHeader;
+ EFI_IMAGE_OPTIONAL_HEADER_UNION PeHdr;
+
+ //
+ // Position to the start of the file
+ //
+ fseek (Fptr, 0, SEEK_SET);
+
+ //
+ // Read the DOS header
+ //
+ if (fread (&DosHeader, sizeof (DosHeader), 1, Fptr) != 1) {
+ Error (NULL, 0, 0004, "Failed to read the DOS stub from the input file!", NULL);
+ return STATUS_ERROR;
+ }
+ //
+ // Check the magic number (0x5A4D)
+ //
+ if (DosHeader.e_magic != EFI_IMAGE_DOS_SIGNATURE) {
+ Error (NULL, 0, 2000, "Invalid parameter", "Input file does not appear to be a PE32 image (magic number)!");
+ return STATUS_ERROR;
+ }
+ //
+ // Position into the file and check the PE signature
+ //
+ fseek (Fptr, (long) DosHeader.e_lfanew, SEEK_SET);
+
+ //
+ // Read PE headers
+ //
+ if (fread (&PeHdr, sizeof (PeHdr), 1, Fptr) != 1) {
+ Error (NULL, 0, 0004, "Failed to read PE/COFF headers from input file!", NULL);
+ return STATUS_ERROR;
+ }
+
+
+ //
+ // Check the PE signature in the header "PE\0\0"
+ //
+ if (PeHdr.Pe32.Signature != EFI_IMAGE_NT_SIGNATURE) {
+ Error (NULL, 0, 2000, "Invalid parameter", "Input file does not appear to be a PE32 image (signature)!");
+ return STATUS_ERROR;
+ }
+
+ memcpy ((char *) MachineType, &PeHdr.Pe32.FileHeader.Machine, 2);
+
+ if (PeHdr.Pe32.OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
+ *SubSystem = PeHdr.Pe32.OptionalHeader.Subsystem;
+ } else if (PeHdr.Pe32Plus.OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) {
+ *SubSystem = PeHdr.Pe32Plus.OptionalHeader.Subsystem;
+ } else {
+ Error (NULL, 0, 2000, "Invalid parameter", "Unable to find subsystem type!");
+ return STATUS_ERROR;
+ }
+
+ if (mOptions.Verbose) {
+ VerboseMsg(" Got subsystem = 0x%X from image\n", *SubSystem);
+ }
+
+ //
+ // File was successfully identified as a PE32
+ //
+ return STATUS_SUCCESS;
+}
+
+static
+int
+ParseCommandLine (
+ int Argc,
+ char *Argv[],
+ OPTIONS *Options
+ )
+/*++
+
+Routine Description:
+
+ Given the Argc/Argv program arguments, and a pointer to an options structure,
+ parse the command-line options and check their validity.
+
+
+Arguments:
+
+ Argc - standard C main() argument count
+ Argv[] - standard C main() argument list
+ Options - pointer to a structure to store the options in
+
+Returns:
+
+ STATUS_SUCCESS success
+ non-zero otherwise
+
+--*/
+{
+ FILE_LIST *FileList;
+ FILE_LIST *PrevFileList;
+ UINT32 FileFlags;
+ UINT32 ClassCode;
+ UINT32 CodeRevision;
+ EFI_STATUS Status;
+ BOOLEAN EfiRomFlag;
+ UINT64 TempValue;
+
+ FileFlags = 0;
+ EfiRomFlag = FALSE;
+
+ //
+ // Clear out the options
+ //
+ memset ((char *) Options, 0, sizeof (OPTIONS));
+
+ //
+ // To avoid compile warnings
+ //
+ FileList = PrevFileList = NULL;
+
+ ClassCode = 0;
+ CodeRevision = 0;
+ //
+ // Skip over the program name
+ //
+ Argc--;
+ Argv++;
+
+ //
+ // If no arguments, assume they want usage info
+ //
+ if (Argc == 0) {
+ Usage ();
+ return STATUS_ERROR;
+ }
+
+ if ((stricmp(Argv[0], "-h") == 0) || (stricmp(Argv[0], "--help") == 0)) {
+ Usage();
+ return STATUS_ERROR;
+ }
+
+ if ((stricmp(Argv[0], "--version") == 0)) {
+ Version();
+ return STATUS_ERROR;
+ }
+
+ //
+ // Process until no more arguments
+ //
+ while (Argc > 0) {
+ if (Argv[0][0] == '-') {
+ //
+ // Vendor ID specified with -f
+ //
+ if (stricmp (Argv[0], "-f") == 0) {
+ //
+ // Make sure there's another parameter
+ //
+ Status = AsciiStringToUint64(Argv[1], FALSE, &TempValue);
+ if (EFI_ERROR (Status)) {
+ Error (NULL, 0, 2000, "Invalid option value", "%s = %s", Argv[0], Argv[1]);
+ return 1;
+ }
+ if (TempValue >= 0x10000) {
+ Error (NULL, 0, 2000, "Invalid option value", "Vendor Id %s out of range!", Argv[1]);
+ return 1;
+ }
+ Options->VendId = (UINT16) TempValue;
+ Options->VendIdValid = 1;
+
+ Argv++;
+ Argc--;
+ } else if (stricmp (Argv[0], "-i") == 0) {
+ //
+ // Device ID specified with -i
+ // Make sure there's another parameter
+ //
+ Status = AsciiStringToUint64(Argv[1], FALSE, &TempValue);
+ if (EFI_ERROR (Status)) {
+ Error (NULL, 0, 2000, "Invalid option value", "%s = %s", Argv[0], Argv[1]);
+ return 1;
+ }
+ if (TempValue >= 0x10000) {
+ Error (NULL, 0, 2000, "Invalid option value", "Device Id %s out of range!", Argv[1]);
+ return 1;
+ }
+ Options->DevId = (UINT16) TempValue;
+ Options->DevIdValid = 1;
+
+ Argv++;
+ Argc--;
+ } else if ((stricmp (Argv[0], "-o") == 0) || (stricmp (Argv[0], "--output") == 0)) {
+ //
+ // Output filename specified with -o
+ // Make sure there's another parameter
+ //
+ if (Argv[1] == NULL || Argv[1][0] == '-') {
+ Error (NULL, 0, 2000, "Invalid parameter", "Missing output file name with %s option!", Argv[0]);
+ return STATUS_ERROR;
+ }
+ strcpy (Options->OutFileName, Argv[1]);
+
+ Argv++;
+ Argc--;
+ } else if ((stricmp (Argv[0], "-h") == 0) || (stricmp (Argv[0], "--help") == 0)) {
+ //
+ // Help option
+ //
+ Usage ();
+ return STATUS_ERROR;
+ } else if (stricmp (Argv[0], "-b") == 0) {
+ //
+ // Specify binary files with -b
+ //
+ FileFlags = FILE_FLAG_BINARY;
+ } else if ((stricmp (Argv[0], "-e") == 0) || (stricmp (Argv[0], "-ec") == 0)) {
+ //
+ // Specify EFI files with -e. Specify EFI-compressed with -c.
+ //
+ FileFlags = FILE_FLAG_EFI;
+ if ((Argv[0][2] == 'c') || (Argv[0][2] == 'C')) {
+ FileFlags |= FILE_FLAG_COMPRESS;
+ }
+ //
+ // Specify not to set the LAST bit in the last file with -n
+ //
+ } else if (stricmp (Argv[0], "-n") == 0) {
+ Options->NoLast = 1;
+ } else if (((stricmp (Argv[0], "-v") == 0)) || ((stricmp (Argv[0], "--verbose") == 0))) {
+ //
+ // -v for verbose
+ //
+ Options->Verbose = 1;
+ } else if (stricmp (Argv[0], "--debug") == 0) {
+ Status = AsciiStringToUint64(Argv[1], FALSE, &DebugLevel);
+ if (EFI_ERROR (Status)) {
+ Error (NULL, 0, 2000, "Invalid option value", "%s = %s", Argv[0], Argv[1]);
+ return 1;
+ }
+ if (DebugLevel > 9) {
+ Error (NULL, 0, 2000, "Invalid option value", "Debug Level range is 0-9, current input level is %d", Argv[1]);
+ return 1;
+ }
+ if (DebugLevel>=5 && DebugLevel<=9) {
+ Options->Debug = TRUE;
+ } else {
+ Options->Debug = FALSE;
+ }
+ Argv++;
+ Argc--;
+ } else if ((stricmp (Argv[0], "--quiet") == 0) || (stricmp (Argv[0], "-q") == 0)) {
+ Options->Quiet = TRUE;
+ } else if ((stricmp (Argv[0], "--dump") == 0) || (stricmp (Argv[0], "-d") == 0)) {
+ //
+ // -dump for dumping a ROM image. In this case, say that the device id
+ // and vendor id are valid so we don't have to specify bogus ones on the
+ // command line.
+ //
+ Options->DumpOption = 1;
+
+ Options->VendIdValid = 1;
+ Options->DevIdValid = 1;
+ FileFlags = FILE_FLAG_BINARY;
+ } else if ((stricmp (Argv[0], "-l") == 0) || (stricmp (Argv[0], "--class-code") == 0)) {
+ //
+ // Class code value for the next file in the list.
+ // Make sure there's another parameter
+ //
+ Status = AsciiStringToUint64(Argv[1], FALSE, &TempValue);
+ if (EFI_ERROR (Status)) {
+ Error (NULL, 0, 2000, "Invalid option value", "%s = %s", Argv[0], Argv[1]);
+ return 1;
+ }
+ ClassCode = (UINT32) TempValue;
+ if (ClassCode & 0xFF000000) {
+ Error (NULL, 0, 2000, "Invalid parameter", "Class code %s out of range!", Argv[1]);
+ return STATUS_ERROR;
+ }
+ if (FileList != NULL && FileList->ClassCode == 0) {
+ FileList->ClassCode = ClassCode;
+ }
+ Argv++;
+ Argc--;
+ } else if ((stricmp (Argv[0], "-r") == 0) || (stricmp (Argv[0], "--Revision") == 0)) {
+ //
+ // Code revision in the PCI data structure. The value is for the next
+ // file in the list.
+ // Make sure there's another parameter
+ //
+ Status = AsciiStringToUint64(Argv[1], FALSE, &TempValue);
+ if (EFI_ERROR (Status)) {
+ Error (NULL, 0, 2000, "Invalid option value", "%s = %s", Argv[0], Argv[1]);
+ return 1;
+ }
+ CodeRevision = (UINT32) TempValue;
+ if (CodeRevision & 0xFFFF0000) {
+ Error (NULL, 0, 2000, "Invalid parameter", "Code revision %s out of range!", Argv[1]);
+ return STATUS_ERROR;
+ }
+ if (FileList != NULL && FileList->CodeRevision == 0) {
+ FileList->CodeRevision = (UINT16) CodeRevision;
+ }
+ Argv++;
+ Argc--;
+ } else if ((stricmp (Argv[0], "-p") == 0) || (stricmp (Argv[0], "--pci23") == 0)) {
+ //
+ // Default layout meets PCI 3.0 specifications, specifying this flag will for a PCI 2.3 layout.
+ //
+ mOptions.Pci23 = 1;
+ } else {
+ Error (NULL, 0, 2000, "Invalid parameter", "Invalid option specified: %s", Argv[0]);
+ return STATUS_ERROR;
+ }
+ } else {
+ //
+ // Not a slash-option argument. Must be a file name. Make sure they've specified
+ // -e or -b already.
+ //
+ if ((FileFlags & (FILE_FLAG_BINARY | FILE_FLAG_EFI)) == 0) {
+ Error (NULL, 0, 2000, "Invalid parameter", "Missing -e or -b with input file %s!", Argv[0]);
+ return STATUS_ERROR;
+ }
+ //
+ // Check Efi Option RomImage
+ //
+ if ((FileFlags & FILE_FLAG_EFI) == FILE_FLAG_EFI) {
+ EfiRomFlag = TRUE;
+ }
+ //
+ // Create a new file structure
+ //
+ FileList = (FILE_LIST *) malloc (sizeof (FILE_LIST));
+ if (FileList == NULL) {
+ Error (NULL, 0, 4001, "Resource", "memory cannot be allocated!", NULL);
+ return STATUS_ERROR;
+ }
+
+ //
+ // set flag and class code for this image.
+ //
+ memset ((char *) FileList, 0, sizeof (FILE_LIST));
+ FileList->FileName = Argv[0];
+ FileList->FileFlags = FileFlags;
+ FileList->ClassCode = ClassCode;
+ FileList->CodeRevision = (UINT16) CodeRevision;
+ ClassCode = 0;
+ CodeRevision = 0;
+
+ if (Options->FileList == NULL) {
+ Options->FileList = FileList;
+ } else {
+ if (PrevFileList == NULL) {
+ PrevFileList = FileList;
+ } else {
+ PrevFileList->Next = FileList;
+ }
+ }
+
+ PrevFileList = FileList;
+ }
+ //
+ // Next argument
+ //
+ Argv++;
+ Argc--;
+ }
+
+ //
+ // Must have specified some files
+ //
+ if (Options->FileList == NULL) {
+ Error (NULL, 0, 2000, "Invalid parameter", "Missing input file name!");
+ return STATUS_ERROR;
+ }
+
+ //
+ // For EFI OptionRom image, Make sure a device ID and vendor ID are both specified.
+ //
+ if (EfiRomFlag) {
+ if (!Options->VendIdValid) {
+ Error (NULL, 0, 2000, "Missing Vendor ID in command line", NULL);
+ return STATUS_ERROR;
+ }
+
+ if (!Options->DevIdValid) {
+ Error (NULL, 0, 2000, "Missing Device ID in command line", NULL);
+ return STATUS_ERROR;
+ }
+ }
+
+ return 0;
+}
+
+static
+void
+Version (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Print version information for this utility.
+
+Arguments:
+
+ None.
+
+Returns:
+
+ Nothing.
+--*/
+{
+ fprintf (stdout, "%s Version %d.%d\n", UTILITY_NAME, UTILITY_MAJOR_VERSION, UTILITY_MINOR_VERSION);
+}
+
+static
+void
+Usage (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Print usage information for this utility.
+
+Arguments:
+
+ None.
+
+Returns:
+
+ Nothing.
+
+--*/
+{
+ //
+ // Summary usage
+ //
+ fprintf (stdout, "Usage: %s [options] [file name] \n\n", UTILITY_NAME);
+
+ //
+ // Copyright declaration
+ //
+ fprintf (stdout, "Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.\n\n");
+
+ //
+ // Details Option
+ //
+ fprintf (stdout, "Options:\n");
+ fprintf (stdout, " -o FileName, --output FileName\n\
+ File will be created to store the ouput content.\n");
+ fprintf (stdout, " -e EfiFileName\n\
+ EFI PE32 image files.\n");
+ fprintf (stdout, " -ec EfiFileName\n\
+ EFI PE32 image files and will be compressed.\n");
+ fprintf (stdout, " -b BinFileName\n\
+ Legacy binary files.\n");
+ fprintf (stdout, " -l ClassCode\n\
+ Hex ClassCode in the PCI data structure header.\n");
+ fprintf (stdout, " -r Rev Hex Revision in the PCI data structure header.\n");
+ fprintf (stdout, " -n Not to automatically set the LAST bit in the last file.\n");
+ fprintf (stdout, " -f VendorId\n\
+ Hex PCI Vendor ID for the device OpROM.\n");
+ fprintf (stdout, " -i DeviceId\n\
+ Hex PCI Device ID for the device OpROM.\n");
+ fprintf (stdout, " -p, --pci23\n\
+ Default layout meets PCI 3.0 specifications\n\
+ specifying this flag will for a PCI 2.3 layout.\n");
+ fprintf (stdout, " -d, --dump\n\
+ Dump the headers of an existing option ROM image.\n");
+ fprintf (stdout, " -v, --verbose\n\
+ Turn on verbose output with informational messages.\n");
+ fprintf (stdout, " --version Show program's version number and exit.\n");
+ fprintf (stdout, " -h, --help\n\
+ Show this help message and exit.\n");
+ fprintf (stdout, " -q, --quiet\n\
+ Disable all messages except FATAL ERRORS.\n");
+ fprintf (stdout, " --debug [#,0-9]\n\
+ Enable debug messages at level #.\n");
+}
+
+static
+void
+DumpImage (
+ FILE_LIST *InFile
+ )
+/*++
+
+Routine Description:
+
+ Dump the headers of an existing option ROM image
+
+Arguments:
+
+ InFile - the file name of an existing option ROM image
+
+Returns:
+
+ none
+
+--*/
+{
+ PCI_EXPANSION_ROM_HEADER PciRomHdr;
+ FILE *InFptr;
+ UINT32 ImageStart;
+ UINT32 ImageCount;
+ EFI_PCI_EXPANSION_ROM_HEADER EfiRomHdr;
+ PCI_DATA_STRUCTURE PciDs23;
+ PCI_3_0_DATA_STRUCTURE PciDs30;
+
+ //
+ // Open the input file
+ //
+ if ((InFptr = fopen (InFile->FileName, "rb")) == NULL) {
+ Error (NULL, 0, 0001, "Error opening file", InFile->FileName);
+ return ;
+ }
+ //
+ // Go through the image and dump the header stuff for each
+ //
+ ImageCount = 0;
+ for (;;) {
+ //
+ // Save our postition in the file, since offsets in the headers
+ // are relative to the particular image.
+ //
+ ImageStart = ftell (InFptr);
+ ImageCount++;
+
+ //
+ // Read the option ROM header. Have to assume a raw binary image for now.
+ //
+ if (fread (&PciRomHdr, sizeof (PciRomHdr), 1, InFptr) != 1) {
+ Error (NULL, 0, 3001, "Not supported", "Failed to read PCI ROM header from file!");
+ goto BailOut;
+ }
+
+ //
+ // Dump the contents of the header
+ //
+ fprintf (stdout, "Image %u -- Offset 0x%X\n", (unsigned) ImageCount, (unsigned) ImageStart);
+ fprintf (stdout, " ROM header contents\n");
+ fprintf (stdout, " Signature 0x%04X\n", PciRomHdr.Signature);
+ fprintf (stdout, " PCIR offset 0x%04X\n", PciRomHdr.PcirOffset);
+ //
+ // Find PCI data structure
+ //
+ if (fseek (InFptr, ImageStart + PciRomHdr.PcirOffset, SEEK_SET)) {
+ Error (NULL, 0, 3001, "Not supported", "Failed to seek to PCI data structure!");
+ goto BailOut;
+ }
+ //
+ // Read and dump the PCI data structure
+ //
+ memset (&PciDs23, 0, sizeof (PciDs23));
+ memset (&PciDs30, 0, sizeof (PciDs30));
+ if (mOptions.Pci23 == 1) {
+ if (fread (&PciDs23, sizeof (PciDs23), 1, InFptr) != 1) {
+ Error (NULL, 0, 3001, "Not supported", "Failed to read PCI data structure from file %s!", InFile->FileName);
+ goto BailOut;
+ }
+ } else {
+ if (fread (&PciDs30, sizeof (PciDs30), 1, InFptr) != 1) {
+ Error (NULL, 0, 3001, "Not supported", "Failed to read PCI data structure from file %s!", InFile->FileName);
+ goto BailOut;
+ }
+ }
+ if (mOptions.Verbose) {
+ VerboseMsg("Read PCI data structure from file %s", InFile->FileName);
+ }
+
+ //fprintf (stdout, " PCI Data Structure\n");
+ if (mOptions.Pci23 == 1) {
+ fprintf (
+ stdout,
+ " Signature %c%c%c%c\n",
+ (char) PciDs23.Signature,
+ (char) (PciDs23.Signature >> 8),
+ (char) (PciDs23.Signature >> 16),
+ (char) (PciDs23.Signature >> 24)
+ );
+ fprintf (stdout, " Vendor ID 0x%04X\n", PciDs23.VendorId);
+ fprintf (stdout, " Device ID 0x%04X\n", PciDs23.DeviceId);
+ fprintf (stdout, " Length 0x%04X\n", PciDs23.Length);
+ fprintf (stdout, " Revision 0x%04X\n", PciDs23.Revision);
+ fprintf (
+ stdout,
+ " Class Code 0x%06X\n",
+ (unsigned) (PciDs23.ClassCode[0] | (PciDs23.ClassCode[1] << 8) | (PciDs23.ClassCode[2] << 16))
+ );
+ fprintf (stdout, " Image size 0x%X\n", (unsigned) PciDs23.ImageLength * 512);
+ fprintf (stdout, " Code revision: 0x%04X\n", PciDs23.CodeRevision);
+ fprintf (stdout, " Indicator 0x%02X", PciDs23.Indicator);
+ } else {
+ fprintf (
+ stdout,
+ " Signature %c%c%c%c\n",
+ (char) PciDs30.Signature,
+ (char) (PciDs30.Signature >> 8),
+ (char) (PciDs30.Signature >> 16),
+ (char) (PciDs30.Signature >> 24)
+ );
+ fprintf (stdout, " Vendor ID 0x%04X\n", PciDs30.VendorId);
+ fprintf (stdout, " Device ID 0x%04X\n", PciDs30.DeviceId);
+ fprintf (stdout, " Length 0x%04X\n", PciDs30.Length);
+ fprintf (stdout, " Revision 0x%04X\n", PciDs30.Revision);
+ fprintf (stdout, " DeviceListOffset 0x%02X\n", PciDs30.DeviceListOffset);
+ fprintf (
+ stdout,
+ " Class Code 0x%06X\n",
+ (unsigned) (PciDs30.ClassCode[0] | (PciDs30.ClassCode[1] << 8) | (PciDs30.ClassCode[2] << 16))
+ );
+ fprintf (stdout, " Image size 0x%X\n", (unsigned) PciDs30.ImageLength * 512);
+ fprintf (stdout, " Code revision: 0x%04X\n", PciDs30.CodeRevision);
+ fprintf (stdout, " MaxRuntimeImageLength 0x%02X\n", PciDs30.MaxRuntimeImageLength);
+ fprintf (stdout, " ConfigUtilityCodeHeaderOffset 0x%02X\n", PciDs30.ConfigUtilityCodeHeaderOffset);
+ fprintf (stdout, " DMTFCLPEntryPointOffset 0x%02X\n", PciDs30.DMTFCLPEntryPointOffset);
+ fprintf (stdout, " Indicator 0x%02X", PciDs30.Indicator);
+ }
+ //
+ // Print the indicator, used to flag the last image
+ //
+ if (PciDs23.Indicator == INDICATOR_LAST || PciDs30.Indicator == INDICATOR_LAST) {
+ fprintf (stdout, " (last image)\n");
+ } else {
+ fprintf (stdout, "\n");
+ }
+ //
+ // Print the code type. If EFI code, then we can provide more info.
+ //
+ if (mOptions.Pci23 == 1) {
+ fprintf (stdout, " Code type 0x%02X", PciDs23.CodeType);
+ } else {
+ fprintf (stdout, " Code type 0x%02X", PciDs30.CodeType);
+ }
+ if (PciDs23.CodeType == PCI_CODE_TYPE_EFI_IMAGE || PciDs30.CodeType == PCI_CODE_TYPE_EFI_IMAGE) {
+ fprintf (stdout, " (EFI image)\n");
+ //
+ // Re-read the header as an EFI ROM header, then dump more info
+ //
+ fprintf (stdout, " EFI ROM header contents\n");
+ if (fseek (InFptr, ImageStart, SEEK_SET)) {
+ Error (NULL, 0, 5001, "Failed to re-seek to ROM header structure!", NULL);
+ goto BailOut;
+ }
+
+ if (fread (&EfiRomHdr, sizeof (EfiRomHdr), 1, InFptr) != 1) {
+ Error (NULL, 0, 5001, "Failed to read EFI PCI ROM header from file!", NULL);
+ goto BailOut;
+ }
+ //
+ // Now dump more info
+ //
+ fprintf (stdout, " EFI Signature 0x%04X\n", (unsigned) EfiRomHdr.EfiSignature);
+ fprintf (
+ stdout,
+ " Compression Type 0x%04X ",
+ EfiRomHdr.CompressionType
+ );
+ if (EfiRomHdr.CompressionType == EFI_PCI_EXPANSION_ROM_HEADER_COMPRESSED) {
+ fprintf (stdout, "(compressed)\n");
+ } else {
+ fprintf (stdout, "(not compressed)\n");
+ }
+
+ fprintf (
+ stdout,
+ " Machine type 0x%04X (%s)\n",
+ EfiRomHdr.EfiMachineType,
+ GetMachineTypeStr (EfiRomHdr.EfiMachineType)
+ );
+ fprintf (
+ stdout,
+ " Subsystem 0x%04X (%s)\n",
+ EfiRomHdr.EfiSubsystem,
+ GetSubsystemTypeStr (EfiRomHdr.EfiSubsystem)
+ );
+ fprintf (
+ stdout,
+ " EFI image offset 0x%04X (@0x%X)\n",
+ EfiRomHdr.EfiImageHeaderOffset,
+ EfiRomHdr.EfiImageHeaderOffset + (unsigned) ImageStart
+ );
+
+ } else {
+ //
+ // Not an EFI image
+ //
+ fprintf (stdout, "\n");
+ }
+ //
+ // If code type is EFI image, then dump it as well?
+ //
+ // if (PciDs.CodeType == PCI_CODE_TYPE_EFI_IMAGE) {
+ // }
+ //
+ // If last image, then we're done
+ //
+ if (PciDs23.Indicator == INDICATOR_LAST || PciDs30.Indicator == INDICATOR_LAST) {
+ goto BailOut;
+ }
+ //
+ // Seek to the start of the next image
+ //
+ if (mOptions.Pci23 == 1) {
+ if (fseek (InFptr, ImageStart + (PciDs23.ImageLength * 512), SEEK_SET)) {
+ Error (NULL, 0, 3001, "Not supported", "Failed to seek to next image!");
+ goto BailOut;
+ }
+ } else {
+ if (fseek (InFptr, ImageStart + (PciDs30.ImageLength * 512), SEEK_SET)) {
+ Error (NULL, 0, 3001, "Not supported", "Failed to seek to next image!");
+ goto BailOut;
+ }
+ }
+ }
+
+BailOut:
+ fclose (InFptr);
+}
+
+char *
+GetMachineTypeStr (
+ UINT16 MachineType
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ MachineType - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ int Index;
+
+ for (Index = 0; mMachineTypes[Index].Name != NULL; Index++) {
+ if (mMachineTypes[Index].Value == MachineType) {
+ return mMachineTypes[Index].Name;
+ }
+ }
+
+ return "unknown";
+}
+
+static
+char *
+GetSubsystemTypeStr (
+ UINT16 SubsystemType
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ SubsystemType - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+{
+ int Index;
+
+ for (Index = 0; mSubsystemTypes[Index].Name != NULL; Index++) {
+ if (mSubsystemTypes[Index].Value == SubsystemType) {
+ return mSubsystemTypes[Index].Name;
+ }
+ }
+
+ return "unknown";
+}
diff --git a/BaseTools/Source/C/EfiRom/EfiRom.h b/BaseTools/Source/C/EfiRom/EfiRom.h
new file mode 100644
index 0000000000..d87c4c61b7
--- /dev/null
+++ b/BaseTools/Source/C/EfiRom/EfiRom.h
@@ -0,0 +1,366 @@
+/** @file
+
+Copyright (c) 1999 - 2008, Intel Corporation. All rights reserved.
+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.
+
+
+Module Name:
+
+ EfiRom.h
+
+Abstract:
+
+ This file contains the relevant declarations required
+ to generate Option Rom File
+
+**/
+
+#ifndef __EFI_ROM_H__
+#define __EFI_ROM_H__
+
+#include
+#include
+#include
+
+#include
+#include // for PE32 structure definitions
+
+#include // for option ROM header structures
+#include
+
+#include "Compress.h"
+#include "CommonLib.h"
+
+//
+// Version of this utility
+//
+#define UTILITY_NAME "EfiRom"
+#define UTILITY_MAJOR_VERSION 0
+#define UTILITY_MINOR_VERSION 1
+
+//
+// Define the max length of a filename
+//
+#define MAX_PATH 200
+
+//
+// Define the default file extension name
+//
+#define DEFAULT_OUTPUT_EXTENSION ".rom"
+
+//
+// Max size for an option ROM image
+//
+#define MAX_OPTION_ROM_SIZE (1024 * 1024 * 16) // 16MB
+
+//
+// Values for the indicator field in the PCI data structure
+//
+#define INDICATOR_LAST 0x80 // last file in series of files
+
+//
+// Masks for the FILE_LIST.FileFlags field
+//
+#define FILE_FLAG_BINARY 0x01
+#define FILE_FLAG_EFI 0x02
+#define FILE_FLAG_COMPRESS 0x04
+
+//
+// Use this linked list structure to keep track of all the filenames
+// specified on the command line.
+//
+typedef struct _FILE_LIST {
+ struct _FILE_LIST *Next;
+ CHAR8 *FileName;
+ UINT32 FileFlags;
+ UINT32 ClassCode;
+ UINT16 CodeRevision;
+} FILE_LIST;
+
+//
+// Use this to track our command-line options
+//
+typedef struct {
+ CHAR8 OutFileName[MAX_PATH];
+ INT8 NoLast;
+ UINT16 ClassCode;
+ UINT16 PciRevision;
+ UINT16 VendId;
+ UINT16 DevId;
+ UINT8 VendIdValid;
+ UINT8 DevIdValid;
+ INT8 Verbose;
+ INT8 Quiet;
+ INT8 Debug;
+ INT8 Pci23;
+ INT8 Pci30;
+ INT8 DumpOption;
+// INT8 Help;
+// INT8 Version;
+ FILE_LIST *FileList;
+} OPTIONS;
+
+//
+// Make a global structure to keep track of command-line options
+//
+static OPTIONS mOptions;
+
+//
+// Use these to convert from machine type value to a named type
+//
+typedef struct {
+ UINT16 Value;
+ CHAR8 *Name;
+} STRING_LOOKUP;
+
+//
+// Machine Types
+//
+static STRING_LOOKUP mMachineTypes[] = {
+ { EFI_IMAGE_MACHINE_IA32, "IA32" },
+ { EFI_IMAGE_MACHINE_IA64, "IA64" },
+ { EFI_IMAGE_MACHINE_EBC, "EBC" },
+ { 0, NULL }
+};
+
+//
+// Subsystem Types
+//
+static STRING_LOOKUP mSubsystemTypes[] = {
+ { EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION, "EFI application" },
+ { EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER, "EFI boot service driver" },
+ { EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER, "EFI runtime driver" },
+ { 0, NULL }
+};
+
+//
+// Function prototypes
+//
+static
+void
+Version (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Displays the utility version to STDOUT
+
+Arguments:
+
+ None
+
+Returns:
+
+ None
+
+--*/
+;
+
+static
+void
+Usage (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Displays the utility usage syntax to STDOUT
+
+Arguments:
+
+ None
+
+Returns:
+
+ None
+
+--*/
+;
+
+static
+int
+ParseCommandLine (
+ int Argc,
+ char *Argv[],
+ OPTIONS *Options
+ )
+/*++
+
+Routine Description:
+
+ Given the Argc/Argv program arguments, and a pointer to an options structure,
+ parse the command-line options and check their validity.
+
+Arguments:
+
+ Argc - standard C main() argument count
+ Argv[] - standard C main() argument list
+ Options - pointer to a structure to store the options in
+
+Returns:
+
+ STATUS_SUCCESS success
+ non-zero otherwise
+
+--*/
+;
+
+static
+int
+CheckPE32File (
+ FILE *Fptr,
+ UINT16 *MachineType,
+ UINT16 *SubSystem
+ )
+/*++
+
+Routine Description:
+
+ Given the Argc/Argv program arguments, and a pointer to an options structure,
+ parse the command-line options and check their validity.
+
+Arguments:
+
+ Argc - standard C main() argument count
+ Argv[] - standard C main() argument list
+ Options - pointer to a structure to store the options in
+
+Returns:
+
+ STATUS_SUCCESS success
+ non-zero otherwise
+
+--*/
+;
+
+static
+int
+ProcessEfiFile (
+ FILE *OutFptr,
+ FILE_LIST *InFile,
+ UINT16 VendId,
+ UINT16 DevId,
+ UINT32 *Size
+ )
+/*++
+
+Routine Description:
+
+ Process a PE32 EFI file.
+
+Arguments:
+
+ OutFptr - file pointer to output binary ROM image file we're creating
+ InFile - structure contains information on the PE32 file to process
+ VendId - vendor ID as required in the option ROM header
+ DevId - device ID as required in the option ROM header
+ Size - pointer to where to return the size added to the output file
+
+Returns:
+
+ 0 - successful
+
+--*/
+;
+
+static
+int
+ProcessBinFile (
+ FILE *OutFptr,
+ FILE_LIST *InFile,
+ UINT32 *Size
+ )
+/*++
+
+Routine Description:
+
+ Process a binary input file.
+
+Arguments:
+
+ OutFptr - file pointer to output binary ROM image file we're creating
+ InFile - structure contains information on the binary file to process
+ Size - pointer to where to return the size added to the output file
+
+Returns:
+
+ 0 - successful
+
+--*/
+;
+
+static
+void
+DumpImage (
+ FILE_LIST *InFile
+ )
+/*++
+
+Routine Description:
+
+ Dump the headers of an existing option ROM image
+
+Arguments:
+
+ InFile - the file name of an existing option ROM image
+
+Returns:
+
+ none
+
+--*/
+;
+
+char *
+GetMachineTypeStr (
+ UINT16 MachineType
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ MachineType - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+;
+
+static
+char *
+GetSubsystemTypeStr (
+ UINT16 SubsystemType
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ SubsystemType - GC_TODO: add argument description
+
+Returns:
+
+ GC_TODO: add return values
+
+--*/
+;
+
+#endif
diff --git a/BaseTools/Source/C/EfiRom/GNUmakefile b/BaseTools/Source/C/EfiRom/GNUmakefile
new file mode 100644
index 0000000000..eb76913713
--- /dev/null
+++ b/BaseTools/Source/C/EfiRom/GNUmakefile
@@ -0,0 +1,22 @@
+## @file
+# Windows makefile for 'EfiRom' module build.
+#
+# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.
+# 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.
+#
+ARCH ?= IA32
+MAKEROOT ?= ..
+
+APPNAME = EfiRom
+
+LIBS = -lCommon
+
+OBJECTS = EfiRom.o
+
+include $(MAKEROOT)/Makefiles/app.makefile
diff --git a/BaseTools/Source/C/EfiRom/Makefile b/BaseTools/Source/C/EfiRom/Makefile
new file mode 100644
index 0000000000..67a9f2521b
--- /dev/null
+++ b/BaseTools/Source/C/EfiRom/Makefile
@@ -0,0 +1,22 @@
+## @file
+# Windows makefile for 'EfiRom' module build.
+#
+# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.
+# 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.
+#
+!INCLUDE ..\Makefiles\ms.common
+
+APPNAME = EfiRom
+
+LIBS = $(LIB_PATH)\Common.lib
+
+OBJECTS = EfiRom.obj
+
+!INCLUDE ..\Makefiles\ms.app
+
diff --git a/BaseTools/Source/C/GNUmakefile b/BaseTools/Source/C/GNUmakefile
new file mode 100644
index 0000000000..ad034be538
--- /dev/null
+++ b/BaseTools/Source/C/GNUmakefile
@@ -0,0 +1,90 @@
+## @file
+# GNU Make makefile for C tools build.
+#
+# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.
+#
+# 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.
+#
+
+ifndef ARCH
+ #
+ # If ARCH is not defined, then we use 'uname -m' to attempt
+ # try to figure out the appropriate ARCH.
+ #
+ uname_m = $(shell uname -m)
+ $(info Attempting to detect ARCH from 'uname -m': $(uname_m))
+ ifeq ($(uname_m),x86_64)
+ ARCH=X64
+ endif
+ ifeq ($(uname_m),i386)
+ ARCH=IA32
+ endif
+ ifeq ($(uname_m),i686)
+ ARCH=IA32
+ endif
+ ifndef ARCH
+ $(info Could not detected ARCH from uname results)
+ $(error ARCH is not defined!)
+ endif
+ $(info Detected ARCH of $(ARCH) using uname.)
+endif
+
+export ARCH
+
+MAKEROOT = .
+
+include Makefiles/header.makefile
+
+all: makerootdir subdirs $(MAKEROOT)/libs
+ @echo Finished building BaseTools C Tools with ARCH=$(ARCH)
+
+LIBRARIES = Common
+# NON_BUILDABLE_APPLICATIONS = GenBootSector BootSectImage
+APPLICATIONS = \
+ GnuGenBootSector \
+ BootSectImage \
+ EfiLdrImage \
+ EfiRom \
+ GenFfs \
+ GenFv \
+ GenFw \
+ GenPage \
+ GenSec \
+ GenCrc32 \
+ GenVtf \
+ LzmaCompress \
+ Split \
+ TianoCompress \
+ VolInfo \
+ VfrCompile
+
+SUBDIRS := $(LIBRARIES) $(APPLICATIONS)
+
+.PHONY: outputdirs
+makerootdir:
+ -mkdir -p $(MAKEROOT)
+
+.PHONY: subdirs $(SUBDIRS)
+subdirs: $(SUBDIRS)
+$(SUBDIRS):
+ $(MAKE) -C $@
+
+.PHONY: $(patsubst %,%-clean,$(sort $(SUBDIRS)))
+$(patsubst %,%-clean,$(sort $(SUBDIRS))):
+ -$(MAKE) -C $(@:-clean=) clean
+
+clean: $(patsubst %,%-clean,$(sort $(SUBDIRS)))
+
+clean: localClean
+
+localClean:
+ rm -f $(MAKEROOT)/bin/*
+ -rmdir $(MAKEROOT)/libs $(MAKEROOT)/bin
+
+include Makefiles/footer.makefile
diff --git a/BaseTools/Source/C/GenBootSector/FatFormat.h b/BaseTools/Source/C/GenBootSector/FatFormat.h
new file mode 100644
index 0000000000..1f77e879b3
--- /dev/null
+++ b/BaseTools/Source/C/GenBootSector/FatFormat.h
@@ -0,0 +1,152 @@
+/** @file
+
+ Fat file system structure and definition.
+
+Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.
+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.
+
+--*/
+
+#ifndef _FAT_BPB_H_
+#define _FAT_BPB_H_
+
+#include "CommonLib.h"
+
+#pragma pack(1)
+
+typedef struct {
+ //
+ // Fat common field
+ //
+ UINT8 BS_jmpBoot[3];
+ CHAR8 BS_OEMName[8];
+ UINT16 BPB_BytsPerSec;
+ UINT8 BPB_SecPerClus;
+ UINT16 BPB_RsvdSecCnt;
+ UINT8 BPB_NumFATs;
+ UINT16 BPB_RootEntCnt;
+ UINT16 BPB_TotSec16;
+ UINT8 BPB_Media;
+ UINT16 BPB_FATSz16;
+ UINT16 BPB_SecPerTrk;
+ UINT16 BPB_NumHeads;
+ UINT32 BPB_HiddSec;
+ UINT32 BPB_TotSec32;
+
+ //
+ // Fat12/16 specific field
+ //
+ UINT8 BS_DrvNum;
+ UINT8 BS_Reserved1;
+ UINT8 BS_BootSig;
+ UINT32 BS_VolID;
+ CHAR8 BS_VolLab[11];
+ CHAR8 BS_FilSysType[8];
+
+ //
+ // Boot Code and Data
+ //
+ UINT8 Reserved[448];
+
+ //
+ // Fat common signature - 0xAA55
+ //
+ UINT16 Signature;
+} FAT12_16_BPB_STRUCT;
+
+typedef struct {
+ //
+ // Fat common field
+ //
+ UINT8 BS_jmpBoot[3];
+ CHAR8 BS_OEMName[8];
+ UINT16 BPB_BytsPerSec;
+ UINT8 BPB_SecPerClus;
+ UINT16 BPB_RsvdSecCnt;
+ UINT8 BPB_NumFATs;
+ UINT16 BPB_RootEntCnt;
+ UINT16 BPB_TotSec16;
+ UINT8 BPB_Media;
+ UINT16 BPB_FATSz16;
+ UINT16 BPB_SecPerTrk;
+ UINT16 BPB_NumHeads;
+ UINT32 BPB_HiddSec;
+ UINT32 BPB_TotSec32;
+
+ //
+ // Fat32 specific field
+ //
+ UINT32 BPB_FATSz32;
+ UINT16 BPB_ExtFlags;
+ UINT16 BPB_FSVer;
+ UINT32 BPB_RootClus;
+ UINT16 BPB_FSInfo;
+ UINT16 BPB_BkBootSec;
+ UINT8 BPB_Reserved[12];
+ UINT8 BS_DrvNum;
+ UINT8 BS_Reserved1;
+ UINT8 BS_BootSig;
+ UINT32 BS_VolID;
+ CHAR8 BS_VolLab[11];
+ CHAR8 BS_FilSysType[8];
+
+ //
+ // Boot Code and Data
+ //
+ UINT8 Reserved[420];
+
+ //
+ // Fat common signature - 0xAA55
+ //
+ UINT16 Signature;
+} FAT32_BPB_STRUCT;
+
+typedef union {
+ FAT12_16_BPB_STRUCT Fat12_16;
+ FAT32_BPB_STRUCT Fat32;
+} FAT_BPB_STRUCT;
+
+typedef enum {
+ FatTypeUnknown,
+ FatTypeFat12,
+ FatTypeFat16,
+ FatTypeFat32,
+ FatTypeMax
+} FAT_TYPE;
+
+typedef struct {
+ CHAR8 DIR_Name[11];
+ UINT8 DIR_Attr;
+ UINT8 DIR_NTRes;
+ UINT8 DIR_CrtTimeTenth;
+ UINT16 DIR_CrtTime;
+ UINT16 DIR_CrtDate;
+ UINT16 DIR_LstAccDate;
+ UINT16 DIR_FstClusHI;
+ UINT16 DIR_WrtTime;
+ UINT16 DIR_WrtDate;
+ UINT16 DIR_FstClusLO;
+ UINT32 DIR_FileSize;
+} FAT_DIRECTORY_ENTRY;
+
+#pragma pack()
+
+#define FAT_MAX_FAT12_CLUSTER 0xFF5
+#define FAT_MAX_FAT16_CLUSTER 0xFFF5
+
+#define FAT_BS_SIGNATURE 0xAA55
+#define FAT_BS_BOOTSIG 0x29
+#define FAT_BS_JMP1 0xEB
+#define FAT_BS_JMP2 0xE9
+#define FAT_FILSYSTYPE "FAT "
+#define FAT12_FILSYSTYPE "FAT12 "
+#define FAT16_FILSYSTYPE "FAT16 "
+#define FAT32_FILSYSTYPE "FAT32 "
+
+#endif
diff --git a/BaseTools/Source/C/GenBootSector/GenBootSector.c b/BaseTools/Source/C/GenBootSector/GenBootSector.c
new file mode 100644
index 0000000000..4a9a0e1b57
--- /dev/null
+++ b/BaseTools/Source/C/GenBootSector/GenBootSector.c
@@ -0,0 +1,796 @@
+/** @file
+
+Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.
+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.
+
+Module Name:
+
+ genbootsector.c
+
+Abstract:
+ Reading/writing MBR/DBR.
+ NOTE:
+ If we write MBR to disk, we just update the MBR code and the partition table wouldn't be over written.
+ If we process DBR, we will patch MBR to set first partition active if no active partition exists.
+
+**/
+
+#include
+#include
+#include
+#include
+
+#include "ParseInf.h"
+#include "EfiUtilityMsgs.h"
+
+//
+// Utility Name
+//
+#define UTILITY_NAME "GenBootSector"
+
+//
+// Utility version information
+//
+#define UTILITY_MAJOR_VERSION 0
+#define UTILITY_MINOR_VERSION 1
+
+#define MAX_DRIVE 26
+#define PARTITION_TABLE_OFFSET 0x1BE
+
+#define SIZE_OF_PARTITION_ENTRY 0x10
+
+#define PARTITION_ENTRY_STARTLBA_OFFSET 8
+
+#define PARTITION_ENTRY_NUM 4
+
+INT
+GetDrvNumOffset (
+ IN VOID *BootSector
+ );
+
+typedef enum {
+ PatchTypeUnknown,
+ PatchTypeFloppy,
+ PatchTypeIde,
+ PatchTypeUsb,
+ PatchTypeFileImage // input and output are all file image, patching action is same as PatchTypeFloppy
+} PATCH_TYPE;
+
+typedef enum {
+ PathUnknown,
+ PathFile,
+ PathFloppy,
+ PathUsb,
+ PathIde
+} PATH_TYPE;
+
+typedef enum {
+ ErrorSuccess,
+ ErrorFileCreate,
+ ErrorFileReadWrite,
+ ErrorNoMbr,
+ ErrorFatType,
+ ErrorPath,
+} ERROR_STATUS;
+
+CHAR *ErrorStatusDesc[] = {
+ "Success",
+ "Failed to create files",
+ "Failed to read/write files",
+ "No MBR exists",
+ "Failed to detect Fat type",
+ "Inavlid path"
+};
+
+typedef struct _DRIVE_TYPE_DESC {
+ UINT Type;
+ CHAR *Description;
+} DRIVE_TYPE_DESC;
+
+#define DRIVE_TYPE_ITEM(x) {x, #x}
+DRIVE_TYPE_DESC DriveTypeDesc[] = {
+ DRIVE_TYPE_ITEM (DRIVE_UNKNOWN),
+ DRIVE_TYPE_ITEM (DRIVE_NO_ROOT_DIR),
+ DRIVE_TYPE_ITEM (DRIVE_REMOVABLE),
+ DRIVE_TYPE_ITEM (DRIVE_FIXED),
+ DRIVE_TYPE_ITEM (DRIVE_REMOTE),
+ DRIVE_TYPE_ITEM (DRIVE_CDROM),
+ DRIVE_TYPE_ITEM (DRIVE_RAMDISK),
+ (UINT) -1, NULL
+};
+
+typedef struct _DRIVE_INFO {
+ CHAR VolumeLetter;
+ DRIVE_TYPE_DESC *DriveType;
+ UINT DiskNumber;
+} DRIVE_INFO;
+
+typedef struct _PATH_INFO {
+ CHAR *Path;
+ CHAR PhysicalPath[260];
+ PATH_TYPE Type;
+ BOOL Input;
+} PATH_INFO;
+
+#define BOOT_SECTOR_LBA_OFFSET 0x1FA
+
+#define IsLetter(x) (((x) >= 'a' && (x) <= 'z') || ((x) >= 'A' && (x) <= 'Z'))
+
+BOOL
+GetDriveInfo (
+ CHAR VolumeLetter,
+ DRIVE_INFO *DriveInfo
+ )
+/*++
+Routine Description:
+ Get drive information including disk number and drive type,
+ where disknumber is useful for reading/writing disk raw data.
+ NOTE: Floppy disk doesn't have disk number but it doesn't matter because
+ we can reading/writing floppy disk without disk number.
+
+Arguments:
+ VolumeLetter : volume letter, e.g.: C for C:, A for A:
+ DriveInfo : pointer to DRIVE_INFO structure receiving drive information.
+
+Return:
+ TRUE : successful
+ FALSE : failed
+--*/
+{
+ HANDLE VolumeHandle;
+ STORAGE_DEVICE_NUMBER StorageDeviceNumber;
+ DWORD BytesReturned;
+ BOOL Success;
+ UINT DriveType;
+ UINT Index;
+
+ CHAR RootPath[] = "X:\\"; // "X:\" -> for GetDriveType
+ CHAR VolumeAccessPath[] = "\\\\.\\X:"; // "\\.\X:" -> to open the volume
+
+ RootPath[0] = VolumeAccessPath[4] = VolumeLetter;
+ DriveType = GetDriveType(RootPath);
+ if (DriveType != DRIVE_REMOVABLE && DriveType != DRIVE_FIXED) {
+ return FALSE;
+ }
+
+ DriveInfo->VolumeLetter = VolumeLetter;
+ VolumeHandle = CreateFile (
+ VolumeAccessPath,
+ 0,
+ FILE_SHARE_READ | FILE_SHARE_WRITE,
+ NULL,
+ OPEN_EXISTING,
+ 0,
+ NULL
+ );
+ if (VolumeHandle == INVALID_HANDLE_VALUE) {
+ fprintf (
+ stderr,
+ "error E0005: CreateFile failed: Volume = %s, LastError = 0x%x\n",
+ VolumeAccessPath,
+ GetLastError ()
+ );
+ return FALSE;
+ }
+
+ //
+ // Get Disk Number. It should fail when operating on floppy. That's ok
+ // because Disk Number is only needed when operating on Hard or USB disk.
+ //
+ // To direct write to disk:
+ // for USB and HD: use path = \\.\PHYSICALDRIVEx, where x is Disk Number
+ // for floppy: use path = \\.\X:, where X can be A or B
+ //
+ Success = DeviceIoControl(
+ VolumeHandle,
+ IOCTL_STORAGE_GET_DEVICE_NUMBER,
+ NULL,
+ 0,
+ &StorageDeviceNumber,
+ sizeof(StorageDeviceNumber),
+ &BytesReturned,
+ NULL
+ );
+ //
+ // DeviceIoControl should fail if Volume is floppy or network drive.
+ //
+ if (!Success) {
+ DriveInfo->DiskNumber = (UINT) -1;
+ } else if (StorageDeviceNumber.DeviceType != FILE_DEVICE_DISK) {
+ //
+ // Only care about the disk.
+ //
+ return FALSE;
+ } else{
+ DriveInfo->DiskNumber = StorageDeviceNumber.DeviceNumber;
+ }
+ CloseHandle(VolumeHandle);
+
+ //
+ // Fill in the type string
+ //
+ DriveInfo->DriveType = NULL;
+ for (Index = 0; DriveTypeDesc[Index].Description != NULL; Index ++) {
+ if (DriveType == DriveTypeDesc[Index].Type) {
+ DriveInfo->DriveType = &DriveTypeDesc[Index];
+ break;
+ }
+ }
+
+ if (DriveInfo->DriveType == NULL) {
+ //
+ // Should have a type.
+ //
+ fprintf (stderr, "error E3005: Fatal Error!!!\n");
+ return FALSE;
+ }
+ return TRUE;
+}
+
+VOID
+ListDrive (
+ VOID
+ )
+/*++
+Routine Description:
+ List every drive in current system and their information.
+
+--*/
+{
+ UINT Index;
+ DRIVE_INFO DriveInfo;
+
+ UINT Mask = GetLogicalDrives();
+
+ for (Index = 0; Index < MAX_DRIVE; Index++) {
+ if (((Mask >> Index) & 0x1) == 1) {
+ if (GetDriveInfo ('A' + (CHAR) Index, &DriveInfo)) {
+ if (Index < 2) {
+ // Floppy will occupy 'A' and 'B'
+ fprintf (
+ stdout,
+ "%c: - Type: %s\n",
+ DriveInfo.VolumeLetter,
+ DriveInfo.DriveType->Description
+ );
+ } else {
+ fprintf (
+ stdout,
+ "%c: - DiskNum: %u, Type: %s\n",
+ DriveInfo.VolumeLetter,
+ (unsigned) DriveInfo.DiskNumber,
+ DriveInfo.DriveType->Description
+ );
+ }
+ }
+ }
+ }
+
+}
+
+INT
+GetBootSectorOffset (
+ HANDLE DiskHandle,
+ PATH_INFO *PathInfo
+ )
+/*++
+Description:
+ Get the offset of boot sector.
+ For non-MBR disk, offset is just 0
+ for disk with MBR, offset needs to be caculated by parsing MBR
+
+ NOTE: if no one is active, we will patch MBR to select first partition as active.
+
+Arguments:
+ DiskHandle : HANDLE of disk
+ PathInfo : PATH_INFO structure.
+ WriteToDisk : TRUE indicates writing
+
+Return:
+ -1 : failed
+ o.w. : Offset to boot sector
+--*/
+{
+ BYTE DiskPartition[0x200];
+ DWORD BytesReturn;
+ DWORD DbrOffset;
+ DWORD Index;
+ BOOL HasMbr;
+
+ DbrOffset = 0;
+ HasMbr = FALSE;
+
+ SetFilePointer(DiskHandle, 0, NULL, FILE_BEGIN);
+ if (!ReadFile (DiskHandle, DiskPartition, 0x200, &BytesReturn, NULL)) {
+ return -1;
+ }
+
+ //
+ // Check Signature, Jmp, and Boot Indicator.
+ // if all pass, we assume MBR found.
+ //
+
+ // Check Signature: 55AA
+ if ((DiskPartition[0x1FE] == 0x55) && (DiskPartition[0x1FF] == 0xAA)) {
+ // Check Jmp: (EB ?? 90) or (E9 ?? ??)
+ if (((DiskPartition[0] != 0xEB) || (DiskPartition[2] != 0x90)) &&
+ (DiskPartition[0] != 0xE9)) {
+ // Check Boot Indicator: 0x00 or 0x80
+ // Boot Indicator is the first byte of Partition Entry
+ HasMbr = TRUE;
+ for (Index = 0; Index < PARTITION_ENTRY_NUM; ++Index) {
+ if ((DiskPartition[PARTITION_TABLE_OFFSET + Index * SIZE_OF_PARTITION_ENTRY] & 0x7F) != 0) {
+ HasMbr = FALSE;
+ break;
+ }
+ }
+ }
+ }
+
+ if (HasMbr) {
+ //
+ // Skip MBR
+ //
+ for (Index = 0; Index < PARTITION_ENTRY_NUM; Index++) {
+ //
+ // Found Boot Indicator.
+ //
+ if (DiskPartition[PARTITION_TABLE_OFFSET + (Index * SIZE_OF_PARTITION_ENTRY)] == 0x80) {
+ DbrOffset = *(DWORD *)&DiskPartition[PARTITION_TABLE_OFFSET + (Index * SIZE_OF_PARTITION_ENTRY) + PARTITION_ENTRY_STARTLBA_OFFSET];
+ break;
+ }
+ }
+ //
+ // If no boot indicator, we manually select 1st partition, and patch MBR.
+ //
+ if (Index == PARTITION_ENTRY_NUM) {
+ DbrOffset = *(DWORD *)&DiskPartition[PARTITION_TABLE_OFFSET + PARTITION_ENTRY_STARTLBA_OFFSET];
+ if (!PathInfo->Input && (PathInfo->Type == PathUsb)) {
+ SetFilePointer(DiskHandle, 0, NULL, FILE_BEGIN);
+ DiskPartition[PARTITION_TABLE_OFFSET] = 0x80;
+ WriteFile (DiskHandle, DiskPartition, 0x200, &BytesReturn, NULL);
+ }
+ }
+ }
+
+ return DbrOffset;
+}
+
+/**
+ * Get window file handle for input/ouput disk/file.
+ *
+ * @param PathInfo
+ * @param ProcessMbr
+ * @param FileHandle
+ *
+ * @return ERROR_STATUS
+ */
+ERROR_STATUS
+GetFileHandle (
+ PATH_INFO *PathInfo,
+ BOOL ProcessMbr,
+ HANDLE *FileHandle,
+ DWORD *DbrOffset
+ )
+{
+ DWORD OpenFlag;
+
+ OpenFlag = OPEN_ALWAYS;
+ if (PathInfo->Input || PathInfo->Type != PathFile) {
+ OpenFlag = OPEN_EXISTING;
+ }
+
+ *FileHandle = CreateFile(
+ PathInfo->PhysicalPath,
+ GENERIC_READ | GENERIC_WRITE,
+ FILE_SHARE_READ,
+ NULL,
+ OpenFlag,
+ FILE_ATTRIBUTE_NORMAL,
+ NULL
+ );
+ if (*FileHandle == INVALID_HANDLE_VALUE) {
+ return ErrorFileCreate;
+ }
+
+ if ((PathInfo->Type == PathIde) || (PathInfo->Type == PathUsb)){
+ *DbrOffset = GetBootSectorOffset (*FileHandle, PathInfo);
+ if (!ProcessMbr) {
+ //
+ // 1. Process boot sector, set file pointer to the beginning of boot sector
+ //
+ SetFilePointer (*FileHandle, *DbrOffset * 0x200, NULL, FILE_BEGIN);
+ } else if(*DbrOffset == 0) {
+ //
+ // If user want to process Mbr, but no Mbr exists, simply return FALSE
+ //
+ return ErrorNoMbr;
+ } else {
+ //
+ // 2. Process MBR, set file pointer to 0
+ //
+ SetFilePointer (*FileHandle, 0, NULL, FILE_BEGIN);
+ }
+ }
+
+ return ErrorSuccess;
+}
+
+/**
+ Writing or reading boot sector or MBR according to the argument.
+
+ @param InputInfo PATH_INFO instance for input path
+ @param OutputInfo PATH_INFO instance for output path
+ @param ProcessMbr TRUE is to process MBR, otherwise, processing boot sector
+
+ @return ERROR_STATUS
+ **/
+ERROR_STATUS
+ProcessBsOrMbr (
+ PATH_INFO *InputInfo,
+ PATH_INFO *OutputInfo,
+ BOOL ProcessMbr
+ )
+{
+ BYTE DiskPartition[0x200] = {0};
+ BYTE DiskPartitionBackup[0x200] = {0};
+ DWORD BytesReturn;
+ INT DrvNumOffset;
+ HANDLE InputHandle;
+ HANDLE OutputHandle;
+ ERROR_STATUS Status;
+ DWORD InputDbrOffset;
+ DWORD OutputDbrOffset;
+
+ //
+ // Create file Handle and move file Pointer is pointed to beginning of Mbr or Dbr
+ //
+ Status = GetFileHandle(InputInfo, ProcessMbr, &InputHandle, &InputDbrOffset);
+ if (Status != ErrorSuccess) {
+ return Status;
+ }
+
+ //
+ // Create file Handle and move file Pointer is pointed to beginning of Mbr or Dbr
+ //
+ Status = GetFileHandle(OutputInfo, ProcessMbr, &OutputHandle, &OutputDbrOffset);
+ if (Status != ErrorSuccess) {
+ return Status;
+ }
+
+ //
+ // Read boot sector from source disk/file
+ //
+ if (!ReadFile (InputHandle, DiskPartition, 0x200, &BytesReturn, NULL)) {
+ return ErrorFileReadWrite;
+ }
+
+ if (InputInfo->Type == PathUsb) {
+ // Manually set BS_DrvNum to 0x80 as window's format.exe has a bug which will clear this field discarding USB disk's MBR.
+ // offset of BS_DrvNum is 0x24 for FAT12/16
+ // 0x40 for FAT32
+ //
+ DrvNumOffset = GetDrvNumOffset (DiskPartition);
+ if (DrvNumOffset == -1) {
+ return ErrorFatType;
+ }
+ //
+ // Some legacy BIOS require 0x80 discarding MBR.
+ // Question left here: is it needed to check Mbr before set 0x80?
+ //
+ DiskPartition[DrvNumOffset] = ((InputDbrOffset > 0) ? 0x80 : 0);
+ }
+
+ if (InputInfo->Type == PathIde) {
+ //
+ // Patch LBAOffsetForBootSector
+ //
+ *(DWORD *)&DiskPartition [BOOT_SECTOR_LBA_OFFSET] = InputDbrOffset;
+ }
+
+ if (OutputInfo->Type != PathFile) {
+ if (ProcessMbr) {
+ //
+ // Use original partition table
+ //
+ if (!ReadFile (OutputHandle, DiskPartitionBackup, 0x200, &BytesReturn, NULL)) {
+ return ErrorFileReadWrite;
+ }
+ memcpy (DiskPartition + 0x1BE, DiskPartitionBackup + 0x1BE, 0x40);
+ SetFilePointer (OutputHandle, 0, NULL, FILE_BEGIN);
+
+ }
+ }
+
+ //
+ // Write boot sector to taget disk/file
+ //
+ if (!WriteFile (OutputHandle, DiskPartition, 0x200, &BytesReturn, NULL)) {
+ return ErrorFileReadWrite;
+ }
+
+ CloseHandle (InputHandle);
+ CloseHandle (OutputHandle);
+
+ return ErrorSuccess;
+}
+
+void
+Version (
+ void
+ )
+/*++
+
+Routine Description:
+
+ Displays the standard utility information to SDTOUT
+
+Arguments:
+
+ None
+
+Returns:
+
+ None
+
+--*/
+{
+ printf ("%s v%d.%d -Utility to retrieve and update the boot sector or MBR.\n", UTILITY_NAME, UTILITY_MAJOR_VERSION, UTILITY_MINOR_VERSION);
+ printf ("Copyright (c) 2009 - 2010 Intel Corporation. All rights reserved.\n");
+}
+
+VOID
+PrintUsage (
+ void
+ )
+{
+ Version();
+ printf ("\nUsage: \n\
+ GenBootSector\n\
+ [-l, --list list disks]\n\
+ [-i, --input Filename]\n\
+ [-o, --output Filename]\n\
+ [-m, --mbr process the MBR also]\n\
+ [-v, --verbose]\n\
+ [--version]\n\
+ [-q, --quiet disable all messages except fatal errors]\n\
+ [-d, --debug[#]\n\
+ [-h, --help]\n");
+
+}
+
+/**
+ Get path information, including physical path for windows platform.
+
+ @param PathInfo Point to PATH_INFO structure.
+
+ @return whether path is valid.
+**/
+ERROR_STATUS
+GetPathInfo (
+ PATH_INFO *PathInfo
+ )
+{
+ DRIVE_INFO DriveInfo;
+ CHAR VolumeLetter;
+ CHAR DiskPathTemplate[] = "\\\\.\\PHYSICALDRIVE%u";
+ CHAR FloppyPathTemplate[] = "\\\\.\\%c:";
+ FILE *f;
+
+ //
+ // If path is disk path
+ //
+ if (IsLetter(PathInfo->Path[0]) && (PathInfo->Path[1] == ':') && (PathInfo->Path[2] == '\0')) {
+ VolumeLetter = PathInfo->Path[0];
+ if ((VolumeLetter == 'A') || (VolumeLetter == 'a') ||
+ (VolumeLetter == 'B') || (VolumeLetter == 'b')) {
+ PathInfo->Type = PathFloppy;
+ sprintf (PathInfo->PhysicalPath, FloppyPathTemplate, VolumeLetter);
+ return ErrorSuccess;
+ }
+
+ if (!GetDriveInfo(VolumeLetter, &DriveInfo)) {
+ fprintf (stderr, "ERROR: GetDriveInfo - 0x%x\n", GetLastError ());
+ return ErrorPath;
+ }
+
+ if (!PathInfo->Input && (DriveInfo.DriveType->Type == DRIVE_FIXED)) {
+ fprintf (stderr, "ERROR: Could patch own IDE disk!\n");
+ return ErrorPath;
+ }
+
+ sprintf(PathInfo->PhysicalPath, DiskPathTemplate, DriveInfo.DiskNumber);
+ if (DriveInfo.DriveType->Type == DRIVE_REMOVABLE) {
+ PathInfo->Type = PathUsb;
+ } else if (DriveInfo.DriveType->Type == DRIVE_FIXED) {
+ PathInfo->Type = PathIde;
+ } else {
+ fprintf (stderr, "ERROR, Invalid disk path - %s", PathInfo->Path);
+ return ErrorPath;
+ }
+
+ return ErrorSuccess;
+ }
+
+ PathInfo->Type = PathFile;
+ if (PathInfo->Input) {
+ //
+ // If path is file path, check whether file is valid.
+ //
+ f = fopen (PathInfo->Path, "r");
+ if (f == NULL) {
+ fprintf (stderr, "error E2003: File was not provided!\n");
+ return ErrorPath;
+ }
+ }
+ PathInfo->Type = PathFile;
+ strcpy(PathInfo->PhysicalPath, PathInfo->Path);
+
+ return ErrorSuccess;
+}
+
+INT
+main (
+ INT argc,
+ CHAR *argv[]
+ )
+{
+ CHAR8 *AppName;
+ INTN Index;
+ BOOLEAN ProcessMbr;
+ ERROR_STATUS Status;
+ EFI_STATUS EfiStatus;
+ PATH_INFO InputPathInfo = {0};
+ PATH_INFO OutputPathInfo = {0};
+ UINT64 LogLevel;
+
+ SetUtilityName (UTILITY_NAME);
+
+ AppName = *argv;
+ argv ++;
+ argc --;
+
+ ProcessMbr = FALSE;
+
+ if (argc == 0) {
+ PrintUsage();
+ return 0;
+ }
+
+ //
+ // Parse command line
+ //
+ for (Index = 0; Index < argc; Index ++) {
+ if ((stricmp (argv[Index], "-l") == 0) || (stricmp (argv[Index], "--list") == 0)) {
+ ListDrive ();
+ return 0;
+ }
+
+ if ((stricmp (argv[Index], "-m") == 0) || (stricmp (argv[Index], "--mbr") == 0)) {
+ ProcessMbr = TRUE;
+ continue;
+ }
+
+ if ((stricmp (argv[Index], "-i") == 0) || (stricmp (argv[Index], "--input") == 0)) {
+ InputPathInfo.Path = argv[Index + 1];
+ InputPathInfo.Input = TRUE;
+ if (InputPathInfo.Path == NULL) {
+ Error (NULL, 0, 1003, "Invalid option value", "Input file name can't be NULL");
+ return 1;
+ }
+ if (InputPathInfo.Path[0] == '-') {
+ Error (NULL, 0, 1003, "Invalid option value", "Input file is missing");
+ return 1;
+ }
+ ++Index;
+ continue;
+ }
+
+ if ((stricmp (argv[Index], "-o") == 0) || (stricmp (argv[Index], "--output") == 0)) {
+ OutputPathInfo.Path = argv[Index + 1];
+ OutputPathInfo.Input = FALSE;
+ if (OutputPathInfo.Path == NULL) {
+ Error (NULL, 0, 1003, "Invalid option value", "Output file name can't be NULL");
+ return 1;
+ }
+ if (OutputPathInfo.Path[0] == '-') {
+ Error (NULL, 0, 1003, "Invalid option value", "Output file is missing");
+ return 1;
+ }
+ ++Index;
+ continue;
+ }
+
+ if ((stricmp (argv[Index], "-h") == 0) || (stricmp (argv[Index], "--help") == 0)) {
+ PrintUsage ();
+ return 0;
+ }
+
+ if (stricmp (argv[Index], "--version") == 0) {
+ Version ();
+ return 0;
+ }
+
+ if ((stricmp (argv[Index], "-v") == 0) || (stricmp (argv[Index], "--verbose") == 0)) {
+ continue;
+ }
+
+ if ((stricmp (argv[Index], "-q") == 0) || (stricmp (argv[Index], "--quiet") == 0)) {
+ continue;
+ }
+
+ if ((stricmp (argv[Index], "-d") == 0) || (stricmp (argv[Index], "--debug") == 0)) {
+ EfiStatus = AsciiStringToUint64 (argv[Index + 1], FALSE, &LogLevel);
+ if (EFI_ERROR (EfiStatus)) {
+ Error (NULL, 0, 1003, "Invalid option value", "%s = %s", argv[Index], argv[Index + 1]);
+ return 1;
+ }
+ if (LogLevel > 9) {
+ Error (NULL, 0, 1003, "Invalid option value", "Debug Level range is 0-9, currnt input level is %d", (int) LogLevel);
+ return 1;
+ }
+ SetPrintLevel (LogLevel);
+ DebugMsg (NULL, 0, 9, "Debug Mode Set", "Debug Output Mode Level %s is set!", argv[Index + 1]);
+ ++Index;
+ continue;
+ }
+
+ //
+ // Don't recognize the parameter.
+ //
+ Error (NULL, 0, 1000, "Unknown option", "%s", argv[Index]);
+ return 1;
+ }
+
+ if (InputPathInfo.Path == NULL) {
+ Error (NULL, 0, 1001, "Missing options", "Input file is missing");
+ return 1;
+ }
+
+ if (OutputPathInfo.Path == NULL) {
+ Error (NULL, 0, 1001, "Missing options", "Output file is missing");
+ return 1;
+ }
+
+ if (GetPathInfo(&InputPathInfo) != ErrorSuccess) {
+ Error (NULL, 0, 1003, "Invalid option value", "Input file can't be found.");
+ return 1;
+ }
+
+ if (GetPathInfo(&OutputPathInfo) != ErrorSuccess) {
+ Error (NULL, 0, 1003, "Invalid option value", "Output file can't be found.");
+ return 1;
+ }
+
+ //
+ // Process DBR (Patch or Read)
+ //
+ Status = ProcessBsOrMbr (&InputPathInfo, &OutputPathInfo, ProcessMbr);
+
+ if (Status == ErrorSuccess) {
+ fprintf (
+ stdout,
+ "%s %s: successful!\n",
+ (OutputPathInfo.Type != PathFile) ? "Write" : "Read",
+ ProcessMbr ? "MBR" : "DBR"
+ );
+ return 0;
+ } else {
+ fprintf (
+ stderr,
+ "%s: %s %s: failed - %s (LastError: 0x%x)!\n",
+ (Status == ErrorNoMbr) ? "WARNING" : "ERROR",
+ (OutputPathInfo.Type != PathFile) ? "Write" : "Read",
+ ProcessMbr ? "MBR" : "DBR",
+ ErrorStatusDesc[Status],
+ GetLastError ()
+ );
+ return 1;
+ }
+}
diff --git a/BaseTools/Source/C/GenBootSector/GetDrvNumOffset.c b/BaseTools/Source/C/GenBootSector/GetDrvNumOffset.c
new file mode 100644
index 0000000000..065833b79f
--- /dev/null
+++ b/BaseTools/Source/C/GenBootSector/GetDrvNumOffset.c
@@ -0,0 +1,73 @@
+/** @file
+
+ Get Drv Num offset from Fat file system.
+
+Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.
+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.
+
+**/
+
+#include
+#include "FatFormat.h"
+
+INTN
+GetDrvNumOffset (
+ IN VOID *BootSector
+ )
+{
+ FAT_BPB_STRUCT *FatBpb;
+ UINTN RootDirSectors;
+ UINTN FATSz;
+ UINTN TotSec;
+ UINTN DataSec;
+ UINTN CountOfClusters;
+
+ FatBpb = (FAT_BPB_STRUCT *) BootSector;
+
+ //
+ // Check FAT type algorithm from FAT spec
+ //
+ RootDirSectors = ((FatBpb->Fat12_16.BPB_RootEntCnt * sizeof(FAT_DIRECTORY_ENTRY)) +
+ (FatBpb->Fat12_16.BPB_BytsPerSec - 1)) / FatBpb->Fat12_16.BPB_BytsPerSec;
+
+ if (FatBpb->Fat12_16.BPB_FATSz16 != 0) {
+ FATSz = FatBpb->Fat12_16.BPB_FATSz16;
+ } else {
+ FATSz = FatBpb->Fat32.BPB_FATSz32;
+ }
+ if (FATSz == 0) {
+ fprintf (stderr, "error E3003: FAT - BPB_FATSz16, BPB_FATSz32 - 0, expected: Non-Zero number\n");
+ return -1;
+ }
+
+ if (FatBpb->Fat12_16.BPB_TotSec16 != 0) {
+ TotSec = FatBpb->Fat12_16.BPB_TotSec16;
+ } else {
+ TotSec = FatBpb->Fat12_16.BPB_TotSec32;
+ }
+ if (TotSec == 0) {
+ fprintf (stderr, "error E3003: FAT - BPB_TotSec16, BPB_TotSec32 - 0, expected: Non-Zero number\n");
+ return -1;
+ }
+
+ DataSec = TotSec - (
+ FatBpb->Fat12_16.BPB_RsvdSecCnt +
+ FatBpb->Fat12_16.BPB_NumFATs * FATSz +
+ RootDirSectors
+ );
+
+ CountOfClusters = DataSec / FatBpb->Fat12_16.BPB_SecPerClus;
+
+ if (CountOfClusters < FAT_MAX_FAT16_CLUSTER) {
+ return (INTN) ((UINTN) &FatBpb->Fat12_16.BS_DrvNum - (UINTN) FatBpb);
+ } else {
+ return (INTN) ((UINTN) &FatBpb->Fat32.BS_DrvNum - (UINTN) FatBpb);
+ }
+}
+
diff --git a/BaseTools/Source/C/GenBootSector/Makefile b/BaseTools/Source/C/GenBootSector/Makefile
new file mode 100644
index 0000000000..6ba39db166
--- /dev/null
+++ b/BaseTools/Source/C/GenBootSector/Makefile
@@ -0,0 +1,22 @@
+## @file
+# Windows makefile for 'GenBootSector' module build.
+#
+# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.
+# 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.
+#
+!INCLUDE ..\Makefiles\ms.common
+
+APPNAME = GenBootSector
+
+LIBS = $(LIB_PATH)\Common.lib
+
+OBJECTS = GenBootSector.obj GetDrvNumOffset.obj
+
+!INCLUDE ..\Makefiles\ms.app
+
diff --git a/BaseTools/Source/C/GenCrc32/GNUmakefile b/BaseTools/Source/C/GenCrc32/GNUmakefile
new file mode 100644
index 0000000000..4f055c9b4e
--- /dev/null
+++ b/BaseTools/Source/C/GenCrc32/GNUmakefile
@@ -0,0 +1,22 @@
+## @file
+# Windows makefile for 'GenCrc32' module build.
+#
+# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.
+# 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.
+#
+ARCH ?= IA32
+MAKEROOT ?= ..
+
+APPNAME = GenCrc32
+
+LIBS = -lCommon
+
+OBJECTS = GenCrc32.o
+
+include $(MAKEROOT)/Makefiles/app.makefile
diff --git a/BaseTools/Source/C/GenCrc32/GenCrc32.c b/BaseTools/Source/C/GenCrc32/GenCrc32.c
new file mode 100644
index 0000000000..0a31f54890
--- /dev/null
+++ b/BaseTools/Source/C/GenCrc32/GenCrc32.c
@@ -0,0 +1,363 @@
+/** @file
+
+Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.
+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.
+
+Module Name:
+
+ GenCrc32.c
+
+Abstract:
+ Calculate Crc32 value and Verify Crc32 value for input data.
+
+**/
+
+#include
+#include
+#include
+
+#include "ParseInf.h"
+#include "EfiUtilityMsgs.h"
+#include "CommonLib.h"
+#include "Crc32.h"
+
+#define UTILITY_NAME "GenCrc32"
+#define UTILITY_MAJOR_VERSION 0
+#define UTILITY_MINOR_VERSION 1
+
+#define CRC32_NULL 0
+#define CRC32_ENCODE 1
+#define CRC32_DECODE 2
+
+VOID
+Version (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Displays the standard utility information to SDTOUT
+
+Arguments:
+
+ None
+
+Returns:
+
+ None
+
+--*/
+{
+ fprintf (stdout, "%s Version %d.%d\n", UTILITY_NAME, UTILITY_MAJOR_VERSION, UTILITY_MINOR_VERSION);
+}
+
+VOID
+Usage (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Displays the utility usage syntax to STDOUT
+
+Arguments:
+
+ None
+
+Returns:
+
+ None
+
+--*/
+{
+ //
+ // Summary usage
+ //
+ fprintf (stdout, "\nUsage: %s -e|-d [options] \n\n", UTILITY_NAME);
+
+ //
+ // Copyright declaration
+ //
+ fprintf (stdout, "Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.\n\n");
+
+ //
+ // Details Option
+ //
+ fprintf (stdout, "Options:\n");
+ fprintf (stdout, " -o FileName, --output FileName\n\
+ File will be created to store the ouput content.\n");
+ fprintf (stdout, " -e, --encode Calculate CRC32 value for the input file.\n");
+ fprintf (stdout, " -d, --decode Verify CRC32 value for the input file.\n");
+ fprintf (stdout, " -v, --verbose Turn on verbose output with informational messages.\n");
+ fprintf (stdout, " -q, --quiet Disable all messages except key message and fatal error\n");
+ fprintf (stdout, " --debug level Enable debug messages, at input debug level.\n");
+ fprintf (stdout, " --version Show program's version number and exit.\n");
+ fprintf (stdout, " -h, --help Show this help message and exit.\n");
+}
+
+int
+main (
+ int argc,
+ CHAR8 *argv[]
+ )
+/*++
+
+Routine Description:
+
+ Main function.
+
+Arguments:
+
+ argc - Number of command line parameters.
+ argv - Array of pointers to parameter strings.
+
+Returns:
+ STATUS_SUCCESS - Utility exits successfully.
+ STATUS_ERROR - Some error occurred during execution.
+
+--*/
+{
+ EFI_STATUS Status;
+ CHAR8 *OutputFileName;
+ CHAR8 *InputFileName;
+ UINT8 *FileBuffer;
+ UINT32 FileSize;
+ UINT64 LogLevel;
+ UINT8 FileAction;
+ UINT32 Crc32Value;
+ FILE *InFile;
+ FILE *OutFile;
+
+ //
+ // Init local variables
+ //
+ LogLevel = 0;
+ Status = EFI_SUCCESS;
+ InputFileName = NULL;
+ OutputFileName = NULL;
+ FileAction = CRC32_NULL;
+ InFile = NULL;
+ OutFile = NULL;
+ Crc32Value = 0;
+ FileBuffer = NULL;
+
+ SetUtilityName (UTILITY_NAME);
+
+ if (argc == 1) {
+ Error (NULL, 0, 1001, "Missing options", "no options input");
+ Usage ();
+ return STATUS_ERROR;
+ }
+
+ //
+ // Parse command line
+ //
+ argc --;
+ argv ++;
+
+ if ((stricmp (argv[0], "-h") == 0) || (stricmp (argv[0], "--help") == 0)) {
+ Version ();
+ Usage ();
+ return STATUS_SUCCESS;
+ }
+
+ if (stricmp (argv[0], "--version") == 0) {
+ Version ();
+ return STATUS_SUCCESS;
+ }
+
+ while (argc > 0) {
+ if ((stricmp (argv[0], "-o") == 0) || (stricmp (argv[0], "--output") == 0)) {
+ if (argv[1] == NULL || argv[1][0] == '-') {
+ Error (NULL, 0, 1003, "Invalid option value", "Output File name is missing for -o option");
+ goto Finish;
+ }
+ OutputFileName = argv[1];
+ argc -= 2;
+ argv += 2;
+ continue;
+ }
+
+ if ((stricmp (argv[0], "-e") == 0) || (stricmp (argv[0], "--encode") == 0)) {
+ FileAction = CRC32_ENCODE;
+ argc --;
+ argv ++;
+ continue;
+ }
+
+ if ((stricmp (argv[0], "-d") == 0) || (stricmp (argv[0], "--decode") == 0)) {
+ FileAction = CRC32_DECODE;
+ argc --;
+ argv ++;
+ continue;
+ }
+
+ if ((stricmp (argv[0], "-v") == 0) || (stricmp (argv[0], "--verbose") == 0)) {
+ SetPrintLevel (VERBOSE_LOG_LEVEL);
+ VerboseMsg ("Verbose output Mode Set!");
+ argc --;
+ argv ++;
+ continue;
+ }
+
+ if ((stricmp (argv[0], "-q") == 0) || (stricmp (argv[0], "--quiet") == 0)) {
+ SetPrintLevel (KEY_LOG_LEVEL);
+ KeyMsg ("Quiet output Mode Set!");
+ argc --;
+ argv ++;
+ continue;
+ }
+
+ if (stricmp (argv[0], "--debug") == 0) {
+ Status = AsciiStringToUint64 (argv[1], FALSE, &LogLevel);
+ if (EFI_ERROR (Status)) {
+ Error (NULL, 0, 1003, "Invalid option value", "%s = %s", argv[0], argv[1]);
+ goto Finish;
+ }
+ if (LogLevel > 9) {
+ Error (NULL, 0, 1003, "Invalid option value", "Debug Level range is 0-9, current input level is %d", (int) LogLevel);
+ goto Finish;
+ }
+ SetPrintLevel (LogLevel);
+ DebugMsg (NULL, 0, 9, "Debug Mode Set", "Debug Output Mode Level %s is set!", argv[1]);
+ argc -= 2;
+ argv += 2;
+ continue;
+ }
+
+ if (argv[0][0] == '-') {
+ Error (NULL, 0, 1000, "Unknown option", argv[0]);
+ goto Finish;
+ }
+
+ //
+ // Get Input file file name.
+ //
+ InputFileName = argv[0];
+ argc --;
+ argv ++;
+ }
+
+ VerboseMsg ("%s tool start.", UTILITY_NAME);
+
+ //
+ // Check Input paramters
+ //
+ if (FileAction == CRC32_NULL) {
+ Error (NULL, 0, 1001, "Missing option", "either the encode or the decode option must be specified!");
+ return STATUS_ERROR;
+ } else if (FileAction == CRC32_ENCODE) {
+ VerboseMsg ("File will be encoded by Crc32");
+ } else if (FileAction == CRC32_DECODE) {
+ VerboseMsg ("File will be decoded by Crc32");
+ }
+
+ if (InputFileName == NULL) {
+ Error (NULL, 0, 1001, "Missing option", "Input files are not specified");
+ goto Finish;
+ } else {
+ VerboseMsg ("Input file name is %s", InputFileName);
+ }
+
+ if (OutputFileName == NULL) {
+ Error (NULL, 0, 1001, "Missing option", "Output file are not specified");
+ goto Finish;
+ } else {
+ VerboseMsg ("Output file name is %s", OutputFileName);
+ }
+
+ //
+ // Open Input file and read file data.
+ //
+ InFile = fopen (InputFileName, "rb");
+ if (InFile == NULL) {
+ Error (NULL, 0, 0001, "Error opening file", InputFileName);
+ return STATUS_ERROR;
+ }
+
+ fseek (InFile, 0, SEEK_END);
+ FileSize = ftell (InFile);
+ fseek (InFile, 0, SEEK_SET);
+
+ FileBuffer = (UINT8 *) malloc (FileSize);
+ if (FileBuffer == NULL) {
+ Error (NULL, 0, 4001, "Resource", "memory cannot be allcoated!");
+ goto Finish;
+ }
+
+ fread (FileBuffer, 1, FileSize, InFile);
+ fclose (InFile);
+ VerboseMsg ("the size of the input file is %u bytes", (unsigned) FileSize);
+
+ //
+ // Open output file
+ //
+ OutFile = fopen (OutputFileName, "wb");
+ if (OutFile == NULL) {
+ Error (NULL, 0, 0001, "Error opening file", OutputFileName);
+ goto Finish;
+ }
+
+ //
+ // Calculate Crc32 value
+ //
+ if (FileAction == CRC32_ENCODE) {
+ Status = CalculateCrc32 (FileBuffer, FileSize, &Crc32Value);
+ if (Status != EFI_SUCCESS) {
+ Error (NULL, 0, 3000, "Invalid", "Calculate CRC32 value failed!");
+ goto Finish;
+ }
+ //
+ // Done, write output file.
+ //
+ fwrite (&Crc32Value, 1, sizeof (Crc32Value), OutFile);
+ VerboseMsg ("The calculated CRC32 value is 0x%08x", (unsigned) Crc32Value);
+ fwrite (FileBuffer, 1, FileSize, OutFile);
+ VerboseMsg ("the size of the encoded file is %u bytes", (unsigned) FileSize + sizeof (UINT32));
+ } else {
+ //
+ // Verify Crc32 Value
+ //
+ Status = CalculateCrc32 (FileBuffer + sizeof (UINT32), FileSize - sizeof (UINT32), &Crc32Value);
+ if (Status != EFI_SUCCESS) {
+ Error (NULL, 0, 3000, "Invalid", "Calculate CRC32 value failed!");
+ goto Finish;
+ }
+ VerboseMsg ("The calculated CRC32 value is 0x%08x and File Crc32 value is 0x%08x", (unsigned) Crc32Value, (unsigned) (*(UINT32 *)FileBuffer));
+ if (Crc32Value != *(UINT32 *)FileBuffer) {
+ Error (NULL, 0, 3000, "Invalid", "CRC32 value of input file is not correct!");
+ Status = STATUS_ERROR;
+ goto Finish;
+ }
+ //
+ // Done, write output file.
+ //
+ fwrite (FileBuffer + sizeof (UINT32), 1, FileSize - sizeof (UINT32), OutFile);
+ VerboseMsg ("the size of the decoded file is %u bytes", (unsigned) FileSize - sizeof (UINT32));
+ }
+
+Finish:
+ if (FileBuffer != NULL) {
+ free (FileBuffer);
+ }
+
+ if (OutFile != NULL) {
+ fclose (OutFile);
+ }
+
+ VerboseMsg ("%s tool done with return code is 0x%x.", UTILITY_NAME, GetUtilityStatus ());
+
+ return GetUtilityStatus ();
+}
+
+
+
+
diff --git a/BaseTools/Source/C/GenCrc32/Makefile b/BaseTools/Source/C/GenCrc32/Makefile
new file mode 100644
index 0000000000..e0049a4abd
--- /dev/null
+++ b/BaseTools/Source/C/GenCrc32/Makefile
@@ -0,0 +1,22 @@
+## @file
+# Windows makefile for 'GenCrc32' module build.
+#
+# Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.