Metropoli BBS
VIEWER: setupin MODE: TEXT (ASCII)
#
# 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
edrmvIN220P() {
                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 Family 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/IN220P/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
                /usr/sbin/netinfo -r -d d22e_0 -d d22e_1 -d d22e_2 -d d22e_3
                /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 IN220P ] ; then
        mkdir IN220P
fi
cd IN220P

if [ ! -f /usr/lib/tcprt/IN220P/spacein.c ] ; then
        echo ""
        echo "Can not find spacein.c at /usr/lib/tcprt/IN220P directory"
        exit 0
fi
cp /usr/lib/tcprt/IN220P/spacein.c ./Space.c

cd /

brd=0

cfg0=N
cfg1=N
cfg2=N
cfg3=N

##vect0=0
##vect1=0
##vect2=0
##vect3=0

while getyn "Do you want to configure Board_$brd?"
do
    echo "\nBoard_$brd configuring ..."

##    while   p "Interrupt vector number [5]: \c "
##    do	    read vect
##	case "$vect" in
##	"")
##		vect=5;
##		break;
##		;;
##	2)
##		vect=9;
##		break;
##		;;
##	[0-9]*)
##		break;
##		;;
##	*)
##		p "Vector number must be decimal digits"
##		;;
##	esac
##    done

    case "$brd" in
    0)
        cfg0=Y
##	vect0=$vect
        ;;
    1)
        cfg1=Y
##	vect1=$vect
        ;;
    2)
        cfg2=Y
##	vect2=$vect
        ;;
    3)
        cfg3=Y
##	vect3=$vect
        ;;
    esac

    /usr/sbin/netinfo -a -d d22e_$brd
    /etc/confnet.d/configure -i -p inet -d d22e_$brd

###
### Let user change the setting of /IN-220P Family Card
### This call must be put after 'idinstall' because /etc/conf/pack.d/d22e/space.c
### is created after 'idinstall'
###
    system_d22e  $brd

    brd=`expr $brd + 1`

done

if [ -f /etc/netware/nwconfig ]
then
    echo "\n\t0: d22e_0 adpater 0"
    echo "\t1: d22e_1 adapter 1"
    echo "\t2: d22e_2 adapter 2"
    echo "\t3: d22e_3 adapter 3"
    echo "Select one adapter to support Netware: \c"
    read port
    ed -s /etc/netware/nwconfig << TOAST > /dev/null
/lan_1_adapter/
d
i
lan_1_adapter = "/dev/d22e_$port"
.
w
q
TOAST
fi

cd /tmp
if [ ! -d IN220P ] ; then
        mkdir IN220P
fi
cd IN220P


#
# 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    iScfHM   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  5   1   0    0    0  0  0" > ./System
if [ $brd -gt 1 ]; then
   echo "d22e  $cfg1  4  5   1   0    0    0  0  0" >> ./System
fi
if [ $brd -gt 2 ]; then
   echo "d22e  $cfg2  4  5   1   0    0    0  0  0" >> ./System
fi
if [ $brd -gt 3 ]; then
   echo "d22e  $cfg3  4  5   1   0    0    0  0  0" >> ./System
fi

#
# 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
if [ $brd -gt 1 ] ; then
   echo "clone     d22e_1    c:1       d22e" >> ./Node
fi
if [ $brd -gt 2 ] ; then
   echo "clone     d22e_2    c:2       d22e" >> ./Node
fi
if [ $brd -gt 3 ] ; then
   echo "clone     d22e_3    c:3       d22e" >> ./Node
fi


# Driver.o
cp /usr/lib/tcprt/IN220P/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 IN220P

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


[ RETURN TO DIRECTORY ]