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