xref: /openbsd/sys/kern/tty_conf.c (revision cecf84d4)
1 /*	$OpenBSD: tty_conf.c,v 1.21 2015/03/14 03:38:51 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/tty.h>
43 #include <sys/conf.h>
44 
45 #define	ttynodisc ((int (*)(dev_t, struct tty *, struct proc *))enodev)
46 #define	ttyerrclose ((int (*)(struct tty *, int flags, struct proc *))enodev)
47 #define	ttyerrio ((int (*)(struct tty *, struct uio *, int))enodev)
48 #define	ttyerrinput ((int (*)(int c, struct tty *))enodev)
49 #define	ttyerrstart ((int (*)(struct tty *))enodev)
50 
51 int	nullioctl(struct tty *, u_long, caddr_t, int, struct proc *);
52 
53 #include "ppp.h"
54 #if NPPP > 0
55 int	pppopen(dev_t dev, struct tty *tp, struct proc *);
56 int	pppclose(struct tty *tp, int flags, struct proc *);
57 int	ppptioctl(struct tty *tp, u_long cmd, caddr_t data,
58 			int flag, struct proc *p);
59 int	pppinput(int c, struct tty *tp);
60 int	pppstart(struct tty *tp);
61 int	pppread(struct tty *tp, struct uio *uio, int flag);
62 int	pppwrite(struct tty *tp, struct uio *uio, int flag);
63 #endif
64 
65 #include "nmea.h"
66 #if NNMEA > 0
67 int	nmeaopen(dev_t, struct tty *, struct proc *);
68 int	nmeaclose(struct tty *, int, struct proc *);
69 int	nmeainput(int, struct tty *);
70 #endif
71 
72 #include "msts.h"
73 #if NMSTS > 0
74 int	mstsopen(dev_t, struct tty *, struct proc *);
75 int	mstsclose(struct tty *, int, struct proc *);
76 int	mstsinput(int, struct tty *);
77 #endif
78 
79 #include "endrun.h"
80 #if NENDRUN > 0
81 int	endrunopen(dev_t, struct tty *, struct proc *);
82 int	endrunclose(struct tty *, int, struct proc *);
83 int	endruninput(int, struct tty *);
84 #endif
85 
86 struct	linesw linesw[] =
87 {
88 	{ ttyopen, ttylclose, ttread, ttwrite, nullioctl,
89 	  ttyinput, ttstart, ttymodem },		/* 0- termios */
90 
91 	{ ttynodisc, ttyerrclose, ttyerrio, ttyerrio, nullioctl,
92 	  ttyerrinput, ttyerrstart, nullmodem },	/* 1- defunct */
93 
94 	/* 2- old NTTYDISC (defunct) */
95 	{ ttynodisc, ttyerrclose, ttyerrio, ttyerrio, nullioctl,
96 	  ttyerrinput, ttyerrstart, nullmodem },
97 
98 	/* 3- TABLDISC (defunct) */
99 	{ ttynodisc, ttyerrclose, ttyerrio, ttyerrio, nullioctl,
100 	  ttyerrinput, ttyerrstart, nullmodem },
101 
102 	/* 4- SLIPDISC (defunct) */
103 	{ ttynodisc, ttyerrclose, ttyerrio, ttyerrio, nullioctl,
104 	  ttyerrinput, ttyerrstart, nullmodem },
105 
106 #if NPPP > 0
107 	{ pppopen, pppclose, pppread, pppwrite, ppptioctl,
108 	  pppinput, pppstart, ttymodem },		/* 5- PPPDISC */
109 #else
110 	{ ttynodisc, ttyerrclose, ttyerrio, ttyerrio, nullioctl,
111 	  ttyerrinput, ttyerrstart, nullmodem },
112 #endif
113 
114 	/* 6- STRIPDISC (defunct) */
115 	{ ttynodisc, ttyerrclose, ttyerrio, ttyerrio, nullioctl,
116 	  ttyerrinput, ttyerrstart, nullmodem },
117 
118 #if NNMEA > 0
119 	{ nmeaopen, nmeaclose, ttread, ttwrite, nullioctl,
120 	  nmeainput, ttstart, ttymodem },		/* 7- NMEADISC */
121 #else
122 	{ ttynodisc, ttyerrclose, ttyerrio, ttyerrio, nullioctl,
123 	  ttyerrinput, ttyerrstart, nullmodem },
124 #endif
125 
126 #if NMSTS > 0
127 	{ mstsopen, mstsclose, ttread, ttwrite, nullioctl,
128 	  mstsinput, ttstart, ttymodem },		/* 8- MSTSDISC */
129 #else
130 	{ ttynodisc, ttyerrclose, ttyerrio, ttyerrio, nullioctl,
131 	  ttyerrinput, ttyerrstart, nullmodem },
132 #endif
133 
134 #if NENDRUN > 0
135 	{ endrunopen, endrunclose, ttread, ttwrite, nullioctl,
136 	  endruninput, ttstart, ttymodem },		/* 9- ENDRUNDISC */
137 #else
138 	{ ttynodisc, ttyerrclose, ttyerrio, ttyerrio, nullioctl,
139 	  ttyerrinput, ttyerrstart, nullmodem },
140 #endif
141 };
142 
143 int	nlinesw = sizeof (linesw) / sizeof (linesw[0]);
144 
145 /*
146  * Do nothing specific version of line
147  * discipline specific ioctl command.
148  */
149 int
150 nullioctl(struct tty *tp, u_long cmd, char *data, int flags, struct proc *p)
151 {
152 	return (-1);
153 }
154