home *** CD-ROM | disk | FTP | other *** search
/ Chip 2007 January, February, March & April / Chip-Cover-CD-2007-02.iso / boot / i386 / rescue / etc / init.d / setserial < prev    next >
Text File  |  2006-11-29  |  10KB  |  238 lines

  1. #!/bin/sh
  2. #
  3. # /etc/init.d/serial 
  4. #
  5. # Initializes the serial ports on your system
  6. #
  7. # Without uncommenting some of the lines in this script, you'll be unable to
  8. # use ports other than the first two, and those only if they use "standard"
  9. # IRQ values (whatever those are... :^)  The rc.serial script made a couple
  10. # machines I tested this on hang at this point in the boot process, so it's
  11. # commented out by default. However, if you need to set up extended serial
  12. # ports, it's a very good starting point. It usually works great.
  13. # More info that will be useful: I did some testing and found that the lines
  14. # in /etc/rc.d/rc.serial that are most likely to make the machine hang are the
  15. # one that sets up /dev/ttyS3, and the last time, which causes a report to be
  16. # issued to the console about how the ports were configured. This tries to
  17. # report on *every* port... if you change it so it only lists the ports you're
  18. # going to use (/dev/ttyS0 /dev/cua1 /dev/cua2 for example) that it probably
  19. # won't cause a hang. Also, the "wild" interrupt detection used for auto-
  20. # configuration can cause problems as well. I highly recommend using the
  21. # manual configuration lines to avoid trouble.
  22. #
  23. ### BEGIN INIT INFO
  24. # Provides:          setserial
  25. # Should-Start:      $local_fs boot.loadmodules
  26. # Default-Start:     B
  27. # Default-Stop:
  28. # Description:       Initializes the serial ports
  29. ### END INIT INFO
  30.  
  31. . /etc/rc.status
  32.  
  33. SETSERIAL="/bin/setserial -b"
  34.  
  35. rc_reset
  36. case $1 in
  37.   start|b)
  38.     PORTS=`(for p in /dev/ttyS*; do isserial <$p && echo $p; done) 2>/dev/null`
  39.  
  40.     run_setserial ()
  41.     {
  42.     $SETSERIAL $@
  43.     rc_status
  44.     }
  45.  
  46.     echo "Configuring serial ports..."
  47.  
  48.     # Do wild interrupt detection (uncomment if you're brave enough to
  49.     # attempt auto-configuration... )
  50.     #
  51.     # run_setserial -W ${PORTS}
  52.  
  53.     ###############################################################
  54.     #
  55.     # AUTOMATIC CONFIGURATION 
  56.     #
  57.     # Uncomment the appropriate lines below to enable auto-configuration
  58.     # of a particular board.  Or comment them out to disable them....
  59.     #
  60.     ###############################################################
  61.  
  62.     # Do AUTOMATIC_IRQ probing
  63.     #
  64.     AUTO_IRQ=auto_irq
  65.  
  66.     # These are the standard COM1 through COM4 devices
  67.     #
  68.     # If you have an internal modeme with a Rockwell Chipset, add a "skip_test"
  69.     # to the /dev/ttyS3 line below.  (It's not added by default because it will
  70.     # screw up people with 8514 displays).
  71.     #
  72.     # run_setserial /dev/ttyS0 ${AUTO_IRQ} skip_test autoconfig
  73.     # run_setserial /dev/ttyS1 ${AUTO_IRQ} skip_test autoconfig
  74.     # run_setserial /dev/ttyS2 ${AUTO_IRQ} skip_test autoconfig
  75.     # run_setserial /dev/ttyS3 ${AUTO_IRQ} autoconfig
  76.  
  77.     # These are for the first AST Fourport board (base address 0x1A0)
  78.     #
  79.     # run_setserial /dev/ttyS4 ${AUTO_IRQ} autoconfig
  80.     # run_setserial /dev/ttyS5 ${AUTO_IRQ} autoconfig
  81.     # run_setserial /dev/ttyS6 ${AUTO_IRQ} autoconfig
  82.     # run_setserial /dev/ttyS7 ${AUTO_IRQ} autoconfig
  83.  
  84.     # These are for the second AST Fourport board (base address 0x2A0)
  85.     #
  86.     # run_setserial /dev/ttyS8 ${AUTO_IRQ} autoconfig
  87.     # run_setserial /dev/ttyS9 ${AUTO_IRQ} autoconfig
  88.     # run_setserial /dev/ttyS10 ${AUTO_IRQ} autoconfig
  89.     # run_setserial /dev/ttyS11 ${AUTO_IRQ} autoconfig
  90.  
  91.     # These are the 3rd and 4th ports on the Accent Async board.
  92.     #
  93.     # run_setserial /dev/ttyS12 ${AUTO_IRQ} autoconfig
  94.     # run_setserial /dev/ttyS13 ${AUTO_IRQ} autoconfig
  95.  
  96.     # Usenet Serial Board II (base address 0x100)
  97.     #
  98.     # run_setserial /dev/ttyS16 ${AUTO_IRQ} autoconfig
  99.     # run_setserial /dev/ttyS17 ${AUTO_IRQ} autoconfig
  100.     # run_setserial /dev/ttyS18 ${AUTO_IRQ} autoconfig
  101.     # run_setserial /dev/ttyS19 ${AUTO_IRQ} autoconfig
  102.  
  103.  
  104.     # BocaBoard 4 port (BB-1004) (base address 0x100)
  105.     # 
  106.     # run_setserial /dev/ttyS16 ${AUTO_IRQ} autoconfig
  107.     # run_setserial /dev/ttyS17 ${AUTO_IRQ} autoconfig
  108.     # run_setserial /dev/ttyS18 ${AUTO_IRQ} autoconfig
  109.     # run_setserial /dev/ttyS19 ${AUTO_IRQ} autoconfig
  110.  
  111.     # BocaBoard 8 port (BB-1008) (base address 0x100),
  112.     # or two BB-1004's (base addresses 0x100 and 0x120)
  113.     #
  114.     # run_setserial /dev/ttyS16 ${AUTO_IRQ} autoconfig
  115.     # run_setserial /dev/ttyS17 ${AUTO_IRQ} autoconfig
  116.     # run_setserial /dev/ttyS18 ${AUTO_IRQ} autoconfig
  117.     # run_setserial /dev/ttyS19 ${AUTO_IRQ} autoconfig
  118.     # run_setserial /dev/ttyS20 ${AUTO_IRQ} autoconfig
  119.     # run_setserial /dev/ttyS21 ${AUTO_IRQ} autoconfig
  120.     # run_setserial /dev/ttyS22 ${AUTO_IRQ} autoconfig
  121.     # run_setserial /dev/ttyS23 ${AUTO_IRQ} autoconfig
  122.  
  123.     # BocaBoard 16 port (BB-1008), (base address 0x100),
  124.     # or two BB-1008's (base addresses 0x100 and 0x140),
  125.     # or four BB-1004's (base address 0x100, 0x120, 0x140, and 0x160)
  126.     #
  127.     # Warning --- some of these ports may conflict with the Future Domain
  128.     # SCSI controller.  If you want to run both the BocaBoards and the 
  129.     # Future Domain controller, you may need to change the port assignment
  130.     # of the Bocaboards -- see below in the section on manual configuration.
  131.     #
  132.     # run_setserial /dev/ttyS16 ${AUTO_IRQ} autoconfig
  133.     # run_setserial /dev/ttyS17 ${AUTO_IRQ} autoconfig
  134.     # run_setserial /dev/ttyS18 ${AUTO_IRQ} autoconfig
  135.     # run_setserial /dev/ttyS19 ${AUTO_IRQ} autoconfig
  136.     # run_setserial /dev/ttyS20 ${AUTO_IRQ} autoconfig
  137.     # run_setserial /dev/ttyS21 ${AUTO_IRQ} autoconfig
  138.     # run_setserial /dev/ttyS22 ${AUTO_IRQ} autoconfig
  139.     # run_setserial /dev/ttyS23 ${AUTO_IRQ} autoconfig
  140.     # run_setserial /dev/ttyS24 ${AUTO_IRQ} autoconfig
  141.     # run_setserial /dev/ttyS25 ${AUTO_IRQ} autoconfig
  142.     # run_setserial /dev/ttyS26 ${AUTO_IRQ} autoconfig
  143.     # run_setserial /dev/ttyS27 ${AUTO_IRQ} autoconfig
  144.     # run_setserial /dev/ttyS28 ${AUTO_IRQ} autoconfig
  145.     # run_setserial /dev/ttyS29 ${AUTO_IRQ} autoconfig
  146.     # run_setserial /dev/ttyS30 ${AUTO_IRQ} autoconfig
  147.     # run_setserial /dev/ttyS31 ${AUTO_IRQ} autoconfig
  148.  
  149.     ###############################################################
  150.     #
  151.     # MANUAL CONFIGURATION 
  152.     #
  153.     # If you want to do manual configuration of one or more of your 
  154.     # serial ports, uncomment and modify the relevant lines.
  155.     #
  156.     ###############################################################
  157.  
  158.     # These are the standard COM1 through COM4 devices
  159.     #
  160.     # run_setserial /dev/ttyS0 uart 16550A port 0x3F8 irq 4
  161.     # run_setserial /dev/ttyS1 uart 16550A port 0x2F8 irq 3
  162.     # run_setserial /dev/ttyS2 uart 16450 port 0x3E8 irq 4
  163.     # run_setserial /dev/ttyS3 uart 16450 port 0x2E8 irq 3
  164.     
  165.     # These are the first set of AST Fourport ports
  166.     #
  167.     # run_setserial /dev/ttyS4 uart 16450 port 0x2A0 irq 7 fourport
  168.     # run_setserial /dev/ttyS5 uart 16450 port 0x2A8 irq 7 fourport
  169.     # run_setserial /dev/ttyS6 uart 16450 port 0x2B0 irq 7 fourport
  170.     # run_setserial /dev/ttyS7 uart 16450 port 0x2B8 irq 7 fourport
  171.     
  172.     # These are the second set of AST Fourport ports
  173.     #
  174.     # run_setserial /dev/ttyS8 uart 16450 port 0x2A0 irq 5 fourport
  175.     # run_setserial /dev/ttyS9 uart 16450 port 0x2A8 irq 5 fourport
  176.     # run_setserial /dev/ttyS10 uart 16450 port 0x2B0 irq 5 fourport
  177.     # run_setserial /dev/ttyS11 uart 16450 port 0x2B8 irq 5 fourport
  178.  
  179.     # These are the 3rd and 4th ports on the Accent Async board.
  180.     #
  181.     # run_setserial /dev/ttyS12 uart 16450 port 0x330 irq 4
  182.     # run_setserial /dev/ttyS13 uart 16450 port 0x338 irq 4
  183.     
  184.     # These are two spare devices you can use to customize for 
  185.     # some board which is not supported above....
  186.     # run_setserial /dev/ttyS14 uart XXXXX port XXXX irq X
  187.     # run_setserial /dev/ttyS15 uart XXXXX port XXXX irq X
  188.     
  189.     # These are the ports used for either the Usenet Serial II
  190.     # board, or the Boca Board 4, 8, or 16 port boards.
  191.     #
  192.     # Uncomment only the first 4 lines for the Usenet Serial II board,
  193.     # and uncomment the first 4, 8, or all 16 lines for the
  194.     # Boca Board BB-1004, BB-1008, and BB-2016 respectively.
  195.     #
  196.     # run_setserial /dev/ttyS16 uart 16550A port 0x100 irq 12
  197.     # run_setserial /dev/ttyS17 uart 16550A port 0x108 irq 12
  198.     # run_setserial /dev/ttyS18 uart 16550A port 0x110 irq 12
  199.     # run_setserial /dev/ttyS19 uart 16550A port 0x118 irq 12
  200.     # run_setserial /dev/ttyS20 uart 16550A port 0x120 irq 12
  201.     # run_setserial /dev/ttyS21 uart 16550A port 0x128 irq 12
  202.     # run_setserial /dev/ttyS22 uart 16550A port 0x130 irq 12
  203.     # run_setserial /dev/ttyS23 uart 16550A port 0x138 irq 12
  204.     # run_setserial /dev/ttyS24 uart 16550A port 0x140 irq 12
  205.     # run_setserial /dev/ttyS25 uart 16550A port 0x148 irq 12
  206.     # run_setserial /dev/ttyS26 uart 16550A port 0x150 irq 12
  207.     # run_setserial /dev/ttyS27 uart 16550A port 0x158 irq 12
  208.     # run_setserial /dev/ttyS28 uart 16550A port 0x160 irq 12
  209.     # run_setserial /dev/ttyS29 uart 16550A port 0x168 irq 12
  210.     # run_setserial /dev/ttyS30 uart 16550A port 0x170 irq 12
  211.     # run_setserial /dev/ttyS31 uart 16550A port 0x178 irq 12
  212.     
  213.     ###########################################################
  214.     #
  215.     # Print the results of the serial configuration process
  216.     #
  217.     ###########################################################
  218.     
  219.  
  220.     ${SETSERIAL} -bg ${PORTS}
  221.     rc_status
  222.     echo "Configured serial ports"
  223.     rc_status -v1
  224.     ;;
  225.   stop)
  226.     # skip / do nothing
  227.     ;;
  228.   status)
  229.     PORTS=`(for p in /dev/ttyS*; do isserial <$p && echo $p; done) 2>/dev/null`
  230.     ${SETSERIAL} -bg ${PORTS}
  231.     rc_status -v1
  232.     ;;
  233.   *)
  234.     echo "usage: setserial {start|stop|status}"
  235.     ;;
  236. esac
  237. rc_exit
  238.