summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorRichard J. Knight <rjknight@us.ibm.com>2017-10-13 15:49:25 -0500
committerRichard J. Knight <rjknight@us.ibm.com>2017-10-17 15:05:22 -0500
commit41e7df45e64f623499b8d286a4012e6e7d24eaf6 (patch)
treee7a54e4950d2610c3fddeaf2b74b53b424315bf1 /tools
downloadtalos-hcode-41e7df45e64f623499b8d286a4012e6e7d24eaf6.tar.gz
talos-hcode-41e7df45e64f623499b8d286a4012e6e7d24eaf6.zip
Initial hcode commit
Change-Id: I2c6c9b05c6afbd7732f472ea9cf049d00c5cad45
Diffstat (limited to 'tools')
-rwxr-xr-xtools/addCopyright1200
-rw-r--r--tools/build/Makefile39
-rw-r--r--tools/build/README.md209
-rw-r--r--tools/build/common.dir/cflags.env.mk27
-rw-r--r--tools/build/common.dir/clean.final.mk21
-rw-r--r--tools/build/common.dir/clean.rules.mk35
-rw-r--r--tools/build/common.dir/exe.rules.mk149
-rw-r--r--tools/build/common.dir/modules.rules.mk162
-rw-r--r--tools/build/common.dir/objects.rules.mk57
-rw-r--r--tools/build/common.dir/order.final.mk66
-rw-r--r--tools/build/common.dir/symlink.rules.mk41
-rw-r--r--tools/build/common.dir/util.rules.mk25
-rw-r--r--tools/build/common.dir/verbose.rules.mk42
-rw-r--r--tools/build/image.dir/assembler.rules.mk43
-rw-r--r--tools/build/image.dir/bin.rules.mk71
-rw-r--r--tools/build/image.dir/binheader.rules.mk164
-rw-r--r--tools/build/image.dir/cflags.env.mk44
-rw-r--r--tools/build/image.dir/ddcontainer.rules.mk67
-rw-r--r--tools/build/image.dir/dir.rules.mk35
-rw-r--r--tools/build/image.dir/elfexe.rules.mk46
-rw-r--r--tools/build/image.dir/elfout.rules.mk49
-rw-r--r--tools/build/image.dir/linkScript.rules.mk41
-rw-r--r--tools/build/image.dir/ppe.env.mk52
-rw-r--r--tools/build/image.dir/ppe_object.rules.mk96
-rw-r--r--tools/build/image.dir/ppebin.rules.mk60
-rw-r--r--tools/build/image.dir/ppeimage.rules.mk139
-rw-r--r--tools/build/image.dir/xipimage.rules.mk123
-rw-r--r--tools/build/image.dir/xiptool.rules.mk92
-rw-r--r--tools/build/release_tag.txt1
-rw-r--r--tools/build/rules.dir/cc.rules.mk132
-rw-r--r--tools/build/rules.dir/cflags.env.mk32
-rw-r--r--tools/build/rules.dir/chips.env.mk33
-rw-r--r--tools/build/rules.dir/dirs.env.mk47
-rw-r--r--tools/build/rules.dir/fapi2.env.mk81
-rw-r--r--tools/build/rules.dir/mflags.env.mk58
-rw-r--r--tools/build/rules.dir/procedure.rules.mk76
-rwxr-xr-xtools/envsetup/gerrit-hostname79
-rwxr-xr-xtools/envsetup/setupgithooks64
-rwxr-xr-xtools/hooks/post-commit29
-rwxr-xr-xtools/hooks/pre-commit36
-rwxr-xr-xtools/hooks/tools/pre-commit-actions60
-rw-r--r--tools/imageProcs/hw_image.S134
-rw-r--r--tools/imageProcs/hw_image.cmd141
-rw-r--r--tools/imageProcs/hw_image.mk99
-rw-r--r--tools/imageProcs/ioppe_image.S136
-rw-r--r--tools/imageProcs/ioppe_image.cmd97
-rw-r--r--tools/imageProcs/ioppe_image.mk78
-rwxr-xr-xtools/verify-commit390
48 files changed, 4998 insertions, 0 deletions
diff --git a/tools/addCopyright b/tools/addCopyright
new file mode 100755
index 00000000..76f5ecf1
--- /dev/null
+++ b/tools/addCopyright
@@ -0,0 +1,1200 @@
+#!/usr/bin/perl
+# IBM_PROLOG_BEGIN_TAG
+# This is an automatically generated prolog.
+#
+# $Source: tools/addCopyright $
+#
+# IBM CONFIDENTIAL
+#
+# EKB Project
+#
+# Contributors Listed Below - COPYRIGHT 2015
+# [+] International Business Machines Corp.
+#
+#
+# The source code for this program is not published or otherwise
+# divested of its trade secrets, irrespective of what has been
+# deposited with the U.S. Copyright Office.
+#
+# IBM_PROLOG_END_TAG
+
+#################################### ABOUT ####################################
+# Forked from: #
+# Author: Mark Jerde (mjerde@us.ibm.com) #
+# Date: Fri Mar 19 17:40:32 2010 UTC #
+# #
+# addCopyright will automatically insert appropriate copyright statements #
+# in source files following the IBM copyright guidelines (and templates) #
+# referenced below : #
+# FSP ClearCase Architecture #
+# Version 1.9 #
+# 10/12/2010 #
+# Editor: Alan Hlava #
+# #
+# Section 3.14.1 of the above doc has templates for different files #
+# #
+# NOTE: FSP uses the phrase "OCO Source materials" in their copyright #
+# block, which is classified as 'p1' . We will use the same #
+# classification here. #
+# NOTE: to list all files in src EXCEPT the build dir, run: #
+# make clean # remove autogenerated files #
+# find src -path 'src/build' -prune -o ! -type d -print | tr '\n' ' ' #
+# #
+# addCopyright does not support piping, but you can send these #
+# to a file, add "addCopyright update" to the beginning of the line, #
+# and run the file to update all #
+###############################################################################
+
+use strict;
+use warnings;
+use POSIX;
+use Getopt::Long;
+use File::Basename;
+use lib dirname (__FILE__);
+use Cwd;
+
+#------------------------------------------------------------------------------
+# Project-specific settings.
+#------------------------------------------------------------------------------
+my $ReleaseYear = `date +%Y`;
+chomp( $ReleaseYear );
+$ReleaseYear = $ENV{'DATE_OVERRIDE'} if defined $ENV{'DATE_OVERRIDE'};
+
+my $copyrightSymbol = "";
+# my $copyrightSymbol = "(C)"; # Uncomment if unable to use  character.
+
+# set by environment variable in project env.bash
+my $projectName = $ENV{'PROJECT_NAME'};
+my $copyrightStr = "COPYRIGHT";
+my $projectRoot = $ENV{'PROJECT_ROOT'};
+
+## note that these use single ticks so that the escape chars are NOT evaluated yet.
+my $OLD_DELIMITER_END = 'IBM_PROLOG_END';
+my $DELIMITER_END = 'IBM_PROLOG_END_TAG';
+my $DELIMITER_BEGIN = 'IBM_PROLOG_BEGIN_TAG';
+
+my $SOURCE_BEGIN_TAG = "\$Source:";
+my $SOURCE_END_TAG = "\$";
+
+# Desired License, set by environment variable in project env.bash
+my $LicenseFile = $ENV{'LICENSE'};
+use constant LICENSE_PROLOG => "LICENSE_PROLOG";
+
+#------------------------------------------------------------------------------
+# Contributer info
+#------------------------------------------------------------------------------
+
+# Constants for company's copyright
+# When adding a new company add constant here and to %fileContributorsCompany
+use constant IBM => 'International Business Machines Corp.';
+use constant GOOGLE => 'Google Inc.';
+
+# Create mapping for git contrubitors to companies
+my %fileContributorsCompany = (
+ "ibm.com" => IBM,
+ "ozlabs.org" => IBM,
+ "google.com" => GOOGLE,
+ "Google Shared Technology" => GOOGLE,
+);
+
+#------------------------------------------------------------------------------
+# Constants
+#------------------------------------------------------------------------------
+use constant RC_INVALID_PARAMETERS => 1;
+use constant RC_NO_COPYRIGHT_BLOCK => 2;
+use constant RC_BAD_CONTRIBUTORS_BLOCK => 3;
+use constant RC_INVALID_FILETYPE => 4;
+use constant RC_DIFFERS_FROM_LICENSE_PROLOG => 5;
+use constant RC_NO_LICENSE_PROLOG_FILE => 6;
+
+#------------------------------------------------------------------------------
+# Global Vars
+#------------------------------------------------------------------------------
+my $opt_help = 0;
+my $opt_debug = 0;
+my $operation = "";
+my $opt_logfile = "";
+
+my $DelimiterBegin = "";
+my $CopyrightBlock = "";
+my $DelimiterEnd = "";
+my $CopyRightString = "";
+my $copyright_check = 0;
+
+my $TempFile = "";
+my @Files = ();
+
+my $rc = 0;
+
+# NOTE: $OLD_DELIMITER_END is a subset of $DELIMITER_END so must match
+# $DELIMITER_END first in order to return the entire string.
+my $g_end_del_re = "($DELIMITER_END|$OLD_DELIMITER_END)";
+my $g_prolog_re = "($DELIMITER_BEGIN)((.|\n)+?)$g_end_del_re";
+
+#######################################################################
+# Main
+#######################################################################
+if (scalar(@ARGV) < 2)
+{
+ ## needs at least one filename and an operation as a parameter
+ usage();
+}
+
+
+my @SaveArgV = @ARGV;
+#------------------------------------------------------------------------------
+# Parse optional input arguments
+#------------------------------------------------------------------------------
+GetOptions( "help|?" => \$opt_help,
+ "validate" => sub { $operation="validate"; },
+ "update" => sub { $operation="update"; },
+ "copyright-check" => \$copyright_check,
+ "log-failed-files=s" => \$opt_logfile,
+ "debug" => \$opt_debug,
+ );
+
+## scan through remaining args and store all files in @Files
+## check for old-type parms, just in case
+foreach ( @ARGV )
+{
+ ## print $_;
+ if ( m/^debug$/ ) { $opt_debug = 1; next; }
+ if ( m/^update$/ ) { $operation = $_; next; }
+ if ( m/^validate$/ ) { $operation = $_; next; }
+
+ push @Files, $_ ;
+}
+
+
+if ( $opt_debug )
+{
+ print STDERR __LINE__, " : ---- DEBUG -----\n";
+ print STDERR "help = $opt_help\n";
+ print STDERR "debug = $opt_debug\n";
+ print STDERR "operation = $operation\n";
+ print STDERR "log-failed-files = $opt_logfile\n";
+
+ ## dump files specified
+ print STDERR "Files:\n";
+ print STDERR join( ' ', @Files ), "\n";
+
+ print STDERR "ReleaseYear = $ReleaseYear\n";
+
+ print "\n";
+}
+
+if ( $operation eq "" )
+{
+ print STDERR "No operation specified\n";
+ usage();
+ exit RC_INVALID_PARAMETERS;
+}
+
+if ( ( $opt_logfile ne "" )
+ ## && ( $operation eq "validate" )
+ )
+{
+ my $logdate = `date +%Y-%m-%d:%H%M`;
+ chomp $logdate;
+ open( LOGFH, "> $opt_logfile" ) or die "ERROR $?: Failed to open $opt_logfile: $!";
+ print LOGFH "## logfile generated $logdate from command line:\n";
+ print LOGFH $0, " ", join( ' ', @SaveArgV );
+ print LOGFH "\nFAILING files:\n";
+}
+
+########################################################################
+## MAIN
+########################################################################
+# Loop through all files and process.
+foreach ( @Files )
+{
+
+ ## clear global vars
+ $DelimiterBegin = "";
+ $CopyrightBlock = "";
+ $DelimiterEnd = "";
+ $CopyRightString = "";
+ $rc = 0;
+
+
+ ## get filetype
+ my $filetype = filetype($_);
+ print STDOUT "File $_: Type $filetype\n";
+
+ ## set Temporary file name.
+ $TempFile = "$_.gitCPYWRT";
+ if ( $opt_debug ) { print STDERR __LINE__, ": Temporary file name = $TempFile\n"; }
+
+ ##
+ ## Special case files have prolog tag strings in the code.
+ ## Just return 0 and add copyright manually.
+ ##
+ if ( m/addCopyright/ || m/tools\/mirror-patch/ )
+ {
+ print STDOUT "---------------------------------------------------------\n";
+ print STDOUT "Skipping special case file: $_\n";
+ print STDOUT " Please add the copyright prolog manually.\n";
+ print STDOUT "---------------------------------------------------------\n";
+ next;
+ }
+
+ ##
+ ## Ignore UML directories
+ ##
+ if ( m/uml/ )
+ {
+ print STDOUT "---------------------------------------------------------\n";
+ print STDOUT "Skipping UML case file: $_\n";
+ print STDOUT "---------------------------------------------------------\n";
+ next;
+ }
+
+ ##
+ ## Special case for common-tools project, just return 0 and add
+ ## copyright manually.
+ ##
+ if ($projectName =~ m/common-tools/i)
+ {
+ print STDOUT "---------------------------------------------------------\n";
+ print STDOUT "Skipping copyright for file in common-tools project: $_\n";
+ print STDOUT " Please copy file to your project and run the\n";
+ print STDOUT " copyright script there.\n";
+ print STDOUT " Done this way to ensure copyright prologs for\n";
+ print STDOUT " these tools match the project they live in\n";
+ print STDOUT "---------------------------------------------------------\n";
+ next;
+ }
+
+ ##
+ ## Gerrit submissions can include deleted files, just warn and continue
+ if ( ! -e $_ )
+ {
+ print STDOUT "---------------------------------------------------------\n";
+ print STDOUT "Skipping deleted file: $_\n";
+ print STDOUT "---------------------------------------------------------\n";
+ next;
+ }
+
+ ##
+ ## Unknown files are valid, but should generate a warning.
+ if ("Unknown" eq $filetype)
+ {
+ print STDOUT "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n";
+ print STDOUT "WARNING:: File $_ :Unknown Filetype: $filetype\n";
+ print STDOUT " Skipping this file and continuing.\n";
+ print STDOUT " Please add the copyright prolog manually.\n";
+ print STDOUT "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n";
+
+ next;
+ }
+
+ ##
+ ## text files are valid, but should generate a warning.
+ if (("txt" eq $filetype) || "Initfile" eq $filetype)
+ {
+ print STDOUT "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n";
+ print STDOUT "WARNING:: File $_ : Filetype: $filetype\n";
+ print STDOUT " Skipping this file and continuing.\n";
+ print STDOUT " If needed, Please add the copyright \n";
+ print STDOUT " prolog manually.\n";
+ print STDOUT "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\n";
+
+ next;
+ }
+
+ ##
+ ## Check if any parent directory below $projectRoot has a LICENSE_PROLOG file
+ ## Backtrack from the directory where the file lives and find the first
+ ## custom LICENSE_PROLOG file.
+ my $path = cwd."/".$_;
+ do
+ {
+ # Remove everything after last slash
+ $path =~ s|/[^/]*$||;
+ # Check if path has LICENSE_PROLOG file
+ my $custom_license_file = $path."/".LICENSE_PROLOG;
+ if (-e $custom_license_file)
+ {
+ # Set LicenseFile to closest custom LICENSE_PROLOG to file.
+ $LicenseFile = $custom_license_file;
+ # Exit loop, 'last' breaks out of both loops.
+ $path = $projectRoot;
+ }
+ } while ($path ne $projectRoot);
+
+ ## extract the existing copyright block
+ $CopyrightBlock = extractCopyrightBlock( $_ );
+
+ ##
+ ## validate the file.
+ ## if $logfile exists, print failing filename to $logfile and
+ ## keep going.
+ ## Otherwise, exit with $rc
+ ##
+ if ( $operation =~ m/validate/i )
+ {
+ $rc = validate( $_ );
+ if ( $rc )
+ {
+ print STDOUT "$_ FAILED copyright validation: $rc \n";
+ if ( $opt_logfile ne "" )
+ {
+ print LOGFH "$_ # FAILED $rc \n";
+ }
+ else
+ {
+ exit $rc;
+ }
+ }
+
+ ## continue to next file
+ next;
+ } ## endif validate
+
+ ##
+ ## update
+ ##
+ if ($operation =~ m/update/i)
+ {
+ $rc = update( $_, $filetype );
+ if ( $rc )
+ {
+ print STDOUT "$_ FAILED copyright update: $rc \n";
+ exit $rc;
+ }
+
+ ## continue to next file
+ next;
+ } ## endif update
+
+} # end foreach
+
+if ( $opt_logfile ne "" )
+{
+ close( LOGFH );
+}
+
+#########################################################################
+## Subroutines
+#########################################################################
+
+#######################################
+## usage: print usage and quit
+#######################################
+sub usage
+{
+ print STDERR "Usage: addCopyright { update | validate } \n";
+ print STDERR " [ --log-failed-files ]\n";
+ print STDERR " [ --debug ] \n";
+ print STDERR " file1 file2 ...\n";
+
+}
+
+#######################################
+## validate the file
+## param[in] $filename to validate
+## returns 0 success, nonzero failure
+## See constants above for values of failure
+#######################################
+sub validate
+{
+ my ( $filename ) = @_;
+ my $rc = 0;
+
+ if ( $CopyrightBlock eq "" )
+ {
+ print STDOUT "WARNING: No copyright block.\n";
+ return RC_NO_COPYRIGHT_BLOCK;
+ }
+
+ $rc = checkCopyrightBlock( $CopyrightBlock, $filename);
+
+ # good file
+ return $rc;
+}
+
+##
+## @sub update the copyright block.
+##
+## @param[in] filename
+## @param[in] filetype
+##
+## @return success or failure (currently only return success)
+##
+sub update
+{
+ my ( $filename, $filetype ) = @_;
+ my $olddelimiter = 0;
+ my $localrc = 0;
+ $localrc = validate( $filename );
+
+ if ( $localrc != 0 )
+ {
+ print STDOUT "Copyright Block check returned $localrc , fixing...\n";
+
+ if ( $localrc != RC_NO_COPYRIGHT_BLOCK )
+ {
+ if ( $opt_debug) { print STDERR __LINE__, ": remove old copyright block...\n"; }
+ removeCopyrightBlock( $filename, $filetype );
+ }
+
+ if ($opt_debug) { print STDERR __LINE__, ": Add empty copyright block...\n"; }
+ addEmptyCopyrightBlock( $filename, $filetype, $localrc );
+
+ if ( $opt_debug ) { print STDERR __LINE__, ": fill in new copyright block...\n"; }
+ fillinEmptyCopyrightBlock( $filename, $filetype);
+ }
+
+ ## return OK by default.
+ return 0;
+}
+
+
+#####################################
+## Analyze file and return a text string of the file type
+#####################################
+sub filetype
+{
+ my $filename = shift;
+ my $fileinfo = `file $filename | sed 's/^.*: //'`;
+ chomp $fileinfo;
+
+ # Sorted by anticipated frequency of occurrence.
+ if ( $filename =~ m/\.xml$/i )
+ # Added XML file to the top of the list because some comments in
+ # an XML file cause older versions of 'file' to incorrectly return
+ # "ASCII C++ program text" even though the file is obviously XML.
+ # Specifically we are seeing "<!-- // ..." cause this trouble.
+ {
+ return "xml"
+ }
+ if ( $filename =~ m/\.txt$/i )
+ {
+ return "txt"
+ }
+ if ( $filename =~ m/\.initfile$/i )
+ {
+ return "Initfile"
+ }
+ if ( ( $filename =~ m/\.[cht]$/i )
+ ||( $filename =~ m/\.[cht]\+\+$/i )
+ ||( $filename =~ m/\.[cht]pp$/i )
+ ||( $filename =~ m/\.inl$/ ) # inline C functions
+ ||( $filename =~ m/\.y$/ ) # yacc
+ ||( $filename =~ m/\.lex$/ ) # flex
+ ||( $fileinfo =~ m/c program text/i )
+ ||( $fileinfo =~ m/c\+\+ program text/i )
+ ||( $fileinfo =~ m/c source/i )
+ ||( $fileinfo =~ m/c\+\+ source/i )
+ )
+ {
+ return "C";
+ }
+ if ( ( $filename =~ m/\.pl$/ )
+ ||( $filename =~ m/\.perl$/ )
+ ||( $filename =~ m/\.pm$/ )
+ ||( $fileinfo =~ m/perl.*script.*text executable/i) )
+ {
+ return "Perl";
+ }
+ if ($filename =~ m/\.s$/i)
+ {
+ return "Assembly";
+ }
+ if (($filename =~ m/Makefile$/i) or
+ ($filename =~ m/\.mk$/i))
+ {
+ return "Makefile";
+ }
+ if ( $filename =~ m/\.am$/i )
+ {
+ return "Automake";
+ }
+ if ( ($filename =~ m/configure\.ac$/i)
+ ||($filename =~ m/Makefile\.in$/i) )
+ {
+ return "Autoconf";
+ }
+ if ( ( $filename =~ m/\.[kc]{0,1}sh$/i )
+ ||( $filename =~ m/\.bash$/i )
+ ||( $fileinfo =~ m/shell script/i )
+ ||( $fileinfo =~ m/^a \/bin\/[af]sh( -x|) *script text( executable|)$/ )
+ ||( $fileinfo eq "Bourne shell script text")
+ ||( $fileinfo eq "Bourne shell script text executable")
+ ||( $fileinfo eq "Bourne-Again shell script text")
+ ||( $fileinfo eq "Bourne-Again shell script text executable") )
+ {
+ return "Shellscript";
+ }
+ if ( $filename =~ m/\.py$/ )
+ {
+ return "Python";
+ }
+ if ( $filename =~ m/\.tcl$/ )
+ {
+ return "Tcl";
+ }
+ if ( $filename =~ m/\.x$/ )
+ {
+ return "RPC";
+ }
+ if ( ($filename =~ m/^commitinfo$/)
+ ||($filename =~ m/^checkoutlist$/)
+ ||($filename =~ m/^loginfo$/) )
+ {
+ return "CVS";
+ }
+ if ( $filename =~ m/\.emx$/ )
+ {
+ # Used by Rational Software Architect. modelling file.
+ return "EmxFile";
+ }
+ if ( $filename =~ m/\.mof$/ )
+ {
+ return "MofFile";
+ }
+ if ( $filename =~ m/\.ld$/ )
+ {
+ return "LinkerScript";
+ }
+ if ( $filename =~ m/\.rule$/i )
+ {
+ return "PrdRuleFile"
+ }
+ if ( ( $filename =~ m/\.emx$/i )
+ ||( $filename =~ m/\.odt$/i )
+ ||( $filename =~ m/\.gitignore$/i )
+ ||( $filename =~ m/\.conf$/i )
+ ||( $filename =~ m/\.lidhdr$/i )
+ ||( $filename =~ m/\.vpdinfo$/i )
+ ||( $filename =~ m/\.pdf$/i )
+
+ )
+ {
+ # Known, but we can't deal with it so call it unknown.
+ return "Unknown";
+ }
+ if ( -f $filename )
+ {
+ my $type = `grep "\\\$Filetype:.*\\\$" $filename`;
+ if ( $type =~ m/\$Filetype:([^\$]*)\$/ )
+ {
+ $type = $1;
+ }
+ $type =~ s/^\s*//;
+ $type =~ s/\s*$//;
+ my %knownTypes = qw/Assembly Assembly Automake Automake Autoconf Autoconf C C CVS CVS EmxFile EmxFile LinkerScript LinkerScript Makefile Makefile MofFile MofFile Perl Perl PrdRuleFile PrdRuleFile Python Python RPC RPC Shellscript Shellscript Tcl Tcl/;
+ return $type if defined($knownTypes{$type});
+ }
+ { # Other random files containing non-printable characters.
+ my $file = `cat $filename`;
+ if ( $file =~ m/([^\x20-\x7E\s])/ )
+ {
+ return "Unknown";
+ }
+ }
+ return "Unknown";
+}
+
+########################################################################
+## extractCopyrightBlock
+##
+## param[in] $infile - filename
+##
+## param[out] returns block or ""
+########################################################################
+sub extractCopyrightBlock
+{
+ my ( $infile ) = shift;
+
+ # Extract the prolog
+ my $prolog = `sed -n \"/$DELIMITER_BEGIN/,/$DELIMITER_END/p\" $infile`;
+ # Critical to remove newline for validate step
+ chomp($prolog);
+
+ ## As long as we're here extract the copyright string within the block
+ ## and save it to a global var
+ $CopyRightString = $1 if ( $prolog =~ /(^.*$copyrightStr.*$)/m );
+
+ return $prolog;
+}
+
+
+#######################################
+## Check Copyright Block
+##
+## @param[in] - Copyright block
+## @parma[in] - filename
+##
+## @return 0 if success, nonzero otherwise
+#######################################
+use File::Temp;
+sub checkCopyrightBlock
+{
+ my ( $block, $filename ) = @_;
+
+ ## Check if custom LICENSE_PROLOG
+ if ($LicenseFile ne "")
+ {
+ ## Get desired license
+ my $license_prolog = genCopyrightBlock($filename, filetype($filename));
+
+ if ($block ne $license_prolog)
+ {
+ # Print strings to files to use unix diff, do not need to add the
+ # File::Diff module this way.
+ my ($blockHndl, $blockFile) = File::Temp::tempfile();
+ my ($licenseHndl, $licenseFile)= File::Temp::tempfile();
+ print $blockHndl $block;
+ print $licenseHndl $license_prolog;
+ close($blockHndl);
+ close($licenseHndl);
+
+ print STDERR "\nERROR> Prolog not correct for $filename.\n";
+ print STDERR "To fix run: git show --pretty=\"format:\" --name-only | xargs addCopyright update\n";
+ print STDERR "\nDiff:\n";
+ print STDERR `diff $blockFile $licenseFile`;
+ my $relLicensePath = $LicenseFile;
+ $relLicensePath =~ s/$projectRoot//;
+ print STDERR "\nWARNING: Copyright block does not match LICENSE_PROLOG file found at $relLicensePath\n";
+ system("rm -f $blockFile $licenseFile");
+ return RC_DIFFERS_FROM_LICENSE_PROLOG;
+ }
+ }
+ else
+ {
+ print STDERR "WARNING: Missing LICNESE_PROLOG file in directory structure\n";
+ return RC_NO_LICENSE_PROLOG_FILE;
+ }
+
+ return 0;
+}
+
+sub createYearString
+{
+ my ( $filename ) = @_;
+ my $yearstr = "";
+ my @years = ();
+
+ ## Analyse the CopyRightString for begin and end years - this is for old
+ ## files that are checked in from FSP. In this case the earliest
+ ## year will be before it was checked into git . We have to construct
+ ## a yearstring based on the earliest year.
+ if ( $CopyRightString =~ m/$copyrightStr/ )
+ {
+ @years = ( $CopyRightString =~ /([0-9]{4})/g );
+ }
+ push @years, $ReleaseYear; # Add the current year.
+
+ ##
+ ## Make a call to git to find the earliest commit date of the file
+ ## new files will not have a log, so the "git log" call above will
+ # return nothing.
+ ## Push any year we find onto the @years array
+ my $cmd = "git log -- $filename | grep Date: | tail -n 1";
+ ## print "run $cmd\n";
+ my @logstrings = split( " ", `$cmd` );
+ if ( $? ) { die "ERROR $? : Could not run $cmd $!\n"; }
+
+ if ( scalar(@logstrings) >= 5 )
+ {
+ push @years, $logstrings[5] ;
+ }
+
+ ## sort and remove duplicates by loading it into a hash
+ my %temphash;
+ @temphash{@years} = ();
+ my @outyears = sort keys %temphash;
+
+ if ( $opt_debug )
+ { print STDERR __LINE__, ": years: ", join( ',', @outyears ), "\n"; }
+
+ ## lowest year, which may be the only one.
+ $yearstr = $outyears[0] ;
+
+ ## if there is more than one index then also output the highest one.
+ if ( $#outyears > 0 )
+ {
+ # A '-' is preferred but CMVC uses ',' so using ','.
+ $yearstr .= ",$outyears[$#outyears]";
+ }
+
+
+ return $yearstr;
+}
+
+###################################
+## Helper function for removeCopyrightBlock()
+###################################
+sub removeProlog
+{
+ my ( $data, $begin_re, $end_re ) = @_;
+
+ $data =~ s/(\n?)(.*?$begin_re.*$g_prolog_re(.|\n)*?$end_re.*?\n)/$1/;
+
+ return $data;
+}
+
+###################################
+## remove old Copyright Block in preparation for making a new one.
+## makes up a debug file named "<filename>.remove"
+###################################
+sub removeCopyrightBlock
+{
+ my ( $filename, $filetype ) = @_ ;
+ my $data = "" ;
+
+ ## Modify file in place with temp file Perl Cookbook 7.8
+ my $savedbgfile = "$filename.remove";
+ system( "cp -p $filename $TempFile" ); ## preserve file permissions
+ open( INPUT, "< $filename" ) or die " $? can't open $filename: $!" ;
+ read( INPUT, $data, -s INPUT ) or die "ERROR $? : reading $filename: $!";
+ close( INPUT ) or die " $? can't close $filename: $!" ;
+
+ open( OUTPUT, "> $TempFile" ) or die " $? can't open $TempFile: $!" ;
+ select( OUTPUT ); ## new default filehandle for print
+
+ ## preprocess to get rid of OLD_DELIMITER_END
+ $data =~ s/$OLD_DELIMITER_END(\s+?)/$DELIMITER_END$1/;
+
+ if ( "C" eq $filetype )
+ {
+ ## pre-process this for /* */ comments
+ $data = removeProlog( $data, '\/\*', '\*\/' );
+
+ ## Now apply filter for // comments
+ $data = removeProlog( $data, '\/\/', '' );
+ }
+ elsif ( ("RPC" eq $filetype) or
+ ("LinkerScript" eq $filetype)
+ )
+ {
+ $data = removeProlog( $data, '\/\*', '\*\/' );
+ }
+ elsif ( $filetype eq "xml" )
+ {
+ $data = removeProlog( $data, '<!--', '-->' );
+ }
+ elsif ( "Assembly" eq $filetype )
+ {
+ $data = removeProlog( $data, '\#', '' );
+ }
+ elsif ( ("Autoconf" eq $filetype) or
+ ("Automake" eq $filetype) or
+ ("CVS" eq $filetype) or
+ ("Makefile" eq $filetype) or
+ ("Perl" eq $filetype) or
+ ("PrdRuleFile" eq $filetype) or
+ ("Python" eq $filetype) or
+ ("Shellscript" eq $filetype) or
+ ("Tcl" eq $filetype)
+ )
+ {
+ # Don't wipe the the '#!' line at the top.
+ $data = removeProlog( $data, '\#', '' );
+ }
+ else
+ {
+ print STDERR "ERROR: Don't know how to remove old block from $filetype file.\n";
+ close OUTPUT;
+ return RC_INVALID_FILETYPE;
+ }
+
+ print OUTPUT $data;
+
+ ## finish up the files
+ close( OUTPUT ) or die " $? can't close $TempFile: $!" ;
+ rename( $filename, "$savedbgfile" ) or die " $? can't rename $filename: $!" ;
+ rename( $TempFile, $filename ) or die " $? can't rename $TempFile: $!" ;
+ if ( !$opt_debug )
+ {
+ ## leave the files around for debug
+ unlink( $savedbgfile ) or die " $? can't delete $savedbgfile: $!";
+
+ }
+}
+
+###################################
+## Add an empty copyright block to the file, for example (C/C++ files):
+##
+## // IBM_PROLOG_BEGIN_TAG IBM_PROLOG_END_TAG
+##
+## - The block will be filled-in in the next step.
+##
+## @param[in] - filename to modify
+## @param[in] - filetype
+## @param[in] - returncode from validate
+##
+## @return none
+##
+## - Makes up a debug file called "<filename>.empty"
+##################################
+sub addEmptyCopyrightBlock
+{
+ my ( $filename, $filetype, $validaterc ) = @_;
+ my $line;
+
+ ## Modify file in place with temp file Perl Cookbook 7.8
+ my $savedbgfile = "$filename.empty";
+ system( "cp -p $filename $TempFile" ) ; ## preserve permissions
+ open( INPUT, "< $filename" ) or die " $? can't open $filename: $!" ;
+ open( OUTPUT, "> $TempFile" ) or die " $? can't open $TempFile: $!" ;
+ select( OUTPUT );
+ ## new default filehandle for print
+ if (("Autoconf" eq $filetype) or
+ ("Automake" eq $filetype) or
+ ("CVS" eq $filetype) or
+ ("Perl" eq $filetype) or
+ ("Python" eq $filetype) or
+ ("Shellscript" eq $filetype) or
+ ("Tcl" eq $filetype))
+ {
+ ## All files with a "shebang" at the beginning
+ $line = <INPUT>;
+ # Keep the '#!' line at the top.
+ ## The following says : if the first line is a "shebang" line
+ ## (e.g. "#!/usr/bin/perl"), then print it _before_ the copyright
+ ## block, otherwise (the unless line), print it _after_ the copyright
+ ## block.
+ if ($line =~ m/^#!/)
+ {
+ print OUTPUT $line;
+ }
+ print OUTPUT "$DELIMITER_BEGIN $DELIMITER_END\n";
+ unless ($line =~ m/^#!/)
+ {
+ print OUTPUT $line;
+ }
+ }
+ elsif ( "xml" eq $filetype )
+ {
+ # Browsers will complain if the first line of the file contains
+ # anything but the <?xml version=...?> tag.
+ while ( $line = <INPUT> )
+ {
+ unless ( $line =~ m/^<\?xml/ )
+ {
+ print OUTPUT "$DELIMITER_BEGIN $DELIMITER_END\n";
+ print OUTPUT $line;
+ last;
+ }
+
+ print OUTPUT $line;
+ }
+ }
+ else
+ {
+ print OUTPUT "$DELIMITER_BEGIN $DELIMITER_END\n";
+ }
+
+ # Copy rest of file
+ while (defined($line = <INPUT>))
+ {
+ print OUTPUT $line;
+ }
+
+ ## finish up the files
+ close( INPUT ) or die " $? can't close $filename: $!" ;
+ close( OUTPUT ) or die " $? can't close $TempFile: $!" ;
+ rename( $filename, "$savedbgfile" ) or die " $? can't rename $filename: $!" ;
+ rename( $TempFile, $filename ) or die " $? can't rename $TempFile: $!" ;
+ if ( !$opt_debug )
+ {
+ ## leave the files around for debug
+ unlink( $savedbgfile ) or die " $? can't delete $savedbgfile: $!";
+ }
+}
+
+############################################
+## Helper functions for fillinEmptyCopyrightBlock()
+############################################
+sub addPrologComments
+{
+ my ( $data, $begin, $end ) = @_;
+
+ my @lines = split( /\n/, $data );
+
+ $data = '';
+ for my $line ( @lines )
+ {
+ # If there is an block comment end tag, fill the end of the line with
+ # spaces.
+ if ( $end )
+ {
+ my $max_line_len = 70;
+ my $len = length($line);
+ if ( $len < $max_line_len )
+ {
+ my $fill = ' ' x ($max_line_len - $len);
+ $line .= $fill;
+ }
+ }
+
+ # NOTE: CMVC prologs with inline comments will have a single trailing
+ # space at the end of the line. This is undesirable for most
+ # developers so it will not be added.
+ if ( $line =~ m/$DELIMITER_BEGIN/)
+ {
+ $line = "$line $end" if ( $end );
+ $line = "$begin $line\n";
+ }
+ elsif ( $line =~ m/$DELIMITER_END/ )
+ {
+ $line = "$line $end" if ( $end );
+ $line = "$begin $line";
+ }
+ else
+ {
+ if ( not $end and not $line )
+ {
+ # Compensate for blank lines with no end delimeter.
+ $line = "$begin\n";
+ }
+ else
+ {
+ $line = "$begin $line";
+ $line = "$line $end" if ( $end );
+ $line = "$line\n";
+ }
+ }
+
+ $data .= $line;
+ }
+
+ return $data;
+}
+
+############################################
+## Generates final copyright block
+##
+## @parma[in] filename
+##
+## @return final copyright block string
+############################################
+sub genCopyrightBlock
+{
+ my ($filename, $filetype) = @_;
+
+ my $copyrightYear = createYearString( $filename );
+
+ # Get copyright contributors based on hash so no duplicates
+ my %fileContributors = getFileContributors( $filename );
+ my $copyright_Contributors = "";
+ foreach my $key (sort keys %fileContributors)
+ {
+ $copyright_Contributors .= "[+] ".$key."\n";
+ }
+
+ ## Get desired license
+ my $LicenseContent = "";
+ open(LICENSE, "< $LicenseFile") or die " $? can't open $LicenseFile: $!" ;
+ while (my $line = <LICENSE>)
+ {
+ my $evalLine = eval "qq($line)";
+ $LicenseContent .= $evalLine;
+ }
+ close(LICENSE);
+
+ ## define the final copyright block template here.
+ my $IBMCopyrightBlock = <<EOF;
+$DELIMITER_BEGIN
+$LicenseContent
+$DELIMITER_END
+EOF
+
+ if ("Assembly" eq $filetype)
+ {
+ $IBMCopyrightBlock = addPrologComments($IBMCopyrightBlock, '#', '');
+ }
+ elsif ( ("Makefile" eq $filetype) or
+ ("PrdRuleFile" eq $filetype) )
+ {
+ $IBMCopyrightBlock = addPrologComments($IBMCopyrightBlock, '#', '');
+ }
+ elsif (("Autoconf" eq $filetype) or
+ ("Automake" eq $filetype) or
+ ("CVS" eq $filetype) or
+ ("Perl" eq $filetype) or
+ ("Python" eq $filetype) or
+ ("Shellscript" eq $filetype) or
+ ("Tcl" eq $filetype))
+ {
+ ## all files with a "shebang"
+ $IBMCopyrightBlock = addPrologComments($IBMCopyrightBlock, '#', '');
+ }
+ elsif ( "C" eq $filetype )
+ {
+ ## lex files are classified as C, but do not recognize '//' comments
+ $IBMCopyrightBlock = addPrologComments($IBMCopyrightBlock, '/*', '*/');
+ }
+ elsif ( ("RPC" eq $filetype) or
+ ("LinkerScript" eq $filetype)
+ )
+ {
+ $IBMCopyrightBlock = addPrologComments($IBMCopyrightBlock, '/*', '*/');
+ }
+ elsif ("EmxFile" eq $filetype)
+ {
+ # Not yet formatted correctly for EmxFile needs, but should coexist.
+ $IBMCopyrightBlock = "$DELIMITER_BEGIN IBM Confidential OCO Source Materials (C) Copyright IBM Corp. $copyrightYear The source code for this program is not published or otherwise divested of its trade secrets, irrespective of what has been deposited with the U.S. Copyright Office. $DELIMITER_END";
+ }
+ elsif ("MofFile" eq $filetype)
+ {
+ $IBMCopyrightBlock = addPrologComments($IBMCopyrightBlock, '//', '');
+ }
+ elsif ( "xml" eq $filetype)
+ {
+ $IBMCopyrightBlock = addPrologComments($IBMCopyrightBlock, '<!--', '-->');
+ }
+ else
+ {
+ print STDERR "ERROR: Can\'t handle filetype: $filetype\n";
+ return RC_INVALID_FILETYPE;
+ }
+
+ return $IBMCopyrightBlock;
+}
+
+############################################
+## fill in the empty copyright block
+## Copyright guidelines from:
+## FSP ClearCase Architecture
+## Version 1.9
+## 10/12/2010
+## Editor: Alan Hlava
+##
+## Section 3.14.1 has templates for different files
+##
+############################################
+sub fillinEmptyCopyrightBlock
+{
+ my ( $filename, $filetype ) = @_;
+
+ my $copyrightYear = createYearString( $filename );
+
+ ## define the final copyright block template here.
+ my $IBMCopyrightBlock = genCopyrightBlock($filename,$filetype);
+
+ ## Modify file in place with temp file Perl Cookbook 7.8
+ my $savedbgfile = "$filename.fillin";
+ system( "cp -p $filename $TempFile" ); ## preserve file permissions
+ open( INPUT, "< $filename" ) or die " $? can't open $filename: $!" ;
+ my $newline;
+ my $lines = "";
+ while ( defined($newline = <INPUT>) ) { $lines .= $newline; }
+
+ # Replace existing block with the current content.
+ $lines =~ s/$DELIMITER_BEGIN[^\$]*$DELIMITER_END/$IBMCopyrightBlock/s;
+
+ open( OUTPUT, "> $TempFile" ) or die " $? can't open $TempFile: $!" ;
+ select( OUTPUT ); ## new default filehandle for print
+ print OUTPUT $lines;
+
+ ## finish up the files
+ close( INPUT ) or die " $? can't close $filename: $!" ;
+ close( OUTPUT ) or die " $? can't close $TempFile: $!" ;
+ rename( $filename, "$savedbgfile" ) or die " $? can't rename $filename: $!" ;
+ rename( $TempFile, $filename ) or die " $? can't rename $TempFile: $!" ;
+ if ( !$opt_debug )
+ {
+ ## leave the files around for debug
+ unlink( $savedbgfile ) or die " $? can't delete $savedbgfile: $!";
+ }
+}
+
+#######################################
+## Gets file contirbutors based on git log of a file
+##
+## @parma[in] filename
+##
+## @return hash of contributors (key,value) => (name/company, 1)
+#######################################
+sub getFileContributors
+{
+ my ( $filename ) = @_;
+ # Create a "set like" hash for file contributors to handle duplicates
+ # so key is the only important information
+ my %fileContributors = ();
+
+ # Check file for company Origin
+ my $gitDomain = `git log --follow -- $filename | grep Origin: | sort | uniq`;
+ my @gitDomain = split('\n', $gitDomain);
+ foreach my $origin (@gitDomain)
+ {
+ chomp($origin);
+ # Remove all characters through word "Origin:"
+ $origin =~ s/[^:]*\://;
+ # Remove white space after colon
+ $origin =~ s/^\s+//;
+ if (exists($fileContributorsCompany{$origin}))
+ {
+ # Add company info for copyright contribution
+ $fileContributors{$fileContributorsCompany{$origin}} = 1;
+ }
+ }
+
+ # Check file for all contributors
+ my $gitAuthors = `git log --follow --pretty="%aN <%aE>" -- $filename | sort | uniq`;
+ my @gitAuthors = split('\n', $gitAuthors);
+
+ # Add current commiter.
+ # If running copyright_check run 'git log' as a commit is not taking place
+ # Otherwise check using 'git config' as this is a pre-commit hook
+ my $curAuthorEmail = "";
+ if ($copyright_check)
+ {
+ $curAuthorEmail = `git log -n1 --pretty=format:"%aN <%aE>"`;
+ chomp($curAuthorEmail);
+ }
+ else
+ {
+ my $curAuthorName = `git config user.name`;
+ $curAuthorEmail = `git config user.email`;
+ chomp($curAuthorEmail);
+ $curAuthorEmail = "$curAuthorName <".$curAuthorEmail.">";
+ }
+ push(@gitAuthors, $curAuthorEmail);
+ foreach my $contributor (@gitAuthors)
+ {
+ my $companyExists = 0;
+ chomp($contributor);
+ # Grab company domain out of contributor's email
+ my $domain = substr ($contributor, index($contributor, '@') + 1, -1);
+
+ # Due to multiple prefixes for IBM like us, in, linux, etc will try
+ # removing characters up to each period (.) until correct domain
+ # address found
+ my @domainSections = split(/\./,$domain);
+ for (my $i = 0; $i < @domainSections; $i++)
+ {
+ if (exists($fileContributorsCompany{$domain}))
+ {
+ $companyExists = 1;
+ last;
+ }
+ # Remove all characters upto & including the first period (.) seen
+ $domain =~ s/[^.]*\.//;
+ }
+
+ #Check if contributor's company exists
+ if ($companyExists)
+ {
+ # Add company info for copyright contribution
+ $fileContributors{$fileContributorsCompany{$domain}} = 1;
+ }
+ else
+ {
+ my $name = substr ($contributor, 0, index($contributor, '<') -1);
+ if($name)
+ {
+ # Add individual info for copyright contribution
+ $fileContributors{$name} = 1;
+ }
+ else
+ {
+ die("Cannot find name of contributor in git commit");
+ }
+ }
+ }
+ return %fileContributors;
+}
diff --git a/tools/build/Makefile b/tools/build/Makefile
new file mode 100644
index 00000000..36cbf5ac
--- /dev/null
+++ b/tools/build/Makefile
@@ -0,0 +1,39 @@
+# IBM_PROLOG_BEGIN_TAG
+# This is an automatically generated prolog.
+#
+# $Source: tools/build/Makefile $
+#
+# IBM CONFIDENTIAL
+#
+# EKB Project
+#
+# COPYRIGHT 2015,2017
+# [+] International Business Machines Corp.
+#
+#
+# The source code for this program is not published or otherwise
+# divested of its trade secrets, irrespective of what has been
+# deposited with the U.S. Copyright Office.
+#
+# IBM_PROLOG_END_TAG
+
+# Root makefile for the build system.
+# Includes subdirectory makefiles in a specific order:
+# * Build system 'environment' files (*.env.mk).
+# * Build system 'rule' files (*.rules.mk).
+# * Global make files (from $(MAKEFILE_PATH).
+# * All dependency include files from $(__DEP_INCLUDES).
+# * Build system 'final' files (*.final.mk).
+
+CTEPATH ?= $(CROSS_COMPILER_PATH)
+GCC-TOOL-PREFIX ?= $(CROSS_COMPILER_PATH)/bin/powerpc-eabi-
+BINUTILS-TOOL-PREFIX ?= $(CROSS_COMPILER_PATH)/powerpc-eabi/bin/
+
+.SECONDEXPANSION:
+.DEFAULT_GOAL = all
+
+-include $(wildcard $(addsuffix /*.env.mk,$(wildcard *.dir)))
+-include $(wildcard $(addsuffix /*.rules.mk,$(wildcard *.dir)))
+-include $(wildcard $(addsuffix /*.mk,$(MAKEFILE_PATH)))
+-include $(__DEP_INCLUDES)
+-include $(wildcard $(addsuffix /*.final.mk,$(wildcard *.dir)))
diff --git a/tools/build/README.md b/tools/build/README.md
new file mode 100644
index 00000000..d9f2f680
--- /dev/null
+++ b/tools/build/README.md
@@ -0,0 +1,209 @@
+## Introduction ##
+
+For the typical procedure, `p8_foo.[CH]`, you should make a corresponding
+makefile: `p8_foo.mk`. In most cases this can simply be two lines:
+
+ PROCEDURE=p8_foo
+ $(call BUILD_PROCEDURE)
+
+If you need more advanced options, such as creating and linking against a
+library of utilities see the broader details below.
+
+## Typically Used Target Macros ##
+
+### BUILD_PROCEDURE ###
+This macro will automatically generate all the recipes for building a FAPI
+procedure. Requires that the following variables are defined prior to calling
+this macro:
+
+* `PROCEDURE=name` - Name of the procedure. name.o is an implied
+ required object.
+* `FAPI=version` - Optional method to specify the FAPI version.
+
+Example:
+
+ PROCEDURE=foo
+ $(call BUILD_PROCEDURE)
+
+Since BUILD_PROCEDURE is a special case of a 'module', you should see the
+BUILD_MODULE macro for more advanced capabilities. The most likely used
+additional features are `OBJS+=` and `lib$(PROCEDURE)_DEPLIBS+=`.
+
+### BUILD_WRAPPER ###
+This macro will automatically generate all the recipes for building a FAPI
+wrapper. Requires that the following variables are defined prior to calling
+this macro:
+
+* `PROCEDURE=name` - Name of the wrapper. name.o is an implied required
+ object.
+* `FAPI=version` - Optional method to specify the FAPI version.
+* `$(WRAPPER)_USELIBS` - Indicates that this wrapper needs include files
+ defined by a procedure or module.
+
+Many wrappers will #include a header file defined by a procedure. In order
+for the build system to find this header file, the `$(WRAPPER)_USELIBS`
+variable will need to be populated. Since procedures are loaded indirectly
+in Cronus via `dlopen`, needed procedures should not be in the
+`$(WRAPPER)_DEPLIBS` variable.
+
+Example:
+
+ WRAPPER=foo_wrap
+ foo_wrap_USELIBS+=foo
+ $(call BUILD_WRAPPER)
+
+Since BUILD_WRAPPER is a special case of an 'executable', you should see the
+BUILD_WRAPPER macro for more advanced capabilities. The most likely used
+additional features are `OBJS+=` and `$(WRAPPER)_DEPLIBS+=`.
+
+### BUILD_MODULE ###
+This macro will automatically generate all the recipes for building a shared
+library. Requires that the following variables are defined prior to calling
+this macro:
+
+* `MODULE=name` - Give a name to the module.
+* `OBJS=list of objects` - Give a list of .o files required.
+
+As a result, this macro will define how to build lib$(MODULE).so as well as
+all necessary dependencies.
+
+This macro can utilize these additional variables:
+
+* `lib$(MODULE)_*FLAGS` - Extra compile / linker flags for the module.
+* `lib$(MODULE)_DEPLIBS` - Local modules that this module depends on.
+* `lib$(MODULE)_EXTRALIBS` - External shared libs that this module depends on.
+* `lib$(MODULE)_PATH` - Optional alternate location to place library objects.
+* `lib$(MODULE)_TARGET` - Optional mechanism to select between the 'host' or
+ 'target' (default) cross-compiler set.
+* `lib$(MODULE)_DEPSORDER - Order-only dependencies.
+* `$(OBJ)_*FLAGS` - Extra compile / linker flags for a specific object.
+
+Example:
+
+ MODULE=foo
+ OBJS+=foo.o
+ libfoo_DEPLIBS+=bar
+ $(call BUILD_MODULE)
+
+### BUILD_EXE ###
+
+This macro will automatically generate all the recipes for building an
+executable. Requires that the following variables are defined prior to
+calling this macro:
+* `EXE=name` - Give a name to the executable.
+* `OBJS=list of objects` - Give a list of .o files required.
+
+As a result, this macro will define how to build $(MODULE).exe as well as
+all necessary dependencies.
+
+This macro can utilize these additional variables:
+
+* `$(EXE)_*FLAGS` - Extra compile / linker flags for a specific executable.
+* `$(EXE)_DEPLIBS` - Local modules that this executable depends on.
+* `$(EXE)_EXTRALIBS` - External shared libs that this executable depends on.
+* `$(EXE)_PATH` - Optional alternate location to place executable objects.
+* `$(EXE)_TARGET` - Optional mechanism to select between the 'host' or
+ 'target' (default) cross-compiler set.
+* `$(EXE)_DEPSORDER - Order-only dependencies.
+* `$(OBJ)_*FLAGS` - Extra compile / linker flags for a specific object.
+
+Example:
+
+ EXE=foo
+ OBJS+=foo.o
+ foo_DEPLIBS+=bar
+ $(call BUILD_EXE)
+
+### BUILD_GENERATED ###
+This macro will automatically generate all the recipes for running a tool that
+generates other files. Requires that the following variables are defined prior
+to calling this macro:
+
+* `GENERATED=name` - Give a name to this generator.
+* `COMMAND=tool` - Name of the tool to run.
+* `SOURCES=file1 file2` - List of files as 'input' to the tool.
+* `TARGETS=file3 file4` - List of files that are created as 'output'.
+* `$(GENERATED)_RUN` - A macro that identifies how to run this tool.
+
+As a result, this macro will rerun the tool whenever the command or source
+files change and will automatically add the targets to the 'clean' list.
+
+This macro can utilize these additional variables:
+
+* `$(GENERATED)_PATH` - Optional path to put output into.
+* `$(GENERATED)_COMMAND_PATH` - Path to tool, assumed to be the current
+ directory of the .mk file if not given.
+
+Example:
+
+ GENERATED=foo2bar
+ COMMAND=foo2bar
+ SOURCES+=foo.xml
+ TARGETS+=bar.xml
+ define foo2bar_RUN
+ \t\t$$< --input=$$(filter-out $$<,$$^) \
+ --output=$$($(GENERATED)_PATH)/bar.xml
+ endef
+
+## Other Macros ##
+
+### ADD_MODULE_SRCDIR ###
+Adds a list of additional source paths to a module. A call to
+ADD_MODULE_INCDIR is also automatically implied.
+
+Usage:
+
+ $(call ADD_MODULE_SRCDIR,module,/path1 /path2)
+
+### ADD_MODULE_INCDIR ###
+Adds a list of additional include paths to a module.
+
+Usage:
+
+ $(call ADD_MODULE_INCDIR,module,/path1 /path2)
+
+### ADD_MODULE_OBJ ###
+Adds a list of objects to a module's dependency list.
+
+Usage:
+
+ $(call ADD_MODULE_OBJ,module,file1.o file2.o)
+
+### ADD_EXE_SRCDIR ###
+See ADD_MODULE_SRCDIR.
+
+### ADD_EXE_INCDIR ###
+See ADD_MODULE_INCDIR.
+
+### ADD_EXE_OBJ ###
+See ADD_MODULE_OBJ.
+
+### CLEAN_TARGET ###
+
+`CLEAN_TARGET` is used to identify a file to remove when the user performs
+"make clean".
+
+Usage:
+
+ $(call CLEAN_TARGET,../path/to/removed/file)
+
+## General / Global Variables ##
+
+`BUILD_VERBOSE` - Can be set by the environment to establish verbose output.
+
+`LOCALCOMMONFLAGS` - Flags to pass to `CC` and `CPP`.
+
+`LOCALCFLAGS` - Flags to pass to `CC`.
+
+`LOCALCXXFLAGS` - Flags to pass to `CPP`.
+
+`LOCALLDFLAGS` - Flags to pass to `LD`
+
+`GEN_TARGETS` - List of targets to build in the 'gen' pass.
+
+`MODULE_TARGETS` - List of modules to build in the 'module' pass.
+
+`EXE_TARGETS` - List of targets to build in the 'exe' pass.
+
+`ALL_TARGETS` - List of targets to build in the 'all' pass.
+
diff --git a/tools/build/common.dir/cflags.env.mk b/tools/build/common.dir/cflags.env.mk
new file mode 100644
index 00000000..03f5bfaa
--- /dev/null
+++ b/tools/build/common.dir/cflags.env.mk
@@ -0,0 +1,27 @@
+# IBM_PROLOG_BEGIN_TAG
+# This is an automatically generated prolog.
+#
+# $Source: tools/build/common.dir/cflags.env.mk $
+#
+# IBM CONFIDENTIAL
+#
+# EKB Project
+#
+# COPYRIGHT 2015,2017
+# [+] International Business Machines Corp.
+#
+#
+# The source code for this program is not published or otherwise
+# divested of its trade secrets, irrespective of what has been
+# deposited with the U.S. Copyright Office.
+#
+# IBM_PROLOG_END_TAG
+
+# Makefile to define useful common flags for all environments.
+
+LOCALCOMMONFLAGS += -O3 -fPIC -Wall -Werror
+LOCALLDFLAGS += --std=gnu++11
+ifeq ($(UNAME),Linux)
+LOCALLDFLAGS += -rdynamic
+endif
+LOCALCXXFLAGS += --std=gnu++11
diff --git a/tools/build/common.dir/clean.final.mk b/tools/build/common.dir/clean.final.mk
new file mode 100644
index 00000000..2aa88ce5
--- /dev/null
+++ b/tools/build/common.dir/clean.final.mk
@@ -0,0 +1,21 @@
+# IBM_PROLOG_BEGIN_TAG
+# This is an automatically generated prolog.
+#
+# $Source: tools/build/common.dir/clean.final.mk $
+#
+# IBM CONFIDENTIAL
+#
+# EKB Project
+#
+# COPYRIGHT 2015
+# [+] International Business Machines Corp.
+#
+#
+# The source code for this program is not published or otherwise
+# divested of its trade secrets, irrespective of what has been
+# deposited with the U.S. Copyright Office.
+#
+# IBM_PROLOG_END_TAG
+.PHONY: clean
+clean: $(addprefix _BUILD/CLEAN/,$(wildcard $(__CLEAN_TARGETS)))
+ $(C2) " CLEAN ALL"
diff --git a/tools/build/common.dir/clean.rules.mk b/tools/build/common.dir/clean.rules.mk
new file mode 100644
index 00000000..ef2dfcd3
--- /dev/null
+++ b/tools/build/common.dir/clean.rules.mk
@@ -0,0 +1,35 @@
+# IBM_PROLOG_BEGIN_TAG
+# This is an automatically generated prolog.
+#
+# $Source: tools/build/common.dir/clean.rules.mk $
+#
+# IBM CONFIDENTIAL
+#
+# EKB Project
+#
+# COPYRIGHT 2015,2017
+# [+] International Business Machines Corp.
+#
+#
+# The source code for this program is not published or otherwise
+# divested of its trade secrets, irrespective of what has been
+# deposited with the U.S. Copyright Office.
+#
+# IBM_PROLOG_END_TAG
+
+# Makefile that defines a special target to remove files.
+
+## $(call CLEAN_TARGET,/path/to/file)
+## Adds target to the __CLEAN_TARGETS variable.
+CLEAN_TARGET = $(eval $(call __CLEAN_TARGET,$(1)))
+__CLEAN_TARGET = __CLEAN_TARGETS += $(1)
+
+
+# Special rule for CLEAN pass that will delete a file (path/to/file) from
+# a rule _BUILD/CLEAN/path/to/file.
+.PHONY: _BUILD/CLEAN/%
+_BUILD/CLEAN/% :
+ $(C2) " RM $(notdir $@)"
+ $(C1) rm -rf $(subst _BUILD/CLEAN/,,$@)
+ $(C1) rm -rf $(subst .so,_x86_64.so,$(subst libp,p, $(subst _BUILD/CLEAN/,,$@)))
+
diff --git a/tools/build/common.dir/exe.rules.mk b/tools/build/common.dir/exe.rules.mk
new file mode 100644
index 00000000..e187062e
--- /dev/null
+++ b/tools/build/common.dir/exe.rules.mk
@@ -0,0 +1,149 @@
+# IBM_PROLOG_BEGIN_TAG
+# This is an automatically generated prolog.
+#
+# $Source: tools/build/common.dir/exe.rules.mk $
+#
+# IBM CONFIDENTIAL
+#
+# EKB Project
+#
+# COPYRIGHT 2015,2017
+# [+] International Business Machines Corp.
+#
+#
+# The source code for this program is not published or otherwise
+# divested of its trade secrets, irrespective of what has been
+# deposited with the U.S. Copyright Office.
+#
+# IBM_PROLOG_END_TAG
+
+# Makefile that defines how we build executables.
+#
+# Macros:
+# BUILD_EXE - Macro to automatically generate all the recipes for
+# building an executable.
+# ADD_EXE_OBJ - Macro to add additional objects to an executable.
+# ADD_EXE_SRCDIR - Macro to add additional source dirs to an executable.
+# ADD_EXE_INCDIR - Macro to add additional include dirs to an executable.
+# Special variables:
+# $(EXE)_*FLAGS - Extra compile / linker flags for a specific executable.
+# $(EXE)_DEPLIBS - Local modules that this executable depends on.
+# $(EXE)_EXTRALIBS - External shared libs that this executable depends on.
+# $(EXE)_PATH - Optional alternate location to place executable objects.
+# $(EXE)_TARGET - Optional mechanism to select between the 'host' or
+# 'target' (default) cross-compiler set.
+# Input:
+# Optional input to delay the running of BUILD_GENERATED macro to a
+# later phase.
+#
+# BUILD_EXE
+# This macro will automatically generate all the recipes for building an
+# executable. Requires that the following variables are defined
+# prior to calling this macro:
+# * EXE=name - Give a name to the executable.
+# * OBJS=list of objects - Give a list of .o files required.
+#
+# As a result, this macro will define how to build $(MODULE).exe as well
+# as all necessary dependencies.
+BUILD_EXE = $(eval $(call __BUILD_EXE, $1))
+
+# Order of operations:
+# * Define default exe object PATH.
+# * Add all OBJ to exe objects.
+# * Add directory of the defining .mk file to the source path for this exe.
+# * Set up LOCAL*FLAGS variables for the exe.
+# * Define dependencies for the exe:
+# - lib$(EXE).a
+# - All $(EXE)_DEPLIB modules.
+# - All $(EXE)_EXTRALIBS shared libraries
+# - Call environment's __CALL_LD macro to link exe.
+# * Define dependencies for the lib$(EXE).a archive.
+# - All lib$(EXE)_OBJS.
+# - Call environment's __CALL_AR macro to create archive.
+# * Add exe and archive to 'clean' target list.
+# * Create helper target for 'make $(EXE)'.
+# * Erase EXE and OBJS variables.
+#
+# Input:
+# Optional input to delay the running of BUILD_GENERATED macro to a
+# later phase.
+
+define __BUILD_EXE
+$(EXE)_PATH ?= $(OBJPATH)/$(EXE)
+$(EXE)_LIBPATH ?= $(LIBPATH)
+$(call __ADD_EXE_OBJ,$(EXE),$(OBJS))
+$(call __ADD_EXE_SRCDIR,$(EXE),$(dir $(lastword $(MAKEFILE_LIST))))
+
+$(EXEPATH)/$(EXE).exe: LOCALCOMMONFLAGS += $$($(EXE)_COMMONFLAGS)
+$(EXEPATH)/$(EXE).exe: LOCALCFLAGS += $$($(EXE)_CFLAGS)
+$(EXEPATH)/$(EXE).exe: LOCALCXXFLAGS += $$($(EXE)_CXXFLAGS)
+$(EXEPATH)/$(EXE).exe: LOCALLDFLAGS += $$($(EXE)_LDFLAGS)
+$(EXEPATH)/$(EXE).exe: $$($(EXE)_PATH)/lib$(EXE).a \
+ $$(foreach lib,$$($(EXE)_DEPLIBS),$$($(EXE)_LIBPATH)/lib$$(lib).a) \
+ $$($(EXE)_EXTRALIBS) $$($(EXE)_DEPS) | $$($(EXE)_DEPSORDER)
+$(call __CALL_LD,$$(or $$($(EXE)_TARGET),TARGET))
+
+$$($(EXE)_PATH)/lib$(EXE).a: $$($(EXE)_OBJS)
+$(call __CALL_AR,$$(or $$($(EXE)_TARGET),TARGET))
+
+$(call __CLEAN_TARGET,$(EXEPATH)/$(EXE).exe)
+$(call __CLEAN_TARGET,$$($(EXE)_PATH)/lib$(EXE).a)
+
+.PHONY: $(EXE)
+$(EXE) : _BUILD/GEN_TARGETS
+ @$$(MAKE) $(EXEPATH)/$(EXE).exe
+$(or $(strip $1),EXE)_TARGETS += $(EXEPATH)/$(EXE).exe
+
+EXE:=
+OBJS:=
+
+endef
+
+# ADD_EXE_OBJ
+# This macro will add additional objects to an executable's dependency list.
+# Usage:
+# $(call ADD_EXE_OBJ,exe,file1.o file2.o)
+ADD_EXE_OBJ = $(eval $(call __ADD_EXE_OBJ,$(1),$(2)))
+# Order of operations:
+# * Prepend $(EXE)_PATH to the path for the object.
+# * Add object and corresponding .dep file to the 'clean' target list.
+# * Add generated .dep file for header-file dependencies to __DEP_INCLUDES.
+define __ADD_EXE_OBJ
+$(1)_OBJS += $$(addprefix $$($(1)_PATH)/,$(2))
+$(foreach obj,$(2),$(call CLEAN_TARGET,$$($(1)_PATH)/$(obj))
+ $(call CLEAN_TARGET,$$($(1)_PATH)/$(obj:.o=.dep)))
+
+__DEP_INCLUDES += $$(wildcard $$(addprefix $$($(1)_PATH)/,$(2:.o=.dep)))
+endef
+
+# ADD_EXE_SRCDIR
+# This macro will add additional source paths to an executable.
+# Usage:
+# $(call ADD_EXE_SRCDIR,exe,/path1 /path2)
+ADD_EXE_SRCDIR = $(eval $(call __ADD_EXE_SRCDIR,$(1),$(2)))
+__ADD_EXE_SRCDIR = \
+ $(foreach path,$(2),$(call ___ADD_EXE_SRCDIR,$(1),$(2)))
+# Order of operations:
+# * Add the path to the include list.
+# * Generate all the possible .C->.o, .c->.o, etc. pattern recipes.
+define ___ADD_EXE_SRCDIR
+$(call __ADD_EXE_INCDIR,$(1),$(2))
+$(call __GENERATE_OBJECTRULES,$(OBJPATH)/$(1),$(2),$$(or $$($(1)_TARGET),TARGET))
+endef
+
+# ADD_EXE_INCDIR
+# This macro will add additional include paths to a module.
+ADD_EXE_INCDIR = $(eval $(call __ADD_EXE_INCDIR,$(1),$(2)))
+__ADD_EXE_INCDIR = \
+ $(foreach path,$(2),$(call ___ADD_EXE_INCDIR,$(1),$(path)))
+# Order of operations:
+# * Add path to -iquote COMMON flags for #include "" style include.
+# * Add path to -I COMMON flags for #include <> style include.
+# * Add path to $(exe)_INCDIRS for use by other targets.
+define ___ADD_EXE_INCDIR
+
+$(1)_COMMONFLAGS += -iquote$(2)
+$(1)_COMMONFLAGS += -I$(2)
+$(1)_INCDIRS += $(2)
+
+endef
diff --git a/tools/build/common.dir/modules.rules.mk b/tools/build/common.dir/modules.rules.mk
new file mode 100644
index 00000000..ed6bb7f1
--- /dev/null
+++ b/tools/build/common.dir/modules.rules.mk
@@ -0,0 +1,162 @@
+# IBM_PROLOG_BEGIN_TAG
+# This is an automatically generated prolog.
+#
+# $Source: tools/build/common.dir/modules.rules.mk $
+#
+# OpenPOWER HCODE Project
+#
+# COPYRIGHT 2015,2017
+# [+] International Business Machines Corp.
+#
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+# IBM_PROLOG_END_TAG
+
+# Makefile that defines how we build 'modules', which is another name for a
+# shared library.
+#
+# Macros:
+# BUILD_MODULE - Macro to automatically generate all the recipes for
+# building a shared library.
+# ADD_MODULE_OBJ - Macro to add additional objects to a module.
+# ADD_MODULE_SRCDIR - Macro to add additional source dirs to a module.
+# ADD_MODULE_INCDIR - Macro to add additional include dirs to a module.
+# Special variables:
+# lib$(MODULE)_*FLAGS - Extra compile / linker flags for a specific module.
+# lib$(MODULE)_DEPLIBS - Local modules that this module depends on.
+# lib$(MODULE)_EXTRALIBS - External shared libs that this module depends on.
+# lib$(MODULE)_PATH - Optional alternate location to place library objects.
+# lib$(MODULE)_TARGET - Optional mechanism to select between the 'host' or
+# 'target' (default) cross-compiler set.
+# Input:
+# Optional input to delay the running of BUILD_GENERATED macro to a
+# later phase.
+#
+# BUILD_MODULE
+# This macro will automatically generate all the recipes for building a
+# shared library. Requires that the following variables are defined
+# prior to calling this macro:
+# * MODULE=name - Give a name to the module.
+# * OBJS=list of objects - Give a list of .o files required.
+#
+# As a result, this macro will define how to build lib$(MODULE).so as well
+# as all necessary dependencies.
+BUILD_MODULE = $(eval $(call __BUILD_MODULE,$1))
+
+# Order of operations:
+# * Define default module object PATH.
+# * Add all OBJ to module objects.
+# * Add directory of the defining .mk file to the source path for this module.
+# * Set up LOCAL*FLAGS variables for the module.
+# * Define dependencies for the module:
+# - lib$(MODULE).a
+# - All lib$(MODULE)_DEPLIB modules.
+# - All lib$(MODULE)_EXTRALIBS shared libraries
+# - Call environment's __CALL_LDSO macro to link module.
+# * Define dependencies for the lib$(MODULE).a archive.
+# - All lib$(MODULE)_OBJS.
+# - Call environment's __CALL_AR macro to create archive.
+# * Add module and archive to 'clean' target list.
+# * Create helper target for 'make $(MODULE)'.
+# * Erase MODULE and OBJS variables.
+#
+# Input:
+# Optional input to delay the running of BUILD_GENERATED macro to a
+# later phase.
+
+define __BUILD_MODULE
+lib$(MODULE)_PATH ?= $(OBJPATH)/$(MODULE)
+lib$(MODULE)_LIBPATH ?= $(LIBPATH)
+$(call __ADD_MODULE_OBJ,$(MODULE),$(OBJS))
+$(call __ADD_MODULE_SRCDIR,$(MODULE),$(dir $(lastword $(MAKEFILE_LIST))))
+$$(lib$(MODULE)_LIBPATH)/lib$(MODULE).so: LOCALCOMMONFLAGS += $$(lib$(MODULE)_COMMONFLAGS)
+$$(lib$(MODULE)_LIBPATH)/lib$(MODULE).so: LOCALCFLAGS += $$(lib$(MODULE)_CFLAGS)
+$$(lib$(MODULE)_LIBPATH)/lib$(MODULE).so: LOCALCXXFLAGS += $$(lib$(MODULE)_CXXFLAGS)
+$$(lib$(MODULE)_LIBPATH)/lib$(MODULE).so: LOCALLDFLAGS += $$(lib$(MODULE)_LDFLAGS)
+$$(lib$(MODULE)_LIBPATH)/lib$(MODULE).so: $$(lib$(MODULE)_LIBPATH)/lib$(MODULE).a \
+ $$(foreach lib,$$(lib$(MODULE)_DEPLIBS),$$$$(lib$(MODULE)_LIBPATH)/lib$$(lib).a ) \
+ $$(lib$(MODULE)_EXTRALIBS) | $$(lib$(MODULE)_DEPSORDER)
+$(call __CALL_LDSO,$$(or $$(lib$(MODULE)_TARGET),TARGET))
+
+$$(lib$(MODULE)_LIBPATH)/lib$(MODULE).a: LOCALCOMMONFLAGS += $$(lib$(MODULE)_COMMONFLAGS)
+$$(lib$(MODULE)_LIBPATH)/lib$(MODULE).a: LOCALCFLAGS += $$(lib$(MODULE)_CFLAGS)
+$$(lib$(MODULE)_LIBPATH)/lib$(MODULE).a: LOCALCXXFLAGS += $$(lib$(MODULE)_CXXFLAGS)
+$$(lib$(MODULE)_LIBPATH)/lib$(MODULE).a: LOCALLDFLAGS += $$(lib$(MODULE)_LDFLAGS)
+
+
+$$(lib$(MODULE)_LIBPATH)/lib$(MODULE).a: $$(lib$(MODULE)_OBJS)
+$(call __CALL_AR,$$(or $$(lib$(MODULE)_TARGET),TARGET))
+
+$(call __CLEAN_TARGET,$$(lib$(MODULE)_LIBPATH)/lib$(MODULE).so)
+$(call __CLEAN_TARGET,$$(lib$(MODULE)_LIBPATH)/lib$(MODULE).a)
+$(call __CLEAN_TARGET,$$(lib$(MODULE)_LIBPATH)/$(MODULE)_x86_64.so)
+
+.PHONY: $(MODULE)
+$(MODULE) : _BUILD/GEN_TARGETS
+ @$$(MAKE) $$(lib$(MODULE)_LIBPATH)/lib$(MODULE).so
+$(or $(strip $1),MODULE)_TARGETS += $$(lib$(MODULE)_LIBPATH)/lib$(MODULE).so
+
+MODULE:=
+OBJS:=
+
+endef
+
+# ADD_MODULE_OBJ
+# This macro will add additional objects to a module's dependency list.
+# Usage:
+# $(call ADD_MODULE_OBJ,module,file1.o file2.o)
+ADD_MODULE_OBJ = $(eval $(call __ADD_MODULE_OBJ,$(1),$(2)))
+# Order of operations:
+# * Prepend lib$(MODULE)_PATH to the path for the object.
+# * Add object and corresponding .dep file to the 'clean' target list.
+# * Add generated .dep file for header-file dependencies to __DEP_INCLUDES.
+define __ADD_MODULE_OBJ
+lib$(1)_OBJS += $$(addprefix $$(lib$(1)_PATH)/,$(2))
+$(foreach obj,$(2),$(call CLEAN_TARGET,$$(lib$(1)_PATH)/$(obj))
+ $(call CLEAN_TARGET,$$(lib$(1)_PATH)/$(obj:.o=.dep)))
+
+__DEP_INCLUDES += $$(wildcard $$(addprefix $$(lib$(1)_PATH)/,$(2:.o=.dep)))
+endef
+
+# ADD_MODULE_SRCDIR
+# This macro will add additional source paths to a module.
+# Usage:
+# $(call ADD_MODULE_SRCDIR,module,/path1 /path2)
+ADD_MODULE_SRCDIR = $(eval $(call __ADD_MODULE_SRCDIR,$(1),$(2)))
+__ADD_MODULE_SRCDIR = \
+ $(foreach path,$(2),$(call ___ADD_MODULE_SRCDIR,$(1),$(2)))
+# Order of operations:
+# * Add the path to the include list.
+# * Generate all the possible .C->.o, .c->.o, etc. pattern recipes.
+define ___ADD_MODULE_SRCDIR
+$(call __ADD_MODULE_INCDIR,$(1),$(2))
+$(call __GENERATE_OBJECTRULES,$(OBJPATH)/$(1),$(2),$$(or $$(lib$(1)_TARGET),TARGET))
+endef
+
+# ADD_MODULE_INCDIR
+# This macro will add additional include paths to a module.
+ADD_MODULE_INCDIR = $(eval $(call __ADD_MODULE_INCDIR,$(1),$(2)))
+__ADD_MODULE_INCDIR = \
+ $(foreach path,$(2),$(call ___ADD_MODULE_INCDIR,$(1),$(path)))
+# Order of operations:
+# * Add path to -iquote COMMON flags for #include "" style include.
+# * Add path to -I COMMON flags for #include <> style include.
+# * Add path to lib$(module)_INCDIRS for use by other targets.
+define ___ADD_MODULE_INCDIR
+
+lib$(1)_COMMONFLAGS += -iquote$(2)
+lib$(1)_COMMONFLAGS += -I$(2)
+lib$(1)_INCDIRS += $(2)
+
+endef
diff --git a/tools/build/common.dir/objects.rules.mk b/tools/build/common.dir/objects.rules.mk
new file mode 100644
index 00000000..1af5cf9d
--- /dev/null
+++ b/tools/build/common.dir/objects.rules.mk
@@ -0,0 +1,57 @@
+# IBM_PROLOG_BEGIN_TAG
+# This is an automatically generated prolog.
+#
+# $Source: tools/build/common.dir/objects.rules.mk $
+#
+# IBM CONFIDENTIAL
+#
+# EKB Project
+#
+# COPYRIGHT 2015,2017
+# [+] International Business Machines Corp.
+#
+#
+# The source code for this program is not published or otherwise
+# divested of its trade secrets, irrespective of what has been
+# deposited with the U.S. Copyright Office.
+#
+# IBM_PROLOG_END_TAG
+
+# Makefile with helper utility for generating all the possible wildcard
+# recipes for an object file.
+
+# __GENERATE_OBJECTRULES
+# $(__GENERATE_OBJECTRULES,destpath,srcpath,target)
+# target should be one of: HOST, TARGET.
+define __GENERATE_OBJECTRULES
+.PRECIOUS: $(1)/%.o
+
+$(1)/%.o: LOCALCOMMONFLAGS += $$($$(@F)_COMMONFLAGS)
+$(1)/%.o: private LOCALCFLAGS += $$($$(@F)_CFLAGS)
+$(1)/%.o: private LOCALCXXFLAGS += $$($$(@F)_CXXFLAGS)
+
+$(1)/%.yy.o: $(2)/%.yy.C
+$(call __CALL_CXX_DEP,$(3))
+$(call __CALL_CXX,$(3))
+
+$(1)/%.tab.o: $(2)/%.tab.C
+$(call __CALL_CXX_DEP,$(3))
+$(call __CALL_CXX,$(3))
+
+$(1)/%.o: $(2)/%.C
+$(call __CALL_CXX_DEP,$(3))
+$(call __CALL_CXX,$(3))
+
+$(1)/%.o: $(2)/%.cc
+$(call __CALL_CXX_DEP,$(3))
+$(call __CALL_CXX,$(3))
+
+$(1)/%.o: $(2)/%.cpp
+$(call __CALL_CXX_DEP,$(3))
+$(call __CALL_CXX,$(3))
+
+$(1)/%.o: $(2)/%.c
+$(call __CALL_CC_DEP,$(3))
+$(call __CALL_CC,$(3))
+
+endef
diff --git a/tools/build/common.dir/order.final.mk b/tools/build/common.dir/order.final.mk
new file mode 100644
index 00000000..e98c1460
--- /dev/null
+++ b/tools/build/common.dir/order.final.mk
@@ -0,0 +1,66 @@
+# IBM_PROLOG_BEGIN_TAG
+# This is an automatically generated prolog.
+#
+# $Source: tools/build/common.dir/order.final.mk $
+#
+# OpenPOWER HCODE Project
+#
+# COPYRIGHT 2015,2017
+# [+] International Business Machines Corp.
+#
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+# IBM_PROLOG_END_TAG
+
+# Makefile to define the order of all the 'passes':
+# * 'GEN' where files are generated.
+# * 'MODULE' where modules are built.
+# * 'EXE' where executables are built.
+# * 'IMAGE' where images are built.
+# * 'ALL' for everything else, like documentation.
+
+HW_IMAGE_VERSION = $(shell cat $(ROOTPATH)/../tools/build/release_tag.txt)
+
+.PHONY: _BUILD/GEN_TARGETS _BUILD/GEN_TARGETS/ACT
+_BUILD/GEN_TARGETS:
+ @$(MAKE) _BUILD/GEN_TARGETS/ACT
+_BUILD/GEN_TARGETS/ACT: $(GEN_TARGETS) suppress_nothing_to_do
+
+.PHONY: _BUILD/MODULE_TARGETS _BUILD/MODULE_TARGETS/ACT
+_BUILD/MODULE_TARGETS: _BUILD/GEN_TARGETS
+ @$(MAKE) _BUILD/MODULE_TARGETS/ACT
+_BUILD/MODULE_TARGETS/ACT: $(MODULE_TARGETS) suppress_nothing_to_do
+
+.PHONY: _BUILD/EXE_TARGETS _BUILD/EXE_TARGETS/ACT
+_BUILD/EXE_TARGETS: _BUILD/MODULE_TARGETS
+ @$(MAKE) _BUILD/EXE_TARGETS/ACT
+_BUILD/EXE_TARGETS/ACT: $(EXE_TARGETS) suppress_nothing_to_do
+
+.PHONY: _BUILD/IMAGE_TARGETS _BUILD/IMAGE_TARGETS/ACT
+_BUILD/IMAGE_TARGETS: _BUILD/EXE_TARGETS | $(IMAGE_DEPS)
+ @$(MAKE) _BUILD/IMAGE_TARGETS/ACT
+_BUILD/IMAGE_TARGETS/ACT: $(IMAGE_TARGETS) suppress_nothing_to_do
+
+.PHONY: all _BUILD/ALL_TARGETS/ACT
+all: _BUILD/IMAGE_TARGETS install_rings
+ @$(MAKE) _BUILD/ALL_TARGETS/ACT
+ $(EXEPATH)/p9_xip_tool.exe $(IMAGEPATH)/hw_image/p9n.hw_image.bin set build_tag $(HW_IMAGE_VERSION)
+_BUILD/ALL_TARGETS/ACT: $(ALL_TARGETS) suppress_nothing_to_do
+
+
+.PHONY: install_rings
+
+install_rings:
+ @mkdir -p $(GENPATH)/rings/hw/
+ @cp $(BASEPATH)/rings/* $(GENPATH)/rings/hw/
diff --git a/tools/build/common.dir/symlink.rules.mk b/tools/build/common.dir/symlink.rules.mk
new file mode 100644
index 00000000..b5654f20
--- /dev/null
+++ b/tools/build/common.dir/symlink.rules.mk
@@ -0,0 +1,41 @@
+# IBM_PROLOG_BEGIN_TAG
+# This is an automatically generated prolog.
+#
+# $Source: tools/build/common.dir/symlink.rules.mk $
+#
+# IBM CONFIDENTIAL
+#
+# EKB Project
+#
+# COPYRIGHT 2015,2016
+# [+] International Business Machines Corp.
+#
+#
+# The source code for this program is not published or otherwise
+# divested of its trade secrets, irrespective of what has been
+# deposited with the U.S. Copyright Office.
+#
+# IBM_PROLOG_END_TAG
+#CREATE_SYMLINK
+# This macro creates a symlink for the generated common fapi2 files
+# that will be used to compile fapi2_ifCompiler as well
+# Input:
+# $1 = File with fully qualified path
+# $2 = output directory path
+# Output: A symlink to output directory
+define CREATE_SYMLINK
+$(eval GENERATED=create_symlink_$(notdir $1))
+$(eval SOURCES+=$1)
+$(eval TARGETS=$(notdir $1))
+$(eval $(GENERATED)_COMMAND_PATH=)
+$(eval $(GENERATED)_PATH=$2)
+$(eval $(GENERATED)_RUN=$(call CREATE_SYMLINK_RUN_COMMAND,$1))
+$(call BUILD_GENERATED)
+endef
+
+#CREATE_SYMLINK_RUN_COMMAND
+# This macro defines the command used to create the symlink
+define CREATE_SYMLINK_RUN_COMMAND
+ $(C1) rm -f $($(GENERATED)_PATH)/$(notdir $1) && \
+ ln -s $$$$(realpath $$$$<) $($(GENERATED)_PATH)/$(notdir $1)
+endef
diff --git a/tools/build/common.dir/util.rules.mk b/tools/build/common.dir/util.rules.mk
new file mode 100644
index 00000000..6b1d87f7
--- /dev/null
+++ b/tools/build/common.dir/util.rules.mk
@@ -0,0 +1,25 @@
+# IBM_PROLOG_BEGIN_TAG
+# This is an automatically generated prolog.
+#
+# $Source: tools/build/common.dir/util.rules.mk $
+#
+# IBM CONFIDENTIAL
+#
+# EKB Project
+#
+# COPYRIGHT 2015
+# [+] International Business Machines Corp.
+#
+#
+# The source code for this program is not published or otherwise
+# divested of its trade secrets, irrespective of what has been
+# deposited with the U.S. Copyright Office.
+#
+# IBM_PROLOG_END_TAG
+
+# Utility recipes and macros.
+
+# A bogus recipe to suppress makes 'nothing to do' messages.
+.PHONY: suppress_nothing_to_do
+suppress_nothing_to_do:
+ @true
diff --git a/tools/build/common.dir/verbose.rules.mk b/tools/build/common.dir/verbose.rules.mk
new file mode 100644
index 00000000..46e9dbf8
--- /dev/null
+++ b/tools/build/common.dir/verbose.rules.mk
@@ -0,0 +1,42 @@
+# IBM_PROLOG_BEGIN_TAG
+# This is an automatically generated prolog.
+#
+# $Source: tools/build/common.dir/verbose.rules.mk $
+#
+# IBM CONFIDENTIAL
+#
+# EKB Project
+#
+# COPYRIGHT 2013,2015
+# [+] International Business Machines Corp.
+#
+#
+# The source code for this program is not published or otherwise
+# divested of its trade secrets, irrespective of what has been
+# deposited with the U.S. Copyright Office.
+#
+# IBM_PROLOG_END_TAG
+
+# File: verbose.rules.mk
+# Description:
+# Control the verbosity of make commands by defining some prefixes that
+# other make rules can use.
+#
+# Setting the environment variable BUILD_VERBOSE=1 echos the full commands
+# being executed, while leaving it off echos just a short description.
+
+# Variables:
+# C1 - Prefix for the command to be executed. ex. '$(C1)$(CC) foo.C'
+# C2 - Prefix for the short description of the command. ex. '$(C2)CC foo.C'
+
+ifdef BUILD_VERBOSE
+ C1=
+ C2=@true || echo
+else
+ C1=@
+ C2=@echo
+ MAKE+= --no-print-directory
+endif
+
+MAKE+= --no-builtin-rules --no-builtin-variables
+
diff --git a/tools/build/image.dir/assembler.rules.mk b/tools/build/image.dir/assembler.rules.mk
new file mode 100644
index 00000000..eefbb821
--- /dev/null
+++ b/tools/build/image.dir/assembler.rules.mk
@@ -0,0 +1,43 @@
+# IBM_PROLOG_BEGIN_TAG
+# This is an automatically generated prolog.
+#
+# $Source: tools/build/image.dir/assembler.rules.mk $
+#
+# IBM CONFIDENTIAL
+#
+# EKB Project
+#
+# COPYRIGHT 2016
+# [+] International Business Machines Corp.
+#
+#
+# The source code for this program is not published or otherwise
+# divested of its trade secrets, irrespective of what has been
+# deposited with the U.S. Copyright Office.
+#
+# IBM_PROLOG_END_TAG
+
+# Makefile that defines how we build .S files
+# Currently, we are using power-pc assembler
+#
+# Macros:
+# __GENERATE_ASM_OBJECTRULES: Macro to compiler .S into .o
+# Inputs:
+# $1 == output path
+# $2 == src path
+# $3 == target toolchain
+define __GENERATE_ASM_OBJECTRULES
+.PRECIOUS: $1/%.s
+
+$1/%.o: private LOCALCOMMONFLAGS = $$(basename $($$(@F))_COMMONFLAGS)
+
+$1/%.s: private LOCALCOMMONFLAGS =
+
+$1/%.s : $(2)/%.S
+ $(C2) " GEN $$(@F)"
+ $(C1) mkdir -p $1 && $$($(3)_PREFIX)$$(CC) -E $$($$(basename $$(@F))_COMMONFLAGS) -o $$@ $$^
+
+$1/%.o : $1/%.s
+ $(C2) " GEN $$(@F)"
+ $(C1) mkdir -p $1 && $$($(3)_PREFIX)$$(AS) $$(ASFLAGS) -o $$@ $$^
+endef
diff --git a/tools/build/image.dir/bin.rules.mk b/tools/build/image.dir/bin.rules.mk
new file mode 100644
index 00000000..79f8affc
--- /dev/null
+++ b/tools/build/image.dir/bin.rules.mk
@@ -0,0 +1,71 @@
+# IBM_PROLOG_BEGIN_TAG
+# This is an automatically generated prolog.
+#
+# $Source: tools/build/image.dir/bin.rules.mk $
+#
+# IBM CONFIDENTIAL
+#
+# EKB Project
+#
+# COPYRIGHT 2016
+# [+] International Business Machines Corp.
+#
+#
+# The source code for this program is not published or otherwise
+# divested of its trade secrets, irrespective of what has been
+# deposited with the U.S. Copyright Office.
+#
+# IBM_PROLOG_END_TAG
+
+# Makefile that defines how we generate binaries for a specific XIP image
+#
+# Macros:
+# GEN_IMAGE_BINARY: Macro to generate an XIP normalized binary and
+# disassembly from an elf executable
+# Input:
+# $1 == IMAGE
+# $2 == OUTPUT PATH
+# $3 == TOOLCHAIN
+# Order Of Operation:
+# Run objcopy and objdump to gnerate an image_temp.bin
+# Run p9_xip_tool's normalize commonad on image_temp.bin
+# After normalization, copy image_temp.bin to image.bin
+# Set build_date, build_time, build_user, and build_host information in the
+# image
+# Create a report for this image
+define GEN_IMAGE_BINARY
+$2/$1_temp.bin : $2/$1.out
+ $(C2) " GEN $$(@F)"
+ $(C1) $$($(3)_PREFIX)$(OBJCOPY) -O binary $$^ $$@ --gap-fill 0x00 --pad-to 0x`/usr/bin/nm $$^ \
+ | grep "image_end" | cut -d " " -f 1`
+ $(C2) " GEN $$(@F).dis"
+ $(C1) $$($(3)_PREFIX)$$(OBJDUMP) -S $$^ > $2/$$(@F).dis
+
+$2/.$1.normalize.bin.built : $2/$1_temp.bin $(EXEPATH)/p9_xip_tool.exe
+ $(C2) " GEN $$(@F)"
+ $(call XIP_NORMALIZE,$2/$1_temp.bin) && \
+ cp $2/$1_temp.bin $2/$1.bin && touch $$@
+
+$(call XIP_TOOL,set,build_date,$2/.$1.normalize.bin.built,`date +%Y%m%d`)
+$(call XIP_TOOL,set,build_time,$2/.$1.setbuild_date,`date +%H%M`)
+$(call XIP_TOOL,set,build_user,$2/.$1.setbuild_time,`id -un`)
+$(call XIP_TOOL,set,build_host,$2/.$1.setbuild_user,`hostname`)
+
+$2/.$1.bin.built : $2/.$1.normalize.bin.built $$($1_TARGETS)
+ $(C2) " GEN $$(@F)"
+ $(C1) touch $$@
+
+$2/$1.bin : $2/.$1.bin.built
+$2/$1.dis : $2/.$1.bin.built
+
+
+$(call __CLEAN_TARGET,$2/.$1.bin.built)
+$(call __CLEAN_TARGET,$2/.$1.normalize.bin.built)
+$(call __CLEAN_TARGET,$2/$1_temp.bin)
+$(call __CLEAN_TARGET,$2/$1.bin)
+$(call __CLEAN_TARGET,$2/$1.s)
+$(call __CLEAN_TARGET,$2/$1.o)
+$(call __CLEAN_TARGET,$2/$1.dis)
+$(call __CLEAN_TARGET,$2/$1_temp.bin.dis)
+endef
+
diff --git a/tools/build/image.dir/binheader.rules.mk b/tools/build/image.dir/binheader.rules.mk
new file mode 100644
index 00000000..e8cfc82e
--- /dev/null
+++ b/tools/build/image.dir/binheader.rules.mk
@@ -0,0 +1,164 @@
+# IBM_PROLOG_BEGIN_TAG
+# This is an automatically generated prolog.
+#
+# $Source: tools/build/image.dir/binheader.rules.mk $
+#
+# IBM CONFIDENTIAL
+#
+# EKB Project
+#
+# COPYRIGHT 2016,2017
+# [+] International Business Machines Corp.
+#
+#
+# The source code for this program is not published or otherwise
+# divested of its trade secrets, irrespective of what has been
+# deposited with the U.S. Copyright Office.
+#
+# IBM_PROLOG_END_TAG
+#
+# Makefile that automatically define all the recipes required to generate an
+# binary header image
+#
+# MACROS:
+# BUILD_BINHEADER: Macro to automatically generate all the recipes
+# for building a binary header image
+#
+# ADD_BINHEADER_SRCDIR:
+# Macro to add additional source directories to an image
+# ADD_BINHEADER_INCDIR:
+# Macro to add additional include directories to an image
+#
+# Special Variables:
+# $(IMAGE)_PATH - alternate location to place image in
+# $(IMAGE)_LINK_SCRIPT - alternate linker script to use
+# $(IMAGE)_COMMONFLAGS - optional compile time flags to pass in
+#
+# BUILD_BINHEADER
+# This macro will automatically generate all the recipes for building
+# a binary header image. Requires that the following variables are defined:
+# - IMAGE=name - name of the image to generate
+# - $(IMAGE)_TARGET - toolchain to use (PPE|PPC2PPE)
+# As a result, this macro will define how to build $(IMAGE).bin
+BUILD_BINHEADER = $(eval $(call __BUILD_BINHEADER,$(1),$(2)))
+
+# Order of operation:
+# Define default output path and linker script
+# Add directory of the defining .mk file to the source path for this image
+# Setup LOCALCOMMONFLAGS for this image
+# Create phony target to allow "make $(IMAGE)"
+# Call helper macros to generate .bin file
+# Erase IMAGE and OBJS variable
+
+define __BUILD_BINHEADER
+$(IMAGE)_PATH ?= $(OBJPATH)/$(IMAGE)
+$(IMAGE)_LINK_SCRIPT ?= $(IMAGE)Link
+$(call ADD_BINHEADER_OBJ,$(IMAGE),$(OBJS))
+$(call ADD_BINHEADER_SRCDIR,$(IMAGE),$(dir $(lastword $(MAKEFILE_LIST))))
+
+$(IMAGEPATH)/$(IMAGE)/$(IMAGE).bin: LOCALCOMMONFLAGS =
+$(IMAGEPATH)/$(IMAGE)/$(IMAGE).bin: LOCALCOMMONFLAGS += $$($(IMAGE)_COMMONFLAGS)
+$(IMAGEPATH)/$(IMAGE)/$(IMAGE).bin: LOCALLDFLAGS = $$($(IMAGE)_LDFLAGS)
+
+.PHONY: $(IMAGE)
+$(IMAGE) :
+ $(C1) mkdir -p $(IMAGEPATH)/$(IMAGE)
+ @$$(MAKE) $(IMAGEPATH)/$(IMAGE)/$(IMAGE).bin
+
+##
+## rules to make a bin from a obj
+$(call GEN_HEADER_BINARY,$(IMAGE),$(IMAGEPATH)/$(IMAGE),PPE_BINUTILS,$1,$2)
+$(call PROCESS_LINK_SCRIPT,$(IMAGE),$(OBJPATH)/$(IMAGE),\
+ $$($(IMAGE)_LINK_SCRIPT),$$($(IMAGE)_TARGET))
+
+IMAGE_TARGETS += $(IMAGEPATH)/$(IMAGE)/$(IMAGE).bin
+
+IMAGE:=
+OBJS:=
+
+endef
+
+
+# ADD_BINHEADER_SRCDIR
+# This macro will add additional source paths to an executable.
+# Usage:
+# $(call ADD_BINHEADER_SRCDIR,exe,/path1 /path2)
+ADD_BINHEADER_SRCDIR = $(eval $(call __ADD_BINHEADER_SRCDIR,$(1),$(2)))
+__ADD_BINHEADER_SRCDIR = \
+ $(foreach path,$(2),$(call ___ADD_BINHEADER_SRCDIR,$(1),$(2)))
+# Order of operations:
+# * Add the path to the include list.
+# * Generate all the possible .C->.o, .c->.o, etc. pattern recipes.
+define ___ADD_BINHEADER_SRCDIR
+$(call __ADD_BINHEADER_INCDIR,$(1),$(2))
+$(call __GENERATE_PPE_OBJECTRULES,$(OBJPATH)/$(1),$(2),$$($(1)_TARGET))
+endef
+
+# ADD_BINHEADER_INCDIR
+# This macro will add additional include paths to a module.
+ADD_BINHEADER_INCDIR = $(eval $(call __ADD_BINHEADER_INCDIR,$(1),$(2)))
+__ADD_BINHEADER_INCDIR = \
+ $(foreach path,$(2),$(call ___ADD_BINHEADER_INCDIR,$(1),$(path)))
+# Order of operations:
+# * Add path to -I COMMON flags for #include <> style include.
+# * Add path to $(exe)_INCDIRS for use by other targets.
+define ___ADD_BINHEADER_INCDIR
+$(1)_COMMONFLAGS += -I$(2)
+$(1)_INCDIRS += $(2)
+
+endef
+
+# __ADD_BINHEADER_OBJ
+# This macro will add additional objects to a module's dependency list.
+# Usage:
+# $(call ADD_BINHEADER_OBJ,image,file1.o file2.o)
+ADD_BINHEADER_OBJ = $(eval $(call __ADD_BINHEADER_OBJ,$(1),$(2)))
+# Order of operations:
+# * Prepend $(IMAGE)_PATH to the path for the object.
+# * Add object and corresponding .dep file to the 'clean' target list.
+# * Add generated .dep file for header-file dependencies to __DEP_INCLUDES.
+# * Create any directories which are required for objects.
+define __ADD_BINHEADER_OBJ
+$(1)_OBJS += $$(addprefix $$($(1)_PATH)/,$(2))
+file= $$(addprefix $$($(1)_PATH)/,$(2))
+$(foreach obj,$(2),$(call CLEAN_TARGET,$$($(1)_PATH)/$(obj))
+ $(call CLEAN_TARGET,$$($(1)_PATH)/$(obj:.o=.dep))
+ $(call CLEAN_TARGET,$$($(1)_PATH)/$(obj:.o=.s)))
+
+__DEP_INCLUDES += $$(wildcard $$(addprefix $$($(1)_PATH)/,$(2:.o=.dep)))
+
+$(call depend_on_dir,$(file))
+
+endef
+
+# Makefile that defines how to make a binary image
+#
+# Macros:
+# GEN_HEADER_BINARY: Macro to generate a binary headerfile
+#
+# Input:
+# $1 == IMAGE
+# $2 == OUTPUT PATH
+# $3 == TARGET toolchain
+# $4 == DEPENDENT IMAGE 1 necessary for calculation of header entry value
+# $5 == DEPENDENT IMAGE 2 necessary for calculation of header entry value (optional)
+#
+# Order Of Operation:
+# Run objcopy to generate the binary
+# Run ImgEditor to add timestamp & version info to the binary
+
+define GEN_HEADER_BINARY
+$2/$1.bin : $(OBJPATH)/$1/link_$1_script $$($1_OBJS) $4
+ $(C2) " GEN $$(@F)"
+ $(C1) mkdir -p $(2) && \
+ $$($3_PREFIX)$$(LD) $$(LOCALLDFLAGS) \
+ -T$$< -Map $2/$1.map -o $2/$1_temp.bin \
+ -s $$($1_OBJS) && \
+ $$(EXEPATH)/$(IMAGE_EDITOR) $2/$1_temp.bin $(4) $(5) && \
+ mv $2/$1_temp.bin $$@
+
+$(call __CLEAN_TARGET,$2/$1.bin)
+$(call __CLEAN_TARGET,$2/$1.map)
+IMAGE_EDITOR=
+endef
+
diff --git a/tools/build/image.dir/cflags.env.mk b/tools/build/image.dir/cflags.env.mk
new file mode 100644
index 00000000..c8209e99
--- /dev/null
+++ b/tools/build/image.dir/cflags.env.mk
@@ -0,0 +1,44 @@
+# IBM_PROLOG_BEGIN_TAG
+# This is an automatically generated prolog.
+#
+# $Source: tools/build/image.dir/cflags.env.mk $
+#
+# IBM CONFIDENTIAL
+#
+# EKB Project
+#
+# COPYRIGHT 2016,2017
+# [+] International Business Machines Corp.
+#
+#
+# The source code for this program is not published or otherwise
+# divested of its trade secrets, irrespective of what has been
+# deposited with the U.S. Copyright Office.
+#
+# IBM_PROLOG_END_TAG
+
+# Override the LOCALCOMMONFLAGS from other cflags.env.mk files
+PPE_LOCALCOMMONFLAGS = -Wall -Werror
+PPE_LOCALCOMMONFLAGS += -fsigned-char
+PPE_LOCALCOMMONFLAGS += -msoft-float
+PPE_LOCALCOMMONFLAGS += -meabi
+PPE_LOCALCOMMONFLAGS += -msdata=eabi
+PPE_LOCALCOMMONFLAGS += -ffreestanding
+PPE_LOCALCOMMONFLAGS += -fno-common
+PPE_LOCALCOMMONFLAGS += -fno-inline-functions-called-once
+
+PPE_CFLAGS = -Os
+PPE_CFLAGS += -gpubnames -gdwarf-3
+PPE_CFLAGS += -ffunction-sections
+PPE_CFLAGS += -fdata-sections
+PPE_CFLAGS += -mcpu=ppe42
+PPE_CFLAGS += -pipe
+
+PPE_CXXFLAGS = -std=c++11
+PPE_CXXFLAGS += -nostdinc++
+PPE_CXXFLAGS += -fno-rtti
+PPE_CXXFLAGS += -fno-threadsafe-statics
+PPE_CXXFLAGS += -fno-exceptions
+
+ASFLAGS = -mppe42
+
diff --git a/tools/build/image.dir/ddcontainer.rules.mk b/tools/build/image.dir/ddcontainer.rules.mk
new file mode 100644
index 00000000..92af3d16
--- /dev/null
+++ b/tools/build/image.dir/ddcontainer.rules.mk
@@ -0,0 +1,67 @@
+# IBM_PROLOG_BEGIN_TAG
+# This is an automatically generated prolog.
+#
+# $Source: tools/build/image.dir/ddcontainer.rules.mk $
+#
+# IBM CONFIDENTIAL
+#
+# EKB Project
+#
+# COPYRIGHT 2017
+# [+] International Business Machines Corp.
+#
+#
+# The source code for this program is not published or otherwise
+# divested of its trade secrets, irrespective of what has been
+# deposited with the U.S. Copyright Office.
+#
+# IBM_PROLOG_END_TAG
+
+DD_CONTAINER_TOOL = $(eval $(call _DD_CONTAINER_TOOL,$1,$2,$3))
+
+# call p9_dd_container_tool.exe to create specified container
+#
+# outdated container is always removed first, because the tool
+# retains an existing container, and hence it complains about
+# duplicate dd levels being added to an existing container
+#
+# $1 dependencies (usually blocks to be added)
+# $2 container to be created
+# $3 blocks and DD levels to be added
+define _DD_CONTAINER_TOOL
+$2 : $(EXEPATH)/p9_dd_container_tool.exe $1
+ $(C2) " GEN $$(@F)"
+ $(C1) rm -f $2
+ $(C1) $(EXEPATH)/p9_dd_container_tool.exe --cont $2 --command add $3
+
+$(call __CLEAN_TARGET,$2)
+endef
+
+BUILD_DD_LEVEL_CONTAINER = $(eval $(call _BUILD_DD_LEVEL_CONTAINER,$1,$2))
+
+# creates parameters for p9_dd_container_tool command line, e.g.
+#
+# $(IMAGE)_DD_CONT = --cont output/images/sgpe_image/p9n.stop_gpe.bin
+# $(IMAGE)_DD_ADD = --dd 10 --block output/images/stop_gpe_p9n10/stop_gpe_p9n10.bin \
+# --dd 20 --block output/images/stop_gpe_p9n20/stop_gpe_p9n20.bin
+#
+# assuming this directory structure and these file names:
+#
+# output/images/<base file name>_<chip id><ec level>/<base file name>_<chip id><ec level>.bin
+#
+# $1 == chipId
+# $2 == base name of file without chipid/dd suffix
+
+define _BUILD_DD_LEVEL_CONTAINER
+$(eval $(IMAGE)_DD_CONT_$2?=$$($(IMAGE)_PATH)/$1.$2.bin)
+$(eval $(IMAGE)_DD_ADD_$2?=)
+$(eval $(IMAGE)_DD_DEPS_$2?=)
+
+$(foreach ec, $($(1)_EC),\
+ $(eval $(IMAGE)_DD_FILE_$2_$(ec)=$(IMAGEPATH)/$2_$1$(ec)/$2_$1$(ec).bin)\
+ $(eval $(IMAGE)_DD_DEPS_$2+= $$($(IMAGE)_DD_FILE_$2_$(ec)))\
+ $(eval $(IMAGE)_DD_ADD_$2+= --dd 0x$(ec) --block $$($(IMAGE)_DD_FILE_$2_$(ec))))
+
+$(eval $(call DD_CONTAINER_TOOL,$$($(IMAGE)_DD_DEPS_$2),$$($(IMAGE)_DD_CONT_$2),$$($(IMAGE)_DD_ADD_$2)))
+endef
+
diff --git a/tools/build/image.dir/dir.rules.mk b/tools/build/image.dir/dir.rules.mk
new file mode 100644
index 00000000..fd4e0505
--- /dev/null
+++ b/tools/build/image.dir/dir.rules.mk
@@ -0,0 +1,35 @@
+# IBM_PROLOG_BEGIN_TAG
+# This is an automatically generated prolog.
+#
+# $Source: tools/build/image.dir/dir.rules.mk $
+#
+# IBM CONFIDENTIAL
+#
+# EKB Project
+#
+# COPYRIGHT 2016
+# [+] International Business Machines Corp.
+#
+#
+# The source code for this program is not published or otherwise
+# divested of its trade secrets, irrespective of what has been
+# deposited with the U.S. Copyright Office.
+#
+# IBM_PROLOG_END_TAG
+#
+# Makefile that automatically define the recipies for all the p9_xip_tool
+# commands
+#
+# Macro:
+# depend_on_dir: adds an order only dependancy for a directory which contains
+# the specified file. Adds a target to create the directory
+# Input:
+# $1 - fully specified file
+# Usage: $(call depend_on_dir, path/to/object.o )
+define depend_on_dir
+$(1): | $(dir $(1))
+
+$(dir $(1)):
+ mkdir -p $$@
+
+endef
diff --git a/tools/build/image.dir/elfexe.rules.mk b/tools/build/image.dir/elfexe.rules.mk
new file mode 100644
index 00000000..edc06918
--- /dev/null
+++ b/tools/build/image.dir/elfexe.rules.mk
@@ -0,0 +1,46 @@
+# IBM_PROLOG_BEGIN_TAG
+# This is an automatically generated prolog.
+#
+# $Source: tools/build/image.dir/elfexe.rules.mk $
+#
+# IBM CONFIDENTIAL
+#
+# EKB Project
+#
+# COPYRIGHT 2016
+# [+] International Business Machines Corp.
+#
+#
+# The source code for this program is not published or otherwise
+# divested of its trade secrets, irrespective of what has been
+# deposited with the U.S. Copyright Office.
+#
+# IBM_PROLOG_END_TAG
+
+# Makefile that defines how we generate elf executable
+#
+# Macro: GEN_ELF_EXE: generates ELF exe from linker script and .S files
+#
+# Input:
+# $1 == IMAGE
+# $2 == OUTPUT PATH
+# $3 == TOOLCHAIN
+# $4 == LAYOUT
+# Usage:
+# $(call GEN_ELF_EXE,$(IMAGE),$$($(IMAGE)_PATH, prefix )
+define GEN_ELF_EXE
+$2/.$1.elf.built : $2/link_$1_script $4 $$($1_OBJS)
+ $(C2) " GEN $1.out"
+ $(C1) mkdir -p $(2) && \
+ $$($(3)_PREFIX)$$(LD) -T$$< -Map $2/$1.map -o $2/$1.out \
+ $4 $$($1_OBJS) --start-group --end-group && \
+ touch $$@
+
+$2/$1.out : $2/.$1.elf.built
+$2/$1.map : $2/.$1.elf.built
+
+$(call __CLEAN_TARGET,$2/.$1.elf.built)
+$(call __CLEAN_TARGET,$2/$1.out)
+$(call __CLEAN_TARGET,$2/$1.map)
+
+endef
diff --git a/tools/build/image.dir/elfout.rules.mk b/tools/build/image.dir/elfout.rules.mk
new file mode 100644
index 00000000..c59c267a
--- /dev/null
+++ b/tools/build/image.dir/elfout.rules.mk
@@ -0,0 +1,49 @@
+# IBM_PROLOG_BEGIN_TAG
+# This is an automatically generated prolog.
+#
+# $Source: tools/build/image.dir/elfout.rules.mk $
+#
+# IBM CONFIDENTIAL
+#
+# EKB Project
+#
+# COPYRIGHT 2016
+# [+] International Business Machines Corp.
+#
+#
+# The source code for this program is not published or otherwise
+# divested of its trade secrets, irrespective of what has been
+# deposited with the U.S. Copyright Office.
+#
+# IBM_PROLOG_END_TAG
+# Makefile that defines how we generate elf out
+#
+# Macro: GEN_ELF_OUT: generates ELF out from linker script and .S files
+#
+# Input:
+# $1 == IMAGE
+# $2 == OUTPUT PATH
+# $3 == TARGET toolchain
+# Usage:
+# $(call GEN_ELF_OUT,$(IMAGE),$$($(IMAGE)_PATH),$(TOOLCHAIN)
+
+define GEN_ELF_OUT
+$2/$1.out.built : $(OBJPATH)/$1/link_$1_script $$($1_OBJS)
+ $(C2) " GEN $1.out"
+ $(C1) mkdir -p $(2) && \
+ $$($3_PREFIX)$$(LD) $$(LDFLAGS) $$(LOCALLDFLAGS) \
+ -T$$< -Map $2/$1.map -o $2/$1.out $$($(1)_LIBPATH) \
+ $$($1_OBJS) --start-group $$($(1)_DEPLIBS) --end-group && \
+ touch $$@
+
+$2/$1.map : $2/$1.out.built
+$2/$1.out : $2/$1.out.built
+
+
+$(call __CLEAN_TARGET,$2/$1.out.built)
+$(call __CLEAN_TARGET,$2/$1.out)
+$(call __CLEAN_TARGET,$2/$1.map)
+
+endef
+
+
diff --git a/tools/build/image.dir/linkScript.rules.mk b/tools/build/image.dir/linkScript.rules.mk
new file mode 100644
index 00000000..5f523ede
--- /dev/null
+++ b/tools/build/image.dir/linkScript.rules.mk
@@ -0,0 +1,41 @@
+# IBM_PROLOG_BEGIN_TAG
+# This is an automatically generated prolog.
+#
+# $Source: tools/build/image.dir/linkScript.rules.mk $
+#
+# IBM CONFIDENTIAL
+#
+# EKB Project
+#
+# COPYRIGHT 2016,2017
+# [+] International Business Machines Corp.
+#
+#
+# The source code for this program is not published or otherwise
+# divested of its trade secrets, irrespective of what has been
+# deposited with the U.S. Copyright Office.
+#
+# IBM_PROLOG_END_TAG
+
+# Makefile that defines how we process a linker script
+#
+# Macro:
+# PROCESS_LINK_SCRIPT: Runs gcc pre-processor on link script
+# Inputs:
+# $1 = IMAGE
+# $2 = OUTPUTPATH
+# $3 = <image>.cmd
+# $4 = TARGET toolchain
+# Usage:
+# $(call PROCESS_LINK_SCRIPT,$(IMAGE),$$($(IMAGE)_PATH,$(IMAGE).cmd)
+define PROCESS_LINK_SCRIPT
+$2/link_$1_script : $(addprefix $(dir $(lastword $(MAKEFILE_LIST))),$3)
+ $(C2) " GEN link_$1_script"
+ $(C1) mkdir -p $2
+ $(C1) $$($(4)_PREFIX)$$(CPP) -E -x c++ -P $$($1_COMMONFLAGS) -Upowerpc $$< -o $2/link_$1_script_temp.cmd
+ $(C1) $$($(4)_PREFIX)$$(CPP) -E -x c++ -P $$($1_COMMONFLAGS) -Upowerpc $2/link_$1_script_temp.cmd -o $$@
+
+$(call __CLEAN_TARGET,$2/link_$1_script)
+
+endef
+
diff --git a/tools/build/image.dir/ppe.env.mk b/tools/build/image.dir/ppe.env.mk
new file mode 100644
index 00000000..27cb6d52
--- /dev/null
+++ b/tools/build/image.dir/ppe.env.mk
@@ -0,0 +1,52 @@
+# IBM_PROLOG_BEGIN_TAG
+# This is an automatically generated prolog.
+#
+# $Source: tools/build/image.dir/ppe.env.mk $
+#
+# IBM CONFIDENTIAL
+#
+# EKB Project
+#
+# COPYRIGHT 2016,2017
+# [+] International Business Machines Corp.
+#
+#
+# The source code for this program is not published or otherwise
+# divested of its trade secrets, irrespective of what has been
+# deposited with the U.S. Copyright Office.
+#
+# IBM_PROLOG_END_TAG
+#
+PK_SRCDIR=$(ROOTPATH)/chips/p9/procedures/ppe/pk
+PM_LIBDIR=$(ROOTPATH)/chips/p9/common/pmlib
+HCODE_LIBDIR=$(ROOTPATH)/chips/p9/procedures/ppe_closed/lib
+HCODE_COMMON_LIBDIR=$(ROOTPATH)/chips/p9/procedures/hwp/lib
+HCODE_UTILS_INCDIR=$(ROOTPATH)/chips/p9/procedures/utils/
+PPE_TOOLS=$(ROOTPATH)/chips/p9/procedures/ppe/tools
+PK_TRACEPP=$(EXEPATH)/ppetracepp.exe
+P2P_SRCDIR=$(PPE_TOOLS)/PowerPCtoPPE
+CME_SRCDIR=$(ROOTPATH)/chips/p9/procedures/ppe_closed/cme
+SGPE_SRCDIR=$(ROOTPATH)/chips/p9/procedures/ppe_closed/sgpe
+IPPE_SRCDIR=$(ROOTPATH)/chips/p9/procedures/ppe_closed/ippe
+FAPI2_SRCDIR=$(ROOTPATH)/chips/p9/procedures/ppe/hwpf/src
+FAPI2_PLAT_SRCDIR=$(ROOTPATH)/chips/p9/procedures/ppe/hwpf/src/plat
+PGPE_SRCDIR=$(ROOTPATH)/chips/p9/procedures/ppe_closed/pgpe
+SGPE_FAPI2_INC+=$(ROOTPATH)/chips/p9/procedures/ppe/hwpf/include/ \
+ $(ROOTPATH)/chips/p9/procedures/ppe/hwpf/include/plat/ \
+ $(ROOTPATH)/chips/p9/procedures/ppe_closed/sgpe/stop_gpe/utils/
+
+FAPI2_INC=$(ROOTPATH)/hwpf/fapi2/include/
+STD_INC+=$(ROOTPATH)/chips/p9/procedures/ppe/include/std/ \
+ $(ROOTPATH)/chips/p9/procedures/ppe/tools/ppetracepp/ \
+ $(ROOTPATH)/chips/p9/procedures/hwp/
+COMMON_INCDIR=$(ROOTPATH)/chips/p9/common/include/
+
+
+CPP?=gcc
+TCPP?=gcc
+AS?=as
+OBJCOPY?=objcopy
+OBJDUMP?=objdump
+
+PCP=$(P2P_SRCDIR)/ppc-ppe-pcp.py
+THASH = $(PPE_TOOLS)/ppetracepp/tracehash.pl
diff --git a/tools/build/image.dir/ppe_object.rules.mk b/tools/build/image.dir/ppe_object.rules.mk
new file mode 100644
index 00000000..50dc0dc6
--- /dev/null
+++ b/tools/build/image.dir/ppe_object.rules.mk
@@ -0,0 +1,96 @@
+# IBM_PROLOG_BEGIN_TAG
+# This is an automatically generated prolog.
+#
+# $Source: tools/build/image.dir/ppe_object.rules.mk $
+#
+# IBM CONFIDENTIAL
+#
+# EKB Project
+#
+# COPYRIGHT 2016
+# [+] International Business Machines Corp.
+#
+#
+# The source code for this program is not published or otherwise
+# divested of its trade secrets, irrespective of what has been
+# deposited with the U.S. Copyright Office.
+#
+# IBM_PROLOG_END_TAG
+
+# Makefile that defines how we build .o files from .S and .c
+# Currently, we are using power-pc ppe assembler
+#
+# Macros:
+# __GENERATE_PPE_OBJECTRULES: Macro to compiler .S/.c into .o
+# Extra step required for PPC2PPE environment .s to .es to .o
+#
+# For the PPE native compiler, it is anticipated that eventually
+# the .o will be generated directly from source, but until it's
+# mature, an intermediate .s is generated.
+#
+# The Trace strings are also extracted at this point.
+#
+# Inputs:
+# $1 == output path
+# $2 == src path
+# $3 == TARGET tool chain
+# $1/%.o: private LOCALCOMMONFLAGS += $$($$(@F)_COMMONFLAGS)
+
+define __GENERATE_PPE_OBJECTRULES
+.PRECIOUS: $(1)/%.s
+
+$1/%.s : $(2)/%.S
+ $(C2) " GEN $$(@F)"
+ $(C1) mkdir -p $$(@D)
+ $(C1) $$(PK_TRACEPP) $$($(3)_PREFIX)$$(CC) -E $$(LOCALCOMMONFLAGS) \
+ -o $$@ $$^
+
+$(1)/%.s: $(2)/%.c
+ $(C2) " DEP $$(@F:.s=.dep)"
+ $(C1) mkdir -p $$(@D)
+ $(C1) $$($(3)_PREFIX)$$(CC) -M -MP -MT $$@ \
+ $$(COMMONFLAGS) $$(CFLAGS) \
+ $$(LOCALCOMMONFLAGS) $$(LOCALCFLAGS) \
+ $$< -o $$(subst .s,.dep,$$@)
+
+ $(C2) " CC$(3) $$(@F)"
+ $(C1) $$(PK_TRACEPP) $$($(3)_PREFIX)$$(CC) $$(COMMONFLAGS) \
+ $$(CFLAGS) $$(LOCALCOMMONFLAGS) $$(LOCALCFLAGS) \
+ $$< -S -o $$@
+
+
+ifeq "PPE" "$(3)"
+$1/%.o : $1/%.s
+ $(C2) " GEN $$(@F)"
+ $(C1) mkdir -p $$(@D)
+ $(C1) $$($(3)_PREFIX)$$(AS) $$(ASFLAGS) -o $$@ $$^
+
+$(1)/%.s: $(2)/%.C
+ $(C2) " DEP $$(@F:.s=.dep)"
+ $(C1) mkdir -p $$(@D)
+ $(C1) $$($(3)_PREFIX)$$(CXX) -M -MP -MT $$@ \
+ $$(COMMONFLAGS) $$(CFLAGS) \
+ $$(LOCALCOMMONFLAGS) $$(LOCALCFLAGS) \
+ $$< -o $$(subst .s,.dep,$$@)
+
+ $(C2) " C++$(3) $$(@F)"
+ $(C1) $$(PK_TRACEPP) $$($(3)_PREFIX)$$(CXX) $$(COMMONFLAGS) \
+ $$(CFLAGS) $$(LOCALCOMMONFLAGS) $$(LOCALCFLAGS) $$(PPE_CXXFLAGS) \
+ $$< -S -o $$@
+
+else
+
+.PRECIOUS: $(1)/%.es
+
+$(1)/%.es: $(1)/%.s
+ $(C2) " PCP $$(@F)"
+ $(C1) $(PCP) -e -b -f $$< > /dev/null
+
+$(1)/%.o: $(1)/%.es
+ $(C2) " GEN $$(@F)"
+ $(C1) $$(PPE_BINUTILS_PREFIX)$$(AS) $$(ASFLAGS) -o $$@ $$<
+
+endif
+
+endef
+
diff --git a/tools/build/image.dir/ppebin.rules.mk b/tools/build/image.dir/ppebin.rules.mk
new file mode 100644
index 00000000..f3ac447a
--- /dev/null
+++ b/tools/build/image.dir/ppebin.rules.mk
@@ -0,0 +1,60 @@
+# IBM_PROLOG_BEGIN_TAG
+# This is an automatically generated prolog.
+#
+# $Source: tools/build/image.dir/ppebin.rules.mk $
+#
+# IBM CONFIDENTIAL
+#
+# EKB Project
+#
+# COPYRIGHT 2016,2017
+# [+] International Business Machines Corp.
+#
+#
+# The source code for this program is not published or otherwise
+# divested of its trade secrets, irrespective of what has been
+# deposited with the U.S. Copyright Office.
+#
+# IBM_PROLOG_END_TAG
+# Makefile that defines how we generate binaries for a specific source
+#
+# Macros:
+# GEN_PPEIMAGE_BINARY: Macro to generate a PPE image binary and disassembly
+# from an elf output.
+# Input:
+# $1 == IMAGE
+# $2 == OUTPUT PATH
+# $3 == TARGET toolchain
+#
+# Order Of Operation:
+# Run objcopy to generate the binary
+# If ImgEditor exists then run ImgEditor to add timestamp & version info
+# to the binary
+# Run objdump to generate an assembler listing
+# Run trace hash to generate the trexStringFile
+
+define GEN_PPEIMAGE_BINARY
+$2/$1.bin : $2/$1.out
+ $(C2) " GEN $$(@F)"
+ $(C1) mkdir -p $$(@D)
+ $(C1) $$($(3)_PREFIX)$$(OBJCOPY) -O binary $$^ $2/$1_temp.bin
+ifdef IMAGE_EDITOR
+ifneq ("$(wildcard $(EXEPATH)/$(IMAGE_EDITOR))", "")
+ $(C1) $(EXEPATH)/$(IMAGE_EDITOR) $2/$1_temp.bin;
+endif
+endif
+ $(C1) mv $2/$1_temp.bin $$@
+ $(C2) " GEN $$(@F).dis"
+ $(C1) $$($(3)_PREFIX)$$(OBJDUMP) -S $$^ > $2/$1.dis
+ $(C2) " GEN trexStringFile"
+ $(C1) $$(THASH) -c -d $(OBJPATH)/$(1) \
+ -s $(OBJPATH)/$(1)/trexStringFile > /dev/null
+
+$2/$1.dis : $2/$1.bin
+
+$(call __CLEAN_TARGET,$2/$1.bin)
+$(call __CLEAN_TARGET,$2/$1.dis)
+$(call __CLEAN_TARGET,$(OBJPATH)/$(1)/trexStringFile)
+IMAGE_EDITOR=
+endef
+
diff --git a/tools/build/image.dir/ppeimage.rules.mk b/tools/build/image.dir/ppeimage.rules.mk
new file mode 100644
index 00000000..da986989
--- /dev/null
+++ b/tools/build/image.dir/ppeimage.rules.mk
@@ -0,0 +1,139 @@
+# IBM_PROLOG_BEGIN_TAG
+# This is an automatically generated prolog.
+#
+# $Source: tools/build/image.dir/ppeimage.rules.mk $
+#
+# IBM CONFIDENTIAL
+#
+# EKB Project
+#
+# COPYRIGHT 2016
+# [+] International Business Machines Corp.
+#
+#
+# The source code for this program is not published or otherwise
+# divested of its trade secrets, irrespective of what has been
+# deposited with the U.S. Copyright Office.
+#
+# IBM_PROLOG_END_TAG
+#
+# Makefile that automatically define all the recipes required to generate a
+# PPE image
+#
+# MACROS:
+# BUILD_PPEIMAGE: Macro to automatically generate all the recipes for
+# building a PPE image
+# ADD_PPEIMAGE_SRCDIR: Macro to add additional source directories
+# ADD_PPEIMAGE_INCDIR: Macro to add additional include directories
+# Special Variables:
+# $(IMAGE)_PATH - alternate location to place image in
+# $(IMAGE)_LINK_SCRIPT - alternate linker script to use
+# $(IMAGE)_COMMONFLAGS - optional compile time flags to pass in
+#
+# BUILD_PPEIMAGE
+# This macro will automatically generate all the recipes for building a PPE
+# image. Requires that the following variables are defined:
+# - IMAGE=name - name of the image to generate
+# As a result, this macro will define how to build $(IMAGE).bin
+BUILD_PPEIMAGE = $(eval $(call __BUILD_PPEIMAGE))
+
+# Order of operation:
+# Define default output path and linker script
+# Add directory of the defining .mk file to the source path for this image
+# Setup LOCALCOMMONFLAGS for this image
+# Create phony target to allow "make $(IMAGE)"
+# Call helper macros to generate .bin file
+# Erase IMAGE and OBJS variable
+define __BUILD_PPEIMAGE
+
+$(IMAGE)_PATH ?= $(OBJPATH)/$(IMAGE)
+$(IMAGE)_LINK_SCRIPT ?= $(IMAGE).cmd
+
+ifeq "PPE" "$($(IMAGE)_TARGET)"
+endif
+
+$(call ADD_PPEIMAGE_OBJ,$(IMAGE),$(OBJS))
+$(call ADD_PPEIMAGE_SRCDIR,$(IMAGE),$(dir $(lastword $(MAKEFILE_LIST))))
+
+$(IMAGEPATH)/$(IMAGE)/$(IMAGE).bin: LOCALCOMMONFLAGS= $(PPE_LOCALCOMMONFLAGS)
+$(IMAGEPATH)/$(IMAGE)/$(IMAGE).bin: LOCALCOMMONFLAGS+= \
+ $($($(IMAGE)_TARGET)_CFLAGS)
+$(IMAGEPATH)/$(IMAGE)/$(IMAGE).bin: LOCALCOMMONFLAGS+= -DIMAGE_NAME=$(IMAGE)
+$(IMAGEPATH)/$(IMAGE)/$(IMAGE).bin: LOCALCOMMONFLAGS+= \
+ -DPK_TRACE_HASH_PREFIX=$($(IMAGE)_TRACE_HASH_PREFIX)
+$(IMAGEPATH)/$(IMAGE)/$(IMAGE).bin: LOCALCOMMONFLAGS+=$$($(IMAGE)_COMMONFLAGS)
+$(IMAGEPATH)/$(IMAGE)/$(IMAGE).bin: LOCALCFLAGS+= $$($(IMAGE)_CFLAGS)
+$(IMAGEPATH)/$(IMAGE)/$(IMAGE).bin: LOCALCXXFLAGS= $$($(IMAGE)_CXXFLAGS)
+$(IMAGEPATH)/$(IMAGE)/$(IMAGE).bin: LOCALLDFLAGS= $$($(IMAGE)_LDFLAGS)
+
+.PHONY: $(IMAGE)
+$(IMAGE) :
+ $(C1) mkdir -p $(IMAGEPATH)/$(IMAGE)
+ @$$(MAKE) $(IMAGEPATH)/$(IMAGE)/$(IMAGE).bin
+
+$(call GEN_PPEIMAGE_BINARY,$(IMAGE),$(IMAGEPATH)/$(IMAGE),PPE_BINUTILS)
+$(call GEN_ELF_OUT,$(IMAGE),$(IMAGEPATH)/$(IMAGE),PPE_BINUTILS)
+
+$(call PROCESS_LINK_SCRIPT,$(IMAGE),$(OBJPATH)/$(IMAGE),\
+ $$($(IMAGE)_LINK_SCRIPT),$$($(IMAGE)_TARGET))
+
+IMAGE_TARGETS += $(IMAGEPATH)/$(IMAGE)/$(IMAGE).bin
+
+IMAGE:=
+OBJS:=
+
+endef
+
+# ADD_PPEIMAGE_SRCDIR
+# This macro will add additional source paths to an executable.
+# Usage:
+# $(call ADD_PPEIMAGE_SRCDIR,exe,/path1 /path2)
+ADD_PPEIMAGE_SRCDIR = $(eval $(call __ADD_PPEIMAGE_SRCDIR,$(1),$(2)))
+__ADD_PPEIMAGE_SRCDIR = \
+ $(foreach path,$(2),$(call ___ADD_PPEIMAGE_SRCDIR,$(1),$(2)))
+# Order of operations:
+# * Add the path to the include list.
+# * Generate all the possible .C->.o, .c->.o, etc. pattern recipes.
+define ___ADD_PPEIMAGE_SRCDIR
+$(call __ADD_PPEIMAGE_INCDIR,$(1),$(2))
+$(call __GENERATE_PPE_OBJECTRULES,$(OBJPATH)/$(1),$(2),$$($(1)_TARGET))
+
+endef
+
+# ADD_PPEIMAGE_INCDIR
+# This macro will add additional include paths to a module.
+ADD_PPEIMAGE_INCDIR = $(eval $(call __ADD_PPEIMAGE_INCDIR,$(1),$(2)))
+__ADD_PPEIMAGE_INCDIR = \
+ $(foreach path,$(2),$(call ___ADD_PPEIMAGE_INCDIR,$(1),$(path)))
+# Order of operations:
+# * Add path to -I COMMON flags for #include <> style include.
+# * Add path to $(exe)_INCDIRS for use by other targets.
+define ___ADD_PPEIMAGE_INCDIR
+$(1)_COMMONFLAGS += -I$(2)
+$(1)_INCDIRS += $(2)
+
+endef
+
+
+
+
+# __ADD_PPEIMAGE_OBJ
+# This macro will add additional objects to a module's dependency list.
+# Usage:
+# $(call ADD_PPEIMAGE_OBJ,image,file1.o file2.o)
+ADD_PPEIMAGE_OBJ = $(eval $(call __ADD_PPEIMAGE_OBJ,$(1),$(2)))
+# Order of operations:
+# * Prepend $(IMAGE)_PATH to the path for the object.
+# * Add object and corresponding .dep file to the 'clean' target list.
+# * Add generated .dep file for header-file dependencies to __DEP_INCLUDES.
+define __ADD_PPEIMAGE_OBJ
+$(1)_OBJS += $$(addprefix $$($(1)_PATH)/,$(2))
+$(foreach obj,$(2),$(call CLEAN_TARGET,$$($(1)_PATH)/$(obj))
+ $(call CLEAN_TARGET,$$($(1)_PATH)/$(obj:.o=.dep))
+ $(call CLEAN_TARGET,$$($(1)_PATH)/$(obj:.o=.s))
+ $(call CLEAN_TARGET,$$($(1)_PATH)/$(obj:.o=.es))
+ $(call CLEAN_TARGET,$$($(1)_PATH)/$(obj:.o=.s.ppe.hash)))
+
+__DEP_INCLUDES += $$(wildcard $$(addprefix $$($(1)_PATH)/,$(2:.o=.dep)))
+
+endef
diff --git a/tools/build/image.dir/xipimage.rules.mk b/tools/build/image.dir/xipimage.rules.mk
new file mode 100644
index 00000000..8615daac
--- /dev/null
+++ b/tools/build/image.dir/xipimage.rules.mk
@@ -0,0 +1,123 @@
+# IBM_PROLOG_BEGIN_TAG
+# This is an automatically generated prolog.
+#
+# $Source: tools/build/image.dir/xipimage.rules.mk $
+#
+# IBM CONFIDENTIAL
+#
+# EKB Project
+#
+# COPYRIGHT 2016
+# [+] International Business Machines Corp.
+#
+#
+# The source code for this program is not published or otherwise
+# divested of its trade secrets, irrespective of what has been
+# deposited with the U.S. Copyright Office.
+#
+# IBM_PROLOG_END_TAG
+#
+# Makefile that automatically define all the recipes required to generate an
+# XIP image
+#
+# MACROS:
+# BUILD_XIPIMAGE: Macro to automatically generate all the recipes for building
+# an XIP image
+# ADD_XIPIMAGE_SRCDIR: Macro to add additional source directories to an image
+# ADD_XIPIMAGE_INCDIR: Macro to add additional include directories to an image
+# Special Variables:
+# $(IMAGE)_PATH - alternate location to place image in
+# $(IMAGE)_LINK_SCRIPT - alternate linker script to use
+# $(IMAGE)_COMMONFLAGS - optional compile time flags to pass in
+#
+# BUILD_XIPIMAGE
+# This macro will automatically generate all the recipes for building an xip
+# image. Requires that the following variables are defined:
+# - IMAGE=name - name of the image to generate
+# As a result, this macro will define how to build $(IMAGE).bin
+BUILD_XIPIMAGE = $(eval $(call __BUILD_XIPIMAGE))
+
+# Order of operation:
+# Define default output path and linker script
+# Add directory of the defining .mk file to the source path for this image
+# Setup LOCALCOMMONFLAGS for this image
+# Create phony target to allow "make $(IMAGE)"
+# Call helper macros to generate .bin file
+# Erase IMAGE and OBJS variable
+define __BUILD_XIPIMAGE
+$(IMAGE)_PATH ?= $(IMAGEPATH)/$(IMAGE)
+$(IMAGE)_LINK_SCRIPT ?= $(IMAGE).cmd
+$(IMAGE)_LAYOUT ?= $(IMAGEPATH)/$(IMAGE)/$(IMAGE).o
+
+XIPPATH=$(ROOTPATH)/chips/p9/xip
+
+$(call ADD_XIPIMAGE_INCDIR,$(IMAGE),$(XIPPATH))
+$(call ADD_XIPIMAGE_SRCDIR,$(IMAGE),$(dir $(lastword $(MAKEFILE_LIST))))
+$$($(IMAGE)_PATH)/$(IMAGE).bin : LOCALCOMMONFLAGS += $$($(IMAGE)_COMMONFLAGS)
+
+.PHONY: $(IMAGE)
+$(IMAGE) : _BUILD/GEN_TARGETS | $(IMAGE_DEPS)
+ $(C1) mkdir -p $$($(IMAGE)_PATH)
+ @$$(MAKE) $$($(IMAGE)_PATH)/$(IMAGE).bin
+ $(C1) mkdir -p $$($(IMAGE)_PATH)/p9n/ec_10
+ $(C1) ln -sf ../../$(IMAGE).bin $$($(IMAGE)_PATH)/p9n/ec_10/$(IMAGE).bin
+
+IMAGE_TARGETS += $$($(IMAGE)_PATH)/$(IMAGE).bin
+
+$(call GEN_IMAGE_BINARY,$(IMAGE),$$($(IMAGE)_PATH),$$(or $$($(1)_TARGET),PPE))
+$(call GEN_ELF_EXE,$(IMAGE),$$($(IMAGE)_PATH),$$(or $$($(1)_TARGET),PPE),$$($(IMAGE)_LAYOUT))
+$(call PROCESS_LINK_SCRIPT,$(IMAGE),$$($(IMAGE)_PATH), \
+ $$($(IMAGE)_LINK_SCRIPT),$$(or $$($(1)_TARGET),PPE))
+
+IMAGE:=
+OBJS:=
+
+endef
+
+# ADD_XIPIMAGE_SRCDIR
+# This macro will add additional source paths to an image
+# Usage:
+# $(call ADD_XIPIMAGE_SRCDIR,XIPIMAGE,/path1 /path2)
+ADD_XIPIMAGE_SRCDIR = $(eval $(call __ADD_XIPIMAGE_SRCDIR,$(1),$(2)))
+__ADD_XIPIMAGE_SRCDIR = \
+ $(foreach path,$(2),$(call ___ADD_XIPIMAGE_SRCDIR,$(1),$(2)))
+
+# Order of operations:
+# * Add the path to the include list.
+# * Generate all the possible .C->.o, .c->.o, etc. pattern recipes.
+define ___ADD_XIPIMAGE_SRCDIR
+$(call __ADD_XIPIMAGE_INCDIR,$(1),$(2))
+$(call __GENERATE_ASM_OBJECTRULES,$$($(IMAGE)_PATH),$(2),$$(or $$($(1)_TARGET),PPE))
+endef
+
+# ADD_XIPIMAGE_INCDIR
+# This macro will add additional include paths for an image
+ADD_XIPIMAGE_INCDIR = $(eval $(call __ADD_XIPIMAGE_INCDIR,$(1),$(2)))
+__ADD_XIPIMAGE_INCDIR = \
+ $(foreach path,$(2),$(call ___ADD_XIPIMAGE_INCDIR,$(1),$(path)))
+# Order of operations:
+# * Add path to -I COMMON flags for #include <> style include.
+# * Add path to $(IMAGE)_INCDIRS for use by other targets.
+define ___ADD_XIPIMAGE_INCDIR
+$(1)_COMMONFLAGS += -I$(2)
+$(1)_INCDIRS += $(2)
+endef
+
+
+# __ADD_XIPIMAGE_OBJ
+# This macro will add additional objects to a module's dependency list.
+# Usage:
+# $(call ADD_XIPIMAGE_OBJ,image,file1.o file2.o)
+ADD_XIPIMAGE_OBJ = $(eval $(call __ADD_XIPIMAGE_OBJ,$(1),$(2)))
+# Order of operations:
+# * Prepend $(IMAGE)_PATH to the path for the object.
+# * Add object and corresponding .dep file to the 'clean' target list.
+# * Add generated .dep file for header-file dependencies to __DEP_INCLUDES.
+define __ADD_XIPIMAGE_OBJ
+$(1)_OBJS += $$(addprefix $$($(1)_PATH)/,$(2))
+$(foreach obj,$(2),$(call CLEAN_TARGET,$$($(1)_PATH)/$(obj))
+ $(call CLEAN_TARGET,$$($(1)_PATH)/$(obj:.o=.dep)))
+
+__DEP_INCLUDES += $$(wildcard $$(addprefix $$($(1)_PATH)/,$(2:.o=.dep)))
+
+endef
diff --git a/tools/build/image.dir/xiptool.rules.mk b/tools/build/image.dir/xiptool.rules.mk
new file mode 100644
index 00000000..e25bfa31
--- /dev/null
+++ b/tools/build/image.dir/xiptool.rules.mk
@@ -0,0 +1,92 @@
+# IBM_PROLOG_BEGIN_TAG
+# This is an automatically generated prolog.
+#
+# $Source: tools/build/image.dir/xiptool.rules.mk $
+#
+# IBM CONFIDENTIAL
+#
+# EKB Project
+#
+# COPYRIGHT 2016,2017
+# [+] International Business Machines Corp.
+#
+#
+# The source code for this program is not published or otherwise
+# divested of its trade secrets, irrespective of what has been
+# deposited with the U.S. Copyright Office.
+#
+# IBM_PROLOG_END_TAG
+
+# Makefile that automatically define the recipies for all the p9_xip_tool
+# commands
+#
+# Macro:
+# XIP_TOOL: Defines a generic recipie to run any xip_tool command
+# Input:
+# $1 <- XIP Command
+# $2 <- section name <optional>
+# $3 <- any option that we need to pass to the XIP command and NEED to set a
+# dependency on <optional>
+# $4 <- any options that needs to be passed to the XIP command that we don't
+# need to set a dependency on <optional>
+# $5 <- optional target file diferentiator (eg. ec level)
+# Usage: $(call XIP_TOOL, append, .sgpe, path/to/sgpe.bin)
+
+XIP_TOOL = $(eval $(call _XIP_TOOL,$1,$2,$3,$4,$5))
+
+define _XIP_TOOL
+$(IMAGE)_PATH ?= $(IMAGEPATH)/$(IMAGE)
+
+$$($(IMAGE)_PATH)/.$(IMAGE).$(1)$(2)$(5) : $(EXEPATH)/p9_xip_tool.exe $3
+ $(C2) " GEN $$(@F)"
+ $(C1) $(EXEPATH)/p9_xip_tool.exe $$($(IMAGE)_PATH)/$(IMAGE).bin \
+ $1 $2 $4 > $$($(IMAGE)_PATH)/$(IMAGE).$(1)$(2)$(5) && touch $$@
+
+
+$(IMAGE)_TARGETS+= $$($(IMAGE)_PATH)/.$(IMAGE).$(1)$(2)$(5)
+$(call __CLEAN_TARGET,$$($(IMAGE)_PATH)/.$(IMAGE).$(1)$(2)$(5))
+$(call __CLEAN_TARGET,$$($(IMAGE)_PATH)/$(IMAGE).$(1)$(2)$(5))
+$(call __CLEAN_TARGET,$$@)
+
+endef
+
+# XIP_NORMALIZE command needs to be executed prior to generating a bin file for
+# an image. However, all the other xip commonads are executed after the
+# generation of the bin file. Therefore, we have a separate macro for XIP
+# NORMALIZE. If we use the generic XIP_TOOL, then we will end up with circular
+# dependency
+define XIP_NORMALIZE
+ $(C1) $(EXEPATH)/p9_xip_tool.exe $1 normalize
+endef
+
+# Macros:
+# APPEND_EMPTY_SECTION: Creates an image of a given size and appends it to
+# $(IMAGE).bin
+# Input:
+# $1 == XIP section to append the image to
+# $2 == Size of the section (in bytes)
+# $3 == Optional dependancy file
+# Usage:
+# $(call APPEND_EMPTY_SECTION,hcode,1024,$(CME_IMAGE_DEPS))
+APPEND_EMPTY_SECTION = $(eval $(call _APPEND_EMPTY_SECTION,$1,$2,$3))
+
+# Order of Operation:
+# - Define default path to the image being genreated
+# - Create a rule to generate an image of all zeros with a given size
+# - call XIP_TOOL append command to append the generated section to
+# the image
+define _APPEND_EMPTY_SECTION
+$(IMAGE)_PATH ?= $(IMAGEPATH)/$(IMAGE)
+
+$$($(IMAGE)_PATH)/$1.bin : $$($(IMAGE)_PATH)/.$(IMAGE).normalize.bin.built $3
+ $(C2) " GEN $$(@F)"
+ $(C1) dd if=/dev/zero of=$$($(IMAGE)_PATH)/$1.bin count=1 bs=$2 && \
+ touch $$($(IMAGE)_PATH)/$1.bin.done
+
+$$($(IMAGE)_PATH)/$1.bin.done: $$($(IMAGE)_PATH)/$1.bin
+
+$(call XIP_TOOL,append,.$(1),$$($(IMAGE)_PATH)/$1.bin.done,$$($(IMAGE)_PATH)/$1.bin)
+
+$(call __CLEAN_TARGET, $$($(IMAGE)_PATH)/$1.bin.done)
+$(call __CLEAN_TARGET, $$($(IMAGE)_PATH)/$1.bin)
+endef
diff --git a/tools/build/release_tag.txt b/tools/build/release_tag.txt
new file mode 100644
index 00000000..f777caef
--- /dev/null
+++ b/tools/build/release_tag.txt
@@ -0,0 +1 @@
+hw100117a.910
diff --git a/tools/build/rules.dir/cc.rules.mk b/tools/build/rules.dir/cc.rules.mk
new file mode 100644
index 00000000..173a1fdb
--- /dev/null
+++ b/tools/build/rules.dir/cc.rules.mk
@@ -0,0 +1,132 @@
+# IBM_PROLOG_BEGIN_TAG
+# This is an automatically generated prolog.
+#
+# $Source: tools/build/rules.dir/cc.rules.mk $
+#
+# OpenPOWER HCODE Project
+#
+# COPYRIGHT 2015,2017
+# [+] International Business Machines Corp.
+#
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+# IBM_PROLOG_END_TAG
+
+# Makefile that defines macros for calling various compiler tools:
+# * __CALL_CXX for C++ compiler.
+# * __CALL_CC for C compiler.
+# * __CALL_LDSO for the .so linker.
+# * __CALL_LD for the .exe linker.
+# * __CALL_AR for the archiver.
+# * __CALL_CXX_DEP for generating an include dependency via CXX.
+# * __CALL_CC_DEP for generating an include dependency via CC.
+#
+# See the manpage if you want to understand these incantations more.
+
+define __CALL_CXX
+ifeq "TARGET" "$(1)"
+ $(C2) " C++ $$(@F)"
+else
+ $(C2) " C++$(1) $$(@F)"
+endif
+ $(C1) mkdir -p $$(@D)
+ $(C1) $$($(1)_PREFIX)$$(CXX) $$(COMMONFLAGS) $$(CXXFLAGS) \
+ $$(LOCALCOMMONFLAGS) $$(LOCALCXXFLAGS) \
+ $$< -c -o $$@
+endef
+
+define __CALL_CC
+ifeq "TARGET" "$(1)"
+ $(C2) " CC $$(@F)"
+else
+ $(C2) " CC$(1) $$(@F)"
+endif
+ $(C1) mkdir -p $$(@D)
+ $(C1) $$($(1)_PREFIX)$$(CC) $$(COMMONFLAGS) $$(CFLAGS) \
+ $$(LOCALCOMMONFLAGS) $$(LOCALCFLAGS) \
+ $$< -c -o $$@
+endef
+
+define __CALL_LDSO
+ifeq "TARGET" "$(1)"
+ $(C2) " LDSO $$(@F)"
+else
+ $(C2) " LDSO$(1) $$(@F)"
+endif
+ $(C1) mkdir -p $$(@D)
+ $(C1) $$($(1)_PREFIX)$$(CXX) $$(LDFLAGS) \
+ -shared $$(addprefix -L,$(FAPI2_PLAT_LIB)) $$(LOCALLDFLAGS) \
+ $$(patsubst lib%.so,-l%, $$(notdir $$(filter %.so, $$^))) \
+ -Wl,--whole-archive \
+ $$(filter-out $$(CTEPATH)%, $$(filter %.a,$$^)) \
+ -Wl,--no-whole-archive \
+ $$(filter $$(CTEPATH)%, $$(filter %.a,$$^)) -o $$@
+ $(C1) ln -sf $$@ \
+ $$(addprefix $$(dir $$@),$$(patsubst lib%.so, %_x86_64.so,$$(notdir $$@)))
+endef
+
+define __CALL_LD
+ifeq "TARGET" "$(1)"
+ $(C2) " LD $$(@F)"
+else
+ $(C2) " LD$(1) $$(@F)"
+endif
+ $(C1) mkdir -p $$(@D)
+ $(C1) $$($(1)_PREFIX)$$(CXX) $$(LDFLAGS) \
+ $$(addprefix -L,$(FAPI2_PLAT_LIB)) $$(LOCALLDFLAGS) \
+ $$(patsubst lib%.so,-l%, $$(notdir $$(filter %.so, $$^))) \
+ -Wl,--whole-archive \
+ $$(filter-out $$(CTEPATH)%, $$(filter %.a,$$^)) \
+ -Wl,--no-whole-archive \
+ $$(filter $$(CTEPATH)%, $$(filter %.a,$$^)) \
+ -o $$@
+endef
+
+define __CALL_AR
+ifeq "TARGET" "$(1)"
+ $(C2) " AR $$(@F)"
+else
+ $(C2) " AR$(1) $$(@F)"
+endif
+ $(C1) mkdir -p $$(@D)
+ $(C1) rm -f $$@
+ $(C1) $$($(1)_PREFIX)$$(AR) rcs $$@ $$^
+endef
+
+define __CALL_CXX_DEP
+ifeq "TARGET" "$(1)"
+ $(C2) " DEP $$(@F:.o=.dep)"
+else
+ $(C2) " DEP$(1) $$(@F:.o=.dep)"
+endif
+ $(C1) mkdir -p $$(@D)
+ $(C1) $$($(1)_PREFIX)$$(CXX) -M -MP -MT $$@ \
+ $$(COMMONFLAGS) $$(CXXFLAGS) \
+ $$(LOCALCOMMONFLAGS) $$(LOCALCXXFLAGS) \
+ $$< -o $$(subst .o,.dep,$$@)
+endef
+
+define __CALL_CC_DEP
+ifeq "TARGET" "$(1)"
+ $(C2) " DEP $$(@F:.o=.dep)"
+else
+ $(C2) " DEP$(1) $$(@F:.o=.dep)"
+endif
+ $(C1) mkdir -p $$(@D)
+ $(C1) $$($(1)_PREFIX)$$(CC) -M -MP -MT $$@ \
+ $$(COMMONFLAGS) $$(CFLAGS) \
+ $$(LOCALCOMMONFLAGS) $$(LOCALCFLAGS) \
+ $$< -o $$(subst .o,.dep,$$@)
+
+endef
diff --git a/tools/build/rules.dir/cflags.env.mk b/tools/build/rules.dir/cflags.env.mk
new file mode 100644
index 00000000..e76f185a
--- /dev/null
+++ b/tools/build/rules.dir/cflags.env.mk
@@ -0,0 +1,32 @@
+# IBM_PROLOG_BEGIN_TAG
+# This is an automatically generated prolog.
+#
+# $Source: tools/build/rules.dir/cflags.env.mk $
+#
+# OpenPOWER HCODE Project
+#
+# COPYRIGHT 2015,2017
+# [+] International Business Machines Corp.
+#
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+# IBM_PROLOG_END_TAG
+
+# Makefile for additional compile flags.
+
+# Force 64 bit compile and link.
+ifeq ( $(UNAME), Linux )
+LOCALCOMMONFLAGS += -m64
+endif
+CFLAGS += -O0
diff --git a/tools/build/rules.dir/chips.env.mk b/tools/build/rules.dir/chips.env.mk
new file mode 100644
index 00000000..f52ca500
--- /dev/null
+++ b/tools/build/rules.dir/chips.env.mk
@@ -0,0 +1,33 @@
+# IBM_PROLOG_BEGIN_TAG
+# This is an automatically generated prolog.
+#
+# $Source: tools/build/rules.dir/chips.env.mk $
+#
+# OpenPOWER HCODE Project
+#
+# COPYRIGHT 2015,2017
+# [+] International Business Machines Corp.
+#
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+# IBM_PROLOG_END_TAG
+
+# Lists of chip subdirectories.
+CHIPS += p9
+
+p9_CHIPID += p9n
+
+p9n_EC += 10 20 21
+
+HW_IMAGE_VARIATIONS = hw
diff --git a/tools/build/rules.dir/dirs.env.mk b/tools/build/rules.dir/dirs.env.mk
new file mode 100644
index 00000000..45a97201
--- /dev/null
+++ b/tools/build/rules.dir/dirs.env.mk
@@ -0,0 +1,47 @@
+# IBM_PROLOG_BEGIN_TAG
+# This is an automatically generated prolog.
+#
+# $Source: tools/build/rules.dir/dirs.env.mk $
+#
+# OpenPOWER HCODE Project
+#
+# COPYRIGHT 2015,2017
+# [+] International Business Machines Corp.
+#
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+# IBM_PROLOG_END_TAG
+
+# Makefile to define additional paths to find global makefiles.
+
+# Pick up fapi2 makefiles.
+ifeq ($(UNAME),Linux)
+
+# Pick up image build makefiles
+MAKEFILE_PATH += $(ROOTPATH)/chips/p9/procedures/ppe_closed/cme/stop_cme
+MAKEFILE_PATH += $(ROOTPATH)/chips/p9/procedures/ppe_closed/cme
+MAKEFILE_PATH += $(ROOTPATH)/chips/p9/procedures/ppe_closed/sgpe/stop_gpe
+MAKEFILE_PATH += $(ROOTPATH)/chips/p9/procedures/ppe_closed/sgpe/boot
+MAKEFILE_PATH += $(ROOTPATH)/chips/p9/procedures/ppe_closed/pgpe/pstate_gpe
+MAKEFILE_PATH += $(ROOTPATH)/chips/p9/procedures/ppe_closed/pgpe/boot
+MAKEFILE_PATH += $(ROOTPATH)/chips/p9/procedures/ppe_closed/ippe/iox
+MAKEFILE_PATH += $(ROOTPATH)/chips/p9/procedures/ppe_closed/ippe/ioa
+MAKEFILE_PATH += $(ROOTPATH)/chips/p9/procedures/ppe/tools/ppetracepp
+MAKEFILE_PATH += $(ROOTPATH)/chips/p9/xip
+MAKEFILE_PATH += $(ROOTPATH)/chips/p9/utils/imageProcs
+MAKEFILE_PATH += $(ROOTPATH)/tools/imageProcs
+MAKEFILE_PATH += $(BASEPATH)/tools/imageProcs
+endif
+
+
diff --git a/tools/build/rules.dir/fapi2.env.mk b/tools/build/rules.dir/fapi2.env.mk
new file mode 100644
index 00000000..564fdc20
--- /dev/null
+++ b/tools/build/rules.dir/fapi2.env.mk
@@ -0,0 +1,81 @@
+# IBM_PROLOG_BEGIN_TAG
+# This is an automatically generated prolog.
+#
+# $Source: tools/build/rules.dir/fapi2.env.mk $
+#
+# OpenPOWER HCODE Project
+#
+# COPYRIGHT 2015,2017
+# [+] International Business Machines Corp.
+#
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+# IBM_PROLOG_END_TAG
+
+# Makefile to define all the variables and paths for building FAPI2 under
+# Cronus.
+
+# Attribute XML files.
+# Filter out Temp defaults XML file from Attribute XML files.
+# NOTE: The hb_temp_defaults.xml file is not a normal attribute file with the
+# normal structures that define the attribute itself. It temporarily
+# provides default values for new attributes defined in other files.
+FAPI2_ATTR_XML += $(wildcard $(addsuffix /procedures/xml/attribute_info/*.xml, \
+ $(addprefix $(ROOTPATH)/chips/,$(CHIPS))))
+FAPI2_ATTR_XML += $(filter-out \
+ $(ROOTPATH)/hwpf/fapi2/xml/attribute_info/hb_temp_defaults.xml, \
+ $(wildcard $(ROOTPATH)/hwpf/fapi2/xml/attribute_info/*.xml))
+
+# Error XML files.
+FAPI2_ERROR_XML += $(wildcard $(addsuffix /procedures/xml/error_info/*.xml, \
+ $(addprefix $(ROOTPATH)/chips/,$(CHIPS))))
+FAPI2_ERROR_XML += $(wildcard $(ROOTPATH)/hwpf/fapi2/xml/error_info/*.xml)
+
+# Chip SCOM address header files.
+FAPI2_PLAT_INCLUDE += $(addsuffix /common/include, \
+ $(addprefix $(ROOTPATH)/chips/,$(CHIPS)))
+
+# HW Init header files.
+FAPI2_PLAT_INCLUDE += $(addsuffix /procedures/hwp/initfiles, \
+ $(addprefix $(ROOTPATH)/chips/,$(CHIPS)))
+
+# Utils header files
+FAPI2_PLAT_INCLUDE += $(addsuffix /utils, \
+ $(addprefix $(ROOTPATH)/chips/,$(CHIPS)))
+
+# Scan Rings header files
+FAPI2_PLAT_INCLUDE += $(addsuffix /utils/imageProcs, \
+ $(addprefix $(ROOTPATH)/chips/,$(CHIPS)))
+
+# include the ffdc collection procedures
+FAPI2_PLAT_INCLUDE += $(addsuffix /procedures/hwp/ffdc, \
+ $(addprefix $(ROOTPATH)/chips/,$(CHIPS)))
+
+# FAPI2 paths
+FAPI2_PATH = $(ROOTPATH)/hwpf/fapi2
+FAPI2_PLAT_INCLUDE += $(FAPI2_PATH)/include
+
+# FAPI2 paths from Cronus.
+FAPI2_PLAT_INCLUDE += $(ECMD_PLAT_INCLUDE)
+FAPI2_PLAT_INCLUDE += $(CTEPATH)/tools/ecmd/$(ECMD_RELEASE)/ext/fapi2/capi
+FAPI2_PLAT_INCLUDE += $(FAPI2_PATH)/include/plat
+FAPI2_PLAT_LIB = $(ECMD_PLAT_LIB)
+FAPI2_SCRIPT_PATH += \
+ $(CTEPATH)/tools/ecmd/$(ECMD_RELEASE)/ext/fapi2/capi/scripts
+
+# Extra libraries to link against for Cronus.
+FAPI2_REQUIRED_LIBS += $(ECMD_REQUIRED_LIBS)
+FAPI2_REQUIRED_LIBS += $(FAPI2_PLAT_LIB)/fapi2ClientCapi.a
+FAPI2_REQUIRED_LIBS += $(FAPI2_PLAT_LIB)/libfapi2.so
+
diff --git a/tools/build/rules.dir/mflags.env.mk b/tools/build/rules.dir/mflags.env.mk
new file mode 100644
index 00000000..77aaad6f
--- /dev/null
+++ b/tools/build/rules.dir/mflags.env.mk
@@ -0,0 +1,58 @@
+# IBM_PROLOG_BEGIN_TAG
+# This is an automatically generated prolog.
+#
+# $Source: tools/build/rules.dir/mflags.env.mk $
+#
+# OpenPOWER HCODE Project
+#
+# COPYRIGHT 2015,2017
+# [+] International Business Machines Corp.
+#
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+# IBM_PROLOG_END_TAG
+
+# Makefile to contain general default variables for the make environment.
+
+# Default output paths.
+ROOTPATH=../../import
+OUTPUTPATH?=$(ROOTPATH)/../output
+LIBPATH?=$(OUTPUTPATH)/lib
+EXEPATH?=$(OUTPUTPATH)/bin
+OBJPATH?=$(OUTPUTPATH)/obj
+GENPATH?=$(OUTPUTPATH)/gen
+IMAGEPATH?=$(OUTPUTPATH)/images
+XIPPATH?=$(ROOTPATH)/chips/p9/xip
+
+# Location of the cross-compiler toolchain.
+UNAME = $(shell uname)
+__EKB_PREFIX?=/opt/rh/devtoolset-2/root/usr/bin/
+
+ifeq ($(UNAME),AIX)
+__EKB_PREFIX=/opt/xsite/contrib/bin/
+endif
+
+HOST_PREFIX?=$(__EKB_PREFIX)
+TARGET_PREFIX?=$(__EKB_PREFIX)
+
+# Location of PPE42 cross-compiler toolchain
+PPE_TOOL_PATH ?= $(CTEPATH)/tools/ppetools/prod
+PPE_PREFIX ?= $(PPE_TOOL_PATH)/bin/powerpc-eabi-
+PPE_BINUTILS_PREFIX ?= $(PPE_TOOL_PATH)/powerpc-eabi/bin/
+
+# Default compiler tools to use.
+CC?=gcc
+CXX?=g++
+AR?=ar
+LD?=ld
diff --git a/tools/build/rules.dir/procedure.rules.mk b/tools/build/rules.dir/procedure.rules.mk
new file mode 100644
index 00000000..3e7c7ef0
--- /dev/null
+++ b/tools/build/rules.dir/procedure.rules.mk
@@ -0,0 +1,76 @@
+# IBM_PROLOG_BEGIN_TAG
+# This is an automatically generated prolog.
+#
+# $Source: tools/build/rules.dir/procedure.rules.mk $
+#
+# OpenPOWER HCODE Project
+#
+# COPYRIGHT 2015,2017
+# [+] International Business Machines Corp.
+#
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+# IBM_PROLOG_END_TAG
+
+# Makefile that defines how we build 'procedures', which are a special kind of
+# module recognized by Cronus.
+
+# BUILD_PROCEDURE
+# This macro will automatically generate all the recipes for building a
+# procedure. Requires that the following variables are defined prior to
+# calling this macro:
+# * PROCEDURE=name - Name of the procedure. name.o is an implied
+# required object.
+# * FAPI=version - Optional method to specify the FAPI version.
+#
+# Input: $1
+# * Optional input to delay the running of BUILD_MODULE macro to a
+# later phase
+#
+define BUILD_PROCEDURE
+$(eval $(call __BUILD_PROCEDURE)) \
+$(call BUILD_MODULE,$1) \
+$(eval PROCEDURE:=) \
+$(eval FAPI:=)
+endef
+
+# Order of operations:
+# * Assign MODULE=$(PROCEDURE)
+# * Add $(PROCEDURE).o to the required objects.
+# * Call the macro for the FAPI1, FAPI2, or FAPI2_IFCOMPILER specific flags.
+define __BUILD_PROCEDURE
+MODULE = $(PROCEDURE)
+OBJS += $(if $(filter $(FAPI),2_IFCOMPILER),,$(PROCEDURE).o)
+$(if $(FAPI),$(call FAPI$(FAPI)_PROCEDURE),$(call FAPI2_PROCEDURE))
+endef
+
+
+# Settings needed for FAPI1 procedures.
+define FAPI1_PROCEDURE
+$(warning "WARNING: We don't know how to build FAPI1 yet for $(PROCEDURE)")
+endef
+
+# Settings needed for FAPI2 rocedures.
+# * Add the $(GENPATH) to the source directory.
+# * Add fapi2 framework include path.
+# * Add Cronus inclue paths.
+# * Add dependency for fapi2 module.
+# * Add dependency on Cronus libraries.
+# * Add dependency on libdl.so.
+define FAPI2_PROCEDURE
+$(call ADD_MODULE_SRCDIR,$(PROCEDURE),$(GENPATH))
+$(call __ADD_MODULE_INCDIR,$(PROCEDURE),$(FAPI2_PATH)/include)
+$(call __ADD_MODULE_INCDIR,$(PROCEDURE),$(FAPI2_PLAT_INCLUDE))
+lib$(PROCEDURE)_LDFLAGS += -ldl
+endef
diff --git a/tools/envsetup/gerrit-hostname b/tools/envsetup/gerrit-hostname
new file mode 100755
index 00000000..443a6598
--- /dev/null
+++ b/tools/envsetup/gerrit-hostname
@@ -0,0 +1,79 @@
+#!/usr/bin/perl
+# IBM_PROLOG_BEGIN_TAG
+# This is an automatically generated prolog.
+#
+# $Source: tools/envsetup/gerrit-hostname $
+#
+# OpenPOWER HCODE Project
+#
+# COPYRIGHT 2015,2017
+# [+] International Business Machines Corp.
+#
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+# IBM_PROLOG_END_TAG
+
+## Usage
+# It is imperative that there are no prints other than the die command or
+# "export GERRIT_SRV=$host" as this script is evaluated by env.bash and not
+# called directly
+
+use strict;
+
+my $homeDir = $ENV{'HOME'};
+my $sshConfigFile = $homeDir."/.ssh/config";
+# If the server changes location these will change
+my $gerritHostname = "ralgit01.raleigh.ibm.com";
+my $gerritPort = "29418";
+
+open(CONFIG, "< $sshConfigFile") or die " $? can't open $sshConfigFile: $!" ;
+
+my $host = "";
+my $hostname = "";
+my $port = "";
+while (my $line = <CONFIG>)
+{
+ # Whitespace after each constant is important
+ if ($line =~ m/^Host [^\s]/)
+ {
+ ($host) = $line =~ m/^Host (.*?)\s/;
+ }
+ elsif ($line =~ m/Hostname [^\s]/)
+ {
+ ($hostname) = $line =~ m/^*Hostname (.*)/;
+ }
+ elsif ($line =~ m/Port [^\s]/)
+ {
+ ($port) = $line =~ m/^*Port (.*)/;
+ }
+
+ # Check if we found the gerrit host name
+ if ($host ne "" &&
+ $hostname eq $gerritHostname &&
+ $port eq $gerritPort)
+ {
+ last;
+ }
+}
+close(CONFIG);
+
+if ($host eq "")
+{
+ die "Error> Could not find gerrit host in $sshConfigFile";
+}
+else
+{
+ # Set gerrit server env variable by returning command to env.bash
+ print "export GERRIT_SRV=$host\n";
+}
diff --git a/tools/envsetup/setupgithooks b/tools/envsetup/setupgithooks
new file mode 100755
index 00000000..12444caf
--- /dev/null
+++ b/tools/envsetup/setupgithooks
@@ -0,0 +1,64 @@
+#!/bin/bash
+# IBM_PROLOG_BEGIN_TAG
+# This is an automatically generated prolog.
+#
+# $Source: tools/envsetup/setupgithooks $
+#
+# OpenPOWER HCODE Project
+#
+# COPYRIGHT 2015,2017
+# [+] International Business Machines Corp.
+#
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+# IBM_PROLOG_END_TAG
+
+# Each developer runs this from the git_repo base dir, where it will copy the
+# needed scripts into .git/hooks/ directory and make them executable.
+
+if [ -d $HOOKSDIR ]
+then
+
+ # Get hooks from Gerrit, if needed.
+ if [ ! -f $HOOKSDIR/commit-msg ]
+ then
+ echo "Copying Gerrit hooks..."
+ scp -p -q $GERRIT_SRV:hooks/commit-msg $HOOKSDIR || exit -1
+ fi
+
+ # Copy custom pre/post commit hooks from tools directory.
+ if [ -f "$EKBHOOKSDIR/pre-commit" -a \
+ -f "$EKBHOOKSDIR/post-commit" ]
+ then
+ echo "Copying pre/post commit hooks..."
+
+ cp $EKBHOOKSDIR/pre-commit $HOOKSDIR/ || exit -1
+ cp $EKBHOOKSDIR/pre-commit $HOOKSDIR/pre-applypatch || exit -1
+ cp $EKBHOOKSDIR/post-commit $HOOKSDIR/ || exit -1
+
+ chmod u+x $HOOKSDIR/pre-commit || exit -1
+ chmod u+x $HOOKSDIR/pre-applypatch || exit -1
+ chmod u+x $HOOKSDIR/post-commit || exit -1
+
+ else
+ echo "Cannot find or access pre or post commit scripts"
+ exit 0
+ fi
+
+else
+ echo "Cannot find or access .git/hooks directory"
+ exit 0
+fi
+
+exit 0
diff --git a/tools/hooks/post-commit b/tools/hooks/post-commit
new file mode 100755
index 00000000..6601ed74
--- /dev/null
+++ b/tools/hooks/post-commit
@@ -0,0 +1,29 @@
+#!/bin/bash
+# IBM_PROLOG_BEGIN_TAG
+# This is an automatically generated prolog.
+#
+# $Source: tools/hooks/post-commit $
+#
+# OpenPOWER HCODE Project
+#
+# COPYRIGHT 2015,2017
+# [+] International Business Machines Corp.
+#
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+# IBM_PROLOG_END_TAG
+
+if [ -z $DISABLEHOOKS ] && [ -z $MIRROR ]; then
+ $TOOLSDIR/verify-commit
+fi
diff --git a/tools/hooks/pre-commit b/tools/hooks/pre-commit
new file mode 100755
index 00000000..04ad9a81
--- /dev/null
+++ b/tools/hooks/pre-commit
@@ -0,0 +1,36 @@
+#!/bin/bash
+# IBM_PROLOG_BEGIN_TAG
+# This is an automatically generated prolog.
+#
+# $Source: tools/hooks/pre-commit $
+#
+# OpenPOWER HCODE Project
+#
+# COPYRIGHT 2015,2017
+# [+] International Business Machines Corp.
+#
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+# IBM_PROLOG_END_TAG
+
+if [ -z $EKBHOOKSDIR ]; then
+ echo Error: environment not setup properly...
+ echo "Run 'source env.bash' or './ekb workon' based on your current environment"
+ echo "For more info run './ekb --help'"
+ exit -1
+fi
+
+if [ -z $DISABLEHOOKS ] && [ -z $MIRROR ]; then
+ $EKBHOOKSDIR/tools/pre-commit-actions
+fi
diff --git a/tools/hooks/tools/pre-commit-actions b/tools/hooks/tools/pre-commit-actions
new file mode 100755
index 00000000..7c0e8b1b
--- /dev/null
+++ b/tools/hooks/tools/pre-commit-actions
@@ -0,0 +1,60 @@
+#!/usr/bin/perl
+# IBM_PROLOG_BEGIN_TAG
+# This is an automatically generated prolog.
+#
+# $Source: tools/hooks/tools/pre-commit-actions $
+#
+# OpenPOWER HCODE Project
+#
+# COPYRIGHT 2015,2017
+# [+] International Business Machines Corp.
+#
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+# IBM_PROLOG_END_TAG
+
+# This hook is used to add or update copyright prolog statements and run
+# the code beautifier astyle.
+use Getopt::Long;
+
+my $copyrightScript = "addCopyright";
+my @fileList = ();
+my $args = @ARGV;
+
+if ($args)
+{
+ @fileList = @ARGV;
+}
+else
+{
+ ## Make up a list of all staged files ( --cached --name-only )
+ ## Filter for only Added or Modified ( --diff-filter=AM )
+ chomp( @fileList = `git diff --cached --name-only --diff-filter=AM` );
+}
+
+
+if ( @fileList )
+{
+ print "run $copyrightScript update ...\n";
+ print " $_\n" foreach @fileList;
+ print "\n";
+
+ system "$ENV{'TOOLSDIR'}/$copyrightScript update @fileList";
+ die("$?") if ($? != 0);
+
+ system "git add @fileList" if ($args == 0);
+ exit 1 if ($? != 0);
+}
+
+exit 0;
diff --git a/tools/imageProcs/hw_image.S b/tools/imageProcs/hw_image.S
new file mode 100644
index 00000000..9c0502a3
--- /dev/null
+++ b/tools/imageProcs/hw_image.S
@@ -0,0 +1,134 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: tools/imageProcs/hw_image.S $ */
+/* */
+/* OpenPOWER HCODE Project */
+/* */
+/* COPYRIGHT 2016,2017 */
+/* [+] International Business Machines Corp. */
+/* */
+/* */
+/* Licensed under the Apache License, Version 2.0 (the "License"); */
+/* you may not use this file except in compliance with the License. */
+/* You may obtain a copy of the License at */
+/* */
+/* http://www.apache.org/licenses/LICENSE-2.0 */
+/* */
+/* Unless required by applicable law or agreed to in writing, software */
+/* distributed under the License is distributed on an "AS IS" BASIS, */
+/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */
+/* implied. See the License for the specific language governing */
+/* permissions and limitations under the License. */
+/* */
+/* IBM_PROLOG_END_TAG */
+
+// *INDENT-OFF*
+
+#include <p9_xip_image.h>
+
+ .macro P9XipHeader, magic, link_address, image_size
+
+ .section .header, "a", @progbits
+
+ ////////////////////////////////////////////////////////////////////
+ // First, reserve space for all the enteries in the header
+ // Identification - 8-byte aligned; 8 Entries; TOC-Indexed
+ ////////////////////////////////////////////////////////////////////
+
+__magic:
+ .quad (\magic)
+__L1_LoaderAddr:
+ .quad 0
+__L2_LoaderAddr:
+ .quad 0
+__kernelAddr:
+ .quad 0
+__link_address:
+ .quad (\link_address)
+__header_64_reserved:
+ .quad 0, 0, 0
+
+ .xip_toc magic, P9_XIP_UINT64, __magic
+ .xip_toc link_address, P9_XIP_UINT64, __link_address
+
+ ////////////////////////////////////////////////////////////////////
+ // Section Table - 8-byte aligned; 15 entries; Not TOC-Indexed
+ ////////////////////////////////////////////////////////////////////
+
+ .xip_section header
+ .xip_section
+ .xip_section
+ .xip_section toc, 4
+ .xip_section strings
+
+ .xip_section sgpe, 8
+ .xip_section core_restore, 8
+ .xip_section cme, 8
+ .xip_section pgpe, 8
+ .xip_section ioppe, 8
+ .xip_section fppe, 8
+ .xip_section rings, 8
+ .xip_section overlays, 8
+
+ .xip_section
+ .xip_section
+
+ ////////////////////////////////////////////////////////////////////
+ // Other Information - 4-byte aligned; 8 entries; TOC-Indexed
+ ////////////////////////////////////////////////////////////////////
+
+__image_size:
+ .long (\image_size)
+__build_date:
+ .long 0
+__build_time:
+ .long 0
+__build_tag:
+ .asciz "unknown " # 20 Characters
+
+ .xip_toc image_size, P9_XIP_UINT32, __image_size
+ .xip_toc build_date, P9_XIP_UINT32, __build_date
+ .xip_toc build_time, P9_XIP_UINT32, __build_time
+ .xip_toc build_tag, P9_XIP_STRING, __build_tag
+
+ ////////////////////////////////////////////////////////////////////
+ // Other Information - 1-byte aligned; 8 entries; TOC-Indexed
+ ////////////////////////////////////////////////////////////////////
+
+__header_version:
+ .byte P9_XIP_HEADER_VERSION
+__toc_normalized:
+ .byte 0
+__toc_sorted:
+ .byte 0
+__header_8_reserved:
+ .byte 0, 0, 0, 0, 0
+
+ .xip_toc header_version, P9_XIP_UINT8, __header_version
+ .xip_toc toc_normalized, P9_XIP_UINT8, __toc_normalized
+ .xip_toc toc_sorted, P9_XIP_UINT8, __toc_sorted
+
+ ////////////////////////////////////////////////////////////////////
+ // Strings; 64 characters allocated; TOC-Indexed
+ ////////////////////////////////////////////////////////////////////
+
+__build_user:
+ .asciz "unknown " # 16 Characters
+__build_host:
+ .asciz "unknown " # 40 characters
+__header_string_reserved:
+ .space 8, 0
+
+ .xip_toc build_user, P9_XIP_STRING, __build_user
+ .xip_toc build_host, P9_XIP_STRING, __build_host
+
+ .endm
+
+ .section .toc, "a", @progbits
+ .section .strings, "aS", @progbits
+
+ // FIXME: start address of HW Image in PNOR
+ P9XipHeader P9_XIP_MAGIC_HW, 0x80000000, _hw_image_size
+
+// *INDENT-ON*
diff --git a/tools/imageProcs/hw_image.cmd b/tools/imageProcs/hw_image.cmd
new file mode 100644
index 00000000..f88820e6
--- /dev/null
+++ b/tools/imageProcs/hw_image.cmd
@@ -0,0 +1,141 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: tools/imageProcs/hw_image.cmd $ */
+/* */
+/* OpenPOWER HCODE Project */
+/* */
+/* COPYRIGHT 2016,2017 */
+/* [+] International Business Machines Corp. */
+/* */
+/* */
+/* Licensed under the Apache License, Version 2.0 (the "License"); */
+/* you may not use this file except in compliance with the License. */
+/* You may obtain a copy of the License at */
+/* */
+/* http://www.apache.org/licenses/LICENSE-2.0 */
+/* */
+/* Unless required by applicable law or agreed to in writing, software */
+/* distributed under the License is distributed on an "AS IS" BASIS, */
+/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */
+/* implied. See the License for the specific language governing */
+/* permissions and limitations under the License. */
+/* */
+/* IBM_PROLOG_END_TAG */
+// Need to do this so that elf32-powerpc is not modified!
+#undef powerpc
+
+#define HW_IMAGE_ORIGIN 0x80000000
+OUTPUT_FORMAT(elf32-powerpc);
+
+SECTIONS
+{
+ . = HW_IMAGE_ORIGIN;
+ _hw_image_origin = . - 0;
+ ////////////////////////////////
+ // Header
+ ////////////////////////////////
+ . = ALIGN(1);
+ _header_origin = .;
+ _header_offset = . - _hw_image_origin;
+ .header . : { *(.header) }
+ _header_size = . - _header_origin;
+
+ ////////////////////////////////
+ // TOC
+ ////////////////////////////////
+ . = ALIGN(4);
+ _toc_origin = .;
+ _toc_offset = . - _hw_image_origin;
+ .toc . : { *(.toc) }
+ _toc_size = . - _toc_origin;
+
+ ////////////////////////////////
+ // STRING
+ ////////////////////////////////
+ . = ALIGN(1);
+ _strings_origin = .;
+ _strings_offset = . - _hw_image_origin;
+ .strings . : { *(.strings) }
+ _strings_size = . - _strings_origin;
+
+ ////////////////////////////////
+ // SGPE
+ ////////////////////////////////
+ . = ALIGN(8);
+ _sgpe_origin = .;
+ _sgpe_offset = . - _hw_image_origin;
+ .sgpe . : { *(.sgpe) }
+ _sgpe_size = . - _sgpe_origin;
+
+ ////////////////////////////////
+ // CORE RESTORE
+ ////////////////////////////////
+ . = ALIGN(8);
+ _core_restore_origin = .;
+ _core_restore_offset = . - _hw_image_origin;
+ .core_restore . : { *(.core_restore) }
+ _core_restore_size = . - _core_restore_origin;
+
+ ////////////////////////////////
+ // CME
+ ////////////////////////////////
+ . = ALIGN(8);
+ _cme_origin = .;
+ _cme_offset = . - _hw_image_origin;
+ .cme . : { *(.cme) }
+ _cme_size = . - _cme_origin;
+
+ ////////////////////////////////
+ // PGPE
+ ////////////////////////////////
+ . = ALIGN(8);
+ _pgpe_origin = .;
+ _pgpe_offset = . - _hw_image_origin;
+ .pgpe . : { *(.pgpe) }
+ _pgpe_size = . - _pgpe_origin;
+
+ ////////////////////////////////
+ // IOPPE
+ ////////////////////////////////
+ . = ALIGN(8);
+ _ioppe_origin = .;
+ _ioppe_offset = . - _hw_image_origin;
+ .ioppe . : { *(.ioppe) }
+ _ioppe_size = . - _ioppe_origin;
+
+ ////////////////////////////////
+ // FPPE
+ ////////////////////////////////
+ . = ALIGN(8);
+ _fppe_origin = .;
+ _fppe_offset = . - _hw_image_origin;
+ .fppe . : { *(.fppe) }
+ _fppe_size = . - _fppe_origin;
+
+ ////////////////////////////////
+ // RINGS
+ ////////////////////////////////
+ . = ALIGN(8);
+ _rings_origin = .;
+ _rings_offset = . - _hw_image_origin;
+ .rings . : { *(.rings) }
+ _rings_size = . - _rings_origin;
+
+ ////////////////////////////////
+ // OVERLAYS
+ ////////////////////////////////
+ . = ALIGN(8);
+ _overlays_origin = .;
+ _overlays_offset = . - _hw_image_origin;
+ .overlays . : { *(.overlays) }
+ _overlays_size = . - _overlays_origin;
+
+ ////////////////////////////////
+ // end of the image
+ ////////////////////////////////
+ . = ALIGN(8);
+ _hw_image_size = . - _hw_image_origin;
+ _hw_image_end = . - 0;
+
+}
diff --git a/tools/imageProcs/hw_image.mk b/tools/imageProcs/hw_image.mk
new file mode 100644
index 00000000..91776d4a
--- /dev/null
+++ b/tools/imageProcs/hw_image.mk
@@ -0,0 +1,99 @@
+# IBM_PROLOG_BEGIN_TAG
+# This is an automatically generated prolog.
+#
+# $Source: tools/imageProcs/hw_image.mk $
+#
+# OpenPOWER HCODE Project
+#
+# COPYRIGHT 2016,2017
+# [+] International Business Machines Corp.
+#
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+# IBM_PROLOG_END_TAG
+
+MAX_SBE_RING_SECTION_SIZE ?= 25600
+
+#depend on the completion of the base hw_image
+#binfiles to add to the hw_image
+#various image dependencies to serialize hw_image creation
+#$1 == type
+#$2 == chipId
+define BUILD_HW_IMAGE
+$(eval IMAGE=$2.$1_image)
+
+
+$(eval $(IMAGE)_PATH=$(IMAGEPATH)/hw_image)
+$(eval $(IMAGE)_LINK_SCRIPT=hw_image.cmd)
+$(eval $(IMAGE)_LAYOUT=$(IMAGEPATH)/hw_image/hw_image.o)
+$(eval hw_image_COMMONFLAGS += -I$(ROOTPATH)/chips/p9/xip/)
+
+$(eval $(IMAGE)_FILE_SGPE = $(IMAGEPATH)/sgpe_image/$2.sgpe_image.bin)
+$(eval $(IMAGE)_FILE_RESTORE = $(IMAGEPATH)/restore_image/$2.restore_image.bin)
+$(eval $(IMAGE)_FILE_CME = $(IMAGEPATH)/cme_image/$2.cme_image.bin)
+$(eval $(IMAGE)_FILE_PSTATE = $(IMAGEPATH)/pstate_gpe_image/$2.pstate_gpe_image.bin)
+$(eval $(IMAGE)_FILE_IOPPE = $(IMAGEPATH)/ioppe_image/$2.ioppe_image.bin)
+$(eval $(IMAGE)_FILE_RINGS = $(GENPATH)/rings/$1/$2.$1.rings.bin)
+$(eval $(IMAGE)_FILE_OVERLAYS= $(GENPATH)/rings/$1/$2.$1.overlays.bin)
+
+# dependencies for appending image sections in sequence
+$(eval $(IMAGE)_DEPS_SGPE =$(IMAGEPATH)/sgpe_image/.$2.sgpe_image.bin.built)
+$(eval $(IMAGE)_DEPS_SGPE+=$$($(IMAGE)_PATH)/.$(IMAGE).setbuild_host)
+
+
+$(eval $(IMAGE)_DEPS_RESTORE =$(IMAGEPATH)/restore_image/.$2.restore_image.bin.built)
+$(eval $(IMAGE)_DEPS_RESTORE+=$$($(IMAGE)_PATH)/.$(IMAGE).append.sgpe)
+
+$(eval $(IMAGE)_DEPS_CME =$(IMAGEPATH)/cme_image/.$2.cme_image.bin.built)
+$(eval $(IMAGE)_DEPS_CME+=$$($(IMAGE)_PATH)/.$(IMAGE).append.core_restore)
+
+$(eval $(IMAGE)_DEPS_PSTATE =$(IMAGEPATH)/pstate_gpe_image/.$2.pstate_gpe_image.bin.built)
+$(eval $(IMAGE)_DEPS_PSTATE+=$$($(IMAGE)_PATH)/.$(IMAGE).append.cme)
+
+$(eval $(IMAGE)_DEPS_IOPPE =$(IMAGEPATH)/ioppe_image/.$2.ioppe_image.bin.built)
+$(eval $(IMAGE)_DEPS_IOPPE+=$$($(IMAGE)_PATH)/.$(IMAGE).append.pgpe)
+
+$(eval $(IMAGE)_DEPS_RINGS =$$($(IMAGE)_FILE_RINGS))
+$(eval $(IMAGE)_DEPS_RINGS+=$$($(IMAGE)_PATH)/.$(IMAGE).append.ioppe)
+
+$(eval $(IMAGE)_DEPS_OVERLAYS = $$($(IMAGE)_FILE_OVERLAYS))
+$(eval $(IMAGE)_DEPS_OVERLAYS+= $$($(IMAGE)_PATH)/.$(IMAGE).append.rings)
+
+# image build using all files and serialised by dependencies
+$(eval $(call XIP_TOOL,append,.sgpe,$$($(IMAGE)_DEPS_SGPE),$$($(IMAGE)_FILE_SGPE)))
+$(eval $(call XIP_TOOL,append,.core_restore,$$($(IMAGE)_DEPS_RESTORE),$$($(IMAGE)_FILE_RESTORE)))
+$(eval $(call XIP_TOOL,append,.cme,$$($(IMAGE)_DEPS_CME),$$($(IMAGE)_FILE_CME)))
+$(eval $(call XIP_TOOL,append,.pgpe,$$($(IMAGE)_DEPS_PSTATE),$$($(IMAGE)_FILE_PSTATE)))
+$(eval $(call XIP_TOOL,append,.ioppe,$$($(IMAGE)_DEPS_IOPPE),$$($(IMAGE)_FILE_IOPPE)))
+
+
+$(eval $(call XIP_TOOL,append,.rings,$$($(IMAGE)_DEPS_RINGS),$$($(IMAGE)_FILE_RINGS)))
+
+$(eval $(call XIP_TOOL,append,.overlays,$$($(IMAGE)_DEPS_OVERLAYS), $$($(IMAGE)_FILE_OVERLAYS) 1))
+
+$(eval $(call XIP_TOOL,report,,$$($(IMAGE)_PATH)/.$(IMAGE).append.overlays))
+
+$(eval $(foreach ec, $(p9n_EC),\
+ $(eval $(call VERIFY_SBE_RING_SECTION, 0x$(ec), $(MAX_SBE_RING_SECTION_SIZE),$(ec)))))
+
+$(eval $(call BUILD_XIPIMAGE))
+endef
+
+define VERIFY_SBE_RING_SECTION
+ $(eval $(call XIP_TOOL,check-sbe-ring-section,,$($(IMAGE)_PATH)/.$(IMAGE).report, $1 $2,$3))
+endef
+
+$(eval $(call BUILD_HW_IMAGE,hw,p9n))
+
+
diff --git a/tools/imageProcs/ioppe_image.S b/tools/imageProcs/ioppe_image.S
new file mode 100644
index 00000000..4f3354be
--- /dev/null
+++ b/tools/imageProcs/ioppe_image.S
@@ -0,0 +1,136 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: tools/imageProcs/ioppe_image.S $ */
+/* */
+/* OpenPOWER HCODE Project */
+/* */
+/* COPYRIGHT 2016,2017 */
+/* [+] International Business Machines Corp. */
+/* */
+/* */
+/* Licensed under the Apache License, Version 2.0 (the "License"); */
+/* you may not use this file except in compliance with the License. */
+/* You may obtain a copy of the License at */
+/* */
+/* http://www.apache.org/licenses/LICENSE-2.0 */
+/* */
+/* Unless required by applicable law or agreed to in writing, software */
+/* distributed under the License is distributed on an "AS IS" BASIS, */
+/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */
+/* implied. See the License for the specific language governing */
+/* permissions and limitations under the License. */
+/* */
+/* IBM_PROLOG_END_TAG */
+
+// *INDENT-OFF*
+
+#include <p9_xip_image.h>
+
+ .macro P9XipHeader, magic, link_address, image_size
+
+ .section .header, "a", @progbits
+
+ ////////////////////////////////////////////////////////////////////
+ // First, reserve space for all the enteries in the header
+ // Identification - 8-byte aligned; 8 Entries; TOC-Indexed
+ ////////////////////////////////////////////////////////////////////
+
+__magic:
+ .quad (\magic)
+__L1_LoaderAddr:
+ .quad 0
+__L2_LoaderAddr:
+ .quad 0
+__kernelAddr:
+ .quad 0
+__link_address:
+ .quad (\link_address)
+__header_64_reserved:
+ .quad 0, 0, 0
+
+ .xip_toc magic, P9_XIP_UINT64, __magic
+ .xip_toc L1_LoaderAddr, P9_XIP_UINT64, __L1_LoaderAddr
+ .xip_toc L2_LoaderAddr, P9_XIP_UINT64, __L2_LoaderAddr
+ .xip_toc kernelAddr, P9_XIP_UINT64, __kernelAddr
+ .xip_toc link_address, P9_XIP_UINT64, __link_address
+
+ ////////////////////////////////////////////////////////////////////
+ // Section Table - 8-byte aligned; 15 entries; Not TOC-Indexed
+ ////////////////////////////////////////////////////////////////////
+
+ .xip_section header
+ .xip_section
+ .xip_section
+ .xip_section toc, 4
+ .xip_section strings
+
+ .xip_section iof
+ .xip_section ioo_abus
+ .xip_section ioo_nv
+ .xip_section
+ .xip_section
+
+ .xip_section
+ .xip_section
+ .xip_section
+ .xip_section
+ .xip_section
+
+ ////////////////////////////////////////////////////////////////////
+ // Other Information - 4-byte aligned; 8 entries; TOC-Indexed
+ ////////////////////////////////////////////////////////////////////
+
+__image_size:
+ .long (\image_size)
+__build_date:
+ .long 0
+__build_time:
+ .long 0
+__build_tag:
+ .asciz "unknown " # 20 Characters
+
+ .xip_toc image_size, P9_XIP_UINT32, __image_size
+ .xip_toc build_date, P9_XIP_UINT32, __build_date
+ .xip_toc build_time, P9_XIP_UINT32, __build_time
+ .xip_toc build_tag, P9_XIP_STRING, __build_tag
+
+ ////////////////////////////////////////////////////////////////////
+ // Other Information - 1-byte aligned; 8 entries; TOC-Indexed
+ ////////////////////////////////////////////////////////////////////
+
+__header_version:
+ .byte P9_XIP_HEADER_VERSION
+__toc_normalized:
+ .byte 0
+__toc_sorted:
+ .byte 0
+__header_8_reserved:
+ .byte 0, 0, 0, 0, 0
+
+ .xip_toc header_version, P9_XIP_UINT8, __header_version
+ .xip_toc toc_normalized, P9_XIP_UINT8, __toc_normalized
+ .xip_toc toc_sorted, P9_XIP_UINT8, __toc_sorted
+
+ ////////////////////////////////////////////////////////////////////
+ // Strings; 64 characters allocated; TOC-Indexed
+ ////////////////////////////////////////////////////////////////////
+
+__build_user:
+ .asciz "unknown " # 16 Characters
+__build_host:
+ .asciz "unknown " # 24 characters
+__header_string_reserved:
+ .space 8, 0
+
+ .xip_toc build_user, P9_XIP_STRING, __build_user
+ .xip_toc build_host, P9_XIP_STRING, __build_host
+
+ .endm
+
+ .section .toc, "a", @progbits
+ .section .strings, "aS", @progbits
+
+ P9XipHeader P9_XIP_MAGIC_IOPPE, 0x80000000, _ioppe_image_size
+
+// *INDENT-ON*
diff --git a/tools/imageProcs/ioppe_image.cmd b/tools/imageProcs/ioppe_image.cmd
new file mode 100644
index 00000000..40955e12
--- /dev/null
+++ b/tools/imageProcs/ioppe_image.cmd
@@ -0,0 +1,97 @@
+/* IBM_PROLOG_BEGIN_TAG */
+/* This is an automatically generated prolog. */
+/* */
+/* $Source: tools/imageProcs/ioppe_image.cmd $ */
+/* */
+/* OpenPOWER HCODE Project */
+/* */
+/* COPYRIGHT 2016,2017 */
+/* [+] International Business Machines Corp. */
+/* */
+/* */
+/* Licensed under the Apache License, Version 2.0 (the "License"); */
+/* you may not use this file except in compliance with the License. */
+/* You may obtain a copy of the License at */
+/* */
+/* http://www.apache.org/licenses/LICENSE-2.0 */
+/* */
+/* Unless required by applicable law or agreed to in writing, software */
+/* distributed under the License is distributed on an "AS IS" BASIS, */
+/* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or */
+/* implied. See the License for the specific language governing */
+/* permissions and limitations under the License. */
+/* */
+/* IBM_PROLOG_END_TAG */
+
+// Need to do this so that elf32-powerpc is not modified!
+#undef powerpc
+
+#define IOPPE_IMAGE_ORIGIN 0x80000000
+OUTPUT_FORMAT(elf32-powerpc);
+
+SECTIONS
+{
+ . = IOPPE_IMAGE_ORIGIN;
+ _ioppe_image_origin = . - 0;
+ ////////////////////////////////
+ // Header
+ ////////////////////////////////
+ . = ALIGN(1);
+ _header_origin = .;
+ _header_offset = . - _ioppe_image_origin;
+ .header . : { *(.header) }
+ _header_size = . - _header_origin;
+
+ ////////////////////////////////
+ // TOC
+ ////////////////////////////////
+ . = ALIGN(4);
+ _toc_origin = .;
+ _toc_offset = . - _ioppe_image_origin;
+ .toc . : { *(.toc) }
+ _toc_size = . - _toc_origin;
+
+ ////////////////////////////////
+ // STRING
+ ////////////////////////////////
+ . = ALIGN(1);
+ _strings_origin = .;
+ _strings_offset = . - _ioppe_image_origin;
+ .strings . : { *(.strings) }
+ _strings_size = . - _strings_origin;
+
+ ////////////////////////////////
+ // IOF
+ ////////////////////////////////
+ . = ALIGN(8);
+ _iof_origin = .;
+ _iof_offset = . - _ioppe_image_origin;
+ .iof . : { *(.iof) }
+ _iof_size = . - _iof_origin;
+
+ ////////////////////////////////
+ // IOO ABUS
+ ////////////////////////////////
+ . = ALIGN(8);
+ _ioo_abus_origin = .;
+ _ioo_abus_offset = . - _ioppe_image_origin;
+ .ioo_abus . : { *(.ioo_abus) }
+ _ioo_abus_size = . - _ioo_abus_origin;
+
+ ////////////////////////////////
+ // IOO NV
+ ////////////////////////////////
+ . = ALIGN(8);
+ _ioo_nv_origin = .;
+ _ioo_nv_offset = . - _ioppe_image_origin;
+ .ioo_nv . : { *(.ioo_nv) }
+ _ioo_nv_size = . - _ioo_nv_origin;
+
+ ////////////////////////////////
+ // end of the image
+ ////////////////////////////////
+ . = ALIGN(8);
+ _ioppe_image_size = . - _ioppe_image_origin;
+ _ioppe_image_end = . - 0;
+
+}
diff --git a/tools/imageProcs/ioppe_image.mk b/tools/imageProcs/ioppe_image.mk
new file mode 100644
index 00000000..e7818bd7
--- /dev/null
+++ b/tools/imageProcs/ioppe_image.mk
@@ -0,0 +1,78 @@
+# IBM_PROLOG_BEGIN_TAG
+# This is an automatically generated prolog.
+#
+# $Source: tools/imageProcs/ioppe_image.mk $
+#
+# OpenPOWER HCODE Project
+#
+# COPYRIGHT 2016,2017
+# [+] International Business Machines Corp.
+#
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+# IBM_PROLOG_END_TAG
+# $1 == chipId
+define BUILD_IOPPE_IMAGE
+$(eval IMAGE=$1.ioppe_image)
+
+$(eval $(IMAGE)_PATH=$(IMAGEPATH)/ioppe_image)
+$(eval $(IMAGE)_LINK_SCRIPT=ioppe_image.cmd)
+$(eval $(IMAGE)_LAYOUT=$(IMAGEPATH)/ioppe_image/ioppe_image.o)
+$(eval ioppe_image_COMMONFLAGS += -I$(ROOTPATH)/chips/p9/xip/)
+
+# files to be appended to image
+$(eval $(IMAGE)_FILE_IOF=$(IMAGEPATH)/iox/iox.bin)
+$(eval $(IMAGE)_FILE_IOO_ABUS=$(IMAGEPATH)/ioa/ioa.bin)
+
+$(eval $(IMAGE)_FILE_IOO_NV=$(CONFIG_IONV_FILE_LOCATION))
+
+# dependencies for appending image sections in sequence:
+# - file to be appended
+# - all dependencies of previously appended sections or on raw image
+# - append operation as to other section that has to be finished first
+$(eval $(IMAGE)_DEPS_IOF =$$($(IMAGE)_FILE_IOF))
+$(eval $(IMAGE)_DEPS_IOF+=$$($(IMAGE)_PATH)/.$(IMAGE).setbuild_host)
+
+$(eval $(IMAGE)_DEPS_IOO_ABUS =$$($(IMAGE)_FILE_IOO_ABUS))
+$(eval $(IMAGE)_DEPS_IOO_ABUS+=$$($(IMAGE)_DEPS_IOF))
+$(eval $(IMAGE)_DEPS_IOO_ABUS+=$$($(IMAGE)_PATH)/.$(IMAGE).append.iof)
+
+$(eval $(IMAGE)_DEPS_IOO_NV =$$($(IMAGE)_FILE_IOO_NV))
+$(eval $(IMAGE)_DEPS_IOO_NV+=$$($(IMAGE)_DEPS_IOO_ABUS))
+$(eval $(IMAGE)_DEPS_IOO_NV+=$$($(IMAGE)_PATH)/.$(IMAGE).append.ioo_abus)
+
+$(eval $(IMAGE)_DEPS_REPORT =$$($(IMAGE)_DEPS_IOO_NV))
+
+#fix up the dependancies if we include the ionv.bin file
+$(if $(findstring y,$(CONFIG_INCLUDE_IONV)),\
+$(eval $(IMAGE)_DEPS_REPORT+=$$($(IMAGE)_PATH)/.$(IMAGE).append.ioo_nv),\
+$(eval $(IMAGE)_DEPS_REPORT+=$$($(IMAGE)_PATH)/.$(IMAGE).append.ioo_abus))
+
+# image build using all files and serialised by dependencies
+$(eval $(call XIP_TOOL,append,.iof,$$($(IMAGE)_DEPS_IOF),$$($(IMAGE)_FILE_IOF)))
+$(eval $(call XIP_TOOL,append,.ioo_abus,$$($(IMAGE)_DEPS_IOO_ABUS),$$($(IMAGE)_FILE_IOO_ABUS)))
+
+$(if $(findstring y,$(CONFIG_INCLUDE_IONV)),\
+$(eval $(call XIP_TOOL,append,.ioo_nv,$$($(IMAGE)_DEPS_IOO_NV),$$($(IMAGE)_FILE_IOO_NV))))
+
+# create image report for image with all files appended
+$(eval $(call XIP_TOOL,report,,$$($(IMAGE)_DEPS_REPORT)))
+
+$(eval $(call BUILD_XIPIMAGE))
+endef
+
+$(foreach chip,$(CHIPS),\
+ $(foreach chipId, $($(chip)_CHIPID),\
+ $(eval $(call BUILD_IOPPE_IMAGE,$(chipId)))))
+
diff --git a/tools/verify-commit b/tools/verify-commit
new file mode 100755
index 00000000..4a167981
--- /dev/null
+++ b/tools/verify-commit
@@ -0,0 +1,390 @@
+#!/usr/bin/perl
+# IBM_PROLOG_BEGIN_TAG
+# This is an automatically generated prolog.
+#
+# $Source: tools/verify-commit $
+#
+# OpenPOWER HCODE Project
+#
+# COPYRIGHT 2015,2017
+# [+] International Business Machines Corp.
+#
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+# implied. See the License for the specific language governing
+# permissions and limitations under the License.
+#
+# IBM_PROLOG_END_TAG
+
+use strict;
+use Getopt::Long qw(:config pass_through);
+
+my $issueFound = 0;
+my $errorFound = 0;
+my $warningCount = 0;
+my $showAll = 0;
+
+use constant MAX_WARNINGS => 5;
+use constant MAX_CODE_LINE_LENGTH => 120;
+
+my $projectName = $ENV{'PROJECT_NAME'};
+
+GetOptions("show-all" => \$showAll);
+
+verifyPatchSet(); # Verify the patch contents.
+verifyCommitMsg(); # Verify the commit message.
+
+# Finish out the divider.
+if ($issueFound)
+{
+ print "------------------------------------------------------------\n";
+ my $hiddenWarnings = $warningCount - MAX_WARNINGS;
+ if ($hiddenWarnings > 0 && !$showAll)
+ {
+ print " $hiddenWarnings Warning(s) Hidden\n";
+ print " Run 'verify-commit --show-all'\n";
+ print "------------------------------------------------------------\n";
+ }
+}
+
+# Return a bad RC if we found an error. Let warnings pass.
+exit ($errorFound ? -1 : 0);
+
+
+########################### Subroutines ################################
+
+# @sub verifyPatchSet
+#
+# Extract the contents (lines changed) from the patch set and verify.
+#
+sub verifyPatchSet
+{
+ # git-diff options:
+ # * Diff against the previous commit (HEAD~1)
+ # * Filter only added and modified files (AM).
+ # * Show only the lines changed, with no context (U0).
+ # Grep only the lines marked with "+" (instead of "-") to find just the
+ # actions done by this patchset and not the content removed.
+ open PATCH_CONTENTS, "git diff HEAD~1 --diff-filter=AM -U0 | ".
+ "grep -e \"^+\" -e \"^@@.*+[0-9]\\+\" |";
+
+ my %fileContents = ();
+
+ my $lastFile = "";
+ my $fileLines = ();
+ my $lineCount = 0;
+ while (my $line = <PATCH_CONTENTS>)
+ {
+ chomp $line;
+
+ # Line starting with "+++ b/path/to/file" indicate a new file.
+ if ($line =~ m/^\+\+\+ b\/(.*)/)
+ {
+ # Save previous file into the map.
+ if ($lastFile ne "")
+ {
+ $fileContents{$lastFile} = $fileLines;
+ $fileLines = ();
+ $lineCount = 0;
+ }
+ $lastFile = $1;
+ }
+ # Lines starting with "@@" indicates a seek in the file, so update
+ # line numbers.
+ elsif ($line =~ m/^@@.*\+([0-9]+)/)
+ {
+ $lineCount = $1 - 1;
+ }
+ else
+ {
+ $line =~ s/^\+//; # filter off the leading + symbol.
+ $lineCount++;
+ push @{$fileLines}, [$line, $lineCount];
+ }
+ }
+ if ($lastFile ne "") # Save last file into the map.
+ {
+ $fileContents{$lastFile} = $fileLines;
+ $fileLines = ();
+ }
+
+ # Verify each line of each file.
+ foreach my $file (sort keys %fileContents)
+ {
+ foreach my $line (@{$fileContents{$file}})
+ {
+ verifyFileLine($file, @{$line}[0], @{$line}[1]);
+ }
+ }
+}
+
+# @sub verifyFileLine
+#
+# Checks a particular line of the file for the following issues:
+# * Warning: Lines longer than MAX_CODE_LINE_LENGTH characters, except in trace statement.
+# * Warning: Trailing whitespace.
+# * Warning: Tab characters outside of makefiles.
+# * Warning: TODO or FIXME type tag without a corresponding RTC number.
+# * Warning: NOMERGE tag found.
+#
+sub verifyFileLine
+{
+ my ($file,$line,$count) = @_;
+
+ # Check line length.
+ if (length($line) > MAX_CODE_LINE_LENGTH)
+ {
+ # Allow trace statements and .C/.H files to slide.
+ # Astyle should format .C/.H files, jenkins job will confirm astyle was
+ # run. Done to avoid scenario where astyle cannot split at MAX_CODE_LINE_LENGTH chars.
+ if (($line =~ m/TRAC[DSFU]/) ||
+ ($line =~m/TS_FAIL/) ||
+ ($line =~m/printk/) ||
+ ($line =~m/displayf/) ||
+ ($line =~ m/FAPI_(INF|IMP|ERR|DBG|SCAN)/) ||
+ ($line =~ m/print/) ||
+ ($file =~ m/\.[cChH]/))
+ {
+ }
+ else
+ {
+ warning($file,$line,$count,
+ (sprintf "Length is more than %d characters (%d).",
+ MAX_CODE_LINE_LENGTH, length($line))
+ );
+ }
+ }
+
+ # Check trailing whitespace.
+ if ($line =~ m/\s$/)
+ {
+ warning($file,$line,$count,
+ "Trailing whitespace found.");
+ }
+
+ # Check tabs.
+ if ($line =~ m/\t/)
+ {
+ # Makefiles are ok (require tabs).
+ if (not (($file =~ m/makefile/) || ($file =~ m/Makefile/) ||
+ ($file =~ m/\.mk/)))
+ {
+ warning($file,$line,$count,
+ "Tab character found.");
+ }
+ }
+
+ # Check "TODO" or "FIXME" type comments.
+ if (($line =~ m/TODO/i) || ($line =~ m/FIXME/i))
+ {
+ if ( (not ($line =~ m/RTC[\s:]\s*[0-9]+/)) &&
+ (not ($line =~ m/CQ[\s:]\s*[A-Z][A-Z][0-9]+/)))
+ {
+ warning($file,$line,$count,
+ "TODO/FIXME tag without corresponding RTC or CQ number.");
+ }
+ }
+
+ # Check "NOMERGE" type comment.
+ if ($line =~ m/NOMERGE/i)
+ {
+ warning($file,$line,$count,
+ "NOMERGE tag found.");
+ }
+
+}
+
+# @sub verifyCommitMsg
+#
+# Looks at the commit message to verify the following items:
+# * Topic is exactly 1 line long.
+# * Lines are less than 80 characters.
+# * No trailing whitespace.
+# * Tags, such as 'RTC:', are only found in the footer.
+# * Untagged lines are not found in the footer.
+# * RTC tag is formatted correctly.
+# * Warning for lacking RTC tag.
+#
+sub verifyCommitMsg
+{
+ open COMMIT_CONTENTS, "git log -n1 --pretty=format:%B |";
+ my $lineCount = 0;
+ my $rtcTag = "";
+ my $cqTag = "";
+ my $changeId = "";
+ my $taggedLine = "";
+ my $untaggedLine = "";
+
+ while (my $line = <COMMIT_CONTENTS>)
+ {
+ $lineCount++;
+ chomp $line;
+
+ # Check line length over 80 characters.
+ if (length($line) > 80)
+ {
+ error("Commit Message",$line,$lineCount,
+ (sprintf "Length is more than 80 characters (%d).",
+ length($line))
+ );
+ }
+
+ # Check trailing whitespace.
+ if ($line =~ m/[^\s]+\s$/)
+ {
+ error("Commit Message",$line,$lineCount,
+ "Trailing whitespace found.");
+ }
+
+ # Blank line indicates a new "section".
+ if ($line =~ m/^$/)
+ {
+ # Check for tags outside of the footer.
+ # (new section implies previous section was not a footer)
+ if ("" ne $taggedLine)
+ {
+ error("Commit Message",$taggedLine,$lineCount,
+ "Tagged line found outside commit-msg footer.");
+ }
+
+ $rtcTag = "";
+ $cqTag = "";
+ $untaggedLine = "";
+ $taggedLine = "";
+ }
+ else
+ {
+ # Check for multi-line topic.
+ if ($lineCount == 2)
+ {
+ error("Commit Message",$line,$lineCount,
+ "Topic must be only one line long.");
+ }
+ }
+
+ # Verify format of RTC message.
+ if ($line =~ m/^\s*RTC:\s*[0-9]+(.*)/)
+ {
+ if ("" ne $rtcTag)
+ {
+ error("Commit Message",$line,$lineCount,
+ "Duplicate RTC tag found.");
+ }
+
+ $rtcTag = $line;
+ if ("" ne $1)
+ {
+ error("Commit Message",$line,$lineCount,
+ (sprintf "RTC tag format incorrect (%s).", $1));
+ }
+ }
+
+ if ($line =~ m/^\s*CQ:\s*[A-Z][A-Z][0-9]+(.*)/)
+ {
+ if ("" ne $cqTag)
+ {
+ error("Commit Message",$line,$lineCount,
+ "Duplicate CQ tag found.");
+ }
+
+ $cqTag = $line;
+ if ("" ne $1)
+ {
+ error("Commit Message",$line,$lineCount,
+ (sprintf "CQ tag format incorrect (%s).", $1));
+ }
+ }
+
+ if ($line =~ m/^\s*Change-Id:\s*[I][\w]+(.*)/)
+ {
+ if ("" ne $changeId)
+ {
+ error("Commit Message",$line,$lineCount,
+ "Mulitple Change-Id's found.");
+ }
+
+ $changeId = $line;
+ if ("" ne $1)
+ {
+ error("Commit Message",$line,$lineCount,
+ (sprintf "Change-Id format incorrect (%s).", $1));
+ }
+ }
+
+ # Identify if this is a tagged line or a non-tagged line and store
+ # away.
+ if ($line =~ m/^\s*[A-Za-z0-9\-_]+:[^:]/)
+ {
+ # We allow lines that look like tags in the topic like...
+ # "FOO: Adding support for BAR."
+ # Unless the Change-Id is in the topic
+ if ($lineCount > 1 || ($line =~ m/Change-Id/))
+ {
+ $taggedLine = $line;
+ }
+ }
+ else
+ {
+ $untaggedLine = $line;
+ }
+ }
+
+ # Warn for missing RTC tag.
+ if (("" eq $rtcTag) && ("" eq $cqTag))
+ {
+ warning("Commit Message","<end-of-file>",$lineCount,
+ "Neither RTC nor CQ tag found.");
+ }
+
+ # Error for missing Change-Id.
+ if ("" eq $changeId)
+ {
+ error("Commit Message","<end-of-file>",$lineCount,
+ "Change-Id not found.");
+ }
+
+ # Error for a mix of tag / untagged in the last section (ie. untagged
+ # lines in the footer).
+ if (("" ne $untaggedLine) && ("" ne $taggedLine))
+ {
+ error("Commit Message",$untaggedLine,$lineCount,
+ "Untagged line found in footer.");
+ }
+}
+
+sub warning
+{
+ my ($file, $line, $count, $statement) = @_;
+
+ if ($warningCount < MAX_WARNINGS || $showAll)
+ {
+ print "------------------------------------------------------------\n";
+ print "WARNING: $statement\n";
+ print " $file:$count\n";
+ print " $line\n";
+ }
+
+ $issueFound = 1;
+ $warningCount++;
+}
+
+sub error
+{
+ my ($file, $line, $count, $statement) = @_;
+ print "------------------------------------------------------------\n";
+ print "ERROR: $statement\n";
+ print " $file:$count\n";
+ print " $line\n";
+
+ $issueFound = 1;
+ $errorFound = 1;
+}
+
OpenPOWER on IntegriCloud