Sun-Fire-X4540-hc-topology.xmlgen revision 133e64dc1e1364a61b2182e682067321a0b4a128
#!/usr/local/bin/perl
#
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
# Common Development and Distribution License (the "License").
# You may not use this file except in compliance with the License.
#
# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
# or http://www.opensolaris.org/os/licensing.
# See the License for the specific language governing permissions
# and limitations under the License.
#
# When distributing Covered Code, include this CDDL HEADER in each
# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
# If applicable, add the following below this CDDL HEADER, with the
# fields enclosed by brackets "[]" replaced with your own identifying
# information: Portions Copyright [yyyy] [name of copyright owner]
#
# CDDL HEADER END
#
#
# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#ident "%Z%%M% %I% %E% SMI"
#
use Getopt::Std;
my $sys_supported = {"name" => "Sun-Fire-X4540",
"prop_name" => "sfx4500",
"num_bays" => "48"};
$IFILE = "filehandle";
$OFILE = "filehandle";
sub Usage()
{
print STDERR "Usage: xml-gen -p <platform> -i <input_xml_file> -o <output_xml_file>\n";
}
sub calc_sfx_prop
{
my $name = shift;
my $hdd = shift;
my $sid = shift;
printf OFILE "\n";
printf OFILE " <propgroup name='%s-properties'", $name;
printf OFILE " version='1' name-stability='Private'";
printf OFILE " data-stability='Private' >\n";
printf OFILE " <propval name='fru-update-action'";
printf OFILE " type='string' value='ipmi:fru gid=3 hdd=%d' />\n", $hdd;
printf OFILE " <propval name='indicator-name-0'";
printf OFILE " type='string' value='+PRSNT' />\n";
printf OFILE " <propval name='indicator-action-0'";
printf OFILE " type='string' value='ipmi:state sid=%d amask=0x0001' />\n",
$sid;
printf OFILE " <propval name='indicator-name-1'";
printf OFILE " type='string' value='-PRSNT' />\n";
printf OFILE " <propval name='indicator-action-1'";
printf OFILE " type='string' value='ipmi:state sid=%d dmask=0x0001' />\n",
$sid;
printf OFILE " <propval name='indicator-name-2'";
printf OFILE " type='string' value='+OK2RM' />\n";
printf OFILE " <propval name='indicator-action-2'";
printf OFILE " type='string' value='ipmi:state sid=%d amask=0x0008' />\n",
$sid;
printf OFILE " <propval name='indicator-name-3'";
printf OFILE " type='string' value='-OK2RM' />\n";
printf OFILE " <propval name='indicator-action-3'";
printf OFILE " type='string' value='ipmi:state sid=%d dmask=0x0008' />\n",
$sid;
printf OFILE " <propval name='indicator-name-4'";
printf OFILE " type='string' value='+FAULT' />\n";
printf OFILE " <propval name='indicator-action-4'";
printf OFILE " type='string' value='ipmi:state sid=%d amask=0x0002' />\n",
$sid;
printf OFILE " <propval name='indicator-name-5'";
printf OFILE " type='string' value='-FAULT' />\n";
printf OFILE " <propval name='indicator-action-5'";
printf OFILE " type='string' value='ipmi:state sid=%d dmask=0x0002' />\n",
$sid;
printf OFILE " <propval name='indicator-rule-";
printf OFILE "states-0' type='string' value='absent>present' />\n";
printf OFILE " <propval name='indicator-rule-";
printf OFILE "actions-0' type='string' value='+PRSNT&amp;+OK2RM' />\n";
printf OFILE " <propval name='indicator-rule-";
printf OFILE "states-1' type='string' value='present>configured' />\n";
printf OFILE " <propval name='indicator-rule-";
printf OFILE "actions-1' type='string' value='+PRSNT&amp;-OK2RM' />\n";
printf OFILE " <propval name='indicator-rule-";
printf OFILE "states-2' type='string' value='configured>unconfigured' />\n";
printf OFILE " <propval name='indicator-rule-";
printf OFILE "actions-2' type='string' value='+OK2RM' />\n";
printf OFILE " <propval name='indicator-rule-";
printf OFILE "states-3' type='string' value='unconfigured>configured' />\n";
printf OFILE " <propval name='indicator-rule-";
printf OFILE "actions-3' type='string' value='-OK2RM' />\n";
printf OFILE " <propval name='indicator-rule-";
printf OFILE "states-4' type='string' value='unconfigured>absent' />\n";
printf OFILE " <propval name='indicator-rule-";
printf OFILE "actions-4' type='string' value='-OK2RM&amp;-PRSNT' />\n";
printf OFILE " <propval name='indicator-rule-";
printf OFILE "states-5' type='string' value='configured>absent' />\n";
printf OFILE " <propval name='indicator-rule-";
printf OFILE "actions-5' type='string' value='-OK2RM&amp;-PRSNT' />\n";
printf OFILE " <propval name='indicator-rule-";
printf OFILE "states-6' type='string' value='present>absent' />\n";
printf OFILE " <propval name='indicator-rule-";
printf OFILE "actions-6' type='string' value='-OK2RM&amp;-PRSNT' />\n";
printf OFILE " <propval name='indicator-rule-";
printf OFILE "states-7' type='string' value='absent>configured' />\n";
printf OFILE " <propval name='indicator-rule-";
printf OFILE "actions-7' type='string' value='-OK2RM&amp;+PRSNT' />\n";
printf OFILE " </propgroup>\n";
printf OFILE "\n";
}
sub calc_nodes
{
my @pci0=(0, 0, 0, 0x3c, 0x3c, 0x3c);
my @pci1=(0x377, 0x375, 0x376, 0x377, 0x375, 0x376);
my @pci2=(0xa, 0xb, 0xf, 0xa, 0xb, 0xf);
for ($bay = 0; $bay < $sys_supported->{"num_bays"}; $bay++) {
$controller = $bay / 8;
$target = $bay % 8 ;
$sid = 90 + $bay;
$physdev = "/pci\@" . sprintf("%x", $pci0[$controller]) .
",0/pci10de," . sprintf("%x", $pci1[$controller]) .
"\@" . sprintf("%x", $pci2[$controller]) .
"/pci1000,1000\@0";
printf OFILE "\n";
printf OFILE " <node instance='%d'>\n", $bay;
printf OFILE "\n";
printf OFILE " <propgroup name='protocol'";
printf OFILE " version='1' name-stability='Private'";
printf OFILE " data-stability='Private' >\n";
printf OFILE " <propval name='ASRU' ";
printf OFILE "type='fmri' value=";
printf OFILE "'dev:///" . $physdev . "' />\n";
printf OFILE " <propval name='label'";
printf OFILE " type='string' value='bay%d' />\n", $bay;
printf OFILE " </propgroup>\n";
printf OFILE " <propgroup name='io'";
printf OFILE " version='1' name-stability='Private'";
printf OFILE " data-stability='Private' >\n";
printf OFILE " <propval name='ap-path'";
printf OFILE " type='string'";
printf OFILE " value='/devices" . $physdev;
printf OFILE ":scsi::dsk/c%dt%dd0", $controller + 1, $target;
printf OFILE "' />\n";
printf OFILE " </propgroup>\n";
calc_sfx_prop($sys_supported->{"prop_name"}, $bay, $sid);
printf OFILE " <propgroup name='binding'";
printf OFILE " version='1' name-stability='Private'";
printf OFILE " data-stability='Private' >\n";
printf OFILE " <propval name='occupant-path'";
printf OFILE " type='string'";
printf OFILE " value='" . $physdev . "/sd\@%d,0", $target;
printf OFILE "' />\n";
printf OFILE " </propgroup>\n";
printf OFILE "\n";
printf OFILE " </node>\n";
printf OFILE "\n";
}
}
$ok = getopts("p:i:o:h", \%options);
if ($options{'h'}) {
Usage();
exit (1);
}
$platform = $options{'p'};
$input_file = $options{'i'};
$output_file = $options{'o'};
if (!$platform || !$input_file || !$output_file) {
Usage();
exit (1);
}
open(IFILE, "< $input_file") || die("$input_file cannot be opened.");
open(OFILE, "> $output_file") || die("$output_file cannot be opened.");
while ($line = <IFILE>) {
chomp($line);
if ($line ne "</topology>") {
print OFILE "$line\n";
} else {
last;
}
}
print OFILE " <!--xml-gen internal storage-->\n";
printf OFILE " <range name='bay' min='0' max='%d'>\n", $sys_supported->{"num_bays"};
calc_nodes(0);
printf OFILE " <dependents grouping='children'>\n";
printf OFILE " <range name='disk' min='0'";
printf OFILE " max='1'>\n";
printf OFILE " <enum-method name='disk'";
printf OFILE " version='1' />\n";
printf OFILE " </range>\n";
printf OFILE " </dependents>\n";
printf OFILE "\n";
printf OFILE " </range>\n";
print OFILE "$line\n";
while ($line = <IFILE>) {
print OFILE $line;
}
close OFILE;
close IFILE;