#!/bin/sh
#ident	"@(#)gtconfig.sh	4.2	95/08/16 SMI"	/* SunOS 5.1 */
#
# Copyright (c) 1991 by Sun Microsystems, Inc.
#
# /etc/rc2.d/S91gtconfig - Configure for the GT.

PATH=/usr/bin:/bin:/usr/sbin

#
# Check to see if we're using a galaxy
# If so, exit.
#
if [ "`/sbin/uname -m`" != "sun4c" ]; then
	hid=`/etc/sysdef -h | tail -1`
	h=`expr $hid : '\(..\)'`
	if [ "$h" -eq 71 ]; then
		# Galaxy, not supported yet
		exit 0
	fi
fi

devpath=/dev
test -d /dev/fbs && devpath=/dev/fbs

#
# Use prtconf to see if any gt are attached,
# and get a list of them
#
devs=`/bin/ls $devpath | egrep "^gt[0-9]+"`

#
# If there aren't any around, there's no need to load
# the driver, so quit.
#
if [ "$devs" = "" ]
then
	exit 0
fi

#
# We have a gt, so modload the driver and
# make sure that it was successful.
#
err=`modload /kernel/drv/gt 2>&1`
if [ $? -ne 0 ]; then
	echo "Problems loading GT driver: $err"
	exit 1
fi

#
# Now download the microcode to each driver.
#
for inst in $devs
do
	#
	# If we can find the binary, then download the microcode to
	# this instance.
	#
	if [ -f /usr/sbin/gtconfig ]
	then
		errmsg="`/usr/sbin/gtconfig -d $devpath/$inst -I /usr/lib 2>&1`"
		test -n "$errmsg" && echo "$errmsg"	
	fi
done

exit 0
