#!/bin/bash
# $Id: rc.afb,v 1.1.1.1 1999/09/08 06:42:36 davem Exp $
#
# chkconfig: 2345 90 10
# description: Load microcode at boottime to all detected Elite3D
#	       graphics cards.
#


# If this is not sparc64 or no AFBs, get out of here.
if [ `/bin/uname -m` != "sparc64" ]
then
	exit 0
fi

if [ `/bin/dmesg | /bin/grep -c "Elite 3D"` -eq 0 ]
then
	exit 0
fi

# The microcode loader binary and the microcode
# itself must exist.
if [ ! -x /usr/sbin/afbinit -o ! -f /usr/lib/afb.ucode ]
then
	exit 0
fi

# Make FB device list.
afb_devs=`/bin/dmesg | /bin/egrep -i "Elite 3D" | /bin/sed 's/\:.*//'`

# Load microcode onto each card.
for AFB in ${afb_devs}
do
	echo -n "${AFB}: Loading Elite3D microcode... "
	/usr/sbin/afbinit /dev/${AFB} /usr/lib/afb.ucode
	echo "done."
done
