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