2 * Copyright (c) 1982, 1986, 1991, 1993
3 * The Regents of the University of California. All rights reserved.
4 * (c) UNIX System Laboratories, Inc.
5 * All or some portions of this file are derived from material licensed
6 * to the University of California by American Telephone and Telegraph
7 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
8 * the permission of UNIX System Laboratories, Inc.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by the University of
21 * California, Berkeley and its contributors.
22 * 4. 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.
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
38 * @(#)tty_conf.c 8.4 (Berkeley) 1/21/94
41 #include <sys/cdefs.h>
42 __FBSDID("$FreeBSD$");
44 #include "opt_compat.h"
46 #include <sys/param.h>
47 #include <sys/systm.h>
55 static l_open_t l_noopen;
56 static l_close_t l_noclose;
57 static l_rint_t l_norint;
58 static l_start_t l_nostart;
61 * XXX it probably doesn't matter what the entries other than the l_open
62 * entry are here. The l_nullioctl and ttymodem entries still look fishy.
63 * Reconsider the removal of nullmodem anyway. It was too much like
64 * ttymodem, but a completely null version might be useful.
67 { l_noopen, l_noclose, l_noread, l_nowrite, \
68 l_nullioctl, l_norint, l_nostart, ttymodem }
70 struct linesw linesw[MAXLDISC] =
73 { ttyopen, ttylclose, ttread, ttwrite,
74 l_nullioctl, ttyinput, ttstart, ttymodem },
75 NODISC(1), /* 1- defunct */
78 { ttyopen, ttylclose, ttread, ttwrite,
79 l_nullioctl, ttyinput, ttstart, ttymodem },
83 NODISC(3), /* loadable */
84 NODISC(4), /* SLIPDISC */
85 NODISC(5), /* PPPDISC */
86 NODISC(6), /* NETGRAPHDISC */
87 NODISC(7), /* loadable */
88 NODISC(8), /* loadable */
91 int nlinesw = sizeof (linesw) / sizeof (linesw[0]);
93 static struct linesw nodisc = NODISC(0);
95 #define LOADABLE_LDISC 7
97 * ldisc_register: Register a line discipline.
99 * discipline: Index for discipline to load, or LDISC_LOAD for us to choose.
100 * linesw_p: Pointer to linesw_p.
102 * Returns: Index used or -1 on failure.
105 ldisc_register(discipline, linesw_p)
107 struct linesw *linesw_p;
111 if (discipline == LDISC_LOAD) {
113 for (i = LOADABLE_LDISC; i < MAXLDISC; i++)
114 if (bcmp(linesw + i, &nodisc, sizeof(nodisc)) == 0) {
118 else if (discipline >= 0 && discipline < MAXLDISC) {
122 if (slot != -1 && linesw_p)
123 linesw[slot] = *linesw_p;
129 * ldisc_deregister: Deregister a line discipline obtained with
132 * discipline: Index for discipline to unload.
135 ldisc_deregister(discipline)
138 if (discipline < MAXLDISC) {
139 linesw[discipline] = nodisc;
162 l_noread(tp, uio, flag)
172 l_nowrite(tp, uio, flag)
199 * Do nothing specific version of line
200 * discipline specific ioctl command.
203 l_nullioctl(tp, cmd, data, flags, td)