The Design and Implementation of the FreeBSD Operating System, Second Edition
Now available: The Design and Implementation of the FreeBSD Operating System (Second Edition)


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]

FreeBSD/Linux Kernel Cross Reference
sys/kern/tty_conf.c

Version: -  FREEBSD  -  FREEBSD-13-STABLE  -  FREEBSD-13-0  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  l41  -  OPENBSD  -  linux-2.6  -  MK84  -  PLAN9  -  xnu-8792 
SearchContext: -  none  -  3  -  10 

    1 /*-
    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.
    9  *
   10  * Redistribution and use in source and binary forms, with or without
   11  * modification, are permitted provided that the following conditions
   12  * are met:
   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.
   25  *
   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
   36  * SUCH DAMAGE.
   37  *
   38  *      @(#)tty_conf.c  8.4 (Berkeley) 1/21/94
   39  * $FreeBSD: src/sys/kern/tty_conf.c,v 1.8.4.1 1999/09/05 08:15:27 peter Exp $
   40  */
   41 
   42 #include <sys/param.h>
   43 #include <sys/systm.h>
   44 #include <sys/tty.h>
   45 #include <sys/conf.h>
   46 
   47 #ifndef MAXLDISC
   48 #define MAXLDISC 8
   49 #endif
   50 
   51 static l_open_t         l_noopen;
   52 static l_close_t        l_noclose;
   53 static l_ioctl_t        l_nullioctl;
   54 static l_rint_t         l_norint;
   55 static l_start_t        l_nostart;
   56 
   57 /*
   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.
   62  */
   63 #define NODISC(n) \
   64         { l_noopen,     l_noclose,      l_noread,       l_nowrite, \
   65           l_nullioctl,  l_norint,       l_nostart,      ttymodem }
   66 
   67 struct  linesw linesw[MAXLDISC] =
   68 {
   69                                 /* 0- termios */
   70         { ttyopen,      ttylclose,      ttread,         ttwrite,
   71           l_nullioctl,  ttyinput,       ttstart,        ttymodem },
   72         NODISC(1),              /* 1- defunct */
   73                                 /* 2- NTTYDISC */
   74 #ifdef COMPAT_43
   75         { ttyopen,      ttylclose,      ttread,         ttwrite,
   76           l_nullioctl,  ttyinput,       ttstart,        ttymodem },
   77 #else
   78         NODISC(2),
   79 #endif
   80         NODISC(3),              /* TABLDISC */
   81         NODISC(4),              /* SLIPDISC */
   82         NODISC(5),              /* PPPDISC */
   83         NODISC(6),              /* loadable */
   84         NODISC(7),              /* loadable */
   85 };
   86 
   87 int     nlinesw = sizeof (linesw) / sizeof (linesw[0]);
   88 
   89 static struct linesw nodisc = NODISC(0);
   90 
   91 #define LOADABLE_LDISC 6
   92 /*
   93  * ldisc_register: Register a line discipline.
   94  *
   95  * discipline: Index for discipline to load, or LDISC_LOAD for us to choose.
   96  * linesw_p:   Pointer to linesw_p.
   97  *
   98  * Returns: Index used or -1 on failure.
   99  */
  100 int
  101 ldisc_register(discipline, linesw_p)
  102         int discipline;
  103         struct linesw *linesw_p;
  104 {
  105         int slot = -1;
  106 
  107         if (discipline == LDISC_LOAD) {
  108                 int i;
  109                 for (i = LOADABLE_LDISC; i < MAXLDISC; i++)
  110                         if (bcmp(linesw + i, &nodisc, sizeof(nodisc)) == 0) {
  111                                 slot = i;
  112                         }
  113         }
  114         else if (discipline >= 0 && discipline < MAXLDISC) {
  115                 slot = discipline;
  116         }
  117 
  118         if (slot != -1 && linesw_p)
  119                 linesw[slot] = *linesw_p;
  120 
  121         return slot;
  122 }
  123 
  124 /*
  125  * ldisc_deregister: Deregister a line discipline obtained with
  126  * ldisc_register.  Can only deregister "loadable" ones now.
  127  *
  128  * discipline: Index for discipline to unload.
  129  */
  130 void
  131 ldisc_deregister(discipline)
  132         int discipline;
  133 {
  134         if (discipline >= LOADABLE_LDISC && discipline < MAXLDISC) {
  135                 linesw[discipline] = nodisc;
  136         }
  137 }
  138 
  139 static int
  140 l_noopen(dev, tp)
  141         dev_t dev;
  142         struct tty *tp;
  143 {
  144 
  145         return (ENODEV);
  146 }
  147 
  148 static int
  149 l_noclose(tp, flag)
  150         struct tty *tp;
  151         int flag;
  152 {
  153 
  154         return (ENODEV);
  155 }
  156 
  157 int
  158 l_noread(tp, uio, flag)
  159         struct tty *tp;
  160         struct uio *uio;
  161         int flag;
  162 {
  163 
  164         return (ENODEV);
  165 }
  166 
  167 int
  168 l_nowrite(tp, uio, flag)
  169         struct tty *tp;
  170         struct uio *uio;
  171         int flag;
  172 {
  173 
  174         return (ENODEV);
  175 }
  176 
  177 static int
  178 l_norint(c, tp)
  179         int c;
  180         struct tty *tp;
  181 {
  182 
  183         return (ENODEV);
  184 }
  185 
  186 static int
  187 l_nostart(tp)
  188         struct tty *tp;
  189 {
  190 
  191         return (ENODEV);
  192 }
  193 
  194 /*
  195  * Do nothing specific version of line
  196  * discipline specific ioctl command.
  197  */
  198 static int
  199 l_nullioctl(tp, cmd, data, flags, p)
  200         struct tty *tp;
  201         int cmd;
  202         char *data;
  203         int flags;
  204         struct proc *p;
  205 {
  206 
  207         return (-1);
  208 }

Cache object: 581230b46c322f04e8745a8261865644


[ source navigation ] [ diff markup ] [ identifier search ] [ freetext search ] [ file search ] [ list types ] [ track identifier ]


This page is part of the FreeBSD/Linux Linux Kernel Cross-Reference, and was automatically generated using a modified version of the LXR engine.