#
# set -x
# Globals
#
PATH=/bin:/usr/bin:/etc:/etc/conf/bin
tmp=/tmp/tcp$$
ROOT=
CONF=${ROOT}/usr/sys/conf
DEVDIR=${ROOT}/dev
ETC=${ROOT}/etc
TCP_CONF=${ROOT}/usr/lib/tcprt
TCP_IF=${TCP_CONF}/if.conf
TCPPERM=${ETC}/perms/tcprt # permlist of this product
INET=${ROOT}/usr/sys/inet
# function definitions
#
# usage: safemv file1 file2
# move file1 to file2 without chance of interruption
safemv() {
trap "" 1 2 3 15
mv $1 $2
trap 1 2 3 15
}
# usage: safecopy file1 file2
# copies file1 to file2 without chance of interruption
safecopy() {
trap "" 1 2 3 15
cp $1 $2
trap 1 2 3 15
}
# Prompt for yes or no answer with message passed as argument -
# returns non-zero for no
getyn() {
while echo "\n$* (y/n/q) \c">&2
do read yn rest
case $yn in
[yY]) return 0 ;;
[nN]|[qQ]) return 1 ;;
*) echo "Please answer y,n or q" >&2 ;;
esac
done
}
# print a prompt
#
p() {
set -f
/bin/echo $*
set +f
return $?
}
# Remove temp files and exit with the status passed as argument
cleanup() {
trap '' 1 2 3 15
[ "$tmp" ] && rm -f $tmp*
exit $1
}
# Re-link new kernel
relink() {
cd /etc/conf/bin
if [ -z "$_NOPROMPT" ] ; then
echo "\nRe-linking the kernel ... \c" >&2
fi
./idbuild -B
return 0
}
#
# Edit the sdevice file to remove the driver
edrmvdlk() {
ed -s $1 << TOAST > /dev/null
/^$1/
d
a
d22e N 4 5 1 2 0 0 0 0
.
w
q
TOAST
}
addhex() {
echo "$1 $2" | nawk ' {
printf("%x", atoh($1) + atoh($2));
}
function atoh(number) {
i = 0
j = length(number)
result = 0
while ( i < j ) {
result = result + (hexval(substr(number,j - i,1)) * (16 ^ i))
i = i + 1
}
return result
}
function hexval(letter) {
if (letter == "a") return 10 + 0
if (letter == "b") return 11 + 0
if (letter == "c") return 12 + 0
if (letter == "d") return 13 + 0
if (letter == "e") return 14 + 0
if (letter == "f") return 15 + 0
return (letter + 0)
}'
}
#
# system_d22e()
#
system_d22e() {
bd=$1
MediaType=3
echo ""
echo "NOTE:"
echo " If the board of IN-220P Series is a non-plug and play card,"
echo " please use setup program in DOS to change I/O base address,"
echo " and IRQ number if conflict."
echo ""
echo ""
echo "Please choose the media mode that you want ...................."
echo ""
echo " 0. Twisted pair connection."
echo " 1. BNC connection."
echo " 2. AUI connection."
echo " 3. Automatic detection between TP BNC and AUI."
echo " 4. Use EEPROM setting."
echo ""
while p " Enter number of media selection [3]: \c"
do read MediaType
case $MediaType in
0) MediaTypeTXT="MEDIA_UTP";
echo " Media mode : Twisted pair. ";
break;
;;
1) MediaTypeTXT="MEDIA_BNC";
echo " Media mode : BNC. ";
break;
;;
2) MediaTypeTXT="MEDIA_AUI";
echo " Media mode : AUI. ";
break;
;;
3|"") MediaTypeTXT="MEDIA_AUTO";
echo " Media mode : Automatic detection between TP BNC and AUI. ";
break;
;;
4) MediaTypeTXT="MEDIA_DEFAULT";
echo " Media mode : Use EEPROM setting. ";
break;
;;
*) echo "Enter 0 1 2 3 or 4 !"
;;
esac
done
ed -s /tmp/dlk/Space.c << TOAST > /dev/null
/#define ND22E_MediaType_$bd/
d
i
#define ND22E_MediaType_$bd $MediaTypeTXT
.
w
q
TOAST
BIO=0
EIO=0
IRQ=0
NMINORS="1"
}
# main()
cd /
tput clear
# Add drivers via configure
#
while echo "Do you wish to install or delete the network driver (i/d/q) \c"
do read ANSWER
case $ANSWER in
I|i)
break
;;
D|d)
cd /etc/conf/bin
idinstall -d -e d22e
/etc/confnet.d/configure -r -p inet -d d22e_0 -d d22e_1 -d d22e_2 -d d22e_3
cd /
# Relink the kernel with the new driver information
if [ -z "$_NOPROMPT" ] ; then
if getyn "\nDo you wish to relink the kernel now?"
then
relink
else
echo "\nChanges will not take effect until the kernel is relinked." >&2
fi
else
relink
fi
cleanup 0
;;
Q|q)
cleanup 0
;;
*) echo "Please answer 'i', 'd' or 'q'."
;;
esac
done
echo " "
# space.c
cd /tmp
if [ ! -d dlk ] ; then
mkdir dlk
fi
cd dlk
if [ ! -f /usr/lib/tcprt/dlk/Spacein.c ] ; then
echo ""
echo "Can not find Spacein.c at /usr/lib/tcprt/dlk directory"
exit 0
fi
cp /usr/lib/tcprt/dlk/Spacein.c ./Space.c
cd /
brd=0
cfg0=N
cfg1=N
cfg2=N
cfg3=N
while getyn "Do you want to configure Board_$brd?"
do
echo "\nBoard_$brd configuring ..."
case "$brd" in
0)
cfg0=Y
;;
1)
cfg1=Y
;;
2)
cfg2=Y
;;
3)
cfg3=Y
;;
esac
###
### Let user change the setting of DE-220 Family Card
### This call must be put after 'idinstall' because /etc/conf/pack.d/d22e/space.c
### is created after 'idinstall'
###
system_d22e $brd
/usr/sbin/netinfo -a -d d22e_$brd
/etc/confnet.d/configure -i -p inet -d d22e_$brd
brd=`expr $brd + 1`
done
cd /tmp
if [ ! -d dlk ] ; then
mkdir dlk
fi
cd dlk
#
# mdevice(4)
#
# d22e - Device name
# Ihp - Function list, init routine, halt routine, poll routine
# iScHM - Characteristics of driver, installable, STREAMS, character,
# control hardware, multiple major numbers
# d22e - Handler prefix, ex: d22einit()...
# 0 - Block Major number
# 0-3 - Character Major number
# 1 - Minimum units
# 4 - Maximum units
# -1 - DMA channel, -1 means does not use DMA
#
echo "d22e I iScHM d22e 0 0-3 1 4 -1" > ./Master
#
# sdevice(4)
#
# d22e - Device name
# Y/N - Configure
# 4 - Unit
# 5 - IPL (Interrupt Privilege Level)
# 0 - Type, does not require an interrupt line
# 0 - Vector, no vector
# 0 - SIOA, Start I/O Address
# 0 - EIOA, End I/O Address
# 0 - SCMA, Start Controller Address
# 0 - ECMA, End Controller Address
#
echo "d22e $cfg0 4 0 0 0 0 0 0 0" > ./System
echo "d22e $cfg1 4 0 0 0 0 0 0 0" >> ./System
echo "d22e $cfg2 4 0 0 0 0 0 0 0" >> ./System
echo "d22e $cfg3 4 0 0 0 0 0 0 0" >> ./System
#
# idmknod(1M)
#
# clone - DSP internal name
# d22e_0 - name of node to be inserted
# c:0 - character device and major number 0
# d22e - minor device number
#
echo "clone d22e_0 c:0 d22e" > ./Node
echo "clone d22e_1 c:1 d22e" >> ./Node
echo "clone d22e_2 c:2 d22e" >> ./Node
echo "clone d22e_3 c:3 d22e" >> ./Node
# Driver.o
cp /usr/lib/tcprt/dlk/IN220P.o ./Driver.o
### echo "Modifying Streams Data Configuration Parameters"
#/etc/conf/bin/idtune -m -c NBLK64 20
#/etc/conf/bin/idtune -m -c NBLK2048 100
if [ -d /etc/conf/pack.d/d22e ] ; then
idinstall -u -m -s -n -o -p -e d22e
else
idinstall -a d22e
fi
cd .. ; rm -rf dlk
echo ""
ed -s /etc/conf/mdevice.d/d22e << TOAST > /dev/null
/ddi 5/
d
w
q
TOAST
cd /
# Relink the kernel with the new driver information
if [ -z "$_NOPROMPT" ] ; then
if getyn "\nDo you wish to relink the kernel now?"
then
relink
else
echo "\nUNIX will not work until the kernel is relinked." >&2
cleanup 0
fi
else
relink
fi
echo "\n\treboot the system\n" >&2