175900Sjoe#!/bin/sh
275900Sjoe# $FreeBSD: releng/10.2/release/picobsd/mfs_tree/etc/rc.serial 75900 2001-04-24 07:46:35Z joe $
375900Sjoe
475900Sjoe# Change some defaults for serial devices.
575900Sjoe# Standard defaults are:
675900Sjoe#	dtrwait 300 drainwait 0
775900Sjoe#	initial cflag from <sys/ttydefaults.h> = cread cs8 hupcl
875900Sjoe#	initial iflag, lflag and oflag all 0
975900Sjoe#	speed 9600
1075900Sjoe#	special chars from <sys/ttydefaults.h>
1175900Sjoe#	nothing locked
1275900Sjoe# except for serial consoles the initial iflag, lflag and oflag are from
1375900Sjoe# <sys/ttydefaults.h> and clocal is locked on.
1475900Sjoe
1575900Sjoedefault() {
1675900Sjoe	# Reset everything changed by the other functions to initial defaults.
1775900Sjoe
1875900Sjoe	ci=$1; shift	# call in device identifier
1975900Sjoe	co=$1; shift	# call out device identifier
2075900Sjoe
2175900Sjoe	for i in $*
2275900Sjoe	do
2375900Sjoe		comcontrol /dev/tty$ci$i dtrwait 300 drainwait 0
2475900Sjoe		stty </dev/ttyi$ci$i -clocal  crtscts  hupcl 9600 reprint ^R
2575900Sjoe		stty </dev/ttyl$ci$i -clocal -crtscts -hupcl 0
2675900Sjoe		stty </dev/cuai$co$i -clocal  crtscts  hupcl 9600 reprint ^R
2775900Sjoe		stty </dev/cual$co$i -clocal -crtscts -hupcl 0
2875900Sjoe	done
2975900Sjoe}
3075900Sjoe
3175900Sjoemaybe() {
3275900Sjoe	# Special settings.
3375900Sjoe
3475900Sjoe	ci=$1; shift
3575900Sjoe	co=$1; shift
3675900Sjoe
3775900Sjoe	for i in $*
3875900Sjoe	do
3975900Sjoe		# Don't use ^R; it breaks bash's ^R when typed ahead.
4075900Sjoe		stty </dev/ttyi$ci$i reprint undef
4175900Sjoe		stty </dev/cuai$co$i reprint undef
4275900Sjoe		# Lock clocal off on dialin device for security.
4375900Sjoe		stty </dev/ttyl$ci$i clocal
4475900Sjoe		# Lock the speeds to use old binaries that don't support them.
4575900Sjoe		# Any legal speed works to lock the initial speed.
4675900Sjoe		stty </dev/ttyl$ci$i 300
4775900Sjoe		stty </dev/cual$co$i 300
4875900Sjoe	done
4975900Sjoe}
5075900Sjoe
5175900Sjoemodem() {
5275900Sjoe	# Modem that supports CTS and perhaps RTS handshaking.
5375900Sjoe
5475900Sjoe	ci=$1; shift
5575900Sjoe	co=$1; shift
5675900Sjoe
5775900Sjoe	for i in $*
5875900Sjoe	do
5975900Sjoe		# may depend on modem
6075900Sjoe		comcontrol /dev/tty$ci$i dtrwait 100 drainwait 180
6175900Sjoe		# Lock crtscts on.
6275900Sjoe		# Speed reasonable for V42bis.
6375900Sjoe		stty </dev/ttyi$ci$i crtscts 57600
6475900Sjoe		stty </dev/ttyl$ci$i crtscts
6575900Sjoe		stty </dev/cuai$co$i crtscts 57600
6675900Sjoe		stty </dev/cual$co$i crtscts
6775900Sjoe	done
6875900Sjoe}
6975900Sjoe
7075900Sjoemouse() {
7175900Sjoe	# Mouse on either callin or callout port.
7275900Sjoe
7375900Sjoe	ci=$1; shift
7475900Sjoe	co=$1; shift
7575900Sjoe
7675900Sjoe	for i in $*
7775900Sjoe	do
7875900Sjoe		# Lock clocal on, hupcl off.
7975900Sjoe		# Standard speed for Microsoft mouse.
8075900Sjoe		stty </dev/ttyi$ci$i clocal -hupcl 1200
8175900Sjoe		stty </dev/ttyl$ci$i clocal  hupcl
8275900Sjoe		stty </dev/cuai$co$i clocal -hupcl 1200
8375900Sjoe		stty </dev/cual$co$i clocal  hupcl
8475900Sjoe	done
8575900Sjoe}
8675900Sjoe
8775900Sjoeterminal() {
8875900Sjoe	# Terminal that supports CTS and perhaps RTS handshaking
8975900Sjoe	# with the cable or terminal arranged so that DCD is on
9075900Sjoe	# at least while the terminal is on.
9175900Sjoe	# Also works for bidirectional communications to another pc
9275900Sjoe	# provided at most one side runs getty.
9375900Sjoe	# Same as modem() except we want a faster speed and no dtrwait.
9475900Sjoe
9575900Sjoe	ci=$1; shift
9675900Sjoe	co=$1; shift
9775900Sjoe
9875900Sjoe	modem $ci $co $*
9975900Sjoe	for i in $*
10075900Sjoe	do
10175900Sjoe		comcontrol /dev/tty$ci$i dtrwait 0
10275900Sjoe		stty </dev/ttyi$ci$i 115200
10375900Sjoe		stty </dev/cuai$co$i 115200
10475900Sjoe	done
10575900Sjoe}
10675900Sjoe
10775900Sjoe# Don't use anything from this file unless you have some buggy programs
10875900Sjoe# that require it.
10975900Sjoe
11075900Sjoe# Edit the functions and the examples to suit your system.
11175900Sjoe# $1 is the call in device identifier, $2 is the call out device identifier
11275900Sjoe# and the remainder of the line lists the device numbers.
11375900Sjoe
11475900Sjoe# Initialize assorted 8250-16550 (sio) ports.
11575900Sjoe# 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
11675900Sjoe# mouse    d a      2
11775900Sjoe# modem    d a    1
11875900Sjoe# terminal d a  0
11975900Sjoe
12075900Sjoe# Initialize all ports on a Cyclades-8yo.
12175900Sjoe# modem    c c  00 01 02 03 04 05 06 07
12275900Sjoe
12375900Sjoe# Initialize all ports on a Cyclades-16ye.
12475900Sjoe# modem    c c  00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 
12575900Sjoe
12675900Sjoe# Initialize all ports on a Digiboard 8.
12775900Sjoe# modem    D D  00 01 02 03 04 05 06 07
128