]>
git.saurik.com Git - apple/xnu.git/blob - bsd/kern/tty_conf.c
2 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
23 * @APPLE_LICENSE_HEADER_END@
25 /* Copyright (c) 1997 Apple Computer, Inc. All Rights Reserved */
27 * Copyright (c) 1982, 1986, 1991, 1993
28 * The Regents of the University of California. All rights reserved.
29 * (c) UNIX System Laboratories, Inc.
30 * All or some portions of this file are derived from material licensed
31 * to the University of California by American Telephone and Telegraph
32 * Co. or Unix System Laboratories, Inc. and are reproduced herein with
33 * the permission of UNIX System Laboratories, Inc.
35 * Redistribution and use in source and binary forms, with or without
36 * modification, are permitted provided that the following conditions
38 * 1. Redistributions of source code must retain the above copyright
39 * notice, this list of conditions and the following disclaimer.
40 * 2. Redistributions in binary form must reproduce the above copyright
41 * notice, this list of conditions and the following disclaimer in the
42 * documentation and/or other materials provided with the distribution.
43 * 3. All advertising materials mentioning features or use of this software
44 * must display the following acknowledgement:
45 * This product includes software developed by the University of
46 * California, Berkeley and its contributors.
47 * 4. Neither the name of the University nor the names of its contributors
48 * may be used to endorse or promote products derived from this software
49 * without specific prior written permission.
51 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
52 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
53 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
54 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
55 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
56 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
57 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
58 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
59 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
60 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
63 * @(#)tty_conf.c 8.4 (Berkeley) 1/21/94
66 #include <sys/param.h>
67 #include <sys/systm.h>
76 static l_open_t l_noopen
;
77 static l_close_t l_noclose
;
78 static l_ioctl_t l_nullioctl
;
79 static l_rint_t l_norint
;
80 static l_start_t l_nostart
;
82 #define l_noopen ((int (*) __P((dev_t, struct tty *)))enodev)
83 #define l_noclose ((int (*) __P((struct tty *, int flags)))enodev)
84 #define l_noread ((int (*) __P((struct tty *, struct uio *, int)))enodev)
85 #define l_nowrite l_noread
86 #define l_norint ((int (*) __P((int c, struct tty *)))enodev)
87 #define l_nostart ((int (*) __P((struct tty *)))enodev)
89 l_nullioctl(struct tty
*tp
, u_long cmd
, caddr_t data
, int flag
, struct proc
*p
);
93 * XXX it probably doesn't matter what the entries other than the l_open
94 * entry are here. The l_nullioctl and ttymodem entries still look fishy.
95 * Reconsider the removal of nullmodem anyway. It was too much like
96 * ttymodem, but a completely null version might be useful.
99 { l_noopen, l_noclose, l_noread, l_nowrite, \
100 l_nullioctl, l_norint, l_nostart, ttymodem }
102 struct linesw linesw
[MAXLDISC
] =
105 { ttyopen
, ttylclose
, ttread
, ttwrite
,
106 l_nullioctl
, ttyinput
, ttstart
, ttymodem
},
107 NODISC(1), /* 1- defunct */
110 { ttyopen
, ttylclose
, ttread
, ttwrite
,
111 l_nullioctl
, ttyinput
, ttstart
, ttymodem
},
115 NODISC(3), /* TABLDISC */
116 NODISC(4), /* SLIPDISC */
117 NODISC(5), /* PPPDISC */
118 NODISC(6), /* loadable */
119 NODISC(7), /* loadable */
122 int nlinesw
= sizeof (linesw
) / sizeof (linesw
[0]);
124 static struct linesw nodisc
= NODISC(0);
126 #define LOADABLE_LDISC 6
128 * ldisc_register: Register a line discipline.
130 * discipline: Index for discipline to load, or LDISC_LOAD for us to choose.
131 * linesw_p: Pointer to linesw_p.
133 * Returns: Index used or -1 on failure.
136 ldisc_register(discipline
, linesw_p
)
138 struct linesw
*linesw_p
;
142 if (discipline
== LDISC_LOAD
) {
144 for (i
= LOADABLE_LDISC
; i
< MAXLDISC
; i
++)
145 if (bcmp(linesw
+ i
, &nodisc
, sizeof(nodisc
)) == 0) {
149 else if (discipline
>= 0 && discipline
< MAXLDISC
) {
153 if (slot
!= -1 && linesw_p
)
154 linesw
[slot
] = *linesw_p
;
160 * ldisc_deregister: Deregister a line discipline obtained with
161 * ldisc_register. Can only deregister "loadable" ones now.
163 * discipline: Index for discipline to unload.
166 ldisc_deregister(discipline
)
169 if (discipline
>= LOADABLE_LDISC
&& discipline
< MAXLDISC
) {
170 linesw
[discipline
] = nodisc
;
194 l_noread(tp
, uio
, flag
)
204 l_nowrite(tp
, uio
, flag
)
232 * Do nothing specific version of line
233 * discipline specific ioctl command.
236 l_nullioctl(tp
, cmd
, data
, flags
, p
)