Home | History | Annotate | Line # | Download | only in kern
tty_conf.c revision 1.27
      1  1.27       eeh /*	$NetBSD: tty_conf.c,v 1.27 2000/09/22 01:37:27 eeh Exp $	*/
      2  1.14       cgd 
      3  1.10       cgd /*-
      4  1.10       cgd  * Copyright (c) 1982, 1986, 1991, 1993
      5  1.10       cgd  *	The Regents of the University of California.  All rights reserved.
      6  1.10       cgd  * (c) UNIX System Laboratories, Inc.
      7  1.10       cgd  * All or some portions of this file are derived from material licensed
      8  1.10       cgd  * to the University of California by American Telephone and Telegraph
      9  1.10       cgd  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
     10  1.10       cgd  * the permission of UNIX System Laboratories, Inc.
     11  1.10       cgd  *
     12  1.10       cgd  * Redistribution and use in source and binary forms, with or without
     13  1.10       cgd  * modification, are permitted provided that the following conditions
     14  1.10       cgd  * are met:
     15  1.10       cgd  * 1. Redistributions of source code must retain the above copyright
     16  1.10       cgd  *    notice, this list of conditions and the following disclaimer.
     17  1.10       cgd  * 2. Redistributions in binary form must reproduce the above copyright
     18  1.10       cgd  *    notice, this list of conditions and the following disclaimer in the
     19  1.10       cgd  *    documentation and/or other materials provided with the distribution.
     20  1.10       cgd  * 3. All advertising materials mentioning features or use of this software
     21  1.10       cgd  *    must display the following acknowledgement:
     22  1.10       cgd  *	This product includes software developed by the University of
     23  1.10       cgd  *	California, Berkeley and its contributors.
     24  1.10       cgd  * 4. Neither the name of the University nor the names of its contributors
     25  1.10       cgd  *    may be used to endorse or promote products derived from this software
     26  1.10       cgd  *    without specific prior written permission.
     27  1.10       cgd  *
     28  1.10       cgd  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
     29  1.10       cgd  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
     30  1.10       cgd  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
     31  1.10       cgd  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
     32  1.10       cgd  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
     33  1.10       cgd  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
     34  1.10       cgd  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
     35  1.10       cgd  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
     36  1.10       cgd  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
     37  1.10       cgd  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
     38  1.10       cgd  * SUCH DAMAGE.
     39  1.10       cgd  *
     40  1.20      fvdl  *	@(#)tty_conf.c	8.5 (Berkeley) 1/9/95
     41  1.10       cgd  */
     42  1.22   thorpej 
     43  1.22   thorpej #include "opt_compat_freebsd.h"
     44  1.24  christos #include "opt_compat_43.h"
     45  1.10       cgd 
     46  1.10       cgd #include <sys/param.h>
     47  1.10       cgd #include <sys/systm.h>
     48  1.10       cgd #include <sys/buf.h>
     49  1.10       cgd #include <sys/ioctl.h>
     50  1.10       cgd #include <sys/proc.h>
     51  1.10       cgd #include <sys/tty.h>
     52  1.10       cgd #include <sys/conf.h>
     53  1.10       cgd 
     54  1.10       cgd #define	ttynodisc ((int (*) __P((dev_t, struct tty *)))enodev)
     55  1.10       cgd #define	ttyerrclose ((int (*) __P((struct tty *, int flags)))enodev)
     56  1.10       cgd #define	ttyerrio ((int (*) __P((struct tty *, struct uio *, int)))enodev)
     57  1.10       cgd #define	ttyerrinput ((int (*) __P((int c, struct tty *)))enodev)
     58  1.10       cgd #define	ttyerrstart ((int (*) __P((struct tty *)))enodev)
     59  1.10       cgd 
     60  1.17  christos int	nullioctl __P((struct tty *, u_long, caddr_t, int, struct proc *));
     61  1.10       cgd 
     62  1.10       cgd #include "tb.h"
     63  1.10       cgd #if NTB > 0
     64  1.10       cgd int	tbopen __P((dev_t dev, struct tty *tp));
     65  1.10       cgd int	tbclose __P((struct tty *tp, int flags));
     66  1.10       cgd int	tbread __P((struct tty *tp, struct uio *uio, int flags));
     67  1.15       cgd int	tbtioctl __P((struct tty *tp, u_long cmd, caddr_t data,
     68  1.10       cgd 			int flag, struct proc *p));
     69  1.10       cgd int	tbinput __P((int c, struct tty *tp));
     70  1.10       cgd #endif
     71  1.10       cgd 
     72  1.10       cgd #include "sl.h"
     73  1.10       cgd #if NSL > 0
     74  1.10       cgd int	slopen __P((dev_t dev, struct tty *tp));
     75  1.10       cgd int	slclose __P((struct tty *tp, int flags));
     76  1.15       cgd int	sltioctl __P((struct tty *tp, u_long cmd, caddr_t data,
     77  1.10       cgd 			int flag, struct proc *p));
     78  1.10       cgd int	slinput __P((int c, struct tty *tp));
     79  1.10       cgd int	slstart __P((struct tty *tp));
     80  1.10       cgd #endif
     81  1.10       cgd 
     82  1.10       cgd #include "ppp.h"
     83  1.10       cgd #if NPPP > 0
     84  1.10       cgd int	pppopen __P((dev_t dev, struct tty *tp));
     85  1.10       cgd int	pppclose __P((struct tty *tp, int flags));
     86  1.15       cgd int	ppptioctl __P((struct tty *tp, u_long cmd, caddr_t data,
     87  1.10       cgd 			int flag, struct proc *p));
     88  1.13    paulus int	pppinput __P((int c, struct tty *tp));
     89  1.13    paulus int	pppstart __P((struct tty *tp));
     90  1.10       cgd int	pppread __P((struct tty *tp, struct uio *uio, int flag));
     91  1.10       cgd int	pppwrite __P((struct tty *tp, struct uio *uio, int flag));
     92  1.10       cgd #endif
     93  1.10       cgd 
     94  1.18  jonathan #include "strip.h"
     95  1.18  jonathan #if NSTRIP > 0
     96  1.18  jonathan int	stripopen __P((dev_t dev, struct tty *tp));
     97  1.18  jonathan int	stripclose __P((struct tty *tp, int flags));
     98  1.18  jonathan int	striptioctl __P((struct tty *tp, u_long cmd, caddr_t data,
     99  1.18  jonathan 			int flag, struct proc *p));
    100  1.18  jonathan int	stripinput __P((int c, struct tty *tp));
    101  1.18  jonathan int	stripstart __P((struct tty *tp));
    102  1.18  jonathan #endif
    103  1.18  jonathan 
    104  1.26       eeh /*
    105  1.26       eeh  * XXXXXX
    106  1.26       eeh  *
    107  1.26       eeh  * The implementation for the following is currently in
    108  1.26       eeh  * sys/dev/sun.  I expect it will be moved out of there
    109  1.26       eeh  * eventually, but until then add yourself to the list if
    110  1.26       eeh  * you want to use the Sun Keyboard or Mouse line disciplines.
    111  1.26       eeh  */
    112  1.26       eeh #if defined(__sparc__) || defined(__sparc_v9__) || defined(sun3) || defined(sun3x)
    113  1.25       eeh #include "kbd.h"
    114  1.25       eeh #if NKBD > 0
    115  1.25       eeh int	sunkbdinput __P((int c, struct tty *tp));
    116  1.25       eeh int	sunkbdstart __P((struct tty *tp));
    117  1.25       eeh int	sunkbdstart __P((struct tty *tp));
    118  1.25       eeh #endif
    119  1.25       eeh 
    120  1.25       eeh #include "ms.h"
    121  1.25       eeh #if NMS > 0
    122  1.25       eeh int	sunmsinput __P((int c, struct tty *tp));
    123  1.26       eeh #endif
    124  1.25       eeh #endif
    125  1.25       eeh 
    126  1.10       cgd struct	linesw linesw[] =
    127  1.10       cgd {
    128  1.21   mycroft 	{ ttylopen, ttylclose, ttread, ttwrite, nullioctl,
    129  1.10       cgd 	  ttyinput, ttstart, ttymodem },		/* 0- termios */
    130  1.10       cgd 
    131  1.10       cgd 	{ ttynodisc, ttyerrclose, ttyerrio, ttyerrio, nullioctl,
    132  1.10       cgd 	  ttyerrinput, ttyerrstart, nullmodem },	/* 1- defunct */
    133  1.10       cgd 
    134  1.16   mycroft #if defined(COMPAT_43) || defined(COMPAT_FREEBSD)
    135  1.21   mycroft 	{ ttylopen, ttylclose, ttread, ttwrite, nullioctl,
    136  1.12   mycroft 	  ttyinput, ttstart, ttymodem },		/* 2- old NTTYDISC */
    137  1.12   mycroft #else
    138  1.10       cgd 	{ ttynodisc, ttyerrclose, ttyerrio, ttyerrio, nullioctl,
    139  1.10       cgd 	  ttyerrinput, ttyerrstart, nullmodem },	/* 2- defunct */
    140  1.12   mycroft #endif
    141  1.10       cgd 
    142  1.10       cgd #if NTB > 0
    143  1.10       cgd 	{ tbopen, tbclose, tbread, ttyerrio, tbtioctl,
    144  1.10       cgd 	  tbinput, ttstart, nullmodem },		/* 3- TABLDISC */
    145  1.10       cgd #else
    146  1.10       cgd 	{ ttynodisc, ttyerrclose, ttyerrio, ttyerrio, nullioctl,
    147  1.10       cgd 	  ttyerrinput, ttyerrstart, nullmodem },
    148  1.10       cgd #endif
    149  1.10       cgd 
    150  1.10       cgd #if NSL > 0
    151  1.10       cgd 	{ slopen, slclose, ttyerrio, ttyerrio, sltioctl,
    152  1.10       cgd 	  slinput, slstart, nullmodem },		/* 4- SLIPDISC */
    153  1.10       cgd #else
    154  1.10       cgd 	{ ttynodisc, ttyerrclose, ttyerrio, ttyerrio, nullioctl,
    155  1.10       cgd 	  ttyerrinput, ttyerrstart, nullmodem },
    156  1.10       cgd #endif
    157  1.10       cgd 
    158  1.10       cgd #if NPPP > 0
    159  1.10       cgd 	{ pppopen, pppclose, pppread, pppwrite, ppptioctl,
    160  1.10       cgd 	  pppinput, pppstart, ttymodem },		/* 5- PPPDISC */
    161  1.18  jonathan #else
    162  1.18  jonathan 	{ ttynodisc, ttyerrclose, ttyerrio, ttyerrio, nullioctl,
    163  1.18  jonathan 	  ttyerrinput, ttyerrstart, nullmodem },
    164  1.18  jonathan #endif
    165  1.18  jonathan 
    166  1.18  jonathan #if NSTRIP > 0
    167  1.18  jonathan 	{ stripopen, stripclose, ttyerrio, ttyerrio, striptioctl,
    168  1.19    kleink 	  stripinput, stripstart, nullmodem },		/* 6- STRIPDISC */
    169  1.25       eeh #else
    170  1.25       eeh 	{ ttynodisc, ttyerrclose, ttyerrio, ttyerrio, nullioctl,
    171  1.25       eeh 	  ttyerrinput, ttyerrstart, nullmodem },
    172  1.25       eeh #endif
    173  1.25       eeh 
    174  1.25       eeh /*
    175  1.25       eeh  * The following are special line disciplines for Sun style Keybaords and Mice.
    176  1.25       eeh  * Since they are used to handle special hardware they are enabled if/when the
    177  1.25       eeh  * hardware is detected and you cannot switch in or out of them by normal means.
    178  1.25       eeh  *
    179  1.25       eeh  * All I/O currently goes through the keyboard and mouse device nodes so the
    180  1.25       eeh  * TTY does no I/O itself.
    181  1.25       eeh  */
    182  1.25       eeh #if NKBD > 0
    183  1.25       eeh 	{ ttylopen, ttylclose, ttyerrio, ttyerrio, nullioctl,
    184  1.25       eeh 	  sunkbdinput, sunkbdstart, nullmodem },	/* 7- SUNKBDDISC */
    185  1.25       eeh #else
    186  1.25       eeh 	{ ttynodisc, ttyerrclose, ttyerrio, ttyerrio, nullioctl,
    187  1.25       eeh 	  ttyerrinput, ttyerrstart, nullmodem },
    188  1.25       eeh #endif
    189  1.25       eeh 
    190  1.25       eeh #if NMS > 0
    191  1.25       eeh 	{ ttylopen, ttylclose, ttyerrio, ttyerrio, nullioctl,
    192  1.25       eeh 	  sunmsinput, ttstart, nullmodem },		/* 8- SUNMOUSEDISC */
    193  1.10       cgd #else
    194  1.10       cgd 	{ ttynodisc, ttyerrclose, ttyerrio, ttyerrio, nullioctl,
    195  1.10       cgd 	  ttyerrinput, ttyerrstart, nullmodem },
    196  1.10       cgd #endif
    197  1.10       cgd };
    198  1.10       cgd 
    199  1.23     perry int	nlinesw = sizeof(linesw) / sizeof(linesw[0]);
    200  1.10       cgd 
    201  1.10       cgd /*
    202  1.10       cgd  * Do nothing specific version of line
    203  1.10       cgd  * discipline specific ioctl command.
    204  1.10       cgd  */
    205  1.10       cgd /*ARGSUSED*/
    206  1.17  christos int
    207  1.10       cgd nullioctl(tp, cmd, data, flags, p)
    208  1.10       cgd 	struct tty *tp;
    209  1.15       cgd 	u_long cmd;
    210  1.10       cgd 	char *data;
    211  1.10       cgd 	int flags;
    212  1.10       cgd 	struct proc *p;
    213  1.10       cgd {
    214  1.10       cgd 
    215  1.10       cgd #ifdef lint
    216  1.10       cgd 	tp = tp; data = data; flags = flags; p = p;
    217  1.10       cgd #endif
    218  1.10       cgd 	return (-1);
    219  1.10       cgd }
    220