1*43a90889SApple OSS Distributions /* 2*43a90889SApple OSS Distributions * Copyright (c) 2000-2018 Apple Inc. All rights reserved. 3*43a90889SApple OSS Distributions * 4*43a90889SApple OSS Distributions * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5*43a90889SApple OSS Distributions * 6*43a90889SApple OSS Distributions * This file contains Original Code and/or Modifications of Original Code 7*43a90889SApple OSS Distributions * as defined in and that are subject to the Apple Public Source License 8*43a90889SApple OSS Distributions * Version 2.0 (the 'License'). You may not use this file except in 9*43a90889SApple OSS Distributions * compliance with the License. The rights granted to you under the License 10*43a90889SApple OSS Distributions * may not be used to create, or enable the creation or redistribution of, 11*43a90889SApple OSS Distributions * unlawful or unlicensed copies of an Apple operating system, or to 12*43a90889SApple OSS Distributions * circumvent, violate, or enable the circumvention or violation of, any 13*43a90889SApple OSS Distributions * terms of an Apple operating system software license agreement. 14*43a90889SApple OSS Distributions * 15*43a90889SApple OSS Distributions * Please obtain a copy of the License at 16*43a90889SApple OSS Distributions * http://www.opensource.apple.com/apsl/ and read it before using this file. 17*43a90889SApple OSS Distributions * 18*43a90889SApple OSS Distributions * The Original Code and all software distributed under the License are 19*43a90889SApple OSS Distributions * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20*43a90889SApple OSS Distributions * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21*43a90889SApple OSS Distributions * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22*43a90889SApple OSS Distributions * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23*43a90889SApple OSS Distributions * Please see the License for the specific language governing rights and 24*43a90889SApple OSS Distributions * limitations under the License. 25*43a90889SApple OSS Distributions * 26*43a90889SApple OSS Distributions * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27*43a90889SApple OSS Distributions */ 28*43a90889SApple OSS Distributions /* Copyright (c) 1997 Apple Computer, Inc. All Rights Reserved */ 29*43a90889SApple OSS Distributions /*- 30*43a90889SApple OSS Distributions * Copyright (c) 1982, 1986, 1993 31*43a90889SApple OSS Distributions * The Regents of the University of California. All rights reserved. 32*43a90889SApple OSS Distributions * (c) UNIX System Laboratories, Inc. 33*43a90889SApple OSS Distributions * All or some portions of this file are derived from material licensed 34*43a90889SApple OSS Distributions * to the University of California by American Telephone and Telegraph 35*43a90889SApple OSS Distributions * Co. or Unix System Laboratories, Inc. and are reproduced herein with 36*43a90889SApple OSS Distributions * the permission of UNIX System Laboratories, Inc. 37*43a90889SApple OSS Distributions * 38*43a90889SApple OSS Distributions * Redistribution and use in source and binary forms, with or without 39*43a90889SApple OSS Distributions * modification, are permitted provided that the following conditions 40*43a90889SApple OSS Distributions * are met: 41*43a90889SApple OSS Distributions * 1. Redistributions of source code must retain the above copyright 42*43a90889SApple OSS Distributions * notice, this list of conditions and the following disclaimer. 43*43a90889SApple OSS Distributions * 2. Redistributions in binary form must reproduce the above copyright 44*43a90889SApple OSS Distributions * notice, this list of conditions and the following disclaimer in the 45*43a90889SApple OSS Distributions * documentation and/or other materials provided with the distribution. 46*43a90889SApple OSS Distributions * 3. All advertising materials mentioning features or use of this software 47*43a90889SApple OSS Distributions * must display the following acknowledgement: 48*43a90889SApple OSS Distributions * This product includes software developed by the University of 49*43a90889SApple OSS Distributions * California, Berkeley and its contributors. 50*43a90889SApple OSS Distributions * 4. Neither the name of the University nor the names of its contributors 51*43a90889SApple OSS Distributions * may be used to endorse or promote products derived from this software 52*43a90889SApple OSS Distributions * without specific prior written permission. 53*43a90889SApple OSS Distributions * 54*43a90889SApple OSS Distributions * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 55*43a90889SApple OSS Distributions * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 56*43a90889SApple OSS Distributions * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 57*43a90889SApple OSS Distributions * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 58*43a90889SApple OSS Distributions * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 59*43a90889SApple OSS Distributions * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 60*43a90889SApple OSS Distributions * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 61*43a90889SApple OSS Distributions * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 62*43a90889SApple OSS Distributions * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 63*43a90889SApple OSS Distributions * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 64*43a90889SApple OSS Distributions * SUCH DAMAGE. 65*43a90889SApple OSS Distributions * 66*43a90889SApple OSS Distributions * @(#)tty.h 8.6 (Berkeley) 1/21/94 67*43a90889SApple OSS Distributions */ 68*43a90889SApple OSS Distributions 69*43a90889SApple OSS Distributions #ifndef _SYS_TTY_H_ 70*43a90889SApple OSS Distributions #define _SYS_TTY_H_ 71*43a90889SApple OSS Distributions 72*43a90889SApple OSS Distributions #include <sys/appleapiopts.h> 73*43a90889SApple OSS Distributions #include <sys/cdefs.h> 74*43a90889SApple OSS Distributions #include <sys/termios.h> 75*43a90889SApple OSS Distributions #include <sys/select.h> /* For struct selinfo. */ 76*43a90889SApple OSS Distributions #if XNU_KERNEL_PRIVATE 77*43a90889SApple OSS Distributions #include <os/refcnt.h> 78*43a90889SApple OSS Distributions #endif 79*43a90889SApple OSS Distributions 80*43a90889SApple OSS Distributions #ifdef KERNEL 81*43a90889SApple OSS Distributions 82*43a90889SApple OSS Distributions __BEGIN_DECLS 83*43a90889SApple OSS Distributions #include <kern/locks.h> 84*43a90889SApple OSS Distributions __END_DECLS 85*43a90889SApple OSS Distributions 86*43a90889SApple OSS Distributions /* 87*43a90889SApple OSS Distributions * NetBSD Clists are actually ring buffers. The c_cc, c_cf, c_cl fields have 88*43a90889SApple OSS Distributions * exactly the same behaviour as in true clists. 89*43a90889SApple OSS Distributions * if c_cq is NULL, the ring buffer has no TTY_QUOTE functionality 90*43a90889SApple OSS Distributions * (but, saves memory and cpu time) 91*43a90889SApple OSS Distributions * 92*43a90889SApple OSS Distributions * *DON'T* play with c_cs, c_ce, c_cq, or c_cl outside tty_subr.c!!! 93*43a90889SApple OSS Distributions */ 94*43a90889SApple OSS Distributions struct clist { 95*43a90889SApple OSS Distributions int c_cc; /* count of characters in queue */ 96*43a90889SApple OSS Distributions int c_cn; /* total ring buffer length */ 97*43a90889SApple OSS Distributions u_char *c_cf; /* points to first character */ 98*43a90889SApple OSS Distributions u_char *c_cl; /* points to next open character */ 99*43a90889SApple OSS Distributions u_char *c_cs; /* start of ring buffer */ 100*43a90889SApple OSS Distributions u_char *c_ce; /* c_ce + c_len */ 101*43a90889SApple OSS Distributions u_char *c_cq; /* N bits/bytes long, see tty_subr.c */ 102*43a90889SApple OSS Distributions }; 103*43a90889SApple OSS Distributions 104*43a90889SApple OSS Distributions #ifndef TTYCLSIZE 105*43a90889SApple OSS Distributions #define TTYCLSIZE 1024 106*43a90889SApple OSS Distributions #endif 107*43a90889SApple OSS Distributions 108*43a90889SApple OSS Distributions /* 109*43a90889SApple OSS Distributions * Per-tty structure. 110*43a90889SApple OSS Distributions * 111*43a90889SApple OSS Distributions * Should be split in two, into device and tty drivers. 112*43a90889SApple OSS Distributions * Glue could be masks of what to echo and circular buffer 113*43a90889SApple OSS Distributions * (low, high, timeout). 114*43a90889SApple OSS Distributions */ 115*43a90889SApple OSS Distributions struct tty { 116*43a90889SApple OSS Distributions lck_mtx_t t_lock; /* Per tty lock */ 117*43a90889SApple OSS Distributions 118*43a90889SApple OSS Distributions struct clist t_rawq; /* Device raw input queue. */ 119*43a90889SApple OSS Distributions long t_rawcc; /* Raw input queue statistics. */ 120*43a90889SApple OSS Distributions struct clist t_canq; /* Device canonical queue. */ 121*43a90889SApple OSS Distributions long t_cancc; /* Canonical queue statistics. */ 122*43a90889SApple OSS Distributions struct clist t_outq; /* Device output queue. */ 123*43a90889SApple OSS Distributions long t_outcc; /* Output queue statistics. */ 124*43a90889SApple OSS Distributions int t_line; /* Interface to device drivers. */ 125*43a90889SApple OSS Distributions dev_t t_dev; /* Device. */ 126*43a90889SApple OSS Distributions int t_state; /* Device and driver (TS*) state. */ 127*43a90889SApple OSS Distributions int t_flags; /* Tty flags. */ 128*43a90889SApple OSS Distributions int t_timeout; /* Timeout for ttywait() */ 129*43a90889SApple OSS Distributions struct pgrp *t_pgrp; /* (TTYL+LL) Foreground process group. */ 130*43a90889SApple OSS Distributions struct session *t_session; /* (TTYL+LL) Enclosing session. */ 131*43a90889SApple OSS Distributions struct selinfo t_rsel; /* Tty read/oob select. */ 132*43a90889SApple OSS Distributions struct selinfo t_wsel; /* Tty write select. */ 133*43a90889SApple OSS Distributions struct termios t_termios; /* Termios state. */ 134*43a90889SApple OSS Distributions struct winsize t_winsize; /* Window size. */ 135*43a90889SApple OSS Distributions /* Start output. */ 136*43a90889SApple OSS Distributions void (*t_oproc)(struct tty *); 137*43a90889SApple OSS Distributions /* Stop output. */ 138*43a90889SApple OSS Distributions void (*t_stop)(struct tty *, int); 139*43a90889SApple OSS Distributions /* Set hardware state. */ 140*43a90889SApple OSS Distributions int (*t_param)(struct tty *, struct termios *); 141*43a90889SApple OSS Distributions void *t_sc; /* XXX: net/if_sl.c:sl_softc. */ 142*43a90889SApple OSS Distributions int t_column; /* Tty output column. */ 143*43a90889SApple OSS Distributions int t_rocount, t_rocol; /* Tty. */ 144*43a90889SApple OSS Distributions int t_hiwat; /* High water mark. */ 145*43a90889SApple OSS Distributions int t_lowat; /* Low water mark. */ 146*43a90889SApple OSS Distributions int t_gen; /* Generation number. */ 147*43a90889SApple OSS Distributions void *t_iokit; /* IOKit management */ 148*43a90889SApple OSS Distributions #if XNU_KERNEL_PRIVATE 149*43a90889SApple OSS Distributions os_ref_atomic_t t_refcnt; 150*43a90889SApple OSS Distributions #else 151*43a90889SApple OSS Distributions int t_refcnt; /* reference count */ 152*43a90889SApple OSS Distributions #endif 153*43a90889SApple OSS Distributions thread_t t_locked_thread; /* thread that owns the lock */ 154*43a90889SApple OSS Distributions }; 155*43a90889SApple OSS Distributions 156*43a90889SApple OSS Distributions #define TTY_NULL (struct tty *)NULL 157*43a90889SApple OSS Distributions 158*43a90889SApple OSS Distributions #define t_cc t_termios.c_cc 159*43a90889SApple OSS Distributions #define t_cflag t_termios.c_cflag 160*43a90889SApple OSS Distributions #define t_iflag t_termios.c_iflag 161*43a90889SApple OSS Distributions #define t_ispeed t_termios.c_ispeed 162*43a90889SApple OSS Distributions #define t_lflag t_termios.c_lflag 163*43a90889SApple OSS Distributions #define t_min t_termios.c_min 164*43a90889SApple OSS Distributions #define t_oflag t_termios.c_oflag 165*43a90889SApple OSS Distributions #define t_ospeed t_termios.c_ospeed 166*43a90889SApple OSS Distributions #define t_time t_termios.c_time 167*43a90889SApple OSS Distributions 168*43a90889SApple OSS Distributions 169*43a90889SApple OSS Distributions #define TTIPRI 25 /* Sleep priority for tty reads. */ 170*43a90889SApple OSS Distributions #define TTOPRI 26 /* Sleep priority for tty writes. */ 171*43a90889SApple OSS Distributions 172*43a90889SApple OSS Distributions /* 173*43a90889SApple OSS Distributions * User data unfortunately has to be copied through buffers on the way to 174*43a90889SApple OSS Distributions * and from clists. The buffers are on the stack so their sizes must be 175*43a90889SApple OSS Distributions * fairly small. 176*43a90889SApple OSS Distributions */ 177*43a90889SApple OSS Distributions #define IBUFSIZ 384 /* Should be >= max value of MIN. */ 178*43a90889SApple OSS Distributions #define OBUFSIZ 100 179*43a90889SApple OSS Distributions 180*43a90889SApple OSS Distributions #ifndef TTYHOG 181*43a90889SApple OSS Distributions #define TTYHOG 1024 182*43a90889SApple OSS Distributions #endif 183*43a90889SApple OSS Distributions 184*43a90889SApple OSS Distributions #define TTMAXHIWAT roundup(2048, CBSIZE) 185*43a90889SApple OSS Distributions #define TTMINHIWAT roundup(100, CBSIZE) 186*43a90889SApple OSS Distributions #define TTMAXLOWAT 256 187*43a90889SApple OSS Distributions #define TTMINLOWAT 32 188*43a90889SApple OSS Distributions #else 189*43a90889SApple OSS Distributions struct tty; 190*43a90889SApple OSS Distributions struct clist; 191*43a90889SApple OSS Distributions #endif /* KERNEL */ 192*43a90889SApple OSS Distributions 193*43a90889SApple OSS Distributions /* These flags are kept in t_state. */ 194*43a90889SApple OSS Distributions #define TS_SO_OLOWAT 0x00001 /* Wake up when output <= low water. */ 195*43a90889SApple OSS Distributions #define TS_ASYNC 0x00002 /* Tty in async I/O mode. */ 196*43a90889SApple OSS Distributions #define TS_BUSY 0x00004 /* Draining output. */ 197*43a90889SApple OSS Distributions #define TS_CARR_ON 0x00008 /* Carrier is present. */ 198*43a90889SApple OSS Distributions #define TS_FLUSH 0x00010 /* Outq has been flushed during DMA. */ 199*43a90889SApple OSS Distributions #define TS_ISOPEN 0x00020 /* Open has completed. */ 200*43a90889SApple OSS Distributions #define TS_TBLOCK 0x00040 /* Further input blocked. */ 201*43a90889SApple OSS Distributions #define TS_TIMEOUT 0x00080 /* Wait for output char processing. */ 202*43a90889SApple OSS Distributions #define TS_TTSTOP 0x00100 /* Output paused. */ 203*43a90889SApple OSS Distributions #ifdef notyet 204*43a90889SApple OSS Distributions #define TS_WOPEN 0x00200 /* Open in progress. */ 205*43a90889SApple OSS Distributions #endif 206*43a90889SApple OSS Distributions #define TS_XCLUDE 0x00400 /* Tty requires exclusivity. */ 207*43a90889SApple OSS Distributions 208*43a90889SApple OSS Distributions /* State for intra-line fancy editing work. */ 209*43a90889SApple OSS Distributions #define TS_BKSL 0x00800 /* State for lowercase \ work. */ 210*43a90889SApple OSS Distributions #define TS_CNTTB 0x01000 /* Counting tab width, ignore FLUSHO. */ 211*43a90889SApple OSS Distributions #define TS_ERASE 0x02000 /* Within a \.../ for PRTRUB. */ 212*43a90889SApple OSS Distributions #define TS_LNCH 0x04000 /* Next character is literal. */ 213*43a90889SApple OSS Distributions #define TS_TYPEN 0x08000 /* Retyping suspended input (PENDIN). */ 214*43a90889SApple OSS Distributions #define TS_LOCAL (TS_BKSL | TS_CNTTB | TS_ERASE | TS_LNCH | TS_TYPEN) 215*43a90889SApple OSS Distributions 216*43a90889SApple OSS Distributions /* Extras. */ 217*43a90889SApple OSS Distributions #define TS_CAN_BYPASS_L_RINT 0x010000 /* Device in "raw" mode. */ 218*43a90889SApple OSS Distributions #define TS_CONNECTED 0x020000 /* Connection open. */ 219*43a90889SApple OSS Distributions #define TS_SNOOP 0x040000 /* Device is being snooped on. */ 220*43a90889SApple OSS Distributions #define TS_SO_OCOMPLETE 0x080000 /* Wake up when output completes. */ 221*43a90889SApple OSS Distributions #define TS_ZOMBIE 0x100000 /* Connection lost. */ 222*43a90889SApple OSS Distributions 223*43a90889SApple OSS Distributions /* Hardware flow-control-invoked bits. */ 224*43a90889SApple OSS Distributions #define TS_CAR_OFLOW 0x200000 /* For MDMBUF (XXX handle in driver). */ 225*43a90889SApple OSS Distributions #ifdef notyet 226*43a90889SApple OSS Distributions #define TS_CTS_OFLOW 0x400000 /* For CCTS_OFLOW. */ 227*43a90889SApple OSS Distributions #define TS_DSR_OFLOW 0x800000 /* For CDSR_OFLOW. */ 228*43a90889SApple OSS Distributions #endif 229*43a90889SApple OSS Distributions 230*43a90889SApple OSS Distributions #define TS_IOCTL_NOT_OK 0x1000000 /* Workaround <rdar://....> */ 231*43a90889SApple OSS Distributions #define TS_REVOKE 0x2000000 /* Terminal getting revoked */ 232*43a90889SApple OSS Distributions 233*43a90889SApple OSS Distributions 234*43a90889SApple OSS Distributions /* Character type information. */ 235*43a90889SApple OSS Distributions #define ORDINARY 0 236*43a90889SApple OSS Distributions #define CONTROL 1 237*43a90889SApple OSS Distributions #define BACKSPACE 2 238*43a90889SApple OSS Distributions #define NEWLINE 3 239*43a90889SApple OSS Distributions #define TAB 4 240*43a90889SApple OSS Distributions #define VTAB 5 241*43a90889SApple OSS Distributions #define RETURN 6 242*43a90889SApple OSS Distributions 243*43a90889SApple OSS Distributions struct speedtab { 244*43a90889SApple OSS Distributions int sp_speed; 245*43a90889SApple OSS Distributions int sp_code; 246*43a90889SApple OSS Distributions }; 247*43a90889SApple OSS Distributions 248*43a90889SApple OSS Distributions /* Modem control commands (driver). */ 249*43a90889SApple OSS Distributions #define DMSET 0 250*43a90889SApple OSS Distributions #define DMBIS 1 251*43a90889SApple OSS Distributions #define DMBIC 2 252*43a90889SApple OSS Distributions #define DMGET 3 253*43a90889SApple OSS Distributions 254*43a90889SApple OSS Distributions /* Flags on a character passed to ttyinput. */ 255*43a90889SApple OSS Distributions #define TTY_CHARMASK 0x000000ff /* Character mask */ 256*43a90889SApple OSS Distributions #define TTY_QUOTE 0x00000100 /* Character quoted */ 257*43a90889SApple OSS Distributions #define TTY_ERRORMASK 0xff000000 /* Error mask */ 258*43a90889SApple OSS Distributions #define TTY_FE 0x01000000 /* Framing error */ 259*43a90889SApple OSS Distributions #define TTY_PE 0x02000000 /* Parity error */ 260*43a90889SApple OSS Distributions #define TTY_OE 0x04000000 /* Overrun error */ 261*43a90889SApple OSS Distributions #define TTY_BI 0x08000000 /* Break condition */ 262*43a90889SApple OSS Distributions 263*43a90889SApple OSS Distributions #ifdef KERNEL 264*43a90889SApple OSS Distributions 265*43a90889SApple OSS Distributions /* Unique sleep addresses. */ 266*43a90889SApple OSS Distributions #define TSA_CARR_ON(tp) ((void *)&(tp)->t_rawq) 267*43a90889SApple OSS Distributions #define TSA_HUP_OR_INPUT(tp) ((void *)&(tp)->t_rawq.c_cf) 268*43a90889SApple OSS Distributions #define TSA_OCOMPLETE(tp) ((void *)&(tp)->t_outq.c_cl) 269*43a90889SApple OSS Distributions #define TSA_OLOWAT(tp) ((void *)&(tp)->t_outq) 270*43a90889SApple OSS Distributions #define TSA_PTC_READ(tp) ((void *)&(tp)->t_outq.c_cf) 271*43a90889SApple OSS Distributions #define TSA_PTC_WRITE(tp) ((void *)&(tp)->t_rawq.c_cl) 272*43a90889SApple OSS Distributions #define TSA_PTS_READ(tp) ((void *)&(tp)->t_canq) 273*43a90889SApple OSS Distributions 274*43a90889SApple OSS Distributions 275*43a90889SApple OSS Distributions __BEGIN_DECLS 276*43a90889SApple OSS Distributions 277*43a90889SApple OSS Distributions int b_to_q(const u_char *cp, int cc, struct clist *q); 278*43a90889SApple OSS Distributions void catq(struct clist *from, struct clist *to); 279*43a90889SApple OSS Distributions void clist_init(void); 280*43a90889SApple OSS Distributions int getc(struct clist *q); 281*43a90889SApple OSS Distributions void ndflush(struct clist *q, int cc); 282*43a90889SApple OSS Distributions int ndqb(struct clist *q, int flag); 283*43a90889SApple OSS Distributions u_char *firstc(struct clist *clp, int *c); 284*43a90889SApple OSS Distributions u_char *nextc(struct clist *q, u_char *cp, int *c); 285*43a90889SApple OSS Distributions int putc(int c, struct clist *q); 286*43a90889SApple OSS Distributions int q_to_b(struct clist *q, u_char *cp, int cc); 287*43a90889SApple OSS Distributions int unputc(struct clist *q); 288*43a90889SApple OSS Distributions int clalloc(struct clist *clp, int size, int quot); 289*43a90889SApple OSS Distributions void clfree(struct clist *clp); 290*43a90889SApple OSS Distributions void cinit(void); 291*43a90889SApple OSS Distributions void clrbits(u_char *cp, int off, int len); 292*43a90889SApple OSS Distributions 293*43a90889SApple OSS Distributions #ifdef KERNEL_PRIVATE 294*43a90889SApple OSS Distributions void tty_init(void); 295*43a90889SApple OSS Distributions /* 296*43a90889SApple OSS Distributions * The locked version of this function is used from routines which hold 297*43a90889SApple OSS Distributions * the tty_lock(), such as ttcompat() in tty_compat.c 298*43a90889SApple OSS Distributions */ 299*43a90889SApple OSS Distributions int ttioctl_locked(struct tty *tp, u_long com, caddr_t data, int flag, 300*43a90889SApple OSS Distributions struct proc *p); 301*43a90889SApple OSS Distributions 302*43a90889SApple OSS Distributions int ttcompat(struct tty *tp, u_long com, caddr_t data, int flag, 303*43a90889SApple OSS Distributions struct proc *p); 304*43a90889SApple OSS Distributions #endif /* KERNEL_PRIVATE */ 305*43a90889SApple OSS Distributions 306*43a90889SApple OSS Distributions void tty_lock(struct tty *tp); 307*43a90889SApple OSS Distributions bool tty_trylock(struct tty *tp); 308*43a90889SApple OSS Distributions void tty_unlock(struct tty *tp); 309*43a90889SApple OSS Distributions bool tty_islocked(struct tty *tp); 310*43a90889SApple OSS Distributions 311*43a90889SApple OSS Distributions void termioschars(struct termios *t); 312*43a90889SApple OSS Distributions int tputchar(int c, struct tty *tp); 313*43a90889SApple OSS Distributions int ttioctl(struct tty *tp, u_long com, caddr_t data, int flag, 314*43a90889SApple OSS Distributions struct proc *p); 315*43a90889SApple OSS Distributions int ttread(struct tty *tp, struct uio *uio, int flag); 316*43a90889SApple OSS Distributions int ttyselect(struct tty *tp, int rw, void * wql, struct proc *p); 317*43a90889SApple OSS Distributions int ttselect(dev_t dev, int rw, void * wql, struct proc *p); 318*43a90889SApple OSS Distributions void ttsetwater(struct tty *tp); 319*43a90889SApple OSS Distributions int ttspeedtab(int speed, struct speedtab *table); 320*43a90889SApple OSS Distributions int ttstart(struct tty *tp); 321*43a90889SApple OSS Distributions void ttwakeup(struct tty *tp); 322*43a90889SApple OSS Distributions int ttwrite(struct tty *tp, struct uio *uio, int flag); 323*43a90889SApple OSS Distributions void ttwwakeup(struct tty *tp); 324*43a90889SApple OSS Distributions void ttyblock(struct tty *tp); 325*43a90889SApple OSS Distributions int ttycheckoutq(struct tty *tp, int wait); 326*43a90889SApple OSS Distributions int ttyclose(struct tty *tp); /* LEGACY: avoid using */ 327*43a90889SApple OSS Distributions void ttyflush(struct tty *tp, int rw); 328*43a90889SApple OSS Distributions void ttyinfo(struct tty *tp); 329*43a90889SApple OSS Distributions void ttyinfo_locked(struct tty *tp); 330*43a90889SApple OSS Distributions int ttyinput(int c, struct tty *tp); 331*43a90889SApple OSS Distributions int ttylclose(struct tty *tp, int flag); 332*43a90889SApple OSS Distributions int ttymodem(struct tty *tp, int flag); 333*43a90889SApple OSS Distributions int ttyopen(dev_t device, struct tty *tp); 334*43a90889SApple OSS Distributions int ttysleep(struct tty *tp, 335*43a90889SApple OSS Distributions void *chan, int pri, const char *wmesg, int timeout); 336*43a90889SApple OSS Distributions int ttywait(struct tty *tp); 337*43a90889SApple OSS Distributions struct tty *ttymalloc(void); 338*43a90889SApple OSS Distributions void ttyfree(struct tty *); 339*43a90889SApple OSS Distributions void ttyfree_locked(struct tty *); 340*43a90889SApple OSS Distributions 341*43a90889SApple OSS Distributions #ifdef XNU_KERNEL_PRIVATE 342*43a90889SApple OSS Distributions extern void ttyhold(struct tty *tp); 343*43a90889SApple OSS Distributions 344*43a90889SApple OSS Distributions #define TTY_LOCK_OWNED(tp) LCK_MTX_ASSERT(&tp->t_lock, LCK_MTX_ASSERT_OWNED) 345*43a90889SApple OSS Distributions #define TTY_LOCK_NOTOWNED(tp) LCK_MTX_ASSERT(&tp->t_lock, LCK_MTX_ASSERT_NOTOWNED) 346*43a90889SApple OSS Distributions 347*43a90889SApple OSS Distributions #define PTS_MAJOR 4 348*43a90889SApple OSS Distributions #define PTC_MAJOR 5 349*43a90889SApple OSS Distributions #endif /* defined(XNU_KERNEL_PRIVATE) */ 350*43a90889SApple OSS Distributions 351*43a90889SApple OSS Distributions __END_DECLS 352*43a90889SApple OSS Distributions 353*43a90889SApple OSS Distributions #endif /* KERNEL */ 354*43a90889SApple OSS Distributions 355*43a90889SApple OSS Distributions #endif /* !_SYS_TTY_H_ */ 356