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  * (MPSAFE)
    3  *
    4  * Copyright (c) 1982, 1986, 1991, 1993
    5  *      The Regents of the University of California.  All rights reserved.
    6  * (c) UNIX System Laboratories, Inc.
    7  * All or some portions of this file are derived from material licensed
    8  * to the University of California by American Telephone and Telegraph
    9  * Co. or Unix System Laboratories, Inc. and are reproduced herein with
   10  * the permission of UNIX System Laboratories, Inc.
   11  *
   12  * Redistribution and use in source and binary forms, with or without
   13  * modification, are permitted provided that the following conditions
   14  * are met:
   15  * 1. Redistributions of source code must retain the above copyright
   16  *    notice, this list of conditions and the following disclaimer.
   17  * 2. Redistributions in binary form must reproduce the above copyright
   18  *    notice, this list of conditions and the following disclaimer in the
   19  *    documentation and/or other materials provided with the distribution.
   20  * 3. Neither the name of the University nor the names of its contributors
   21  *    may be used to endorse or promote products derived from this software
   22  *    without specific prior written permission.
   23  *
   24  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
   25  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   26  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   27  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
   28  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   29  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   30  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   31  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   32  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   33  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   34  * SUCH DAMAGE.
   35  *
   36  *      @(#)tty_conf.c  8.4 (Berkeley) 1/21/94
   37  * $FreeBSD: src/sys/kern/tty_conf.c,v 1.16.2.1 2002/03/11 01:14:55 dd Exp $
   38  */
   39 
   40 #include "opt_compat.h"
   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 9
   49 #endif
   50 
   51 static l_open_t         l_noopen;
   52 static l_close_t        l_noclose;
   53 static l_rint_t         l_norint;
   54 static l_start_t        l_nostart;
   55 
   56 /*
   57  * XXX it probably doesn't matter what the entries other than the l_open
   58  * entry are here.  The l_nullioctl and ttymodem entries still look fishy.
   59  * Reconsider the removal of nullmodem anyway.  It was too much like
   60  * ttymodem, but a completely null version might be useful.
   61  */
   62 #define NODISC(n) \
   63         { l_noopen,     l_noclose,      l_noread,       l_nowrite, \
   64           l_nullioctl,  l_norint,       l_nostart,      ttymodem }
   65 
   66 struct  linesw linesw[MAXLDISC] =
   67 {
   68                                 /* 0- termios */
   69         { ttyopen,      ttylclose,      ttread,         ttwrite,
   70           l_nullioctl,  ttyinput,       ttstart,        ttymodem },
   71         NODISC(1),              /* 1- defunct */
   72                                 /* 2- NTTYDISC */
   73 #ifdef COMPAT_43
   74         { ttyopen,      ttylclose,      ttread,         ttwrite,
   75           l_nullioctl,  ttyinput,       ttstart,        ttymodem },
   76 #else
   77         NODISC(2),
   78 #endif
   79         NODISC(3),              /* loadable */
   80         NODISC(4),              /* SLIPDISC */
   81         NODISC(5),              /* PPPDISC */
   82         NODISC(6),              /* NETGRAPHDISC */
   83         NODISC(7),              /* loadable */
   84         NODISC(8),              /* loadable */
   85 };
   86 
   87 int     nlinesw = NELEM(linesw);
   88 
   89 static struct linesw nodisc = NODISC(0);
   90 
   91 #define LOADABLE_LDISC 7
   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(int discipline, struct linesw *linesw_p)
  102 {
  103         int slot = -1;
  104 
  105         lwkt_gettoken(&tty_token);
  106         if (discipline == LDISC_LOAD) {
  107                 int i;
  108                 for (i = LOADABLE_LDISC; i < MAXLDISC; i++)
  109                         if (bcmp(linesw + i, &nodisc, sizeof(nodisc)) == 0) {
  110                                 slot = i;
  111                         }
  112         }
  113         else if (discipline >= 0 && discipline < MAXLDISC) {
  114                 slot = discipline;
  115         }
  116 
  117         if (slot != -1 && linesw_p)
  118                 linesw[slot] = *linesw_p;
  119 
  120         lwkt_reltoken(&tty_token);
  121         return slot;
  122 }
  123 
  124 /*
  125  * ldisc_deregister: Deregister a line discipline obtained with
  126  * ldisc_register.
  127  *
  128  * discipline: Index for discipline to unload.
  129  */
  130 void
  131 ldisc_deregister(int discipline)
  132 {
  133         lwkt_gettoken(&tty_token);
  134         if (discipline < MAXLDISC) {
  135                 linesw[discipline] = nodisc;
  136         }
  137         lwkt_reltoken(&tty_token);
  138 }
  139 
  140 static int
  141 l_noopen(cdev_t dev, struct tty *tp)
  142 {
  143 
  144         return (ENODEV);
  145 }
  146 
  147 static int
  148 l_noclose(struct tty *tp, int flag)
  149 {
  150 
  151         return (ENODEV);
  152 }
  153 
  154 int
  155 l_noread(struct tty *tp, struct uio *uio, int flag)
  156 {
  157 
  158         return (ENODEV);
  159 }
  160 
  161 int
  162 l_nowrite(struct tty *tp, struct uio *uio, int flag)
  163 {
  164 
  165         return (ENODEV);
  166 }
  167 
  168 static int
  169 l_norint(int c, struct tty *tp)
  170 {
  171 
  172         return (ENODEV);
  173 }
  174 
  175 static int
  176 l_nostart(struct tty *tp)
  177 {
  178 
  179         return (ENODEV);
  180 }
  181 
  182 /*
  183  * Do nothing specific version of line
  184  * discipline specific ioctl command.
  185  */
  186 int
  187 l_nullioctl(struct tty *tp, u_long cmd, char *data, int flags,
  188             struct ucred *cred)
  189 {
  190 
  191         return (ENOIOCTL);
  192 }

Cache object: c20fed1db1cc1982ac0eb0dd87fcc784


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