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/sys/ttydevsw.h

Version: -  FREEBSD  -  FREEBSD-12-STABLE  -  FREEBSD-12-0  -  FREEBSD-11-STABLE  -  FREEBSD-11-2  -  FREEBSD-11-1  -  FREEBSD-11-0  -  FREEBSD-10-STABLE  -  FREEBSD-10-4  -  FREEBSD-10-3  -  FREEBSD-10-2  -  FREEBSD-10-1  -  FREEBSD-10-0  -  FREEBSD-9-STABLE  -  FREEBSD-9-3  -  FREEBSD-9-2  -  FREEBSD-9-1  -  FREEBSD-9-0  -  FREEBSD-8-STABLE  -  FREEBSD-8-4  -  FREEBSD-8-3  -  FREEBSD-8-2  -  FREEBSD-8-1  -  FREEBSD-8-0  -  FREEBSD-7-STABLE  -  FREEBSD-7-4  -  FREEBSD-7-3  -  FREEBSD-7-2  -  FREEBSD-7-1  -  FREEBSD-7-0  -  FREEBSD-6-STABLE  -  FREEBSD-6-4  -  FREEBSD-6-3  -  FREEBSD-6-2  -  FREEBSD-6-1  -  FREEBSD-6-0  -  FREEBSD-5-STABLE  -  FREEBSD-5-5  -  FREEBSD-5-4  -  FREEBSD-5-3  -  FREEBSD-5-2  -  FREEBSD-5-1  -  FREEBSD-5-0  -  FREEBSD-4-STABLE  -  FREEBSD-3-STABLE  -  FREEBSD22  -  linux-2.6  -  linux-2.4.22  -  MK83  -  MK84  -  PLAN9  -  DFBSD  -  NETBSD  -  NETBSD5  -  NETBSD4  -  NETBSD3  -  NETBSD20  -  OPENBSD  -  xnu-517  -  xnu-792  -  xnu-792.6.70  -  xnu-1228  -  xnu-1456.1.26  -  xnu-1699.24.8  -  xnu-2050.18.24  -  OPENSOLARIS  -  minix-3-1-1 
SearchContext: -  none  -  3  -  10 

    1 /*-
    2  * Copyright (c) 2008 Ed Schouten <ed@FreeBSD.org>
    3  * All rights reserved.
    4  *
    5  * Portions of this software were developed under sponsorship from Snow
    6  * B.V., the Netherlands.
    7  *
    8  * Redistribution and use in source and binary forms, with or without
    9  * modification, are permitted provided that the following conditions
   10  * are met:
   11  * 1. Redistributions of source code must retain the above copyright
   12  *    notice, this list of conditions and the following disclaimer.
   13  * 2. Redistributions in binary form must reproduce the above copyright
   14  *    notice, this list of conditions and the following disclaimer in the
   15  *    documentation and/or other materials provided with the distribution.
   16  *
   17  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
   18  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
   19  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
   20  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
   21  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
   22  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
   23  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
   24  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
   25  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
   26  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   27  * SUCH DAMAGE.
   28  *
   29  * $FreeBSD: releng/9.0/sys/sys/ttydevsw.h 223722 2011-07-02 13:54:20Z ed $
   30  */
   31 
   32 #ifndef _SYS_TTYDEVSW_H_
   33 #define _SYS_TTYDEVSW_H_
   34 
   35 #ifndef _SYS_TTY_H_
   36 #error "can only be included through <sys/tty.h>"
   37 #endif /* !_SYS_TTY_H_ */
   38 
   39 /*
   40  * Driver routines that are called from the line discipline to adjust
   41  * hardware parameters and such.
   42  */
   43 typedef int tsw_open_t(struct tty *tp);
   44 typedef void tsw_close_t(struct tty *tp);
   45 typedef void tsw_outwakeup_t(struct tty *tp);
   46 typedef void tsw_inwakeup_t(struct tty *tp);
   47 typedef int tsw_ioctl_t(struct tty *tp, u_long cmd, caddr_t data,
   48     struct thread *td);
   49 typedef int tsw_cioctl_t(struct tty *tp, int unit, u_long cmd, caddr_t data,
   50     struct thread *td);
   51 typedef int tsw_param_t(struct tty *tp, struct termios *t);
   52 typedef int tsw_modem_t(struct tty *tp, int sigon, int sigoff);
   53 typedef int tsw_mmap_t(struct tty *tp, vm_ooffset_t offset,
   54     vm_paddr_t * paddr, int nprot, vm_memattr_t *memattr);
   55 typedef void tsw_pktnotify_t(struct tty *tp, char event);
   56 typedef void tsw_free_t(void *softc);
   57 
   58 struct ttydevsw {
   59         unsigned int    tsw_flags;      /* Default TTY flags. */
   60 
   61         tsw_open_t      *tsw_open;      /* Device opening. */
   62         tsw_close_t     *tsw_close;     /* Device closure. */
   63 
   64         tsw_outwakeup_t *tsw_outwakeup; /* Output available. */
   65         tsw_inwakeup_t  *tsw_inwakeup;  /* Input can be stored again. */
   66 
   67         tsw_ioctl_t     *tsw_ioctl;     /* ioctl() hooks. */
   68         tsw_cioctl_t    *tsw_cioctl;    /* ioctl() on control devices. */
   69         tsw_param_t     *tsw_param;     /* TIOCSETA device parameter setting. */
   70         tsw_modem_t     *tsw_modem;     /* Modem sigon/sigoff. */
   71 
   72         tsw_mmap_t      *tsw_mmap;      /* mmap() hooks. */
   73         tsw_pktnotify_t *tsw_pktnotify; /* TIOCPKT events. */
   74 
   75         tsw_free_t      *tsw_free;      /* Destructor. */
   76 
   77         void            *tsw_spare[4];  /* For future use. */
   78 };
   79 
   80 static __inline int
   81 ttydevsw_open(struct tty *tp)
   82 {
   83         tty_lock_assert(tp, MA_OWNED);
   84         MPASS(!tty_gone(tp));
   85 
   86         return tp->t_devsw->tsw_open(tp);
   87 }
   88 
   89 static __inline void
   90 ttydevsw_close(struct tty *tp)
   91 {
   92         tty_lock_assert(tp, MA_OWNED);
   93         MPASS(!tty_gone(tp));
   94 
   95         tp->t_devsw->tsw_close(tp);
   96 }
   97 
   98 static __inline void
   99 ttydevsw_outwakeup(struct tty *tp)
  100 {
  101         tty_lock_assert(tp, MA_OWNED);
  102         MPASS(!tty_gone(tp));
  103 
  104         /* Prevent spurious wakeups. */
  105         if (ttydisc_getc_poll(tp) == 0)
  106                 return;
  107 
  108         tp->t_devsw->tsw_outwakeup(tp);
  109 }
  110 
  111 static __inline void
  112 ttydevsw_inwakeup(struct tty *tp)
  113 {
  114         tty_lock_assert(tp, MA_OWNED);
  115         MPASS(!tty_gone(tp));
  116 
  117         /* Prevent spurious wakeups. */
  118         if (tp->t_flags & TF_HIWAT_IN)
  119                 return;
  120 
  121         tp->t_devsw->tsw_inwakeup(tp);
  122 }
  123 
  124 static __inline int
  125 ttydevsw_ioctl(struct tty *tp, u_long cmd, caddr_t data, struct thread *td)
  126 {
  127         tty_lock_assert(tp, MA_OWNED);
  128         MPASS(!tty_gone(tp));
  129 
  130         return tp->t_devsw->tsw_ioctl(tp, cmd, data, td);
  131 }
  132 
  133 static __inline int
  134 ttydevsw_cioctl(struct tty *tp, int unit, u_long cmd, caddr_t data, struct thread *td)
  135 {
  136         tty_lock_assert(tp, MA_OWNED);
  137         MPASS(!tty_gone(tp));
  138 
  139         return tp->t_devsw->tsw_cioctl(tp, unit, cmd, data, td);
  140 }
  141 
  142 static __inline int
  143 ttydevsw_param(struct tty *tp, struct termios *t)
  144 {
  145         MPASS(!tty_gone(tp));
  146 
  147         return tp->t_devsw->tsw_param(tp, t);
  148 }
  149 
  150 static __inline int
  151 ttydevsw_modem(struct tty *tp, int sigon, int sigoff)
  152 {
  153         MPASS(!tty_gone(tp));
  154 
  155         return tp->t_devsw->tsw_modem(tp, sigon, sigoff);
  156 }
  157 
  158 static __inline int
  159 ttydevsw_mmap(struct tty *tp, vm_ooffset_t offset, vm_paddr_t *paddr,
  160     int nprot, vm_memattr_t *memattr)
  161 {
  162         MPASS(!tty_gone(tp));
  163 
  164         return tp->t_devsw->tsw_mmap(tp, offset, paddr, nprot, memattr);
  165 }
  166 
  167 static __inline void
  168 ttydevsw_pktnotify(struct tty *tp, char event)
  169 {
  170         tty_lock_assert(tp, MA_OWNED);
  171         MPASS(!tty_gone(tp));
  172 
  173         tp->t_devsw->tsw_pktnotify(tp, event);
  174 }
  175 
  176 static __inline void
  177 ttydevsw_free(struct tty *tp)
  178 {
  179         MPASS(tty_gone(tp));
  180 
  181         tp->t_devsw->tsw_free(tty_softc(tp));
  182 }
  183 
  184 #endif /* !_SYS_TTYDEVSW_H_ */

Cache object: 2b8d8b82e6a1fd2374a7636249e0ebd7


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