xref: /onnv-gate/usr/src/uts/common/sys/vt_impl.h (revision 7688:2757e6e1bb2a)
1*7688SAaron.Zang@Sun.COM /*
2*7688SAaron.Zang@Sun.COM  * CDDL HEADER START
3*7688SAaron.Zang@Sun.COM  *
4*7688SAaron.Zang@Sun.COM  * The contents of this file are subject to the terms of the
5*7688SAaron.Zang@Sun.COM  * Common Development and Distribution License (the "License").
6*7688SAaron.Zang@Sun.COM  * You may not use this file except in compliance with the License.
7*7688SAaron.Zang@Sun.COM  *
8*7688SAaron.Zang@Sun.COM  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9*7688SAaron.Zang@Sun.COM  * or http://www.opensolaris.org/os/licensing.
10*7688SAaron.Zang@Sun.COM  * See the License for the specific language governing permissions
11*7688SAaron.Zang@Sun.COM  * and limitations under the License.
12*7688SAaron.Zang@Sun.COM  *
13*7688SAaron.Zang@Sun.COM  * When distributing Covered Code, include this CDDL HEADER in each
14*7688SAaron.Zang@Sun.COM  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15*7688SAaron.Zang@Sun.COM  * If applicable, add the following below this CDDL HEADER, with the
16*7688SAaron.Zang@Sun.COM  * fields enclosed by brackets "[]" replaced with your own identifying
17*7688SAaron.Zang@Sun.COM  * information: Portions Copyright [yyyy] [name of copyright owner]
18*7688SAaron.Zang@Sun.COM  *
19*7688SAaron.Zang@Sun.COM  * CDDL HEADER END
20*7688SAaron.Zang@Sun.COM  */
21*7688SAaron.Zang@Sun.COM 
22*7688SAaron.Zang@Sun.COM /*
23*7688SAaron.Zang@Sun.COM  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
24*7688SAaron.Zang@Sun.COM  * Use is subject to license terms.
25*7688SAaron.Zang@Sun.COM  */
26*7688SAaron.Zang@Sun.COM 
27*7688SAaron.Zang@Sun.COM #ifndef _SYS_VT_IMPL_H
28*7688SAaron.Zang@Sun.COM #define	_SYS_VT_IMPL_H
29*7688SAaron.Zang@Sun.COM 
30*7688SAaron.Zang@Sun.COM #ifdef __cplusplus
31*7688SAaron.Zang@Sun.COM extern "C" {
32*7688SAaron.Zang@Sun.COM #endif
33*7688SAaron.Zang@Sun.COM 
34*7688SAaron.Zang@Sun.COM #include <sys/types.h>
35*7688SAaron.Zang@Sun.COM #include <sys/stream.h>
36*7688SAaron.Zang@Sun.COM #include <sys/vt.h>
37*7688SAaron.Zang@Sun.COM #include <sys/kd.h>
38*7688SAaron.Zang@Sun.COM #include <sys/tem.h>
39*7688SAaron.Zang@Sun.COM #include <sys/tty.h>
40*7688SAaron.Zang@Sun.COM #include <sys/cred.h>
41*7688SAaron.Zang@Sun.COM #include <sys/list.h>
42*7688SAaron.Zang@Sun.COM #include <sys/avl.h>
43*7688SAaron.Zang@Sun.COM #include <sys/note.h>
44*7688SAaron.Zang@Sun.COM 
45*7688SAaron.Zang@Sun.COM #define	WCS_INIT	0x00000001	/* tty is init */
46*7688SAaron.Zang@Sun.COM #define	WCS_ISOPEN	0x00000002	/* open is complete */
47*7688SAaron.Zang@Sun.COM #define	WCS_STOPPED	0x00000004	/* output is stopped */
48*7688SAaron.Zang@Sun.COM #define	WCS_DELAY	0x00000008	/* waiting for delay to finish */
49*7688SAaron.Zang@Sun.COM #define	WCS_BUSY	0x00000010	/* waiting for transmission to finish */
50*7688SAaron.Zang@Sun.COM 
51*7688SAaron.Zang@Sun.COM typedef struct vc_waitactive_msg {
52*7688SAaron.Zang@Sun.COM 	list_node_t	wa_list_node;
53*7688SAaron.Zang@Sun.COM 	int	wa_msg_minor;		/* minor number from which msg comes */
54*7688SAaron.Zang@Sun.COM 	int	wa_wait_minor;		/* which node we are waiting for */
55*7688SAaron.Zang@Sun.COM 	mblk_t *wa_mp;
56*7688SAaron.Zang@Sun.COM } vc_waitactive_msg_t;
57*7688SAaron.Zang@Sun.COM 
58*7688SAaron.Zang@Sun.COM /* virtual console soft state associated with each vt */
59*7688SAaron.Zang@Sun.COM typedef struct vc_state {
60*7688SAaron.Zang@Sun.COM 	minor_t	vc_minor;
61*7688SAaron.Zang@Sun.COM 	avl_node_t vc_avl_node;
62*7688SAaron.Zang@Sun.COM 	uchar_t	vc_switch_mode;		/* VT_AUTO or VT_PROCESS */
63*7688SAaron.Zang@Sun.COM 	char	vc_waitv;
64*7688SAaron.Zang@Sun.COM 	int	vc_relsig;
65*7688SAaron.Zang@Sun.COM 	int	vc_acqsig;
66*7688SAaron.Zang@Sun.COM 	pid_t	vc_pid;
67*7688SAaron.Zang@Sun.COM 	minor_t	vc_switchto;
68*7688SAaron.Zang@Sun.COM 	int	vc_flags;
69*7688SAaron.Zang@Sun.COM 
70*7688SAaron.Zang@Sun.COM 	int	vc_dispnum;
71*7688SAaron.Zang@Sun.COM 	int	vc_login;
72*7688SAaron.Zang@Sun.COM 
73*7688SAaron.Zang@Sun.COM 	tem_vt_state_t vc_tem;		/* Terminal emulator state */
74*7688SAaron.Zang@Sun.COM 	tty_common_t vc_ttycommon;	/* data common to all tty drivers */
75*7688SAaron.Zang@Sun.COM 	bufcall_id_t vc_bufcallid;	/* id returned by qbufcall */
76*7688SAaron.Zang@Sun.COM 	timeout_id_t vc_timeoutid;	/* id returned by qtimeout */
77*7688SAaron.Zang@Sun.COM 
78*7688SAaron.Zang@Sun.COM 	queue_t	*vc_wq;			/* write queue */
79*7688SAaron.Zang@Sun.COM 
80*7688SAaron.Zang@Sun.COM #ifdef _HAVE_TEM_FIRMWARE
81*7688SAaron.Zang@Sun.COM 	int	vc_pendc;		/* pending output character */
82*7688SAaron.Zang@Sun.COM #endif /* _HAVE_TEM_FIRMWARE */
83*7688SAaron.Zang@Sun.COM 
84*7688SAaron.Zang@Sun.COM 	/*
85*7688SAaron.Zang@Sun.COM 	 * vc_state_lock is currently only used to protect vc_flags,
86*7688SAaron.Zang@Sun.COM 	 * more precisely, the state change of vc_state_t.
87*7688SAaron.Zang@Sun.COM 	 * The existence of this lock is because wc_modechg_cb().
88*7688SAaron.Zang@Sun.COM 	 * wc_modechg_cb() is a callback function which may result in
89*7688SAaron.Zang@Sun.COM 	 * multiple threads accessing vc_flags regardless the STREAMS
90*7688SAaron.Zang@Sun.COM 	 * periemters of wc module.
91*7688SAaron.Zang@Sun.COM 	 * Since wc_modechg_cb() only conducts read access to vc_flags,
92*7688SAaron.Zang@Sun.COM 	 * we only need to hold this lock when writing to vc_flags in
93*7688SAaron.Zang@Sun.COM 	 * wc module (except wc_modechg_cb()).
94*7688SAaron.Zang@Sun.COM 	 * See locking policy in wscons.c for more info.
95*7688SAaron.Zang@Sun.COM 	 */
96*7688SAaron.Zang@Sun.COM 	kmutex_t vc_state_lock;
97*7688SAaron.Zang@Sun.COM } vc_state_t;
98*7688SAaron.Zang@Sun.COM _NOTE(MUTEX_PROTECTS_DATA(vc_state_t::vc_state_lock, vc_state_t::vc_flags))
99*7688SAaron.Zang@Sun.COM 
100*7688SAaron.Zang@Sun.COM #define	VC_DEFAULT_COUNT	16
101*7688SAaron.Zang@Sun.COM 
102*7688SAaron.Zang@Sun.COM /* Invalid VT minor number */
103*7688SAaron.Zang@Sun.COM #define	VT_MINOR_INVALID	((minor_t)-1)
104*7688SAaron.Zang@Sun.COM /* Argument to vt_minor2vc to get the softstate of the active VT */
105*7688SAaron.Zang@Sun.COM #define	VT_ACTIVE		VT_MINOR_INVALID
106*7688SAaron.Zang@Sun.COM 
107*7688SAaron.Zang@Sun.COM /*
108*7688SAaron.Zang@Sun.COM  * VC_INSTANCES_COUNT should be regarded as reading access to vc_avl_root
109*7688SAaron.Zang@Sun.COM  */
110*7688SAaron.Zang@Sun.COM #define	VC_INSTANCES_COUNT	(avl_numnodes(&vc_avl_root))
111*7688SAaron.Zang@Sun.COM 
112*7688SAaron.Zang@Sun.COM void vt_ioctl(queue_t *q, mblk_t *mp);
113*7688SAaron.Zang@Sun.COM void vt_miocdata(queue_t *qp, mblk_t *mp);
114*7688SAaron.Zang@Sun.COM void vt_clean(queue_t *q, vc_state_t *pvc);
115*7688SAaron.Zang@Sun.COM void vt_close(queue_t *q, vc_state_t *pvc, cred_t *crp);
116*7688SAaron.Zang@Sun.COM int vt_open(minor_t minor, queue_t *rq, cred_t *crp);
117*7688SAaron.Zang@Sun.COM int vt_check_hotkeys(mblk_t *mp);
118*7688SAaron.Zang@Sun.COM vc_state_t *vt_minor2vc(minor_t);
119*7688SAaron.Zang@Sun.COM 
120*7688SAaron.Zang@Sun.COM extern dev_info_t *wc_dip;
121*7688SAaron.Zang@Sun.COM extern avl_tree_t vc_avl_root;
122*7688SAaron.Zang@Sun.COM extern minor_t	vc_active_console;
123*7688SAaron.Zang@Sun.COM extern kmutex_t vc_lock;
124*7688SAaron.Zang@Sun.COM extern minor_t vc_last_console;
125*7688SAaron.Zang@Sun.COM 
126*7688SAaron.Zang@Sun.COM major_t vt_wc_attached(void);
127*7688SAaron.Zang@Sun.COM void vt_getactive(char *, int);
128*7688SAaron.Zang@Sun.COM boolean_t vt_minor_valid(minor_t minor);
129*7688SAaron.Zang@Sun.COM void vt_resize(uint_t);
130*7688SAaron.Zang@Sun.COM void vt_attach(void);
131*7688SAaron.Zang@Sun.COM void vt_init(void);
132*7688SAaron.Zang@Sun.COM 
133*7688SAaron.Zang@Sun.COM #ifdef __cplusplus
134*7688SAaron.Zang@Sun.COM }
135*7688SAaron.Zang@Sun.COM #endif
136*7688SAaron.Zang@Sun.COM 
137*7688SAaron.Zang@Sun.COM #endif /* _SYS_VT_IMPL_H */
138