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