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