home *** CD-ROM | disk | FTP | other *** search
/ Jason Aller Floppy Collection / 202.img / SCO386N2.TD0 / usr / sys / io / mousconfig < prev    next >
Encoding:
Text File  |  1988-08-30  |  2.9 KB  |  160 lines

  1.  
  2. #    %Z% %M% %I% %D% %Q%
  3. #
  4. #    Copyright (C) The Santa Cruz Operation, 1988.
  5. #    This Module contains Proprietary Information of
  6. #    The Santa Cruz Operation, Microsoft Corporation
  7. #    and AT&T, and should be treated as Confidential.
  8. #
  9. # MOUSCONFIG    - XENIX System V busmouse configuration.
  10. #
  11.  
  12. PATH=/etc:/bin:/usr/bin
  13. DIR=/usr/sys/io
  14. STOREL="/usr/lib/storel -DM_I386 -Mx -r -omoustmp.o"
  15. MOUSFILE=mousconf.asm
  16. MOUSOFILE=mousconf.o
  17. TMPFILE=/tmp/mousconfig$$
  18.  
  19. # Define return values
  20. : ${OK=0} ${FAIL=1} ${STOP=10} ${HALT=11}
  21.  
  22. cleanup="rm -rf $TMPFILE"
  23.  
  24. trap 'eval $cleanup; exit $FAIL' 1 2 3 15
  25.  
  26. # Prompt for yes or no answer - returns non-zero for no
  27. getyn() {
  28.     while    echo "\n$* (y/n) \c">&2
  29.     do    read yn rest
  30.         case $yn in
  31.         [yY])    return 0             ;;
  32.         [nN])    return 1            ;;
  33.         *)    echo "Please answer y or n" >&2    ;;
  34.         esac
  35.     done
  36. }
  37.  
  38. Getdfl() {
  39.     read prm1 prm2 prm3 prm4 < $TMPFILE
  40.     modified=
  41. }
  42. Reset() {
  43.     prm1=0 prm2=0H
  44.     modified=1
  45. }
  46. Getcur() {
  47.     echo `sed -n -e '
  48.         /@PARM/    {
  49.             s/.*[     ]*equ[     ]*//
  50.             s/[     ].*//
  51.             p
  52.             }
  53.     ' $MOUSFILE` > $TMPFILE
  54. }
  55. Setcur() {
  56.     ed - $MOUSFILE <<-EOF
  57.         /@PARM1/s/equ[     ]*[^     ]*/equ    $prm1/
  58.         /@PARM2/s/equ[     ]*[^     ]*/equ    $prm2/
  59.     w
  60.     q
  61.     EOF
  62.     $STOREL $MOUSFILE > /dev/null 2>&1 || {
  63.         getyn "System configure failed.  Try again?" || {
  64.             # answered no
  65.             echo "\nThe system should be configured in order to use a busmouse.  Exiting."
  66.             eval $cleanup
  67.             exit $FAIL 
  68.             }
  69.         # answered yes
  70.         return 1
  71.     }
  72.     mv moustmp.o $MOUSOFILE
  73. }
  74. Showcur() {
  75.     echo "
  76.     Busmouse Parameters    Values    Comments
  77.     -------------------     ------    --------
  78.     1. Interrupt Vector    $prm1    logical vector number
  79.     2. Base Address        $prm2    i/o addresses start here
  80.     
  81.     Zero Values Imply Auto-Configuration"
  82. }
  83.  
  84. # beginning
  85. case $# in
  86. 0)
  87.     ;;
  88. *)
  89.     echo "USAGE: mousconfig"
  90.     eval $cleanup
  91.     exit $FAIL
  92.     ;;
  93. esac
  94.  
  95. status=0
  96. cd $DIR
  97. Getcur
  98. Getdfl
  99.  
  100. while echo "\nBusmouse Configuration
  101.  
  102.     1. Display current busmouse parameters
  103.     2. Modify current busmouse parameters
  104.     3. Select previous busmouse parameters
  105.     4. Select default busmouse parameters
  106.  
  107. Enter an option or 'q' to quit: \c"
  108. do
  109.     read ans
  110.     case "$ans" in
  111.     1)    Showcur
  112.         ;;
  113.     2)
  114.         Showcur
  115.         while echo "\nEnter a parameter to modify or 'q' to return to the main menu: \c"
  116.         do
  117.             read y
  118.             case "$y" in
  119.             [1-4])    while echo "\nHexadecimal values may be entered with a trailing 'H'.
  120. For example, 0x0300 would be entered as 0300H.
  121. Enter the new value or <RETURN> to use the existing value: \c"
  122.                 do
  123.                     read z
  124.                     case "$z" in
  125.                     [0-9]*)
  126.                         eval prm$y=$z
  127.                         modified=1
  128.                         break
  129.                         ;;
  130.                     "")    break
  131.                         ;;
  132.                     *)    echo "Please enter a numeric value. \n"
  133.                         ;;
  134.                     esac
  135.                 done
  136.                 ;;
  137.             [qQ])    break
  138.                 ;;
  139.             *)    echo "Please enter a choice, 1-4 or 'q'. \n"
  140.                 ;;
  141.             esac
  142.         done
  143.         ;;
  144.     3)    [ $modified ] && {
  145.             Getdfl
  146.             Showcur
  147.             }
  148.         ;;
  149.     4)    Reset
  150.         Showcur
  151.         ;;
  152.     [qQ])    [ $modified ] && Setcur 
  153.         break
  154.         ;;
  155.     *)    echo "\nPlease enter '1', '2', '3', '4' or 'q'.\n"
  156.         ;;
  157.     esac
  158. done
  159. eval $cleanup
  160.