#!/bin/ksh


#This script is based on information given in sun infodoc #16490
#If you have a modern, "enterprise" level sun, just use
# prtdiag -v
# (although in principle this script should still work for you.)

TMPFILE=/tmp/tmp.$$
uname -n
prtconf | head -5 | egrep 'Memory|SUNW'


prtconf -pv | /usr/bin/nawk '
$2 == "'\'memory\''" {print saveline ; exit }
$1 == "reg:"	{saveline=$0}
                {}
' >$TMPFILE

arch=`uname -m`
if [ "$arch" = "sun4m" ] ; then
	SEDEXPR='s/[0-9a-f]*\.[0-9a-f]*\.\([0-9a-f]*\)[. $]/\1 /g'
	CUTCMD="cut -f3,6,9,12,15,18,21,24 -d."
else
	SEDEXPR='s/[0-9a-f]*\.[0-9a-f]*\.[0-9a-f]*\.\([0-9a-f]*\)[. $]/\1 /g'
	CUTCMD=
fi

print ""


banks=`awk '/reg:/ {print $2,$3}' $TMPFILE | sed -e "$SEDEXPR"`

count=1;
for mem in $banks ; do
print bank $count:
count=$((count + 1))

   case $mem in
	'00800000')
		print 8MB
		;;
	'01000000')
		print 16MB
		;;
	'02000000')
		print 32MB
		;;
	'04000000')
		print 64MB
		;;
	'08000000')
		print 128MB
		;;
	'10000000')
		print 256MB
		;;
	'20000000')
		print 512MB
		;;
	'40000000')
		print 1GIG
		;;
	'80000000')
		print 2GIG
		;;
	'00000000')
		print '[empty]'
		;;
	
	*)
		print UNKNOWN "(value is $mem)"
		;;
   esac
done
#$CUTCMD
#

rm $TMPFILE
