#! /usr/bin/sh
#
# ident	"@(#)efcode.cleanup.sh	1.1	07/05/24 SMI"
#
# Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
# Use is subject to license terms.
#
# Efcode cleanup
# Disable efdaemon on target systems not supporting Embedded Fcode Interpreter
# Enable  efdaemon on target systems supporting Embedded Fcode Interpreter
#
# We may need to enable/disable the efdaemon services in SMF.  This could
# happen if th system the flash was created on and the target system support
# different hotplug implementations.
#
ARCH=`/usr/bin/uname -m`

# 
# if arch == sun4u
#
# Not all sun4u platforms support efcode. 
# Daemon support is based upon finding the 
# "pcicfg.e (PCIe/PCI Config (EFCode Enabled)"
# module in the modinfo output
#
if [ `/usr/sbin/modinfo | /usr/bin/grep -c pcicfg` != "0" ]; then
	echo "/usr/sbin/svcadm enable /platform/${ARCH}/efdaemon:default" >> \
	    ${FLASH_ROOT}/var/svc/profile/upgrade
else
	echo "/usr/sbin/svcadm disable /platform/${ARCH}/efdaemon:default" >> \
	    ${FLASH_ROOT}/var/svc/profile/upgrade
fi
