Home | History | Annotate | Line # | Download | only in kern
tty_conf.c revision 1.24
      1 /*	$NetBSD: tty_conf.c,v 1.24 1998/12/10 15:09:18 christos 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.5 (Berkeley) 1/9/95
     41  */
     42 
     43 #include "opt_compat_freebsd.h"
     44 #include "opt_compat_43.h"
     45 
     46 #include <sys/param.h>
     47 #include <sys/systm.h>
     48 #include <sys/buf.h>
     49 #include <sys/ioctl.h>
     50 #include <sys/proc.h>
     51 #include <sys/tty.h>
     52 #include <sys/conf.h>
     53 
     54 #define	ttynodisc ((int (*) __P((dev_t, struct tty *)))enodev)
     55 #define	ttyerrclose ((int (*) __P((struct tty *, int flags)))enodev)
     56 #define	ttyerrio ((int (*) __P((struct tty *, struct uio *, int)))enodev)
     57 #define	ttyerrinput ((int (*) __P((int c, struct tty *)))enodev)
     58 #define	ttyerrstart ((int (*) __P((struct tty *)))enodev)
     59 
     60 int	nullioctl __P((struct tty *, u_long, caddr_t, int, struct proc *));
     61 
     62 #include "tb.h"
     63 #if NTB > 0
     64 int	tbopen __P((dev_t dev, struct tty *tp));
     65 int	tbclose __P((struct tty *tp, int flags));
     66 int	tbread __P((struct tty *tp, struct uio *uio, int flags));
     67 int	tbtioctl __P((struct tty *tp, u_long cmd, caddr_t data,
     68 			int flag, struct proc *p));
     69 int	tbinput __P((int c, struct tty *tp));
     70 #endif
     71 
     72 #include "sl.h"
     73 #if NSL > 0
     74 int	slopen __P((dev_t dev, struct tty *tp));
     75 int	slclose __P((struct tty *tp, int flags));
     76 int	sltioctl __P((struct tty *tp, u_long cmd, caddr_t data,
     77 			int flag, struct proc *p));
     78 int	slinput __P((int c, struct tty *tp));
     79 int	slstart __P((struct tty *tp));
     80 #endif
     81 
     82 #include "ppp.h"
     83 #if NPPP > 0
     84 int	pppopen __P((dev_t dev, struct tty *tp));
     85 int	pppclose __P((struct tty *tp, int flags));
     86 int	ppptioctl __P((struct tty *tp, u_long cmd, caddr_t data,
     87 			int flag, struct proc *p));
     88 int	pppinput __P((int c, struct tty *tp));
     89 int	pppstart __P((struct tty *tp));
     90 int	pppread __P((struct tty *tp, struct uio *uio, int flag));
     91 int	pppwrite __P((struct tty *tp, struct uio *uio, int flag));
     92 #endif
     93 
     94 #include "strip.h"
     95 #if NSTRIP > 0
     96 int	stripopen __P((dev_t dev, struct tty *tp));
     97 int	stripclose __P((struct tty *tp, int flags));
     98 int	striptioctl __P((struct tty *tp, u_long cmd, caddr_t data,
     99 			int flag, struct proc *p));
    100 int	stripinput __P((int c, struct tty *tp));
    101 int	stripstart __P((struct tty *tp));
    102 #endif
    103 
    104 struct	linesw linesw[] =
    105 {
    106 	{ ttylopen, ttylclose, ttread, ttwrite, nullioctl,
    107 	  ttyinput, ttstart, ttymodem },		/* 0- termios */
    108 
    109 	{ ttynodisc, ttyerrclose, ttyerrio, ttyerrio, nullioctl,
    110 	  ttyerrinput, ttyerrstart, nullmodem },	/* 1- defunct */
    111 
    112 #if defined(COMPAT_43) || defined(COMPAT_FREEBSD)
    113 	{ ttylopen, ttylclose, ttread, ttwrite, nullioctl,
    114 	  ttyinput, ttstart, ttymodem },		/* 2- old NTTYDISC */
    115 #else
    116 	{ ttynodisc, ttyerrclose, ttyerrio, ttyerrio, nullioctl,
    117 	  ttyerrinput, ttyerrstart, nullmodem },	/* 2- defunct */
    118 #endif
    119 
    120 #if NTB > 0
    121 	{ tbopen, tbclose, tbread, ttyerrio, tbtioctl,
    122 	  tbinput, ttstart, nullmodem },		/* 3- TABLDISC */
    123 #else
    124 	{ ttynodisc, ttyerrclose, ttyerrio, ttyerrio, nullioctl,
    125 	  ttyerrinput, ttyerrstart, nullmodem },
    126 #endif
    127 
    128 #if NSL > 0
    129 	{ slopen, slclose, ttyerrio, ttyerrio, sltioctl,
    130 	  slinput, slstart, nullmodem },		/* 4- SLIPDISC */
    131 #else
    132 	{ ttynodisc, ttyerrclose, ttyerrio, ttyerrio, nullioctl,
    133 	  ttyerrinput, ttyerrstart, nullmodem },
    134 #endif
    135 
    136 #if NPPP > 0
    137 	{ pppopen, pppclose, pppread, pppwrite, ppptioctl,
    138 	  pppinput, pppstart, ttymodem },		/* 5- PPPDISC */
    139 #else
    140 	{ ttynodisc, ttyerrclose, ttyerrio, ttyerrio, nullioctl,
    141 	  ttyerrinput, ttyerrstart, nullmodem },
    142 #endif
    143 
    144 #if NSTRIP > 0
    145 	{ stripopen, stripclose, ttyerrio, ttyerrio, striptioctl,
    146 	  stripinput, stripstart, nullmodem },		/* 6- STRIPDISC */
    147 #else
    148 	{ ttynodisc, ttyerrclose, ttyerrio, ttyerrio, nullioctl,
    149 	  ttyerrinput, ttyerrstart, nullmodem },
    150 #endif
    151 };
    152 
    153 int	nlinesw = sizeof(linesw) / sizeof(linesw[0]);
    154 
    155 /*
    156  * Do nothing specific version of line
    157  * discipline specific ioctl command.
    158  */
    159 /*ARGSUSED*/
    160 int
    161 nullioctl(tp, cmd, data, flags, p)
    162 	struct tty *tp;
    163 	u_long cmd;
    164 	char *data;
    165 	int flags;
    166 	struct proc *p;
    167 {
    168 
    169 #ifdef lint
    170 	tp = tp; data = data; flags = flags; p = p;
    171 #endif
    172 	return (-1);
    173 }
    174