Home | History | Annotate | Line # | Download | only in kern
tty_conf.c revision 1.25
      1 /*	$NetBSD: tty_conf.c,v 1.25 2000/09/21 23:31:14 eeh 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 #include "kbd.h"
    105 #if NKBD > 0
    106 int	sunkbdinput __P((int c, struct tty *tp));
    107 int	sunkbdstart __P((struct tty *tp));
    108 int	sunkbdstart __P((struct tty *tp));
    109 #endif
    110 
    111 #include "ms.h"
    112 #if NMS > 0
    113 int	sunmsinput __P((int c, struct tty *tp));
    114 #endif
    115 
    116 struct	linesw linesw[] =
    117 {
    118 	{ ttylopen, ttylclose, ttread, ttwrite, nullioctl,
    119 	  ttyinput, ttstart, ttymodem },		/* 0- termios */
    120 
    121 	{ ttynodisc, ttyerrclose, ttyerrio, ttyerrio, nullioctl,
    122 	  ttyerrinput, ttyerrstart, nullmodem },	/* 1- defunct */
    123 
    124 #if defined(COMPAT_43) || defined(COMPAT_FREEBSD)
    125 	{ ttylopen, ttylclose, ttread, ttwrite, nullioctl,
    126 	  ttyinput, ttstart, ttymodem },		/* 2- old NTTYDISC */
    127 #else
    128 	{ ttynodisc, ttyerrclose, ttyerrio, ttyerrio, nullioctl,
    129 	  ttyerrinput, ttyerrstart, nullmodem },	/* 2- defunct */
    130 #endif
    131 
    132 #if NTB > 0
    133 	{ tbopen, tbclose, tbread, ttyerrio, tbtioctl,
    134 	  tbinput, ttstart, nullmodem },		/* 3- TABLDISC */
    135 #else
    136 	{ ttynodisc, ttyerrclose, ttyerrio, ttyerrio, nullioctl,
    137 	  ttyerrinput, ttyerrstart, nullmodem },
    138 #endif
    139 
    140 #if NSL > 0
    141 	{ slopen, slclose, ttyerrio, ttyerrio, sltioctl,
    142 	  slinput, slstart, nullmodem },		/* 4- SLIPDISC */
    143 #else
    144 	{ ttynodisc, ttyerrclose, ttyerrio, ttyerrio, nullioctl,
    145 	  ttyerrinput, ttyerrstart, nullmodem },
    146 #endif
    147 
    148 #if NPPP > 0
    149 	{ pppopen, pppclose, pppread, pppwrite, ppptioctl,
    150 	  pppinput, pppstart, ttymodem },		/* 5- PPPDISC */
    151 #else
    152 	{ ttynodisc, ttyerrclose, ttyerrio, ttyerrio, nullioctl,
    153 	  ttyerrinput, ttyerrstart, nullmodem },
    154 #endif
    155 
    156 #if NSTRIP > 0
    157 	{ stripopen, stripclose, ttyerrio, ttyerrio, striptioctl,
    158 	  stripinput, stripstart, nullmodem },		/* 6- STRIPDISC */
    159 #else
    160 	{ ttynodisc, ttyerrclose, ttyerrio, ttyerrio, nullioctl,
    161 	  ttyerrinput, ttyerrstart, nullmodem },
    162 #endif
    163 
    164 /*
    165  * The following are special line disciplines for Sun style Keybaords and Mice.
    166  * Since they are used to handle special hardware they are enabled if/when the
    167  * hardware is detected and you cannot switch in or out of them by normal means.
    168  *
    169  * All I/O currently goes through the keyboard and mouse device nodes so the
    170  * TTY does no I/O itself.
    171  */
    172 #if NKBD > 0
    173 	{ ttylopen, ttylclose, ttyerrio, ttyerrio, nullioctl,
    174 	  sunkbdinput, sunkbdstart, nullmodem },	/* 7- SUNKBDDISC */
    175 #else
    176 	{ ttynodisc, ttyerrclose, ttyerrio, ttyerrio, nullioctl,
    177 	  ttyerrinput, ttyerrstart, nullmodem },
    178 #endif
    179 
    180 #if NMS > 0
    181 	{ ttylopen, ttylclose, ttyerrio, ttyerrio, nullioctl,
    182 	  sunmsinput, ttstart, nullmodem },		/* 8- SUNMOUSEDISC */
    183 #else
    184 	{ ttynodisc, ttyerrclose, ttyerrio, ttyerrio, nullioctl,
    185 	  ttyerrinput, ttyerrstart, nullmodem },
    186 #endif
    187 };
    188 
    189 int	nlinesw = sizeof(linesw) / sizeof(linesw[0]);
    190 
    191 /*
    192  * Do nothing specific version of line
    193  * discipline specific ioctl command.
    194  */
    195 /*ARGSUSED*/
    196 int
    197 nullioctl(tp, cmd, data, flags, p)
    198 	struct tty *tp;
    199 	u_long cmd;
    200 	char *data;
    201 	int flags;
    202 	struct proc *p;
    203 {
    204 
    205 #ifdef lint
    206 	tp = tp; data = data; flags = flags; p = p;
    207 #endif
    208 	return (-1);
    209 }
    210