2 * Copyright (c) 2004 Poul-Henning Kamp. All rights reserved.
3 * Copyright (c) 1982, 1986, 1991, 1993
4 * The Regents of the University of California. All rights reserved.
5 * (c) UNIX System Laboratories, Inc.
6 * All or some portions of this file are derived from material licensed
7 * to the University of California by American Telephone and Telegraph
8 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
9 * the permission of UNIX System Laboratories, Inc.
11 * Redistribution and use in source and binary forms, with or without
12 * modification, are permitted provided that the following conditions
14 * 1. Redistributions of source code must retain the above copyright
15 * notice, this list of conditions and the following disclaimer.
16 * 2. Redistributions in binary form must reproduce the above copyright
17 * notice, this list of conditions and the following disclaimer in the
18 * documentation and/or other materials provided with the distribution.
19 * 4. Neither the name of the University nor the names of its contributors
20 * may be used to endorse or promote products derived from this software
21 * without specific prior written permission.
23 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
24 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
27 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
28 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
29 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
32 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
35 * @(#)tty_conf.c 8.4 (Berkeley) 1/21/94
38 #include <sys/cdefs.h>
39 __FBSDID("$FreeBSD$");
41 #include "opt_compat.h"
43 #include <sys/param.h>
44 #include <sys/systm.h>
52 static l_open_t l_noopen;
53 static l_close_t l_noclose;
54 static l_rint_t l_norint;
55 static l_start_t l_nostart;
58 * XXX it probably doesn't matter what the entries other than the l_open
59 * entry are here. The l_nullioctl and ttymodem entries still look fishy.
60 * Reconsider the removal of nullmodem anyway. It was too much like
61 * ttymodem, but a completely null version might be useful.
64 static struct linesw nodisc = {
69 .l_ioctl = l_nullioctl,
75 static struct linesw termios_disc = {
80 .l_ioctl = l_nullioctl,
87 # define ntty_disc termios_disc
89 # define ntty_disc nodisc
92 struct linesw *linesw[MAXLDISC] = {
93 &termios_disc, /* 0 - termios */
94 &nodisc, /* 1 - defunct */
95 &ntty_disc, /* 2 - NTTYDISC */
96 &nodisc, /* 3 - loadable */
97 &nodisc, /* 4 - SLIPDISC */
98 &nodisc, /* 5 - PPPDISC */
99 &nodisc, /* 6 - NETGRAPHDISC */
100 &nodisc, /* 7 - loadable */
101 &nodisc, /* 8 - loadable */
104 int nlinesw = sizeof (linesw) / sizeof (linesw[0]);
106 #define LOADABLE_LDISC 7
109 * ldisc_register: Register a line discipline.
111 * discipline: Index for discipline to load, or LDISC_LOAD for us to choose.
112 * linesw_p: Pointer to linesw_p.
114 * Returns: Index used or -1 on failure.
118 ldisc_register(int discipline, struct linesw *linesw_p)
122 if (discipline == LDISC_LOAD) {
124 for (i = LOADABLE_LDISC; i < MAXLDISC; i++)
125 if (linesw[i] == &nodisc) {
129 } else if (discipline >= 0 && discipline < MAXLDISC) {
133 if (slot != -1 && linesw_p)
134 linesw[slot] = linesw_p;
140 * ldisc_deregister: Deregister a line discipline obtained with
143 * discipline: Index for discipline to unload.
147 ldisc_deregister(int discipline)
150 if (discipline < MAXLDISC)
151 linesw[discipline] = &nodisc;
155 * "no" and "null" versions of line discipline functions
159 l_noopen(struct cdev *dev, struct tty *tp)
166 l_noclose(struct tty *tp, int flag)
173 l_noread(struct tty *tp, struct uio *uio, int flag)
180 l_nowrite(struct tty *tp, struct uio *uio, int flag)
187 l_norint(int c, struct tty *tp)
194 l_nostart(struct tty *tp)
201 l_nullioctl(struct tty *tp, u_long cmd, char *data, int flags, struct thread *td)