xref: /illumos-gate/usr/src/uts/common/xen/io/xencons.h (revision 843e1988)
1*843e1988Sjohnlev /*
2*843e1988Sjohnlev  * CDDL HEADER START
3*843e1988Sjohnlev  *
4*843e1988Sjohnlev  * The contents of this file are subject to the terms of the
5*843e1988Sjohnlev  * Common Development and Distribution License (the "License").
6*843e1988Sjohnlev  * You may not use this file except in compliance with the License.
7*843e1988Sjohnlev  *
8*843e1988Sjohnlev  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*843e1988Sjohnlev  * or http://www.opensolaris.org/os/licensing.
10*843e1988Sjohnlev  * See the License for the specific language governing permissions
11*843e1988Sjohnlev  * and limitations under the License.
12*843e1988Sjohnlev  *
13*843e1988Sjohnlev  * When distributing Covered Code, include this CDDL HEADER in each
14*843e1988Sjohnlev  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*843e1988Sjohnlev  * If applicable, add the following below this CDDL HEADER, with the
16*843e1988Sjohnlev  * fields enclosed by brackets "[]" replaced with your own identifying
17*843e1988Sjohnlev  * information: Portions Copyright [yyyy] [name of copyright owner]
18*843e1988Sjohnlev  *
19*843e1988Sjohnlev  * CDDL HEADER END
20*843e1988Sjohnlev  */
21*843e1988Sjohnlev 
22*843e1988Sjohnlev /*	Copyright (c) 1990, 1991 UNIX System Laboratories, Inc.	*/
23*843e1988Sjohnlev /*	Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T	*/
24*843e1988Sjohnlev /*	  All Rights Reserved 	*/
25*843e1988Sjohnlev 
26*843e1988Sjohnlev /*
27*843e1988Sjohnlev  * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
28*843e1988Sjohnlev  * Use is subject to license terms.
29*843e1988Sjohnlev  */
30*843e1988Sjohnlev 
31*843e1988Sjohnlev #ifndef	_SYS_XENCONS_H
32*843e1988Sjohnlev #define	_SYS_XENCONS_H
33*843e1988Sjohnlev 
34*843e1988Sjohnlev #pragma ident	"%Z%%M%	%I%	%E% SMI"
35*843e1988Sjohnlev 
36*843e1988Sjohnlev #ifdef __cplusplus
37*843e1988Sjohnlev extern "C" {
38*843e1988Sjohnlev #endif
39*843e1988Sjohnlev 
40*843e1988Sjohnlev #include <sys/tty.h>
41*843e1988Sjohnlev #include <sys/ksynch.h>
42*843e1988Sjohnlev #include <sys/dditypes.h>
43*843e1988Sjohnlev #include <xen/public/io/console.h>
44*843e1988Sjohnlev 
45*843e1988Sjohnlev 
46*843e1988Sjohnlev /*
47*843e1988Sjohnlev  * Xencons tracing macros.  These are a similar to some macros in sys/vtrace.h.
48*843e1988Sjohnlev  *
49*843e1988Sjohnlev  * XXX - Needs review:  would it be better to use the macros in sys/vtrace.h ?
50*843e1988Sjohnlev  */
51*843e1988Sjohnlev #ifdef DEBUG
52*843e1988Sjohnlev #define	DEBUGWARN0(fac, format) \
53*843e1988Sjohnlev 	if (debug & (fac)) \
54*843e1988Sjohnlev 		cmn_err(CE_WARN, format)
55*843e1988Sjohnlev #define	DEBUGNOTE0(fac, format) \
56*843e1988Sjohnlev 	if (debug & (fac)) \
57*843e1988Sjohnlev 		cmn_err(CE_NOTE, format)
58*843e1988Sjohnlev #define	DEBUGNOTE1(fac, format, arg1) \
59*843e1988Sjohnlev 	if (debug & (fac)) \
60*843e1988Sjohnlev 		cmn_err(CE_NOTE, format, arg1)
61*843e1988Sjohnlev #define	DEBUGNOTE2(fac, format, arg1, arg2) \
62*843e1988Sjohnlev 	if (debug & (fac)) \
63*843e1988Sjohnlev 		cmn_err(CE_NOTE, format, arg1, arg2)
64*843e1988Sjohnlev #define	DEBUGNOTE3(fac, format, arg1, arg2, arg3) \
65*843e1988Sjohnlev 	if (debug & (fac)) \
66*843e1988Sjohnlev 		cmn_err(CE_NOTE, format, arg1, arg2, arg3)
67*843e1988Sjohnlev #define	DEBUGCONT0(fac, format) \
68*843e1988Sjohnlev 	if (debug & (fac)) \
69*843e1988Sjohnlev 		cmn_err(CE_CONT, format)
70*843e1988Sjohnlev #define	DEBUGCONT1(fac, format, arg1) \
71*843e1988Sjohnlev 	if (debug & (fac)) \
72*843e1988Sjohnlev 		cmn_err(CE_CONT, format, arg1)
73*843e1988Sjohnlev #define	DEBUGCONT2(fac, format, arg1, arg2) \
74*843e1988Sjohnlev 	if (debug & (fac)) \
75*843e1988Sjohnlev 		cmn_err(CE_CONT, format, arg1, arg2)
76*843e1988Sjohnlev #define	DEBUGCONT3(fac, format, arg1, arg2, arg3) \
77*843e1988Sjohnlev 	if (debug & (fac)) \
78*843e1988Sjohnlev 		cmn_err(CE_CONT, format, arg1, arg2, arg3)
79*843e1988Sjohnlev #define	DEBUGCONT4(fac, format, arg1, arg2, arg3, arg4) \
80*843e1988Sjohnlev 	if (debug & (fac)) \
81*843e1988Sjohnlev 		cmn_err(CE_CONT, format, arg1, arg2, arg3, arg4)
82*843e1988Sjohnlev #define	DEBUGCONT10(fac, format, \
83*843e1988Sjohnlev 	arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10) \
84*843e1988Sjohnlev 	if (debug & (fac)) \
85*843e1988Sjohnlev 		cmn_err(CE_CONT, format, \
86*843e1988Sjohnlev 		arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10)
87*843e1988Sjohnlev #else
88*843e1988Sjohnlev #define	DEBUGWARN0(fac, format)
89*843e1988Sjohnlev #define	DEBUGNOTE0(fac, format)
90*843e1988Sjohnlev #define	DEBUGNOTE1(fac, format, arg1)
91*843e1988Sjohnlev #define	DEBUGNOTE2(fac, format, arg1, arg2)
92*843e1988Sjohnlev #define	DEBUGNOTE3(fac, format, arg1, arg2, arg3)
93*843e1988Sjohnlev #define	DEBUGCONT0(fac, format)
94*843e1988Sjohnlev #define	DEBUGCONT1(fac, format, arg1)
95*843e1988Sjohnlev #define	DEBUGCONT2(fac, format, arg1, arg2)
96*843e1988Sjohnlev #define	DEBUGCONT3(fac, format, arg1, arg2, arg3)
97*843e1988Sjohnlev #define	DEBUGCONT4(fac, format, arg1, arg2, arg3, arg4)
98*843e1988Sjohnlev #define	DEBUGCONT10(fac, format, \
99*843e1988Sjohnlev 	arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8, arg9, arg10)
100*843e1988Sjohnlev #endif
101*843e1988Sjohnlev 
102*843e1988Sjohnlev /* enum value for sw and hw flow control action */
103*843e1988Sjohnlev typedef enum {
104*843e1988Sjohnlev 	FLOW_CHECK,
105*843e1988Sjohnlev 	FLOW_STOP,
106*843e1988Sjohnlev 	FLOW_START
107*843e1988Sjohnlev } async_flowc_action;
108*843e1988Sjohnlev 
109*843e1988Sjohnlev #define	async_stopc	async_ttycommon.t_stopc
110*843e1988Sjohnlev #define	async_startc	async_ttycommon.t_startc
111*843e1988Sjohnlev 
112*843e1988Sjohnlev /*
113*843e1988Sjohnlev  * Console instance data.
114*843e1988Sjohnlev  * Each of the fields in this structure is required to be protected by a
115*843e1988Sjohnlev  * mutex lock at the highest priority at which it can be altered.
116*843e1988Sjohnlev  */
117*843e1988Sjohnlev 
118*843e1988Sjohnlev struct xencons {
119*843e1988Sjohnlev 	int		flags;	/* random flags  */
120*843e1988Sjohnlev 	struct asyncline *priv;	/* protocol private data -- asyncline */
121*843e1988Sjohnlev 	dev_info_t	*dip;	/* dev_info */
122*843e1988Sjohnlev 	int		unit;	/* which port */
123*843e1988Sjohnlev 	kmutex_t	excl;	/* adaptive mutex */
124*843e1988Sjohnlev 	kcondvar_t	excl_cv;	/* condition variable */
125*843e1988Sjohnlev 	struct cons_polledio polledio;	/* polled I/O functions */
126*843e1988Sjohnlev 	unsigned char	pollbuf[60];	/* polled I/O data */
127*843e1988Sjohnlev 	int		polldix;	/* polled data buffer index */
128*843e1988Sjohnlev 	int		polllen;	/* polled data buffer length */
129*843e1988Sjohnlev 	volatile struct xencons_interface *ifp;	/* console ring buffers */
130*843e1988Sjohnlev 	int		console_irq;	/* dom0 console interrupt */
131*843e1988Sjohnlev 	int		evtchn;		/* console event channel */
132*843e1988Sjohnlev };
133*843e1988Sjohnlev 
134*843e1988Sjohnlev /*
135*843e1988Sjohnlev  * Asychronous protocol private data structure for ASY.
136*843e1988Sjohnlev  * Each of the fields in the structure is required to be protected by
137*843e1988Sjohnlev  * the lower priority lock except the fields that are set only at
138*843e1988Sjohnlev  * base level but cleared (with out lock) at interrupt level.
139*843e1988Sjohnlev  */
140*843e1988Sjohnlev 
141*843e1988Sjohnlev struct asyncline {
142*843e1988Sjohnlev 	int		async_flags;	/* random flags */
143*843e1988Sjohnlev 	kcondvar_t	async_flags_cv; /* condition variable for flags */
144*843e1988Sjohnlev 	dev_t		async_dev;	/* device major/minor numbers */
145*843e1988Sjohnlev 	mblk_t		*async_xmitblk;	/* transmit: active msg block */
146*843e1988Sjohnlev 	struct xencons	*async_common;	/* device common data */
147*843e1988Sjohnlev 	tty_common_t 	async_ttycommon; /* tty driver common data */
148*843e1988Sjohnlev 	bufcall_id_t	async_wbufcid;	/* id for pending write-side bufcall */
149*843e1988Sjohnlev 	timeout_id_t	async_polltid;	/* softint poll timeout id */
150*843e1988Sjohnlev 	timeout_id_t    async_dtrtid;   /* delaying DTR turn on */
151*843e1988Sjohnlev 	timeout_id_t    async_utbrktid; /* hold minimum untimed break time id */
152*843e1988Sjohnlev 
153*843e1988Sjohnlev 	/*
154*843e1988Sjohnlev 	 * The following fields are protected by the excl_hi lock.
155*843e1988Sjohnlev 	 * Some, such as async_flowc, are set only at the base level and
156*843e1988Sjohnlev 	 * cleared (without the lock) only by the interrupt level.
157*843e1988Sjohnlev 	 */
158*843e1988Sjohnlev 	uchar_t		*async_optr;	/* output pointer */
159*843e1988Sjohnlev 	int		async_ocnt;	/* output count */
160*843e1988Sjohnlev 	ushort_t	async_rput;	/* producing pointer for input */
161*843e1988Sjohnlev 	ushort_t	async_rget;	/* consuming pointer for input */
162*843e1988Sjohnlev 	int		async_inflow_source; /* input flow control type */
163*843e1988Sjohnlev 
164*843e1988Sjohnlev 	union {
165*843e1988Sjohnlev 		struct {
166*843e1988Sjohnlev 			uchar_t _hw;	/* overrun (hw) */
167*843e1988Sjohnlev 			uchar_t _sw;	/* overrun (sw) */
168*843e1988Sjohnlev 		} _a;
169*843e1988Sjohnlev 		ushort_t uover_overrun;
170*843e1988Sjohnlev 	} async_uover;
171*843e1988Sjohnlev #define	async_overrun		async_uover._a.uover_overrun
172*843e1988Sjohnlev #define	async_hw_overrun	async_uover._a._hw
173*843e1988Sjohnlev #define	async_sw_overrun	async_uover._a._sw
174*843e1988Sjohnlev 	short		async_ext;	/* modem status change count */
175*843e1988Sjohnlev 	short		async_work;	/* work to do flag */
176*843e1988Sjohnlev };
177*843e1988Sjohnlev 
178*843e1988Sjohnlev /* definitions for async_flags field */
179*843e1988Sjohnlev #define	ASYNC_EXCL_OPEN	 0x10000000	/* exclusive open */
180*843e1988Sjohnlev #define	ASYNC_WOPEN	 0x00000001	/* waiting for open to complete */
181*843e1988Sjohnlev #define	ASYNC_ISOPEN	 0x00000002	/* open is complete */
182*843e1988Sjohnlev #define	ASYNC_STOPPED	 0x00000010	/* output is stopped */
183*843e1988Sjohnlev #define	ASYNC_PROGRESS	 0x00001000	/* made progress on output effort */
184*843e1988Sjohnlev #define	ASYNC_CLOSING	 0x00002000	/* processing close on stream */
185*843e1988Sjohnlev #define	ASYNC_SW_IN_FLOW 0x00020000	/* sw input flow control in effect */
186*843e1988Sjohnlev #define	ASYNC_SW_OUT_FLW 0x00040000	/* sw output flow control in effect */
187*843e1988Sjohnlev #define	ASYNC_SW_IN_NEEDED 0x00080000	/* sw input flow control char is */
188*843e1988Sjohnlev 					/* needed to be sent */
189*843e1988Sjohnlev #define	ASYNC_OUT_FLW_RESUME 0x00100000 /* output need to be resumed */
190*843e1988Sjohnlev 					/* because of transition of flow */
191*843e1988Sjohnlev 					/* control from stop to start */
192*843e1988Sjohnlev 
193*843e1988Sjohnlev 
194*843e1988Sjohnlev /* definitions for asy_flags field */
195*843e1988Sjohnlev #define	ASY_CONSOLE	0x00000080
196*843e1988Sjohnlev 
197*843e1988Sjohnlev /* definitions for async_inflow_source field in struct asyncline */
198*843e1988Sjohnlev #define	IN_FLOW_NULL	0x00000000
199*843e1988Sjohnlev #define	IN_FLOW_STREAMS	0x00000002
200*843e1988Sjohnlev #define	IN_FLOW_USER	0x00000004
201*843e1988Sjohnlev 
202*843e1988Sjohnlev #define	XENCONS_BURST	128	/* burst size for console writes */
203*843e1988Sjohnlev 
204*843e1988Sjohnlev #ifdef __cplusplus
205*843e1988Sjohnlev }
206*843e1988Sjohnlev #endif
207*843e1988Sjohnlev 
208*843e1988Sjohnlev #endif	/* _SYS_XENCONS_H */
209