summaryrefslogtreecommitdiff
path: root/usr/src/cmd
diff options
context:
space:
mode:
authorJerry Jelinek <jerry.jelinek@joyent.com>2019-08-16 11:15:20 +0000
committerJerry Jelinek <jerry.jelinek@joyent.com>2019-08-16 11:15:20 +0000
commit0833839f60181af6fcf14de327d3ba2b30da8ed2 (patch)
treeaf7f3254e70fb8ad910d460648f9af42c0210457 /usr/src/cmd
parentadf665b5e735d87cf7d6b4e8932fb7dce88e42ad (diff)
parentd3b5f56344d8bfcdd6cfb82446af0e5e55ad9ebe (diff)
downloadillumos-joyent-0833839f60181af6fcf14de327d3ba2b30da8ed2.tar.gz
[illumos-gate merge]
commit d3b5f56344d8bfcdd6cfb82446af0e5e55ad9ebe 11528 Makefile.noget can get gone 11529 Use -Wno-maybe-initialized commit c4ccc1f9004b70b07e4cdb57641c38ab607306c9 11226 Remove NetraCT support commit dcfeff93f67a1188722a358e0fbfcd604993e573 11561 loader script needs to place .eh_frame after .text commit a8ffe4975d219124d53dcd9de30126f3a595d28f 11555 gptzfsboot: boot prompt is not refreshed on device change commit 79940ff6ac581ff9431c474dcfa18c78f1cb7a50 11556 ip_attr.c functions need to not dereference conn_ixa directly after lock drop commit fe949611d4f0a0f42a6923a31cd3073e5b2bc97c 10540 wsdiff much slower under python3 than python2 commit c1064fd7ce62fe763a4475e9988ffea3b22137de 11541 allocation_classes feature must be enabled to add log device Conflicts: usr/src/uts/sparc/Makefile.sparc usr/src/uts/intel/dev/Makefile usr/src/uts/i86pc/pcie/Makefile usr/src/cmd/zoneadmd/Makefile
Diffstat (limited to 'usr/src/cmd')
-rw-r--r--usr/src/cmd/abi/spectrans/parser/Makefile.targ2
-rw-r--r--usr/src/cmd/acctadm/Makefile2
-rw-r--r--usr/src/cmd/addbadsec/Makefile2
-rw-r--r--usr/src/cmd/allocate/Makefile2
-rw-r--r--usr/src/cmd/amt/Makefile.com2
-rw-r--r--usr/src/cmd/ast/msgcc/Makefile2
-rw-r--r--usr/src/cmd/audio/audioctl/Makefile2
-rw-r--r--usr/src/cmd/audio/audioplay/Makefile2
-rw-r--r--usr/src/cmd/audio/utilities/Makefile2
-rw-r--r--usr/src/cmd/auditconfig/Makefile2
-rw-r--r--usr/src/cmd/auditreduce/Makefile2
-rw-r--r--usr/src/cmd/autopush/Makefile2
-rw-r--r--usr/src/cmd/awk/Makefile2
-rw-r--r--usr/src/cmd/awk_xpg4/Makefile2
-rw-r--r--usr/src/cmd/backup/Makefile.backup2
-rw-r--r--usr/src/cmd/backup/dump/Makefile2
-rw-r--r--usr/src/cmd/bart/Makefile2
-rw-r--r--usr/src/cmd/bdiff/Makefile2
-rw-r--r--usr/src/cmd/bnu/Makefile.inc2
-rw-r--r--usr/src/cmd/cal/Makefile2
-rw-r--r--usr/src/cmd/cdrw/Makefile2
-rw-r--r--usr/src/cmd/chmod/Makefile2
-rw-r--r--usr/src/cmd/cmd-crypto/cryptoadm/Makefile2
-rw-r--r--usr/src/cmd/cmd-crypto/decrypt/Makefile.com2
-rw-r--r--usr/src/cmd/cmd-crypto/digest/Makefile.com2
-rw-r--r--usr/src/cmd/cmd-crypto/pktool/Makefile2
-rw-r--r--usr/src/cmd/cmd-inet/lib/ipmgmtd/Makefile2
-rw-r--r--usr/src/cmd/cmd-inet/lib/nwamd/Makefile2
-rw-r--r--usr/src/cmd/cmd-inet/usr.bin/Makefile2
-rw-r--r--usr/src/cmd/cmd-inet/usr.bin/ftp/Makefile2
-rw-r--r--usr/src/cmd/cmd-inet/usr.bin/nc/Makefile2
-rw-r--r--usr/src/cmd/cmd-inet/usr.bin/netstat/Makefile2
-rw-r--r--usr/src/cmd/cmd-inet/usr.bin/pppd/Makefile2
-rw-r--r--usr/src/cmd/cmd-inet/usr.bin/pppdump/Makefile2
-rw-r--r--usr/src/cmd/cmd-inet/usr.bin/rdist/Makefile2
-rw-r--r--usr/src/cmd/cmd-inet/usr.bin/talk/Makefile2
-rw-r--r--usr/src/cmd/cmd-inet/usr.lib/ilbd/Makefile2
-rw-r--r--usr/src/cmd/cmd-inet/usr.lib/ilbd/ilb/Makefile2
-rw-r--r--usr/src/cmd/cmd-inet/usr.lib/in.mpathd/Makefile2
-rw-r--r--usr/src/cmd/cmd-inet/usr.lib/in.ndpd/Makefile2
-rw-r--r--usr/src/cmd/cmd-inet/usr.lib/mdnsd/Makefile2
-rw-r--r--usr/src/cmd/cmd-inet/usr.lib/ncaconfd/Makefile2
-rw-r--r--usr/src/cmd/cmd-inet/usr.lib/vrrpd/Makefile2
-rw-r--r--usr/src/cmd/cmd-inet/usr.sbin/Makefile2
-rw-r--r--usr/src/cmd/cmd-inet/usr.sbin/ifconfig/Makefile2
-rw-r--r--usr/src/cmd/cmd-inet/usr.sbin/ilbadm/Makefile2
-rw-r--r--usr/src/cmd/cmd-inet/usr.sbin/in.routed/Makefile2
-rw-r--r--usr/src/cmd/cmd-inet/usr.sbin/in.talkd/Makefile2
-rw-r--r--usr/src/cmd/cmd-inet/usr.sbin/inetadm/Makefile2
-rw-r--r--usr/src/cmd/cmd-inet/usr.sbin/inetconv/Makefile2
-rw-r--r--usr/src/cmd/cmd-inet/usr.sbin/ipmpstat/Makefile2
-rw-r--r--usr/src/cmd/cmd-inet/usr.sbin/ipqosconf/Makefile2
-rw-r--r--usr/src/cmd/cmd-inet/usr.sbin/ipsecutils/Makefile2
-rw-r--r--usr/src/cmd/cmd-inet/usr.sbin/kssl/kssladm/Makefile2
-rw-r--r--usr/src/cmd/cmd-inet/usr.sbin/nwamadm/Makefile2
-rw-r--r--usr/src/cmd/cmd-inet/usr.sbin/nwamcfg/Makefile2
-rw-r--r--usr/src/cmd/cmd-inet/usr.sbin/routeadm/Makefile2
-rw-r--r--usr/src/cmd/cmd-inet/usr.sbin/snoop/Makefile2
-rw-r--r--usr/src/cmd/cmd-inet/usr.sbin/traceroute/Makefile2
-rw-r--r--usr/src/cmd/consadm/Makefile.com2
-rw-r--r--usr/src/cmd/cpc/cpustat/Makefile2
-rw-r--r--usr/src/cmd/cpio/Makefile2
-rw-r--r--usr/src/cmd/cron/Makefile2
-rw-r--r--usr/src/cmd/csh/i386/Makefile2
-rw-r--r--usr/src/cmd/csh/sparc/Makefile2
-rw-r--r--usr/src/cmd/csplit/Makefile2
-rw-r--r--usr/src/cmd/ctrun/Makefile2
-rw-r--r--usr/src/cmd/dc/Makefile2
-rw-r--r--usr/src/cmd/dcs/sparc/sun4u/Makefile2
-rw-r--r--usr/src/cmd/dd/Makefile2
-rw-r--r--usr/src/cmd/devfsadm/Makefile.com2
-rw-r--r--usr/src/cmd/devinfo/Makefile2
-rw-r--r--usr/src/cmd/devmgmt/cmds/Makefile2
-rw-r--r--usr/src/cmd/dfs.cmds/dfshares/Makefile2
-rw-r--r--usr/src/cmd/dfs.cmds/sharectl/Makefile.com2
-rw-r--r--usr/src/cmd/dfs.cmds/sharemgr/Makefile.com2
-rw-r--r--usr/src/cmd/diff/Makefile2
-rw-r--r--usr/src/cmd/dis/Makefile2
-rw-r--r--usr/src/cmd/dispadmin/Makefile2
-rw-r--r--usr/src/cmd/dladm/Makefile2
-rw-r--r--usr/src/cmd/dlmgmtd/Makefile2
-rw-r--r--usr/src/cmd/dlstat/Makefile2
-rw-r--r--usr/src/cmd/du/Makefile2
-rw-r--r--usr/src/cmd/ed/Makefile2
-rw-r--r--usr/src/cmd/eeprom/Makefile.com2
-rw-r--r--usr/src/cmd/eqn/eqn.d/Makefile2
-rw-r--r--usr/src/cmd/eqn/neqn.d/Makefile2
-rw-r--r--usr/src/cmd/expr/Makefile2
-rw-r--r--usr/src/cmd/file/Makefile2
-rw-r--r--usr/src/cmd/filesync/Makefile2
-rw-r--r--usr/src/cmd/find/Makefile2
-rw-r--r--usr/src/cmd/flowstat/Makefile2
-rw-r--r--usr/src/cmd/fm/eversholt/Makefile.esc.com2
-rw-r--r--usr/src/cmd/fm/fmd/Makefile.fmd2
-rw-r--r--usr/src/cmd/fm/fmdump/Makefile.com2
-rw-r--r--usr/src/cmd/fm/fminject/Makefile.com2
-rw-r--r--usr/src/cmd/fm/ipmitopo/Makefile.com2
-rw-r--r--usr/src/cmd/fm/modules/common/disk-monitor/Makefile2
-rw-r--r--usr/src/cmd/fm/modules/common/eversholt/Makefile2
-rw-r--r--usr/src/cmd/fm/modules/common/fabric-xlate/Makefile2
-rw-r--r--usr/src/cmd/fm/modules/common/ip-transport/Makefile2
-rw-r--r--usr/src/cmd/fm/modules/common/sw-diag-response/software-diagnosis/Makefile2
-rw-r--r--usr/src/cmd/fm/modules/sun4u/cpumem-diagnosis/Makefile2
-rw-r--r--usr/src/cmd/fm/modules/sun4v/etm/Makefile2
-rw-r--r--usr/src/cmd/fmtmsg/Makefile2
-rw-r--r--usr/src/cmd/format/Makefile2
-rw-r--r--usr/src/cmd/fs.d/Makefile2
-rw-r--r--usr/src/cmd/fs.d/autofs/Makefile2
-rw-r--r--usr/src/cmd/fs.d/nfs/lockd/Makefile2
-rw-r--r--usr/src/cmd/fs.d/nfs/mount/Makefile2
-rw-r--r--usr/src/cmd/fs.d/nfs/mountd/Makefile2
-rw-r--r--usr/src/cmd/fs.d/nfs/nfslog/Makefile2
-rw-r--r--usr/src/cmd/fs.d/nfs/nfsmapid/Makefile2
-rw-r--r--usr/src/cmd/fs.d/nfs/showmount/Makefile2
-rw-r--r--usr/src/cmd/fs.d/nfs/statd/Makefile2
-rw-r--r--usr/src/cmd/fs.d/pcfs/fsck/Makefile2
-rw-r--r--usr/src/cmd/fs.d/pcfs/mount/Makefile2
-rw-r--r--usr/src/cmd/fs.d/tmpfs/Makefile2
-rw-r--r--usr/src/cmd/fs.d/udfs/fsck/Makefile2
-rw-r--r--usr/src/cmd/fs.d/udfs/fsdb/Makefile2
-rw-r--r--usr/src/cmd/fs.d/udfs/fstyp/Makefile2
-rw-r--r--usr/src/cmd/fs.d/udfs/labelit/Makefile2
-rw-r--r--usr/src/cmd/fs.d/udfs/mkfs/Makefile2
-rw-r--r--usr/src/cmd/fs.d/ufs/ff/Makefile2
-rw-r--r--usr/src/cmd/fs.d/ufs/fsck/Makefile2
-rw-r--r--usr/src/cmd/fs.d/ufs/fsdb/Makefile2
-rw-r--r--usr/src/cmd/fs.d/ufs/fssnap/Makefile2
-rw-r--r--usr/src/cmd/fs.d/ufs/mkfs/Makefile2
-rw-r--r--usr/src/cmd/fs.d/ufs/newfs/Makefile2
-rw-r--r--usr/src/cmd/fs.d/ufs/repquota/Makefile2
-rw-r--r--usr/src/cmd/fs.d/ufs/tunefs/Makefile2
-rw-r--r--usr/src/cmd/fs.d/ufs/volcopy/Makefile2
-rw-r--r--usr/src/cmd/fwflash/Makefile.com2
-rw-r--r--usr/src/cmd/geniconvtbl/Makefile.com2
-rw-r--r--usr/src/cmd/getfacl/Makefile2
-rw-r--r--usr/src/cmd/grep/Makefile2
-rw-r--r--usr/src/cmd/gss/gssd/Makefile2
-rw-r--r--usr/src/cmd/hotplugd/Makefile2
-rw-r--r--usr/src/cmd/id/Makefile2
-rw-r--r--usr/src/cmd/idmap/idmap/Makefile2
-rw-r--r--usr/src/cmd/idmap/idmapd/Makefile2
-rw-r--r--usr/src/cmd/init/Makefile2
-rw-r--r--usr/src/cmd/intrstat/Makefile.com2
-rw-r--r--usr/src/cmd/ipf/Makefile.ipf2
-rw-r--r--usr/src/cmd/iscsiadm/Makefile2
-rw-r--r--usr/src/cmd/isns/isnsadm/Makefile2
-rw-r--r--usr/src/cmd/isns/isnsd/Makefile2
-rw-r--r--usr/src/cmd/kbd/Makefile2
-rw-r--r--usr/src/cmd/keyserv/Makefile2
-rw-r--r--usr/src/cmd/krb5/kadmin/kclient/Makefile2
-rw-r--r--usr/src/cmd/krb5/kadmin/kdcmgr/Makefile2
-rw-r--r--usr/src/cmd/krb5/slave/Makefile2
-rw-r--r--usr/src/cmd/latencytop/Makefile.com2
-rw-r--r--usr/src/cmd/ldap/Makefile.com2
-rw-r--r--usr/src/cmd/ldapcachemgr/Makefile2
-rw-r--r--usr/src/cmd/ldmad/Makefile2
-rw-r--r--usr/src/cmd/listen/Makefile2
-rw-r--r--usr/src/cmd/loadkeys/Makefile2
-rw-r--r--usr/src/cmd/lockstat/Makefile.com2
-rw-r--r--usr/src/cmd/lofiadm/Makefile2
-rw-r--r--usr/src/cmd/logadm/Makefile2
-rw-r--r--usr/src/cmd/logins/Makefile2
-rw-r--r--usr/src/cmd/lp/Makefile.lp2
-rw-r--r--usr/src/cmd/lp/lib/filters/Makefile2
-rw-r--r--usr/src/cmd/luxadm/Makefile2
-rw-r--r--usr/src/cmd/mail/Makefile2
-rw-r--r--usr/src/cmd/mailx/Makefile2
-rw-r--r--usr/src/cmd/mandoc/Makefile.common2
-rw-r--r--usr/src/cmd/mdb/Makefile.kmdb2
-rw-r--r--usr/src/cmd/mdb/Makefile.libstandctf2
-rw-r--r--usr/src/cmd/mdb/Makefile.mdb2
-rw-r--r--usr/src/cmd/mdb/i86pc/modules/unix/amd64/Makefile2
-rw-r--r--usr/src/cmd/mdb/i86xpv/modules/unix/amd64/Makefile2
-rw-r--r--usr/src/cmd/mdb/intel/amd64/genunix/Makefile2
-rw-r--r--usr/src/cmd/mdb/intel/amd64/idm/Makefile2
-rw-r--r--usr/src/cmd/mdb/intel/amd64/ipp/Makefile2
-rw-r--r--usr/src/cmd/mdb/intel/amd64/libproc/Makefile2
-rw-r--r--usr/src/cmd/mdb/intel/amd64/libumem/Makefile2
-rw-r--r--usr/src/cmd/mdb/intel/amd64/pmcs/Makefile2
-rw-r--r--usr/src/cmd/mdb/intel/ia32/libproc/Makefile2
-rw-r--r--usr/src/cmd/mdb/intel/ia32/libumem/Makefile2
-rw-r--r--usr/src/cmd/mdb/intel/modules/amd_opteron/amd64/Makefile2
-rw-r--r--usr/src/cmd/mdb/intel/modules/generic_cpu/amd64/Makefile2
-rw-r--r--usr/src/cmd/mdb/sparc/v7/libproc/Makefile2
-rw-r--r--usr/src/cmd/mdb/sparc/v7/libumem/Makefile2
-rw-r--r--usr/src/cmd/mdb/sparc/v9/genunix/Makefile2
-rw-r--r--usr/src/cmd/mdb/sparc/v9/idm/Makefile2
-rw-r--r--usr/src/cmd/mdb/sparc/v9/ipp/Makefile2
-rw-r--r--usr/src/cmd/mdb/sparc/v9/libproc/Makefile2
-rw-r--r--usr/src/cmd/mdb/sparc/v9/libumem/Makefile2
-rw-r--r--usr/src/cmd/mdb/sparc/v9/pmcs/Makefile2
-rw-r--r--usr/src/cmd/mdb/sun4u/modules/unix/v9/Makefile2
-rw-r--r--usr/src/cmd/mdb/sun4v/modules/unix/v9/Makefile2
-rw-r--r--usr/src/cmd/mdb/tools/findfp/Makefile.com2
-rw-r--r--usr/src/cmd/mdb/tools/setdynflag/Makefile.com2
-rw-r--r--usr/src/cmd/mkdir/Makefile2
-rw-r--r--usr/src/cmd/mkmsgs/Makefile2
-rw-r--r--usr/src/cmd/mknod/Makefile2
-rw-r--r--usr/src/cmd/mktemp/Makefile2
-rw-r--r--usr/src/cmd/more/Makefile2
-rw-r--r--usr/src/cmd/msgfmt/Makefile2
-rw-r--r--usr/src/cmd/mv/Makefile2
-rw-r--r--usr/src/cmd/ndmpadm/Makefile2
-rw-r--r--usr/src/cmd/ndmpd/Makefile2
-rw-r--r--usr/src/cmd/netadm/iu.ap.sh2
-rw-r--r--usr/src/cmd/newform/Makefile2
-rw-r--r--usr/src/cmd/newtask/Makefile.com2
-rw-r--r--usr/src/cmd/nl/Makefile2
-rw-r--r--usr/src/cmd/nlsadmin/Makefile2
-rw-r--r--usr/src/cmd/nscd/Makefile2
-rw-r--r--usr/src/cmd/pack/Makefile2
-rw-r--r--usr/src/cmd/passmgmt/Makefile2
-rw-r--r--usr/src/cmd/pbind/Makefile.com2
-rw-r--r--usr/src/cmd/pcitool/Makefile.com2
-rw-r--r--usr/src/cmd/pg/Makefile2
-rw-r--r--usr/src/cmd/picl/plugins/Makefile.com2
-rw-r--r--usr/src/cmd/picl/plugins/lib/picld_pluginutil/Makefile.com2
-rw-r--r--usr/src/cmd/picl/plugins/sun4u/Makefile8
-rw-r--r--usr/src/cmd/picl/plugins/sun4u/snowbird/Makefile55
-rw-r--r--usr/src/cmd/picl/plugins/sun4u/snowbird/conf/Makefile75
-rw-r--r--usr/src/cmd/picl/plugins/sun4u/snowbird/conf/SUNW,Netra-CP2300.RTM.conf100
-rw-r--r--usr/src/cmd/picl/plugins/sun4u/snowbird/conf/SUNW,Netra-CP2300.conf83
-rw-r--r--usr/src/cmd/picl/plugins/sun4u/snowbird/conf/envmond.conf30
-rw-r--r--usr/src/cmd/picl/plugins/sun4u/snowbird/envmond/Makefile106
-rw-r--r--usr/src/cmd/picl/plugins/sun4u/snowbird/envmond/picldr.c822
-rw-r--r--usr/src/cmd/picl/plugins/sun4u/snowbird/envmond/picldr.h94
-rw-r--r--usr/src/cmd/picl/plugins/sun4u/snowbird/envmond/piclenvmond.c436
-rw-r--r--usr/src/cmd/picl/plugins/sun4u/snowbird/envmond/piclenvmond.h110
-rw-r--r--usr/src/cmd/picl/plugins/sun4u/snowbird/envmond/piclplatmod.c837
-rw-r--r--usr/src/cmd/picl/plugins/sun4u/snowbird/envmond/piclsensors.c863
-rw-r--r--usr/src/cmd/picl/plugins/sun4u/snowbird/envmond/piclsensors.h119
-rw-r--r--usr/src/cmd/picl/plugins/sun4u/snowbird/frutree/Makefile106
-rw-r--r--usr/src/cmd/picl/plugins/sun4u/snowbird/frutree/piclfrutree.c5969
-rw-r--r--usr/src/cmd/picl/plugins/sun4u/snowbird/frutree/piclfrutree.h264
-rw-r--r--usr/src/cmd/picl/plugins/sun4u/snowbird/frutree/piclkstat.c428
-rw-r--r--usr/src/cmd/picl/plugins/sun4u/snowbird/frutree/picllibdevinfo.c853
-rw-r--r--usr/src/cmd/picl/plugins/sun4u/snowbird/frutree/piclscsi.c899
-rw-r--r--usr/src/cmd/picl/plugins/sun4u/snowbird/lib/Makefile51
-rw-r--r--usr/src/cmd/picl/plugins/sun4u/snowbird/lib/fruaccess/Makefile104
-rw-r--r--usr/src/cmd/picl/plugins/sun4u/snowbird/lib/fruaccess/fru_access_impl.h263
-rw-r--r--usr/src/cmd/picl/plugins/sun4u/snowbird/lib/fruaccess/libfruaccess.c3438
-rw-r--r--usr/src/cmd/picl/plugins/sun4u/snowbird/lib/fruaccess/piclfruaccess_platmod.c116
-rw-r--r--usr/src/cmd/picl/plugins/sun4u/snowbird/lib/fruaccess/piclsdr.c343
-rw-r--r--usr/src/cmd/picl/plugins/sun4u/snowbird/lib/fruaccess/piclsmc.c997
-rw-r--r--usr/src/cmd/picl/plugins/sun4u/snowbird/lib/libctsmc/Makefile91
-rw-r--r--usr/src/cmd/picl/plugins/sun4u/snowbird/lib/libctsmc/libctsmc.c476
-rw-r--r--usr/src/cmd/picl/plugins/sun4u/snowbird/lib/libctsmc/smclib.h69
-rw-r--r--usr/src/cmd/picl/plugins/sun4u/snowbird/watchdog/Makefile102
-rw-r--r--usr/src/cmd/picl/plugins/sun4u/snowbird/watchdog/piclwatchdog.c1837
-rw-r--r--usr/src/cmd/picl/plugins/sun4u/snowbird/watchdog/piclwatchdog.h288
-rw-r--r--usr/src/cmd/picl/plugins/sun4u/snowbird/watchdog/piclwd_platmod.c59
-rw-r--r--usr/src/cmd/picl/plugins/sun4v/mdesc/mdescplugin.c8
-rw-r--r--usr/src/cmd/plimit/amd64/Makefile2
-rw-r--r--usr/src/cmd/plimit/i386/Makefile2
-rw-r--r--usr/src/cmd/plimit/sparcv9/Makefile2
-rw-r--r--usr/src/cmd/pools/Makefile.pools2
-rw-r--r--usr/src/cmd/powertop/Makefile.com2
-rw-r--r--usr/src/cmd/praudit/Makefile2
-rw-r--r--usr/src/cmd/prctl/Makefile.com2
-rw-r--r--usr/src/cmd/print/bsd-sysv-commands/Makefile2
-rw-r--r--usr/src/cmd/print/printmgr/com/sun/admin/pm/server/Makefile2
-rw-r--r--usr/src/cmd/priocntl/Makefile2
-rw-r--r--usr/src/cmd/projects/Makefile2
-rw-r--r--usr/src/cmd/prtconf/Makefile.com2
-rw-r--r--usr/src/cmd/prtvtoc/Makefile2
-rw-r--r--usr/src/cmd/psrset/Makefile.com2
-rw-r--r--usr/src/cmd/ptools/Makefile.bld4
-rw-r--r--usr/src/cmd/raidctl/Makefile2
-rw-r--r--usr/src/cmd/ramdiskadm/Makefile2
-rw-r--r--usr/src/cmd/rcap/Makefile.com2
-rw-r--r--usr/src/cmd/rcm_daemon/Makefile.com9
-rw-r--r--usr/src/cmd/rcm_daemon/common/ttymux_rcm.c1434
-rw-r--r--usr/src/cmd/rcm_daemon/common/ttymux_rcm_impl.h100
-rw-r--r--usr/src/cmd/rctladm/Makefile2
-rw-r--r--usr/src/cmd/refer/Makefile2
-rw-r--r--usr/src/cmd/rmdir/Makefile2
-rw-r--r--usr/src/cmd/rmformat/Makefile2
-rw-r--r--usr/src/cmd/rmmount/Makefile2
-rw-r--r--usr/src/cmd/rmvolmgr/Makefile2
-rw-r--r--usr/src/cmd/rpcinfo/Makefile2
-rw-r--r--usr/src/cmd/sa/Makefile2
-rw-r--r--usr/src/cmd/sendmail/Makefile.cmd2
-rw-r--r--usr/src/cmd/setfacl/Makefile2
-rw-r--r--usr/src/cmd/sf880drd/Makefile2
-rw-r--r--usr/src/cmd/sgs/ar/Makefile.com2
-rw-r--r--usr/src/cmd/sgs/dump/Makefile.com2
-rw-r--r--usr/src/cmd/sgs/elfdump/Makefile.com2
-rw-r--r--usr/src/cmd/sgs/elfedit/Makefile.com2
-rw-r--r--usr/src/cmd/sgs/elfedit/modules/Makefile.com2
-rw-r--r--usr/src/cmd/sgs/elfwrap/Makefile.com2
-rw-r--r--usr/src/cmd/sgs/error/i386/Makefile2
-rw-r--r--usr/src/cmd/sgs/error/sparc/Makefile2
-rw-r--r--usr/src/cmd/sgs/gprof/Makefile.com2
-rw-r--r--usr/src/cmd/sgs/lex/Makefile.com2
-rw-r--r--usr/src/cmd/sgs/libelf/Makefile.com2
-rw-r--r--usr/src/cmd/sgs/libld/Makefile.com2
-rw-r--r--usr/src/cmd/sgs/liblddbg/Makefile.com2
-rw-r--r--usr/src/cmd/sgs/librtld/Makefile.com2
-rw-r--r--usr/src/cmd/sgs/librtld_db/Makefile.com2
-rw-r--r--usr/src/cmd/sgs/m4/i386/Makefile2
-rw-r--r--usr/src/cmd/sgs/m4/sparc/Makefile2
-rw-r--r--usr/src/cmd/sgs/mcs/Makefile.com2
-rw-r--r--usr/src/cmd/sgs/prof/Makefile.com2
-rw-r--r--usr/src/cmd/sgs/rtld/Makefile.com2
-rw-r--r--usr/src/cmd/sgs/rtld/mdbmod/Makefile.com2
-rw-r--r--usr/src/cmd/sgs/yacc/Makefile.com2
-rw-r--r--usr/src/cmd/smbsrv/smbadm/Makefile2
-rw-r--r--usr/src/cmd/smserverd/Makefile2
-rw-r--r--usr/src/cmd/sort/Makefile.com2
-rw-r--r--usr/src/cmd/stat/iostat/Makefile2
-rw-r--r--usr/src/cmd/stat/kstat/Makefile2
-rw-r--r--usr/src/cmd/stat/mpstat/Makefile2
-rw-r--r--usr/src/cmd/stat/vmstat/Makefile2
-rw-r--r--usr/src/cmd/stmsboot/Makefile2
-rw-r--r--usr/src/cmd/streams/strcmd/Makefile2
-rw-r--r--usr/src/cmd/strings/Makefile.com2
-rw-r--r--usr/src/cmd/sunpc/other/Makefile2
-rw-r--r--usr/src/cmd/svc/configd/Makefile2
-rw-r--r--usr/src/cmd/svc/lsvcrun/Makefile2
-rw-r--r--usr/src/cmd/svc/mfstscan/Makefile2
-rw-r--r--usr/src/cmd/svc/profile/Makefile8
-rw-r--r--usr/src/cmd/svc/profile/platform_SUNW,UltraSPARC-IIi-Netract.xml40
-rw-r--r--usr/src/cmd/svc/startd/Makefile2
-rw-r--r--usr/src/cmd/svc/svcadm/Makefile2
-rw-r--r--usr/src/cmd/svc/svccfg/Makefile2
-rw-r--r--usr/src/cmd/svc/svcprop/Makefile2
-rw-r--r--usr/src/cmd/svc/svcs/Makefile2
-rw-r--r--usr/src/cmd/svr4pkg/Makefile.svr4pkg2
-rw-r--r--usr/src/cmd/svr4pkg/libinst/Makefile2
-rw-r--r--usr/src/cmd/swap/Makefile.com2
-rw-r--r--usr/src/cmd/syseventadm/Makefile2
-rw-r--r--usr/src/cmd/syseventd/daemons/syseventd/Makefile2
-rw-r--r--usr/src/cmd/syseventd/modules/sysevent_conf_mod/Makefile2
-rw-r--r--usr/src/cmd/syseventd/modules/zfs_mod/Makefile2
-rw-r--r--usr/src/cmd/syslogd/Makefile.com2
-rw-r--r--usr/src/cmd/tar/Makefile2
-rw-r--r--usr/src/cmd/tbl/Makefile2
-rw-r--r--usr/src/cmd/tcopy/Makefile2
-rw-r--r--usr/src/cmd/tcpd/Makefile2
-rw-r--r--usr/src/cmd/th_tools/Makefile2
-rw-r--r--usr/src/cmd/tic/Makefile.common2
-rw-r--r--usr/src/cmd/tip/Makefile2
-rw-r--r--usr/src/cmd/tnf/prex/Makefile.com2
-rw-r--r--usr/src/cmd/tnf/tnfxtract/Makefile.com2
-rw-r--r--usr/src/cmd/troff/troff.d/Makefile2
-rw-r--r--usr/src/cmd/truss/Makefile.com2
-rw-r--r--usr/src/cmd/ttymon/Makefile2
-rw-r--r--usr/src/cmd/ucodeadm/Makefile2
-rw-r--r--usr/src/cmd/uname/Makefile2
-rw-r--r--usr/src/cmd/unpack/Makefile2
-rw-r--r--usr/src/cmd/users/Makefile2
-rw-r--r--usr/src/cmd/vi/misc/Makefile2
-rw-r--r--usr/src/cmd/vi/port/Makefile2
-rw-r--r--usr/src/cmd/volcheck/Makefile2
-rw-r--r--usr/src/cmd/volrmmount/Makefile2
-rw-r--r--usr/src/cmd/vt/Makefile2
-rw-r--r--usr/src/cmd/wall/Makefile2
-rw-r--r--usr/src/cmd/ypcmd/Makefile2
-rw-r--r--usr/src/cmd/ypcmd/revnetgroup/Makefile2
-rw-r--r--usr/src/cmd/ypcmd/yppasswd/Makefile2
-rw-r--r--usr/src/cmd/zic/Makefile.common2
-rw-r--r--usr/src/cmd/zinject/Makefile.com2
-rw-r--r--usr/src/cmd/zlogin/Makefile10
-rw-r--r--usr/src/cmd/zlogin/zlogin.c4
-rw-r--r--usr/src/cmd/zlook/Makefile.com2
-rw-r--r--usr/src/cmd/zoneadm/Makefile2
-rw-r--r--usr/src/cmd/zoneadmd/Makefile9
-rw-r--r--usr/src/cmd/zonecfg/Makefile2
-rw-r--r--usr/src/cmd/zonestat/zonestat/Makefile2
-rw-r--r--usr/src/cmd/zonestat/zonestatd/Makefile2
370 files changed, 347 insertions, 22422 deletions
diff --git a/usr/src/cmd/abi/spectrans/parser/Makefile.targ b/usr/src/cmd/abi/spectrans/parser/Makefile.targ
index 525b5bf824..8c62e3e315 100644
--- a/usr/src/cmd/abi/spectrans/parser/Makefile.targ
+++ b/usr/src/cmd/abi/spectrans/parser/Makefile.targ
@@ -44,7 +44,7 @@ CLOBBERFILES += $(LINTLIB) $(LIBRARY)
CERRWARN += -_gcc=-Wno-parentheses
CERRWARN += -_gcc=-Wno-unused-label
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/acctadm/Makefile b/usr/src/cmd/acctadm/Makefile
index 6055a32f2b..209d9db664 100644
--- a/usr/src/cmd/acctadm/Makefile
+++ b/usr/src/cmd/acctadm/Makefile
@@ -35,7 +35,7 @@ include ../Makefile.cmd
ROOTMANIFESTDIR = $(ROOTSVCSYSTEM)
CFLAGS += $(CCVERBOSE)
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-parentheses
LDLIBS += -lexacct -lscf -lsecdb -ldladm
POFILE = acctadm.po
diff --git a/usr/src/cmd/addbadsec/Makefile b/usr/src/cmd/addbadsec/Makefile
index fc45ac9abe..54fc4fa23b 100644
--- a/usr/src/cmd/addbadsec/Makefile
+++ b/usr/src/cmd/addbadsec/Makefile
@@ -33,7 +33,7 @@ include ../Makefile.cmd
CPPFLAGS += -D_EXTVTOC
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/allocate/Makefile b/usr/src/cmd/allocate/Makefile
index 637283c06c..f537293574 100644
--- a/usr/src/cmd/allocate/Makefile
+++ b/usr/src/cmd/allocate/Makefile
@@ -29,7 +29,7 @@ ETCTSOLFILES = devalloc_defaults
include ../Makefile.cmd
CERRWARN += -_gcc=-Wno-unused-value
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-parentheses
CERRWARN += -_gcc=-Wno-clobbered
diff --git a/usr/src/cmd/amt/Makefile.com b/usr/src/cmd/amt/Makefile.com
index a3a7691e4c..2787e642f1 100644
--- a/usr/src/cmd/amt/Makefile.com
+++ b/usr/src/cmd/amt/Makefile.com
@@ -35,7 +35,7 @@ LDLIBS += -lelf
LINTFLAGS += -erroff=E_NAME_USED_NOT_DEF2
LINTFLAGS64 += -erroff=E_NAME_USED_NOT_DEF2
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CLEANFILES += $(PROG) $(OBJS)
diff --git a/usr/src/cmd/ast/msgcc/Makefile b/usr/src/cmd/ast/msgcc/Makefile
index 306cb54f72..70a1f3f25b 100644
--- a/usr/src/cmd/ast/msgcc/Makefile
+++ b/usr/src/cmd/ast/msgcc/Makefile
@@ -50,7 +50,7 @@ CFLAGS += \
CERRWARN += -_gcc=-Wno-parentheses
CERRWARN += -_gcc=-Wno-empty-body
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/audio/audioctl/Makefile b/usr/src/cmd/audio/audioctl/Makefile
index f9c6b65c8b..ee4c8edac6 100644
--- a/usr/src/cmd/audio/audioctl/Makefile
+++ b/usr/src/cmd/audio/audioctl/Makefile
@@ -30,7 +30,7 @@ include ../../Makefile.cmd
LDLIBS += -ldevinfo
CFLAGS += $(CCVERBOSE)
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
.KEEP_STATE:
diff --git a/usr/src/cmd/audio/audioplay/Makefile b/usr/src/cmd/audio/audioplay/Makefile
index 23ce81e74d..895c00f2af 100644
--- a/usr/src/cmd/audio/audioplay/Makefile
+++ b/usr/src/cmd/audio/audioplay/Makefile
@@ -39,7 +39,7 @@ LDFLAGS += -L../utilities
CFLAGS += $(CCVERBOSE)
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
SMOFF += indenting
diff --git a/usr/src/cmd/audio/utilities/Makefile b/usr/src/cmd/audio/utilities/Makefile
index d2d68162b1..5aa3024509 100644
--- a/usr/src/cmd/audio/utilities/Makefile
+++ b/usr/src/cmd/audio/utilities/Makefile
@@ -33,7 +33,7 @@ INCLUDES += -I../include
CPPFLAGS += $(INCLUDES)
CFLAGS += $(CCVERBOSE)
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-unused-variable
CERRWARN += -_gcc=-Wno-parentheses
diff --git a/usr/src/cmd/auditconfig/Makefile b/usr/src/cmd/auditconfig/Makefile
index 54d9e8e6b0..ce287fff2b 100644
--- a/usr/src/cmd/auditconfig/Makefile
+++ b/usr/src/cmd/auditconfig/Makefile
@@ -38,7 +38,7 @@ POFILE = $(PROG).po
MSGFILES = $(SRCS)
CPPFLAGS += -I$(LIBBSM)
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-parentheses
.KEEP_STATE:
diff --git a/usr/src/cmd/auditreduce/Makefile b/usr/src/cmd/auditreduce/Makefile
index 2ddee8299b..9984ce57a6 100644
--- a/usr/src/cmd/auditreduce/Makefile
+++ b/usr/src/cmd/auditreduce/Makefile
@@ -41,7 +41,7 @@ MSGFILES = $(SRCS)
CPPFLAGS += -I$(TABLEDIR) -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
LDLIBS += -lnsl -lbsm -lscf -ltsol
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-parentheses
# false positives / need cleanup
diff --git a/usr/src/cmd/autopush/Makefile b/usr/src/cmd/autopush/Makefile
index 4ff7a09068..7af1622c09 100644
--- a/usr/src/cmd/autopush/Makefile
+++ b/usr/src/cmd/autopush/Makefile
@@ -29,7 +29,7 @@ ROOTFS_PROG= $(PROG)
include ../Makefile.cmd
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
.KEEP_STATE:
diff --git a/usr/src/cmd/awk/Makefile b/usr/src/cmd/awk/Makefile
index b958093755..046f0b739e 100644
--- a/usr/src/cmd/awk/Makefile
+++ b/usr/src/cmd/awk/Makefile
@@ -40,7 +40,7 @@ include ../Makefile.cmd
CERRWARN += -_gcc=-Wno-unused-label
CERRWARN += -_gcc=-Wno-parentheses
CERRWARN += -_gcc=-Wno-unused-variable
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/awk_xpg4/Makefile b/usr/src/cmd/awk_xpg4/Makefile
index dc03ef3b1e..515ee7a5c0 100644
--- a/usr/src/cmd/awk_xpg4/Makefile
+++ b/usr/src/cmd/awk_xpg4/Makefile
@@ -44,7 +44,7 @@ CPPFLAGS += -D_FILE_OFFSET_BITS=64
CFLAGS += $(CCVERBOSE)
CERRWARN += -_gcc=-Wno-unused-label
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
YFLAGS += -d
LDLIBS += -lm
CLEANFILES= awk.c y.tab.h
diff --git a/usr/src/cmd/backup/Makefile.backup b/usr/src/cmd/backup/Makefile.backup
index 5a4712eb6e..a4086ac9e7 100644
--- a/usr/src/cmd/backup/Makefile.backup
+++ b/usr/src/cmd/backup/Makefile.backup
@@ -42,7 +42,7 @@ CSTYLEFLAGS= -h -p -P
CERRWARN += -_gcc=-Wno-implicit-function-declaration
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-clobbered
# not linted
diff --git a/usr/src/cmd/backup/dump/Makefile b/usr/src/cmd/backup/dump/Makefile
index 965fcf8eae..1e24b4845d 100644
--- a/usr/src/cmd/backup/dump/Makefile
+++ b/usr/src/cmd/backup/dump/Makefile
@@ -69,7 +69,7 @@ CPPFLAGS= -I$(LOCAL) -I$(GENERAL) -I$(GLOBAL) -DPARTIAL \
-D_LARGEFILE64_SOURCE=1
CERRWARN += -_gcc=-Wno-implicit-function-declaration
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-clobbered
CERRWARN += -_gcc=-Wno-extra
LIBDUMP= ../lib/libdump.a
diff --git a/usr/src/cmd/bart/Makefile b/usr/src/cmd/bart/Makefile
index 67623232e0..47938144ab 100644
--- a/usr/src/cmd/bart/Makefile
+++ b/usr/src/cmd/bart/Makefile
@@ -33,7 +33,7 @@ include ../Makefile.cmd
LDLIBS += -lsec -lmd
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
SMOFF += indenting
diff --git a/usr/src/cmd/bdiff/Makefile b/usr/src/cmd/bdiff/Makefile
index 0b76705ff5..941df00f7c 100644
--- a/usr/src/cmd/bdiff/Makefile
+++ b/usr/src/cmd/bdiff/Makefile
@@ -32,7 +32,7 @@ include ../Makefile.cmd
FILEMODE= 755
CPPFLAGS += -D_FILE_OFFSET_BITS=64
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/bnu/Makefile.inc b/usr/src/cmd/bnu/Makefile.inc
index 5433cd6431..476c5cc290 100644
--- a/usr/src/cmd/bnu/Makefile.inc
+++ b/usr/src/cmd/bnu/Makefile.inc
@@ -44,7 +44,7 @@ SRCS = account.c anlwrk.c bnuconvert.c callers.c \
CERRWARN += -_gcc=-Wno-parentheses
CERRWARN += -_gcc=-Wno-char-subscripts
CERRWARN += -_gcc=-Wno-unused-variable
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-extra
CERRWARN += -_gcc=-Wno-implicit-function-declaration
diff --git a/usr/src/cmd/cal/Makefile b/usr/src/cmd/cal/Makefile
index 0cf3f27ba5..8ae9a69d1e 100644
--- a/usr/src/cmd/cal/Makefile
+++ b/usr/src/cmd/cal/Makefile
@@ -33,7 +33,7 @@ DCFILE= $(PROG).dc
CFLAGS += $(CCVERBOSE)
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
.KEEP_STATE:
diff --git a/usr/src/cmd/cdrw/Makefile b/usr/src/cmd/cdrw/Makefile
index f44584ed69..aa39fca47b 100644
--- a/usr/src/cmd/cdrw/Makefile
+++ b/usr/src/cmd/cdrw/Makefile
@@ -38,7 +38,7 @@ SRCS= $(OBJS:.o=.c)
LDLIBS += -lhal -lsecdb
NONLINTLDLIBS = -ldbus-1
CFLAGS += $(CCVERBOSE)
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-parentheses
CPPFLAGS += -D_REENTRANT -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 $(HAL_DBUS_CPPFLAGS)
LINTFLAGS += -um
diff --git a/usr/src/cmd/chmod/Makefile b/usr/src/cmd/chmod/Makefile
index 00788f1205..45439d6628 100644
--- a/usr/src/cmd/chmod/Makefile
+++ b/usr/src/cmd/chmod/Makefile
@@ -33,7 +33,7 @@ include ../Makefile.cmd
CFLAGS += $(CCVERBOSE)
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CPPFLAGS += -D_FILE_OFFSET_BITS=64
diff --git a/usr/src/cmd/cmd-crypto/cryptoadm/Makefile b/usr/src/cmd/cmd-crypto/cryptoadm/Makefile
index 1f421601fc..621de49f78 100644
--- a/usr/src/cmd/cmd-crypto/cryptoadm/Makefile
+++ b/usr/src/cmd/cmd-crypto/cryptoadm/Makefile
@@ -40,7 +40,7 @@ POFILES = $(OBJS:%.o=%.po)
POFILE = $(PROG)_all.po
CFLAGS += $(CCVERBOSE)
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-parentheses
LDLIBS += -lcryptoutil
diff --git a/usr/src/cmd/cmd-crypto/decrypt/Makefile.com b/usr/src/cmd/cmd-crypto/decrypt/Makefile.com
index f549085acf..d6bb139100 100644
--- a/usr/src/cmd/cmd-crypto/decrypt/Makefile.com
+++ b/usr/src/cmd/cmd-crypto/decrypt/Makefile.com
@@ -39,7 +39,7 @@ CFLAGS64 += $(CCVERBOSE)
CPPFLAGS += -D_FILE_OFFSET_BITS=64
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
LDLIBS += -lkmf -lpkcs11 -lcryptoutil
diff --git a/usr/src/cmd/cmd-crypto/digest/Makefile.com b/usr/src/cmd/cmd-crypto/digest/Makefile.com
index ecc0652cee..0426ce906c 100644
--- a/usr/src/cmd/cmd-crypto/digest/Makefile.com
+++ b/usr/src/cmd/cmd-crypto/digest/Makefile.com
@@ -38,7 +38,7 @@ CFLAGS += $(CCVERBOSE)
CFLAGS64 += $(CCVERBOSE)
CPPFLAGS +=-D_FILE_OFFSET_BITS=64
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
LDLIBS += -lkmf -lpkcs11 -lcryptoutil
diff --git a/usr/src/cmd/cmd-crypto/pktool/Makefile b/usr/src/cmd/cmd-crypto/pktool/Makefile
index 45a0113ca3..b1746c2a14 100644
--- a/usr/src/cmd/cmd-crypto/pktool/Makefile
+++ b/usr/src/cmd/cmd-crypto/pktool/Makefile
@@ -53,7 +53,7 @@ CPPFLAGS += -I. -I$(KMFDIR)/include -I$(ADJUNCT_PROTO)/usr/include/libxml2 \
-I$(KMFDIR)/ber_der/inc
CFLAGS += $(CCVERBOSE) -DDEBUG
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-unused-label
# not linted, too much mess, but it should be
diff --git a/usr/src/cmd/cmd-inet/lib/ipmgmtd/Makefile b/usr/src/cmd/cmd-inet/lib/ipmgmtd/Makefile
index f150602cc9..499d0b89b0 100644
--- a/usr/src/cmd/cmd-inet/lib/ipmgmtd/Makefile
+++ b/usr/src/cmd/cmd-inet/lib/ipmgmtd/Makefile
@@ -41,7 +41,7 @@ ROOTCFGFILES= $(CFGFILES:%=$(ROOTCFGDIR)/%)
ROOTMANIFESTDIR= $(ROOTSVCNETWORK)
CERRWARN += -_gcc=-Wno-switch
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
$(ROOTCFGFILES) := OWNER= ipadm
$(ROOTCFGFILES) := GROUP= sys
diff --git a/usr/src/cmd/cmd-inet/lib/nwamd/Makefile b/usr/src/cmd/cmd-inet/lib/nwamd/Makefile
index 160b027d0c..b0cd337547 100644
--- a/usr/src/cmd/cmd-inet/lib/nwamd/Makefile
+++ b/usr/src/cmd/cmd-inet/lib/nwamd/Makefile
@@ -54,7 +54,7 @@ LDLIBS += -ldhcpagent -ldhcputil -ldladm -ldlpi -lgen \
-linetutil -lipadm -lkstat -lnsl -lnvpair -lnwam \
-lsecdb -lscf -lsocket -lsysevent -lumem -luutil
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-parentheses
CERRWARN += -_gcc=-Wno-switch
CERRWARN += -_gcc=-Wno-unused-label
diff --git a/usr/src/cmd/cmd-inet/usr.bin/Makefile b/usr/src/cmd/cmd-inet/usr.bin/Makefile
index 6e47c6e6f0..ec3c38d215 100644
--- a/usr/src/cmd/cmd-inet/usr.bin/Makefile
+++ b/usr/src/cmd/cmd-inet/usr.bin/Makefile
@@ -73,7 +73,7 @@ $(ROOTSUIDPROG) := FILEMODE= 04555
CPPFLAGS += -DSYSV -DSTRNET -DBSD_COMP -I$(CMDINETCOMMONDIR)
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-unused-function
ruptime := SMOFF += leaks
diff --git a/usr/src/cmd/cmd-inet/usr.bin/ftp/Makefile b/usr/src/cmd/cmd-inet/usr.bin/ftp/Makefile
index b2cf966be6..67a3656e18 100644
--- a/usr/src/cmd/cmd-inet/usr.bin/ftp/Makefile
+++ b/usr/src/cmd/cmd-inet/usr.bin/ftp/Makefile
@@ -42,7 +42,7 @@ CPPFLAGS += -D_FILE_OFFSET_BITS=64 \
CERRWARN += -_gcc=-Wno-parentheses
CERRWARN += -_gcc=-Wno-clobbered
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-address
# not linted
diff --git a/usr/src/cmd/cmd-inet/usr.bin/nc/Makefile b/usr/src/cmd/cmd-inet/usr.bin/nc/Makefile
index b93a1c9132..25d04d6448 100644
--- a/usr/src/cmd/cmd-inet/usr.bin/nc/Makefile
+++ b/usr/src/cmd/cmd-inet/usr.bin/nc/Makefile
@@ -31,7 +31,7 @@ SRCS= $(OBJS:%.o=%.c)
include ../../../Makefile.cmd
LDLIBS += -lresolv -lsocket
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
.KEEP_STATE:
diff --git a/usr/src/cmd/cmd-inet/usr.bin/netstat/Makefile b/usr/src/cmd/cmd-inet/usr.bin/netstat/Makefile
index e4de485e4e..9c2565656f 100644
--- a/usr/src/cmd/cmd-inet/usr.bin/netstat/Makefile
+++ b/usr/src/cmd/cmd-inet/usr.bin/netstat/Makefile
@@ -46,7 +46,7 @@ OBJS= $(LOCALOBJS) $(COMMONOBJS) $(STAT_COMMON_OBJS)
SRCS= $(LOCALSRCS) $(COMMONSRCS) $(STAT_COMMON_SRCS)
CPPFLAGS += -DNDEBUG -I$(CMDINETCOMMONDIR) -I$(STATCOMMONDIR)
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-parentheses
LDLIBS += -ldhcpagent -lsocket -lnsl -lkstat -ltsnet -ltsol
diff --git a/usr/src/cmd/cmd-inet/usr.bin/pppd/Makefile b/usr/src/cmd/cmd-inet/usr.bin/pppd/Makefile
index 234a87f7d6..a5afd14897 100644
--- a/usr/src/cmd/cmd-inet/usr.bin/pppd/Makefile
+++ b/usr/src/cmd/cmd-inet/usr.bin/pppd/Makefile
@@ -51,7 +51,7 @@ OBJS += chap_ms.o
EXOBJS += mschap_test.o
CLOBBERFILES += mschap_test
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# main() is too hairy for smatch
SMATCH=off
diff --git a/usr/src/cmd/cmd-inet/usr.bin/pppdump/Makefile b/usr/src/cmd/cmd-inet/usr.bin/pppdump/Makefile
index 7908ed7488..959f554636 100644
--- a/usr/src/cmd/cmd-inet/usr.bin/pppdump/Makefile
+++ b/usr/src/cmd/cmd-inet/usr.bin/pppdump/Makefile
@@ -15,7 +15,7 @@ CPPFLAGS += -DPPP_DEFS_IN_NET
CERRWARN += -_gcc=-Wno-implicit-function-declaration
CERRWARN += -_gcc=-Wno-parentheses
CERRWARN += -_gcc=-Wno-unused-variable
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/cmd-inet/usr.bin/rdist/Makefile b/usr/src/cmd/cmd-inet/usr.bin/rdist/Makefile
index 837a6145e2..298c1b5793 100644
--- a/usr/src/cmd/cmd-inet/usr.bin/rdist/Makefile
+++ b/usr/src/cmd/cmd-inet/usr.bin/rdist/Makefile
@@ -53,7 +53,7 @@ CERRWARN += -_gcc=-Wno-unused-function
CERRWARN += -_gcc=-Wno-unused-label
CERRWARN += -_gcc=-Wno-parentheses
CERRWARN += -_gcc=-Wno-clobbered
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/cmd-inet/usr.bin/talk/Makefile b/usr/src/cmd/cmd-inet/usr.bin/talk/Makefile
index d0565eec44..ed46caa121 100644
--- a/usr/src/cmd/cmd-inet/usr.bin/talk/Makefile
+++ b/usr/src/cmd/cmd-inet/usr.bin/talk/Makefile
@@ -39,7 +39,7 @@ POFILE= talk.po
#
CFLAGS += $(CCVERBOSE)
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CPPFLAGS += -DSYSV -DSTRNET -DBSD_COMP
LDLIBS += -lcurses -lsocket -lnsl
diff --git a/usr/src/cmd/cmd-inet/usr.lib/ilbd/Makefile b/usr/src/cmd/cmd-inet/usr.lib/ilbd/Makefile
index 2feba006c7..8de83d6243 100644
--- a/usr/src/cmd/cmd-inet/usr.lib/ilbd/Makefile
+++ b/usr/src/cmd/cmd-inet/usr.lib/ilbd/Makefile
@@ -51,7 +51,7 @@ CPPFLAGS += -I$(LIB_INC)
CPPFLAGS += -I$(SRC)/uts/common
CERRWARN += -_gcc=-Wno-switch
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-unused-label
# not linted
diff --git a/usr/src/cmd/cmd-inet/usr.lib/ilbd/ilb/Makefile b/usr/src/cmd/cmd-inet/usr.lib/ilbd/ilb/Makefile
index 30504eb2f5..19dc47e456 100644
--- a/usr/src/cmd/cmd-inet/usr.lib/ilbd/ilb/Makefile
+++ b/usr/src/cmd/cmd-inet/usr.lib/ilbd/ilb/Makefile
@@ -36,7 +36,7 @@ all: $(PROG)
include ../../Makefile.lib
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
ROOTLIBINETILB = $(ROOTLIBINET)/ilb
ROOTLIBINETILBPROG = $(PROG:%=$(ROOTLIBINETILB)/%)
diff --git a/usr/src/cmd/cmd-inet/usr.lib/in.mpathd/Makefile b/usr/src/cmd/cmd-inet/usr.lib/in.mpathd/Makefile
index f28c630ac3..3668af100b 100644
--- a/usr/src/cmd/cmd-inet/usr.lib/in.mpathd/Makefile
+++ b/usr/src/cmd/cmd-inet/usr.lib/in.mpathd/Makefile
@@ -46,7 +46,7 @@ CPPFLAGS += -D_XOPEN_SOURCE=600 -D__EXTENSIONS__
LDLIBS += -lsocket -lnsl -lsysevent -lnvpair -lipmp -linetutil -ldlpi
LINTFLAGS += -erroff=E_INCONS_ARG_DECL2 -erroff=E_INCONS_ARG_USED2
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
#
# Instrument in.mpathd with CTF data to ease debugging.
diff --git a/usr/src/cmd/cmd-inet/usr.lib/in.ndpd/Makefile b/usr/src/cmd/cmd-inet/usr.lib/in.ndpd/Makefile
index 4b8faf3a3f..904871239a 100644
--- a/usr/src/cmd/cmd-inet/usr.lib/in.ndpd/Makefile
+++ b/usr/src/cmd/cmd-inet/usr.lib/in.ndpd/Makefile
@@ -58,7 +58,7 @@ LINTFLAGS += -erroff=E_INCONS_ARG_DECL2 -erroff=E_INCONS_VAL_TYPE_DECL2
LINTFLAGS += -erroff=E_BAD_PTR_CAST_ALIGN
CERRWARN += -_gcc=-Wno-switch
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/cmd-inet/usr.lib/mdnsd/Makefile b/usr/src/cmd/cmd-inet/usr.lib/mdnsd/Makefile
index afac8667f2..5424242b0d 100644
--- a/usr/src/cmd/cmd-inet/usr.lib/mdnsd/Makefile
+++ b/usr/src/cmd/cmd-inet/usr.lib/mdnsd/Makefile
@@ -46,7 +46,7 @@ include ../../../Makefile.cmd
CERRWARN += -_gcc=-Wno-unused-variable
CERRWARN += -_gcc=-Wno-implicit-function-declaration
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/cmd-inet/usr.lib/ncaconfd/Makefile b/usr/src/cmd/cmd-inet/usr.lib/ncaconfd/Makefile
index 81233c5994..1a447f1888 100644
--- a/usr/src/cmd/cmd-inet/usr.lib/ncaconfd/Makefile
+++ b/usr/src/cmd/cmd-inet/usr.lib/ncaconfd/Makefile
@@ -36,7 +36,7 @@ include ../Makefile.lib
LDLIBS += -lsocket -lnsl
CPPFLAGS += -I$(SRC)/uts/common/inet/nca
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
POFILE = ${PROG}.po
diff --git a/usr/src/cmd/cmd-inet/usr.lib/vrrpd/Makefile b/usr/src/cmd/cmd-inet/usr.lib/vrrpd/Makefile
index 0039ea5f6a..2faa3bf02b 100644
--- a/usr/src/cmd/cmd-inet/usr.lib/vrrpd/Makefile
+++ b/usr/src/cmd/cmd-inet/usr.lib/vrrpd/Makefile
@@ -47,7 +47,7 @@ CPPFLAGS += -D_XOPEN_SOURCE=600 -D__EXTENSIONS__
LDLIBS += -lvrrpadm -lsocket -lnsl -ldladm -linetutil -lipadm -lsysevent -lnvpair -lsecdb
LINTFLAGS += -erroff=E_INCONS_ARG_DECL2 -erroff=E_INCONS_ARG_USED2
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
#
# Instrument vrrpd with CTF data to ease debugging.
diff --git a/usr/src/cmd/cmd-inet/usr.sbin/Makefile b/usr/src/cmd/cmd-inet/usr.sbin/Makefile
index 2b33026630..98971bf5b0 100644
--- a/usr/src/cmd/cmd-inet/usr.sbin/Makefile
+++ b/usr/src/cmd/cmd-inet/usr.sbin/Makefile
@@ -102,7 +102,7 @@ COMMONSRCS= $(COMMONOBJS:%.o=$(CMDINETCOMMONDIR)/%.c)
SRCS+= $(COMMONSRCS)
CERRWARN += -_gcc=-Wno-implicit-function-declaration
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-unused-variable
CERRWARN += -_gcc=-Wno-unused-function
CERRWARN += -_gcc=-Wno-parentheses
diff --git a/usr/src/cmd/cmd-inet/usr.sbin/ifconfig/Makefile b/usr/src/cmd/cmd-inet/usr.sbin/ifconfig/Makefile
index 2f5b321f63..dfdb22cbde 100644
--- a/usr/src/cmd/cmd-inet/usr.sbin/ifconfig/Makefile
+++ b/usr/src/cmd/cmd-inet/usr.sbin/ifconfig/Makefile
@@ -37,7 +37,7 @@ COMMONSRCS= $(CMDINETCOMMONDIR)/$(COMMONOBJS:%.o=%.c)
SRCS= $(LOCALSRCS) $(COMMONSRCS)
CPPFLAGS += -I$(CMDINETCOMMONDIR) -I$(SRC)/common/net/dhcp
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-parentheses
LDLIBS += -ldhcpagent -ldlpi -linetutil -lipmp -ldladm -lipadm
LINTFLAGS += -m
diff --git a/usr/src/cmd/cmd-inet/usr.sbin/ilbadm/Makefile b/usr/src/cmd/cmd-inet/usr.sbin/ilbadm/Makefile
index 73b2b67758..6ecf5e326f 100644
--- a/usr/src/cmd/cmd-inet/usr.sbin/ilbadm/Makefile
+++ b/usr/src/cmd/cmd-inet/usr.sbin/ilbadm/Makefile
@@ -38,7 +38,7 @@ CPPFLAGS += -I$(SRC)/lib/libilb/common -I$(SRC)/uts/common
CERRWARN += -_gcc=-Wno-switch
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/cmd-inet/usr.sbin/in.routed/Makefile b/usr/src/cmd/cmd-inet/usr.sbin/in.routed/Makefile
index 022fc53a8b..65077da947 100644
--- a/usr/src/cmd/cmd-inet/usr.sbin/in.routed/Makefile
+++ b/usr/src/cmd/cmd-inet/usr.sbin/in.routed/Makefile
@@ -39,7 +39,7 @@ LINTFLAGS += -erroff=E_FUNC_DECL_VAR_ARG2 -erroff=E_INCONS_VAL_TYPE_DECL2 \
CPPFLAGS += $(_D_XOPEN_EXTN)
CFLAGS += $(CCVERBOSE)
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/cmd-inet/usr.sbin/in.talkd/Makefile b/usr/src/cmd/cmd-inet/usr.sbin/in.talkd/Makefile
index 27e0ea85ab..b61e615607 100644
--- a/usr/src/cmd/cmd-inet/usr.sbin/in.talkd/Makefile
+++ b/usr/src/cmd/cmd-inet/usr.sbin/in.talkd/Makefile
@@ -35,7 +35,7 @@ $(ROOTMANIFEST) := FILEMODE= 444
CFLAGS += $(CCVERBOSE)
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
LDLIBS += -lsocket -lnsl
.KEEP_STATE:
diff --git a/usr/src/cmd/cmd-inet/usr.sbin/inetadm/Makefile b/usr/src/cmd/cmd-inet/usr.sbin/inetadm/Makefile
index 55cbbf7aab..e79bc10e1c 100644
--- a/usr/src/cmd/cmd-inet/usr.sbin/inetadm/Makefile
+++ b/usr/src/cmd/cmd-inet/usr.sbin/inetadm/Makefile
@@ -33,7 +33,7 @@ include ../../../Makefile.cmd
LDLIBS += -lscf -luutil -linetsvc
CERRWARN += -_gcc=-Wno-switch
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
lint := LINTFLAGS = -ux
diff --git a/usr/src/cmd/cmd-inet/usr.sbin/inetconv/Makefile b/usr/src/cmd/cmd-inet/usr.sbin/inetconv/Makefile
index acd230f592..9f6c5f267d 100644
--- a/usr/src/cmd/cmd-inet/usr.sbin/inetconv/Makefile
+++ b/usr/src/cmd/cmd-inet/usr.sbin/inetconv/Makefile
@@ -29,7 +29,7 @@ PROG = inetconv
include ../../../Makefile.cmd
LDLIBS += -lscf -linetsvc
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
.KEEP_STATE:
diff --git a/usr/src/cmd/cmd-inet/usr.sbin/ipmpstat/Makefile b/usr/src/cmd/cmd-inet/usr.sbin/ipmpstat/Makefile
index cb0ca92b43..df83fc4c15 100644
--- a/usr/src/cmd/cmd-inet/usr.sbin/ipmpstat/Makefile
+++ b/usr/src/cmd/cmd-inet/usr.sbin/ipmpstat/Makefile
@@ -29,7 +29,7 @@ ROOTUSRSBINLINKS = $(PROG:%=$(ROOTUSRSBIN)/%)
include $(SRC)/cmd/Makefile.cmd
CSTD = $(CSTD_GNU99)
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
LDLIBS += -lipmp -lsocket -lsysevent -lnvpair -lofmt
XGETFLAGS += -a -x $(PROG).xcl
diff --git a/usr/src/cmd/cmd-inet/usr.sbin/ipqosconf/Makefile b/usr/src/cmd/cmd-inet/usr.sbin/ipqosconf/Makefile
index 485110bb74..90c4570bdd 100644
--- a/usr/src/cmd/cmd-inet/usr.sbin/ipqosconf/Makefile
+++ b/usr/src/cmd/cmd-inet/usr.sbin/ipqosconf/Makefile
@@ -51,7 +51,7 @@ $(ROOTLIBIPQOSCONFTYPES) := FILEMODE= 0444
CPPFLAGS += -D__EXTENSIONS__
CERRWARN += -_gcc=-Wno-switch
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/cmd-inet/usr.sbin/ipsecutils/Makefile b/usr/src/cmd/cmd-inet/usr.sbin/ipsecutils/Makefile
index 3cbe3dbb38..80e4a9ecf2 100644
--- a/usr/src/cmd/cmd-inet/usr.sbin/ipsecutils/Makefile
+++ b/usr/src/cmd/cmd-inet/usr.sbin/ipsecutils/Makefile
@@ -57,7 +57,7 @@ CLEANFILES += $(PROG) $(POFILES)
CPPFLAGS += -DSYSV -DBSD_COMP -I$(CMDINETCOMMONDIR) -I.
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-switch
# not linted
diff --git a/usr/src/cmd/cmd-inet/usr.sbin/kssl/kssladm/Makefile b/usr/src/cmd/cmd-inet/usr.sbin/kssl/kssladm/Makefile
index 4abf5b25f6..00f4ffdb2e 100644
--- a/usr/src/cmd/cmd-inet/usr.sbin/kssl/kssladm/Makefile
+++ b/usr/src/cmd/cmd-inet/usr.sbin/kssl/kssladm/Makefile
@@ -42,7 +42,7 @@ ROOTUSRLIBPROG = $(PROG:%=$(ROOTLIB)/%)
.KEEP_STATE:
CFLAGS += $(CCVERBOSE)
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-address
LDLIBS += -lkmf -lpkcs11 -lcryptoutil -lnsl -lsocket
diff --git a/usr/src/cmd/cmd-inet/usr.sbin/nwamadm/Makefile b/usr/src/cmd/cmd-inet/usr.sbin/nwamadm/Makefile
index e3984bdda6..3b0f69b0d7 100644
--- a/usr/src/cmd/cmd-inet/usr.sbin/nwamadm/Makefile
+++ b/usr/src/cmd/cmd-inet/usr.sbin/nwamadm/Makefile
@@ -33,7 +33,7 @@ XGETFLAGS += -a -x $(PROG).xcl
LDLIBS += -lofmt -linetutil -lnsl -lnwam -lumem -lscf
CERRWARN += -_gcc=-Wno-switch
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/cmd-inet/usr.sbin/nwamcfg/Makefile b/usr/src/cmd/cmd-inet/usr.sbin/nwamcfg/Makefile
index 25d961bdb1..6b9572f233 100644
--- a/usr/src/cmd/cmd-inet/usr.sbin/nwamcfg/Makefile
+++ b/usr/src/cmd/cmd-inet/usr.sbin/nwamcfg/Makefile
@@ -39,7 +39,7 @@ CLEANFILES += nwamcfg_lex.c nwamcfg_grammar.tab.c nwamcfg_grammar.tab.h
CLEANFILES += $(PROG).ln
CERRWARN += -_gcc=-Wno-switch
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-unused-variable
CERRWARN += -_gcc=-Wno-unused-label
CERRWARN += -_gcc=-Wno-implicit-function-declaration
diff --git a/usr/src/cmd/cmd-inet/usr.sbin/routeadm/Makefile b/usr/src/cmd/cmd-inet/usr.sbin/routeadm/Makefile
index bd235b77b9..1226ab79e1 100644
--- a/usr/src/cmd/cmd-inet/usr.sbin/routeadm/Makefile
+++ b/usr/src/cmd/cmd-inet/usr.sbin/routeadm/Makefile
@@ -50,7 +50,7 @@ ROOTUSRSBINLINKS= $(PROG:%=$(ROOTUSRSBIN)/%)
CPPFLAGS += -I../../../../common/svc -I$(CMDINETCOMMONDIR)
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
$(NOT_RELEASE_BUILD)CPPFLAGS += -DDEBUG
LDLIBS += -lscf -luutil -lsocket
diff --git a/usr/src/cmd/cmd-inet/usr.sbin/snoop/Makefile b/usr/src/cmd/cmd-inet/usr.sbin/snoop/Makefile
index 88a13c99e1..4e3dd8259a 100644
--- a/usr/src/cmd/cmd-inet/usr.sbin/snoop/Makefile
+++ b/usr/src/cmd/cmd-inet/usr.sbin/snoop/Makefile
@@ -55,7 +55,7 @@ LDLIBS += -ldhcputil -ldlpi -lsocket -lnsl -ltsol -luuid
LDFLAGS += $(MAPFILE.NGB:%=-M%)
CERRWARN += -_gcc=-Wno-switch
CERRWARN += -_gcc=-Wno-implicit-function-declaration
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-clobbered
CERRWARN += -_gcc=-Wno-unused-value
CERRWARN += -_gcc=-Wno-parentheses
diff --git a/usr/src/cmd/cmd-inet/usr.sbin/traceroute/Makefile b/usr/src/cmd/cmd-inet/usr.sbin/traceroute/Makefile
index dac6d08a21..87ff688b17 100644
--- a/usr/src/cmd/cmd-inet/usr.sbin/traceroute/Makefile
+++ b/usr/src/cmd/cmd-inet/usr.sbin/traceroute/Makefile
@@ -51,7 +51,7 @@ CPPFLAGS += -D_XOPEN_SOURCE=500 -D__EXTENSIONS__
LINTFLAGS += -erroff=E_FUNC_DECL_VAR_ARG2 -erroff=E_INCONS_ARG_DECL2 \
-erroff=E_INCONS_ARG_USED2 -erroff=E_INCONS_VAL_TYPE_DECL2
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-clobbered
.KEEP_STATE:
diff --git a/usr/src/cmd/consadm/Makefile.com b/usr/src/cmd/consadm/Makefile.com
index 135b5d9a8f..6c11b2504f 100644
--- a/usr/src/cmd/consadm/Makefile.com
+++ b/usr/src/cmd/consadm/Makefile.com
@@ -33,7 +33,7 @@ OBJS= $(COMMONOBJS)
include ../../Makefile.cmd
CFLAGS += $(CCVERBOSE)
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CPPFLAGS +=
FILEMODE = 0555
diff --git a/usr/src/cmd/cpc/cpustat/Makefile b/usr/src/cmd/cpc/cpustat/Makefile
index edff7bd831..6864a2b55d 100644
--- a/usr/src/cmd/cpc/cpustat/Makefile
+++ b/usr/src/cmd/cpc/cpustat/Makefile
@@ -37,7 +37,7 @@ STAT_COMMON_SRCS = $(STAT_COMMON_OBJS:%.o=$(STATCOMMONDIR)/%.c)
SRCS += $(STAT_COMMON_SRCS)
CFLAGS += $(CCVERBOSE) $(CTF_FLAGS)
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CPPFLAGS += -D_REENTRANT -I$(SRC)/lib/libcpc/common -I$(STATCOMMONDIR)
LDLIBS += -lcpc -lkstat
diff --git a/usr/src/cmd/cpio/Makefile b/usr/src/cmd/cpio/Makefile
index ccad9b0efc..18c3a18cca 100644
--- a/usr/src/cmd/cpio/Makefile
+++ b/usr/src/cmd/cpio/Makefile
@@ -31,7 +31,7 @@ SRCS= $(OBJS:%.o=%.c)
include ../Makefile.cmd
CPPFLAGS += -D_FILE_OFFSET_BITS=64 -DSOLARIS_PRIVS
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/cron/Makefile b/usr/src/cmd/cron/Makefile
index c45159969e..bfd9e19840 100644
--- a/usr/src/cmd/cron/Makefile
+++ b/usr/src/cmd/cron/Makefile
@@ -37,7 +37,7 @@ ROOTMETHOD = $(ROOTLIBSVCMETHOD)/svc-cron
CPPFLAGS += -D_FILE_OFFSET_BITS=64 -I $(SRC)/common/util
CERRWARN += -_gcc=-Wno-parentheses
CERRWARN += -_gcc=-Wno-unused-label
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-unused-variable
CERRWARN += -_gcc=-Wno-unused-value
diff --git a/usr/src/cmd/csh/i386/Makefile b/usr/src/cmd/csh/i386/Makefile
index c019a85dee..581e79cbf3 100644
--- a/usr/src/cmd/csh/i386/Makefile
+++ b/usr/src/cmd/csh/i386/Makefile
@@ -26,7 +26,7 @@ CPPFLAGS += -D_FILE_OFFSET_BITS=64
LDLIBS += -lcurses
CERRWARN += -_gcc=-Wno-implicit-function-declaration
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-parentheses
CERRWARN += -_gcc=-Wno-implicit-int
CERRWARN += -_gcc=-Wno-unused-function
diff --git a/usr/src/cmd/csh/sparc/Makefile b/usr/src/cmd/csh/sparc/Makefile
index df03abd8a7..7f1262b278 100644
--- a/usr/src/cmd/csh/sparc/Makefile
+++ b/usr/src/cmd/csh/sparc/Makefile
@@ -23,7 +23,7 @@ CPPFLAGS= -I. $(DEFS) $(MBCHAR) $(CPPFLAGS.master)
CPPFLAGS += -I../../sh
CPPFLAGS += -D_FILE_OFFSET_BITS=64
CERRWARN += -_gcc=-Wno-implicit-function-declaration
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-parentheses
CERRWARN += -_gcc=-Wno-implicit-int
CERRWARN += -_gcc=-Wno-unused-function
diff --git a/usr/src/cmd/csplit/Makefile b/usr/src/cmd/csplit/Makefile
index 66e008958a..a9c5fd8d99 100644
--- a/usr/src/cmd/csplit/Makefile
+++ b/usr/src/cmd/csplit/Makefile
@@ -33,7 +33,7 @@ XGETFLAGS += -a -x csplit.xcl
CPPFLAGS += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE=1
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
.KEEP_STATE:
diff --git a/usr/src/cmd/ctrun/Makefile b/usr/src/cmd/ctrun/Makefile
index 318c7e0874..2f372bbdce 100644
--- a/usr/src/cmd/ctrun/Makefile
+++ b/usr/src/cmd/ctrun/Makefile
@@ -30,7 +30,7 @@ include ../Makefile.cmd
CFLAGS += $(CCVERBOSE)
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
LDLIBS += -lcontract -luutil
.KEEP_STATE:
diff --git a/usr/src/cmd/dc/Makefile b/usr/src/cmd/dc/Makefile
index 58ddd81f1a..27f3520005 100644
--- a/usr/src/cmd/dc/Makefile
+++ b/usr/src/cmd/dc/Makefile
@@ -36,7 +36,7 @@ LDFLAGS += $(MAPFILE.NGB:%=-M%)
CERRWARN += -_gcc=-Wno-implicit-function-declaration
CERRWARN += -_gcc=-Wno-unused-value
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/dcs/sparc/sun4u/Makefile b/usr/src/cmd/dcs/sparc/sun4u/Makefile
index 0abbf69042..d5861b82b2 100644
--- a/usr/src/cmd/dcs/sparc/sun4u/Makefile
+++ b/usr/src/cmd/dcs/sparc/sun4u/Makefile
@@ -90,7 +90,7 @@ LINT_FLAGS= -c -Nlevel=4 -Ncheck $($(CONCURR_MODE)_FLAGS)
XGETFLAGS += -a -s -x $(PROG).xcl
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
#
# LIBRARIES:
diff --git a/usr/src/cmd/dd/Makefile b/usr/src/cmd/dd/Makefile
index 1a459b9e94..7462e58d72 100644
--- a/usr/src/cmd/dd/Makefile
+++ b/usr/src/cmd/dd/Makefile
@@ -29,7 +29,7 @@ PROG= dd
include ../Makefile.cmd
CFLAGS += $(CCVERBOSE)
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CPPFLAGS += -D_FILE_OFFSET_BITS=64
LDLIBS += -lcmdutils
diff --git a/usr/src/cmd/devfsadm/Makefile.com b/usr/src/cmd/devfsadm/Makefile.com
index 17129c7d7b..4332220e5f 100644
--- a/usr/src/cmd/devfsadm/Makefile.com
+++ b/usr/src/cmd/devfsadm/Makefile.com
@@ -97,7 +97,7 @@ LINTFLAGS += -erroff=E_NAME_USED_NOT_DEF2
LINTFLAGS += -erroff=E_NAME_DEF_NOT_USED2
LINTFLAGS += -erroff=E_NAME_MULTIPLY_DEF2
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-char-subscripts
CERRWARN += -_gcc=-Wno-parentheses
diff --git a/usr/src/cmd/devinfo/Makefile b/usr/src/cmd/devinfo/Makefile
index 58b5c56131..f262fe3359 100644
--- a/usr/src/cmd/devinfo/Makefile
+++ b/usr/src/cmd/devinfo/Makefile
@@ -32,7 +32,7 @@ include ../Makefile.cmd
LDLIBS += -ladm -lefi
CFLAGS += $(CCVERBOSE)
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
.KEEP_STATE:
diff --git a/usr/src/cmd/devmgmt/cmds/Makefile b/usr/src/cmd/devmgmt/cmds/Makefile
index 6eaec76115..1ef64c363b 100644
--- a/usr/src/cmd/devmgmt/cmds/Makefile
+++ b/usr/src/cmd/devmgmt/cmds/Makefile
@@ -37,7 +37,7 @@ PROG = devattr devreserv getvol putdgrp devfree getdev listdgrp getdgrp \
LDLIBS += -ladm
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
SMOFF += signed
diff --git a/usr/src/cmd/dfs.cmds/dfshares/Makefile b/usr/src/cmd/dfs.cmds/dfshares/Makefile
index 7134e8e4d7..ac05242ffd 100644
--- a/usr/src/cmd/dfs.cmds/dfshares/Makefile
+++ b/usr/src/cmd/dfs.cmds/dfshares/Makefile
@@ -34,7 +34,7 @@ CFLAGS += -s
include ../../Makefile.cmd
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
.KEEP_STATE:
diff --git a/usr/src/cmd/dfs.cmds/sharectl/Makefile.com b/usr/src/cmd/dfs.cmds/sharectl/Makefile.com
index 052b0100d7..0a5d9047ca 100644
--- a/usr/src/cmd/dfs.cmds/sharectl/Makefile.com
+++ b/usr/src/cmd/dfs.cmds/sharectl/Makefile.com
@@ -40,7 +40,7 @@ MYCPPFLAGS = -I.. -I../../sharemgr
CPPFLAGS += $(MYCPPFLAGS)
LDLIBS += -lshare -lumem
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
SRCS = $(SHARECTL_SRC)
OBJS = $(SHARECTL_OBJ)
diff --git a/usr/src/cmd/dfs.cmds/sharemgr/Makefile.com b/usr/src/cmd/dfs.cmds/sharemgr/Makefile.com
index 49272439c6..3c5567cfbe 100644
--- a/usr/src/cmd/dfs.cmds/sharemgr/Makefile.com
+++ b/usr/src/cmd/dfs.cmds/sharemgr/Makefile.com
@@ -43,7 +43,7 @@ LDLIBS += -lshare -lscf -lsecdb -lumem
all install := LDLIBS += -lxml2
LINTFLAGS += -u
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
POFILES = $(SRCS:.c=.po)
POFILE = sharemgr.po
diff --git a/usr/src/cmd/diff/Makefile b/usr/src/cmd/diff/Makefile
index cfa0ab04d2..a29c75c671 100644
--- a/usr/src/cmd/diff/Makefile
+++ b/usr/src/cmd/diff/Makefile
@@ -31,7 +31,7 @@ LIBDIFFH= diffh
include ../Makefile.cmd
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-address
#
diff --git a/usr/src/cmd/dis/Makefile b/usr/src/cmd/dis/Makefile
index c35932248f..bd56703ca3 100644
--- a/usr/src/cmd/dis/Makefile
+++ b/usr/src/cmd/dis/Makefile
@@ -32,7 +32,7 @@ SRCS= $(OBJS:%.o=%.c)
include ../Makefile.cmd
LDLIBS += -ldisasm -luutil -lelf -ldemangle-sys
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
.KEEP_STATE:
diff --git a/usr/src/cmd/dispadmin/Makefile b/usr/src/cmd/dispadmin/Makefile
index 6df5bbca3f..93e4ab653d 100644
--- a/usr/src/cmd/dispadmin/Makefile
+++ b/usr/src/cmd/dispadmin/Makefile
@@ -43,7 +43,7 @@ ROOTETCFILES= $(ETCFILES:%=$(ROOTETC)/%)
include ../Makefile.cmd
CFLAGS += $(CCVERBOSE)
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
ROOTDIR= $(ROOT)/usr/lib/class
ROOTDIRS= $(ROOTDIR) \
diff --git a/usr/src/cmd/dladm/Makefile b/usr/src/cmd/dladm/Makefile
index 734ecd8268..8c93d1008a 100644
--- a/usr/src/cmd/dladm/Makefile
+++ b/usr/src/cmd/dladm/Makefile
@@ -43,7 +43,7 @@ LDLIBS += $(ZLAZYLOAD) -lrstp $(ZNOLAZYLOAD) -lnsl -lumem -lcustr
CERRWARN += -_gcc=-Wno-switch
CERRWARN += -_gcc=-Wno-unused-label
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
SMOFF += snprintf_overflow
diff --git a/usr/src/cmd/dlmgmtd/Makefile b/usr/src/cmd/dlmgmtd/Makefile
index ee51fd8cd2..91fa6db521 100644
--- a/usr/src/cmd/dlmgmtd/Makefile
+++ b/usr/src/cmd/dlmgmtd/Makefile
@@ -41,7 +41,7 @@ $(ROOTCFGDIR)/datalink.conf := FILEMODE= 644
LDLIBS += -ldladm -ldlpi -lavl -lnvpair -lsysevent -lcontract
CERRWARN += -_gcc=-Wno-unused-label
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
#
# Instrument dlmgmtd with CTF data to ease debugging.
diff --git a/usr/src/cmd/dlstat/Makefile b/usr/src/cmd/dlstat/Makefile
index bd274d10c0..75bf5acc60 100644
--- a/usr/src/cmd/dlstat/Makefile
+++ b/usr/src/cmd/dlstat/Makefile
@@ -33,7 +33,7 @@ include ../Makefile.cmd
CERRWARN += -_gcc=-Wno-implicit-function-declaration
CERRWARN += -_gcc=-Wno-unused-label
CERRWARN += -_gcc=-Wno-unused-variable
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/du/Makefile b/usr/src/cmd/du/Makefile
index 35b414e6cd..695eb11993 100644
--- a/usr/src/cmd/du/Makefile
+++ b/usr/src/cmd/du/Makefile
@@ -31,7 +31,7 @@ include ../Makefile.cmd
CFLAGS += $(CCVERBOSE)
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
$(XPG4) := CFLAGS += -DXPG4
CPPFLAGS += -D_FILE_OFFSET_BITS=64
POFILE = du_cmd.po
diff --git a/usr/src/cmd/ed/Makefile b/usr/src/cmd/ed/Makefile
index 0c9339377e..d4066cab10 100644
--- a/usr/src/cmd/ed/Makefile
+++ b/usr/src/cmd/ed/Makefile
@@ -42,7 +42,7 @@ CFLAGS += $(CCVERBOSE)
CERRWARN += -_gcc=-Wno-parentheses
CERRWARN += -_gcc=-Wno-unused-variable
CERRWARN += -_gcc=-Wno-unused-function
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/eeprom/Makefile.com b/usr/src/cmd/eeprom/Makefile.com
index eab53d485d..98398f0ab9 100644
--- a/usr/src/cmd/eeprom/Makefile.com
+++ b/usr/src/cmd/eeprom/Makefile.com
@@ -39,7 +39,7 @@ DIRMODE = 755
OBJS = error.o
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-implicit-function-declaration
# not linted
diff --git a/usr/src/cmd/eqn/eqn.d/Makefile b/usr/src/cmd/eqn/eqn.d/Makefile
index 08c289eb03..6c46021db2 100644
--- a/usr/src/cmd/eqn/eqn.d/Makefile
+++ b/usr/src/cmd/eqn/eqn.d/Makefile
@@ -35,7 +35,7 @@ LDFLAGS += $(MAPFILE.NGB:%=-M%)
CERRWARN += -_gcc=-Wno-implicit-function-declaration
CERRWARN += -_gcc=-Wno-unused-label
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/eqn/neqn.d/Makefile b/usr/src/cmd/eqn/neqn.d/Makefile
index a50bc23501..d4993d648d 100644
--- a/usr/src/cmd/eqn/neqn.d/Makefile
+++ b/usr/src/cmd/eqn/neqn.d/Makefile
@@ -28,7 +28,7 @@ CPPFLAGS = -DNEQN -I. -I.. $(CPPFLAGS.master)
LDFLAGS += $(MAPFILE.NGB:%=-M%)
CERRWARN += -_gcc=-Wno-implicit-function-declaration
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-unused-label
# not linted
diff --git a/usr/src/cmd/expr/Makefile b/usr/src/cmd/expr/Makefile
index 08117a45a3..fe0b846109 100644
--- a/usr/src/cmd/expr/Makefile
+++ b/usr/src/cmd/expr/Makefile
@@ -37,7 +37,7 @@ SRCS= expr.c compile.c
include ../Makefile.cmd
CFLAGS += $(CCVERBOSE)
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-extra
# "missing type for func"
SMATCH=off
diff --git a/usr/src/cmd/file/Makefile b/usr/src/cmd/file/Makefile
index f6e0ba9e81..e11a4c0259 100644
--- a/usr/src/cmd/file/Makefile
+++ b/usr/src/cmd/file/Makefile
@@ -41,7 +41,7 @@ include ../Makefile.cmd
CSTD= $(CSTD_GNU99)
C99LMODE= -Xc99=%all
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-type-limits
POFILE= file_all.po
diff --git a/usr/src/cmd/filesync/Makefile b/usr/src/cmd/filesync/Makefile
index df62a44193..50e8a25bb2 100644
--- a/usr/src/cmd/filesync/Makefile
+++ b/usr/src/cmd/filesync/Makefile
@@ -34,7 +34,7 @@ include ../Makefile.cmd
LDLIBS += -lgen
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/find/Makefile b/usr/src/cmd/find/Makefile
index fa138bdd66..1278f68668 100644
--- a/usr/src/cmd/find/Makefile
+++ b/usr/src/cmd/find/Makefile
@@ -37,7 +37,7 @@ CPPFLAGS += -D_FILE_OFFSET_BITS=64 -I $(SRC)/common/util
CERRWARN += -_gcc=-Wno-switch
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
LINTFLAGS += -u
LDLIBS += -lsec
diff --git a/usr/src/cmd/flowstat/Makefile b/usr/src/cmd/flowstat/Makefile
index c568245899..fad17d84ab 100644
--- a/usr/src/cmd/flowstat/Makefile
+++ b/usr/src/cmd/flowstat/Makefile
@@ -37,7 +37,7 @@ LDLIBS += -L$(ROOT)/lib
LDLIBS += -ldladm -lofmt
CERRWARN += -_gcc=-Wno-implicit-function-declaration
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/fm/eversholt/Makefile.esc.com b/usr/src/cmd/fm/eversholt/Makefile.esc.com
index 97d684c164..ffda5bbe11 100644
--- a/usr/src/cmd/fm/eversholt/Makefile.esc.com
+++ b/usr/src/cmd/fm/eversholt/Makefile.esc.com
@@ -46,7 +46,7 @@ $(NOT_RELEASE_BUILD)CPPFLAGS += -DDEBUG
CPPFLAGS += -I$(EVERCMNSRC) -I.
CFLAGS += $(CCVERBOSE)
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-unused-label
CERRWARN += -_gcc=-Wno-parentheses
CERRWARN += -_gcc=-Wno-switch
diff --git a/usr/src/cmd/fm/fmd/Makefile.fmd b/usr/src/cmd/fm/fmd/Makefile.fmd
index 7ad59e737a..caf737e114 100644
--- a/usr/src/cmd/fm/fmd/Makefile.fmd
+++ b/usr/src/cmd/fm/fmd/Makefile.fmd
@@ -120,7 +120,7 @@ CFLAGS += $(CTF_FLAGS) $(CCVERBOSE) $(XSTRCONST)
LINTFLAGS += -mu
CERRWARN += -_gcc=-Wno-switch
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-clobbered
$(RELEASE_BUILD)CERRWARN += -_gcc=-Wno-unused-but-set-variable
CERRWARN += -_gcc=-Wno-unused-variable
diff --git a/usr/src/cmd/fm/fmdump/Makefile.com b/usr/src/cmd/fm/fmdump/Makefile.com
index fbd90d9ea1..37a6f77e1e 100644
--- a/usr/src/cmd/fm/fmdump/Makefile.com
+++ b/usr/src/cmd/fm/fmdump/Makefile.com
@@ -39,7 +39,7 @@ LDLIBS += -L$(ROOT)/usr/lib/fm -lfmd_log -lnvpair -ltopo -lfmd_msg
LDFLAGS += -R/usr/lib/fm
LINTFLAGS += -mnu
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
.NO_PARALLEL:
.PARALLEL: $(OBJS) $(LINTFILES)
diff --git a/usr/src/cmd/fm/fminject/Makefile.com b/usr/src/cmd/fm/fminject/Makefile.com
index c6b60be1cb..bbcbdd095c 100644
--- a/usr/src/cmd/fm/fminject/Makefile.com
+++ b/usr/src/cmd/fm/fminject/Makefile.com
@@ -50,7 +50,7 @@ CLEANFILES += inj_grammar.c inj_grammar.h inj_lex.c y.tab.h y.tab.c
CPPFLAGS += -I. -I../common
CFLAGS += $(CCVERBOSE) $(CTF_FLAGS)
CERRWARN += -_gcc=-Wno-switch
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-type-limits
CERRWARN += -_gcc=-Wno-unused-label
CERRWARN += -_gcc=-Wno-unused-variable
diff --git a/usr/src/cmd/fm/ipmitopo/Makefile.com b/usr/src/cmd/fm/ipmitopo/Makefile.com
index 003331dba6..d82449d1e9 100644
--- a/usr/src/cmd/fm/ipmitopo/Makefile.com
+++ b/usr/src/cmd/fm/ipmitopo/Makefile.com
@@ -41,7 +41,7 @@ CFLAGS += $(CTF_FLAGS) $(CCVERBOSE) $(XSTRCONST)
LDLIBS += -lipmi -lnvpair
LINTFLAGS += -mnu
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
.NO_PARALLEL:
.PARALLEL: $(OBJS) $(LINTFILES)
diff --git a/usr/src/cmd/fm/modules/common/disk-monitor/Makefile b/usr/src/cmd/fm/modules/common/disk-monitor/Makefile
index 3acbf7c3df..11d1642d2d 100644
--- a/usr/src/cmd/fm/modules/common/disk-monitor/Makefile
+++ b/usr/src/cmd/fm/modules/common/disk-monitor/Makefile
@@ -35,7 +35,7 @@ LINTFLAGS += -I. -I$(SRC)/lib/fm/topo/modules/common/disk -L$(ROOT)/usr/lib/fm
CFLAGS += -I. -I$(SRC)/lib/fm/topo/modules/common/disk
LDLIBS += -lsysevent -lnvpair -lsmbios -lcfgadm -ltopo -luutil -lipmi
LDFLAGS += -L$(ROOT)/usr/lib/fm -R/usr/lib/fm
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/fm/modules/common/eversholt/Makefile b/usr/src/cmd/fm/modules/common/eversholt/Makefile
index 0ca385c960..a6397dbd87 100644
--- a/usr/src/cmd/fm/modules/common/eversholt/Makefile
+++ b/usr/src/cmd/fm/modules/common/eversholt/Makefile
@@ -45,7 +45,7 @@ include ../../Makefile.plugin
CPPFLAGS += -DFMAPLUGIN -I$(EVERSRCDIR) -I.
CERRWARN += -_gcc=-Wno-unused-label
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-switch
CERRWARN += -_gcc=-Wno-parentheses
CERRWARN += -_gcc=-Wno-implicit-function-declaration
diff --git a/usr/src/cmd/fm/modules/common/fabric-xlate/Makefile b/usr/src/cmd/fm/modules/common/fabric-xlate/Makefile
index ce58c99d73..5395bfdf06 100644
--- a/usr/src/cmd/fm/modules/common/fabric-xlate/Makefile
+++ b/usr/src/cmd/fm/modules/common/fabric-xlate/Makefile
@@ -41,7 +41,7 @@ LDLIBS += -luutil -lxml2 -L$(ROOTLIB)/fm -ltopo
CERRWARN += -_gcc=-Wno-parentheses
CERRWARN += -_gcc=-Wno-switch
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/fm/modules/common/ip-transport/Makefile b/usr/src/cmd/fm/modules/common/ip-transport/Makefile
index bafe1caba3..fb4db5994f 100644
--- a/usr/src/cmd/fm/modules/common/ip-transport/Makefile
+++ b/usr/src/cmd/fm/modules/common/ip-transport/Makefile
@@ -33,7 +33,7 @@ SRCS = ip.c
include ../../Makefile.plugin
LDLIBS += -lsocket -lnsl
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/fm/modules/common/sw-diag-response/software-diagnosis/Makefile b/usr/src/cmd/fm/modules/common/sw-diag-response/software-diagnosis/Makefile
index 4317a71857..00cd45bb65 100644
--- a/usr/src/cmd/fm/modules/common/sw-diag-response/software-diagnosis/Makefile
+++ b/usr/src/cmd/fm/modules/common/sw-diag-response/software-diagnosis/Makefile
@@ -50,4 +50,4 @@ LINTFLAGS += $(INCS)
LDLIBS += -L$(ROOTLIB)/fm -ltopo -luutil -luuid -lkstat
LDFLAGS += -R/usr/lib/fm
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
diff --git a/usr/src/cmd/fm/modules/sun4u/cpumem-diagnosis/Makefile b/usr/src/cmd/fm/modules/sun4u/cpumem-diagnosis/Makefile
index f54dc1ada9..8569d3628e 100644
--- a/usr/src/cmd/fm/modules/sun4u/cpumem-diagnosis/Makefile
+++ b/usr/src/cmd/fm/modules/sun4u/cpumem-diagnosis/Makefile
@@ -44,5 +44,5 @@ LDLIBS += -L$(ROOT)/usr/lib/fm -lfmd_adm
LDFLAGS += -R/usr/lib/fm
CERRWARN += -_gcc=-Wno-switch
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-char-subscripts
diff --git a/usr/src/cmd/fm/modules/sun4v/etm/Makefile b/usr/src/cmd/fm/modules/sun4v/etm/Makefile
index 2ea2e79af5..0e3e1cc8d1 100644
--- a/usr/src/cmd/fm/modules/sun4v/etm/Makefile
+++ b/usr/src/cmd/fm/modules/sun4v/etm/Makefile
@@ -41,4 +41,4 @@ DYNFLAGS += -R/usr/lib
CERRWARN += -_gcc=-Wno-unused-value
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
diff --git a/usr/src/cmd/fmtmsg/Makefile b/usr/src/cmd/fmtmsg/Makefile
index c5ae7e2c1f..ccc0408f6d 100644
--- a/usr/src/cmd/fmtmsg/Makefile
+++ b/usr/src/cmd/fmtmsg/Makefile
@@ -30,7 +30,7 @@ SRCS= $(OBJS:%.o=%.c)
include ../Makefile.cmd
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
.KEEP_STATE:
diff --git a/usr/src/cmd/format/Makefile b/usr/src/cmd/format/Makefile
index 6c9f7781f7..0c8e32b3c0 100644
--- a/usr/src/cmd/format/Makefile
+++ b/usr/src/cmd/format/Makefile
@@ -46,7 +46,7 @@ DATA= format.dat
include ../Makefile.cmd
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-parentheses
CERRWARN += -_gcc=-Wno-unused-label
CERRWARN += -_gcc=-Wno-clobbered
diff --git a/usr/src/cmd/fs.d/Makefile b/usr/src/cmd/fs.d/Makefile
index 6e692b98cf..1b1939e1f7 100644
--- a/usr/src/cmd/fs.d/Makefile
+++ b/usr/src/cmd/fs.d/Makefile
@@ -85,7 +85,7 @@ CPPFLAGS += -D_LARGEFILE64_SOURCE
CERRWARN += -_gcc=-Wno-implicit-function-declaration
CERRWARN += -_gcc=-Wno-parentheses
CERRWARN += -_gcc=-Wno-unused-variable
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-unused-function
# not linted
diff --git a/usr/src/cmd/fs.d/autofs/Makefile b/usr/src/cmd/fs.d/autofs/Makefile
index c91673ad42..5a3a9fd234 100644
--- a/usr/src/cmd/fs.d/autofs/Makefile
+++ b/usr/src/cmd/fs.d/autofs/Makefile
@@ -95,7 +95,7 @@ CPPFLAGS= -I. -I.. -I../nfs/lib $(CPPFLAGS.master) -D_REENTRANT \
CERRWARN += -_gcc=-Wno-parentheses
CERRWARN += -_gcc=-Wno-unused-variable
CERRWARN += -_gcc=-Wno-switch
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-unused-label
CERRWARN += -_gcc=-Wno-unused-function
diff --git a/usr/src/cmd/fs.d/nfs/lockd/Makefile b/usr/src/cmd/fs.d/nfs/lockd/Makefile
index e013de8aaa..417fc44a0c 100644
--- a/usr/src/cmd/fs.d/nfs/lockd/Makefile
+++ b/usr/src/cmd/fs.d/nfs/lockd/Makefile
@@ -44,7 +44,7 @@ CSTD = $(CSTD_GNU99)
CERRWARN += -_gcc=-Wno-parentheses
CERRWARN += -_gcc=-Wno-switch
CERRWARN += -_gcc=-Wno-unused-variable
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/fs.d/nfs/mount/Makefile b/usr/src/cmd/fs.d/nfs/mount/Makefile
index c461949514..cb6c77044b 100644
--- a/usr/src/cmd/fs.d/nfs/mount/Makefile
+++ b/usr/src/cmd/fs.d/nfs/mount/Makefile
@@ -39,7 +39,7 @@ UNCHECKED_HDRS= webnfs.h
CERRWARN += -_gcc=-Wno-parentheses
CERRWARN += -_gcc=-Wno-switch
CERRWARN += -_gcc=-Wno-unused-variable
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-address
CERRWARN += -_gcc=-Wno-unused-function
diff --git a/usr/src/cmd/fs.d/nfs/mountd/Makefile b/usr/src/cmd/fs.d/nfs/mountd/Makefile
index 36d3d4bca4..2daa3f38ba 100644
--- a/usr/src/cmd/fs.d/nfs/mountd/Makefile
+++ b/usr/src/cmd/fs.d/nfs/mountd/Makefile
@@ -42,7 +42,7 @@ DOBJ = $(DSRC:%.d=%.o)
LDLIBS += -lrpcsvc -lnsl -lbsm -lsocket -ltsnet -ltsol -lnvpair -lscf -lumem
CPPFLAGS += -D_REENTRANT -I../lib
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-switch
# not linted
diff --git a/usr/src/cmd/fs.d/nfs/nfslog/Makefile b/usr/src/cmd/fs.d/nfs/nfslog/Makefile
index 7b2763a8d2..712cf79d53 100644
--- a/usr/src/cmd/fs.d/nfs/nfslog/Makefile
+++ b/usr/src/cmd/fs.d/nfs/nfslog/Makefile
@@ -40,7 +40,7 @@ SRCS= $(LOCAL:%.o=%.c) $(COMMON:%.o=../lib/%.c)
LDLIBS += -lsocket -lnsl
CFLAGS += $(CCVERBOSE)
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-switch
CERRWARN += -_gcc=-Wno-type-limits
diff --git a/usr/src/cmd/fs.d/nfs/nfsmapid/Makefile b/usr/src/cmd/fs.d/nfs/nfsmapid/Makefile
index 5f0af9ef89..a8ebbd4eb5 100644
--- a/usr/src/cmd/fs.d/nfs/nfsmapid/Makefile
+++ b/usr/src/cmd/fs.d/nfs/nfsmapid/Makefile
@@ -44,7 +44,7 @@ CPPFLAGS += -I../lib -D_POSIX_PTHREAD_SEMANTICS
CERRWARN += -_gcc=-Wno-implicit-function-declaration
CERRWARN += -_gcc=-Wno-unused-variable
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/fs.d/nfs/showmount/Makefile b/usr/src/cmd/fs.d/nfs/showmount/Makefile
index 527c776481..c9abffdf07 100644
--- a/usr/src/cmd/fs.d/nfs/showmount/Makefile
+++ b/usr/src/cmd/fs.d/nfs/showmount/Makefile
@@ -46,7 +46,7 @@ LDLIBS += -lrpcsvc -lnsl
CERRWARN += -_gcc=-Wno-implicit-function-declaration
CERRWARN += -_gcc=-Wno-parentheses
CERRWARN += -_gcc=-Wno-unused-variable
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/fs.d/nfs/statd/Makefile b/usr/src/cmd/fs.d/nfs/statd/Makefile
index c64bbb71ca..adb5cd9dd5 100644
--- a/usr/src/cmd/fs.d/nfs/statd/Makefile
+++ b/usr/src/cmd/fs.d/nfs/statd/Makefile
@@ -42,7 +42,7 @@ CPPFLAGS += -D_REENTRANT -DSUN_THREADS
CERRWARN += -_gcc=-Wno-unused-variable
CERRWARN += -_gcc=-Wno-switch
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/fs.d/pcfs/fsck/Makefile b/usr/src/cmd/fs.d/pcfs/fsck/Makefile
index 4be0621768..d0b75a8449 100644
--- a/usr/src/cmd/fs.d/pcfs/fsck/Makefile
+++ b/usr/src/cmd/fs.d/pcfs/fsck/Makefile
@@ -52,7 +52,7 @@ CPPFLAGS += -D_LARGEFILE64_SOURCE
CERRWARN += -_gcc=-Wno-parentheses
CERRWARN += -_gcc=-Wno-unused-variable
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
#
# We need to tell lint not to complain about the routines
diff --git a/usr/src/cmd/fs.d/pcfs/mount/Makefile b/usr/src/cmd/fs.d/pcfs/mount/Makefile
index bb29ed53d8..af7da82edc 100644
--- a/usr/src/cmd/fs.d/pcfs/mount/Makefile
+++ b/usr/src/cmd/fs.d/pcfs/mount/Makefile
@@ -31,4 +31,4 @@ include ../../Makefile.fstype
include ../../Makefile.mount
include ../../Makefile.mount.targ
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
diff --git a/usr/src/cmd/fs.d/tmpfs/Makefile b/usr/src/cmd/fs.d/tmpfs/Makefile
index 61599e70f4..1dc1cb6059 100644
--- a/usr/src/cmd/fs.d/tmpfs/Makefile
+++ b/usr/src/cmd/fs.d/tmpfs/Makefile
@@ -31,4 +31,4 @@ include ../Makefile.fstype
include ../Makefile.mount
include ../Makefile.mount.targ
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
diff --git a/usr/src/cmd/fs.d/udfs/fsck/Makefile b/usr/src/cmd/fs.d/udfs/fsck/Makefile
index a5c12a6baa..b1d9610c70 100644
--- a/usr/src/cmd/fs.d/udfs/fsck/Makefile
+++ b/usr/src/cmd/fs.d/udfs/fsck/Makefile
@@ -38,7 +38,7 @@ UDFSDIR= ../mkfs
UDFSOBJS= udfslib.o
#UDFSSRCS= $(UDFSOBJS:%.o=%.c)
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-parentheses
# not linted
diff --git a/usr/src/cmd/fs.d/udfs/fsdb/Makefile b/usr/src/cmd/fs.d/udfs/fsdb/Makefile
index 7c5c2494ab..36c430cf7e 100644
--- a/usr/src/cmd/fs.d/udfs/fsdb/Makefile
+++ b/usr/src/cmd/fs.d/udfs/fsdb/Makefile
@@ -48,7 +48,7 @@ LINTFLAGS64 += -erroff=E_STATIC_UNUSED
CERRWARN += -_gcc=-Wno-implicit-function-declaration
CERRWARN += -_gcc=-Wno-unused-label
CERRWARN += -_gcc=-Wno-unused-variable
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-unused-value
CERRWARN += -_gcc=-Wno-unused-function
diff --git a/usr/src/cmd/fs.d/udfs/fstyp/Makefile b/usr/src/cmd/fs.d/udfs/fstyp/Makefile
index 292faf8b32..3406009369 100644
--- a/usr/src/cmd/fs.d/udfs/fstyp/Makefile
+++ b/usr/src/cmd/fs.d/udfs/fstyp/Makefile
@@ -37,7 +37,7 @@ CFLAGS += $(C_PICFLAGS)
DYNLIB= $(LIBPROG)
CERRWARN += -_gcc=-Wno-unused-function
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
LDLIBS += -lnvpair -ladm -lc
diff --git a/usr/src/cmd/fs.d/udfs/labelit/Makefile b/usr/src/cmd/fs.d/udfs/labelit/Makefile
index 51c22de0b5..a21bc6ad8a 100644
--- a/usr/src/cmd/fs.d/udfs/labelit/Makefile
+++ b/usr/src/cmd/fs.d/udfs/labelit/Makefile
@@ -40,7 +40,7 @@ LINTFLAGS += -xerroff=E_STATIC_UNUSED
LINTFLAGS64 += -xerroff=E_STATIC_UNUSED
CERRWARN += -_gcc=-Wno-unused-function
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
labelit : labelit.o ud_lib.o
$(LINK.c) -o $@ labelit.o ud_lib.o $(LDLIBS)
diff --git a/usr/src/cmd/fs.d/udfs/mkfs/Makefile b/usr/src/cmd/fs.d/udfs/mkfs/Makefile
index 078f90c5fb..a2fbab17ab 100644
--- a/usr/src/cmd/fs.d/udfs/mkfs/Makefile
+++ b/usr/src/cmd/fs.d/udfs/mkfs/Makefile
@@ -47,7 +47,7 @@ UDFSDIR= ../../../../uts/common/fs/ufs
UDFSOBJS=
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/fs.d/ufs/ff/Makefile b/usr/src/cmd/fs.d/ufs/ff/Makefile
index a36af880e0..4cfa9a0dbd 100644
--- a/usr/src/cmd/fs.d/ufs/ff/Makefile
+++ b/usr/src/cmd/fs.d/ufs/ff/Makefile
@@ -40,7 +40,7 @@ POFILE=
CPPFLAGS += -D_LARGEFILE64_SOURCE
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/fs.d/ufs/fsck/Makefile b/usr/src/cmd/fs.d/ufs/fsck/Makefile
index cc3bd8dd12..3c3724644c 100644
--- a/usr/src/cmd/fs.d/ufs/fsck/Makefile
+++ b/usr/src/cmd/fs.d/ufs/fsck/Makefile
@@ -50,7 +50,7 @@ LDLIBS += -lefi -lavl
CERRWARN += -_gcc=-Wno-parentheses
CERRWARN += -_gcc=-Wno-implicit-function-declaration
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/fs.d/ufs/fsdb/Makefile b/usr/src/cmd/fs.d/ufs/fsdb/Makefile
index 64527b4e5f..8d4fb03fda 100644
--- a/usr/src/cmd/fs.d/ufs/fsdb/Makefile
+++ b/usr/src/cmd/fs.d/ufs/fsdb/Makefile
@@ -36,7 +36,7 @@ CERRWARN += -_gcc=-Wno-char-subscripts
CERRWARN += -_gcc=-Wno-implicit-function-declaration
CERRWARN += -_gcc=-Wno-parentheses
CERRWARN += -_gcc=-Wno-unused-variable
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/fs.d/ufs/fssnap/Makefile b/usr/src/cmd/fs.d/ufs/fssnap/Makefile
index c1dfb654c2..d61955c88d 100644
--- a/usr/src/cmd/fs.d/ufs/fssnap/Makefile
+++ b/usr/src/cmd/fs.d/ufs/fssnap/Makefile
@@ -43,7 +43,7 @@ CPPFLAGS += -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE
CERRWARN += -_gcc=-Wno-type-limits
CERRWARN += -_gcc=-Wno-implicit-function-declaration
CERRWARN += -_gcc=-Wno-unused-variable
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/fs.d/ufs/mkfs/Makefile b/usr/src/cmd/fs.d/ufs/mkfs/Makefile
index 1df1d8c86d..a21865c9b6 100644
--- a/usr/src/cmd/fs.d/ufs/mkfs/Makefile
+++ b/usr/src/cmd/fs.d/ufs/mkfs/Makefile
@@ -41,7 +41,7 @@ MKFSOBJS= mkfs.o
CERRWARN += -_gcc=-Wno-implicit-function-declaration
CERRWARN += -_gcc=-Wno-unused-variable
CERRWARN += -_gcc=-Wno-empty-body
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# can't hack main() !
SMATCH = off
diff --git a/usr/src/cmd/fs.d/ufs/newfs/Makefile b/usr/src/cmd/fs.d/ufs/newfs/Makefile
index 82e10b3aaf..182ef9cefb 100644
--- a/usr/src/cmd/fs.d/ufs/newfs/Makefile
+++ b/usr/src/cmd/fs.d/ufs/newfs/Makefile
@@ -37,7 +37,7 @@ CPPFLAGS += -I../../ -D_LARGEFILE64_SOURCE
LDLIBS += -ladm -lefi
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/fs.d/ufs/repquota/Makefile b/usr/src/cmd/fs.d/ufs/repquota/Makefile
index 4bb399e549..fb8d250c1b 100644
--- a/usr/src/cmd/fs.d/ufs/repquota/Makefile
+++ b/usr/src/cmd/fs.d/ufs/repquota/Makefile
@@ -37,7 +37,7 @@ include ../../Makefile.fstype
CPPFLAGS += -D_LARGEFILE64_SOURCE
CERRWARN += -_gcc=-Wno-type-limits
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/fs.d/ufs/tunefs/Makefile b/usr/src/cmd/fs.d/ufs/tunefs/Makefile
index ba6df6c8f5..50eb11a5be 100644
--- a/usr/src/cmd/fs.d/ufs/tunefs/Makefile
+++ b/usr/src/cmd/fs.d/ufs/tunefs/Makefile
@@ -38,7 +38,7 @@ LDLIBS += -ladm
CPPFLAGS += -D_LARGEFILE64_SOURCE
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/fs.d/ufs/volcopy/Makefile b/usr/src/cmd/fs.d/ufs/volcopy/Makefile
index 9e767c6561..7bf60ec2f8 100644
--- a/usr/src/cmd/fs.d/ufs/volcopy/Makefile
+++ b/usr/src/cmd/fs.d/ufs/volcopy/Makefile
@@ -33,7 +33,7 @@ include ../../Makefile.fstype
CERRWARN += -_gcc=-Wno-implicit-function-declaration
CERRWARN += -_gcc=-Wno-unused-variable
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/fwflash/Makefile.com b/usr/src/cmd/fwflash/Makefile.com
index 3a5d9c36a2..08b90ce62b 100644
--- a/usr/src/cmd/fwflash/Makefile.com
+++ b/usr/src/cmd/fwflash/Makefile.com
@@ -26,7 +26,7 @@
# common rules for $SRC/cmd/fwflash
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-address
# not linted
diff --git a/usr/src/cmd/geniconvtbl/Makefile.com b/usr/src/cmd/geniconvtbl/Makefile.com
index adca670979..45fb5f174e 100644
--- a/usr/src/cmd/geniconvtbl/Makefile.com
+++ b/usr/src/cmd/geniconvtbl/Makefile.com
@@ -85,7 +85,7 @@ CLEANFILES = $(OBJS) $(YTABC) $(YTABH) $(LEXYY) $(YOUT) \
$(POFILES) $(POFILE)
CPPFLAGS += -I. -I..
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-unused-label
CERRWARN += -_gcc=-Wno-switch
CERRWARN += -_gcc=-Wno-unused-variable
diff --git a/usr/src/cmd/getfacl/Makefile b/usr/src/cmd/getfacl/Makefile
index 575c1bd3cb..8166d04252 100644
--- a/usr/src/cmd/getfacl/Makefile
+++ b/usr/src/cmd/getfacl/Makefile
@@ -29,7 +29,7 @@ PROG= getfacl
include ../Makefile.cmd
CERRWARN += -_gcc=-Wno-unused-variable
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
.KEEP_STATE:
diff --git a/usr/src/cmd/grep/Makefile b/usr/src/cmd/grep/Makefile
index 85d00f57fe..9bcfdcebe6 100644
--- a/usr/src/cmd/grep/Makefile
+++ b/usr/src/cmd/grep/Makefile
@@ -31,7 +31,7 @@ EFILE= egrep
include ../Makefile.cmd
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
ROOTXPG4LINKS = $(ROOTXPG4BIN)/$(FFILE) $(ROOTXPG4BIN)/$(EFILE) $(ROOTXPG4BIN)/$(PROG)
ROOTLINKS = $(ROOTBIN)/$(FFILE) $(ROOTBIN)/$(EFILE)
diff --git a/usr/src/cmd/gss/gssd/Makefile b/usr/src/cmd/gss/gssd/Makefile
index cb03db28a1..90ef85ab9e 100644
--- a/usr/src/cmd/gss/gssd/Makefile
+++ b/usr/src/cmd/gss/gssd/Makefile
@@ -74,7 +74,7 @@ COPTFLAG += $(XESS) #-I$(KINCDIR)
CERRWARN += -_gcc=-Wno-unused-variable
CERRWARN += -_gcc=-Wno-implicit-function-declaration
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/hotplugd/Makefile b/usr/src/cmd/hotplugd/Makefile
index 2a7be28033..91fd605489 100644
--- a/usr/src/cmd/hotplugd/Makefile
+++ b/usr/src/cmd/hotplugd/Makefile
@@ -44,7 +44,7 @@ $(ROOTMANIFEST) := FILEMODE= 444
CPPFLAGS += -I$(SRC)/lib/libhotplug/common
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
LDLIBS += -ldevinfo -lhotplug -lnvpair -lsecdb -lrcm -lbsm
.KEEP_STATE:
diff --git a/usr/src/cmd/id/Makefile b/usr/src/cmd/id/Makefile
index e6c3eef31a..d3bfb1e3cc 100644
--- a/usr/src/cmd/id/Makefile
+++ b/usr/src/cmd/id/Makefile
@@ -30,7 +30,7 @@ XPG4PROG= id
include ../Makefile.cmd
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
.KEEP_STATE:
diff --git a/usr/src/cmd/idmap/idmap/Makefile b/usr/src/cmd/idmap/idmap/Makefile
index 7f62b99649..3fb37bd6f5 100644
--- a/usr/src/cmd/idmap/idmap/Makefile
+++ b/usr/src/cmd/idmap/idmap/Makefile
@@ -39,7 +39,7 @@ CERRWARN += -_gcc=-Wno-switch
CERRWARN += -_gcc=-Wno-unused-label
CERRWARN += -_gcc=-Wno-char-subscripts
CERRWARN += -_gcc=-Wno-unused-function
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-address
# not linted
diff --git a/usr/src/cmd/idmap/idmapd/Makefile b/usr/src/cmd/idmap/idmapd/Makefile
index 4b2c59b59d..bcbd288752 100644
--- a/usr/src/cmd/idmap/idmapd/Makefile
+++ b/usr/src/cmd/idmap/idmapd/Makefile
@@ -62,7 +62,7 @@ include ../../Makefile.cmd
CERRWARN += -_gcc=-Wno-type-limits
CERRWARN += -_gcc=-Wno-switch
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/init/Makefile b/usr/src/cmd/init/Makefile
index 9d70fa9539..a644c8087a 100644
--- a/usr/src/cmd/init/Makefile
+++ b/usr/src/cmd/init/Makefile
@@ -37,7 +37,7 @@ include ../Makefile.ctf
CSTD = $(CSTD_GNU99)
LDLIBS += -lpam -lbsm -lcontract -lscf
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
LINTFLAGS += -erroff=E_NAME_USED_NOT_DEF2
CLOBBERFILES= $(STATIC)
diff --git a/usr/src/cmd/intrstat/Makefile.com b/usr/src/cmd/intrstat/Makefile.com
index 6c25d6f020..d0448ce718 100644
--- a/usr/src/cmd/intrstat/Makefile.com
+++ b/usr/src/cmd/intrstat/Makefile.com
@@ -38,7 +38,7 @@ SRCS += $(STAT_COMMON_SRCS)
CPPFLAGS += -I$(STATCOMMONDIR)
CFLAGS += $(CCVERBOSE)
CFLAGS64 += $(CCVERBOSE)
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
LDLIBS += -ldtrace
FILEMODE = 0555
diff --git a/usr/src/cmd/ipf/Makefile.ipf b/usr/src/cmd/ipf/Makefile.ipf
index f960a477a2..54c80175e9 100644
--- a/usr/src/cmd/ipf/Makefile.ipf
+++ b/usr/src/cmd/ipf/Makefile.ipf
@@ -35,7 +35,7 @@ CPPFLAGS += -I$(COMMONIPF) -I$(KERNELIPF) -DSUNDDI -DUSE_INET6 \
-DSOLARIS2=$(RELEASE_MINOR)
CERRWARN += -_gcc=-Wno-unused-variable
CERRWARN += -_gcc=-Wno-type-limits
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-unused-label
CERRWARN += -_gcc=-Wno-parentheses
CERRWARN += -_gcc=-Wno-unused-function
diff --git a/usr/src/cmd/iscsiadm/Makefile b/usr/src/cmd/iscsiadm/Makefile
index f515f892c5..d293c2fe69 100644
--- a/usr/src/cmd/iscsiadm/Makefile
+++ b/usr/src/cmd/iscsiadm/Makefile
@@ -41,7 +41,7 @@ CERRWARN += -_gcc=-Wno-parentheses
CERRWARN += -_gcc=-Wno-unused-variable
CERRWARN += -_gcc=-Wno-unused-function
CERRWARN += -_gcc=-Wno-switch
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/isns/isnsadm/Makefile b/usr/src/cmd/isns/isnsadm/Makefile
index e40079b4ef..a59d2c17a8 100644
--- a/usr/src/cmd/isns/isnsadm/Makefile
+++ b/usr/src/cmd/isns/isnsadm/Makefile
@@ -39,7 +39,7 @@ POFILES = $(OBJS:%.o=%.po)
LINTFLAGS += -xerroff=E_BAD_FORMAT_STR2
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/isns/isnsd/Makefile b/usr/src/cmd/isns/isnsd/Makefile
index 0cfabc0cfb..8cca720f32 100644
--- a/usr/src/cmd/isns/isnsd/Makefile
+++ b/usr/src/cmd/isns/isnsd/Makefile
@@ -61,7 +61,7 @@ LINTFLAGS += -xerroff=E_CASE_FALLTHRU
CERRWARN += -_gcc=-Wno-char-subscripts
CERRWARN += -_gcc=-Wno-ignored-qualifiers
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-implicit-function-declaration
# not linted
diff --git a/usr/src/cmd/kbd/Makefile b/usr/src/cmd/kbd/Makefile
index 935ff52681..e1f28388c6 100644
--- a/usr/src/cmd/kbd/Makefile
+++ b/usr/src/cmd/kbd/Makefile
@@ -33,7 +33,7 @@ ROOTMANIFESTDIR = $(ROOTSVCSYSTEM)
PROG = kbd
CFLAGS += $(CCVERBOSE)
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
LDLIBS += -lscf
all: $(PROG)
diff --git a/usr/src/cmd/keyserv/Makefile b/usr/src/cmd/keyserv/Makefile
index f787415ab9..dae01bb1a1 100644
--- a/usr/src/cmd/keyserv/Makefile
+++ b/usr/src/cmd/keyserv/Makefile
@@ -70,7 +70,7 @@ CPPFLAGS += -I. -I$(SRC)/lib/libnsl/include -I$(SRC)/lib/libsldap/common \
CERRWARN += -_gcc=-Wno-implicit-function-declaration
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-unused-variable
CERRWARN += -_gcc=-Wno-address
CERRWARN += -_gcc=-Wno-unused-function
diff --git a/usr/src/cmd/krb5/kadmin/kclient/Makefile b/usr/src/cmd/krb5/kadmin/kclient/Makefile
index bf766992c3..b15874dd4b 100644
--- a/usr/src/cmd/krb5/kadmin/kclient/Makefile
+++ b/usr/src/cmd/krb5/kadmin/kclient/Makefile
@@ -61,7 +61,7 @@ CPPFLAGS += -I$(SRC)/uts/common/gssapi/include \
-I$(SRC)/uts/common/gssapi/include \
-I$(SRC)/uts/common/gssapi/mechs/krb5/include
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-parentheses
CERRWARN += -_gcc=-Wno-unused-function
diff --git a/usr/src/cmd/krb5/kadmin/kdcmgr/Makefile b/usr/src/cmd/krb5/kadmin/kdcmgr/Makefile
index 47bbc0ab43..7431b1d989 100644
--- a/usr/src/cmd/krb5/kadmin/kdcmgr/Makefile
+++ b/usr/src/cmd/krb5/kadmin/kdcmgr/Makefile
@@ -36,7 +36,7 @@ include ../../../Makefile.cmd
POFILE= $(SSRCS:%.sh=%.po)
CERRWARN += -_gcc=-Wno-implicit-function-declaration
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/krb5/slave/Makefile b/usr/src/cmd/krb5/slave/Makefile
index 5b29e30459..7604827368 100644
--- a/usr/src/cmd/krb5/slave/Makefile
+++ b/usr/src/cmd/krb5/slave/Makefile
@@ -60,7 +60,7 @@ CERRWARN += -_gcc=-Wno-unused-variable
CERRWARN += -_gcc=-Wno-unused-function
CERRWARN += -_gcc=-Wno-implicit-function-declaration
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-unused-value
CERRWARN += -_gcc=-Wno-address
diff --git a/usr/src/cmd/latencytop/Makefile.com b/usr/src/cmd/latencytop/Makefile.com
index 9918e58bee..75f7efef16 100644
--- a/usr/src/cmd/latencytop/Makefile.com
+++ b/usr/src/cmd/latencytop/Makefile.com
@@ -33,7 +33,7 @@ include ../../Makefile.cmd
CFLAGS += $(CCVERBOSE)
CFLAGS64 += $(CCVERBOSE)
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
SMOFF += all_func_returns
diff --git a/usr/src/cmd/ldap/Makefile.com b/usr/src/cmd/ldap/Makefile.com
index ef207e6ffd..694b71b891 100644
--- a/usr/src/cmd/ldap/Makefile.com
+++ b/usr/src/cmd/ldap/Makefile.com
@@ -88,7 +88,7 @@ CERRWARN += -_gcc=-Wno-implicit-function-declaration
CERRWARN += -_gcc=-Wno-parentheses
CERRWARN += -_gcc=-Wno-unused-function
CERRWARN += -_gcc=-Wno-unused-variable
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/ldapcachemgr/Makefile b/usr/src/cmd/ldapcachemgr/Makefile
index b396397820..7048a9115c 100644
--- a/usr/src/cmd/ldapcachemgr/Makefile
+++ b/usr/src/cmd/ldapcachemgr/Makefile
@@ -54,7 +54,7 @@ CPPFLAGS += -D_REENTRANT -DSUN_THREADS \
CERRWARN += -_gcc=-Wno-parentheses
CERRWARN += -_gcc=-Wno-switch
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/ldmad/Makefile b/usr/src/cmd/ldmad/Makefile
index 0e38ddbb00..b966f307e9 100644
--- a/usr/src/cmd/ldmad/Makefile
+++ b/usr/src/cmd/ldmad/Makefile
@@ -65,7 +65,7 @@ INCS += -I$(ROOT)/usr/platform/sun4v/include/sys
INCS += -I$(SRC)/uts/sun4v
CPPFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 $(INCS)
CSTD = $(CSTD_GNU99)
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
LINTFLAGS += -erroff=E_BAD_PTR_CAST_ALIGN
diff --git a/usr/src/cmd/listen/Makefile b/usr/src/cmd/listen/Makefile
index d37edf6d6c..a35fb2b372 100644
--- a/usr/src/cmd/listen/Makefile
+++ b/usr/src/cmd/listen/Makefile
@@ -63,7 +63,7 @@ CERRWARN += -_gcc=-Wno-implicit-function-declaration
CERRWARN += -_gcc=-Wno-unused-variable
CERRWARN += -_gcc=-Wno-empty-body
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/loadkeys/Makefile b/usr/src/cmd/loadkeys/Makefile
index df0c686088..fe942ea4ee 100644
--- a/usr/src/cmd/loadkeys/Makefile
+++ b/usr/src/cmd/loadkeys/Makefile
@@ -41,7 +41,7 @@ include ../Makefile.cmd
CERRWARN += -_gcc=-Wno-switch
CERRWARN += -_gcc=-Wno-implicit-function-declaration
CERRWARN += -_gcc=-Wno-unused-label
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/lockstat/Makefile.com b/usr/src/cmd/lockstat/Makefile.com
index 7e8ee6cf6d..8ee28e41da 100644
--- a/usr/src/cmd/lockstat/Makefile.com
+++ b/usr/src/cmd/lockstat/Makefile.com
@@ -33,7 +33,7 @@ include ../../Makefile.cmd
LDLIBS += -lelf -lkstat -ldtrace
CFLAGS += $(CCVERBOSE)
CFLAGS64 += $(CCVERBOSE)
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
SMOFF += index_overflow
diff --git a/usr/src/cmd/lofiadm/Makefile b/usr/src/cmd/lofiadm/Makefile
index 462488cd35..4c5b2ed59c 100644
--- a/usr/src/cmd/lofiadm/Makefile
+++ b/usr/src/cmd/lofiadm/Makefile
@@ -39,7 +39,7 @@ CPPFLAGS += -I $(SRC)/common/crypto -I $(SRC)/common/lzma
LDLIBS += -ldevinfo -lpkcs11 -lcryptoutil
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/logadm/Makefile b/usr/src/cmd/logadm/Makefile
index 246f7b6ef8..b9ee0560ea 100644
--- a/usr/src/cmd/logadm/Makefile
+++ b/usr/src/cmd/logadm/Makefile
@@ -35,7 +35,7 @@ include ../Makefile.cmd
CPPFLAGS += -D_FILE_OFFSET_BITS=64
CERRWARN += -_gcc=-Wno-parentheses
CERRWARN += -_gcc=-Wno-clobbered
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
XGETFLAGS += -a -x logadm.xcl
$(ROOTETC)/$(CONFIGFILE):= FILEMODE= 644
diff --git a/usr/src/cmd/logins/Makefile b/usr/src/cmd/logins/Makefile
index 865f2163bd..4f07886a2b 100644
--- a/usr/src/cmd/logins/Makefile
+++ b/usr/src/cmd/logins/Makefile
@@ -30,7 +30,7 @@ include ../Makefile.cmd
TEXT_DOMAIN= SUNW_OST_ADMIN
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
FILEMODE= 0750
diff --git a/usr/src/cmd/lp/Makefile.lp b/usr/src/cmd/lp/Makefile.lp
index c4c4ff2a92..2505a84756 100644
--- a/usr/src/cmd/lp/Makefile.lp
+++ b/usr/src/cmd/lp/Makefile.lp
@@ -88,7 +88,7 @@ LINTUSR = $(LPLIB)/users/llib-llpusr.ln
CERRWARN += -_gcc=-Wno-sequence-point
CERRWARN += -_gcc=-Wno-implicit-function-declaration
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-unused-variable
CERRWARN += -_gcc=-Wno-unused-value
CERRWARN += -_gcc=-Wno-unused-label
diff --git a/usr/src/cmd/lp/lib/filters/Makefile b/usr/src/cmd/lp/lib/filters/Makefile
index 09c55243b6..86a533485b 100644
--- a/usr/src/cmd/lp/lib/filters/Makefile
+++ b/usr/src/cmd/lp/lib/filters/Makefile
@@ -50,7 +50,7 @@ LIBS = $(LIBRARY)
CPPFLAGS = -I../../include $(CPPFLAGS.master)
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-parentheses
# not linted
diff --git a/usr/src/cmd/luxadm/Makefile b/usr/src/cmd/luxadm/Makefile
index 7b8abc40d3..77781b9202 100644
--- a/usr/src/cmd/luxadm/Makefile
+++ b/usr/src/cmd/luxadm/Makefile
@@ -39,7 +39,7 @@ POFILE = luxadm.po
include ../Makefile.cmd
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-unused-label
CERRWARN += -_gcc=-Wno-address
diff --git a/usr/src/cmd/mail/Makefile b/usr/src/cmd/mail/Makefile
index 8f24d04f95..45487bfcee 100644
--- a/usr/src/cmd/mail/Makefile
+++ b/usr/src/cmd/mail/Makefile
@@ -73,7 +73,7 @@ EDITPATH= \
CPPFLAGS = -DSVR4 -I. $(CPPFLAGS.master)
CERRWARN += -_gcc=-Wno-implicit-function-declaration
CERRWARN += -_gcc=-Wno-unused-variable
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-clobbered
CERRWARN += -_gcc=-Wno-extra
diff --git a/usr/src/cmd/mailx/Makefile b/usr/src/cmd/mailx/Makefile
index 57bc1bcfe5..3b19ad4b4f 100644
--- a/usr/src/cmd/mailx/Makefile
+++ b/usr/src/cmd/mailx/Makefile
@@ -66,7 +66,7 @@ $(ROOTUCBMAILRC) := FILEMODE = 0644
CPPFLAGS= -Ihdr -DUSG -DOPTIM $(CPPFLAGS.master)
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-unused-variable
CERRWARN += -_gcc=-Wno-clobbered
# not linted
diff --git a/usr/src/cmd/mandoc/Makefile.common b/usr/src/cmd/mandoc/Makefile.common
index 42d73be9f5..ac9df1c135 100644
--- a/usr/src/cmd/mandoc/Makefile.common
+++ b/usr/src/cmd/mandoc/Makefile.common
@@ -79,7 +79,7 @@ OBJS= arch.o \
OBJS += compat_ohash.o
# XXX gcc 4.4.4 false positive
-roff.o := CERRWARN += -_gcc=-Wno-uninitialized
+roff.o := CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/mdb/Makefile.kmdb b/usr/src/cmd/mdb/Makefile.kmdb
index f295d2463f..be670d3fc6 100644
--- a/usr/src/cmd/mdb/Makefile.kmdb
+++ b/usr/src/cmd/mdb/Makefile.kmdb
@@ -98,7 +98,7 @@ ALLLINTFLAGS = $(LINTFLAGS) \
-xerroff=E_INCONS_VAL_TYPE_DECL2 \
-xerroff=E_INCONS_VAL_TYPE_USED2
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-unused-label
CERRWARN += -_gcc=-Wno-char-subscripts
CERRWARN += -_gcc=-Wno-clobbered
diff --git a/usr/src/cmd/mdb/Makefile.libstandctf b/usr/src/cmd/mdb/Makefile.libstandctf
index 176291399c..e24e39d777 100644
--- a/usr/src/cmd/mdb/Makefile.libstandctf
+++ b/usr/src/cmd/mdb/Makefile.libstandctf
@@ -62,7 +62,7 @@ LINTFILES = $(OBJS:%.o=%.ln)
LINTFLAGS += -n -errtags=yes
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
.NO_PARALLEL:
.PARALLEL: $(OBJS)
diff --git a/usr/src/cmd/mdb/Makefile.mdb b/usr/src/cmd/mdb/Makefile.mdb
index 5207c740f3..5eb6f4e977 100644
--- a/usr/src/cmd/mdb/Makefile.mdb
+++ b/usr/src/cmd/mdb/Makefile.mdb
@@ -102,7 +102,7 @@ C99LMODE= -Xc99=%all
LDLIBS += -lcurses -lkvm -lproc -lrtld_db -lctf -lumem -ldisasm -lscf
LDLIBS += -ldemangle-sys
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-char-subscripts
CERRWARN += -_gcc=-Wno-clobbered
CERRWARN += -_gcc=-Wno-parentheses
diff --git a/usr/src/cmd/mdb/i86pc/modules/unix/amd64/Makefile b/usr/src/cmd/mdb/i86pc/modules/unix/amd64/Makefile
index ea8099272e..54bc62a086 100644
--- a/usr/src/cmd/mdb/i86pc/modules/unix/amd64/Makefile
+++ b/usr/src/cmd/mdb/i86pc/modules/unix/amd64/Makefile
@@ -45,6 +45,6 @@ CPPFLAGS += -I$(SRC)/uts/intel
CERRWARN += -_gcc=-Wno-char-subscripts
CERRWARN += -_gcc=-Wno-parentheses
CERRWARN += -_gcc=-Wno-unused-label
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-unused-function
diff --git a/usr/src/cmd/mdb/i86xpv/modules/unix/amd64/Makefile b/usr/src/cmd/mdb/i86xpv/modules/unix/amd64/Makefile
index dd0e3d3318..5854a1610e 100644
--- a/usr/src/cmd/mdb/i86xpv/modules/unix/amd64/Makefile
+++ b/usr/src/cmd/mdb/i86xpv/modules/unix/amd64/Makefile
@@ -49,6 +49,6 @@ CPPFLAGS += -I$(SRC)/uts/intel
CERRWARN += -_gcc=-Wno-char-subscripts
CERRWARN += -_gcc=-Wno-parentheses
CERRWARN += -_gcc=-Wno-unused-label
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-unused-function
diff --git a/usr/src/cmd/mdb/intel/amd64/genunix/Makefile b/usr/src/cmd/mdb/intel/amd64/genunix/Makefile
index 8d73bebcb1..3b14cb5a58 100644
--- a/usr/src/cmd/mdb/intel/amd64/genunix/Makefile
+++ b/usr/src/cmd/mdb/intel/amd64/genunix/Makefile
@@ -74,7 +74,7 @@ CPPFLAGS += -I$(SRC)/uts/intel
CERRWARN += -_gcc=-Wno-char-subscripts
CERRWARN += -_gcc=-Wno-unused-label
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-parentheses
CERRWARN += -_gcc=-Wno-type-limits
diff --git a/usr/src/cmd/mdb/intel/amd64/idm/Makefile b/usr/src/cmd/mdb/intel/amd64/idm/Makefile
index c68aa1c1dc..a3d7b2f52f 100644
--- a/usr/src/cmd/mdb/intel/amd64/idm/Makefile
+++ b/usr/src/cmd/mdb/intel/amd64/idm/Makefile
@@ -41,4 +41,4 @@ CPPFLAGS += -I$(ISCSITBASE)
CPPFLAGS += -I$(ISCSIBASE)
CPPFLAGS += -I$(ISERBASE)
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
diff --git a/usr/src/cmd/mdb/intel/amd64/ipp/Makefile b/usr/src/cmd/mdb/intel/amd64/ipp/Makefile
index da6e6cfea0..502240f3b3 100644
--- a/usr/src/cmd/mdb/intel/amd64/ipp/Makefile
+++ b/usr/src/cmd/mdb/intel/amd64/ipp/Makefile
@@ -34,4 +34,4 @@ include ../../../../Makefile.cmd.64
include ../../Makefile.amd64
include ../../../Makefile.module
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
diff --git a/usr/src/cmd/mdb/intel/amd64/libproc/Makefile b/usr/src/cmd/mdb/intel/amd64/libproc/Makefile
index 64e67e2d0d..5b06592bd2 100644
--- a/usr/src/cmd/mdb/intel/amd64/libproc/Makefile
+++ b/usr/src/cmd/mdb/intel/amd64/libproc/Makefile
@@ -38,7 +38,7 @@ include ../../../Makefile.module
CFLAGS64 += -I../../../../../lib/libproc/common
LINTFLAGS64 += -I../../../../../lib/libproc/common
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
%.o: $(MODSRCS_DIR)/%.c
$(COMPILE.c) $<
diff --git a/usr/src/cmd/mdb/intel/amd64/libumem/Makefile b/usr/src/cmd/mdb/intel/amd64/libumem/Makefile
index ae22217a1b..5a9b46141d 100644
--- a/usr/src/cmd/mdb/intel/amd64/libumem/Makefile
+++ b/usr/src/cmd/mdb/intel/amd64/libumem/Makefile
@@ -53,7 +53,7 @@ dmod/$(MODULE) := LDLIBS += -lproc -lm
CERRWARN += -_gcc=-Wno-unused-label
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
%.o: $(MODSRCS_DIR)/%.c
$(COMPILE.c) $<
diff --git a/usr/src/cmd/mdb/intel/amd64/pmcs/Makefile b/usr/src/cmd/mdb/intel/amd64/pmcs/Makefile
index 02f4962b86..3527c9a764 100644
--- a/usr/src/cmd/mdb/intel/amd64/pmcs/Makefile
+++ b/usr/src/cmd/mdb/intel/amd64/pmcs/Makefile
@@ -39,4 +39,4 @@ CPPFLAGS += -I$(SRC)/uts/common
CERRWARN += -_gcc=-Wno-switch
CERRWARN += -_gcc=-Wno-char-subscripts
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
diff --git a/usr/src/cmd/mdb/intel/ia32/libproc/Makefile b/usr/src/cmd/mdb/intel/ia32/libproc/Makefile
index 08d6644a93..369a8ec90f 100644
--- a/usr/src/cmd/mdb/intel/ia32/libproc/Makefile
+++ b/usr/src/cmd/mdb/intel/ia32/libproc/Makefile
@@ -37,7 +37,7 @@ include ../../../Makefile.module
CFLAGS += -I../../../../../lib/libproc/common
LINTFLAGS += -I../../../../../lib/libproc/common
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
%.o: $(MODSRCS_DIR)/%.c
$(COMPILE.c) $<
diff --git a/usr/src/cmd/mdb/intel/ia32/libumem/Makefile b/usr/src/cmd/mdb/intel/ia32/libumem/Makefile
index bde1be90ac..ca4d07a66a 100644
--- a/usr/src/cmd/mdb/intel/ia32/libumem/Makefile
+++ b/usr/src/cmd/mdb/intel/ia32/libumem/Makefile
@@ -52,7 +52,7 @@ dmod/$(MODULE) := LDLIBS += -lproc -lm
CERRWARN += -_gcc=-Wno-unused-label
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
%.o: $(MODSRCS_DIR)/%.c
$(COMPILE.c) $<
diff --git a/usr/src/cmd/mdb/intel/modules/amd_opteron/amd64/Makefile b/usr/src/cmd/mdb/intel/modules/amd_opteron/amd64/Makefile
index 324ea9da32..10a426a348 100644
--- a/usr/src/cmd/mdb/intel/modules/amd_opteron/amd64/Makefile
+++ b/usr/src/cmd/mdb/intel/modules/amd_opteron/amd64/Makefile
@@ -37,4 +37,4 @@ CPPFLAGS += -I$(SRC)/uts/i86pc/cpu
CPPFLAGS += -I$(SRC)/uts/intel
CPPFLAGS += -I$(SRC)/uts/i86pc
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
diff --git a/usr/src/cmd/mdb/intel/modules/generic_cpu/amd64/Makefile b/usr/src/cmd/mdb/intel/modules/generic_cpu/amd64/Makefile
index 55b43df8fb..f545fce59d 100644
--- a/usr/src/cmd/mdb/intel/modules/generic_cpu/amd64/Makefile
+++ b/usr/src/cmd/mdb/intel/modules/generic_cpu/amd64/Makefile
@@ -36,4 +36,4 @@ CPPFLAGS += -I$(SRC)/uts/i86pc/cpu
CPPFLAGS += -I$(SRC)/uts/intel
CPPFLAGS += -I$(SRC)/uts/i86pc
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
diff --git a/usr/src/cmd/mdb/sparc/v7/libproc/Makefile b/usr/src/cmd/mdb/sparc/v7/libproc/Makefile
index 137a96b715..e8782a568a 100644
--- a/usr/src/cmd/mdb/sparc/v7/libproc/Makefile
+++ b/usr/src/cmd/mdb/sparc/v7/libproc/Makefile
@@ -37,7 +37,7 @@ include ../../../Makefile.module
CFLAGS += -I../../../../../lib/libproc/common
LINTFLAGS += -I../../../../../lib/libproc/common
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
%.o: $(MODSRCS_DIR)/%.c
$(COMPILE.c) $<
diff --git a/usr/src/cmd/mdb/sparc/v7/libumem/Makefile b/usr/src/cmd/mdb/sparc/v7/libumem/Makefile
index 0488e6739a..7475d38815 100644
--- a/usr/src/cmd/mdb/sparc/v7/libumem/Makefile
+++ b/usr/src/cmd/mdb/sparc/v7/libumem/Makefile
@@ -52,7 +52,7 @@ dmod/$(MODULE) := LDLIBS += -lproc -lm
CERRWARN += -_gcc=-Wno-unused-label
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
%.o: $(MODSRCS_DIR)/%.c
$(COMPILE.c) $<
diff --git a/usr/src/cmd/mdb/sparc/v9/genunix/Makefile b/usr/src/cmd/mdb/sparc/v9/genunix/Makefile
index a9a8a60aa2..00dadda34b 100644
--- a/usr/src/cmd/mdb/sparc/v9/genunix/Makefile
+++ b/usr/src/cmd/mdb/sparc/v9/genunix/Makefile
@@ -67,7 +67,7 @@ CPPFLAGS += -I$(SRC)/uts/sparc/v9
CERRWARN += -_gcc=-Wno-char-subscripts
CERRWARN += -_gcc=-Wno-unused-label
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-parentheses
CERRWARN += -_gcc=-Wno-type-limits
diff --git a/usr/src/cmd/mdb/sparc/v9/idm/Makefile b/usr/src/cmd/mdb/sparc/v9/idm/Makefile
index c0d77bb8bb..cf5e9e82ff 100644
--- a/usr/src/cmd/mdb/sparc/v9/idm/Makefile
+++ b/usr/src/cmd/mdb/sparc/v9/idm/Makefile
@@ -40,4 +40,4 @@ CPPFLAGS += -I$(ISCSITBASE)
CPPFLAGS += -I$(ISCSIBASE)
CPPFLAGS += -I$(ISERBASE)
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
diff --git a/usr/src/cmd/mdb/sparc/v9/ipp/Makefile b/usr/src/cmd/mdb/sparc/v9/ipp/Makefile
index d546ca1f4a..daf786871f 100644
--- a/usr/src/cmd/mdb/sparc/v9/ipp/Makefile
+++ b/usr/src/cmd/mdb/sparc/v9/ipp/Makefile
@@ -34,4 +34,4 @@ include ../../../../Makefile.cmd.64
include ../../Makefile.sparcv9
include ../../../Makefile.module
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
diff --git a/usr/src/cmd/mdb/sparc/v9/libproc/Makefile b/usr/src/cmd/mdb/sparc/v9/libproc/Makefile
index 8dbdc151d4..bc50e68808 100644
--- a/usr/src/cmd/mdb/sparc/v9/libproc/Makefile
+++ b/usr/src/cmd/mdb/sparc/v9/libproc/Makefile
@@ -38,7 +38,7 @@ include ../../../Makefile.module
CFLAGS64 += -I../../../../../lib/libproc/common
LINTFLAGS64 += -I../../../../../lib/libproc/common
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
%.o: $(MODSRCS_DIR)/%.c
$(COMPILE.c) $<
diff --git a/usr/src/cmd/mdb/sparc/v9/libumem/Makefile b/usr/src/cmd/mdb/sparc/v9/libumem/Makefile
index 87ce977423..cada3a7d9c 100644
--- a/usr/src/cmd/mdb/sparc/v9/libumem/Makefile
+++ b/usr/src/cmd/mdb/sparc/v9/libumem/Makefile
@@ -66,7 +66,7 @@ dmod/$(MODULE) := LDLIBS += -lproc -lm
CERRWARN += -_gcc=-Wno-unused-label
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
%.o: $(MODSRCS_DIR)/%.c
$(COMPILE.c) $<
diff --git a/usr/src/cmd/mdb/sparc/v9/pmcs/Makefile b/usr/src/cmd/mdb/sparc/v9/pmcs/Makefile
index 2d28be38f9..5ca8d43850 100644
--- a/usr/src/cmd/mdb/sparc/v9/pmcs/Makefile
+++ b/usr/src/cmd/mdb/sparc/v9/pmcs/Makefile
@@ -39,4 +39,4 @@ CPPFLAGS += -I$(SRC)/uts/common
CERRWARN += -_gcc=-Wno-switch
CERRWARN += -_gcc=-Wno-char-subscripts
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
diff --git a/usr/src/cmd/mdb/sun4u/modules/unix/v9/Makefile b/usr/src/cmd/mdb/sun4u/modules/unix/v9/Makefile
index 529847d000..9c23823491 100644
--- a/usr/src/cmd/mdb/sun4u/modules/unix/v9/Makefile
+++ b/usr/src/cmd/mdb/sun4u/modules/unix/v9/Makefile
@@ -41,4 +41,4 @@ CPPFLAGS += -I$(SRC)/uts/sun4
CPPFLAGS += -I$(SRC)/uts/sun4u
CPPFLAGS += -I$(SRC)/uts/sfmmu
CPPFLAGS += -I$(SRC)/uts/sparc/v9
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
diff --git a/usr/src/cmd/mdb/sun4v/modules/unix/v9/Makefile b/usr/src/cmd/mdb/sun4v/modules/unix/v9/Makefile
index 6dda857ccb..30ea58449a 100644
--- a/usr/src/cmd/mdb/sun4v/modules/unix/v9/Makefile
+++ b/usr/src/cmd/mdb/sun4v/modules/unix/v9/Makefile
@@ -45,4 +45,4 @@ CPPFLAGS += -I$(SRC)/uts/sun4v
CPPFLAGS += -I$(SRC)/uts/sun4u
CPPFLAGS += -I$(SRC)/uts/sfmmu
CPPFLAGS += -I$(SRC)/uts/sparc/v9
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
diff --git a/usr/src/cmd/mdb/tools/findfp/Makefile.com b/usr/src/cmd/mdb/tools/findfp/Makefile.com
index 1da6562ccb..6ac7877527 100644
--- a/usr/src/cmd/mdb/tools/findfp/Makefile.com
+++ b/usr/src/cmd/mdb/tools/findfp/Makefile.com
@@ -44,7 +44,7 @@ include ../../common/Makefile.util
#
CPPFLAGS = -I../../common -I../common
CFLAGS += $(CCVERBOSE)
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
LDFLAGS =
LDLIBS = -lelf
diff --git a/usr/src/cmd/mdb/tools/setdynflag/Makefile.com b/usr/src/cmd/mdb/tools/setdynflag/Makefile.com
index 9db6e62e8a..02807d7089 100644
--- a/usr/src/cmd/mdb/tools/setdynflag/Makefile.com
+++ b/usr/src/cmd/mdb/tools/setdynflag/Makefile.com
@@ -43,7 +43,7 @@ include ../../common/Makefile.util
#
CPPFLAGS = -I../../common
CFLAGS += $(CCVERBOSE)
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
LDFLAGS =
LDLIBS = -lelf
diff --git a/usr/src/cmd/mkdir/Makefile b/usr/src/cmd/mkdir/Makefile
index e01d79efc2..fac3bc4fbc 100644
--- a/usr/src/cmd/mkdir/Makefile
+++ b/usr/src/cmd/mkdir/Makefile
@@ -31,7 +31,7 @@ SRCS= mkdir.c ../chmod/common.c
include ../Makefile.cmd
CFLAGS += $(CCVERBOSE)
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-parentheses
LDLIBS += -lgen
diff --git a/usr/src/cmd/mkmsgs/Makefile b/usr/src/cmd/mkmsgs/Makefile
index 3bf86c9da2..55e4b66d91 100644
--- a/usr/src/cmd/mkmsgs/Makefile
+++ b/usr/src/cmd/mkmsgs/Makefile
@@ -29,7 +29,7 @@ include ../Makefile.cmd
LDLIBS += -lgen
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/mknod/Makefile b/usr/src/cmd/mknod/Makefile
index cdffd352bd..c28ca59dc0 100644
--- a/usr/src/cmd/mknod/Makefile
+++ b/usr/src/cmd/mknod/Makefile
@@ -29,7 +29,7 @@ PROG= mknod
include ../Makefile.cmd
CFLAGS += $(CCVERBOSE)
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
.KEEP_STATE:
diff --git a/usr/src/cmd/mktemp/Makefile b/usr/src/cmd/mktemp/Makefile
index 6113762e0f..18e6feb96c 100644
--- a/usr/src/cmd/mktemp/Makefile
+++ b/usr/src/cmd/mktemp/Makefile
@@ -28,7 +28,7 @@ PROG= mktemp
include ../Makefile.cmd
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
.KEEP_STATE:
diff --git a/usr/src/cmd/more/Makefile b/usr/src/cmd/more/Makefile
index cfa30880a2..3aa829a0a9 100644
--- a/usr/src/cmd/more/Makefile
+++ b/usr/src/cmd/more/Makefile
@@ -39,7 +39,7 @@ $(ROOTLIBDATA) := FILEMODE = 0644
CFLAGS += $(CCVERBOSE)
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-clobbered
# not linted
diff --git a/usr/src/cmd/msgfmt/Makefile b/usr/src/cmd/msgfmt/Makefile
index 4e4a626413..13d8e3f141 100644
--- a/usr/src/cmd/msgfmt/Makefile
+++ b/usr/src/cmd/msgfmt/Makefile
@@ -66,7 +66,7 @@ ROOTLIBPROG= $(LIBPROG:%=$(ROOTLIB)/%)
CERRWARN += -_gcc=-Wno-parentheses
CERRWARN += -_gcc=-Wno-unused-label
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-unused-variable
.KEEP_STATE:
diff --git a/usr/src/cmd/mv/Makefile b/usr/src/cmd/mv/Makefile
index 5e866b5bbf..fd9c1661ee 100644
--- a/usr/src/cmd/mv/Makefile
+++ b/usr/src/cmd/mv/Makefile
@@ -42,7 +42,7 @@ CLOBBERFILES += $(CPFILE) $(LNFILE)
CFLAGS += $(CCVERBOSE)
CERRWARN += -_gcc=-Wno-parentheses
CERRWARN += -_gcc=-Wno-unused-variable
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
$(XPG4) := CFLAGS += -DXPG4
LINTFLAGS += -DXPG4 -u
XGETFLAGS += -a -x mv.xcl
diff --git a/usr/src/cmd/ndmpadm/Makefile b/usr/src/cmd/ndmpadm/Makefile
index 94f51fce89..ff7bd926a9 100644
--- a/usr/src/cmd/ndmpadm/Makefile
+++ b/usr/src/cmd/ndmpadm/Makefile
@@ -46,7 +46,7 @@ POFILE= ndmpadm.po
LDLIBS += -lndmp
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
.KEEP_STATE:
diff --git a/usr/src/cmd/ndmpd/Makefile b/usr/src/cmd/ndmpd/Makefile
index d1dd86cf8d..33b145b72c 100644
--- a/usr/src/cmd/ndmpd/Makefile
+++ b/usr/src/cmd/ndmpd/Makefile
@@ -71,7 +71,7 @@ LINTFLAGS += -xerroff=E_INCONS_ARG_USED2
CERRWARN += -_gcc=-Wno-unused-variable
CERRWARN += -_gcc=-Wno-switch
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-address
LDLIBS += -lsocket -lnsl -lzfs -lsec -lndmp -lmd5 -lnvpair -lumem -lbsm -lgen -lcmdutils -linetutil
diff --git a/usr/src/cmd/netadm/iu.ap.sh b/usr/src/cmd/netadm/iu.ap.sh
index 9ac9b143d4..a7247daf2e 100644
--- a/usr/src/cmd/netadm/iu.ap.sh
+++ b/usr/src/cmd/netadm/iu.ap.sh
@@ -20,6 +20,7 @@
# CDDL HEADER END
#
#
+# Copyright 2019 Peter Tribble.
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
@@ -72,7 +73,6 @@ case "$MACH" in
usbsprl -1 0 ldterm ttcompat
usbsksp -1 0 ldterm ttcompat
usbftdi -1 0 ldterm ttcompat
- ttymux -1 0 ldterm ttcompat
ipsecesp -1 0 ipsecesp
ipsecah -1 0 ipsecah
oplmsu 0 0 ldterm ttcompat
diff --git a/usr/src/cmd/newform/Makefile b/usr/src/cmd/newform/Makefile
index 56a6c40af3..f9a02ab204 100644
--- a/usr/src/cmd/newform/Makefile
+++ b/usr/src/cmd/newform/Makefile
@@ -27,7 +27,7 @@ PROG= newform
include ../Makefile.cmd
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
.KEEP_STATE:
diff --git a/usr/src/cmd/newtask/Makefile.com b/usr/src/cmd/newtask/Makefile.com
index 7f2dbf60ee..aa262f7ff7 100644
--- a/usr/src/cmd/newtask/Makefile.com
+++ b/usr/src/cmd/newtask/Makefile.com
@@ -35,7 +35,7 @@ CFLAGS += $(CCVERBOSE)
CFLAGS64 += $(CCVERBOSE)
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CPPFLAGS += -I..
diff --git a/usr/src/cmd/nl/Makefile b/usr/src/cmd/nl/Makefile
index 20caaeb35f..74877dc7d0 100644
--- a/usr/src/cmd/nl/Makefile
+++ b/usr/src/cmd/nl/Makefile
@@ -40,7 +40,7 @@ include ../Makefile.cmd
LDLIBS += -lgen
CFLAGS += $(CCVERBOSE)
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-unused-variable
# not linted
diff --git a/usr/src/cmd/nlsadmin/Makefile b/usr/src/cmd/nlsadmin/Makefile
index 9f88bb3986..7eeddca585 100644
--- a/usr/src/cmd/nlsadmin/Makefile
+++ b/usr/src/cmd/nlsadmin/Makefile
@@ -30,7 +30,7 @@ include ../Makefile.cmd
FILEMODE= 0755
CERRWARN += -_gcc=-Wno-implicit-function-declaration
CERRWARN += -_gcc=-Wno-unused-variable
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/nscd/Makefile b/usr/src/cmd/nscd/Makefile
index 08eb99fb30..9bd4d3e18f 100644
--- a/usr/src/cmd/nscd/Makefile
+++ b/usr/src/cmd/nscd/Makefile
@@ -61,7 +61,7 @@ LINTFLAGS += -erroff=E_NAME_USED_NOT_DEF2
LINTFLAGS += -erroff=E_NAME_DEF_NOT_USED2
CERRWARN += -_gcc=-Wno-switch
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-parentheses
CERRWARN += -_gcc=-Wno-type-limits
diff --git a/usr/src/cmd/pack/Makefile b/usr/src/cmd/pack/Makefile
index b50710d831..e86e527e95 100644
--- a/usr/src/cmd/pack/Makefile
+++ b/usr/src/cmd/pack/Makefile
@@ -29,7 +29,7 @@ include ../Makefile.cmd
CFLAGS += $(CCVERBOSE)
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
XGETFLAGS += -a -x $(PROG).xcl
CPPFLAGS += -D_FILE_OFFSET_BITS=64
diff --git a/usr/src/cmd/passmgmt/Makefile b/usr/src/cmd/passmgmt/Makefile
index 2ce3ab254f..21fd15a65f 100644
--- a/usr/src/cmd/passmgmt/Makefile
+++ b/usr/src/cmd/passmgmt/Makefile
@@ -41,7 +41,7 @@ $(ROOTFILE):= FILEMODE= $(LIBFILEMODE)
LDLIBS += -lsecdb -lnsl
CERRWARN += -_gcc=-Wno-type-limits
CERRWARN += -_gcc=-Wno-implicit-function-declaration
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/pbind/Makefile.com b/usr/src/cmd/pbind/Makefile.com
index 13f6fab98a..187d55b8ee 100644
--- a/usr/src/cmd/pbind/Makefile.com
+++ b/usr/src/cmd/pbind/Makefile.com
@@ -33,7 +33,7 @@ include ../../Makefile.cmd
LDLIBS += -lproc
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
.KEEP_STATE:
diff --git a/usr/src/cmd/pcitool/Makefile.com b/usr/src/cmd/pcitool/Makefile.com
index de7dd7c05b..ef5ec51668 100644
--- a/usr/src/cmd/pcitool/Makefile.com
+++ b/usr/src/cmd/pcitool/Makefile.com
@@ -31,7 +31,7 @@ UTSBASE = ../../../../src/uts
LDLIBS += -ldevinfo
CFLAGS += -D$(MACH) -I$(UTSBASE)/common
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-parentheses
CERRWARN += -_gcc=-Wno-unused-variable
diff --git a/usr/src/cmd/pg/Makefile b/usr/src/cmd/pg/Makefile
index c5ba757837..0b6b8d2dd9 100644
--- a/usr/src/cmd/pg/Makefile
+++ b/usr/src/cmd/pg/Makefile
@@ -34,7 +34,7 @@ XGETFLAGS += -a -x $(PROG).xcl
CPPFLAGS += -D_FILE_OFFSET_BITS=64
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-clobbered
.KEEP_STATE:
diff --git a/usr/src/cmd/picl/plugins/Makefile.com b/usr/src/cmd/picl/plugins/Makefile.com
index d56f0ec184..308c3782fe 100644
--- a/usr/src/cmd/picl/plugins/Makefile.com
+++ b/usr/src/cmd/picl/plugins/Makefile.com
@@ -31,7 +31,7 @@ CPPFLAGS += -I$(SRC)/cmd/picl/plugins/inc
CFLAGS += $(CCVERBOSE)
CERRWARN += -_gcc=-Wno-parentheses
CERRWARN += -_gcc=-Wno-char-subscripts
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-switch
CERRWARN += -_gcc=-Wno-unused-function
CERRWARN += -_gcc=-Wno-unused-variable
diff --git a/usr/src/cmd/picl/plugins/lib/picld_pluginutil/Makefile.com b/usr/src/cmd/picl/plugins/lib/picld_pluginutil/Makefile.com
index b590aa9806..e803da9e56 100644
--- a/usr/src/cmd/picl/plugins/lib/picld_pluginutil/Makefile.com
+++ b/usr/src/cmd/picl/plugins/lib/picld_pluginutil/Makefile.com
@@ -53,7 +53,7 @@ POFILE= picld_pluginutil.po
CPPFLAGS += -I.. -I$(SRC)/lib/libpicl -I$(SRC)/lib/libpicltree
CFLAGS += $(CCVERBOSE)
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
SMOFF += all_func_returns
diff --git a/usr/src/cmd/picl/plugins/sun4u/Makefile b/usr/src/cmd/picl/plugins/sun4u/Makefile
index b35c001756..2de3454ef2 100644
--- a/usr/src/cmd/picl/plugins/sun4u/Makefile
+++ b/usr/src/cmd/picl/plugins/sun4u/Makefile
@@ -22,9 +22,7 @@
#
# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
-#
-#
-# ident "%Z%%M% %I% %E% SMI"
+# Copyright 2019 Peter Tribble.
#
# cmd/picl/plugins/sun4u/Makefile
#
@@ -34,11 +32,11 @@ include $(SRC)/Makefile.master
SUBDIRS= lib .WAIT envmon .WAIT \
frudata grover excalibur psvc littleneck daktari \
cherrystone lw2plus lw8 taco enchilada chicago blade mpxu ents \
- chalupa silverstone sebring snowbird schumacher seattle boston .WAIT
+ chalupa silverstone sebring schumacher seattle boston .WAIT
MSGSUBDIRS= lib frudata grover excalibur psvc littleneck daktari \
cherrystone lw2plus lw8 taco enchilada chicago blade envmon mpxu ents \
- silverstone sebring snowbird
+ silverstone sebring
all := TARGET= all
install := TARGET= install
diff --git a/usr/src/cmd/picl/plugins/sun4u/snowbird/Makefile b/usr/src/cmd/picl/plugins/sun4u/snowbird/Makefile
deleted file mode 100644
index 6b83a0cd5c..0000000000
--- a/usr/src/cmd/picl/plugins/sun4u/snowbird/Makefile
+++ /dev/null
@@ -1,55 +0,0 @@
-#
-# 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 2009 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-
-# include library definitions
-include $(SRC)/lib/Makefile.lib
-include $(SRC)/Makefile.psm
-
-PLATFORM = SUNW,Netra-CP2300
-
-ROOTLIBDIR = $(ROOT_PLAT_PLUGINDIR)
-
-SUBDIRS= lib conf frutree envmond watchdog .WAIT
-MSGSUBDIRS= frutree envmond watchdog
-
-all := TARGET= all
-install := TARGET= install
-clean := TARGET= clean
-clobber := TARGET= clobber
-lint := TARGET= lint
-_msg := TARGET= _msg
-
-.KEEP_STATE:
-
-all clean clobber lint: $(SUBDIRS)
-
-install: $(SUBDIRS)
-
-_msg: $(MSGSUBDIRS)
-
-$(SUBDIRS): FRC
- @cd $@; pwd; $(MAKE) $(TARGET)
-
-FRC:
diff --git a/usr/src/cmd/picl/plugins/sun4u/snowbird/conf/Makefile b/usr/src/cmd/picl/plugins/sun4u/snowbird/conf/Makefile
deleted file mode 100644
index d2bf411ca6..0000000000
--- a/usr/src/cmd/picl/plugins/sun4u/snowbird/conf/Makefile
+++ /dev/null
@@ -1,75 +0,0 @@
-#
-# 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 2009 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-
-include $(SRC)/Makefile.psm
-
-# include library definitions
-include $(SRC)/lib/Makefile.lib
-
-PLATFORM = SUNW,Netra-CP2300
-ROOT_PLATFORM = $(USR_PLAT_DIR)/$(PLATFORM)
-
-include $(SRC)/cmd/picl/plugins/Makefile.com
-
-ROOTLIBDIR = $(ROOT_PLAT_PLUGINDIR)
-
-CONF_2300 = SUNW,Netra-CP2300.conf SUNW,Netra-CP2300.RTM.conf envmond.conf
-
-ROOTCONF_2300 = $(CONF_2300:%=$(ROOTLIBDIR)/%)
-$(ROOTCONF_2300) := FILEMODE = 0644
-ROOTLINTDIR_2300 = $(ROOTLIBDIR)
-
-.KEEP_STATE:
-
-SUBDIRS=
-
-all := TARGET= all
-install := TARGET= install
-clean := TARGET= clean
-clobber := TARGET= clobber
-lint := TARGET= lint
-
-all:
-
-install: $(ROOTLIBDIR) $(ROOTCONF_2300)
-
-$(CONF_2300): FRC
- $(RM) $(ROOTLIBPLUGINDIR)/$@
- $(INS) -s -m 0644 -f $(ROOT_PLAT_PLUGINDIR) $@
-
-# include library targets
-include $(SRC)/lib/Makefile.targ
-include $(SRC)/cmd/picl/plugins/Makefile.targ
-
-$(ROOTLINTDIR_2300)/%: ../%
- $(INS.file)
-
-lint:
-
-$(SUBDIRS): FRC
- @cd $@; pwd; $(MAKE) $(TARGET)
-
-FRC:
-
diff --git a/usr/src/cmd/picl/plugins/sun4u/snowbird/conf/SUNW,Netra-CP2300.RTM.conf b/usr/src/cmd/picl/plugins/sun4u/snowbird/conf/SUNW,Netra-CP2300.RTM.conf
deleted file mode 100644
index 2230a177f0..0000000000
--- a/usr/src/cmd/picl/plugins/sun4u/snowbird/conf/SUNW,Netra-CP2300.RTM.conf
+++ /dev/null
@@ -1,100 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (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 2004 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-#pragma ident "%Z%%M% %I% %E% SMI"
-VERSION 1.0
-
-NODE CPU location
- PROP State string r 0 "connected"
- PROP SlotType string r 0 "pci"
- PROP Label string r 0 "CPU"
- PROP devfs-path string r 0 "/pci@1f,0"
- PROP PdevProbePath string r 0 ""
- PROP bus-addr string r 0 "1,1"
- NODE CPU fru
- PROP FRUType string r 0 "bridge/fhs"
- PROP State string r 0 "configured"
- PROP Condition string r 0 "unknown"
- PROP AdminLock string rw 0 "disabled"
- NODE PMC-1 location
- PROP SlotType string r 0 "pci"
- PROP Label string r 0 "PMC-A"
- PROP bus-addr string r 0 "0x1"
- PROP GeoAddr uint r 1 1
- PROP devfs-path string r 0 "/pci@1f,0/pci@1"
- ENDNODE
- NODE PMC-2 location
- PROP SlotType string r 0 "pci"
- PROP Label string r 0 "PMC-B"
- PROP bus-addr string r 0 "0x2"
- PROP GeoAddr uint r 1 2
- PROP devfs-path string r 0 "/pci@1f,0/pci@1"
- ENDNODE
- ENDNODE
-ENDNODE
-NODE RTM location
- PROP State string r 0 "connected"
- PROP SlotType string r 0 "rtm"
- PROP Label string r 0 "RTM"
- PROP PdevProbePath string r 0 "/pci@1f,0"
- PROP bus-addr string r 0 "1,1"
- NODE RTM fru
- PROP FRUType string r 0 "RTM"
- PROP State string r 0 "configured"
- PROP Condition string r 0 "ok"
- PROP AdminLock string rw 0 "disabled"
- NODE su0 port
- PROP Label string r 0 "COM-A"
- PROP bus-addr string r 0 "0,3f8"
- PROP GeoAddr uint r 1 1
- PROP PortType string r 0 "serial"
- PROP devfs-path string r 0 "/pci@1f,0/pci@1,1/isa@7"
- ENDNODE
-
- NODE su1 port
- PROP Label string r 0 "COM-B"
- PROP bus-addr string r 0 "0,2e8"
- PROP GeoAddr uint r 1 2
- PROP PortType string r 0 "serial"
- PROP devfs-path string r 0 "/pci@1f,0/pci@1,1/isa@7"
- ENDNODE
-
- NODE dmfe0 port
- PROP Label string r 0 "ETHERNET A"
- PROP bus-addr string r 0 "1"
- PROP GeoAddr uint r 1 1
- PROP PortType string r 0 "network"
- PROP devfs-path string r 0 "/pci@1f,0/pci@1,1"
- ENDNODE
-
- NODE dmfe1 port
- PROP Label string r 0 "ETHERNET B"
- PROP bus-addr string r 0 "2"
- PROP GeoAddr uint r 1 2
- PROP PortType string r 0 "network"
- PROP devfs-path string r 0 "/pci@1f,0/pci@1,1"
- ENDNODE
- ENDNODE
-ENDNODE
diff --git a/usr/src/cmd/picl/plugins/sun4u/snowbird/conf/SUNW,Netra-CP2300.conf b/usr/src/cmd/picl/plugins/sun4u/snowbird/conf/SUNW,Netra-CP2300.conf
deleted file mode 100644
index 8970f5f94c..0000000000
--- a/usr/src/cmd/picl/plugins/sun4u/snowbird/conf/SUNW,Netra-CP2300.conf
+++ /dev/null
@@ -1,83 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (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 2004 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-#pragma ident "%Z%%M% %I% %E% SMI"
-VERSION 1.0
-
-NODE CPU location
- PROP State string r 0 "connected"
- PROP SlotType string r 0 "pci"
- PROP Label string r 0 "CPU"
- PROP bus-addr string r 0 "1,1"
- PROP devfs-path string r 0 "/pci@1f,0"
- PROP PdevProbePath string r 0 "/pci@1f,0"
- NODE CPU fru
- PROP FRUType string r 0 "bridge/fhs"
- PROP State string r 0 "configured"
- PROP Condition string r 0 "unknown"
- PROP AdminLock string rw 0 "disabled"
- NODE PMC-1 location
- PROP SlotType string r 0 "pci"
- PROP Label string r 0 "PMC-A"
- PROP bus-addr string r 0 "0x1"
- PROP GeoAddr uint r 1 1
- PROP devfs-path string r 0 "/pci@1f,0/pci@1"
- ENDNODE
- NODE PMC-2 location
- PROP SlotType string r 0 "pci"
- PROP Label string r 0 "PMC-B"
- PROP bus-addr string r 0 "0x2"
- PROP GeoAddr uint r 1 2
- PROP devfs-path string r 0 "/pci@1f,0/pci@1"
- ENDNODE
- NODE su0 port
- PROP Label string r 0 "COM"
- PROP bus-addr string r 0 "0,3f8"
- PROP GeoAddr uint r 1 1
- PROP PortType string r 0 "serial"
- PROP devfs-path string r 0 "/pci@1f,0/pci@1,1/isa@7"
- ENDNODE
- NODE dmfe0 port
- PROP Label string r 0 "ETHERNET A"
- PROP bus-addr string r 0 "1"
- PROP GeoAddr uint r 1 1
- PROP PortType string r 0 "network"
- PROP devfs-path string r 0 "/pci@1f,0/pci@1,1"
- ENDNODE
-
- NODE dmfe1 port
- PROP Label string r 0 "ETHERNET B"
- PROP bus-addr string r 0 "2"
- PROP GeoAddr uint r 1 2
- PROP PortType string r 0 "network"
- PROP devfs-path string r 0 "/pci@1f,0/pci@1,1"
- ENDNODE
- ENDNODE
-ENDNODE
-NODE RTM location
- PROP Label string r 0 "RTM"
- PROP State string r 0 "empty"
- PROP SlotType string r 0 "rtm"
-ENDNODE
diff --git a/usr/src/cmd/picl/plugins/sun4u/snowbird/conf/envmond.conf b/usr/src/cmd/picl/plugins/sun4u/snowbird/conf/envmond.conf
deleted file mode 100644
index bb0b1e2ba2..0000000000
--- a/usr/src/cmd/picl/plugins/sun4u/snowbird/conf/envmond.conf
+++ /dev/null
@@ -1,30 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (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 2004 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-#pragma ident "%Z%%M% %I% %E% SMI"
-#
-# The line format is:
-# interval policy_name policy_args
-10 alarmcard
diff --git a/usr/src/cmd/picl/plugins/sun4u/snowbird/envmond/Makefile b/usr/src/cmd/picl/plugins/sun4u/snowbird/envmond/Makefile
deleted file mode 100644
index c2a2d7e3e7..0000000000
--- a/usr/src/cmd/picl/plugins/sun4u/snowbird/envmond/Makefile
+++ /dev/null
@@ -1,106 +0,0 @@
-#
-# 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 2009 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-
-include $(SRC)/Makefile.psm
-
-LIBRARY = libpiclenvmond.a
-VERS = .1
-PLATFORM = SUNW,Netra-CP2300
-
-OBJECTS= piclenvmond.o piclsensors.o picldr.o piclplatmod.o
-
-# include library definitions
-include $(SRC)/lib/Makefile.lib
-
-ROOT_PLATFORM = $(USR_PLAT_DIR)/$(PLATFORM)
-
-include $(SRC)/cmd/picl/plugins/Makefile.com
-
-CFLAGS += $(CCVERBOSE)
-CPPFLAGS += -D_REENTRANT -D_SNOWBIRD \
- -I$(USR_PSM_INCL_DIR) \
- -I$(SRC)/uts/sun4u/sys \
- -I$(SRC)/cmd/picl/plugins/inc \
- -I$(SRC)/cmd/picl/plugins/sun4u/snowbird/lib/libctsmc
-
-SRCS= $(OBJECTS:%.o=%.c)
-
-LIBS = $(DYNLIB)
-
-ROOTLIBDIR = $(ROOT_PLAT_PLUGINDIR)
-
-CLEANFILES = $(LINTOUT) $(LINTLIB)
-
-LDLIBS += -L$(SRC)/lib/libptree/$(MACH)
-LDLIBS += -L$(SRC)/cmd/picl/plugins/sun4u/snowbird/lib/libctsmc
-LDLIBS += -L$(ROOT)/usr/lib/picl/plugins -lc -lpicltree \
- -lpicl -lnvpair -lm -ldevinfo -lcfgadm \
- -lpiclfrutree -lrcm -lctsmc
-LDLIBS += -R/usr/platform/$(PLATFORM)/lib
-LDLIBS += -R/usr/platform/$(PLATFORM)/lib/picl/plugins
-LDLIBS += -R/usr/platform/sun4u/lib/picl/plugins:/usr/lib/picl/plugins
-
-.KEEP_STATE:
-
-SUBDIRS=
-
-POFILE= snowbird_piclenvmond.po
-POFILES= $(SRCS:%.c=%.po)
-
-all := TARGET= all
-install := TARGET= install
-clean := TARGET= clean
-clobber := TARGET= clobber
-lint := TARGET= lint
-_msg := TARGET= _msg
-
-all: $(LIBS) $(LIBLINKS)
-
-install: $(ROOTLIBDIR) all $(ROOTLIBS) $(ROOTLINKS)
-
-$(LIBLINKS): FRC
- $(RM) $@; $(SYMLINK) ./$(DYNLIB) $@
-
-_msg: $(MSGDOMAIN) $(POFILE)
- $(RM) $(MSGDOMAIN)/$(POFILE)
- $(CP) $(POFILE) $(MSGDOMAIN)/$(POFILE)
-
-$(POFILE): $(POFILES)
- $(CAT) $(POFILES) > $(POFILE)
-
-$(MSGDOMAIN):
- $(INS.dir)
-
-# include library targets
-include $(SRC)/lib/Makefile.targ
-include $(SRC)/cmd/picl/plugins/Makefile.targ
-
-lint :
- $(LINT.c) $(SRCS)
-
-$(SUBDIRS): FRC
- @cd $@; pwd; $(MAKE) $(TARGET)
-
-FRC:
diff --git a/usr/src/cmd/picl/plugins/sun4u/snowbird/envmond/picldr.c b/usr/src/cmd/picl/plugins/sun4u/snowbird/envmond/picldr.c
deleted file mode 100644
index 9fa6a7cb27..0000000000
--- a/usr/src/cmd/picl/plugins/sun4u/snowbird/envmond/picldr.c
+++ /dev/null
@@ -1,822 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (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 2004 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <limits.h>
-#include <sys/systeminfo.h>
-#include <pthread.h>
-#include <syslog.h>
-#include <picl.h>
-#include <picltree.h>
-#include <picldefs.h>
-#include <string.h>
-#include <strings.h>
-#include <sys/param.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <stropts.h>
-#include <assert.h>
-#include <libnvpair.h>
-#include <libintl.h>
-#include <poll.h>
-#include <smclib.h>
-#include "piclenvmond.h"
-#include "picldr.h"
-
-/* external functions */
-extern picl_errno_t env_platmod_init();
-extern void env_platmod_handle_event(const char *, const void *, size_t);
-extern picl_errno_t env_platmod_create_sensors();
-extern picl_errno_t env_platmod_setup_hotswap();
-extern picl_errno_t env_platmod_sp_monitor();
-extern picl_errno_t env_platmod_handle_bus_if_change(uint8_t);
-extern picl_errno_t env_platmod_handle_latch_open();
-extern void env_platmod_handle_sensor_event(void *);
-extern int process_platmod_sp_state_change_notif(void *);
-extern int process_platmod_change_cpu_node_state(void *);
-extern int process_platmod_change_cpci_state(void *);
-extern int process_platmod_async_msg_notif(void *);
-extern void process_platmod_sp_heartbeat(uint8_t);
-extern picl_errno_t env_platmod_create_hotswap_prop();
-extern picl_errno_t env_create_property(int ptype, int pmode,
- size_t psize, char *pname, int (*readfn)(ptree_rarg_t *, void *),
- int (*writefn)(ptree_warg_t *, const void *),
- picl_nodehdl_t nodeh, picl_prophdl_t *propp, void *vbuf);
-extern char *strtok_r(char *s1, const char *s2, char **lasts);
-
-/* external variables */
-extern int env_debug;
-
-static char sys_name[SYS_NMLN];
-static char chassisconf_name[SYS_NMLN];
-static boolean_t parse_config_file = B_FALSE;
-static int8_t alarm_check_interval = -1;
-static picl_nodehdl_t frutreeh = 0;
-static pthread_t polling_threadID;
-static boolean_t create_polling_thr = B_TRUE;
-
-/* globals */
-uint8_t cpu_geo_addr = 0;
-picl_nodehdl_t rooth = 0, chassis_nodehdl = 0, cpu_nodehdl = 0;
-picl_nodehdl_t platformh = 0, sysmgmth = 0, cpu_lnodehdl = 0;
-
-/*
- * envmond policy structure
- */
-typedef struct _policy {
- uint8_t interval;
- char *pname;
- char *argp;
- struct _policy *nextp;
-} env_policy_t;
-
-/*
- * read_policy_configuration - extract info. from the envmond.conf
- */
-static int
-env_read_policy_configuration(char *conffile, env_policy_t **policypp)
-{
- FILE *fp;
- char buf[RECORD_MAXSIZE];
- char *token, *lasts;
- env_policy_t *policyp;
-
- if ((fp = fopen(conffile, "r")) == NULL) {
- return (-1);
- }
- while (fgets(buf, sizeof (buf), fp) != NULL) {
- if (buf[0] && (buf[0] == '#' || buf[0] == '\n')) {
- continue;
- }
- token = (char *)strtok_r(buf, RECORD_WHITESPACE, &lasts);
- if (token == NULL) {
- continue;
- }
- policyp = (env_policy_t *)malloc(sizeof (env_policy_t));
- if (policyp == NULL) {
- goto errors;
- }
- policyp->interval = (uint8_t)strtoul(token, NULL, 0);
- token = (char *)strtok_r(lasts, RECORD_WHITESPACE, &lasts);
- if (token == NULL) {
- free(policyp);
- } else {
- policyp->pname = strdup(token);
- if (NULL == policyp->pname) {
- goto errors;
- }
- }
- if (lasts) {
- policyp->argp = strdup(lasts);
- if (policyp->argp == NULL) {
- goto errors;
- }
- } else {
- policyp->argp = NULL;
- }
- policyp->nextp = *policypp;
- *policypp = policyp;
- }
- (void) fclose(fp);
- return (0);
-
-errors:
- (void) fclose(fp);
- while (*policypp) {
- policyp = *policypp;
- *policypp = (*policypp)->nextp;
- free(policyp->pname);
- free(policyp->argp);
- free(policyp);
- }
- return (-1);
-}
-
-/*
- * supports environmental policies
- */
-static void
-env_parse_config_file()
-{
- char conffile[MAXPATHLEN];
- env_policy_t *policyp, *tmp;
- struct stat st;
-
- if (parse_config_file == B_FALSE) {
- return;
- }
- (void) snprintf(conffile, sizeof (conffile), ENV_CONFIG_FILE,
- sys_name);
- bzero(&st, sizeof (st));
- if (stat(conffile, &st) == -1) {
- return;
- }
-
- policyp = NULL;
- if (env_read_policy_configuration(conffile, &policyp) == -1) {
- return;
- }
- assert(policyp);
-
- while (policyp) {
- tmp = policyp;
- policyp = policyp->nextp;
- if (strcmp(tmp->pname, SERVICE_PROCESSOR) == 0) {
- alarm_check_interval = tmp->interval;
- if (env_debug & DEBUG)
- syslog(LOG_INFO, "Alarm Heartbeat frequency: "
- "%d seconds", alarm_check_interval);
- }
- free(tmp->pname);
- free(tmp->argp);
- free(tmp);
- }
-}
-
-/*
- * detects the presence of RTM for CPU board
- */
-static boolean_t
-is_rtm_present()
-{
- sc_reqmsg_t req_pkt;
- sc_rspmsg_t rsp_pkt;
- uint8_t size = 0;
-
- req_pkt.data[0] = ENV_RTM_BUS_ID;
- req_pkt.data[1] = ENV_RTM_SLAVE_ADDR;
- req_pkt.data[2] = ENV_RTM_READ_SIZE;
- size = ENV_RTM_PKT_LEN;
-
- /* initialize the request packet */
- (void) smc_init_smc_msg(&req_pkt, SMC_MASTER_RW_CMD,
- DEFAULT_SEQN, size);
-
- /* make a call to smc library to send cmd */
- if (smc_send_msg(DEFAULT_FD, &req_pkt, &rsp_pkt,
- POLL_TIMEOUT) != SMC_SUCCESS) {
- return (B_FALSE);
- }
- return (B_TRUE);
-}
-
-/*
- * this routine does the following:
- * 1. initializes the CPU geo-addr
- * 2. gets the system name
- * 3. create the chassis type property
- * 4. creates the conf_file property
- */
-static picl_errno_t
-env_set_cpu_info()
-{
- int rc = 0;
- sc_reqmsg_t req_pkt;
- sc_rspmsg_t rsp_pkt;
- uint8_t size = 0;
- char conf_name[PICL_PROPNAMELEN_MAX];
-
- /* get the geo_addr */
- /* initialize the request packet */
- (void) smc_init_smc_msg(&req_pkt, SMC_GET_GEOGRAPHICAL_ADDRESS,
- DEFAULT_SEQN, size);
-
- /* make a call to smc library to send cmd */
- if (smc_send_msg(DEFAULT_FD, &req_pkt, &rsp_pkt,
- POLL_TIMEOUT) != SMC_SUCCESS) {
- return (PICL_FAILURE);
- }
- cpu_geo_addr = rsp_pkt.data[0];
-
- /* get the system name */
- if (sysinfo(SI_PLATFORM, sys_name, sizeof (sys_name)) == -1) {
- return (PICL_FAILURE);
- }
- (void) strncpy(chassisconf_name, sys_name,
- sizeof (chassisconf_name));
-
- /* initialize the node handles */
- if ((rc = ptree_get_root(&rooth)) != PICL_SUCCESS) {
- return (rc);
- }
-
- if ((rc = ptree_get_node_by_path(FRUTREE_PATH, &frutreeh)) !=
- PICL_SUCCESS) {
- return (rc);
- }
-
- if ((rc = ptree_get_node_by_path(PICL_FRUTREE_CHASSIS,
- &chassis_nodehdl)) != PICL_SUCCESS) {
- return (rc);
- }
-
- /* create the chassis type property */
- if ((rc = env_create_property(PICL_PTYPE_CHARSTRING,
- PICL_READ, PICL_PROPNAMELEN_MAX, PICL_PROP_CHASSIS_TYPE,
- NULLREAD, NULLWRITE, chassis_nodehdl, (picl_prophdl_t *)NULL,
- chassisconf_name)) != PICL_SUCCESS) {
- return (rc);
- }
-
- /*
- * create dummy prop to inform frutree plugin abt conf file
- * (rtm based or w/o rtm)
- * frutree plugin removes this prop after reading the value
- */
- if (is_rtm_present() == B_TRUE) {
- (void) snprintf(conf_name, sizeof (conf_name),
- "%s.RTM.conf", chassisconf_name);
- } else {
- (void) snprintf(conf_name, sizeof (conf_name),
- "%s.conf", chassisconf_name);
- }
-
- if ((rc = env_create_property(PICL_PTYPE_CHARSTRING,
- PICL_READ, PICL_PROPNAMELEN_MAX, PICL_PROP_CONF_FILE, NULLREAD,
- NULLWRITE, chassis_nodehdl, (picl_prophdl_t *)NULL,
- conf_name)) != PICL_SUCCESS) {
- return (rc);
- }
- return (PICL_SUCCESS);
-}
-
-/*
- * initialization
- */
-picl_errno_t
-env_init()
-{
- picl_errno_t rc = PICL_SUCCESS;
-
- if ((rc = env_set_cpu_info()) != PICL_SUCCESS) {
- return (rc);
- }
-
- /* parse the configuration file */
- env_parse_config_file();
-
- /*
- * do any platform specific intialization if required
- * IMPORTANT: must post dr_incoming resource event on
- * chassis after doing all the reqd checks
- */
- rc = env_platmod_init();
- return (rc);
-}
-
-/*
- * sets smc global enables
- */
-static int
-env_set_smc_global_enables(boolean_t ipmi_enable)
-{
- sc_reqmsg_t req_pkt;
- sc_rspmsg_t rsp_pkt;
- uint8_t size = 0;
-
- /* initialize the request packet */
- (void) smc_init_smc_msg(&req_pkt, SMC_GET_GLOBAL_ENABLES,
- DEFAULT_SEQN, size);
-
- /* make a call to smc library to send cmd */
- if (smc_send_msg(DEFAULT_FD, &req_pkt, &rsp_pkt,
- POLL_TIMEOUT) != SMC_SUCCESS) {
- return (-1);
- }
-
- req_pkt.data[0] = rsp_pkt.data[0];
- req_pkt.data[1] = rsp_pkt.data[1];
- if (ipmi_enable) {
- req_pkt.data[1] |= ENV_IPMI_ENABLE_MASK;
- req_pkt.data[1] &= ENV_SENSOR_ENABLE_MASK;
- } else {
- req_pkt.data[1] &= ENV_IPMI_DISABLE_MASK;
- req_pkt.data[1] |= ENV_SENSOR_DISABLE_MASK;
- }
- size = ENV_SET_GLOBAL_PKT_LEN;
- (void) smc_init_smc_msg(&req_pkt, SMC_SET_GLOBAL_ENABLES,
- DEFAULT_SEQN, size);
-
- /* make a call to smc library to send cmd */
- if (smc_send_msg(DEFAULT_FD, &req_pkt, &rsp_pkt,
- POLL_TIMEOUT) != SMC_SUCCESS) {
- return (-1);
- }
- return (0);
-}
-
-/*
- * wrapper smc drv open
- */
-int
-env_open_smc(void)
-{
- int fd;
- if ((fd = open(SMC_NODE, O_RDWR)) < 0) {
- return (-1);
- }
- return (fd);
-}
-
-static picl_smc_event_t
-env_handle_smc_local_event(void *res_datap)
-{
- picl_errno_t rc = PICL_SUCCESS;
- uint8_t event = SMC_LOCAL_EVENT;
- uint8_t event_data = BYTE_0(res_datap);
-
- if (env_debug & EVENTS)
- syslog(LOG_INFO, "Local Event Received, data %x\n", event_data);
-
- switch (event_data) {
- case SMC_LOCAL_EVENT_BRIDGE_IN_RESET : /*FALLTHRU*/
- case SMC_LOCAL_EVENT_BRIDGE_OUT_OF_RESET :
- if ((rc = env_platmod_handle_bus_if_change(
- event_data)) != PICL_SUCCESS) {
- syslog(LOG_ERR, gettext("SUNW_envmond:Error"
- " in handling bus interface change "
- "event, error = %d"), rc);
- }
- break;
- case SMC_LOCAL_EVENT_LATCH_OPENED:
- syslog(LOG_INFO, gettext("LATCH OPEN DETECTED"));
- if ((rc = env_platmod_handle_latch_open()) !=
- PICL_SUCCESS) {
- syslog(LOG_ERR, gettext("SUNW_envmond:Error"
- " in handling latch open event, "
- "error = %d"), rc);
- }
- break;
- default:
- break;
- }
- return (event);
-}
-
-static void
-env_handle_async_msg_event(void *res_datap)
-{
- int rc = SMC_SUCCESS;
- uint8_t event = BYTE_6(res_datap);
-
- if (env_debug & EVENTS)
- syslog(LOG_INFO, "Asynchronous Event %x Received, data %x\n",
- event, BYTE_7(res_datap));
- switch (event) {
- /*
- * This message comes to CPU when the service processor is going offline
- * or online.
- */
- case EVENT_MSG_AC_STATE_CHANGE:
- if ((rc = process_platmod_sp_state_change_notif(res_datap)) !=
- SMC_SUCCESS) {
- syslog(LOG_ERR, gettext("SUNW_envmond:Error in handling"
- "service processor change of state event, "
- "error = %d"), rc);
- }
- break;
- /*
- * This message comes to CPU when service processor
- * requests the CPU to go online or offline (shutdown).
- */
- case EVENT_MSG_CHANGE_CPU_NODE_STATE:
- if ((rc = process_platmod_change_cpu_node_state(res_datap)) !=
- SMC_SUCCESS) {
- syslog(LOG_ERR, gettext("SUNW_envmond:Error in handling"
- "cpu change of state event, error = %d"), rc);
- }
- break;
- /*
- * This message comes to CPU(Satellite) when the
- * other node (Host) is going online or offline.
- */
- case EVENT_MSG_CHANGE_CPCI_STATE:
- if ((rc = process_platmod_change_cpci_state(res_datap)) !=
- SMC_SUCCESS) {
- syslog(LOG_ERR, gettext("SUNW_envmond:Error in handling"
- "cpci change state event, error = %d"), rc);
- }
- break;
- /*
- * This message comes from service processor to inform
- * change in states for other nodes
- */
- case EVENT_MSG_ASYNC_EVENT_NOTIFICATION:
- if ((rc = process_platmod_async_msg_notif(res_datap)) !=
- SMC_SUCCESS) {
- syslog(LOG_ERR, gettext("SUNW_envmond:Error in handling"
- "async event notification, error = %d"), rc);
- }
- break;
- case MSG_GET_CPU_NODE_STATE:
- /* respond to the service processor heartbeat */
- process_platmod_sp_heartbeat(BYTE_5(res_datap));
- break;
- default:
- event = NO_EVENT;
- break;
- }
-}
-
-/*ARGSUSED*/
-static picl_smc_event_t
-env_process_smc_event(int fd, void **datapp)
-{
- sc_rspmsg_t rsp_msg;
- picl_smc_event_t event;
- void *res_datap = NULL;
-
- if (read(fd, (char *)&rsp_msg, SC_MSG_MAX_SIZE) < 0) {
- return (NO_EVENT);
- }
-
- if (SC_MSG_CC(&rsp_msg) != 0) {
- return (NO_EVENT);
- }
-
- res_datap = SC_MSG_DATA(&rsp_msg);
- if (env_debug & EVENTS)
- syslog(LOG_INFO, "Async Msg Cmd,data0,2 = %x,%x,%x\n",
- SC_MSG_CMD(&rsp_msg), BYTE_0(res_datap),
- BYTE_2(res_datap));
-
- if (SC_MSG_CMD(&rsp_msg) == SMC_SMC_LOCAL_EVENT_NOTIF) {
- event = env_handle_smc_local_event(res_datap);
- } else { /* it must be an IPMI event */
- switch (BYTE_2(res_datap)) {
- case 0x3:
- case 0x4:
- if (env_debug & DEBUG)
- syslog(LOG_INFO, gettext("SUNW_envmond: "
- " Sensor Event Received\n"));
- /* sensor event */
- switch (BYTE_3(res_datap)) {
- case TEMPERATURE_SENSOR_TYPE:
- event = TEMPERATURE_SENSOR_EVENT;
- env_platmod_handle_sensor_event(res_datap);
- break;
- default:
- syslog(LOG_ERR, gettext("SUNW_envmond:Unknown "
- "sensor Event:%d\n"), BYTE_3(res_datap));
- event = NO_EVENT;
- break;
- }
- default:
- env_handle_async_msg_event(res_datap);
- break;
- }
- }
- return (event);
-}
-
-/*
- * polls SMC driver for SMC events
- */
-/*ARGSUSED*/
-static void *
-env_polling_thread(void *args)
-{
- int poll_rc;
- struct pollfd poll_fds[1];
- void *datap;
- int smcfd;
- struct strioctl strio;
- sc_cmdspec_t set;
-
- smcfd = env_open_smc();
- if (smcfd == -1) {
- syslog(LOG_ERR, gettext("SUNW_envmond:Error in polling, "
- "Open of SMC drv failed"));
- create_polling_thr = B_TRUE;
- return (NULL);
- }
-
- set.args[0] = SMC_SENSOR_EVENT_ENABLE_SET;
- set.attribute = SC_ATTR_SHARED;
- strio.ic_cmd = SCIOC_MSG_SPEC;
- strio.ic_timout = 0;
- strio.ic_len = ENV_SENSOR_EV_ENABLE_PKT_LEN;
- strio.ic_dp = (char *)&set;
- if (ioctl(smcfd, I_STR, &strio) < 0) {
- syslog(LOG_ERR, gettext("SUNW_envmond:Request for "
- "Sensor events failed"));
- (void) close(smcfd);
- create_polling_thr = B_TRUE;
- return (NULL);
- }
-
- /* request for async messages */
- poll_fds[0].fd = smcfd;
- poll_fds[0].events = POLLIN|POLLPRI;
- poll_fds[0].revents = 0;
-
- set.attribute = SC_ATTR_SHARED;
- set.args[0] = SMC_IPMI_RESPONSE_NOTIF;
- set.args[1] = SMC_SMC_LOCAL_EVENT_NOTIF;
- strio.ic_cmd = SCIOC_MSG_SPEC;
- strio.ic_timout = 0;
- strio.ic_len = ENV_IPMI_SMC_ENABLE_PKT_LEN;
- strio.ic_dp = (char *)&set;
- if (ioctl(smcfd, I_STR, &strio) == -1) {
- syslog(LOG_ERR, gettext("SUNW_envmond:Request for"
- "Async messages failed"));
- (void) close(smcfd);
- create_polling_thr = B_TRUE;
- return (NULL);
- }
-
- /* Now wait for SMC events to come */
- for (;;) {
- poll_rc = poll(poll_fds, 1, -1); /* poll forever */
- if (poll_rc < 0) {
- syslog(LOG_ERR, gettext("SUNW_envmond:Event "
- "processing halted"));
- break;
- }
- if (env_process_smc_event(smcfd, &datap) == NO_EVENT) {
- syslog(LOG_ERR, gettext("SUNW_envmond:"
- "wrong event data posted from SMC"));
- }
- }
- (void) close(smcfd);
- create_polling_thr = B_TRUE;
- return (NULL);
-}
-
-/*
- * (to be)Called during chassis configuration. It does the following tasks.
- * Set global enables on SMC
- * Register for local(SMC) events and remote(IPMI) messages (State Change msgs)
- * creates sensor nodes
- * Initialize hotswap
- * Initiallize the interaction with service processor
- */
-static picl_errno_t
-env_start_services(void)
-{
- int rc;
- if (env_debug & DEBUG) {
- syslog(LOG_INFO, "env_start_services begin");
- }
-
- /* set the SMC global enables */
- if (env_set_smc_global_enables(B_TRUE) == -1) {
- syslog(LOG_ERR, gettext("SUNW_envmond:Setting SMC "
- "Globals failed"));
- return (PICL_FAILURE);
- }
-
- /* start a worker thread to poll for SMC events */
- if (create_polling_thr) {
- rc = pthread_create(&polling_threadID, NULL,
- &env_polling_thread, NULL);
- if (rc != 0) {
- syslog(LOG_ERR, gettext("SUNW_envmond:Error in "
- "creating polling thread"));
- return (PICL_FAILURE);
- }
- create_polling_thr = B_FALSE;
- }
-
- /* create the sensor nodes */
- if ((rc = env_platmod_create_sensors()) != PICL_SUCCESS) {
- syslog(LOG_ERR, gettext("SUNW_envmond:Error in creating sensor"
- " nodes, error = %d"), rc);
- }
-
- /* intialize the hotswap framework */
- if ((rc = env_platmod_setup_hotswap()) != PICL_SUCCESS) {
- syslog(LOG_ERR, gettext("SUNW_envmond:Error in hotswap "
- "initialization, error = %d"), rc);
- }
-
- if ((rc = env_platmod_create_hotswap_prop()) != PICL_SUCCESS) {
- syslog(LOG_ERR, gettext("SUNW_envmond:Error in creating "
- "hotswap prop, error = %d"), rc);
- }
-
- /* intialize interaction with service processor */
- if ((rc = env_platmod_sp_monitor()) != PICL_SUCCESS) {
- syslog(LOG_ERR, gettext("SUNW_envmond:Failed to interact with"
- " service processor, error = %d"), rc);
- }
- return (PICL_SUCCESS);
-}
-
-static picl_errno_t
-env_handle_chassis_configuring_event(char *state)
-{
- picl_errno_t rc = PICL_SUCCESS;
- picl_prophdl_t proph;
- picl_nodehdl_t rtm_lnodehdl = 0;
- char *cpu_name = PICL_NODE_CPU;
- char *rtm_name = PICL_NODE_RTM;
- uint64_t status_time;
-
- if (strcmp(state, PICLEVENTARGVAL_CONFIGURING) != 0) {
- return (PICL_SUCCESS);
- }
-
- /* initialize cpu loc node handle */
- if (cpu_lnodehdl == 0) {
- if ((rc = ptree_find_node(chassis_nodehdl,
- PICL_PROP_NAME, PICL_PTYPE_CHARSTRING,
- cpu_name, (strlen(cpu_name) + 1),
- &cpu_lnodehdl)) != PICL_SUCCESS) {
- syslog(LOG_ERR, gettext("SUNW_envmond: failed "
- " to get CPU nodehdl, error = %d"), rc);
- return (rc);
- }
- }
-
- /* create geo-addr prop under CPU location */
- if (ptree_get_prop_by_name(cpu_lnodehdl, PICL_PROP_GEO_ADDR,
- &proph) == PICL_PROPNOTFOUND) {
- if ((rc = env_create_property(PICL_PTYPE_UNSIGNED_INT,
- PICL_READ, sizeof (cpu_geo_addr),
- PICL_PROP_GEO_ADDR, NULLREAD, NULLWRITE,
- cpu_lnodehdl, &proph,
- (void *)&cpu_geo_addr)) != PICL_SUCCESS) {
- return (rc);
- }
- }
- if (ptree_get_prop_by_name(cpu_lnodehdl,
- PICL_PROP_STATUS_TIME, &proph) != PICL_SUCCESS) {
- status_time = (uint64_t)time(NULL);
- (void) env_create_property(PICL_PTYPE_TIMESTAMP,
- PICL_READ, sizeof (status_time),
- PICL_PROP_STATUS_TIME, NULLREAD, NULLWRITE,
- cpu_lnodehdl, &proph, &status_time);
- }
-
- /* create geo address property for RTM node (if present) */
- (void) ptree_find_node(chassis_nodehdl,
- PICL_PROP_NAME, PICL_PTYPE_CHARSTRING, rtm_name,
- (strlen(rtm_name) + 1), &rtm_lnodehdl);
-
- if (rtm_lnodehdl == 0) { /* RTM not present */
- return (PICL_SUCCESS);
- }
-
- if (ptree_get_prop_by_name(rtm_lnodehdl, PICL_PROP_GEO_ADDR,
- &proph) == PICL_PROPNOTFOUND) {
- if ((rc = env_create_property(PICL_PTYPE_UNSIGNED_INT,
- PICL_READ, sizeof (cpu_geo_addr), PICL_PROP_GEO_ADDR,
- NULLREAD, NULLWRITE, rtm_lnodehdl, &proph,
- &cpu_geo_addr)) != PICL_SUCCESS) {
- syslog(LOG_ERR, gettext("SUNW_envmond:Failed "
- "to create CPU geo-addr, error = %d"), rc);
- return (rc);
- }
- }
- if (ptree_get_prop_by_name(rtm_lnodehdl,
- PICL_PROP_STATUS_TIME, &proph) != PICL_SUCCESS) {
- status_time = (uint64_t)time(NULL);
- (void) env_create_property(PICL_PTYPE_TIMESTAMP,
- PICL_READ, sizeof (status_time), PICL_PROP_STATUS_TIME,
- NULLREAD, NULLWRITE, rtm_lnodehdl, &proph,
- &status_time);
- }
-
- /* start all the environment monitoring services */
- if ((rc = env_start_services()) != PICL_SUCCESS) {
- return (rc);
- }
- return (PICL_SUCCESS);
-}
-
-/*
- * routine to handle all the picl state and condition change events
- */
-void
-env_handle_event(const char *ename, const void *earg, size_t size)
-{
- picl_nodehdl_t nodeh = 0;
- nvlist_t *nvlp;
- char *value;
- boolean_t state_event;
- char result[PICL_PROPNAMELEN_MAX];
-
- if (!ename) {
- return;
- }
- if (strcmp(ename, PICLEVENT_STATE_CHANGE) == 0) {
- state_event = B_TRUE;
- } else if (strcmp(ename, PICLEVENT_CONDITION_CHANGE) == 0) {
- state_event = B_FALSE;
- } else {
- return;
- }
-
- /* unpack the nvlist and get the information */
- if (nvlist_unpack((char *)earg, size, &nvlp, NULL)) {
- return;
- }
- if (nvlist_lookup_uint64(nvlp, PICLEVENTARG_NODEHANDLE, &nodeh) == -1) {
- nvlist_free(nvlp);
- return;
- }
- if (nvlist_lookup_string(nvlp, (state_event) ?
- PICLEVENTARG_STATE :
- PICLEVENTARG_CONDITION, &value) != 0) {
- nvlist_free(nvlp);
- return;
- }
-
- if (env_debug & PICLEVENTS) {
- if (ptree_get_propval_by_name(nodeh, PICL_PROP_NAME,
- result, sizeof (result)) != PICL_SUCCESS) {
- syslog(LOG_ERR, " SUNW_envmond: error in getting"
- " %s", PICL_PROP_NAME);
- nvlist_free(nvlp);
- return;
- }
- syslog(LOG_INFO, "SUNW_envmond: %s (%s) on %s",
- ename, value, result);
- }
-
- if (chassis_nodehdl == 0 && state_event) {
- if (ptree_get_propval_by_name(nodeh, PICL_PROP_NAME,
- result, sizeof (result)) != PICL_SUCCESS) {
- nvlist_free(nvlp);
- return;
- }
- if (strcmp(result, PICL_NODE_CHASSIS) == 0) {
- chassis_nodehdl = nodeh;
- }
- }
- if (nodeh == chassis_nodehdl && state_event) {
- (void) env_handle_chassis_configuring_event(value);
- }
- /* do any platform specific handling that is reqd */
- env_platmod_handle_event(ename, earg, size);
- nvlist_free(nvlp);
-}
diff --git a/usr/src/cmd/picl/plugins/sun4u/snowbird/envmond/picldr.h b/usr/src/cmd/picl/plugins/sun4u/snowbird/envmond/picldr.h
deleted file mode 100644
index d3f9e6fefd..0000000000
--- a/usr/src/cmd/picl/plugins/sun4u/snowbird/envmond/picldr.h
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (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 2004 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#ifndef _PICLDR_H
-#define _PICLDR_H
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef enum picl_smc_event {
- NO_EVENT = 0,
- TEMPERATURE_SENSOR_EVENT,
- CPU_NODE_STATE_CHANGE_NOTIFICATION,
- CHANGE_CPCI_STATE, /* request to config/unconfig cpci i/f */
- CHANGE_CPU_NODE_STATE, /* request on online/offline node */
- SMC_LOCAL_EVENT
-} picl_smc_event_t;
-
-#define SMC_NODE "/dev/ctsmc"
-#define SMC_BMC_ADDR 0x20
-#define CPU_NODE_STATE_ONLINE 1
-#define CPU_NODE_STATE_OFFLINE 0
-
-/* event messages */
-#define EVENT_MSG_AC_STATE_CHANGE 0xf5
-#define EVENT_MSG_CHANGE_CPCI_STATE 0x65
-#define EVENT_MSG_CHANGE_CPU_NODE_STATE 0x62
-#define EVENT_MSG_ASYNC_EVENT_NOTIFICATION 0x82
-#define MSG_GET_CPU_NODE_STATE 0x61
-#define SMC_LOCAL_EVENT_BRIDGE_IN_RESET 0x00
-#define SMC_LOCAL_EVENT_BRIDGE_OUT_OF_RESET 0x01
-#define SMC_LOCAL_EVENT_LATCH_OPENED 0x06
-
-#define CPCI_STATE_OFFLINE 0
-#define CPCI_STATE_ONLINE 1
-#define SATCPU_STATE_ONLINE 0x7
-#define SATCPU_STATE_OFFLINE 0x8
-#define HEALTHY_ASSERT 1
-#define HEALTHY_DEASSERT 2
-
-#define SMC_MASTER_RW_CMD 0x90
-#define ENV_CONFIG_FILE "/usr/platform/%s/lib/picl/plugins/envmond.conf"
-#define RECORD_MAXSIZE (256)
-#define RECORD_WHITESPACE (": \t")
-#define SERVICE_PROCESSOR "alarmcard"
-
-/* packet lengths */
-#define ENV_RTM_PKT_LEN 3
-#define ENV_SET_GLOBAL_PKT_LEN 2
-#define ENV_SENSOR_EV_ENABLE_PKT_LEN 2
-#define ENV_IPMI_SMC_ENABLE_PKT_LEN 3
-
-/* rtm pkt data */
-#define ENV_RTM_BUS_ID 7
-#define ENV_RTM_SLAVE_ADDR 0xa0
-#define ENV_RTM_READ_SIZE 0xa
-
-/* global enables data */
-#define ENV_IPMI_ENABLE_MASK 0x10
-#define ENV_IPMI_DISABLE_MASK 0xef
-#define ENV_SENSOR_ENABLE_MASK 0xfb
-#define ENV_SENSOR_DISABLE_MASK 0x04
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _PICLDR_H */
diff --git a/usr/src/cmd/picl/plugins/sun4u/snowbird/envmond/piclenvmond.c b/usr/src/cmd/picl/plugins/sun4u/snowbird/envmond/piclenvmond.c
deleted file mode 100644
index d74a28f116..0000000000
--- a/usr/src/cmd/picl/plugins/sun4u/snowbird/envmond/piclenvmond.c
+++ /dev/null
@@ -1,436 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (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 2004 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <unistd.h>
-#include <picl.h>
-#include <picltree.h>
-#include <picldefs.h>
-#include <pthread.h>
-#include <syslog.h>
-#include <string.h>
-#include <libnvpair.h>
-#include <libintl.h>
-#include "piclenvmond.h"
-
-/* external funcs and varaibles */
-extern void env_handle_event(const char *, const void *, size_t);
-extern picl_errno_t env_init();
-extern void env_platmod_fini();
-extern int sensor_fd;
-extern pthread_t env_temp_thr_tid;
-
-/* local defines */
-#define TIMEOUT (10)
-
-#pragma init(piclenvmond_register)
-
-/*
- * Plugin registration entry points
- */
-static void piclenvmond_register(void);
-static void piclenvmond_init(void);
-static void piclenvmond_fini(void);
-static void piclenvmond_evhandler(const char *, const void *, size_t, void *);
-
-int env_debug = 0x0;
-
-static picld_plugin_reg_t envmond_reg_info = {
- PICLD_PLUGIN_VERSION_1,
- PICLD_PLUGIN_CRITICAL,
- "SUNW_piclenvmond",
- piclenvmond_init,
- piclenvmond_fini
-};
-
-typedef struct {
- picl_nodehdl_t nodehdl;
- char node_name[PICL_PROPNAMELEN_MAX];
-} env_callback_args_t;
-
-/*
- * picld entry points
- */
-static void
-piclenvmond_register(void)
-{
- (void) picld_plugin_register(&envmond_reg_info);
-}
-
-/*
- * picld entry point
- * - do all the initialization
- * - register for interested picl events
- */
-static void
-piclenvmond_init(void)
-{
- picl_errno_t rc = PICL_SUCCESS;
-
- if ((rc = env_init()) != PICL_SUCCESS) {
- syslog(LOG_ERR, gettext("SUNW_envmond:envmond init failed, "
- "error = %d"), rc);
- return;
- }
-
- /* register handler for state change events */
- (void) ptree_register_handler(PICLEVENT_STATE_CHANGE,
- piclenvmond_evhandler, NULL);
- /* register handler for condition change events */
- (void) ptree_register_handler(PICLEVENT_CONDITION_CHANGE,
- piclenvmond_evhandler, NULL);
-
-}
-
-static void
-piclenvmond_fini(void)
-{
- void *exitval;
-
- /* unregister event handler */
- (void) ptree_unregister_handler(PICLEVENT_STATE_CHANGE,
- piclenvmond_evhandler, NULL);
- (void) ptree_unregister_handler(PICLEVENT_CONDITION_CHANGE,
- piclenvmond_evhandler, NULL);
-
- /* cancel all the threads */
- (void) pthread_cancel(env_temp_thr_tid);
- (void) pthread_join(env_temp_thr_tid, &exitval);
-
- /* do any platform specific cleanups required */
- env_platmod_fini();
- (void) close(sensor_fd);
-}
-
-/*ARGSUSED*/
-static void
-piclenvmond_evhandler(const char *ename, const void *earg, size_t size,
- void *cookie)
-{
- env_handle_event(ename, earg, size);
-}
-
-/*
- * Utility functions
- */
-
-/*
- * create_property -- Create a PICL property
- */
-picl_errno_t
-env_create_property(int ptype, int pmode, size_t psize, char *pname,
- int (*readfn)(ptree_rarg_t *, void *),
- int (*writefn)(ptree_warg_t *, const void *),
- picl_nodehdl_t nodeh, picl_prophdl_t *propp, void *vbuf)
-{
- picl_errno_t rc; /* return code */
- ptree_propinfo_t propinfo; /* propinfo structure */
- picl_prophdl_t proph;
-
- rc = ptree_get_prop_by_name(nodeh, pname, &proph);
- if (rc == PICL_SUCCESS) { /* prop. already exists */
- return (rc);
- }
-
- rc = ptree_init_propinfo(&propinfo, PTREE_PROPINFO_VERSION,
- ptype, pmode, psize, pname, readfn, writefn);
- if (rc != PICL_SUCCESS) {
- syslog(LOG_ERR, PTREE_INIT_PROPINFO_FAILED_MSG, rc);
- return (rc);
- }
-
- rc = ptree_create_and_add_prop(nodeh, &propinfo, vbuf, propp);
- if (rc != PICL_SUCCESS) {
- syslog(LOG_ERR, PTREE_CREATE_AND_ADD_PROP_FAILED_MSG, rc);
- return (rc);
- }
- return (PICL_SUCCESS);
-}
-
-/*
- * The picl event completion handler.
- */
-/* ARGSUSED */
-static void
-event_completion_handler(char *ename, void *earg, size_t size)
-{
- free(earg);
- free(ename);
-}
-
-/*
- * utility routine to post PICL events
- */
-/*ARGSUSED*/
-static int
-post_picl_event(const char *ename, char *envl, size_t elen,
- picl_nodehdl_t nodeh, int cond_wait)
-{
- nvlist_t *nvlp;
- size_t nvl_size;
- char *pack_buf = NULL;
- char *evname;
-
- if (nodeh == 0) {
- return (PICL_FAILURE);
- }
- if ((evname = strdup(ename)) == NULL)
- return (PICL_FAILURE);
- if (envl) {
- if (nvlist_unpack(envl, elen, &nvlp, 0) < 0) {
- nvlist_free(nvlp);
- free(evname);
- return (PICL_FAILURE);
- }
- } else {
- if (nvlist_alloc(&nvlp, NV_UNIQUE_NAME_TYPE, NULL)) {
- free(evname);
- return (PICL_FAILURE);
- }
- }
-
- if (nvlist_add_uint64(nvlp, PICLEVENTARG_NODEHANDLE, nodeh) == -1) {
- nvlist_free(nvlp);
- free(evname);
- return (PICL_FAILURE);
- }
-
- if (nvlist_pack(nvlp, &pack_buf, &nvl_size, NV_ENCODE_NATIVE, NULL)) {
- nvlist_free(nvlp);
- free(evname);
- return (PICL_FAILURE);
- }
- nvlist_free(nvlp);
-
- if (env_debug & EVENTS) {
- char enodename[PICL_PROPNAMELEN_MAX];
- if (ptree_get_propval_by_name(nodeh, PICL_PROP_NAME,
- enodename, sizeof (enodename)) == PICL_SUCCESS)
- syslog(LOG_INFO, "envmond:Posting %s on %s\n",
- ename, enodename);
- }
-
- if (ptree_post_event(evname, pack_buf, nvl_size,
- event_completion_handler) != 0) {
- syslog(LOG_ERR, gettext("SUNW_envmond: Error posting %s PICL"
- " event."), ename);
- free(pack_buf);
- free(evname);
- return (PICL_FAILURE);
- }
- return (PICL_SUCCESS);
-}
-
-/*
- * post dr_req events
- */
-picl_errno_t
-post_dr_req_event(picl_nodehdl_t fruh, char *dr_req_type, uint8_t wait)
-{
- nvlist_t *nvlp; /* nvlist of event specific args */
- size_t nvl_size;
- char *pack_buf = NULL;
- char dr_ap_id[PICL_PROPNAMELEN_MAX];
- int rc = PICL_SUCCESS;
-
- if (env_debug & DEBUG)
- syslog(LOG_DEBUG, "Post %s on %llx", dr_req_type, fruh);
- if (fruh == 0) {
- return (PICL_INVALIDARG);
- }
- if ((rc = ptree_get_propval_by_name(fruh, PICL_PROP_NAME,
- dr_ap_id, sizeof (dr_ap_id))) != PICL_SUCCESS) {
- return (rc);
- }
-
- if (nvlist_alloc(&nvlp, NV_UNIQUE_NAME_TYPE, NULL)) {
- return (PICL_FAILURE);
- }
-
- if (nvlist_add_string(nvlp, PICLEVENTARG_AP_ID, dr_ap_id) == -1) {
- nvlist_free(nvlp);
- return (PICL_FAILURE);
- }
- if (nvlist_add_string(nvlp, PICLEVENTARG_DR_REQ_TYPE, dr_req_type)
- == -1) {
- nvlist_free(nvlp);
- return (PICL_FAILURE);
- }
- if (nvlist_pack(nvlp, &pack_buf, &nvl_size, NV_ENCODE_NATIVE, NULL)) {
- nvlist_free(nvlp);
- return (PICL_FAILURE);
- }
- nvlist_free(nvlp);
-
- if (env_debug & DEBUG)
- syslog(LOG_DEBUG, "Posting %s on %s", dr_req_type, dr_ap_id);
- rc = post_picl_event(PICLEVENT_DR_REQ, pack_buf, nvl_size, fruh,
- wait);
-
- free(pack_buf);
- return (rc);
-}
-
-/*
- * routine to post dr_ap_state change events
- */
-picl_errno_t
-post_dr_ap_state_change_event(picl_nodehdl_t nodehdl, char *dr_hint,
- uint8_t wait)
-{
- nvlist_t *nvlp; /* nvlist of event specific args */
- size_t nvl_size;
- char *pack_buf = NULL;
- char dr_ap_id[PICL_PROPNAMELEN_MAX];
- int rc = PICL_SUCCESS;
-
- if (nodehdl == 0) {
- return (PICL_FAILURE);
- }
- if ((rc = ptree_get_propval_by_name(nodehdl, PICL_PROP_NAME,
- dr_ap_id, sizeof (dr_ap_id))) != PICL_SUCCESS) {
- return (rc);
- }
- if (nvlist_alloc(&nvlp, NV_UNIQUE_NAME_TYPE, NULL)) {
- return (PICL_FAILURE);
- }
-
- if (nvlist_add_string(nvlp, PICLEVENTARG_AP_ID, dr_ap_id) == -1) {
- nvlist_free(nvlp);
- return (PICL_FAILURE);
- }
- if (nvlist_add_string(nvlp, PICLEVENTARG_HINT, dr_hint) == -1) {
- nvlist_free(nvlp);
- return (PICL_FAILURE);
- }
- if (nvlist_pack(nvlp, &pack_buf, &nvl_size, NV_ENCODE_NATIVE, NULL)) {
- nvlist_free(nvlp);
- return (PICL_FAILURE);
- }
- nvlist_free(nvlp);
- rc = post_picl_event(PICLEVENT_DR_AP_STATE_CHANGE, pack_buf,
- nvl_size, nodehdl, wait);
- free(pack_buf);
- return (rc);
-}
-
-picl_errno_t
-post_cpu_state_change_event(picl_nodehdl_t fruh, char *event_type, uint8_t wait)
-{
- nvlist_t *nvlp; /* nvlist of event specific args */
- size_t nvl_size;
- char *pack_buf = NULL;
- int rc = PICL_SUCCESS;
-
- if (fruh == 0) {
- return (PICL_FAILURE);
- }
-
- if (nvlist_alloc(&nvlp, NV_UNIQUE_NAME_TYPE, NULL))
- return (PICL_FAILURE);
-
- if (nvlist_add_int64(nvlp, PICLEVENTARG_NODEHANDLE, fruh)) {
- nvlist_free(nvlp);
- return (PICL_FAILURE);
- }
-
- if (nvlist_add_string(nvlp, PICLEVENTARG_CPU_EV_TYPE,
- event_type) == -1) {
- nvlist_free(nvlp);
- return (PICL_FAILURE);
- }
-
- if (nvlist_pack(nvlp, &pack_buf, &nvl_size, NV_ENCODE_NATIVE, NULL)) {
- nvlist_free(nvlp);
- return (PICL_FAILURE);
- }
- nvlist_free(nvlp);
- rc = post_picl_event(PICLEVENT_CPU_STATE_CHANGE, pack_buf,
- nvl_size, fruh, wait);
- free(pack_buf);
- return (rc);
-}
-
-int
-post_sensor_event(picl_nodehdl_t hdl, char *sensor_evalue, uint8_t wait)
-{
- nvlist_t *nvlp; /* nvlist of event specific args */
- size_t nvl_size;
- char *pack_buf = NULL;
- char dr_ap_id[PICL_PROPNAMELEN_MAX];
- int rc = PICL_SUCCESS;
-
- if (env_debug & DEBUG)
- syslog(LOG_DEBUG, "Post %s on %llx", sensor_evalue, hdl);
- if (hdl == 0)
- return (PICL_FAILURE);
-
- if (nvlist_alloc(&nvlp, NV_UNIQUE_NAME_TYPE, NULL))
- return (PICL_FAILURE);
-
- if (nvlist_add_string(nvlp, PICLEVENTARG_CONDITION,
- sensor_evalue) == -1) {
- nvlist_free(nvlp);
- return (PICL_FAILURE);
- }
- if (nvlist_pack(nvlp, &pack_buf, &nvl_size, NV_ENCODE_NATIVE, NULL)) {
- nvlist_free(nvlp);
- return (PICL_FAILURE);
- }
- nvlist_free(nvlp);
-
- if (env_debug & DEBUG) {
- if (ptree_get_propval_by_name(hdl, PICL_PROP_NAME, dr_ap_id,
- sizeof (dr_ap_id)) == PICL_SUCCESS)
- syslog(LOG_DEBUG, "Posting %s on %s", sensor_evalue,
- dr_ap_id);
- }
- rc = post_picl_event(PICLEVENT_CONDITION_CHANGE, pack_buf, nvl_size,
- hdl, wait);
- free(pack_buf);
- return (rc);
-}
-
-/*
- * return B_TRUE if admin lock is enabled
- * return B_FALSE if admin lock is disabled
- */
-boolean_t
-env_admin_lock_enabled(picl_nodehdl_t fruh)
-{
- char adminlock[PICL_PROPNAMELEN_MAX];
-
- if (ptree_get_propval_by_name(fruh, PICL_PROP_ADMIN_LOCK,
- adminlock, sizeof (adminlock))
- != PICL_SUCCESS) {
- return (B_FALSE);
- }
- if (strcmp(adminlock, PICL_ADMINLOCK_ENABLED) == 0) {
- return (B_TRUE);
- }
- return (B_FALSE);
-}
diff --git a/usr/src/cmd/picl/plugins/sun4u/snowbird/envmond/piclenvmond.h b/usr/src/cmd/picl/plugins/sun4u/snowbird/envmond/piclenvmond.h
deleted file mode 100644
index 017c1e5d91..0000000000
--- a/usr/src/cmd/picl/plugins/sun4u/snowbird/envmond/piclenvmond.h
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (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 2004 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#ifndef _PICLENVMOND_H
-#define _PICLENVMOND_H
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/* debug flags */
-#define DEBUG 0x1 /* generic debug messages */
-#define EVENTS 0x2 /* only events related debug message */
-#define PTREE 0x4 /* messages relating to picltree search */
-#define SP_MONITOR 0x8 /* AC health monitoring messages only */
-#define CHASSIS_INFO 0x10 /* Chassis related debug information */
-#define PICLEVENTS 0x20 /* Display only PICL events received */
-
-#define PICL_NODE_CHASSIS "chassis"
-#define PICL_NODE_CPU "CPU"
-#define PICL_NODE_RTM "RTM"
-#define PICL_PROP_CONF_FILE "conf_name"
-#define TEMPERATURE_SENSOR_TYPE (0x1u)
-
-typedef enum {
- LOC_STATE_UNKNOWN = 0,
- LOC_STATE_EMPTY,
- LOC_STATE_DISCONNECTING,
- LOC_STATE_DISCONNECTED,
- LOC_STATE_CONNECTING,
- LOC_STATE_CONNECTED,
- FRU_STATE_UNKNOWN,
- FRU_STATE_UNCONFIGURING,
- FRU_STATE_UNCONFIGURED,
- FRU_STATE_CONFIGURING,
- FRU_STATE_CONFIGURED,
- FRU_COND_OK,
- FRU_COND_FAILING,
- FRU_COND_FAILED,
- FRU_COND_DEGRADED,
- FRU_COND_UNKNOWN,
- FRU_COND_TESTING
-} env_state_event_t;
-
-typedef enum {NO_COND_TIMEDWAIT = 0, COND_TIMEDWAIT, NO_WAIT} env_wait_state_t;
-
-#define NULLREAD (int (*)(ptree_rarg_t *, void *))0
-#define NULLWRITE (int (*)(ptree_warg_t *, const void *))0
-#define POLL_TIMEOUT 5000
-#define DEFAULT_FD -1
-#define DEFAULT_SEQN 0xff
-
-/* byte of pointer to signed integer */
-#define BYTE_0(_X) (*((int8_t *)(_X) + 0))
-#define BYTE_1(_X) (*((int8_t *)(_X) + 1))
-#define BYTE_2(_X) (*((int8_t *)(_X) + 2))
-#define BYTE_3(_X) (*((int8_t *)(_X) + 3))
-#define BYTE_4(_X) (*((int8_t *)(_X) + 4))
-#define BYTE_5(_X) (*((int8_t *)(_X) + 5))
-#define BYTE_6(_X) (*((int8_t *)(_X) + 6))
-#define BYTE_7(_X) (*((int8_t *)(_X) + 7))
-#define BYTE_8(_X) (*((int8_t *)(_X) + 8))
-
-#define BIT_0(_X) ((_X) & 0x01)
-#define BIT_1(_X) ((_X) & 0x02)
-#define BIT_2(_X) ((_X) & 0x04)
-#define BIT_3(_X) ((_X) & 0x08)
-#define BIT_4(_X) ((_X) & 0x10)
-#define BIT_5(_X) ((_X) & 0x20)
-#define BIT_6(_X) ((_X) & 0x40)
-#define BIT_7(_X) ((_X) & 0x80)
-
-#define PICL_ADMINLOCK_DISABLED "disabled"
-#define PICL_ADMINLOCK_ENABLED "enabled"
-
-#define PTREE_INIT_PROPINFO_FAILED_MSG \
- gettext("SUNW_envmond:ptree_init_propinfo() failed, error = %d")
-#define PTREE_CREATE_AND_ADD_PROP_FAILED_MSG \
- gettext("SUNW_envmond: ptree_create_and_add_prop() failed error = %d")
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _PICLENVMOND_H */
diff --git a/usr/src/cmd/picl/plugins/sun4u/snowbird/envmond/piclplatmod.c b/usr/src/cmd/picl/plugins/sun4u/snowbird/envmond/piclplatmod.c
deleted file mode 100644
index 43c4c3d056..0000000000
--- a/usr/src/cmd/picl/plugins/sun4u/snowbird/envmond/piclplatmod.c
+++ /dev/null
@@ -1,837 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (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 2004 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <stdio.h>
-#include <limits.h>
-#include <unistd.h>
-#include <sys/systeminfo.h>
-#include <pthread.h>
-#include <syslog.h>
-#include <picl.h>
-#include <picltree.h>
-#include <picldefs.h>
-#include <string.h>
-#include <libnvpair.h>
-#include <libintl.h>
-#include <librcm.h>
-#include <stropts.h>
-#include <smclib.h>
-#include <sys/sysevent/dr.h>
-#include "piclenvmond.h"
-#include "picldr.h"
-
-/* local defines */
-#define RESET_CPU "/usr/sbin/shutdown -y -g 0 -i6"
-#define SHUTDOWN_CPU "/usr/sbin/shutdown -y -g 0 -i0"
-#define RCM_ABSTRACT_RESOURCE "SUNW_snowbird/board0/CPU1"
-#define CPU_SENSOR_GEO_ADDR 0xe
-#define IS_HEALTHY 0x01
-#define PICL_NODE_SYSMGMT "sysmgmt"
-#define SYSMGMT_PATH PLATFORM_PATH"/pci/pci/isa/sysmgmt"
-#define BUF_SIZE 7
-
-/* external functions */
-extern picl_errno_t env_create_property(int, int, size_t, char *,
- int (*readfn)(ptree_rarg_t *, void *),
- int (*writefn)(ptree_warg_t *, const void *),
- picl_nodehdl_t, picl_prophdl_t *, void *);
-extern picl_errno_t post_dr_req_event(picl_nodehdl_t, char *, uint8_t);
-extern picl_errno_t post_dr_ap_state_change_event(picl_nodehdl_t, char *,
- uint8_t);
-extern boolean_t env_admin_lock_enabled(picl_nodehdl_t);
-extern picl_errno_t env_create_temp_sensor_node(picl_nodehdl_t, uint8_t);
-extern void env_handle_sensor_event(void *);
-extern int env_open_smc();
-
-/* external variables */
-extern int env_debug;
-extern uint8_t cpu_geo_addr;
-extern picl_nodehdl_t rooth, platformh, sysmgmth, sensorh;
-extern picl_nodehdl_t chassis_nodehdl, cpu_nodehdl, cpu_lnodehdl;
-
-/* locals */
-static pthread_mutex_t env_dmc_mutex = PTHREAD_MUTEX_INITIALIZER;
-static pthread_cond_t env_dmc_cond = PTHREAD_COND_INITIALIZER;
-static boolean_t env_reset_cpu = B_FALSE;
-static boolean_t env_shutdown_system = B_FALSE;
-static env_state_event_t env_chassis_state = FRU_STATE_UNKNOWN;
-static char *rcm_abstr_cp2300_name = RCM_ABSTRACT_RESOURCE;
-static boolean_t env_got_dmc_msg = B_FALSE;
-static long env_dmc_wait_time = 15;
-static pthread_t dmc_thr_tid;
-
-/*
- * issue halt or reboot based on the reset_cpu flag
- */
-/*ARGSUSED*/
-static void
-shutdown_cpu(boolean_t force)
-{
- if (env_shutdown_system) {
- if (env_reset_cpu) {
- (void) pclose(popen(RESET_CPU, "w"));
- } else {
- (void) pclose(popen(SHUTDOWN_CPU, "w"));
- }
- }
-}
-
-/*
- * inform RCM framework that the remove op is successful
- */
-static void
-confirm_rcm(char *abstr_name, rcm_handle_t *rhandle)
-{
- rcm_notify_remove(rhandle, abstr_name, 0, NULL);
-}
-
-/*
- * inform RCM framework that the remove op is failed
- */
-static void
-fail_rcm(char *abstr_name, rcm_handle_t *rhandle)
-{
- (void) rcm_notify_online(rhandle, abstr_name, 0, NULL);
-}
-
-/*
- * check RCM framework if it is ok to offline a device
- */
-static int
-check_rcm(char *rcm_abstr_cp2300_name, uint_t flags)
-{
- rcm_info_t *rinfo;
- rcm_handle_t *rhandle;
- int rv;
-
- if (rcm_alloc_handle(NULL, 0, NULL, &rhandle) != RCM_SUCCESS) {
- return (RCM_FAILURE);
- }
-
- rv = rcm_request_offline(rhandle, rcm_abstr_cp2300_name,
- flags, &rinfo);
-
- if (rv == RCM_FAILURE) {
- rcm_free_info(rinfo);
- fail_rcm(rcm_abstr_cp2300_name, rhandle);
- rcm_free_handle(rhandle);
- return (RCM_FAILURE);
- }
- if (rv == RCM_CONFLICT) {
- rcm_free_info(rinfo);
- rcm_free_handle(rhandle);
- return (RCM_CONFLICT);
- }
-
- confirm_rcm(rcm_abstr_cp2300_name, rhandle);
- rcm_free_info(rinfo);
- rcm_free_handle(rhandle);
- return (RCM_SUCCESS);
-}
-
-/*
- * utility routine to send response to an IPMI message
- */
-static int
-send_response2remote_device(uint8_t ipmb_addr, uint8_t cmd, uint8_t reqseq_lun,
- uint8_t cc)
-{
- int rc = SMC_SUCCESS;
- sc_reqmsg_t req_pkt;
- sc_rspmsg_t rsp_pkt;
- uint8_t data = cc; /* completion code */
-
- /* make a call to ctsmc lib */
- (void) smc_init_ipmi_msg(&req_pkt, cmd, DEFAULT_FD, 1, &data,
- (reqseq_lun >> 2), ipmb_addr, SMC_NETFN_APP_RSP,
- (reqseq_lun & 0x03));
- rc = smc_send_msg(DEFAULT_FD, &req_pkt, &rsp_pkt,
- POLL_TIMEOUT);
-
- if (rc != SMC_SUCCESS)
- syslog(LOG_ERR, gettext("SUNW_envmond:Error in sending response"
- " to %x, error = %d"), ipmb_addr, rc);
- return (rc);
-}
-
-/*
- * do all the checks like adminlock check, rcm check and initiate
- * shutdown
- */
-/*ARGSUSED*/
-static int
-initiate_shutdown(boolean_t force)
-{
- int rv;
- uint_t rcmflags = 0;
- struct timespec rqtp, rmtp;
-
- if (!env_shutdown_system) {
- return (-1);
- }
-
- /* check the adminlock prop */
- if ((!force) && (env_admin_lock_enabled(cpu_nodehdl))) {
- syslog(LOG_ERR, gettext("SUNW_envmond: "
- "CPU in use! Cannot shutdown"));
- return (-1);
- }
-
- if (force) {
- rcmflags = RCM_FORCE;
- }
-
- /* check with rcm framework */
- rv = check_rcm(rcm_abstr_cp2300_name, rcmflags);
-
- if ((rv == RCM_FAILURE) || (rv == RCM_CONFLICT)) {
- syslog(LOG_ERR, gettext("SUNW_envmond: RCM error %d, Cannot"
- " shutdown"), rv);
- return (-1);
- }
-
- /*
- * force events on chassis node
- */
- if (force) {
- if (post_dr_req_event(chassis_nodehdl, DR_REQ_OUTGOING_RES,
- NO_WAIT) == PICL_SUCCESS) {
- /* wait a little for clean up of frutree */
- rqtp.tv_sec = 5;
- rqtp.tv_nsec = 0;
- (void) nanosleep(&rqtp, &rmtp);
- }
- /*
- * If force option is set, do it right here for now
- * since there is no way to pass this info via events
- * to frutree framework.
- */
- shutdown_cpu(force);
- return (0);
- }
-
- if (post_dr_req_event(chassis_nodehdl, DR_REQ_OUTGOING_RES, NO_WAIT)
- != PICL_SUCCESS) {
- syslog(LOG_ERR, gettext("SUNW_envmond:cannot shutdown "
- "the host CPU."));
- return (-1);
- }
- return (0);
-}
-
-/*
- * get the HEALTHY# line state
- * Return -1 for Error
- * 0 for HEALTHY# down
- * 1 for HEALTHY# up
- */
-static int
-env_get_healthy_status()
-{
- sc_reqmsg_t req_pkt;
- sc_rspmsg_t rsp_pkt;
- uint8_t size = 0;
-
- /* initialize the request packet */
- (void) smc_init_smc_msg(&req_pkt, SMC_GET_EXECUTION_STATE,
- DEFAULT_SEQN, size);
-
- /* make a call to smc library to send cmd */
- if (smc_send_msg(DEFAULT_FD, &req_pkt, &rsp_pkt,
- POLL_TIMEOUT) != SMC_SUCCESS) {
- return (-1);
- }
- return (rsp_pkt.data[0] & IS_HEALTHY);
-}
-
-/*
- * initialization
- */
-picl_errno_t
-env_platmod_init()
-{
- picl_errno_t rc = PICL_SUCCESS;
-
- if (rooth == 0) {
- if (ptree_get_root(&rooth) != PICL_SUCCESS) {
- return (rc);
- }
- }
-
- if (chassis_nodehdl == 0) {
- if ((rc = ptree_get_node_by_path(PICL_FRUTREE_CHASSIS,
- &chassis_nodehdl)) != PICL_SUCCESS) {
- return (rc);
- }
- }
- if (post_dr_req_event(chassis_nodehdl, DR_REQ_INCOMING_RES,
- NO_WAIT) != PICL_SUCCESS) {
- syslog(LOG_ERR, gettext("SUNW_envmond: Error in "
- "Posting configure event for Chassis node"));
- rc = PICL_FAILURE;
- }
- return (rc);
-}
-
-/*
- * release all the resources
- */
-void
-env_platmod_fini()
-{
- cpu_geo_addr = 0;
- rooth = platformh = sysmgmth = 0;
- chassis_nodehdl = cpu_nodehdl = cpu_lnodehdl = 0;
- env_chassis_state = FRU_STATE_UNKNOWN;
- (void) ptree_delete_node(sensorh);
- (void) ptree_destroy_node(sensorh);
-}
-
-/*
- * handle chassis state change
- */
-static void
-env_handle_chassis_state_event(char *state)
-{
- if (strcmp(state, PICLEVENTARGVAL_CONFIGURING) == 0) {
- env_chassis_state = FRU_STATE_CONFIGURING;
- return;
- }
-
- if (strcmp(state, PICLEVENTARGVAL_UNCONFIGURED) == 0) {
- if (env_chassis_state == FRU_STATE_CONFIGURING ||
- env_chassis_state == FRU_STATE_UNKNOWN) {
- /* picl intialization is failed, dont issue shutdown */
- env_chassis_state = FRU_STATE_UNCONFIGURED;
- return;
- }
- env_chassis_state = FRU_STATE_UNCONFIGURED;
- if (env_reset_cpu) {
- (void) pclose(popen(RESET_CPU, "w"));
- } else {
- (void) pclose(popen(SHUTDOWN_CPU, "w"));
- }
- return;
- }
-
- if (strcmp(state, PICLEVENTARGVAL_CONFIGURED) == 0) {
- env_chassis_state = FRU_STATE_CONFIGURED;
- }
-}
-
-/*
- * event handler for watchdog state change event
- */
-static picl_errno_t
-env_handle_watchdog_expiry(picl_nodehdl_t wd_nodehdl)
-{
- picl_errno_t rc = PICL_SUCCESS;
- char class[PICL_CLASSNAMELEN_MAX];
- char value[PICL_PROPNAMELEN_MAX];
- char cond[BUF_SIZE];
-
- if ((rc = ptree_get_propval_by_name(wd_nodehdl,
- PICL_PROP_CLASSNAME, class,
- PICL_CLASSNAMELEN_MAX)) != PICL_SUCCESS) {
- return (rc);
- }
-
- /* if the event is not of watchdog-timer, return */
- if (strcmp(class, PICL_CLASS_WATCHDOG_TIMER) != 0) {
- return (PICL_INVALIDARG);
- }
-
- if ((rc = ptree_get_propval_by_name(wd_nodehdl,
- PICL_PROP_WATCHDOG_ACTION, value, sizeof (value))) !=
- PICL_SUCCESS) {
- return (rc);
- }
-
- /* if action is none, dont do anything */
- if (strcmp(value, PICL_PROPVAL_WD_ACTION_ALARM) != 0) {
- return (PICL_SUCCESS);
- }
-
- (void) strncpy(cond, PICLEVENTARGVAL_FAILED, sizeof (cond));
- /* update CPU condition to failed */
- if ((rc = ptree_update_propval_by_name(cpu_nodehdl,
- PICL_PROP_CONDITION, cond, sizeof (cond))) != PICL_SUCCESS) {
- return (rc);
- }
-
- /* post dr ap state change event */
- rc = post_dr_ap_state_change_event(cpu_nodehdl,
- DR_RESERVED_ATTR, NO_COND_TIMEDWAIT);
- return (rc);
-}
-
-/*
- * rotine that handles all the picl state and condition change events
- */
-void
-env_platmod_handle_event(const char *ename, const void *earg, size_t size)
-{
- picl_errno_t rc;
- picl_nodehdl_t nodeh = 0;
- picl_prophdl_t proph;
- nvlist_t *nvlp;
- char *value;
- boolean_t state_event;
- env_state_event_t event;
- char result[PICL_PROPNAMELEN_MAX];
- uint64_t status_time, cond_time;
- char cond[BUF_SIZE];
-
- if (!ename) {
- return;
- }
- if (strcmp(ename, PICLEVENT_STATE_CHANGE) == 0) {
- state_event = B_TRUE;
- } else if (strcmp(ename, PICLEVENT_CONDITION_CHANGE) == 0) {
- state_event = B_FALSE;
- } else {
- syslog(LOG_ERR, gettext("SUNW_envmond: unknown event:%s\n"),
- ename);
- return;
- }
-
- /* unpack the nvlist and get the information */
- if (nvlist_unpack((char *)earg, size, &nvlp, NULL)) {
- return;
- }
- if (nvlist_lookup_uint64(nvlp, PICLEVENTARG_NODEHANDLE, &nodeh) == -1) {
- nvlist_free(nvlp);
- return;
- }
- if (nvlist_lookup_string(nvlp, (state_event) ?
- PICLEVENTARG_STATE :
- PICLEVENTARG_CONDITION, &value) != 0) {
- nvlist_free(nvlp);
- return;
- }
-
- if (env_debug & PICLEVENTS) {
- if (ptree_get_propval_by_name(nodeh, PICL_PROP_NAME,
- result, sizeof (result)) != PICL_SUCCESS) {
- syslog(LOG_ERR, " SUNW_envmond: error in getting"
- " node name");
- nvlist_free(nvlp);
- return;
- }
- syslog(LOG_INFO, "SUNW_envmond: %s (%s) on %s",
- ename, value, result);
- }
-
- if (chassis_nodehdl == 0 && state_event) {
- if (ptree_get_propval_by_name(nodeh, PICL_PROP_NAME,
- result, sizeof (result)) != PICL_SUCCESS) {
- nvlist_free(nvlp);
- return;
- }
- if (strcmp(result, PICL_NODE_CHASSIS) == 0) {
- chassis_nodehdl = nodeh;
- }
- }
-
- if (nodeh == chassis_nodehdl && state_event) {
- env_handle_chassis_state_event(value);
- nvlist_free(nvlp);
- return;
- }
-
- if (strcmp(PICLEVENTARGVAL_DISCONNECTED, value) == 0) {
- event = LOC_STATE_DISCONNECTED;
- } else if (strcmp(PICLEVENTARGVAL_CONNECTED, value) == 0) {
- event = LOC_STATE_CONNECTED;
- } else if (strcmp(PICLEVENTARGVAL_EMPTY, value) == 0) {
- event = LOC_STATE_EMPTY;
- } else if (strcmp(PICLEVENTARGVAL_CONFIGURED, value) == 0) {
- event = FRU_STATE_CONFIGURED;
- } else if (strcmp(PICLEVENTARGVAL_UNCONFIGURED, value) == 0) {
- event = FRU_STATE_UNCONFIGURED;
- } else if (strcmp(PICL_PROPVAL_WD_STATE_EXPIRED, value) == 0) {
- /* watchdog expiry event */
- if ((rc = env_handle_watchdog_expiry(nodeh)) != PICL_SUCCESS) {
- syslog(LOG_ERR, gettext("SUNW_envmond:Error in handling"
- "watchdog expiry event"));
- }
- nvlist_free(nvlp);
- return;
- } else {
- nvlist_free(nvlp);
- return;
- }
-
- switch (event) {
- case LOC_STATE_EMPTY:
- break;
-
- case LOC_STATE_DISCONNECTED:
- if (nodeh == cpu_lnodehdl) {
- (void) initiate_shutdown(B_FALSE);
- }
- break;
- case LOC_STATE_CONNECTED:
- if (nodeh != cpu_lnodehdl) {
- break;
- }
- if (ptree_get_propval_by_name(cpu_lnodehdl,
- PICL_PROP_CHILD, &cpu_nodehdl,
- sizeof (picl_nodehdl_t)) != PICL_SUCCESS) {
- syslog(LOG_ERR, gettext("SUNW_envmond:Cannot "
- "initialize CPU node handle %llx"), nodeh);
- cpu_nodehdl = 0;
- }
- break;
- case FRU_STATE_CONFIGURED:
- if (nodeh != cpu_nodehdl) {
- break;
- }
- if (ptree_get_prop_by_name(cpu_nodehdl,
- PICL_PROP_STATUS_TIME, &proph) != PICL_SUCCESS) {
- status_time = (uint64_t)time(NULL);
- (void) env_create_property(PICL_PTYPE_TIMESTAMP,
- PICL_READ, sizeof (status_time),
- PICL_PROP_STATUS_TIME, NULLREAD,
- NULLWRITE, cpu_nodehdl, &proph,
- &status_time);
- }
- if (ptree_get_prop_by_name(cpu_nodehdl,
- PICL_PROP_CONDITION_TIME, &proph) != PICL_SUCCESS) {
- cond_time = (uint64_t)time(NULL);
- (void) env_create_property(PICL_PTYPE_TIMESTAMP,
- PICL_READ, sizeof (cond_time),
- PICL_PROP_CONDITION_TIME, NULLREAD,
- NULLWRITE, cpu_nodehdl, &proph,
- &cond_time);
- }
- env_shutdown_system = B_FALSE;
- /* if HEALTHY# is UP update the condition to "ok" */
- switch (env_get_healthy_status()) {
- case 0:
- /* update CPU condition to failed */
- (void) strncpy(cond, PICLEVENTARGVAL_FAILED, sizeof (cond));
- break;
- case 1:
- /* update CPU condition to ok */
- (void) strncpy(cond, PICLEVENTARGVAL_OK, sizeof (cond));
- break;
- case -1: /*FALLTHRU*/
- default:
- /* update the condition to unknown */
- (void) strncpy(cond, PICLEVENTARGVAL_UNKNOWN, sizeof (cond));
- syslog(LOG_ERR, gettext("SUNW_envmond:Error in "
- "reading HEALTHY# status"));
- }
-
- if ((rc = ptree_update_propval_by_name(cpu_nodehdl,
- PICL_PROP_CONDITION, cond, sizeof (cond))) !=
- PICL_SUCCESS) {
- syslog(LOG_ERR, gettext("SUNW_envmond:Error in "
- "updating CPU condition, error = %d"), rc);
- }
- break;
- case FRU_STATE_UNCONFIGURED:
- if (env_reset_cpu && nodeh == cpu_nodehdl) {
- (void) initiate_shutdown(B_FALSE);
- }
- break;
- default:
- break;
- } /* end of switch */
- nvlist_free(nvlp);
-}
-
-/*
- * This thread waits for dmc message to come, as it has to send
- * response ACK back to DMC. Otherwise DMC may think that message
- * is lost and issues poweroff on a node. So there is a chance for
- * CPU to be powered off in the middle of shutdown process. If the
- * DMC message didnt come, then process the local shutdown request.
- */
-/*ARGSUSED*/
-static void *
-env_wait_for_dmc_msg(void *args)
-{
- struct timeval ct;
- struct timespec to;
-
- (void) pthread_mutex_lock(&env_dmc_mutex);
- if (env_got_dmc_msg == B_TRUE) {
- (void) pthread_mutex_unlock(&env_dmc_mutex);
- return (NULL);
- }
-
- /*
- * wait for specified time to check if dmc sends the
- * shutdown request
- */
- (void) gettimeofday(&ct, NULL);
- to.tv_sec = ct.tv_sec + env_dmc_wait_time;
- to.tv_nsec = 0;
- (void) pthread_cond_timedwait(&env_dmc_cond,
- &env_dmc_mutex, &to);
- if (env_got_dmc_msg == B_TRUE) {
- (void) pthread_mutex_unlock(&env_dmc_mutex);
- return (NULL);
- }
- (void) pthread_mutex_unlock(&env_dmc_mutex);
-
- env_shutdown_system = B_TRUE;
- env_reset_cpu = B_FALSE;
- (void) initiate_shutdown(B_FALSE);
- return (NULL);
-}
-
-/*
- * Handle the Latch open event(shutdown the node)
- */
-picl_errno_t
-env_platmod_handle_latch_open()
-{
- /*
- * create a thread to process local event after waiting for DMC CPU
- * node state offline message
- */
- if (pthread_create(&dmc_thr_tid, NULL, &env_wait_for_dmc_msg,
- NULL) != 0) {
- syslog(LOG_ERR, gettext("SUNW_envmond:Error in creating "
- "dmc thread"));
- return (PICL_FAILURE);
- }
- return (PICL_SUCCESS);
-}
-
-/*
- * For Sanibel, hotswap initialization is not reqd.
- */
-picl_errno_t
-env_platmod_setup_hotswap()
-{
- return (PICL_SUCCESS);
-}
-
-/*
- * For sanibel this supoort is not required
- */
-picl_errno_t
-env_platmod_sp_monitor()
-{
- return (PICL_SUCCESS);
-}
-
-/*
- * For sanibel this supoort is not required
- */
-picl_errno_t
-env_platmod_create_hotswap_prop()
-{
- return (PICL_SUCCESS);
-}
-
-/*
- * For sanibel this supoort is not required
- */
-/*ARGSUSED*/
-void
-process_platmod_sp_heartbeat(uint8_t data)
-{
-}
-
-/*
- * For sanibel this supoort is not required
- */
-/*ARGSUSED*/
-int
-process_platmod_async_msg_notif(void *resdatap)
-{
- return (0);
-}
-
-/*
- * For sanibel this supoort is not required
- */
-/*ARGSUSED*/
-int
-process_platmod_change_cpci_state(void *res_datap)
-{
- return (0);
-}
-
-/*
- * handle request from service processor for shutdown/online
- */
-int
-process_platmod_change_cpu_node_state(void *res_datap)
-{
- int rc = SMC_SUCCESS;
- uint8_t state = BYTE_7(res_datap);
- boolean_t force_flag = B_FALSE;
-
- switch (state & 1) {
- case CPU_NODE_STATE_OFFLINE:
- (void) pthread_mutex_lock(&env_dmc_mutex);
- env_got_dmc_msg = B_TRUE;
- (void) pthread_cond_signal(&env_dmc_cond);
- (void) pthread_mutex_unlock(&env_dmc_mutex);
- env_shutdown_system = B_TRUE;
- if ((state >> 2) & 1)
- env_reset_cpu = B_TRUE;
- if (state >> 1 & 1) { /* force flag set? */
- force_flag = B_TRUE;
- } else {
- force_flag = B_FALSE;
- }
-
- if (initiate_shutdown(force_flag) == 0) {
- if ((rc = send_response2remote_device(SMC_BMC_ADDR,
- EVENT_MSG_CHANGE_CPU_NODE_STATE,
- BYTE_5(res_datap), 0x0)) != SMC_SUCCESS) {
- return (rc);
- }
- } else {
- if ((rc = send_response2remote_device(SMC_BMC_ADDR,
- EVENT_MSG_CHANGE_CPU_NODE_STATE,
- BYTE_5(res_datap), 0xFF)) != SMC_SUCCESS) {
- return (rc);
- }
- env_shutdown_system = B_FALSE;
- if ((state >> 2) & 1)
- env_reset_cpu = B_FALSE;
- }
- break;
- case CPU_NODE_STATE_ONLINE:
- if ((rc = send_response2remote_device(SMC_BMC_ADDR,
- EVENT_MSG_CHANGE_CPU_NODE_STATE,
- BYTE_5(res_datap), 0x0)) != SMC_SUCCESS) {
- return (rc);
- }
- break;
- default:
- break;
- }
- return (0);
-}
-
-/*
- * Handle change in state of service processor
- */
-int
-process_platmod_sp_state_change_notif(void *res_datap)
-{
- int rc = SMC_SUCCESS;
- uint8_t state = BYTE_7(res_datap);
- uint8_t rq_addr = BYTE_4(res_datap);
-
- if (rq_addr != SMC_BMC_ADDR) {
- return (PICL_FAILURE);
- }
-
- switch (state) {
- case CPU_NODE_STATE_ONLINE:
- /* Send ACK to service processor */
- if ((rc = send_response2remote_device(SMC_BMC_ADDR,
- EVENT_MSG_AC_STATE_CHANGE,
- BYTE_5(res_datap), 0x0)) != SMC_SUCCESS) {
- return (rc);
- }
- break;
-
- case CPU_NODE_STATE_OFFLINE:
- /* Send ACK to service processor */
- if ((rc = send_response2remote_device(SMC_BMC_ADDR,
- EVENT_MSG_AC_STATE_CHANGE,
- BYTE_5(res_datap), 0x0)) != SMC_SUCCESS) {
- return (rc);
- }
- break;
-
- default:
- if ((rc = send_response2remote_device(SMC_BMC_ADDR,
- EVENT_MSG_AC_STATE_CHANGE,
- BYTE_5(res_datap), 0xFF)) != SMC_SUCCESS) {
- return (rc);
- }
- break;
- }
- return (0);
-}
-
-/*
- * For sanibel this supoort is not required
- */
-/*ARGSUSED*/
-picl_errno_t
-env_platmod_handle_bus_if_change(uint8_t data)
-{
- return (PICL_SUCCESS);
-}
-
-/*
- * create the temperature sensor nodes
- */
-picl_errno_t
-env_platmod_create_sensors()
-{
- picl_errno_t rc = PICL_SUCCESS;
-
- if (rooth == 0) {
- if ((rc = ptree_get_root(&rooth)) != PICL_SUCCESS) {
- return (rc);
- }
- }
-
- if (platformh == 0) {
- if ((rc = ptree_get_node_by_path(PLATFORM_PATH,
- &platformh)) != PICL_SUCCESS) {
- return (rc);
- }
- }
-
- if (sysmgmth == 0) {
- if ((rc = ptree_get_node_by_path(SYSMGMT_PATH,
- &sysmgmth)) != PICL_SUCCESS) {
- return (rc);
- }
- }
-
- rc = env_create_temp_sensor_node(sysmgmth, CPU_SENSOR_GEO_ADDR);
- return (rc);
-}
-
-/*
- * handler for sensor event
- */
-void
-env_platmod_handle_sensor_event(void *res_datap)
-{
- if (BYTE_4(res_datap) != CPU_SENSOR_GEO_ADDR) {
- return;
- }
- env_handle_sensor_event(res_datap);
-}
diff --git a/usr/src/cmd/picl/plugins/sun4u/snowbird/envmond/piclsensors.c b/usr/src/cmd/picl/plugins/sun4u/snowbird/envmond/piclsensors.c
deleted file mode 100644
index 60d95e9f5a..0000000000
--- a/usr/src/cmd/picl/plugins/sun4u/snowbird/envmond/piclsensors.c
+++ /dev/null
@@ -1,863 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (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 2004 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Routines in this file are used to manage CPU temperature sensor
- */
-
-#include <stdio.h>
-#include <unistd.h>
-#include <smclib.h>
-#include <libintl.h>
-#include <syslog.h>
-#include <pthread.h>
-#include <string.h>
-#include <strings.h>
-#include <picl.h>
-#include <picltree.h>
-#include <picldefs.h>
-#include <pthread.h>
-#include <errno.h>
-#include <stropts.h>
-#include "piclenvmond.h"
-#include "piclsensors.h"
-
-#define NULLREAD (int (*)(ptree_rarg_t *, void *))0
-#define NULLWRITE (int (*)(ptree_warg_t *, const void *))0
-#define POLL_TIMEOUT 5000
-#define BUF_SIZE 50
-
-/* packet lengths */
-#define ENV_GET_THRESHOLD_PKT_LEN 1
-#define ENV_SET_THRESHOLD_PKT_LEN 8
-#define ENV_READ_SENSOR_PKT_LEN 1
-#define ENV_SENSOR_EVENT_ENABLE_PKT_LEN 2
-
-/* req pkt data */
-#define ENV_SENSOR_EVENT_ENABLE_MASK 0x80
-
-/* ptree wrapper to create property */
-extern picl_errno_t env_create_property(int ptype, int pmode,
- size_t psize, char *pname, int (*readfn)(ptree_rarg_t *, void *),
- int (*writefn)(ptree_warg_t *, const void *),
- picl_nodehdl_t nodeh, picl_prophdl_t *propp, void *vbuf);
-extern int post_sensor_event(picl_nodehdl_t, char *, uint8_t);
-extern int env_open_smc(void);
-extern int env_debug;
-
-/* globals */
-int sensor_fd = -1;
-picl_nodehdl_t sensorh = 0;
-pthread_t env_temp_thr_tid;
-
-/* local vars */
-static env_temp_sensor_t temp_sensor;
-static pthread_mutex_t sensor_mutex = PTHREAD_MUTEX_INITIALIZER;
-static pthread_mutex_t env_temp_monitor_mutex = PTHREAD_MUTEX_INITIALIZER;
-static pthread_cond_t env_temp_monitor_cv = PTHREAD_COND_INITIALIZER;
-static env_temp_threshold_t env_curr_state = NORMAL_THRESHOLD;
-static char *env_thresholds[] = {
- PICL_PROP_LOW_WARNING,
- PICL_PROP_LOW_SHUTDOWN,
- PICL_PROP_LOW_POWER_OFF,
- PICL_PROP_HIGH_WARNING,
- PICL_PROP_HIGH_SHUTDOWN,
- PICL_PROP_HIGH_POWER_OFF
-};
-static int cpu_sensor_geo_addr = 0;
-
-/* local func prototypes */
-static void *env_temp_monitor(void *args);
-
-/*
- * Reads the threshold value from hardware
- */
-static picl_errno_t
-env_get_temp_threshold(int sensor_no, int threshold_no,
- int8_t *threshold_reading)
-{
- sc_reqmsg_t req_pkt;
- sc_rspmsg_t rsp_pkt;
- smc_errno_t rc = SMC_SUCCESS;
- uint8_t size = 0;
-
- if (threshold_no < 1 || threshold_no > 6) {
- return (PICL_INVALIDARG);
- }
-
- req_pkt.data[0] = sensor_no;
- size = ENV_GET_THRESHOLD_PKT_LEN;
- /* initialize the request packet */
- (void) smc_init_smc_msg(&req_pkt, SMC_SENSOR_THRESHOLD_GET,
- DEFAULT_SEQN, size);
-
- /* make a call to smc library to send cmd */
- if ((rc = smc_send_msg(DEFAULT_FD, &req_pkt, &rsp_pkt,
- POLL_TIMEOUT)) != SMC_SUCCESS) {
- syslog(LOG_ERR, SMC_GET_SENSOR_THRES_FAILED,
- sensor_no, rc);
- return (PICL_FAILURE);
- }
-
- switch (threshold_no) {
- case LOW_WARNING_THRESHOLD:
- if (LOW_WARNING_BIT(rsp_pkt.data[0])) {
- *threshold_reading = rsp_pkt.data[1];
- } else {
- return (PICL_PERMDENIED);
- }
- break;
- case LOW_SHUTDOWN_THRESHOLD:
- if (LOW_SHUTDOWN_BIT(rsp_pkt.data[0])) {
- *threshold_reading = rsp_pkt.data[2];
- } else {
- return (PICL_PERMDENIED);
- }
- break;
- case LOW_POWEROFF_THRESHOLD:
- if (LOW_POWEROFF_BIT(rsp_pkt.data[0])) {
- *threshold_reading = rsp_pkt.data[3];
- } else {
- return (PICL_PERMDENIED);
- }
- break;
- case HIGH_WARNING_THRESHOLD:
- if (HIGH_WARNING_BIT(rsp_pkt.data[0])) {
- *threshold_reading = rsp_pkt.data[4];
- } else {
- return (PICL_PERMDENIED);
- }
- break;
- case HIGH_SHUTDOWN_THRESHOLD:
- if (HIGH_SHUTDOWN_BIT(rsp_pkt.data[0])) {
- *threshold_reading = rsp_pkt.data[5];
- } else {
- return (PICL_PERMDENIED);
- }
- break;
- case HIGH_POWEROFF_THRESHOLD:
- if (HIGH_POWEROFF_BIT(rsp_pkt.data[0])) {
- *threshold_reading = rsp_pkt.data[6];
- } else {
- return (PICL_PERMDENIED);
- }
- break;
- default:
- return (PICL_INVALIDARG);
- }
- return (PICL_SUCCESS);
-}
-
-/*
- * Sets the threshold temperature specified in given sensor number
- */
-static picl_errno_t
-env_set_temp_threshold(int sensor_no, int threshold_no,
- int8_t set_value)
-{
- sc_reqmsg_t req_pkt;
- sc_rspmsg_t rsp_pkt;
- smc_errno_t rc;
- uint8_t size = 0;
-
- if (threshold_no < 1 || threshold_no > 6) {
- return (PICL_INVALIDARG);
- }
-
- req_pkt.data[0] = (int8_t)sensor_no;
- req_pkt.data[1] = 0x01 << (threshold_no - 1); /* set the bit mask */
- req_pkt.data[1 + threshold_no] = set_value;
- size = ENV_SET_THRESHOLD_PKT_LEN;
-
- /* initialize the request packet */
- (void) smc_init_smc_msg(&req_pkt, SMC_SENSOR_THRESHOLD_SET,
- DEFAULT_SEQN, size);
-
- /* make a call to smc library to send cmd */
- if ((rc = smc_send_msg(sensor_fd, &req_pkt, &rsp_pkt,
- POLL_TIMEOUT)) != SMC_SUCCESS) {
- syslog(LOG_ERR, SMC_SET_SENSOR_THRES_FAILED,
- sensor_no, rc);
- return (PICL_FAILURE);
- }
- return (PICL_SUCCESS);
-}
-
-/*
- * returns the sensor reading of the SMC sensor specified in sensor_no
- */
-static picl_errno_t
-env_get_sensor_reading(uint8_t sensor_no, int8_t *sensor_reading)
-{
- sc_reqmsg_t req_pkt;
- sc_rspmsg_t rsp_pkt;
- smc_errno_t rc = SMC_SUCCESS;
- uint8_t size = 0;
-
- req_pkt.data[0] = sensor_no;
- /* initialize the request packet */
- size = ENV_READ_SENSOR_PKT_LEN;
- (void) smc_init_smc_msg(&req_pkt, SMC_SENSOR_READING_GET,
- DEFAULT_SEQN, size);
-
- /* make a call to smc library to send cmd */
- if ((rc = smc_send_msg(DEFAULT_FD, &req_pkt, &rsp_pkt,
- POLL_TIMEOUT)) != SMC_SUCCESS) {
- syslog(LOG_ERR, SMC_GET_SENSOR_READING_FAILED,
- sensor_no, rc);
- return (PICL_FAILURE);
- }
- *sensor_reading = rsp_pkt.data[0];
- return (PICL_SUCCESS);
-}
-
-/*
- * volatile call back function to read the current temparature
- */
-static int
-get_curr_temp(ptree_rarg_t *argp, void *bufp)
-{
- uint8_t sensor_no;
- int8_t sensor_reading;
- picl_errno_t rc;
-
- if ((rc = ptree_get_propval_by_name(argp->nodeh,
- PICL_PROP_GEO_ADDR, &sensor_no, sizeof (sensor_no))) !=
- PICL_SUCCESS) {
- return (rc);
- }
-
- /* read the temp from SMC f/w */
- if ((rc = env_get_sensor_reading(sensor_no, &sensor_reading)) !=
- PICL_SUCCESS) {
- return (rc);
- }
- *(int8_t *)bufp = sensor_reading;
-
- /* update the internal cache */
- (void) pthread_mutex_lock(&sensor_mutex);
- temp_sensor.curr_temp = sensor_reading;
- (void) pthread_mutex_unlock(&sensor_mutex);
-
- return (PICL_SUCCESS);
-}
-
-/*
- * volatile function that returns the state of sensor
- */
-static int
-get_sensor_condition(ptree_rarg_t *argp, void *bufp)
-{
- uint8_t sensor_no;
- picl_errno_t rc = PICL_SUCCESS;
- int8_t sensor_reading;
-
- if ((rc = ptree_get_propval_by_name(argp->nodeh,
- PICL_PROP_GEO_ADDR, &sensor_no, sizeof (sensor_no))) !=
- PICL_SUCCESS) {
- return (rc);
- }
-
- /* read the curr temp from SMC f/w */
- if ((rc = env_get_sensor_reading(sensor_no, &sensor_reading)) !=
- PICL_SUCCESS) {
- (void) pthread_mutex_lock(&sensor_mutex);
- (void) strncpy(temp_sensor.state, PICLEVENTARGVAL_UNKNOWN,
- sizeof (temp_sensor.state));
- (void) strncpy((char *)bufp, PICLEVENTARGVAL_UNKNOWN,
- PICL_PROPNAMELEN_MAX);
- (void) pthread_mutex_unlock(&sensor_mutex);
- return (PICL_SUCCESS);
- }
-
- (void) pthread_mutex_lock(&sensor_mutex);
-
- if (sensor_reading > temp_sensor.hi_shutdown ||
- sensor_reading < temp_sensor.lo_shutdown)
- (void) strncpy(temp_sensor.state,
- PICLEVENTARGVAL_SENSOR_COND_SHUTDOWN,
- sizeof (temp_sensor.state));
- else if (sensor_reading > temp_sensor.hi_warning ||
- sensor_reading < temp_sensor.lo_warning)
- (void) strncpy(temp_sensor.state,
- PICLEVENTARGVAL_SENSOR_COND_WARNING,
- sizeof (temp_sensor.state));
- else
- (void) strncpy(temp_sensor.state, PICLEVENTARGVAL_OK,
- sizeof (temp_sensor.state));
- (void) strncpy((char *)bufp, temp_sensor.state,
- PICL_PROPNAMELEN_MAX);
-
- (void) pthread_mutex_unlock(&sensor_mutex);
- return (PICL_SUCCESS);
-}
-
-/*
- * volatile property to read sensor thresholds
- */
-static int
-get_sensor_thr(ptree_rarg_t *argp, void *bufp)
-{
- picl_errno_t rc = PICL_SUCCESS;
- ptree_propinfo_t pi;
- char prop_name[PICL_PROPNAMELEN_MAX];
-
- if ((rc = ptree_get_propinfo(argp->proph, &pi)) != PICL_SUCCESS) {
- return (rc);
- }
- (void) strncpy(prop_name, pi.piclinfo.name, sizeof (prop_name));
-
- (void) pthread_mutex_lock(&sensor_mutex);
-
- if (strcmp(prop_name, PICL_PROP_LOW_WARNING) == 0) {
- *(int8_t *)bufp = temp_sensor.lo_warning;
- } else if (strcmp(prop_name, PICL_PROP_LOW_SHUTDOWN) == 0) {
- *(int8_t *)bufp = temp_sensor.lo_shutdown;
- } else if (strcmp(prop_name, PICL_PROP_LOW_POWER_OFF) == 0) {
- *(int8_t *)bufp = temp_sensor.lo_poweroff;
- } else if (strcmp(prop_name, PICL_PROP_HIGH_WARNING) == 0) {
- *(int8_t *)bufp = temp_sensor.hi_warning;
- } else if (strcmp(prop_name, PICL_PROP_HIGH_SHUTDOWN) == 0) {
- *(int8_t *)bufp = temp_sensor.hi_shutdown;
- } else if (strcmp(prop_name, PICL_PROP_HIGH_POWER_OFF) == 0) {
- *(int8_t *)bufp = temp_sensor.hi_poweroff;
- } else {
- rc = PICL_INVALIDARG;
- }
-
- (void) pthread_mutex_unlock(&sensor_mutex);
- return (rc);
-}
-
-/*
- * volatile callback function to set the temp thresholds
- */
-static int
-set_sensor_thr(ptree_warg_t *argp, const void *bufp)
-{
- picl_errno_t rc = PICL_SUCCESS;
- ptree_propinfo_t pi;
- int threshold_no = 0;
- int8_t temp = *(int8_t *)bufp;
- char cmd[BUF_SIZE];
- char prop_name[PICL_PROPNAMELEN_MAX];
-
- if ((rc = ptree_get_propinfo(argp->proph, &pi)) != PICL_SUCCESS) {
- return (rc);
- }
- (void) strncpy(prop_name, pi.piclinfo.name, sizeof (prop_name));
- cmd[0] = '\0';
-
- (void) pthread_mutex_lock(&sensor_mutex);
-
- if (strcmp(prop_name, PICL_PROP_LOW_WARNING) == 0) {
- /* warning cannot be less than shutdown threshold */
- if (temp <= temp_sensor.lo_shutdown) {
- (void) pthread_mutex_unlock(&sensor_mutex);
- return (PICL_INVALIDARG);
- }
- threshold_no = LOW_WARNING_THRESHOLD;
- } else if (strcmp(prop_name, PICL_PROP_LOW_SHUTDOWN) == 0) {
- /* shutdown cannot be greater than warning threshold */
- if (temp >= temp_sensor.lo_warning) {
- (void) pthread_mutex_unlock(&sensor_mutex);
- return (PICL_INVALIDARG);
- }
- threshold_no = LOW_SHUTDOWN_THRESHOLD;
- } else if (strcmp(prop_name, PICL_PROP_LOW_POWER_OFF) == 0) {
- (void) pthread_mutex_unlock(&sensor_mutex);
- return (PICL_PERMDENIED);
- } else if (strcmp(prop_name, PICL_PROP_HIGH_WARNING) == 0) {
- if ((temp + 5) > temp_sensor.hi_shutdown) {
- (void) pthread_mutex_unlock(&sensor_mutex);
- return (PICL_INVALIDARG);
- }
- /* change the OBP nvram property */
- (void) snprintf(cmd, sizeof (cmd),
- EEPROM_WARNING_CMD, temp);
- threshold_no = HIGH_WARNING_THRESHOLD;
- } else if (strcmp(prop_name, PICL_PROP_HIGH_SHUTDOWN) == 0) {
- if ((temp - 5) < temp_sensor.hi_warning) {
- (void) pthread_mutex_unlock(&sensor_mutex);
- return (PICL_INVALIDARG);
- }
- /* change the OBP nvram property */
- (void) snprintf(cmd, sizeof (cmd),
- EEPROM_SHUTDOWN_CMD, temp);
- threshold_no = HIGH_SHUTDOWN_THRESHOLD;
- } else if (strcmp(prop_name, PICL_PROP_HIGH_POWER_OFF) == 0) {
- if (temp > MAX_POWEROFF_TEMP ||
- (temp - 5) < temp_sensor.hi_shutdown) {
- (void) pthread_mutex_unlock(&sensor_mutex);
- return (PICL_INVALIDARG);
- }
- /* change the OBP nvram property */
- threshold_no = HIGH_POWEROFF_THRESHOLD;
- (void) snprintf(cmd, sizeof (cmd),
- EEPROM_POWEROFF_CMD, temp);
- } else {
- (void) pthread_mutex_unlock(&sensor_mutex);
- return (PICL_INVALIDARG);
- }
- (void) pthread_mutex_unlock(&sensor_mutex);
-
- if ((rc = env_set_temp_threshold(cpu_sensor_geo_addr,
- threshold_no, temp)) != PICL_SUCCESS) {
- return (rc);
- }
-
- (void) pthread_mutex_lock(&sensor_mutex);
- switch (threshold_no) {
- case LOW_WARNING_THRESHOLD:
- temp_sensor.lo_warning = temp;
- break;
- case LOW_SHUTDOWN_THRESHOLD:
- temp_sensor.lo_shutdown = temp;
- break;
- case LOW_POWEROFF_THRESHOLD:
- temp_sensor.lo_poweroff = temp;
- break;
- case HIGH_WARNING_THRESHOLD:
- temp_sensor.hi_warning = temp;
- break;
- case HIGH_SHUTDOWN_THRESHOLD:
- temp_sensor.hi_shutdown = temp;
- break;
- case HIGH_POWEROFF_THRESHOLD:
- temp_sensor.hi_poweroff = temp;
- break;
- }
- (void) pthread_mutex_unlock(&sensor_mutex);
-
- /* execute the cmd to change OBP nvram property */
- if (cmd[0]) {
- (void) pclose(popen(cmd, "w"));
- }
- return (PICL_SUCCESS);
-}
-
-/*
- * this routine reads the hardware state and initialises the internal
- * cache for temperature thresholds
- */
-static picl_errno_t
-env_init_temp_sensor_values(int sensor_no, env_temp_sensor_t *sensor)
-{
- if (env_get_sensor_reading(sensor_no, &sensor->curr_temp) !=
- PICL_SUCCESS) {
- return (PICL_FAILURE);
- }
-
- if (env_get_temp_threshold(sensor_no, LOW_WARNING_THRESHOLD,
- &sensor->lo_warning) != PICL_SUCCESS) {
- syslog(LOG_ERR, SMC_GET_LWT_FAILED);
- return (PICL_FAILURE);
- }
-
- if (env_get_temp_threshold(sensor_no, LOW_SHUTDOWN_THRESHOLD,
- &sensor->lo_shutdown) != PICL_SUCCESS) {
- syslog(LOG_ERR, SMC_GET_LST_FAILED);
- return (PICL_FAILURE);
- }
-
- if (env_get_temp_threshold(sensor_no, LOW_POWEROFF_THRESHOLD,
- &sensor->lo_poweroff) != PICL_SUCCESS) {
- syslog(LOG_ERR, SMC_GET_LPT_FAILED);
- return (PICL_FAILURE);
- }
-
- if (env_get_temp_threshold(sensor_no, HIGH_WARNING_THRESHOLD,
- &sensor->hi_warning) != PICL_SUCCESS) {
- syslog(LOG_ERR, SMC_SET_LWT_FAILED);
- return (PICL_FAILURE);
- }
-
- if (env_get_temp_threshold(sensor_no, HIGH_SHUTDOWN_THRESHOLD,
- &sensor->hi_shutdown) != PICL_SUCCESS) {
- syslog(LOG_ERR, SMC_SET_LST_FAILED);
- return (PICL_FAILURE);
- }
-
- if (env_get_temp_threshold(sensor_no, HIGH_POWEROFF_THRESHOLD,
- &sensor->hi_poweroff) != PICL_SUCCESS) {
- syslog(LOG_ERR, SMC_SET_LPT_FAILED);
- return (PICL_FAILURE);
- }
-
- if (sensor->curr_temp > sensor->hi_shutdown ||
- sensor->curr_temp < sensor->lo_shutdown) {
- (void) strncpy(sensor->state,
- PICLEVENTARGVAL_SENSOR_COND_SHUTDOWN,
- sizeof (sensor->state));
- } else if (sensor->curr_temp > sensor->hi_warning ||
- sensor->curr_temp < sensor->lo_warning) {
- (void) strncpy(sensor->state,
- PICLEVENTARGVAL_SENSOR_COND_WARNING,
- sizeof (sensor->state));
- } else {
- (void) strncpy(sensor->state, PICLEVENTARGVAL_OK,
- sizeof (sensor->state));
- }
- return (PICL_SUCCESS);
-}
-
-/*
- * sensor_event_enable_set: enables or disables Event Message generation
- * from a sensor specified by sensor_no
- */
-static int
-sensor_event_enable_set(uint8_t sensor_no, boolean_t enable)
-{
- smc_errno_t rc = SMC_SUCCESS;
- sc_reqmsg_t req_pkt;
- sc_rspmsg_t rsp_pkt;
- uint8_t size = 0;
-
- req_pkt.data[0] = sensor_no;
- req_pkt.data[1] = 0;
- if (enable) {
- req_pkt.data[1] |= ENV_SENSOR_EVENT_ENABLE_MASK;
- }
- size = ENV_SENSOR_EVENT_ENABLE_PKT_LEN;
-
- (void) smc_init_smc_msg(&req_pkt, SMC_SENSOR_EVENT_ENABLE_SET,
- DEFAULT_SEQN, size);
-
- /* make a call to smc library to send cmd */
- if ((rc = smc_send_msg(DEFAULT_FD, &req_pkt, &rsp_pkt,
- POLL_TIMEOUT)) != SMC_SUCCESS) {
- syslog(LOG_ERR, SMC_ENABLE_SENSOR_EVENT_FAILED, rc);
- return (PICL_FAILURE);
- }
- return (PICL_SUCCESS);
-}
-
-/*
- * creates temperature sensor node and all of its properties
- */
-picl_errno_t
-env_create_temp_sensor_node(picl_nodehdl_t parenth, uint8_t sensor_no)
-{
- int i = 0;
- picl_errno_t rc = PICL_SUCCESS;
- int8_t sensor_reading = 0;
- struct strioctl strio;
- sc_cmdspec_t set;
-
- sensor_fd = env_open_smc();
- if (sensor_fd < 0) {
- syslog(LOG_ERR, gettext("SUNW_envmond:Error in "
- "opening SMC(failed to create sensor nodes)"));
- return (PICL_FAILURE);
- }
-
- /* grab exclusive access to set the thresholds */
- set.args[0] = SMC_SENSOR_THRESHOLD_SET;
- set.attribute = SC_ATTR_EXCLUSIVE;
- strio.ic_cmd = SCIOC_MSG_SPEC;
- strio.ic_timout = 0;
- strio.ic_len = 2;
- strio.ic_dp = (char *)&set;
- if (ioctl(sensor_fd, I_STR, &strio) < 0) {
- syslog(LOG_ERR, SMC_GET_EXCLUSIVE_ERR);
- (void) close(sensor_fd);
- return (PICL_FAILURE);
- }
-
- cpu_sensor_geo_addr = sensor_no;
- /* create temperature sensor node */
- if ((rc = ptree_create_and_add_node(parenth, CPU_SENSOR,
- PICL_CLASS_TEMPERATURE_SENSOR, &sensorh)) !=
- PICL_SUCCESS) {
- (void) close(sensor_fd);
- return (rc);
- }
-
- /* create Label prop. */
- if ((rc = env_create_property(PICL_PTYPE_CHARSTRING, PICL_READ,
- PICL_PROPNAMELEN_MAX, PICL_PROP_LABEL, NULLREAD,
- NULLWRITE, sensorh, (picl_prophdl_t *)NULL,
- (char *)PICL_PROPVAL_LABEL_AMBIENT)) != PICL_SUCCESS) {
- (void) ptree_delete_node(sensorh);
- (void) ptree_destroy_node(sensorh);
- (void) close(sensor_fd);
- return (rc);
- }
-
- /* create the geo-addr property */
- if ((rc = env_create_property(PICL_PTYPE_UNSIGNED_INT,
- PICL_READ, sizeof (sensor_no), PICL_PROP_GEO_ADDR,
- NULLREAD, NULLWRITE, sensorh, (picl_prophdl_t *)NULL,
- &sensor_no)) != PICL_SUCCESS) {
- (void) ptree_delete_node(sensorh);
- (void) ptree_destroy_node(sensorh);
- (void) close(sensor_fd);
- return (rc);
- }
-
- /* read the current temp from hardware */
- if (env_get_sensor_reading(sensor_no, &sensor_reading) !=
- PICL_SUCCESS) {
- (void) ptree_delete_node(sensorh);
- (void) ptree_destroy_node(sensorh);
- (void) close(sensor_fd);
- return (PICL_FAILURE);
- }
-
- /* create temperature prop. */
- if ((rc = env_create_property(PICL_PTYPE_INT,
- PICL_READ + PICL_VOLATILE, sizeof (sensor_reading),
- PICL_PROP_TEMPERATURE, get_curr_temp,
- NULLWRITE, sensorh, (picl_prophdl_t *)NULL,
- &sensor_reading)) != PICL_SUCCESS) {
- (void) ptree_delete_node(sensorh);
- (void) ptree_destroy_node(sensorh);
- (void) close(sensor_fd);
- return (rc);
- }
-
- /* create the threshold properties */
- for (i = 0; i < NUM_OF_THRESHOLDS; i++) {
- if ((rc = env_create_property(PICL_PTYPE_INT,
- PICL_READ + PICL_WRITE + PICL_VOLATILE,
- sizeof (uint8_t), env_thresholds[i],
- get_sensor_thr, set_sensor_thr,
- sensorh, (picl_prophdl_t *)NULL,
- (void *)NULL)) != PICL_SUCCESS) {
- (void) ptree_delete_node(sensorh);
- (void) ptree_destroy_node(sensorh);
- (void) close(sensor_fd);
- return (rc);
- }
- }
-
- /* intialise the internal cache */
- if (env_init_temp_sensor_values(cpu_sensor_geo_addr,
- &temp_sensor) != PICL_SUCCESS) {
- (void) ptree_delete_node(sensorh);
- (void) ptree_destroy_node(sensorh);
- (void) close(sensor_fd);
- return (PICL_FAILURE);
- }
-
- /* create STATE prop. */
- if ((rc = env_create_property(PICL_PTYPE_CHARSTRING,
- PICL_READ + PICL_VOLATILE, PICL_PROPNAMELEN_MAX,
- PICL_PROP_CONDITION, get_sensor_condition, NULLWRITE,
- sensorh, (picl_prophdl_t *)NULL,
- temp_sensor.state)) != PICL_SUCCESS) {
- (void) ptree_delete_node(sensorh);
- (void) ptree_destroy_node(sensorh);
- (void) close(sensor_fd);
- return (rc);
- }
-
- /* start temperature monitoring thread */
- if (pthread_create(&env_temp_thr_tid, NULL,
- &env_temp_monitor, NULL) != 0) {
- syslog(LOG_ERR, gettext("SUNW_envmond:Error in "
- "creating temperature monitor thread"));
- }
-
- /* enable sensor-event */
- (void) sensor_event_enable_set(sensor_no, B_TRUE);
- return (PICL_SUCCESS);
-}
-
-/*
- * handles the sensor events (post corresponding Condition picl event)
- */
-void
-env_handle_sensor_event(void *res_datap)
-{
- uint8_t offset;
- char sensor_cond[BUF_SIZE];
-
- if (BYTE_4(res_datap) != cpu_sensor_geo_addr) {
- return;
- }
-
- if (BYTE_5(res_datap) != THRESHOLD_TYPE) {
- return;
- }
-
- if (env_debug & DEBUG) {
- syslog(LOG_INFO, "Temperature = %d\n", BYTE_7(res_datap));
- syslog(LOG_INFO,
- "Threshold changed to %d\n", BYTE_8(res_datap));
- }
-
- /* Threshold event */
- offset = BYTE_6(res_datap) & 0x0F; /* first 4 bits */
- switch (offset) {
- case 0:
- (void) pthread_mutex_lock(&env_temp_monitor_mutex);
- if (env_curr_state == LOW_WARNING_THRESHOLD) {
- (void) pthread_cond_signal(&env_temp_monitor_cv);
- (void) pthread_mutex_unlock(&env_temp_monitor_mutex);
- return;
- }
- env_curr_state = LOW_WARNING_THRESHOLD;
- (void) pthread_cond_signal(&env_temp_monitor_cv);
- (void) pthread_mutex_unlock(&env_temp_monitor_mutex);
- (void) strncpy(sensor_cond,
- PICLEVENTARGVAL_SENSOR_COND_WARNING,
- sizeof (sensor_cond));
- syslog(LOG_CRIT, gettext("SUNW_envmond:current temperature (%d)"
- " is below lower warning temperature (%d).\n"),
- BYTE_7(res_datap), BYTE_8(res_datap));
- break;
- case 2:
- (void) pthread_mutex_lock(&env_temp_monitor_mutex);
- if (env_curr_state == LOW_SHUTDOWN_THRESHOLD) {
- (void) pthread_cond_signal(&env_temp_monitor_cv);
- (void) pthread_mutex_unlock(&env_temp_monitor_mutex);
- return;
- }
- env_curr_state = LOW_SHUTDOWN_THRESHOLD;
- (void) pthread_cond_signal(&env_temp_monitor_cv);
- (void) pthread_mutex_unlock(&env_temp_monitor_mutex);
- (void) strncpy(sensor_cond,
- PICLEVENTARGVAL_SENSOR_COND_SHUTDOWN,
- sizeof (sensor_cond));
- syslog(LOG_CRIT, gettext("SUNW_envmond:current temperature (%d)"
- " is below lower critical temperature (%d).\n"),
- BYTE_7(res_datap), BYTE_8(res_datap));
- break;
- case 7:
- (void) pthread_mutex_lock(&env_temp_monitor_mutex);
- if (env_curr_state == HIGH_WARNING_THRESHOLD) {
- (void) pthread_cond_signal(&env_temp_monitor_cv);
- (void) pthread_mutex_unlock(&env_temp_monitor_mutex);
- return;
- }
- env_curr_state = HIGH_WARNING_THRESHOLD;
- (void) pthread_cond_signal(&env_temp_monitor_cv);
- (void) pthread_mutex_unlock(&env_temp_monitor_mutex);
- (void) strncpy(sensor_cond,
- PICLEVENTARGVAL_SENSOR_COND_WARNING,
- sizeof (sensor_cond));
- syslog(LOG_CRIT, gettext("SUNW_envmond:current temperature (%d)"
- " exceeds upper warning temperature (%d).\n"),
- BYTE_7(res_datap), BYTE_8(res_datap));
- break;
- case 9:
- (void) pthread_mutex_lock(&env_temp_monitor_mutex);
- if (env_curr_state == HIGH_SHUTDOWN_THRESHOLD) {
- (void) pthread_cond_signal(&env_temp_monitor_cv);
- (void) pthread_mutex_unlock(&env_temp_monitor_mutex);
- return;
- }
- env_curr_state = HIGH_SHUTDOWN_THRESHOLD;
- (void) pthread_cond_signal(&env_temp_monitor_cv);
- (void) pthread_mutex_unlock(&env_temp_monitor_mutex);
- (void) strncpy(sensor_cond,
- PICLEVENTARGVAL_SENSOR_COND_SHUTDOWN,
- sizeof (sensor_cond));
- syslog(LOG_CRIT, gettext("SUNW_envmond:current temperature (%d)"
- " exceeds upper critical temperature (%d).\n"),
- BYTE_7(res_datap), BYTE_8(res_datap));
- break;
- default:
- (void) strncpy(sensor_cond, PICLEVENTARGVAL_UNKNOWN,
- sizeof (sensor_cond));
- break;
- }
-
- if (post_sensor_event(sensorh, sensor_cond, NO_COND_TIMEDWAIT)
- != PICL_SUCCESS) {
- syslog(LOG_ERR, gettext("SUNW_envmond:Error in posting "
- "%s event"), PICLEVENT_CONDITION_CHANGE);
- }
-}
-
-/*
- * this thread monitors the temperature when the current temperature
- * raises above high warning threshold
- */
-/*ARGSUSED*/
-static void *
-env_temp_monitor(void *args)
-{
- int ret;
- timespec_t to;
- int8_t sensor_reading;
- char sensor_cond[BUF_SIZE];
-
- (void) pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
- (void) pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
-
- for (;;) {
- (void) pthread_mutex_lock(&env_temp_monitor_mutex);
- if (env_curr_state == NORMAL_THRESHOLD) {
- pthread_cond_wait(&env_temp_monitor_cv,
- &env_temp_monitor_mutex);
- }
-
- /* check until temp drops below warning threshold */
- to.tv_sec = ENV_TEMP_MONITOR_TIME;
- to.tv_nsec = 0;
- ret = pthread_cond_reltimedwait_np(&env_temp_monitor_cv,
- &env_temp_monitor_mutex, &to);
- if (ret != ETIMEDOUT) {
- (void) pthread_mutex_unlock(&env_temp_monitor_mutex);
- continue;
- }
-
- /* read the present temperature */
- if (env_get_sensor_reading(cpu_sensor_geo_addr,
- &sensor_reading) != PICL_SUCCESS) {
- (void) pthread_mutex_unlock(&env_temp_monitor_mutex);
- continue;
- }
-
- (void) pthread_mutex_lock(&sensor_mutex);
- if (sensor_reading < temp_sensor.hi_warning &&
- sensor_reading > temp_sensor.lo_warning) {
- /* temperature is ok now */
- (void) strncpy(sensor_cond, PICLEVENTARGVAL_OK,
- sizeof (sensor_cond));
- env_curr_state = NORMAL_THRESHOLD;
- }
- (void) pthread_mutex_unlock(&sensor_mutex);
-
- if (env_curr_state == NORMAL_THRESHOLD) {
- syslog(LOG_NOTICE, gettext("SUNW_envmond:Current "
- "temperature is ok now"));
- if (post_sensor_event(sensorh, sensor_cond,
- NO_COND_TIMEDWAIT) != PICL_SUCCESS) {
- syslog(LOG_ERR, gettext("SUNW_envmond:Error in"
- " posting %s event"),
- PICLEVENT_CONDITION_CHANGE);
- }
- }
- (void) pthread_mutex_unlock(&env_temp_monitor_mutex);
- }
- /*NOTREACHED*/
- return (NULL);
-}
diff --git a/usr/src/cmd/picl/plugins/sun4u/snowbird/envmond/piclsensors.h b/usr/src/cmd/picl/plugins/sun4u/snowbird/envmond/piclsensors.h
deleted file mode 100644
index 07a1fd365a..0000000000
--- a/usr/src/cmd/picl/plugins/sun4u/snowbird/envmond/piclsensors.h
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (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 2004 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#ifndef _PICLSENSORS_H
-#define _PICLSENSORS_H
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define CPU_SENSOR "CPU-sensor"
-#define EEPROM_WARNING_CMD "eeprom warning-temperature=%d"
-#define EEPROM_SHUTDOWN_CMD "eeprom critical-temperature=%d"
-#define EEPROM_POWEROFF_CMD "eeprom shutdown-temperature=%d"
-
-#define ENV_TEMP_MONITOR_TIME 60 /* 60 secs */
-
-#define NUM_OF_THRESHOLDS 6
-#define MAX_POWEROFF_TEMP 84
-
-typedef struct {
-uint8_t sensor_no;
- int8_t curr_temp;
- int8_t hi_poweroff;
- int8_t hi_shutdown;
- int8_t hi_warning;
- int8_t lo_poweroff;
- int8_t lo_shutdown;
- int8_t lo_warning;
- char state[20];
-} env_temp_sensor_t;
-
-typedef enum {
- NORMAL_THRESHOLD = 0x0, /* temp is within thresholds */
- LOW_WARNING_THRESHOLD = 0x1,
- LOW_SHUTDOWN_THRESHOLD = 0x2,
- LOW_POWEROFF_THRESHOLD = 0x3,
- HIGH_WARNING_THRESHOLD = 0x4,
- HIGH_SHUTDOWN_THRESHOLD = 0x5,
- HIGH_POWEROFF_THRESHOLD = 0x6
-} env_temp_threshold_t;
-
-#define LOW_WARNING_BIT(_X) (BIT_0(_X))
-#define LOW_SHUTDOWN_BIT(_X) (BIT_1(_X))
-#define LOW_POWEROFF_BIT(_X) (BIT_2(_X))
-#define HIGH_WARNING_BIT(_X) (BIT_3(_X))
-#define HIGH_SHUTDOWN_BIT(_X) (BIT_4(_X))
-#define HIGH_POWEROFF_BIT(_X) (BIT_5(_X))
-
-#define THRESHOLD_TYPE 0x1
-
-#define SMC_GET_SENSOR_READING_FAILED \
- gettext("SUNW_envmond: Error in getting sensor reading, "\
- "sensor = %d, errno = %d\n")
-#define SMC_GET_SENSOR_THRES_FAILED \
- gettext("SUNW_envmond: Error in getting sensor threshold, "\
- "sensor = %d, errno = %d\n")
-#define SMC_SET_SENSOR_THRES_FAILED \
- gettext("SUNW_envmond: Error in setting sensor threshold, "\
- "sensor = %d, errno = %d\n")
-#define SMC_GET_LWT_FAILED \
- gettext("SUNW_envmond: Error in getting low warning threshold")
-#define SMC_GET_LST_FAILED \
- gettext("SUNW_envmond: Error in getting low shutdown threshold")
-#define SMC_GET_LPT_FAILED \
- gettext("SUNW_envmond: Error in getting low poweroff threshold")
-#define SMC_GET_HWT_FAILED \
- gettext("SUNW_envmond: Error in getting high warning threshold")
-#define SMC_GET_HST_FAILED \
- gettext("SUNW_envmond: Error in getting high shutdown threshold")
-#define SMC_GET_HPT_FAILED \
- gettext("SUNW_envmond: Error in getting high poweroff threshold")
-#define SMC_SET_LWT_FAILED \
- gettext("SUNW_envmond: Error in setting low warning threshold")
-#define SMC_SET_LST_FAILED \
- gettext("SUNW_envmond: Error in setting low shutdown threshold")
-#define SMC_SET_LPT_FAILED \
- gettext("SUNW_envmond: Error in setting low poweroff threshold")
-#define SMC_SET_HWT_FAILED \
- gettext("SUNW_envmond: Error in setting high warning threshold")
-#define SMC_SET_HST_FAILED \
- gettext("SUNW_envmond: Error in setting high shutdown threshold")
-#define SMC_SET_HPT_FAILED \
- gettext("SUNW_envmond: Error in setting high poweroff threshold")
-#define SMC_ENABLE_SENSOR_EVENT_FAILED \
- gettext("SUNW_envmond: Error in enabling sesnor events, error = %d")
-#define SMC_GET_EXCLUSIVE_ERR \
- gettext("SUNW_envmond:Error in getting exclusive access to set "\
- "temperature sensor thresholds")
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _PICLSENSORS_H */
diff --git a/usr/src/cmd/picl/plugins/sun4u/snowbird/frutree/Makefile b/usr/src/cmd/picl/plugins/sun4u/snowbird/frutree/Makefile
deleted file mode 100644
index 26585d2071..0000000000
--- a/usr/src/cmd/picl/plugins/sun4u/snowbird/frutree/Makefile
+++ /dev/null
@@ -1,106 +0,0 @@
-#
-# 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 2009 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-# cmd/picl/plugins/sun4u/snowbird/frutree/Makefile
-#
-
-include $(SRC)/Makefile.psm
-
-LIBRARY = libpiclfrutree.a
-VERS = .1
-PLATFORM = SUNW,Netra-CP2300
-
-OBJECTS = piclfrutree.o picllibdevinfo.o piclkstat.o piclscsi.o
-
-# include library definitions
-include $(SRC)/lib/Makefile.lib
-
-ROOT_PLATFORM = $(USR_PLAT_DIR)/$(PLATFORM)
-
-include $(SRC)/cmd/picl/plugins/Makefile.com
-
-CFLAGS += $(CCVERBOSE)
-CPPFLAGS += -D_REENTRANT -I$(SRC)/uts/common/
-
-SRCS= $(OBJECTS:%.o=%.c)
-
-LIBS= $(DYNLIB)
-
-ROOTLIBDIR= $(ROOT_PLAT_PLUGINDIR)
-
-CLEANFILES= $(LINTOUT) $(LINTLIB)
-
-CPPFLAGS += -I$(USR_PSM_INCL_DIR)
-CPPFLAGS += -I$(SRC)/cmd/picl/plugins/lib/picld_pluginutil
-CPPFLAGS += -I$(SRC)/lib/libfru/include
-
-LDLIBS += -L$(SRC)/lib/libptree/$(MACH)
-LDLIBS += -L$(SRC)/cmd/picl/plugins/lib/picld_pluginutil/$(MACH)
-LDLIBS += -L$(ROOT)/usr/lib/picl/plugins -lcfgadm -lc -lpicltree \
- -lpicld_pluginutil -lfru -lnvpair -ldevinfo \
- -lkstat -lpicldevtree
-LDLIBS += -R/usr/platform/sun4u/lib/picl/plugins:/usr/lib/picl/plugins
-
-.KEEP_STATE:
-
-SUBDIRS=
-
-POFILE= snowbird_piclfrutree.po
-POFILES= $(SRCS:%.c=%.po)
-
-all := TARGET= all
-install := TARGET= install
-clean := TARGET= clean
-clobber := TARGET= clobber
-lint := TARGET= lint
-_msg := TARGET= _msg
-
-all: $(LIBS) $(LIBLINKS)
-
-install: $(ROOTLIBDIR) all $(ROOTLIBS) $(ROOTLINKS)
-
-$(LIBLINKS): FRC
- $(RM) $@; $(SYMLINK) ./$(DYNLIB) $@
-
-_msg: $(MSGDOMAIN) $(POFILE)
- $(RM) $(MSGDOMAIN)/$(POFILE)
- $(CP) $(POFILE) $(MSGDOMAIN)/$(POFILE)
-
-$(POFILE): $(POFILES)
- $(CAT) $(POFILES) > $(POFILE)
-
-$(MSGDOMAIN):
- $(INS.dir)
-
-# include library targets
-include $(SRC)/lib/Makefile.targ
-include $(SRC)/cmd/picl/plugins/Makefile.targ
-
-lint :
- $(LINT.c) $(SRCS)
-
-$(SUBDIRS): FRC
- @cd $@; pwd; $(MAKE) $(TARGET)
-
-FRC:
diff --git a/usr/src/cmd/picl/plugins/sun4u/snowbird/frutree/piclfrutree.c b/usr/src/cmd/picl/plugins/sun4u/snowbird/frutree/piclfrutree.c
deleted file mode 100644
index f4a906c232..0000000000
--- a/usr/src/cmd/picl/plugins/sun4u/snowbird/frutree/piclfrutree.c
+++ /dev/null
@@ -1,5969 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (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 2004 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * platform independent module to manage nodes under frutree
- */
-
-/*
- * This file has the frutree initialization code:
- * 1) parse the config file to create all locations in the chassis
- * 2) probe each location to find fru and probe the fru recursively to
- * create locations, port nodes
- * 3) handle hotswap picl events (dr_ap_state_change, dr_req)
- * - update the frutree
- * - send out picl-state-change, picl-condition-events
- * 4) Monitor the port nodes state and condition
- */
-
-#include <stdlib.h>
-#include <sys/param.h>
-#include <strings.h>
-#include <string.h>
-#include <limits.h>
-#include <syslog.h>
-#include <pthread.h>
-#include <thread.h>
-#include <libintl.h>
-#include <sys/systeminfo.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <dirent.h>
-#include <fcntl.h>
-#include <ctype.h>
-#include <time.h>
-#include <poll.h>
-#include <assert.h>
-#include <libnvpair.h>
-#include <alloca.h>
-#include <stdarg.h>
-#include <config_admin.h>
-#include <libdevinfo.h>
-#include <synch.h>
-#include <sys/time.h>
-#include <picl.h>
-#include <picltree.h>
-#include <picldefs.h>
-#include <picld_pluginutil.h>
-#include <libfru.h>
-#include <sys/sysevent/dr.h>
-#include <ptree_impl.h>
-#include "piclfrutree.h"
-
-#pragma init(piclfrutree_register)
-
-/*
- * following values are tunables that can be changed using
- * environment variables
- */
-int frutree_debug = NONE; /* debug switch */
-static int frutree_poll_timeout = 5; /* polling time to monitor ports */
-static int frutree_drwait_time = 10; /* wait time for dr operation */
-
-#define PICL_PROP_CONF_FILE "conf_name"
-#define PICL_ADMINLOCK_DISABLED "disabled"
-#define PICL_ADMINLOCK_ENABLED "enabled"
-#define HASH_TABLE_SIZE (64)
-#define BUF_SIZE 25
-#define HASH_INDEX(s, x) ((int)((x) & ((s) - 1)))
-#define FRUDATA_PTR(_X) ((frutree_frunode_t *)(((hashdata_t *)(_X))->data))
-#define LOCDATA_PTR(_X) ((frutree_locnode_t *)(((hashdata_t *)(_X))->data))
-#define PORTDATA_PTR(_X) ((frutree_portnode_t *)(((hashdata_t *)(_X))->data))
-
-/* Hash table structure */
-typedef struct frutree_hash_elm {
- picl_nodehdl_t hdl;
- void *nodep;
- struct frutree_hash_elm *nextp;
-} frutree_hashelm_t;
-
-typedef struct {
- int hash_size;
- frutree_hashelm_t **tbl;
-} frutree_hash_t;
-
-typedef struct {
- frutree_datatype_t type;
- void *data;
-} hashdata_t;
-
-typedef int (*callback_t)(picl_nodehdl_t, void *);
-typedef enum {
- INIT_FRU = 0x0,
- CREATE_DEVICES_ENTRIES,
- CONFIGURE_FRU,
- UNCONFIGURE_FRU,
- CPU_OFFLINE,
- CPU_ONLINE,
- HANDLE_CONFIGURE,
- HANDLE_UNCONFIGURE,
- HANDLE_INSERT,
- HANDLE_REMOVE,
- HANDLE_LOCSTATE_CHANGE,
- POST_COND_EVENT,
- POST_EVENTS
-} action_t;
-
-typedef struct {
- action_t action;
- void *data;
-} frutree_dr_arg_t;
-
-typedef struct event_queue {
- frutree_dr_arg_t arg;
- struct event_queue *next;
-}ev_queue_t;
-
-typedef struct {
- char node_name[PICL_PROPNAMELEN_MAX];
- picl_nodehdl_t retnodeh;
-} frutree_callback_data_t;
-
-typedef struct remove_list {
- picl_nodehdl_t nodeh;
- struct remove_list *next;
-} delete_list_t;
-
-typedef struct {
- frutree_frunode_t *frup;
- delete_list_t *first;
-} frutree_init_callback_arg_t;
-
-boolean_t frutree_connects_initiated = B_FALSE;
-static ev_queue_t *queue_head = NULL;
-static ev_queue_t *queue_tail = NULL;
-static pthread_mutex_t ev_mutex;
-static pthread_cond_t ev_cond;
-
-static frutree_hash_t node_hash_table = {0, NULL};
-static picl_nodehdl_t chassish = 0;
-static picl_nodehdl_t frutreeh = 0;
-static picl_nodehdl_t rooth = 0;
-static picl_nodehdl_t platformh = 0;
-static boolean_t post_picl_events = B_FALSE;
-static int piclevent_pending = 0;
-static char conf_file[MAXPATHLEN];
-static char sys_name[SYS_NMLN];
-
-static mutex_t piclevent_mutex = DEFAULTMUTEX;
-static cond_t piclevent_completed_cv = DEFAULTCV;
-static rwlock_t hash_lock;
-
-static pthread_t tid;
-static void *dr_thread(void *);
-
-static pthread_t init_threadID;
-static pthread_t monitor_tid;
-static pthread_mutex_t monitor_mutex = PTHREAD_MUTEX_INITIALIZER;
-static pthread_cond_t monitor_cv = PTHREAD_COND_INITIALIZER;
-static int fini_called = 0;
-static void *monitor_node_status(void *);
-static ev_queue_t *remove_from_queue(void);
-static picl_errno_t handle_chassis_configure(frutree_frunode_t *frup);
-
-/*
- * location states.
- */
-static char *loc_state[] = {
- PICLEVENTARGVAL_UNKNOWN,
- PICLEVENTARGVAL_EMPTY,
- PICLEVENTARGVAL_CONNECTED,
- PICLEVENTARGVAL_DISCONNECTED,
- PICLEVENTARGVAL_CONNECTING,
- PICLEVENTARGVAL_DISCONNECTING,
- NULL
-};
-
-/*
- * fru states.
- */
-static char *fru_state[] = {
- PICLEVENTARGVAL_UNKNOWN,
- PICLEVENTARGVAL_CONFIGURED,
- PICLEVENTARGVAL_UNCONFIGURED,
- PICLEVENTARGVAL_CONFIGURING,
- PICLEVENTARGVAL_UNCONFIGURING,
- NULL
-};
-
-/*
- * fru condition.
- */
-static char *fru_cond[] = {
- PICLEVENTARGVAL_UNKNOWN,
- PICLEVENTARGVAL_FAILED,
- PICLEVENTARGVAL_FAILING,
- PICLEVENTARGVAL_OK,
- PICLEVENTARGVAL_TESTING,
- NULL
-};
-
-/*
- * port states.
- */
-static char *port_state[] = {
- PICLEVENTARGVAL_DOWN,
- PICLEVENTARGVAL_UP,
- PICLEVENTARGVAL_UNKNOWN,
- NULL
-};
-
-/*
- * port condition.
- */
-static char *port_cond[] = {
- PICLEVENTARGVAL_OK,
- PICLEVENTARGVAL_FAILING,
- PICLEVENTARGVAL_FAILED,
- PICLEVENTARGVAL_TESTING,
- PICLEVENTARGVAL_UNKNOWN,
- NULL
-};
-
-/* mapping between libcfgadm error codes to picl error codes */
-static const int cfg2picl_errmap[][2] = {
- {CFGA_OK, PICL_SUCCESS},
- {CFGA_NACK, PICL_NORESPONSE},
- {CFGA_NOTSUPP, PICL_NOTSUPPORTED},
- {CFGA_OPNOTSUPP, PICL_NOTSUPPORTED},
- {CFGA_PRIV, PICL_FAILURE},
- {CFGA_BUSY, PICL_TREEBUSY},
- {CFGA_SYSTEM_BUSY, PICL_TREEBUSY},
- {CFGA_DATA_ERROR, PICL_FAILURE},
- {CFGA_LIB_ERROR, PICL_FAILURE},
- {CFGA_NO_LIB, PICL_FAILURE},
- {CFGA_INSUFFICENT_CONDITION, PICL_FAILURE},
- {CFGA_INVAL, PICL_INVALIDARG},
- {CFGA_ERROR, PICL_FAILURE},
- {CFGA_APID_NOEXIST, PICL_NODENOTFOUND},
- {CFGA_ATTR_INVAL, PICL_INVALIDARG}
-};
-
-/* local functions */
-static void piclfrutree_register(void);
-static void piclfrutree_init(void);
-static void piclfrutree_fini(void);
-static void * init_thread(void *);
-static void frutree_wd_evhandler(const char *, const void *, size_t, void *);
-static void frutree_dr_apstate_change_evhandler(const char *, const void *,
- size_t, void *);
-static void frutree_dr_req_evhandler(const char *, const void *,
- size_t, void *);
-static void frutree_cpu_state_change_evhandler(const char *, const void *,
- size_t, void *);
-static void init_queue(void);
-static void frutree_get_env();
-static picl_errno_t hash_init(void);
-static picl_errno_t hash_remove_entry(picl_nodehdl_t);
-static picl_errno_t hash_lookup_entry(picl_nodehdl_t, void **);
-static void hash_destroy();
-static picl_errno_t initialize_frutree();
-static picl_errno_t update_loc_state(frutree_locnode_t *, boolean_t *);
-static int is_autoconfig_enabled(char *);
-static picl_errno_t do_action(picl_nodehdl_t, int action, void *);
-static picl_errno_t probe_fru(frutree_frunode_t *, boolean_t);
-static picl_errno_t handle_fru_unconfigure(frutree_frunode_t *);
-static picl_errno_t update_loc_state(frutree_locnode_t *, boolean_t *);
-static picl_errno_t update_fru_state(frutree_frunode_t *, boolean_t *);
-static picl_errno_t update_port_state(frutree_portnode_t *, boolean_t);
-static picl_errno_t configure_fru(frutree_frunode_t *, cfga_flags_t);
-static picl_errno_t post_piclevent(const char *, char *, char *,
- picl_nodehdl_t, frutree_wait_t);
-static picl_errno_t fru_init(frutree_frunode_t *);
-
-/* External functions */
-extern boolean_t is_fru_present_under_location(frutree_locnode_t *);
-extern int kstat_port_state(frutree_port_type_t, char *, int);
-extern int kstat_port_cond(frutree_port_type_t, char *, int);
-extern picl_errno_t probe_libdevinfo(frutree_frunode_t *,
- frutree_device_args_t **, boolean_t);
-extern picl_errno_t get_scsislot_name(char *, char *, char *);
-extern picl_errno_t probe_for_scsi_frus(frutree_frunode_t *);
-extern picl_errno_t get_fru_path(char *, frutree_frunode_t *);
-extern picl_errno_t scsi_info_init();
-extern void scsi_info_fini();
-extern picl_errno_t get_port_info(frutree_portnode_t *);
-extern char *strtok_r(char *s1, const char *s2, char **lasts);
-
-/* Plugin initialization */
-static picld_plugin_reg_t frutree_reg_info = {
- PICLD_PLUGIN_VERSION_1,
- PICLD_PLUGIN_CRITICAL,
- "SUNW_piclfrutree",
- piclfrutree_init,
- piclfrutree_fini
-};
-
-/* ptree entry points */
-static void
-piclfrutree_register(void)
-{
- FRUTREE_DEBUG0(FRUTREE_INIT, "piclfrutree register");
- (void) picld_plugin_register(&frutree_reg_info);
-}
-
-static void
-piclfrutree_init(void)
-{
- FRUTREE_DEBUG0(FRUTREE_INIT, "piclfrutree_init begin");
- (void) rwlock_init(&hash_lock, USYNC_THREAD, NULL);
- fini_called = 0;
-
- /* read the environment variables */
- frutree_get_env();
-
- if (sysinfo(SI_PLATFORM, sys_name, sizeof (sys_name)) == -1) {
- return;
- }
-
- if (hash_init() != PICL_SUCCESS) {
- return;
- }
- if (initialize_frutree() != PICL_SUCCESS) {
- return;
- }
-
- /* initialize the event queue */
- (void) init_queue();
-
- (void) pthread_cond_init(&ev_cond, NULL);
- (void) pthread_mutex_init(&ev_mutex, NULL);
- if (pthread_create(&tid, NULL, &dr_thread, NULL) != 0) {
- return;
- }
- /* register for picl events */
- if (ptree_register_handler(PICLEVENT_DR_AP_STATE_CHANGE,
- frutree_dr_apstate_change_evhandler, NULL) !=
- PICL_SUCCESS) {
- return;
- }
-
- if (ptree_register_handler(PICLEVENT_DR_REQ,
- frutree_dr_req_evhandler, NULL) != PICL_SUCCESS) {
- return;
- }
-
- if (ptree_register_handler(PICLEVENT_CPU_STATE_CHANGE,
- frutree_cpu_state_change_evhandler, NULL) !=
- PICL_SUCCESS) {
- return;
- }
-
- if (ptree_register_handler(PICLEVENT_STATE_CHANGE,
- frutree_wd_evhandler, NULL) != PICL_SUCCESS) {
- return;
- }
- FRUTREE_DEBUG0(FRUTREE_INIT, "piclfrutree_init end");
-}
-
-static void
-piclfrutree_fini(void)
-{
- ev_queue_t *event = NULL;
- void *exitval;
-
- FRUTREE_DEBUG0(EVENTS, "piclfrutree_fini begin");
-
- fini_called = 1;
- /* unregister event handlers */
- (void) ptree_unregister_handler(PICLEVENT_DR_AP_STATE_CHANGE,
- frutree_dr_apstate_change_evhandler, NULL);
- (void) ptree_unregister_handler(PICLEVENT_DR_REQ,
- frutree_dr_req_evhandler, NULL);
- (void) ptree_unregister_handler(PICLEVENT_CPU_STATE_CHANGE,
- frutree_cpu_state_change_evhandler, NULL);
- (void) ptree_unregister_handler(PICLEVENT_STATE_CHANGE,
- frutree_wd_evhandler, NULL);
-
- /* flush the event queue */
- (void) pthread_mutex_lock(&ev_mutex);
- event = remove_from_queue();
- while (event) {
- free(event);
- event = remove_from_queue();
- }
- queue_head = queue_tail = NULL;
-
- (void) pthread_cond_broadcast(&ev_cond);
- (void) pthread_mutex_unlock(&ev_mutex);
- (void) pthread_cancel(tid);
- (void) pthread_join(tid, &exitval);
- (void) pthread_cancel(monitor_tid);
- (void) pthread_join(monitor_tid, &exitval);
- (void) pthread_cancel(init_threadID);
- (void) pthread_join(init_threadID, &exitval);
-
- hash_destroy();
- (void) ptree_delete_node(frutreeh);
- (void) ptree_destroy_node(frutreeh);
-
- frutree_connects_initiated = B_FALSE;
- chassish = frutreeh = rooth = platformh = 0;
- post_picl_events = B_FALSE;
- piclevent_pending = 0;
- FRUTREE_DEBUG0(EVENTS, "piclfrutree_fini end");
-}
-
-/* read the ENVIRONMENT variables and initialize tunables */
-static void
-frutree_get_env()
-{
- char *val;
- int intval = 0;
-
- /* read frutree debug flag value */
- if (val = getenv(FRUTREE_DEBUG)) {
- errno = 0;
- intval = strtol(val, (char **)NULL, 0);
- if (errno == 0) {
- frutree_debug = intval;
- FRUTREE_DEBUG1(PRINT_ALL, "SUNW_frutree:debug = %x",
- frutree_debug);
- }
- }
-
- /* read poll timeout value */
- if (val = getenv(FRUTREE_POLL_TIMEOUT)) {
- errno = 0;
- intval = strtol(val, (char **)NULL, 0);
- if (errno == 0) {
- frutree_poll_timeout = intval;
- }
- }
-
- /* read drwait time value */
- if (val = getenv(FRUTREE_DRWAIT)) {
- errno = 0;
- intval = strtol(val, (char **)NULL, 0);
- if (errno == 0) {
- frutree_drwait_time = intval;
- }
- }
-}
-
-/*
- * callback function for ptree_walk_tree_class to get the
- * node handle of node
- * matches a node with same class and name
- */
-static int
-frutree_get_nodehdl(picl_nodehdl_t nodeh, void *c_args)
-{
- picl_errno_t rc;
- char name[PICL_PROPNAMELEN_MAX];
- frutree_callback_data_t *fru_arg;
-
- if (c_args == NULL)
- return (PICL_INVALIDARG);
- fru_arg = (frutree_callback_data_t *)c_args;
-
- if ((rc = ptree_get_propval_by_name(nodeh, PICL_PROP_NAME, name,
- sizeof (name))) != PICL_SUCCESS) {
- return (rc);
- }
-
- if (strcmp(fru_arg->node_name, name) == 0) {
- fru_arg->retnodeh = nodeh;
- return (PICL_WALK_TERMINATE);
- }
- return (PICL_WALK_CONTINUE);
-}
-
-/* queue implementation (used to queue hotswap events) */
-static void
-init_queue(void)
-{
- queue_head = NULL;
- queue_tail = NULL;
-}
-
-/* add an event to the queue */
-static int
-add_to_queue(frutree_dr_arg_t dr_data)
-{
- ev_queue_t *new_event;
-
- new_event = (ev_queue_t *)malloc(sizeof (ev_queue_t));
- if (new_event == NULL)
- return (PICL_NOSPACE);
-
- new_event->arg.action = dr_data.action;
- new_event->arg.data = dr_data.data;
- new_event->next = NULL;
-
- if (queue_head == NULL) {
- queue_head = new_event;
- } else {
- queue_tail->next = new_event;
- }
- queue_tail = new_event;
-
- return (PICL_SUCCESS);
-}
-
-static ev_queue_t *
-remove_from_queue(void)
-{
- ev_queue_t *event = NULL;
-
- if (queue_head == NULL)
- return (NULL);
-
- event = queue_head;
- queue_head = queue_head->next;
-
- if (queue_head == NULL)
- queue_tail = NULL;
- return (event);
-}
-
-/*
- * event handler for watchdog expiry event (picl-state-change) event on
- * watchdog-timer node
- */
-/* ARGSUSED */
-static void
-frutree_wd_evhandler(const char *ename, const void *earg, size_t size,
- void *cookie)
-{
- nvlist_t *nvlp;
- char *wd_state = NULL;
- picl_errno_t rc;
- picl_nodehdl_t wd_nodehdl;
- char value[PICL_PROPNAMELEN_MAX];
- frutree_callback_data_t fru_arg;
-
- if (ename == NULL)
- return;
-
- if (strncmp(ename, PICLEVENT_STATE_CHANGE,
- strlen(PICLEVENT_STATE_CHANGE))) {
- return;
- }
-
- if (nvlist_unpack((char *)earg, size, &nvlp, NULL)) {
- return;
- }
-
- if (nvlist_lookup_uint64(nvlp, PICLEVENTARG_NODEHANDLE,
- &wd_nodehdl) == -1) {
- nvlist_free(nvlp);
- return;
- }
-
- if (nvlist_lookup_string(nvlp, PICLEVENTARG_STATE,
- &wd_state) != 0) {
- nvlist_free(nvlp);
- return;
- }
-
- if ((rc = ptree_get_propval_by_name(wd_nodehdl,
- PICL_PROP_CLASSNAME, value, sizeof (value))) != PICL_SUCCESS) {
- nvlist_free(nvlp);
- return;
- }
-
- /* if the event is not of watchdog-timer, return */
- if (strcmp(value, PICL_CLASS_WATCHDOG_TIMER) != 0) {
- nvlist_free(nvlp);
- return;
- }
-
- FRUTREE_DEBUG1(EVENTS, "frutree:Received WD event(%s)", wd_state);
- /* frutree plugin handles only watchdog expiry events */
- if (strcmp(wd_state, PICL_PROPVAL_WD_STATE_EXPIRED) != 0) {
- nvlist_free(nvlp);
- return;
- }
-
- if ((rc = ptree_get_propval_by_name(wd_nodehdl,
- PICL_PROP_WATCHDOG_ACTION, value, sizeof (value))) !=
- PICL_SUCCESS) {
- nvlist_free(nvlp);
- return;
- }
-
- /* if action is none, dont do anything */
- if (strcmp(value, PICL_PROPVAL_WD_ACTION_NONE) == 0) {
- nvlist_free(nvlp);
- return;
- }
-
- /* find the CPU nodehdl */
- (void) strncpy(fru_arg.node_name, SANIBEL_PICLNODE_CPU,
- sizeof (fru_arg.node_name));
- fru_arg.retnodeh = 0;
- if ((rc = ptree_walk_tree_by_class(chassish, PICL_CLASS_FRU,
- &fru_arg, frutree_get_nodehdl)) != PICL_SUCCESS) {
- nvlist_free(nvlp);
- return;
- }
-
- if (fru_arg.retnodeh == NULL) {
- nvlist_free(nvlp);
- return;
- }
-
- if ((rc = post_piclevent(PICLEVENT_CONDITION_CHANGE,
- PICLEVENTARGVAL_FAILED, NULL, fru_arg.retnodeh,
- NO_WAIT)) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_POST_PICLEVENT_ERR,
- SANIBEL_PICLNODE_CPU, PICLEVENT_CONDITION_CHANGE, rc);
- }
- nvlist_free(nvlp);
-}
-
-/*
- * event handler for dr_ap_state_change event
- * - determine the event type and queue it in dr_queue to handle it
- */
-/* ARGSUSED */
-static void
-frutree_dr_apstate_change_evhandler(const char *ename, const void *earg,
- size_t size, void *cookie)
-{
- nvlist_t *nvlp;
- char *name = NULL;
- char *ap_id = NULL;
- char *hint = NULL;
- picl_nodehdl_t nodeh, childh;
- hashdata_t *hashptr = NULL;
- frutree_dr_arg_t dr_arg;
- frutree_frunode_t *frup = NULL;
- frutree_locnode_t *locp = NULL;
- frutree_callback_data_t fru_arg;
- boolean_t state_changed = B_FALSE;
-
- if (ename == NULL)
- return;
-
- if (strncmp(ename, PICLEVENT_DR_AP_STATE_CHANGE,
- strlen(PICLEVENT_DR_AP_STATE_CHANGE)) != 0) {
- return;
- }
-
- if (nvlist_unpack((char *)earg, size, &nvlp, NULL)) {
- return;
- }
-
- if (nvlist_lookup_string(nvlp, PICLEVENTARG_AP_ID, &ap_id) == -1) {
- nvlist_free(nvlp);
- return;
- }
-
- if (nvlist_lookup_string(nvlp, PICLEVENTARG_HINT, &hint) == -1) {
- nvlist_free(nvlp);
- return;
- }
-
- /* check for empty strings */
- if (!ap_id || !hint) {
- FRUTREE_DEBUG0(EVENTS, "Empty hint/ap_id");
- nvlist_free(nvlp);
- return;
- }
-
- /* get the location name */
- name = strrchr(ap_id, ':');
- if (name == NULL) {
- name = ap_id;
- } else {
- name++;
- }
-
- /* find the loc object */
- (void) strncpy(fru_arg.node_name, name, sizeof (fru_arg.node_name));
- fru_arg.retnodeh = 0;
- if (ptree_walk_tree_by_class(chassish, PICL_CLASS_LOCATION,
- &fru_arg, frutree_get_nodehdl) != PICL_SUCCESS) {
- nvlist_free(nvlp);
- return;
- }
-
- if (fru_arg.retnodeh == NULL) {
- nvlist_free(nvlp);
- return;
- }
- nodeh = fru_arg.retnodeh;
-
- if (hash_lookup_entry(nodeh, (void **)&hashptr) != PICL_SUCCESS) {
- nvlist_free(nvlp);
- return;
- }
- locp = LOCDATA_PTR(hashptr);
- if (locp == NULL) {
- nvlist_free(nvlp);
- return;
- }
-
- if (strcmp(hint, DR_HINT_INSERT) == 0) {
- dr_arg.action = HANDLE_INSERT;
- dr_arg.data = locp;
- (void) pthread_mutex_lock(&ev_mutex);
- if (add_to_queue(dr_arg) != PICL_SUCCESS) {
- (void) pthread_mutex_unlock(&ev_mutex);
- nvlist_free(nvlp);
- return;
- }
- (void) pthread_cond_signal(&ev_cond);
- (void) pthread_mutex_unlock(&ev_mutex);
- nvlist_free(nvlp);
- return;
- }
-
- if (strcmp(hint, DR_HINT_REMOVE) == 0) {
- dr_arg.action = HANDLE_REMOVE;
- dr_arg.data = locp;
- (void) pthread_mutex_lock(&ev_mutex);
- if (add_to_queue(dr_arg) != PICL_SUCCESS) {
- (void) pthread_mutex_unlock(&ev_mutex);
- nvlist_free(nvlp);
- return;
- }
- (void) pthread_cond_signal(&ev_cond);
- (void) pthread_mutex_unlock(&ev_mutex);
- nvlist_free(nvlp);
- return;
- }
-
- if (strcmp(hint, DR_RESERVED_ATTR) != 0) { /* unknown event */
- nvlist_free(nvlp);
- return;
- }
-
- /* handle DR_RESERVED_ATTR HINT */
- /* check if this is a fru event */
- if (ptree_get_propval_by_name(locp->locnodeh, PICL_PROP_CHILD,
- &childh, sizeof (childh)) == PICL_SUCCESS) {
- /* get the child fru information */
- if (hash_lookup_entry(childh, (void **)&hashptr) ==
- PICL_SUCCESS) {
- frup = FRUDATA_PTR(hashptr);
- }
- }
- if (frup == NULL) {
- nvlist_free(nvlp);
- return;
- }
-
- (void) pthread_mutex_lock(&frup->mutex);
- if (frup->dr_in_progress) {
- /* dr in progress, neglect the event */
- (void) pthread_mutex_unlock(&frup->mutex);
- nvlist_free(nvlp);
- return;
- }
- (void) pthread_mutex_unlock(&frup->mutex);
-
- if (update_fru_state(frup, &state_changed) != PICL_SUCCESS) {
- nvlist_free(nvlp);
- return;
- }
-
- if (state_changed) {
- (void) pthread_mutex_lock(&frup->mutex);
- /* figure out if this is config/unconfig operation */
- if (frup->state == FRU_STATE_CONFIGURED) {
- dr_arg.action = HANDLE_CONFIGURE;
- dr_arg.data = frup;
- } else if (frup->state == FRU_STATE_UNCONFIGURED) {
- dr_arg.action = HANDLE_UNCONFIGURE;
- dr_arg.data = frup;
- }
- (void) pthread_mutex_unlock(&frup->mutex);
-
- (void) pthread_mutex_lock(&ev_mutex);
- if (add_to_queue(dr_arg) != PICL_SUCCESS) {
- (void) pthread_mutex_unlock(&ev_mutex);
- nvlist_free(nvlp);
- return;
- }
- (void) pthread_cond_signal(&ev_cond);
- (void) pthread_mutex_unlock(&ev_mutex);
- nvlist_free(nvlp);
- return;
- }
-
- /* check if this event is related to location */
- (void) pthread_mutex_lock(&locp->mutex);
- if (locp->dr_in_progress) {
- /* dr in progress, neglect the event */
- (void) pthread_mutex_unlock(&locp->mutex);
- nvlist_free(nvlp);
- return;
- }
- (void) pthread_mutex_unlock(&locp->mutex);
- if (update_loc_state(locp, &state_changed) != PICL_SUCCESS) {
- nvlist_free(nvlp);
- return;
- }
-
- if (state_changed) { /* location state has changed */
- dr_arg.action = HANDLE_LOCSTATE_CHANGE;
- dr_arg.data = locp;
-
- (void) pthread_mutex_lock(&ev_mutex);
- if (add_to_queue(dr_arg) != PICL_SUCCESS) {
- (void) pthread_mutex_unlock(&ev_mutex);
- nvlist_free(nvlp);
- return;
- }
- (void) pthread_cond_signal(&ev_cond);
- (void) pthread_mutex_unlock(&ev_mutex);
- nvlist_free(nvlp);
- return;
- }
- /* duplicate event */
- nvlist_free(nvlp);
-}
-
-/*
- * Event handler for dr_req event
- */
-/* ARGSUSED */
-static void
-frutree_dr_req_evhandler(const char *ename, const void *earg, size_t size,
- void *cookie)
-{
- nvlist_t *nvlp;
- char *name = NULL;
- char *ap_id = NULL;
- char *dr_req = NULL;
- picl_nodehdl_t nodeh;
- frutree_dr_arg_t dr_arg;
- hashdata_t *hashptr = NULL;
- frutree_frunode_t *frup = NULL;
- frutree_callback_data_t fru_arg;
-
- if (ename == NULL)
- return;
-
- if (strncmp(ename, PICLEVENT_DR_REQ, strlen(PICLEVENT_DR_REQ)) != 0) {
- return;
- }
- if (nvlist_unpack((char *)earg, size, &nvlp, NULL)) {
- return;
- }
- if (nvlist_lookup_string(nvlp, PICLEVENTARG_AP_ID, &ap_id) == -1) {
- nvlist_free(nvlp);
- return;
- }
- if (nvlist_lookup_string(nvlp, PICLEVENTARG_DR_REQ_TYPE,
- &dr_req) == -1) {
- nvlist_free(nvlp);
- return;
- }
-
- if (!ap_id || !dr_req) {
- FRUTREE_DEBUG0(EVENTS, "Empty dr_req/ap_id");
- nvlist_free(nvlp);
- return;
- }
-
- /* get the location name */
- name = strrchr(ap_id, ':');
- if (name == NULL) {
- name = ap_id;
- } else {
- name++;
- }
-
- if (name == NULL) {
- nvlist_free(nvlp);
- return;
- }
-
- FRUTREE_DEBUG2(EVENTS, "DR_REQ:%s on %s", dr_req, name);
- (void) strncpy(fru_arg.node_name, name, sizeof (fru_arg.node_name));
- fru_arg.retnodeh = 0;
- if (ptree_walk_tree_by_class(frutreeh, PICL_CLASS_FRU,
- &fru_arg, frutree_get_nodehdl) != PICL_SUCCESS) {
- nvlist_free(nvlp);
- return;
- }
-
- if (fru_arg.retnodeh == NULL) {
- nvlist_free(nvlp);
- return;
- }
- nodeh = fru_arg.retnodeh;
-
- /* find the fru object */
- if (hash_lookup_entry(nodeh, (void **)&hashptr) != PICL_SUCCESS) {
- nvlist_free(nvlp);
- return;
- }
- frup = FRUDATA_PTR(hashptr);
- if (frup == NULL) {
- nvlist_free(nvlp);
- return;
- }
-
- if (strcmp(dr_req, DR_REQ_INCOMING_RES) == 0) {
- dr_arg.action = CONFIGURE_FRU;
- dr_arg.data = frup;
-
- } else if (strcmp(dr_req, DR_REQ_OUTGOING_RES) == 0) {
- dr_arg.action = UNCONFIGURE_FRU;
- dr_arg.data = frup;
-
- } else {
- nvlist_free(nvlp);
- return;
- }
-
- (void) pthread_mutex_lock(&ev_mutex);
- if (add_to_queue(dr_arg) != PICL_SUCCESS) {
- (void) pthread_mutex_unlock(&ev_mutex);
- nvlist_free(nvlp);
- return;
- }
- (void) pthread_cond_signal(&ev_cond);
- (void) pthread_mutex_unlock(&ev_mutex);
- nvlist_free(nvlp);
-}
-
-/*
- * Event handler for cpu_state_change event
- */
-/* ARGSUSED */
-static void
-frutree_cpu_state_change_evhandler(const char *ename, const void *earg,
- size_t size, void *cookie)
-{
- char *hint = NULL;
- nvlist_t *nvlp;
- frutree_frunode_t *frup = NULL;
- hashdata_t *hashptr = NULL;
- picl_nodehdl_t nodeh;
- frutree_dr_arg_t dr_arg;
-
- if (ename == NULL)
- return;
-
- if (strncmp(ename, PICLEVENT_CPU_STATE_CHANGE,
- strlen(PICLEVENT_CPU_STATE_CHANGE)) != 0) {
- return;
- }
-
- if (nvlist_unpack((char *)earg, size, &nvlp, NULL)) {
- return;
- }
- if (nvlist_lookup_uint64(nvlp, PICLEVENTARG_NODEHANDLE, &nodeh) == -1) {
- nvlist_free(nvlp);
- return;
- }
- if (nvlist_lookup_string(nvlp, PICLEVENTARG_CPU_EV_TYPE, &hint) == -1) {
- nvlist_free(nvlp);
- return;
- }
-
- if (hash_lookup_entry(nodeh, (void **)&hashptr) != PICL_SUCCESS) {
- nvlist_free(nvlp);
- return;
- }
- frup = FRUDATA_PTR(hashptr);
- if (frup == NULL) {
- nvlist_free(nvlp);
- return;
- }
-
- if (strcmp(hint, PICLEVENTARGVAL_OFFLINE) == 0) {
- dr_arg.action = CPU_OFFLINE;
- dr_arg.data = frup;
- } else if (strcmp(hint, PICLEVENTARGVAL_ONLINE) == 0) {
- dr_arg.action = CPU_ONLINE;
- dr_arg.data = frup;
- } else {
- nvlist_free(nvlp);
- return;
- }
-
- (void) pthread_mutex_lock(&ev_mutex);
- if (add_to_queue(dr_arg) != PICL_SUCCESS) {
- (void) pthread_mutex_unlock(&ev_mutex);
- nvlist_free(nvlp);
- return;
- }
- (void) pthread_cond_signal(&ev_cond);
- (void) pthread_mutex_unlock(&ev_mutex);
- nvlist_free(nvlp);
-}
-
-static void
-attach_driver(char *driver)
-{
- char cmd[BUF_SIZE];
- cmd[0] = '\0';
- (void) snprintf(cmd, sizeof (cmd), "%s %s",
- DEVFSADM_CMD, driver);
- (void) pclose(popen(cmd, "r"));
-}
-
-/*
- * Find the node in platform tree with given devfs-path.
- * ptree_find_node is getting a node with devfs-path /pci@1f,0/pci@1,1
- * when we want to find node with /pci@1f,0/pci@1. The fix
- * is required in libpicltree. For now use ptree_walk_tree_by_class
- * to find the node.
- */
-static int
-find_ref_parent(picl_nodehdl_t nodeh, void *c_args)
-{
- picl_prophdl_t proph;
- ptree_propinfo_t propinfo;
- void *vbuf;
- frutree_callback_data_t *fru_arg;
-
- if (c_args == NULL)
- return (PICL_INVALIDARG);
- fru_arg = (frutree_callback_data_t *)c_args;
-
- if (ptree_get_prop_by_name(nodeh, PICL_PROP_DEVFS_PATH,
- &proph) != PICL_SUCCESS) {
- return (PICL_WALK_CONTINUE);
- }
-
- if (ptree_get_propinfo(proph, &propinfo) != PICL_SUCCESS) {
- return (PICL_WALK_CONTINUE);
- }
-
- vbuf = alloca(propinfo.piclinfo.size);
- if (vbuf == NULL)
- return (PICL_WALK_CONTINUE);
-
- if (ptree_get_propval(proph, vbuf,
- propinfo.piclinfo.size) != PICL_SUCCESS) {
- return (PICL_WALK_CONTINUE);
- }
-
- /* compare the devfs_path */
- if (strcmp(fru_arg->node_name, (char *)vbuf) == 0) {
- fru_arg->retnodeh = nodeh;
- return (PICL_WALK_TERMINATE);
- }
- return (PICL_WALK_CONTINUE);
-}
-/*
- * Find the reference node in /platform tree
- * return : 0 - if node is not found
- */
-static picl_nodehdl_t
-get_reference_handle(picl_nodehdl_t nodeh)
-{
- picl_prophdl_t proph;
- ptree_propinfo_t propinfo;
- void *vbuf;
- picl_errno_t rc = PICL_SUCCESS;
- char devfs_path[PICL_PROPNAMELEN_MAX];
- char value[PICL_PROPNAMELEN_MAX];
- char class[PICL_PROPNAMELEN_MAX];
- frutree_callback_data_t fru_arg;
- picl_nodehdl_t refhdl = 0, ref_parent = 0, nodehdl = 0;
-
- /*
- * for fru node, get the devfspath and bus-addr of
- * its parent.
- */
- if (ptree_get_propval_by_name(nodeh, PICL_PROP_CLASSNAME,
- class, sizeof (class)) != PICL_SUCCESS) {
- return (0);
- }
-
- if (strcmp(class, PICL_CLASS_FRU) == 0) {
- if (ptree_get_propval_by_name(nodeh, PICL_PROP_PARENT,
- &nodehdl, sizeof (nodehdl)) != PICL_SUCCESS) {
- return (0);
- }
- } else if (strcmp(class, PICL_CLASS_PORT) == 0) {
- nodehdl = nodeh;
- } else {
- return (0);
- }
-
- if (ptree_get_propval_by_name(nodehdl, PICL_PROP_DEVFS_PATH,
- devfs_path, sizeof (devfs_path)) != PICL_SUCCESS) {
- return (0);
- }
- if (ptree_get_propval_by_name(nodehdl, PICL_PROP_BUS_ADDR,
- value, sizeof (value)) != PICL_SUCCESS) {
- return (0);
- }
-
- /* find the node with same devfs-path */
- (void) strncpy(fru_arg.node_name, devfs_path,
- sizeof (fru_arg.node_name));
- fru_arg.retnodeh = 0;
- if (ptree_walk_tree_by_class(platformh, NULL,
- (void *)&fru_arg, find_ref_parent) != PICL_SUCCESS) {
- return (0);
- }
-
- if (fru_arg.retnodeh == NULL)
- return (0);
-
- ref_parent = fru_arg.retnodeh;
- /* traverse thru childeren and find the reference node */
- rc = ptree_get_propval_by_name(ref_parent, PICL_PROP_CHILD,
- &refhdl, sizeof (picl_nodehdl_t));
- while (rc == PICL_SUCCESS) {
- nodehdl = refhdl;
- rc = ptree_get_propval_by_name(refhdl, PICL_PROP_PEER,
- &refhdl, sizeof (picl_nodehdl_t));
- /*
- * compare the bus_addr or Unit address
- * format of bus_addr can be either (1,3 or 0x6)
- */
- if (ptree_get_prop_by_name(nodehdl, PICL_PROP_BUS_ADDR,
- &proph) != PICL_SUCCESS) {
- if (ptree_get_prop_by_name(nodehdl,
- PICL_PROP_UNIT_ADDRESS, &proph) !=
- PICL_SUCCESS) {
- continue;
- }
- }
-
- if (ptree_get_propinfo(proph, &propinfo) != PICL_SUCCESS) {
- continue;
- }
-
- vbuf = alloca(propinfo.piclinfo.size);
- if (vbuf == NULL)
- continue;
-
- if (ptree_get_propval(proph, vbuf,
- propinfo.piclinfo.size) != PICL_SUCCESS) {
- continue;
- }
-
- if (strchr((char *)vbuf, ',') != NULL) {
- if (strcmp(value, (char *)vbuf) == 0) {
- return (nodehdl);
- }
- } else {
- if (strtoul((char *)vbuf, NULL, 16) ==
- strtoul(value, NULL, 16)) {
- return (nodehdl);
- }
- }
- }
- return (0);
-}
-
-/* Hash Table Management */
-static void
-free_data(frutree_datatype_t type, hashdata_t *datap)
-{
- frutree_frunode_t *frup = NULL;
- frutree_locnode_t *locp = NULL;
- frutree_portnode_t *portp = NULL;
-
- if (datap == NULL) {
- return;
- }
-
- switch (type) {
- case FRU_TYPE:
- frup = (frutree_frunode_t *)datap->data;
- free(frup->name);
- (void) pthread_mutex_destroy(&frup->mutex);
- (void) pthread_cond_destroy(&frup->cond_cv);
- (void) pthread_cond_destroy(&frup->busy_cond_cv);
- free(frup);
- break;
- case LOC_TYPE:
- locp = (frutree_locnode_t *)datap->data;
- free(locp->name);
- (void) pthread_mutex_destroy(&locp->mutex);
- (void) pthread_cond_destroy(&locp->cond_cv);
- free(locp);
- break;
- case PORT_TYPE:
- portp = (frutree_portnode_t *)datap->data;
- free(portp->name);
- free(portp);
- break;
- }
- free(datap);
-}
-
-/*
- * Initialize the hash table
- */
-static picl_errno_t
-hash_init(void)
-{
- int i;
-
- FRUTREE_DEBUG0(HASHTABLE, "hash_init begin");
- node_hash_table.tbl = (frutree_hashelm_t **)malloc(
- sizeof (frutree_hashelm_t *) * HASH_TABLE_SIZE);
-
- if (node_hash_table.tbl == NULL) {
- return (PICL_NOSPACE);
- }
-
- /* initialize each entry in hashtable */
- node_hash_table.hash_size = HASH_TABLE_SIZE;
- for (i = 0; i < node_hash_table.hash_size; ++i) {
- node_hash_table.tbl[i] = NULL;
- }
- return (PICL_SUCCESS);
-}
-
-/*
- * Destroy the hash table
- */
-static void
-hash_destroy(void)
-{
- int i;
- frutree_hashelm_t *el;
- hashdata_t *datap = NULL;
-
- (void) rw_wrlock(&hash_lock);
- if (node_hash_table.tbl == NULL) {
- (void) rw_unlock(&hash_lock);
- return;
- }
-
- /* loop thru each linked list in the table and free */
- for (i = 0; i < node_hash_table.hash_size; ++i) {
- while (node_hash_table.tbl[i] != NULL) {
- el = node_hash_table.tbl[i];
- node_hash_table.tbl[i] = el->nextp;
- datap = (hashdata_t *)el->nodep;
- free_data(datap->type, datap);
- el->nodep = NULL;
- free(el);
- el = NULL;
- }
- }
- free(node_hash_table.tbl);
- (void) rw_unlock(&hash_lock);
-}
-
-/*
- * Add an entry to the hash table
- */
-static picl_errno_t
-hash_add_entry(picl_nodehdl_t hdl, void *nodep)
-{
- int indx;
- frutree_hashelm_t *el;
-
- FRUTREE_DEBUG0(HASHTABLE, "hash_add_entry : begin");
- (void) rw_wrlock(&hash_lock);
-
- if (node_hash_table.tbl == NULL) {
- (void) rw_unlock(&hash_lock);
- return (PICL_NOTINITIALIZED);
- }
-
- el = (frutree_hashelm_t *)malloc(sizeof (frutree_hashelm_t));
- if (el == NULL) {
- (void) rw_unlock(&hash_lock);
- return (PICL_NOSPACE);
- }
-
- el->hdl = hdl;
- el->nodep = nodep;
- el->nextp = NULL;
-
- if (frutree_debug & HASHTABLE) {
- picl_nodehdl_t nodeid;
- nodeid = hdl;
- cvt_ptree2picl(&nodeid);
- FRUTREE_DEBUG1(HASHTABLE, "added node: %llx", nodeid);
- }
-
- indx = HASH_INDEX(node_hash_table.hash_size, hdl);
- if (node_hash_table.tbl[indx] == NULL) {
- /* first element for this index */
- node_hash_table.tbl[indx] = el;
- (void) rw_unlock(&hash_lock);
- return (PICL_SUCCESS);
- }
-
- el->nextp = node_hash_table.tbl[indx];
- node_hash_table.tbl[indx] = el;
- (void) rw_unlock(&hash_lock);
- return (PICL_SUCCESS);
-}
-
-/*
- * Remove a hash entry from the table
- */
-static picl_errno_t
-hash_remove_entry(picl_nodehdl_t hdl)
-{
- int i;
- hashdata_t *datap = NULL;
- frutree_hashelm_t *prev, *cur;
-
- (void) rw_wrlock(&hash_lock);
-
- if (node_hash_table.tbl == NULL) {
- (void) rw_unlock(&hash_lock);
- return (PICL_NOTINITIALIZED);
- }
-
- i = HASH_INDEX(node_hash_table.hash_size, hdl);
-
- /* check that the hash chain is not empty */
- if (node_hash_table.tbl[i] == NULL) {
- (void) rw_wrlock(&hash_lock);
- return (PICL_NODENOTFOUND);
- }
-
- /* search hash chain for entry to be removed */
- prev = NULL;
- cur = node_hash_table.tbl[i];
- while (cur) {
- if (cur->hdl == hdl) {
- if (prev == NULL) { /* 1st elem in hash chain */
- node_hash_table.tbl[i] = cur->nextp;
- } else {
- prev->nextp = cur->nextp;
- }
- datap = (hashdata_t *)cur->nodep;
- free_data(datap->type, datap);
- cur->nodep = NULL;
- free(cur);
- cur = NULL;
-
- if (frutree_debug & HASHTABLE) {
- picl_nodehdl_t nodeid;
- nodeid = hdl;
- cvt_ptree2picl(&nodeid);
- FRUTREE_DEBUG1(HASHTABLE, "removed node: %llx",
- nodeid);
- }
-
- (void) rw_unlock(&hash_lock);
- return (PICL_SUCCESS);
- }
- prev = cur;
- cur = cur->nextp;
- }
-
- /* entry was not found */
- (void) rw_unlock(&hash_lock);
- return (PICL_NODENOTFOUND);
-}
-
-/*
- * Lookup a handle in the table
- */
-static picl_errno_t
-hash_lookup_entry(picl_nodehdl_t hdl, void **nodepp)
-{
- int i;
- frutree_hashelm_t *el;
-
- FRUTREE_DEBUG1(HASHTABLE, "hash_lookup begin: %llx", hdl);
- (void) rw_rdlock(&hash_lock);
-
- if (node_hash_table.tbl == NULL) {
- (void) rw_unlock(&hash_lock);
- return (PICL_NOTINITIALIZED);
- }
- if (nodepp == NULL) {
- (void) rw_unlock(&hash_lock);
- return (PICL_INVALIDHANDLE);
- }
-
- i = HASH_INDEX(node_hash_table.hash_size, hdl);
-
- if (node_hash_table.tbl[i] == NULL) {
- (void) rw_unlock(&hash_lock);
- return (PICL_NODENOTFOUND);
- }
-
- el = node_hash_table.tbl[i];
- while (el) {
- if (el->hdl == hdl) {
- *nodepp = el->nodep;
- (void) rw_unlock(&hash_lock);
- return (PICL_SUCCESS);
- }
- el = el->nextp;
- }
- (void) rw_unlock(&hash_lock);
- return (PICL_NODENOTFOUND);
-}
-
-/* create and initialize data structure for a loc node */
-static picl_errno_t
-make_loc_data(char *full_name, hashdata_t **hashptr)
-{
- char *name_copy;
- frutree_locnode_t *locp;
- hashdata_t *datap = NULL;
-
- datap = (hashdata_t *)malloc(sizeof (hashdata_t));
- if (datap == NULL) {
- return (PICL_NOSPACE);
- }
- datap->type = LOC_TYPE;
-
- /* allocate the data */
- locp = (frutree_locnode_t *)malloc(sizeof (frutree_locnode_t));
- if (locp == NULL) {
- free(datap);
- return (PICL_NOSPACE);
- }
-
- /* make a copy of the name */
- name_copy = strdup(full_name);
- if (name_copy == NULL) {
- free(locp);
- free(datap);
- return (PICL_NOSPACE);
- }
-
- /* initialize the data */
- locp->name = name_copy;
- locp->locnodeh = 0;
- locp->state = LOC_STATE_UNKNOWN;
- locp->prev_state = LOC_STATE_UNKNOWN;
- locp->cpu_node = B_FALSE;
- locp->autoconfig_enabled = B_FALSE;
- locp->state_mgr = UNKNOWN;
- locp->dr_in_progress = B_FALSE;
- (void) pthread_mutex_init(&locp->mutex, NULL);
- (void) pthread_cond_init(&locp->cond_cv, NULL);
-
- datap->data = locp;
- *hashptr = datap;
- return (PICL_SUCCESS);
-}
-
-/* create and initialize data structure for a fru node */
-static picl_errno_t
-make_fru_data(char *full_name, hashdata_t **hashptr)
-{
- char *name_copy;
- frutree_frunode_t *frup;
- hashdata_t *datap = NULL;
-
- datap = (hashdata_t *)malloc(sizeof (hashdata_t));
- if (datap == NULL) {
- return (PICL_NOSPACE);
- }
- datap->type = FRU_TYPE;
-
- /* allocate the data */
- frup = (frutree_frunode_t *)malloc(sizeof (frutree_frunode_t));
- if (frup == NULL) {
- free(datap);
- return (PICL_NOSPACE);
- }
-
- /* make a copy of the name */
- name_copy = strdup(full_name);
- if (name_copy == NULL) {
- free(frup);
- free(datap);
- return (PICL_NOSPACE);
- }
-
- /* initialize the data */
- frup->name = name_copy;
- frup->frunodeh = 0;
- frup->state = FRU_STATE_UNCONFIGURED;
- frup->prev_state = FRU_STATE_UNKNOWN;
- frup->cond = FRU_COND_UNKNOWN;
- frup->prev_cond = FRU_COND_UNKNOWN;
- frup->cpu_node = B_FALSE;
- frup->autoconfig_enabled = B_FALSE;
- frup->dr_in_progress = B_FALSE;
- frup->busy = B_FALSE;
- frup->state_mgr = UNKNOWN;
- frup->fru_path[0] = '\0';
- (void) pthread_mutex_init(&frup->mutex, NULL);
- (void) pthread_cond_init(&frup->cond_cv, NULL);
- (void) pthread_cond_init(&frup->busy_cond_cv, NULL);
-
- datap->data = frup;
- *hashptr = datap;
- return (PICL_SUCCESS);
-}
-
-/* create and initialize data structure for a port node */
-static picl_errno_t
-make_port_data(char *full_name, hashdata_t **hashptr)
-{
- char *name_copy;
- frutree_portnode_t *portp;
- hashdata_t *datap = NULL;
-
- datap = (hashdata_t *)malloc(sizeof (hashdata_t));
- if (datap == NULL) {
- return (PICL_NOSPACE);
- }
- datap->type = PORT_TYPE;
-
- /* allocate the data */
- portp = (frutree_portnode_t *)malloc(sizeof (frutree_portnode_t));
- if (portp == NULL) {
- free(datap);
- return (PICL_NOSPACE);
- }
- /* make a copy of the name */
- name_copy = strdup(full_name);
- if (name_copy == NULL) {
- free(portp);
- free(datap);
- return (PICL_NOSPACE);
- }
-
- /* initialize the data */
- portp->name = name_copy;
- portp->portnodeh = 0;
- portp->state = PORT_STATE_UNKNOWN;
- portp->cond = PORT_COND_UNKNOWN;
- datap->data = portp;
- *hashptr = datap;
- return (PICL_SUCCESS);
-}
-
-/*
- * utility routine to create table entries
- */
-static picl_errno_t
-create_table_entry(picl_prophdl_t tblhdl, picl_nodehdl_t refhdl, char *class)
-{
- picl_errno_t rc;
- ptree_propinfo_t propinfo;
- picl_prophdl_t prophdl[2];
- char buf[PICL_CLASSNAMELEN_MAX];
-
- /* first column is class */
- if ((rc = ptree_init_propinfo(&propinfo, PTREE_PROPINFO_VERSION,
- PICL_PTYPE_CHARSTRING, PICL_READ, PICL_CLASSNAMELEN_MAX,
- PICL_PROP_CLASS, NULLREAD,
- NULLWRITE)) != PICL_SUCCESS) {
- return (rc);
- }
-
- if ((rc = ptree_create_prop(&propinfo, class,
- &prophdl[0])) != PICL_SUCCESS) {
- return (rc);
- }
-
- /* second column is reference property */
- (void) snprintf(buf, sizeof (buf), "_%s_", class);
- if ((rc = ptree_init_propinfo(&propinfo, PTREE_PROPINFO_VERSION,
- PICL_PTYPE_REFERENCE, PICL_READ,
- sizeof (picl_nodehdl_t), buf, NULLREAD,
- NULLWRITE)) != PICL_SUCCESS) {
- return (rc);
- }
-
- if ((rc = ptree_create_prop(&propinfo, &refhdl,
- &prophdl[1])) != PICL_SUCCESS) {
- return (rc);
- }
-
- /* add row to table */
- if ((rc = ptree_add_row_to_table(tblhdl, 2, prophdl)) != PICL_SUCCESS) {
- return (rc);
- }
- return (PICL_SUCCESS);
-}
-
-/*
- * Utility routine to create picl property
- */
-static picl_errno_t
-create_property(int ptype, int pmode, size_t psize, char *pname,
- int (*readfn)(ptree_rarg_t *, void *),
- int (*writefn)(ptree_warg_t *, const void *),
- picl_nodehdl_t nodeh, picl_prophdl_t *prophp, void *vbuf)
-{
- picl_errno_t rc;
- ptree_propinfo_t propinfo;
- picl_prophdl_t proph;
-
- if (pname == NULL || vbuf == NULL) {
- return (PICL_FAILURE);
- }
-
- if (ptype == PICL_PTYPE_TABLE) {
- if ((rc = ptree_create_table((picl_prophdl_t *)vbuf))
- != PICL_SUCCESS) {
- return (rc);
- }
- }
-
- if ((rc = ptree_get_prop_by_name(nodeh, pname, &proph)) ==
- PICL_SUCCESS) { /* property already exists */
- return (rc);
- }
-
- rc = ptree_init_propinfo(&propinfo, PTREE_PROPINFO_VERSION,
- ptype, pmode, psize, pname, readfn, writefn);
- if (rc != PICL_SUCCESS) {
- return (rc);
- }
-
- rc = ptree_create_and_add_prop(nodeh, &propinfo, vbuf, prophp);
- if (rc != PICL_SUCCESS) {
- return (rc);
- }
- return (PICL_SUCCESS);
-}
-
-/*
- * create frutree node, chassis node
- */
-static picl_errno_t
-initialize_frutree()
-{
- int rc = PICL_SUCCESS;
- hashdata_t *datap = NULL;
- frutree_frunode_t *frup = NULL;
- uint64_t ap_status_time;
-
- FRUTREE_DEBUG0(FRUTREE_INIT, "initialize_frutree begin");
- /* Get the root of the PICL tree */
- if ((rc = ptree_get_root(&rooth)) != PICL_SUCCESS) {
- return (rc);
- }
- FRUTREE_DEBUG1(FRUTREE_INIT, "roothdl = %llx", rooth);
-
- /* create /frutree node */
- if ((rc = ptree_create_and_add_node(rooth, PICL_NODE_FRUTREE,
- PICL_CLASS_PICL, &frutreeh)) != PICL_SUCCESS) {
- return (rc);
- }
- FRUTREE_DEBUG1(FRUTREE_INIT, "frutreeh = %llx", frutreeh);
-
- /* create chassis node */
- if ((rc = ptree_create_node(PICL_NODE_CHASSIS, PICL_CLASS_FRU,
- &chassish)) != PICL_SUCCESS) {
- return (rc);
- }
- FRUTREE_DEBUG1(FRUTREE_INIT, "chassish = %llx", chassish);
-
- /* Allocate fru data */
- if ((rc = make_fru_data(PICL_NODE_CHASSIS, &datap)) !=
- PICL_SUCCESS) {
- (void) ptree_destroy_node(chassish);
- return (rc);
- }
- /* initialise chassis handle and parent handle */
- frup = FRUDATA_PTR(datap);
- frup->frunodeh = chassish;
-
- /* Add the chassis node to the tree */
- if ((rc = ptree_add_node(frutreeh, chassish)) != PICL_SUCCESS) {
- free_data(datap->type, datap);
- (void) ptree_destroy_node(chassish);
- return (rc);
- }
-
- /* create chassis state property */
- if ((rc = create_property(PICL_PTYPE_CHARSTRING,
- PICL_READ, PICL_PROPNAMELEN_MAX, PICL_PROP_STATE,
- NULLREAD, NULLWRITE, chassish, (picl_prophdl_t *)NULL,
- PICLEVENTARGVAL_UNCONFIGURED)) != PICL_SUCCESS) {
- free_data(datap->type, datap);
- (void) ptree_delete_node(chassish);
- (void) ptree_destroy_node(chassish);
- return (rc);
- }
- ap_status_time = (uint64_t)(time(NULL));
- if ((rc = create_property(PICL_PTYPE_TIMESTAMP, PICL_READ,
- sizeof (ap_status_time), PICL_PROP_STATUS_TIME,
- NULLREAD, NULLWRITE, chassish,
- NULL, &ap_status_time)) != PICL_SUCCESS) {
- free_data(datap->type, datap);
- (void) ptree_delete_node(chassish);
- (void) ptree_destroy_node(chassish);
- return (rc);
- }
-
- /* save chassis info in hashtable */
- if ((rc = hash_add_entry(chassish,
- (void *)datap)) != PICL_SUCCESS) {
- free_data(datap->type, datap);
- (void) ptree_delete_node(chassish);
- (void) ptree_destroy_node(chassish);
- return (rc);
- }
- return (PICL_SUCCESS);
-}
-
-/*
- * Read the temporary property created by platform specific
- * plugin to get the config file name.
- */
-static picl_errno_t
-get_configuration_file()
-{
- picl_errno_t rc;
- picl_prophdl_t proph;
- char file_name[PICL_PROPNAMELEN_MAX];
-
- if ((rc = ptree_get_prop_by_name(chassish,
- PICL_PROP_CONF_FILE, &proph)) != PICL_SUCCESS) {
- return (rc);
- }
-
- if ((rc = ptree_get_propval(proph, file_name,
- sizeof (file_name))) != PICL_SUCCESS) {
- return (rc);
- }
-
- (void) snprintf(conf_file, sizeof (conf_file),
- PICLD_PLAT_PLUGIN_DIRF"%s", sys_name, file_name);
- /* delete the tmp prop created by platform specific plugin */
- (void) ptree_delete_prop(proph);
- (void) ptree_destroy_prop(proph);
- FRUTREE_DEBUG1(EVENTS, "Using %s conf file", conf_file);
- return (PICL_SUCCESS);
-}
-
-/*
- * Read the cfgadm data and get the latest information
- */
-static picl_errno_t
-get_cfgadm_state(cfga_list_data_t *data, char *ap_id)
-{
- int nlist;
- cfga_err_t ap_list_err;
- cfga_list_data_t *list = NULL;
- char * const *p = &ap_id;
-
- if (data == NULL || ap_id == NULL) {
- return (PICL_INVALIDARG);
- }
-
- ap_list_err = config_list_ext(1, p, &list, &nlist, NULL,
- NULL, NULL, 0);
- if (ap_list_err != CFGA_OK) {
- free(list);
- return (cfg2picl_errmap[ap_list_err][1]);
- }
-
- (void) memcpy(data, list, sizeof (cfga_list_data_t));
- free(list);
- return (PICL_SUCCESS);
-}
-
-/*
- * syncup with cfgadm data and read latest location state information
- */
-static picl_errno_t
-update_loc_state(frutree_locnode_t *locp, boolean_t *updated)
-{
- int i = 0;
- cfga_list_data_t *list = NULL;
- picl_errno_t rc, rc1;
- char valbuf[PICL_PROPNAMELEN_MAX];
- char slot_type[PICL_PROPNAMELEN_MAX];
- uint64_t ap_status_time;
-
- *updated = B_FALSE;
- if (locp->state_mgr == PLUGIN_PVT) {
- if ((rc = ptree_get_propval_by_name(locp->locnodeh,
- PICL_PROP_STATE, (void *)valbuf,
- PICL_PROPNAMELEN_MAX)) != PICL_SUCCESS) {
- return (rc);
- }
-
- /* if there is a change in state, update the internal value */
- if (strcmp(loc_state[locp->state], valbuf) != 0) {
- ap_status_time = (uint64_t)(time(NULL));
- if ((rc = ptree_update_propval_by_name(locp->locnodeh,
- PICL_PROP_STATUS_TIME, (void *)&ap_status_time,
- sizeof (ap_status_time))) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_UPDATE_PROP_ERR,
- PICL_PROP_STATUS_TIME, locp->name, rc);
- }
- *updated = B_TRUE;
- locp->prev_state = locp->state;
- for (i = 0; (loc_state[i] != NULL); i++) {
- if (strcmp(loc_state[i], valbuf) == 0) {
- locp->state = i;
- return (PICL_SUCCESS);
- }
- }
- }
- return (PICL_SUCCESS);
- } else if (locp->state_mgr == STATIC_LOC) {
- return (PICL_SUCCESS);
- }
-
- /* get the info from the libcfgadm interface */
- list = (cfga_list_data_t *)malloc(sizeof (cfga_list_data_t));
- if (list == NULL) {
- return (PICL_NOSPACE);
- }
-
- if ((rc = get_cfgadm_state(list, locp->name)) != PICL_SUCCESS) {
- if ((rc1 = ptree_get_propval_by_name(locp->locnodeh,
- PICL_PROP_SLOT_TYPE, slot_type,
- sizeof (slot_type))) != PICL_SUCCESS) {
- free(list);
- return (rc1);
- }
- if (strcmp(slot_type, SANIBEL_SCSI_SLOT) != 0 &&
- strcmp(slot_type, SANIBEL_IDE_SLOT) != 0) {
- free(list);
- return (rc);
- }
- /* this is a scsi location */
- if (rc != PICL_NODENOTFOUND) {
- free(list);
- return (rc);
- }
-
- /*
- * for scsi locations, if node is not found,
- * consider location state as empty
- */
- (void) pthread_mutex_lock(&locp->mutex);
- if (locp->state != LOC_STATE_EMPTY) {
- *updated = B_TRUE;
- locp->prev_state = locp->state;
- locp->state = LOC_STATE_EMPTY;
- ap_status_time = (uint64_t)(time(NULL));
- if ((rc = ptree_update_propval_by_name(locp->locnodeh,
- PICL_PROP_STATUS_TIME, (void *)&ap_status_time,
- sizeof (ap_status_time))) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_UPDATE_PROP_ERR,
- PICL_PROP_STATUS_TIME, locp->name, rc);
- }
- }
- (void) pthread_mutex_unlock(&locp->mutex);
- free(list);
- return (PICL_SUCCESS);
- }
-
- (void) pthread_mutex_lock(&locp->mutex);
- switch (list->ap_r_state) {
- case CFGA_STAT_CONNECTED:
- if (locp->state != LOC_STATE_CONNECTED) {
- *updated = B_TRUE;
- locp->prev_state = locp->state;
- locp->state = LOC_STATE_CONNECTED;
- }
- break;
- case CFGA_STAT_DISCONNECTED:
- if (locp->state != LOC_STATE_DISCONNECTED) {
- *updated = B_TRUE;
- locp->prev_state = locp->state;
- locp->state = LOC_STATE_DISCONNECTED;
- }
- break;
- case CFGA_STAT_EMPTY:
- if (locp->state != LOC_STATE_EMPTY) {
- *updated = B_TRUE;
- locp->prev_state = locp->state;
- locp->state = LOC_STATE_EMPTY;
- }
- break;
- default:
- if (locp->state != LOC_STATE_UNKNOWN) {
- *updated = B_TRUE;
- locp->prev_state = locp->state;
- locp->state = LOC_STATE_UNKNOWN;
- }
- }
-
- if (*updated == B_TRUE) {
- ap_status_time = (uint64_t)(time(NULL));
- if ((rc = ptree_update_propval_by_name(locp->locnodeh,
- PICL_PROP_STATUS_TIME, (void *)&ap_status_time,
- sizeof (ap_status_time))) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_UPDATE_PROP_ERR,
- PICL_PROP_STATUS_TIME, locp->name, rc);
- }
- }
-
- /* update the autoconfig flag */
- switch (is_autoconfig_enabled(locp->name)) {
- case 1:
- locp->autoconfig_enabled = B_TRUE;
- break;
- case 0:
- default:
- locp->autoconfig_enabled = B_FALSE;
- break;
- }
- (void) pthread_mutex_unlock(&locp->mutex);
-
- free(list);
- return (PICL_SUCCESS);
-}
-
-/*
- * volatile callback function to return the state value for a location
- */
-static int
-get_loc_state(ptree_rarg_t *rarg, void *buf)
-{
- picl_errno_t rc;
- frutree_dr_arg_t dr_arg;
- hashdata_t *hashptr = NULL;
- frutree_locnode_t *locp = NULL;
- boolean_t state_change = B_FALSE;
-
- if (buf == NULL) {
- return (PICL_INVALIDARG);
- }
-
- if ((rc = hash_lookup_entry(rarg->nodeh, (void **)&hashptr)) !=
- PICL_SUCCESS) {
- return (rc);
- }
-
- locp = LOCDATA_PTR(hashptr);
- if (locp == NULL) {
- return (PICL_FAILURE);
- }
-
- (void) pthread_mutex_lock(&locp->mutex);
- if (locp->dr_in_progress == B_TRUE) {
- /* return the cached value */
- (void) strncpy((char *)buf, loc_state[locp->state],
- PICL_PROPNAMELEN_MAX);
- (void) pthread_mutex_unlock(&locp->mutex);
- return (PICL_SUCCESS);
- }
- (void) pthread_mutex_unlock(&locp->mutex);
-
- if ((rc = update_loc_state(locp, &state_change)) != PICL_SUCCESS) {
- FRUTREE_DEBUG2(EVENTS, GET_LOC_STATE_ERR, locp->name, rc);
- /* return the cached value */
- (void) strncpy((char *)buf, loc_state[locp->state],
- PICL_PROPNAMELEN_MAX);
- return (rc);
- }
-
- /* if there is a state change, handle the event */
- if (state_change) {
- (void) pthread_mutex_lock(&locp->mutex);
- if (locp->state == LOC_STATE_EMPTY) { /* card removed */
- dr_arg.action = HANDLE_REMOVE;
- } else if (locp->prev_state == LOC_STATE_EMPTY) {
- dr_arg.action = HANDLE_INSERT; /* card inserted */
- } else {
- /* loc state changed */
- dr_arg.action = HANDLE_LOCSTATE_CHANGE;
- }
- (void) pthread_mutex_unlock(&locp->mutex);
- dr_arg.data = locp;
- (void) pthread_mutex_lock(&ev_mutex);
- if ((rc = add_to_queue(dr_arg)) != PICL_SUCCESS) {
- (void) pthread_mutex_unlock(&ev_mutex);
- FRUTREE_DEBUG3(EVENTS, EVENT_NOT_HANDLED,
- "dr_ap_state_change", locp->name, rc);
- } else {
- (void) pthread_cond_signal(&ev_cond);
- (void) pthread_mutex_unlock(&ev_mutex);
- }
- }
-
- (void) strncpy((char *)buf, loc_state[locp->state],
- PICL_PROPNAMELEN_MAX);
- return (PICL_SUCCESS);
-}
-
-/*
- * syncup with cfgadm data and read latest fru state information
- */
-static picl_errno_t
-update_fru_state(frutree_frunode_t *frup, boolean_t *updated)
-{
- int i;
- picl_errno_t rc;
- picl_nodehdl_t loch;
- uint64_t ap_status_time;
- hashdata_t *hashptr = NULL;
- cfga_list_data_t *list = NULL;
- frutree_locnode_t *locp = NULL;
- char valbuf[PICL_PROPNAMELEN_MAX];
-
- *updated = B_FALSE;
- if (frup->state_mgr == PLUGIN_PVT) {
- if ((rc = ptree_get_propval_by_name(frup->frunodeh,
- PICL_PROP_STATE, (void *)valbuf,
- PICL_PROPNAMELEN_MAX)) != PICL_SUCCESS) {
- return (rc);
- }
-
- /* if there is a change in state, update the internal value */
- if (strcmp(fru_state[frup->state], valbuf) != 0) {
- *updated = B_TRUE;
- frup->prev_state = frup->state;
- ap_status_time = (uint64_t)(time(NULL));
- if ((rc = ptree_update_propval_by_name(frup->frunodeh,
- PICL_PROP_STATUS_TIME, (void *)&ap_status_time,
- sizeof (ap_status_time))) != PICL_SUCCESS) {
- if (rc == PICL_PROPNOTFOUND) {
- (void) create_property(
- PICL_PTYPE_TIMESTAMP, PICL_READ,
- sizeof (ap_status_time),
- PICL_PROP_STATUS_TIME,
- NULLREAD, NULLWRITE,
- frup->frunodeh,
- NULL, &ap_status_time);
- } else {
- FRUTREE_DEBUG3(EVENTS,
- PTREE_UPDATE_PROP_ERR,
- PICL_PROP_STATUS_TIME,
- frup->name, rc);
- }
- }
- for (i = 0; (fru_state[i] != NULL); i++) {
- if (strcmp(fru_state[i], valbuf) == 0) {
- frup->state = i;
- return (PICL_SUCCESS);
- }
- }
- }
- return (PICL_SUCCESS);
- } else if (frup->state_mgr == STATIC_LOC) {
- frup->state = FRU_STATE_CONFIGURED;
- return (PICL_SUCCESS);
- }
-
- if ((rc = ptree_get_propval_by_name(frup->frunodeh, PICL_PROP_PARENT,
- &loch, sizeof (loch))) != PICL_SUCCESS) {
- return (rc);
- }
-
- if ((rc = hash_lookup_entry(loch, (void **)&hashptr)) !=
- PICL_SUCCESS) {
- return (rc);
- }
- locp = LOCDATA_PTR(hashptr);
- if (locp == NULL) {
- return (PICL_FAILURE);
- }
-
- list = (cfga_list_data_t *)malloc(sizeof (cfga_list_data_t));
- if (list == NULL) {
- return (PICL_NOSPACE);
- }
-
- if ((rc = get_cfgadm_state(list, locp->name)) != PICL_SUCCESS) {
- free(list);
- return (rc);
- }
-
- (void) pthread_mutex_lock(&frup->mutex);
- switch (list->ap_o_state) {
- case CFGA_STAT_CONFIGURED:
- if (frup->state != FRU_STATE_CONFIGURED) {
- *updated = B_TRUE;
- frup->prev_state = frup->state;
- frup->state = FRU_STATE_CONFIGURED;
- }
- break;
- case CFGA_STAT_UNCONFIGURED:
- if (frup->state != FRU_STATE_UNCONFIGURED) {
- *updated = B_TRUE;
- frup->prev_state = frup->state;
- frup->state = FRU_STATE_UNCONFIGURED;
- }
- break;
- default:
- if (frup->state != FRU_STATE_UNKNOWN) {
- *updated = B_TRUE;
- frup->prev_state = frup->state;
- frup->state = FRU_STATE_UNKNOWN;
- }
- break;
- }
-
- /* update the fru_type property */
- if (list->ap_type) {
- if ((rc = ptree_update_propval_by_name(frup->frunodeh,
- PICL_PROP_FRU_TYPE, list->ap_type,
- sizeof (list->ap_type))) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_UPDATE_PROP_ERR,
- PICL_PROP_FRU_TYPE, frup->name, rc);
- }
- }
-
- if (*updated == B_TRUE) {
- ap_status_time = (uint64_t)(time(NULL));
- if ((rc = ptree_update_propval_by_name(frup->frunodeh,
- PICL_PROP_STATUS_TIME, (void *)&ap_status_time,
- sizeof (ap_status_time))) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_UPDATE_PROP_ERR,
- PICL_PROP_STATUS_TIME, frup->name, rc);
- }
- }
- (void) pthread_mutex_unlock(&frup->mutex);
-
- free(list);
- return (PICL_SUCCESS);
-}
-
-/*
- * syncup with cfgadm data and read latest fru condition information
- */
-static picl_errno_t
-update_fru_condition(frutree_frunode_t *frup, boolean_t *updated)
-{
- int i = 0;
- picl_errno_t rc;
- picl_nodehdl_t loch;
- uint64_t ap_cond_time;
- hashdata_t *hashptr = NULL;
- cfga_list_data_t *list = NULL;
- frutree_locnode_t *locp = NULL;
- char valbuf[PICL_PROPNAMELEN_MAX];
-
- *updated = B_FALSE;
- if (frup->state_mgr == PLUGIN_PVT) {
- if ((rc = ptree_get_propval_by_name(frup->frunodeh,
- PICL_PROP_CONDITION, (void *)valbuf,
- PICL_PROPNAMELEN_MAX)) != PICL_SUCCESS) {
- return (rc);
- }
-
- /*
- * if there is a change in condition, update the
- * internal value
- */
- if (strcmp(fru_cond[frup->cond], valbuf) != 0) {
- *updated = B_TRUE;
- ap_cond_time = (uint64_t)(time(NULL));
- if ((rc = ptree_update_propval_by_name(frup->frunodeh,
- PICL_PROP_CONDITION_TIME, (void *)&ap_cond_time,
- sizeof (ap_cond_time))) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_UPDATE_PROP_ERR,
- PICL_PROP_CONDITION_TIME, frup->name,
- rc);
- }
- frup->prev_cond = frup->cond;
-
- for (i = 0; (fru_cond[i] != NULL); i++) {
- if (strcmp(fru_cond[i], valbuf) == 0) {
- frup->cond = i;
- return (PICL_SUCCESS);
- }
- }
- }
- return (PICL_SUCCESS);
- } else if (frup->state_mgr == STATIC_LOC) {
- frup->cond = FRU_COND_OK;
- return (PICL_SUCCESS);
- }
-
- if ((rc = ptree_get_propval_by_name(frup->frunodeh, PICL_PROP_PARENT,
- &loch, sizeof (loch))) != PICL_SUCCESS) {
- return (rc);
- }
-
- if ((rc = hash_lookup_entry(loch, (void **)&hashptr)) !=
- PICL_SUCCESS) {
- return (rc);
- }
-
- locp = LOCDATA_PTR(hashptr);
- if (locp == NULL) {
- return (PICL_FAILURE);
- }
- list = (cfga_list_data_t *)malloc(sizeof (cfga_list_data_t));
- if (list == NULL) {
- return (PICL_NOSPACE);
- }
-
- if ((rc = get_cfgadm_state(list, locp->name)) != PICL_SUCCESS) {
- free(list);
- return (rc);
- }
-
- switch (list->ap_cond) {
- case CFGA_COND_OK:
- if (frup->cond != FRU_COND_OK) {
- *updated = B_TRUE;
- frup->prev_cond = frup->cond;
- frup->cond = FRU_COND_OK;
- }
- break;
- case CFGA_COND_FAILING:
- if (frup->cond != FRU_COND_FAILING) {
- *updated = B_TRUE;
- frup->prev_cond = frup->cond;
- frup->cond = FRU_COND_FAILING;
- }
- break;
- case CFGA_COND_FAILED:
- case CFGA_COND_UNUSABLE:
- if (frup->cond != FRU_COND_FAILED) {
- *updated = B_TRUE;
- frup->prev_cond = frup->cond;
- frup->cond = FRU_COND_FAILED;
- }
- break;
- default:
- if (frup->cond != FRU_COND_UNKNOWN) {
- *updated = B_TRUE;
- frup->prev_cond = frup->cond;
- frup->cond = FRU_COND_UNKNOWN;
- }
- }
-
- if (*updated == B_TRUE) {
- ap_cond_time = (uint64_t)(time(NULL));
- if ((rc = ptree_update_propval_by_name(frup->frunodeh,
- PICL_PROP_CONDITION_TIME, (void *)&ap_cond_time,
- sizeof (ap_cond_time))) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_UPDATE_PROP_ERR,
- PICL_PROP_CONDITION_TIME, frup->name, rc);
- }
- }
- free(list);
- return (PICL_SUCCESS);
-}
-
-/*
- * Volatile callback function to read fru state
- */
-static int
-get_fru_state(ptree_rarg_t *rarg, void *buf)
-{
- picl_errno_t rc;
- hashdata_t *hashptr = NULL;
- frutree_frunode_t *frup = NULL;
- boolean_t state_change = B_FALSE;
- frutree_dr_arg_t dr_arg;
-
- if (buf == NULL) {
- return (PICL_INVALIDARG);
- }
-
- if ((rc = hash_lookup_entry(rarg->nodeh, (void **)&hashptr)) !=
- PICL_SUCCESS) {
- return (rc);
- }
-
- frup = FRUDATA_PTR(hashptr);
- if (frup == NULL) {
- return (PICL_FAILURE);
- }
-
- /* return the cached value, if dr is in progress */
- (void) pthread_mutex_lock(&frup->mutex);
- if (frup->dr_in_progress) {
- (void) pthread_mutex_unlock(&frup->mutex);
- (void) strncpy((char *)buf, fru_state[frup->state],
- PICL_PROPNAMELEN_MAX);
- return (PICL_SUCCESS);
- }
- (void) pthread_mutex_unlock(&frup->mutex);
-
- if ((rc = update_fru_state(frup, &state_change)) != PICL_SUCCESS) {
- FRUTREE_DEBUG2(EVENTS, GET_FRU_STATE_ERR, frup->name, rc);
- /* return the cached value */
- (void) strncpy((char *)buf, fru_state[frup->state],
- PICL_PROPNAMELEN_MAX);
- return (rc);
- }
-
- /* if there is a state change, handle the event */
- if (state_change) {
- (void) pthread_mutex_lock(&frup->mutex);
- /* figure out if this is config/unconfig operation */
- if (frup->state == FRU_STATE_CONFIGURED) {
- dr_arg.action = HANDLE_CONFIGURE;
- dr_arg.data = frup;
- } else if (frup->state == FRU_STATE_UNCONFIGURED) {
- dr_arg.action = HANDLE_UNCONFIGURE;
- dr_arg.data = frup;
- }
- (void) pthread_mutex_unlock(&frup->mutex);
-
- (void) pthread_mutex_lock(&ev_mutex);
- if ((rc = add_to_queue(dr_arg)) != PICL_SUCCESS) {
- (void) pthread_mutex_unlock(&ev_mutex);
- FRUTREE_DEBUG3(EVENTS, EVENT_NOT_HANDLED,
- "dr_ap_state_chage", frup->name, rc);
- } else {
- (void) pthread_cond_signal(&ev_cond);
- (void) pthread_mutex_unlock(&ev_mutex);
- }
- }
-
- (void) strncpy((char *)buf, fru_state[frup->state],
- PICL_PROPNAMELEN_MAX);
-
- return (PICL_SUCCESS);
-}
-
-/*
- * Volatile callback function to read fru condition
- */
-static int
-get_fru_condition(ptree_rarg_t *rarg, void *buf)
-{
- picl_errno_t rc;
- frutree_dr_arg_t dr_arg;
- hashdata_t *hashptr = NULL;
- frutree_frunode_t *frup = NULL;
- boolean_t cond_changed = B_FALSE;
-
- if (buf == NULL) {
- return (PICL_INVALIDARG);
- }
-
- if ((rc = hash_lookup_entry(rarg->nodeh, (void **)&hashptr)) !=
- PICL_SUCCESS) {
- return (rc);
- }
-
- frup = FRUDATA_PTR(hashptr);
- if (frup == NULL) {
- return (PICL_FAILURE);
- }
-
- /* return the cached value, if dr is in progress */
- (void) pthread_mutex_lock(&frup->mutex);
- if (frup->dr_in_progress) {
- (void) pthread_mutex_unlock(&frup->mutex);
- (void) strncpy((char *)buf, fru_cond[frup->cond],
- PICL_PROPNAMELEN_MAX);
- return (PICL_SUCCESS);
-
- }
- (void) pthread_mutex_unlock(&frup->mutex);
-
- if ((rc = update_fru_condition(frup, &cond_changed)) != PICL_SUCCESS) {
- FRUTREE_DEBUG2(EVENTS, GET_FRU_COND_ERR, frup->name, rc);
- /* return the cached value */
- (void) strncpy((char *)buf, fru_cond[frup->cond],
- PICL_PROPNAMELEN_MAX);
- return (rc);
- }
- if (cond_changed) {
- dr_arg.action = POST_COND_EVENT;
- dr_arg.data = frup;
- (void) pthread_mutex_lock(&ev_mutex);
- if ((rc = add_to_queue(dr_arg)) != PICL_SUCCESS) {
- (void) pthread_mutex_unlock(&ev_mutex);
- FRUTREE_DEBUG3(EVENTS, EVENT_NOT_HANDLED,
- "condition event", frup->name, rc);
- } else {
- (void) pthread_cond_signal(&ev_cond);
- (void) pthread_mutex_unlock(&ev_mutex);
- }
- }
-
- /* if there is a condition change, post picl event */
- (void) strncpy((char *)buf, fru_cond[frup->cond],
- PICL_PROPNAMELEN_MAX);
-
- return (PICL_SUCCESS);
-}
-
-static void
-free_cache(frutree_cache_t *cachep)
-{
- frutree_cache_t *tmp = NULL;
- if (cachep == NULL)
- return;
-
- while (cachep != NULL) {
- tmp = cachep;
- cachep = cachep->next;
- free(tmp);
- }
-}
-
-/*
- * traverse the /platform tree in PICL tree to create logical devices table
- */
-static picl_errno_t
-probe_platform_tree(frutree_frunode_t *frup, frutree_device_args_t **devp)
-{
- picl_errno_t rc;
- picl_nodehdl_t refhdl = 0;
- char class[PICL_CLASSNAMELEN_MAX];
- frutree_device_args_t *device = NULL;
- picl_prophdl_t tblprophdl;
- picl_prophdl_t dev_tblhdl, env_tblhdl = 0;
-
- if (devp == NULL) {
- return (PICL_FAILURE);
- }
- device = *(frutree_device_args_t **)devp;
- if (device == NULL) {
- return (PICL_FAILURE);
- }
-
- /* traverse thru platform tree and add entries to Devices table */
- if ((refhdl = get_reference_handle(frup->frunodeh)) == 0) {
- return (PICL_NODENOTFOUND);
- }
-
- /* create Devices table property */
- if ((rc = create_property(PICL_PTYPE_TABLE, PICL_READ,
- sizeof (picl_prophdl_t), PICL_PROP_DEVICES, NULLREAD,
- NULLWRITE, frup->frunodeh, &tblprophdl, &dev_tblhdl)) !=
- PICL_SUCCESS) {
- return (rc);
- }
-
- if ((rc = ptree_get_propval_by_name(refhdl, PICL_PROP_CLASSNAME,
- class, sizeof (class))) != PICL_SUCCESS) {
- return (rc);
- }
-
- if ((rc = create_table_entry(dev_tblhdl, refhdl, class)) !=
- PICL_SUCCESS) {
- return (rc);
- }
-
- /* create Environment devices table property */
- if ((rc = create_property(PICL_PTYPE_TABLE, PICL_READ,
- sizeof (picl_prophdl_t), PICL_PROP_ENV, NULLREAD,
- NULLWRITE, frup->frunodeh, &tblprophdl, &env_tblhdl)) !=
- PICL_SUCCESS) {
- return (rc);
- }
-
- device->nodeh = refhdl;
- device->device_tblhdl = dev_tblhdl;
- device->env_tblhdl = env_tblhdl;
- device->first = NULL;
- device->last = NULL;
- device->create_cache = B_FALSE;
-
- /* probe using platform tree info */
- if ((rc = do_action(refhdl, CREATE_DEVICES_ENTRIES,
- device)) != PICL_SUCCESS) {
- free_cache(device->first);
- return (rc);
- }
- return (PICL_SUCCESS);
-}
-
-/*
- * create temp conf file to pass it to picld util lib to create
- * nodes under the fru
- */
-static picl_errno_t
-create_fru_children(frutree_frunode_t *frup, frutree_device_args_t device)
-{
- int fd;
- picl_errno_t rc;
- char conffile[MAXPATHLEN];
- char dir[MAXPATHLEN];
- struct stat file_stat;
- char version[BUF_SIZE];
- frutree_cache_t *cachep = NULL;
-
- cachep = device.first;
- if (cachep == NULL) {
- return (PICL_SUCCESS);
- }
-
- /* create the configuration file for the fru */
- (void) snprintf(dir, MAXPATHLEN, "%s%s", TEMP_DIR, frup->name);
- bzero(&file_stat, sizeof (file_stat));
- if (stat(conffile, &file_stat) == -1) {
- if (mkdir(conffile, 0755) == -1) {
- return (PICL_FAILURE);
- }
- }
-
- (void) snprintf(conffile, MAXPATHLEN, "%s/%s", dir, PROBE_FILE);
- if ((fd = open(conffile, O_WRONLY|O_CREAT|O_TRUNC, 0644)) == -1) {
- (void) rmdir(dir);
- return (PICL_FAILURE);
- }
-
- (void) snprintf(version, sizeof (version), "VERSION %d.0",
- PTREE_PROPINFO_VERSION);
- if (write(fd, version, strlen(version)) != strlen(version)) {
- (void) remove(conffile);
- (void) rmdir(dir);
- (void) close(fd);
- return (PICL_FAILURE);
- }
-
- /* traverse thru each cache entry and append to conf file */
- while (cachep != NULL) {
- if (write(fd, cachep->buf, strlen(cachep->buf))
- != strlen(cachep->buf)) {
- (void) close(fd);
- (void) remove(conffile);
- (void) rmdir(dir);
- return (PICL_FAILURE);
- }
- cachep = cachep->next;
- }
- (void) close(fd);
-
- /* create child nodes for fru using the conffile created */
- if ((rc = picld_pluginutil_parse_config_file(frup->frunodeh,
- conffile)) != PICL_SUCCESS) {
- (void) remove(conffile);
- (void) rmdir(dir);
- return (rc);
- }
- (void) remove(conffile);
- (void) rmdir(dir);
-
- if ((rc = fru_init(frup)) != PICL_SUCCESS) {
- return (rc);
- }
- return (PICL_SUCCESS);
-}
-
-/*
- * probes libdevinfo and create the port nodes under a fru
- * probes for any scsi devices under a fru
- */
-static picl_errno_t
-probe_fru(frutree_frunode_t *frup, boolean_t load_drivers)
-{
- picl_errno_t rc;
- picl_nodehdl_t child, loch;
- char slot_type[PICL_PROPNAMELEN_MAX];
- char devfs_path[PICL_PROPNAMELEN_MAX];
- char probe_path[PICL_PROPNAMELEN_MAX];
- frutree_device_args_t *device = NULL;
-
- if (frup == NULL) {
- return (PICL_FAILURE);
- }
- FRUTREE_DEBUG1(EVENTS, "probing :%s", frup->name);
-
- if ((rc = ptree_get_propval_by_name(frup->frunodeh, PICL_PROP_PARENT,
- &loch, sizeof (loch))) != PICL_SUCCESS) {
- return (rc);
- }
-
- bzero(devfs_path, PICL_PROPNAMELEN_MAX);
- bzero(probe_path, PICL_PROPNAMELEN_MAX);
- if ((rc = ptree_get_propval_by_name(loch, PICL_PROP_DEVFS_PATH,
- devfs_path, sizeof (devfs_path))) == PICL_SUCCESS) {
- device = (frutree_device_args_t *)malloc(
- sizeof (frutree_device_args_t));
- if (device == NULL) {
- return (PICL_NOSPACE);
- }
- device->first = NULL;
- device->last = NULL;
- (void) probe_platform_tree(frup, &device);
- free_cache(device->first);
- free(device);
- }
-
- /*
- * if parent has NULL probe-path, skip probing this fru
- * probe only child locations (if present).
- * if probe-path is not present use devfs-path as path for
- * probing the fru.
- */
- rc = ptree_get_propval_by_name(loch, PICL_PROP_PROBE_PATH,
- probe_path, sizeof (probe_path));
- if (rc != PICL_SUCCESS) {
- if (!devfs_path[0]) { /* devfspath is also not present */
- return (PICL_SUCCESS); /* nothing to probe */
- } else {
- /* use devfs-path as path for probing */
- if ((rc = get_fru_path(devfs_path, frup)) !=
- PICL_SUCCESS) {
- return (rc);
- }
- }
- } else {
- /* NULL path, skip probing this fru */
- if (strlen(probe_path) == 0) {
- rc = fru_init(frup); /* probe its children */
- return (rc);
- } else {
- /* valid probe-path */
- if ((rc = get_fru_path(probe_path, frup)) !=
- PICL_SUCCESS) {
- return (rc);
- }
- }
- }
-
- /* children present already, no need to probe libdevinfo */
- rc = ptree_get_propval_by_name(frup->frunodeh, PICL_PROP_CHILD,
- &child, sizeof (picl_nodehdl_t));
- if (rc == PICL_SUCCESS) { /* child present */
- if ((rc = fru_init(frup)) != PICL_SUCCESS) {
- return (rc);
- }
- /* now create the scsi nodes for this fru */
- if ((rc = probe_for_scsi_frus(frup)) != PICL_SUCCESS) {
- return (rc);
- }
- return (PICL_SUCCESS);
- }
-
- if (ptree_get_propval_by_name(frup->frunodeh, PICL_PROP_PARENT,
- &loch, sizeof (loch)) != PICL_SUCCESS) {
- return (rc);
- }
- if ((rc = ptree_get_propval_by_name(loch, PICL_PROP_SLOT_TYPE,
- slot_type, sizeof (slot_type))) != PICL_SUCCESS) {
- return (rc);
- }
- /* no need to probe further for scsi frus */
- if (strcmp(slot_type, SANIBEL_SCSI_SLOT) == 0 ||
- strcmp(slot_type, SANIBEL_IDE_SLOT) == 0) {
- return (PICL_SUCCESS);
- }
-
- device = (frutree_device_args_t *)malloc(
- sizeof (frutree_device_args_t));
- if (device == NULL) {
- return (PICL_NOSPACE);
- }
- device->first = NULL;
- device->last = NULL;
-
- if ((rc = probe_libdevinfo(frup, &device, load_drivers)) !=
- PICL_SUCCESS) {
- free_cache(device->first);
- free(device);
- return (rc);
- }
-
- if (device->first != NULL) {
- if ((rc = create_fru_children(frup, *device)) != PICL_SUCCESS) {
- free_cache(device->first);
- free(device);
- return (rc);
- }
- }
- free_cache(device->first);
- free(device);
-
- /* now create the scsi nodes for this fru */
- if ((rc = probe_for_scsi_frus(frup)) != PICL_SUCCESS) {
- return (rc);
- }
- return (PICL_SUCCESS);
-}
-
-/*
- * callback function for ptree_walk_tree_by_class,
- * used to update hashtable during DR_HINT_REMOVE event
- */
-/*ARGSUSED*/
-static int
-frutree_update_hash(picl_nodehdl_t nodeh, void *c_args)
-{
- picl_errno_t rc = 0;
- if ((rc = hash_remove_entry(nodeh)) != PICL_SUCCESS) {
- return (rc);
- }
- return (PICL_WALK_CONTINUE);
-}
-
-/*
- * routine to handle DR_HINT_REMOVE
- */
-static picl_errno_t
-handle_fru_remove(frutree_frunode_t *frup)
-{
- picl_errno_t rc = PICL_SUCCESS;
-
- if (frup == NULL) {
- return (PICL_FAILURE);
- }
-
- if ((rc = ptree_walk_tree_by_class(frup->frunodeh,
- NULL, NULL, frutree_update_hash)) != PICL_SUCCESS) {
- return (rc);
- }
- (void) ptree_delete_node(frup->frunodeh);
- (void) ptree_destroy_node(frup->frunodeh);
- if ((rc = hash_remove_entry(frup->frunodeh)) !=
- PICL_SUCCESS) {
- return (rc);
- }
- return (PICL_SUCCESS);
-}
-
-/* remove State and Condition props for all the nodes under fru */
-/*ARGSUSED*/
-static int
-frutree_handle_unconfigure(picl_nodehdl_t nodeh, void *c_args)
-{
- picl_errno_t rc = 0;
- picl_prophdl_t proph;
- char class[PICL_PROPNAMELEN_MAX];
-
- if (ptree_get_prop_by_name(nodeh, PICL_PROP_STATE,
- &proph) == PICL_SUCCESS) {
- (void) ptree_delete_prop(proph);
- (void) ptree_destroy_prop(proph);
- }
- if (ptree_get_prop_by_name(nodeh, PICL_PROP_STATUS_TIME,
- &proph) == PICL_SUCCESS) {
- (void) ptree_delete_prop(proph);
- (void) ptree_destroy_prop(proph);
- }
-
- if ((rc = ptree_get_propval_by_name(nodeh, PICL_PROP_CLASSNAME,
- class, sizeof (class))) != PICL_SUCCESS) {
- return (rc);
- }
-
- if (strcmp(class, PICL_CLASS_PORT) == 0) {
- if (ptree_get_prop_by_name(nodeh, PICL_PROP_CONDITION,
- &proph) == PICL_SUCCESS) {
- (void) ptree_delete_prop(proph);
- (void) ptree_destroy_prop(proph);
- }
- if (ptree_get_prop_by_name(nodeh, PICL_PROP_CONDITION_TIME,
- &proph) == PICL_SUCCESS) {
- (void) ptree_delete_prop(proph);
- (void) ptree_destroy_prop(proph);
- }
- /* delete devices table */
- if (ptree_get_prop_by_name(nodeh, PICL_PROP_DEVICES,
- &proph) == PICL_SUCCESS) {
- (void) ptree_delete_prop(proph);
- (void) ptree_destroy_prop(proph);
- }
- }
- return (PICL_WALK_CONTINUE);
-}
-
-/*
- * traverse thru each node fru node and do cleanup
- */
-static picl_errno_t
-handle_fru_unconfigure(frutree_frunode_t *frup)
-{
- picl_errno_t rc = 0, retval = 0;
- picl_prophdl_t proph;
- picl_nodehdl_t childh, peerh, nodeh;
- hashdata_t *hashptr = NULL;
- frutree_frunode_t *child_frup = NULL;
- char class[PICL_PROPNAMELEN_MAX];
-
- if (frup == NULL) {
- return (PICL_FAILURE);
- }
-
- /* delete devices table */
- if (ptree_get_prop_by_name(frup->frunodeh, PICL_PROP_DEVICES,
- &proph) == PICL_SUCCESS) {
- (void) ptree_delete_prop(proph);
- (void) ptree_destroy_prop(proph);
- }
-
- /* delete Environment devices table */
- if (ptree_get_prop_by_name(frup->frunodeh, PICL_PROP_ENV,
- &proph) == PICL_SUCCESS) {
- (void) ptree_delete_prop(proph);
- (void) ptree_destroy_prop(proph);
- }
-
- if ((rc = ptree_walk_tree_by_class(frup->frunodeh,
- NULL, NULL, frutree_handle_unconfigure)) != PICL_SUCCESS) {
- return (rc);
- }
-
- /* remove all the fru nodes under the child locations */
- retval = ptree_get_propval_by_name(frup->frunodeh, PICL_PROP_CHILD,
- &peerh, sizeof (peerh));
- while (retval == PICL_SUCCESS) {
- nodeh = peerh;
- retval = ptree_get_propval_by_name(nodeh, PICL_PROP_PEER,
- &peerh, sizeof (peerh));
- if ((rc = ptree_get_propval_by_name(nodeh, PICL_PROP_CLASSNAME,
- class, sizeof (class))) != PICL_SUCCESS) {
- return (rc);
- }
-
- if (strcmp(class, PICL_CLASS_PORT) == 0) {
- continue;
- }
-
- /* if the child location has fru, delete the fru */
- if (ptree_get_propval_by_name(nodeh, PICL_PROP_CHILD,
- &childh, sizeof (childh)) != PICL_SUCCESS) {
- continue;
- }
-
- /* child is present under the location */
- if ((rc = hash_lookup_entry(childh, (void **)&hashptr)) !=
- PICL_SUCCESS) {
- return (rc);
- }
- child_frup = FRUDATA_PTR(hashptr);
- (void) handle_fru_remove(child_frup);
- }
- return (PICL_SUCCESS);
-}
-
-/*
- * create the properties under the fru
- */
-static picl_errno_t
-create_fru_props(frutree_frunode_t *frup)
-{
- picl_errno_t rc;
- uint64_t ap_status_time = 0;
- boolean_t state_change;
-
- /* create state props */
- if ((rc = create_property(PICL_PTYPE_CHARSTRING,
- PICL_READ + PICL_VOLATILE, PICL_PROPNAMELEN_MAX,
- PICL_PROP_STATE, get_fru_state, NULLWRITE,
- frup->frunodeh, NULL, fru_state[frup->state])) !=
- PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_CREATE_PROP_FAILED,
- PICL_PROP_STATE, frup->name, rc);
- }
-
- ap_status_time = (uint64_t)(time(NULL));
- if ((rc = create_property(PICL_PTYPE_TIMESTAMP, PICL_READ,
- sizeof (ap_status_time), PICL_PROP_STATUS_TIME,
- NULLREAD, NULLWRITE, frup->frunodeh,
- NULL, &ap_status_time)) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_CREATE_PROP_FAILED,
- PICL_PROP_STATUS_TIME, frup->name, rc);
- }
-
- if ((rc = update_fru_state(frup, &state_change)) != PICL_SUCCESS) {
- FRUTREE_DEBUG2(EVENTS, GET_FRU_STATE_ERR, frup->name, rc);
- return (rc);
- }
-
- /* create condition props */
- if ((rc = create_property(PICL_PTYPE_CHARSTRING,
- PICL_READ + PICL_VOLATILE, PICL_PROPNAMELEN_MAX,
- PICL_PROP_CONDITION, get_fru_condition, NULLWRITE,
- frup->frunodeh, NULL, fru_cond[frup->cond])) !=
- PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_CREATE_PROP_FAILED,
- PICL_PROP_CONDITION, frup->name, rc);
- }
- if ((rc = create_property(PICL_PTYPE_TIMESTAMP, PICL_READ,
- sizeof (ap_status_time), PICL_PROP_CONDITION_TIME,
- NULLREAD, NULLWRITE, frup->frunodeh, NULL,
- &ap_status_time)) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_CREATE_PROP_FAILED,
- PICL_PROP_CONDITION_TIME, frup->name, rc);
- }
-
- if ((rc = update_fru_condition(frup, &state_change)) != PICL_SUCCESS) {
- FRUTREE_DEBUG2(EVENTS, GET_FRU_COND_ERR, frup->name, rc);
- return (rc);
- }
-
- /* create admin lock prop */
- if ((rc = create_property(PICL_PTYPE_CHARSTRING,
- PICL_READ + PICL_WRITE, PICL_PROPNAMELEN_MAX,
- PICL_PROP_ADMIN_LOCK, NULLREAD, NULLWRITE,
- frup->frunodeh, NULL, PICL_ADMINLOCK_DISABLED)) !=
- PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_CREATE_PROP_FAILED,
- PICL_PROP_ADMIN_LOCK, frup->name, rc);
- }
- return (rc);
-}
-
-/*
- * calls libcfgadm API to do a connect on a location
- */
-static picl_errno_t
-connect_fru(frutree_locnode_t *locp)
-{
- picl_errno_t rc;
- cfga_err_t ap_list_err;
- cfga_flags_t flags = 0;
- boolean_t state_change;
- uint64_t ap_status_time;
- hrtime_t start;
- hrtime_t end;
-
- if (locp == NULL) {
- return (PICL_FAILURE);
- }
- if ((rc = post_piclevent(PICLEVENT_STATE_CHANGE,
- PICLEVENTARGVAL_CONNECTING, loc_state[locp->state],
- locp->locnodeh, WAIT)) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_POST_PICLEVENT_ERR,
- locp->name, PICLEVENT_STATE_CHANGE, rc);
- }
-
- (void) pthread_mutex_lock(&locp->mutex);
- locp->dr_in_progress = B_TRUE;
- (void) pthread_mutex_unlock(&locp->mutex);
-
- if (frutree_debug & PERF_DATA) {
- start = gethrtime();
- }
- ap_list_err = config_change_state(CFGA_CMD_CONNECT, 1, &(locp->name),
- NULL, NULL, NULL, NULL, flags);
-
- if (frutree_debug & PERF_DATA) {
- end = gethrtime();
- FRUTREE_DEBUG2(PERF_DATA, "time for connect on %s: %lld nsec",
- locp->name, (end - start));
- }
- if (ap_list_err != CFGA_OK) {
- (void) pthread_mutex_lock(&locp->mutex);
- locp->dr_in_progress = B_FALSE;
- (void) pthread_mutex_unlock(&locp->mutex);
-
- /* release mutex before updating state */
- (void) update_loc_state(locp, &state_change);
- if ((rc = post_piclevent(PICLEVENT_STATE_CHANGE,
- loc_state[locp->state], PICLEVENTARGVAL_CONNECTING,
- locp->locnodeh, WAIT)) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_POST_PICLEVENT_ERR,
- locp->name, PICLEVENT_STATE_CHANGE, rc);
- }
- if (locp->state == LOC_STATE_CONNECTED) {
- /* wakeup threads sleeping on this condition */
- (void) pthread_mutex_lock(&locp->mutex);
- (void) pthread_cond_broadcast(&locp->cond_cv);
- (void) pthread_mutex_unlock(&locp->mutex);
- return (PICL_SUCCESS);
- }
- return (cfg2picl_errmap[ap_list_err][1]);
- }
- (void) pthread_mutex_lock(&locp->mutex);
-
- locp->dr_in_progress = B_FALSE;
- locp->prev_state = LOC_STATE_DISCONNECTED;
- locp->state = LOC_STATE_CONNECTED;
- ap_status_time = (uint64_t)(time(NULL));
- if ((rc = ptree_update_propval_by_name(locp->locnodeh,
- PICL_PROP_STATUS_TIME, (void *)&ap_status_time,
- sizeof (ap_status_time))) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_UPDATE_PROP_ERR,
- PICL_PROP_STATUS_TIME, locp->name, rc);
- }
-
- /* wakeup threads sleeping on this condition */
- (void) pthread_cond_broadcast(&locp->cond_cv);
- (void) pthread_mutex_unlock(&locp->mutex);
-
- if ((rc = post_piclevent(PICLEVENT_STATE_CHANGE,
- PICLEVENTARGVAL_CONNECTED, PICLEVENTARGVAL_CONNECTING,
- locp->locnodeh, WAIT)) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_POST_PICLEVENT_ERR,
- locp->name, PICLEVENT_STATE_CHANGE, rc);
- }
- return (PICL_SUCCESS);
-}
-
-/*
- * calls libcfgadm API to do a disconnect on a location
- */
-static picl_errno_t
-disconnect_fru(frutree_locnode_t *locp)
-{
- picl_errno_t rc;
- picl_nodehdl_t childh;
- hashdata_t *hashptr = NULL;
- timestruc_t to;
- struct timeval tp;
- hrtime_t start, end;
- cfga_err_t ap_list_err;
- cfga_flags_t flags = 0;
- boolean_t state_change;
- uint64_t ap_status_time;
- frutree_frunode_t *frup = NULL;
-
- if (locp == NULL) {
- return (PICL_FAILURE);
- }
-
- (void) pthread_mutex_lock(&locp->mutex);
- if (locp->state == LOC_STATE_DISCONNECTED) {
- (void) pthread_mutex_unlock(&locp->mutex);
- return (PICL_SUCCESS);
- }
- (void) pthread_mutex_unlock(&locp->mutex);
-
- /* get the child fru information */
- if (ptree_get_propval_by_name(locp->locnodeh, PICL_PROP_CHILD,
- &childh, sizeof (childh)) == PICL_SUCCESS) {
- if (hash_lookup_entry(childh, (void **)&hashptr) ==
- PICL_SUCCESS) {
- frup = FRUDATA_PTR(hashptr);
- }
- }
-
- if (frup == NULL) {
- return (PICL_SUCCESS);
- }
-
- (void) pthread_mutex_lock(&frup->mutex);
-
- (void) gettimeofday(&tp, NULL);
- to.tv_sec = tp.tv_sec + frutree_drwait_time;
- to.tv_nsec = tp.tv_usec * 1000;
-
- if (frup->state != FRU_STATE_UNCONFIGURED) {
- (void) pthread_cond_timedwait(&frup->cond_cv,
- &frup->mutex, &to);
- }
-
- if (frup->state != FRU_STATE_UNCONFIGURED) {
- FRUTREE_DEBUG1(LOG_ERR, "SUNW_frutree:Disconnect operation on"
- " %s failed", locp->name);
- (void) pthread_mutex_unlock(&frup->mutex);
- return (PICL_FAILURE);
- }
- (void) pthread_mutex_unlock(&frup->mutex);
-
- if ((rc = post_piclevent(PICLEVENT_STATE_CHANGE,
- PICLEVENTARGVAL_DISCONNECTING, loc_state[locp->state],
- locp->locnodeh, WAIT)) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_POST_PICLEVENT_ERR,
- locp->name, PICLEVENT_STATE_CHANGE, rc);
- }
-
- (void) pthread_mutex_lock(&locp->mutex);
- locp->dr_in_progress = B_TRUE;
- (void) pthread_mutex_unlock(&locp->mutex);
-
- if (frutree_debug & PERF_DATA) {
- start = gethrtime();
- }
-
- ap_list_err = config_change_state(CFGA_CMD_DISCONNECT, 1, &(locp->name),
- NULL, NULL, NULL, NULL, flags);
- if (frutree_debug & PERF_DATA) {
- end = gethrtime();
- FRUTREE_DEBUG2(PERF_DATA, "time for disconnect on %s: %lld ns",
- locp->name, (end - start));
- }
- if (ap_list_err != CFGA_OK) {
- (void) pthread_mutex_lock(&locp->mutex);
- locp->dr_in_progress = B_FALSE;
- (void) pthread_mutex_unlock(&locp->mutex);
-
- /* release mutex before updating state */
- (void) update_loc_state(locp, &state_change);
- if ((rc = post_piclevent(PICLEVENT_STATE_CHANGE,
- loc_state[locp->state], PICLEVENTARGVAL_DISCONNECTING,
- locp->locnodeh, WAIT)) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_POST_PICLEVENT_ERR,
- locp->name, PICLEVENT_STATE_CHANGE, rc);
- }
- (void) pthread_mutex_lock(&locp->mutex);
- if (locp->state == LOC_STATE_DISCONNECTED) {
- (void) pthread_mutex_unlock(&locp->mutex);
- return (PICL_SUCCESS);
- }
- (void) pthread_mutex_unlock(&locp->mutex);
- return (cfg2picl_errmap[ap_list_err][1]);
- }
- (void) pthread_mutex_lock(&locp->mutex);
- locp->dr_in_progress = B_FALSE;
- locp->prev_state = LOC_STATE_CONNECTED;
- locp->state = LOC_STATE_DISCONNECTED;
- ap_status_time = (uint64_t)(time(NULL));
- if ((rc = ptree_update_propval_by_name(locp->locnodeh,
- PICL_PROP_STATUS_TIME, (void *)&ap_status_time,
- sizeof (ap_status_time))) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_UPDATE_PROP_ERR,
- PICL_PROP_STATUS_TIME, locp->name, rc);
- }
- (void) pthread_mutex_unlock(&locp->mutex);
-
- if ((rc = post_piclevent(PICLEVENT_STATE_CHANGE,
- PICLEVENTARGVAL_DISCONNECTED, PICLEVENTARGVAL_DISCONNECTING,
- locp->locnodeh, WAIT)) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_POST_PICLEVENT_ERR,
- locp->name, PICLEVENT_STATE_CHANGE, rc);
- }
- return (PICL_SUCCESS);
-}
-
-/*
- * Handle DR_INCOMING_RES event
- */
-static void
-handle_fru_configure(frutree_frunode_t *frup)
-{
- picl_errno_t rc;
- boolean_t cond_changed;
-
- if (frup == NULL)
- return;
-
- if ((rc = probe_fru(frup, B_FALSE)) != PICL_SUCCESS) {
- FRUTREE_DEBUG2(EVENTS, PROBE_FRU_ERR, frup->name, rc);
- }
-
- /* update the fru condition */
- (void) update_fru_condition(frup, &cond_changed);
- if (cond_changed) {
- if ((rc = post_piclevent(PICLEVENT_CONDITION_CHANGE,
- fru_cond[frup->cond], fru_cond[frup->prev_cond],
- frup->frunodeh, WAIT)) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_POST_PICLEVENT_ERR,
- frup->name, PICLEVENT_CONDITION_CHANGE, rc);
- }
- }
-
- if ((rc = post_piclevent(PICLEVENT_STATE_CHANGE,
- fru_state[frup->state], fru_state[frup->prev_state],
- frup->frunodeh, WAIT)) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_POST_PICLEVENT_ERR,
- frup->name, PICLEVENT_STATE_CHANGE, rc);
- }
-}
-
-/*
- * call libcfgadm API to configure a fru
- * (Handle DR_INCOMING_RES event)
- */
-static picl_errno_t
-configure_fru(frutree_frunode_t *frup, cfga_flags_t flags)
-{
- picl_errno_t rc;
- picl_nodehdl_t parenth;
- timestruc_t to;
- struct timeval tp;
- hrtime_t start, end;
- cfga_err_t ap_list_err;
- uint64_t ap_status_time;
- hashdata_t *hashptr = NULL;
- frutree_locnode_t *locp = NULL;
- boolean_t state_change, cond_changed;
-
- if (frup == NULL) {
- return (PICL_FAILURE);
- }
-
- (void) pthread_mutex_lock(&frup->mutex);
- if (frup->state == FRU_STATE_CONFIGURED) {
- (void) pthread_mutex_unlock(&frup->mutex);
- ap_list_err = config_change_state(CFGA_CMD_CONFIGURE, 1,
- &(frup->name), NULL, NULL, NULL, NULL, flags);
- return (PICL_SUCCESS);
- }
- (void) pthread_mutex_unlock(&frup->mutex);
-
- if ((rc = ptree_get_propval_by_name(frup->frunodeh, PICL_PROP_PARENT,
- &parenth, sizeof (parenth))) != PICL_SUCCESS) {
- return (rc);
- }
-
- if ((rc = hash_lookup_entry(parenth, (void **)&hashptr)) !=
- PICL_SUCCESS) {
- return (rc);
- }
- locp = LOCDATA_PTR(hashptr);
- if (locp == NULL) {
- return (PICL_FAILURE);
- }
-
- (void) pthread_mutex_lock(&locp->mutex);
-
- (void) gettimeofday(&tp, NULL);
- to.tv_sec = tp.tv_sec + frutree_drwait_time;
- to.tv_nsec = tp.tv_usec * 1000;
-
- /* wait for sometime for location to get connected */
- if (locp->state != LOC_STATE_CONNECTED) {
- (void) pthread_cond_timedwait(&locp->cond_cv,
- &locp->mutex, &to);
- }
-
- if (locp->state != LOC_STATE_CONNECTED) { /* give up */
- FRUTREE_DEBUG1(EVENTS, "SUNW_frutree:Configure operation on"
- " %s failed as loc is not connected", locp->name);
- (void) pthread_mutex_unlock(&locp->mutex);
- return (PICL_FAILURE);
- }
- (void) pthread_mutex_unlock(&locp->mutex);
-
- if ((rc = post_piclevent(PICLEVENT_STATE_CHANGE,
- PICLEVENTARGVAL_CONFIGURING, fru_state[frup->state],
- frup->frunodeh, WAIT)) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_POST_PICLEVENT_ERR,
- frup->name, PICLEVENT_STATE_CHANGE, rc);
- }
-
- (void) pthread_mutex_lock(&frup->mutex);
- frup->dr_in_progress = B_TRUE;
- (void) pthread_mutex_unlock(&frup->mutex);
-
- if (frutree_debug & PERF_DATA) {
- start = gethrtime();
- }
- ap_list_err = config_change_state(CFGA_CMD_CONFIGURE, 1,
- &(frup->name), NULL, NULL, NULL, NULL, flags);
-
- if (frutree_debug & PERF_DATA) {
- end = gethrtime();
- FRUTREE_DEBUG2(PERF_DATA, "time for configure on %s: %lld nsec",
- frup->name, (end - start));
- }
-
- if (ap_list_err != CFGA_OK) {
- (void) pthread_mutex_lock(&frup->mutex);
- frup->dr_in_progress = B_FALSE;
- (void) pthread_mutex_unlock(&frup->mutex);
- /* release mutex before updating state */
- (void) update_fru_state(frup, &state_change);
- if ((rc = post_piclevent(PICLEVENT_STATE_CHANGE,
- fru_state[frup->state], PICLEVENTARGVAL_CONFIGURING,
- frup->frunodeh, WAIT)) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_POST_PICLEVENT_ERR,
- frup->name, PICLEVENT_STATE_CHANGE, rc);
- }
- /* update the fru condition */
- (void) update_fru_condition(frup, &state_change);
- if (state_change) {
- if ((rc = post_piclevent(PICLEVENT_CONDITION_CHANGE,
- fru_cond[frup->cond], fru_cond[frup->prev_cond],
- frup->frunodeh, WAIT)) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_POST_PICLEVENT_ERR,
- frup->name, PICLEVENT_CONDITION_CHANGE,
- rc);
- }
- }
- return (cfg2picl_errmap[ap_list_err][1]);
- }
- (void) pthread_mutex_lock(&frup->mutex);
- frup->dr_in_progress = B_FALSE;
- frup->prev_state = FRU_STATE_UNCONFIGURED;
- frup->state = FRU_STATE_CONFIGURED;
- ap_status_time = (uint64_t)(time(NULL));
- if ((rc = ptree_update_propval_by_name(frup->frunodeh,
- PICL_PROP_STATUS_TIME, (void *)&ap_status_time,
- sizeof (ap_status_time))) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_UPDATE_PROP_ERR,
- PICL_PROP_STATUS_TIME, frup->name, rc);
- }
- (void) pthread_mutex_unlock(&frup->mutex);
-
- if ((rc = probe_fru(frup, B_FALSE)) != PICL_SUCCESS) {
- FRUTREE_DEBUG2(FRUTREE_INIT, PROBE_FRU_ERR, frup->name, rc);
- }
- /* update the fru condition */
- (void) update_fru_condition(frup, &cond_changed);
- if (cond_changed) {
- if ((rc = post_piclevent(PICLEVENT_CONDITION_CHANGE,
- fru_cond[frup->cond], fru_cond[frup->prev_cond],
- frup->frunodeh, WAIT)) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_POST_PICLEVENT_ERR,
- frup->name, PICLEVENT_CONDITION_CHANGE, rc);
- }
- }
-
- /* send the state change event */
- if ((rc = post_piclevent(PICLEVENT_STATE_CHANGE,
- fru_state[frup->state], PICLEVENTARGVAL_CONFIGURING,
- frup->frunodeh, WAIT)) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_POST_PICLEVENT_ERR,
- frup->name, PICLEVENT_STATE_CHANGE, rc);
- }
- return (PICL_SUCCESS);
-}
-
-/*
- * Handle DR_OUTGOING_RES event
- * (call libcfgadm API to unconfigure a fru)
- */
-static picl_errno_t
-unconfigure_fru(frutree_frunode_t *frup, cfga_flags_t flags)
-{
- picl_errno_t rc;
- cfga_err_t ap_list_err;
- boolean_t state_change;
- uint64_t ap_status_time;
- hrtime_t start;
- hrtime_t end;
-
- if (frup == NULL) {
- return (PICL_FAILURE);
- }
-
- (void) pthread_mutex_lock(&frup->mutex);
- if (frup->state == FRU_STATE_UNCONFIGURED) {
- (void) pthread_mutex_unlock(&frup->mutex);
- return (PICL_SUCCESS);
- }
- (void) pthread_mutex_unlock(&frup->mutex);
-
- if ((rc = post_piclevent(PICLEVENT_STATE_CHANGE,
- PICLEVENTARGVAL_UNCONFIGURING, fru_state[frup->state],
- frup->frunodeh, WAIT)) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_POST_PICLEVENT_ERR,
- frup->name, PICLEVENT_STATE_CHANGE, rc);
- }
-
- (void) pthread_mutex_lock(&frup->mutex);
- while (frup->busy == B_TRUE) {
- (void) pthread_cond_wait(&frup->busy_cond_cv,
- &frup->mutex);
- }
-
- frup->dr_in_progress = B_TRUE;
- (void) pthread_mutex_unlock(&frup->mutex);
-
- if (frutree_debug & PERF_DATA) {
- start = gethrtime();
- }
- ap_list_err = config_change_state(CFGA_CMD_UNCONFIGURE, 1,
- &(frup->name), NULL, NULL, NULL, NULL, flags);
- if (frutree_debug & PERF_DATA) {
- end = gethrtime();
- FRUTREE_DEBUG2(PERF_DATA, "time for unconfigure on %s: %lld ns",
- frup->name, (end - start));
- }
- if (ap_list_err != CFGA_OK) {
- /*
- * call configure again (workaround for
- * ENUM# to get generated for next attempt)
- */
- config_change_state(CFGA_CMD_CONFIGURE, 1,
- &(frup->name), NULL, NULL, NULL, NULL, flags);
-
- (void) pthread_mutex_lock(&frup->mutex);
- frup->dr_in_progress = B_FALSE;
- (void) pthread_mutex_unlock(&frup->mutex);
-
- /* release mutex before updating state */
- (void) update_fru_condition(frup, &state_change);
- if (state_change) {
- if ((rc = post_piclevent(PICLEVENT_CONDITION_CHANGE,
- fru_cond[frup->cond], fru_cond[frup->prev_cond],
- frup->frunodeh, WAIT)) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_POST_PICLEVENT_ERR,
- frup->name, PICLEVENT_CONDITION_CHANGE,
- rc);
- }
- }
- (void) update_fru_state(frup, &state_change);
- if ((rc = post_piclevent(PICLEVENT_STATE_CHANGE,
- fru_state[frup->state], PICLEVENTARGVAL_UNCONFIGURING,
- frup->frunodeh, WAIT)) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_POST_PICLEVENT_ERR,
- frup->name, PICLEVENT_STATE_CHANGE, rc);
- }
- return (cfg2picl_errmap[ap_list_err][1]);
- }
-
- (void) pthread_mutex_lock(&frup->mutex);
-
- frup->dr_in_progress = B_FALSE;
- frup->prev_state = FRU_STATE_CONFIGURED;
- frup->state = FRU_STATE_UNCONFIGURED;
- ap_status_time = (uint64_t)(time(NULL));
- if ((rc = ptree_update_propval_by_name(frup->frunodeh,
- PICL_PROP_STATUS_TIME, (void *)&ap_status_time,
- sizeof (ap_status_time))) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_UPDATE_PROP_ERR,
- PICL_PROP_STATUS_TIME, frup->name, rc);
- }
- /* wakeup threads sleeping on this condition */
- (void) pthread_cond_broadcast(&frup->cond_cv);
- (void) pthread_mutex_unlock(&frup->mutex);
-
- /* update the fru condition */
- if ((rc = update_fru_condition(frup, &state_change)) != PICL_SUCCESS) {
- FRUTREE_DEBUG2(EVENTS, GET_FRU_STATE_ERR,
- frup->name, rc);
- }
- if (state_change) {
- if ((rc = post_piclevent(PICLEVENT_CONDITION_CHANGE,
- fru_cond[frup->cond], fru_cond[frup->prev_cond],
- frup->frunodeh, WAIT)) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_POST_PICLEVENT_ERR,
- frup->name, PICLEVENT_CONDITION_CHANGE, rc);
- }
- }
-
- if ((rc = post_piclevent(PICLEVENT_STATE_CHANGE,
- PICLEVENTARGVAL_UNCONFIGURED, PICLEVENTARGVAL_UNCONFIGURING,
- frup->frunodeh, WAIT)) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_POST_PICLEVENT_ERR,
- frup->name, PICLEVENT_STATE_CHANGE, rc);
- }
- return (PICL_SUCCESS);
-}
-
-/* creates fru nodes with basic properties and sends out intializing events */
-static int
-create_fru_node(frutree_locnode_t *locp, frutree_frunode_t **child_frupp)
-{
- picl_errno_t rc;
- hashdata_t *fru_data = NULL;
- frutree_frunode_t *frup = NULL;
- picl_nodehdl_t fruh, child;
- char slot_type[PICL_PROPNAMELEN_MAX];
- char fru_name[PICL_PROPNAMELEN_MAX];
- char apid_type[PICL_PROPNAMELEN_MAX];
- boolean_t fru_present = B_FALSE;
- boolean_t state_changed = B_FALSE;
-
- if (locp->state == LOC_STATE_EMPTY) {
- return (PICL_SUCCESS);
- }
-
- /* check if fru is present or not */
- rc = ptree_get_propval_by_name(locp->locnodeh, PICL_PROP_CHILD,
- &child, sizeof (picl_nodehdl_t));
- if (rc == PICL_SUCCESS) {
- fru_present = B_TRUE;
- fruh = child;
- (void) ptree_get_propval_by_name(child, PICL_PROP_NAME,
- fru_name, sizeof (fru_name));
- }
-
- /* create fru node */
- if (fru_present == B_FALSE) {
- (void) strncpy(fru_name, locp->name, sizeof (fru_name));
- if ((rc = ptree_create_node(fru_name, PICL_CLASS_FRU,
- &fruh)) != PICL_SUCCESS) {
- return (rc);
- }
- }
-
- /* initialize internal data structures */
- if ((rc = make_fru_data(fru_name, &fru_data)) != PICL_SUCCESS) {
- return (rc);
- }
- frup = FRUDATA_PTR(fru_data);
-
- frup->frunodeh = fruh;
- frup->cpu_node = locp->cpu_node;
- frup->state_mgr = locp->state_mgr;
- *child_frupp = frup;
-
- if ((rc = hash_add_entry(fruh, (void *)(fru_data))) != PICL_SUCCESS) {
- (void) ptree_destroy_node(fruh);
- free_data(FRU_TYPE, (fru_data));
- return (rc);
- }
-
- if (locp->state_mgr == STATIC_LOC) {
- if ((rc = ptree_get_propval_by_name(locp->locnodeh,
- PICL_PROP_SLOT_TYPE, slot_type,
- sizeof (slot_type))) == PICL_SUCCESS) {
- (void) strncpy(apid_type, slot_type,
- sizeof (apid_type));
- }
- }
-
- /* create fru type property */
- if ((rc = create_property(PICL_PTYPE_CHARSTRING, PICL_READ,
- PICL_PROPNAMELEN_MAX, PICL_PROP_FRU_TYPE, NULLREAD,
- NULLWRITE, fruh, NULL, apid_type)) !=
- PICL_SUCCESS) {
- FRUTREE_DEBUG3(FRUTREE_INIT, PTREE_CREATE_PROP_FAILED,
- PICL_PROP_FRU_TYPE, frup->name, rc);
- }
-
- if (fru_present == B_FALSE) {
- if ((rc = ptree_add_node(locp->locnodeh, fruh)) !=
- PICL_SUCCESS) {
- (void) ptree_destroy_node(fruh);
- (void) hash_remove_entry(fruh);
- return (rc);
- }
- }
-
- if (locp->state_mgr == PLUGIN_PVT) {
- (void) update_fru_state(frup, &state_changed);
- return (PICL_SUCCESS);
- }
-
- if ((rc = create_fru_props(frup)) != PICL_SUCCESS) {
- return (rc);
- }
- return (PICL_SUCCESS);
-}
-
-static picl_errno_t
-add_node2cache(picl_nodehdl_t nodeh, char *class, frutree_cache_t **cacheptr)
-{
- int instance;
- picl_errno_t rc;
- char driver[PICL_PROPNAMELEN_MAX];
- char bus_addr[PICL_PROPNAMELEN_MAX];
- char devfs_path[PICL_PROPNAMELEN_MAX];
- char node_name[PICL_PROPNAMELEN_MAX];
- char port_type[PICL_PROPNAMELEN_MAX];
- char label[PICL_PROPNAMELEN_MAX];
- frutree_cache_t *cachep = NULL;
-
- if (strcmp(class, SANIBEL_NETWORK_PORT) == 0) {
- (void) strncpy(label, SANIBEL_NETWORK_LABEL, sizeof (label));
- (void) strncpy(node_name, PICL_CLASS_PORT, sizeof (node_name));
- (void) strncpy(port_type, SANIBEL_NETWORK_PORT,
- sizeof (port_type));
-
- } else if (strcmp(class, SANIBEL_SERIAL_PORT) == 0) {
- (void) strncpy(label, SANIBEL_SERIAL_PORT, sizeof (label));
- (void) strncpy(node_name, PICL_CLASS_PORT, sizeof (node_name));
- (void) strncpy(port_type, SANIBEL_SERIAL_PORT,
- sizeof (port_type));
-
- } else if (strcmp(class, SANIBEL_PARALLEL_PORT) == 0) {
- (void) strncpy(label, SANIBEL_PARALLEL_PORT, sizeof (label));
- (void) strncpy(node_name, PICL_CLASS_PORT, sizeof (node_name));
- (void) strncpy(port_type, SANIBEL_PARALLEL_PORT,
- sizeof (port_type));
-
- } else {
- return (PICL_FAILURE);
- }
-
- if ((rc = ptree_get_propval_by_name(nodeh, PICL_PROP_INSTANCE,
- &instance, sizeof (instance))) != PICL_SUCCESS) {
- return (rc);
- }
-
- /* load the driver */
- if (instance < 0) {
- attach_driver(driver);
- }
-
- if ((rc = ptree_get_propval_by_name(nodeh, PICL_PROP_DEVFS_PATH,
- devfs_path, sizeof (devfs_path))) != PICL_SUCCESS) {
- return (rc);
- }
-
- /* get either bus address or unit address */
- if ((rc = ptree_get_propval_by_name(nodeh, PICL_PROP_BUS_ADDR, bus_addr,
- sizeof (bus_addr))) != PICL_SUCCESS) {
- if ((rc = ptree_get_propval_by_name(nodeh,
- PICL_PROP_UNIT_ADDRESS, bus_addr,
- sizeof (bus_addr))) != PICL_SUCCESS) {
- return (rc);
- }
- }
-
- if ((rc = ptree_get_propval_by_name(nodeh, PICL_PROP_DRIVER_NAME,
- driver, sizeof (driver))) != PICL_SUCCESS) {
- return (rc);
- }
-
- cachep = (frutree_cache_t *)malloc(sizeof (frutree_cache_t));
- if (NULL == cachep) {
- return (PICL_NOSPACE);
- }
- cachep->buf[0] = '\0';
-
- /* update the cache buffer in PICL configuration format */
- (void) snprintf(cachep->buf, sizeof (cachep->buf),
- "\n%s %s%d %s\n"
- "\t%s %s %s %s 0 \"%s %d\"\n"
- "\t%s %s %s %s 0 \"%s\"\n"
- "\t%s %s %s %s 1 %d\n"
- "\t%s %s %s %s 0 \"%s\"\n"
- "\t%s %s %s %s 0 \"%s\"\n"
- "%s\n",
- "NODE", driver, instance, node_name,
- "PROP", PICL_PROP_LABEL, "string", "r", label, instance,
- "PROP", PICL_PROP_BUS_ADDR, "string", "r", bus_addr,
- "PROP", PICL_PROP_GEO_ADDR, "uint", "r", instance,
- "PROP", PICL_PROP_PORT_TYPE, "string", "r", port_type,
- "PROP", PICL_PROP_DEVFS_PATH, "string", "r", devfs_path,
- "ENDNODE");
- *cacheptr = cachep;
- return (PICL_SUCCESS);
-}
-
-/* ARGSUSED */
-static int
-create_device_entries(picl_nodehdl_t nodeh, void *c_args)
-{
- char class[PICL_CLASSNAMELEN_MAX];
- char name[PICL_PROPNAMELEN_MAX];
- frutree_device_args_t *device = NULL;
- frutree_cache_t *cachep = NULL;
-
- if (c_args == NULL) { /* need not create cache */
- return (PICL_INVALIDARG);
- }
- device = (frutree_device_args_t *)c_args;
-
- if (ptree_get_propval_by_name(nodeh, PICL_PROP_CLASSNAME,
- class, sizeof (class)) != PICL_SUCCESS) {
- return (PICL_WALK_CONTINUE);
- }
-
- /* add reference handle to Devices table */
- (void) create_table_entry(device->device_tblhdl, nodeh, class);
-
- /* add to Environment Devices table */
- if (strcmp(class, PICL_CLASS_TEMPERATURE_SENSOR) == 0) {
- if (device->env_tblhdl) {
- (void) create_table_entry(device->env_tblhdl, nodeh,
- class);
- }
- }
-
- if (device->create_cache != B_TRUE) { /* dont create cache */
- return (PICL_WALK_CONTINUE);
- }
-
- /* compare the classname and create the cache entry for the child */
- if (ptree_get_propval_by_name(nodeh, PICL_PROP_NAME, name,
- sizeof (name)) != PICL_SUCCESS) {
- return (PICL_WALK_CONTINUE);
- }
-
- if (strcmp(name, SANIBEL_PICLNODE_PARALLEL) == 0) {
- (void) strncpy(class, SANIBEL_PARALLEL_PORT, sizeof (class));
- }
-
- if (add_node2cache(nodeh, class, &cachep) != PICL_SUCCESS) {
- return (PICL_WALK_CONTINUE);
- }
-
- /* add cache to the linked list */
- if (cachep != NULL) {
- cachep->next = NULL;
- if (device->first == NULL) { /* 1st node */
- device->first = cachep;
- device->last = NULL;
-
- } else if (device->last != NULL) { /* last node */
- device->last->next = cachep;
- device->last = cachep;
-
- } else { /* 2nd node */
- device->first->next = cachep;
- device->last = cachep;
- }
- }
- return (PICL_WALK_CONTINUE);
-}
-
-/*
- * determine the state manager for this node
- */
-static picl_errno_t
-get_loc_type(frutree_locnode_t *locp)
-{
- picl_errno_t rc;
- cfga_list_data_t *list = NULL;
- char valbuf[PICL_PROPNAMELEN_MAX];
- char slot_type[PICL_PROPNAMELEN_MAX];
-
- if (locp->state_mgr != UNKNOWN)
- return (PICL_SUCCESS);
-
- rc = ptree_get_propval_by_name(locp->locnodeh, PICL_PROP_STATE,
- (void *)valbuf, PICL_PROPNAMELEN_MAX);
- if (rc == PICL_SUCCESS) { /* managed by platform specific plugin */
- locp->state_mgr = PLUGIN_PVT;
- return (PICL_SUCCESS);
- }
-
- /* get the info from the libcfgadm interface */
- list = (cfga_list_data_t *)malloc(sizeof (cfga_list_data_t));
- if (list == NULL) {
- return (PICL_NOSPACE);
- }
-
- if ((rc = get_cfgadm_state(list, locp->name)) == PICL_SUCCESS) {
- locp->state_mgr = CFGADM_AP;
- } else {
- if ((rc = ptree_get_propval_by_name(locp->locnodeh,
- PICL_PROP_SLOT_TYPE, slot_type,
- sizeof (slot_type))) != PICL_SUCCESS) {
- free(list);
- return (rc);
- }
- if (strcmp(slot_type, SANIBEL_SCSI_SLOT) == 0 ||
- strcmp(slot_type, SANIBEL_IDE_SLOT) == 0) {
- /*
- * for scsi locations, if cfgadm ap is
- * not present, then consider it as device
- * not present
- */
- locp->state_mgr = CFGADM_AP;
- } else {
- /*
- * devices like PMC card doesnt showup in cfgadm
- */
- locp->state_mgr = STATIC_LOC;
- }
- }
- free(list);
- return (PICL_SUCCESS);
-}
-
-/*
- * Initialize the location node.(create all the props)
- */
-static picl_errno_t
-location_init(frutree_locnode_t *locp)
-{
- picl_errno_t rc;
- boolean_t state_change;
- uint64_t ap_status_time = 0;
- char valbuf[PICL_PROPNAMELEN_MAX];
-
- /* check if it is a CPU location node or not */
- if (ptree_get_propval_by_name(locp->locnodeh, PICL_PROP_NAME,
- (void *)valbuf, PICL_PROPNAMELEN_MAX) == PICL_SUCCESS) {
- if (strncmp(valbuf, SANIBEL_PICLNODE_CPU,
- strlen(SANIBEL_PICLNODE_CPU)) == 0) {
- locp->cpu_node = B_TRUE;
- }
- }
- /*
- * Algorithm:
- * if "State" prop is already created (node is managed by other plugin)
- * does nothing
- * else if cfgadm ap is found
- * creates State prop and intializes it
- * else
- * find the nodes using libdevinfo under a given path
- * at given geoaddr
- * if node is found
- * mark node state a connected
- * else
- * mark node state a empty
- */
- (void) get_loc_type(locp);
- if (locp->state_mgr == PLUGIN_PVT) {
- (void) update_loc_state(locp, &state_change);
- return (PICL_SUCCESS);
- }
-
- if (locp->state_mgr == STATIC_LOC) {
- /*
- * in case of scsi locations,, loc state will be connected
- * no need to check again if the fru is present using libdevinfo
- */
- if (locp->state != LOC_STATE_CONNECTED) {
- if (is_fru_present_under_location(locp) == B_TRUE) {
- locp->state = LOC_STATE_CONNECTED;
- } else {
- locp->state = LOC_STATE_EMPTY;
- }
- }
- }
- /* create state property */
- if ((rc = create_property(PICL_PTYPE_CHARSTRING,
- PICL_READ + PICL_VOLATILE, PICL_PROPNAMELEN_MAX,
- PICL_PROP_STATE, get_loc_state, NULLWRITE, locp->locnodeh,
- NULL, loc_state[locp->state])) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(FRUTREE_INIT, PTREE_CREATE_PROP_FAILED,
- PICL_PROP_STATE, locp->name, rc);
- return (rc);
- }
- ap_status_time = (uint64_t)(time(NULL));
-
- /* create location StatusTime prop. */
- if ((rc = create_property(PICL_PTYPE_TIMESTAMP, PICL_READ,
- sizeof (uint64_t), PICL_PROP_STATUS_TIME, NULLREAD,
- NULLWRITE, locp->locnodeh, NULL, &ap_status_time)) !=
- PICL_SUCCESS) {
- FRUTREE_DEBUG3(FRUTREE_INIT, PTREE_CREATE_PROP_FAILED,
- PICL_PROP_STATUS_TIME, locp->name, rc);
- return (rc);
- }
-
- if ((rc = update_loc_state(locp, &state_change)) != PICL_SUCCESS) {
- FRUTREE_DEBUG2(FRUTREE_INIT, GET_LOC_STATE_ERR, locp->name, rc);
- return (rc);
- }
- return (PICL_SUCCESS);
-}
-
-static frutree_port_type_t
-frutree_get_port_type(frutree_portnode_t *portp)
-{
- char device_type[PICL_PROPNAMELEN_MAX];
- frutree_port_type_t port_type = UNKNOWN_PORT;
-
- if (portp == NULL) {
- return (port_type);
- }
-
- if (ptree_get_propval_by_name(portp->portnodeh,
- PICL_PROP_PORT_TYPE, device_type,
- sizeof (device_type)) == PICL_SUCCESS) {
- if (strcmp(device_type, SANIBEL_NETWORK_PORT) == 0) {
- port_type = NETWORK_PORT;
- } else if (strcmp(device_type,
- SANIBEL_SERIAL_PORT) == 0) {
- port_type = SERIAL_PORT;
- } else if (strcmp(device_type,
- SANIBEL_PARALLEL_PORT) == 0) {
- port_type = PARALLEL_PORT;
- }
- }
- return (port_type);
-}
-
-/* volatile callback function to get port condition */
-static int
-get_port_condition(ptree_rarg_t *rarg, void *buf)
-{
- picl_errno_t rc;
- hashdata_t *hashptr = NULL;
- frutree_portnode_t *portp = NULL;
- frutree_port_type_t port_type;
-
- if (buf == NULL) {
- return (PICL_INVALIDARG);
- }
-
- if ((rc = hash_lookup_entry(rarg->nodeh, (void **)&hashptr)) !=
- PICL_SUCCESS) {
- return (rc);
- }
-
- portp = PORTDATA_PTR(hashptr);
- if (portp == NULL) {
- return (PICL_FAILURE);
- }
- port_type = frutree_get_port_type(portp);
-
- if (port_type == UNKNOWN_PORT) {
- portp->cond = PORT_COND_UNKNOWN;
- (void) strncpy((char *)buf, port_cond[portp->cond],
- PICL_PROPNAMELEN_MAX);
- return (PICL_SUCCESS);
- }
-
- if ((rc = update_port_state(portp, B_TRUE)) != PICL_SUCCESS) {
- return (rc);
- }
-
- (void) strncpy((char *)buf, port_cond[portp->cond],
- PICL_PROPNAMELEN_MAX);
- return (PICL_SUCCESS);
-}
-
-/* volatile callback function to get port state */
-static int
-get_port_state(ptree_rarg_t *rarg, void *buf)
-{
- picl_errno_t rc;
- hashdata_t *hashptr = NULL;
- frutree_portnode_t *portp = NULL;
- frutree_port_type_t port_type;
-
- if (buf == NULL) {
- return (PICL_INVALIDARG);
- }
- if ((rc = hash_lookup_entry(rarg->nodeh, (void **)&hashptr)) !=
- PICL_SUCCESS) {
- return (rc);
- }
- portp = PORTDATA_PTR(hashptr);
- if (portp == NULL) {
- return (PICL_FAILURE);
- }
-
- port_type = frutree_get_port_type(portp);
- if (port_type == UNKNOWN_PORT) {
- portp->state = PORT_STATE_UNKNOWN;
- (void) strncpy((char *)buf, port_state[portp->state],
- PICL_PROPNAMELEN_MAX);
- return (PICL_SUCCESS);
- }
-
- if ((rc = update_port_state(portp, B_TRUE)) != PICL_SUCCESS) {
- return (rc);
- }
- (void) strncpy((char *)buf, port_state[portp->state],
- PICL_PROPNAMELEN_MAX);
- return (PICL_SUCCESS);
-}
-
-/*
- * Creates State and Condition property for a port node
- */
-static picl_errno_t
-port_init(frutree_portnode_t *portp)
-{
- picl_prophdl_t proph;
- ptree_propinfo_t propinfo;
- void *vbuf;
- picl_errno_t rc;
- uint64_t status_time;
- picl_nodehdl_t refhdl;
- frutree_device_args_t device;
- picl_prophdl_t tblprophdl, tblhdl;
- char class[PICL_PROPNAMELEN_MAX];
-
- if (portp == NULL) {
- return (PICL_FAILURE);
- }
- refhdl = get_reference_handle(portp->portnodeh);
-
- /* traverse thru platform tree and add entries to Devices table */
- if (refhdl != 0) {
- /* create Devices table property */
- if ((rc = create_property(PICL_PTYPE_TABLE, PICL_READ,
- sizeof (picl_prophdl_t), PICL_PROP_DEVICES,
- NULLREAD, NULLWRITE, portp->portnodeh, &tblprophdl,
- &tblhdl)) != PICL_SUCCESS) {
- return (rc);
- }
-
- /* walk down the subtree and populate Devices */
- if ((rc = ptree_get_propval_by_name(refhdl,
- PICL_PROP_CLASSNAME, class,
- sizeof (class))) != PICL_SUCCESS) {
- return (rc);
- }
- if ((rc = create_table_entry(tblhdl, refhdl, class)) !=
- PICL_SUCCESS) {
- return (rc);
- }
-
- device.nodeh = refhdl;
- device.device_tblhdl = tblhdl;
- device.first = NULL;
- device.last = NULL;
- device.create_cache = B_FALSE;
-
- if ((rc = do_action(refhdl, CREATE_DEVICES_ENTRIES,
- (void *)&device)) != PICL_SUCCESS) {
- return (rc);
- }
-
- if ((rc = ptree_get_prop_by_name(refhdl, PICL_PROP_INSTANCE,
- &proph)) != PICL_SUCCESS) {
- return (rc);
- }
- if ((rc = ptree_get_propinfo(proph, &propinfo)) !=
- PICL_SUCCESS) {
- return (rc);
- }
- vbuf = alloca(propinfo.piclinfo.size);
- if (vbuf == NULL)
- return (PICL_NOSPACE);
-
- if ((rc = ptree_get_propval(proph, vbuf,
- propinfo.piclinfo.size)) != PICL_SUCCESS) {
- return (rc);
- }
- portp->instance = *(int *)vbuf;
-
- if ((rc = ptree_get_prop_by_name(refhdl,
- PICL_PROP_DRIVER_NAME, &proph)) != PICL_SUCCESS) {
- return (rc);
- }
- if ((rc = ptree_get_propinfo(proph, &propinfo)) !=
- PICL_SUCCESS) {
- return (rc);
- }
- vbuf = alloca(propinfo.piclinfo.size);
- if (vbuf == NULL)
- return (PICL_NOSPACE);
-
- if ((rc = ptree_get_propval(proph, vbuf,
- propinfo.piclinfo.size)) != PICL_SUCCESS) {
- return (rc);
- }
-
- (void) strncpy(portp->driver, (char *)vbuf,
- sizeof (portp->driver));
- } else {
- /* this node is created using libdevinfo or conf file */
- if ((rc = get_port_info(portp)) != PICL_SUCCESS) {
- return (rc);
- }
- }
-
- /* create state and condition properties */
- if ((rc = create_property(PICL_PTYPE_CHARSTRING,
- PICL_READ | PICL_VOLATILE, PICL_PROPNAMELEN_MAX,
- PICL_PROP_STATE, get_port_state, NULLWRITE, portp->portnodeh,
- NULL, port_state[portp->state])) != PICL_SUCCESS) {
- return (rc);
- }
-
- status_time = (uint64_t)(time(NULL));
- if ((rc = create_property(PICL_PTYPE_TIMESTAMP, PICL_READ,
- sizeof (uint64_t), PICL_PROP_STATUS_TIME, NULLREAD,
- NULLWRITE, portp->portnodeh, NULL, &status_time)) !=
- PICL_SUCCESS) {
- return (rc);
- }
-
- if ((rc = create_property(PICL_PTYPE_CHARSTRING,
- PICL_READ | PICL_VOLATILE, PICL_PROPNAMELEN_MAX,
- PICL_PROP_CONDITION, get_port_condition, NULLWRITE,
- portp->portnodeh, NULL, port_cond[portp->cond])) !=
- PICL_SUCCESS) {
- return (rc);
- }
- if ((rc = create_property(PICL_PTYPE_TIMESTAMP, PICL_READ,
- sizeof (uint64_t), PICL_PROP_CONDITION_TIME, NULLREAD,
- NULLWRITE, portp->portnodeh, NULL, &status_time)) !=
- PICL_SUCCESS) {
- return (rc);
- }
- (void) update_port_state(portp, B_FALSE);
- return (PICL_SUCCESS);
-}
-
-/*
- * This routine dynamically determines the scsi name (using libcfgadm)
- * that corresponds to the node specified in configuration file
- */
-static picl_errno_t
-init_scsi_slot(frutree_frunode_t *frup, frutree_locnode_t **ptr2locp,
- boolean_t *node_name_changed)
-{
- picl_errno_t rc;
- char devfs_path[PICL_PROPNAMELEN_MAX];
- char bus_addr[PICL_PROPNAMELEN_MAX];
- char label[PICL_PROPNAMELEN_MAX];
- char name[MAXPATHLEN];
- uint8_t geo_addr = 0;
- frutree_locnode_t *locp = NULL, *new_locp = NULL;
- hashdata_t *hashptr = NULL;
- picl_nodehdl_t nodeh;
-
- if (ptr2locp == NULL) {
- return (PICL_INVALIDARG);
- }
- locp = (frutree_locnode_t *)*ptr2locp;
- *node_name_changed = B_FALSE;
-
- if (locp == NULL) {
- return (PICL_FAILURE);
- }
-
- if ((rc = ptree_get_propval_by_name(locp->locnodeh,
- PICL_PROP_DEVFS_PATH, devfs_path,
- sizeof (devfs_path))) != PICL_SUCCESS) {
- return (rc);
- }
-
- if ((rc = ptree_get_propval_by_name(locp->locnodeh,
- PICL_PROP_BUS_ADDR, bus_addr,
- sizeof (bus_addr))) != PICL_SUCCESS) {
- return (rc);
- }
-
- /* find the dynamic ap_id from libcfgadm */
- if ((rc = get_scsislot_name(devfs_path, bus_addr,
- name)) != PICL_SUCCESS) {
- /* if rc is NODENOTFOUND, then slot is empty */
- if (rc != PICL_NODENOTFOUND) {
- return (rc);
- } else {
- return (PICL_SUCCESS);
- }
- }
-
- /* node name is same, so dont change anything */
- if (strcmp(name, locp->name) == 0) {
- return (PICL_SUCCESS);
- }
-
- if ((rc = ptree_get_propval_by_name(locp->locnodeh,
- PICL_PROP_GEO_ADDR, &geo_addr,
- sizeof (geo_addr))) != PICL_SUCCESS) {
- geo_addr = 0;
- }
-
- if ((rc = ptree_get_propval_by_name(locp->locnodeh,
- PICL_PROP_LABEL, label,
- sizeof (label))) != PICL_SUCCESS) {
- return (rc);
- }
-
- /* Now recreate the node with new name */
- if ((rc = ptree_create_node(name, PICL_CLASS_LOCATION,
- &nodeh)) != PICL_SUCCESS) {
- return (rc);
- }
-
- /* add all the properties now */
- (void) create_property(PICL_PTYPE_CHARSTRING, PICL_READ,
- PICL_PROPNAMELEN_MAX, PICL_PROP_SLOT_TYPE, NULLREAD,
- NULLWRITE, nodeh, (picl_prophdl_t *)NULL,
- SANIBEL_SCSI_SLOT);
-
- (void) create_property(PICL_PTYPE_CHARSTRING, PICL_READ,
- PICL_PROPNAMELEN_MAX, PICL_PROP_LABEL, NULLREAD,
- NULLWRITE, nodeh, (picl_prophdl_t *)NULL,
- label);
-
- (void) create_property(PICL_PTYPE_CHARSTRING, PICL_READ,
- PICL_PROPNAMELEN_MAX, PICL_PROP_BUS_ADDR, NULLREAD,
- NULLWRITE, nodeh, (picl_prophdl_t *)NULL,
- bus_addr);
-
- (void) create_property(PICL_PTYPE_UNSIGNED_INT, PICL_READ,
- sizeof (uint8_t), PICL_PROP_GEO_ADDR, NULLREAD,
- NULLWRITE, nodeh, (picl_prophdl_t *)NULL,
- &geo_addr);
-
- (void) create_property(PICL_PTYPE_CHARSTRING, PICL_READ,
- PICL_PROPNAMELEN_MAX, PICL_PROP_DEVFS_PATH, NULLREAD,
- NULLWRITE, nodeh, (picl_prophdl_t *)NULL,
- devfs_path);
- (void) ptree_add_node(frup->frunodeh, nodeh);
-
- if ((rc = make_loc_data(name, &hashptr)) != PICL_SUCCESS) {
- return (rc);
- }
- /* save data in hash table */
- if ((rc = hash_add_entry(nodeh, (void *)hashptr)) != PICL_SUCCESS) {
- free_data(hashptr->type, hashptr);
- return (rc);
- }
-
- new_locp = LOCDATA_PTR(hashptr);
- new_locp->locnodeh = nodeh;
- *ptr2locp = new_locp;
- *node_name_changed = B_TRUE;
- return (PICL_SUCCESS);
-}
-
-/*
- * find the child nodes under a fru and initialize them
- */
-static int
-frutree_initialize_children(picl_nodehdl_t childh, void *c_args)
-{
- picl_errno_t rc;
- picl_nodehdl_t parenth;
- boolean_t node_changed = B_FALSE;
- hashdata_t *datap = NULL;
- char name[PICL_PROPNAMELEN_MAX];
- char class[PICL_PROPNAMELEN_MAX];
- frutree_frunode_t *frup = NULL;
- frutree_init_callback_arg_t *arg;
-
- if (c_args == NULL) {
- return (PICL_INVALIDARG);
- }
- arg = (frutree_init_callback_arg_t *)c_args;
- frup = arg->frup;
-
- if ((rc = ptree_get_propval_by_name(childh, PICL_PROP_PARENT,
- &parenth, sizeof (parenth))) != PICL_SUCCESS) {
- return (rc);
- }
-
- if (parenth != frup->frunodeh)
- return (PICL_WALK_CONTINUE);
-
- if ((rc = ptree_get_propval_by_name(childh, PICL_PROP_CLASSNAME, class,
- sizeof (class))) != PICL_SUCCESS) {
- return (rc);
- }
-
- if ((rc = ptree_get_propval_by_name(childh, PICL_PROP_NAME, name,
- sizeof (name))) != PICL_SUCCESS) {
- return (rc);
- }
-
- if (strcmp(class, PICL_CLASS_LOCATION) == 0) {
- char slot_type[PICL_PROPNAMELEN_MAX];
- frutree_locnode_t *locp = NULL;
- frutree_frunode_t *child_frup = NULL;
- /* initialize internal data structure */
- if ((rc = make_loc_data(name, &datap)) != PICL_SUCCESS) {
- return (PICL_WALK_CONTINUE);
- }
- locp = LOCDATA_PTR(datap);
- locp->locnodeh = childh;
- /* save data in hash table */
- (void) hash_add_entry(childh, (void *)datap);
- if ((rc = ptree_get_propval_by_name(locp->locnodeh,
- PICL_PROP_SLOT_TYPE, slot_type,
- sizeof (slot_type))) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(FRUTREE_INIT, PTREE_GET_PROPVAL_ERR,
- PICL_PROP_SLOT_TYPE, locp->name, rc);
- return (PICL_WALK_CONTINUE);
- } else {
- if (strcmp(slot_type, SANIBEL_SCSI_SLOT) == 0 ||
- strcmp(slot_type, SANIBEL_IDE_SLOT) == 0) {
- /*
- * this rountine finds the valid cfgadm
- * ap_id name for a given node and
- * creates a new node with that name.
- * If the node name is changed, the present
- * node must be added to the list of nodes
- * to be deleted from tree after ptree walk.
- */
- (void) init_scsi_slot(frup, &locp,
- &node_changed);
- if (node_changed) {
- delete_list_t *nodep = NULL;
- /*
- * add this node to list of nodes
- * to be removed
- */
- nodep = (delete_list_t *)malloc(
- sizeof (delete_list_t));
- if (nodep == NULL) {
- return (PICL_NOSPACE);
- }
- nodep->nodeh = childh;
- nodep->next = NULL;
-
- if (arg->first == NULL) {
- arg->first = nodep;
- } else { /* add 2 front */
- nodep->next = arg->first;
- arg->first = nodep;
- }
- }
- }
- }
- if ((rc = location_init(locp)) != PICL_SUCCESS) {
- return (PICL_WALK_CONTINUE);
- }
-
- /* if location is empty, done */
- if (locp->state == LOC_STATE_EMPTY ||
- locp->state == LOC_STATE_UNKNOWN) {
- return (PICL_WALK_CONTINUE);
- }
-
- /* create the fru node and initialize it */
- if ((rc = create_fru_node(locp, &child_frup)) !=
- PICL_SUCCESS) {
- return (PICL_WALK_CONTINUE);
- }
-
- /*
- * if fru is already configured, create the
- * subtree under the child fru
- */
- if (child_frup->state == FRU_STATE_CONFIGURED) {
- /* initialize the fru_path */
- if ((rc = probe_fru(child_frup, B_TRUE)) !=
- PICL_SUCCESS) {
- FRUTREE_DEBUG2(EVENTS, PROBE_FRU_ERR,
- child_frup->name, rc);
- }
- }
- } else if (strcmp(class, PICL_CLASS_PORT) == 0) {
- frutree_portnode_t *portp = NULL;
- if ((rc = make_port_data(name, &datap)) != PICL_SUCCESS) {
- return (PICL_WALK_CONTINUE);
- }
- (void) hash_add_entry(childh, (void *)datap);
- portp = PORTDATA_PTR(datap);
- portp->portnodeh = childh;
- (void) port_init(portp);
- }
- return (PICL_WALK_CONTINUE);
-}
-
-/* traverse thru all locations under fru and initiate connects */
-static int
-initiate_connects(picl_nodehdl_t nodeh, void *args)
-{
- picl_errno_t rc;
- hashdata_t *hashptr = NULL;
- picl_nodehdl_t parenth;
- frutree_frunode_t *frup = NULL;
- frutree_locnode_t *locp = NULL;
-
- if (args == NULL) {
- return (PICL_INVALIDARG);
- }
- frup = (frutree_frunode_t *)args;
-
- if ((rc = ptree_get_propval_by_name(nodeh, PICL_PROP_PARENT,
- &parenth, sizeof (parenth))) != PICL_SUCCESS) {
- return (rc);
- }
-
- if (parenth != frup->frunodeh)
- return (PICL_WALK_CONTINUE);
-
- if ((rc = hash_lookup_entry(nodeh, (void **)&hashptr)) !=
- PICL_SUCCESS) {
- return (PICL_WALK_CONTINUE);
- }
- locp = LOCDATA_PTR(hashptr);
-
- if (locp->state == LOC_STATE_EMPTY ||
- locp->state == LOC_STATE_UNKNOWN ||
- locp->state == LOC_STATE_CONNECTED) {
- return (PICL_WALK_CONTINUE);
- }
-
- /* if loc is not connected, do a connect operation */
- if (locp->autoconfig_enabled) {
- if ((rc = connect_fru(locp)) != PICL_SUCCESS) {
- FRUTREE_DEBUG2(EVENTS, CONNECT_FAILED_ERR,
- locp->name, rc);
- }
- }
- return (PICL_WALK_CONTINUE);
-}
-
-/*
- * Initializes the subtree under a FRU
- */
-static picl_errno_t
-fru_init(frutree_frunode_t *frup)
-{
- picl_errno_t rc;
- delete_list_t *tmp = NULL, *curr = NULL;
- frutree_init_callback_arg_t arg;
-
- if (frup == NULL) {
- return (PICL_INVALIDARG);
- }
-
- arg.frup = frup;
- arg.first = NULL;
-
- /*
- * this routine creates internal data structures for
- * all the children under this fru and initializes them
- */
- if ((rc = do_action(frup->frunodeh, INIT_FRU,
- (void *)&arg)) != PICL_SUCCESS) {
- return (rc);
- }
-
- /* traverse thru delete_nodes_list and delete the nodes from tree */
- curr = arg.first;
- while (curr) {
- tmp = curr;
- (void) ptree_delete_node(tmp->nodeh);
- (void) ptree_destroy_node(tmp->nodeh);
- (void) hash_remove_entry(tmp->nodeh);
- free(tmp);
- curr = curr->next;
- }
-
- /*
- * dont post events during intialization (for other FRUs)
- * chassis intialization will take care of posting events
- * for complete frutree
- */
- if ((frup->frunodeh == chassish) ||
- (post_picl_events == B_TRUE)) {
- if ((rc = do_action(frup->frunodeh, POST_EVENTS, NULL)) !=
- PICL_SUCCESS) {
- FRUTREE_DEBUG1(LOG_ERR, "SUNW_frutree:Error in "
- "posting picl events(error=%d)", rc);
- }
- }
-
- if (frup->frunodeh == chassish) {
- post_picl_events = B_TRUE;
- frutree_connects_initiated = B_TRUE;
- }
-
- /* initiate connects */
- if ((rc = ptree_walk_tree_by_class(frup->frunodeh, PICL_CLASS_LOCATION,
- (void *)frup, initiate_connects)) != PICL_SUCCESS) {
- return (rc);
- }
- return (PICL_SUCCESS);
-}
-
-/*ARGSUSED*/
-static int
-post_events(picl_nodehdl_t childh, void *c_args)
-{
- int rc;
- hashdata_t *hashptr = NULL;
- frutree_frunode_t *frup = NULL;
- frutree_locnode_t *locp = NULL;
- frutree_portnode_t *portp = NULL;
- char classval[PICL_CLASSNAMELEN_MAX];
-
- if ((rc = ptree_get_propval_by_name(childh, PICL_PROP_CLASSNAME,
- classval, sizeof (classval))) != PICL_SUCCESS) {
- return (PICL_WALK_CONTINUE);
- }
-
- if ((rc = hash_lookup_entry(childh, (void **)&hashptr)) !=
- PICL_SUCCESS) {
- return (PICL_WALK_CONTINUE);
- }
-
- if (strcmp(classval, PICL_CLASS_LOCATION) == 0) {
- locp = LOCDATA_PTR(hashptr);
- if ((rc = post_piclevent(PICLEVENT_STATE_CHANGE,
- loc_state[locp->state], loc_state[locp->prev_state],
- childh, WAIT)) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_POST_PICLEVENT_ERR,
- locp->name, PICLEVENT_STATE_CHANGE, rc);
- }
- return (PICL_WALK_CONTINUE);
- }
-
- if (strcmp(classval, PICL_CLASS_FRU) == 0) {
- frup = FRUDATA_PTR(hashptr);
- if ((rc = post_piclevent(PICLEVENT_STATE_CHANGE,
- fru_state[frup->state], fru_state[frup->prev_state],
- childh, WAIT)) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_POST_PICLEVENT_ERR,
- frup->name, PICLEVENT_STATE_CHANGE, rc);
- }
- if ((rc = post_piclevent(PICLEVENT_CONDITION_CHANGE,
- fru_cond[frup->cond], fru_cond[frup->prev_cond],
- frup->frunodeh, WAIT)) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_POST_PICLEVENT_ERR,
- frup->name, PICLEVENT_CONDITION_CHANGE, rc);
- }
- return (PICL_WALK_CONTINUE);
- }
-
- if (strcmp(classval, PICL_CLASS_PORT) == 0) {
- portp = PORTDATA_PTR(hashptr);
- if ((rc = post_piclevent(PICLEVENT_STATE_CHANGE,
- port_state[portp->state], NULL,
- portp->portnodeh, WAIT)) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_POST_PICLEVENT_ERR,
- portp->name, PICLEVENT_STATE_CHANGE, rc);
- }
- if ((rc = post_piclevent(PICLEVENT_CONDITION_CHANGE,
- port_cond[portp->cond], NULL,
- portp->portnodeh, WAIT)) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_POST_PICLEVENT_ERR,
- portp->name, PICLEVENT_CONDITION_CHANGE, rc);
- }
- return (PICL_WALK_CONTINUE);
- }
- return (PICL_WALK_CONTINUE);
-}
-
-/*
- * This function is a utility function that calls the
- * appropriate call back function for the all the nodes under
- * the specified root node.
- * future additions can be done by defining new action and callback.
- */
-static picl_errno_t
-do_action(picl_nodehdl_t root, int action, void *cargs)
-{
- int rc;
- callback_t func_ptr;
- char *class = NULL;
-
- switch (action) {
-
- case INIT_FRU:
- func_ptr = frutree_initialize_children;
- class = NULL;
- break;
- case CREATE_DEVICES_ENTRIES:
- func_ptr = create_device_entries;
- class = NULL;
- break;
- case POST_EVENTS:
- func_ptr = post_events;
- class = NULL;
- break;
- default:
- return (PICL_INVALIDARG);
- }
-
- if ((rc = ptree_walk_tree_by_class(root, class, cargs,
- func_ptr)) != PICL_SUCCESS) {
- return (rc);
- }
- return (PICL_SUCCESS);
-}
-
-static picl_errno_t
-frutree_update_chassis_state(frutree_frustate_t state,
- frutree_frustate_t prev_state)
-{
- uint64_t ap_status_time;
- picl_errno_t rc = 0;
- char present_state[PICL_PROPNAMELEN_MAX];
-
- (void) strncpy(present_state, fru_state[state], sizeof (present_state));
- (void) ptree_update_propval_by_name(chassish,
- PICL_PROP_STATE, present_state, sizeof (present_state));
-
- ap_status_time = (uint64_t)(time(NULL));
- if ((rc = ptree_update_propval_by_name(chassish,
- PICL_PROP_STATUS_TIME, (void *)&ap_status_time,
- sizeof (ap_status_time))) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_UPDATE_PROP_ERR,
- PICL_PROP_STATUS_TIME, PICL_NODE_CHASSIS, rc);
- }
- if ((rc = post_piclevent(PICLEVENT_STATE_CHANGE,
- fru_state[state], fru_state[prev_state],
- chassish, WAIT)) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_POST_PICLEVENT_ERR,
- PICL_NODE_CHASSIS, PICLEVENT_STATE_CHANGE, rc);
- }
- return (PICL_SUCCESS);
-}
-
-static picl_errno_t
-frutree_init()
-{
- picl_errno_t rc;
- frutree_frunode_t *frup = NULL;
- hashdata_t *hashptr = NULL;
-
- if ((rc = ptree_get_node_by_path(PLATFORM_PATH, &platformh)) !=
- PICL_SUCCESS) {
- return (rc);
- }
-
- if ((rc = hash_lookup_entry(chassish, (void **)&hashptr)) !=
- PICL_SUCCESS) {
- return (rc);
- }
- frup = FRUDATA_PTR(hashptr);
-
- /* create the nodes in conf file under chassis node */
- if ((rc = picld_pluginutil_parse_config_file(chassish,
- conf_file)) != PICL_SUCCESS) {
- /* update chassis state to unconfigured */
- (void) frutree_update_chassis_state(
- FRU_STATE_UNCONFIGURED, FRU_STATE_UNKNOWN);
- return (rc);
- }
-
- /* update chassis state to configuring */
- (void) frutree_update_chassis_state(
- FRU_STATE_CONFIGURING, FRU_STATE_UNCONFIGURED);
-
- if (scsi_info_init() != PICL_SUCCESS) {
- /* update chassis state to unconfigured */
- (void) frutree_update_chassis_state(
- FRU_STATE_UNCONFIGURED, FRU_STATE_CONFIGURING);
- return (PICL_FAILURE);
- }
-
- /* traverse thru all the nodes under chassis, initialize them */
- if ((rc = fru_init(frup)) != PICL_SUCCESS) {
- /* update chassis state to unconfigured */
- (void) frutree_update_chassis_state(
- FRU_STATE_UNCONFIGURED, FRU_STATE_CONFIGURING);
- scsi_info_fini();
- return (rc);
- }
- /* free the memory used during initialization */
- scsi_info_fini();
- /* start node monitoring thread */
- if (pthread_create(&monitor_tid, NULL, monitor_node_status,
- NULL) != 0) {
- FRUTREE_DEBUG0(EVENTS, "SUNW_frutree:Error in creating node"
- " monitoring thread");
- }
-
- (void) pthread_mutex_lock(&frup->mutex);
- frup->state = FRU_STATE_CONFIGURED;
- (void) pthread_mutex_unlock(&frup->mutex);
-
- /* update chassis state to configured */
- (void) frutree_update_chassis_state(
- FRU_STATE_CONFIGURED, FRU_STATE_CONFIGURING);
- return (PICL_SUCCESS);
-}
-
-/* ARGSUSED */
-static void *
-init_thread(void *arg)
-{
- picl_errno_t rc;
-
- FRUTREE_DEBUG0(FRUTREE_INIT, "init_thread begin");
-
- (void) pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
- (void) pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
-
- if (get_configuration_file() != PICL_SUCCESS) {
- return (NULL);
- }
- FRUTREE_DEBUG1(FRUTREE_INIT, "conf_file = %s", conf_file);
- if ((rc = frutree_init()) != PICL_SUCCESS) {
- FRUTREE_DEBUG1(FRUTREE_INIT, "frutree_init failed, error = %d",
- rc);
- }
- FRUTREE_DEBUG0(FRUTREE_INIT, "init_thread end");
- return (NULL);
-}
-
-/* ARGSUSED */
-static void
-event_completion_handler(char *ename, void *earg, size_t size)
-{
- if (frutree_debug & EV_COMPLETION) {
- char name[PICL_PROPNAMELEN_MAX];
- nvlist_t *nvlp;
- char *value = NULL;
- char *arg = NULL;
- picl_nodehdl_t fruhdl;
- time_t current_time;
-
- if (strncmp(ename, PICLEVENT_STATE_CHANGE,
- strlen(PICLEVENT_STATE_CHANGE)) == 0) {
- arg = PICLEVENTARG_STATE;
- } else if (strncmp(ename, PICLEVENT_CONDITION_CHANGE,
- strlen(PICLEVENT_CONDITION_CHANGE)) == 0) {
- arg = PICLEVENTARG_CONDITION;
- }
-
- (void) nvlist_unpack((char *)earg, size, &nvlp, NULL);
- (void) nvlist_lookup_uint64(nvlp, PICLEVENTARG_NODEHANDLE,
- &fruhdl);
- if (arg != NULL)
- (void) nvlist_lookup_string(nvlp, arg, &value);
-
- (void) ptree_get_propval_by_name(fruhdl, PICL_PROP_NAME,
- (void *)name, sizeof (name));
- current_time = (uint64_t)(time(NULL));
- if (value != NULL) {
- FRUTREE_DEBUG4(EV_COMPLETION, "ev_completed[%s]%s(%s) "
- "on %s", ctime(&current_time), ename, value, name);
- }
- nvlist_free(nvlp);
- }
-
- (void) mutex_lock(&piclevent_mutex);
- piclevent_pending = 0;
- (void) cond_broadcast(&piclevent_completed_cv);
- (void) mutex_unlock(&piclevent_mutex);
- free(earg);
- free(ename);
-}
-
-picl_errno_t
-post_piclevent(const char *event, char *val1,
- char *val2, picl_nodehdl_t nodeh, frutree_wait_t wait)
-{
- nvlist_t *nvl;
- size_t nvl_size;
- char *pack_buf = NULL;
- char *ename = NULL;
- char *arg = NULL;
- picl_errno_t rc;
- timestruc_t to;
- struct timeval tp;
-
- if (event == NULL || val1 == NULL) {
- return (PICL_INVALIDARG);
- }
- if (nvlist_alloc(&nvl, NV_UNIQUE_NAME_TYPE, NULL)) {
- return (PICL_FAILURE);
- }
- if (nvlist_add_uint64(nvl, PICLEVENTARG_NODEHANDLE, nodeh)) {
- nvlist_free(nvl);
- return (PICL_FAILURE);
- }
-
- if ((ename = strdup(event)) == NULL) {
- nvlist_free(nvl);
- return (PICL_NOSPACE);
- }
-
- if (strncmp(ename, PICLEVENT_STATE_CHANGE,
- strlen(PICLEVENT_STATE_CHANGE)) == 0) {
- arg = PICLEVENTARG_STATE;
- } else if (strncmp(ename, PICLEVENT_CONDITION_CHANGE,
- strlen(PICLEVENT_CONDITION_CHANGE)) == 0) {
- arg = PICLEVENTARG_CONDITION;
- } else {
- free(ename);
- nvlist_free(nvl);
- return (PICL_INVALIDARG);
- }
-
- if (nvlist_add_string(nvl, arg, val1)) {
- free(ename);
- nvlist_free(nvl);
- return (PICL_FAILURE);
- }
-
- if (strncmp(ename, PICLEVENT_CONDITION_CHANGE,
- strlen(PICLEVENT_CONDITION_CHANGE)) == 0) {
- if (nvlist_pack(nvl, &pack_buf, &nvl_size, NV_ENCODE_NATIVE,
- NULL)) {
- free(ename);
- nvlist_free(nvl);
- return (PICL_FAILURE);
- }
- } else { /* state change event */
-
- if (val2 != NULL) {
- /* if there is a last state, add it to nvlist */
- if (nvlist_add_string(nvl,
- PICLEVENTARG_LAST_STATE, val2)) {
- free(ename);
- nvlist_free(nvl);
- return (PICL_FAILURE);
- }
- }
- }
-
- if (nvlist_pack(nvl, &pack_buf, &nvl_size, NV_ENCODE_NATIVE, NULL)) {
- free(ename);
- nvlist_free(nvl);
- return (PICL_FAILURE);
- }
-
- (void) mutex_lock(&piclevent_mutex);
- while (piclevent_pending) {
- (void) cond_wait(&piclevent_completed_cv,
- &piclevent_mutex);
- }
- piclevent_pending = 1;
- (void) mutex_unlock(&piclevent_mutex);
-
- if ((rc = ptree_post_event(ename, pack_buf, nvl_size,
- event_completion_handler)) != PICL_SUCCESS) {
- free(ename);
- free(pack_buf);
- nvlist_free(nvl);
- (void) mutex_lock(&piclevent_mutex);
- piclevent_pending = 0;
- (void) mutex_unlock(&piclevent_mutex);
- return (rc);
- }
-
- if (frutree_debug) {
- char name[PICL_PROPNAMELEN_MAX];
- (void) ptree_get_propval_by_name(nodeh, PICL_PROP_NAME,
- name, sizeof (name));
- if (val2 != NULL) {
- FRUTREE_DEBUG4(EVENTS, "%s(%s -> %s) on %s", ename,
- val2, val1, name);
- } else {
- FRUTREE_DEBUG3(EVENTS, "%s(%s) on %s", ename,
- val1, name);
- }
- }
-
- if (wait) { /* wait for the event to be handled */
- (void) mutex_lock(&piclevent_mutex);
- while (piclevent_pending) {
- (void) gettimeofday(&tp, NULL);
- to.tv_sec = tp.tv_sec + 1;
- to.tv_nsec = tp.tv_usec * 1000;
- (void) cond_timedwait(&piclevent_completed_cv,
- &piclevent_mutex, &to);
- }
- (void) mutex_unlock(&piclevent_mutex);
- }
- nvlist_free(nvl);
- return (PICL_SUCCESS);
-}
-
-/*
- * return values
- * -1 : error
- * 0 : not enabled
- * 1 : enabled
- */
-/* ARGSUSED */
-static int
-is_autoconfig_enabled(char *loc_name)
-{
- return (1);
-}
-
-static picl_errno_t
-update_loc_type(frutree_locnode_t *locp)
-{
- cfga_list_data_t *list = NULL;
- /* get the info from the libcfgadm interface */
- list = (cfga_list_data_t *)malloc(sizeof (cfga_list_data_t));
- if (list == NULL) {
- return (PICL_NOSPACE);
- }
-
- if (get_cfgadm_state(list, locp->name) == PICL_SUCCESS) {
- locp->state_mgr = CFGADM_AP;
- free(list);
- return (PICL_SUCCESS);
- }
- free(list);
- return (PICL_NODENOTFOUND);
-}
-
-/*
- * handles DR_INCOMING_RES on chassis node
- * (refresh piclfrutree tree)
- */
-static int
-reconfigure_chassis(picl_nodehdl_t nodeh, void *args)
-{
- picl_errno_t rc;
- hashdata_t *hashptr = NULL;
- picl_nodehdl_t parenth, childh;
- frutree_frunode_t *frup = NULL, *child_frup = NULL;
- frutree_locnode_t *locp = NULL;
- boolean_t state_changed = B_FALSE;
- boolean_t cond_changed = B_FALSE;
- frutree_dr_arg_t dr_arg;
-
- if (args == NULL) {
- return (PICL_INVALIDARG);
- }
- frup = (frutree_frunode_t *)args;
-
- if ((rc = ptree_get_propval_by_name(nodeh, PICL_PROP_PARENT,
- &parenth, sizeof (parenth))) != PICL_SUCCESS) {
- return (rc);
- }
-
- if (parenth != frup->frunodeh)
- return (PICL_WALK_CONTINUE);
-
- if ((rc = hash_lookup_entry(nodeh, (void **)&hashptr)) !=
- PICL_SUCCESS) {
- return (PICL_WALK_CONTINUE);
- }
- locp = LOCDATA_PTR(hashptr);
-
- /* if the location has child fru, get its information */
- if (ptree_get_propval_by_name(nodeh, PICL_PROP_CHILD,
- &childh, sizeof (childh)) == PICL_SUCCESS) {
- /* get the child fru information */
- if (hash_lookup_entry(childh, (void **)&hashptr) ==
- PICL_SUCCESS) {
- child_frup = FRUDATA_PTR(hashptr);
- }
- }
-
- /* for each location, update the state */
- if (locp->state_mgr == STATIC_LOC) {
- /* check if cfgadm ap_id is present */
- rc = update_loc_type(locp);
- if (rc == PICL_SUCCESS) {
- if (child_frup) {
- child_frup->state_mgr = locp->state_mgr;
- (void) update_fru_state(child_frup,
- &state_changed);
- }
- }
- }
-
- state_changed = B_FALSE;
- (void) update_loc_state(locp, &state_changed);
- if (state_changed) {
- switch (locp->state) {
- case LOC_STATE_CONNECTED:
- case LOC_STATE_DISCONNECTED:
- if (locp->prev_state == LOC_STATE_EMPTY ||
- locp->prev_state == LOC_STATE_UNKNOWN) {
- /* handle fru insertion */
- dr_arg.action = HANDLE_INSERT;
- } else {
- /* handle loc state change */
- dr_arg.action = HANDLE_LOCSTATE_CHANGE;
- }
- break;
- case LOC_STATE_EMPTY:
- /* handle fru removal */
- if (locp->prev_state == LOC_STATE_UNKNOWN) {
- /* post piclevent to update led */
- dr_arg.action = HANDLE_LOCSTATE_CHANGE;
- } else {
- /* disconnected fru is removed */
- dr_arg.action = HANDLE_REMOVE;
- }
- break;
- default:
- return (PICL_WALK_CONTINUE);
- } /* end of switch */
-
- dr_arg.data = locp;
- (void) pthread_mutex_lock(&ev_mutex);
- if ((rc = add_to_queue(dr_arg)) != PICL_SUCCESS) {
- (void) pthread_mutex_unlock(&ev_mutex);
- return (PICL_WALK_CONTINUE);
- }
- (void) pthread_cond_signal(&ev_cond);
- (void) pthread_mutex_unlock(&ev_mutex);
- return (PICL_WALK_CONTINUE);
- } else {
- /* connect the disconnect locations */
- if (locp->state == LOC_STATE_DISCONNECTED &&
- locp->autoconfig_enabled == B_TRUE) {
- if ((rc = connect_fru(locp)) != PICL_SUCCESS) {
- FRUTREE_DEBUG2(EVENTS, CONNECT_FAILED_ERR,
- locp->name, rc);
- }
- return (PICL_WALK_CONTINUE);
- }
- }
-
- /* post picl event for child fru */
- if (child_frup == NULL) {
- return (PICL_WALK_CONTINUE);
- }
-
- /* update the state */
- (void) update_fru_state(child_frup, &state_changed);
- if (state_changed) {
- if ((rc = post_piclevent(PICLEVENT_STATE_CHANGE,
- fru_state[child_frup->state],
- fru_state[child_frup->prev_state],
- child_frup->frunodeh, WAIT)) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_POST_PICLEVENT_ERR,
- child_frup->name, PICLEVENT_STATE_CHANGE, rc);
- }
- }
-
- /* update the condition */
- (void) update_fru_condition(child_frup, &cond_changed);
- if (cond_changed) {
- if ((rc = post_piclevent(PICLEVENT_CONDITION_CHANGE,
- fru_cond[child_frup->cond],
- fru_cond[child_frup->prev_cond],
- child_frup->frunodeh, WAIT)) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_POST_PICLEVENT_ERR,
- child_frup->name, PICLEVENT_CONDITION_CHANGE,
- rc);
- }
- }
- return (PICL_WALK_CONTINUE);
-}
-
-static picl_errno_t
-handle_chassis_configure(frutree_frunode_t *frup)
-{
- picl_errno_t rc;
-
- if (frup == NULL) {
- return (PICL_INVALIDARG);
- }
-
- (void) pthread_mutex_lock(&frup->mutex);
- FRUTREE_DEBUG1(EVENTS, "DR_INCOMING_RES on %s", frup->name);
- if (frup->state == FRU_STATE_UNCONFIGURED) {
- frup->state = FRU_STATE_CONFIGURING;
- (void) pthread_mutex_unlock(&frup->mutex);
- /* initial probe/initialization */
- /* create a thread to do the initialization */
- if (pthread_create(&init_threadID, NULL, &init_thread,
- NULL) != 0) {
- return (PICL_FAILURE);
- }
- return (PICL_SUCCESS);
- }
- (void) pthread_mutex_unlock(&frup->mutex);
-
- /*
- * 1. update the state of all the nodes in chassis
- * 2. handle all the state changes accordingly
- */
- if ((rc = ptree_walk_tree_by_class(chassish, PICL_CLASS_LOCATION,
- (void *)frup, reconfigure_chassis)) != PICL_SUCCESS) {
- return (rc);
- }
- return (PICL_SUCCESS);
-}
-
-static picl_errno_t
-handle_chassis_unconfigure(frutree_frunode_t *frup)
-{
- picl_errno_t rc;
-
- if (frup->state == FRU_STATE_UNCONFIGURED) {
- return (PICL_SUCCESS);
- }
-
- /* do any cleanups here */
- if ((rc = post_piclevent(PICLEVENT_STATE_CHANGE,
- PICLEVENTARGVAL_UNCONFIGURING, PICLEVENTARGVAL_CONFIGURED,
- chassish, WAIT)) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_POST_PICLEVENT_ERR,
- PICL_NODE_CHASSIS, PICLEVENT_STATE_CHANGE, rc);
- }
-
- if ((rc = ptree_update_propval_by_name(chassish,
- PICL_PROP_STATE, PICLEVENTARGVAL_UNCONFIGURED,
- PICL_PROPNAMELEN_MAX)) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_UPDATE_PROP_ERR,
- PICL_PROP_STATE, PICL_NODE_CHASSIS, rc);
- }
- frup->prev_state = FRU_STATE_CONFIGURED;
- frup->state = FRU_STATE_UNCONFIGURED;
- (void) handle_fru_unconfigure(frup);
-
- if ((rc = post_piclevent(PICLEVENT_STATE_CHANGE,
- PICLEVENTARGVAL_UNCONFIGURED, PICLEVENTARGVAL_UNCONFIGURING,
- chassish, WAIT)) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_POST_PICLEVENT_ERR,
- PICL_NODE_CHASSIS, PICLEVENT_STATE_CHANGE, rc);
- }
- return (PICL_SUCCESS);
-}
-
-static picl_errno_t
-configuration_fn(frutree_dr_arg_t *dr_arg)
-{
- picl_errno_t rc;
- picl_nodehdl_t parenth;
- cfga_flags_t flags = 0;
- frutree_frunode_t *frup = NULL;
- frutree_locnode_t *locp = NULL;
- hashdata_t *hashptr = NULL;
- boolean_t state_changed = B_FALSE;
-
- if (dr_arg == NULL)
- return (PICL_FAILURE);
-
- frup = (frutree_frunode_t *)dr_arg->data;
- if (frup == NULL) {
- free(dr_arg);
- return (PICL_FAILURE);
- }
-
- if (frup->frunodeh == chassish) {
- rc = handle_chassis_configure(frup);
- free(dr_arg);
- return (rc);
- }
-
- if ((rc = ptree_get_propval_by_name(frup->frunodeh, PICL_PROP_PARENT,
- &parenth, sizeof (parenth))) != PICL_SUCCESS) {
- free(dr_arg);
- return (rc);
- }
-
- if ((rc = hash_lookup_entry(parenth, (void **)&hashptr)) !=
- PICL_SUCCESS) {
- free(dr_arg);
- return (rc);
- }
- locp = LOCDATA_PTR(hashptr);
-
- /*
- * update the location state also, as this could be
- * user initiated connect operation
- */
- (void) update_loc_state(locp, &state_changed);
- if (state_changed)
- if ((rc = post_piclevent(PICLEVENT_STATE_CHANGE,
- loc_state[locp->state], loc_state[locp->prev_state],
- locp->locnodeh, WAIT)) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_POST_PICLEVENT_ERR,
- locp->name, PICLEVENT_STATE_CHANGE, rc);
- }
-
- switch (dr_arg->action) {
- case CPU_ONLINE:
- flags |= CFGA_FLAG_FORCE;
- FRUTREE_DEBUG1(EVENTS, "CPU online on %s", frup->name);
- if (locp->state != LOC_STATE_CONNECTED) {
- if (locp->autoconfig_enabled) {
- if ((rc = connect_fru(locp)) != PICL_SUCCESS) {
- FRUTREE_DEBUG2(EVENTS,
- CONNECT_FAILED_ERR,
- locp->name, rc);
- }
- }
- break;
- } /*FALLTHRU*/
-
- /* do configure now */
- case CONFIGURE_FRU: /* dr_incoming_res */
- FRUTREE_DEBUG1(EVENTS, "DR_INCOMING_RES on %s", frup->name);
- if ((rc = configure_fru(frup, flags)) != PICL_SUCCESS) {
- FRUTREE_DEBUG2(EVENTS, CONFIGURE_FAILED_ERR,
- frup->name, rc);
- break;
- }
- }
- free(dr_arg);
- return (PICL_SUCCESS);
-}
-
-/* handles all dr related events */
-static picl_errno_t
-handle_dr_event(frutree_dr_arg_t *dr_arg)
-{
- picl_errno_t rc;
- picl_nodehdl_t loch, childh;
- hashdata_t *hashptr = NULL;
- cfga_flags_t flags = 0;
- frutree_dr_arg_t *arg = NULL;
- frutree_dr_arg_t fru_dr_arg;
- frutree_locnode_t *locp = NULL;
- frutree_frunode_t *frup = NULL, *child_frup = NULL;
- boolean_t state_changed = B_FALSE, cond_changed = B_FALSE;
-
- switch (dr_arg->action) {
- case CPU_ONLINE:
- case CONFIGURE_FRU:
-
- frup = (frutree_frunode_t *)dr_arg->data;
- arg = (frutree_dr_arg_t *)malloc(sizeof (frutree_dr_arg_t));
- if (arg == NULL) {
- FRUTREE_DEBUG2(EVENTS, CONFIGURE_FAILED_ERR,
- frup->name, PICL_NOSPACE);
- return (NULL);
- }
- arg->action = dr_arg->action;
- arg->data = dr_arg->data;
- (void) configuration_fn((void *)arg);
- break;
-
- case CPU_OFFLINE:
- flags |= CFGA_FLAG_FORCE;
- frup = (frutree_frunode_t *)dr_arg->data;
- if (frup == NULL) {
- break;
- }
- FRUTREE_DEBUG1(EVENTS, "CPU_OFFLINE on %s", frup->name);
- if ((rc = unconfigure_fru(frup, flags)) != PICL_SUCCESS) {
- FRUTREE_DEBUG2(EVENTS, UNCONFIG_FAILED_ERR, frup->name, rc);
- break;
- }
-
- if ((rc = handle_fru_unconfigure(frup)) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, EVENT_NOT_HANDLED, PICLEVENT_DR_REQ,
- frup->name, rc);
- }
- break;
-
- case UNCONFIGURE_FRU: /* dr_outgoing_res */
- frup = (frutree_frunode_t *)dr_arg->data;
- if (frup == NULL) {
- break;
- }
- FRUTREE_DEBUG1(EVENTS, "DR_OUTGOING_RES on %s", frup->name);
- if (frup->frunodeh == chassish) {
- (void) handle_chassis_unconfigure(frup);
- break;
- }
-
- if ((rc = unconfigure_fru(frup, flags)) != PICL_SUCCESS) {
- FRUTREE_DEBUG2(EVENTS, UNCONFIG_FAILED_ERR, frup->name, rc);
- break;
- }
-
- if ((rc = handle_fru_unconfigure(frup)) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, EVENT_NOT_HANDLED,
- PICLEVENT_DR_REQ, frup->name, rc);
- }
-
- if (ptree_get_propval_by_name(frup->frunodeh, PICL_PROP_PARENT,
- &loch, sizeof (loch)) != PICL_SUCCESS) {
- break;
- }
-
- if ((rc = hash_lookup_entry(loch, (void **)&hashptr)) !=
- PICL_SUCCESS) {
- break;
- }
- locp = LOCDATA_PTR(hashptr);
-
- /* check the autoconfig flag */
- if (locp->autoconfig_enabled == B_FALSE) {
- break;
- }
-
- if ((rc = disconnect_fru(locp)) != PICL_SUCCESS) {
- FRUTREE_DEBUG2(EVENTS, "SUNW_frutree:Disconnect on %s "
- "failed(error=%d)", locp->name, rc);
- }
- break;
-
- case HANDLE_CONFIGURE: /* basic hotswap operation */
-
- frup = (frutree_frunode_t *)dr_arg->data;
- if (frup == NULL) {
- break;
- }
- FRUTREE_DEBUG1(EVENTS, "HANDLE CONFIGURE on %s", frup->name);
- handle_fru_configure(frup);
- break;
-
- case HANDLE_UNCONFIGURE: /* basic hotswap operation */
-
- /* cleanup the internal data structures */
-
- frup = (frutree_frunode_t *)dr_arg->data;
- if (frup == NULL) {
- break;
- }
- FRUTREE_DEBUG1(EVENTS, "HANDLE UNCONFIGURE on %s", frup->name);
-
- if ((rc = post_piclevent(PICLEVENT_STATE_CHANGE,
- fru_state[frup->state], fru_state[frup->prev_state],
- frup->frunodeh, WAIT)) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_POST_PICLEVENT_ERR,
- frup->name, PICLEVENT_STATE_CHANGE, rc);
- }
-
- /* update the fru condition */
- (void) update_fru_condition(frup, &state_changed);
- if (state_changed) {
- if ((rc = post_piclevent(PICLEVENT_CONDITION_CHANGE,
- fru_cond[frup->cond], fru_cond[frup->prev_cond],
- frup->frunodeh, WAIT)) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_POST_PICLEVENT_ERR,
- frup->name, PICLEVENT_CONDITION_CHANGE, rc);
- }
- }
- if ((rc = handle_fru_unconfigure(frup)) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, EVENT_NOT_HANDLED,
- PICLEVENT_DR_AP_STATE_CHANGE, frup->name, rc);
- }
- break;
-
- case HANDLE_LOCSTATE_CHANGE: /* basic hotswap operation */
- /* posts state change events of location */
- locp = (frutree_locnode_t *)dr_arg->data;
- if (locp == NULL) {
- break;
- }
- FRUTREE_DEBUG1(EVENTS, "HANDLE LOC STATE CHANGE on %s", locp->name);
- if ((rc = post_piclevent(PICLEVENT_STATE_CHANGE,
- loc_state[locp->state], loc_state[locp->prev_state],
- locp->locnodeh, WAIT)) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_POST_PICLEVENT_ERR,
- locp->name, PICLEVENT_STATE_CHANGE, rc);
- }
-
- /* wakeup threads sleeping on this condition */
- (void) pthread_mutex_lock(&locp->mutex);
- if (locp->state == LOC_STATE_CONNECTED) {
- (void) pthread_cond_broadcast(&locp->cond_cv);
- }
- (void) pthread_mutex_unlock(&locp->mutex);
-
- /* if the location has child fru, get its information */
- if (ptree_get_propval_by_name(locp->locnodeh, PICL_PROP_CHILD,
- &childh, sizeof (childh)) == PICL_SUCCESS) {
- /* get the child fru information */
- if (hash_lookup_entry(childh, (void **)&hashptr) ==
- PICL_SUCCESS) {
- child_frup = FRUDATA_PTR(hashptr);
- }
- }
- /* update the child fru state and handle any state changes */
- if (child_frup == NULL) {
- break;
- }
-
- if ((rc = update_fru_state(child_frup, &state_changed)) !=
- PICL_SUCCESS) {
- FRUTREE_DEBUG2(EVENTS, GET_FRU_STATE_ERR, child_frup->name, rc);
- break;
- }
-
- if (state_changed == B_FALSE) {
- /*
- * if there is no change in state, check for condition
- * changes.
- * if there is a state change, handling state change
- * will take care of condition changes also.
- */
- (void) update_fru_condition(child_frup, &cond_changed);
- if (cond_changed == B_FALSE) {
- break;
- }
-
- if ((rc = post_piclevent(PICLEVENT_CONDITION_CHANGE,
- fru_cond[child_frup->cond],
- fru_cond[child_frup->prev_cond],
- child_frup->frunodeh, WAIT)) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_POST_PICLEVENT_ERR,
- child_frup->name,
- PICLEVENT_CONDITION_CHANGE, rc);
- }
- break;
- }
-
- /* add to queue to handle the fru state change */
- (void) pthread_mutex_lock(&child_frup->mutex);
- /* figure out if this is config/unconfig operation */
- if (child_frup->state == FRU_STATE_CONFIGURED) {
- fru_dr_arg.action = HANDLE_CONFIGURE;
- fru_dr_arg.data = child_frup;
- } else if (child_frup->state == FRU_STATE_UNCONFIGURED) {
- fru_dr_arg.action = HANDLE_UNCONFIGURE;
- fru_dr_arg.data = child_frup;
- }
- (void) pthread_mutex_unlock(&child_frup->mutex);
-
- (void) pthread_mutex_lock(&ev_mutex);
- if ((rc = add_to_queue(fru_dr_arg)) != PICL_SUCCESS) {
- (void) pthread_mutex_unlock(&ev_mutex);
- break;
- }
- (void) pthread_cond_signal(&ev_cond);
- (void) pthread_mutex_unlock(&ev_mutex);
- break;
-
- case HANDLE_INSERT: /* dr_apstate_change (HINT_INSERT) */
- locp = (frutree_locnode_t *)dr_arg->data;
- if (locp == NULL) {
- break;
- }
- FRUTREE_DEBUG1(EVENTS, "HANDLE INSERT on %s", locp->name);
- /* if the location has child fru, get its information */
- if (ptree_get_propval_by_name(locp->locnodeh, PICL_PROP_CHILD,
- &childh, sizeof (childh)) == PICL_SUCCESS) {
- /* get the child fru information */
- if (hash_lookup_entry(childh, (void **)&hashptr) ==
- PICL_SUCCESS) {
- child_frup = FRUDATA_PTR(hashptr);
- }
- }
- if (child_frup) {
- /*
- * if previous state is not empty, it could be a
- * hint insert to retry connects
- */
- (void) update_loc_state(locp, &state_changed);
- if (state_changed) {
- if ((rc = post_piclevent(PICLEVENT_STATE_CHANGE,
- loc_state[locp->state],
- loc_state[locp->prev_state], locp->locnodeh,
- WAIT)) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_POST_PICLEVENT_ERR,
- locp->name, PICLEVENT_STATE_CHANGE, rc);
- }
- }
-
- (void) update_fru_condition(child_frup, &cond_changed);
- if (cond_changed == B_TRUE) {
- if ((rc = post_piclevent(PICLEVENT_CONDITION_CHANGE,
- fru_cond[child_frup->cond],
- fru_cond[child_frup->prev_cond],
- child_frup->frunodeh, WAIT)) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS,
- PTREE_POST_PICLEVENT_ERR,
- child_frup->name,
- PICLEVENT_CONDITION_CHANGE, rc);
- }
- }
- if (!locp->autoconfig_enabled) {
- break;
- }
-
- if (locp->state != LOC_STATE_CONNECTED) {
- if ((rc = connect_fru(locp)) != PICL_SUCCESS) {
- FRUTREE_DEBUG2(EVENTS, CONNECT_FAILED_ERR,
- locp->name, rc);
- }
- }
- break;
- }
-
- (void) update_loc_state(locp, &state_changed);
- if ((rc = create_fru_node(locp, &child_frup)) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, EVENT_NOT_HANDLED,
- PICLEVENT_DR_AP_STATE_CHANGE, locp->name, rc);
- break;
- }
-
- if ((rc = post_piclevent(PICLEVENT_STATE_CHANGE,
- loc_state[locp->state], loc_state[locp->prev_state],
- locp->locnodeh, WAIT)) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_POST_PICLEVENT_ERR,
- locp->name, PICLEVENT_STATE_CHANGE, rc);
- }
-
- if (locp->autoconfig_enabled) {
- if ((rc = connect_fru(locp)) != PICL_SUCCESS) {
- FRUTREE_DEBUG2(EVENTS, CONNECT_FAILED_ERR,
- locp->name, rc);
- }
- }
- break;
-
- case HANDLE_REMOVE: /* dr_apstate_change (HINT_REMOVE) */
- locp = (frutree_locnode_t *)dr_arg->data;
- if (locp == NULL) {
- break;
- }
- FRUTREE_DEBUG1(EVENTS, "HANDLE REMOVE on %s", locp->name);
-
- if (locp->state == LOC_STATE_EMPTY) {
- break; /* discard the spurious event */
- }
-
- (void) update_loc_state(locp, &state_changed);
- /* if the location has child fru, get its information */
- if (ptree_get_propval_by_name(locp->locnodeh, PICL_PROP_CHILD,
- &childh, sizeof (childh)) == PICL_SUCCESS) {
- /* get the child fru information */
- if (hash_lookup_entry(childh, (void **)&hashptr) ==
- PICL_SUCCESS) {
- frup = FRUDATA_PTR(hashptr);
- }
- }
- if (frup == NULL) {
- break;
- }
-
- /*
- * frutree need to post this event before handling the
- * fru remove, so that other plugins (like frudata) can
- * do the cleanup
- */
- if ((rc = post_piclevent(PICLEVENT_STATE_CHANGE,
- loc_state[locp->state], loc_state[locp->prev_state],
- locp->locnodeh, WAIT)) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_POST_PICLEVENT_ERR,
- locp->name, PICLEVENT_STATE_CHANGE, rc);
- }
-
- if ((rc = handle_fru_remove(frup)) != PICL_SUCCESS) {
- FRUTREE_DEBUG2(EVENTS, "SUNW_frutree:Error in handling"
- "removal of fru under %s(error=%d)", locp->name, rc);
- }
- break;
-
- case POST_COND_EVENT:
- frup = (frutree_frunode_t *)dr_arg->data;
- if (frup == NULL) {
- break;
- }
- if ((rc = post_piclevent(PICLEVENT_CONDITION_CHANGE,
- fru_cond[frup->cond], fru_cond[frup->prev_cond],
- frup->frunodeh, WAIT)) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_POST_PICLEVENT_ERR,
- frup->name, PICLEVENT_CONDITION_CHANGE, rc);
- }
- default:
- break;
- }
- return (PICL_SUCCESS);
-}
-
-/*ARGSUSED*/
-static void*
-dr_thread(void * arg)
-{
- ev_queue_t *event = NULL;
-
- (void) pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
- (void) pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
- for (;;) {
- if (fini_called)
- break;
- (void) pthread_mutex_lock(&ev_mutex);
- while (queue_head == NULL) {
- (void) pthread_cond_wait(&ev_cond, &ev_mutex);
- }
-
- event = remove_from_queue();
- (void) pthread_mutex_unlock(&ev_mutex);
- while (event) {
- (void) handle_dr_event(&event->arg);
- free(event);
- event = NULL;
- (void) pthread_mutex_lock(&ev_mutex);
- event = remove_from_queue();
- (void) pthread_mutex_unlock(&ev_mutex);
- }
- }
- return (NULL);
-}
-
-static picl_errno_t
-update_port_state(frutree_portnode_t *portp, boolean_t post_ev)
-{
- int state, cond;
- picl_errno_t rc;
- uint64_t ap_status_time;
- boolean_t state_changed = B_FALSE;
- boolean_t cond_changed = B_FALSE;
- frutree_port_type_t port_type;
-
- if (portp == NULL) {
- return (PICL_INVALIDARG);
- }
- port_type = frutree_get_port_type(portp);
-
- if (port_type == UNKNOWN_PORT) {
- return (PICL_SUCCESS);
- }
- state = kstat_port_state(port_type, portp->driver,
- portp->instance);
- cond = kstat_port_cond(port_type, portp->driver,
- portp->instance);
- switch (state) {
- case 0:
- /* DOWN */
- if (portp->state != PORT_STATE_DOWN) {
- portp->state = PORT_STATE_DOWN;
- state_changed = B_TRUE;
- }
- break;
- case 1:
- /* UP */
- if (portp->state != PORT_STATE_UP) {
- portp->state = PORT_STATE_UP;
- state_changed = B_TRUE;
- }
- break;
- default:
- /* UNKNOWN */
- if (portp->state != PORT_STATE_UNKNOWN) {
- portp->state = PORT_STATE_UNKNOWN;
- state_changed = B_TRUE;
- }
- }
-
- if (post_ev && state_changed) {
- ap_status_time = (uint64_t)(time(NULL));
- if ((rc = ptree_update_propval_by_name(portp->portnodeh,
- PICL_PROP_STATUS_TIME, &ap_status_time,
- sizeof (uint64_t))) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_UPDATE_PROP_ERR,
- PICL_PROP_STATUS_TIME, portp->name, rc);
-
- }
- if ((rc = post_piclevent(PICLEVENT_STATE_CHANGE,
- port_state[portp->state], NULL,
- portp->portnodeh, WAIT)) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_POST_PICLEVENT_ERR,
- portp->name, PICLEVENT_STATE_CHANGE, rc);
- }
- }
-
- switch (cond) {
- case 0:
- if (portp->cond != PORT_COND_OK) {
- portp->cond = PORT_COND_OK;
- cond_changed = B_TRUE;
- }
- break;
- case 1:
- if (portp->cond != PORT_COND_FAILING) {
- portp->cond = PORT_COND_FAILING;
- cond_changed = B_TRUE;
- }
- break;
- case 2:
- if (portp->cond != PORT_COND_FAILED) {
- portp->cond = PORT_COND_FAILED;
- cond_changed = B_TRUE;
- }
- break;
- case 3:
- if (portp->cond != PORT_COND_TESTING) {
- portp->cond = PORT_COND_TESTING;
- cond_changed = B_TRUE;
- }
- break;
- default:
- if (portp->cond != PORT_COND_UNKNOWN) {
- portp->cond = PORT_COND_UNKNOWN;
- cond_changed = B_TRUE;
- }
- }
-
- if (post_ev && cond_changed) {
- ap_status_time = (uint64_t)(time(NULL));
- if ((rc = ptree_update_propval_by_name(portp->portnodeh,
- PICL_PROP_CONDITION_TIME, &ap_status_time,
- sizeof (uint64_t))) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_UPDATE_PROP_ERR,
- PICL_PROP_CONDITION_TIME, portp->name, rc);
- }
- if ((rc = post_piclevent(PICLEVENT_CONDITION_CHANGE,
- port_cond[portp->cond], NULL,
- portp->portnodeh, WAIT)) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_POST_PICLEVENT_ERR,
- portp->name, PICLEVENT_CONDITION_CHANGE, rc);
- }
- }
- return (PICL_SUCCESS);
-}
-
-/*
- * monitor port nodes and scsi nodes under a fru
- */
-static int
-monitor_nodes_under_fru(picl_nodehdl_t nodeh, void *c_args)
-{
- picl_errno_t rc;
- picl_nodehdl_t parenth;
- hashdata_t *hashptr = NULL;
- boolean_t state_changed;
- frutree_portnode_t *portp = NULL;
- frutree_locnode_t *locp = NULL;
- frutree_frunode_t *frup = NULL;
- char class[PICL_PROPNAMELEN_MAX];
- char slot_type[PICL_PROPNAMELEN_MAX];
-
- if (c_args == NULL) {
- return (PICL_INVALIDARG);
- }
- frup = (frutree_frunode_t *)c_args;
-
- if (ptree_get_propval_by_name(nodeh, PICL_PROP_PARENT,
- &parenth, sizeof (parenth)) != PICL_SUCCESS) {
- return (PICL_WALK_CONTINUE);
- }
-
- if (parenth != frup->frunodeh)
- return (PICL_WALK_CONTINUE);
-
- if ((rc = ptree_get_propval_by_name(nodeh, PICL_PROP_CLASSNAME, class,
- sizeof (class))) != PICL_SUCCESS) {
- return (PICL_WALK_CONTINUE);
- }
-
- if ((rc = hash_lookup_entry(nodeh, (void **)&hashptr)) !=
- PICL_SUCCESS) {
- return (PICL_WALK_CONTINUE);
- }
-
- if (strcmp(class, PICL_CLASS_LOCATION) == 0) {
- locp = LOCDATA_PTR(hashptr);
- if (ptree_get_propval_by_name(locp->locnodeh,
- PICL_PROP_SLOT_TYPE, slot_type,
- sizeof (slot_type)) != PICL_SUCCESS) {
- return (PICL_WALK_CONTINUE);
- }
- if (strcmp(slot_type, SANIBEL_SCSI_SLOT) == 0 ||
- strcmp(slot_type, SANIBEL_IDE_SLOT) == 0) {
- return (PICL_WALK_CONTINUE);
- }
- (void) update_loc_state(locp, &state_changed);
- if (state_changed) {
- if ((rc = post_piclevent(PICLEVENT_STATE_CHANGE,
- loc_state[locp->state],
- loc_state[locp->prev_state],
- locp->locnodeh, WAIT)) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_POST_PICLEVENT_ERR,
- locp->name, PICLEVENT_STATE_CHANGE, rc);
- }
- }
- } else if (strcmp(class, PICL_CLASS_PORT) == 0) {
- portp = PORTDATA_PTR(hashptr);
- (void) update_port_state(portp, B_TRUE);
- }
- return (PICL_WALK_CONTINUE);
-}
-
-/* This routine monitors only port node, scsi nodes */
-/* ARGSUSED */
-static int
-monitor_fru(picl_nodehdl_t nodeh, void *c_args)
-{
- picl_errno_t rc;
- picl_nodehdl_t loch;
- hashdata_t *hashptr = NULL;
- frutree_frunode_t *frup = NULL;
- boolean_t state_changed, cond_changed;
- char slot_type[PICL_PROPNAMELEN_MAX];
-
- if (hash_lookup_entry(nodeh, (void **)&hashptr) !=
- PICL_SUCCESS) {
- return (PICL_WALK_CONTINUE);
- }
- frup = FRUDATA_PTR(hashptr);
-
- (void) pthread_mutex_lock(&frup->mutex);
- if (frup->dr_in_progress) {
- (void) pthread_mutex_unlock(&frup->mutex);
- return (PICL_WALK_CONTINUE);
- }
- frup->busy = B_TRUE;
- (void) pthread_mutex_unlock(&frup->mutex);
-
- /* get the parent information to determine if it is scsi slot or not */
- if (ptree_get_propval_by_name(nodeh, PICL_PROP_PARENT,
- &loch, sizeof (loch)) != PICL_SUCCESS) {
- return (PICL_WALK_CONTINUE);
- }
- if (ptree_get_propval_by_name(loch, PICL_PROP_SLOT_TYPE, slot_type,
- sizeof (slot_type)) != PICL_SUCCESS) {
- return (PICL_WALK_CONTINUE);
- }
-
- if (strcmp(slot_type, SANIBEL_SCSI_SLOT) == 0 ||
- strcmp(slot_type, SANIBEL_IDE_SLOT) == 0) {
- /* scsi fru */
- (void) update_fru_state(frup, &state_changed);
- (void) update_fru_condition(frup, &cond_changed);
- if (state_changed) {
- if ((rc = post_piclevent(PICLEVENT_STATE_CHANGE,
- fru_state[frup->state],
- fru_state[frup->prev_state],
- frup->frunodeh, WAIT)) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_POST_PICLEVENT_ERR,
- frup->name, PICLEVENT_STATE_CHANGE, rc);
- }
- }
- if (cond_changed) {
- if ((rc = post_piclevent(PICLEVENT_CONDITION_CHANGE,
- fru_cond[frup->cond], fru_cond[frup->prev_cond],
- frup->frunodeh, WAIT)) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_POST_PICLEVENT_ERR,
- frup->name, PICLEVENT_CONDITION_CHANGE,
- rc);
- }
- }
- (void) pthread_mutex_lock(&frup->mutex);
- frup->busy = B_FALSE;
- (void) pthread_cond_signal(&frup->busy_cond_cv);
- (void) pthread_mutex_unlock(&frup->mutex);
- return (PICL_WALK_CONTINUE);
- }
-
- if (frup->state != FRU_STATE_CONFIGURED) {
- (void) pthread_mutex_lock(&frup->mutex);
- frup->busy = B_FALSE;
- (void) pthread_cond_signal(&frup->busy_cond_cv);
- (void) pthread_mutex_unlock(&frup->mutex);
- return (PICL_WALK_CONTINUE);
- }
-
- (void) ptree_walk_tree_by_class(chassish,
- NULL, (void *)frup, monitor_nodes_under_fru);
-
- (void) pthread_mutex_lock(&frup->mutex);
- frup->busy = B_FALSE;
- (void) pthread_cond_signal(&frup->busy_cond_cv);
- (void) pthread_mutex_unlock(&frup->mutex);
- return (PICL_WALK_CONTINUE);
-}
-
-/* ARGSUSED */
-static void *
-monitor_node_status(void *arg)
-{
- int err;
- timestruc_t to;
- struct timeval tp;
-
- (void) pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);
- (void) pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, NULL);
-
- FRUTREE_DEBUG0(EVENTS, "Monitoring for port status started");
- do
- {
- (void) pthread_mutex_lock(&monitor_mutex);
- (void) gettimeofday(&tp, NULL);
- to.tv_sec = tp.tv_sec + frutree_poll_timeout;
- to.tv_nsec = tp.tv_usec * 1000;
- err = pthread_cond_timedwait(&monitor_cv, &monitor_mutex, &to);
-
- (void) pthread_mutex_unlock(&monitor_mutex);
- if (err == ETIMEDOUT) { /* woke up from sleep */
- (void) ptree_walk_tree_by_class(chassish,
- PICL_CLASS_FRU, (void *)NULL, monitor_fru);
- }
- } while (fini_called == 0);
- return (NULL);
-}
-
-picl_errno_t
-create_children(frutree_frunode_t *frup, char *scsi_loc, char *bus_addr,
- int slot_no, char *slot_type, boolean_t is_cfgadm_ap)
-{
- int i = 0;
- picl_errno_t rc;
- picl_nodehdl_t nodeh;
- uint8_t geo_addr = 0;
- hashdata_t *datap = NULL;
- frutree_locnode_t *locp = NULL;
- hashdata_t *hashptr = NULL;
- char fru_type[PICL_PROPNAMELEN_MAX];
- frutree_frunode_t *child_frup = NULL;
- frutree_callback_data_t fru_arg;
-
- if (frup == NULL || scsi_loc == NULL || slot_type == NULL) {
- return (PICL_FAILURE);
- }
-
- /* check if the location is already created */
- (void) strncpy(fru_arg.node_name, scsi_loc,
- sizeof (fru_arg.node_name));
- fru_arg.retnodeh = 0;
- if ((rc = ptree_walk_tree_by_class(chassish, PICL_CLASS_LOCATION,
- &fru_arg, frutree_get_nodehdl)) == PICL_SUCCESS) {
- if (fru_arg.retnodeh != 0) { /* node is already present */
- return (PICL_SUCCESS);
- }
- }
-
- /* create the location node and all its properties */
- if ((rc = ptree_create_node(scsi_loc, PICL_CLASS_LOCATION,
- &nodeh)) != PICL_SUCCESS) {
- return (rc);
- }
-
- if ((rc = create_property(PICL_PTYPE_CHARSTRING, PICL_READ,
- PICL_PROPNAMELEN_MAX, PICL_PROP_SLOT_TYPE, NULLREAD,
- NULLWRITE, nodeh, NULL, slot_type)) !=
- PICL_SUCCESS) {
- FRUTREE_DEBUG3(FRUTREE_INIT, PTREE_CREATE_PROP_FAILED,
- PICL_PROP_SLOT_TYPE, scsi_loc, rc);
- }
-
- if ((rc = create_property(PICL_PTYPE_CHARSTRING, PICL_READ,
- PICL_PROPNAMELEN_MAX, PICL_PROP_LABEL, NULLREAD,
- NULLWRITE, nodeh, NULL, bus_addr)) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(FRUTREE_INIT, PTREE_CREATE_PROP_FAILED,
- PICL_PROP_LABEL, scsi_loc, rc);
- }
-
- if ((rc = create_property(PICL_PTYPE_CHARSTRING, PICL_READ,
- PICL_PROPNAMELEN_MAX, PICL_PROP_BUS_ADDR, NULLREAD,
- NULLWRITE, nodeh, NULL, bus_addr)) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(FRUTREE_INIT, PTREE_CREATE_PROP_FAILED,
- PICL_PROP_BUS_ADDR, scsi_loc, rc);
- }
-
- geo_addr = slot_no;
- if ((rc = create_property(PICL_PTYPE_UNSIGNED_INT, PICL_READ,
- sizeof (uint8_t), PICL_PROP_GEO_ADDR, NULLREAD,
- NULLWRITE, nodeh, (picl_prophdl_t *)NULL,
- &geo_addr)) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(FRUTREE_INIT, PTREE_CREATE_PROP_FAILED,
- PICL_PROP_GEO_ADDR, scsi_loc, rc);
- }
-
- if ((rc = create_property(PICL_PTYPE_CHARSTRING, PICL_READ,
- PICL_PROPNAMELEN_MAX, PICL_PROP_DEVFS_PATH, NULLREAD,
- NULLWRITE, nodeh, NULL, frup->fru_path)) !=
- PICL_SUCCESS) {
- FRUTREE_DEBUG3(FRUTREE_INIT, PTREE_CREATE_PROP_FAILED,
- PICL_PROP_DEVFS_PATH, scsi_loc, rc);
- }
-
- if ((rc = ptree_add_node(frup->frunodeh, nodeh)) != PICL_SUCCESS) {
- (void) ptree_destroy_node(nodeh);
- return (rc);
- }
-
- /* save the node in hashtable */
- if ((rc = make_loc_data(scsi_loc, &datap)) != PICL_SUCCESS) {
- return (rc);
- }
- locp = LOCDATA_PTR(datap);
- locp->locnodeh = nodeh;
- /* save data in hash table */
- (void) hash_add_entry(nodeh, (void *)datap);
-
- if ((rc = hash_lookup_entry(nodeh, (void **)&hashptr)) !=
- PICL_SUCCESS) {
- return (rc);
- }
- locp = LOCDATA_PTR(hashptr);
-
- if (is_cfgadm_ap != B_TRUE) { /* device found in libdevinfo */
- locp->state_mgr = STATIC_LOC;
- locp->state = LOC_STATE_CONNECTED;
- }
-
- if ((rc = location_init(locp)) != PICL_SUCCESS) {
- return (rc);
- }
-
- /* if location is empty, done */
- if (locp->state == LOC_STATE_EMPTY) {
- if ((rc = post_piclevent(PICLEVENT_STATE_CHANGE,
- PICLEVENTARGVAL_EMPTY, NULL,
- locp->locnodeh, WAIT)) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_POST_PICLEVENT_ERR,
- locp->name, PICLEVENT_STATE_CHANGE, rc);
- }
- return (PICL_SUCCESS);
- }
-
- /* create the fru node and initilize it */
- if ((rc = create_fru_node(locp, &child_frup)) != PICL_SUCCESS) {
- return (rc);
- }
-
- /* post picl event on location (frudata is consumer for these events) */
- if ((rc = post_piclevent(PICLEVENT_STATE_CHANGE,
- loc_state[locp->state], PICLEVENTARGVAL_EMPTY,
- locp->locnodeh, WAIT)) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_POST_PICLEVENT_ERR,
- locp->name, PICLEVENT_STATE_CHANGE, rc);
- }
-
- if (child_frup->state_mgr == STATIC_LOC) {
- /* derive the fru_type from name */
- while (i < strlen(scsi_loc)) {
- if (isdigit(scsi_loc[i])) {
- (void) strncpy(fru_type, scsi_loc, i);
- fru_type[i] = '\0';
- break;
- }
- ++i;
- }
- if ((rc = ptree_update_propval_by_name(child_frup->frunodeh,
- PICL_PROP_FRU_TYPE, fru_type, sizeof (fru_type))) !=
- PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_UPDATE_PROP_ERR,
- PICL_PROP_FRU_TYPE, child_frup->name, rc);
- }
- }
-
- /* post picl state change event on fru state */
- if ((rc = post_piclevent(PICLEVENT_STATE_CHANGE,
- fru_state[child_frup->state], PICLEVENTARGVAL_UNKNOWN,
- child_frup->frunodeh, WAIT)) != PICL_SUCCESS) {
- FRUTREE_DEBUG3(EVENTS, PTREE_POST_PICLEVENT_ERR,
- frup->name, PICLEVENT_STATE_CHANGE, rc);
- }
- /* for scsi FRUs we need not probe further */
- return (PICL_SUCCESS);
-}
-
-/*
- * recursive search in the subtree
- */
-/*ARGSUSED*/
-boolean_t
-is_location_present_in_subtree(frutree_frunode_t *frup, const char *name,
- const char *path)
-{
- frutree_callback_data_t fru_arg;
-
- (void) strncpy(fru_arg.node_name, name,
- sizeof (fru_arg.node_name));
- fru_arg.retnodeh = 0;
- if (ptree_walk_tree_by_class(frup->frunodeh, PICL_CLASS_LOCATION,
- &fru_arg, frutree_get_nodehdl) == PICL_SUCCESS) {
- if (fru_arg.retnodeh != 0) { /* node is already present */
- return (B_TRUE);
- }
- }
- return (B_FALSE);
-}
diff --git a/usr/src/cmd/picl/plugins/sun4u/snowbird/frutree/piclfrutree.h b/usr/src/cmd/picl/plugins/sun4u/snowbird/frutree/piclfrutree.h
deleted file mode 100644
index b2c4b47829..0000000000
--- a/usr/src/cmd/picl/plugins/sun4u/snowbird/frutree/piclfrutree.h
+++ /dev/null
@@ -1,264 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (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 2004 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#ifndef _PICLFRUTREE_H
-#define _PICLFRUTREE_H
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <sys/param.h>
-#include <syslog.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-typedef enum {
- NONE = 0x0,
- FRUTREE_INIT = 0x1,
- EVENTS = 0x2,
- HASHTABLE = 0x4,
- PERF_DATA = 0x8,
- EV_COMPLETION = 0x10,
- PRINT_ALL = 0xFF
-} frutree_debug_t;
-
-#define FRUTREE_DEBUG0(lvl, fmt) \
- if (lvl & frutree_debug) { \
- syslog(LOG_DEBUG, fmt); \
- }
-#define FRUTREE_DEBUG1(lvl, fmt, d1) \
- if (lvl & frutree_debug) { \
- syslog(LOG_DEBUG, fmt, d1); \
- }
-#define FRUTREE_DEBUG2(lvl, fmt, d1, d2) \
- if (lvl & frutree_debug) { \
- syslog(LOG_DEBUG, fmt, d1, d2); \
- }
-#define FRUTREE_DEBUG3(lvl, fmt, d1, d2, d3) \
- if (lvl & frutree_debug) { \
- syslog(LOG_DEBUG, fmt, d1, d2, d3); \
- }
-#define FRUTREE_DEBUG4(lvl, fmt, d1, d2, d3, d4) \
- if (lvl & frutree_debug) {\
- syslog(LOG_DEBUG, fmt, d1, d2, d3, d4); \
- }
-
-/* environment variables to tune the variables */
-#define FRUTREE_DEBUG "SUNW_FRUTREE_DEBUG"
-#define FRUTREE_POLL_TIMEOUT "SUNW_FRUTREE_POLL_TIMEOUT"
-#define FRUTREE_DRWAIT "SUNW_FRUTREE_DRWAIT_TIME"
-
-/* PICL defines */
-#define PICL_NODE_CHASSIS "chassis"
-
-/* Sanibel specific defines */
-#define SANIBEL_PICLNODE_CPU "CPU"
-#define SANIBEL_PICLNODE_PARALLEL "ecpp"
-#define SANIBEL_NETWORK_LABEL "ENET"
-#define SANIBEL_CPCISLOT_TYPE "cpci"
-#define SANIBEL_NETWORK_PORT "network"
-#define SANIBEL_SERIAL_PORT "serial"
-#define SANIBEL_PARALLEL_PORT "parallel"
-#define SANIBEL_SCSI_SLOT "scsi"
-#define SANIBEL_IDE_SLOT "ide"
-#define SANIBEL_UNKNOWN_SLOT "unknown"
-#define DEVICE_CLASS_SCSI "scsi"
-#define DEVICE_CLASS_IDE "dada"
-
-#define MAX_BUFSIZE 512
-#define SUPER_USER 0
-#define DEVFSADM_CMD "/usr/sbin/devfsadm -i"
-#define TEMP_DIR "/var/tmp/"
-#define PROBE_FILE "probed"
-#define NULLREAD (int (*)(ptree_rarg_t *, void *))0
-#define NULLWRITE (int (*)(ptree_warg_t *, const void *))0
-
-#define PTREE_CREATE_PROP_FAILED \
- gettext("SUNW_frutree:Error in creating property:%s, "\
- "under %s(error=%d)")
-#define PTREE_POST_PICLEVENT_ERR \
- gettext("SUNW_frutree:Error in posting picl event %s(%s)(error=%d)")
-#define PTREE_EVENT_HANDLING_ERR \
- gettext("SUNW_frutree:Error in handling %s event on %s(error=%d)")
-#define GET_LOC_STATE_ERR \
- gettext("SUNW_frutree:Error in getting state info for %s"\
- "(location)(error=%d)")
-#define GET_FRU_STATE_ERR \
- gettext("SUNW_frutree:Error in getting state for %s(fru)(error=%d)")
-#define GET_FRU_COND_ERR \
- gettext("SUNW_frutree:Error in getting condition for %s(fru)(error=%d)")
-#define CONNECT_FAILED_ERR \
- gettext("SUNW_frutree:Connect operation on %s failed(error=%d)")
-#define CONFIGURE_FAILED_ERR \
- gettext("SUNW_frutree:Configure operation on %s failed(error=%d)")
-#define UNCONFIG_FAILED_ERR \
- gettext("SUNW_frutree:Unconfigure operation on %s failed(error=%d)")
-#define DISCONNECT_FAILED_ERR \
- gettext("SUNW_frutree:Disconnect operation on %s failed(error=%d)")
-#define PROBE_FRU_ERR \
- gettext("SUNW_frutree:Error in probing fru under %s(error=%d)")
-#define PTREE_UPDATE_PROP_ERR \
- gettext("SUNW_frutree:Error updating %s of %s(error=%d)")
-#define PTREE_GET_PROPVAL_ERR \
- gettext("SUNW_frutree:Error in getting value of %s(%s)(error=%d)")
-#define PTREE_DEVICE_CREATE_ERR \
- gettext("SUNW_frutree:Error in creating nodes under %s(error=%d)")
-#define EVENT_NOT_HANDLED \
- gettext("SUNW_frutree:Error in handling %s on %s(error=%d)")
-#define ERROR_REINIT \
- gettext("SUNW_frutree:Error in reinitializing %s")
-
-typedef enum {
- NO_WAIT = 0,
- WAIT
-} frutree_wait_t;
-
-typedef uint8_t frutree_frustate_t;
-typedef uint8_t frutree_frucond_t;
-typedef uint8_t frutree_locstate_t;
-typedef uint8_t frutree_port_type_t;
-typedef uint8_t frutree_datatype_t;
-typedef uint8_t frutree_loctype_t;
-
-/* valid fru states */
-#define FRU_STATE_UNKNOWN 0x0
-#define FRU_STATE_CONFIGURED 0x1
-#define FRU_STATE_UNCONFIGURED 0x2
-#define FRU_STATE_CONFIGURING 0x3
-#define FRU_STATE_UNCONFIGURING 0x4
-
-/* valid fru condition */
-#define FRU_COND_UNKNOWN 0x0
-#define FRU_COND_FAILED 0x1
-#define FRU_COND_FAILING 0x2
-#define FRU_COND_OK 0x3
-#define FRU_COND_TESTING 0x4
-
-/* port states */
-#define PORT_STATE_DOWN 0x0
-#define PORT_STATE_UP 0x1
-#define PORT_STATE_UNKNOWN 0x2
-
-/* port condition */
-#define PORT_COND_OK 0x0
-#define PORT_COND_FAILING 0x1
-#define PORT_COND_FAILED 0x2
-#define PORT_COND_TESTING 0x3
-#define PORT_COND_UNKNOWN 0x4
-
-/* port types */
-#define NETWORK_PORT 0x0
-#define SERIAL_PORT 0x1
-#define PARALLEL_PORT 0x2
-#define UNKNOWN_PORT 0x4
-
-/* location states */
-#define LOC_STATE_UNKNOWN 0x0
-#define LOC_STATE_EMPTY 0x1
-#define LOC_STATE_CONNECTED 0x2
-#define LOC_STATE_DISCONNECTED 0x3
-#define LOC_STATE_CONNECTING 0x4
-#define LOC_STATE_DISCONNECTING 0x5
-
-/* types of nodes */
-#define LOC_TYPE 0x0
-#define FRU_TYPE 0x1
-#define PORT_TYPE 0x2
-
-/* location managers */
-#define CFGADM_AP 0x0 /* managed based on cfgadm data */
-#define PLUGIN_PVT 0x1 /* managed by other plugin */
-#define STATIC_LOC 0x2 /* managed based on libdevinfo */
-#define UNKNOWN 0x3 /* unknown */
-
-typedef struct conf_cache {
- char buf[MAX_BUFSIZE];
- struct conf_cache *next;
-} frutree_cache_t;
-
-typedef struct {
- picl_nodehdl_t nodeh;
- picl_prophdl_t device_tblhdl;
- picl_prophdl_t env_tblhdl;
- frutree_cache_t *first;
- frutree_cache_t *last;
- boolean_t create_cache;
-} frutree_device_args_t;
-
-typedef struct loc_node frutree_locnode_t;
-typedef struct fru_node frutree_frunode_t;
-typedef struct port_node frutree_portnode_t;
-
-/* information on a particular location */
-struct loc_node {
- picl_nodehdl_t locnodeh; /* handle of the loc node itself */
- char *name;
- boolean_t cpu_node;
- boolean_t dr_in_progress;
- boolean_t autoconfig_enabled;
- frutree_loctype_t state_mgr; /* state manager */
- frutree_locstate_t state; /* present state */
- frutree_locstate_t prev_state; /* previous state */
- pthread_mutex_t mutex;
- pthread_cond_t cond_cv;
-};
-
-/* information on a particular port */
-struct port_node {
- picl_nodehdl_t portnodeh;
- char *name;
- int state;
- int cond;
- uint8_t instance;
- char driver[MAXPATHLEN];
-};
-
-/* information on a particular fru */
-struct fru_node {
- /* variable data */
- picl_nodehdl_t frunodeh;
- char *name;
- frutree_frustate_t state;
- frutree_frustate_t prev_state;
- frutree_frucond_t cond;
- frutree_frucond_t prev_cond;
- boolean_t cpu_node;
- boolean_t autoconfig_enabled;
- boolean_t dr_in_progress;
- boolean_t busy;
- frutree_loctype_t state_mgr;
- char fru_path[MAXPATHLEN];
- pthread_mutex_t mutex;
- pthread_cond_t cond_cv;
- pthread_cond_t busy_cond_cv;
-};
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _PICLFRUTREE_H */
diff --git a/usr/src/cmd/picl/plugins/sun4u/snowbird/frutree/piclkstat.c b/usr/src/cmd/picl/plugins/sun4u/snowbird/frutree/piclkstat.c
deleted file mode 100644
index 60b6b99efa..0000000000
--- a/usr/src/cmd/picl/plugins/sun4u/snowbird/frutree/piclkstat.c
+++ /dev/null
@@ -1,428 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (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 2004 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-/*
- * Implementation to get PORT nodes state and condition information
- */
-#include <stdio.h>
-#include <stdlib.h>
-#include <ctype.h>
-#include <strings.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <stropts.h>
-#include <locale.h>
-#include <syslog.h>
-#include <sys/types.h>
-#include <sys/termios.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <kstat.h>
-#include <signal.h>
-#include <assert.h>
-#include <config_admin.h>
-
-#include <picl.h>
-#include "piclfrutree.h"
-
-#define LINK_UP "link_up"
-#define DUPLEX "duplex"
-#define IF_SPEED "ifspeed"
-#define IERRORS "ierrors"
-#define IPACKETS "ipackets"
-#define OERRORS "oerrors"
-#define OPACKETS "opackets"
-#define NOCANPUT "nocanput"
-#define RUNT_ERRORS "runt_errors"
-#define COLLISIONS "collisions"
-
-typedef int (*funcp)(kstat_ctl_t *, char *, int);
-
-static kstat_named_t *kstat_name_lookup(kstat_ctl_t *, char *, int, char *);
-static int kstat_network_port_state(kstat_ctl_t *kc, char *, int);
-static int kstat_network_port_cond(kstat_ctl_t *kc, char *, int);
-static int serial_port_state(kstat_ctl_t *, char *, int);
-static int serial_port_cond(kstat_ctl_t *kc, char *, int);
-static int parallel_port_state(kstat_ctl_t *, char *, int);
-static int parallel_port_cond(kstat_ctl_t *kc, char *, int);
-static void sig_alarm_handler(int);
-
-static funcp port_state[] = {
- kstat_network_port_state,
- serial_port_state,
- parallel_port_state
-};
-
-static funcp port_cond[] = {
- kstat_network_port_cond,
- serial_port_cond,
- parallel_port_cond
-};
-
-/*
- * kstat_port_state: returns ethernet, or serial, or parallel port status
- * 1 = up, 0 = down, anything else = unknown
- */
-int
-kstat_port_state(frutree_port_type_t port_type, char *driver_name,
- int driver_instance)
-{
- int rc = -1;
- kstat_ctl_t *kc = NULL;
-
- switch (port_type) {
- case NETWORK_PORT:
- case SERIAL_PORT:
- case PARALLEL_PORT:
- if ((kc = kstat_open()) == NULL) {
- return (-1);
- }
- rc = port_state[port_type](kc, driver_name, driver_instance);
- kstat_close(kc);
- return (rc);
- default:
- return (-1);
- }
-}
-
-/*
- * kstat_port_cond: returns ethernet, or serial, or parallel port condition
- */
-int
-kstat_port_cond(frutree_port_type_t port_type, char *driver_name,
- int driver_instance)
-{
- int rc = -1;
- kstat_ctl_t *kc = NULL;
- switch (port_type) {
- case NETWORK_PORT:
- case SERIAL_PORT:
- case PARALLEL_PORT:
- if ((kc = kstat_open()) == NULL) {
- return (-1);
- }
- rc = port_cond[port_type](kc, driver_name, driver_instance);
- kstat_close(kc);
- return (rc);
- default:
- return (-1);
- }
-}
-
-static kstat_named_t *
-kstat_name_lookup(kstat_ctl_t *kc, char *ks_module, int ks_instance, char *name)
-{
- kstat_t *ksp;
-
- assert(kc);
- assert(ks_module);
- assert(name);
-
- for (ksp = kc->kc_chain; ksp; ksp = ksp->ks_next) {
- if (strcmp(ksp->ks_module, ks_module) == 0 &&
- ksp->ks_instance == ks_instance &&
- ksp->ks_type == KSTAT_TYPE_NAMED &&
- kstat_read(kc, ksp, NULL) != -1 &&
- kstat_data_lookup(ksp, name)) {
-
- ksp = kstat_lookup(kc, ks_module, ks_instance,
- ksp->ks_name);
- if (!ksp)
- return (NULL);
- if (kstat_read(kc, ksp, NULL) == -1)
- return (NULL);
- return ((kstat_named_t *)kstat_data_lookup(ksp, name));
- }
- }
- return (NULL);
-}
-
-/*
- * kstat_network_port_state: returns kstat info of a network port
- * 1 = up, 0 = down, anything else = unknown
- */
-static int
-kstat_network_port_state(kstat_ctl_t *kc, char *ks_module, int ks_instance)
-{
- kstat_named_t *port_datap = NULL;
-
- if ((port_datap = kstat_name_lookup(kc, ks_module, ks_instance,
- LINK_UP)) == NULL) {
- return (-1);
- }
- if (port_datap == NULL) {
- return (-1);
- }
- if (port_datap->data_type == KSTAT_DATA_UINT32) {
- if (port_datap->value.ui32 == 1) {
- return (1);
- } else if (port_datap->value.ui32 == 0) {
- return (0);
- } else {
- return (-1);
- }
- } else {
- if (port_datap->value.ui64 == 1) {
- return (1);
- } else if (port_datap->value.ui64 == 0) {
- return (0);
- } else {
- return (-1);
- }
- }
-}
-
-/*
- * kstat_network_port_cond: returns kstat info of a network port
- * 0 = OK, 1 = FAILING, 2 = FAILED, 3 = TESTING, -1 = unknown
- */
-static int
-kstat_network_port_cond(kstat_ctl_t *kc, char *ks_module, int ks_instance)
-{
- kstat_named_t *port_datap = NULL;
- uint64_t collisions, runt, link_up, link_duplex;
- uint64_t ifspeed, ierrors, ipackets, oerrors, opackets;
-
- if ((port_datap = kstat_name_lookup(kc, ks_module, ks_instance,
- LINK_UP)) == NULL) {
- return (-1);
- }
-
- if (port_datap->data_type == KSTAT_DATA_UINT32) {
- link_up = port_datap->value.ui32;
- } else {
- link_up = port_datap->value.ui64;
- }
- if (link_up == 0) {
- return (2);
- }
-
- if ((port_datap = kstat_name_lookup(kc, ks_module, ks_instance,
- DUPLEX)) == NULL) {
- return (-1);
- }
-
- if (port_datap->data_type == KSTAT_DATA_UINT32) {
- link_duplex = port_datap->value.ui32;
- } else {
- link_duplex = port_datap->value.ui64;
- }
- if (link_duplex == 0) {
- return (2);
- }
-
- if ((port_datap = kstat_name_lookup(kc, ks_module, ks_instance,
- IF_SPEED)) == NULL) {
- return (-1);
- }
- if (port_datap->data_type == KSTAT_DATA_UINT32) {
- ifspeed = port_datap->value.ui32;
- } else {
- ifspeed = port_datap->value.ui64;
- }
- if (ifspeed == 0) {
- return (2);
- }
-
- /* check for FAILING conditions */
- if ((port_datap = kstat_name_lookup(kc, ks_module, ks_instance,
- IERRORS)) == NULL) {
- return (-1);
- }
- if (port_datap->data_type == KSTAT_DATA_UINT32) {
- ierrors = port_datap->value.ui32;
- } else {
- ierrors = port_datap->value.ui64;
- }
-
- if ((port_datap = kstat_name_lookup(kc, ks_module, ks_instance,
- IPACKETS)) == NULL) {
- return (-1);
- }
-
- if (port_datap->data_type == KSTAT_DATA_UINT32) {
- ipackets = port_datap->value.ui32;
- } else {
- ipackets = port_datap->value.ui64;
- }
- if (ierrors > ipackets/10) {
- return (1);
- }
-
- if ((port_datap = kstat_name_lookup(kc, ks_module, ks_instance,
- OERRORS)) == NULL) {
- return (-1);
- }
- if (port_datap->data_type == KSTAT_DATA_UINT32) {
- oerrors = port_datap->value.ui32;
- } else {
- oerrors = port_datap->value.ui64;
- }
-
- if ((port_datap = kstat_name_lookup(kc, ks_module, ks_instance,
- OPACKETS)) == NULL) {
- return (-1);
- }
- if (port_datap->data_type == KSTAT_DATA_UINT32) {
- opackets = port_datap->value.ui32;
- } else {
- opackets = port_datap->value.ui64;
- }
- if (oerrors > opackets/10) {
- return (1);
- }
-
- if ((port_datap = kstat_name_lookup(kc, ks_module, ks_instance,
- RUNT_ERRORS)) == NULL) {
- return (-1);
- }
- if (port_datap->data_type == KSTAT_DATA_UINT32) {
- runt = port_datap->value.ui32;
- } else {
- runt = port_datap->value.ui64;
- }
- if (runt > ipackets/10) {
- return (1);
- }
-
- if ((port_datap = kstat_name_lookup(kc, ks_module, ks_instance,
- COLLISIONS)) == NULL) {
- return (-1);
- }
- if (port_datap->data_type == KSTAT_DATA_UINT32) {
- collisions = port_datap->value.ui32;
- } else {
- collisions = port_datap->value.ui64;
- }
- if (collisions > (opackets+ipackets)/30) {
- return (1);
- }
- return (0);
-}
-
-/*
- * serial_port_state: returns status a serial port
- * 1 = up, 0 = down, anything else = unknown
- */
-
-/* ARGSUSED */
-static int
-serial_port_state(kstat_ctl_t *kc, char *driver, int instance)
-{
- int fd;
- char device[20];
- struct termios flags;
- struct sigaction old_sa, new_sa;
-
- (void) memset(&old_sa, 0, sizeof (old_sa));
- (void) memset(&new_sa, 0, sizeof (new_sa));
- new_sa.sa_handler = sig_alarm_handler;
- (void) sigaction(SIGALRM, &new_sa, &old_sa);
- (void) alarm(1);
-
- (void) snprintf(device, sizeof (device), "/dev/tty%c", instance+'a');
- fd = open(device, O_RDONLY|O_NDELAY|O_NONBLOCK|O_NOCTTY);
-
- /* Restore sig action flags */
- (void) sigaction(SIGALRM, &old_sa, (struct sigaction *)0);
- /* Disable alarm */
- (void) alarm(0);
-
- if (fd == -1) {
- return (-1);
- }
-
- if (isatty(fd) == 0) {
- (void) close(fd);
- return (-1);
- }
- (void) memset(&flags, 0, sizeof (flags));
- if (ioctl(fd, TCGETS, &flags) != 0) {
- (void) close(fd);
- return (-1);
- }
- (void) close(fd);
- return ((flags.c_cflag & TIOCM_LE) ? 1 : 0);
-}
-
-/* ARGSUSED */
-static void
-sig_alarm_handler(int signo)
-{
-}
-
-/*
- * serial_port_cond: returns status of a serial port
- * 0 = OK, 1 = FAILING, 2 = FAILED, 3 = TESTING, anything else = UNKNOWN
- */
-static int
-serial_port_cond(kstat_ctl_t *kc, char *driver, int instance)
-{
- switch (serial_port_state(kc, driver, instance)) {
- case 1:
- return (0);
- default:
- return (-1);
- }
-}
-
-/*
- * parallel_port_state: returns kstat info of a serial port
- * 1 = up, 0 = down, anything else = unknown
- */
-static int
-parallel_port_state(kstat_ctl_t *kc, char *ks_module, int ks_instance)
-{
- kstat_t *ksp = NULL;
- kstat_named_t *port_datap = NULL;
- char *data_lookup;
- char ks_name[20];
-
- (void) snprintf(ks_name, sizeof (ks_name), "%s%d", ks_module,
- ks_instance);
- if ((ksp = kstat_lookup(kc, ks_module, ks_instance, ks_name)) == NULL) {
- return (-1);
- }
- if (kstat_read(kc, ksp, NULL) == -1) {
- return (-1);
- }
- data_lookup = "";
- port_datap = (kstat_named_t *)kstat_data_lookup(ksp, data_lookup);
- if (port_datap == NULL) {
- return (-1);
- }
- return (-1);
-}
-
-/*
- * parallel_port_cond: returns kstat info of a serial port
- * 1 = up, 0 = down, anything else = unknown
- */
-static int
-parallel_port_cond(kstat_ctl_t *kc, char *ks_module, int ks_instance)
-{
- return (parallel_port_state(kc, ks_module, ks_instance));
-}
diff --git a/usr/src/cmd/picl/plugins/sun4u/snowbird/frutree/picllibdevinfo.c b/usr/src/cmd/picl/plugins/sun4u/snowbird/frutree/picllibdevinfo.c
deleted file mode 100644
index 091e72383e..0000000000
--- a/usr/src/cmd/picl/plugins/sun4u/snowbird/frutree/picllibdevinfo.c
+++ /dev/null
@@ -1,853 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (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 2005 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Implementation to interact with libdevinfo to find port nodes,
- * and information regarding each node (fru, port, location).
- */
-
-#include <stdio.h>
-#include <libdevinfo.h>
-#include <picl.h>
-#include <picltree.h>
-#include <strings.h>
-#include <stdlib.h>
-#include <config_admin.h>
-#include <sys/types.h>
-#include <sys/obpdefs.h>
-#include <sys/pci.h>
-#include <picldefs.h>
-#include "piclfrutree.h"
-
-#include <syslog.h>
-
-static di_prom_handle_t prom_handle = DI_PROM_HANDLE_NIL;
-extern int frutree_debug;
-
-typedef struct {
- di_node_t rnode;
- char bus_addr[PICL_PROPNAMELEN_MAX];
- char path[PICL_PROPNAMELEN_MAX];
- void *arg;
- picl_errno_t retval;
-} frutree_devinfo_t;
-
-typedef struct p_info {
- frutree_port_type_t type;
- int geo_addr;
- int instance;
- char drv_name[20];
- char bus_addr[20];
- char devfs_path[MAXPATHLEN];
- struct p_info *next;
-}port_info_t;
-
-typedef struct {
- port_info_t *first;
- port_info_t *last;
- int n_serial;
- int n_parallel;
- int n_network;
-} plist_t;
-
-static void
-free_list(plist_t *listptr)
-{
- port_info_t *tmp;
- port_info_t *nextptr;
- if (listptr == NULL)
- return;
-
- nextptr = listptr->first;
- while (nextptr != NULL) {
- tmp = nextptr;
- nextptr = nextptr->next;
- free(tmp);
- }
-}
-
-/* (callback function for qsort) compare the bus_addr */
-static int
-compare(const void *a, const void *b)
-{
- port_info_t *pinfo1, *pinfo2;
- port_info_t **ptr2pinfo1, **ptr2pinfo2;
-
- ptr2pinfo1 = (port_info_t **)a;
- ptr2pinfo2 = (port_info_t **)b;
-
- pinfo1 = (port_info_t *)*ptr2pinfo1;
- pinfo2 = (port_info_t *)*ptr2pinfo2;
- return (strcmp(pinfo1->bus_addr, pinfo2->bus_addr));
-}
-
-/*
- * assigns GeoAddr property for ports based on bus-addr
- */
-static picl_errno_t
-assign_geo_addr(plist_t *list, frutree_port_type_t type)
-{
-
- int i = 0;
- port_info_t **port_info = NULL;
- port_info_t *nextptr = NULL;
- int num_ports = 0;
-
- if (list == NULL) {
- return (PICL_FAILURE);
- }
-
- if (list->first == NULL) {
- return (PICL_SUCCESS);
- }
-
- switch (type) {
- case SERIAL_PORT:
- if (list->n_serial == 0) {
- return (PICL_SUCCESS);
- }
- num_ports = list->n_serial;
- break;
-
- case PARALLEL_PORT:
- if (list->n_parallel == 0) {
- return (PICL_SUCCESS);
- }
- num_ports = list->n_parallel;
- break;
-
- case NETWORK_PORT:
- if (list->n_network == 0) {
- return (PICL_SUCCESS);
- }
- num_ports = list->n_network;
- break;
-
- }
-
- port_info = (port_info_t **)malloc(
- sizeof (port_info_t *) * num_ports);
- if (port_info == NULL) {
- return (PICL_NOSPACE);
- }
-
- /* traverse thru list and look for ports of given type */
- nextptr = list->first;
- while (nextptr != NULL) {
- if (nextptr->type != type) {
- nextptr = nextptr->next;
- continue;
- }
- port_info[i] = nextptr;
- nextptr = nextptr->next;
- i++;
- }
-
- /* sort the nodes to assign geo_address */
- (void) qsort((void *)port_info, num_ports,
- sizeof (port_info_t *), compare);
- for (i = 0; i < num_ports; i++) {
- if (port_info[i] != NULL) {
- port_info[i]->geo_addr = i + 1;
- }
- }
- free(port_info);
- return (PICL_SUCCESS);
-}
-
-static picl_errno_t
-create_port_config_info(plist_t *list, frutree_device_args_t *devp)
-{
- port_info_t *port_info = NULL;
- frutree_cache_t *cachep = NULL;
- char port_type[PICL_PROPNAMELEN_MAX];
- char label[PICL_PROPNAMELEN_MAX];
-
- if (list == NULL) {
- return (PICL_FAILURE);
- }
-
- port_info = list->first;
- while (port_info != NULL) {
-
- cachep = (frutree_cache_t *)malloc(sizeof (frutree_cache_t));
- if (cachep == NULL) {
- return (PICL_NOSPACE);
- }
-
- switch (port_info->type) {
- case NETWORK_PORT:
- (void) strncpy(label, SANIBEL_NETWORK_LABEL,
- sizeof (label));
- (void) strncpy(port_type, SANIBEL_NETWORK_PORT,
- sizeof (port_type));
- break;
- case PARALLEL_PORT:
- (void) strncpy(label, SANIBEL_PARALLEL_PORT,
- sizeof (label));
- (void) strncpy(port_type, SANIBEL_PARALLEL_PORT,
- sizeof (port_type));
- break;
- case SERIAL_PORT:
- (void) strncpy(label, SANIBEL_SERIAL_PORT,
- sizeof (label));
- (void) strncpy(port_type, SANIBEL_SERIAL_PORT,
- sizeof (port_type));
- break;
- default:
- port_info = port_info->next;
- }
- cachep->buf[0] = '\0';
- cachep->next = NULL;
- (void) snprintf(cachep->buf,
- sizeof (cachep->buf),
- "\n%s %s%d %s\n"
- "\t%s %s %s %s 0 \"%s %d\"\n"
- "\t%s %s %s %s 0 \"%s\"\n"
- "\t%s %s %s %s 1 %d\n"
- "\t%s %s %s %s 0 \"%s\"\n"
- "\t%s %s %s %s 0 \"%s\"\n"
- "%s\n",
- "NODE", port_info->drv_name, port_info->instance,
- PICL_CLASS_PORT,
- "PROP", PICL_PROP_LABEL, "string", "r",
- label, (port_info->geo_addr -1),
- "PROP", PICL_PROP_BUS_ADDR, "string",
- "r", port_info->bus_addr,
- "PROP", PICL_PROP_GEO_ADDR, "uint",
- "r", port_info->geo_addr,
- "PROP", PICL_PROP_PORT_TYPE, "string",
- "r", port_type,
- "PROP", PICL_PROP_DEVFS_PATH, "string",
- "r", port_info->devfs_path,
- "ENDNODE");
-
- /* add to the cache */
- if (devp->first == NULL) { /* 1st node */
- devp->first = cachep;
- devp->last = NULL;
- } else if (devp->last != NULL) { /* last node */
- devp->last->next = cachep;
- devp->last = cachep;
- } else { /* 2nd node */
- devp->first->next = cachep;
- devp->last = cachep;
- }
- port_info = port_info->next; /* advance to next node */
- }
- return (PICL_SUCCESS);
-}
-
-/*ARGSUSED*/
-static int
-load_driver(di_node_t node, void *arg)
-{
- char *drv_name = NULL;
- char cmd[MAXPATHLEN];
-
- if (di_node_state(node) >= DS_ATTACHED) {
- return (DI_WALK_CONTINUE);
- }
- drv_name = di_driver_name(node);
- if (drv_name == NULL) {
- return (DI_WALK_CONTINUE);
- }
-
- (void) snprintf(cmd, sizeof (cmd), "%s %s",
- DEVFSADM_CMD, drv_name);
- (void) pclose(popen(cmd, "r"));
- return (DI_WALK_CONTINUE);
-}
-
-static picl_errno_t
-load_drivers(char *path)
-{
- di_node_t rnode;
- if (path == NULL) {
- return (PICL_INVALIDARG);
- }
-
- rnode = di_init(path, DINFOSUBTREE|DINFOMINOR);
- if (rnode == DI_NODE_NIL) {
- return (PICL_FAILURE);
- }
-
- if (di_walk_node(rnode, DI_WALK_CLDFIRST, NULL, load_driver) != 0) {
- di_fini(rnode);
- return (PICL_FAILURE);
- }
-
- di_fini(rnode);
- return (PICL_SUCCESS);
-}
-
-/*
- * probe for port nodes
- */
-static int
-probe_tree(di_node_t node, void *arg)
-{
- char *nodetype = NULL;
- char *devfs_path = NULL;
- char *bus_addr = NULL;
- char *drv_name = NULL;
- plist_t *listptr = NULL;
- port_info_t *port_info = NULL;
- frutree_port_type_t port_type = UNKNOWN_PORT;
- di_minor_t minor = DI_MINOR_NIL;
-
- if (arg == NULL) {
- return (DI_WALK_TERMINATE);
- }
- listptr = (plist_t *)arg;
-
- while ((minor = di_minor_next(node, minor)) != DI_MINOR_NIL) {
- nodetype = di_minor_nodetype(minor);
- if (nodetype == NULL) {
- continue;
- }
-
- if (strcmp(nodetype, DDI_NT_NET) == 0) {
- port_type = NETWORK_PORT;
- } else if (strcmp(nodetype, DDI_NT_PARALLEL) == 0) {
- port_type = PARALLEL_PORT;
- } else if ((strcmp(nodetype, DDI_NT_SERIAL) == 0) ||
- (strcmp(nodetype, DDI_NT_SERIAL_MB) == 0) ||
- (strcmp(nodetype, DDI_NT_SERIAL_DO) == 0) ||
- (strcmp(nodetype, DDI_NT_SERIAL_MB_DO) == 0)) {
- port_type = SERIAL_PORT;
- } else {
- continue;
- }
-
- /* found port node */
- devfs_path = di_devfs_path(node);
- if (devfs_path == NULL) {
- continue;
- }
-
- bus_addr = di_bus_addr(node);
- drv_name = di_driver_name(node);
-
- if ((bus_addr == NULL) || (drv_name == NULL)) {
- di_devfs_path_free(devfs_path);
- continue;
- }
-
- port_info = malloc(sizeof (port_info_t));
- if (port_info == NULL) {
- di_devfs_path_free(devfs_path);
- return (PICL_NOSPACE);
- }
-
- (void) strncpy(port_info->devfs_path, devfs_path,
- sizeof (port_info->devfs_path));
- (void) strncpy(port_info->bus_addr, bus_addr,
- sizeof (port_info->bus_addr));
- (void) strncpy(port_info->drv_name, drv_name,
- sizeof (port_info->drv_name));
- port_info->type = port_type;
- port_info->instance = di_instance(node);
- port_info->geo_addr = -1;
- port_info->next = NULL;
-
- switch (port_type) {
- case NETWORK_PORT:
- listptr->n_network++;
- break;
- case SERIAL_PORT:
- listptr->n_serial++;
- break;
- case PARALLEL_PORT:
- listptr->n_parallel++;
- break;
- }
-
- /* add to the list */
- if (listptr->first == NULL) { /* 1st node */
- listptr->first = port_info;
- listptr->last = NULL;
- } else if (listptr->last != NULL) { /* last node */
- listptr->last->next = port_info;
- listptr->last = port_info;
- } else { /* 2nd node */
- listptr->first->next = port_info;
- listptr->last = port_info;
- }
- di_devfs_path_free(devfs_path);
- return (DI_WALK_CONTINUE);
- }
- return (DI_WALK_CONTINUE);
-}
-
-/* This routine probes libdevinfo for port nodes */
-picl_errno_t
-probe_libdevinfo(frutree_frunode_t *frup, frutree_device_args_t ** device,
- boolean_t load_drv)
-{
- di_node_t rnode;
- picl_errno_t rc;
- plist_t list;
-
- if (frup == NULL) {
- return (PICL_FAILURE);
- }
- FRUTREE_DEBUG1(EVENTS, "loading drivers for %s", frup->name);
-
- if (load_drv == B_TRUE) {
- if ((rc = load_drivers(frup->fru_path)) != PICL_SUCCESS) {
- return (rc);
- }
- }
- FRUTREE_DEBUG1(EVENTS, "done with loading drivers for %s", frup->name);
-
- rnode = di_init(frup->fru_path, DINFOSUBTREE|DINFOMINOR);
- if (rnode == DI_NODE_NIL) {
- return (PICL_FAILURE);
- }
-
- list.first = NULL;
- list.last = NULL;
- list.n_network = 0;
- list.n_serial = 0;
- list.n_parallel = 0;
-
- if (di_walk_node(rnode, DI_WALK_CLDFIRST, &list, probe_tree) != 0) {
- di_fini(rnode);
- free_list(&list);
- return (PICL_FAILURE);
- }
-
- if (list.n_serial > 0)
- if ((rc = assign_geo_addr(&list, SERIAL_PORT)) != PICL_SUCCESS) {
- di_fini(rnode);
- free_list(&list);
- return (rc);
- }
-
- if (list.n_network > 0)
- if ((rc = assign_geo_addr(&list, NETWORK_PORT)) != PICL_SUCCESS) {
- di_fini(rnode);
- free_list(&list);
- return (rc);
- }
-
- if (list.n_parallel > 0)
- if ((rc = assign_geo_addr(&list, PARALLEL_PORT)) != PICL_SUCCESS) {
- di_fini(rnode);
- free_list(&list);
- return (rc);
- }
-
- if ((rc = create_port_config_info(&list, *device)) != PICL_SUCCESS) {
- di_fini(rnode);
- free_list(&list);
- return (rc);
- }
-
- di_fini(rnode);
- free_list(&list);
- FRUTREE_DEBUG1(EVENTS, "done with probing %s", frup->name);
- return (PICL_SUCCESS);
-}
-
-static int
-get_reg_dev(di_node_t node)
-{
- int *reg = NULL;
- if (di_prop_lookup_ints(DDI_DEV_T_ANY, node, OBP_REG, &reg) < 0) {
- if (di_prom_prop_lookup_ints(prom_handle, node, OBP_REG,
- &reg) < 0) {
- return (-1);
- }
- return (PCI_REG_DEV_G(reg[0]));
- }
- return (PCI_REG_DEV_G(reg[0]));
-}
-
-static int
-walk_tree(di_node_t node, void *arg)
-{
- char *path = NULL;
- char *bus_addr = NULL;
- char *char_di_bus_addr = NULL;
- int busaddr = 0;
- int di_busaddr = 0;
- char *node_name = NULL;
- frutree_devinfo_t *devinfo;
- frutree_frunode_t *frup = NULL;
-
- devinfo = *(frutree_devinfo_t **)arg;
- frup = (frutree_frunode_t *)devinfo->arg;
- if (frup == NULL) {
- return (DI_WALK_TERMINATE);
- }
-
- if (devinfo->rnode == node) { /* skip the root node */
- return (DI_WALK_CONTINUE);
- }
- bus_addr = devinfo->bus_addr;
-
- char_di_bus_addr = di_bus_addr(node);
- if (char_di_bus_addr == NULL) {
- /*
- * look for reg property
- * This applies to only cPCI devices
- */
- if (strstr(bus_addr, ",") != NULL) {
- /* bus addr is of type 1,0 */
- /* we dont handle this case yet */
- return (DI_WALK_PRUNECHILD);
- }
- di_busaddr = get_reg_dev(node);
- if (di_busaddr == -1) {
- /* reg prop not found */
- return (DI_WALK_PRUNECHILD);
- }
-
- /* check if the bus addresses are same */
- errno = 0;
- busaddr = strtol(bus_addr, (char **)NULL, 16);
- if (errno != 0) {
- return (DI_WALK_TERMINATE);
- }
- if (di_busaddr != busaddr) {
- return (DI_WALK_PRUNECHILD);
- }
-
- /* build the fru path name */
- /* parent_path/nodename@bus_addr */
- node_name = di_node_name(node);
- if (node_name == NULL) {
- return (DI_WALK_TERMINATE);
- }
- (void) snprintf(devinfo->path, sizeof (devinfo->path),
- "%s/%s@%s", frup->fru_path, node_name, bus_addr);
- return (DI_WALK_TERMINATE);
- }
-
- if (strstr(bus_addr, ",") != NULL) { /* bus addr is of type 1,0 */
- if (strcmp(bus_addr, char_di_bus_addr) != 0) {
- return (DI_WALK_PRUNECHILD);
- }
- } else { /* bus addr is of type 0x */
-
- /* check if the values are same */
- errno = 0;
- busaddr = strtol(bus_addr, (char **)NULL, 16);
- if (errno != 0) {
- return (DI_WALK_TERMINATE);
- }
-
- errno = 0;
- di_busaddr = strtol(char_di_bus_addr, (char **)NULL, 16);
- if (errno != 0) {
- return (DI_WALK_TERMINATE);
- }
-
- if (di_busaddr != busaddr) {
- return (DI_WALK_PRUNECHILD);
- }
- }
-
- /* node found */
- path = di_devfs_path(node);
- (void) strncpy(devinfo->path, path, sizeof (devinfo->path));
- di_devfs_path_free(path);
- return (DI_WALK_TERMINATE);
-}
-
-picl_errno_t
-get_fru_path(char *parent_path, frutree_frunode_t *frup)
-{
- picl_errno_t rc = 0;
- picl_nodehdl_t loch;
- di_node_t rnode;
- frutree_devinfo_t *devinfo = NULL;
- char slot_type[PICL_PROPNAMELEN_MAX];
- char probe_path[PICL_PROPNAMELEN_MAX];
- char bus_addr[PICL_PROPNAMELEN_MAX];
-
- if ((rc = ptree_get_propval_by_name(frup->frunodeh, PICL_PROP_PARENT,
- &loch, sizeof (loch))) != PICL_SUCCESS) {
- return (rc);
- }
-
- if ((rc = ptree_get_propval_by_name(loch, PICL_PROP_SLOT_TYPE,
- slot_type, sizeof (slot_type))) != PICL_SUCCESS) {
- return (rc);
- }
-
- if (strcmp(slot_type, SANIBEL_SCSI_SLOT) == 0 ||
- strcmp(slot_type, SANIBEL_IDE_SLOT) == 0) {
- if (ptree_get_propval_by_name(loch, PICL_PROP_PROBE_PATH,
- probe_path, sizeof (probe_path)) != PICL_SUCCESS) {
- return (rc);
- }
- (void) strncpy(frup->fru_path, probe_path,
- sizeof (frup->fru_path));
- return (PICL_SUCCESS);
- }
-
- prom_handle = di_prom_init();
- rnode = di_init(parent_path, DINFOSUBTREE|DINFOMINOR);
- if (rnode == DI_NODE_NIL) {
- di_prom_fini(prom_handle);
- return (PICL_FAILURE);
- }
-
- devinfo = (frutree_devinfo_t *)malloc(sizeof (frutree_devinfo_t));
- if (devinfo == NULL) {
- di_fini(rnode);
- di_prom_fini(prom_handle);
- return (PICL_NOSPACE);
- }
-
- if (ptree_get_propval_by_name(loch, PICL_PROP_BUS_ADDR,
- bus_addr, sizeof (bus_addr)) != PICL_SUCCESS) {
- free(devinfo);
- di_fini(rnode);
- di_prom_fini(prom_handle);
- return (rc);
- }
-
- devinfo->rnode = rnode;
- (void) strncpy(devinfo->bus_addr, bus_addr, sizeof (devinfo->bus_addr));
- devinfo->path[0] = '\0';
- devinfo->arg = frup;
-
- if (di_walk_node(rnode, DI_WALK_SIBFIRST, &devinfo, walk_tree) != 0) {
- di_fini(rnode);
- di_prom_fini(prom_handle);
- free(devinfo);
- return (PICL_FAILURE);
- }
- di_fini(rnode);
- di_prom_fini(prom_handle);
-
- if (devinfo->path[0]) {
- (void) strncpy(frup->fru_path, devinfo->path,
- sizeof (frup->fru_path));
- free(devinfo);
- return (PICL_SUCCESS);
- } else {
- free(devinfo);
- return (PICL_NODENOTFOUND);
- }
-}
-
-static int
-find_fru_node(di_node_t node, void *arg)
-{
- frutree_locnode_t *locp = NULL;
- char *char_di_bus_addr = NULL;
- int busaddr = 0;
- int di_busaddr = 0;
- char bus_addr[PICL_PROPNAMELEN_MAX];
- frutree_devinfo_t *devinfo = NULL;
-
- devinfo = *(frutree_devinfo_t **)arg;
- locp = *(frutree_locnode_t **)devinfo->arg;
-
- if (devinfo->rnode == node) {
- return (DI_WALK_CONTINUE);
- }
-
- char_di_bus_addr = di_bus_addr(node);
- if (char_di_bus_addr == NULL) {
- return (DI_WALK_PRUNECHILD);
- }
-
- if (ptree_get_propval_by_name(locp->locnodeh, PICL_PROP_BUS_ADDR,
- bus_addr, sizeof (bus_addr)) != PICL_SUCCESS) {
- return (DI_WALK_PRUNECHILD);
- }
-
- if (strstr(bus_addr, ",") != NULL) {
- /* bus addr is of type 1,0 */
- if (strcmp(bus_addr, char_di_bus_addr) == 0) {
- devinfo->retval = PICL_SUCCESS;
- return (DI_WALK_TERMINATE);
- } else {
- return (DI_WALK_PRUNECHILD);
- }
- } else { /* bus addr is of type 0x */
-
- /* check if the values are same */
- errno = 0;
- busaddr = strtol(bus_addr, (char **)NULL, 16);
- if (errno != 0) {
- return (DI_WALK_PRUNECHILD);
- }
-
- errno = 0;
- di_busaddr = strtol(char_di_bus_addr, (char **)NULL, 16);
- if (errno != 0) {
- return (DI_WALK_PRUNECHILD);
- }
-
- if (di_busaddr == busaddr) {
- devinfo->retval = PICL_SUCCESS;
- return (DI_WALK_TERMINATE);
- } else {
- return (DI_WALK_PRUNECHILD);
- }
- }
-}
-
-/*
- * checks if a fru is present under location using pdev-path and busaddr
- */
-boolean_t
-is_fru_present_under_location(frutree_locnode_t *locp)
-{
- di_node_t rnode;
- frutree_devinfo_t *devinfo = NULL;
- char probe_path[PICL_PROPNAMELEN_MAX];
-
- if (locp == NULL) {
- return (B_FALSE);
- }
-
- if (ptree_get_propval_by_name(locp->locnodeh, PICL_PROP_PROBE_PATH,
- probe_path, sizeof (probe_path)) != PICL_SUCCESS) {
- if (ptree_get_propval_by_name(locp->locnodeh,
- PICL_PROP_DEVFS_PATH, probe_path,
- sizeof (probe_path)) != PICL_SUCCESS) {
- return (B_FALSE);
- }
- }
-
- rnode = di_init(probe_path, DINFOSUBTREE);
- if (rnode == DI_NODE_NIL) {
- di_fini(rnode);
- return (B_FALSE);
- }
-
- devinfo = (frutree_devinfo_t *)malloc(sizeof (frutree_devinfo_t));
- if (devinfo == NULL) {
- di_fini(rnode);
- return (B_FALSE);
- }
- devinfo->rnode = rnode;
- devinfo->arg = (frutree_locnode_t **)&locp;
- devinfo->retval = PICL_FAILURE;
-
- if (di_walk_node(rnode, DI_WALK_SIBFIRST, &devinfo,
- find_fru_node) != 0) {
- di_fini(rnode);
- free(devinfo);
- return (B_FALSE);
- }
- di_fini(rnode);
-
- if (devinfo->retval == PICL_SUCCESS) {
- free(devinfo);
- return (B_TRUE);
- } else {
- free(devinfo);
- return (B_FALSE);
- }
-}
-
-/*
- * initializes the port driver and instance fields based on libdevinfo
- */
-picl_errno_t
-get_port_info(frutree_portnode_t *portp)
-{
- picl_errno_t rc;
- di_node_t rnode, curr, peer;
- char devfs_path[PICL_PROPNAMELEN_MAX];
- char bus_addr[PICL_PROPNAMELEN_MAX];
- char *di_busaddr = NULL, *di_drv = NULL;
- int di_int_busaddr, int_busaddr;
-
- if ((rc = ptree_get_propval_by_name(portp->portnodeh,
- PICL_PROP_DEVFS_PATH, devfs_path,
- sizeof (devfs_path))) != PICL_SUCCESS) {
- return (rc);
- }
-
- if (ptree_get_propval_by_name(portp->portnodeh, PICL_PROP_BUS_ADDR,
- bus_addr, sizeof (bus_addr)) != PICL_SUCCESS) {
- return (rc);
- }
-
- rnode = di_init(devfs_path, DINFOCPYALL);
- if (rnode == DI_NODE_NIL) {
- return (PICL_FAILURE);
- }
-
- peer = di_child_node(rnode);
- while (peer != DI_NODE_NIL) {
- curr = peer;
- peer = di_sibling_node(curr);
-
- di_busaddr = di_bus_addr(curr);
- if (di_busaddr == NULL) {
- continue;
- }
-
- /* compare the bus_addr */
- if (strstr(bus_addr, ",") != NULL) {
- /* bus addr is of type 1,0 */
- if (strcmp(bus_addr, di_busaddr) != 0) {
- continue;
- }
- } else { /* bus addr is of type 0x */
- errno = 0;
- int_busaddr = strtol(bus_addr, (char **)NULL, 16);
- if (errno != 0) {
- continue;
- }
-
- errno = 0;
- di_int_busaddr = strtol(di_busaddr, (char **)NULL, 16);
- if (errno != 0) {
- continue;
- }
-
- if (di_int_busaddr != int_busaddr) {
- continue;
- }
- }
- di_drv = di_driver_name(curr);
- if (di_drv == NULL) {
- di_fini(rnode);
- return (PICL_FAILURE);
- }
- /* initialize the driver name and instance number */
- (void) strncpy(portp->driver, di_drv, sizeof (portp->driver));
- portp->instance = di_instance(curr);
- di_fini(rnode);
- return (PICL_SUCCESS);
- }
- di_fini(rnode);
- return (PICL_NODENOTFOUND);
-}
diff --git a/usr/src/cmd/picl/plugins/sun4u/snowbird/frutree/piclscsi.c b/usr/src/cmd/picl/plugins/sun4u/snowbird/frutree/piclscsi.c
deleted file mode 100644
index 25280a5644..0000000000
--- a/usr/src/cmd/picl/plugins/sun4u/snowbird/frutree/piclscsi.c
+++ /dev/null
@@ -1,899 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (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 2005 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/* implementation specific to scsi nodes probing */
-
-#include <stdio.h>
-#include <unistd.h>
-#include <syslog.h>
-#include <stdlib.h>
-#include <sys/param.h>
-#include <config_admin.h>
-#include <string.h>
-#include <strings.h>
-#include <picl.h>
-#include <picltree.h>
-#include <libintl.h>
-#include <libdevinfo.h>
-#include <sys/types.h>
-#include <picldefs.h>
-#include "piclfrutree.h"
-
-#define SCSI_SLOT "scsi-bus"
-#define SCSI_LOC_FORMAT "t%dd0"
-#define TARGET "target"
-#define CLASS "class"
-#define BUF_SIZE 256
-
-#define SCSI_INITIATOR_ID 7
-#define DRV_TYPE_DSK 1
-#define DRV_TYPE_TAPE 2
-#define NUM_DSK_TARGS 15
-/*
- * No support for wide tapes for now.
- * If required wide support, set this to 8
- * See st.conf.
- */
-#define NUM_TAPE_TARGS 7
-
-#define DIRLINK_DSK "dsk"
-#define DIRLINK_RMT "rmt"
-#define DRV_SCSI_DSK "sd"
-#define DRV_SCSI_TAPE "st"
-#define NULL_ENTRY 0
-
-/* currently supported directory strings for SCSI FRUs in cfgadm APs */
-static char *scsi_dirlink_names[] = { DIRLINK_DSK, DIRLINK_RMT, NULL_ENTRY};
-/* currently supported SCSI FRU drivers */
-static struct scsi_drv_info {
- char *drv_name;
- uint8_t num_targets;
- uint8_t drv_type;
-} scsi_drv[] = {
- DRV_SCSI_DSK, NUM_DSK_TARGS, DRV_TYPE_DSK,
- DRV_SCSI_TAPE, NUM_TAPE_TARGS, DRV_TYPE_TAPE,
- NULL_ENTRY, NULL_ENTRY, NULL_ENTRY
- };
-
-/* the following defs are based on defines in scsi cfgadm plugin */
-#define CDROM "CD-ROM"
-#define RMM "tape"
-#define DISK "disk"
-
-extern boolean_t is_location_present_in_subtree(frutree_frunode_t *,
- const char *, const char *);
-extern picl_errno_t create_children(frutree_frunode_t *, char *, char *,
- int, char *, boolean_t);
-extern char *strtok_r(char *s1, const char *s2, char **lasts);
-extern boolean_t frutree_connects_initiated;
-extern int frutree_debug;
-
-typedef struct node {
- struct node *next;
- cfga_list_data_t *data;
-} node_t;
-
-typedef struct linked_list {
- node_t *first;
- int num_nodes;
-} plist_t;
-
-typedef struct scsi_info {
- frutree_frunode_t *frup;
- cfga_list_data_t *cfgalist;
- plist_t *list;
- int num_list;
- boolean_t compare_cfgadm;
- int geo_addr;
-} scsi_info_t;
-
-static plist_t *scsi_list = NULL;
-static cfga_list_data_t *cfglist = NULL;
-static int nlist = 0;
-
-static void
-free_list(plist_t *list)
-{
- node_t *tmp = NULL, *tmp1 = NULL;
-
- if (list == NULL)
- return;
- tmp = list->first;
- while (tmp != NULL) {
- free(tmp->data);
- tmp1 = tmp->next;
- free(tmp);
- tmp = tmp1;
- }
-}
-
-/*
- * This routine gets the list of scsi controllers present
- */
-static cfga_err_t
-populate_controllers_list(plist_t *cntrl_list, cfga_list_data_t *list, int num)
-{
- int i;
- node_t *nodeptr = NULL;
- cfga_list_data_t *temp = NULL;
-
- if (cntrl_list == NULL || list == NULL) {
- return (CFGA_ATTR_INVAL);
- }
-
- cntrl_list->first = NULL;
- cntrl_list->num_nodes = 0;
-
- if (num == 0) {
- return (CFGA_OK);
- }
-
- for (i = 0; i < num; i++) {
- if (strcmp(list[i].ap_type, SCSI_SLOT) != 0) {
- continue;
- }
-
- /* scsi controller */
- temp = (cfga_list_data_t *)malloc(sizeof (cfga_list_data_t));
- if (temp == NULL) {
- return (CFGA_ERROR);
- }
- (void) memcpy(temp, &list[i], sizeof (cfga_list_data_t));
-
- nodeptr = (node_t *)malloc(sizeof (node_t));
- if (nodeptr == NULL) {
- free(temp);
- return (CFGA_ERROR);
- }
- nodeptr->data = temp;
- nodeptr->next = NULL;
-
- /* append to the list */
- if (cntrl_list->first == NULL) {
- cntrl_list->first = nodeptr;
- cntrl_list->num_nodes++;
- } else {
- nodeptr->next = cntrl_list->first;
- cntrl_list->first = nodeptr;
- cntrl_list->num_nodes++;
- }
- }
- return (CFGA_OK);
-}
-
-picl_errno_t
-scsi_info_init()
-{
- cfga_err_t ap_list_err;
-
- ap_list_err = config_list_ext(0, NULL, &cfglist, &nlist, NULL,
- NULL, NULL, CFGA_FLAG_LIST_ALL);
-
- if (ap_list_err != CFGA_OK) {
- if (ap_list_err == CFGA_NOTSUPP) {
- return (PICL_SUCCESS);
- } else {
- return (PICL_FAILURE);
- }
- }
-
- scsi_list = (plist_t *)malloc(sizeof (plist_t));
- if (scsi_list == NULL) {
- free(cfglist);
- return (PICL_NOSPACE);
- }
-
- ap_list_err = populate_controllers_list(scsi_list, cfglist, nlist);
- if (ap_list_err != CFGA_OK) {
- free(cfglist);
- free(scsi_list);
- return (PICL_FAILURE);
- }
- return (PICL_SUCCESS);
-}
-
-void
-scsi_info_fini()
-{
- free(cfglist);
- free_list(scsi_list);
- free(scsi_list);
-}
-
-/*
- * This routine searches the controllers list to find the mapping based
- * on given devfs_path.
- * caller should allocate memory for ap_id
- */
-static picl_errno_t
-find_scsi_controller(char *devfs_path, plist_t *list, char *ap_id)
-{
- node_t *tmp = NULL;
- char *lasts = NULL;
- char *token = NULL;
- char path[MAXPATHLEN];
-
- if (devfs_path == NULL || ap_id == NULL) {
- return (PICL_INVALIDARG);
- }
- (void) snprintf((char *)path, sizeof (path), "/devices%s", devfs_path);
-
- tmp = list->first;
- while (tmp != NULL) {
- lasts = tmp->data->ap_phys_id;
- token = (char *)strtok_r(lasts, (const char *)":",
- (char **)&lasts);
- if (token == NULL) {
- tmp = tmp->next;
- continue;
- }
-
- if (strcmp(path, token) == 0) { /* match found */
- (void) strncpy(ap_id, tmp->data->ap_log_id,
- sizeof (ap_id));
- return (PICL_SUCCESS);
- }
- tmp = tmp->next;
- }
- return (PICL_NODENOTFOUND);
-}
-
-/*
- * This routine dynamically determines the cfgadm attachment point
- * for a given devfspath and target id.
- * memory for name should be allocated by the caller.
- */
-picl_errno_t
-get_scsislot_name(char *devfs_path, char *bus_addr, char *name)
-{
- picl_errno_t rc;
- int target_id = 0;
- int numlist;
- plist_t list;
- cfga_err_t ap_list_err;
- cfga_list_data_t *cfgalist = NULL;
- char controller[MAXPATHLEN];
-
- ap_list_err = config_list_ext(0, NULL, &cfgalist,
- &numlist, NULL, NULL, NULL, CFGA_FLAG_LIST_ALL);
- if (ap_list_err != CFGA_OK) {
- return (PICL_NODENOTFOUND);
- }
-
- ap_list_err = populate_controllers_list(&list, cfgalist,
- numlist);
- if (ap_list_err != CFGA_OK) {
- free_list(&list);
- free(cfgalist);
- return (PICL_NODENOTFOUND);
- }
-
- if (list.num_nodes <= 0) {
- free(cfgalist);
- return (PICL_NODENOTFOUND);
- }
-
- if ((rc = find_scsi_controller(devfs_path, &list,
- controller)) != PICL_SUCCESS) {
- free(cfgalist);
- free_list(&list);
- return (rc);
- }
- target_id = strtol(bus_addr, (char **)NULL, 16);
- (void) sprintf(name, "%s::dsk/%st%dd0", controller,
- controller, target_id);
- free(cfgalist);
- free_list(&list);
- return (PICL_SUCCESS);
-}
-
-/*
- * Arg scsi_loc can be any of the following forms appearing in cfgadm output
- * c0::dsk/c0t0d0
- * c1::sd56
- * c2::rmt/0
- * c3::st41
- * dsk/c1t1d0
- * rmt/1
- * /devices/pci@1f,0/pci@1,1/scsi@2:scsi::dsk/c0t0d0
- *
- * On return, bus_addr contains the target id of the device.
- * Please note that currently the target id is computed. It is better
- * to eventually change this to getting from libdevinfo.
- * Also, please note that SCSI_INITIATOR_ID should not
- * be hardcoded, but should be dynamically retrieved from an OBP property.
- */
-static void
-get_bus_addr(char *scsi_loc, char **bus_addr)
-{
- char *ap, *token, *p, *ap_idp;
- int len = 0, i = 0;
- char parse_link = 0;
- char addr[BUF_SIZE], ap_id[BUF_SIZE];
- char fileinfo[BUF_SIZE], ap_id_link[BUF_SIZE];
-
- (void) strncpy(ap_id, scsi_loc, sizeof (ap_id));
- ap = strrchr(ap_id, ':');
- if (!ap)
- ap = ap_idp = ap_id;
- else
- ap_idp = ++ap;
-
- while (scsi_dirlink_names[i] && !len) {
- len = strspn(ap, scsi_dirlink_names[i++]);
- /*
- * strspn may return positive len even when there is no
- * complete string matches!!! hence the following check is
- * necessary. So ensure the string match.
- */
- if (len && strstr(ap, scsi_dirlink_names[i-1]))
- break;
- len = 0;
- }
- if (len)
- parse_link = 1;
- else {
- i = 0;
- while (scsi_drv[i].drv_name && !len) {
- len = strspn(ap, scsi_drv[i++].drv_name);
- if (len && strstr(ap, scsi_drv[i-1].drv_name))
- break;
- len = 0;
- }
- }
- ap += len;
- if (strlen(ap) && parse_link) {
-
- /* slice 0 must be present in the system */
- if (strstr(ap, "/c")) {
- if (strstr(ap, "s0") == NULL)
- (void) strcat(ap, "s0");
- }
- /* get the devlink and read the target id from minor node */
- (void) snprintf(ap_id_link, sizeof (ap_id_link), "/dev/%s",
- ap_idp);
- (void) bzero(fileinfo, sizeof (fileinfo));
- if (readlink(ap_id_link, fileinfo, sizeof (fileinfo)) < 0)
- return;
- if (!fileinfo[0])
- return;
- ap = strrchr(fileinfo, '@');
- ap++;
- }
- token = (char *)strtok_r(ap, ",", &p);
- (void) strncpy(addr, token, sizeof (addr));
- if (!parse_link) {
- int drv_inst = atoi(token);
- int tmp_targ_id = drv_inst % scsi_drv[i-1].num_targets;
- int targ_id = scsi_drv[i-1].drv_type == DRV_TYPE_DSK ?
- (tmp_targ_id < SCSI_INITIATOR_ID ?
- tmp_targ_id : tmp_targ_id+1):
- DRV_TYPE_TAPE ? tmp_targ_id : drv_inst;
- (void) snprintf(addr, sizeof (addr), "%d", targ_id);
- }
- if (strlen(addr)) {
- *bus_addr = (char *)malloc(strlen(addr)+1);
- if ((*bus_addr) == NULL)
- return;
- (void) strcpy((char *)*bus_addr, addr);
- }
-}
-
-/*
- * This routine determines all the scsi nodes under a FRU and
- * creates a subtree of all the scsi nodes with basic properties.
- */
-static picl_errno_t
-dyn_probe_for_scsi_frus(frutree_frunode_t *frup, cfga_list_data_t *cfgalist,
- plist_t *list, int numlist)
-{
- picl_errno_t rc;
- int i, geo_addr = 0;
- node_t *curr = NULL;
- char *bus_addr = NULL;
- char path[MAXPATHLEN];
- char controller_name[MAXPATHLEN];
-
- /* for each controller in the list, find if disk/fru is present */
- curr = list->first;
- while (curr != NULL) {
- /* compare the path */
- (void) snprintf((char *)path, sizeof (path), "/devices%s",
- frup->fru_path);
- if (strstr(curr->data->ap_phys_id, path) == NULL) {
- curr = curr->next;
- continue;
-
- }
- (void) snprintf(controller_name, sizeof (controller_name),
- "%s::", curr->data->ap_log_id);
-
- for (i = 0; i < numlist; i++) {
- if (strcmp(cfgalist[i].ap_type, SCSI_SLOT) == 0) {
- continue;
- }
- if (strstr(cfgalist[i].ap_log_id,
- controller_name) == NULL) {
- continue;
- }
- /* check if device is under fru */
- if (strstr(cfgalist[i].ap_phys_id, path) == NULL) {
- continue;
- }
-
- /* we found a scsi fru */
- geo_addr++;
- /* check if the device is present in subtree */
- if (is_location_present_in_subtree(frup,
- cfgalist[i].ap_log_id, path) == B_TRUE) {
- continue;
- }
- get_bus_addr(cfgalist[i].ap_log_id, &bus_addr);
- if (bus_addr == NULL) {
- continue;
- }
- rc = create_children(frup, cfgalist[i].ap_log_id,
- bus_addr, geo_addr, SANIBEL_SCSI_SLOT, B_TRUE);
- free(bus_addr);
- if (rc != PICL_SUCCESS) {
- FRUTREE_DEBUG3(FRUTREE_INIT, "SUNW_frutree:"
- "Error in creating node %s under %s(error=%d)",
- cfgalist[i].ap_log_id, frup->name, rc);
- }
- }
- curr = curr->next;
- }
- return (PICL_SUCCESS);
-}
-
-/*
- * data used here is cached information (cfglist, nlist)
- */
-static picl_errno_t
-cache_probe_for_scsi_frus(frutree_frunode_t *frup)
-{
- int i, geo_addr = 0;
- picl_errno_t rc;
- node_t *curr = NULL;
- char path[MAXPATHLEN];
- char controller_name[MAXPATHLEN];
- char *bus_addr = NULL;
-
- /* for each controller in the list, find if disk/fru is present */
- if (scsi_list == NULL) {
- return (PICL_SUCCESS);
- }
- curr = scsi_list->first;
- while (curr != NULL) {
- /* compare the path */
- (void) snprintf((char *)path, sizeof (path), "/devices%s",
- frup->fru_path);
- if (strstr(curr->data->ap_phys_id, path) == NULL) {
- curr = curr->next;
- continue;
- }
- (void) snprintf(controller_name, sizeof (controller_name),
- "%s::", curr->data->ap_log_id);
-
- for (i = 0; i < nlist; i++) {
- if (strcmp(cfglist[i].ap_type, SCSI_SLOT) == 0) {
- continue;
- }
- if (strstr(cfglist[i].ap_log_id,
- controller_name) == NULL) {
- continue;
- }
- /* check if the device is under fru */
- if (strstr(cfglist[i].ap_phys_id, path) == NULL) {
- continue;
- }
-
- /* we found a scsi fru */
- geo_addr++;
- /* check if the device is present in subtree */
- if (is_location_present_in_subtree(frup,
- cfglist[i].ap_log_id, path) == B_TRUE) {
- continue;
- }
- get_bus_addr(cfglist[i].ap_log_id, &bus_addr);
- if (bus_addr == NULL) {
- continue;
- }
- rc = create_children(frup, cfglist[i].ap_log_id,
- bus_addr, geo_addr, SANIBEL_SCSI_SLOT, B_TRUE);
- free(bus_addr);
- if (rc != PICL_SUCCESS) {
- FRUTREE_DEBUG3(FRUTREE_INIT, "SUNW_frutree:"
- "Error in creating node %s under %s(error=%d)",
- cfglist[i].ap_log_id, frup->name, rc);
- }
- }
- curr = curr->next;
- }
- return (PICL_SUCCESS);
-}
-
-/*
- * This routine checks if the node (scsi device) is present in cfgadm data
- * Algorithm:
- * 1. traverse thru list of controllers and find
- * the controller of interest
- * 2. go thru list of devices under controller and compare if the target is same
- * 3. if yes
- * - device is already represented
- * 4. if No
- * - The node must be repreented in PICL tree.
- */
-static boolean_t
-is_node_present(scsi_info_t *scsi_info, char *devfs_path, int target)
-{
- node_t *curr = NULL;
- char path[MAXPATHLEN];
- char controller[MAXPATHLEN];
- char *bus_addr = NULL;
- char *lasts = NULL, *token = NULL;
- int i = 0;
-
- if (scsi_info == NULL) {
- return (B_FALSE);
- }
-
- if (scsi_info->list == NULL) {
- return (B_FALSE);
- }
-
- (void) snprintf(path, sizeof (path), "/devices%s", devfs_path);
-
- curr = scsi_info->list->first;
- while (curr != NULL) {
-
- lasts = curr->data->ap_phys_id;
- token = (char *)strtok_r(lasts, (const char *)":",
- (char **)&lasts);
- if (token == NULL) {
- curr = curr->next;
- continue;
- }
-
- if (strstr(path, token) == NULL) {
- /* this controller is not of interest */
- curr = curr->next;
- continue;
- }
-
- (void) snprintf(controller, sizeof (controller), "%s::",
- curr->data->ap_log_id);
- for (i = 0; i < scsi_info->num_list; i++) {
- if (strcmp(scsi_info->cfgalist[i].ap_type,
- SCSI_SLOT) == 0) {
- continue;
- }
-
- if (strstr(scsi_info->cfgalist[i].ap_log_id,
- controller) == NULL) {
- continue;
- }
-
- get_bus_addr(scsi_info->cfgalist[i].ap_phys_id,
- &bus_addr);
- /*
- * compare with target value
- */
- if (bus_addr == NULL) {
- return (B_TRUE);
- }
- if (strtoul(bus_addr, NULL, 16) == target) {
- /*
- * this device is already represented
- * in fru tree
- */
- free(bus_addr);
- return (B_TRUE);
- }
- free(bus_addr);
- }
- curr = curr->next;
- }
- return (B_FALSE);
-}
-
-static di_prop_t
-get_prop_by_name(di_node_t node, char *name)
-{
- di_prop_t prop = DI_PROP_NIL;
- char *prop_name = NULL;
-
- prop = di_prop_next(node, DI_PROP_NIL);
- while (prop != DI_PROP_NIL) {
- prop_name = di_prop_name(prop);
- if (prop_name != NULL) {
- if (strcmp(prop_name, name) == 0) {
- return (prop);
- }
- }
- prop = di_prop_next(node, prop);
- }
- return (DI_PROP_NIL);
-}
-
-static int
-get_geoaddr(picl_nodehdl_t nodeh, void *c_args)
-{
- picl_errno_t rc;
- uint8_t *geo_addr = NULL;
- char slot_type[PICL_PROPNAMELEN_MAX];
-
- if (c_args == NULL)
- return (PICL_INVALIDARG);
- geo_addr = (uint8_t *)c_args;
-
- if ((rc = ptree_get_propval_by_name(nodeh, PICL_PROP_SLOT_TYPE,
- slot_type, sizeof (slot_type))) != PICL_SUCCESS) {
- return (rc);
- }
-
- if (strcmp(slot_type, SANIBEL_SCSI_SLOT) == 0 ||
- strcmp(slot_type, SANIBEL_IDE_SLOT) == 0) {
- *geo_addr = *geo_addr + 1;
- }
- return (PICL_WALK_CONTINUE);
-}
-
-static int
-frutree_get_geoaddr(frutree_frunode_t *frup)
-{
- int geo_addr = 1;
- if (ptree_walk_tree_by_class(frup->frunodeh, PICL_CLASS_LOCATION,
- &geo_addr, get_geoaddr) != PICL_SUCCESS) {
- return (geo_addr);
- }
- return (geo_addr);
-}
-
-static int
-probe_disks(di_node_t node, void *arg)
-{
- di_prop_t prop;
- picl_errno_t rc;
- int *target_val = NULL;
- char *nodetype = NULL;
- char *devfs_path = NULL;
- char *bus_addr = NULL;
- char *drv_name = NULL;
- scsi_info_t *data = NULL;
- di_minor_t minor = DI_MINOR_NIL;
- char *class = NULL;
- char node_name[BUF_SIZE];
- char slot_type[PICL_PROPNAMELEN_MAX];
-
- if (arg == NULL)
- return (DI_WALK_TERMINATE);
-
- data = *(scsi_info_t **)arg;
- if (data == NULL) {
- return (DI_WALK_TERMINATE);
- }
-
- /* initialize the geo_addr value */
- if (data->geo_addr == 0) {
- if (data->compare_cfgadm == B_FALSE) {
- data->geo_addr = 1;
- } else {
- data->geo_addr = frutree_get_geoaddr(data->frup);
- }
- }
-
- while ((minor = di_minor_next(node, minor)) != DI_MINOR_NIL) {
- nodetype = di_minor_nodetype(minor);
- if (nodetype == NULL) {
- continue;
- }
-
- if (strcmp(nodetype, DDI_NT_BLOCK_CHAN) == 0 ||
- strcmp(nodetype, DDI_NT_BLOCK_WWN) == 0) {
- (void) snprintf(node_name, sizeof (node_name),
- "%s%d", DISK, data->geo_addr);
- } else if (strcmp(nodetype, DDI_NT_TAPE) == 0) {
- (void) snprintf(node_name, sizeof (node_name),
- "%s%d", RMM, data->geo_addr);
- } else if (strcmp(nodetype, DDI_NT_CD) == 0 ||
- strcmp(nodetype, DDI_NT_CD_CHAN) == 0) {
- (void) snprintf(node_name, sizeof (node_name),
- "%s%d", CDROM, data->geo_addr);
- } else {
- continue;
- }
-
- devfs_path = di_devfs_path(node);
- drv_name = di_driver_name(node);
- bus_addr = di_bus_addr(node);
- if (devfs_path == NULL) {
- continue;
- }
- if (drv_name == NULL || bus_addr == NULL) {
- di_devfs_path_free(devfs_path);
- continue;
- }
- prop = get_prop_by_name(node, TARGET);
- if (prop != DI_PROP_NIL) {
- di_prop_ints(prop, &target_val);
- if (data->compare_cfgadm) {
- /* check if node is present in cfgadm data */
- if (is_node_present(data, devfs_path,
- *target_val) == B_TRUE) {
- di_devfs_path_free(devfs_path);
- return (DI_WALK_CONTINUE);
- }
- }
-
- di_devfs_path_free(devfs_path);
- prop = get_prop_by_name(node, CLASS);
- if (prop != DI_PROP_NIL) {
- di_prop_strings(prop, &class);
- }
-
- /* determine the slot type based on class code */
- if (class != NULL) {
- if (strcmp(class, DEVICE_CLASS_SCSI) == 0) {
- (void) strncpy(slot_type,
- SANIBEL_SCSI_SLOT,
- sizeof (slot_type));
- } else if (strcmp(class,
- DEVICE_CLASS_IDE) == 0) {
- (void) strncpy(slot_type,
- SANIBEL_IDE_SLOT,
- sizeof (slot_type));
- } else {
- (void) strncpy(slot_type,
- SANIBEL_UNKNOWN_SLOT,
- sizeof (slot_type));
- }
-
- } else {
- (void) strncpy(slot_type, SANIBEL_UNKNOWN_SLOT,
- sizeof (slot_type));
- }
-
- if ((rc = create_children(data->frup, node_name,
- bus_addr, data->geo_addr, slot_type,
- B_FALSE)) != PICL_SUCCESS) {
- return (rc);
- }
- /* increment the geo_addr */
- data->geo_addr++;
- } else {
- di_devfs_path_free(devfs_path);
- continue;
- }
- return (DI_WALK_CONTINUE);
- }
- return (DI_WALK_CONTINUE);
-}
-
-static picl_errno_t
-probe_scsi_in_libdevinfo(frutree_frunode_t *frup, cfga_list_data_t *cfgalist,
- plist_t *list, int num_list, boolean_t compare_cfgadm)
-{
- di_node_t rnode;
- scsi_info_t *scsi_data = NULL;
-
- if (frup == NULL) {
- return (PICL_FAILURE);
- }
-
- rnode = di_init(frup->fru_path, DINFOCPYALL);
- if (rnode == DI_NODE_NIL) {
- return (PICL_FAILURE);
- }
-
- scsi_data = (scsi_info_t *)malloc(sizeof (scsi_info_t));
- if (scsi_data == NULL) {
- di_fini(rnode);
- return (PICL_NOSPACE);
- }
-
- scsi_data->frup = frup;
- scsi_data->cfgalist = cfgalist;
- scsi_data->list = list;
- scsi_data->num_list = num_list;
- scsi_data->compare_cfgadm = compare_cfgadm;
- scsi_data->geo_addr = 0;
- if (di_walk_node(rnode, DI_WALK_CLDFIRST, &scsi_data,
- probe_disks) != 0) {
- free(scsi_data);
- di_fini(rnode);
- return (PICL_FAILURE);
- }
-
- free(scsi_data);
- di_fini(rnode);
- return (PICL_SUCCESS);
-}
-
-picl_errno_t
-probe_for_scsi_frus(frutree_frunode_t *frup)
-{
- int numlist;
- picl_errno_t rc;
- plist_t list;
- cfga_err_t ap_list_err;
- cfga_list_data_t *cfgalist = NULL;
-
- if (frutree_connects_initiated == B_TRUE) { /* probing after hotswap */
- ap_list_err = config_list_ext(0, NULL, &cfgalist,
- &numlist, NULL, NULL, NULL, CFGA_FLAG_LIST_ALL);
-
- if (ap_list_err != CFGA_OK) {
- rc = probe_scsi_in_libdevinfo(frup, NULL, NULL,
- 0, B_FALSE);
- return (rc);
- }
-
- /* get list of all controllers in the system */
- ap_list_err = populate_controllers_list(&list, cfgalist,
- numlist);
- if (ap_list_err != CFGA_OK) {
- free_list(&list);
- free(cfgalist);
- rc = probe_scsi_in_libdevinfo(frup, NULL, NULL,
- 0, B_FALSE);
- return (rc);
- }
-
- /* no controllers found */
- if (list.num_nodes <= 0) {
- free_list(&list);
- free(cfgalist);
- rc = probe_scsi_in_libdevinfo(frup, NULL, NULL,
- 0, B_FALSE);
- return (rc);
- }
- /*
- * we have to fetch cfgadm, look for scsi controllers
- * dynamically
- */
- (void) dyn_probe_for_scsi_frus(frup, cfgalist, &list, numlist);
- rc = probe_scsi_in_libdevinfo(frup, cfgalist, &list,
- numlist, B_TRUE);
- free_list(&list);
- free(cfgalist);
- return (rc);
- } else {
- /* during initialization */
- /* use the cached cfgadm data */
- rc = cache_probe_for_scsi_frus(frup);
- if (scsi_list && scsi_list->num_nodes > 0) {
- rc = probe_scsi_in_libdevinfo(frup, cfglist,
- scsi_list, nlist, B_TRUE);
- } else {
- rc = probe_scsi_in_libdevinfo(frup, NULL,
- NULL, 0, B_FALSE);
- }
- return (rc);
- }
-}
diff --git a/usr/src/cmd/picl/plugins/sun4u/snowbird/lib/Makefile b/usr/src/cmd/picl/plugins/sun4u/snowbird/lib/Makefile
deleted file mode 100644
index 0936b179fb..0000000000
--- a/usr/src/cmd/picl/plugins/sun4u/snowbird/lib/Makefile
+++ /dev/null
@@ -1,51 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License, Version 1.0 only
-# (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 2004 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-#pragma ident "%Z%%M% %I% %E% SMI"
-#
-# cmd/picl/plugins/sun4u/snowbird/lib/Makefile
-#
-
-SUBDIRS= libctsmc fruaccess .WAIT
-
-MSGSUBDIRS= libctsmc fruaccess .WAIT
-
-all := TARGET= all
-install := TARGET= install
-clean := TARGET= clean
-clobber := TARGET= clobber
-lint := TARGET= lint
-_msg := TARGET= _msg
-
-.KEEP_STATE:
-
-all install clean clobber lint : $(SUBDIRS)
-
-_msg: $(MSGSUBDIRS)
-
-$(SUBDIRS): FRC
- @cd $@; pwd; $(MAKE) $(TARGET)
-
-FRC:
diff --git a/usr/src/cmd/picl/plugins/sun4u/snowbird/lib/fruaccess/Makefile b/usr/src/cmd/picl/plugins/sun4u/snowbird/lib/fruaccess/Makefile
deleted file mode 100644
index d0ae930dca..0000000000
--- a/usr/src/cmd/picl/plugins/sun4u/snowbird/lib/fruaccess/Makefile
+++ /dev/null
@@ -1,104 +0,0 @@
-#
-# 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 2009 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-# cmd/picl/plugins/sun4u/snowbird/lib/fruaccess/Makefile
-#
-
-LIBRARY= libfruaccess.a
-VERS= .1
-
-OBJECTS= libfruaccess.o piclsmc.o piclsdr.o piclfruaccess_platmod.o \
- crcutils.o crcmodel.o
-
-# include library definitions
-include $(SRC)/lib/Makefile.lib
-include $(SRC)/Makefile.psm
-include $(SRC)/cmd/picl/plugins/Makefile.com
-
-ROOT_PLATFORM = $(USR_PLAT_DIR)/SUNW,Netra-CP2300
-
-SRCS= libfruaccess.c piclsmc.c piclsdr.c piclfruaccess_platmod.c\
- ../../../lib/fruaccess/crcutils.c \
- ../../../lib/fruaccess/crcmodel.c
-
-SRCDIR= ../../../lib/fruaccess/.
-
-LIBS = $(DYNLIB)
-
-CLEANFILES= $(LINTOUT) $(LINTLIB)
-
-ROOTLIBDIR = $(ROOT_PLAT_LIBDIR)
-
-LINTSRC = $(LINTLIB:%.ln=%)
-ROOTLINTDIR = $(ROOTLIBDIR)
-ROOTLINT = $(LINTSRC:%=$(ROOTLINTDIR)/%)
-
-CFLAGS += $(CCVERBOSE)
-CPPFLAGS += -I$(SRC)/uts/sun4u/sys
-CPPFLAGS += -I$(SRC)/cmd/picl/plugins/sun4u/lib/fruaccess
-CPPFLAGS += -I$(SRC)/lib/libfruutils
-CPPFLAGS += -I$(SRC)/lib/libfru/include
-CPPFLAGS += -I$(SRC)/cmd/picl/plugins/sun4u/snowbird/lib/libctsmc
-
-LDLIBS += -L$(SRC)/lib/libpicl/$(MACH) -L$(SRC)/lib/libpicltree/$(MACH)
-LDLIBS += -L $(ROOT)/usr/platform/SUNW,Netra-CP2300/lib
-LDLIBS += -L$(SRC)/cmd/picl/plugins/sun4u/snowbird/lib/libctsmc
-LDLIBS += -R/usr/platform/sun4u/lib
-LDLIBS += -R/usr/platform/SUNW,Netra-CP2300/lib
-LDLIBS += -lc -lpicltree -lfruutils -lctsmc
-
-.KEEP_STATE:
-
-SUBDIRS=
-
-all := TARGET= all
-install := TARGET= install
-clean := TARGET= clean
-clobber := TARGET= clobber
-lint := TARGET= lint
-_msg := TARGET= _msg
-
-all: $(LIBS) $(LIBLINKS)
-
-install:$(ROOTLIBDIR) all $(ROOTLIBS) $(ROOTLINKS)
-
-$(LIBLINKS): FRC
- $(RM) $(LIBLINKS); $(SYMLINK) $(DYNLIB) $(LIBLINKS)
-
-_msg:
-
-# include library targets
-include $(SRC)/cmd/picl/plugins/Makefile.targ
-include $(SRC)/lib/Makefile.targ
-
-$(ROOTLINTDIR)/%: ../%
- $(INS.file)
-
-lint :
- $(LINT.c) $(SRCS)
-
-$(SUBDIRS): FRC
- @cd $@; pwd; $(MAKE) $(TARGET)
-
-FRC:
diff --git a/usr/src/cmd/picl/plugins/sun4u/snowbird/lib/fruaccess/fru_access_impl.h b/usr/src/cmd/picl/plugins/sun4u/snowbird/lib/fruaccess/fru_access_impl.h
deleted file mode 100644
index 359fbe13e3..0000000000
--- a/usr/src/cmd/picl/plugins/sun4u/snowbird/lib/fruaccess/fru_access_impl.h
+++ /dev/null
@@ -1,263 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (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 2004 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#ifndef _FRU_ACCESS_IMPL_H
-#define _FRU_ACCESS_IMPL_H
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <sys/types.h>
-#include <unistd.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <dial.h>
-#include <strings.h>
-#include <libdevinfo.h>
-#include <sys/systeminfo.h>
-#include <picl.h>
-#include <picltree.h>
-#include <syslog.h>
-#include <errno.h>
-#include <limits.h>
-#include "picldefs.h"
-#include "libfru.h"
-#include "fru_tag.h"
-#include "fru_access.h"
-
-/* converts slot# to ipmb addr */
-#define IPMB_ADDR(_X) (((_X) < 10) ? (0xb0 + 2 * ((_X) - 1)) :\
- (0xb0 + 2 * (_X)))
-#define MANR_TAG 0xF80010B7 /* ManR tag */
-#define SEG_NAME_LEN 2
-
-#define MANR_TIME_LEN 4
-#define MANR_FRUDESCR_LEN 80
-#define MANR_MFRLOC_LEN 64
-#define MANR_PARTNUM_LEN 7
-#define MANR_SERIALNUM_LEN 6
-#define MANR_VENDORNAME_LEN 2
-#define MANR_DASHLVL_LEN 2
-#define MANR_REVLVL_LEN 2
-#define MANR_FRUNAME_LEN 16
-
-#define NO_FRUDATA 0x0
-#define IPMI_FORMAT 0x1
-#define SUN_FORMAT 0x2
-
-/* These are newly introduced #defines for Snowbird */
-#define INPUT_FILE "/dev/ctsmc"
-#define NUM_OF_SECTIONS 2
-#define DYNAMIC_OFFSET 0x0
-#define STATIC_OFFSET 0x1800
-#define WRITE_SECTION 0
-#define DYNAMIC_LENGTH (6 * 1024); /* 6k bytes */
-#define STATIC_LENGTH (2 * 1024); /* 2k bytes */
-#define MANR_SIZE 183 /* MANR record size in bytes */
-
-#define PICL_SLOT_CPCI "cpci"
-#define PICL_SLOT_PCI "pci"
-#define PICL_NODE_CHASSIS "chassis"
-#define SD_SEGMENT_NAME "SD"
-#define SD_SEGMENT_DESCRIPTOR 0x00004924
-#define SEGMENT_TRAILER_LEN 1
-#define SEGMENT_CHKSM_LEN 4
-
-/* format structure */
-typedef struct {
- int format;
- int sun_lun; /* this info comes from SDR */
- int sun_device_id; /* this info comes from SDR */
- uint8_t src;
- uint8_t dest;
-} format_t;
-
-/* ManR payload structure */
-typedef struct {
- char timestamp[MANR_TIME_LEN];
- char fru_descr[MANR_FRUDESCR_LEN];
- char manufacture_loc[MANR_MFRLOC_LEN];
- char sun_part_no[MANR_PARTNUM_LEN];
- char sun_serial_no[MANR_SERIALNUM_LEN];
- char vendor_name[MANR_VENDORNAME_LEN]; /* JEDEC CODE */
- char inital_hw_dash_lvl[MANR_DASHLVL_LEN];
- char inital_hw_rev_lvl[MANR_REVLVL_LEN];
- char fru_short_name[MANR_FRUNAME_LEN];
-} payload_t;
-/* object types */
-typedef enum {CONTAINER_TYPE, SECTION_TYPE, SEGMENT_TYPE, PACKET_TYPE} object_t;
-
-#define TABLE_SIZE 64 /* hash table size */
-
-/* section header */
-#define SECTION_HDR_TAG 0x08
-#define SECTION_HDR_VER 0x0001
-#define SECTION_HDR_LENGTH 0x06
-#define SECTION_HDR_CRC8 0x00
-#define SECTION_HDR_VER_BIT0 0x00
-#define SECTION_HDR_VER_BIT1 0x01
-
-#define READ_ONLY_SECTION 1 /* section is read-only */
-
-#define GET_SEGMENT_DESCRIPTOR \
- (seg_layout->descriptor[1]|seg_layout->descriptor[0] << 16)
-
-#define GET_SECTION_HDR_VERSION \
- (sec_hdr.headerversion[1]|sec_hdr.headerversion[0] << 8)
-
-/* Segment Trailer Tag */
-#define SEG_TRAILER_TAG 0x0C
-
-/* defines fixed segment */
-#define SEGMENT_FIXED 1
-
-#define DEFAULT_FD -1
-#define DEFAULT_SEQN -1
-#define FRUACCESS_MSG_ID 11
-
-typedef union {
- uint32_t all_bits;
- struct {
- unsigned read_only : 1;
- unsigned unused : 8;
- unsigned : 8;
- unsigned : 8;
- unsigned : 7;
- } field;
-} sectdescbit_t;
-
-typedef struct {
- sectdescbit_t description;
- uint32_t address; /* for SEEPROMS this is the offset */
- uint32_t size;
-} sectioninfo_t;
-
-typedef uint16_t headerrev_t;
-
-#define MAX_NUMOF_SECTION 2
-
-typedef struct {
- headerrev_t header_ver;
- int num_sections;
- sectioninfo_t section_info[MAX_NUMOF_SECTION];
-} container_info_t;
-
-/* section header layout */
-typedef struct {
- uint8_t headertag; /* section header tag */
- uint8_t headerversion[2]; /* header version (msb) */
- uint8_t headerlength; /* header length */
- uint8_t headercrc8; /* crc8 */
- uint8_t segmentcount; /* total number of segment */
-} section_layout_t;
-
-/* segment header layout */
-typedef struct {
- uint16_t name; /* segment name */
- uint16_t descriptor[2]; /* descriptor (msb) */
- uint16_t offset; /* segment data offset */
- uint16_t length; /* segment length */
-} segment_layout_t;
-
-/* segment information used in finding new offset for a new segment */
-typedef struct {
- int segnum; /* segment number */
- int offset; /* segment offset */
- int length; /* segment length */
- int fixed; /* fixed or non-fixed segment */
-} seg_info_t;
-
-typedef uint64_t handle_t;
-
-struct hash_obj;
-
-/* packet hash object */
-typedef struct {
- handle_t segment_hdl; /* segment handle */
- fru_tag_t tag;
- int tag_size;
- uint8_t *payload;
- payload_t payload_data; /* reqd for ipmi format */
- uint32_t paylen;
- uint32_t payload_offset;
- struct hash_obj *next;
-} packet_obj_t;
-
-/* segment hash object */
-typedef struct {
- handle_t section_hdl; /* section handle */
- int num_of_packets; /* in a segment */
- int trailer_offset;
- segment_t segment;
- struct hash_obj *pkt_obj_list; /* packet object list */
- struct hash_obj *next;
-} segment_obj_t;
-
-/* section hash object */
-typedef struct {
- handle_t cont_hdl; /* container handle */
- section_t section;
- int num_of_segment; /* in a section */
- struct hash_obj *seg_obj_list; /* points to segment objects list */
- struct hash_obj *next;
-} section_obj_t;
-
-/* contianer hash object */
-typedef struct {
- char device_pathname[PATH_MAX]; /* device name */
- int num_of_section; /* num of section in container */
- format_t format;
- struct hash_obj *sec_obj_list; /* points to section objects list */
-} container_obj_t;
-
-/* hash object */
-typedef struct hash_obj {
- int object_type;
- handle_t obj_hdl;
- union {
- container_obj_t *cont_obj;
- section_obj_t *sec_obj;
- segment_obj_t *seg_obj;
- packet_obj_t *pkt_obj;
- } u;
- struct hash_obj *next;
- struct hash_obj *prev;
-} hash_obj_t;
-
-extern unsigned char compute_crc8(unsigned char *bytes, int length);
-extern long compute_crc32(unsigned char *bytes, int length);
-extern long compute_checksum32(unsigned char *bytes, int length);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _FRU_ACCESS_IMPL_H */
diff --git a/usr/src/cmd/picl/plugins/sun4u/snowbird/lib/fruaccess/libfruaccess.c b/usr/src/cmd/picl/plugins/sun4u/snowbird/lib/fruaccess/libfruaccess.c
deleted file mode 100644
index 3a48dcbf5e..0000000000
--- a/usr/src/cmd/picl/plugins/sun4u/snowbird/lib/fruaccess/libfruaccess.c
+++ /dev/null
@@ -1,3438 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (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 2004 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <picl.h>
-#include <limits.h>
-#include <alloca.h>
-#include <stdarg.h>
-#include "smc_if.h"
-#include "fru_access_impl.h"
-
-#pragma init(initialize_fruaccess) /* .init section */
-
-/*
- * This module translates all the frudata plugin requests into platform
- * specific commands and provides information back to frudata plugin.
- */
-
-/*
- * precedence for format.
- * define an ENV variable (SUNW_FRUACCESS_IPMI_PRECEDENCE) to make
- * ipmi format has more precedence than sun format.
- */
-static int precedence = SUN_FORMAT; /* by default */
-#define FRUACCESS_PRECEDENCE "SUNW_FRUACCESS_IPMI_PRECEDENCE"
-
-extern ssize_t pread_new(int, void *, size_t, off_t, format_t *);
-extern ssize_t pwrite_new(int, const void *, size_t, off_t, format_t *);
-extern int get_manr(format_t *, payload_t *);
-extern int is_fru_data_available(int, int, format_t *);
-extern picl_errno_t fruaccess_platmod_init_format(uint8_t, format_t *);
-extern int fruaccess_platmod_check_chassis();
-extern int fruaccess_platmod_check_fru(picl_nodehdl_t parenth);
-
-static container_hdl_t sun_fru_open_container(picl_nodehdl_t);
-static int sun_fru_close_container(container_hdl_t);
-static int sun_fru_get_num_sections(container_hdl_t, door_cred_t *);
-static int sun_fru_get_sections(container_hdl_t, section_t *,
- int, door_cred_t *);
-static int sun_fru_get_num_segments(section_hdl_t, door_cred_t *);
-static int sun_fru_get_segments(section_hdl_t, segment_t *,
- int, door_cred_t *);
-static int sun_fru_add_segment(section_hdl_t, segment_t *,
- section_hdl_t *, door_cred_t *);
-static int sun_fru_delete_segment(segment_hdl_t, section_hdl_t *,
- door_cred_t *);
-static ssize_t sun_fru_read_segment(segment_hdl_t, void *, size_t,
- door_cred_t *);
-static int sun_fru_write_segment(segment_hdl_t, const void *, size_t,
- segment_hdl_t *, door_cred_t *);
-static int sun_fru_get_num_packets(segment_hdl_t, door_cred_t *);
-static int sun_fru_get_packets(segment_hdl_t, packet_t *,
- int, door_cred_t *);
-static ssize_t sun_fru_get_payload(packet_hdl_t, void *, size_t,
- door_cred_t *);
-static int sun_fru_update_payload(packet_hdl_t, const void *, size_t,
- packet_hdl_t *, door_cred_t *);
-static int sun_fru_append_packet(segment_hdl_t, packet_t *,
- const void *, size_t, segment_hdl_t *,
- door_cred_t *);
-static int sun_fru_delete_packet(packet_hdl_t, segment_hdl_t *, door_cred_t *);
-
-static container_hdl_t ipmi_fru_open_container(picl_nodehdl_t);
-static int ipmi_fru_close_container(container_hdl_t);
-static int ipmi_fru_get_num_sections(container_hdl_t, door_cred_t *);
-static int ipmi_fru_get_sections(container_hdl_t, section_t *,
- int, door_cred_t *);
-static int ipmi_fru_get_num_segments(section_hdl_t, door_cred_t *);
-static int ipmi_fru_get_segments(section_hdl_t, segment_t *,
- int, door_cred_t *);
-static int ipmi_fru_add_segment(section_hdl_t, segment_t *,
- section_hdl_t *, door_cred_t *);
-static int ipmi_fru_delete_segment(segment_hdl_t, section_hdl_t *,
- door_cred_t *);
-static ssize_t ipmi_fru_read_segment(segment_hdl_t, void *, size_t,
- door_cred_t *);
-static int ipmi_fru_write_segment(segment_hdl_t, const void *, size_t,
- segment_hdl_t *, door_cred_t *);
-static int ipmi_fru_get_num_packets(segment_hdl_t, door_cred_t *);
-static int ipmi_fru_get_packets(segment_hdl_t, packet_t *,
- int, door_cred_t *);
-static ssize_t ipmi_fru_get_payload(packet_hdl_t, void *, size_t,
- door_cred_t *);
-static int ipmi_fru_update_payload(packet_hdl_t, const void *, size_t,
- packet_hdl_t *, door_cred_t *);
-static int ipmi_fru_append_packet(segment_hdl_t, packet_t *,
- const void *, size_t, segment_hdl_t *,
- door_cred_t *);
-static int ipmi_fru_delete_packet(packet_hdl_t, segment_hdl_t *, door_cred_t *);
-
-typedef struct {
- container_hdl_t (* open_container)(picl_nodehdl_t);
- int (* close_container)(container_hdl_t);
- int (* get_num_sections)(container_hdl_t, door_cred_t *);
- int (* get_sections)(container_hdl_t, section_t *,
- int, door_cred_t *);
- int (* get_num_segments)(section_hdl_t, door_cred_t *);
- int (* get_segments)(section_hdl_t, segment_t *,
- int, door_cred_t *);
- int (* add_segment)(section_hdl_t, segment_t *,
- section_hdl_t *, door_cred_t *);
- int (* delete_segment)(segment_hdl_t, section_hdl_t *,
- door_cred_t *);
- ssize_t (* read_segment)(segment_hdl_t, void *, size_t,
- door_cred_t *);
- int (* write_segment)(segment_hdl_t, const void *, size_t,
- segment_hdl_t *, door_cred_t *);
- int (* get_num_packets)(segment_hdl_t, door_cred_t *);
- int (* get_packets)(segment_hdl_t, packet_t *,
- int, door_cred_t *);
- ssize_t (* get_payload)(packet_hdl_t, void *, size_t,
- door_cred_t *);
- int (* update_payload)(packet_hdl_t, const void *, size_t,
- packet_hdl_t *, door_cred_t *);
- int (* append_packet)(segment_hdl_t, packet_t *,
- const void *, size_t, segment_hdl_t *,
- door_cred_t *);
- int (* delete_packet)(packet_hdl_t, segment_hdl_t *, door_cred_t *);
-} fruaccess_func_ptrs_t;
-
-static fruaccess_func_ptrs_t fruaccess_func[2] = {
- {
- ipmi_fru_open_container,
- ipmi_fru_close_container,
- ipmi_fru_get_num_sections,
- ipmi_fru_get_sections,
- ipmi_fru_get_num_segments,
- ipmi_fru_get_segments,
- ipmi_fru_add_segment,
- ipmi_fru_delete_segment,
- ipmi_fru_read_segment,
- ipmi_fru_write_segment,
- ipmi_fru_get_num_packets,
- ipmi_fru_get_packets,
- ipmi_fru_get_payload,
- ipmi_fru_update_payload,
- ipmi_fru_append_packet,
- ipmi_fru_delete_packet,
- },
- {
- sun_fru_open_container,
- sun_fru_close_container,
- sun_fru_get_num_sections,
- sun_fru_get_sections,
- sun_fru_get_num_segments,
- sun_fru_get_segments,
- sun_fru_add_segment,
- sun_fru_delete_segment,
- sun_fru_read_segment,
- sun_fru_write_segment,
- sun_fru_get_num_packets,
- sun_fru_get_packets,
- sun_fru_get_payload,
- sun_fru_update_payload,
- sun_fru_append_packet,
- sun_fru_delete_packet,
- },
- };
-
-static int is_valid_chassis = -1;
-static hash_obj_t *hash_table[TABLE_SIZE];
-
-static void
-initialize_fruaccess(void)
-{
- int count;
- for (count = 0; count < TABLE_SIZE; count++) {
- hash_table[count] = NULL;
- }
-
- /* check if ipmi format has precedence */
- if (getenv(FRUACCESS_PRECEDENCE)) {
- precedence = IPMI_FORMAT;
- }
-}
-
-/* called to lookup hash object for specified handle in the hash table. */
-static hash_obj_t *
-lookup_handle_object(handle_t handle, int object_type)
-{
- handle_t index_to_hash;
- hash_obj_t *first_hash_obj;
- hash_obj_t *next_hash_obj;
-
- index_to_hash = (handle % TABLE_SIZE);
-
- first_hash_obj = hash_table[index_to_hash];
- for (next_hash_obj = first_hash_obj; next_hash_obj != NULL;
- next_hash_obj = next_hash_obj->next) {
- if ((handle == next_hash_obj->obj_hdl) &&
- (object_type == next_hash_obj->object_type)) {
- return (next_hash_obj);
- }
- }
- return (NULL);
-}
-
-/* called to allocate container hash object */
-static hash_obj_t *
-create_container_hash_object(void)
-{
- hash_obj_t *hash_obj;
- container_obj_t *cont_obj;
-
- cont_obj = malloc(sizeof (container_obj_t));
- if (cont_obj == NULL) {
- return (NULL);
- }
-
- hash_obj = malloc(sizeof (hash_obj_t));
- if (hash_obj == NULL) {
- free(cont_obj);
- return (NULL);
- }
-
- cont_obj->sec_obj_list = NULL;
-
- hash_obj->object_type = CONTAINER_TYPE;
- hash_obj->u.cont_obj = cont_obj;
- hash_obj->next = NULL;
- hash_obj->prev = NULL;
-
- return (hash_obj);
-}
-
-/* called to allocate section hash object */
-static hash_obj_t *
-create_section_hash_object(void)
-{
- hash_obj_t *hash_obj;
- section_obj_t *sec_obj;
-
- sec_obj = malloc(sizeof (section_obj_t));
- if (sec_obj == NULL) {
- return (NULL);
- }
-
- hash_obj = malloc(sizeof (hash_obj_t));
- if (hash_obj == NULL) {
- free(sec_obj);
- return (NULL);
- }
-
- sec_obj->next = NULL;
- sec_obj->seg_obj_list = NULL;
-
- hash_obj->u.sec_obj = sec_obj;
- hash_obj->object_type = SECTION_TYPE;
- hash_obj->next = NULL;
- hash_obj->prev = NULL;
-
- return (hash_obj);
-}
-
-/* called to allocate segment hash object */
-static hash_obj_t *
-create_segment_hash_object(void)
-{
- hash_obj_t *hash_obj;
- segment_obj_t *seg_obj;
-
- seg_obj = malloc(sizeof (segment_obj_t));
- if (seg_obj == NULL) {
- return (NULL);
- }
-
- hash_obj = malloc(sizeof (hash_obj_t));
- if (hash_obj == NULL) {
- free(seg_obj);
- return (NULL);
- }
-
- seg_obj->next = NULL;
- seg_obj->pkt_obj_list = NULL;
-
- hash_obj->object_type = SEGMENT_TYPE;
- hash_obj->u.seg_obj = seg_obj;
- hash_obj->next = NULL;
- hash_obj->prev = NULL;
-
- return (hash_obj);
-}
-
-/* called to allocate packet hash object */
-static hash_obj_t *
-create_packet_hash_object(void)
-{
- hash_obj_t *hash_obj;
- packet_obj_t *pkt_obj;
-
- pkt_obj = malloc(sizeof (packet_obj_t));
- if (pkt_obj == NULL) {
- return (NULL);
- }
-
- hash_obj = malloc(sizeof (hash_obj_t));
- if (hash_obj == NULL) {
- free(pkt_obj);
- return (NULL);
- }
-
- pkt_obj->next = NULL;
-
- hash_obj->object_type = PACKET_TYPE;
- hash_obj->u.pkt_obj = pkt_obj;
- hash_obj->next = NULL;
- hash_obj->prev = NULL;
-
- return (hash_obj);
-}
-
-/* called to add allocated hash object into the hash table */
-static void
-add_hashobject_to_hashtable(hash_obj_t *hash_obj, int object_type)
-{
- handle_t index_to_hash;
- static uint64_t handle_count = 0;
-
- if (object_type != CONTAINER_TYPE) {
- hash_obj->obj_hdl = ++handle_count;
- }
-
- /* where to add ? */
- index_to_hash = ((hash_obj->obj_hdl) % TABLE_SIZE);
-
- hash_obj->next = hash_table[index_to_hash];
- hash_table[index_to_hash] = hash_obj; /* hash obj. added */
-
- if (hash_obj->next != NULL) {
- hash_obj->next->prev = hash_obj;
- }
-}
-
-/* called to add section object list into the section list */
-static void
-add_to_sec_object_list(hash_obj_t *parent_obj, hash_obj_t *child_obj)
-{
- hash_obj_t *next_hash;
-
- child_obj->u.sec_obj->cont_hdl = parent_obj->obj_hdl;
- if (parent_obj->u.cont_obj->sec_obj_list == NULL) {
- parent_obj->u.cont_obj->sec_obj_list = child_obj;
- return;
- }
-
- for (next_hash = parent_obj->u.cont_obj->sec_obj_list;
- next_hash->u.sec_obj->next != NULL;
- next_hash = next_hash->u.sec_obj->next) {
- ;
- }
-
- next_hash->u.sec_obj->next = child_obj;
-}
-
-/* called to add segment object list into segment list */
-static void
-add_to_seg_object_list(hash_obj_t *parent_obj, hash_obj_t *child_obj)
-{
- hash_obj_t *next_hash;
-
- child_obj->u.seg_obj->section_hdl = parent_obj->obj_hdl;
- if (parent_obj->u.sec_obj->seg_obj_list == NULL) {
- parent_obj->u.sec_obj->seg_obj_list = child_obj;
- return;
- }
-
- for (next_hash = parent_obj->u.sec_obj->seg_obj_list;
- next_hash->u.seg_obj->next != NULL;
- next_hash = next_hash->u.seg_obj->next) {
- ;
- }
-
- next_hash->u.seg_obj->next = child_obj;
-}
-
-/* called to add packet object list into packet list */
-static void
-add_to_pkt_object_list(hash_obj_t *parent_obj, hash_obj_t *child_obj)
-{
- hash_obj_t *next_hash;
-
- /* add the packet object in the end of list */
- child_obj->u.pkt_obj->segment_hdl = parent_obj->obj_hdl;
-
- if (parent_obj->u.seg_obj->pkt_obj_list == NULL) {
- parent_obj->u.seg_obj->pkt_obj_list = child_obj;
- return;
- }
-
- for (next_hash = parent_obj->u.seg_obj->pkt_obj_list;
- next_hash->u.pkt_obj->next != NULL;
- next_hash = next_hash->u.pkt_obj->next) {
- ;
- }
-
- next_hash->u.pkt_obj->next = child_obj;
-}
-
-/* fill the information, payload in the conatiner */
-/*ARGSUSED*/
-static int
-initialize_ipmi_container(picl_nodehdl_t fru, hash_obj_t *cont_hash_obj)
-{
- payload_t manr;
- hash_obj_t *seg_hash_obj, *sec_hash_obj, *pkt_hash_obj;
- format_t format;
-
- format = cont_hash_obj->u.cont_obj->format;
- /* plug to SMC driver to fetch the data */
- if (get_manr(&format, &manr) != 0) {
- return (-1);
- }
-
- cont_hash_obj->u.cont_obj->num_of_section = 1;
- cont_hash_obj->u.cont_obj->sec_obj_list = NULL;
-
- sec_hash_obj = create_section_hash_object();
- if (sec_hash_obj == NULL) {
- return (-1);
- }
-
- add_hashobject_to_hashtable(sec_hash_obj, SECTION_TYPE);
-
- /* create fake section info here */
- sec_hash_obj->u.sec_obj->num_of_segment = 1;
- sec_hash_obj->u.sec_obj->section.handle = sec_hash_obj->obj_hdl;
- sec_hash_obj->u.sec_obj->section.offset = 0;
- sec_hash_obj->u.sec_obj->section.protection = READ_ONLY_SECTION;
-
- sec_hash_obj->u.sec_obj->section.length = STATIC_LENGTH;
- sec_hash_obj->u.sec_obj->section.version = SECTION_HDR_VER;
- add_to_sec_object_list(cont_hash_obj, sec_hash_obj);
-
- seg_hash_obj = create_segment_hash_object();
- if (seg_hash_obj == NULL) {
- return (-1);
- }
-
- add_hashobject_to_hashtable(seg_hash_obj, SEGMENT_TYPE);
-
- seg_hash_obj->u.seg_obj->num_of_packets = 1;
- seg_hash_obj->u.seg_obj->segment.handle = seg_hash_obj->obj_hdl;
- (void) strncpy(seg_hash_obj->u.seg_obj->segment.name,
- SD_SEGMENT_NAME,
- sizeof (seg_hash_obj->u.seg_obj->segment.name));
- seg_hash_obj->u.seg_obj->segment.descriptor = SD_SEGMENT_DESCRIPTOR;
- /* tag + payload */
- seg_hash_obj->u.seg_obj->segment.length = MANR_SIZE +
- SEGMENT_TRAILER_LEN + SEGMENT_CHKSM_LEN;
- add_to_seg_object_list(sec_hash_obj, seg_hash_obj);
-
- pkt_hash_obj = create_packet_hash_object();
- if (pkt_hash_obj == NULL) {
- return (-1);
- }
- add_hashobject_to_hashtable(pkt_hash_obj, PACKET_TYPE);
-
- pkt_hash_obj->u.pkt_obj->payload_data = manr;
- if (mk_tag(FRU_F, 0x001, 0x0B7, &pkt_hash_obj->u.pkt_obj->tag) == 4) {
- add_to_pkt_object_list(seg_hash_obj, pkt_hash_obj);
- }
- return (0);
-}
-
-/* Look up the container_hdl in the PICL tree. */
-static container_hdl_t
-ipmi_fru_open_container(picl_nodehdl_t fruh)
-{
- int err;
- hash_obj_t *cont_hash_obj;
-
- err = ptree_get_propval_by_name(fruh, PICL_PROP_FRUDATA_AVAIL,
- NULL, NULL);
- if (err != PICL_SUCCESS) {
- return (0);
- }
-
- cont_hash_obj = lookup_handle_object((handle_t)fruh, CONTAINER_TYPE);
- if (cont_hash_obj == NULL) {
- return (0);
- }
-
- /* initialize the container */
- if (initialize_ipmi_container(fruh, cont_hash_obj) != 0) {
- return (0);
- }
- return (cont_hash_obj->obj_hdl);
-}
-
-/*ARGSUSED*/
-static int
-ipmi_fru_get_num_sections(container_hdl_t container, door_cred_t *cred)
-{
- hash_obj_t *cont_hash_obj;
-
- cont_hash_obj = lookup_handle_object((handle_t)container,
- CONTAINER_TYPE);
- if (cont_hash_obj == NULL) {
- return (-1);
- }
- return (cont_hash_obj->u.cont_obj->num_of_section);
-}
-
-/*ARGSUSED*/
-static int
-ipmi_fru_get_sections(container_hdl_t container, section_t *section,
- int max_sections, door_cred_t *cred)
-{
- int count;
- hash_obj_t *cont_object;
- hash_obj_t *sec_hash;
-
- cont_object = lookup_handle_object((handle_t)container,
- CONTAINER_TYPE);
- if (cont_object == NULL) {
- return (-1);
- }
-
- if (cont_object->u.cont_obj->num_of_section > max_sections) {
- return (-1);
- }
- sec_hash = cont_object->u.cont_obj->sec_obj_list;
-
- for (count = 0; count < cont_object->u.cont_obj->num_of_section &&
- sec_hash != NULL; count++, section++) {
- /* populate section_t */
- section->handle = sec_hash->u.sec_obj->section.handle;
- section->offset = sec_hash->u.sec_obj->section.offset;
- section->length = sec_hash->u.sec_obj->section.length;
- section->protection = sec_hash->u.sec_obj->section.protection;
- section->version = sec_hash->u.sec_obj->section.version;
- sec_hash = sec_hash->u.sec_obj->next;
- }
- return (count);
-}
-
-/*ARGSUSED*/
-static int
-ipmi_fru_get_num_segments(section_hdl_t section, door_cred_t *cred)
-{
- hash_obj_t *sec_object;
-
- sec_object = lookup_handle_object((handle_t)section, SECTION_TYPE);
- if (sec_object == NULL) {
- return (-1);
- }
- return (sec_object->u.sec_obj->num_of_segment);
-}
-
-/*ARGSUSED*/
-static int
-ipmi_fru_get_segments(section_hdl_t section, segment_t *segment,
- int max_segments, door_cred_t *cred)
-{
- int count;
- hash_obj_t *seg_hash;
- hash_obj_t *sec_object;
-
- sec_object = lookup_handle_object((handle_t)section, SECTION_TYPE);
- if (sec_object == NULL) {
- return (-1);
- }
-
- if (sec_object->u.sec_obj->num_of_segment > max_segments) {
- return (-1);
- }
-
- seg_hash = sec_object->u.sec_obj->seg_obj_list;
-
- for (count = 0; count < sec_object->u.sec_obj->num_of_segment &&
- seg_hash != NULL; count++, segment++) {
- /* populate the segment info */
- segment->handle = seg_hash->u.seg_obj->segment.handle;
- (void) memcpy(segment->name, seg_hash->u.seg_obj->segment.name,
- SEG_NAME_LEN);
- segment->descriptor = seg_hash->u.seg_obj->segment.descriptor;
- segment->offset = seg_hash->u.seg_obj->segment.offset;
- segment->length = seg_hash->u.seg_obj->segment.length;
- seg_hash = seg_hash->u.seg_obj->next;
- }
- return (count);
-}
-
-/*ARGSUSED*/
-static int
-ipmi_fru_get_num_packets(segment_hdl_t segment, door_cred_t *cred)
-{
- hash_obj_t *seg_object;
-
- seg_object = lookup_handle_object((handle_t)segment, SEGMENT_TYPE);
- if (seg_object == NULL) {
- return (-1);
- }
- return (seg_object->u.seg_obj->num_of_packets);
-}
-
-/*ARGSUSED*/
-static int
-ipmi_fru_get_packets(segment_hdl_t segment, packet_t *packet,
- int max_packets, door_cred_t *cred)
-{
- int count;
- hash_obj_t *pkt_hash;
- hash_obj_t *seg_object;
-
- seg_object = lookup_handle_object((handle_t)segment, SEGMENT_TYPE);
- if (seg_object == NULL) {
- return (-1);
- }
-
- if (seg_object->u.seg_obj->num_of_packets > max_packets) {
- return (-1);
- }
-
- pkt_hash = seg_object->u.seg_obj->pkt_obj_list;
-
- for (count = 0; count < seg_object->u.seg_obj->num_of_packets &&
- pkt_hash != NULL; count++, packet++) {
- /* populate the segment info */
- packet->handle = pkt_hash->obj_hdl;
- (void) memcpy(&packet->tag, &pkt_hash->u.pkt_obj->tag, 4);
- pkt_hash = pkt_hash->u.pkt_obj->next;
- }
-
- return (count);
-}
-
-/*ARGSUSED*/
-static ssize_t
-ipmi_fru_read_segment(segment_hdl_t segment, void *buffer, size_t nbytes,
- door_cred_t *cred)
-{
- hash_obj_t *seg_hash;
- hash_obj_t *pkt_hash;
-
- /* segment hash object */
- seg_hash = lookup_handle_object(segment, SEGMENT_TYPE);
- if (seg_hash == NULL) {
- return (-1);
- }
-
- if (seg_hash->u.seg_obj->segment.length < nbytes) {
- return (-1);
- }
-
- pkt_hash = seg_hash->u.seg_obj->pkt_obj_list;
-
- if (pkt_hash == NULL) {
- return (-1);
- }
-
- (void) memcpy(buffer, &pkt_hash->u.pkt_obj->payload_data,
- sizeof (payload_t));
- return (nbytes);
-}
-
-/*ARGSUSED*/
-static ssize_t
-ipmi_fru_get_payload(packet_hdl_t packet, void *buffer, size_t nbytes,
- door_cred_t *cred)
-{
- hash_obj_t *packet_hash_obj;
-
- /* size = size of ManR */
- if (nbytes != MANR_SIZE) {
- return (-1);
- }
-
- /* packet hash object */
- packet_hash_obj = lookup_handle_object(packet, PACKET_TYPE);
- if (packet_hash_obj == NULL) {
- return (-1);
- }
-
- (void) memcpy(buffer, &(packet_hash_obj->u.pkt_obj->payload_data),
- MANR_SIZE);
- return (nbytes);
-}
-
-/*ARGSUSED*/
-static int
-ipmi_fru_add_segment(section_hdl_t section, segment_t *segment,
- section_hdl_t *newsection, door_cred_t *cred)
-{
- errno = ENOTSUP;
- return (-1);
-}
-
-/*ARGSUSED*/
-static int
-ipmi_fru_delete_segment(segment_hdl_t segment,
- section_hdl_t *newsection, door_cred_t *cred)
-{
- errno = ENOTSUP;
- return (-1);
-}
-
-
-/*ARGSUSED*/
-static ssize_t
-ipmi_fru_write_segment(segment_hdl_t segment, const void *data,
- size_t nbytes, segment_hdl_t *newsegment, door_cred_t *cred)
-{
- errno = ENOTSUP;
- return (-1);
-}
-
-/*ARGSUSED*/
-static int
-ipmi_fru_update_payload(packet_hdl_t packet, const void *data,
- size_t nbytes, packet_hdl_t *newpacket, door_cred_t *cred)
-{
- errno = ENOTSUP;
- return (-1);
-}
-
-/*ARGSUSED*/
-static int
-ipmi_fru_append_packet(segment_hdl_t segment, packet_t *packet,
- const void *payload, size_t nbytes, segment_hdl_t *newsegment,
- door_cred_t *cred)
-{
- errno = ENOTSUP;
- return (-1);
-}
-
-/*ARGSUSED*/
-static int
-ipmi_fru_delete_packet(packet_hdl_t packet,
- segment_hdl_t *newsegment, door_cred_t *cred)
-{
- errno = ENOTSUP;
- return (-1);
-}
-
-static void
-free_pkt_object_list(hash_obj_t *hash_obj)
-{
- hash_obj_t *next_obj;
- hash_obj_t *free_obj;
-
- next_obj = hash_obj->u.seg_obj->pkt_obj_list;
- while (next_obj != NULL) {
- free_obj = next_obj;
- next_obj = next_obj->u.pkt_obj->next;
- /* if prev is NULL it's the first object in the list */
- if (free_obj->prev == NULL) {
- hash_table[(free_obj->obj_hdl % TABLE_SIZE)] =
- free_obj->next;
- if (free_obj->next != NULL) {
- free_obj->next->prev = free_obj->prev;
- }
- } else {
- free_obj->prev->next = free_obj->next;
- if (free_obj->next != NULL) {
- free_obj->next->prev = free_obj->prev;
- }
- }
-
- free(free_obj->u.pkt_obj);
- free(free_obj);
- }
-
- hash_obj->u.seg_obj->pkt_obj_list = NULL;
-}
-
-static void
-free_segment_hash(handle_t handle, hash_obj_t *sec_hash)
-{
- hash_obj_t *seg_hash;
- hash_obj_t *next_hash;
-
- seg_hash = sec_hash->u.sec_obj->seg_obj_list;
- if (seg_hash == NULL) {
- return;
- }
-
- if (seg_hash->obj_hdl == handle) {
- sec_hash->u.sec_obj->seg_obj_list = seg_hash->u.seg_obj->next;
- } else {
- while (seg_hash->obj_hdl != handle) {
- next_hash = seg_hash;
- seg_hash = seg_hash->u.seg_obj->next;
- if (seg_hash == NULL) {
- return;
- }
- }
- next_hash->u.seg_obj->next = seg_hash->u.seg_obj->next;
- }
-
- if (seg_hash->prev == NULL) {
- hash_table[(seg_hash->obj_hdl % TABLE_SIZE)] = seg_hash->next;
- if (seg_hash->next != NULL) {
- seg_hash->next->prev = NULL;
- }
- } else {
- seg_hash->prev->next = seg_hash->next;
- if (seg_hash->next != NULL) {
- seg_hash->next->prev = seg_hash->prev;
- }
- }
-
- free_pkt_object_list(seg_hash);
- free(seg_hash->u.seg_obj);
- free(seg_hash);
-}
-
-static int
-ipmi_fru_close_container(container_hdl_t container)
-{
- hash_obj_t *hash_obj;
- hash_obj_t *prev_hash;
- hash_obj_t *sec_hash_obj;
- handle_t obj_hdl;
-
- /* lookup for container hash object */
- hash_obj = lookup_handle_object(container, CONTAINER_TYPE);
- if (hash_obj == NULL) {
- return (0);
- }
-
- /* points to section object list */
- sec_hash_obj = hash_obj->u.cont_obj->sec_obj_list;
-
- /* traverse section object list */
- while (sec_hash_obj != NULL) {
-
- /* traverse segment hash object in the section */
- while (sec_hash_obj->u.sec_obj->seg_obj_list != NULL) {
- /* object handle of the segment hash object */
- obj_hdl =
- sec_hash_obj->u.sec_obj->seg_obj_list->obj_hdl;
- free_segment_hash(obj_hdl, sec_hash_obj);
- }
-
- /* going to free section hash object, relink the hash object */
- if (sec_hash_obj->prev == NULL) {
- hash_table[(sec_hash_obj->obj_hdl % TABLE_SIZE)]
- = sec_hash_obj->next;
- if (sec_hash_obj->next != NULL) {
- sec_hash_obj->next->prev = NULL;
- }
- } else {
- sec_hash_obj->prev->next = sec_hash_obj->next;
- if (sec_hash_obj->next != NULL) {
- sec_hash_obj->next->prev = sec_hash_obj->prev;
- }
- }
-
- free(sec_hash_obj->u.sec_obj); /* free section hash object */
-
- prev_hash = sec_hash_obj;
-
- sec_hash_obj = sec_hash_obj->u.sec_obj->next;
-
- free(prev_hash); /* free section hash */
- }
-
- /* free container hash object */
- if (hash_obj->prev == NULL) {
- hash_table[(sec_hash_obj->obj_hdl % TABLE_SIZE)] =
- hash_obj->next;
- if (hash_obj->next != NULL) {
- hash_obj->next->prev = NULL;
- }
- } else {
- hash_obj->prev->next = hash_obj->next;
- if (hash_obj->next != NULL) {
- hash_obj->next->prev = hash_obj->prev;
- }
- }
-
- free(hash_obj->u.cont_obj);
- free(hash_obj);
- return (0);
-}
-
-/* opens the binary file and returns the file descriptor */
-static int
-open_file()
-{
- int fd;
-
- if ((fd = open(INPUT_FILE, O_RDWR)) == -1) {
- return (-1);
- }
- return (fd);
-}
-
-static void
-copy_segment_layout(segment_t *seghdr, void *layout)
-{
- segment_layout_t *seg_layout;
-
- seg_layout = (segment_layout_t *)layout;
- (void) memcpy(seghdr->name, &seg_layout->name, SEG_NAME_LEN);
- seghdr->descriptor = GET_SEGMENT_DESCRIPTOR;
- seghdr->offset = seg_layout->offset;
- seghdr->length = seg_layout->length;
-}
-
-static hash_obj_t *
-get_container_hash_object(int object_type, handle_t handle)
-{
- hash_obj_t *hash_obj;
-
- switch (object_type) {
- case CONTAINER_TYPE :
- break;
-
- case SECTION_TYPE :
- hash_obj = lookup_handle_object(handle, CONTAINER_TYPE);
- if (hash_obj == NULL) {
- return (NULL);
- }
- break;
- case SEGMENT_TYPE :
- hash_obj = lookup_handle_object(handle, SECTION_TYPE);
- if (hash_obj == NULL) {
- return (NULL);
- }
- hash_obj = lookup_handle_object(hash_obj->u.sec_obj->cont_hdl,
- CONTAINER_TYPE);
- break;
- case PACKET_TYPE :
-
- hash_obj = lookup_handle_object(handle, SEGMENT_TYPE);
- if (hash_obj == NULL) {
- return (NULL);
- }
- hash_obj = lookup_handle_object(
- hash_obj->u.seg_obj->section_hdl, SECTION_TYPE);
- if (hash_obj == NULL) {
- return (NULL);
- }
- hash_obj = lookup_handle_object(hash_obj->u.sec_obj->cont_hdl,
- CONTAINER_TYPE);
- break;
- default :
- return (NULL);
- }
- return (hash_obj);
-}
-
-static void
-sort_offsettbl(int segcnt, seg_info_t *offset_tbl)
-{
- int cntx;
- int cnty;
- seg_info_t tmp;
-
- for (cntx = 0; cntx < segcnt+2; cntx++) {
- for (cnty = cntx+1; cnty < segcnt + 2; cnty++) {
- if (offset_tbl[cntx].offset >
- offset_tbl[cnty].offset) {
- (void) memcpy(&tmp, &offset_tbl[cnty],
- sizeof (seg_info_t));
- (void) memcpy(&offset_tbl[cnty],
- &offset_tbl[cntx],
- sizeof (seg_info_t));
-
- (void) memcpy(&offset_tbl[cntx], &tmp,
- sizeof (seg_info_t));
- }
- }
- }
-}
-
-/*
- * Description : move_segment_data() reads the segment data and writes it
- * back to the new segment offset.
- */
-
-static void
-move_segment_data(void *seghdr, int newoffset, container_hdl_t contfd)
-{
- int ret;
- char *buffer;
- segment_layout_t *segment;
- format_t format;
- hash_obj_t *cont_hash;
-
- segment = (segment_layout_t *)seghdr;
-
- buffer = alloca(segment->length);
- if (buffer == NULL) {
- return;
- }
-
- cont_hash = lookup_handle_object((handle_t)contfd, CONTAINER_TYPE);
- if (cont_hash == NULL) {
- return;
- }
-
- format = cont_hash->u.cont_obj->format;
-
- ret = pread_new(contfd, buffer,
- segment->length, segment->offset, &format);
- if (ret != segment->length) {
- return;
- }
-
- segment->offset = newoffset;
-
- ret = pwrite_new(contfd, buffer, segment->length, segment->offset,
- &format);
- if (ret != segment->length) {
- return;
- }
-}
-
-/*
- * Description : pack_segment_data() moves the segment data if there is
- * a hole between two segments.
- */
-
-static void
-pack_segment_data(char *seghdr, int segcnt, container_hdl_t contfd,
- seg_info_t *offset_tbl)
-{
- int cnt;
- int diff;
- int newoffset;
-
- for (cnt = segcnt + 1; cnt > 0; cnt--) {
- if (!offset_tbl[cnt - 1].fixed) {
- if (offset_tbl[cnt].offset
- - (offset_tbl[cnt -1 ].offset
- + offset_tbl[cnt - 1].length) > 0) {
-
- diff = offset_tbl[cnt].offset -
- (offset_tbl[cnt - 1].offset
- + offset_tbl[cnt - 1].length);
- newoffset = offset_tbl[cnt - 1].offset
- + diff;
-
- move_segment_data(seghdr, newoffset,
- contfd);
-
- offset_tbl[cnt - 1].offset = newoffset;
-
- sort_offsettbl(segcnt, offset_tbl);
- }
- }
- }
-}
-
-/*
- * Description : build_offset_tbl() builds the offset table by reading all the
- * segment header. it makes two more entry into the table one for
- * section size and another with start of the section after the
- * segment header.
- */
-
-static int
-build_offset_tbl(void *seghdr, int segcnt, int secsize,
- seg_info_t *offset_tbl)
-{
- int cnt;
- fru_segdesc_t segdesc;
- segment_layout_t *segment;
-
- for (cnt = 0; cnt < segcnt; cnt++) {
- segment = (segment_layout_t *)(seghdr) + cnt;
-
- (void) memcpy(&segdesc, &segment->descriptor,
- sizeof (uint32_t));
- offset_tbl[cnt].segnum = cnt;
- offset_tbl[cnt].offset = segment->offset;
- offset_tbl[cnt].length = segment->length;
- offset_tbl[cnt].fixed = segdesc.field.fixed;
- }
-
- /* upper boundary of segment area (lower address bytes) */
- offset_tbl[cnt].segnum = -1;
- offset_tbl[cnt].offset = sizeof (section_layout_t) + ((cnt + 1)
- * sizeof (segment_layout_t));
-
- offset_tbl[cnt].length = 0;
- offset_tbl[cnt].fixed = 1;
- /* lower boundary of segment area (higher address bytes) */
-
- offset_tbl[cnt+1].segnum = -1;
- offset_tbl[cnt+1].offset = secsize;
- offset_tbl[cnt+1].length = 0;
- offset_tbl[cnt+1].fixed = 1;
- return (0);
-}
-
-static int
-hole_discovery(int bytes, int segcnt, int *totsize, seg_info_t *offset_tbl)
-{
- int cnt = 0;
-
- *totsize = 0;
- for (cnt = segcnt + 1; cnt > 0; cnt--) {
- if (bytes <= offset_tbl[cnt].offset -
- (offset_tbl[cnt - 1].offset +
- offset_tbl[cnt - 1].length)) {
- return (offset_tbl[cnt].offset - bytes);
- }
-
- *totsize += offset_tbl[cnt].offset -
- (offset_tbl[cnt - 1].offset +
- offset_tbl[cnt - 1].length);
- }
- return (0);
-}
-
-
-/*
- * Description : segment_hdr_present() verify space for new segment header to
- * be added.
- */
-
-static int
-segment_hdr_present(int segoffset, int size, seg_info_t *offset_tbl)
-{
- if ((segoffset + size) <= offset_tbl[0].offset)
- return (0);
- else
- return (-1);
-}
-
-/*
- * Description : find_offset() is called from fru_add_segment routine to find
- * a valid offset.
- */
-
-static int
-find_offset(char *seghdr, int segcnt, int secsize, int *sectionoffset,
- int segsize, int fix, container_hdl_t contfd)
-{
- int ret;
- int newoffset;
- int totsize = 0;
- seg_info_t *offset_tbl;
-
- if (segcnt == 0) {
- if (!fix) { /* if not fixed segment */
- *sectionoffset = secsize - segsize;
- }
- return (0);
- }
-
- /*
- * two extra segment info structure are allocated for start of segment
- * and other end of segment. first segment offset is first available
- * space and length is 0. second segment offset is is segment length and
- * offset is 0. build_offset_tbl() explains how upper boundary and lower
- * boudary segment area are initialized in seg_info_t table.
- */
-
- offset_tbl = malloc((segcnt + 2) * sizeof (seg_info_t));
- if (offset_tbl == NULL) {
- return (-1);
- }
-
- /* read all the segment header to make offset table */
- ret = build_offset_tbl(seghdr, segcnt, secsize, offset_tbl);
- if (ret != 0) {
- free(offset_tbl);
- return (-1);
- }
-
- /* sort the table */
- sort_offsettbl(segcnt, offset_tbl);
-
- /* new segment header offset */
- newoffset = sizeof (section_layout_t) + segcnt *
- sizeof (segment_layout_t);
-
- /* do? new segment header overlap any existing data */
- ret = segment_hdr_present(newoffset, sizeof (segment_layout_t),
- offset_tbl);
- if (ret != 0) { /* make room for new segment if possible */
-
- /* look for hole in order to move segment data */
- if (offset_tbl[0].fixed == SEGMENT_FIXED) { /* fixed segment */
- free(offset_tbl);
- return (-1);
- }
-
- newoffset = hole_discovery(offset_tbl[0].length,
- segcnt, &totsize, offset_tbl);
- if (newoffset != 0) { /* found new offset */
- /* now new offset */
- offset_tbl[0].offset = newoffset;
-
- /* move the segment data */
- move_segment_data(seghdr, newoffset, contfd);
- /* again sort the offset table */
- sort_offsettbl(segcnt, offset_tbl);
- } else {
- /* pack the existing hole */
- if (totsize > offset_tbl[0].length) {
- pack_segment_data(seghdr, segcnt,
- contfd, offset_tbl);
- } else {
- free(offset_tbl);
- return (-1);
- }
- }
- }
-
- totsize = 0;
- newoffset = hole_discovery(segsize, segcnt, &totsize, offset_tbl);
-
- if (newoffset == 0) { /* No hole found */
- if (totsize >= segsize) {
- pack_segment_data(seghdr, segcnt, contfd,
- offset_tbl);
- newoffset = hole_discovery(segsize, segcnt,
- &totsize, offset_tbl);
- if (newoffset != 0) {
- *sectionoffset = newoffset;
- free(offset_tbl);
- return (0);
- }
- }
- } else {
- *sectionoffset = newoffset;
- free(offset_tbl);
- return (0);
- }
- free(offset_tbl);
- return (-1);
-}
-
-/*
- * Description :sun_fru_open_container() opens the container associated with
- * a fru. it's called by data plugin module before creating
- * container property. it calls picltree library routine to get
- * the device path and driver binding name for the fru to get the
- * corresponding fru name that describe the fru layout.
- *
- * Arguments :picl_hdl_t fru
- * A handle for PICL tree node of class "fru" representing the
- * FRU with the container to open.
- *
- * Return :
- * On Success, a Positive integer container handle. is returned
- * for use in subsequent fru operations;on error, 0 is returned
- * and "errno" is set appropriately.
- */
-static container_hdl_t
-sun_fru_open_container(picl_nodehdl_t fruhdl)
-{
- int count;
- hash_obj_t *cont_hash_obj;
- hash_obj_t *sec_hash_obj;
-
- cont_hash_obj = lookup_handle_object((handle_t)fruhdl, CONTAINER_TYPE);
- if (cont_hash_obj == NULL) {
- return (NULL);
- }
-
- cont_hash_obj->u.cont_obj->num_of_section = NUM_OF_SECTIONS;
- cont_hash_obj->u.cont_obj->sec_obj_list = NULL;
-
- for (count = 0; count < NUM_OF_SECTIONS; count++) {
- sec_hash_obj = create_section_hash_object();
- if (sec_hash_obj == NULL) {
- return (NULL);
- }
-
- add_hashobject_to_hashtable(sec_hash_obj, SECTION_TYPE);
-
- if (count == 0) {
- sec_hash_obj->u.sec_obj->section.offset =
- DYNAMIC_OFFSET;
- sec_hash_obj->u.sec_obj->section.protection =
- WRITE_SECTION;
- sec_hash_obj->u.sec_obj->section.length =
- DYNAMIC_LENGTH;
- } else {
- sec_hash_obj->u.sec_obj->section.offset = STATIC_OFFSET;
- sec_hash_obj->u.sec_obj->section.protection =
- READ_ONLY_SECTION;
- sec_hash_obj->u.sec_obj->section.length = STATIC_LENGTH;
- }
-
- sec_hash_obj->u.sec_obj->section.version = SECTION_HDR_VER;
-
- add_to_sec_object_list(cont_hash_obj, sec_hash_obj);
- }
-
- return (cont_hash_obj->obj_hdl);
-}
-
-static int
-verify_header_crc8(headerrev_t head_ver, unsigned char *bytes, int length)
-{
- int crc_offset = 0;
- unsigned char orig_crc8 = 0;
- unsigned char calc_crc8 = 0;
-
- switch (head_ver) {
- case SECTION_HDR_VER:
- crc_offset = 4;
- break;
- default:
- errno = EINVAL;
- return (0);
- }
-
- orig_crc8 = bytes[crc_offset];
- bytes[crc_offset] = 0x00; /* clear for calc */
- calc_crc8 = compute_crc8(bytes, length);
- bytes[crc_offset] = orig_crc8; /* restore */
-
- return (orig_crc8 == calc_crc8);
-}
-
-/*
- * Description :
- * sun_fru_get_num_sections() returns number of sections in a
- * container. it calls get_container_index() to get the container
- * index number in the container list.
- *
- * Arguments :
- * container_hdl_t : container handle.
- *
- * Return :
- * int
- * On success, returns number of sections in a container.
- *
- */
-/*ARGSUSED*/
-static int
-sun_fru_get_num_sections(container_hdl_t container, door_cred_t *cred)
-{
- hash_obj_t *hash_object;
-
- hash_object = lookup_handle_object(container, CONTAINER_TYPE);
- if (hash_object == NULL) {
- return (-1);
- }
-
- return (hash_object->u.cont_obj->num_of_section);
-}
-
-/*
- * called from fru_get_sections()
- */
-
-static void
-get_section(int fd, hash_obj_t *sec_hash, section_t *section)
-{
- int retval;
- int size;
- int count;
- uint16_t hdrver;
- hash_obj_t *seg_hash;
- unsigned char *buffer;
- section_obj_t *sec_obj;
- section_layout_t sec_hdr;
- segment_layout_t *seg_hdr;
- segment_layout_t *seg_buf;
- format_t format;
- hash_obj_t *cont_hash;
-
- sec_obj = sec_hash->u.sec_obj;
- if (sec_obj == NULL) {
- return;
- }
-
- /* populate section_t */
- section->handle = sec_hash->obj_hdl;
- section->offset = sec_obj->section.offset;
- section->length = sec_obj->section.length;
- section->protection = sec_obj->section.protection;
- section->version = sec_obj->section.version;
- sec_obj->num_of_segment = 0;
-
- cont_hash = get_container_hash_object(SEGMENT_TYPE, sec_hash->obj_hdl);
- if (cont_hash == NULL) {
- return;
- }
-
- format = cont_hash->u.cont_obj->format;
-
- /* read section header layout */
- retval = pread_new(fd, &sec_hdr, sizeof (sec_hdr),
- sec_obj->section.offset, &format);
- if (retval != sizeof (sec_hdr)) {
- return;
- }
-
- hdrver = GET_SECTION_HDR_VERSION;
-
- if ((sec_hdr.headertag != SECTION_HDR_TAG) &&
- (hdrver != section->version)) {
- return;
- }
-
- /* size = section layout + total sizeof segment header */
- size = sizeof (sec_hdr) + ((sec_hdr.segmentcount)
- * sizeof (segment_layout_t));
- buffer = alloca(size);
- if (buffer == NULL) {
- return;
- }
-
- /* segment header buffer */
- seg_buf = alloca(size - sizeof (sec_hdr));
- if (seg_buf == NULL) {
- return;
- }
-
- /* read segment header */
- retval = pread_new(fd, seg_buf, size - sizeof (sec_hdr),
- sec_obj->section.offset + sizeof (sec_hdr), &format);
- if (retval != (size - sizeof (sec_hdr))) {
- return;
- }
-
- /* copy section header layout */
- (void) memcpy(buffer, &sec_hdr, sizeof (sec_hdr));
-
- /* copy segment header layout */
- (void) memcpy(buffer + sizeof (sec_hdr), seg_buf, size -
- sizeof (sec_hdr));
-
- /* verify crc8 */
- retval = verify_header_crc8(hdrver, buffer, size);
- if (retval != TRUE) {
- return;
- }
-
- section->version = hdrver;
- sec_obj->section.version = hdrver;
-
- seg_hdr = (segment_layout_t *)seg_buf;
-
- for (count = 0; count < sec_hdr.segmentcount; count++, seg_hdr++) {
- seg_hash = create_segment_hash_object();
- if (seg_hash == NULL) {
- return;
- }
-
- add_hashobject_to_hashtable(seg_hash, SEGMENT_TYPE);
-
- copy_segment_layout(&seg_hash->u.seg_obj->segment, seg_hdr);
-
- add_to_seg_object_list(sec_hash, seg_hash);
-
- sec_obj->num_of_segment++;
- }
-}
-
-/*
- * Description :
- * sun_fru_get_sections() fills an array of section structures
- * passed as an argument.
- *
- * Arguments :
- * container_hdl_t : container handle(device descriptor).
- * section_t : array of section structure.
- * int : maximum number of section in a container.
- *
- * Returns :
- * int
- * On success,the number of section structures written is returned;
- * on error, -1 is returned and "errno" is set appropriately.
- *
- */
-/*ARGSUSED*/
-static int
-sun_fru_get_sections(container_hdl_t container, section_t *section, int maxsec,
- door_cred_t *cred)
-{
- int device_fd;
- int count;
- hash_obj_t *cont_object;
- hash_obj_t *sec_hash;
-
- cont_object = lookup_handle_object(container, CONTAINER_TYPE);
- if (cont_object == NULL) {
- return (-1);
- }
-
- if (cont_object->u.cont_obj->num_of_section > maxsec) {
- return (-1);
- }
-
- sec_hash = cont_object->u.cont_obj->sec_obj_list;
- if (sec_hash == NULL) {
- return (-1);
- }
-
- device_fd = open_file();
-
- if (device_fd < 0) {
- return (-1);
- }
-
- for (count = 0; count < cont_object->u.cont_obj->num_of_section;
- count++, section++) {
- section->version = -1;
- /* populate section_t */
- get_section(device_fd, sec_hash, section);
- sec_hash = sec_hash->u.sec_obj->next;
- }
-
- (void) close(device_fd);
-
- return (count);
-}
-
-/*
- * Description :
- * sun_fru_get_num_segments() returns the current number of
- * segments in a section.
- *
- * Arguments :
- * section_hdl_t : section header holding section information.
- *
- * Return :
- * int
- * On success, the number of segments in the argument section is
- * returned; on error -1 is returned.
- */
-/*ARGSUSED*/
-static int
-sun_fru_get_num_segments(section_hdl_t section, door_cred_t *cred)
-{
- hash_obj_t *sec_object;
- section_obj_t *sec_obj;
-
- sec_object = lookup_handle_object(section, SECTION_TYPE);
- if (sec_object == NULL) {
- return (-1);
- }
-
- sec_obj = sec_object->u.sec_obj;
- if (sec_obj == NULL) {
- return (-1);
- }
-
- return (sec_obj->num_of_segment);
-}
-
-/*
- * Description :
- * sun_fru_get_segments() fills an array of structures
- * representing the segments in a section.
- *
- * Arguments :
- * section_hdl_t : holds section number.
- * segment_t : on success will hold segment information.
- * int : maximum number of segment.
- *
- * Return :
- * int
- * On success, the number of segment structures written is
- * returned; on errno -1 is returned.
- */
-/* ARGSUSED */
-static int
-sun_fru_get_segments(section_hdl_t section, segment_t *segment, int maxseg,
- door_cred_t *cred)
-{
- int count;
- hash_obj_t *sec_object;
- hash_obj_t *seg_object;
- section_obj_t *sec_obj;
-
- sec_object = lookup_handle_object(section, SECTION_TYPE);
- if (sec_object == NULL) {
- return (-1);
- }
-
- sec_obj = sec_object->u.sec_obj;
- if (sec_obj == NULL) {
- return (-1);
- }
-
- if (sec_obj->num_of_segment > maxseg) {
- return (-1);
- }
-
- seg_object = sec_object->u.sec_obj->seg_obj_list;
- if (seg_object == NULL) {
- return (-1);
- }
-
- for (count = 0; count < sec_obj->num_of_segment; count++) {
-
- /* populate segment_t */
- segment->handle = seg_object->obj_hdl;
- (void) memcpy(segment->name,
- seg_object->u.seg_obj->segment.name, SEG_NAME_LEN);
- segment->descriptor = seg_object->u.seg_obj->segment.descriptor;
- segment->offset = seg_object->u.seg_obj->segment.offset;
- segment->length = seg_object->u.seg_obj->segment.length;
- seg_object = seg_object->u.seg_obj->next;
- segment++;
- }
- return (0);
-}
-
-/*
- * Description :
- * sun_fru_add_segment() adds a segment to a section.
- *
- * Arguments :
- * section_hdl_t section
- * A handle for the section in which to add the segment.
- *
- * segment_t *segment
- * On entry, the "handle" component of "segment" is ignored and the
- * remaining components specify the parameters of the segment to be
- * added. On return, the "handle" component is set to the handle
- * for the added segment. The segment offset is mandatory for FIXED
- * segments; otherwise, the offset is advisory.
- *
- * Return :
- * int
- * On success, 0 is returned; on error -1 is returned.
- *
- */
-static int
-sun_fru_add_segment(section_hdl_t section, segment_t *segment,
- section_hdl_t *newsection, door_cred_t *cred)
-{
- int fd;
- int retval;
- int offset;
- int sec_size;
- int seg_cnt;
- int bufsize;
- int new_seg_offset;
- int new_seg_length;
- int fixed_segment;
- char trailer[] = { 0x0c, 0x00, 0x00, 0x00, 0x00 };
- hash_obj_t *cont_hash;
- hash_obj_t *sec_hash;
- hash_obj_t *seg_hash;
- fru_segdesc_t *new_seg_desc;
- unsigned char *crcbuf;
- section_layout_t sec_layout;
- segment_layout_t *seg_layout;
- segment_layout_t *segment_buf;
- format_t format;
-
- /* check the effective uid of the client */
- if (cred->dc_euid != 0) {
- errno = EPERM;
- return (-1); /* not a root */
- }
-
- /* section hash */
- sec_hash = lookup_handle_object(section, SECTION_TYPE);
- if (sec_hash == NULL) {
- return (-1);
- }
-
- /* check for read-only section */
- if (sec_hash->u.sec_obj->section.protection == READ_ONLY_SECTION) {
- errno = EPERM;
- return (-1);
- }
-
- /* look for duplicate segment */
- seg_hash = sec_hash->u.sec_obj->seg_obj_list;
- while (seg_hash != NULL) {
- if (strncmp(segment->name, seg_hash->u.seg_obj->segment.name,
- SEG_NAME_LEN) == 0) {
- errno = EEXIST;
- return (-1); /* can't add duplicate segment */
- }
- seg_hash = seg_hash->u.seg_obj->next;
- }
-
- /* get the container hash */
- cont_hash = lookup_handle_object(sec_hash->u.sec_obj->cont_hdl,
- CONTAINER_TYPE);
- if (cont_hash == NULL) {
- return (-1);
- }
-
- format = cont_hash->u.cont_obj->format;
-
- /* open the container */
- fd = open_file();
- if (fd < 0) {
- return (-1);
- }
-
- /* section start here */
- offset = sec_hash->u.sec_obj->section.offset;
-
- /* read section header layout */
- retval = pread_new(fd, &sec_layout, sizeof (sec_layout), offset,
- &format);
- if (retval != sizeof (sec_layout)) {
- (void) close(fd);
- return (-1);
- }
-
- /* check for valid section header */
- if (sec_layout.headertag != SECTION_HDR_TAG) {
- /* write a new one */
- sec_layout.headertag = SECTION_HDR_TAG;
- sec_layout.headerversion[0] = SECTION_HDR_VER_BIT0;
- sec_layout.headerversion[1] = SECTION_HDR_VER_BIT1;
- sec_layout.headerlength = sizeof (sec_layout);
- sec_layout.segmentcount = 0;
- }
-
- /* section size */
- sec_size = sec_hash->u.sec_obj->section.length;
-
- /* number of segment in the section */
- seg_cnt = sec_layout.segmentcount;
-
- /* total sizeof segment + new segment */
- bufsize = sizeof (segment_layout_t) * (seg_cnt + 1);
- segment_buf = alloca(bufsize);
- if (segment_buf == NULL) {
- return (-1);
- }
-
- /* read entire segment header */
- retval = pread_new(fd, segment_buf,
- (bufsize - sizeof (segment_layout_t)),
- offset + sizeof (section_layout_t), &format);
- if (retval != (bufsize - sizeof (segment_layout_t))) {
- (void) close(fd);
- return (-1);
- }
-
- new_seg_offset = segment->offset; /* new segment offset */
- new_seg_length = segment->length; /* new segment length */
-
- new_seg_desc = (fru_segdesc_t *)&segment->descriptor;
-
- fixed_segment = new_seg_desc->field.fixed;
-
- /* get new offset for new segment to be addedd */
- retval = find_offset((char *)segment_buf, seg_cnt, sec_size,
- &new_seg_offset, new_seg_length, fixed_segment, fd);
-
- if (retval != 0) {
- (void) close(fd);
- errno = EAGAIN;
- return (-1);
- }
-
- /* copy new segment data in segment layout */
- seg_layout = (segment_layout_t *)(segment_buf + seg_cnt);
- (void) memcpy(&seg_layout->name, segment->name, SEG_NAME_LEN);
- (void) memcpy(seg_layout->descriptor, &segment->descriptor,
- sizeof (uint32_t));
- seg_layout->length = segment->length;
- seg_layout->offset = new_seg_offset; /* new segment offset */
-
- sec_layout.segmentcount += 1;
-
- crcbuf = alloca(sizeof (section_layout_t) + bufsize);
- if (crcbuf == NULL) {
- (void) close(fd);
- return (-1);
- }
-
- sec_layout.headercrc8 = 0;
- sec_layout.headerlength += sizeof (segment_layout_t);
-
- (void) memcpy(crcbuf, (char *)&sec_layout, sizeof (section_layout_t));
- (void) memcpy(crcbuf + sizeof (section_layout_t), segment_buf, bufsize);
-
- sec_layout.headercrc8 = compute_crc8(crcbuf, bufsize +
- sizeof (section_layout_t));
-
- /* write section header */
- retval = pwrite_new(fd, &sec_layout, sizeof (section_layout_t),
- offset, &format);
- if (retval != sizeof (section_layout_t)) {
- (void) close(fd);
- return (-1);
- }
-
- /* write segment header */
- retval = pwrite_new(fd, segment_buf, bufsize, offset +
- sizeof (section_layout_t), &format);
- if (retval != bufsize) {
- (void) close(fd);
- return (-1);
- }
-
- /* write segment trailer */
- retval = pwrite_new(fd, &trailer, sizeof (trailer), new_seg_offset,
- &format);
- if (retval != sizeof (trailer)) {
- (void) close(fd);
- return (-1);
- }
-
- (void) close(fd);
-
- /* create new segment hash object */
- seg_hash = create_segment_hash_object();
- if (seg_hash == NULL) {
- return (-1);
- }
-
- add_hashobject_to_hashtable(seg_hash, SEGMENT_TYPE);
-
- copy_segment_layout(&seg_hash->u.seg_obj->segment, seg_layout);
-
- add_to_seg_object_list(sec_hash, seg_hash);
-
- sec_hash->u.sec_obj->num_of_segment += 1;
- seg_hash->u.seg_obj->trailer_offset = new_seg_offset;
- *newsection = section; /* return the new section handle */
- return (0);
-}
-
-/*
- * Description :
- * sun_fru_delete_segment() deletes a segment from a section; the
- * associated container data is not altered.
- *
- * Arguments : segment_hdl_t segment handle.
- * section_hdl_t new section handle.
- *
- * Return :
- * int
- * On success, 0 returned; On error -1 is returned.
- */
-static int
-sun_fru_delete_segment(segment_hdl_t segment, section_hdl_t *newsection,
- door_cred_t *cred)
-{
- int num_of_seg;
- int bufsize;
- int count;
- int retval;
- int fd;
- int segnum;
- hash_obj_t *seg_hash;
- hash_obj_t *sec_hash;
- hash_obj_t *cont_hash;
- hash_obj_t *tmp_hash;
- unsigned char *buffer;
- fru_segdesc_t *desc;
- segment_layout_t *seg_buf;
- section_layout_t *sec_layout;
- segment_layout_t *seg_layout;
- segment_layout_t *next_layout;
- format_t format;
-
- /* check the effective uid of the client */
- if (cred->dc_euid != 0) {
- errno = EPERM;
- return (-1); /* not a root */
- }
-
- seg_hash = lookup_handle_object(segment, SEGMENT_TYPE);
- if (seg_hash == NULL) {
- return (-1);
- }
-
- desc = (fru_segdesc_t *)&seg_hash->u.seg_obj->segment.descriptor;
- if (!(desc->field.field_perm & SEGMENT_DELETE)) {
- errno = EPERM;
- return (-1); /* can't delete this segment */
- }
-
- sec_hash = lookup_handle_object(seg_hash->u.seg_obj->section_hdl,
- SECTION_TYPE);
- if (sec_hash == NULL) {
- return (-1);
- }
-
- if (sec_hash->u.sec_obj->section.protection == READ_ONLY_SECTION) {
- errno = EPERM;
- return (-1);
- }
-
- num_of_seg = sec_hash->u.sec_obj->num_of_segment;
-
- bufsize = (sizeof (segment_layout_t) * num_of_seg);
-
- seg_buf = alloca(bufsize);
- if (seg_buf == NULL) {
- return (-1);
- }
-
- segnum = 0;
- for (tmp_hash = sec_hash->u.sec_obj->seg_obj_list; tmp_hash != NULL;
- tmp_hash = tmp_hash->u.seg_obj->next) {
- if (tmp_hash->obj_hdl == segment) {
- break;
- }
- segnum++;
- }
-
- cont_hash = lookup_handle_object(sec_hash->u.sec_obj->cont_hdl,
- CONTAINER_TYPE);
- if (cont_hash == NULL) {
- return (-1);
- }
- format = cont_hash->u.cont_obj->format;
-
- fd = open_file();
- if (fd < 0) {
- return (-1);
- }
-
- sec_layout = alloca(sizeof (section_layout_t));
- if (sec_layout == NULL) {
- (void) close(fd);
- return (-1);
- }
-
- /* read section layout header */
- retval = pread_new(fd, sec_layout, sizeof (section_layout_t),
- sec_hash->u.sec_obj->section.offset, &format);
- if (retval != sizeof (section_layout_t)) {
- (void) close(fd);
- return (-1);
- }
-
- /* read segment header layout */
- retval = pread_new(fd, seg_buf, bufsize,
- sec_hash->u.sec_obj->section.offset +
- sizeof (section_layout_t), &format);
- if (retval != bufsize) {
- (void) close(fd);
- return (-1);
- }
-
- seg_layout = (segment_layout_t *)(seg_buf + segnum);
- next_layout = seg_layout;
- for (count = segnum; count < sec_hash->u.sec_obj->num_of_segment-1;
- count++) {
- next_layout++;
- (void) memcpy(seg_layout, next_layout,
- sizeof (segment_layout_t));
- seg_layout++;
- }
-
- (void) memset(seg_layout, '\0', sizeof (segment_layout_t));
-
- sec_layout->headercrc8 = 0;
-
- sec_layout->headerlength -= sizeof (segment_layout_t);
- sec_layout->segmentcount -= 1;
-
- buffer = alloca(sec_layout->headerlength);
- if (buffer == NULL) {
- (void) close(fd);
- return (-1);
- }
-
- (void) memcpy(buffer, sec_layout, sizeof (section_layout_t));
- (void) memcpy(buffer + sizeof (section_layout_t), seg_buf, bufsize
- - sizeof (segment_layout_t));
- sec_layout->headercrc8 = compute_crc8(buffer,
- sec_layout->headerlength);
-
- /* write section header with update crc8 and header length */
- retval = pwrite_new(fd, sec_layout, sizeof (section_layout_t),
- sec_hash->u.sec_obj->section.offset, &format);
- if (retval != sizeof (section_layout_t)) {
- (void) close(fd);
- return (-1);
- }
-
- /* write the update segment header */
- retval = pwrite_new(fd, seg_buf, bufsize,
- sec_hash->u.sec_obj->section.offset +
- sizeof (section_layout_t), &format);
- (void) close(fd);
- if (retval != bufsize) {
- return (-1);
- }
-
- free_segment_hash(segment, sec_hash);
-
- *newsection = sec_hash->obj_hdl;
- sec_hash->u.sec_obj->num_of_segment = sec_layout->segmentcount;
-
- return (0);
-}
-
-/*
- * Description :
- * sun_fru_read_segment() reads the raw contents of a segment.
- *
- * Arguments : segment_hdl_t : segment handle.
- * void * : buffer containing segment data when function returns.
- * size_t :number of bytes.
- *
- * Return :
- * int
- * On success, the number of bytes read is returned;
- *
- * Notes :
- * Segments containing packets can be read in structured fashion
- * using the fru_get_packets() and fru_get_payload() primitives;the
- * entire byte range of a segment can be read using
- * fru_read_segment().
- */
-/*ARGSUSED*/
-static ssize_t
-sun_fru_read_segment(segment_hdl_t segment, void *buffer, size_t nbytes,
- door_cred_t *cred)
-{
- int fd;
- int retval;
- hash_obj_t *seg_hash;
- hash_obj_t *sec_hash;
- hash_obj_t *cont_hash;
- format_t format;
-
- /* segment hash object */
- seg_hash = lookup_handle_object(segment, SEGMENT_TYPE);
- if (seg_hash == NULL) {
- return (-1);
- }
-
- /* section hash object */
- sec_hash = lookup_handle_object(seg_hash->u.seg_obj->section_hdl,
- SECTION_TYPE);
- if (sec_hash == NULL) {
- return (-1);
- }
-
- /* container hash object */
- cont_hash = lookup_handle_object(sec_hash->u.sec_obj->cont_hdl,
- CONTAINER_TYPE);
- if (cont_hash == NULL) {
- return (-1);
- }
- format = cont_hash->u.cont_obj->format;
-
- if (seg_hash->u.seg_obj->segment.length < nbytes) {
- return (-1);
- }
-
- fd = open_file();
- if (fd < 0) {
- return (-1);
- }
-
- retval = pread_new(fd, buffer, nbytes,
- seg_hash->u.seg_obj->segment.offset, &format);
- (void) close(fd);
- if (retval != nbytes) {
- return (-1);
- }
- return (nbytes);
-}
-
-/*
- * Description :
- * sun_fru_write_segment() writes a raw segment.
- *
- * Arguments : segment_hdl_t :segment handle.
- * const void * : data buffer.
- * size_t : number of bytes.
- * segment_hdl_t : new segment handle.
- *
- * Returns :
- * int
- * On success, the number of bytes written is returned
- *
- */
-/*ARGSUSED*/
-static int
-sun_fru_write_segment(segment_hdl_t segment, const void *data, size_t nbytes,
- segment_hdl_t *newsegment, door_cred_t *cred)
-{
- return (ENOTSUP);
-}
-
-
-static int
-get_packet(int device_fd, void *buffer, int size, int offset, format_t *format)
-{
- int retval;
-
- retval = pread_new(device_fd, (char *)buffer, size, offset, format);
- if (retval != -1) {
- return (0);
- }
- return (-1);
-}
-
-static uint32_t
-get_checksum_crc(hash_obj_t *seg_hash, int data_size)
-{
- int protection;
- int offset = 0;
- uint32_t crc;
- hash_obj_t *sec_hash;
- hash_obj_t *pkt_hash;
- unsigned char *buffer;
-
- sec_hash = lookup_handle_object(seg_hash->u.seg_obj->section_hdl,
- SECTION_TYPE);
- if (sec_hash == NULL) {
- return ((uint32_t)-1);
- }
-
- buffer = alloca(data_size);
- if (buffer == NULL) {
- return ((uint32_t)-1);
- }
-
- /* traverse the packet object list for all the tags and payload */
- for (pkt_hash = seg_hash->u.seg_obj->pkt_obj_list; pkt_hash != NULL;
- pkt_hash = pkt_hash->u.pkt_obj->next) {
- (void) memcpy(buffer + offset, &pkt_hash->u.pkt_obj->tag,
- pkt_hash->u.pkt_obj->tag_size);
- offset += pkt_hash->u.pkt_obj->tag_size;
- (void) memcpy(buffer + offset, pkt_hash->u.pkt_obj->payload,
- pkt_hash->u.pkt_obj->paylen);
- offset += pkt_hash->u.pkt_obj->paylen;
- }
-
- protection = sec_hash->u.sec_obj->section.protection;
-
- if (protection == READ_ONLY_SECTION) { /* read-only section */
- crc = compute_crc32(buffer, data_size);
- } else { /* read/write section */
- crc = compute_checksum32(buffer, data_size);
- }
- return (crc); /* computed crc */
-}
-
-static int
-get_packets(hash_obj_t *seg_hash, int device_fd, int offset, int length)
-{
- int tag_size;
- int paylen;
- int retval;
- int seg_limit = 0;
- int pktcnt = 0;
- char *data;
- uint32_t crc;
- uint32_t origcrc;
- fru_tag_t tag;
- hash_obj_t *pkt_hash_obj;
- fru_segdesc_t *segdesc;
- fru_tagtype_t tagtype;
- format_t format;
- hash_obj_t *cont_hash;
-
- cont_hash = get_container_hash_object(PACKET_TYPE, seg_hash->obj_hdl);
- if (cont_hash == NULL) {
- return (NULL);
- }
- format = cont_hash->u.cont_obj->format;
-
- retval = get_packet(device_fd, &tag, sizeof (fru_tag_t), offset,
- &format);
- if (retval == -1) {
- return (-1);
- }
-
- seg_hash->u.seg_obj->trailer_offset = offset;
-
- data = (char *)&tag;
- while (data[0] != SEG_TRAILER_TAG) {
- tagtype = get_tag_type(&tag); /* verify tag type */
- if (tagtype == -1) {
- return (-1);
- }
-
- tag_size = get_tag_size(tagtype);
- if (tag_size == -1) {
- return (-1);
- }
-
- seg_limit += tag_size;
- if (seg_limit > length) {
- return (-1);
- }
-
- paylen = get_payload_length((void *)&tag);
- if (paylen == -1) {
- return (-1);
- }
-
- seg_limit += paylen;
- if (seg_limit > length) {
- return (-1);
- }
-
- pkt_hash_obj = create_packet_hash_object();
- if (pkt_hash_obj == NULL) {
- return (-1);
- }
-
- pkt_hash_obj->u.pkt_obj->payload = malloc(paylen);
- if (pkt_hash_obj->u.pkt_obj->payload == NULL) {
- free(pkt_hash_obj);
- return (-1);
- }
-
- offset += tag_size;
- retval = pread_new(device_fd, pkt_hash_obj->u.pkt_obj->payload,
- paylen, offset, &format);
- if (retval != paylen) {
- free(pkt_hash_obj->u.pkt_obj->payload);
- free(pkt_hash_obj);
- return (-1);
- }
-
- /* don't change this */
- pkt_hash_obj->u.pkt_obj->tag.raw_data = 0;
- (void) memcpy(&pkt_hash_obj->u.pkt_obj->tag, &tag, tag_size);
- pkt_hash_obj->u.pkt_obj->paylen = paylen;
- pkt_hash_obj->u.pkt_obj->tag_size = tag_size;
- pkt_hash_obj->u.pkt_obj->payload_offset = offset;
-
- offset += paylen;
-
- add_hashobject_to_hashtable(pkt_hash_obj, PACKET_TYPE);
- add_to_pkt_object_list(seg_hash, pkt_hash_obj);
-
- pktcnt++;
-
- retval = get_packet(device_fd, &tag, sizeof (fru_tag_t),
- offset, &format);
- if (retval == -1) {
- return (retval);
- }
-
- data = (char *)&tag;
- }
-
- segdesc = (fru_segdesc_t *)&seg_hash->u.seg_obj->segment.descriptor;
-
- seg_hash->u.seg_obj->trailer_offset = offset;
-
- if (!segdesc->field.ignore_checksum) {
- crc = get_checksum_crc(seg_hash, seg_limit);
- offset = seg_hash->u.seg_obj->segment.offset;
-
- retval = pread_new(device_fd, &origcrc, sizeof (origcrc),
- offset + seg_limit + 1, &format);
- if (retval != sizeof (origcrc)) {
- return (-1);
- }
-
- if (origcrc != crc) {
- seg_hash->u.seg_obj->trailer_offset = offset;
- return (-1);
- }
- }
- return (pktcnt);
-}
-
-/*
- * Description :
- * sun_fru_get_num_packets() returns the current number of packets
- * in a segment.
- *
- * Arguments : segment_hdl_t : segment handle.
- *
- * Return :
- * int
- * On success, the number of packets is returned;
- * -1 on failure.
- */
-/*ARGSUSED*/
-static int
-sun_fru_get_num_packets(segment_hdl_t segment, door_cred_t *cred)
-{
- int device_fd;
- int pktcnt;
- int length;
- uint16_t offset;
- hash_obj_t *cont_hash_obj;
- hash_obj_t *seg_hash;
- fru_segdesc_t *segdesc;
- segment_obj_t *segment_object;
-
- seg_hash = lookup_handle_object(segment, SEGMENT_TYPE);
- if (seg_hash == NULL) {
- return (-1);
- }
-
- segment_object = seg_hash->u.seg_obj;
- if (segment_object == NULL) {
- return (-1);
- }
-
-
- segdesc = (fru_segdesc_t *)&segment_object->segment.descriptor;
- if (segdesc->field.opaque) {
- return (0);
- }
-
- offset = segment_object->segment.offset;
- length = segment_object->segment.length;
-
- cont_hash_obj = get_container_hash_object(SEGMENT_TYPE,
- segment_object->section_hdl);
-
- if (cont_hash_obj == NULL) {
- return (-1);
- }
-
- if (seg_hash->u.seg_obj->pkt_obj_list != NULL) {
- return (segment_object->num_of_packets);
- }
-
- segment_object->num_of_packets = 0;
- device_fd = open_file();
- if (device_fd < 0) {
- return (-1);
- }
-
- pktcnt = get_packets(seg_hash, device_fd, offset,
- length);
- if (pktcnt == -1) {
- free_pkt_object_list(seg_hash);
- seg_hash->u.seg_obj->pkt_obj_list = NULL;
- }
-
- segment_object->num_of_packets = pktcnt;
- (void) close(device_fd);
-
- return (segment_object->num_of_packets);
-}
-
-/*
- * Description :
- * sun_fru_get_packets() fills an array of structures
- * representing the packets in a segment.
- *
- * Arguments : segment_hdl_t : segment handle.
- * packet_t : packet buffer.
- * int : maximum number of packets.
- *
- * Return :
- * int
- * On success, the number of packet structures written is returned;
- * On failure -1 is returned;
- *
- */
-/*ARGSUSED*/
-static int
-sun_fru_get_packets(segment_hdl_t segment, packet_t *packet, int maxpackets,
- door_cred_t *cred)
-{
- int count;
- hash_obj_t *seg_hash_obj;
- hash_obj_t *pkt_hash_obj;
-
- /* segment hash object */
- seg_hash_obj = lookup_handle_object(segment, SEGMENT_TYPE);
- if (seg_hash_obj == NULL) {
- return (-1);
- }
-
- if (seg_hash_obj->u.seg_obj->num_of_packets != maxpackets) {
- return (-1);
- }
-
- pkt_hash_obj = seg_hash_obj->u.seg_obj->pkt_obj_list;
- if (pkt_hash_obj == NULL) {
- return (-1);
- }
-
- for (count = 0; count < maxpackets; count++, packet++) {
- packet->handle = pkt_hash_obj->obj_hdl;
- packet->tag = 0;
- (void) memcpy(&packet->tag, &pkt_hash_obj->u.pkt_obj->tag,
- pkt_hash_obj->u.pkt_obj->tag_size);
- pkt_hash_obj = pkt_hash_obj->u.pkt_obj->next;
- }
-
- return (0);
-}
-
-/*
- * Description :
- * sun_fru_get_payload() copies the contents of a packet's payload.
- *
- * Arguments : packet_hdl_t : packet handle.
- * void * : payload buffer.
- * size_t : sizeof the buffer.
- *
- * Return :
- * int
- * On success, the number of bytes copied is returned; On error
- * -1 returned.
- */
-/*ARGSUSED*/
-static ssize_t
-sun_fru_get_payload(packet_hdl_t packet, void *buffer, size_t nbytes,
- door_cred_t *cred)
-{
- hash_obj_t *packet_hash_obj;
-
- /* packet hash object */
- packet_hash_obj = lookup_handle_object(packet, PACKET_TYPE);
- if (packet_hash_obj == NULL) {
- return (-1);
- }
-
- /* verify payload length */
- if (nbytes != packet_hash_obj->u.pkt_obj->paylen) {
- return (-1);
- }
-
- (void) memcpy(buffer, packet_hash_obj->u.pkt_obj->payload, nbytes);
- return (nbytes);
-}
-
-/*
- * Description :
- * sun_fru_update_payload() writes the contents of a packet's
- * payload.
- *
- * Arguments : packet_hdl_t : packet handle.
- * const void * : data buffer.
- * size_t : buffer size.
- * packet_hdl_t : new packet handle.
- *
- * Return :
- * int
- * On success, 0 is returned; on failure
- * -1 is returned.
- */
-/*ARGSUSED*/
-static int
-sun_fru_update_payload(packet_hdl_t packet, const void *data, size_t nbytes,
- packet_hdl_t *newpacket, door_cred_t *cred)
-{
- int fd;
- int segment_offset;
- int trailer_offset;
- int retval;
- uint32_t crc;
- hash_obj_t *pkt_hash;
- hash_obj_t *seg_hash;
- hash_obj_t *sec_hash;
- hash_obj_t *cont_hash;
- fru_segdesc_t *desc;
- format_t format;
-
- /* check the effective uid of the client */
- if (cred->dc_euid != 0) {
- errno = EPERM;
- return (-1); /* not a root */
- }
-
- /* packet hash object */
- pkt_hash = lookup_handle_object(packet, PACKET_TYPE);
- if (pkt_hash == NULL) {
- return (-1);
- }
-
- /* segment hash object */
- seg_hash = lookup_handle_object(pkt_hash->u.pkt_obj->segment_hdl,
- SEGMENT_TYPE);
- if (seg_hash == NULL) {
- return (-1);
- }
-
- /* check for write perm. */
- desc = (fru_segdesc_t *)&seg_hash->u.seg_obj->segment.descriptor;
- if (!(desc->field.field_perm & SEGMENT_WRITE)) {
- errno = EPERM;
- return (-1); /* write not allowed */
- }
-
- sec_hash = lookup_handle_object(seg_hash->u.seg_obj->section_hdl,
- SECTION_TYPE);
- if (sec_hash == NULL) {
- return (-1);
- }
-
- if (sec_hash->u.sec_obj->section.protection == READ_ONLY_SECTION) {
- errno = EPERM;
- return (-1); /* read-only section */
- }
-
- cont_hash = lookup_handle_object(sec_hash->u.sec_obj->cont_hdl,
- CONTAINER_TYPE);
- if (cont_hash == NULL) {
- return (-1);
- }
-
- format = cont_hash->u.cont_obj->format;
-
- if (pkt_hash->u.pkt_obj->paylen != nbytes) {
- return (-1);
- }
-
- (void) memcpy(pkt_hash->u.pkt_obj->payload, (char *)data, nbytes);
- fd = open_file();
- if (fd < 0) {
- return (-1);
- }
-
- trailer_offset = seg_hash->u.seg_obj->trailer_offset;
- segment_offset = seg_hash->u.seg_obj->segment.offset;
-
- crc = get_checksum_crc(seg_hash, (trailer_offset - segment_offset));
- retval = pwrite_new(fd, data, nbytes,
- pkt_hash->u.pkt_obj->payload_offset, &format);
- if (retval != nbytes) {
- (void) close(fd);
- return (-1);
- }
-
- retval = pwrite_new(fd, &crc, sizeof (crc),
- trailer_offset + 1, &format);
- (void) close(fd);
- if (retval != sizeof (crc)) {
- return (-1);
- }
- *newpacket = packet;
- return (0);
-}
-
-/*
- * Description :
- * sun_fru_append_packet() appends a packet to a segment.
- *
- * Arguments :
- * segment_hdl_t segment
- * A handle for the segment to which the packet will be appended.
- *
- * packet_t *packet
- * On entry, the "tag" component of "packet" specifies the tag
- * value for the added packet; the "handle" component is ignored.
- * On return, the "handle" component is set to the handle of the
- * appended packet.
- *
- * const void *payload
- * A pointer to the caller's buffer containing the payload data for
- * the appended packet.
- *
- * size_t nbytes
- * The size of the caller buffer.
- *
- * Return :
- * int
- * On success, 0 is returned; on error -1 is returned;
- */
-static int
-sun_fru_append_packet(segment_hdl_t segment, packet_t *packet,
- const void *payload, size_t nbytes, segment_hdl_t *newsegment,
- door_cred_t *cred)
-{
- int trailer_offset;
- int tag_size;
- int fd;
- int retval;
- char trailer[] = {0x0c, 0x00, 0x00, 0x00, 0x00};
- uint32_t crc;
- hash_obj_t *seg_hash;
- hash_obj_t *sec_hash;
- hash_obj_t *pkt_hash;
- hash_obj_t *cont_hash;
- fru_tagtype_t tagtype;
- fru_segdesc_t *desc;
- format_t format;
-
- /* check the effective uid of the client */
- if (cred->dc_euid != 0) {
- errno = EPERM;
- return (-1); /* not a root */
- }
-
- seg_hash = lookup_handle_object(segment, SEGMENT_TYPE);
- if (seg_hash == NULL) {
- return (-1);
- }
-
- /* check for write perm. */
- desc = (fru_segdesc_t *)&seg_hash->u.seg_obj->segment.descriptor;
- if (!(desc->field.field_perm & SEGMENT_WRITE)) {
- errno = EPERM;
- return (-1); /* write not allowed */
- }
-
- sec_hash = lookup_handle_object(seg_hash->u.seg_obj->section_hdl,
- SECTION_TYPE);
- if (sec_hash == NULL) {
- return (-1);
- }
-
- if (sec_hash->u.sec_obj->section.protection == READ_ONLY_SECTION) {
- errno = EPERM;
- return (-1); /* read-only section */
- }
-
- trailer_offset = seg_hash->u.seg_obj->trailer_offset;
-
- /*
- * if trailer offset is 0 than parse the segment data to get the trailer
- * offset to compute the remaining space left in the segment area for
- * new packet to be added.
- */
- if (trailer_offset == 0) {
- (void) sun_fru_get_num_packets(segment, cred);
- trailer_offset = seg_hash->u.seg_obj->trailer_offset;
- }
-
- tagtype = get_tag_type((void *)&packet->tag);
- if (tagtype == -1) {
- return (-1);
- }
-
- tag_size = get_tag_size(tagtype);
- if (tag_size == -1) {
- return (-1);
- }
-
- if (seg_hash->u.seg_obj->segment.length >
- ((trailer_offset - seg_hash->u.seg_obj->segment.offset) +
- tag_size + nbytes +
- sizeof (char) + sizeof (uint32_t))) {
- /* create new packet hash */
- pkt_hash = create_packet_hash_object();
- if (pkt_hash == NULL) {
- return (-1);
- }
-
- /* tag initialization */
- (void) memcpy(&pkt_hash->u.pkt_obj->tag, &packet->tag,
- tag_size);
- pkt_hash->u.pkt_obj->tag_size = tag_size;
-
- /* payload inititalization */
- pkt_hash->u.pkt_obj->payload = malloc(nbytes);
- if (pkt_hash->u.pkt_obj->payload == NULL) {
- free(pkt_hash);
- return (-1);
- }
-
- (void) memcpy(pkt_hash->u.pkt_obj->payload, payload, nbytes);
- pkt_hash->u.pkt_obj->paylen = nbytes;
- pkt_hash->u.pkt_obj->payload_offset = trailer_offset + tag_size;
-
- /* add to hash table */
- add_hashobject_to_hashtable(pkt_hash, PACKET_TYPE);
-
- add_to_pkt_object_list(seg_hash, pkt_hash);
-
- cont_hash = lookup_handle_object(sec_hash->u.sec_obj->cont_hdl,
- CONTAINER_TYPE);
- if (cont_hash == NULL) {
- return (-1);
- }
- format = cont_hash->u.cont_obj->format;
-
- fd = open_file();
- if (fd < 0) {
- return (-1);
- }
-
- /* update the trailer offset */
- trailer_offset += tag_size + nbytes;
-
- /* calculate new checksum */
- crc = get_checksum_crc(seg_hash, (trailer_offset -
- seg_hash->u.seg_obj->segment.offset));
-
- retval = pwrite_new(fd, &packet->tag, tag_size, trailer_offset
- - (tag_size + nbytes), &format);
- if (retval != tag_size) {
- (void) close(fd);
- return (-1);
- }
-
- retval = pwrite_new(fd, payload, nbytes,
- trailer_offset - nbytes, &format);
- if (retval != nbytes) {
- (void) close(fd);
- return (-1);
- }
-
- retval = pwrite_new(fd, trailer, sizeof (trailer),
- trailer_offset, &format);
- if (retval != sizeof (trailer)) {
- (void) close(fd);
- return (-1);
- }
-
- retval = pwrite_new(fd, &crc, sizeof (crc),
- trailer_offset + 1, &format);
- (void) close(fd);
- if (retval != sizeof (crc)) {
- return (-1);
- }
-
- seg_hash->u.seg_obj->trailer_offset = trailer_offset;
- seg_hash->u.seg_obj->num_of_packets += 1;
-
- *newsegment = segment; /* return new segment handle */
- return (0);
- } else {
- errno = EAGAIN;
- }
-
- return (-1);
-}
-
-static void
-adjust_packets(int fd, hash_obj_t *free_obj, hash_obj_t *object_list)
-{
- int retval;
- uint32_t new_offset;
- hash_obj_t *hash_ptr;
- format_t format;
- hash_obj_t *hash_obj;
-
- hash_obj = lookup_handle_object(free_obj->obj_hdl, PACKET_TYPE);
- if (hash_obj == NULL) {
- return;
- }
- hash_obj = get_container_hash_object(PACKET_TYPE,
- hash_obj->u.pkt_obj->segment_hdl);
- if (hash_obj == NULL) {
- return;
- }
- format = hash_obj->u.cont_obj->format;
-
- new_offset = free_obj->u.pkt_obj->payload_offset
- - free_obj->u.pkt_obj->tag_size;
- for (hash_ptr = object_list; hash_ptr != NULL;
- hash_ptr = hash_ptr->u.pkt_obj->next) {
- retval = pwrite_new(fd, &hash_ptr->u.pkt_obj->tag,
- hash_ptr->u.pkt_obj->tag_size, new_offset, &format);
- if (retval != hash_ptr->u.pkt_obj->tag_size) {
- return;
- }
- new_offset += hash_ptr->u.pkt_obj->tag_size;
- hash_ptr->u.pkt_obj->payload_offset = new_offset;
- retval = pwrite_new(fd, hash_ptr->u.pkt_obj->payload,
- hash_ptr->u.pkt_obj->paylen, new_offset, &format);
- if (retval != hash_ptr->u.pkt_obj->paylen) {
- return;
- }
- new_offset += hash_ptr->u.pkt_obj->paylen;
- }
-}
-
-static void
-free_packet_object(handle_t handle, hash_obj_t *seg_hash)
-{
- hash_obj_t *pkt_hash;
- hash_obj_t *next_hash;
-
- pkt_hash = seg_hash->u.seg_obj->pkt_obj_list;
- if (pkt_hash == NULL) {
- return;
- }
-
- if (pkt_hash->obj_hdl == handle) {
- seg_hash->u.seg_obj->pkt_obj_list = pkt_hash->u.pkt_obj->next;
- } else {
- while (pkt_hash->obj_hdl != handle) {
- next_hash = pkt_hash;
- pkt_hash = pkt_hash->u.pkt_obj->next;
- if (pkt_hash == NULL) {
- return;
- }
- }
- next_hash->u.pkt_obj->next = pkt_hash->u.pkt_obj->next;
- }
-
- if (pkt_hash->prev == NULL) {
- hash_table[(pkt_hash->obj_hdl % TABLE_SIZE)] = pkt_hash->next;
- if (pkt_hash->next != NULL) {
- pkt_hash->next->prev = NULL;
- }
- } else {
- pkt_hash->prev->next = pkt_hash->next;
- if (pkt_hash->next != NULL) {
- pkt_hash->next->prev = pkt_hash->prev;
- }
- }
-
- free(pkt_hash->u.pkt_obj->payload);
- free(pkt_hash->u.pkt_obj);
- free(pkt_hash);
-}
-
-/*
- * Description :
- * sun_fru_delete_packet() deletes a packet from a segment.
- *
- * Arguments : packet_hdl_t : packet number to be deleted.
- * segment_hdl_t : new segment handler.
- *
- * Return :
- * int
- * On success, 0 is returned; on error, -1.
- *
- * NOTES
- * Packets are adjacent; thus, deleting a packet requires moving
- * succeeding packets to compact the resulting hole.
- */
-static int
-sun_fru_delete_packet(packet_hdl_t packet, segment_hdl_t *newsegment,
- door_cred_t *cred)
-{
- int retval;
- int fd;
- char trailer[] = { 0x0c, 0x00, 0x00, 0x00, 0x00};
- uint32_t crc;
- hash_obj_t *tmp_obj;
- hash_obj_t *pkt_hash;
- hash_obj_t *sec_hash;
- hash_obj_t *cont_hash;
- hash_obj_t *prev_obj;
- hash_obj_t *seg_hash;
- fru_segdesc_t *desc;
- format_t format;
-
- /* check the effective uid of the client */
- if (cred->dc_euid != 0) {
- errno = EPERM;
- return (-1); /* not a root */
- }
-
- /* packet hash object */
- pkt_hash = lookup_handle_object(packet, PACKET_TYPE);
- if (pkt_hash == NULL) {
- return (-1);
- }
-
- /* segment hash object */
- seg_hash = lookup_handle_object(pkt_hash->u.pkt_obj->segment_hdl,
- SEGMENT_TYPE);
- if (seg_hash == NULL) {
- return (-1);
- }
-
- /* check for write perm. */
- desc = (fru_segdesc_t *)&seg_hash->u.seg_obj->segment.descriptor;
- if (!(desc->field.field_perm & SEGMENT_WRITE)) {
- errno = EPERM;
- return (-1); /* write not allowed */
- }
-
- /* section hash object */
- sec_hash = lookup_handle_object(seg_hash->u.seg_obj->section_hdl,
- SECTION_TYPE);
- if (sec_hash == NULL) {
- return (-1);
- }
-
- if (sec_hash->u.sec_obj->section.protection == READ_ONLY_SECTION) {
- errno = EPERM;
- return (-1); /* read-only section */
- }
-
- prev_obj = seg_hash->u.seg_obj->pkt_obj_list;
- if (prev_obj == NULL) {
- return (-1);
- }
-
- /* container hash object */
- cont_hash = lookup_handle_object(sec_hash->u.sec_obj->cont_hdl,
- CONTAINER_TYPE);
- if (cont_hash == NULL) {
- return (-1);
- }
-
- format = cont_hash->u.cont_obj->format;
-
- fd = open_file();
- if (fd < 0) {
- return (-1);
- }
-
- if (prev_obj->obj_hdl == packet) { /* first object to be deleted */
- adjust_packets(fd, prev_obj, prev_obj->u.pkt_obj->next);
- seg_hash->u.seg_obj->trailer_offset -=
- (prev_obj->u.pkt_obj->tag_size
- + prev_obj->u.pkt_obj->paylen);
- free_packet_object(packet, seg_hash);
- } else {
- for (tmp_obj = prev_obj;
- tmp_obj != NULL; tmp_obj = tmp_obj->u.pkt_obj->next) {
- /* found the object */
- if (tmp_obj->obj_hdl == packet) {
- adjust_packets(fd, tmp_obj,
- tmp_obj->u.pkt_obj->next);
- seg_hash->u.seg_obj->trailer_offset -=
- (tmp_obj->u.pkt_obj->tag_size
- + tmp_obj->u.pkt_obj->paylen);
- free_packet_object(packet, seg_hash);
- }
- }
- }
-
- seg_hash->u.seg_obj->num_of_packets -= 1;
-
- /* calculate checksum */
- crc = get_checksum_crc(seg_hash, (seg_hash->u.seg_obj->trailer_offset
- - seg_hash->u.seg_obj->segment.offset));
- /* write trailer at new offset */
- retval = pwrite_new(fd, &trailer, sizeof (trailer),
- seg_hash->u.seg_obj->trailer_offset, &format);
- if (retval != sizeof (trailer)) {
- (void) close(fd);
- return (-1);
- }
-
- /* write the checksum value */
- retval = pwrite_new(fd, &crc, sizeof (crc),
- seg_hash->u.seg_obj->trailer_offset + 1, &format);
- (void) close(fd);
- if (retval != sizeof (crc)) {
- return (-1);
- }
-
- *newsegment = seg_hash->obj_hdl; /* return new segment handle */
- return (0);
-}
-
-/*
- * Description :
- * sun_fru_close_container() removes the association between a
- * container and its handle. this routines free's up all the
- * hash object contained under container.
- *
- * Arguments :
- * container_hdl_t holds the file descriptor of the fru.
- *
- * Return :
- * int
- * return 0.
- *
- */
-/* ARGSUSED */
-static int
-sun_fru_close_container(container_hdl_t container)
-{
- hash_obj_t *hash_obj;
- hash_obj_t *prev_hash;
- hash_obj_t *sec_hash_obj;
- handle_t obj_hdl;
-
- /* lookup for container hash object */
- hash_obj = lookup_handle_object(container, CONTAINER_TYPE);
- if (hash_obj == NULL) {
- return (0);
- }
-
- /* points to section object list */
- sec_hash_obj = hash_obj->u.cont_obj->sec_obj_list;
-
- /* traverse section object list */
- while (sec_hash_obj != NULL) {
-
- /* traverse segment hash object in the section */
- while (sec_hash_obj->u.sec_obj->seg_obj_list != NULL) {
- /* object handle of the segment hash object */
- obj_hdl =
- sec_hash_obj->u.sec_obj->seg_obj_list->obj_hdl;
- free_segment_hash(obj_hdl, sec_hash_obj);
- }
-
- /* going to free section hash object, relink the hash object */
- if (sec_hash_obj->prev == NULL) {
- hash_table[(sec_hash_obj->obj_hdl % TABLE_SIZE)]
- = sec_hash_obj->next;
- if (sec_hash_obj->next != NULL) {
- sec_hash_obj->next->prev = NULL;
- }
- } else {
- sec_hash_obj->prev->next = sec_hash_obj->next;
- if (sec_hash_obj->next != NULL) {
- sec_hash_obj->next->prev = sec_hash_obj->prev;
- }
- }
-
- free(sec_hash_obj->u.sec_obj); /* free section hash object */
-
- prev_hash = sec_hash_obj;
-
- sec_hash_obj = sec_hash_obj->u.sec_obj->next;
-
- free(prev_hash); /* free section hash */
- }
-
- /* free container hash object */
- if (hash_obj->prev == NULL) {
- hash_table[(sec_hash_obj->obj_hdl % TABLE_SIZE)] =
- hash_obj->next;
- if (hash_obj->next != NULL) {
- hash_obj->next->prev = NULL;
- }
- } else {
- hash_obj->prev->next = hash_obj->next;
- if (hash_obj->next != NULL) {
- hash_obj->next->prev = hash_obj->prev;
- }
- }
-
- free(hash_obj->u.cont_obj);
- free(hash_obj);
- return (0);
-}
-
-/*
- * FRU ACCESS API
- */
-
-/*
- * Description :
- * fru_is_data_available checks if the fruid information
- * is available or not on a give fru
- *
- * Arguments :
- * picl_nodehdl_t hold picl node handle of the fru.
- *
- * Return :
- * int
- * return 0 - if fruid is not present.
- * return 1 - if fruid is present.
- */
-int
-fru_is_data_available(picl_nodehdl_t fruh)
-{
- int retval, ret;
- uint8_t slot_no;
- picl_nodehdl_t parenth;
- format_t fru_format;
- hash_obj_t *cont_hash_obj;
-
- if (is_valid_chassis == -1) {
- if (fruaccess_platmod_check_chassis() == 0) {
- is_valid_chassis = 1;
- } else {
- is_valid_chassis = 0;
- }
- }
-
- if (!is_valid_chassis) {
- return (0);
- }
-
- retval = ptree_get_propval_by_name(fruh, PICL_PROP_PARENT,
- &parenth, sizeof (picl_nodehdl_t));
- if (retval != PICL_SUCCESS) {
- return (0);
- }
-
- if (fruaccess_platmod_check_fru(parenth) != 0) {
- return (0);
- }
-
- retval = ptree_get_propval_by_name(parenth, PICL_PROP_GEO_ADDR,
- &slot_no, sizeof (uint8_t));
- if (retval != PICL_SUCCESS) {
- return (0);
- }
-
- if (fruaccess_platmod_init_format(slot_no, &fru_format) !=
- PICL_SUCCESS) {
- return (0);
- }
-
- ret = is_fru_data_available(precedence, slot_no, &fru_format);
- if (ret && (fru_format.format != NO_FRUDATA)) {
- goto create;
- } else {
- return (0);
- }
-create:
-
- cont_hash_obj = create_container_hash_object();
- if (cont_hash_obj == NULL) {
- return (0);
- }
-
- cont_hash_obj->obj_hdl = fruh;
- cont_hash_obj->u.cont_obj->format = fru_format;
-
- /* if both formats are present follow the precedence */
- if (fru_format.format == 0x3) {
- if (precedence == IPMI_FORMAT) {
- cont_hash_obj->u.cont_obj->format.format = IPMI_FORMAT;
- } else {
- cont_hash_obj->u.cont_obj->format.format = SUN_FORMAT;
- }
- }
- add_hashobject_to_hashtable(cont_hash_obj, CONTAINER_TYPE);
- return (1);
-}
-
-/*
- * FRU ACCESS API
- */
-
-/*
- * All the routines check the fruid format and redirects the call to
- * to appropriate routines depending on fruid format.
- * All SUN format routines start with sun_ prefix.
- * All IPMI format routines start with ipmi_ prefix.
- */
-container_hdl_t
-fru_open_container(picl_nodehdl_t fru)
-{
- hash_obj_t *hash_obj;
- format_t fru_format;
-
- hash_obj = lookup_handle_object((handle_t)fru, CONTAINER_TYPE);
- if (hash_obj == NULL) {
- return (-1);
- }
- fru_format = hash_obj->u.cont_obj->format;
- return (fruaccess_func[fru_format.format - 1].open_container(fru));
-}
-
-int
-fru_close_container(container_hdl_t container)
-{
- int ret;
- format_t fru_format;
- hash_obj_t *hash_obj;
-
- hash_obj = lookup_handle_object(container, CONTAINER_TYPE);
- if (hash_obj == NULL) {
- return (-1);
- }
-
- fru_format = hash_obj->u.cont_obj->format;
- ret = fruaccess_func[fru_format.format - 1].close_container(container);
- return (ret);
-}
-
-int
-fru_get_num_sections(container_hdl_t container, door_cred_t *cred)
-{
- int ret;
- format_t fru_format;
- hash_obj_t *hash_obj;
-
- hash_obj = lookup_handle_object(container, CONTAINER_TYPE);
- if (hash_obj == NULL) {
- return (-1);
- }
- fru_format = hash_obj->u.cont_obj->format;
- ret = fruaccess_func[fru_format.format - 1].get_num_sections(container,
- cred);
- return (ret);
-}
-
-int
-fru_get_sections(container_hdl_t container, section_t *section,
- int max_sections, door_cred_t *cred)
-{
- int ret;
- format_t fru_format;
- hash_obj_t *hash_obj;
-
- hash_obj = lookup_handle_object(container, CONTAINER_TYPE);
- if (hash_obj == NULL) {
- return (-1);
- }
- fru_format = hash_obj->u.cont_obj->format;
-
- ret = fruaccess_func[fru_format.format - 1].get_sections(container,
- section, max_sections, cred);
- return (ret);
-}
-
-int
-fru_get_num_segments(section_hdl_t section, door_cred_t *rarg)
-{
- int ret;
- format_t fru_format;
- hash_obj_t *hash_obj;
-
- hash_obj = get_container_hash_object(SEGMENT_TYPE, section);
- if (hash_obj == NULL) {
- return (-1);
- }
- fru_format = hash_obj->u.cont_obj->format;
-
- ret = fruaccess_func[fru_format.format - 1].get_num_segments(section,
- rarg);
- return (ret);
-}
-
-int
-fru_get_segments(section_hdl_t section, segment_t *segment,
- int max_segments, door_cred_t *rarg)
-{
- int ret;
- format_t fru_format;
- hash_obj_t *hash_obj;
-
- hash_obj = get_container_hash_object(SEGMENT_TYPE, section);
- if (hash_obj == NULL) {
- return (-1);
- }
- fru_format = hash_obj->u.cont_obj->format;
- ret = fruaccess_func[fru_format.format - 1].get_segments(section,
- segment, max_segments, rarg);
- return (ret);
-}
-
-int
-fru_add_segment(section_hdl_t section, segment_t *segment,
- section_hdl_t *newsection, door_cred_t *cred)
-{
- int ret;
- format_t fru_format;
- hash_obj_t *hash_obj;
-
- hash_obj = get_container_hash_object(SEGMENT_TYPE, section);
- if (hash_obj == NULL) {
- return (-1);
- }
- fru_format = hash_obj->u.cont_obj->format;
-
- ret = fruaccess_func[fru_format.format - 1].add_segment(section,
- segment, newsection, cred);
- return (ret);
-}
-
-int
-fru_delete_segment(segment_hdl_t segment, section_hdl_t *newsection,
- door_cred_t *cred)
-{
- int ret;
- format_t fru_format;
- hash_obj_t *hash_obj;
-
- hash_obj = get_container_hash_object(PACKET_TYPE, segment);
- if (hash_obj == NULL) {
- return (-1);
- }
- fru_format = hash_obj->u.cont_obj->format;
- ret = fruaccess_func[fru_format.format - 1].delete_segment(segment,
- newsection, cred);
- return (ret);
-}
-
-ssize_t
-fru_read_segment(segment_hdl_t segment, void *buffer, size_t nbytes,
- door_cred_t *cred)
-{
- ssize_t ret;
- format_t fru_format;
- hash_obj_t *hash_obj;
-
- hash_obj = get_container_hash_object(PACKET_TYPE, segment);
- if (hash_obj == NULL) {
- return (-1);
- }
- fru_format = hash_obj->u.cont_obj->format;
- ret = fruaccess_func[fru_format.format - 1].read_segment(segment,
- buffer, nbytes, cred);
- return (ret);
-}
-
-int
-fru_write_segment(segment_hdl_t segment, const void *data, size_t nbytes,
- segment_hdl_t *newsegment, door_cred_t *cred)
-{
- int ret;
- format_t fru_format;
- hash_obj_t *hash_obj;
-
- hash_obj = get_container_hash_object(PACKET_TYPE, segment);
- if (hash_obj == NULL) {
- return (-1);
- }
- fru_format = hash_obj->u.cont_obj->format;
-
- ret = fruaccess_func[fru_format.format - 1].write_segment(segment,
- data, nbytes, newsegment, cred);
- return (ret);
-}
-
-int
-fru_get_num_packets(segment_hdl_t segment, door_cred_t *cred)
-{
- int ret;
- format_t fru_format;
- hash_obj_t *hash_obj;
-
- hash_obj = get_container_hash_object(PACKET_TYPE, segment);
- if (hash_obj == NULL) {
- return (-1);
- }
- fru_format = hash_obj->u.cont_obj->format;
-
- ret = fruaccess_func[fru_format.format - 1].get_num_packets(segment,
- cred);
- return (ret);
-}
-
-int
-fru_get_packets(segment_hdl_t segment, packet_t *packet,
- int max_packets, door_cred_t *cred)
-{
- int ret;
- format_t fru_format;
- hash_obj_t *hash_obj;
-
- hash_obj = get_container_hash_object(PACKET_TYPE, segment);
- if (hash_obj == NULL) {
- return (-1);
- }
- fru_format = hash_obj->u.cont_obj->format;
-
- ret = fruaccess_func[fru_format.format - 1].get_packets(segment,
- packet, max_packets, cred);
- return (ret);
-}
-
-ssize_t
-fru_get_payload(packet_hdl_t packet, void *buffer,
- size_t nbytes, door_cred_t *cred)
-{
- ssize_t ret;
- format_t fru_format;
- hash_obj_t *hash_obj;
-
- hash_obj = lookup_handle_object(packet, PACKET_TYPE);
- if (hash_obj == NULL) {
- return (-1);
- }
-
- hash_obj = get_container_hash_object(PACKET_TYPE,
- hash_obj->u.pkt_obj->segment_hdl);
- if (hash_obj == NULL) {
- return (-1);
- }
- fru_format = hash_obj->u.cont_obj->format;
-
- ret = fruaccess_func[fru_format.format - 1].get_payload(packet, buffer,
- nbytes, cred);
- return (ret);
-}
-
-int
-fru_update_payload(packet_hdl_t packet, const void *data, size_t nbytes,
- packet_hdl_t *newpacket, door_cred_t *cred)
-{
- int ret;
- format_t fru_format;
- hash_obj_t *hash_obj;
-
- hash_obj = lookup_handle_object(packet, PACKET_TYPE);
- if (hash_obj == NULL) {
- return (-1);
- }
-
- hash_obj = get_container_hash_object(PACKET_TYPE,
- hash_obj->u.pkt_obj->segment_hdl);
- if (hash_obj == NULL) {
- return (-1);
- }
- fru_format = hash_obj->u.cont_obj->format;
- ret = fruaccess_func[fru_format.format - 1].update_payload(packet, data,
- nbytes, newpacket, cred);
- return (ret);
-}
-
-int
-fru_append_packet(segment_hdl_t segment, packet_t *packet,
- const void *payload, size_t nbytes, segment_hdl_t *newsegment,
- door_cred_t *cred)
-{
- int ret;
- format_t fru_format;
- hash_obj_t *hash_obj;
-
- hash_obj = get_container_hash_object(PACKET_TYPE, segment);
- if (hash_obj == NULL) {
- return (-1);
- }
- fru_format = hash_obj->u.cont_obj->format;
-
- ret = fruaccess_func[fru_format.format - 1].append_packet(segment,
- packet, payload, nbytes, newsegment, cred);
- return (ret);
-}
-
-int
-fru_delete_packet(packet_hdl_t packet, segment_hdl_t *newsegment,
- door_cred_t *cred)
-{
- int ret;
- format_t fru_format;
- hash_obj_t *hash_obj;
-
- hash_obj = lookup_handle_object(packet, PACKET_TYPE);
- if (hash_obj == NULL) {
- return (-1);
- }
-
- hash_obj = get_container_hash_object(PACKET_TYPE,
- hash_obj->u.pkt_obj->segment_hdl);
- if (hash_obj == NULL) {
- return (-1);
- }
- fru_format = hash_obj->u.cont_obj->format;
-
- ret = fruaccess_func[fru_format.format - 1].delete_packet(packet,
- newsegment, cred);
- return (ret);
-}
diff --git a/usr/src/cmd/picl/plugins/sun4u/snowbird/lib/fruaccess/piclfruaccess_platmod.c b/usr/src/cmd/picl/plugins/sun4u/snowbird/lib/fruaccess/piclfruaccess_platmod.c
deleted file mode 100644
index 2943132451..0000000000
--- a/usr/src/cmd/picl/plugins/sun4u/snowbird/lib/fruaccess/piclfruaccess_platmod.c
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (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 2004 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <picl.h>
-#include <picldefs.h>
-#include "fru_access_impl.h"
-
-#define SNOWBIRD "SUNW,Netra-CP2300"
-
-/*
- * check if the code is running on correct chassis or not.
- * return :
- * 0 - if we are on Snowbird
- * -1 - if we are on wrong system
- * if there is any error
- */
-int
-fruaccess_platmod_check_chassis()
-{
- picl_nodehdl_t chassish;
- char chassis_type[PICL_PROPNAMELEN_MAX];
-
- if (ptree_get_node_by_path(PICL_FRUTREE_CHASSIS,
- &chassish) != PICL_SUCCESS) {
- return (-1);
- }
-
- if (ptree_get_propval_by_name(chassish, PICL_PROP_CHASSIS_TYPE,
- chassis_type, sizeof (chassis_type)) != PICL_SUCCESS) {
- return (-1);
- }
-
- if (strcmp(chassis_type, SNOWBIRD) == 0) {
- return (0);
- } else {
- return (-1);
- }
-}
-
-/*
- * intialize the format structure, fill in src and dest addresses
- */
-picl_errno_t
-fruaccess_platmod_init_format(uint8_t slot_no, format_t *fru_format)
-{
- /* initialize src and dest addresses */
- fru_format->src = IPMB_ADDR(slot_no);
- fru_format->dest = fru_format->src;
- return (PICL_SUCCESS);
-}
-
-/*
- * do all valid checks for fru
- * return : 0 if we can probe for fru
- * -1 if probing is not required
- */
-int
-fruaccess_platmod_check_fru(picl_nodehdl_t parenth)
-{
- int retval;
- char type[PICL_PROPSIZE_MAX];
- picl_nodehdl_t chassish, loc_parenth;
-
- retval = ptree_get_propval_by_name(parenth, PICL_PROP_SLOT_TYPE,
- (void *)type, PICL_PROPSIZE_MAX);
- if (retval != PICL_SUCCESS) {
- return (-1);
- }
-
- /* check only for pci and cpci slots */
- if ((strcmp(type, PICL_SLOT_CPCI) != 0) &&
- (strcmp(type, PICL_SLOT_PCI) != 0)) {
- return (-1);
- }
-
- /* check if location is direct parent of chassis or not */
- if (ptree_get_node_by_path(PICL_FRUTREE_CHASSIS,
- &chassish) != PICL_SUCCESS) {
- return (-1);
- }
-
- retval = ptree_get_propval_by_name(parenth, PICL_PROP_PARENT,
- (void *)&loc_parenth, sizeof (loc_parenth));
- if (retval != PICL_SUCCESS) {
- return (-1);
- }
-
- if (chassish != loc_parenth) {
- return (-1);
- }
- return (0);
-}
diff --git a/usr/src/cmd/picl/plugins/sun4u/snowbird/lib/fruaccess/piclsdr.c b/usr/src/cmd/picl/plugins/sun4u/snowbird/lib/fruaccess/piclsdr.c
deleted file mode 100644
index 41efb7ee61..0000000000
--- a/usr/src/cmd/picl/plugins/sun4u/snowbird/lib/fruaccess/piclsdr.c
+++ /dev/null
@@ -1,343 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (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 2004 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Read the SDR information on a board and get the device id to
- * read the FRUID information
- */
-
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <errno.h>
-#include <time.h>
-#include <poll.h>
-#include <stropts.h>
-#include <stdarg.h>
-#include <syslog.h>
-#include <smclib.h>
-#include "fru_access_impl.h"
-
-#define POLL_TIMEOUT 10000 /* 20 sec */
-#define SEQUENCE 10
-
-#define IPMI_GET_SDR_INFO 0x20
-#define IPMI_SENSOR_NETFN 0x4
-#define SDR_INFO_RESPONSE_SZ_MIN 10
-
-#define NUM_OF_LUN 4
-#define SUN_FRU "SUN FRU SDR"
-#define FRU_DEVICE_SDR_TYPE 0x11
-#define IPMI_SDR_VERSION 0x51
-#define IPMI_DATA_OFFSET 7
-#define IPMI_GET_SDR_INFO_CMD 0x20
-#define SDR_BUFFER_LEN_MAX 100
-
-typedef struct {
- uint8_t src;
- uint8_t dest;
- uint8_t lun;
- uint8_t record_id_lsb;
- uint8_t record_id_msb;
- int offset;
- int length;
- char *buffer;
-} sdr_info_t;
-
-static int get_sdr_info(int, int, uint8_t lun);
-static int get_sdr(sdr_info_t *);
-static int get_sun_sdr(int, uint8_t, uint8_t, uint8_t);
-
-/*
- * bug in smc f/w
- *
- * static int lun_mask[4] = { 0x01, 0x02, 0x04, 0x08 };
- */
-
-/*
- * routine to read the onboard/remote device SDR information
- */
-void
-get_fru_data_info(int src, int dest, format_t *fru_format)
-{
- int ret;
-
- src = IPMB_ADDR(src);
- dest = IPMB_ADDR(dest);
-
- if (src != dest) { /* ipmi */
- int i = 0;
- for (i = 0; i < NUM_OF_LUN; i++) { /* for each lun */
- ret = get_sdr_info(src, dest, i);
- if (ret > 0) {
- ret = get_sun_sdr(ret, src, dest, i);
- if (ret > 0) {
- fru_format->format |= SUN_FORMAT;
- fru_format->sun_device_id = ret;
- fru_format->sun_lun = i;
- break;
- }
- }
- }
- } else { /* on board */
- ret = get_sdr_info(src, dest, 0);
- if (ret > 0) {
- ret = get_sun_sdr(ret, src, dest, 0);
- if (ret > 0) {
- fru_format->format |= SUN_FORMAT;
- fru_format->sun_device_id = ret;
- fru_format->sun_lun = 0;
- }
- }
- }
-}
-
-/*
- * read the onboard sdr information
- */
-static int
-get_onboard_sdr(sdr_info_t *sdr)
-{
- sc_reqmsg_t req_pkt;
- sc_rspmsg_t res_pkt;
-
- SC_MSG_CMD(&req_pkt) = SMC_DEVICE_SDR_GET;
- SC_MSG_LEN(&req_pkt) = 6;
- SC_MSG_ID(&req_pkt) = SEQUENCE;
-
- /* data for request packet */
- req_pkt.data[0] = 0x0;
- req_pkt.data[1] = 0x0;
- req_pkt.data[2] = sdr->record_id_lsb;
- req_pkt.data[3] = sdr->record_id_msb;
- req_pkt.data[4] = sdr->offset;
- req_pkt.data[5] = sdr->length;
-
- if (smc_send_msg(DEFAULT_FD, &req_pkt, &res_pkt,
- POLL_TIMEOUT) != SMC_SUCCESS) {
- return (-1);
- }
-
- bzero(sdr->buffer, SDR_BUFFER_LEN_MAX);
- (void) memcpy(sdr->buffer, res_pkt.data, res_pkt.hdr.len);
- return (0);
-}
-
-/*
- * get the sdr information
- */
-static int
-get_sdr_info(int src, int dest, uint8_t lun)
-{
- sc_reqmsg_t req_pkt;
- sc_rspmsg_t res_pkt;
-
- if (lun >= NUM_OF_LUN) {
- return (-1);
- }
-
- if (src == dest) { /* onboard */
- SC_MSG_CMD(&req_pkt) = SMC_DEVICE_SDR_INFO_GET;
- SC_MSG_LEN(&req_pkt) = 0;
- SC_MSG_ID(&req_pkt) = SEQUENCE;
- if (smc_send_msg(DEFAULT_FD, &req_pkt, &res_pkt,
- POLL_TIMEOUT) != SMC_SUCCESS) {
- return (-1);
- }
- return (res_pkt.data[0]);
- }
-
- /* ipmb access */
- (void) smc_init_ipmi_msg(&req_pkt, IPMI_GET_SDR_INFO_CMD,
- FRUACCESS_MSG_ID, 0, NULL, DEFAULT_SEQN, dest,
- SMC_NETFN_SENSOR_REQ, lun);
-
- if (smc_send_msg(DEFAULT_FD, &req_pkt, &res_pkt,
- POLL_TIMEOUT) != SMC_SUCCESS) {
- return (-1);
- }
-
- /* completion code */
- if (res_pkt.data[IPMI_DATA_OFFSET] != 0) {
- return (-1);
- }
-
- /*
- * Known bug in SMC f/w. take this out for next release
- * if ((res_pkt.data[IPMI_DATA_OFFSET + 2] & lun_mask[lun]) != 1) {
- * return (0);
- * }
- */
- return (res_pkt.data[IPMI_DATA_OFFSET + 1]);
-}
-
-static int
-get_sun_sdr(int num_records, uint8_t src, uint8_t dest, uint8_t lun)
-{
- int i, ret;
- sdr_info_t sdr;
- char data[SDR_BUFFER_LEN_MAX];
- uint8_t next_record_lsb;
- uint8_t next_record_msb;
-
- sdr.src = src;
- sdr.dest = dest;
- sdr.lun = lun;
- sdr.buffer = data;
-
- /* get the first record info */
- next_record_lsb = 0x0;
- next_record_msb = 0x0;
- sdr.length = 4;
- sdr.offset = 0x0;
-
- if (src == dest) { /* onboard */
- for (i = 0; i < num_records; i++) {
- sdr.record_id_lsb = next_record_lsb;
- sdr.record_id_msb = next_record_msb;
-
- if ((ret = get_onboard_sdr(&sdr)) < 0) {
- return (ret);
- }
-
- next_record_lsb = data[0];
- next_record_msb = data[1];
- if (data[4] != IPMI_SDR_VERSION) {
- return (-1);
- }
-
- if (data[5] == FRU_DEVICE_SDR_TYPE) {
- sdr.offset = 0x10;
- sdr.length = strlen(SUN_FRU);
- if ((ret = get_onboard_sdr(&sdr)) < 0) {
- return (ret);
- }
-
- /* first two bytes of response is reserv. id */
- if (strncmp(SUN_FRU, &data[2],
- strlen(SUN_FRU)) == 0) {
- /* found sun sdr */
- sdr.offset = 0x0;
- sdr.length = 7;
- if ((ret = get_onboard_sdr(&sdr)) < 0) {
- return (ret);
- }
- return (data[8]);
- }
- }
- }
- return (-1);
- }
-
- /* ipmb access */
- /* traverse thru all the records until we find sun sdr */
- for (i = 0; i < num_records; i++) {
-
- sdr.record_id_lsb = next_record_lsb;
- sdr.record_id_msb = next_record_msb;
-
- if ((ret = get_sdr(&sdr)) < 0) {
- return (ret);
- }
-
- /* completion code */
- if (data[IPMI_DATA_OFFSET] != 0) {
- return (-1);
- }
- next_record_lsb = data[IPMI_DATA_OFFSET + 1];
- next_record_msb = data[IPMI_DATA_OFFSET + 2];
-
- if (data[IPMI_DATA_OFFSET + 5] != IPMI_SDR_VERSION) {
- return (-1);
- }
-
- if (data[IPMI_DATA_OFFSET + 6] == FRU_DEVICE_SDR_TYPE) {
-
- sdr.offset = 0x10;
- sdr.length = strlen(SUN_FRU);
- if ((ret = get_sdr(&sdr)) < 0) {
- return (ret);
- }
-
- /* completion code */
- if (data[IPMI_DATA_OFFSET] != 0) {
- return (-1);
- }
-
- if (strncmp(&data[IPMI_DATA_OFFSET+ 3],
- SUN_FRU, strlen(SUN_FRU)) == 0) {
- /* found sun sdr */
- sdr.offset = 0x0;
- sdr.length = 7;
- if ((ret = get_sdr(&sdr)) < 0) {
- return (ret);
- }
-
- /* completion code */
- if (data[IPMI_DATA_OFFSET] != 0) {
- return (-1);
- }
- return (data[IPMI_DATA_OFFSET + 9]);
- }
- }
- }
- return (-1);
-}
-
-static int
-get_sdr(sdr_info_t *sdr)
-{
- sc_reqmsg_t req_pkt;
- sc_rspmsg_t res_pkt;
- uint8_t datap[6];
-
- if (sdr->lun > 3) {
- return (-1);
- }
-
- /* data for request packet */
- datap[0] = 0x0; /* reserved */
- datap[1] = 0x0; /* reserved */
- datap[2] = sdr->record_id_lsb;
- datap[3] = sdr->record_id_msb;
- datap[4] = sdr->offset;
- datap[5] = sdr->length;
-
- (void) smc_init_ipmi_msg(&req_pkt, SMC_GET_DEVICE_SDR,
- FRUACCESS_MSG_ID, 6, datap, DEFAULT_SEQN,
- sdr->dest, SMC_NETFN_SENSOR_REQ, sdr->lun);
-
- if (smc_send_msg(DEFAULT_FD, &req_pkt, &res_pkt,
- POLL_TIMEOUT) != SMC_SUCCESS) {
- return (-1);
- }
- bzero(sdr->buffer, SDR_BUFFER_LEN_MAX);
- (void) memcpy(sdr->buffer, res_pkt.data, res_pkt.hdr.len);
- return (0);
-}
diff --git a/usr/src/cmd/picl/plugins/sun4u/snowbird/lib/fruaccess/piclsmc.c b/usr/src/cmd/picl/plugins/sun4u/snowbird/lib/fruaccess/piclsmc.c
deleted file mode 100644
index d30e610691..0000000000
--- a/usr/src/cmd/picl/plugins/sun4u/snowbird/lib/fruaccess/piclsmc.c
+++ /dev/null
@@ -1,997 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (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 2004 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * These routines in this file are used to interact with SMC driver to
- * read and write FRUID data
- */
-
-#include <stdio.h>
-#include <unistd.h>
-#include <string.h>
-#include <strings.h>
-#include <stdarg.h>
-#include <synch.h>
-#include <thread.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <syslog.h>
-#include <stropts.h>
-#include <poll.h>
-#include <smclib.h>
-#include "fru_access_impl.h"
-
-#define POLL_TIMEOUT 10000
-#define FRUID_CHECK_POLL_TIMEOUT 5000
-#define SIZE_TO_READ_WRITE 20
-
-/* IPMI fru spec Storage definition version 1.0, rev 1.1 */
-#define IPMI_COMMON_HEADER_SIZE 8
-#define IPMI_VERSION 1
-#define CMN_HDR_VERSION_MASK 0x0
-#define CMN_HDR_OFFSET 0x0
-#define BD_MFR_OFFSET 6
-#define BD_FIELDS_SIZE 6
-#define AREA_TERMINATION_INDICATOR 0xc1
-
-/* type encoding */
-#define BINARY_TYPE 0x0
-#define BCDPLUS_TYPE 0x1
-#define SIX_BITASCII_TYPE 0x2
-#define UNICODE_TYPE 0x3
-
-/* for ascii conversion */
-#define ASCII_MAP 0x20
-#define BIT_MASK1 0x3f
-#define BIT_MASK2 0x0f
-#define BIT_MASK3 0x03
-
-#define SUN_NAME "SUN MICROSYSTEMS, INC."
-#define SUN_JEDEC_CODE 0x3e
-#define MANR_MAX_LENGTH 80
-#define FRU_DATA_MAX_SIZE 100
-
-/* IPMI commands */
-#define IPMI_GET_DEVICE_ID 0x1
-#define FRU_DEVICE_ID 0x0
-#define READ_FRU_INVENTORY_INFO 0x10
-#define READ_FRU_INVENTORY_DATA 0x11
-#define WRITE_FRU_INVENTORY_DATA 0x12
-
-#define TMP_BUFFER_SIZE 10
-#define BYTE_TO_READ_SUN_CHK 5
-
-typedef struct {
- uint8_t internal; /* internal use area */
- uint8_t chassis; /* chassis info area */
- uint8_t board; /* board area */
- uint8_t product; /* product info area */
- uint8_t records; /* multirecord area */
-} fruid_offset_t;
-
-extern void get_fru_data_info(int, int, format_t *);
-static void convert_to_ascii(uint8_t [], uint8_t [], int, int);
-static void bcdplus_to_ascii(uint8_t [], uint8_t [], int);
-static time_t get_utc_time(uint8_t []);
-static uint8_t cpu_no = 0;
-
-/*
- * Routine to read FRUID information from BMC
- */
-static int
-get_alarm_fru_data(int offset, int size, void *buffer, format_t *format)
-{
- uint8_t datap[5];
- sc_reqmsg_t req_pkt;
- sc_rspmsg_t res_pkt;
-
- if (buffer == NULL) {
- return (-1);
- }
- bzero(buffer, size);
-
- datap[0] = 0x7; /* bus id */
- datap[1] = 0xa0; /* slave address */
- datap[2] = size; /* count */
- datap[3] = offset >> 8; /* MSB */
- datap[4] = (uint8_t)offset; /* LSB */
-
- (void) smc_init_ipmi_msg(&req_pkt, SMC_MASTER_WR_RD_I2C,
- FRUACCESS_MSG_ID, 5, datap, DEFAULT_SEQN, format->dest,
- SMC_NETFN_APP_REQ, SMC_BMC_LUN);
-
- if (smc_send_msg(DEFAULT_FD, &req_pkt, &res_pkt,
- POLL_TIMEOUT) != SMC_SUCCESS) {
- return (-1);
- }
- /* check the completion code */
- if (res_pkt.data[7] != 0) {
- return (-1);
- }
-
- (void) memcpy(buffer, &(res_pkt.data[8]), size);
- return (0);
-}
-
-/*
- * Routine to read FRUID information from other boards
- */
-static int
-get_fru_data(int offset, int size, void *buffer, format_t *format)
-{
- sc_reqmsg_t req_pkt;
- sc_rspmsg_t res_pkt;
- uint8_t datap[4];
- int ipmi = 0;
-
- if (buffer == NULL) {
- return (-1);
- }
-
- /* figure out if onboard access or ipmb access */
- if (format->src == format->dest) {
- ipmi = 0;
- } else {
- ipmi = 1;
- }
-
- switch (ipmi) {
-
- case 0: /* on board info (local i2c) */
-
- SC_MSG_CMD(&req_pkt) = SMC_EEPROM_READ;
- SC_MSG_LEN(&req_pkt) = 4;
- SC_MSG_ID(&req_pkt) = FRUACCESS_MSG_ID;
-
- /* data field for request */
- req_pkt.data[0] = format->sun_device_id; /* device id */
- req_pkt.data[1] = (uint8_t)offset; /* (LSB) */
- req_pkt.data[3] = size;
-
- if (format->format == SUN_FORMAT) {
- req_pkt.data[2] = offset >> 8;
- } else {
- req_pkt.data[2] = 0x0; /* (MSB) always 0x0 for IPMI */
- }
-
- /* make a call to smc library to send cmd */
- if (smc_send_msg(DEFAULT_FD, &req_pkt, &res_pkt,
- POLL_TIMEOUT) != SMC_SUCCESS) {
- return (-1);
- }
-
- if (SC_MSG_LEN(&res_pkt) != size) {
- return (-1);
- }
- (void) memcpy(buffer, res_pkt.data, size);
- return (0);
-
- default:
-
- /* data for request packet */
- datap[0] = format->sun_device_id; /* device id */
- datap[1] = (uint8_t)offset; /* LSB */
- datap[3] = size; /* bytes to read */
- if (format->format == SUN_FORMAT) {
- datap[2] = offset >> 8;
- } else {
- datap[2] = 0x0; /* (MSB) always 0x0 for IPMI */
- }
-
- (void) smc_init_ipmi_msg(&req_pkt, READ_FRU_INVENTORY_DATA,
- FRUACCESS_MSG_ID, 4, datap, DEFAULT_SEQN,
- format->dest, SMC_NETFN_STORAGE_REQ, format->sun_lun);
-
- if (smc_send_msg(DEFAULT_FD, &req_pkt, &res_pkt,
- POLL_TIMEOUT) != SMC_SUCCESS) {
- return (-1);
- }
- /* check the completion code */
- if (res_pkt.data[7] != 0) {
- return (-1);
- }
-
- /* check the size */
- if (res_pkt.data[8] != size) {
- return (-1);
- }
-
- (void) memcpy(buffer, &(res_pkt.data[9]), size);
- return (0);
- }
-}
-
-/*
- * routine to read the IPMI common header field
- */
-static int
-read_common_header(fruid_offset_t *offset, format_t *format)
-{
- int ret = 0;
- uint8_t data[FRU_DATA_MAX_SIZE];
-
- ret = get_fru_data(CMN_HDR_OFFSET, IPMI_COMMON_HEADER_SIZE, data,
- format);
- if (ret < 0) {
- return (-1);
- }
-
- /* version check */
- if ((data[0] | CMN_HDR_VERSION_MASK) != 1) {
- return (-1);
- }
-
- offset->internal = data[1] * 8;
- offset->chassis = data[2] * 8;
- offset->board = data[3] * 8;
- offset->product = data[4] * 8;
- offset->records = data[5] * 8;
-
- return (0);
-}
-
-/*
- * Read the values of each field based on FORMAT
- */
-/* ARGSUSED */
-static int
-read_bd_fields(uint8_t *field, int offset, format_t *format)
-{
-
- int ret, encode_type = 0x0, len, length, extra_bytes, alloc_size;
- uint8_t *store;
- uint8_t data[FRU_DATA_MAX_SIZE];
-
- bzero(field, MANR_MAX_LENGTH);
-
- ret = get_fru_data(offset, BD_FIELDS_SIZE, data, format);
- if (ret < 0) {
- return (-1);
- }
-
- if (data[0] == AREA_TERMINATION_INDICATOR) {
- return (0);
- }
-
- encode_type = data[0] >> 6;
- len = data[0] & 0x3f;
- if (len <= 0) {
- return (0);
- }
-
- ret = get_fru_data(offset+1, len, data, format);
- if (ret < 0) {
- return (-1);
- }
-
- switch (encode_type) {
-
- case SIX_BITASCII_TYPE:
-
- length = len - (len % 3);
- extra_bytes = len % 3;
- alloc_size = ((length/3) * 4) + extra_bytes;
- store = (uint8_t *)malloc(sizeof (uint8_t) * alloc_size);
- if (store == NULL) {
- return (-1);
- }
- convert_to_ascii(data, store, len, extra_bytes);
- break;
-
- case BCDPLUS_TYPE:
-
- alloc_size = len * 2;
- store = (uint8_t *)malloc(sizeof (uint8_t) * alloc_size);
- if (store == NULL) {
- return (-1);
- }
-
- bcdplus_to_ascii(data, store, len);
- break;
-
- case BINARY_TYPE:
- case UNICODE_TYPE:
- default:
- return (-1);
- }
-
- (void) memcpy(field, store, alloc_size);
- free(store);
- return (len);
-}
-
-static int
-read_board_info(uint8_t board_offset, payload_t *manr, format_t *format)
-{
- time_t time;
- uint8_t *buffer;
- uint8_t mfg_time[4];
- uint8_t data[FRU_DATA_MAX_SIZE];
- int ret = 0, current_offset = 0x0;
- int bd_area_len = 0;
-
- /* read version, length, lang code, mfg. time */
- ret = get_fru_data(board_offset, BD_FIELDS_SIZE, data, format);
-
- if (ret < 0) {
- return (-1);
- }
-
- /* version check */
- if ((data[0] | CMN_HDR_VERSION_MASK) != 1) {
- return (-1);
- }
-
- /* byte 2 is lang code */
- bd_area_len = data[1] * 8;
- mfg_time[3] = data[3];
- mfg_time[2] = data[4];
- mfg_time[1] = data[5];
- mfg_time[0] = 0x0;
- time = get_utc_time(mfg_time);
-
- /* fill the timestamp into manr */
- (void) memcpy(manr->timestamp, &time, MANR_TIME_LEN);
-
- if (bd_area_len < BD_MFR_OFFSET) {
- return (-1);
- }
- buffer = (uint8_t *)malloc(sizeof (uint8_t) * MANR_MAX_LENGTH);
- if (buffer == NULL) {
- return (-1);
- }
-
- /* read the board info */
- current_offset += board_offset + BD_MFR_OFFSET;
- current_offset += read_bd_fields(buffer, current_offset, format);
-
- if (strncmp(SUN_NAME, (char *)buffer, sizeof (SUN_NAME)) == 0) {
- manr->vendor_name[0] = 0x00;
- manr->vendor_name[1] = 0x3e;
- } else {
- manr->vendor_name[0] = 0x00;
- manr->vendor_name[1] = 0x00;
- }
-
- current_offset += 1; /* for length/type field */
-
- current_offset += read_bd_fields(buffer, current_offset, format);
- current_offset += 1; /* for length/type field */
- (void) memcpy(manr->fru_short_name, buffer, MANR_FRUNAME_LEN);
-
- current_offset += read_bd_fields(buffer, current_offset, format);
- current_offset += 1; /* for length/type field */
- (void) memcpy(manr->sun_serial_no, buffer, MANR_SERIALNUM_LEN);
-
- current_offset += read_bd_fields(buffer, current_offset, format);
- current_offset += 1; /* for length/type field */
- (void) memcpy(manr->sun_part_no, buffer, MANR_PARTNUM_LEN);
-
- /*
- * We dont need the FRU FILE ID, so just skip the field
- * and get the offset to read the custom MFG. info fields
- */
- current_offset += read_bd_fields(buffer, current_offset, format);
- current_offset += 1; /* for length/type field */
-
- current_offset += read_bd_fields(buffer, current_offset, format);
- current_offset += 1; /* for length/type field */
-
- /* read the custom mfg. info fields */
- current_offset += read_bd_fields(buffer, current_offset, format);
- current_offset += 1; /* for length/type field */
- (void) memcpy(manr->manufacture_loc, buffer, MANR_MFRLOC_LEN);
-
- current_offset += read_bd_fields(buffer, current_offset, format);
- (void) memcpy(manr->fru_descr, buffer, MANR_FRUDESCR_LEN);
-
- free(buffer);
- return (0);
-}
-
-/*
- * Read the IPMI information from hardware and translate it into
- * MANR(SUN format)
- */
-int
-get_manr(format_t *format, payload_t *manr)
-{
- int ret = 0;
- fruid_offset_t *offset = NULL;
-
- offset = (fruid_offset_t *)malloc(sizeof (fruid_offset_t));
- if (offset == NULL) {
- return (-1);
- }
-
- ret = read_common_header(offset, format);
- if (ret != 0) {
- free(offset);
- return (-1);
- }
-
- if (offset->board != 0) {
- ret = read_board_info(offset->board, manr, format);
- }
-
- free(offset);
- return (ret);
-}
-
-static void
-convert_to_ascii(uint8_t data [], uint8_t store[],
- int length, int extra_bytes)
-{
- uint8_t x, y;
- int index = 0;
- int i, idx = length - (length % 3);
-
- for (i = 0; ; i += 3) {
-
- x = 0x0;
- y = 0x0;
-
- if (i == idx && extra_bytes == 0) {
- break;
- }
-
- /* get the first six bits */
- x = (data[i] & BIT_MASK1);
- x += ASCII_MAP;
- store[index] = x;
-
- if (i == idx && extra_bytes == 1) {
- break;
- }
-
- /*
- * get last 2 bits of first byte and first
- * 4 bits of second byte
- */
-
- x = (data[i] >> 6);
- y = (data[i + 1] & BIT_MASK2) << 2;
- x |= y + ASCII_MAP;
- store[index+1] = x;
-
- if (i == idx) {
- break;
- }
-
- /* get last 4 bits of second byte and 2 bits of last byte */
- x = data[i + 1] >> 4;
- y = (data[i + 2] & BIT_MASK3) << 4;
- x |= y + ASCII_MAP;
- store[index+2] = x;
-
- /* get last six bits of third byte */
- store[index + 3] = (data[i + 2] >> 2) + ASCII_MAP;
- index += 4;
- }
-}
-
-static void
-bcdplus_to_ascii(uint8_t data[], uint8_t store[], int len)
-{
- int i, j, index = 0;
- uint8_t tmp = 0;
-
- struct {
- int a:4;
- int b:4;
- } val;
-
- for (i = 0; i < len; i++) {
- (void) memcpy(&val, &data[i], 1);
- for (j = 0; j < 2; j++) {
- if (j == 0) {
- tmp = val.a;
- } else
- tmp = val.b;
-
- if (tmp <= 9) {
- /* ascii conversion */
- store[index++] = tmp + 48;
- continue;
- }
-
- switch (tmp) {
-
- case 0xa:
- store[index++] = ' ';
- break;
- case 0xb:
- store[index++] = '-';
- break;
- case 0xc:
- store[index++] = '.';
- break;
- default:
- store[index++] = ' ';
- }
- }
- }
-}
-
-/* converts ipmi format time to UTC time (unix 32 bit timestamp) */
-static time_t
-get_utc_time(uint8_t data [])
-{
- time_t time;
- struct tm tm1;
- uint32_t ipmi_time;
-
- (void) memcpy(&ipmi_time, data, 4);
-
- ipmi_time *= 60; /* convert into seconds */
-
- /* get UTC time for 0:00 1/1/96 (ipmi epoch) */
- tm1.tm_sec = 0;
- tm1.tm_min = 0;
- tm1.tm_hour = 0;
- tm1.tm_mday = 1;
- tm1.tm_mon = 0;
- tm1.tm_year = 96;
-
- time = mktime(&tm1);
- time += ipmi_time;
-
- return (time);
-}
-
-/*
- * routine to write information to BMC
- */
-static int
-write_alarm_fru_data(const void *buffer, size_t size,
- off_t offset, format_t *format)
-{
- sc_reqmsg_t req_pkt;
- sc_rspmsg_t res_pkt;
- uint8_t *datap = NULL;
-
- if (buffer == NULL) {
- return (-1);
- }
- datap = (uint8_t *)malloc(sizeof (uint8_t) * (size + 5));
- if (datap == NULL) {
- return (-1);
- }
-
- datap[0] = 0x7; /* bus id */
- datap[1] = 0xa0; /* slave address */
- datap[2] = 0; /* count */
- datap[3] = offset >> 8; /* MSB */
- datap[4] = (uint8_t)offset; /* LSB */
- (void) memcpy((void *)&(datap[5]), buffer, size);
-
- /* initialize ipmi request packet */
- (void) smc_init_ipmi_msg(&req_pkt, SMC_MASTER_WR_RD_I2C,
- FRUACCESS_MSG_ID, (5 + size), datap, DEFAULT_SEQN,
- format->dest, SMC_NETFN_APP_REQ, SMC_BMC_LUN);
- free(datap);
-
- /* send ipmi request packet */
- if (smc_send_msg(DEFAULT_FD, &req_pkt, &res_pkt,
- POLL_TIMEOUT) != SMC_SUCCESS) {
- return (-1);
- }
- /* check the completion code */
- if (res_pkt.data[7] != 0) {
- return (-1);
- }
- return (0);
-}
-
-static int
-write_fru_data(const void *buffer, size_t size,
- off_t offset, format_t *format)
-{
- int ipmi = 0;
- sc_reqmsg_t req_pkt;
- sc_rspmsg_t res_pkt;
- uint8_t *datap = NULL;
-
- if (buffer == NULL) {
- return (-1);
- }
-
- if (format->src == format->dest) {
- ipmi = 0;
- } else {
- ipmi = 1;
- }
-
- switch (ipmi) {
-
- case 0: /* on board info (local i2c) */
-
- SC_MSG_CMD(&req_pkt) = SMC_EEPROM_WRITE;
- SC_MSG_LEN(&req_pkt) = 4 + size;
- SC_MSG_ID(&req_pkt) = FRUACCESS_MSG_ID;
-
- /* data field for request */
- req_pkt.data[0] = format->sun_device_id; /* device id */
- req_pkt.data[1] = offset; /* (LSB) */
- req_pkt.data[3] = size;
- if (format->format == SUN_FORMAT) {
- req_pkt.data[2] = offset >> 8;
- } else {
- req_pkt.data[2] = 0x0; /* (MSB) always 0x0 for IPMI */
- }
- (void) memcpy((void *)&(req_pkt.data[4]), buffer, size);
-
- /* make a call to smc library to send cmd */
- if (smc_send_msg(DEFAULT_FD, &req_pkt, &res_pkt,
- POLL_TIMEOUT) != SMC_SUCCESS) {
- return (-1);
- }
- break;
-
- default: /* read data from remote device (ipmi) */
- datap = (uint8_t *)malloc(sizeof (uint8_t) * (size + 4));
- if (datap == NULL) {
- return (-1);
- }
-
- datap[0] = format->sun_device_id; /* device id */
- datap[1] = offset; /* LSB */
- datap[3] = size; /* nbytes */
- if (format->format == SUN_FORMAT) {
- datap[2] = offset >> 8;
- } else {
- datap[2] = 0x0; /* (MSB) always 0x0 for IPMI */
- }
- (void) memcpy((void *)&(datap[4]), buffer, size);
-
- (void) smc_init_ipmi_msg(&req_pkt, WRITE_FRU_INVENTORY_DATA,
- FRUACCESS_MSG_ID, (4 + size), datap, DEFAULT_SEQN,
- format->dest, SMC_NETFN_STORAGE_REQ, format->sun_lun);
- free(datap);
-
- if (smc_send_msg(DEFAULT_FD, &req_pkt, &res_pkt,
- POLL_TIMEOUT) != SMC_SUCCESS) {
- return (-1);
- }
- /* check the completion code */
- if (res_pkt.data[7] != 0) {
- return (-1);
- }
- break;
- } /* end of switch */
- return (0);
-}
-
-/*
- * This routine splits the data to write into smaller chunks and
- * write it to FRUID chip using SMC drv APIs
- */
-
-/* ARGSUSED */
-ssize_t
-pwrite_new(int fd, const void *buffer, size_t size,
- off_t offset, format_t *format)
-{
- int ret;
- int index = 0;
- size_t bytes = 0;
- off_t next_offset = 0x0;
- off_t curr_offset = offset;
- size_t bytes_to_write = size;
- uint8_t *data;
- int retry = 3;
- int (* func_ptr)(const void *, size_t, off_t, format_t *);
-
- if (format->dest == 0x20) {
- func_ptr = write_alarm_fru_data;
- } else {
- func_ptr = write_fru_data;
- }
-
- data = (uint8_t *)buffer;
- while (bytes_to_write != 0) {
-
- retry = 3;
- ret = 1;
-
- if (bytes_to_write > SIZE_TO_READ_WRITE) {
- bytes = SIZE_TO_READ_WRITE;
- next_offset = curr_offset + SIZE_TO_READ_WRITE;
- } else {
- bytes = bytes_to_write;
- }
-
- bytes_to_write = bytes_to_write - bytes;
- while ((ret != 0) && (retry != 0)) {
- ret = (*func_ptr)((void *)&data[index],
- bytes, curr_offset, format);
- retry--;
- }
- if (ret != 0) {
- return (ret);
- }
- index = index + bytes;
- curr_offset = next_offset;
- }
- return (size);
-}
-
-/*
- * This routine reads the data in smaller chunks and
- * sends it to upper layer(frudata plugin) in the sw stack
- */
-/* ARGSUSED */
-ssize_t
-pread_new(int fd, void *buffer, size_t size,
- off_t offset, format_t *format)
-{
- int ret;
- int index = 0;
- size_t bytes = 0;
- off_t next_offset = 0x0;
- off_t curr_offset = offset;
- size_t bytes_to_read = size;
- uint8_t *data;
- int retry = 3;
- int (* func_ptr)(int, int, void *, format_t *);
-
- if (format->dest == 0x20) {
- func_ptr = get_alarm_fru_data;
- } else {
- func_ptr = get_fru_data;
- }
-
- data = (uint8_t *)buffer;
-
- while (bytes_to_read != 0) {
-
- retry = 3;
- ret = 1;
-
- if (bytes_to_read > SIZE_TO_READ_WRITE) {
- bytes = SIZE_TO_READ_WRITE;
- next_offset = curr_offset + SIZE_TO_READ_WRITE;
- } else {
- bytes = bytes_to_read;
- }
-
- bytes_to_read = bytes_to_read - bytes;
-
- while ((ret != 0) && (retry != 0)) {
- ret = (* func_ptr)(curr_offset, bytes,
- (void *) &data[index], format);
- retry--;
- }
- if (ret != 0) {
- return (ret);
- }
- index = index + bytes;
- curr_offset = next_offset;
- }
- return (size);
-}
-
-/*
- * routine to check if IPMI fruid info is available,
- * return 0: IPMI fruid not present
- * return 1: IPMI fruid present
- */
-static int
-is_ipmi_fru_data_available(int src, int dest)
-{
- sc_reqmsg_t req_pkt;
- sc_rspmsg_t res_pkt;
- uint8_t datap[5];
-
- /* on board access */
- if (src == dest) {
-
- SC_MSG_CMD(&req_pkt) = SMC_EEPROM_READ;
- SC_MSG_LEN(&req_pkt) = 4;
- SC_MSG_ID(&req_pkt) = FRUACCESS_MSG_ID;
-
- /* data field for request */
- req_pkt.data[0] = 0x0; /* eeprom number (ipmi format) */
- req_pkt.data[1] = CMN_HDR_OFFSET; /* (LSB) */
- req_pkt.data[2] = 0x0; /* (MSB) always 0x0 for IPMI */
- req_pkt.data[3] = IPMI_COMMON_HEADER_SIZE;
-
- /* make a call to smc library to send cmd */
- if (smc_send_msg(DEFAULT_FD, &req_pkt, &res_pkt,
- POLL_TIMEOUT) != SMC_SUCCESS) {
- return (0);
- }
-
- /* version check */
- if (res_pkt.data[0] != IPMI_VERSION) {
- return (0);
- } else {
- return (1);
- }
- }
-
- /* ipmi access */
- datap[0] = FRU_DEVICE_ID; /* fru device id - always */
- datap[1] = 0x0; /* LSB */
- datap[2] = 0x0; /* MSB */
- datap[3] = 8; /* bytes to read */
-
- (void) smc_init_ipmi_msg(&req_pkt, READ_FRU_INVENTORY_DATA,
- FRUACCESS_MSG_ID, 4, datap, DEFAULT_SEQN,
- IPMB_ADDR(dest), SMC_NETFN_STORAGE_REQ, SMC_BMC_LUN);
-
- if (smc_send_msg(DEFAULT_FD, &req_pkt, &res_pkt,
- FRUID_CHECK_POLL_TIMEOUT) != SMC_SUCCESS) {
- return (0);
- }
-
- if (res_pkt.data[9] == IPMI_VERSION) {
- return (1);
- } else {
- return (0);
- }
-}
-
-/*
- * routine to check if fruid info is available on BMC,
- * return 0: fruid not present
- * return 1: fruid present
- */
-static int
-is_alarm_frudata_available(format_t *fru_format)
-{
- int ret;
- char buffer[TMP_BUFFER_SIZE];
- int fd = -1;
- format_t format;
-
- bzero(buffer, sizeof (buffer));
- format.src = fru_format->src;
- format.dest = fru_format->dest;
- format.sun_device_id = 0x0;
- format.sun_lun = 0x0;
- format.format |= SUN_FORMAT;
-
- /* passing dummy fd */
- /* for now read the first 3 bytes and check the info */
- ret = pread_new(fd, (void *) buffer, 3, STATIC_OFFSET, &format);
- if (ret < 0) {
- return (0);
- }
-
- if (buffer[0] != SECTION_HDR_TAG) {
- fru_format->format = NO_FRUDATA;
- return (0);
- }
-
- fru_format->format = SUN_FORMAT;
- fru_format->sun_device_id = 0x0;
- fru_format->sun_lun = 0x0;
- return (1);
-}
-
-/*
- * checks if the remote device intelligent device (IPMI capable) or not
- * return 0: not ipmi capable
- * return 1: ipmi capable
- */
-static int
-is_ipmi_capable(int src, int dest)
-{
- sc_reqmsg_t req_pkt;
- sc_rspmsg_t res_pkt;
-
- if (src == dest) {
- return (1);
- }
-
- (void) smc_init_ipmi_msg(&req_pkt, IPMI_GET_DEVICE_ID,
- FRUACCESS_MSG_ID, 0, NULL, DEFAULT_SEQN,
- IPMB_ADDR(dest), SMC_NETFN_APP_REQ, SMC_BMC_LUN);
-
- if (smc_send_msg(DEFAULT_FD, &req_pkt, &res_pkt,
- FRUID_CHECK_POLL_TIMEOUT) != SMC_SUCCESS) {
- return (0);
- }
- return (1); /* got response */
-}
-
-int
-is_fru_data_available(int precedence, int slot_no, format_t *fru_format)
-{
- int ret, fd = 0;
- uint8_t data[TMP_BUFFER_SIZE];
-
- fru_format->format = NO_FRUDATA;
- if (fru_format->dest == 0x20) { /* alarm card */
- ret = is_alarm_frudata_available(fru_format);
- return (ret);
- }
-
- if (cpu_no == 0) { /* get the geo_addr */
- sc_reqmsg_t req_pkt;
- sc_rspmsg_t rsp_pkt;
- uint8_t size = 0;
-
- /* initialize the request packet */
- (void) smc_init_smc_msg(&req_pkt,
- SMC_GET_GEOGRAPHICAL_ADDRESS, DEFAULT_SEQN, size);
- /* make a call to smc library to send cmd */
- if (smc_send_msg(DEFAULT_FD, &req_pkt, &rsp_pkt,
- POLL_TIMEOUT) != SMC_SUCCESS) {
- return (0);
- }
- if (SC_MSG_LEN(&rsp_pkt) == 0) {
- return (0);
- }
- cpu_no = rsp_pkt.data[0];
- }
-
- /* check if it is IPMI intelligent or not */
- if (slot_no != cpu_no) {
- ret = is_ipmi_capable(cpu_no, slot_no);
- if (ret == 0) { /* dumb I/O card */
- return (0);
- }
- }
-
- /* check if ipmi frudata is present or not */
- ret = is_ipmi_fru_data_available(cpu_no, slot_no);
- if (ret == 1) {
- fru_format->format |= IPMI_FORMAT;
- fru_format->sun_device_id = 0x0;
- fru_format->sun_lun = 0x0;
-
- /* no need to look for sun format */
- if (precedence == IPMI_FORMAT) {
- return (fru_format->format);
- }
- }
-
- /* check if sun fruid is present */
- get_fru_data_info(cpu_no, slot_no, fru_format);
- /* check the hdr version */
- if (fru_format->format & SUN_FORMAT) {
- ret = pread_new(fd, &data, BYTE_TO_READ_SUN_CHK,
- STATIC_OFFSET, fru_format);
- if (ret != BYTE_TO_READ_SUN_CHK) {
- fru_format->format = fru_format->format &
- (~ (SUN_FORMAT));
- fru_format->sun_device_id = 0x0;
- fru_format->sun_lun = 0x0;
- }
- if (data[0] != SECTION_HDR_TAG) {
- fru_format->format = fru_format->format &
- (~ (SUN_FORMAT));
- fru_format->sun_device_id = 0x0;
- fru_format->sun_lun = 0x0;
- }
- }
- return (fru_format->format);
-}
diff --git a/usr/src/cmd/picl/plugins/sun4u/snowbird/lib/libctsmc/Makefile b/usr/src/cmd/picl/plugins/sun4u/snowbird/lib/libctsmc/Makefile
deleted file mode 100644
index f6531cd3d7..0000000000
--- a/usr/src/cmd/picl/plugins/sun4u/snowbird/lib/libctsmc/Makefile
+++ /dev/null
@@ -1,91 +0,0 @@
-#
-# 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 2009 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-# cmd/picl/plugins/sun4u/snowbird/lib/smc_util/Makefile
-#
-
-LIBRARY = libctsmc.a
-VERS = .1
-PLATFORM = SUNW,Netra-CP2300
-
-OBJECTS= libctsmc.o
-
-# include library definitions
-include $(SRC)/lib/Makefile.lib
-include $(SRC)/Makefile.psm
-include $(SRC)/cmd/picl/plugins/Makefile.com
-
-ROOT_PLATFORM = $(USR_PLAT_DIR)/$(PLATFORM)
-
-SRCS= $(OBJECTS:%.o=%.c)
-
-LIBS = $(DYNLIB)
-
-CLEANFILES= $(LINTOUT) $(LINTLIB)
-
-ROOTLIBDIR = $(ROOT_PLAT_LIBDIR)
-
-LINTSRC = $(LINTLIB:%.ln=%)
-ROOTLINTDIR = $(ROOTLIBDIR)
-ROOTLINT = $(LINTSRC:%=$(ROOTLINTDIR)/%)
-
-CFLAGS += $(CCVERBOSE)
-CPPFLAGS += -D_REENTRANT -D_SNOWBIRD -I$(SRC)/uts/sun4u/sys
-LDLIBS += -L $(ROOT)/usr/platform/$(PLATFORM)/lib
-LDLIBS += -R/usr/platform/sun4u/lib
-LDLIBS += -lc
-
-.KEEP_STATE:
-
-SUBDIRS=
-
-all := TARGET= all
-install := TARGET= install
-clean := TARGET= clean
-clobber := TARGET= clobber
-lint := TARGET= lint
-_msg := TARGET= _msg
-
-all:$(LIBS) $(LIBLINKS)
-
-install:$(ROOTLIBDIR) all $(ROOTLIBS) $(ROOTLINKS)
-
-$(LIBLINKS): FRC
- $(RM) $(LIBLINKS); $(SYMLINK) $(DYNLIB) $(LIBLINKS)
-_msg:
-
-# include library targets
-include $(SRC)/cmd/picl/plugins/Makefile.targ
-include $(SRC)/lib/Makefile.targ
-
-$(ROOTLINTDIR)/%: ../%
- $(INS.file)
-
-lint :
- $(LINT.c) $(SRCS)
-
-$(SUBDIRS): FRC
- @cd $@; pwd; $(MAKE) $(TARGET)
-
-FRC:
diff --git a/usr/src/cmd/picl/plugins/sun4u/snowbird/lib/libctsmc/libctsmc.c b/usr/src/cmd/picl/plugins/sun4u/snowbird/lib/libctsmc/libctsmc.c
deleted file mode 100644
index 7bd71245c4..0000000000
--- a/usr/src/cmd/picl/plugins/sun4u/snowbird/lib/libctsmc/libctsmc.c
+++ /dev/null
@@ -1,476 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (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 2004 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * This is utility library that provides APIs to interact with SMC driver
- */
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-#include <poll.h>
-#include <assert.h>
-#include <unistd.h>
-#include <string.h>
-#include <strings.h>
-#include <stdarg.h>
-#include <stropts.h>
-#include <syslog.h>
-#include "smclib.h"
-
-static int debug_on = 0;
-
-/* Error messages */
-#define SMC_ERRMSG_OPEN "SMC open failed, cmd = %x\n"
-#define SMC_ERRMSG_WRITE "SMC write failed, cmd = %x\n"
-#define SMC_ERRMSG_POLLTIMEOUT "SMC poll timed out, cmd = %x\n"
-#define SMC_ERRMSG_POLLFAILED "SMC poll failed, cmd = %x\n"
-#define SMC_ERRMSG_POLL_T "SMC poll timed out, dest = %x\n"
-#define SMC_ERRMSG_POLL_F "SMC poll failed, dest = %x\n"
-#define SMC_ERRMSG_READ "SMC read response failed, cmd = %x\n"
-#define SMC_ERRMSG_ERROR "SMC error, cc = %d, msg_id = %x\n"
-#define SMC_ERRMSG_SETATTR "SMC setting read attribute failed\n"
-#define SMC_ERRMSG_GET_SEQN "SMC error in getting seqn for %x\n"
-#define SMC_ERRMSG_IPMI_ERR "SMC IPMI invalid cc:%x, dest = %x\n"
-#define SMC_ERRMSG_GET_GEO "SMC get GeoAddr failed\n"
-
-/* Macros */
-#define REQ_SA(_X) (((_X) < 10) ? (0xb0 + 2 * ((_X) - 1)) :\
- (0xb0 + 2 * (_X)))
-#define LUN_BITMASK 0x03 /* last two bits */
-#define RESPONSE_MSG 0x01 /* last bit */
-
-#define SMC_LOCAL_SEQ_NO 10
-#define SMC_POLL_TIME 1000 /* 1 sec */
-#define NORMAL_COMPLETION_CODE 0
-#define IPMI_MSG_CHANNEL_0 0x0
-#define IPMI_REQ_HDR_LEN 0x8 /* includes command & data checksum */
-#define IPMI_RSP_HDR_LEN 0x8
-#define SMC_NETFN_SEQ_OFFSET 5
-#define SMC_CMD_OFFSET 6
-
-#define SMC_NODE ("/dev/ctsmc")
-#define DEFAULT_FD -1
-#define DEFAULT_SEQN 128
-
-/*
- * IPMI packet header
- */
-typedef struct {
- uint8_t channel_no; /* channel num */
- uint8_t rs_addr; /* dest addr */
- uint8_t netfn_lun; /* netfn and lun */
- uint8_t checksum; /* checksum for dest and netfn_lun */
- uint8_t rq_addr; /* sender addr */
- uint8_t seq_num; /* sequence number */
- uint8_t cmd; /* ipmi cmd */
-} smc_ipmi_header_t;
-
-/*
- * debug printf
- */
-static void
-dbg_print(const char *fmt, ...)
-{
- if (debug_on > 0) {
- va_list ap;
- va_start(ap, fmt);
- (void) vprintf(fmt, ap);
- va_end(ap);
- }
-}
-
-/*
- * send a local command to SMC
- */
-static smc_errno_t
-smc_send_local_cmd(int fd, sc_reqmsg_t *req_pkt, sc_rspmsg_t *rsp_pkt,
- int poll_time)
-{
- int poll_rc;
- struct pollfd poll_fds[1];
-
- poll_fds[0].fd = fd;
- poll_fds[0].events = POLLIN|POLLPRI;
- poll_fds[0].revents = 0;
-
- /* send the command to SMC */
- if (write(fd, req_pkt, SC_SEND_HEADER + SC_MSG_LEN(req_pkt)) < 0) {
- dbg_print(SMC_ERRMSG_WRITE, SC_MSG_CMD(req_pkt));
- return (SMC_REQ_FAILURE);
- }
-
- poll_rc = poll(poll_fds, 1, poll_time);
- if (poll_rc == 0) {
- dbg_print(SMC_ERRMSG_POLLTIMEOUT, SC_MSG_CMD(req_pkt));
- return (SMC_ACK_FAILURE);
- } else if (poll_rc == -1) {
- dbg_print(SMC_ERRMSG_POLLFAILED, SC_MSG_CMD(req_pkt));
- return (SMC_ACK_FAILURE);
- }
-
- /* read the response from SMC */
- if (read(fd, rsp_pkt, SC_MSG_MAX_SIZE) == -1) {
- dbg_print(SMC_ERRMSG_READ, SC_MSG_CMD(req_pkt));
- return (SMC_ACK_FAILURE);
- }
-
- /* check if response is valid */
- if (SC_MSG_ID(rsp_pkt) != SC_MSG_ID(req_pkt)) {
- dbg_print(SMC_ERRMSG_ERROR, SC_MSG_CC(rsp_pkt),
- SC_MSG_ID(rsp_pkt));
- return (SMC_INVALID_SEQ);
- }
-
- if (SC_MSG_CC(rsp_pkt) != 0) {
- return (SMC_FAILURE);
- }
-
- return (SMC_SUCCESS);
-}
-
-/*
- * get_geo_addr -- returns the geographical address of a CPU board
- */
-static int
-get_geo_addr(uint8_t *geo_addr)
-{
- int fd, rc;
- sc_reqmsg_t req_pkt;
- sc_rspmsg_t rsp_pkt;
-
- if ((fd = open(SMC_NODE, O_RDWR)) < 0) {
- dbg_print(SMC_ERRMSG_OPEN,
- SMC_GET_GEOGRAPHICAL_ADDRESS);
- return (SMC_FAILURE);
- }
-
- SC_MSG_CMD(&req_pkt) = SMC_GET_GEOGRAPHICAL_ADDRESS;
- SC_MSG_LEN(&req_pkt) = 0;
- SC_MSG_ID(&req_pkt) = SMC_LOCAL_SEQ_NO;
-
- /* no request data */
- if ((rc = smc_send_local_cmd(fd, &req_pkt, &rsp_pkt,
- SMC_POLL_TIME)) != SMC_SUCCESS) {
- (void) close(fd);
- return (rc);
- }
-
- *geo_addr = rsp_pkt.data[0];
- (void) close(fd);
- return (SMC_SUCCESS);
-}
-
-/*
- * checksum - returns a 2-complement check sum
- */
-static uint8_t
-checksum(uint8_t buf[], int start, int end)
-{
- int i;
- uint8_t sum = 0x0;
-
- for (i = start; i <= end; i++) {
- sum += buf[i];
- }
- sum = ~sum + 1;
- return (sum);
-}
-
-/*
- * func to send IPMI messages
- */
-static smc_errno_t
-smc_send_ipmi_message(int fd, sc_reqmsg_t *req_pkt, sc_rspmsg_t *rsp_pkt,
- int poll_time)
-{
- int result, nbytes, i = 0;
- struct pollfd fds;
- uint8_t cc, netfn;
- boolean_t is_response = B_FALSE;
- char data[SC_MSG_MAX_SIZE], *p;
-
- if (debug_on) {
- bzero(data, SC_MSG_MAX_SIZE);
- p = data;
- for (i = 0; i < SC_MSG_LEN(req_pkt); i++) {
- (void) sprintf(p, "%02x ", req_pkt->data[i]);
- p = data + strlen(data);
- }
- p = data;
- syslog(LOG_ERR, "REQ> %s", p);
- }
-
- netfn = req_pkt->data[2] >> 2;
- if (netfn & RESPONSE_MSG) {
- is_response = B_TRUE;
- }
-
- if ((nbytes = write(fd, (char *)req_pkt, SC_SEND_HEADER +
- SC_MSG_LEN(req_pkt))) < 0) {
- dbg_print(SMC_ERRMSG_WRITE, SMC_SEND_MESSAGE);
- return (SMC_REQ_FAILURE);
- }
-
- if ((nbytes = read(fd, (char *)rsp_pkt, SC_MSG_MAX_SIZE)) < 0) {
- dbg_print(SMC_ERRMSG_READ, SMC_SEND_MESSAGE);
- return (SMC_ACK_FAILURE);
- }
-
- if (SC_MSG_CC(rsp_pkt) != 0) {
- dbg_print(SMC_ERRMSG_ERROR, SC_MSG_CC(rsp_pkt),
- SC_MSG_ID(rsp_pkt));
- return (SMC_ACK_FAILURE);
- }
-
- if (is_response) { /* need not wait for response */
- return (SMC_SUCCESS);
- }
-
- fds.fd = fd;
- fds.events = POLLIN | POLLPRI;
- fds.revents = 0;
- result = poll(&fds, 1, poll_time);
-
- if (result == 0) {
- dbg_print(SMC_ERRMSG_POLL_T, req_pkt->data[1]);
- return (SMC_RSP_TIMEOUT);
- } else if (result < 0) {
- dbg_print(SMC_ERRMSG_POLL_F, req_pkt->data[1]);
- return (SMC_RSP_ERROR);
- }
-
- nbytes = read(fd, rsp_pkt, SC_MSG_MAX_SIZE);
- if (nbytes < 0) {
- dbg_print(SMC_ERRMSG_READ, SMC_SEND_MESSAGE);
- return (SMC_RSP_ERROR);
- }
-
- if (debug_on) {
- bzero(data, SC_MSG_MAX_SIZE);
- p = data;
- for (i = 0; i < nbytes; i++) {
- (void) sprintf(p, "%02x ", rsp_pkt->data[i]);
- p = data + strlen(data);
- }
- p = data;
- syslog(LOG_DEBUG, "RES> %s, seq = %x, cmd = %x, len = %x,"
- "cc = %x", p, SC_MSG_ID(rsp_pkt), SC_MSG_CMD(rsp_pkt),
- SC_MSG_LEN(rsp_pkt), SC_MSG_CC(rsp_pkt));
- }
-
- if (SC_MSG_CC(rsp_pkt) != 0) {
- dbg_print(SMC_ERRMSG_IPMI_ERR, rsp_pkt->hdr.cc,
- req_pkt->data[SMC_CMD_OFFSET]);
- return (SMC_RSP_ERROR);
- }
-
- if (req_pkt->data[SMC_NETFN_SEQ_OFFSET] !=
- rsp_pkt->data[SMC_NETFN_SEQ_OFFSET]) {
- dbg_print("SMC: Invalid sequence number in"
- " IPMI Response (sent %x, received %x)\n",
- req_pkt->data[5], rsp_pkt->data[SMC_NETFN_SEQ_OFFSET]);
- }
-
- if ((cc = rsp_pkt->data[IPMI_RSP_HDR_LEN-1]) != 0) {
- dbg_print("SMC:IPMI response completion "
- "error %x, command = %x\n",
- cc, req_pkt->data[SMC_CMD_OFFSET]);
- }
- return (SMC_SUCCESS);
-}
-
-/*
- * Initializes the IPMI request packet
- */
-smc_errno_t
-smc_init_ipmi_msg(sc_reqmsg_t *req_msg, uint8_t cmd, uint8_t msg_id,
- uint8_t msg_data_size, uint8_t *msg_data_buf, int8_t seq_num,
- int ipmb_addr, smc_netfn_t netfn, smc_lun_t lun)
-{
- static uint8_t geo_addr = 0;
- smc_ipmi_header_t ipmi_header;
- uint8_t data[2];
- if (msg_data_size > 0) {
- if ((msg_data_size > (SC_SEND_DSIZE - IPMI_REQ_HDR_LEN)) ||
- (msg_data_buf == NULL)) {
- return (SMC_FAILURE);
- }
- }
-
- /* get the geo addr for first time */
- if (geo_addr == 0) {
- if (get_geo_addr(&geo_addr) != SMC_SUCCESS) {
- dbg_print(SMC_ERRMSG_GET_GEO);
- return (SMC_FAILURE);
- }
- }
-
- SC_MSG_CMD(req_msg) = SMC_SEND_MESSAGE;
- SC_MSG_ID(req_msg) = msg_id;
- SC_MSG_LEN(req_msg) = IPMI_REQ_HDR_LEN + msg_data_size;
- ipmi_header.channel_no = IPMI_MSG_CHANNEL_0;
- ipmi_header.rs_addr = data[0] = ipmb_addr;
- ipmi_header.netfn_lun = data[1] = (netfn << 2) | lun;
- ipmi_header.checksum = checksum(data, 0, 1);
- ipmi_header.rq_addr = REQ_SA(geo_addr);
- ipmi_header.cmd = cmd;
- if (seq_num >= 0 && seq_num < 64) {
- ipmi_header.seq_num = (seq_num << 2) | SMC_SMS_LUN;
- } else {
- ipmi_header.seq_num = DEFAULT_SEQN;
- }
-
- /* copy the header */
- (void) bcopy((void *)&ipmi_header, SC_MSG_DATA(req_msg),
- sizeof (ipmi_header));
-
- /* copy the msg data into request packet */
- (void) bcopy((void *)msg_data_buf, (void *)((uchar_t *)req_msg->data +
- (IPMI_REQ_HDR_LEN - 1)), msg_data_size);
- return (SMC_SUCCESS);
-}
-
-/*
- * Initialize a SMC packet
- */
-smc_errno_t
-smc_init_smc_msg(sc_reqmsg_t *req_msg, smc_app_command_t cmd,
- uint8_t msg_id, uint8_t msg_data_size)
-{
- if (msg_data_size > SC_SEND_DSIZE) {
- return (SMC_FAILURE);
- }
-
- /* fill the packet */
- SC_MSG_CMD(req_msg) = cmd;
- SC_MSG_LEN(req_msg) = msg_data_size;
- SC_MSG_ID(req_msg) = msg_id;
- return (SMC_SUCCESS);
-}
-
-/*
- * Sends SMC(local) and IPMI messages
- */
-smc_errno_t
-smc_send_msg(int fd, sc_reqmsg_t *req_msg, sc_rspmsg_t *rsp_msg,
- int poll_time)
-{
- int rc = SMC_SUCCESS;
- uint8_t dsize, dest;
- boolean_t close_fd = B_FALSE;
- boolean_t free_seqn = B_FALSE;
- struct strioctl scioc;
- sc_seqdesc_t smc_seq;
- int8_t seq_no;
-
- if (req_msg == NULL || rsp_msg == NULL) {
- return (SMC_FAILURE);
- }
-
- if (fd < 0) {
- close_fd = B_TRUE;
- if ((fd = open(SMC_NODE, O_RDWR)) < 0) {
- dbg_print(SMC_ERRMSG_OPEN,
- SC_MSG_CMD(req_msg));
- return (SMC_FAILURE);
- }
- }
-
- if (ioctl(fd, I_SRDOPT, RMSGD) < 0) {
- dbg_print(SMC_ERRMSG_SETATTR);
- if (close_fd)
- (void) close(fd);
- return (SMC_FAILURE);
- }
-
- if (SC_MSG_CMD(req_msg) != SMC_SEND_MESSAGE) {
- rc = smc_send_local_cmd(fd, req_msg, rsp_msg, poll_time);
- if (close_fd) {
- (void) close(fd);
- }
- return (rc);
- }
-
- /* This is an IPMI message */
- dsize = SC_MSG_LEN(req_msg) - IPMI_REQ_HDR_LEN;
- if (dsize > (SC_SEND_DSIZE - IPMI_REQ_HDR_LEN)) {
- if (close_fd) {
- (void) close(fd);
- }
- return (SMC_FAILURE);
- }
-
- /* check if sequence num is valid or not */
- if (req_msg->data[SMC_NETFN_SEQ_OFFSET] == DEFAULT_SEQN) {
- free_seqn = B_TRUE;
- bzero(&smc_seq, sizeof (sc_seqdesc_t));
- dest = smc_seq.d_addr = req_msg->data[1]; /* dest */
- smc_seq.n_seqn = 1;
- smc_seq.seq_numbers[0] = 0;
- scioc.ic_cmd = SCIOC_RESERVE_SEQN;
- scioc.ic_timout = 0;
- scioc.ic_len = sizeof (sc_seqdesc_t);
- scioc.ic_dp = (char *)&smc_seq;
- if (ioctl(fd, I_STR, &scioc) < 0) {
- dbg_print(SMC_ERRMSG_GET_SEQN, dest);
- if (close_fd) {
- (void) close(fd);
- }
- return (SMC_FAILURE);
- }
- seq_no = smc_seq.seq_numbers[0];
- req_msg->data[SMC_NETFN_SEQ_OFFSET] =
- (seq_no << 2) | SMC_SMS_LUN;
- }
-
- req_msg->data[(IPMI_REQ_HDR_LEN-1)+dsize] =
- checksum(req_msg->data, 4, (IPMI_REQ_HDR_LEN-2)+dsize);
-
- rc = smc_send_ipmi_message(fd, req_msg, rsp_msg, poll_time);
-
- if (free_seqn) { /* free seqn if library reserved it */
- smc_seq.d_addr = dest;
- smc_seq.n_seqn = 1;
- smc_seq.seq_numbers[0] = seq_no;
- scioc.ic_cmd = SCIOC_FREE_SEQN;
- scioc.ic_timout = 0;
- scioc.ic_len = sizeof (sc_seqdesc_t);
- scioc.ic_dp = (char *)&smc_seq;
- if (ioctl(fd, I_STR, &scioc) < 0) {
- dbg_print("SMC:Error in releasing sequence "
- "number\n");
- rc = SMC_FAILURE;
- }
- }
- if (close_fd) {
- (void) close(fd);
- }
- return (rc);
-}
diff --git a/usr/src/cmd/picl/plugins/sun4u/snowbird/lib/libctsmc/smclib.h b/usr/src/cmd/picl/plugins/sun4u/snowbird/lib/libctsmc/smclib.h
deleted file mode 100644
index d950a8c293..0000000000
--- a/usr/src/cmd/picl/plugins/sun4u/snowbird/lib/libctsmc/smclib.h
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (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 2004 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#ifndef __SMCLIB_H__
-#define __SMCLIB_H__
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <sys/types.h>
-#include <smc_if.h>
-#include <smc_commands.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/*
- * SMC error codes
- */
-typedef enum {
- SMC_SUCCESS = 0x0,
- SMC_FAILURE = 0x1,
- SMC_REQ_FAILURE = 0x2,
- SMC_ACK_TIMEOUT = 0x3,
- SMC_ACK_FAILURE = 0x4,
- SMC_RSP_FAILURE = 0x5,
- SMC_RSP_TIMEOUT = 0x6,
- SMC_INVALID_SEQ = 0x7,
- SMC_RSP_ERROR = 0x8
-} smc_errno_t;
-
-extern smc_errno_t smc_init_smc_msg(sc_reqmsg_t *req_msg, smc_app_command_t cmd,
- uint8_t msg_id, uint8_t msg_data_size);
-
-extern smc_errno_t smc_init_ipmi_msg(sc_reqmsg_t *req_msg, uint8_t cmd,
- uint8_t msg_id, uint8_t msg_data_size, uint8_t *msg_data_buf,
- int8_t seq_num, int ipmb_addr, smc_netfn_t netfn, smc_lun_t lun);
-
-extern smc_errno_t smc_send_msg(int fd, sc_reqmsg_t *req_pkt,
- sc_rspmsg_t *rsp_pkt, int poll_time);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* __SMCLIB_H__ */
diff --git a/usr/src/cmd/picl/plugins/sun4u/snowbird/watchdog/Makefile b/usr/src/cmd/picl/plugins/sun4u/snowbird/watchdog/Makefile
deleted file mode 100644
index d24e64f171..0000000000
--- a/usr/src/cmd/picl/plugins/sun4u/snowbird/watchdog/Makefile
+++ /dev/null
@@ -1,102 +0,0 @@
-#
-# 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 2009 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-
-LIBRARY= libpiclwd.a
-VERS= .1
-
-OBJECTS= piclwatchdog.o piclwd_platmod.o
-
-# include library definitions
-include $(SRC)/lib/Makefile.lib
-include $(SRC)/Makefile.psm
-include $(SRC)/cmd/picl/plugins/Makefile.com
-
-SRCS= $(OBJECTS:%.o=%.c)
-
-LIBS = $(DYNLIB)
-
-ROOT_PLATFORM = $(USR_PLAT_DIR)/SUNW,Netra-CP2300
-
-CLEANFILES= $(LINTOUT) $(LINTLIB)
-
-ROOTLIBDIR = $(ROOT_PLAT_PLUGINDIR)
-
-CFLAGS += $(CCVERBOSE)
-CPPFLAGS += -I$(SRC)/uts/sun4u/sys -I$(SRC)/uts/common
-CPPFLAGS += -I$(SRC)/cmd/picl/plugins/sun4u/snowbird/lib/libctsmc
-CPPFLAGS += -I$(SRC)/uts/common
-
-LDLIBS += -R/usr/platform/SUNW,Netra-CP2300/lib/picl/plugins
-LDLIBS += -R/usr/platform/SUNW,Netra-CP2300/lib
-LDLIBS += -R/usr/platform/sun4u/lib
-LDLIBS += -L$(SRC)/lib/libpicl/$(MACH) -L$(SRC)/lib/libpicltree/$(MACH)
-LDLIBS += -L $(ROOT)/usr/platform/$(PLATFORM)/lib
-LDLIBS += -L$(ROOT_PLATFORM)/lib/picl/plugins
-LDLIBS += -L$(SRC)/cmd/picl/plugins/sun4u/snowbird/lib/libctsmc
-LDLIBS += -L$(ROOT)/usr/lib/picl/plugins -lnvpair -lpicltree
-LDLIBS += -ldevinfo -lctsmc -lpiclfrutree -lc
-
-.KEEP_STATE:
-
-SUBDIRS=
-
-POFILE= snowbird_piclwatchdog.po
-POFILES= $(SRCS:%.c=%.po)
-
-all := TARGET= all
-install := TARGET= install
-clean := TARGET= clean
-clobber := TARGET= clobber
-lint := TARGET= lint
-_msg := TARGET= _msg
-
-all: $(LIBS) $(LIBLINKS)
-
-install: $(ROOTLIBDIR) all $(ROOTLIBS) $(ROOTLINKS)
-
-$(LIBLINKS): FRC
- $(RM) $@; $(SYMLINK) $(DYNLIB) $@
-
-_msg: $(MSGDOMAIN) $(POFILE)
- $(RM) $(MSGDOMAIN)/$(POFILE)
- $(CP) $(POFILE) $(MSGDOMAIN)/$(POFILE)
-
-$(POFILE): $(POFILES)
- $(CAT) $(POFILES) > $(POFILE)
-
-$(MSGDOMAIN):
- $(INS.dir)
-
-# include library targets
-include $(SRC)/cmd/picl/plugins/Makefile.targ
-include $(SRC)/lib/Makefile.targ
-
-lint :
- $(LINT.c) $(SRCS)
-
-$(SUBDIRS): FRC
- @cd $@; pwd; $(MAKE) $(TARGET)
-
-FRC:
diff --git a/usr/src/cmd/picl/plugins/sun4u/snowbird/watchdog/piclwatchdog.c b/usr/src/cmd/picl/plugins/sun4u/snowbird/watchdog/piclwatchdog.c
deleted file mode 100644
index 00af353d0e..0000000000
--- a/usr/src/cmd/picl/plugins/sun4u/snowbird/watchdog/piclwatchdog.c
+++ /dev/null
@@ -1,1837 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (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 2004 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * This module is used to monitor and control watchdog timer for
- * UltraSPARC-IIi CPU in Snowbird
- */
-
-#include <stdio.h>
-#include <fcntl.h>
-#include <unistd.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <strings.h>
-#include <string.h>
-#include <ctype.h>
-#include <alloca.h>
-#include <limits.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <libintl.h>
-#include <syslog.h>
-#include <locale.h>
-#include <picl.h>
-#include <picltree.h>
-#include <libnvpair.h>
-#include <poll.h>
-#include <errno.h>
-#include <syslog.h>
-#include <sys/priocntl.h>
-#include <sys/rtpriocntl.h>
-#include <sys/tspriocntl.h>
-#include <sys/fsspriocntl.h>
-#include <stropts.h>
-#include <synch.h>
-#include <signal.h>
-#include <thread.h>
-#include <picldefs.h>
-#include <smclib.h>
-#include "piclwatchdog.h"
-
-#pragma init(wd_picl_register) /* init section */
-
-/* debug variables */
-static int wd_debug = 0;
-static hrtime_t start1, end1;
-static int count = 0;
-typedef struct { /* used to keep track of time taken for last 5 pats */
- int res_seq;
- int req_seq;
- int64_t time;
-} wd_time_t;
-
-#define NUMBER_OF_READINGS 5
-static wd_time_t time1[NUMBER_OF_READINGS];
-
-/* global declarations */
-static int wd_fd = -1; /* fd used to send watchdog commands */
-static int polling_fd = -1; /* polling thread that snoops for events */
-static int wd_enable = 1;
-static int state_configured = 0; /* chassis state */
-static int props_created = 0;
-static int wd_pat_thr_priority = -1;
-static pid_t pid = -1; /* PID that owns watchdog services */
-static cond_t patting_cv;
-static mutex_t data_lock;
-static mutex_t patting_lock;
-static int32_t pat_time = 0;
-static thread_t polling_thr_tid;
-static thread_t patting_thr_tid;
-static wd_data_t wd_data;
-static char wd_conf[MAXPATHLEN];
-
-#define NULLREAD (int (*)(ptree_rarg_t *, void *))0
-#define NULLWRITE (int (*)(ptree_warg_t *, const void *))0
-
-/* ptree interface */
-static void wd_picl_register(void);
-static void wd_picl_init(void);
-static void wd_picl_fini(void);
-static void wd_state_change_evhandler(const char *,
- const void *, size_t, void *);
-
-/* local functions */
-static int wd_write_timeout(ptree_warg_t *, const void *);
-static int wd_write_action(ptree_warg_t *, const void *);
-static int wd_read_action(ptree_rarg_t *, void *);
-static int wd_read_timeout(ptree_rarg_t *, void *);
-extern char *strtok_r(char *s1, const char *s2, char **lasts);
-extern int wd_get_chassis_type();
-
-static picld_plugin_reg_t wd_reg_info = {
- PICLD_PLUGIN_VERSION_1,
- PICLD_PLUGIN_CRITICAL,
- "SUNW_picl_watchdog",
- wd_picl_init,
- wd_picl_fini,
-};
-
-/*
- * This function parses wd.conf file to set the tunables
- * tunables at present: patting thread priority, pat time, wd_enable
- */
-static void
-wd_parse_config_file(char *wd_conf)
-{
- FILE *fp;
- char buf[WD_CONF_MAXSIZE];
- char *token, *last, *value;
-
- if ((fp = fopen(wd_conf, "r")) == NULL) {
- return;
- }
-
- while (fgets(buf, sizeof (buf), fp) != NULL) {
- if (buf[0] == '\0' || buf[0] == '#') {
- continue;
- }
- token = last = value = NULL;
- value = (char *)strtok_r((char *)buf, WD_DELIMETER, &last);
- if (last) {
- token = (char *)strtok_r(last, WD_DELIMETER, &last);
- } else {
- continue;
- }
-
- if (value == NULL || token == NULL) {
- continue;
- }
- if (strcmp(token, WD_PAT_THREAD_PRIORITY) == 0) {
- wd_pat_thr_priority = strtol(value,
- (char **)NULL, 10);
- } else if (strcmp(token, WD_PATTING_TIME) == 0) {
- errno = 0;
- pat_time = strtol(value, (char **)NULL, 10);
- if (errno != 0) {
- pat_time = 0;
- }
- } else if (strcmp(token, WD_ENABLE) == 0) {
- if (strcmp(value, "false") == 0) {
- wd_enable = 0;
- }
- } else { /* unknown token */
- continue;
- }
- }
- (void) fclose(fp);
-}
-
-/*
- * read the SMC watchdog registers
- */
-static int
-wd_get_reg_dump(uint8_t buffer[])
-{
- int rc = 0, i;
- sc_reqmsg_t req_pkt;
- sc_rspmsg_t rsp_pkt;
-
- /* initialize the request packet */
- (void) smc_init_smc_msg(&req_pkt, SMC_GET_WATCHDOG_TIMER,
- DEFAULT_SEQN, 0);
-
- /* make a call to smc library to send cmd */
- if ((rc = smc_send_msg(DEFAULT_FD, &req_pkt, &rsp_pkt,
- WD_POLL_TIMEOUT)) != SMC_SUCCESS) {
- WD_DEBUG1(WD_PICL_GET_ERR, rc);
- return (PICL_FAILURE);
- }
-
- /* read 8 bytes */
- bzero(buffer, WD_REGISTER_LEN);
- for (i = 0; i < WD_REGISTER_LEN; i++) {
- buffer[i] = rsp_pkt.data[i];
- }
- return (PICL_SUCCESS);
-}
-
-/*
- * get the HEALTHY# line state
- * Return -1 for Error
- * 0 for HEALTHY# down
- * 1 for HEALTHY# up
- */
-static int
-wd_get_healthy_status()
-{
- sc_reqmsg_t req_pkt;
- sc_rspmsg_t rsp_pkt;
-
- /* initialize the request packet */
- (void) smc_init_smc_msg(&req_pkt, SMC_GET_EXECUTION_STATE,
- DEFAULT_SEQN, 0);
-
- /* make a call to smc library to send cmd */
- if (smc_send_msg(DEFAULT_FD, &req_pkt, &rsp_pkt,
- WD_POLL_TIMEOUT) != SMC_SUCCESS) {
- return (-1);
- }
-
- return ((rsp_pkt.data[0] & IS_HEALTHY) ? WD_HEALTHY_UP :
- WD_HEALTHY_DOWN);
-}
-
-/*ARGSUSED*/
-static void
-event_completion_handler(char *ename, void *earg, size_t size)
-{
- free(ename);
- free(earg);
-}
-
-/*
- * posts picl-state-change event if there is change in watchdog-timer state
- */
-static picl_errno_t
-post_wd_state_event(picl_nodehdl_t nodeh, char *state)
-{
- nvlist_t *nvl;
- size_t nvl_size;
- char *pack_buf = NULL;
- picl_errno_t rc;
- char *ename = PICLEVENT_STATE_CHANGE, *evname = NULL;
-
- if (state == NULL) {
- return (PICL_FAILURE);
- }
-
- if ((evname = strdup(ename)) == NULL) {
- return (PICL_NOSPACE);
- }
-
- if ((rc = nvlist_alloc(&nvl, NV_UNIQUE_NAME_TYPE, NULL)) != 0) {
- free(evname);
- syslog(LOG_ERR, WD_NVLIST_ERR, rc);
- return (PICL_FAILURE);
- }
-
- if ((rc = nvlist_add_uint64(nvl, PICLEVENTARG_NODEHANDLE,
- nodeh)) != 0) {
- nvlist_free(nvl);
- free(evname);
- syslog(LOG_ERR, WD_NVLIST_ERR, rc);
- return (PICL_FAILURE);
- }
-
- if ((rc = nvlist_add_string(nvl, PICLEVENTARG_STATE,
- state)) != 0) {
- nvlist_free(nvl);
- free(evname);
- syslog(LOG_ERR, WD_NVLIST_ERR, rc);
- return (PICL_FAILURE);
- }
-
- if ((rc = nvlist_pack(nvl, &pack_buf, &nvl_size, NV_ENCODE_NATIVE,
- NULL)) != 0) {
- nvlist_free(nvl);
- free(evname);
- syslog(LOG_ERR, WD_NVLIST_ERR, rc);
- return (PICL_FAILURE);
- }
-
- if ((rc = ptree_post_event(evname, pack_buf, nvl_size,
- event_completion_handler)) != PICL_SUCCESS) {
- free(pack_buf);
- free(evname);
- nvlist_free(nvl);
- return (rc);
- }
- nvlist_free(nvl);
- return (PICL_SUCCESS);
-}
-
-/*
- * Updates the State value in picl tree and posts a state-change event
- */
-static void
-wd_picl_update_state(int level, uint8_t stat)
-{
- picl_errno_t rc;
- char state[PICL_PROPNAMELEN_MAX];
-
- switch (stat) {
- case WD_ARMED:
- (void) strncpy(state, PICL_PROPVAL_WD_STATE_ARMED,
- sizeof (state));
- break;
- case WD_DISARMED:
- (void) strncpy(state, PICL_PROPVAL_WD_STATE_DISARMED,
- sizeof (state));
- break;
- case WD_EXPIRED:
- (void) strncpy(state, PICL_PROPVAL_WD_STATE_EXPIRED,
- sizeof (state));
- break;
- default:
- return;
- }
-
- (void) mutex_lock(&data_lock);
- switch (level) {
- case WD1:
- wd_data.wd1_run_state = stat;
- break;
- case WD2:
- wd_data.wd2_run_state = stat;
- break;
- case WD1_2:
- wd_data.wd1_run_state = stat;
- wd_data.wd2_run_state = stat;
- break;
- default:
- return;
- }
- (void) mutex_unlock(&data_lock);
-
- if (!state_configured) {
- return;
- }
-
- switch (level) {
- case WD1:
- if ((rc = post_wd_state_event(wd_data.wd1_nodehdl,
- state)) != PICL_SUCCESS) {
- syslog(LOG_ERR, WD_PICL_POST_EVENT_ERR, rc);
- }
- break;
- case WD2:
- if ((rc = post_wd_state_event(wd_data.wd2_nodehdl,
- state)) != PICL_SUCCESS) {
- syslog(LOG_ERR, WD_PICL_POST_EVENT_ERR, rc);
- }
- break;
-
- case WD1_2:
- if ((rc = post_wd_state_event(wd_data.wd1_nodehdl,
- state)) != PICL_SUCCESS) {
- syslog(LOG_ERR, WD_PICL_POST_EVENT_ERR, rc);
- }
- if ((rc = post_wd_state_event(wd_data.wd2_nodehdl,
- state)) != PICL_SUCCESS) {
- syslog(LOG_ERR, WD_PICL_POST_EVENT_ERR, rc);
- }
- break;
- }
-}
-
-/*
- * Sends a command to SMC to reset the watchdog-timers
- */
-static int
-wd_pat()
-{
- int rc = 0;
- static uint8_t seq = 1;
- sc_reqmsg_t req_pkt;
- sc_rspmsg_t rsp_pkt;
-
- if (seq < WD_MAX_SEQN) {
- req_pkt.hdr.msg_id = seq++;
- } else {
- seq = 1;
- req_pkt.hdr.msg_id = seq;
- }
-
- if (wd_debug & WD_TIME_DEBUG) {
- start1 = gethrtime();
- }
-
- /* initialize the request packet */
- (void) smc_init_smc_msg(&req_pkt, SMC_RESET_WATCHDOG_TIMER,
- DEFAULT_SEQN, 0);
-
- /* make a call to smc library to send cmd */
- if ((rc = smc_send_msg(wd_fd, &req_pkt, &rsp_pkt,
- WD_POLL_TIMEOUT)) != SMC_SUCCESS) {
- syslog(LOG_CRIT, WD_PICL_PAT_ERR, rc);
- return (PICL_FAILURE);
- }
-
- if (wd_debug & WD_TIME_DEBUG) {
- end1 = gethrtime();
- time1[count].res_seq = SC_MSG_ID(&rsp_pkt);
- time1[count].req_seq = SC_MSG_ID(&req_pkt);
- time1[count].time = (end1 - start1);
-
- if (count < (NUMBER_OF_READINGS - 1)) {
- count++;
- } else {
- count = 0;
- }
- }
- return (PICL_SUCCESS);
-}
-
-/* used to set the new values for watchdog and start the watchdog */
-static int
-wd_start(uchar_t action_1, uchar_t action_2,
- uchar_t timeout_2, uchar_t *timeout_1, uint8_t patting_option)
-{
- int rc = 0;
- sc_reqmsg_t req_pkt;
- sc_rspmsg_t rsp_pkt;
-
- if (timeout_1 == NULL) {
- return (PICL_FAILURE);
- }
-
- req_pkt.data[0] = WD_USEFLAG_OS;
- req_pkt.data[1] = action_1 | action_2; /* actions */
- req_pkt.data[2] = timeout_2; /* wd timeout 2 */
- req_pkt.data[3] = WD_XPR_FLG_CLR_OS; /* expiration flags */
- req_pkt.data[4] = timeout_1[1]; /* LSB for wd timeout 1 */
- req_pkt.data[5] = timeout_1[0]; /* MSB for wd timeout 1 */
-
- if (patting_option == ENABLE_AUTO_PAT) {
- req_pkt.data[0] |= WD_ENABLE_AUTO_PAT;
- }
-
- /* initialize the request packet */
- (void) smc_init_smc_msg(&req_pkt, SMC_SET_WATCHDOG_TIMER,
- DEFAULT_SEQN, WD_SET_CMD_DATA_LEN);
-
- /* make a call to smc library to send cmd */
- if ((rc = smc_send_msg(wd_fd, &req_pkt, &rsp_pkt,
- WD_POLL_TIMEOUT)) != SMC_SUCCESS) {
- WD_DEBUG1(WD_PICL_START_ERR, rc);
- return (PICL_FAILURE);
- }
-
- /* reset the watchdog timer */
- (void) smc_init_smc_msg(&req_pkt, SMC_RESET_WATCHDOG_TIMER,
- DEFAULT_SEQN, 0);
- if ((rc = smc_send_msg(wd_fd, &req_pkt, &rsp_pkt,
- WD_POLL_TIMEOUT)) != SMC_SUCCESS) {
- WD_DEBUG1(WD_PICL_START_ERR, rc);
- return (PICL_FAILURE);
- }
- return (PICL_SUCCESS);
-}
-
-/*
- * Validates timeout and action fields and arms the watchdog-timers
- */
-static int
-wd_arm(uint8_t patting_option)
-{
- int rc;
- uint16_t wd_time1;
- uint8_t wd_time2, wd1_action, wd2_action;
- uint8_t timeout1[2];
-
- if (wd_data.wd1_timeout >= 0) {
- wd_time1 = wd_data.wd1_timeout/WD_L1_RESOLUTION;
- } else {
- wd_time1 = 0;
- }
-
- if (wd_data.wd2_timeout >= 0) {
- wd_time2 = wd_data.wd2_timeout/WD_L2_RESOLUTION;
- } else {
- wd_time2 = 0;
- }
-
- timeout1[0] = wd_time1 >> 8; /* MSB */
- timeout1[1] = wd_time1 & 0x00ff; /* LSB */
-
- /* check the HELATHY# status if action is alarm */
- if (wd_data.wd1_action == WD_ACTION_HEALTHY_DOWN_HOST ||
- wd_data.wd1_action == WD_ACTION_HEALTHY_DOWN_SAT) {
- rc = wd_get_healthy_status();
- if (rc == WD_HEALTHY_DOWN) {
- WD_DEBUG0(WD_HEALTHY_ERR);
- return (PICL_FAILURE);
- } else if (rc == -1) {
- syslog(LOG_ERR, WD_GET_HEALTH_ERR);
- return (PICL_FAILURE);
- }
- }
-
- if (wd_data.wd1_timeout == -1) {
- wd1_action = WD_ACTION_NONE2;
- } else {
- wd1_action = wd_data.wd1_action;
- }
-
- if (wd_data.wd2_timeout == -1) {
- wd2_action = WD_ACTION_NONE2;
- } else {
- wd2_action = wd_data.wd2_action;
- }
-
- rc = wd_start(wd1_action, wd2_action,
- wd_time2, timeout1, patting_option);
- return (rc);
-}
-
-/*
- * This is thread is a RealTime class thread. This thread pats the
- * watchdog-timers in regular intervals before the expiry.
- */
-/*ARGSUSED*/
-static void *
-wd_patting_thread(void *args)
-{
- time_t sec;
- pcinfo_t pci;
- long nano_sec;
- timestruc_t to;
- long sleep_time;
- struct timeval tp;
- int err, state;
-
- for (;;) {
- (void) mutex_lock(&patting_lock);
- while (wd_data.wd_pat_state == WD_NORESET) {
- (void) cond_wait(&patting_cv, &patting_lock);
- }
- (void) mutex_unlock(&patting_lock);
-
- /* reset pat-time to zero */
- pat_time = 0; /* tunable */
- wd_parse_config_file(wd_conf);
-
- if (wd_pat_thr_priority < 0 || wd_pat_thr_priority > 59) {
- wd_pat_thr_priority = WD_DEFAULT_THREAD_PRIORITY;
- }
-
- /* change the priority of thread to realtime class */
- (void) strncpy(pci.pc_clname, "RT", sizeof (pci.pc_clname));
- if (priocntl(P_LWPID, P_MYID, PC_GETCID, (caddr_t)&pci) != -1) {
- pcparms_t pcp;
- rtparms_t *rtp = (rtparms_t *)pcp.pc_clparms;
- rtp->rt_pri = wd_pat_thr_priority;
- rtp->rt_tqsecs = 0;
- rtp->rt_tqnsecs = RT_TQDEF;
- pcp.pc_cid = pci.pc_cid;
- if (priocntl(P_LWPID, P_MYID, PC_SETPARMS,
- (caddr_t)&pcp) != 0) {
- syslog(LOG_ERR, WD_PICL_RT_THRD_FAIL);
- }
- } else {
- syslog(LOG_ERR, WD_PICL_RT_THRD_NO_PERM_ERR);
- }
-
- switch (wd_data.wd1_timeout) {
- case 0:
- if (wd_arm(DISABLE_AUTO_PAT) == PICL_SUCCESS) {
- wd_picl_update_state(WD1, WD_ARMED);
- if (wd_data.wd2_timeout >= 0) {
- wd_picl_update_state(WD2, WD_ARMED);
- }
- } else {
- syslog(LOG_ERR, WD_PICL_START_ERR,
- PICL_FAILURE);
- }
- /* no need to pat */
- (void) mutex_lock(&patting_lock);
- wd_data.wd_pat_state = WD_NORESET;
- (void) mutex_unlock(&patting_lock);
- continue;
- case -1:
- if (wd_data.wd2_timeout < 0) {
- (void) mutex_lock(&patting_lock);
- wd_data.wd_pat_state = WD_NORESET;
- (void) mutex_unlock(&patting_lock);
- continue;
- }
- if (wd_arm(DISABLE_AUTO_PAT) == PICL_SUCCESS) {
- wd_picl_update_state(WD2, WD_ARMED);
- } else {
- syslog(LOG_ERR, WD_PICL_START_ERR,
- PICL_FAILURE);
- }
- /* no need to pat */
- (void) mutex_lock(&patting_lock);
- wd_data.wd_pat_state = WD_NORESET;
- (void) mutex_unlock(&patting_lock);
- continue;
- default:
- break;
- }
-
- if (pat_time == 0) {
- if (wd_data.wd1_timeout > WD_PAT_TIME) {
- pat_time = WD_PAT_TIME;
- } else {
- pat_time = wd_data.wd1_timeout - 80;
- }
- }
- if (pat_time <= 0) {
- WD_DEBUG0(WD_PICL_PAT_TIME_ERR);
- (void) mutex_lock(&patting_lock);
- wd_data.wd_pat_state = WD_NORESET;
- (void) mutex_unlock(&patting_lock);
- continue;
- }
- sleep_time = wd_data.wd1_timeout - pat_time;
-
- if (wd_data.wd1_timeout <= 0 || sleep_time <= 0) {
- WD_DEBUG0(WD_PICL_ARM_PAT_ERR);
- (void) mutex_lock(&patting_lock);
- wd_data.wd_pat_state = WD_NORESET;
- (void) mutex_unlock(&patting_lock);
- continue;
- } else {
- wd_picl_update_state(WD1, WD_ARMED);
- }
-
- if (wd_data.wd2_timeout >= 0) {
- wd_picl_update_state(WD2, WD_ARMED);
- }
-
- sec = sleep_time/1000;
- nano_sec = (sleep_time - (sec * 1000)) * 1000000;
-
- if (wd_arm(ENABLE_AUTO_PAT) != PICL_SUCCESS) {
- wd_picl_update_state(WD1_2, WD_DISARMED);
- (void) mutex_lock(&patting_lock);
- wd_data.wd_pat_state = WD_NORESET;
- (void) mutex_unlock(&patting_lock);
- syslog(LOG_ERR, WD_PICL_START_ERR, PICL_FAILURE);
- continue;
- }
-
- do /* pat the watchdog until expiry or user disarm */
- {
- (void) mutex_lock(&patting_lock);
- state = wd_data.wd_pat_state;
- if (state == WD_NORESET) {
- (void) mutex_unlock(&patting_lock);
- break;
- }
- (void) gettimeofday(&tp, NULL);
- to.tv_sec = tp.tv_sec + sec;
- if ((nano_sec + (tp.tv_usec * 1000)) >= 1000000000) {
- to.tv_sec += 1;
- to.tv_nsec = (nano_sec +
- (tp.tv_usec * 1000)) - 1000000000;
- } else {
- to.tv_nsec = nano_sec + (tp.tv_usec * 1000);
- }
-
- err = cond_timedwait(&patting_cv, &patting_lock, &to);
- (void) mutex_unlock(&patting_lock);
-
- if (err == ETIME) { /* woke up from sleep */
- (void) wd_pat();
- }
- } while (state == WD_RESET);
- }
- /*NOTREACHED*/
- return (NULL);
-}
-
-/*
- * returns 0 if owner is not alive
- * returns 1 if owner is alive
- * returns -1 if there is no active owner
- */
-static int
-is_owner_alive()
-{
- char strpid[50];
- struct stat buf;
-
- if (pid == -1) {
- return (-1);
- }
-
- /* check if the file exists or not */
- (void) snprintf(strpid, sizeof (pid), "/proc/%ld/status", pid);
- errno = 0;
- if (stat(strpid, &buf) == 0) {
- return (1);
- }
- if (errno == ENOENT) {
- return (0);
- } else {
- syslog(LOG_ERR, WD_GET_OWN_FAILED, errno);
- }
- return (-1);
-}
-
-/*
- * Sends a cmd to SMC to stop watchdog timers
- */
-static int
-wd_stop()
-{
- int rc = 0;
- sc_reqmsg_t req_pkt;
- sc_rspmsg_t rsp_pkt;
- uint8_t buffer[8];
-
- if (wd_get_reg_dump(buffer) != 0) {
- return (PICL_FAILURE);
- }
- /* clear the expiration flags */
- buffer[3] = 0xff; /* expiration flags */
-
- (void) memcpy(SC_MSG_DATA(&req_pkt), buffer,
- WD_SET_CMD_DATA_LEN);
-
- /* initialize the request packet */
- (void) smc_init_smc_msg(&req_pkt, SMC_SET_WATCHDOG_TIMER,
- DEFAULT_SEQN, WD_SET_CMD_DATA_LEN);
-
- /* make a call to smc library to send cmd */
- if ((rc = smc_send_msg(wd_fd, &req_pkt, &rsp_pkt,
- WD_POLL_TIMEOUT)) != SMC_SUCCESS) {
- syslog(LOG_ERR, WD_PICL_STOP_ERR, rc);
- return (PICL_FAILURE);
- }
- return (PICL_SUCCESS);
-}
-
-/*
- * Function used by volatile callback function for wd-op property
- * under controller. This is used to arm, disarm the watchdog-timers
- * in response to user actions
- */
-static int
-wd_worker_function(uint8_t flag, pid_t proc_id)
-{
- int rc = PICL_SUCCESS;
- int wd1_state, wd2_state;
-
- (void) mutex_lock(&data_lock);
- wd1_state = wd_data.wd1_run_state;
- wd2_state = wd_data.wd2_run_state;
- (void) mutex_unlock(&data_lock);
-
- switch (flag) {
-
- case USER_ARMED_WD:
-
- /* watchdog can only be armed if all the timers are disarmed */
- if (wd1_state != WD_DISARMED) {
- WD_DEBUG0(WD_PICL_WD1_RUNNING_ERR);
- rc = PICL_FAILURE;
- break;
- }
- if (wd2_state != WD_DISARMED) {
- WD_DEBUG0(WD_PICL_WD2_RUNNING_ERR);
- rc = PICL_FAILURE;
- break;
- }
-
- /* check the HELATHY# status if action is alarm */
- if (wd_data.wd1_timeout >= 0) {
- if (wd_data.wd1_action == WD_ACTION_HEALTHY_DOWN_HOST ||
- wd_data.wd1_action == WD_ACTION_HEALTHY_DOWN_SAT) {
- rc = wd_get_healthy_status();
- if (rc == WD_HEALTHY_DOWN) {
- WD_DEBUG0(WD_HEALTHY_ERR);
- return (PICL_FAILURE);
- } else if (rc == -1) {
- syslog(LOG_ERR, WD_GET_HEALTH_ERR);
- return (PICL_FAILURE);
- } else {
- rc = PICL_SUCCESS;
- }
- }
- }
-
- /* signal the patting thread */
- (void) mutex_lock(&patting_lock);
- wd_data.wd_pat_state = WD_RESET;
- (void) cond_signal(&patting_cv);
- (void) mutex_unlock(&patting_lock);
- break;
-
- case USER_DISARMED_WD:
-
- /*
- * if the caller doesnot own watchdog services,
- * check to see if the owner is still alive using procfs
- */
- if (proc_id != pid) {
- switch (is_owner_alive()) {
- case -1:
- if ((wd1_state != WD_DISARMED) ||
- (wd2_state != WD_DISARMED)) {
- break;
- }
- /* watchdog is already disarmed */
- WD_DEBUG0(WD_PICL_NO_WD_ERR);
- return (PICL_FAILURE);
- case 1:
- /* owner is still alive, deny the operation */
- WD_DEBUG0(WD_PICL_PERM_DENIED);
- return (PICL_PERMDENIED);
- default:
- break;
- }
- }
-
- /* watchdog is running */
- if ((rc = wd_stop()) == PICL_SUCCESS) {
- wd_picl_update_state(WD1_2, WD_DISARMED);
- (void) mutex_lock(&patting_lock);
- wd_data.wd_pat_state = WD_NORESET;
- (void) cond_signal(&patting_cv);
- (void) mutex_unlock(&patting_lock);
- }
- break;
-
- case USER_ARMED_PAT_WD: /* for debug purposes only */
-
- /*
- * first arm-pat operation is used for arming the watchdog
- * subsequent arm-pat operations will be used for patting
- * the watchdog
- */
- /* WD is stopped */
- if (wd1_state == WD_DISARMED && wd2_state == WD_DISARMED) {
- if ((rc = wd_arm(DISABLE_AUTO_PAT)) == PICL_SUCCESS) {
- if (wd_data.wd1_timeout >= 0) {
- wd_picl_update_state(WD1, WD_ARMED);
- }
-
- if (wd_data.wd2_timeout >= 0) {
- wd_picl_update_state(WD2, WD_ARMED);
- }
- } else {
- return (rc);
- }
- } else { /* WD is running */
- if (wd1_state != WD_ARMED) {
- WD_DEBUG0(WD_PICL_NO_WD_ERR);
- return (PICL_INVALIDARG);
- }
-
- /* check if OS is patting the watchdog or not */
- (void) mutex_lock(&patting_lock);
- if (wd_data.wd_pat_state == WD_RESET) {
- WD_DEBUG0(WD_PICL_TRY_PAT_ERR);
- (void) mutex_unlock(&patting_lock);
- return (PICL_INVALIDARG);
- }
-
- /* check if the process owns the WD services */
- if (proc_id != pid) {
- WD_DEBUG0(WD_PICL_PERM_DENIED);
- return (PICL_PERMDENIED);
- }
- rc = wd_pat();
- }
- break;
-
- default:
- rc = PICL_INVALIDARG;
- break;
-
- } /* switch */
-
- return (rc);
-}
-
-/*ARGSUSED*/
-static int
-wd_write_op(ptree_warg_t *parg, const void *buf)
-{
- int rc = PICL_INVALIDARG;
- uint8_t flag;
-
- /* only after state is configured */
- if (!state_configured) {
- if (parg->cred.dc_pid != getpid()) {
- WD_DEBUG0(WD_PICL_STATE_INVALID);
- return (PICL_PERMDENIED);
- }
- }
-
- /* only super user can write this property */
- if (parg->cred.dc_euid != SUPER_USER) {
- WD_DEBUG0(WD_NO_ROOT_PERM);
- return (PICL_PERMDENIED);
- }
-
- if (strcmp((char *)buf, PICL_PROPVAL_WD_OP_ARM) == 0) {
- flag = USER_ARMED_WD;
- rc = PICL_SUCCESS;
- }
-
- if (strcmp((char *)buf, PICL_PROPVAL_WD_OP_DISARM) == 0) {
- flag = USER_DISARMED_WD;
- rc = PICL_SUCCESS;
- }
-
- /* for debug purpose only */
- if (strcmp((char *)buf, WD_ARM_PAT) == 0) {
- flag = USER_ARMED_PAT_WD;
- rc = PICL_SUCCESS;
- }
-
- if (rc == PICL_SUCCESS) {
- rc = wd_worker_function(flag, parg->cred.dc_pid);
- } else {
- rc = PICL_INVALIDARG;
- }
-
- if (rc == PICL_SUCCESS) {
-
- switch (flag) {
- case USER_ARMED_PAT_WD:
- case USER_ARMED_WD:
-
- /* get the process id of client */
- if (parg->cred.dc_pid != getpid()) {
- pid = parg->cred.dc_pid;
- } else {
- pid = -1;
- }
- break;
- case USER_DISARMED_WD:
- /* reset the pid */
- pid = -1;
- default:
- break;
- }
- }
- return (rc);
-}
-
-/* volatile call back function to read the watchdog L1 status */
-/*ARGSUSED*/
-static int
-wd1_read_status(ptree_rarg_t *parg, void *buf)
-{
- int rc = PICL_SUCCESS;
-
- (void) mutex_lock(&data_lock);
-
- switch (wd_data.wd1_run_state) {
-
- case WD_EXPIRED:
- (void) strncpy((char *)buf, PICL_PROPVAL_WD_STATE_EXPIRED,
- PICL_PROPNAMELEN_MAX);
- break;
-
- case WD_DISARMED:
- (void) strncpy((char *)buf, PICL_PROPVAL_WD_STATE_DISARMED,
- PICL_PROPNAMELEN_MAX);
- break;
-
- case WD_ARMED:
- (void) strncpy((char *)buf, PICL_PROPVAL_WD_STATE_ARMED,
- PICL_PROPNAMELEN_MAX);
- break;
-
- default:
- rc = PICL_FAILURE;
- }
- (void) mutex_unlock(&data_lock);
- return (rc);
-}
-
-/*
- * this function is used to read the state of L2 timer
- */
-static int
-wd_get_wd2_status(int *present_status)
-{
- int rc;
- uchar_t buffer[WD_REGISTER_LEN];
-
- bzero(buffer, WD_REGISTER_LEN);
- (void) mutex_lock(&data_lock);
- *present_status = wd_data.wd2_run_state;
- if (wd_data.wd2_run_state != WD_ARMED) {
- /* we already have the latest state */
- (void) mutex_unlock(&data_lock);
- return (PICL_SUCCESS);
- }
- (void) mutex_unlock(&data_lock);
-
- /* read watchdog registers */
- if ((rc = wd_get_reg_dump(buffer)) != 0) {
- return (rc);
- }
-
- if (buffer[0] & WD_WD_RUNNING) {
- *present_status = WD_ARMED;
- return (PICL_SUCCESS);
- }
-
- if (buffer[3] != 0) {
- (void) mutex_lock(&data_lock);
- *present_status = wd_data.wd2_run_state = WD_EXPIRED;
- (void) mutex_unlock(&data_lock);
- }
- return (PICL_SUCCESS);
-}
-
-/* volatile call back function to read the watchdog L2 status */
-/*ARGSUSED*/
-static int
-wd2_read_status(ptree_rarg_t *parg, void *buf)
-{
- int present_status, rc;
-
- if ((rc = wd_get_wd2_status(&present_status)) !=
- PICL_SUCCESS) {
- return (rc);
- }
-
- /* copy the present state in user buffer */
- switch (present_status) {
- case WD_ARMED:
- (void) strncpy((char *)buf, PICL_PROPVAL_WD_STATE_ARMED,
- PICL_PROPNAMELEN_MAX);
- break;
- case WD_EXPIRED:
- (void) strncpy((char *)buf, PICL_PROPVAL_WD_STATE_EXPIRED,
- PICL_PROPNAMELEN_MAX);
- break;
- case WD_DISARMED:
- (void) strncpy((char *)buf, PICL_PROPVAL_WD_STATE_DISARMED,
- PICL_PROPNAMELEN_MAX);
- break;
- }
- return (PICL_SUCCESS);
-}
-
-/* this thread listens for watchdog expiry events */
-/*ARGSUSED*/
-static void *
-wd_polling(void *args)
-{
- uint8_t stat;
- int poll_retval;
- struct pollfd fds;
- sc_rspmsg_t rsp_pkt;
- int i;
-
- fds.fd = polling_fd;
- fds.events = POLLIN | POLLPRI;
- fds.revents = 0;
-
- for (;;) {
- poll_retval = poll(&fds, 1, -1);
- if (props_created == 0)
- continue;
- switch (poll_retval) {
- case 0:
- break;
-
- case -1:
- syslog(LOG_ERR, WD_PICL_POLL_ERR);
- break;
-
- default:
- /* something happened */
- if ((read(polling_fd, &rsp_pkt,
- sizeof (sc_rspmsg_t))) < 0) {
- syslog(LOG_ERR, WD_PICL_SMC_READ_ERR);
- break;
- }
-
- if (rsp_pkt.hdr.cmd == SMC_EXPIRED_WATCHDOG_NOTIF) {
-
- (void) mutex_lock(&data_lock);
- stat = wd_data.wd1_run_state;
- (void) mutex_unlock(&data_lock);
-
- if (stat != WD_ARMED) {
- continue;
- }
-
- wd_picl_update_state(WD1, WD_EXPIRED);
-
- (void) mutex_lock(&patting_lock);
- wd_data.wd_pat_state = WD_NORESET;
- (void) cond_signal(&patting_cv);
-
- (void) mutex_unlock(&patting_lock);
- syslog(LOG_WARNING, WD_WD1_EXPIRED);
- if (wd_debug & WD_TIME_DEBUG) {
- syslog(LOG_ERR, " latest count : %d", count);
- for (i = 0; i < NUMBER_OF_READINGS; i++) {
- syslog(LOG_ERR, "i = %d, req_seq = %d,"
- "res_seq = %d, time = %lld nsec",
- i, time1[i].req_seq,
- time1[i].res_seq,
- time1[i].time);
- }
- }
- if (wd_data.reboot_action) {
- wd_data.reboot_action = 0;
- (void) system(SHUTDOWN_CMD);
- }
- }
- break;
-
- } /* switch */
- }
- /*NOTREACHED*/
- return (NULL);
-}
-
-/*
- * This function reads the hardware state and gets the status of
- * watchdog-timers
- */
-static int
-wd_get_status(wd_state_t *state)
-{
- picl_errno_t rc;
- uchar_t buffer[WD_REGISTER_LEN];
-
- bzero(buffer, WD_REGISTER_LEN);
- /* read watchdog registers */
- if ((rc = wd_get_reg_dump(buffer)) != 0) {
- return (rc);
- }
-
- /* get action */
- state->action1 = buffer[1] & 0xF0; /* most significant 4 bits */
- if (state->action1 == 0x0) {
- state->action1 = WD_ACTION_NONE1;
- }
- state->action2 = buffer[1] & 0x0F; /* least significant 4 bits */
- if (state->action2 == 0x0) {
- state->action2 = WD_ACTION_NONE2;
- }
-
- state->timeout2 = buffer[2];
- state->timeout1[0] = buffer[5]; /* MSB */
- state->timeout1[1] = buffer[4]; /* LSB */
-
- state->present_t1[0] = buffer[7]; /* MSB */
- state->present_t1[1] = buffer[6]; /* LSB */
-
- if (buffer[0] & WD_WD_RUNNING) {
- state->present_state = WD_ARMED;
- return (PICL_SUCCESS);
- }
-
- if (buffer[3] != 0) {
- state->present_state = WD_EXPIRED;
- return (PICL_SUCCESS);
- } else {
- state->present_state = WD_DISARMED;
- return (PICL_SUCCESS);
- }
-}
-
-/* read the smc hardware and intialize the internal state */
-static void
-wd_set_init_state()
-{
- wd_state_t state;
- uint16_t tmp1, tmp2, wd_time1;
-
- if (wd_get_status(&state) != PICL_SUCCESS) {
- syslog(LOG_ERR, WD_PICL_GET_STAT_ERR);
- /* defualt state is expired ??? */
- state.present_state = WD_EXPIRED;
- }
-
- switch (state.present_state) {
- case WD_EXPIRED:
- case WD_DISARMED:
- if (state.present_state == WD_EXPIRED)
- wd_picl_update_state(WD1_2, WD_EXPIRED);
- else
- wd_picl_update_state(WD1_2, WD_DISARMED);
- wd_data.wd_pat_state = WD_NORESET;
- wd_data.wd1_action = state.action1;
- wd_data.wd2_action = state.action2;
- tmp1 = state.timeout1[0] << 8;
- tmp2 = state.timeout1[1];
- wd_time1 = tmp1 | tmp2;
- wd_data.wd1_timeout = wd_time1 * WD_L1_RESOLUTION;
- wd_data.wd2_timeout = state.timeout2 * WD_L2_RESOLUTION;
- break;
- case WD_ARMED:
- /*
- * get the present values and restart the
- * watchdog from os level and continue to pat
- */
- wd_picl_update_state(WD1_2, WD_ARMED);
- wd_data.wd_pat_state = WD_RESET;
- wd_data.wd1_action = (state.action1 << 4);
- wd_data.wd2_action = state.action2;
-
- tmp1 = state.timeout1[0] << 8;
- tmp2 = state.timeout1[1];
- wd_time1 = tmp1 | tmp2;
- wd_data.wd1_timeout = wd_time1 * WD_L1_RESOLUTION;
- wd_data.wd2_timeout = state.timeout2 * WD_L2_RESOLUTION;
- (void) wd_stop();
- }
-}
-
-/*
- * wrapper for ptree interface to create property
- */
-static int
-wd_create_property(
- int ptype, /* PICL property type */
- int pmode, /* PICL access mode */
- size_t psize, /* size of PICL property */
- char *pname, /* property name */
- int (*readfn)(ptree_rarg_t *, void *),
- int (*writefn)(ptree_warg_t *, const void *),
- picl_nodehdl_t nodeh, /* node for property */
- picl_prophdl_t *propp, /* pointer to prop_handle */
- void *vbuf) /* initial value */
-{
- picl_errno_t rc;
- ptree_propinfo_t propinfo;
-
- rc = ptree_init_propinfo(&propinfo, PTREE_PROPINFO_VERSION,
- ptype, pmode, psize, pname, readfn, writefn);
- if (rc != PICL_SUCCESS) {
- syslog(LOG_ERR, WD_PICL_PROP_INIT_ERR, rc);
- return (rc);
- }
-
- rc = ptree_create_and_add_prop(nodeh, &propinfo, vbuf, propp);
- if (rc != PICL_SUCCESS) {
- return (rc);
- }
-
- return (PICL_SUCCESS);
-}
-
-/* Create and add Watchdog properties */
-static void
-wd_create_add_props()
-{
- int rc;
- picl_nodehdl_t rooth, sysmgmt_h, platformh;
- int32_t timeout1 = 0;
- int32_t timeout2 = 0;
- char buf[PICL_WD_PROPVAL_MAX];
-
- /* get picl root node handle */
- if ((rc = ptree_get_root(&rooth)) != PICL_SUCCESS) {
- syslog(LOG_ERR, WD_NODE_INIT_ERR, 1, rc);
- return;
- }
-
- /* get picl platform node handle */
- if ((rc = ptree_get_node_by_path(PLATFORM_PATH,
- &platformh)) != PICL_SUCCESS) {
- syslog(LOG_ERR, WD_NODE_INIT_ERR, 2, rc);
- return;
- }
-
- /* get the picl sysmgmt node handle */
- if ((rc = ptree_find_node(platformh, PICL_PROP_NAME,
- PICL_PTYPE_CHARSTRING,
- PICL_NODE_SYSMGMT, strlen(PICL_NODE_SYSMGMT),
- &sysmgmt_h)) != PICL_SUCCESS) {
- syslog(LOG_ERR, WD_NODE_INIT_ERR, 3, rc);
- return;
- }
-
- /* start creating the watchdog nodes and properties */
- if ((rc = ptree_create_and_add_node(sysmgmt_h, PICL_NODE_WD_CONTROLLER,
- PICL_CLASS_WATCHDOG_CONTROLLER,
- &(wd_data.wd_ctrl_nodehdl))) != PICL_SUCCESS) {
- syslog(LOG_ERR, WD_NODE_INIT_ERR, 4, rc);
- return;
- }
-
- /* Add wd-op property to watchdog controller node */
- (void) strncpy(buf, "", sizeof (buf));
- if ((rc = wd_create_property(PICL_PTYPE_CHARSTRING,
- PICL_WRITE + PICL_VOLATILE,
- PICL_PROPNAMELEN_MAX, PICL_PROP_WATCHDOG_OPERATION,
- NULL, wd_write_op,
- wd_data.wd_ctrl_nodehdl,
- &(wd_data.wd_ops_hdl),
- (void *)buf)) != PICL_SUCCESS) {
- syslog(LOG_ERR, WD_NODE_INIT_ERR, 5, rc);
- return;
- }
-
- /* create L1 node and add to controller */
- if ((rc = ptree_create_and_add_node(wd_data.wd_ctrl_nodehdl,
- PICL_NODE_WD_L1, PICL_CLASS_WATCHDOG_TIMER,
- &(wd_data.wd1_nodehdl))) != PICL_SUCCESS) {
- syslog(LOG_ERR, WD_NODE_INIT_ERR, 6, rc);
- return;
- }
-
- /* create L2 node and add to controller */
- if ((rc = ptree_create_and_add_node(wd_data.wd_ctrl_nodehdl,
- PICL_NODE_WD_L2, PICL_CLASS_WATCHDOG_TIMER,
- &(wd_data.wd2_nodehdl))) != PICL_SUCCESS) {
- syslog(LOG_ERR, WD_NODE_INIT_ERR, 7, rc);
- return;
- }
-
- /* create watchdog properties */
- /* create state property here */
- (void) strncpy(buf, PICL_PROPVAL_WD_STATE_DISARMED,
- sizeof (buf));
- if ((rc = wd_create_property(PICL_PTYPE_CHARSTRING,
- PICL_READ + PICL_VOLATILE, PICL_PROPNAMELEN_MAX,
- PICL_PROP_STATE, wd1_read_status, NULLWRITE,
- wd_data.wd1_nodehdl,
- &(wd_data.wd1_state_hdl), (void *)buf)) != PICL_SUCCESS) {
- syslog(LOG_ERR, WD_NODE_INIT_ERR, 8, rc);
- return;
- }
-
- if ((rc = wd_create_property(PICL_PTYPE_CHARSTRING,
- PICL_READ + PICL_VOLATILE, PICL_PROPNAMELEN_MAX,
- PICL_PROP_STATE, wd2_read_status, NULLWRITE,
- wd_data.wd2_nodehdl,
- &(wd_data.wd2_state_hdl), (void *)buf)) != PICL_SUCCESS) {
- syslog(LOG_ERR, WD_NODE_INIT_ERR, 9, rc);
- return;
- }
-
- /* create timeout property here */
- if ((rc = wd_create_property(PICL_PTYPE_UNSIGNED_INT,
- PICL_READ + PICL_WRITE + PICL_VOLATILE,
- sizeof (timeout1), PICL_PROP_WATCHDOG_TIMEOUT,
- wd_read_timeout, wd_write_timeout, wd_data.wd1_nodehdl,
- &(wd_data.wd1_timeout_hdl), (void *)&(timeout1))) !=
- PICL_SUCCESS) {
- syslog(LOG_ERR, WD_NODE_INIT_ERR, 10, rc);
- return;
- }
-
- if ((rc = wd_create_property(PICL_PTYPE_UNSIGNED_INT,
- PICL_READ + PICL_WRITE + PICL_VOLATILE,
- sizeof (wd_data.wd2_timeout), PICL_PROP_WATCHDOG_TIMEOUT,
- wd_read_timeout, wd_write_timeout, wd_data.wd2_nodehdl,
- &(wd_data.wd2_timeout_hdl), (void *)&(timeout2))) !=
- PICL_SUCCESS) {
- syslog(LOG_ERR, WD_NODE_INIT_ERR, 11, rc);
- return;
- }
-
- /* create wd_action property here */
- (void) strncpy(buf, PICL_PROPVAL_WD_ACTION_NONE,
- sizeof (buf));
- if ((rc = wd_create_property(PICL_PTYPE_CHARSTRING,
- PICL_READ + PICL_WRITE + PICL_VOLATILE,
- PICL_PROPNAMELEN_MAX, PICL_PROP_WATCHDOG_ACTION,
- wd_read_action, wd_write_action,
- wd_data.wd1_nodehdl, &(wd_data.wd1_action_hdl),
- (void *)buf)) != PICL_SUCCESS) {
- syslog(LOG_ERR, WD_NODE_INIT_ERR, 12, rc);
- return;
- }
-
- if ((rc = wd_create_property(PICL_PTYPE_CHARSTRING,
- PICL_READ + PICL_WRITE + PICL_VOLATILE,
- PICL_PROPNAMELEN_MAX, PICL_PROP_WATCHDOG_ACTION,
- wd_read_action, wd_write_action,
- wd_data.wd2_nodehdl, &(wd_data.wd2_action_hdl),
- (void *)buf)) != PICL_SUCCESS) {
- syslog(LOG_ERR, WD_NODE_INIT_ERR, 13, rc);
- return;
- }
-}
-
-static int
-wd_ioctl(int fd, int cmd, int len, char *buf)
-{
- int rtnval;
- struct strioctl sioc;
- sioc.ic_cmd = cmd;
- sioc.ic_timout = 60;
- sioc.ic_len = len;
- sioc.ic_dp = buf;
- rtnval = ioctl(fd, I_STR, &sioc);
- return (rtnval);
-}
-
-static int
-wd_open(int attr)
-{
- int cc;
- sc_cmdspec_t wd_cmdspec;
-
- if ((wd_fd = open(SMC_NODE, attr)) < 0) {
- return (-1);
- }
-
- /* get exclusive access for set and reset commands of watchdog */
- wd_cmdspec.args[0] = SMC_SET_WATCHDOG_TIMER;
- wd_cmdspec.args[1] = SMC_RESET_WATCHDOG_TIMER;
- wd_cmdspec.attribute = SC_ATTR_EXCLUSIVE;
-
- cc = wd_ioctl(wd_fd, SCIOC_MSG_SPEC, 3,
- (char *)&wd_cmdspec);
- if (cc < 0) {
- syslog(LOG_ERR, WD_PICL_EXCLUSIVE_ACCESS_ERR);
- return (-1);
- }
- return (wd_fd);
-}
-
-static int
-wd_open_pollfd(int attr)
-{
- int cc;
- sc_cmdspec_t wd_cmdspec;
-
- if ((polling_fd = open(SMC_NODE, attr)) < 0) {
- return (-1);
- }
-
- /* request for watchdog expiry notification */
- wd_cmdspec.args[0] = SMC_EXPIRED_WATCHDOG_NOTIF;
- wd_cmdspec.attribute = SC_ATTR_EXCLUSIVE;
-
- cc = wd_ioctl(polling_fd, SCIOC_MSG_SPEC, 2,
- (char *)&wd_cmdspec);
- if (cc < 0) {
- syslog(LOG_ERR, WD_PICL_SET_ATTR_FAILED);
- return (-1);
- }
- return (polling_fd);
-}
-
-/* read the ENVIRONMENT variables and initialize tunables */
-static void
-wd_get_env()
-{
- char *val;
- int intval = 0;
-
- /* read frutree debug flag value */
- if (val = getenv(WATCHDOG_DEBUG)) {
- errno = 0;
- intval = strtol(val, (char **)NULL, 0);
- if (errno == 0) {
- wd_debug = intval;
- }
- }
-}
-
-/*
- * PTREE Entry Points
- */
-
-/* picl-state-change event handler */
-/*ARGSUSED*/
-static void
-wd_state_change_evhandler(const char *ename, const void *earg,
- size_t size, void *cookie)
-{
- char *value;
- picl_errno_t rc;
- nvlist_t *nvlp;
- picl_nodehdl_t fruhdl;
- static int spawn_threads = 1;
- char name[PICL_PROPNAMELEN_MAX];
-
- if (strcmp(ename, PICLEVENT_STATE_CHANGE)) {
- return;
- }
-
- /* neglect all events if wd props are already created */
- if (props_created && state_configured) {
- return;
- }
-
- if (nvlist_unpack((char *)earg, size, &nvlp, NULL)) {
- return;
- }
- if ((nvlist_lookup_uint64(nvlp, PICLEVENTARG_NODEHANDLE,
- &fruhdl)) == -1) {
- nvlist_free(nvlp);
- return;
- }
- if (nvlist_lookup_string(nvlp, PICLEVENTARG_STATE, &value)) {
- nvlist_free(nvlp);
- return;
- }
-
- rc = ptree_get_propval_by_name(fruhdl, PICL_PROP_NAME,
- (void *)name, sizeof (name));
- if (rc != PICL_SUCCESS) {
- nvlist_free(nvlp);
- return;
- }
-
- /* care for only events on chassis node */
- if (strcmp(name, PICL_NODE_CHASSIS) != 0) {
- nvlist_free(nvlp);
- return;
- }
-
- if (strcmp(value, PICLEVENTARGVAL_CONFIGURED) == 0) {
- state_configured = 1;
- nvlist_free(nvlp);
- return;
- }
-
- if (strcmp(value, PICLEVENTARGVAL_CONFIGURING) != 0) {
- nvlist_free(nvlp);
- return;
- }
-
- if (wd_fd < 0) {
- if ((wd_fd = wd_open(O_RDWR)) < 0) {
- syslog(LOG_CRIT, WD_PICL_SMC_OPEN_ERR);
- nvlist_free(nvlp);
- return;
- }
- }
-
- if (polling_fd < 0) {
- if ((polling_fd = wd_open_pollfd(O_RDWR)) < 0) {
- syslog(LOG_CRIT, WD_PICL_SMC_OPEN_ERR);
- nvlist_free(nvlp);
- return;
- }
- }
-
- switch (wd_get_chassis_type()) {
- case WD_HOST: /* is host */
- wd_data.is_host = B_TRUE;
- break;
- case WD_STANDALONE: /* is satellite */
- wd_data.is_host = B_FALSE;
- break;
- default:
- nvlist_free(nvlp);
- return;
- }
-
- (void) wd_create_add_props(); /* create and add properties */
- props_created = 1;
-
- /* read the hardware and initialize values */
- (void) wd_set_init_state();
-
- /* initialize wd-conf value */
- (void) snprintf(wd_conf, sizeof (wd_conf), "%s/%s",
- PICL_CONFIG_DIR, WD_CONF_FILE);
-
- if (spawn_threads == 0) {
- /* threads are already created */
- nvlist_free(nvlp);
- return;
- }
-
- /* start monitoring for the events */
- if (thr_create(NULL, NULL, wd_polling,
- NULL, THR_BOUND, &polling_thr_tid) != 0) {
- syslog(LOG_ERR, WD_PICL_THREAD_CREATE_FAILED,
- "polling");
- nvlist_free(nvlp);
- return;
- }
-
- /* thread used to pat watchdog */
- if (thr_create(NULL, NULL, wd_patting_thread,
- NULL, THR_BOUND, &patting_thr_tid) != 0) {
- syslog(LOG_ERR, WD_PICL_THREAD_CREATE_FAILED,
- "patting");
- nvlist_free(nvlp);
- return;
- }
- spawn_threads = 0;
- nvlist_free(nvlp);
-}
-
-static void
-wd_picl_register(void)
-{
- int rc = 0;
- if ((rc = picld_plugin_register(&wd_reg_info)) != PICL_SUCCESS) {
- syslog(LOG_ERR, WD_PICL_REG_ERR, rc);
- }
-}
-
-/* entry point (initialization) */
-static void
-wd_picl_init(void)
-{
- /* initialize the wd_conf path and name */
- (void) snprintf(wd_conf, sizeof (wd_conf), "%s/%s",
- PICL_CONFIG_DIR, WD_CONF_FILE);
-
- /* parse configuration file and set tunables */
- wd_parse_config_file(wd_conf);
-
- /* if watchdog-enable is set to false dont intialize wd subsystem */
- if (wd_enable == 0) {
- return;
- }
-
- /* read watchdog related environment variables */
- wd_get_env();
-
- /* event handler for state change notifications from frutree */
- (void) ptree_register_handler(PICLEVENT_STATE_CHANGE,
- wd_state_change_evhandler, NULL);
-}
-
-static void
-wd_picl_fini(void)
-{
- (void) ptree_unregister_handler(PICLEVENT_STATE_CHANGE,
- wd_state_change_evhandler, NULL);
-
- state_configured = 0; /* chassis state */
- props_created = 0;
- (void) ptree_delete_node(wd_data.wd_ctrl_nodehdl);
- (void) ptree_destroy_node(wd_data.wd_ctrl_nodehdl);
-}
-
-/*
- * volatile function to read the timeout
- */
-static int
-wd_read_timeout(ptree_rarg_t *parg, void *buf)
-{
- /* update the buffer provided by user */
- (void) mutex_lock(&data_lock);
- if (parg->proph == wd_data.wd1_timeout_hdl) {
- *(int32_t *)buf = wd_data.wd1_timeout;
- } else if (parg->proph == wd_data.wd2_timeout_hdl) {
- *(int32_t *)buf = wd_data.wd2_timeout;
- }
- (void) mutex_unlock(&data_lock);
- return (PICL_SUCCESS);
-}
-
-/*
- * volatile function to read the action
- */
-static int
-wd_read_action(ptree_rarg_t *parg, void *buf)
-{
- (void) mutex_lock(&data_lock);
- if (parg->proph == wd_data.wd1_action_hdl) {
- switch (wd_data.wd1_action) {
- case WD_ACTION_HEALTHY_DOWN_HOST:
- case WD_ACTION_HEALTHY_DOWN_SAT:
- (void) strcpy((char *)buf,
- PICL_PROPVAL_WD_ACTION_ALARM);
- break;
- case WD_ACTION_NONE1:
- case WD_ACTION_NONE2:
- if (wd_data.reboot_action == 1) {
- (void) strcpy((char *)buf,
- PICL_PROPVAL_WD_ACTION_REBOOT);
- } else {
- (void) strcpy((char *)buf,
- PICL_PROPVAL_WD_ACTION_NONE);
- }
- break;
- }
- } else if (parg->proph == wd_data.wd2_action_hdl) {
- switch (wd_data.wd2_action) {
- case WD_ACTION_HARD_RESET:
- (void) strcpy((char *)buf,
- PICL_PROPVAL_WD_ACTION_RESET);
- break;
- case WD_ACTION_NONE2:
- (void) strcpy((char *)buf, PICL_PROPVAL_WD_ACTION_NONE);
- break;
- }
- }
- (void) mutex_unlock(&data_lock);
- return (PICL_SUCCESS);
-}
-
-/*
- * volatile function to write the action
- * this function validates the user value before programming the
- * action property. Properties can be modified only when watchdog
- * is in disarmed state.
- */
-static int
-wd_write_action(ptree_warg_t *parg, const void *buf)
-{
- int flag = 0x0;
- picl_errno_t rc = PICL_SUCCESS;
- char wd_action[PICL_WD_PROPVAL_MAX];
-
- /* only super user can write this property */
- if (parg->cred.dc_euid != SUPER_USER) {
- return (PICL_PERMDENIED);
- }
-
- if (parg->proph == wd_data.wd1_action_hdl) {
- flag = WD1;
- } else if (parg->proph == wd_data.wd2_action_hdl) {
- flag = WD2;
- }
-
- /* dont allow any write operations when watchdog is armed */
- (void) mutex_lock(&data_lock);
- if (wd_data.wd1_run_state != WD_DISARMED ||
- wd_data.wd2_run_state != WD_DISARMED) {
- (void) mutex_unlock(&data_lock);
- return (PICL_PERMDENIED);
- }
-
- /* validate the values and store in internal cache */
- (void) strcpy(wd_action, (char *)buf);
- switch (flag) {
- case WD1:
- if (strcmp(wd_action, PICL_PROPVAL_WD_ACTION_ALARM) == 0) {
- if (wd_data.is_host)
- wd_data.wd1_action = WD_ACTION_HEALTHY_DOWN_HOST;
- else
- wd_data.wd1_action = WD_ACTION_HEALTHY_DOWN_SAT;
- wd_data.reboot_action = 0;
- } else if (strcmp(wd_action, PICL_PROPVAL_WD_ACTION_NONE) == 0) {
- wd_data.wd1_action = WD_ACTION_NONE1;
- wd_data.reboot_action = 0;
- } else if (strcmp(wd_action, PICL_PROPVAL_WD_ACTION_REBOOT) == 0) {
- wd_data.wd1_action = WD_ACTION_NONE1;
- wd_data.reboot_action = 1;
- } else {
- rc = PICL_INVALIDARG;
- }
- break;
-
- case WD2:
- if (strcmp(wd_action, PICL_PROPVAL_WD_ACTION_RESET) == 0) {
- wd_data.wd2_action = WD_ACTION_HARD_RESET;
- } else if (strcmp(wd_action, PICL_PROPVAL_WD_ACTION_NONE) == 0) {
- wd_data.wd2_action = WD_ACTION_NONE2;
- } else {
- rc = PICL_INVALIDARG;
- }
- break;
- }
- (void) mutex_unlock(&data_lock);
- return (rc);
-}
-
-/*
- * volatile function to write the timeout
- * this function validates the user value before programming the
- * timeout property. Properties can be modified only when watchdog
- * is in disarmed state.
- */
-static int
-wd_write_timeout(ptree_warg_t *parg, const void *buf)
-{
- int32_t timeout;
- int flag = 0x0;
-
- /* only super user can write this property */
- if (parg->cred.dc_euid != SUPER_USER) {
- return (PICL_PERMDENIED);
- }
-
- /* dont allow any write operations when watchdog is armed */
- (void) mutex_lock(&data_lock);
- if (wd_data.wd1_run_state != WD_DISARMED ||
- wd_data.wd2_run_state != WD_DISARMED) {
- (void) mutex_unlock(&data_lock);
- return (PICL_PERMDENIED);
- }
- (void) mutex_unlock(&data_lock);
-
- if (parg->proph == wd_data.wd1_timeout_hdl) {
- flag = WD1;
- } else if (parg->proph == wd_data.wd2_timeout_hdl) {
- flag = WD2;
- }
-
- /* validate the timeout values */
- timeout = *(int32_t *)buf;
- if (timeout < -1) {
- return (PICL_INVALIDARG);
- }
-
- if (timeout > 0) {
- switch (flag) {
- case WD1:
- if ((timeout % WD_L1_RESOLUTION) != 0) {
- return (PICL_INVALIDARG);
- }
- if ((timeout/WD_L1_RESOLUTION) > WD_MAX_L1) {
- return (PICL_INVALIDARG);
- }
- break;
- case WD2:
- if ((timeout % WD_L2_RESOLUTION) != 0) {
- return (PICL_INVALIDARG);
- }
- if ((timeout/WD_L2_RESOLUTION) > WD_MAX_L2) {
- /* 255 sec */
- return (PICL_INVALIDARG);
- }
- }
- }
-
- /* update the internal cache */
- (void) mutex_lock(&data_lock);
- switch (flag) {
- case WD1:
- wd_data.wd1_timeout = timeout;
- break;
- case WD2:
- wd_data.wd2_timeout = timeout;
- break;
- }
- (void) mutex_unlock(&data_lock);
- return (PICL_SUCCESS);
-}
diff --git a/usr/src/cmd/picl/plugins/sun4u/snowbird/watchdog/piclwatchdog.h b/usr/src/cmd/picl/plugins/sun4u/snowbird/watchdog/piclwatchdog.h
deleted file mode 100644
index 7870fc0363..0000000000
--- a/usr/src/cmd/picl/plugins/sun4u/snowbird/watchdog/piclwatchdog.h
+++ /dev/null
@@ -1,288 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (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 2004 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#ifndef _PICL_WATCHDOG_H
-#define _PICL_WATCHDOG_H
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <libintl.h>
-#include <sys/inttypes.h>
-#include <smclib.h>
-
-#define WD_DEBUG0(fmt) \
- if (wd_debug) { \
- syslog(LOG_DEBUG, fmt); \
- }
-#define WD_DEBUG1(fmt, d1) \
- if (wd_debug) { \
- syslog(LOG_DEBUG, fmt, d1); \
- }
-
-/* environment variable defs */
-#define WATCHDOG_DEBUG "SUNW_WATCHDOG_DEBUG"
-
-/* debug flags */
-#define WD_GENERAL_MSGS 0x1
-#define WD_TIME_DEBUG 0x2
-
-/* tunables */
-#define WD_DEFAULT_THREAD_PRIORITY 0
-#define WD_POLL_TIMEOUT 10000 /* 10 sec */
-#define WD_PAT_TIME 5000
-
-/* constants */
-#define WD_SET_CMD_DATA_LEN 6 /* size for set cmd */
-#define PICL_WD_PROPVAL_MAX 20
-#define SUPER_USER 0
-
-/* watchdog status */
-#define WD_ARMED 0x1 /* watchdog is running */
-#define WD_EXPIRED 0x2 /* watchdog is expired */
-#define WD_DISARMED 0x4 /* watchdog is stopped */
-
-/* patting status */
-#define WD_RESET 0x8 /* client chose to pat. */
-#define WD_NORESET 0x0 /* pat state initial value. */
-
-/* auto pat feature for SMC f/w */
-#define ENABLE_AUTO_PAT 0x1
-#define DISABLE_AUTO_PAT 0x0
-
-/* flags used to track user actions */
-#define USER_ARMED_WD 0x1 /* user armed the watchdog */
-#define USER_ARMED_PAT_WD 0x2 /* debug feature */
-#define USER_PAT_WD 0x3 /* debug feature */
-#define USER_DISARMED_WD 0x4 /* user disarmed watchdog */
-
-/* bit masks */
-#define WD_ACTION_NONE1 0x30 /* action none with interrupt */
-#define WD_ACTION_NONE2 0x00 /* no action */
-#define WD_ACTION_HARD_RESET 0x01 /* hard reset */
-#define WD_ACTION_HEALTHY_DOWN_HOST 0x50 /* dont put bridge in reset */
-#define WD_ACTION_HEALTHY_DOWN_SAT 0x40 /* healthy down, bridge reset */
-#define WD_USEFLAG_OS 0x04 /* set os as user of wd */
-#define WD_XPR_FLG_CLR_OS 0x10 /* to clear sms/os expiry bit */
-#define WD_WD_RUNNING 0x40 /* to check wd running or not */
-#define WD_ENABLE_AUTO_PAT 0x20 /* enable auto pat feature */
-
-/* timer max values */
-#define WD_MAX_L2 0xff /* 255 sec */
-#define WD_MAX_L1 0xffff /* 109.22 min */
-#define WD_L1_RESOLUTION 100 /* 100ms/cnt */
-#define WD_L2_RESOLUTION 1000 /* 1000ms/cnt */
-
-#define WD1 0x1 /* wd level 1 */
-#define WD2 0x2 /* wd level 2 */
-#define WD1_2 0x3 /* wd level 1 and level 2 */
-#define WD_MAX_SEQN 255
-
-/* PICL node names */
-#define PICL_NODE_CHASSIS "chassis"
-#define PICL_NODE_SYSMGMT "sysmgmt"
-#define PICL_NODE_WD_CONTROLLER "watchdog"
-#define PICL_NODE_WD_L1 "watchdog-level1"
-#define PICL_NODE_WD_L2 "watchdog-level2"
-
-/* debug value for wd_op */
-#define WD_ARM_PAT "arm-pat"
-
-/* HEALTHY# status */
-#define WD_HEALTHY_DOWN 0x0
-#define WD_HEALTHY_UP 0x1
-
-#define SHUTDOWN_CMD "shutdown -y -i 6 -g 60 watchdog "\
- "expired.. rebooting"
-/* watchdog config file variables */
-#define PICL_CONFIG_DIR "/etc/picl/config"
-#define WD_CONF_FILE "watchdog.conf"
-#define WD_CONF_MAXSIZE 100
-#define WD_DELIMETER " \t\n"
-
-/* The following values can be tuned using config file */
-#define WD_PAT_THREAD_PRIORITY "wd_thread_priority"
-#define WD_PATTING_TIME "wd_pat_time"
-#define WD_ENABLE "watchdog-enable"
-
-#define WD_HOST 1
-#define WD_STANDALONE 2
-
-/* HEALTHY# bitmask */
-#define IS_HEALTHY 0x01
-
-#define DEFAULT_SEQN 15
-#define DEFAULT_FD -1
-#define SMC_NODE "/dev/ctsmc"
-
-#define WD_REGISTER_LEN 8
-
-typedef struct {
- /* properties values */
- uint8_t wd1_run_state; /* L1 status */
- uint8_t wd1_action; /* L1 action */
- uint8_t wd2_run_state; /* L2 status */
- uint8_t wd2_action; /* L2 action */
- int32_t wd1_timeout; /* L1 timeout */
- int32_t wd2_timeout; /* L2 timeout */
- uchar_t wd_pat_state; /* pat state */
- boolean_t reboot_action; /* is reboot action set */
- boolean_t is_host; /* is a host or standalone CPU */
-
- /* Cache for PICL handles */
- picl_nodehdl_t wd_ctrl_nodehdl; /* watchdog controller */
- /* prop handle for op */
- picl_prophdl_t wd_ops_hdl;
-
- picl_prophdl_t wd1_state_hdl;
- picl_prophdl_t wd1_timeout_hdl;
- picl_prophdl_t wd1_action_hdl;
- picl_nodehdl_t wd1_nodehdl; /* L1 node handle */
-
- picl_prophdl_t wd2_state_hdl;
- picl_prophdl_t wd2_timeout_hdl;
- picl_prophdl_t wd2_action_hdl;
- picl_nodehdl_t wd2_nodehdl; /* L2 node handle */
-} wd_data_t;
-
-/* structure to hold watchdog status */
-typedef struct {
- int present_state;
- uint8_t action1;
- uint8_t action2;
- uint8_t timeout1[2];
- uint8_t timeout2;
- uint8_t present_t1[2];
-} wd_state_t;
-
-/* Error messages */
-#define WD_PICL_NOSPACE \
- gettext("SUNW_piclwatchdog: Error in memory allocation")
-#define WD_PICL_REG_ERR \
- gettext("SUNW_piclwatchdog: Failed to register with picl framework,"\
- " error = %d")
-#define WD_PICL_SMC_OPEN_ERR \
- gettext("SUNW_piclwatchdog: Error in opening SMC drv")
-#define WD_PICL_EXCLUSIVE_ACCESS_ERR \
- gettext("SUNW_piclwatchdog: Error in getting exclusive access "\
- "for watchdog commands")
-#define WD_PICL_THREAD_CREATE_FAILED \
- gettext("SUNW_piclwatchdog: Error in creating %s thread")
-#define WD_PICL_PROP_INIT_ERR \
- gettext("SUNW_piclwatchdog: ptree prop init call failed:%d")
-#define WD_NODE_INIT_ERR \
- gettext("SUNW_piclwatchdog: Error in creating watchdog nodes(%d):%d")
-#define WD_PICL_GET_STAT_ERR \
- gettext("SUNW_piclwatchdog: Error in getting the watchdog status")
-#define WD_PICL_GET_ERR \
- gettext("SUNW_piclwatchdog: Error in getting watchdog status,"\
- " error = %d")
-#define WD_PICL_PAT_ERR \
- gettext("SUNW_piclwatchdog: Error in patting the watchdog"\
- " error = %d")
-#define WD_PICL_START_ERR \
- gettext("SUNW_piclwatchdog: Error in starting the watchdog, error = %d")
-#define WD_PICL_STOP_ERR \
- gettext("SUNW_piclwatchdog: Error in stopping the watchdog,"\
- " error = %d")
-#define WD_PICL_SET_ATTR_FAILED \
- gettext("SUNW_piclwatchdog: Error in setting attributes for a stream")
-#define WD_PICL_RT_THRD_FAIL \
- gettext("SUNW_piclwatchdog: Error in creating real time thread")
-#define WD_PICL_RT_THRD_NO_PERM_ERR \
- gettext("SUNW_piclwatchdog: No perm to change the priority of thread")
-#define WD_PICL_NO_WD_ERR \
- gettext("SUNW_piclwatchdog: Watchdog is not running")
-#define WD_PICL_WD1_RUNNING_ERR \
- gettext("SUNW_piclwatchdog: Disarm the Watchdog level 1")
-#define WD_PICL_WD2_RUNNING_ERR \
- gettext("SUNW_piclwatchdog: Disarm the Watchdog level 2")
-#define WD_PICL_SMC_READ_ERR \
- gettext("SUNW_piclwatchdog: Error in reading from SMC")
-#define WD_PICL_SMC_WRITE_ERR \
- gettext("SUNW_piclwatchdog: Error in writing to SMC")
-#define WD_NO_ROOT_PERM \
- gettext("SUNW_piclwatchdog: Root perm are reqd to perform this op.")
-#define WD_PICL_POLL_ERR \
- gettext("SUNW_piclwatchdog: Error in poll system call")
-#define WD_PICL_INVALID_T1 \
- gettext("SUNW_piclwatchdog: Invalid timeout value for wd level 1")
-#define WD_PICL_INVALID_T2 \
- gettext("SUNW_piclwatchdog: Invalid timeout value for wd level 2")
-#define WD_PICL_TMOUT_LV1_LV2_SETTO_0 \
- gettext("SUNW_piclwatchdog: Invalid timeout val for wd level 1 & 2")
-#define WD_PICL_INVALID_ACTION1 \
- gettext("SUNW_piclwatchdog: Invalid action for level one")
-#define WD_PICL_INVALID_ACTION2 \
- gettext("SUNW_piclwatchdog: Invalid action for level two")
-#define WD_PICL_CLEAR_EXCL_ERR \
- gettext("SUNW_piclwatchdog: Error in clearing exclusive "\
- "access for watchdog commands")
-#define WD_PICL_POST_EVENT_ERR \
- gettext("SUNW_piclwatchdog: Error in posting wd expiry event,"\
- " error = %d")
-#define WD_PICL_COND_SIGNAL_ERR \
- gettext("SUNW_piclwatchdog: Error in cond_signal")
-#define WD_PICL_IS_NOT_SUPPORTED \
- gettext("SUNW_piclwatchdog: This feature is not supported")
-#define WD_PICL_TRY_PAT_ERR \
- gettext("SUNW_piclwatchdog: OS is already patting the watchdog")
-#define WD_PICL_GET_TIMEOUT_ERR \
- gettext("SUNW_piclwatchdog: Error in getting the timeout values")
-#define WD_PICL_ARM_PAT_ERR \
- gettext("SUNW_piclwatchdog: Illegal timeout values for arm-pat op")
-#define WD_PICL_PERM_DENIED \
- gettext("SUNW_piclwatchdog: This client is not the owner of watchdog")
-#define WD_PICL_PAT_TIME_ERR \
- gettext("SUNW_piclwatchdog: Negative value for pat_time \
- is not allowed")
-#define WD_PICL_STATE_INVALID \
- gettext("SUNW_piclwatchdog: WD operations not allowed while "\
- "chassis state is configuring")
-#define WD_HEALTHY_ERR \
- gettext("SUNW_piclwatchdog: Cannot arm the watchdog, "\
- "action already taken")
-#define WD_GET_OWN_FAILED \
- gettext("SUNW_piclwatchdog: Error in finding active owner of watchdog,"\
- " error = %d")
-#define WD_NVLIST_ERR \
- gettext("SUNW_piclwatchdog: Error in posting watchdog event"\
- "(nvlist error), error = %d")
-#define WD_GET_HEALTH_ERR \
- gettext("SUNW_piclwatchdog: Error in getting HEALTHY# status")
-#define WD_UPDATE_STATE_ERR \
- gettext("SUNW_piclwatchdog: Error in updating watchdog state,"\
- "error = %d")
-#define WD_WD1_EXPIRED \
- gettext("SUNW_piclwatchdog: watchdog level 1 expired")
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _PICL_WATCHDOG_H */
diff --git a/usr/src/cmd/picl/plugins/sun4u/snowbird/watchdog/piclwd_platmod.c b/usr/src/cmd/picl/plugins/sun4u/snowbird/watchdog/piclwd_platmod.c
deleted file mode 100644
index 4b00529f54..0000000000
--- a/usr/src/cmd/picl/plugins/sun4u/snowbird/watchdog/piclwd_platmod.c
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (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 2004 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <picl.h>
-#include <picltree.h>
-#include <picldefs.h>
-#include <string.h>
-#include <syslog.h>
-#include "piclwatchdog.h"
-
-#define NETRA_CP2300 "SUNW,Netra-CP2300"
-
-int
-wd_get_chassis_type()
-{
- picl_nodehdl_t chassis_h;
- char chassis_type[PICL_PROPNAMELEN_MAX];
-
- if (ptree_get_node_by_path(PICL_FRUTREE_CHASSIS,
- &chassis_h) != PICL_SUCCESS) {
- return (-1);
- }
-
- if (ptree_get_propval_by_name(chassis_h, PICL_PROP_CHASSIS_TYPE,
- chassis_type, sizeof (chassis_type)) != PICL_SUCCESS) {
- return (-1);
- }
-
- if (strcmp(chassis_type, NETRA_CP2300) == 0) {
- return (WD_STANDALONE);
- } else {
- return (-1);
- }
-}
diff --git a/usr/src/cmd/picl/plugins/sun4v/mdesc/mdescplugin.c b/usr/src/cmd/picl/plugins/sun4v/mdesc/mdescplugin.c
index fa3e985b00..f02c7af356 100644
--- a/usr/src/cmd/picl/plugins/sun4v/mdesc/mdescplugin.c
+++ b/usr/src/cmd/picl/plugins/sun4v/mdesc/mdescplugin.c
@@ -22,6 +22,8 @@
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
+ *
+ * Copyright 2019 Peter Tribble.
*/
/*
@@ -220,11 +222,7 @@ signal_devtree(void)
return;
/*
- * Right now (Aug. 2007) snowbird is the only other platform
- * which uses this event. Since that's a sun4u platform and
- * this is sun4v we do not have to worry about possible confusion
- * or interference between the two by grabbing this event for
- * our own use here. This event is consumed by the devtree
+ * This event is consumed by the devtree
* plug-in. The event signals the plug-in to re-run its
* cpu initialization function, which will cause it to add
* additional information to the cpu devtree nodes (particularly,
diff --git a/usr/src/cmd/plimit/amd64/Makefile b/usr/src/cmd/plimit/amd64/Makefile
index 190969b38f..6835158eae 100644
--- a/usr/src/cmd/plimit/amd64/Makefile
+++ b/usr/src/cmd/plimit/amd64/Makefile
@@ -34,7 +34,7 @@ include ../../Makefile.cmd
include ../../Makefile.cmd.64
CFLAGS64 += $(CCVERBOSE)
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
LDLIBS += -lproc
diff --git a/usr/src/cmd/plimit/i386/Makefile b/usr/src/cmd/plimit/i386/Makefile
index 7bfabc3b75..8e8b3343fa 100644
--- a/usr/src/cmd/plimit/i386/Makefile
+++ b/usr/src/cmd/plimit/i386/Makefile
@@ -33,7 +33,7 @@ SRCS= $(OBJS:%.o=../%.c)
include ../../Makefile.cmd
CFLAGS += $(CCVERBOSE)
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
LDLIBS += -lproc
diff --git a/usr/src/cmd/plimit/sparcv9/Makefile b/usr/src/cmd/plimit/sparcv9/Makefile
index e4f39a0931..a7132565b2 100644
--- a/usr/src/cmd/plimit/sparcv9/Makefile
+++ b/usr/src/cmd/plimit/sparcv9/Makefile
@@ -35,7 +35,7 @@ include ../../Makefile.cmd
include ../../Makefile.cmd.64
CFLAGS64 += $(CCVERBOSE)
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
LDLIBS += -lproc
diff --git a/usr/src/cmd/pools/Makefile.pools b/usr/src/cmd/pools/Makefile.pools
index 14c23e64a4..d9fb87ae3f 100644
--- a/usr/src/cmd/pools/Makefile.pools
+++ b/usr/src/cmd/pools/Makefile.pools
@@ -30,7 +30,7 @@ POOLSCOMMONDIR = $(POOLSSRC)/common
COMMON_OBJS = utils.o
COMMON_SRCS = $(COMMON_OBJS:%.o=$(POOLSCOMMONDIR)/%.c)
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-unused-label
CERRWARN += -_gcc=-Wno-unused-variable
CERRWARN += -_gcc=-Wno-implicit-function-declaration
diff --git a/usr/src/cmd/powertop/Makefile.com b/usr/src/cmd/powertop/Makefile.com
index 37a1434c04..960f7d3106 100644
--- a/usr/src/cmd/powertop/Makefile.com
+++ b/usr/src/cmd/powertop/Makefile.com
@@ -43,7 +43,7 @@ include ../../Makefile.cmd
CFLAGS += $(CCVERBOSE)
CFLAGS64 += $(CCVERBOSE)
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
SMOFF += free
diff --git a/usr/src/cmd/praudit/Makefile b/usr/src/cmd/praudit/Makefile
index b364320c8e..9ae3e01a8b 100644
--- a/usr/src/cmd/praudit/Makefile
+++ b/usr/src/cmd/praudit/Makefile
@@ -43,7 +43,7 @@ CPPFLAGS += -D_PRAUDIT -I$(XLATEDIR)
CPPFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
SMOFF += signed
diff --git a/usr/src/cmd/prctl/Makefile.com b/usr/src/cmd/prctl/Makefile.com
index 6327f99b25..049b53a2db 100644
--- a/usr/src/cmd/prctl/Makefile.com
+++ b/usr/src/cmd/prctl/Makefile.com
@@ -35,7 +35,7 @@ include ../../Makefile.cmd
CFLAGS += $(CCVERBOSE)
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/print/bsd-sysv-commands/Makefile b/usr/src/cmd/print/bsd-sysv-commands/Makefile
index cb71a89a43..f2b8c41230 100644
--- a/usr/src/cmd/print/bsd-sysv-commands/Makefile
+++ b/usr/src/cmd/print/bsd-sysv-commands/Makefile
@@ -65,7 +65,7 @@ in.lpd:= CFLAGS += -DSOLARIS_PRIVATE_POST_0_9
in.lpd:= LDLIBS += -lnsl -lsocket
CERRWARN += -_gcc=-Wno-unused-variable
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/Makefile b/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/Makefile
index 66e2527c01..6fb2c832a5 100644
--- a/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/Makefile
+++ b/usr/src/cmd/print/printmgr/com/sun/admin/pm/server/Makefile
@@ -85,7 +85,7 @@ ROOTLIBS= $(LIBS:%=$(ROOTLIBDIR)/%)
CPPFLAGS += -I$(JAVA_ROOT)/include -I$(JAVA_ROOT)/include/solaris -I.
CERRWARN += -_gcc=-Wno-unused-variable
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/priocntl/Makefile b/usr/src/cmd/priocntl/Makefile
index 526d67098e..eb77eeb33c 100644
--- a/usr/src/cmd/priocntl/Makefile
+++ b/usr/src/cmd/priocntl/Makefile
@@ -36,7 +36,7 @@ include ../Makefile.cmd
LDLIBS += -lcontract
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CLASSD = $(ROOTLIB)/class
RTD = $(CLASSD)/RT
diff --git a/usr/src/cmd/projects/Makefile b/usr/src/cmd/projects/Makefile
index f61bc033b6..570793d0f2 100644
--- a/usr/src/cmd/projects/Makefile
+++ b/usr/src/cmd/projects/Makefile
@@ -35,7 +35,7 @@ LDLIBS += -lproject
.KEEP_STATE:
CFLAGS += $(CCVERBOSE)
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
all: $(PROG)
diff --git a/usr/src/cmd/prtconf/Makefile.com b/usr/src/cmd/prtconf/Makefile.com
index cb54f66d15..0c21866317 100644
--- a/usr/src/cmd/prtconf/Makefile.com
+++ b/usr/src/cmd/prtconf/Makefile.com
@@ -32,7 +32,7 @@ include ../../Makefile.cmd
CFLAGS += $(CCVERBOSE)
CERRWARN += -_gcc=-Wno-parentheses
CERRWARN += -_gcc=-Wno-switch
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
LDLIBS += -ldevinfo -lnvpair -lpcidb
FILEMODE= 02555
diff --git a/usr/src/cmd/prtvtoc/Makefile b/usr/src/cmd/prtvtoc/Makefile
index c4ae5fe936..1a64695fa6 100644
--- a/usr/src/cmd/prtvtoc/Makefile
+++ b/usr/src/cmd/prtvtoc/Makefile
@@ -32,7 +32,7 @@ ROOTSYMLINK= $(ROOTETC)/$(PROG)
LDLIBS += -ladm -lefi
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/psrset/Makefile.com b/usr/src/cmd/psrset/Makefile.com
index b162a57982..1dc5aa08bf 100644
--- a/usr/src/cmd/psrset/Makefile.com
+++ b/usr/src/cmd/psrset/Makefile.com
@@ -33,7 +33,7 @@ include ../../Makefile.cmd
CFLAGS += $(CCVERBOSE)
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
LDLIBS += -lproc
.KEEP_STATE:
diff --git a/usr/src/cmd/ptools/Makefile.bld b/usr/src/cmd/ptools/Makefile.bld
index 8607a5b3f8..b52738b2e0 100644
--- a/usr/src/cmd/ptools/Makefile.bld
+++ b/usr/src/cmd/ptools/Makefile.bld
@@ -65,12 +65,12 @@ CERRWARN_plgrp += -_smatch=off
CERRWARN_pmadvise += -_smatch=off
CERRWARN_ppriv += -_gcc=-Wno-parentheses
-CERRWARN_ppriv += -_gcc=-Wno-uninitialized
+CERRWARN_ppriv += $(CNOWARN_UNINIT)
CERRWARN_ptree += -_gcc=-Wno-parentheses
CERRWARN_ptree += -_smatch=off
-CERRWARN_pstack += -_gcc=-Wno-uninitialized
+CERRWARN_pstack += $(CNOWARN_UNINIT)
CERRWARN_pstack += -_gcc=-Wno-clobbered
CERRWARN_pargs += -_gcc=-Wno-clobbered
diff --git a/usr/src/cmd/raidctl/Makefile b/usr/src/cmd/raidctl/Makefile
index 4f7f648912..51cfb0915a 100644
--- a/usr/src/cmd/raidctl/Makefile
+++ b/usr/src/cmd/raidctl/Makefile
@@ -30,7 +30,7 @@ include $(SRC)/cmd/Makefile.cmd
LDLIBS += -lraidcfg
CFLAGS += $(CCVERBOSE)
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
.KEEP_STATE:
diff --git a/usr/src/cmd/ramdiskadm/Makefile b/usr/src/cmd/ramdiskadm/Makefile
index 7dae74826e..7650809cfb 100644
--- a/usr/src/cmd/ramdiskadm/Makefile
+++ b/usr/src/cmd/ramdiskadm/Makefile
@@ -32,7 +32,7 @@ POFILES= $(OBJS:%.o=%.po)
include ../Makefile.cmd
LDLIBS += -ldevinfo
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
.KEEP_STATE:
diff --git a/usr/src/cmd/rcap/Makefile.com b/usr/src/cmd/rcap/Makefile.com
index 1289c6d4d8..babe6cdf81 100644
--- a/usr/src/cmd/rcap/Makefile.com
+++ b/usr/src/cmd/rcap/Makefile.com
@@ -33,7 +33,7 @@
LDFLAGS += $(MAPFILE.NGB:%=-M%)
CERRWARN += -_gcc=-Wno-unused-function
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-parentheses
SMOFF += strcpy_overflow
diff --git a/usr/src/cmd/rcm_daemon/Makefile.com b/usr/src/cmd/rcm_daemon/Makefile.com
index 621e1cbfb9..cf9f5b0143 100644
--- a/usr/src/cmd/rcm_daemon/Makefile.com
+++ b/usr/src/cmd/rcm_daemon/Makefile.com
@@ -23,6 +23,7 @@
# Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
# Copyright 2016 Nexenta Systems, Inc.
# Copyright (c) 2018, Joyent, Inc.
+# Copyright 2019 Peter Tribble.
#
include ../../Makefile.cmd
@@ -61,8 +62,6 @@ COMMON_MOD_SRC = \
$(COMMON)/ip_anon_rcm.c \
$(COMMON)/bridge_rcm.c
-sparc_MOD_SRC = $(COMMON)/ttymux_rcm.c
-
COMMON_PERL_SCRIPT_SRC =
sparc_PERL_SCRIPT_SRC = SUNW,vdevices.pl
@@ -86,8 +85,6 @@ COMMON_MOD_OBJ = \
ip_anon_rcm.o \
bridge_rcm.o
-sparc_MOD_OBJ = ttymux_rcm.o
-
RCM_DAEMON = rcm_daemon
COMMON_RCM_MODS = \
@@ -106,8 +103,6 @@ COMMON_RCM_MODS = \
SUNW_ip_anon_rcm.so \
SUNW_bridge_rcm.so
-sparc_RCM_MODS = SUNW_ttymux_rcm.so
-
RCM_DIR = rcm
MOD_DIR = modules
SCRIPT_DIR = scripts
@@ -122,7 +117,7 @@ CFLAGS += $(CCVERBOSE) $(C_PICFLAGS)
CERRWARN += -_gcc=-Wno-parentheses
CERRWARN += -_gcc=-Wno-unused-label
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-unused-function
# not linted
diff --git a/usr/src/cmd/rcm_daemon/common/ttymux_rcm.c b/usr/src/cmd/rcm_daemon/common/ttymux_rcm.c
deleted file mode 100644
index 5b50679a3e..0000000000
--- a/usr/src/cmd/rcm_daemon/common/ttymux_rcm.c
+++ /dev/null
@@ -1,1434 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (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 2004 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- * Copyright (c) 2016 by Delphix. All rights reserved.
- */
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <stdarg.h>
-#include <unistd.h>
-#include <assert.h>
-#include <string.h>
-#include <limits.h>
-#include <synch.h>
-#include <libintl.h>
-#include <errno.h>
-#include <libdevinfo.h>
-#include <sys/uio.h>
-#include <sys/sysmacros.h>
-#include <sys/types.h>
-#include <stropts.h>
-#include <sys/stream.h>
-#include <fcntl.h>
-#include <sys/stat.h>
-#include <sys/mkdev.h>
-
-#include <sys/param.h>
-#include <sys/openpromio.h>
-#include <sys/ttymuxuser.h>
-
-#include "ttymux_rcm_impl.h"
-#include "rcm_module.h"
-
-#define TTYMUX_OFFLINE_ERR gettext("Resource is in use by")
-#define TTYMUX_UNKNOWN_ERR gettext("Unknown Operation attempted")
-#define TTYMUX_ONLINE_ERR gettext("Failed to connect under multiplexer")
-#define TTYMUX_INVALID_ERR gettext("Invalid Operation on this resource")
-#define TTYMUX_OFFLINE_FAIL gettext("Failed to disconnect from multiplexer")
-#define TTYMUX_MEMORY_ERR gettext("TTYMUX: strdup failure\n")
-
-
-static int msglvl = 6; /* print messages less than this level */
-#define TEST(cond, stmt) { if (cond) stmt; }
-#define _msg(lvl, args) TEST(msglvl > (lvl), trace args)
-
-static int oflags = O_EXCL|O_RDWR|O_NONBLOCK|O_NOCTTY;
-static dev_t cn_dev = NODEV;
-static rsrc_t *cn_rsrc = NULL;
-static rsrc_t cache_head;
-static rsrc_t cache_tail;
-static mutex_t cache_lock;
-static char muxctl[PATH_MAX] = {0};
-static char muxcon[PATH_MAX] = {0};
-static int muxfd;
-static boolean_t register_rsrcs;
-
-/* module interface routines */
-static int tty_register(rcm_handle_t *);
-static int tty_unregister(rcm_handle_t *);
-static int tty_getinfo(rcm_handle_t *, char *, id_t, uint_t, char **,
- char **, nvlist_t *, rcm_info_t **);
-static int tty_suspend(rcm_handle_t *, char *, id_t,
- timespec_t *, uint_t, char **, rcm_info_t **);
-static int tty_resume(rcm_handle_t *, char *, id_t, uint_t, char **,
- rcm_info_t **);
-static int tty_offline(rcm_handle_t *, char *, id_t, uint_t, char **,
- rcm_info_t **);
-static int tty_online(rcm_handle_t *, char *, id_t, uint_t, char **,
- rcm_info_t **);
-static int tty_remove(rcm_handle_t *, char *, id_t, uint_t, char **,
- rcm_info_t **);
-
-static int get_devpath(char *, char **, dev_t *);
-
-/*
- * Module-Private data
- */
-static struct rcm_mod_ops tty_ops = {
- RCM_MOD_OPS_VERSION,
- tty_register,
- tty_unregister,
- tty_getinfo,
- tty_suspend,
- tty_resume,
- tty_offline,
- tty_online,
- tty_remove,
- NULL,
- NULL
-};
-
-/*PRINTFLIKE1*/
-static void
-trace(char *fmt, ...)
-{
- va_list args;
- char buf[256];
- int sz;
-
- va_start(args, fmt);
- sz = vsnprintf(buf, sizeof (buf), fmt, args);
- va_end(args);
-
- if (sz < 0)
- rcm_log_message(RCM_TRACE1,
- _("TTYMUX: vsnprintf parse error\n"));
- else if (sz > sizeof (buf)) {
- char *b = malloc(sz + 1);
-
- if (b != NULL) {
- va_start(args, fmt);
- sz = vsnprintf(b, sz + 1, fmt, args);
- va_end(args);
- if (sz > 0)
- rcm_log_message(RCM_TRACE1, _("%s"), b);
- free(b);
- }
- } else {
- rcm_log_message(RCM_TRACE1, _("%s"), buf);
- }
-}
-
-/*
- * CACHE MANAGEMENT
- * Resources managed by this module are stored in a list of rsrc_t
- * structures.
- */
-
-/*
- * cache_lookup()
- *
- * Get a cache node for a resource. Call with cache lock held.
- */
-static rsrc_t *
-cache_lookup(const char *resource)
-{
- rsrc_t *rsrc;
- rsrc = cache_head.next;
- while (rsrc != &cache_tail) {
- if (rsrc->id && strcmp(resource, rsrc->id) == 0) {
- return (rsrc);
- }
- rsrc = rsrc->next;
- }
- return (NULL);
-}
-
-/*
- * Get a cache node for a minor node. Call with cache lock held.
- */
-static rsrc_t *
-cache_lookup_bydevt(dev_t devt)
-{
- rsrc_t *rsrc;
- rsrc = cache_head.next;
- while (rsrc != &cache_tail) {
- if (rsrc->dev == devt)
- return (rsrc);
- rsrc = rsrc->next;
- }
- return (NULL);
-}
-
-/*
- * free_node()
- *
- * Free a node. Make sure it isn't in the list!
- */
-static void
-free_node(rsrc_t *node)
-{
- if (node) {
- if (node->id) {
- free(node->id);
- }
- free(node);
- }
-}
-
-/*
- * cache_insert()
- *
- * Call with the cache_lock held.
- */
-static void
-cache_insert(rsrc_t *node)
-{
- /* insert at the head for best performance */
- node->next = cache_head.next;
- node->prev = &cache_head;
-
- node->next->prev = node;
- node->prev->next = node;
-}
-
-/*
- * cache_create()
- *
- * Call with the cache_lock held.
- */
-static rsrc_t *
-cache_create(const char *resource, dev_t dev)
-{
- rsrc_t *rsrc = malloc(sizeof (rsrc_t));
-
- if (rsrc != NULL) {
- if ((rsrc->id = strdup(resource)) != NULL) {
- rsrc->dev = dev;
- rsrc->flags = 0;
- rsrc->dependencies = NULL;
- cache_insert(rsrc);
- } else {
- free(rsrc);
- rsrc = NULL;
- }
- } else {
- _msg(0, ("TTYMUX: malloc failure for resource %s.\n",
- resource));
- }
- return (rsrc);
-}
-
-/*
- * cache_get()
- *
- * Call with the cache_lock held.
- */
-static rsrc_t *
-cache_get(const char *resource)
-{
- rsrc_t *rsrc = cache_lookup(resource);
- if (rsrc == NULL) {
- dev_t dev;
-
- (void) get_devpath((char *)resource, NULL, &dev);
- rsrc = cache_create(resource, dev);
- }
- return (rsrc);
-}
-
-/*
- * cache_remove()
- *
- * Call with the cache_lock held.
- */
-static void
-cache_remove(rsrc_t *node)
-{
- node->next->prev = node->prev;
- node->prev->next = node->next;
- node->next = NULL;
- node->prev = NULL;
-}
-
-/*
- * Open a file identified by fname with the given open flags.
- * If the request is to open a file with exclusive access and the open
- * fails then backoff exponentially and then retry the open.
- * Do not wait for longer than about a second (since this may be an rcm
- * framework thread).
- */
-static int
-open_file(char *fname, int flags)
-{
- int fd, cnt;
- struct timespec ts;
-
- if ((flags & O_EXCL) == 0)
- return (open(fname, flags));
-
- ts.tv_sec = 0;
- ts.tv_nsec = 16000000; /* 16 milliseconds */
-
- for (cnt = 0; cnt < 5 && (fd = open(fname, flags)) == -1; cnt++) {
- (void) nanosleep(&ts, NULL);
- ts.tv_nsec *= 2;
- }
- return (fd);
-}
-
-/*
- * No-op for creating an association between a pair of resources.
- */
-/*ARGSUSED*/
-static int
-nullconnect(link_t *link)
-{
- return (0);
-}
-
-/*
- * No-op for destroying an association between a pair of resources.
- */
-/*ARGSUSED*/
-static int
-nulldisconnect(link_t *link)
-{
- return (0);
-}
-
-/*
- * Record an actual or desired association between two resources
- * identified by their rsrc_t structures.
- */
-static link_t *
-add_dependency(rsrc_t *user, rsrc_t *used)
-{
- link_t *linkhead;
- link_t *link;
-
- if (user == NULL || used == NULL)
- return (NULL);
-
- if (user->id && used->id && strcmp(user->id, used->id) == 0) {
- _msg(2, ("TTYMUX: attempt to connect devices created by "
- "the same driver\n"));
- return (NULL);
- }
-
- /*
- * Search for all resources that this resource user is depending
- * upon.
- */
- linkhead = user->dependencies;
- for (link = linkhead; link != NULL; link = link->next) {
- /*
- * Does the using resource already depends on the used
- * resource
- */
- if (link->used == used)
- return (link);
- }
-
- link = malloc(sizeof (link_t));
-
- if (link == NULL) {
- rcm_log_message(RCM_ERROR, _("TTYMUX: Out of memory\n"));
- return (NULL);
- }
-
- _msg(6, ("TTYMUX: New link user %s used %s\n", user->id, used->id));
-
- link->user = user;
- link->used = used;
- link->linkid = 0;
- link->state = UNKNOWN;
- link->flags = 0;
-
- link->connect = nullconnect;
- link->disconnect = nulldisconnect;
- link->next = linkhead;
-
- user->dependencies = link;
-
- return (link);
-}
-
-/*
- * Send an I_STR stream ioctl to a device
- */
-static int
-istrioctl(int fd, int cmd, void *data, int datalen, int *bytes) {
- struct strioctl ios;
- int rval;
-
- ios.ic_timout = 0; /* use the default */
- ios.ic_cmd = cmd;
- ios.ic_dp = (char *)data;
- ios.ic_len = datalen;
-
- rval = ioctl(fd, I_STR, (char *)&ios);
- if (bytes)
- *bytes = ios.ic_len;
- return (rval);
-}
-
-/*
- * Streams link the driver identified by fd underneath a mux
- * identified by ctrl_fd.
- */
-static int
-plink(int ctrl_fd, int fd)
-{
- int linkid;
-
- /*
- * pop any modules off the lower stream.
- */
- while (ioctl(fd, I_POP, 0) == 0)
- ;
-
- if ((linkid = ioctl(ctrl_fd, I_PLINK, fd)) < 0)
- rcm_log_message(RCM_ERROR,
- _("TTYMUX: I_PLINK error %d.\n"), errno);
- return (linkid);
-}
-
-/*
- * Streams unlink the STREAM identified by linkid from a mux
- * identified by ctrl_fd.
- */
-static int
-punlink(int ctrl_fd, int linkid)
-{
- if (ioctl(ctrl_fd, I_PUNLINK, linkid) < 0)
- return (errno);
- else
- return (0);
-}
-
-/*
- * Connect a pair of resources by establishing the dependency association.
- * Only works for devices that support the TTYMUX ioctls.
- */
-static int
-mux_connect(link_t *link)
-{
- int lfd;
- int rv;
- ttymux_assoc_t as;
- uint8_t ioflags;
-
- _msg(6, ("TTYMUX: mux_connect (%ld:%ld<->%ld:%ld %s <-> %s\n",
- major(link->user->dev), minor(link->user->dev),
- major(link->used->dev), minor(link->used->dev),
- link->user->id, link->used->id));
-
- _msg(12, ("TTYMUX: struct size = %d (plen %d)\n",
- sizeof (as), PATH_MAX));
-
- if (link->user->dev == NODEV || link->used->dev == NODEV) {
- /*
- * One of the resources in the association is not
- * present (wait for the online notification before
- * attempting to establish the dependency association.
- */
- return (EAGAIN);
- }
- if (major(link->user->dev) == major(link->used->dev)) {
- _msg(2, ("TTYMUX: attempt to link devices created by "
- "the same driver\n"));
- return (EINVAL);
- }
- /*
- * Explicitly check for attempts to plumb the system console -
- * required becuase not all serial devices support the
- * O_EXCL open flag.
- */
- if (link->used->dev == cn_dev) {
- rcm_log_message(RCM_WARNING, _("TTYMUX: Request to link the "
- " system console under another device not allowed!\n"));
-
- return (EPERM);
- }
-
- /*
- * Ensure that the input/output mode of the dependent is reasonable
- */
- if ((ioflags = link->flags & FORIO) == 0)
- ioflags = FORIO;
-
- /*
- * Open each resource participating in the association.
- */
- lfd = open(link->used->id, O_EXCL|O_RDWR|O_NONBLOCK|O_NOCTTY);
- if (lfd == -1) {
- if (errno == EBUSY) {
- rcm_log_message(RCM_WARNING, _("TTYMUX: device %s is "
- " busy - " " cannot connect to %s\n"),
- link->used->id, link->user->id);
- } else {
- rcm_log_message(RCM_WARNING,
- _("TTYMUX: open error %d for device %s\n"),
- errno, link->used->id);
- }
- return (errno);
- }
- /*
- * Note: Issuing the I_PLINK and TTYMUX_ASSOC request on the 'using'
- * resource is more generic:
- * muxfd = open(link->user->id, oflags);
- * However using the ctl (MUXCTLLINK) node means that any current opens
- * on the 'using' resource are uneffected.
- */
-
- /*
- * Figure out if the 'used' resource is already associated with
- * some resource - if so tell the caller to try again later.
- * More generally if any user or kernel thread has the resource
- * open then the association should not be made.
- * The ttymux driver makes this check (but it should be done here).
- */
- as.ttymux_linkid = 0;
- as.ttymux_ldev = link->used->dev;
-
- if (istrioctl(muxfd, TTYMUX_GETLINK,
- (void *)&as, sizeof (as), NULL) == 0) {
-
- _msg(7, ("TTYMUX: %ld:%ld (%d) (udev %ld:%ld) already linked\n",
- major(as.ttymux_ldev), minor(as.ttymux_ldev),
- as.ttymux_linkid, major(as.ttymux_udev),
- minor(as.ttymux_udev)));
- link->linkid = as.ttymux_linkid;
- if (as.ttymux_udev != NODEV) {
- (void) close(lfd);
- return (EAGAIN);
- }
- }
-
- /*
- * Now link and associate the used resource under the using resource.
- */
- as.ttymux_udev = link->user->dev;
- as.ttymux_ldev = link->used->dev;
- as.ttymux_tag = 0ul;
- as.ttymux_ioflag = ioflags;
-
- _msg(6, ("TTYMUX: connecting %ld:%ld to %ld:%ld\n",
- major(as.ttymux_ldev), minor(as.ttymux_ldev),
- major(as.ttymux_udev), minor(as.ttymux_udev)));
-
- if (as.ttymux_udev == cn_dev) {
- struct termios tc;
-
- if (ioctl(lfd, TCGETS, &tc) != -1) {
- tc.c_cflag |= CREAD;
- if (ioctl(lfd, TCSETSW, &tc) == -1) {
- rcm_log_message(RCM_WARNING,
- _("TTYMUX: error %d whilst enabling the "
- "receiver on device %d:%d\n"),
- errno, major(as.ttymux_ldev),
- minor(as.ttymux_ldev));
- }
- }
- }
-
- if (as.ttymux_linkid <= 0 && (as.ttymux_linkid =
- plink(muxfd, lfd)) <= 0) {
- rcm_log_message(RCM_WARNING,
- _("TTYMUX: Link error %d for device %s\n"),
- errno, link->used->id);
- rv = errno;
- goto out;
- }
- link->linkid = as.ttymux_linkid;
-
- _msg(6, ("TTYMUX: associating\n"));
- if (istrioctl(muxfd, TTYMUX_ASSOC, (void *)&as, sizeof (as), 0) != 0) {
- rv = errno;
- goto out;
- }
- _msg(6, ("TTYMUX: Succesfully connected %ld:%ld to %ld:%ld\n",
- major(as.ttymux_ldev), minor(as.ttymux_ldev),
- major(as.ttymux_udev), minor(as.ttymux_udev)));
- link->state = CONNECTED;
- (void) close(lfd);
- return (0);
-out:
- rcm_log_message(RCM_WARNING,
- _("TTYMUX: Error [%d] connecting %d:%d to %d:%d\n"),
- rv, major(as.ttymux_ldev), minor(as.ttymux_ldev),
- major(as.ttymux_udev), minor(as.ttymux_udev));
-
- (void) close(lfd);
- if (as.ttymux_linkid > 0) {
- /*
- * There was an error so unwind the I_PLINK step
- */
- if (punlink(muxfd, as.ttymux_linkid) != 0)
- rcm_log_message(RCM_WARNING,
- _("TTYMUX: Unlink error %d (%s).\n"),
- errno, link->used->id);
- }
- return (rv);
-}
-
-/*
- * Disconnect a pair of resources by destroying the dependency association.
- * Only works for devices that support the TTYMUX ioctls.
- */
-static int
-mux_disconnect(link_t *link)
-{
- int rv;
- ttymux_assoc_t as;
-
- _msg(6, ("TTYMUX: mux_disconnect %s<->%s (%ld:%ld<->%ld:%ld)\n",
- link->user->id, link->used->id,
- major(link->user->dev), minor(link->user->dev),
- major(link->used->dev), minor(link->used->dev)));
-
- as.ttymux_ldev = link->used->dev;
-
- if (istrioctl(muxfd, TTYMUX_GETLINK,
- (void *)&as, sizeof (as), NULL) != 0) {
-
- _msg(1, ("TTYMUX: %ld:%ld not linked [err %d]\n",
- major(link->used->dev), minor(link->used->dev), errno));
- return (0);
-
- /*
- * Do not disassociate console resources - simply
- * unlink them so that they remain persistent.
- */
- } else if (as.ttymux_udev != cn_dev &&
- istrioctl(muxfd, TTYMUX_DISASSOC, (void *)&as,
- sizeof (as), 0) == -1) {
-
- rv = errno;
- rcm_log_message(RCM_WARNING,
- _("TTYMUX: Dissassociate error %d for %s\n"),
- rv, link->used->id);
-
- } else if (punlink(muxfd, as.ttymux_linkid) != 0) {
- rv = errno;
- rcm_log_message(RCM_WARNING,
- _("TTYMUX: Error %d unlinking %d:%d\n"),
- errno, major(link->used->dev), minor(link->used->dev));
- } else {
- _msg(6, ("TTYMUX: %s<->%s disconnected.\n",
- link->user->id, link->used->id));
-
- link->state = DISCONNECTED;
- link->linkid = 0;
- rv = 0;
- }
- return (rv);
-}
-
-/* PESISTENCY */
-
-/*
- * Given a special device file system path return the /devices path
- * and/or the device number (dev_t) of the device.
- */
-static int
-get_devpath(char *dev, char **cname, dev_t *devt)
-{
- struct stat sb;
-
- if (cname != NULL)
- *cname = NULL;
-
- if (devt != NULL)
- *devt = NODEV;
-
- if (lstat(dev, &sb) < 0) {
- return (errno);
- } else if ((sb.st_mode & S_IFMT) == S_IFLNK) {
- int lsz;
- char linkbuf[PATH_MAX+1];
-
- if (stat(dev, &sb) < 0)
- return (errno);
-
- lsz = readlink(dev, linkbuf, PATH_MAX);
-
- if (lsz <= 0)
- return (ENODEV);
- linkbuf[lsz] = '\0';
- dev = strstr(linkbuf, "/devices");
- if (dev == NULL)
- return (ENODEV);
- }
-
- if (cname != NULL)
- *cname = strdup(dev);
-
- if (devt != NULL)
- *devt = sb.st_rdev;
-
- return (0);
-}
-
-/*
- * See routine locate_node
- */
-static int
-locate_dev(di_node_t node, di_minor_t minor, void *arg)
-{
- char *devfspath;
- char resource[PATH_MAX];
- rsrc_t *rsrc;
-
- if (di_minor_devt(minor) != (dev_t)arg)
- return (DI_WALK_CONTINUE);
-
- if ((devfspath = di_devfs_path(node)) == NULL)
- return (DI_WALK_TERMINATE);
-
- if (snprintf(resource, sizeof (resource), "/devices%s:%s",
- devfspath, di_minor_name(minor)) > sizeof (resource)) {
- di_devfs_path_free(devfspath);
- return (DI_WALK_TERMINATE);
- }
-
- di_devfs_path_free(devfspath);
-
- rsrc = cache_lookup(resource);
- if (rsrc == NULL &&
- (rsrc = cache_create(resource, di_minor_devt(minor))) == NULL)
- return (DI_WALK_TERMINATE);
-
- rsrc->dev = di_minor_devt(minor);
- rsrc->flags |= PRESENT;
- rsrc->flags &= ~UNKNOWN;
- return (DI_WALK_TERMINATE);
-}
-
-/*
- * Find a devinfo node that matches the device argument (dev).
- * This is an expensive search of the whole device tree!
- */
-static rsrc_t *
-locate_node(dev_t dev, di_node_t *root)
-{
- rsrc_t *rsrc;
-
- assert(root != NULL);
-
- if ((rsrc = cache_lookup_bydevt(dev)) != NULL)
- return (rsrc);
-
- (void) di_walk_minor(*root, NULL, 0, (void*)dev, locate_dev);
-
- return (cache_lookup_bydevt(dev));
-}
-
-/*
- * Search for any existing dependency relationships managed by this
- * RCM module.
- */
-static int
-probe_dependencies()
-{
- ttymux_assocs_t links;
- ttymux_assoc_t *asp;
- int cnt, n;
- rsrc_t *ruser;
- rsrc_t *used;
- link_t *link;
- di_node_t root;
-
- cnt = istrioctl(muxfd, TTYMUX_LIST, (void *)0, 0, 0);
-
- _msg(8, ("TTYMUX: Probed %d links [%d]\n", cnt, errno));
-
- if (cnt <= 0)
- return (0);
-
- if ((links.ttymux_assocs = calloc(cnt, sizeof (ttymux_assoc_t))) == 0)
- return (EAGAIN);
-
- links.ttymux_nlinks = cnt;
-
- n = istrioctl(muxfd, TTYMUX_LIST, (void *)&links, sizeof (links), 0);
-
- if (n == -1) {
- _msg(2, ("TTYMUX: Probe error %s\n", strerror(errno)));
- free(links.ttymux_assocs);
- return (0);
- }
-
- asp = (ttymux_assoc_t *)links.ttymux_assocs;
-
- if ((root = di_init("/", DINFOSUBTREE|DINFOMINOR)) == DI_NODE_NIL)
- return (errno);
-
- (void) mutex_lock(&cache_lock);
- for (; cnt--; asp++) {
- _msg(7, ("TTYMUX: Probed: %ld %ld %ld:%ld <-> %ld:%ld\n",
- asp->ttymux_udev, asp->ttymux_ldev,
- major(asp->ttymux_udev), minor(asp->ttymux_udev),
- major(asp->ttymux_ldev), minor(asp->ttymux_ldev)));
- /*
- * The TTYMUX_LIST ioctl can return links relating
- * to potential devices. Such devices are identified
- * in the path field.
- */
- if (asp->ttymux_ldev == NODEV) {
- char buf[PATH_MAX];
-
- if (asp->ttymux_path == NULL ||
- *asp->ttymux_path != '/')
- continue;
-
- if (snprintf(buf, sizeof (buf), "/devices%s",
- asp->ttymux_path) > sizeof (buf))
- continue;
-
- used = cache_get(buf);
- } else {
- used = locate_node(asp->ttymux_ldev, &root);
- }
- if ((ruser = locate_node(asp->ttymux_udev, &root)) == NULL) {
- _msg(7, ("TTYMUX: Probe: %ld:%ld not present\n",
- major(asp->ttymux_udev), minor(asp->ttymux_udev)));
- continue;
- }
- if (used == NULL) {
- _msg(7, ("TTYMUX: Probe: %ld:%ld not present\n",
- major(asp->ttymux_ldev), minor(asp->ttymux_ldev)));
- continue;
- }
- _msg(6, ("TTYMUX: Probe: Restore %s <-> %s (id %d)\n",
- ruser->id, used->id, asp->ttymux_linkid));
-
- link = add_dependency(ruser, used);
-
- if (link != NULL) {
- link->flags = (uint_t)asp->ttymux_ioflag;
- link->linkid = asp->ttymux_linkid;
- link->state = CONNECTED;
- link->connect = mux_connect;
- link->disconnect = mux_disconnect;
- }
- }
- di_fini(root);
- (void) mutex_unlock(&cache_lock);
- free(links.ttymux_assocs);
- return (0);
-}
-
-/*
- * A resource has become available. Re-establish any associations involving
- * the resource.
- */
-static int
-rsrc_available(rsrc_t *rsrc)
-{
- link_t *link;
- rsrc_t *rs;
-
- if (rsrc->dev == NODEV) {
- /*
- * Now that the resource is present obtain its device number.
- * For this to work the node must be present in the /devices
- * tree (see devfsadm(1M) or drvconfig(1M)).
- * We do not use libdevinfo because the node must be present
- * under /devices for the connect step below to work
- * (the node needs to be opened).
- */
- (void) get_devpath(rsrc->id, NULL, &rsrc->dev);
- if (rsrc->dev == NODEV) {
- _msg(4,
- ("Device node %s does not exist\n", rsrc->id));
- /*
- * What does RCM do with failed online notifications.
- */
- return (RCM_FAILURE);
- }
- }
- for (rs = cache_head.next; rs != &cache_tail; rs = rs->next) {
- for (link = rs->dependencies;
- link != NULL;
- link = link->next) {
- if (link->user == rsrc || link->used == rsrc) {
- _msg(6, ("TTYMUX: re-connect\n"));
- (void) link->connect(link);
- }
- }
- }
- return (RCM_SUCCESS);
-}
-
-/*
- * A resource is going away. Tear down any associations involving
- * the resource.
- */
-static int
-rsrc_unavailable(rsrc_t *rsrc)
-{
- link_t *link;
- rsrc_t *rs;
-
- for (rs = cache_head.next; rs != &cache_tail; rs = rs->next) {
- for (link = rs->dependencies;
- link != NULL;
- link = link->next) {
- if (link->user == rsrc || link->used == rsrc) {
- _msg(6, ("TTYMUX: unavailable %s %s\n",
- link->user->id, link->used->id));
- (void) link->disconnect(link);
- }
- }
- }
-
- return (RCM_SUCCESS);
-}
-
-/*
- * Find any resources that are using a given resource (identified by
- * the rsrc argument). The search begins after the resource identified
- * by the next argument. If next is NULL start at the first resource
- * in this RCM modules resource list. If the redundancy argument is
- * greater than zero then a resource which uses rsrc will only be
- * returned if it is associated with >= redundancy dependents.
- *
- * Thus, provided that the caller keeps the list locked it can iterate
- * through all the resources in the cache that depend upon rsrc.
- */
-static rsrc_t *
-get_next_user(rsrc_t *next, rsrc_t *rsrc, int redundancy)
-{
- rsrc_t *src;
- link_t *link;
- int cnt = 0;
- boolean_t inuse;
-
- src = (next != NULL) ? next->next : cache_head.next;
-
- while (src != &cache_tail) {
- inuse = B_FALSE;
-
- for (link = src->dependencies, cnt = 0;
- link != NULL;
- link = link->next) {
-
- if (link->state == CONNECTED)
- cnt++;
-
- if (link->used == rsrc)
- inuse = B_TRUE;
- }
- if (inuse == B_TRUE &&
- (redundancy <= 0 || cnt == redundancy)) {
- return (src);
- }
-
- src = src->next;
- }
-
- _msg(8, ("TTYMUX: count_users(%s) res %d.\n", rsrc->id, cnt));
- return (NULL);
-}
-
-/*
- * Common handler for RCM notifications.
- */
-/*ARGSUSED*/
-static int
-rsrc_change_common(rcm_handle_t *hd, int op, const char *rsrcid, uint_t flag,
- char **reason, rcm_info_t **dependent_reason, void *arg)
-{
- rsrc_t *rsrc, *user;
- int rv, len;
- char *tmp = NULL;
-
- (void) mutex_lock(&cache_lock);
- rsrc = cache_lookup(rsrcid);
- if (rsrc == NULL) {
- /* shouldn't happen because rsrc has been registered */
- (void) mutex_unlock(&cache_lock);
- return (RCM_SUCCESS);
- }
- if ((muxfd = open_file(muxctl, oflags)) == -1) {
- rcm_log_message(RCM_ERROR, _("TTYMUX: %s unavailable: %s\n"),
- muxctl, strerror(errno));
- (void) mutex_unlock(&cache_lock);
- return (RCM_SUCCESS);
- }
- switch (op) {
-
- case TTYMUX_SUSPEND:
- rv = RCM_FAILURE;
- _msg(4, ("TTYMUX: SUSPEND %s operation refused.\n",
- rsrc->id));
- if ((*reason = strdup(TTYMUX_INVALID_ERR)) == NULL) {
- rcm_log_message(RCM_ERROR, TTYMUX_MEMORY_ERR);
- }
- break;
-
- case TTYMUX_REMOVE:
- rsrc->flags |= UNKNOWN;
- rsrc->flags &= ~(PRESENT | REGISTERED);
- rv = RCM_SUCCESS;
- break;
-
- case TTYMUX_OFFLINE:
- user = get_next_user(NULL, rsrc, 1);
- if (flag & RCM_QUERY) {
- rv = ((flag & RCM_FORCE) || (user == NULL)) ?
- RCM_SUCCESS : RCM_FAILURE;
- if (rv == RCM_FAILURE) {
- tmp = TTYMUX_OFFLINE_ERR;
- assert(tmp != NULL);
- len = strlen(tmp) + strlen(user->id) + 2;
- if ((*reason = (char *)malloc(len)) != NULL) {
- (void) snprintf(*reason, len,
- "%s %s", tmp, user->id);
- } else {
- rcm_log_message(RCM_ERROR, TTYMUX_MEMORY_ERR);
- }
- }
-
- } else if (flag & RCM_FORCE) {
- rv = rsrc_unavailable(rsrc);
-
- if (rv == RCM_FAILURE) {
- if ((*reason = strdup(TTYMUX_OFFLINE_FAIL)) ==
- NULL) {
- rcm_log_message(RCM_ERROR,
- TTYMUX_MEMORY_ERR);
- }
- }
-
- } else if (user != NULL) {
- rv = RCM_FAILURE;
- tmp = TTYMUX_OFFLINE_ERR;
- assert(tmp != NULL);
- len = strlen(tmp) + strlen(user->id) + 2;
- if ((*reason = (char *)malloc(len)) != NULL) {
- (void) snprintf(*reason, len,
- "%s %s", tmp, user->id);
- } else {
- rcm_log_message(RCM_ERROR, TTYMUX_MEMORY_ERR);
- }
-
- } else {
- rv = rsrc_unavailable(rsrc);
- if (rv == RCM_FAILURE) {
- if ((*reason = strdup(TTYMUX_OFFLINE_FAIL)) ==
- NULL) {
- rcm_log_message(RCM_ERROR,
- TTYMUX_MEMORY_ERR);
- }
- }
- }
-
- if (rv == RCM_FAILURE) {
- _msg(4, ("TTYMUX: OFFLINE %s operation refused.\n",
- rsrc->id));
-
- } else {
- _msg(4, ("TTYMUX: OFFLINE %s res %d.\n", rsrc->id, rv));
- }
- break;
-
- case TTYMUX_RESUME:
- rv = RCM_FAILURE;
- _msg(4, ("TTYMUX: RESUME %s operation refused.\n",
- rsrc->id));
- if ((*reason = strdup(TTYMUX_INVALID_ERR)) == NULL) {
- rcm_log_message(RCM_ERROR, TTYMUX_MEMORY_ERR);
- }
- break;
-
- case TTYMUX_ONLINE:
- _msg(4, ("TTYMUX: ONLINE %s res %d.\n", rsrc->id, rv));
- rv = rsrc_available(rsrc);
- if (rv == RCM_FAILURE) {
- if ((*reason = strdup(TTYMUX_ONLINE_ERR)) == NULL) {
- rcm_log_message(RCM_ERROR, TTYMUX_MEMORY_ERR);
- }
- }
- break;
- default:
- rv = RCM_FAILURE;
- if ((*reason = strdup(TTYMUX_UNKNOWN_ERR)) == NULL) {
- rcm_log_message(RCM_ERROR, TTYMUX_MEMORY_ERR);
- }
- }
-
- (void) close(muxfd);
- (void) mutex_unlock(&cache_lock);
- return (rv);
-}
-
-static boolean_t
-find_mux_nodes(char *drv)
-{
- di_node_t root, node;
- di_minor_t dim;
- char *devfspath;
- char muxctlname[] = "ctl";
- char muxconname[] = "con";
- int nminors = 0;
-
- (void) strcpy(muxctl, MUXCTLLINK);
- (void) strcpy(muxcon, MUXCONLINK);
- cn_rsrc = NULL;
-
- if ((root = di_init("/", DINFOCPYALL)) == DI_NODE_NIL) {
- rcm_log_message(RCM_WARNING, _("di_init error\n"));
- return (B_FALSE);
- }
-
- node = di_drv_first_node(drv, root);
- if (node == DI_NODE_NIL) {
- _msg(4, ("no node for %s\n", drv));
- di_fini(root);
- return (B_FALSE);
- }
- /*
- * If the device is not a prom node do not continue.
- */
- if (di_nodeid(node) != DI_PROM_NODEID) {
- di_fini(root);
- return (B_FALSE);
- }
- if ((devfspath = di_devfs_path(node)) == NULL) {
- di_fini(root);
- return (B_FALSE);
- }
-
- /*
- * Loop through all the minor nodes the driver (drv) looking
- * for the ctl node (this is the device on which
- * to issue ioctls).
- */
- dim = DI_MINOR_NIL;
- while ((dim = di_minor_next(node, dim)) != DI_MINOR_NIL) {
-
- _msg(7, ("MUXNODES: minor %s\n", di_minor_name(dim)));
-
- if (strcmp(di_minor_name(dim), muxctlname) == 0) {
- if (snprintf(muxctl, sizeof (muxctl),
- "/devices%s:%s", devfspath,
- di_minor_name(dim)) > sizeof (muxctl)) {
- _msg(1, ("muxctl:snprintf error\n"));
- }
- if (++nminors == 2)
- break;
- } else if (strcmp(di_minor_name(dim), muxconname) == 0) {
- if (snprintf(muxcon, sizeof (muxcon),
- "/devices%s:%s", devfspath,
- di_minor_name(dim)) > sizeof (muxcon)) {
- _msg(1, ("muxcon:snprintf error\n"));
- }
- if (++nminors == 2)
- break;
- }
- }
-
- di_devfs_path_free(devfspath);
- di_fini(root);
-
- if ((muxfd = open_file(muxctl, oflags)) != -1) {
-
- if (istrioctl(muxfd, TTYMUX_CONSDEV, (void *)&cn_dev,
- sizeof (cn_dev), 0) != 0) {
- cn_dev = NODEV;
- } else {
- _msg(8, ("MUXNODES: found sys console: %ld:%ld\n",
- major(cn_dev), minor(cn_dev)));
-
- cn_rsrc = cache_create(muxcon, cn_dev);
- if (cn_rsrc != NULL) {
- cn_rsrc->flags |= PRESENT;
- cn_rsrc->flags &= ~UNKNOWN;
- }
- }
- (void) close(muxfd);
-
- if (cn_dev != NODEV)
- return (B_TRUE);
- } else {
- _msg(1, ("TTYMUX: %s unavailable: %s\n",
- muxctl, strerror(errno)));
- }
-
- return (B_FALSE);
-}
-
-/*
- * Update registrations, and return the ops structure.
- */
-struct rcm_mod_ops *
-rcm_mod_init()
-{
- _msg(4, ("TTYMUX: mod_init:\n"));
- cache_head.next = &cache_tail;
- cache_head.prev = NULL;
- cache_tail.prev = &cache_head;
- cache_tail.next = NULL;
- (void) mutex_init(&cache_lock, NULL, NULL);
-
- /*
- * Find the multiplexer ctl and con nodes
- */
- register_rsrcs = find_mux_nodes(TTYMUX_DRVNAME);
-
- return (&tty_ops);
-}
-
-/*
- * Save state and release resources.
- */
-int
-rcm_mod_fini()
-{
- rsrc_t *rsrc;
- link_t *link, *nlink;
-
- _msg(7, ("TTYMUX: freeing cache.\n"));
- (void) mutex_lock(&cache_lock);
- rsrc = cache_head.next;
- while (rsrc != &cache_tail) {
- cache_remove(rsrc);
-
- for (link = rsrc->dependencies; link != NULL; ) {
- nlink = link->next;
- free(link);
- link = nlink;
- }
-
- free_node(rsrc);
- rsrc = cache_head.next;
- }
- (void) mutex_unlock(&cache_lock);
-
- (void) mutex_destroy(&cache_lock);
- return (RCM_SUCCESS);
-}
-
-/*
- * Return a string describing this module.
- */
-const char *
-rcm_mod_info()
-{
- return ("Serial mux device module 1.1");
-}
-
-/*
- * RCM Notification Handlers
- */
-
-static int
-tty_register(rcm_handle_t *hd)
-{
- rsrc_t *rsrc;
- link_t *link;
- int rv;
-
- if (register_rsrcs == B_FALSE)
- return (RCM_SUCCESS);
-
- if ((muxfd = open_file(muxctl, oflags)) == -1) {
- rcm_log_message(RCM_ERROR, _("TTYMUX: %s unavailable: %s\n"),
- muxctl, strerror(errno));
- return (RCM_SUCCESS);
- }
- /*
- * Search for any new dependencies since the last notification or
- * since module was initialisated.
- */
- (void) probe_dependencies();
-
- /*
- * Search the whole cache looking for any unregistered used resources
- * and register them. Note that the 'using resource' (a ttymux device
- * node) is not subject to DR operations so there is no need to
- * register them with the RCM framework.
- */
- (void) mutex_lock(&cache_lock);
- for (rsrc = cache_head.next; rsrc != &cache_tail; rsrc = rsrc->next) {
- _msg(6, ("TTYMUX: REGISTER rsrc %s flags %d\n",
- rsrc->id, rsrc->flags));
-
- if (rsrc->dependencies != NULL &&
- (rsrc->flags & REGISTERED) == 0) {
- _msg(6, ("TTYMUX: Registering rsrc %s\n", rsrc->id));
- rv = rcm_register_interest(hd, rsrc->id, 0, NULL);
- if (rv == RCM_SUCCESS)
- rsrc->flags |= REGISTERED;
- }
-
- for (link = rsrc->dependencies; link != NULL;
- link = link->next) {
- if ((link->used->flags & REGISTERED) != 0)
- continue;
-
- _msg(6, ("TTYMUX: Registering rsrc %s\n",
- link->used->id));
- rv = rcm_register_interest(hd, link->used->id,
- 0, NULL);
- if (rv != RCM_SUCCESS)
- rcm_log_message(RCM_WARNING,
- _("TTYMUX: err %d registering %s\n"),
- rv, link->used->id);
- else
- link->used->flags |= REGISTERED;
- }
- }
-
- (void) mutex_unlock(&cache_lock);
- (void) close(muxfd);
- return (RCM_SUCCESS);
-}
-
-/*
- * Unregister all registrations.
- */
-static int
-tty_unregister(rcm_handle_t *hd)
-{
- rsrc_t *rsrc;
-
- (void) mutex_lock(&cache_lock);
- /*
- * Search every resource in the cache and if it has been registered
- * then unregister it from the RCM framework.
- */
- for (rsrc = cache_head.next; rsrc != &cache_tail; rsrc = rsrc->next) {
- if ((rsrc->flags & REGISTERED) == 0)
- continue;
-
- if (rcm_unregister_interest(hd, rsrc->id, 0) != RCM_SUCCESS)
- rcm_log_message(RCM_WARNING,
- _("TTYMUX: Failed to unregister %s\n"), rsrc->id);
- else
- rsrc->flags &= ~REGISTERED;
- }
- (void) mutex_unlock(&cache_lock);
- return (RCM_SUCCESS);
-}
-
-/*
- * Report resource usage information.
- */
-/*ARGSUSED*/
-static int
-tty_getinfo(rcm_handle_t *hd, char *rsrcid, id_t id, uint_t flag, char **info,
- char **errstr, nvlist_t *proplist, rcm_info_t **depend_info)
-{
- rsrc_t *rsrc, *user;
- char *ru;
- size_t sz;
-
- (void) mutex_lock(&cache_lock);
- rsrc = cache_lookup(rsrcid);
-
- if (rsrc == NULL) {
- (void) mutex_unlock(&cache_lock);
- *errstr = strdup(gettext("Unmanaged resource"));
- return (RCM_FAILURE);
- }
-
- ru = strdup(gettext("Resource Users"));
- user = NULL;
- while ((user = get_next_user(user, rsrc, -1)) != NULL) {
- *info = ru;
- sz = strlen(*info) + strlen(user->id) + 2;
- ru = malloc(sz);
- if (ru == NULL) {
- free(*info);
- *info = NULL;
- break;
- }
- if (snprintf(ru, sz, ": %s%s", *info, user->id) > sz) {
- _msg(4, ("tty_getinfo: snprintf error.\n"));
- }
-
- free(*info);
- }
- *info = ru;
-
- if (*info == NULL) {
- (void) mutex_unlock(&cache_lock);
- *errstr = strdup(gettext("Short of memory resources"));
- return (RCM_FAILURE);
- }
-
- (void) mutex_unlock(&cache_lock);
- return (RCM_SUCCESS);
-}
-
-/*ARGSUSED*/
-static int
-tty_offline(rcm_handle_t *hd, char *rsrc, id_t id, uint_t flags,
- char **reason, rcm_info_t **dependent_reason)
-{
- return (rsrc_change_common(hd, TTYMUX_OFFLINE, rsrc, flags,
- reason, dependent_reason, NULL));
-}
-
-/*ARGSUSED*/
-static int
-tty_remove(rcm_handle_t *hd, char *rsrc, id_t id, uint_t flags,
- char **reason, rcm_info_t **dependent_reason)
-{
- return (rsrc_change_common(hd, TTYMUX_REMOVE, rsrc, flags,
- reason, dependent_reason, NULL));
-}
-
-/*ARGSUSED*/
-static int
-tty_suspend(rcm_handle_t *hd, char *rsrc, id_t id, timespec_t *interval,
- uint_t flag, char **reason, rcm_info_t **dependent_reason)
-{
- return (rsrc_change_common(hd, TTYMUX_SUSPEND, rsrc, flag,
- reason, dependent_reason, (void *)interval));
-}
-
-/*ARGSUSED*/
-static int
-tty_online(rcm_handle_t *hd, char *rsrc, id_t id, uint_t flags,
- char **reason, rcm_info_t **dependent_reason)
-{
- return (rsrc_change_common(hd, TTYMUX_ONLINE, rsrc, flags,
- reason, dependent_reason, NULL));
-}
-
-/*ARGSUSED*/
-static int
-tty_resume(rcm_handle_t *hd, char *rsrc, id_t id, uint_t flags,
- char **reason, rcm_info_t **dependent_reason)
-{
- return (rsrc_change_common(hd, TTYMUX_RESUME, rsrc, flags,
- reason, dependent_reason, NULL));
-}
diff --git a/usr/src/cmd/rcm_daemon/common/ttymux_rcm_impl.h b/usr/src/cmd/rcm_daemon/common/ttymux_rcm_impl.h
deleted file mode 100644
index e1ae3acfb8..0000000000
--- a/usr/src/cmd/rcm_daemon/common/ttymux_rcm_impl.h
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License, Version 1.0 only
- * (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 (c) 2001 by Sun Microsystems, Inc.
- * All rights reserved.
- */
-
-#ifndef _TTYMUX_RCM_IMPL_H
-#define _TTYMUX_RCM_IMPL_H
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifndef lint
-#define _(x) gettext(x)
-#else
-#define _(x) x
-#endif
-
-#define UNKNOWN 1 /* flags */
-#define PRESENT 2 /* flags */
-#define REGISTERED 4 /* flags */
-#define CONNECTED 8 /* flags */
-#define DISCONNECTED 0x10 /* flags */
-
-/* RCM operations */
-#define TTYMUX_OFFLINE 1
-#define TTYMUX_ONLINE 2
-#define TTYMUX_REMOVE 3
-#define TTYMUX_SUSPEND 4
-#define TTYMUX_RESUME 5
-
-/*
- * Representation of a resource.
- * All resources are placed in a cache structured as a doubly linked list
- * (ie the next and prev fields).
- * The dependencies list identifies which resources this resource is
- * depending upon.
- */
-typedef struct rsrc {
- char *id;
- dev_t dev;
- int flags;
- struct rsrc *next;
- struct rsrc *prev;
- struct link *dependencies;
-} rsrc_t;
-
-/*
- * Representation of a pair of resources participating in a
- * dependency relationship
- * The dependency is cast in terms of a resource that is using
- * another resource in order to provide a service.
- * This structure is used to represent a ttymux minor node that
- * has another serial device multiplexed under it. In this
- * case user resource would correspond to the ttymux minor node and the
- * the used resource would correspond to the multiplexed serial device.
- * The linkid field refers to the STREAM's link identifier.
- */
-typedef struct link {
- rsrc_t *user; /* the using resource */
- rsrc_t *used; /* the used resource */
- int linkid; /* STREAM's link identifier */
- uint_t state;
- int flags;
- int (*connect)(struct link *);
- int (*disconnect)(struct link *);
- struct link *next;
-} link_t;
-
-#define MUXCTLLINK "/devices/multiplexer@0,0:ctl"
-#define MUXCONLINK "/devices/multiplexer@0,0:con"
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _TTYMUX_RCM_IMPL_H */
diff --git a/usr/src/cmd/rctladm/Makefile b/usr/src/cmd/rctladm/Makefile
index 79348db834..2a3a3a39c5 100644
--- a/usr/src/cmd/rctladm/Makefile
+++ b/usr/src/cmd/rctladm/Makefile
@@ -35,7 +35,7 @@ include ../Makefile.cmd
CFLAGS += $(CCVERBOSE)
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
POFILE = rctladm_msg.po
XGETFLAGS = -a
FILEMODE = 0555
diff --git a/usr/src/cmd/refer/Makefile b/usr/src/cmd/refer/Makefile
index a07a51f0ac..c9dd6bd267 100644
--- a/usr/src/cmd/refer/Makefile
+++ b/usr/src/cmd/refer/Makefile
@@ -49,7 +49,7 @@ POFILE= refer.po
CERRWARN += -_gcc=-Wno-implicit-function-declaration
CERRWARN += -_gcc=-Wno-parentheses
CERRWARN += -_gcc=-Wno-unused-variable
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/rmdir/Makefile b/usr/src/cmd/rmdir/Makefile
index 4c935458bd..a9b962f2b7 100644
--- a/usr/src/cmd/rmdir/Makefile
+++ b/usr/src/cmd/rmdir/Makefile
@@ -30,7 +30,7 @@ include ../Makefile.cmd
LDLIBS += -lgen
CFLAGS += $(CCVERBOSE)
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
XGETFLAGS += -a -x rmdir.xcl
diff --git a/usr/src/cmd/rmformat/Makefile b/usr/src/cmd/rmformat/Makefile
index 6761060197..87e1e2f323 100644
--- a/usr/src/cmd/rmformat/Makefile
+++ b/usr/src/cmd/rmformat/Makefile
@@ -35,7 +35,7 @@ SRCS= $(OBJS:.o=.c)
LDLIBS += -lsmedia -lvolmgt -ladm -lefi
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/rmmount/Makefile b/usr/src/cmd/rmmount/Makefile
index 2c6d2646af..2723b40ba5 100644
--- a/usr/src/cmd/rmmount/Makefile
+++ b/usr/src/cmd/rmmount/Makefile
@@ -46,7 +46,7 @@ CERRWARN += -_gcc=-Wno-switch
CERRWARN += -_gcc=-Wno-unused-variable
CERRWARN += -_gcc=-Wno-parentheses
CERRWARN += -_gcc=-Wno-unused-function
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/rmvolmgr/Makefile b/usr/src/cmd/rmvolmgr/Makefile
index 589acaab2d..75481251ec 100644
--- a/usr/src/cmd/rmvolmgr/Makefile
+++ b/usr/src/cmd/rmvolmgr/Makefile
@@ -44,7 +44,7 @@ CPPFLAGS += -I$(ROOT)/usr/include/hal
CSTD = $(CSTD_GNU99)
CERRWARN += -_gcc=-Wno-switch
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-unused-variable
CERRWARN += -_gcc=-Wno-parentheses
CERRWARN += -_gcc=-Wno-unused-function
diff --git a/usr/src/cmd/rpcinfo/Makefile b/usr/src/cmd/rpcinfo/Makefile
index 57483c153a..bf58aba9bb 100644
--- a/usr/src/cmd/rpcinfo/Makefile
+++ b/usr/src/cmd/rpcinfo/Makefile
@@ -31,7 +31,7 @@ include ../Makefile.cmd
CPPFLAGS= -DPORTMAP $(CPPFLAGS.master)
LDLIBS += -lnsl
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
.KEEP_STATE:
diff --git a/usr/src/cmd/sa/Makefile b/usr/src/cmd/sa/Makefile
index 8456d9fead..1b5e2b9fd6 100644
--- a/usr/src/cmd/sa/Makefile
+++ b/usr/src/cmd/sa/Makefile
@@ -33,7 +33,7 @@ include ../Makefile.cmd
ROOTMANIFESTDIR = $(ROOTSVCSYSTEM)
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
SMOFF += all_func_returns
diff --git a/usr/src/cmd/sendmail/Makefile.cmd b/usr/src/cmd/sendmail/Makefile.cmd
index d3378329bd..7434d2b261 100644
--- a/usr/src/cmd/sendmail/Makefile.cmd
+++ b/usr/src/cmd/sendmail/Makefile.cmd
@@ -30,7 +30,7 @@ CPPFLAGS.sm= $(CPPFLAGS.master) -DSOLARIS=2$(RELEASE_MINOR)00 \
-D_FILE_OFFSET_BITS=64
CERRWARN += -_gcc=-Wno-clobbered
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-implicit-function-declaration
CERRWARN += -_gcc=-Wno-empty-body
CERRWARN += -_gcc=-Wno-unused-variable
diff --git a/usr/src/cmd/setfacl/Makefile b/usr/src/cmd/setfacl/Makefile
index 5d03563af4..5f70a8f4de 100644
--- a/usr/src/cmd/setfacl/Makefile
+++ b/usr/src/cmd/setfacl/Makefile
@@ -30,7 +30,7 @@ include ../Makefile.cmd
CERRWARN += -_gcc=-Wno-unused-variable
CERRWARN += -_gcc=-Wno-implicit-function-declaration
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/sf880drd/Makefile b/usr/src/cmd/sf880drd/Makefile
index a37fdd6da5..da325e400a 100644
--- a/usr/src/cmd/sf880drd/Makefile
+++ b/usr/src/cmd/sf880drd/Makefile
@@ -42,7 +42,7 @@ LDLIBS += -lcfgadm
CERRWARN += -_gcc=-Wno-switch
CERRWARN += -_gcc=-Wno-unused-variable
CERRWARN += -_gcc=-Wno-unused-function
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
PSMPROG = $(USR_PSM_LIB_DIR)/$(PROG)
diff --git a/usr/src/cmd/sgs/ar/Makefile.com b/usr/src/cmd/sgs/ar/Makefile.com
index 99e73f70ce..0ea19dc3a8 100644
--- a/usr/src/cmd/sgs/ar/Makefile.com
+++ b/usr/src/cmd/sgs/ar/Makefile.com
@@ -43,7 +43,7 @@ CPPFLAGS= -I. -I../../include $(CPPFLAGS.master) -I$(ELFCAP)
CFLAGS += $(CCVERBOSE)
CSTD= $(CSTD_GNU99)
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
SMOFF += signed
diff --git a/usr/src/cmd/sgs/dump/Makefile.com b/usr/src/cmd/sgs/dump/Makefile.com
index 2224b6ffe1..e857d76a95 100644
--- a/usr/src/cmd/sgs/dump/Makefile.com
+++ b/usr/src/cmd/sgs/dump/Makefile.com
@@ -44,7 +44,7 @@ LLDFLAGS = '$(LDPASS)-R$$ORIGIN/../../lib'
LLDFLAGS64 = '$(LDPASS)-R$$ORIGIN/../../../lib/$(MACH64)'
LDFLAGS += $(LLDFLAGS)
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
SMOFF += indenting
diff --git a/usr/src/cmd/sgs/elfdump/Makefile.com b/usr/src/cmd/sgs/elfdump/Makefile.com
index 5d5c1f4345..a82d85307e 100644
--- a/usr/src/cmd/sgs/elfdump/Makefile.com
+++ b/usr/src/cmd/sgs/elfdump/Makefile.com
@@ -57,7 +57,7 @@ LDFLAGS += $(VERSREF) $(CC_USE_PROTO) $(MAPOPT) $(LLDFLAGS)
LDLIBS += $(ELFLIBDIR) -lelf $(LDDBGLIBDIR) $(LDDBG_LIB) \
$(CONVLIBDIR) $(CONV_LIB)
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/sgs/elfedit/Makefile.com b/usr/src/cmd/sgs/elfedit/Makefile.com
index 276d11972e..99b630ff47 100644
--- a/usr/src/cmd/sgs/elfedit/Makefile.com
+++ b/usr/src/cmd/sgs/elfedit/Makefile.com
@@ -53,7 +53,7 @@ LDLIBS += $(ELFLIBDIR) -lelf $(LDDBGLIBDIR) $(LDDBG_LIB) \
$(CONVLIBDIR) $(CONV_LIB) -ltecla
CERRWARN += -_gcc=-Wno-switch
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
BLTDEFS = msg.h
BLTDATA = msg.c
diff --git a/usr/src/cmd/sgs/elfedit/modules/Makefile.com b/usr/src/cmd/sgs/elfedit/modules/Makefile.com
index e49e89a81f..e9de1523b9 100644
--- a/usr/src/cmd/sgs/elfedit/modules/Makefile.com
+++ b/usr/src/cmd/sgs/elfedit/modules/Makefile.com
@@ -99,7 +99,7 @@ LDFLAGS += $(CC_USE_PROTO) $(LLDFLAGS)
DYNFLAGS += $(VERSREF)
CERRWARN += -_gcc=-Wno-switch
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
BLTDEFS = $(ELFEDITLIBS:%.so=%_msg.h)
BLTDATA = $(ELFEDITLIBS:%.so=%_msg.c)
diff --git a/usr/src/cmd/sgs/elfwrap/Makefile.com b/usr/src/cmd/sgs/elfwrap/Makefile.com
index a167760c6b..fa84c86328 100644
--- a/usr/src/cmd/sgs/elfwrap/Makefile.com
+++ b/usr/src/cmd/sgs/elfwrap/Makefile.com
@@ -56,7 +56,7 @@ LLDFLAGS64 =
LDFLAGS += $(VERSREF) $(CC_USE_PROTO) $(MAPOPTS) $(LLDFLAGS)
LDLIBS += $(ELFLIBDIR) -lelf $(CONVLIBDIR) $(CONV_LIB)
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
BLTDEFS = msg.h
BLTDATA = msg.c
diff --git a/usr/src/cmd/sgs/error/i386/Makefile b/usr/src/cmd/sgs/error/i386/Makefile
index 9d08117798..3c9053e83e 100644
--- a/usr/src/cmd/sgs/error/i386/Makefile
+++ b/usr/src/cmd/sgs/error/i386/Makefile
@@ -43,7 +43,7 @@ CPPFLAGS= $(INCLIST) $(DEFLIST) $(CPPFLAGS.master)
CFLAGS += $(CCVERBOSE)
CSTD= $(CSTD_GNU99)
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-parentheses
SMOFF += no_if_block,indenting
diff --git a/usr/src/cmd/sgs/error/sparc/Makefile b/usr/src/cmd/sgs/error/sparc/Makefile
index 029bcd6f7d..d5520de183 100644
--- a/usr/src/cmd/sgs/error/sparc/Makefile
+++ b/usr/src/cmd/sgs/error/sparc/Makefile
@@ -40,7 +40,7 @@ INCLIST= -I../common
DEFLIST= -DELF
CPPFLAGS= $(INCLIST) $(DEFLIST) $(CPPFLAGS.master)
CFLAGS += $(CCVERBOSE)
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-parentheses
CSTD= $(CSTD_GNU99)
diff --git a/usr/src/cmd/sgs/gprof/Makefile.com b/usr/src/cmd/sgs/gprof/Makefile.com
index 4dd3a736aa..1a46e900cb 100644
--- a/usr/src/cmd/sgs/gprof/Makefile.com
+++ b/usr/src/cmd/sgs/gprof/Makefile.com
@@ -44,7 +44,7 @@ CPPFLAGS= $(INCLIST) $(DEFLIST) $(CPPFLAGS.master) -I$(ELFCAP)
CFLAGS += $(CCVERBOSE)
CSTD= $(CSTD_GNU99)
LDLIBS += $(CONVLIBDIR) $(CONV_LIB) $(ELFLIBDIR) -lelf
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/sgs/lex/Makefile.com b/usr/src/cmd/sgs/lex/Makefile.com
index f2d2c37388..ea2224b2d0 100644
--- a/usr/src/cmd/sgs/lex/Makefile.com
+++ b/usr/src/cmd/sgs/lex/Makefile.com
@@ -49,7 +49,7 @@ SRCDIR = ../common
CSTD= $(CSTD_GNU99)
CERRWARN += -_gcc=-Wno-unused-label
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-parentheses
# Override default source file derivation rule (in Makefile.lib)
diff --git a/usr/src/cmd/sgs/libelf/Makefile.com b/usr/src/cmd/sgs/libelf/Makefile.com
index c715eba55e..35df043a20 100644
--- a/usr/src/cmd/sgs/libelf/Makefile.com
+++ b/usr/src/cmd/sgs/libelf/Makefile.com
@@ -68,7 +68,7 @@ DYNFLAGS += $(VERSREF)
LDLIBS += $(CONVLIBDIR) $(CONV_LIB) -lc
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
SMOFF += indenting
diff --git a/usr/src/cmd/sgs/libld/Makefile.com b/usr/src/cmd/sgs/libld/Makefile.com
index b007c46bad..c85abded8f 100644
--- a/usr/src/cmd/sgs/libld/Makefile.com
+++ b/usr/src/cmd/sgs/libld/Makefile.com
@@ -88,7 +88,7 @@ SRCDIR = ../common
CERRWARN += -_gcc=-Wno-unused-value
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-switch
CERRWARN += -_gcc=-Wno-char-subscripts
CERRWARN += -_gcc=-Wno-type-limits
diff --git a/usr/src/cmd/sgs/liblddbg/Makefile.com b/usr/src/cmd/sgs/liblddbg/Makefile.com
index 3cf7318715..76e161501f 100644
--- a/usr/src/cmd/sgs/liblddbg/Makefile.com
+++ b/usr/src/cmd/sgs/liblddbg/Makefile.com
@@ -58,7 +58,7 @@ include $(SRC)/cmd/sgs/Makefile.com
SRCDIR = ../common
CERRWARN += -_gcc=-Wno-unused-value
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-parentheses
CPPFLAGS += -I$(SRCBASE)/lib/libc/inc
diff --git a/usr/src/cmd/sgs/librtld/Makefile.com b/usr/src/cmd/sgs/librtld/Makefile.com
index 3c397c933c..bc6772751e 100644
--- a/usr/src/cmd/sgs/librtld/Makefile.com
+++ b/usr/src/cmd/sgs/librtld/Makefile.com
@@ -50,7 +50,7 @@ LDLIBS += $(CONVLIBDIR) $(CONV_LIB) $(ELFLIBDIR) -lelf -lc
CERRWARN += -_gcc=-Wno-parentheses
CERRWARN += -_gcc=-Wno-unused-value
CERRWARN += -_gcc=-Wno-type-limits
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
BLTDEFS= msg.h
BLTDATA= msg.c
diff --git a/usr/src/cmd/sgs/librtld_db/Makefile.com b/usr/src/cmd/sgs/librtld_db/Makefile.com
index 46f35529b2..13ce445558 100644
--- a/usr/src/cmd/sgs/librtld_db/Makefile.com
+++ b/usr/src/cmd/sgs/librtld_db/Makefile.com
@@ -40,7 +40,7 @@ CPPFLAGS += -I$(SRCBASE)/lib/libc/inc
DYNFLAGS += $(VERSREF)
LDLIBS += $(CONVLIBDIR) $(CONV_LIB) -lc
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
BLTDEFS= msg.h
BLTDATA= msg.c
diff --git a/usr/src/cmd/sgs/m4/i386/Makefile b/usr/src/cmd/sgs/m4/i386/Makefile
index 1fe2b9b882..6d12f01c06 100644
--- a/usr/src/cmd/sgs/m4/i386/Makefile
+++ b/usr/src/cmd/sgs/m4/i386/Makefile
@@ -56,7 +56,7 @@ CSTD= $(CSTD_GNU99)
CERRWARN += -_gcc=-Wno-parentheses
CERRWARN += -_gcc=-Wno-unused-label
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CLEANFILES += $(BLTSRCS)
diff --git a/usr/src/cmd/sgs/m4/sparc/Makefile b/usr/src/cmd/sgs/m4/sparc/Makefile
index 4581269a08..3847891929 100644
--- a/usr/src/cmd/sgs/m4/sparc/Makefile
+++ b/usr/src/cmd/sgs/m4/sparc/Makefile
@@ -54,7 +54,7 @@ CPPFLAGS= $(INCLIST) $(DEFLIST) $(CPPFLAGS.master)
CFLAGS += $(CCVERBOSE)
CERRWARN += -_gcc=-Wno-parentheses
CERRWARN += -_gcc=-Wno-unused-label
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CSTD= $(CSTD_GNU99)
CLEANFILES += $(BLTSRCS)
diff --git a/usr/src/cmd/sgs/mcs/Makefile.com b/usr/src/cmd/sgs/mcs/Makefile.com
index 6970c04bd0..b732c5c143 100644
--- a/usr/src/cmd/sgs/mcs/Makefile.com
+++ b/usr/src/cmd/sgs/mcs/Makefile.com
@@ -48,7 +48,7 @@ LLDFLAGS64 = '-R$$ORIGIN/../../../lib/$(MACH64)'
LDFLAGS += $(VERSREF) $(LLDFLAGS)
LDLIBS += $(CONVLIBDIR) $(CONV_LIB) $(ELFLIBDIR) -lelf
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
SRCS = $(COMOBJS:%.o=../common/%.c) \
$(TOOLSOBJS:%.o=$(SGSTOOLS)/common/%.c)
diff --git a/usr/src/cmd/sgs/prof/Makefile.com b/usr/src/cmd/sgs/prof/Makefile.com
index 8b5a907718..d713f56acc 100644
--- a/usr/src/cmd/sgs/prof/Makefile.com
+++ b/usr/src/cmd/sgs/prof/Makefile.com
@@ -43,7 +43,7 @@ INCLIST= -I../common -I../../include -I../../include/$(MACH)
CPPFLAGS= $(INCLIST) $(DEFLIST) $(CPPFLAGS.master) -I$(ELFCAP)
CFLAGS += $(CCVERBOSE)
CSTD= $(CSTD_GNU99)
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/sgs/rtld/Makefile.com b/usr/src/cmd/sgs/rtld/Makefile.com
index 1bfd593cee..fbdede2a9e 100644
--- a/usr/src/cmd/sgs/rtld/Makefile.com
+++ b/usr/src/cmd/sgs/rtld/Makefile.com
@@ -87,7 +87,7 @@ ASFLAGS= -P -D_ASM $(CPPFLAGS)
LDLIB = -L ../../libld/$(MACH)
RTLDLIB = -L ../../librtld/$(MACH)
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-unused-variable
CERRWARN += -_gcc=-Wno-switch
diff --git a/usr/src/cmd/sgs/rtld/mdbmod/Makefile.com b/usr/src/cmd/sgs/rtld/mdbmod/Makefile.com
index 795b627bd7..e7cfe1137f 100644
--- a/usr/src/cmd/sgs/rtld/mdbmod/Makefile.com
+++ b/usr/src/cmd/sgs/rtld/mdbmod/Makefile.com
@@ -48,7 +48,7 @@ SGSMSGTARG= ../common/rtld.msg
SGSMSGALL= ../common/rtld.msg
SGSMSGFLAGS += -h $(BLTDEFS) -d $(BLTDATA)
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
MSGSRCS= $(COMOBJS:%.o=../common/%.c) $(BLTDATA)
diff --git a/usr/src/cmd/sgs/yacc/Makefile.com b/usr/src/cmd/sgs/yacc/Makefile.com
index a68a388a87..17a509ca87 100644
--- a/usr/src/cmd/sgs/yacc/Makefile.com
+++ b/usr/src/cmd/sgs/yacc/Makefile.com
@@ -67,7 +67,7 @@ CSTD= $(CSTD_GNU99)
CFLAGS += $(CCVERBOSE)
CFLAGS64 += $(CCVERBOSE)
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/smbsrv/smbadm/Makefile b/usr/src/cmd/smbsrv/smbadm/Makefile
index bfcac47d98..8f7b43a3e3 100644
--- a/usr/src/cmd/smbsrv/smbadm/Makefile
+++ b/usr/src/cmd/smbsrv/smbadm/Makefile
@@ -37,7 +37,7 @@ LDFLAGS += -R/usr/lib/smbsrv
.KEEP_STATE:
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
SMOFF += free
diff --git a/usr/src/cmd/smserverd/Makefile b/usr/src/cmd/smserverd/Makefile
index ac01543191..878f50a73c 100644
--- a/usr/src/cmd/smserverd/Makefile
+++ b/usr/src/cmd/smserverd/Makefile
@@ -46,7 +46,7 @@ LDLIBS += -lnsl -lbsm
CPPFLAGS += -D_REENTRANT
CFLAGS += $(CCVERBOSE)
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-unused-variable
# not linted
diff --git a/usr/src/cmd/sort/Makefile.com b/usr/src/cmd/sort/Makefile.com
index 75affc95a3..47bec7879a 100644
--- a/usr/src/cmd/sort/Makefile.com
+++ b/usr/src/cmd/sort/Makefile.com
@@ -86,7 +86,7 @@ CPPFLAGS += -D_FILE_OFFSET_BITS=64
LINTFLAGS += -U_FILE_OFFSET_BITS
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-unused-function
# not linted
diff --git a/usr/src/cmd/stat/iostat/Makefile b/usr/src/cmd/stat/iostat/Makefile
index 36142d5a8a..0fb3c81080 100644
--- a/usr/src/cmd/stat/iostat/Makefile
+++ b/usr/src/cmd/stat/iostat/Makefile
@@ -32,7 +32,7 @@ include $(SRC)/cmd/stat/Makefile.stat
LDLIBS += -lkstat -ldevinfo -lavl
CFLAGS += $(CCVERBOSE) -I${STATCOMMONDIR}
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-switch
CERRWARN += -_gcc=-Wno-parentheses
FILEMODE= 0555
diff --git a/usr/src/cmd/stat/kstat/Makefile b/usr/src/cmd/stat/kstat/Makefile
index 97b1863e08..668c8ffec8 100644
--- a/usr/src/cmd/stat/kstat/Makefile
+++ b/usr/src/cmd/stat/kstat/Makefile
@@ -32,7 +32,7 @@ include $(SRC)/cmd/stat/Makefile.stat
LDLIBS += -lavl -lcmdutils -ldevinfo -lgen -lkstat
CFLAGS += $(CCVERBOSE) -I${STATCOMMONDIR}
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-switch
CERRWARN += -_gcc=-Wno-parentheses
diff --git a/usr/src/cmd/stat/mpstat/Makefile b/usr/src/cmd/stat/mpstat/Makefile
index fd3d57dafb..8e34815c32 100644
--- a/usr/src/cmd/stat/mpstat/Makefile
+++ b/usr/src/cmd/stat/mpstat/Makefile
@@ -32,7 +32,7 @@ include $(SRC)/cmd/stat/Makefile.stat
LDLIBS += -ldevinfo -lkstat -lavl
CFLAGS += $(CCVERBOSE) -I${STATCOMMONDIR}
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-switch
CERRWARN += -_gcc=-Wno-parentheses
FILEMODE= 0555
diff --git a/usr/src/cmd/stat/vmstat/Makefile b/usr/src/cmd/stat/vmstat/Makefile
index 6827f634a7..fcbbec9071 100644
--- a/usr/src/cmd/stat/vmstat/Makefile
+++ b/usr/src/cmd/stat/vmstat/Makefile
@@ -34,7 +34,7 @@ include $(SRC)/cmd/stat/Makefile.stat
LDLIBS += -ldevinfo -lkstat -lavl
CFLAGS += $(CCVERBOSE) -I${STATCOMMONDIR}
CERRWARN += -_gcc=-Wno-switch
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-parentheses
SMOFF += signed
diff --git a/usr/src/cmd/stmsboot/Makefile b/usr/src/cmd/stmsboot/Makefile
index 8e97f0f467..f662b20763 100644
--- a/usr/src/cmd/stmsboot/Makefile
+++ b/usr/src/cmd/stmsboot/Makefile
@@ -40,7 +40,7 @@ ROOTFSLIB_MPXIO = $(ROOT)/lib/mpxio
ROOTMANIFESTDIR = $(ROOTSVCSYSTEMDEVICE)
LDLIBS += -ldevinfo -ldevid -lnvpair -lumem
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
.KEEP_STATE:
diff --git a/usr/src/cmd/streams/strcmd/Makefile b/usr/src/cmd/streams/strcmd/Makefile
index ce0aa9f71e..905aef36b5 100644
--- a/usr/src/cmd/streams/strcmd/Makefile
+++ b/usr/src/cmd/streams/strcmd/Makefile
@@ -26,7 +26,7 @@ PROG= strchg strconf
include ../../Makefile.cmd
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
.KEEP_STATE:
diff --git a/usr/src/cmd/strings/Makefile.com b/usr/src/cmd/strings/Makefile.com
index 36fc42dd15..daaa1ad8fa 100644
--- a/usr/src/cmd/strings/Makefile.com
+++ b/usr/src/cmd/strings/Makefile.com
@@ -33,7 +33,7 @@ LDLIBS += -lelf
CFLAGS += $(CCVERBOSE)
CFLAGS64 += $(CCVERBOSE)
CERRWARN += -_gcc=-Wno-switch
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
.KEEP_STATE:
diff --git a/usr/src/cmd/sunpc/other/Makefile b/usr/src/cmd/sunpc/other/Makefile
index bd366ffe4e..b5c0d20801 100644
--- a/usr/src/cmd/sunpc/other/Makefile
+++ b/usr/src/cmd/sunpc/other/Makefile
@@ -30,7 +30,7 @@ SRCS= ${PROG:%=%.c}
include ../../Makefile.cmd
CERRWARN += -_gcc=-Wno-implicit-function-declaration
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-unused-variable
# not linted
diff --git a/usr/src/cmd/svc/configd/Makefile b/usr/src/cmd/svc/configd/Makefile
index 419ca6248b..b90b64e302 100644
--- a/usr/src/cmd/svc/configd/Makefile
+++ b/usr/src/cmd/svc/configd/Makefile
@@ -61,7 +61,7 @@ CERRWARN += -_gcc=-Wno-type-limits
CERRWARN += -_gcc=-Wno-unused-label
CERRWARN += -_gcc=-Wno-unused-variable
CERRWARN += -_gcc=-Wno-unused-function
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# strange false positive
SMOFF += free
diff --git a/usr/src/cmd/svc/lsvcrun/Makefile b/usr/src/cmd/svc/lsvcrun/Makefile
index 4eda2674db..91634e8b32 100644
--- a/usr/src/cmd/svc/lsvcrun/Makefile
+++ b/usr/src/cmd/svc/lsvcrun/Makefile
@@ -35,7 +35,7 @@ include ../../Makefile.cmd
LDLIBS += -lcontract -lscf -luutil
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
lint := LINTFLAGS = -ux
diff --git a/usr/src/cmd/svc/mfstscan/Makefile b/usr/src/cmd/svc/mfstscan/Makefile
index 5a24abb0ca..64bcea95b8 100644
--- a/usr/src/cmd/svc/mfstscan/Makefile
+++ b/usr/src/cmd/svc/mfstscan/Makefile
@@ -44,7 +44,7 @@ CPPFLAGS += -I../common
LDLIBS += -lscf -luutil -lmd5
CLOBBERFILES += $(POFILES)
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-unused-label
lint := LINTFLAGS = -ux -erroff=E_GLOBAL_COULD_BE_STATIC2
diff --git a/usr/src/cmd/svc/profile/Makefile b/usr/src/cmd/svc/profile/Makefile
index 8538e630f8..8c44470471 100644
--- a/usr/src/cmd/svc/profile/Makefile
+++ b/usr/src/cmd/svc/profile/Makefile
@@ -46,7 +46,6 @@ PROFILESRCS = \
platform_SUNW,SPARC-Enterprise.xml \
platform_SUNW,Sun-Fire-880.xml \
platform_SUNW,Sun-Fire.xml \
- platform_SUNW,UltraSPARC-IIi-Netract.xml \
platform_none.xml \
platform_sun4v.xml
@@ -68,13 +67,6 @@ install: all $(PROFILES)
$(RM) $(ROOTPROFILE)/platform_SUNW,Sun-Fire-V890.xml
$(LN) $(ROOTPROFILE)/platform_SUNW,Sun-Fire-880.xml \
$(ROOTPROFILE)/platform_SUNW,Sun-Fire-V890.xml
- # SUNW,UltraSPARC-IIe-NetraCT-[46]0
- $(RM) $(ROOTPROFILE)/platform_SUNW,UltraSPARC-IIe-NetraCT-40.xml
- $(RM) $(ROOTPROFILE)/platform_SUNW,UltraSPARC-IIe-NetraCT-60.xml
- $(LN) $(ROOTPROFILE)/platform_SUNW,UltraSPARC-IIi-Netract.xml \
- $(ROOTPROFILE)/platform_SUNW,UltraSPARC-IIe-NetraCT-40.xml
- $(LN) $(ROOTPROFILE)/platform_SUNW,UltraSPARC-IIi-Netract.xml \
- $(ROOTPROFILE)/platform_SUNW,UltraSPARC-IIe-NetraCT-60.xml
$(ROOTPROFILE)/%: %
$(INS.file)
diff --git a/usr/src/cmd/svc/profile/platform_SUNW,UltraSPARC-IIi-Netract.xml b/usr/src/cmd/svc/profile/platform_SUNW,UltraSPARC-IIi-Netract.xml
deleted file mode 100644
index 50ae263b90..0000000000
--- a/usr/src/cmd/svc/profile/platform_SUNW,UltraSPARC-IIi-Netract.xml
+++ /dev/null
@@ -1,40 +0,0 @@
-<?xml version='1.0'?>
-<!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'>
-<!--
- Copyright 2005 Sun Microsystems, Inc. All rights reserved.
- Use is subject to license terms.
-
- CDDL HEADER START
-
- The contents of this file are subject to the terms of the
- Common Development and Distribution License, Version 1.0 only
- (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
-
- ident "%Z%%M% %I% %E% SMI"
-
- NOTE: This service profile is not editable; its contents will be
- overwritten by package or patch operations, including operating
- system upgrade.
-
- Profile for NetraCT and related platforms.
--->
-<service_bundle type='profile' name='default'>
- <service name='platform/sun4u/efdaemon' version='1'
- type='service'>
- <instance name='default' enabled='true'/>
- </service>
-</service_bundle>
diff --git a/usr/src/cmd/svc/startd/Makefile b/usr/src/cmd/svc/startd/Makefile
index 1f71fdbc6c..d9b1c523a7 100644
--- a/usr/src/cmd/svc/startd/Makefile
+++ b/usr/src/cmd/svc/startd/Makefile
@@ -71,7 +71,7 @@ CPPFLAGS += -I. -I../common
CERRWARN += -_gcc=-Wno-parentheses
CERRWARN += -_gcc=-Wno-unused-label
CERRWARN += -_gcc=-Wno-switch
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# these look like real bugs here, but ...
SMOFF += impossible_mask,signed_integer_overflow_check
diff --git a/usr/src/cmd/svc/svcadm/Makefile b/usr/src/cmd/svc/svcadm/Makefile
index 1a6a0dd35c..fae2142dac 100644
--- a/usr/src/cmd/svc/svcadm/Makefile
+++ b/usr/src/cmd/svc/svcadm/Makefile
@@ -35,7 +35,7 @@ POFILE = $(PROG)_all.po
LDLIBS += -lscf -luutil -lcontract
CERRWARN += -_gcc=-Wno-switch
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
lint := LINTFLAGS = -ux
diff --git a/usr/src/cmd/svc/svccfg/Makefile b/usr/src/cmd/svc/svccfg/Makefile
index 0e50a1a293..2e32677477 100644
--- a/usr/src/cmd/svc/svccfg/Makefile
+++ b/usr/src/cmd/svc/svccfg/Makefile
@@ -77,7 +77,7 @@ LDFLAGS += $(MAPOPTS)
CERRWARN += -_gcc=-Wno-unused-label
CERRWARN += -_gcc=-Wno-implicit-function-declaration
CERRWARN += -_gcc=-Wno-switch
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-unused-variable
CERRWARN += -_gcc=-Wno-parentheses
diff --git a/usr/src/cmd/svc/svcprop/Makefile b/usr/src/cmd/svc/svcprop/Makefile
index 4e1f4d4981..13b1da5368 100644
--- a/usr/src/cmd/svc/svcprop/Makefile
+++ b/usr/src/cmd/svc/svcprop/Makefile
@@ -35,7 +35,7 @@ LDLIBS += -lscf -luutil
lint := LINTFLAGS = -ux
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
.KEEP_STATE:
diff --git a/usr/src/cmd/svc/svcs/Makefile b/usr/src/cmd/svc/svcs/Makefile
index 36bd39d567..506f5e9bcf 100644
--- a/usr/src/cmd/svc/svcs/Makefile
+++ b/usr/src/cmd/svc/svcs/Makefile
@@ -39,7 +39,7 @@ CPPFLAGS += -I ../common
lint := LINTFLAGS = -mux
CERRWARN += -_gcc=-Wno-unused-label
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-parentheses
.KEEP_STATE:
diff --git a/usr/src/cmd/svr4pkg/Makefile.svr4pkg b/usr/src/cmd/svr4pkg/Makefile.svr4pkg
index ff43ccf865..9d2e11de89 100644
--- a/usr/src/cmd/svr4pkg/Makefile.svr4pkg
+++ b/usr/src/cmd/svr4pkg/Makefile.svr4pkg
@@ -36,7 +36,7 @@ CPPFLAGS += -I$(SRC)/cmd/svr4pkg/hdrs \
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-address
# multiple issues in this old code
diff --git a/usr/src/cmd/svr4pkg/libinst/Makefile b/usr/src/cmd/svr4pkg/libinst/Makefile
index 9abf6ebd7a..91e87f6173 100644
--- a/usr/src/cmd/svr4pkg/libinst/Makefile
+++ b/usr/src/cmd/svr4pkg/libinst/Makefile
@@ -65,7 +65,7 @@ LINTFLAGS += -un
CERRWARN += -_gcc=-Wno-parentheses
CERRWARN += -_gcc=-Wno-implicit-function-declaration
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-clobbered
CERRWARN += -_gcc=-Wno-unused-variable
diff --git a/usr/src/cmd/swap/Makefile.com b/usr/src/cmd/swap/Makefile.com
index 54361a42d5..fce9598f5c 100644
--- a/usr/src/cmd/swap/Makefile.com
+++ b/usr/src/cmd/swap/Makefile.com
@@ -33,7 +33,7 @@ include ../../Makefile.cmd
CFLAGS += $(CCVERBOSE)
CPPFLAGS += -D_LARGEFILE64_SOURCE
CFLAGS64 += $(CCVERBOSE)
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/syseventadm/Makefile b/usr/src/cmd/syseventadm/Makefile
index 91c515b00f..f877f7f9c4 100644
--- a/usr/src/cmd/syseventadm/Makefile
+++ b/usr/src/cmd/syseventadm/Makefile
@@ -32,7 +32,7 @@ OBJS = $(PROG).o
include ../Makefile.cmd
FILEMODE= 0555
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
POFILES = $(SRCS:.c=.po)
diff --git a/usr/src/cmd/syseventd/daemons/syseventd/Makefile b/usr/src/cmd/syseventd/daemons/syseventd/Makefile
index b599ae9560..9c7af4c462 100644
--- a/usr/src/cmd/syseventd/daemons/syseventd/Makefile
+++ b/usr/src/cmd/syseventd/daemons/syseventd/Makefile
@@ -29,7 +29,7 @@ SRCS = syseventd.c sysevent_signal.c sysevent_client.c
include ../Makefile.com
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
.KEEP_STATE:
diff --git a/usr/src/cmd/syseventd/modules/sysevent_conf_mod/Makefile b/usr/src/cmd/syseventd/modules/sysevent_conf_mod/Makefile
index 94cba19b73..5174d57225 100644
--- a/usr/src/cmd/syseventd/modules/sysevent_conf_mod/Makefile
+++ b/usr/src/cmd/syseventd/modules/sysevent_conf_mod/Makefile
@@ -32,7 +32,7 @@ include ../Makefile.com
LDLIBS += -lnvpair
CPPFLAGS += -I ../../daemons/syseventconfd
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# strange smatch false positive
SMOFF += allocating_enough_data
diff --git a/usr/src/cmd/syseventd/modules/zfs_mod/Makefile b/usr/src/cmd/syseventd/modules/zfs_mod/Makefile
index 13dcc10c90..8b8c2c6c42 100644
--- a/usr/src/cmd/syseventd/modules/zfs_mod/Makefile
+++ b/usr/src/cmd/syseventd/modules/zfs_mod/Makefile
@@ -29,7 +29,7 @@ include ../Makefile.com
CPPFLAGS += -I../../../../lib/libc/inc
LDLIBS += -lzfs -ldevid -lcmdutils -lnvpair
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
.KEEP_STATE:
diff --git a/usr/src/cmd/syslogd/Makefile.com b/usr/src/cmd/syslogd/Makefile.com
index 0898493b3d..6d9c1a35f5 100644
--- a/usr/src/cmd/syslogd/Makefile.com
+++ b/usr/src/cmd/syslogd/Makefile.com
@@ -35,7 +35,7 @@ LLOBJS= $(OBJS:%.o=%.ll)
include ../../Makefile.cmd
$(PROG) lint := LDLIBS += -lscf -lnsl
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/tar/Makefile b/usr/src/cmd/tar/Makefile
index 9a026b00b4..c3096a8220 100644
--- a/usr/src/cmd/tar/Makefile
+++ b/usr/src/cmd/tar/Makefile
@@ -38,7 +38,7 @@ LINTFLAGS += -u
LDLIBS += -lsec -lcmdutils -lnvpair -ltsol
CFLAGS += $(CCVERBOSE)
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/tbl/Makefile b/usr/src/cmd/tbl/Makefile
index cae02cb4f7..12eb8c3ae2 100644
--- a/usr/src/cmd/tbl/Makefile
+++ b/usr/src/cmd/tbl/Makefile
@@ -39,7 +39,7 @@ POFILE= tbl.po
CERRWARN += -_gcc=-Wno-implicit-function-declaration
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-char-subscripts
# not linted
diff --git a/usr/src/cmd/tcopy/Makefile b/usr/src/cmd/tcopy/Makefile
index 3e29556b5f..c5230f1c77 100644
--- a/usr/src/cmd/tcopy/Makefile
+++ b/usr/src/cmd/tcopy/Makefile
@@ -30,7 +30,7 @@ include ../Makefile.cmd
CERRWARN += -_gcc=-Wno-implicit-function-declaration
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-extra
# not linted
diff --git a/usr/src/cmd/tcpd/Makefile b/usr/src/cmd/tcpd/Makefile
index 1697a5e325..1ff5574989 100644
--- a/usr/src/cmd/tcpd/Makefile
+++ b/usr/src/cmd/tcpd/Makefile
@@ -25,7 +25,7 @@ CERRWARN += -erroff=E_FUNC_HAS_NO_RETURN_STMT
CERRWARN += -erroff=E_IMPLICIT_DECL_FUNC_RETURN_INT
CERRWARN += -_gcc=-Wno-unused-variable
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-implicit-function-declaration
CERRWARN += -_gcc=-Wno-return-type
CERRWARN += -_gcc=-Wno-clobbered
diff --git a/usr/src/cmd/th_tools/Makefile b/usr/src/cmd/th_tools/Makefile
index ed9d5ae75a..e1c4ac1baf 100644
--- a/usr/src/cmd/th_tools/Makefile
+++ b/usr/src/cmd/th_tools/Makefile
@@ -33,7 +33,7 @@ LINTFLAGS += -I$(SRC)/uts/common
CSTD= $(CSTD_GNU99)
CFLAGS += $(CCVERBOSE)
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
SRCS = $(PROG:%=%.c)
OBJECTS = $(SRCS:%.c=%.o)
diff --git a/usr/src/cmd/tic/Makefile.common b/usr/src/cmd/tic/Makefile.common
index 354ef9e8c3..0303635751 100644
--- a/usr/src/cmd/tic/Makefile.common
+++ b/usr/src/cmd/tic/Makefile.common
@@ -45,7 +45,7 @@ LDFLAGS += $(MAPFILES:%=-M%)
CERRWARN += -_gcc=-Wno-char-subscripts
CERRWARN += -_gcc=-Wno-implicit-function-declaration
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/tip/Makefile b/usr/src/cmd/tip/Makefile
index f64b4e301c..de0e20742e 100644
--- a/usr/src/cmd/tip/Makefile
+++ b/usr/src/cmd/tip/Makefile
@@ -62,7 +62,7 @@ LINTFLAGS += -u
CPPFLAGS += -DDEFBR=300 -DDEFFS=BUFSIZ -DACULOG -DUSG
CERRWARN += -_gcc=-Wno-parentheses
CERRWARN += -_gcc=-Wno-clobbered
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CONFIG= -DV831 -DVENTEL -DV3451 -DDF02 -DDF03 -DBIZ1031 -DBIZ1022 -DHAYES
ACULIB= aculib/aculib.a
LDLIBS= $(ACULIB) $(LDLIBS.cmd)
diff --git a/usr/src/cmd/tnf/prex/Makefile.com b/usr/src/cmd/tnf/prex/Makefile.com
index 90303b6aa7..35d9c42d0f 100644
--- a/usr/src/cmd/tnf/prex/Makefile.com
+++ b/usr/src/cmd/tnf/prex/Makefile.com
@@ -67,7 +67,7 @@ CFLAGS += $(CCVERBOSE)
CERRWARN += -_gcc=-Wno-unused-label
CERRWARN += -_gcc=-Wno-unused-variable
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/tnf/tnfxtract/Makefile.com b/usr/src/cmd/tnf/tnfxtract/Makefile.com
index dc5b2ea811..d7774db366 100644
--- a/usr/src/cmd/tnf/tnfxtract/Makefile.com
+++ b/usr/src/cmd/tnf/tnfxtract/Makefile.com
@@ -37,7 +37,7 @@ include ../../../Makefile.cmd
LFLAGS= -v
LDLIBS += -lkvm
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/troff/troff.d/Makefile b/usr/src/cmd/troff/troff.d/Makefile
index dfe5b8fee7..455d51a43f 100644
--- a/usr/src/cmd/troff/troff.d/Makefile
+++ b/usr/src/cmd/troff/troff.d/Makefile
@@ -48,7 +48,7 @@ CPPFLAGS = -DUSG -DINCORE -I. -I.. $(CPPFLAGS.master)
CERRWARN += -_gcc=-Wno-implicit-function-declaration
CERRWARN += -_gcc=-Wno-unused-variable
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-extra
# "parse error: parsing (i (9223372034707292160-96) >= 65)"
diff --git a/usr/src/cmd/truss/Makefile.com b/usr/src/cmd/truss/Makefile.com
index bb49c12894..4140101d8d 100644
--- a/usr/src/cmd/truss/Makefile.com
+++ b/usr/src/cmd/truss/Makefile.com
@@ -38,7 +38,7 @@ include ../../Makefile.cmd
CFLAGS += $(CCVERBOSE)
CFLAGS64 += $(CCVERBOSE)
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-switch
# not linted
diff --git a/usr/src/cmd/ttymon/Makefile b/usr/src/cmd/ttymon/Makefile
index 05178e2e4c..ae70a2619c 100644
--- a/usr/src/cmd/ttymon/Makefile
+++ b/usr/src/cmd/ttymon/Makefile
@@ -76,7 +76,7 @@ LDFLAGS += $(MAPFILE.NGB:%=-M%)
CERRWARN += -_gcc=-Wno-parentheses
CERRWARN += -_gcc=-Wno-unused-variable
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-extra
# not linted
diff --git a/usr/src/cmd/ucodeadm/Makefile b/usr/src/cmd/ucodeadm/Makefile
index fe30d02a27..70b6269bc5 100644
--- a/usr/src/cmd/ucodeadm/Makefile
+++ b/usr/src/cmd/ucodeadm/Makefile
@@ -41,7 +41,7 @@ POFILES = $(PROG_OBJS:%.o=%.po)
CPPFLAGS = -I../../common -I../../uts/common
CFLAGS += $(CCVERBOSE)
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-type-limits
LINTFLAGS += -errtags -erroff=E_NAME_DEF_NOT_USED2
LINTFLAGS += -erroff=E_INCONS_ARG_DECL2,E_INCONS_VAL_TYPE_DECL2
diff --git a/usr/src/cmd/uname/Makefile b/usr/src/cmd/uname/Makefile
index daa11b4aa8..14f7291b6e 100644
--- a/usr/src/cmd/uname/Makefile
+++ b/usr/src/cmd/uname/Makefile
@@ -28,7 +28,7 @@ ROOTFS_PROG= $(PROG)
include ../Makefile.cmd
CFLAGS += $(CCVERBOSE)
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
.KEEP_STATE:
diff --git a/usr/src/cmd/unpack/Makefile b/usr/src/cmd/unpack/Makefile
index bb3fc4e9e8..03c55bfe33 100644
--- a/usr/src/cmd/unpack/Makefile
+++ b/usr/src/cmd/unpack/Makefile
@@ -28,7 +28,7 @@ PROG= unpack
include ../Makefile.cmd
CFLAGS += $(CCVERBOSE)
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CPPFLAGS += -D_FILE_OFFSET_BITS=64
LDLIBS += -lcmdutils -lsec
diff --git a/usr/src/cmd/users/Makefile b/usr/src/cmd/users/Makefile
index 253af50ff5..2ad2a40895 100644
--- a/usr/src/cmd/users/Makefile
+++ b/usr/src/cmd/users/Makefile
@@ -30,7 +30,7 @@ SRCS= $(OBJS:%.o=%.c)
include ../Makefile.cmd
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
.KEEP_STATE:
diff --git a/usr/src/cmd/vi/misc/Makefile b/usr/src/cmd/vi/misc/Makefile
index 3b75bb32de..26c7b7b8dc 100644
--- a/usr/src/cmd/vi/misc/Makefile
+++ b/usr/src/cmd/vi/misc/Makefile
@@ -41,7 +41,7 @@ $(XPG4) := CFLAGS += -DXPG4
CERRWARN += -_gcc=-Wno-char-subscripts
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-implicit-function-declaration
CERRWARN += -_gcc=-Wno-unused-variable
diff --git a/usr/src/cmd/vi/port/Makefile b/usr/src/cmd/vi/port/Makefile
index 56cb0ca527..bd35a08e69 100644
--- a/usr/src/cmd/vi/port/Makefile
+++ b/usr/src/cmd/vi/port/Makefile
@@ -59,7 +59,7 @@ CERRWARN += -_gcc=-Wno-parentheses
CERRWARN += -_gcc=-Wno-unused-variable
CERRWARN += -_gcc=-Wno-unused-label
CERRWARN += -_gcc=-Wno-unused-value
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-address
# way too old
diff --git a/usr/src/cmd/volcheck/Makefile b/usr/src/cmd/volcheck/Makefile
index d3ee4572a1..8c2543f014 100644
--- a/usr/src/cmd/volcheck/Makefile
+++ b/usr/src/cmd/volcheck/Makefile
@@ -45,7 +45,7 @@ CSTD = $(CSTD_GNU99)
CERRWARN += -_gcc=-Wno-switch
CERRWARN += -_gcc=-Wno-unused-variable
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-unused-function
# not linted
diff --git a/usr/src/cmd/volrmmount/Makefile b/usr/src/cmd/volrmmount/Makefile
index 848088070c..a357772d00 100644
--- a/usr/src/cmd/volrmmount/Makefile
+++ b/usr/src/cmd/volrmmount/Makefile
@@ -45,7 +45,7 @@ CSTD = $(CSTD_GNU99)
CERRWARN += -_gcc=-Wno-switch
CERRWARN += -_gcc=-Wno-unused-variable
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-unused-function
# not linted
diff --git a/usr/src/cmd/vt/Makefile b/usr/src/cmd/vt/Makefile
index daae42bee4..a08e04c18b 100644
--- a/usr/src/cmd/vt/Makefile
+++ b/usr/src/cmd/vt/Makefile
@@ -33,7 +33,7 @@ VTINFO_SRC= vtinfo.c
include ../Makefile.cmd
CFLAGS += $(CCVERBOSE)
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
vtdaemon := LDLIBS += -lpam -lbsm
lint_vtdaemon := LDLIBS += -lpam -lbsm
diff --git a/usr/src/cmd/wall/Makefile b/usr/src/cmd/wall/Makefile
index f593e0095b..866c7ad6c8 100644
--- a/usr/src/cmd/wall/Makefile
+++ b/usr/src/cmd/wall/Makefile
@@ -32,7 +32,7 @@ FILEMODE = 02555
LDLIBS += -lzonecfg -lcontract
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
SMOFF += leaks
diff --git a/usr/src/cmd/ypcmd/Makefile b/usr/src/cmd/ypcmd/Makefile
index aeefa3031e..9667086a18 100644
--- a/usr/src/cmd/ypcmd/Makefile
+++ b/usr/src/cmd/ypcmd/Makefile
@@ -147,7 +147,7 @@ NIS2LDAPINC = -I$(SRC)/lib/libnisdb/yptol
CERRWARN += -_gcc=-Wno-implicit-function-declaration
CERRWARN += -_gcc=-Wno-parentheses
CERRWARN += -_gcc=-Wno-unused-variable
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-switch
CERRWARN += -_gcc=-Wno-extra
CERRWARN += -_gcc=-Wno-unused-label
diff --git a/usr/src/cmd/ypcmd/revnetgroup/Makefile b/usr/src/cmd/ypcmd/revnetgroup/Makefile
index 7494d1ceef..7f4c4d6c03 100644
--- a/usr/src/cmd/ypcmd/revnetgroup/Makefile
+++ b/usr/src/cmd/ypcmd/revnetgroup/Makefile
@@ -35,7 +35,7 @@ HDRS = getgroup.h table.h util.h
CERRWARN += -_gcc=-Wno-implicit-function-declaration
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/ypcmd/yppasswd/Makefile b/usr/src/cmd/ypcmd/yppasswd/Makefile
index db9d000e49..ac9f82d930 100644
--- a/usr/src/cmd/ypcmd/yppasswd/Makefile
+++ b/usr/src/cmd/ypcmd/yppasswd/Makefile
@@ -59,7 +59,7 @@ RPCYPPASSWDDOBJ = yppasswdd.o changepasswd.o
CERRWARN += -_gcc=-Wno-implicit-function-declaration
CERRWARN += -_gcc=-Wno-parentheses
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/zic/Makefile.common b/usr/src/cmd/zic/Makefile.common
index 197de36fb0..5ad10a2a2e 100644
--- a/usr/src/cmd/zic/Makefile.common
+++ b/usr/src/cmd/zic/Makefile.common
@@ -12,6 +12,6 @@ OBJS= ialloc.o \
SRCS= $(OBJS:%.o=%.c)
CERRWARN += -_gcc=-Wno-unused-variable
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
SMOFF += signed
diff --git a/usr/src/cmd/zinject/Makefile.com b/usr/src/cmd/zinject/Makefile.com
index a1a3baf712..8644e8185d 100644
--- a/usr/src/cmd/zinject/Makefile.com
+++ b/usr/src/cmd/zinject/Makefile.com
@@ -44,7 +44,7 @@ C99LMODE= -Xc99=%all
CPPFLAGS.first = -I$(SRC)/lib/libfakekernel/common -D_FAKE_KERNEL
CPPFLAGS += -D_LARGEFILE64_SOURCE=1 -D_REENTRANT $(INCS)
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-switch
LINTFLAGS += -erroff=E_STATIC_UNUSED
diff --git a/usr/src/cmd/zlogin/Makefile b/usr/src/cmd/zlogin/Makefile
index 70ecb28c5c..a40f872ea4 100644
--- a/usr/src/cmd/zlogin/Makefile
+++ b/usr/src/cmd/zlogin/Makefile
@@ -21,22 +21,24 @@
#
# Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
#
-# Copyright (c) 2018, Joyent, Inc.
+# Copyright 2019 Joyent, Inc.
+#
PROG = zlogin
include ../Makefile.cmd
-LINTFLAGS += -u
LDLIBS += -lsocket -lzonecfg -lcontract -lbrand -lsecdb
CFLAGS += $(CCVERBOSE)
FILEMODE = 0555
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
+CSTD = $(CSTD_GNU99)
+
.KEEP_STATE:
all: $(PROG)
@@ -46,6 +48,4 @@ install: all $(ROOTUSRSBINPROG)
clean:
$(RM) $(OBJS)
-lint: lint_PROG
-
include ../Makefile.targ
diff --git a/usr/src/cmd/zlogin/zlogin.c b/usr/src/cmd/zlogin/zlogin.c
index 1934ba2595..2c9d271abe 100644
--- a/usr/src/cmd/zlogin/zlogin.c
+++ b/usr/src/cmd/zlogin/zlogin.c
@@ -24,6 +24,7 @@
* Copyright (c) 2014 Gary Mills
* Copyright 2016 Joyent, Inc.
* Copyright 2015 Nexenta Systems, Inc. All rights reserved.
+ * Copyright 2019 Joyent, Inc.
*/
/*
@@ -678,7 +679,6 @@ process_user_input(int outfd, int infd)
char ibuf[ZLOGIN_BUFSIZ];
int nbytes;
char *buf = ibuf;
- char c = *buf;
nbytes = read(STDIN_FILENO, ibuf, ZLOGIN_RDBUFSIZ);
if (nbytes == -1 && (errno != EINTR || dead))
@@ -691,7 +691,7 @@ process_user_input(int outfd, int infd)
if (nbytes == 0)
return (1);
- for (c = *buf; nbytes > 0; c = *buf, --nbytes) {
+ for (char c = *buf; nbytes > 0; c = *buf, --nbytes) {
buf++;
if (beginning_of_line && !nocmdchar) {
beginning_of_line = B_FALSE;
diff --git a/usr/src/cmd/zlook/Makefile.com b/usr/src/cmd/zlook/Makefile.com
index fe96088124..a634a72d2c 100644
--- a/usr/src/cmd/zlook/Makefile.com
+++ b/usr/src/cmd/zlook/Makefile.com
@@ -34,7 +34,7 @@ CFLAGS += $(CCGDEBUG) $(CCVERBOSE)
CFLAGS64 += $(CCGDEBUG) $(CCVERBOSE)
CPPFLAGS += -D_LARGEFILE64_SOURCE=1 -D_REENTRANT $(INCS)
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
.KEEP_STATE:
diff --git a/usr/src/cmd/zoneadm/Makefile b/usr/src/cmd/zoneadm/Makefile
index 872e663d00..4581c14af9 100644
--- a/usr/src/cmd/zoneadm/Makefile
+++ b/usr/src/cmd/zoneadm/Makefile
@@ -44,7 +44,7 @@ LDLIBS += -lzonecfg -lsocket -lgen -lpool -lzfs -luuid -lnvpair -lbrand -ldladm
INCS += -I../../common/zfs
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
.KEEP_STATE:
diff --git a/usr/src/cmd/zoneadmd/Makefile b/usr/src/cmd/zoneadmd/Makefile
index e81e4631aa..21cda0ce44 100644
--- a/usr/src/cmd/zoneadmd/Makefile
+++ b/usr/src/cmd/zoneadmd/Makefile
@@ -32,11 +32,10 @@ include ../Makefile.ctf
$(64ONLY)SUBDIRS= $(MACH)
$(BUILD64)SUBDIRS += $(MACH64)
-all := TARGET = all
-install := TARGET = install
-clean := TARGET = clean
-clobber := TARGET = clobber
-lint := TARGET = lint
+CFLAGS += $(CCVERBOSE)
+CERRWARN += -_gcc=-Wno-switch
+CERRWARN += -_gcc=-Wno-parentheses
+CERRWARN += $(CNOWARN_UNINIT)
XGETFLAGS += -a -x zoneadmd.xcl
diff --git a/usr/src/cmd/zonecfg/Makefile b/usr/src/cmd/zonecfg/Makefile
index 4bb03aa97d..382120b554 100644
--- a/usr/src/cmd/zonecfg/Makefile
+++ b/usr/src/cmd/zonecfg/Makefile
@@ -44,7 +44,7 @@ CPPFLAGS += -I.
LDFLAGS += $(MAPOPTS)
CLEANFILES += zonecfg_lex.c zonecfg_grammar.tab.c zonecfg_grammar.tab.h
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
CERRWARN += -_gcc=-Wno-unused-label
CERRWARN += -_gcc=-Wno-unused-variable
CERRWARN += -_gcc=-Wno-implicit-function-declaration
diff --git a/usr/src/cmd/zonestat/zonestat/Makefile b/usr/src/cmd/zonestat/zonestat/Makefile
index 64e2314de5..a8b62f65d3 100644
--- a/usr/src/cmd/zonestat/zonestat/Makefile
+++ b/usr/src/cmd/zonestat/zonestat/Makefile
@@ -32,7 +32,7 @@ include ../../Makefile.cmd
LDLIBS += -lscf -lzonestat -lumem
LINTFLAGS += -u
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off
diff --git a/usr/src/cmd/zonestat/zonestatd/Makefile b/usr/src/cmd/zonestat/zonestatd/Makefile
index 5f27190f10..727c71148c 100644
--- a/usr/src/cmd/zonestat/zonestatd/Makefile
+++ b/usr/src/cmd/zonestat/zonestatd/Makefile
@@ -41,7 +41,7 @@ LDLIBS += -lkstat -lpool -lexacct -lscf \
LINTFLAGS += -u
CERRWARN += -_gcc=-Wno-parentheses
CERRWARN += -_gcc=-Wno-unused-label
-CERRWARN += -_gcc=-Wno-uninitialized
+CERRWARN += $(CNOWARN_UNINIT)
# not linted
SMATCH=off