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