114239Sbde#!/bin/sh 266830Sobrien# 366830Sobrien# Copyright (c) 1996 Andrey A. Chernov 466830Sobrien# All rights reserved. 566830Sobrien# 666830Sobrien# Redistribution and use in source and binary forms, with or without 766830Sobrien# modification, are permitted provided that the following conditions 866830Sobrien# are met: 966830Sobrien# 1. Redistributions of source code must retain the above copyright 1066830Sobrien# notice, this list of conditions and the following disclaimer. 1166830Sobrien# 2. Redistributions in binary form must reproduce the above copyright 1266830Sobrien# notice, this list of conditions and the following disclaimer in the 1366830Sobrien# documentation and/or other materials provided with the distribution. 1466830Sobrien# 1566830Sobrien# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 1666830Sobrien# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 1766830Sobrien# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 1866830Sobrien# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 1966830Sobrien# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2066830Sobrien# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2166830Sobrien# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2266830Sobrien# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 2366830Sobrien# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 2466830Sobrien# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 2566830Sobrien# SUCH DAMAGE. 2666830Sobrien# 2750472Speter# $FreeBSD$ 2866830Sobrien# 2914239Sbde 30100280Sgordon# PROVIDE: serial 31100280Sgordon# REQUIRE: root 32136224Smtm# KEYWORD: nojail 33100280Sgordon 3413798Smpp# Change some defaults for serial devices. 351675Sache# Standard defaults are: 36114682Sbde# dtrwait 300 drainwait `sysctl -n kern.drainwait` 371675Sache# initial cflag from <sys/ttydefaults.h> = cread cs8 hupcl 381675Sache# initial iflag, lflag and oflag all 0 391675Sache# speed 9600 401675Sache# special chars from <sys/ttydefaults.h> 411675Sache# nothing locked 421675Sache# except for serial consoles the initial iflag, lflag and oflag are from 431675Sache# <sys/ttydefaults.h> and clocal is locked on. 441675Sache 451675Sachedefault() { 461675Sache # Reset everything changed by the other functions to initial defaults. 4714239Sbde 48137698Sobrien dc=$1; shift # device name character 49114682Sbde drainwait=`sysctl -n kern.drainwait` 5014239Sbde 511675Sache for i in $* 521675Sache do 53137698Sobrien comcontrol /dev/tty${dc}${i} dtrwait 300 drainwait $drainwait 54137698Sobrien stty < /dev/tty${dc}${i}.init -clocal crtscts hupcl 9600 reprint ^R 55137698Sobrien stty < /dev/tty${dc}${i}.lock -clocal -crtscts -hupcl 0 56137698Sobrien stty < /dev/cua${dc}${i}.init -clocal crtscts hupcl 9600 reprint ^R 57137698Sobrien stty < /dev/cua${dc}${i}.lock -clocal -crtscts -hupcl 0 581675Sache done 591675Sache} 601675Sache 611675Sachemaybe() { 621675Sache # Special settings. 6314239Sbde 64137698Sobrien dc=$1; shift 6514239Sbde 661675Sache for i in $* 671675Sache do 681675Sache # Don't use ^R; it breaks bash's ^R when typed ahead. 69137698Sobrien stty < /dev/tty${dc}${i}.init reprint undef 70137698Sobrien stty < /dev/cua${dc}${i}.init reprint undef 711675Sache # Lock clocal off on dialin device for security. 72137698Sobrien stty < /dev/tty${dc}${i}.lock clocal 731675Sache # Lock the speeds to use old binaries that don't support them. 741675Sache # Any legal speed works to lock the initial speed. 75137698Sobrien stty < /dev/tty${dc}${i}.lock 300 76137698Sobrien stty < /dev/cua${dc}${i}.lock 300 771675Sache done 781675Sache} 791675Sache 801675Sachemodem() { 811675Sache # Modem that supports CTS and perhaps RTS handshaking. 8214239Sbde 83137698Sobrien dc=$1; shift 8414239Sbde 851675Sache for i in $* 861675Sache do 877708Srgrimes # may depend on modem 88137698Sobrien comcontrol /dev/tty${dc}${i} dtrwait 100 drainwait 180 891675Sache # Lock crtscts on. 901675Sache # Speed reasonable for V42bis. 91137698Sobrien stty < /dev/tty${dc}${i}.init crtscts 115200 92137698Sobrien stty < /dev/tty${dc}${i}.lock crtscts 93137698Sobrien stty < /dev/cua${dc}${i}.init crtscts 115200 94137698Sobrien stty < /dev/cua${dc}${i}.lock crtscts 951675Sache done 961675Sache} 971675Sache 981675Sachemouse() { 991675Sache # Mouse on either callin or callout port. 10014239Sbde 101137698Sobrien dc=$1; shift 10214239Sbde 1031675Sache for i in $* 1041675Sache do 1051675Sache # Lock clocal on, hupcl off. 1061675Sache # Standard speed for Microsoft mouse. 107137698Sobrien stty < /dev/tty${dc}${i}.init clocal -hupcl 1200 108137698Sobrien stty < /dev/tty${dc}${i}.lock clocal hupcl 109137698Sobrien stty < /dev/cua${dc}${i}.init clocal -hupcl 1200 110137698Sobrien stty < /dev/cua${dc}${i}.lock clocal hupcl 1111675Sache done 1121675Sache} 1131675Sache 1141675Sacheterminal() { 1151675Sache # Terminal that supports CTS and perhaps RTS handshaking 1161675Sache # with the cable or terminal arranged so that DCD is on 1171675Sache # at least while the terminal is on. 1181675Sache # Also works for bidirectional communications to another pc 1191675Sache # provided at most one side runs getty. 1201675Sache # Same as modem() except we want a faster speed and no dtrwait. 12114239Sbde 122137698Sobrien dc=$1; shift 12314239Sbde 124137698Sobrien modem ${dc} $* 1251675Sache for i in $* 1261675Sache do 127137698Sobrien comcontrol /dev/tty${dc}${i} dtrwait 0 128137698Sobrien stty < /dev/tty${dc}${i}.init 115200 129137698Sobrien stty < /dev/cua${dc}${i}.init 115200 1301675Sache done 1311675Sache} 1321675Sache 133157040Sru3wire() { 134157040Sru # 3-wire serial terminals. These don't supply carrier, so 135157040Sru # clocal needs to be set, and crtscts needs to be unset. 136157040Sru 137157040Sru dc=$1; shift 138157040Sru 139157040Sru terminal ${dc} $* 140157040Sru for i in $* 141157040Sru do 142157040Sru stty < /dev/tty${dc}${i}.init clocal -crtscts 143157040Sru stty < /dev/cua${dc}${i}.init clocal -crtscts 144157040Sru done 145157040Sru} 146157040Sru 1471675Sache# Don't use anything from this file unless you have some buggy programs 1481675Sache# that require it. 14914239Sbde 1501675Sache# Edit the functions and the examples to suit your system. 151157040Sru# $1 is the device identifier, and the remainder of the line 152157040Sru# lists the device numbers. 15314239Sbde 154180619Smarcel# Initialize assorted 8250-16550 (uart) ports. 155180619Smarcel# maybe u 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 156180619Smarcel# mouse u 2 157180619Smarcel# modem u 1 158180619Smarcel# terminal u 0 159180619Smarcel# 3wire u 0 16014239Sbde 16114239Sbde# Initialize all ports on a Cyclades-8yo. 162137698Sobrien# modem c 00 01 02 03 04 05 06 07 16314239Sbde 16414239Sbde# Initialize all ports on a Cyclades-16ye. 165137698Sobrien# modem c 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 16614239Sbde 16714239Sbde# Initialize all ports on a Digiboard 8. 168137698Sobrien# modem D 00 01 02 03 04 05 06 07 169