xref: /titanic_50/usr/src/uts/common/sys/ptyvar.h (revision b3700b074e637f8c6991b70754c88a2cfffb246b)
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-tty driver data structures.
29  */
30 
31 #ifndef	_SYS_PTYVAR_H
32 #define	_SYS_PTYVAR_H
33 
34 #pragma ident	"%Z%%M%	%I%	%E% SMI"
35 
36 #include <sys/tty.h>
37 
38 #ifdef	__cplusplus
39 extern "C" {
40 #endif
41 
42 struct pty {
43 	int	pt_flags;		/* flag bits */
44 	mblk_t	*pt_stuffqfirst;	/* head of queue for ioctls */
45 	mblk_t	*pt_stuffqlast;		/* tail of queue for ioctls */
46 	int	pt_stuffqlen;		/* number of bytes of queued ioctls */
47 	tty_common_t pt_ttycommon;	/* data common to all tty drivers */
48 	bufcall_id_t pt_wbufcid;	/* id of pending write-side bufcall */
49 	struct proc *pt_selr;		/* proc selecting on controller read */
50 	struct proc *pt_selw;		/* proc selecting on controller write */
51 	struct proc *pt_sele;		/* proc selecting on exception */
52 	dev_t	pt_sdev;		/* XXX dev no for the slave */
53 	struct vnode *pt_vnode;		/* XXX vnode for the slave */
54 	short	pt_pgrp;		/* controller side process group */
55 	uchar_t	pt_send;		/* pending message to controller */
56 	uchar_t	pt_ucntl;		/* pending iocontrol for controller */
57 	kmutex_t ptc_lock;		/* per pty mutex lock */
58 	kcondvar_t pt_cv_flags;		/* condition variable for flag state */
59 	kcondvar_t pt_cv_readq;		/* condition variable for read state */
60 	kcondvar_t pt_cv_writeq;	/* condition variable for write state */
61 };
62 
63 #define	PF_RCOLL	0x00000001	/* > 1 process selecting for read */
64 #define	PF_WCOLL	0x00000002	/* > 1 process selecting for write */
65 #define	PF_ECOLL	0x00000004	/* > 1 process selecting for excep. */
66 #define	PF_NBIO		0x00000008	/* non-blocking I/O on controller */
67 #define	PF_ASYNC	0x00000010	/* asynchronous I/O on controller */
68 #define	PF_WOPEN	0x00000020	/* waiting for open to complete */
69 #define	PF_CARR_ON	0x00000040	/* "carrier" is on (cntlr. is open) */
70 #define	PF_SLAVEGONE	0x00000080	/* slave was open, but is now closed */
71 #define	PF_PKT		0x00000100	/* packet mode */
72 #define	PF_STOPPED	0x00000200	/* user told stopped */
73 #define	PF_REMOTE	0x00000400	/* remote and flow controlled input */
74 #define	PF_NOSTOP	0x00000800	/* slave is doing XON/XOFF */
75 #define	PF_UCNTL	0x00001000	/* user control mode */
76 #define	PF_43UCNTL	0x00002000	/* real 4.3 user control mode */
77 #define	PF_IOCTL	0x00004000	/* ioctl call in progress */
78 #define	PF_WAIT		0x00008000	/* wait in close */
79 #define	PF_READ		0x00010000	/* serialise read */
80 #define	PF_WRITE	0x00020000	/* serialise write */
81 #define	PF_WREAD	0x00040000	/* want to read */
82 #define	PF_WWRITE	0x00080000	/* want to write */
83 
84 /*
85  * M_CTL message types.
86  */
87 #define	MC_NOCANON	0	/* module below saying it will canonicalize */
88 #define	MC_DOCANON	1	/* module below saying it won't canonicalize */
89 #define	MC_CANONQUERY	2	/* module above asking whether module below */
90 				/* canonicalizes */
91 #define	MC_SERVICEIMM	3	/* tell the ZS driver to return input */
92 				/* immediately */
93 #define	MC_SERVICEDEF	4	/* tell the ZS driver it can wait */
94 #define	MC_NOIFLAG	5	/* module below saying don't do i flags */
95 #define	MC_NOOFLAG	6	/* module below saying don't do o flags */
96 #define	MC_NOLFLAG	7	/* module below saying don't do l flags */
97 
98 
99 /*
100  * Thus stuff is from the 4.1 termios.h, but we don't want to
101  * put it in the real system, so we hide it here.
102  */
103 
104 /*
105  * Sun version of winsize.
106  */
107 struct ttysize {
108 	int	ts_lines;		/* number of lines on terminal */
109 	int	ts_cols;		/* number of columns on terminal */
110 };
111 
112 
113 #define	TIOCPKT		_IOW('t', 112, int)	/* pty: set/clear packet mode */
114 #define		TIOCPKT_DATA		0x00	/* data packet */
115 #define		TIOCPKT_FLUSHREAD	0x01	/* flush data not yet written */
116 						/* to controller */
117 #define		TIOCPKT_FLUSHWRITE	0x02	/* flush data read from */
118 						/* controller but not yet */
119 						/* processed */
120 #define		TIOCPKT_STOP		0x04	/* stop output */
121 #define		TIOCPKT_START		0x08	/* start output */
122 #define		TIOCPKT_NOSTOP		0x10	/* no more ^S, ^Q */
123 #define		TIOCPKT_DOSTOP		0x20	/* now do ^S, ^Q */
124 #define		TIOCPKT_IOCTL		0x40	/* "ioctl" packet */
125 
126 #define	TIOCUCNTL	_IOW('t', 102, int)	/* pty: set/clr usr cntl mode */
127 #define	TIOCTCNTL	_IOW('t', 32, int)	/* pty: set/clr intercept */
128 						/* ioctl mode */
129 #define	TIOCISPACE	_IOR('t', 128, int)	/* space left in input queue */
130 #define	TIOCISIZE	_IOR('t', 129, int)	/* size of input queue */
131 
132 #define	TIOCSSIZE	_IOW('t', 37, struct ttysize) /* set tty size */
133 #define	TIOCGSIZE	_IOR('t', 38, struct ttysize) /* get tty size */
134 
135 #ifdef _KERNEL
136 
137 /*
138  * pty_softc, npty, ptcph, and pty_initspace are defined in tty_ptyconf.c
139  */
140 
141 extern int	npty;
142 extern struct	pty *pty_softc;
143 extern struct	pollhead ptcph;
144 extern void	pty_initspace(void);
145 
146 /*
147  * define the Berkeley style naming convention
148  */
149 #define	PTY_BANKS	"pqrstuvwxyz"
150 #define	PTY_DIGITS	"0123456789abcdef"
151 #endif /* _KERNEL */
152 
153 #ifdef	__cplusplus
154 }
155 #endif
156 
157 #endif	/* _SYS_PTYVAR_H */
158