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