xref: /onnv-gate/usr/src/uts/sun/sys/ttymux.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 (c) 2001 by Sun Microsystems, Inc.
24*0Sstevel@tonic-gate  * All rights reserved.
25*0Sstevel@tonic-gate  */
26*0Sstevel@tonic-gate 
27*0Sstevel@tonic-gate #ifndef	_TTYMUX_H
28*0Sstevel@tonic-gate #define	_TTYMUX_H
29*0Sstevel@tonic-gate 
30*0Sstevel@tonic-gate #pragma ident	"%Z%%M%	%I%	%E% SMI"
31*0Sstevel@tonic-gate 
32*0Sstevel@tonic-gate #include <sys/obpdefs.h>
33*0Sstevel@tonic-gate #include <sys/tty.h>
34*0Sstevel@tonic-gate #include <sys/ttymuxuser.h>
35*0Sstevel@tonic-gate 
36*0Sstevel@tonic-gate #ifdef	__cplusplus
37*0Sstevel@tonic-gate extern "C" {
38*0Sstevel@tonic-gate #endif
39*0Sstevel@tonic-gate 
40*0Sstevel@tonic-gate #define	SM_MAX_ABSLEN	24	/* maximum length for the s/w abort sequence */
41*0Sstevel@tonic-gate #define	SM_MIN_ABSLEN	2
42*0Sstevel@tonic-gate 
43*0Sstevel@tonic-gate #define	SM_COPYIN	0x1
44*0Sstevel@tonic-gate #define	SM_COPYOUT	0x2
45*0Sstevel@tonic-gate 
46*0Sstevel@tonic-gate typedef
47*0Sstevel@tonic-gate struct sm_iocdata {
48*0Sstevel@tonic-gate 	int sm_iocid;
49*0Sstevel@tonic-gate 	int sm_nacks;	/* number of responses expected */
50*0Sstevel@tonic-gate 	int sm_ackcnt;	/* number of ACKs received */
51*0Sstevel@tonic-gate 	int sm_nakcnt;	/* number of NAKs received */
52*0Sstevel@tonic-gate 	int sm_acnt;	/* number of responses received */
53*0Sstevel@tonic-gate 	int sm_acked;	/* has the message been acked (only one of them) */
54*0Sstevel@tonic-gate 	int sm_policy;	/* which policy is used for acknowleding this ioctl */
55*0Sstevel@tonic-gate 	uint_t sm_flags;
56*0Sstevel@tonic-gate 			/* indicates when copyin/out has been sent upstream */
57*0Sstevel@tonic-gate 	ulong_t  sm_timeval;
58*0Sstevel@tonic-gate } sm_iocdata_t;
59*0Sstevel@tonic-gate 
60*0Sstevel@tonic-gate /*
61*0Sstevel@tonic-gate  * Each minor (refered to as a logical device) created by the multiplexor
62*0Sstevel@tonic-gate  * maps onto multiple real devices.
63*0Sstevel@tonic-gate  * I/O on a logical device is duplicated across multiple real devices.
64*0Sstevel@tonic-gate  * i.e. input from any of the real devices (identified by lqs) is funneled
65*0Sstevel@tonic-gate  * through the queue identified in the ttycommon field of a logical unit.
66*0Sstevel@tonic-gate  * output arriving on the queue identified in the ttycommon field of a logical
67*0Sstevel@tonic-gate  * unit is distributed to all real devices identified by lqs.
68*0Sstevel@tonic-gate  *
69*0Sstevel@tonic-gate  * When a logical unit is open there is a unique queue upstream (identified
70*0Sstevel@tonic-gate  * by ttycommon).
71*0Sstevel@tonic-gate  * When a real unit is open there is a unique lower queue to the h/w driver
72*0Sstevel@tonic-gate  * (identified by ttycommon).
73*0Sstevel@tonic-gate  *
74*0Sstevel@tonic-gate  * If the control lines on RS232 port for a physical unit are unknown and
75*0Sstevel@tonic-gate  * a request for their status has been issued then flags contains the bits
76*0Sstevel@tonic-gate  * TIOCM_PEND and tiocmgetid contains the id of the M_IOCTL streams	message
77*0Sstevel@tonic-gate  * sent down the write queue to obtain the current status (placed in mbits).
78*0Sstevel@tonic-gate  */
79*0Sstevel@tonic-gate typedef
80*0Sstevel@tonic-gate struct sm_uqi {
81*0Sstevel@tonic-gate 	int		sm_lunit;	/* logical unit */
82*0Sstevel@tonic-gate 	int		sm_protocol;	/* in use for this protocol */
83*0Sstevel@tonic-gate 	uint_t		sm_flags;	/* flags */
84*0Sstevel@tonic-gate 	uint_t		sm_mbits;	/* consolidated status of modem lines */
85*0Sstevel@tonic-gate 	tcflag_t	sm_cmask;	/* ignore these control bits */
86*0Sstevel@tonic-gate 	uint_t		sm_policy;	/* ioctl response policy */
87*0Sstevel@tonic-gate 	struct sm_lqi	*sm_lqs;	/* lower queues mapped to this lunit */
88*0Sstevel@tonic-gate 	int		sm_nlqs;
89*0Sstevel@tonic-gate 	kmutex_t	sm_umutex[1];	/* protects uflags */
90*0Sstevel@tonic-gate 	kcondvar_t	sm_ucv[1];	/* waiting for uflags to change */
91*0Sstevel@tonic-gate 	bufcall_id_t	sm_ttybid;	/* ttycommon bufcall */
92*0Sstevel@tonic-gate 	dev_t		sm_dev;		/* currently attached device */
93*0Sstevel@tonic-gate 	int		sm_nwaiters;	/* no. of threads waiting for carrier */
94*0Sstevel@tonic-gate 	queue_t		*sm_waitq;	/* identity of blocked queue */
95*0Sstevel@tonic-gate 	tty_common_t	sm_ttycommon[1];
96*0Sstevel@tonic-gate 					/* queue common data when is open */
97*0Sstevel@tonic-gate 	sm_iocdata_t	sm_siocdata;	/* active ioctl */
98*0Sstevel@tonic-gate 	sm_iocdata_t	sm_piocdata;	/* active private ioctl */
99*0Sstevel@tonic-gate } sm_uqi_t;
100*0Sstevel@tonic-gate 
101*0Sstevel@tonic-gate typedef
102*0Sstevel@tonic-gate struct sm_lqi {
103*0Sstevel@tonic-gate 	struct sm_lqi	*sm_nlqi;	/* chain units together into lists */
104*0Sstevel@tonic-gate 	sm_uqi_t	*sm_uqi;	/* this lunit and uqi are associated */
105*0Sstevel@tonic-gate 	int		sm_linkid;	/* mux id for the link */
106*0Sstevel@tonic-gate 	uint64_t	sm_tag;		/* tag for the link */
107*0Sstevel@tonic-gate 	uint_t		sm_flags;		/* flags */
108*0Sstevel@tonic-gate 	uint_t		sm_uqflags;	/* written by an upper queue */
109*0Sstevel@tonic-gate 	io_mode_t	sm_ioflag;	/* input and/or output stream */
110*0Sstevel@tonic-gate 	int		sm_ctrla_abort_on;
111*0Sstevel@tonic-gate 	int		sm_break_abort_on;
112*0Sstevel@tonic-gate 	uint_t		sm_mbits;	/* status of the modem control lines */
113*0Sstevel@tonic-gate 	tcflag_t	sm_cmask;	/* ignore these control bits */
114*0Sstevel@tonic-gate 	mblk_t		*sm_mp;		/* mblk for next write */
115*0Sstevel@tonic-gate 	bufcall_id_t	sm_bid;		/* bufcall id */
116*0Sstevel@tonic-gate 	bufcall_id_t	sm_ttybid;	/* ttymodes changed bufcall */
117*0Sstevel@tonic-gate 	kmutex_t	sm_umutex[1];	/* protects open code */
118*0Sstevel@tonic-gate 	kcondvar_t	sm_ucv[1];
119*0Sstevel@tonic-gate 	dev_info_t	*sm_dip;
120*0Sstevel@tonic-gate 	dev_t		sm_dev;
121*0Sstevel@tonic-gate 	int		sm_unit;
122*0Sstevel@tonic-gate 	unsigned char	*sm_hadkadbchar;
123*0Sstevel@tonic-gate 	char		*sm_nachar;
124*0Sstevel@tonic-gate 	int		sm_piocid;
125*0Sstevel@tonic-gate 	tty_common_t	sm_ttycommon[1];
126*0Sstevel@tonic-gate 					/* queue common data when open */
127*0Sstevel@tonic-gate 	char		sm_path[MAXPATHLEN];
128*0Sstevel@tonic-gate } sm_lqi_t;
129*0Sstevel@tonic-gate 
130*0Sstevel@tonic-gate /*
131*0Sstevel@tonic-gate  * This structure maintains the state of the console.
132*0Sstevel@tonic-gate  */
133*0Sstevel@tonic-gate typedef struct console {
134*0Sstevel@tonic-gate 	dev_t		sm_dev;		/* the minor node of a console */
135*0Sstevel@tonic-gate 	int		sm_muxid;	/* STREAM's link identifier */
136*0Sstevel@tonic-gate 	io_mode_t	sm_mode;	/* I/O mode */
137*0Sstevel@tonic-gate 	boolean_t	sm_obp_con;	/* is it an OBP console */
138*0Sstevel@tonic-gate 	ihandle_t	sm_i_ihdl;	/* ihandle of the OBP input device */
139*0Sstevel@tonic-gate 	ihandle_t	sm_o_ihdl;	/* ihandle of the OBP output device */
140*0Sstevel@tonic-gate 	char		*sm_path;	/* device tree device path */
141*0Sstevel@tonic-gate 	char		*sm_alias;	/* device path alias */
142*0Sstevel@tonic-gate } sm_console_t;
143*0Sstevel@tonic-gate 
144*0Sstevel@tonic-gate /*
145*0Sstevel@tonic-gate  * This structure contains the information for an open device.
146*0Sstevel@tonic-gate  * If an instance of it exists it is available as a named pointer:
147*0Sstevel@tonic-gate  */
148*0Sstevel@tonic-gate #define	TTYMUXPTR "ttymuxconfig"
149*0Sstevel@tonic-gate 
150*0Sstevel@tonic-gate typedef struct mux_state {
151*0Sstevel@tonic-gate 
152*0Sstevel@tonic-gate 	/* protects ttymux configuration */
153*0Sstevel@tonic-gate 	kmutex_t	sm_cons_mutex;
154*0Sstevel@tonic-gate 
155*0Sstevel@tonic-gate 	/* Information about the standard I/O devices */
156*0Sstevel@tonic-gate 	sm_console_t	sm_cons_stdin;
157*0Sstevel@tonic-gate 	sm_console_t	sm_cons_stdout;
158*0Sstevel@tonic-gate 
159*0Sstevel@tonic-gate 	/* List of multiplexed serial consoles */
160*0Sstevel@tonic-gate 	uint_t		sm_cons_cnt;
161*0Sstevel@tonic-gate 	char		*sm_ialias;
162*0Sstevel@tonic-gate 	char		*sm_oalias;
163*0Sstevel@tonic-gate 	sm_console_t	sm_cons_links[TTYMUX_MAX_LINKS];
164*0Sstevel@tonic-gate 
165*0Sstevel@tonic-gate } sm_mux_state_t;
166*0Sstevel@tonic-gate 
167*0Sstevel@tonic-gate /*
168*0Sstevel@tonic-gate  * Driver instance private information.
169*0Sstevel@tonic-gate  */
170*0Sstevel@tonic-gate typedef
171*0Sstevel@tonic-gate struct sm_ss
172*0Sstevel@tonic-gate {
173*0Sstevel@tonic-gate 	dev_info_t	*sm_dip;	/* device tree information */
174*0Sstevel@tonic-gate 	uint_t		sm_trflag;	/* debug and information levels */
175*0Sstevel@tonic-gate 	sm_uqi_t	*sm_lconsole;	/* the current logical console */
176*0Sstevel@tonic-gate 	sm_mux_state_t	*sm_ms;		/* state associated with a console */
177*0Sstevel@tonic-gate 
178*0Sstevel@tonic-gate 	sm_lqi_t	*sm_lqs;
179*0Sstevel@tonic-gate 	sm_uqi_t	*sm_uqs;
180*0Sstevel@tonic-gate 	uint_t		sm_break_abort_on;
181*0Sstevel@tonic-gate 	uint_t		sm_ctrla_abort_on;
182*0Sstevel@tonic-gate 
183*0Sstevel@tonic-gate 	int		sm_min_redundancy;
184*0Sstevel@tonic-gate 	char		sm_abs[SM_MAX_ABSLEN];
185*0Sstevel@tonic-gate 
186*0Sstevel@tonic-gate } sm_ss_t;
187*0Sstevel@tonic-gate 
188*0Sstevel@tonic-gate #ifdef	__cplusplus
189*0Sstevel@tonic-gate }
190*0Sstevel@tonic-gate #endif
191*0Sstevel@tonic-gate 
192*0Sstevel@tonic-gate #endif	/* _TTYMUX_H */
193