Annotation of kernel/bsd/kern/tty_conf.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 1999 Apple Computer, Inc. All rights reserved.
        !             3:  *
        !             4:  * @APPLE_LICENSE_HEADER_START@
        !             5:  * 
        !             6:  * Portions Copyright (c) 1999 Apple Computer, Inc.  All Rights
        !             7:  * Reserved.  This file contains Original Code and/or Modifications of
        !             8:  * Original Code as defined in and that are subject to the Apple Public
        !             9:  * Source License Version 1.1 (the "License").  You may not use this file
        !            10:  * except in compliance with the License.  Please obtain a copy of the
        !            11:  * License at http://www.apple.com/publicsource and read it before using
        !            12:  * this file.
        !            13:  * 
        !            14:  * The Original Code and all software distributed under the License are
        !            15:  * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
        !            16:  * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
        !            17:  * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
        !            18:  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT.  Please see the
        !            19:  * License for the specific language governing rights and limitations
        !            20:  * under the License.
        !            21:  * 
        !            22:  * @APPLE_LICENSE_HEADER_END@
        !            23:  */
        !            24: 
        !            25: /* Copyright (c) 1997 Apple Computer, Inc. All Rights Reserved */
        !            26: /*-
        !            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.
        !            34:  *
        !            35:  * Redistribution and use in source and binary forms, with or without
        !            36:  * modification, are permitted provided that the following conditions
        !            37:  * are met:
        !            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.
        !            50:  *
        !            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
        !            61:  * SUCH DAMAGE.
        !            62:  *
        !            63:  *     @(#)tty_conf.c  8.4 (Berkeley) 1/21/94
        !            64:  */
        !            65: 
        !            66: #include <sys/param.h>
        !            67: #include <sys/systm.h>
        !            68: #include <sys/tty.h>
        !            69: #include <sys/conf.h>
        !            70: 
        !            71: #ifndef MAXLDISC
        !            72: #define MAXLDISC 8
        !            73: #endif
        !            74: 
        !            75: #ifndef NeXT
        !            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;
        !            81: #else /* NeXT */
        !            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)
        !            88: static int
        !            89: l_nullioctl(struct tty *tp, u_long cmd, caddr_t data, int flag, struct proc *p);
        !            90: #endif /* !NeXT */
        !            91: 
        !            92: /*
        !            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.
        !            97:  */
        !            98: #define NODISC(n) \
        !            99:        { l_noopen,     l_noclose,      l_noread,       l_nowrite, \
        !           100:          l_nullioctl,  l_norint,       l_nostart,      ttymodem }
        !           101: 
        !           102: struct linesw linesw[MAXLDISC] =
        !           103: {
        !           104:                                /* 0- termios */
        !           105:        { ttyopen,      ttylclose,      ttread,         ttwrite,
        !           106:          l_nullioctl,  ttyinput,       ttstart,        ttymodem },
        !           107:        NODISC(1),              /* 1- defunct */
        !           108:                                /* 2- NTTYDISC */
        !           109: #ifdef COMPAT_43
        !           110:        { ttyopen,      ttylclose,      ttread,         ttwrite,
        !           111:          l_nullioctl,  ttyinput,       ttstart,        ttymodem },
        !           112: #else
        !           113:        NODISC(2),
        !           114: #endif
        !           115:        NODISC(3),              /* TABLDISC */
        !           116:        NODISC(4),              /* SLIPDISC */
        !           117:        NODISC(5),              /* PPPDISC */
        !           118:        NODISC(6),              /* loadable */
        !           119:        NODISC(7),              /* loadable */
        !           120: };
        !           121: 
        !           122: int    nlinesw = sizeof (linesw) / sizeof (linesw[0]);
        !           123: 
        !           124: static struct linesw nodisc = NODISC(0);
        !           125: 
        !           126: #define LOADABLE_LDISC 6
        !           127: /*
        !           128:  * ldisc_register: Register a line discipline.
        !           129:  *
        !           130:  * discipline: Index for discipline to load, or LDISC_LOAD for us to choose.
        !           131:  * linesw_p:   Pointer to linesw_p.
        !           132:  *
        !           133:  * Returns: Index used or -1 on failure.
        !           134:  */
        !           135: int
        !           136: ldisc_register(discipline, linesw_p)
        !           137:        int discipline;
        !           138:        struct linesw *linesw_p;
        !           139: {
        !           140:        int slot = -1;
        !           141: 
        !           142:        if (discipline == LDISC_LOAD) {
        !           143:                int i;
        !           144:                for (i = LOADABLE_LDISC; i < MAXLDISC; i++)
        !           145:                        if (bcmp(linesw + i, &nodisc, sizeof(nodisc)) == 0) {
        !           146:                                slot = i;
        !           147:                        }
        !           148:        }
        !           149:        else if (discipline >= 0 && discipline < MAXLDISC) {
        !           150:                slot = discipline;
        !           151:        }
        !           152: 
        !           153:        if (slot != -1 && linesw_p)
        !           154:                linesw[slot] = *linesw_p;
        !           155: 
        !           156:        return slot;
        !           157: }
        !           158: 
        !           159: /*
        !           160:  * ldisc_deregister: Deregister a line discipline obtained with
        !           161:  * ldisc_register.  Can only deregister "loadable" ones now.
        !           162:  *
        !           163:  * discipline: Index for discipline to unload.
        !           164:  */
        !           165: void
        !           166: ldisc_deregister(discipline)
        !           167:        int discipline;
        !           168: {
        !           169:        if (discipline >= LOADABLE_LDISC && discipline < MAXLDISC) {
        !           170:                linesw[discipline] = nodisc;
        !           171:        }
        !           172: }
        !           173: 
        !           174: #ifndef NeXT
        !           175: static int
        !           176: l_noopen(dev, tp)
        !           177:        dev_t dev;
        !           178:        struct tty *tp;
        !           179: {
        !           180: 
        !           181:        return (ENODEV);
        !           182: }
        !           183: 
        !           184: static int
        !           185: l_noclose(tp, flag)
        !           186:        struct tty *tp;
        !           187:        int flag;
        !           188: {
        !           189: 
        !           190:        return (ENODEV);
        !           191: }
        !           192: 
        !           193: int
        !           194: l_noread(tp, uio, flag)
        !           195:        struct tty *tp;
        !           196:        struct uio *uio;
        !           197:        int flag;
        !           198: {
        !           199: 
        !           200:        return (ENODEV);
        !           201: }
        !           202: 
        !           203: int
        !           204: l_nowrite(tp, uio, flag)
        !           205:        struct tty *tp;
        !           206:        struct uio *uio;
        !           207:        int flag;
        !           208: {
        !           209: 
        !           210:        return (ENODEV);
        !           211: }
        !           212: 
        !           213: static int
        !           214: l_norint(c, tp)
        !           215:        int c;
        !           216:        struct tty *tp;
        !           217: {
        !           218: 
        !           219:        return (ENODEV);
        !           220: }
        !           221: 
        !           222: static int
        !           223: l_nostart(tp)
        !           224:        struct tty *tp;
        !           225: {
        !           226: 
        !           227:        return (ENODEV);
        !           228: }
        !           229: #endif /* !NeXT */
        !           230: 
        !           231: /*
        !           232:  * Do nothing specific version of line
        !           233:  * discipline specific ioctl command.
        !           234:  */
        !           235: static int
        !           236: l_nullioctl(tp, cmd, data, flags, p)
        !           237:        struct tty *tp;
        !           238:        u_long cmd;
        !           239:        caddr_t data;
        !           240:        int flags;
        !           241:        struct proc *p;
        !           242: {
        !           243: 
        !           244:        return (-1);
        !           245: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.