Home | History | Annotate | Line # | Download | only in kern
tty_conf.c revision 1.18
      1 /*	$NetBSD: tty_conf.c,v 1.18 1996/05/19 17:17:55 jonathan Exp $	*/
      2 
      3 /*-
      4  * Copyright (c) 1982, 1986, 1991, 1993
      5  *	The Regents of the University of California.  All rights reserved.
      6  * (c) UNIX System Laboratories, Inc.
      7  * All or some portions of this file are derived from material licensed
      8  * to the University of California by American Telephone and Telegraph
      9  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
     10  * the permission of UNIX System Laboratories, Inc.
     11  *
     12  * Redistribution and use in source and binary forms, with or without
     13  * modification, are permitted provided that the following conditions
     14  * are met:
     15  * 1. Redistributions of source code must retain the above copyright
     16  *    notice, this list of conditions and the following disclaimer.
     17  * 2. Redistributions in binary form must reproduce the above copyright
     18  *    notice, this list of conditions and the following disclaimer in the
     19  *    documentation and/or other materials provided with the distribution.
     20  * 3. All advertising materials mentioning features or use of this software
     21  *    must display the following acknowledgement:
     22  *	This product includes software developed by the University of
     23  *	California, Berkeley and its contributors.
     24  * 4. Neither the name of the University nor the names of its contributors
     25  *    may be used to endorse or promote products derived from this software
     26  *    without specific prior written permission.
     27  *
     28  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     29  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     30  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     31  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     32  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     33  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     34  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     35  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     36  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     37  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     38  * SUCH DAMAGE.
     39  *
     40  *	@(#)tty_conf.c	8.4 (Berkeley) 1/21/94
     41  */
     42 
     43 #include <sys/param.h>
     44 #include <sys/systm.h>
     45 #include <sys/buf.h>
     46 #include <sys/ioctl.h>
     47 #include <sys/proc.h>
     48 #include <sys/tty.h>
     49 #include <sys/conf.h>
     50 
     51 #define	ttynodisc ((int (*) __P((dev_t, struct tty *)))enodev)
     52 #define	ttyerrclose ((int (*) __P((struct tty *, int flags)))enodev)
     53 #define	ttyerrio ((int (*) __P((struct tty *, struct uio *, int)))enodev)
     54 #define	ttyerrinput ((int (*) __P((int c, struct tty *)))enodev)
     55 #define	ttyerrstart ((int (*) __P((struct tty *)))enodev)
     56 
     57 int	nullioctl __P((struct tty *, u_long, caddr_t, int, struct proc *));
     58 
     59 #include "tb.h"
     60 #if NTB > 0
     61 int	tbopen __P((dev_t dev, struct tty *tp));
     62 int	tbclose __P((struct tty *tp, int flags));
     63 int	tbread __P((struct tty *tp, struct uio *uio, int flags));
     64 int	tbtioctl __P((struct tty *tp, u_long cmd, caddr_t data,
     65 			int flag, struct proc *p));
     66 int	tbinput __P((int c, struct tty *tp));
     67 #endif
     68 
     69 #include "sl.h"
     70 #if NSL > 0
     71 int	slopen __P((dev_t dev, struct tty *tp));
     72 int	slclose __P((struct tty *tp, int flags));
     73 int	sltioctl __P((struct tty *tp, u_long cmd, caddr_t data,
     74 			int flag, struct proc *p));
     75 int	slinput __P((int c, struct tty *tp));
     76 int	slstart __P((struct tty *tp));
     77 #endif
     78 
     79 #include "ppp.h"
     80 #if NPPP > 0
     81 int	pppopen __P((dev_t dev, struct tty *tp));
     82 int	pppclose __P((struct tty *tp, int flags));
     83 int	ppptioctl __P((struct tty *tp, u_long cmd, caddr_t data,
     84 			int flag, struct proc *p));
     85 int	pppinput __P((int c, struct tty *tp));
     86 int	pppstart __P((struct tty *tp));
     87 int	pppread __P((struct tty *tp, struct uio *uio, int flag));
     88 int	pppwrite __P((struct tty *tp, struct uio *uio, int flag));
     89 #endif
     90 
     91 #include "strip.h"
     92 #if NSTRIP > 0
     93 int	stripopen __P((dev_t dev, struct tty *tp));
     94 int	stripclose __P((struct tty *tp, int flags));
     95 int	striptioctl __P((struct tty *tp, u_long cmd, caddr_t data,
     96 			int flag, struct proc *p));
     97 int	stripinput __P((int c, struct tty *tp));
     98 int	stripstart __P((struct tty *tp));
     99 #endif
    100 
    101 struct	linesw linesw[] =
    102 {
    103 	{ ttyopen, ttylclose, ttread, ttwrite, nullioctl,
    104 	  ttyinput, ttstart, ttymodem },		/* 0- termios */
    105 
    106 	{ ttynodisc, ttyerrclose, ttyerrio, ttyerrio, nullioctl,
    107 	  ttyerrinput, ttyerrstart, nullmodem },	/* 1- defunct */
    108 
    109 #if defined(COMPAT_43) || defined(COMPAT_FREEBSD)
    110 	{ ttyopen, ttylclose, ttread, ttwrite, nullioctl,
    111 	  ttyinput, ttstart, ttymodem },		/* 2- old NTTYDISC */
    112 #else
    113 	{ ttynodisc, ttyerrclose, ttyerrio, ttyerrio, nullioctl,
    114 	  ttyerrinput, ttyerrstart, nullmodem },	/* 2- defunct */
    115 #endif
    116 
    117 #if NTB > 0
    118 	{ tbopen, tbclose, tbread, ttyerrio, tbtioctl,
    119 	  tbinput, ttstart, nullmodem },		/* 3- TABLDISC */
    120 #else
    121 	{ ttynodisc, ttyerrclose, ttyerrio, ttyerrio, nullioctl,
    122 	  ttyerrinput, ttyerrstart, nullmodem },
    123 #endif
    124 
    125 #if NSL > 0
    126 	{ slopen, slclose, ttyerrio, ttyerrio, sltioctl,
    127 	  slinput, slstart, nullmodem },		/* 4- SLIPDISC */
    128 #else
    129 	{ ttynodisc, ttyerrclose, ttyerrio, ttyerrio, nullioctl,
    130 	  ttyerrinput, ttyerrstart, nullmodem },
    131 #endif
    132 
    133 #if NPPP > 0
    134 	{ pppopen, pppclose, pppread, pppwrite, ppptioctl,
    135 	  pppinput, pppstart, ttymodem },		/* 5- PPPDISC */
    136 #else
    137 	{ ttynodisc, ttyerrclose, ttyerrio, ttyerrio, nullioctl,
    138 	  ttyerrinput, ttyerrstart, nullmodem },
    139 #endif
    140 
    141 #if NSTRIP > 0
    142 	{ stripopen, stripclose, ttyerrio, ttyerrio, striptioctl,
    143 	  stripinput, stripstart, nullmodem },		/* 6- STRIPIPDISC */
    144 #else
    145 	{ ttynodisc, ttyerrclose, ttyerrio, ttyerrio, nullioctl,
    146 	  ttyerrinput, ttyerrstart, nullmodem },
    147 #endif
    148 };
    149 
    150 int	nlinesw = sizeof (linesw) / sizeof (linesw[0]);
    151 
    152 /*
    153  * Do nothing specific version of line
    154  * discipline specific ioctl command.
    155  */
    156 /*ARGSUSED*/
    157 int
    158 nullioctl(tp, cmd, data, flags, p)
    159 	struct tty *tp;
    160 	u_long cmd;
    161 	char *data;
    162 	int flags;
    163 	struct proc *p;
    164 {
    165 
    166 #ifdef lint
    167 	tp = tp; data = data; flags = flags; p = p;
    168 #endif
    169 	return (-1);
    170 }
    171