2N/A#!/usr/bin/perl -w
2N/A#
2N/A# CDDL HEADER START
2N/A#
2N/A# The contents of this file are subject to the terms of the
2N/A# Common Development and Distribution License (the "License").
2N/A# You may not use this file except in compliance with the License.
2N/A#
2N/A# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A# or http://www.opensolaris.org/os/licensing.
2N/A# See the License for the specific language governing permissions
2N/A# and limitations under the License.
2N/A#
2N/A# When distributing Covered Code, include this CDDL HEADER in each
2N/A# file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A# If applicable, add the following below this CDDL HEADER, with the
2N/A# fields enclosed by brackets "[]" replaced with your own identifying
2N/A# information: Portions Copyright [yyyy] [name of copyright owner]
2N/A#
2N/A# CDDL HEADER END
2N/A#
2N/A#
2N/A# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
2N/A# Use is subject to license terms.
2N/A#
2N/A
2N/A$num_bays = 48;
2N/A$bay_label = "HD_ID_";
2N/A
2N/Asub calc_sfx_prop
2N/A{
2N/A my $name = shift;
2N/A my $bay = shift;
2N/A my $sid = shift;
2N/A my @names = (
2N/A "+PRSNT", "-PRSNT",
2N/A "+OK2RM", "-OK2RM",
2N/A "+FAULT", "-FAULT");
2N/A my @masks = (
2N/A "amask=0x0001", "dmask=0x0001",
2N/A "amask=0x0008", "dmask=0x0008",
2N/A "amask=0x0002", "dmask=0x0002");
2N/A my @states = (
2N/A "absent>present", "present>configured",
2N/A "configured>unconfigured", "unconfigured>configured",
2N/A "unconfigured>absent", "configured>absent",
2N/A "present>absent", "absent>configured");
2N/A my @actions = (
2N/A "+PRSNT&+OK2RM", "+PRSNT&-OK2RM",
2N/A "+OK2RM", "-OK2RM",
2N/A "-OK2RM&-PRSNT", "-OK2RM&-PRSNT",
2N/A "-OK2RM&-PRSNT", "-OK2RM&+PRSNT");
2N/A
2N/A printf "\n";
2N/A printf " <propgroup name='%s-properties' version='1' " .
2N/A "name-stability='Private' data-stability='Private' >\n", $name;
2N/A printf " <propval name='fru-update-action' type='string' " .
2N/A "value='ipmi:fru gid=3 hdd=%d' />\n", $bay;
2N/A
2N/A for ($i = 0; $i < 6; $i++) {
2N/A printf " <propval name='indicator-name-%d' " .
2N/A "type='string' value='%s' />\n", $i, $names[$i];
2N/A printf " <propval name='indicator-action-%d' " .
2N/A "type='string' value='ipmi:state sid=%d %s' />\n",
2N/A $i, $sid, $masks[$i];
2N/A }
2N/A
2N/A for ($i = 0; $i < 8; $i++) {
2N/A printf " <propval name='indicator-rule-states-%d' " .
2N/A "type='string' value='%s' />\n", $i, $states[$i];
2N/A printf " <propval name='indicator-rule-actions-%d' " .
2N/A "type='string' value='%s' />\n", $i, $actions[$i];
2N/A }
2N/A printf " </propgroup>\n\n";
2N/A}
2N/A
2N/Aprint <<EOF;
2N/A<topology name='disk' scheme='hc'>
2N/A <range name='bay' min='0' max='47'>
2N/A <facility name='locate' type='indicator' provider='fac_prov_ipmi' >
2N/A <propgroup name='facility' version='1' name-stability='Private'
2N/A data-stability='Private' >
2N/A <propval name='type' type='uint32' value='1' />
2N/A <propmethod name='ipmi_entity' version='0' propname='entity_ref'
2N/A proptype='string_array' >
2N/A <argval name='format' type='string_array'>
2N/A <argitem value='hdd\%d.ok2rm.led' />
2N/A </argval>
2N/A <argval name='offset' type='uint32' value='0' />
2N/A <argval name='nparams' type='uint32' value='1' />
2N/A </propmethod>
2N/A <propmethod name='bay_locate_mode' version='0'
2N/A propname='mode' proptype='uint32' mutable='1'>
2N/A </propmethod>
2N/A </propgroup>
2N/A </facility>
2N/A <facility name='ok2rm' type='indicator' provider='fac_prov_ipmi' >
2N/A <propgroup name='facility' version='1' name-stability='Private'
2N/A data-stability='Private' >
2N/A <propval name='type' type='uint32' value='2' />
2N/A <propmethod name='ipmi_entity' version='0' propname='entity_ref'
2N/A proptype='string_array' >
2N/A <argval name='format' type='string_array'>
2N/A <argitem value='hdd\%d.state' />
2N/A </argval>
2N/A <argval name='offset' type='uint32' value='0' />
2N/A <argval name='nparams' type='uint32' value='1' />
2N/A </propmethod>
2N/A <propmethod name='bay_indicator_mode' version='0'
2N/A propname='mode' proptype='uint32' mutable='1'>
2N/A </propmethod>
2N/A </propgroup>
2N/A </facility>
2N/A <facility name='service' type='indicator' provider='fac_prov_ipmi' >
2N/A <propgroup name='facility' version='1' name-stability='Private'
2N/A data-stability='Private' >
2N/A <propval name='type' type='uint32' value='0' />
2N/A <propmethod name='ipmi_entity' version='0' propname='entity_ref'
2N/A proptype='string_array' >
2N/A <argval name='format' type='string_array'>
2N/A <argitem value='hdd\%d.state' />
2N/A </argval>
2N/A <argval name='offset' type='uint32' value='0' />
2N/A <argval name='nparams' type='uint32' value='1' />
2N/A </propmethod>
2N/A <propmethod name='bay_indicator_mode' version='0' propname='mode'
2N/A proptype='uint32' mutable='1'>
2N/A </propmethod>
2N/A </propgroup>
2N/A </facility>
2N/A <facility name='present' type='indicator' provider='fac_prov_ipmi' >
2N/A <propgroup name='facility' version='1' name-stability='Private'
2N/A data-stability='Private' >
2N/A <propval name='type' type='uint32' value='3' />
2N/A <propmethod name='ipmi_entity' version='0' propname='entity_ref'
2N/A proptype='string_array' >
2N/A <argval name='format' type='string_array'>
2N/A <argitem value='hdd\%d.state' />
2N/A </argval>
2N/A <argval name='offset' type='uint32' value='0' />
2N/A <argval name='nparams' type='uint32' value='1' />
2N/A </propmethod>
2N/A <propmethod name='x4500_present_mode' version='0' propname='mode'
2N/A proptype='uint32' mutable='1'>
2N/A </propmethod>
2N/A </propgroup>
2N/A </facility>
2N/AEOF
2N/A
2N/Amy @pci0=(1, 2, 0);
2N/Amy @pci1=(4, 3, 8, 7, 2, 1);
2N/A
2N/Afor ($bay = 0; $bay < $num_bays; $bay++) {
2N/A $sid = 90 + $bay;
2N/A $target = (($bay/12) + (($bay & 1) << 2));
2N/A $index = (($bay >> 2) % 3);
2N/A $p0 = $pci0[$index];
2N/A $index = (($bay >> 1) % 6);
2N/A $p1 = $pci1[$index];
2N/A
2N/A $hpath = sprintf("/pci\@%x,0/pci1022,7458\@%x/pci11ab,11ab\@1",
2N/A $p0, $p1);
2N/A $tpath = sprintf("/disk\@%x,0", $target);
2N/A $apoint = sprintf(":%d", $target);
2N/A
2N/A print <<EOF;
2N/A <node instance='$bay'>
2N/A <propgroup name='protocol' version='1' name-stability='Private'
2N/A data-stability='Private'>
2N/A <propval name='label' type='string' value='$bay_label$bay' />
2N/A </propgroup>
2N/A <propgroup name='io' version='1' name-stability='Private'
2N/A data-stability='Private'>
2N/A <propval name='ap-path' type='string' value='/devices$hpath$apoint' />
2N/A </propgroup>
2N/AEOF
2N/A
2N/A calc_sfx_prop("sfx4500", $bay, $sid);
2N/A
2N/A print <<EOF;
2N/A <propgroup name='binding' version='1' name-stability='Private'
2N/A data-stability='Private'>
2N/A <propval name='occupant-path' type='string'
2N/A value='$hpath$tpath' />
2N/A </propgroup>
2N/A </node>
2N/AEOF
2N/A}
2N/A
2N/Aprint <<EOF;
2N/A <dependents grouping='children'>
2N/A <range name='disk' min='0' max='0'>
2N/A <enum-method name='disk' version='1' />
2N/A </range>
2N/A </dependents>
2N/A </range>
2N/A</topology>
2N/AEOF