home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Internet 2000 December / MICD_2000_12_NR1.iso / Dreamnet / drivery / SMC / 1211.exe / SCO / 3.X / INIT (.txt) < prev    next >
Microsoft Windows Help File Content  |  1997-10-26  |  21KB  |  561 lines

  1. #               (C) 1989-1990 The Santa Cruz Operation, Inc.  All Rights
  2. #               Reserved.  The user has unlimited right to use, modify
  3. #               and incorporate this code into other products provided
  4. #               it is used with SCO products and the user includes
  5. #               this notice and the associated copyright notices with
  6. #               any such application.
  7. LIB=/usr/lib/lli
  8. CONF=/etc/conf
  9. PATH=/bin:/usr/bin:/etc/:$CONF/bin:$LIB
  10. # Set possible return codes for this script
  11. OK=0;   FAIL=1; RELINK=2;
  12. BRAM="0"
  13. ERAM="0"
  14. # Prompt the user for a hex value, it must be within a given range
  15. # Usage:
  16. #       prompt_range "Message" default min max [step]
  17. prompt_range() {
  18.         mesg=$1
  19.         default=$2
  20.         range_min=$3 range_max=$4
  21.         step="1"
  22.         if [ $# -eq 5 ]
  23.         then
  24.                 step=$5
  25.         fi
  26.         while :
  27.         do
  28.                 echo "${mesg} (${range_min}..${range_max}) [${default}] or 'q' to quit: \c"
  29.                 read result
  30.                 case $result in
  31.                 Q|q)
  32.                         return $FAIL
  33.                         ;;
  34.                 "")
  35.                         result=$default
  36.                         ;;
  37.                 esac
  38.                 hc $result $range_min $range_max $step
  39.                 case $? in
  40.                 0) return $OK;;
  41.                 1) cleanup $FAIL;;
  42.                 2) cleanup $FAIL;;
  43.                 esac
  44.         done
  45. # print a prompt
  46. p() {
  47.         set -f
  48.         /bin/echo $*
  49.         set +f
  50.         return $?
  51. # Prompt the user to make a selection a list of values
  52. # Usage:
  53. #       prompt_select "Message" default "value_list"
  54. prompt_select() {
  55.         mesg=$1
  56.         default=$2
  57.         values=$3
  58.         while :
  59.         do
  60.                 if [ "$default" = "" ]
  61.                 then
  62.                         echo "${mesg} (${values}) or 'q' to quit: \c"
  63.                 else
  64.                         echo "${mesg} (${values}) [${default}] or 'q' to quit: \c"
  65.                 fi
  66.                 read result
  67.                 case $result in
  68.                 Q|q)
  69.                         return $FAIL
  70.                         ;;
  71.                 "")
  72.                         result=$default
  73.                         ;;
  74.                 esac
  75.                 for i in $values
  76.                 do
  77.                         if [ "$i" = "$result" ]
  78.                         then
  79.                                 return $OK
  80.                         fi
  81.                 done
  82.                 echo "Illegal value, must be one of (${values})"
  83.         done
  84. # prompt the user to answer a yes no question or 'q' to quit
  85. # Usage:
  86. #       prompt_yn "Message" default
  87. prompt_yn() {
  88.         mesg=$1
  89.         default=$2
  90.         while :
  91.         do
  92.                 echo "${mesg} (y/n) [${default}] or 'q' to quit: \c"
  93.                 read result
  94.                 case $result in
  95.                 q|Q) return $FAIL;;
  96.                 y|Y) result="Y"; return $OK;;
  97.                 n|N) result="N"; return $OK;;
  98.                 "") result=`echo $default | tr "yn" "YN"`; return $OK;;
  99.                 esac
  100.                 echo "Illegal value, please type 'y' 'n' or 'q'"
  101.         done
  102. # Fake up an mdevice and an sdevice for idcheck
  103. makedevs() {
  104.         dir=`pwd`
  105.         rm -fr /tmp/dev$$
  106.         mkdir /tmp/dev$$
  107.         cd /etc/conf/cf.d
  108.         cp mdevice /tmp/dev$$
  109.         cd ../sdevice.d
  110.         cat * > /tmp/dev$$/sdevice
  111.         cd $dir
  112. cleanup() {
  113.         cd /
  114.         rm -fr /tmp/dev$$
  115.         rm -fr /tmp/$base
  116.         exit $1
  117. # Removes the given interrupt vector for the $clash device.
  118. rmvector() {
  119.         clash=$1
  120.         vec=$2
  121.         cd $confdir
  122.         echo "\nRemoving interrupt vector $vec for the $clash device ..."
  123.         [ "$vec" = "2" ] && vec=9
  124.         major=`./configure -j $clash` && {
  125.                 # remove device but leave it required
  126.                 if [ "$major" != "0" ]
  127.                 then
  128.                         ./configure -d -c -m $major -v $vec -Y >> conflog 2>&1 || {
  129.                                 cd $currdir
  130.                                 cleanup $FAIL
  131.                         }
  132.                 else
  133.                         sed -e "s/Y/N/" ../sdevice.d/$clash > /tmp/bog$$
  134.                         mv /tmp/bog$$ ../sdevice.d/$clash
  135.                 fi
  136.                 # remove required setting if no more left
  137.                 if grep "Y" ../sdevice.d/$clash > /dev/null 2>&1
  138.                 then
  139.                         true
  140.                 elif [ "$major" != "0" ]
  141.                 then
  142.                         ./configure -d -c -m $major -v $vec -R -Y >> conflog 2>&1 || {
  143.                                 cd $currdir
  144.                                 cleanup $FAIL
  145.                         }
  146.                 fi
  147.         }
  148.         cd $currdir
  149.         return $OK
  150. # On unix, we must check the files in sdevice.d.
  151. # Sets the variable $clash to the driver code name if there is a driver that
  152. # has already been allocated the given vector. Uses awk.
  153. dointclash() {
  154.         driver=$1
  155.         vec=$2
  156.         [ "$vec" = "2" ] && vec=9
  157.         cd $confdir/../sdevice.d
  158.         clash=`cat * | awk '{ if ( $6 == intr && $2 == "Y" ) exit } \
  159.                         END { print $1 }' intr=$vec`
  160.         cd $currdir
  161.         [ "$clash" = "" -o "$clash" = "$driver" ] && return $FAIL
  162.         # found a clash
  163.         return $OK
  164. checkvec() {
  165.         driver=$1
  166.         vector=$2
  167.         clash=
  168.         currdir=`pwd`
  169.         while dointclash $driver $vector
  170.         do
  171.                 prompt_select "Interrupt vector $vector is already in use for the $clash device.\n\n\
  172. The alternatives available to you are:\n\n\
  173. \t1. Continue the installation and remove vector $vector for the $clash device.\n\
  174. \t2. Select a different interrupt vector.\n\n\
  175. Select an option" 1 "1 2" || {
  176.                         cleanup $FAIL
  177.                 }
  178.                 case $result in
  179.                 1)      rmvector $clash $vector || {
  180.                                 echo "Failed to remove vector $vector"
  181.                                 cleanup $FAIL
  182.                         }
  183.                         makedevs
  184.                         return $OK
  185.                         ;;
  186.                 2)      return $FAIL
  187.                         ;;
  188.                 esac
  189.         done
  190.         return $OK
  191. doaddrclash() {
  192.         driver=$1
  193.         addr1=$2
  194.         addr2=$3
  195.         cd $confdir
  196.         clash=`../bin/idcheck -ar -l $addr1 -u $addr2 -i /tmp/dev$$`
  197.         cd $currdir
  198.         [ "$clash" = "" -o "$clash" = "$driver" ] && return $FAIL
  199.         # found a clash
  200.         return $OK
  201. # Removes the $clash device.
  202. rmaddr() {
  203.         clash=$1
  204.         cd $confdir
  205.         echo "\nRemoving the $clash device ..."
  206.         major=`./configure -j $clash` && {
  207.                 # remove device but leave it required
  208.                 if [ "$major" != "0" ]
  209.                 then
  210.                         ./configure -d -c -m $major -Y >> conflog 2>&1 || {
  211.                                 cd $currdir
  212.                                 cleanup $FAIL
  213.                         }
  214.                 else
  215.                         sed -e "s/Y/N/" ../sdevice.d/$clash > /tmp/bog$$
  216.                         mv /tmp/bog$$ ../sdevice.d/$clash
  217.                 fi
  218.                 # remove required setting if no more left
  219.                 if grep "Y" ../sdevice.d/$clash > /dev/null 2>&1
  220.                 then
  221.                         true
  222.                 elif [ "$major" != "0" ]
  223.                 then
  224.                         ./configure -d -c -m $major -R -Y >> conflog 2>&1 || {
  225.                                 cd $currdir
  226.                                 cleanup $FAIL
  227.                         }
  228.                 fi
  229.         }
  230.         cd $currdir
  231.         return $OK
  232. checkaddr() {
  233.         driver=$1
  234.         addr1=$2
  235.         addr2=$3
  236.         clash=
  237.         currdir=`pwd`
  238.         while doaddrclash $driver $addr1 $addr2
  239.         do
  240.                 if [ "$clash" = "ad" ]
  241.                 then
  242.                         echo "\n\nWARNING: Do not remove the $clash device \c"
  243.                         echo "if you are using an Adaptec disk controller"
  244.                 fi
  245.                 prompt_select "Addresses $addr1-$addr2 are already in use by the $clash device.\n\n\
  246. The alternatives available to you are:\n\n\
  247. \t1. Continue the installation and remove the $clash device.\n\
  248. \t2. Select a different address.\n\n\
  249. Select an option" 1 "1 2" || {
  250.                         cleanup $FAIL
  251.                 }
  252.                 case $result in
  253.                 1)      rmaddr $clash || {
  254.                                 echo "Failed to remove $clash device"
  255.                                 cleanup $FAIL
  256.                         }
  257.                         makedevs
  258.                         return $OK
  259.                         ;;
  260.                 2)      return $FAIL
  261.                         ;;
  262.                 esac
  263.         done
  264.         return $OK
  265. doramclash() {
  266.         driver=$1
  267.         addr1=$2
  268.         addr2=$3
  269.         cd $confdir
  270.         clash=`../bin/idcheck -cr -l $addr1 -u $addr2 -i /tmp/dev$$`
  271.         cd $currdir
  272.         [ "$clash" = "" -o "$clash" = "$driver" ] && return $FAIL
  273.         # found a clash
  274.         return $OK
  275. checkram() {
  276.         driver=$1
  277.         addr1=$2
  278.         addr2=$3
  279.         clash=
  280.         currdir=`pwd`
  281.         while doramclash $driver $addr1 $addr2
  282.         do
  283.                 prompt_yn "
  284. Ram addresses $addr1-$addr2 is already in use for the $clash device.
  285. You must choose a unique address for this device to work.
  286. Do you wish to choose another address now?" y || cleanup $FAIL
  287.                 if [ "$result" = "Y" ]
  288.                 then
  289.                         return $FAIL
  290.                 else
  291.                         cleanup $FAIL
  292.                 fi
  293.         done
  294.         return $OK
  295. # On unix, we must check the lines in mdevice file.
  296. # Sets the variable $clash to the driver code name if there is a driver that
  297. # has already been allocated the given channel. Uses awk.
  298. dodmaclash() {
  299.         driver=$1
  300.         chan=$2
  301.         clash=
  302.         # -1 is never a clash
  303.         [ "$chan" = "-1" ] && return $FAIL
  304.         cd $confdir
  305.         clash=`awk '{ if ( $9 == dma ) print $1 }' dma=$chan mdevice`
  306.         [ "$clash" = "" ] && {
  307.                 cd $currdir
  308.                 return $FAIL
  309.         }
  310.         cat ../sdevice.d/$clash | awk '{ if ( $2 == "Y" ) exit 1 }' || return $OK
  311.         if [ "$rel" = "3.2.0" -o "$rel" = "3.2.1" -o "$rel" = "3.2.2" ]
  312.         then
  313.                 prompt_yn "
  314. DMA channel ${chan} is already in use by the $clash device.  However, the
  315. $clash device is not currently configured into the kernel.  Do you wish to
  316. remove DMA channel ${chan} from the $clash device?" y || cleanup $FAIL
  317.                 if [ "$result" = "Y" ]
  318.                 then
  319.                         sed -e "/^$clash        .*[0-9]$/{" \
  320.                                 -e 's/[0-9]$/-1/p' \
  321.                                 -e '}' mdevice > /tmp/bog$$
  322.                         mv /tmp/bog$$ mdevice
  323.                         cd $currdir
  324.                         return $FAIL
  325.                 else
  326.                         cd $currdir
  327.                         return $OK
  328.                 fi
  329.         fi
  330.         # Should be release >3.2.2, clash driver not installed if we get here.
  331.         cd $currdir
  332.         return $FAIL
  333. # Check if there is a clash of DMA channels
  334. checkdma() {
  335.         driver=$1
  336.         channel=$2
  337.         clash=
  338.         currdir=`pwd`
  339.         while dodmaclash $driver $channel
  340.         do
  341.                 prompt_yn "
  342. DMA channel ${channel} is already in use by the $clash device.
  343. You must choose a unique channel for this device to work.
  344. Do you wish to choose another channel now?" y || cleanup $FAIL
  345.                 if [ "$result" = "Y" ]
  346.                 then
  347.                         return $FAIL
  348.                 else
  349.                         cleanup $FAIL
  350.                 fi
  351.         done
  352.         return $OK
  353. check_args() {
  354.         name=$1
  355.         bd=$2
  356.         case $name in
  357.         r7e) echo "Configuring PCI ethernet adapter board $bd";
  358.                 PREFIX="r7e";
  359.                 MAX_BD=3;
  360.                 ;;
  361.         *) echo "ERROR: Unknown LLI driver being configured ($name$bd)";
  362.                 cleanup $FAIL;
  363.                 ;;
  364.         esac
  365.         if [ $bd -gt $MAX_BD ]
  366.         then
  367.                 echo "ERROR: Only boards 0..$MAX_BD are supported by this driver";
  368.                 cleanup $FAIL
  369.         fi
  370.         echo
  371. # function to produce the info for the System file for the RTL
  372. # boards
  373. system_r7e() {
  374. bd=$1
  375. IRQ=0;
  376. DMA=-1;
  377. FORCE="auto";
  378. BIO=0;
  379. EIO=0;
  380. BUS=0;
  381. DMACHAN=-1
  382. NMINORS="1"
  383. ############################################
  384. ##########clt 11/15/1996####################
  385. ####change space.c file ####################
  386. #set -x
  387. prompt_select "Enter hardware_default_setting, or auto, force 10 or 10bps, half or full duplex:" $FORCE "hwset auto 10half 10full 100half 100full" || cleanup $FAIL
  388. FORCE=$result
  389. [ "$result" = "hwset" ] && FORCE="0"
  390. [ "$result" = "auto" ] && FORCE="2"
  391. [ "$result" = "10half" ] && FORCE="10"
  392. [ "$result" = "10full" ] && FORCE="11"
  393. [ "$result" = "100half" ] && FORCE="100"
  394. [ "$result" = "100full" ] && FORCE="101"
  395. spacef=${CONF}/pack.d/${drv}0/space.c
  396. a=`grep  "^#define[ ]${drv}force_$bd" $spacef`
  397. c="#define ${drv}force_$bd $FORCE"
  398. sed "s/${a}/${c}/" $spacef > /tmp/bog$$
  399. cp /tmp/bog$$ $spacef
  400. rm /tmp/bog$$
  401. echo "Detect PCI fast ethernet adapter hardware automatically."
  402. # function to remove address conflicts in the sio driver
  403. sio_conflict() {
  404.         currdir=`pwd`
  405.         cd /etc/conf/pack.d/sio
  406.         if [ "$type" = "386GT" -a "$base" = "tok0" ]
  407.         then
  408.                 # get rid of sio access to 0x2f0 (Global Interrupt enable) on AT
  409.                 grep "ibm COM3" space.c > /dev/null && {
  410.                         echo "Removing ibm COM3 from link kit..."
  411.                         [ ! -f space.c.rls ] && cp space.c space.c.rls
  412.                         sed -e /"ibm COM3/s/^{/\/* LLI {/p" space.c > /tmp/bog$$
  413.                         mv /tmp/bog$$ space.c > /dev/null 2>&1
  414.                 }
  415.         fi
  416.         grep "(sd)0x$BIO" space.c > /dev/null && {
  417.                 echo "Removing serial cards using base address 0x$BIO from link kit..."
  418.                 [ ! -f space.c.rls ] && cp space.c space.c.rls
  419.                 sed -e /"(sd)0x$BIO,/s/^{/\/* LLI {/p" space.c > /tmp/bog$$
  420.                 mv /tmp/bog$$ space.c > /dev/null 2>&1
  421.         }
  422.         cd $currdir
  423. # determine release, and AT or MCA bus - set rel and type variables accordingly.
  424. os_type() {
  425.         rel=`sed -n 's/^#rel=\(.*\).$/\1/p' /etc/perms/rts`
  426.         if [ "$rel" = "3.2.0" -o "$rel" = "3.2.1" -o "$rel" = "3.2.2" ]
  427.         then
  428.                 type=`sed -n 's/^#typ=\(.*\)$/\1/p' /etc/perms/inst`
  429.         else
  430.                 # 3.2.4 - one release supports AT, MCA, and EISA.
  431.                 uname -X | grep "BusType = MCA" >/dev/null 2>&1
  432.                 if [ $? -eq 0 ]
  433.                 then
  434.                         type=386MC
  435.                 else
  436.                         type=386GT
  437.                 fi
  438.         fi
  439. create_scripts()
  440.         if [ $bd -ne $MAX_BD ]
  441.         then
  442.                 currdir=`pwd`
  443.                 netconfigdir=/usr/lib/netconfig
  444.                 cd $netconfigdir/info
  445.                 newboard=`expr $bd + 1`
  446.                 newfile=${drv}${newboard}
  447.                 cp ${drv}0 $newfile
  448.                 sed -e '/^NAME=.*'"[^0]"'/s/0\"/'$newboard'\"/p' $newfile > /tmp/bog$$
  449.                 sed -e '/^DESCRIPTION=.*'"[^0]"'/s/0\"/'$newboard'\"/p' /tmp/bog$$ > $newfile
  450.                 rm -r /tmp/bog$$
  451.                 chown bin $newfile
  452.                 chgrp bin $newfile
  453.                 chmod 750 $newfile
  454.                 cd $netconfigdir/init
  455.                 ln $base ${drv}`expr $bd + 1` > /dev/null 2>&1
  456.                 cd $netconfigdir/remove
  457.                 ln $base ${drv}`expr $bd + 1` > /dev/null 2>&1
  458.                 cd $currdir
  459.         fi
  460. # main()
  461. # get the name of the init script being run, since one script
  462. # is used for multiple drivers; get the number at the end of the
  463. # script's name
  464. if [ $# -gt 1 ]
  465.         name_below=$1; if_below=$2
  466.         name_above=$3; if_above=$4
  467.         configure=$5
  468. base=`basename $0`
  469. drv=`echo $base | sed -e 's/[0-9]*$//`
  470. bd=`expr $base : '.*\(.\)'`
  471. chains=/usr/lib/lli/chains
  472. chain=$base:$name_above
  473. confdir=/etc/conf/cf.d
  474. makedevs
  475. check_args $drv $bd
  476. # Check and manage our internal chains file.
  477. # This file allows coexistent mkdev and netconfig calls.
  478. # chain already installed
  479. grep $chain $chains > /dev/null 2>& 1 && {
  480. ########## clt test #########
  481. echo "r7e init check chain error !! (1) chain (2) chains"  $chain $chains
  482. ########## clt test #########
  483.         echo $chain >> $chains
  484.         cleanup $OK
  485. # this board already installed
  486. grep $base: $chains > /dev/null 2>& 1 && {
  487.         echo $base already configured.
  488.         echo $chain >> $chains
  489.         [ "$drv" = "tok" -a "$name_above" = "nbe" ] && {
  490.                 space_token
  491.         }
  492.         echo "NODE=/etc/conf/node.d/$base" >/tmp/$base.src
  493.         chmod 777 /tmp/$base.src
  494.         cleanup $OK
  495. # Now check that if we are not board zero that board zero is installed
  496. [ "$bd" -ne "0" ] && {
  497.         grep ${drv}0 $chains > /dev/null 2>& 1 || {
  498.                 echo "${drv}0 not configured, you must configure it first"
  499.                 cleanup $FAIL
  500.         }
  501. # check to see if the driver is already in the kernel link-kit so we can
  502. # either add it or update it later on
  503. idcheck -p $base -i /tmp/dev$$
  504. if [ $? -gt 16 ]
  505.         installed="TRUE"
  506.         installed="FALSE"
  507. if [ "$bd" = "0" ]
  508.         echo "Installing the $drv driver into the link kit"
  509.         cd /usr/lib/lli/$drv
  510.         if [ "$installed" = "TRUE" ]
  511.         then
  512.                 idinstall -u -e -k $base
  513.         else
  514.                 idinstall -a -e -k $base
  515.         fi
  516.         makedevs
  517.         idcheck -p ${drv}0 -i /tmp/dev$$
  518.         if [ $? -le 16 ]
  519.         then
  520.                 echo "${drv}0 must be configured before attempting to configure $drv"
  521.                 cleanup 1
  522.         fi
  523. # create the temporary directory for installing the driver
  524. cd /tmp; rm -rf $base
  525. mkdir $base; cd $base
  526. DMACHAN="-1"
  527. # set rel, type variables.
  528. os_type
  529. # Do special board dependent processing
  530. system_$drv $bd
  531. if [ "$IRQ" = "2" ]
  532.         IRQ=9
  533. echo "$base\tY\t4\t5\t0\t0\t0\t0\t0\t0" >./System
  534. # All the drivers support more than one board.  In fact all the code to
  535. # support all the boards is in the Driver.o for the board for the 1st board
  536. # (eg the e3A0 driver acually contains enough code for the e3A1, e3A2 & e3A3
  537. # boards).  As we need a Driver.o to be associated with 2nd, 3rd or 4th board
  538. # we install a dummy Driver.o, and a Master and Node which will actually cause
  539. # calls into the base driver.
  540. if [ $bd -gt 0 ]
  541.         echo "$base     -       iScH    $PREFIX$bd      0       0       1       256     $DMACHAN" >./Master
  542.         echo "clone     $base   c       $base" >./Node
  543.         if [ "$installed" = "TRUE" ]
  544.         then
  545.                 idinstall -u -m -s -n -e -k $base
  546.         else
  547.                 cp $LIB/Driver.o .
  548.                 idinstall -a -e -k $base
  549.         fi
  550.         echo "$base     I       iScH    $PREFIX 0       0       1       256     $DMACHAN" >./Master
  551.         idinstall -u -m -s -e -k $base
  552. # we successfully installed this driver, add it to the chains file
  553. echo $chain >> $chains
  554. # create next set of info, init, and remove files
  555. create_scripts
  556. # delete any potential BASE I/O address conflicts with the sio driver
  557. [ "$rel" = "3.2.0" -o "$rel" = "3.2.1" -o "$rel" = "3.2.2" ] && sio_conflict
  558. echo "NODE=/etc/conf/node.d/$base" >/tmp/$base.src
  559. chmod 777 /tmp/$base.src
  560. cleanup $RELINK
  561.