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$
   40  */
   41 
   42 #include "opt_compat.h"
   43 
   44 #include <sys/param.h>
   45 #include <sys/systm.h>
   46 #include <sys/tty.h>
   47 #include <sys/conf.h>
   48 
   49 #ifndef MAXLDISC
   50 #define MAXLDISC 8
   51 #endif
   52 
   53 static l_open_t         l_noopen;
   54 static l_close_t        l_noclose;
   55 static l_ioctl_t        l_nullioctl;
   56 static l_rint_t         l_norint;
   57 static l_start_t        l_nostart;
   58 
   59 /*
   60  * XXX it probably doesn't matter what the entries other than the l_open
   61  * entry are here.  The l_nullioctl and ttymodem entries still look fishy.
   62  * Reconsider the removal of nullmodem anyway.  It was too much like
   63  * ttymodem, but a completely null version might be useful.
   64  */
   65 #define NODISC(n) \
   66         { l_noopen,     l_noclose,      l_noread,       l_nowrite, \
   67           l_nullioctl,  l_norint,       l_nostart,      ttymodem }
   68 
   69 struct  linesw linesw[MAXLDISC] =
   70 {
   71                                 /* 0- termios */
   72         { ttyopen,      ttylclose,      ttread,         ttwrite,
   73           l_nullioctl,  ttyinput,       ttstart,        ttymodem },
   74         NODISC(1),              /* 1- defunct */
   75                                 /* 2- NTTYDISC */
   76 #ifdef COMPAT_43
   77         { ttyopen,      ttylclose,      ttread,         ttwrite,
   78           l_nullioctl,  ttyinput,       ttstart,        ttymodem },
   79 #else
   80         NODISC(2),
   81 #endif
   82         NODISC(3),              /* TABLDISC */
   83         NODISC(4),              /* SLIPDISC */
   84         NODISC(5),              /* PPPDISC */
   85         NODISC(6),              /* loadable */
   86         NODISC(7),              /* loadable */
   87 };
   88 
   89 int     nlinesw = sizeof (linesw) / sizeof (linesw[0]);
   90 
   91 static struct linesw nodisc = NODISC(0);
   92 
   93 #define LOADABLE_LDISC 6
   94 /*
   95  * ldisc_register: Register a line discipline.
   96  *
   97  * discipline: Index for discipline to load, or LDISC_LOAD for us to choose.
   98  * linesw_p:   Pointer to linesw_p.
   99  *
  100  * Returns: Index used or -1 on failure.
  101  */
  102 int
  103 ldisc_register(discipline, linesw_p)
  104         int discipline;
  105         struct linesw *linesw_p;
  106 {
  107         int slot = -1;
  108 
  109         if (discipline == LDISC_LOAD) {
  110                 int i;
  111                 for (i = LOADABLE_LDISC; i < MAXLDISC; i++)
  112                         if (bcmp(linesw + i, &nodisc, sizeof(nodisc)) == 0) {
  113                                 slot = i;
  114                         }
  115         }
  116         else if (discipline >= 0 && discipline < MAXLDISC) {
  117                 slot = discipline;
  118         }
  119 
  120         if (slot != -1 && linesw_p)
  121                 linesw[slot] = *linesw_p;
  122 
  123         return slot;
  124 }
  125 
  126 /*
  127  * ldisc_deregister: Deregister a line discipline obtained with
  128  * ldisc_register.  Can only deregister "loadable" ones now.
  129  *
  130  * discipline: Index for discipline to unload.
  131  */
  132 void
  133 ldisc_deregister(discipline)
  134         int discipline;
  135 {
  136         if (discipline >= LOADABLE_LDISC && discipline < MAXLDISC) {
  137                 linesw[discipline] = nodisc;
  138         }
  139 }
  140 
  141 static int
  142 l_noopen(dev, tp)
  143         dev_t dev;
  144         struct tty *tp;
  145 {
  146 
  147         return (ENODEV);
  148 }
  149 
  150 static int
  151 l_noclose(tp, flag)
  152         struct tty *tp;
  153         int flag;
  154 {
  155 
  156         return (ENODEV);
  157 }
  158 
  159 int
  160 l_noread(tp, uio, flag)
  161         struct tty *tp;
  162         struct uio *uio;
  163         int flag;
  164 {
  165 
  166         return (ENODEV);
  167 }
  168 
  169 int
  170 l_nowrite(tp, uio, flag)
  171         struct tty *tp;
  172         struct uio *uio;
  173         int flag;
  174 {
  175 
  176         return (ENODEV);
  177 }
  178 
  179 static int
  180 l_norint(c, tp)
  181         int c;
  182         struct tty *tp;
  183 {
  184 
  185         return (ENODEV);
  186 }
  187 
  188 static int
  189 l_nostart(tp)
  190         struct tty *tp;
  191 {
  192 
  193         return (ENODEV);
  194 }
  195 
  196 /*
  197  * Do nothing specific version of line
  198  * discipline specific ioctl command.
  199  */
  200 static int
  201 l_nullioctl(tp, cmd, data, flags, p)
  202         struct tty *tp;
  203         u_long cmd;
  204         char *data;
  205         int flags;
  206         struct proc *p;
  207 {
  208 
  209         return (ENOIOCTL);
  210 }

Cache object: 2bd6ee01a8f2406a096ff70c4e5d77f1


[ 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.