Add the DragonFly cvs id and perform general cleanups on cvs/rcs/sccs ids. Most
[dragonfly.git] / etc / rc.serial
1 #!/bin/sh
2 #
3 # Copyright (c) 1996  Andrey A. Chernov
4 # All rights reserved.
5 #
6 # Redistribution and use in source and binary forms, with or without
7 # modification, are permitted provided that the following conditions
8 # are met:
9 # 1. Redistributions of source code must retain the above copyright
10 #    notice, this list of conditions and the following disclaimer.
11 # 2. Redistributions in binary form must reproduce the above copyright
12 #    notice, this list of conditions and the following disclaimer in the
13 #    documentation and/or other materials provided with the distribution.
14 #
15 # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
16 # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 # ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
19 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21 # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 # SUCH DAMAGE.
26 #
27 # $FreeBSD: src/etc/rc.serial,v 1.14.2.5 2002/05/07 07:47:17 sobomax Exp $
28 # $DragonFly: src/etc/Attic/rc.serial,v 1.2 2003/06/17 04:24:45 dillon Exp $
29 #
30
31 # Change some defaults for serial devices.
32 # Standard defaults are:
33 #       dtrwait 300 drainwait 0
34 #       initial cflag from <sys/ttydefaults.h> = cread cs8 hupcl
35 #       initial iflag, lflag and oflag all 0
36 #       speed 9600
37 #       special chars from <sys/ttydefaults.h>
38 #       nothing locked
39 # except for serial consoles the initial iflag, lflag and oflag are from
40 # <sys/ttydefaults.h> and clocal is locked on.
41
42 default() {
43         # Reset everything changed by the other functions to initial defaults.
44
45         ci=$1; shift    # call in device identifier
46         co=$1; shift    # call out device identifier
47
48         for i in $*
49         do
50                 comcontrol /dev/tty${ci}${i} dtrwait 300 drainwait 0
51                 stty < /dev/ttyi${ci}${i} -clocal crtscts hupcl 9600 reprint ^R
52                 stty < /dev/ttyl${ci}${i} -clocal -crtscts -hupcl 0
53                 stty < /dev/cuai${co}${i} -clocal crtscts hupcl 9600 reprint ^R
54                 stty < /dev/cual${co}${i} -clocal -crtscts -hupcl 0
55         done
56 }
57
58 maybe() {
59         # Special settings.
60
61         ci=$1; shift
62         co=$1; shift
63
64         for i in $*
65         do
66                 # Don't use ^R; it breaks bash's ^R when typed ahead.
67                 stty < /dev/ttyi${ci}${i} reprint undef
68                 stty < /dev/cuai${co}${i} reprint undef
69                 # Lock clocal off on dialin device for security.
70                 stty < /dev/ttyl${ci}${i} clocal
71                 # Lock the speeds to use old binaries that don't support them.
72                 # Any legal speed works to lock the initial speed.
73                 stty < /dev/ttyl${ci}${i} 300
74                 stty < /dev/cual${co}${i} 300
75         done
76 }
77
78 modem() {
79         # Modem that supports CTS and perhaps RTS handshaking.
80
81         ci=$1; shift
82         co=$1; shift
83
84         for i in $*
85         do
86                 # may depend on modem
87                 comcontrol /dev/tty${ci}${i} dtrwait 100 drainwait 180
88                 # Lock crtscts on.
89                 # Speed reasonable for V42bis.
90                 stty < /dev/ttyi${ci}${i} crtscts 57600
91                 stty < /dev/ttyl${ci}${i} crtscts
92                 stty < /dev/cuai${co}${i} crtscts 57600
93                 stty < /dev/cual${co}${i} crtscts
94         done
95 }
96
97 mouse() {
98         # Mouse on either callin or callout port.
99
100         ci=$1; shift
101         co=$1; shift
102
103         for i in $*
104         do
105                 # Lock clocal on, hupcl off.
106                 # Standard speed for Microsoft mouse.
107                 stty < /dev/ttyi${ci}${i} clocal -hupcl 1200
108                 stty < /dev/ttyl${ci}${i} clocal  hupcl
109                 stty < /dev/cuai${co}${i} clocal -hupcl 1200
110                 stty < /dev/cual${co}${i} clocal  hupcl
111         done
112 }
113
114 terminal() {
115         # Terminal that supports CTS and perhaps RTS handshaking
116         # with the cable or terminal arranged so that DCD is on
117         # at least while the terminal is on.
118         # Also works for bidirectional communications to another pc
119         # provided at most one side runs getty.
120         # Same as modem() except we want a faster speed and no dtrwait.
121
122         ci=$1; shift
123         co=$1; shift
124
125         modem ${ci} ${co} $*
126         for i in $*
127         do
128                 comcontrol /dev/tty${ci}${i} dtrwait 0
129                 stty < /dev/ttyi${ci}${i} 115200
130                 stty < /dev/cuai${co}${i} 115200
131         done
132 }
133
134 # Don't use anything from this file unless you have some buggy programs
135 # that require it.
136
137 # Edit the functions and the examples to suit your system.
138 # $1 is the call in device identifier, $2 is the call out device identifier
139 # and the remainder of the line lists the device numbers.
140
141 # Initialize assorted 8250-16550 (sio) ports.
142 # maybe    d a  0 1 2 3 4 5 6 7 8 9 a b c d e f g h i j k l m n o p q r s t u v
143 # mouse    d a      2
144 # modem    d a    1
145 # terminal d a  0
146
147 # Initialize all ports on a Cyclades-8yo.
148 # modem    c c  00 01 02 03 04 05 06 07
149
150 # Initialize all ports on a Cyclades-16ye.
151 # modem    c c  00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 
152
153 # Initialize all ports on a Digiboard 8.
154 # modem    D D  00 01 02 03 04 05 06 07