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