#!/bin/ksh
#
# This script will make 32 nodes for the a hippi NIC. 
# It is generally ran during installation, but will need to be invoked after
# the initial hippi driver installation/reboot inorder to create additional
# devices needed if more than 1 NIC installed (ie. ess1, ess2). 
#
# Usage: mknod.sgi <unit>
# Defaults to 0th card  (primary card)
#


if [[ $# = "1" ]]
then
    tmp=$1
    let cardNo=${tmp#ess}
    if [[ $cardNo -gt 15 ]]
    then
       print " ERROR: $0 <$1>, Only 15 NIC's currently supported."
       exit 1
    fi
    let minNo=256*cardNo
else
    let cardNo=0
    let minNo=0
fi

if [[ $(uname -m) = "IP27" || $(uname -m) = "IP30" ]]
then

	# HW Graph is responsible for major no. allocation
	# on these platforms.

    rm -rf /dev/hippi/
	ln -s /hw/esshippi /dev/hippi/

else

    # Make the hippi device directory
    mkdir /dev/hippi
    cd /dev/hippi
    rm -rf /dev/hippi/h${cardNo}*


    #
    # If you already are using major device number of '60',
    # please change the '60' in the following statement to a
    # major device number not being used by your system.
    # SGI has the major device range of 60 - 79 reserved for 
    # 3rd party software.
    # Note: If you have multiple Hippi (or GigE) cards, all of them need
    # to have the same major device number. However if you have a Hippi
    # and a GigE card they need to have different major numbers
    #
    let devNum=60

    # Make 32 nodes for the hippi card. 

    print "mknod h${cardNo} c ${devNum} $minNo"
    mknod h${cardNo} c ${devNum} $minNo

    let i=minNo+1
    let minorName=i-256*cardNo
    while (( i <= minNo+31 ))
    do
        print "mknod h${cardNo}.${minorName} c ${devNum} $i"
        mknod h${cardNo}.${minorName} c ${devNum} $i
        let i=i+1
        let minorName=minorName+1
    done
    chmod a+w h${cardNo}*

fi
