xref: /openbsd-src/sys/kern/tty_conf.c (revision 43003dfe3ad45d1698bed8a37f2b0f5b14f20d4f)
1 /*	$OpenBSD: tty_conf.c,v 1.14 2009/08/25 16:16:34 jsg 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 "sl.h"
56 #if NSL > 0
57 int	slopen(dev_t dev, struct tty *tp);
58 int	slclose(struct tty *tp, int flags);
59 int	sltioctl(struct tty *tp, u_long cmd, caddr_t data,
60 			int flag, struct proc *p);
61 int	slinput(int c, struct tty *tp);
62 int	slstart(struct tty *tp);
63 #endif
64 
65 #include "ppp.h"
66 #if NPPP > 0
67 int	pppopen(dev_t dev, struct tty *tp);
68 int	pppclose(struct tty *tp, int flags);
69 int	ppptioctl(struct tty *tp, u_long cmd, caddr_t data,
70 			int flag, struct proc *p);
71 int	pppinput(int c, struct tty *tp);
72 int	pppstart(struct tty *tp);
73 int	pppread(struct tty *tp, struct uio *uio, int flag);
74 int	pppwrite(struct tty *tp, struct uio *uio, int flag);
75 #endif
76 
77 #include "nmea.h"
78 #if NNMEA > 0
79 int	nmeaopen(dev_t, struct tty *);
80 int	nmeaclose(struct tty *, int);
81 int	nmeainput(int, struct tty *);
82 #endif
83 
84 #include "msts.h"
85 #if NMSTS > 0
86 int	mstsopen(dev_t, struct tty *);
87 int	mstsclose(struct tty *, int);
88 int	mstsinput(int, struct tty *);
89 #endif
90 
91 #include "endrun.h"
92 #if NENDRUN > 0
93 int	endrunopen(dev_t, struct tty *);
94 int	endrunclose(struct tty *, int);
95 int	endruninput(int, struct tty *);
96 #endif
97 
98 struct	linesw linesw[] =
99 {
100 	{ ttyopen, ttylclose, ttread, ttwrite, nullioctl,
101 	  ttyinput, ttstart, ttymodem },		/* 0- termios */
102 
103 	{ ttynodisc, ttyerrclose, ttyerrio, ttyerrio, nullioctl,
104 	  ttyerrinput, ttyerrstart, nullmodem },	/* 1- defunct */
105 
106 #if defined(COMPAT_43) || defined(COMPAT_FREEBSD) || defined(COMPAT_BSDOS)
107 	{ ttyopen, ttylclose, ttread, ttwrite, nullioctl,
108 	  ttyinput, ttstart, ttymodem },		/* 2- old NTTYDISC */
109 #else
110 	{ ttynodisc, ttyerrclose, ttyerrio, ttyerrio, nullioctl,
111 	  ttyerrinput, ttyerrstart, nullmodem },	/* 2- defunct */
112 #endif
113 
114 	/* 3- TABLDISC (defunct) */
115 	{ ttynodisc, ttyerrclose, ttyerrio, ttyerrio, nullioctl,
116 	  ttyerrinput, ttyerrstart, nullmodem },
117 
118 #if NSL > 0
119 	{ slopen, slclose, ttyerrio, ttyerrio, sltioctl,
120 	  slinput, slstart, nullmodem },		/* 4- SLIPDISC */
121 #else
122 	{ ttynodisc, ttyerrclose, ttyerrio, ttyerrio, nullioctl,
123 	  ttyerrinput, ttyerrstart, nullmodem },
124 #endif
125 
126 #if NPPP > 0
127 	{ pppopen, pppclose, pppread, pppwrite, ppptioctl,
128 	  pppinput, pppstart, ttymodem },		/* 5- PPPDISC */
129 #else
130 	{ ttynodisc, ttyerrclose, ttyerrio, ttyerrio, nullioctl,
131 	  ttyerrinput, ttyerrstart, nullmodem },
132 #endif
133 
134 	/* 6- STRIPDISC (defunct) */
135 	{ ttynodisc, ttyerrclose, ttyerrio, ttyerrio, nullioctl,
136 	  ttyerrinput, ttyerrstart, nullmodem },
137 
138 #if NNMEA > 0
139 	{ nmeaopen, nmeaclose, ttread, ttwrite, nullioctl,
140 	  nmeainput, ttstart, ttymodem },		/* 7- NMEADISC */
141 #else
142 	{ ttynodisc, ttyerrclose, ttyerrio, ttyerrio, nullioctl,
143 	  ttyerrinput, ttyerrstart, nullmodem },
144 #endif
145 
146 #if NMSTS > 0
147 	{ mstsopen, mstsclose, ttread, ttwrite, nullioctl,
148 	  mstsinput, ttstart, ttymodem },		/* 8- MSTSDISC */
149 #else
150 	{ ttynodisc, ttyerrclose, ttyerrio, ttyerrio, nullioctl,
151 	  ttyerrinput, ttyerrstart, nullmodem },
152 #endif
153 
154 #if NENDRUN > 0
155 	{ endrunopen, endrunclose, ttread, ttwrite, nullioctl,
156 	  endruninput, ttstart, ttymodem },		/* 9- ENDRUNDISC */
157 #else
158 	{ ttynodisc, ttyerrclose, ttyerrio, ttyerrio, nullioctl,
159 	  ttyerrinput, ttyerrstart, nullmodem },
160 #endif
161 };
162 
163 int	nlinesw = sizeof (linesw) / sizeof (linesw[0]);
164 
165 /*
166  * Do nothing specific version of line
167  * discipline specific ioctl command.
168  */
169 /*ARGSUSED*/
170 int
171 nullioctl(struct tty *tp, u_long cmd, char *data, int flags, struct proc *p)
172 {
173 
174 #ifdef lint
175 	tp = tp; data = data; flags = flags; p = p;
176 #endif
177 	return (-1);
178 }
179