xref: /openbsd-src/sys/kern/tty_conf.c (revision db3296cf5c1dd9058ceecc3a29fe4aaa0bd26000)
1 /*	$OpenBSD: tty_conf.c,v 1.8 2003/06/02 23:28:06 millert Exp $	*/
2 /*	$NetBSD: tty_conf.c,v 1.18 1996/05/19 17:17:55 jonathan Exp $	*/
3 
4 /*-
5  * Copyright (c) 1982, 1986, 1991, 1993
6  *	The Regents of the University of California.  All rights reserved.
7  * (c) UNIX System Laboratories, Inc.
8  * All or some portions of this file are derived from material licensed
9  * to the University of California by American Telephone and Telegraph
10  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
11  * the permission of UNIX System Laboratories, Inc.
12  *
13  * Redistribution and use in source and binary forms, with or without
14  * modification, are permitted provided that the following conditions
15  * are met:
16  * 1. Redistributions of source code must retain the above copyright
17  *    notice, this list of conditions and the following disclaimer.
18  * 2. Redistributions in binary form must reproduce the above copyright
19  *    notice, this list of conditions and the following disclaimer in the
20  *    documentation and/or other materials provided with the distribution.
21  * 3. Neither the name of the University nor the names of its contributors
22  *    may be used to endorse or promote products derived from this software
23  *    without specific prior written permission.
24  *
25  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
26  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
29  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35  * SUCH DAMAGE.
36  *
37  *	@(#)tty_conf.c	8.4 (Berkeley) 1/21/94
38  */
39 
40 #include <sys/param.h>
41 #include <sys/systm.h>
42 #include <sys/ioctl.h>
43 #include <sys/proc.h>
44 #include <sys/tty.h>
45 #include <sys/conf.h>
46 
47 #define	ttynodisc ((int (*)(dev_t, struct tty *))enodev)
48 #define	ttyerrclose ((int (*)(struct tty *, int flags))enodev)
49 #define	ttyerrio ((int (*)(struct tty *, struct uio *, int))enodev)
50 #define	ttyerrinput ((int (*)(int c, struct tty *))enodev)
51 #define	ttyerrstart ((int (*)(struct tty *))enodev)
52 
53 int	nullioctl(struct tty *, u_long, caddr_t, int, struct proc *);
54 
55 #include "tb.h"
56 #if NTB > 0
57 int	tbopen(dev_t dev, struct tty *tp);
58 int	tbclose(struct tty *tp, int flags);
59 int	tbread(struct tty *tp, struct uio *uio, int flags);
60 int	tbtioctl(struct tty *tp, u_long cmd, caddr_t data,
61 			int flag, struct proc *p);
62 int	tbinput(int c, struct tty *tp);
63 #endif
64 
65 #include "sl.h"
66 #if NSL > 0
67 int	slopen(dev_t dev, struct tty *tp);
68 int	slclose(struct tty *tp, int flags);
69 int	sltioctl(struct tty *tp, u_long cmd, caddr_t data,
70 			int flag, struct proc *p);
71 int	slinput(int c, struct tty *tp);
72 int	slstart(struct tty *tp);
73 #endif
74 
75 #include "ppp.h"
76 #if NPPP > 0
77 int	pppopen(dev_t dev, struct tty *tp);
78 int	pppclose(struct tty *tp, int flags);
79 int	ppptioctl(struct tty *tp, u_long cmd, caddr_t data,
80 			int flag, struct proc *p);
81 int	pppinput(int c, struct tty *tp);
82 int	pppstart(struct tty *tp);
83 int	pppread(struct tty *tp, struct uio *uio, int flag);
84 int	pppwrite(struct tty *tp, struct uio *uio, int flag);
85 #endif
86 
87 #include "strip.h"
88 #if NSTRIP > 0
89 int	stripopen(dev_t dev, struct tty *tp);
90 int	stripclose(struct tty *tp, int flags);
91 int	striptioctl(struct tty *tp, u_long cmd, caddr_t data,
92 			int flag, struct proc *p);
93 int	stripinput(int c, struct tty *tp);
94 int	stripstart(struct tty *tp);
95 #endif
96 
97 struct	linesw linesw[] =
98 {
99 	{ ttyopen, ttylclose, ttread, ttwrite, nullioctl,
100 	  ttyinput, ttstart, ttymodem },		/* 0- termios */
101 
102 	{ ttynodisc, ttyerrclose, ttyerrio, ttyerrio, nullioctl,
103 	  ttyerrinput, ttyerrstart, nullmodem },	/* 1- defunct */
104 
105 #if defined(COMPAT_43) || defined(COMPAT_FREEBSD) || defined(COMPAT_BSDOS)
106 	{ ttyopen, ttylclose, ttread, ttwrite, nullioctl,
107 	  ttyinput, ttstart, ttymodem },		/* 2- old NTTYDISC */
108 #else
109 	{ ttynodisc, ttyerrclose, ttyerrio, ttyerrio, nullioctl,
110 	  ttyerrinput, ttyerrstart, nullmodem },	/* 2- defunct */
111 #endif
112 
113 #if NTB > 0
114 	{ tbopen, tbclose, tbread, ttyerrio, tbtioctl,
115 	  tbinput, ttstart, nullmodem },		/* 3- TABLDISC */
116 #else
117 	{ ttynodisc, ttyerrclose, ttyerrio, ttyerrio, nullioctl,
118 	  ttyerrinput, ttyerrstart, nullmodem },
119 #endif
120 
121 #if NSL > 0
122 	{ slopen, slclose, ttyerrio, ttyerrio, sltioctl,
123 	  slinput, slstart, nullmodem },		/* 4- SLIPDISC */
124 #else
125 	{ ttynodisc, ttyerrclose, ttyerrio, ttyerrio, nullioctl,
126 	  ttyerrinput, ttyerrstart, nullmodem },
127 #endif
128 
129 #if NPPP > 0
130 	{ pppopen, pppclose, pppread, pppwrite, ppptioctl,
131 	  pppinput, pppstart, ttymodem },		/* 5- PPPDISC */
132 #else
133 	{ ttynodisc, ttyerrclose, ttyerrio, ttyerrio, nullioctl,
134 	  ttyerrinput, ttyerrstart, nullmodem },
135 #endif
136 
137 #if NSTRIP > 0
138 	{ stripopen, stripclose, ttyerrio, ttyerrio, striptioctl,
139 	  stripinput, stripstart, nullmodem },		/* 6- STRIPDISC */
140 #else
141 	{ ttynodisc, ttyerrclose, ttyerrio, ttyerrio, nullioctl,
142 	  ttyerrinput, ttyerrstart, nullmodem },
143 #endif
144 };
145 
146 int	nlinesw = sizeof (linesw) / sizeof (linesw[0]);
147 
148 /*
149  * Do nothing specific version of line
150  * discipline specific ioctl command.
151  */
152 /*ARGSUSED*/
153 int
154 nullioctl(tp, cmd, data, flags, p)
155 	struct tty *tp;
156 	u_long cmd;
157 	char *data;
158 	int flags;
159 	struct proc *p;
160 {
161 
162 #ifdef lint
163 	tp = tp; data = data; flags = flags; p = p;
164 #endif
165 	return (-1);
166 }
167