xref: /illumos-gate/usr/src/uts/common/sys/ptyvar.h (revision 1fa2a664)
1 /*
2  * CDDL HEADER START
3  *
4  * The contents of this file are subject to the terms of the
5  * Common Development and Distribution License, Version 1.0 only
6  * (the "License").  You may not use this file except in compliance
7  * with the License.
8  *
9  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10  * or http://www.opensolaris.org/os/licensing.
11  * See the License for the specific language governing permissions
12  * and limitations under the License.
13  *
14  * When distributing Covered Code, include this CDDL HEADER in each
15  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16  * If applicable, add the following below this CDDL HEADER, with the
17  * fields enclosed by brackets "[]" replaced with your own identifying
18  * information: Portions Copyright [yyyy] [name of copyright owner]
19  *
20  * CDDL HEADER END
21  */
22 /*
23  * Copyright 1989-2003 Sun Microsystems, Inc.  All rights reserved.
24  * Use is subject to license terms.
25  */
26 
27 /*
28  * Pseudo-terminal driver data structures.
29  */
30 
31 #ifndef	_SYS_PTYVAR_H
32 #define	_SYS_PTYVAR_H
33 
34 #include <sys/tty.h>
35 
36 #ifdef	__cplusplus
37 extern "C" {
38 #endif
39 
40 struct pty {
41 	int	pt_flags;		/* flag bits */
42 	mblk_t	*pt_stuffqfirst;	/* head of queue for ioctls */
43 	mblk_t	*pt_stuffqlast;		/* tail of queue for ioctls */
44 	int	pt_stuffqlen;		/* number of bytes of queued ioctls */
45 	tty_common_t pt_ttycommon;	/* data common to all tty drivers */
46 	bufcall_id_t pt_wbufcid;	/* id of pending write-side bufcall */
47 	struct proc *pt_selr;		/* proc selecting on controller read */
48 	struct proc *pt_selw;		/* proc selecting on controller write */
49 	struct proc *pt_sele;		/* proc selecting on exception */
50 	dev_t	pt_sdev;		/* XXX dev no for the subsidiary */
51 	struct vnode *pt_vnode;		/* XXX vnode for the subsidiary */
52 	short	pt_pgrp;		/* controller side process group */
53 	uchar_t	pt_send;		/* pending message to controller */
54 	uchar_t	pt_ucntl;		/* pending iocontrol for controller */
55 	kmutex_t ptc_lock;		/* per pty mutex lock */
56 	kcondvar_t pt_cv_flags;		/* condition variable for flag state */
57 	kcondvar_t pt_cv_readq;		/* condition variable for read state */
58 	kcondvar_t pt_cv_writeq;	/* condition variable for write state */
59 };
60 
61 #define	PF_RCOLL	0x00000001	/* > 1 process selecting for read */
62 #define	PF_WCOLL	0x00000002	/* > 1 process selecting for write */
63 #define	PF_ECOLL	0x00000004	/* > 1 process selecting for excep. */
64 #define	PF_NBIO		0x00000008	/* non-blocking I/O on controller */
65 #define	PF_ASYNC	0x00000010	/* asynchronous I/O on controller */
66 #define	PF_WOPEN	0x00000020	/* waiting for open to complete */
67 #define	PF_CARR_ON	0x00000040	/* "carrier" is on (cntlr. is open) */
68 #define	PF_SUBSIDGONE	0x00000080	/* subsidiary was open, now closed */
69 #define	PF_PKT		0x00000100	/* packet mode */
70 #define	PF_STOPPED	0x00000200	/* user told stopped */
71 #define	PF_REMOTE	0x00000400	/* remote and flow controlled input */
72 #define	PF_NOSTOP	0x00000800	/* subsidiary is doing XON/XOFF */
73 #define	PF_UCNTL	0x00001000	/* user control mode */
74 #define	PF_43UCNTL	0x00002000	/* real 4.3 user control mode */
75 #define	PF_IOCTL	0x00004000	/* ioctl call in progress */
76 #define	PF_WAIT		0x00008000	/* wait in close */
77 #define	PF_READ		0x00010000	/* serialise read */
78 #define	PF_WRITE	0x00020000	/* serialise write */
79 #define	PF_WREAD	0x00040000	/* want to read */
80 #define	PF_WWRITE	0x00080000	/* want to write */
81 
82 /*
83  * M_CTL message types.
84  */
85 #define	MC_NOCANON	0	/* module below saying it will canonicalize */
86 #define	MC_DOCANON	1	/* module below saying it won't canonicalize */
87 #define	MC_CANONQUERY	2	/* module above asking whether module below */
88 				/* canonicalizes */
89 #define	MC_SERVICEIMM	3	/* tell the ZS driver to return input */
90 				/* immediately */
91 #define	MC_SERVICEDEF	4	/* tell the ZS driver it can wait */
92 #define	MC_NOIFLAG	5	/* module below saying don't do i flags */
93 #define	MC_NOOFLAG	6	/* module below saying don't do o flags */
94 #define	MC_NOLFLAG	7	/* module below saying don't do l flags */
95 
96 
97 /*
98  * Thus stuff is from the 4.1 termios.h, but we don't want to
99  * put it in the real system, so we hide it here.
100  */
101 
102 /*
103  * Sun version of winsize.
104  */
105 struct ttysize {
106 	int	ts_lines;		/* number of lines on terminal */
107 	int	ts_cols;		/* number of columns on terminal */
108 };
109 
110 
111 #define	TIOCPKT		_IOW('t', 112, int)	/* pty: set/clear packet mode */
112 #define		TIOCPKT_DATA		0x00	/* data packet */
113 #define		TIOCPKT_FLUSHREAD	0x01	/* flush data not yet written */
114 						/* to controller */
115 #define		TIOCPKT_FLUSHWRITE	0x02	/* flush data read from */
116 						/* controller but not yet */
117 						/* processed */
118 #define		TIOCPKT_STOP		0x04	/* stop output */
119 #define		TIOCPKT_START		0x08	/* start output */
120 #define		TIOCPKT_NOSTOP		0x10	/* no more ^S, ^Q */
121 #define		TIOCPKT_DOSTOP		0x20	/* now do ^S, ^Q */
122 #define		TIOCPKT_IOCTL		0x40	/* "ioctl" packet */
123 
124 #define	TIOCUCNTL	_IOW('t', 102, int)	/* pty: set/clr usr cntl mode */
125 #define	TIOCTCNTL	_IOW('t', 32, int)	/* pty: set/clr intercept */
126 						/* ioctl mode */
127 #define	TIOCISPACE	_IOR('t', 128, int)	/* space left in input queue */
128 #define	TIOCISIZE	_IOR('t', 129, int)	/* size of input queue */
129 
130 #define	TIOCSSIZE	_IOW('t', 37, struct ttysize) /* set tty size */
131 #define	TIOCGSIZE	_IOR('t', 38, struct ttysize) /* get tty size */
132 
133 #ifdef _KERNEL
134 
135 /*
136  * pty_softc, npty, ptcph, and pty_initspace are defined in tty_ptyconf.c
137  */
138 
139 extern int	npty;
140 extern struct	pty *pty_softc;
141 extern struct	pollhead ptcph;
142 extern void	pty_initspace(void);
143 
144 /*
145  * define the Berkeley style naming convention
146  */
147 #define	PTY_BANKS	"pqrstuvwxyz"
148 #define	PTY_DIGITS	"0123456789abcdef"
149 #endif /* _KERNEL */
150 
151 #ifdef	__cplusplus
152 }
153 #endif
154 
155 #endif	/* _SYS_PTYVAR_H */
156