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