callouts: generate processor callouts based on FSI

This script generates processor callouts based on the FSI path. It
outputs this in YAML format:

FSI link off master processor: FRU path

Change-Id: Ib12e0574c733e3f8fe4b9f35a88183722e7b8692
Signed-off-by: Deepak Kodihalli <dkodihal@in.ibm.com>
diff --git a/gen_proc_fsi_callouts.pl b/gen_proc_fsi_callouts.pl
new file mode 100755
index 0000000..41c7ab4
--- /dev/null
+++ b/gen_proc_fsi_callouts.pl
@@ -0,0 +1,81 @@
+#! /usr/bin/perl
+use strict;
+use warnings;
+
+
+use mrw::Targets;
+use mrw::Inventory;
+use mrw::Util;
+use Getopt::Long;
+
+
+my $mrwFile = "";
+my $outFile = "";
+
+
+GetOptions(
+"m=s" => \$mrwFile,
+"o=s" => \$outFile,
+)
+or printUsage();
+
+
+if (($mrwFile eq "") or ($outFile eq ""))
+{
+    printUsage();
+}
+
+
+# Load system MRW
+my $targets = Targets->new;
+$targets->loadXML($mrwFile);
+
+
+# Load inventory
+my @inventory = Inventory::getInventory($targets);
+
+
+open(my $fh, '>', $outFile) or die "Could not open file '$outFile' $!";
+
+
+# MRW/Targets.pm doesn't seem to tell me which the master proc(s) are.
+# Find those out.
+my @procs;
+for my $target (keys %{$targets->getAllTargets()})
+{
+    if ($targets->getType($target) eq "PROC")
+    {
+        push @procs, $target;
+    }
+}
+
+for my $proc (@procs)
+{
+    my $connections = $targets->findConnections($proc, "FSIM");
+    if ("" ne $connections)
+    {
+        # This is a master processor
+        my $link = "0x00"; # revisit on a multinode system
+        my $fru = Util::getEnclosingFru($targets, $proc);
+        print $fh $link.": ".Util::getObmcName(\@inventory, $fru);
+        for my $fsi (@{$connections->{CONN}})
+        {
+            my $master = $fsi->{SOURCE};
+            my $slave = $fsi->{DEST};
+            my $link = $targets->getAttribute($master, "FSI_LINK");
+            my $fru = Util::getEnclosingFru($targets, $slave);
+            print $fh "\n".$link.": ".Util::getObmcName(\@inventory, $fru);
+        }
+    }
+}
+
+
+close $fh;
+
+
+sub printUsage
+{
+    print "
+    $0 -m [MRW file] -o [Output filename]\n";
+    exit(1);
+}