xref: /onnv-gate/usr/src/uts/common/sys/vt_impl.h (revision 12195:cf3a8ea2dcfd)
17688SAaron.Zang@Sun.COM /*
27688SAaron.Zang@Sun.COM  * CDDL HEADER START
37688SAaron.Zang@Sun.COM  *
47688SAaron.Zang@Sun.COM  * The contents of this file are subject to the terms of the
57688SAaron.Zang@Sun.COM  * Common Development and Distribution License (the "License").
67688SAaron.Zang@Sun.COM  * You may not use this file except in compliance with the License.
77688SAaron.Zang@Sun.COM  *
87688SAaron.Zang@Sun.COM  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97688SAaron.Zang@Sun.COM  * or http://www.opensolaris.org/os/licensing.
107688SAaron.Zang@Sun.COM  * See the License for the specific language governing permissions
117688SAaron.Zang@Sun.COM  * and limitations under the License.
127688SAaron.Zang@Sun.COM  *
137688SAaron.Zang@Sun.COM  * When distributing Covered Code, include this CDDL HEADER in each
147688SAaron.Zang@Sun.COM  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157688SAaron.Zang@Sun.COM  * If applicable, add the following below this CDDL HEADER, with the
167688SAaron.Zang@Sun.COM  * fields enclosed by brackets "[]" replaced with your own identifying
177688SAaron.Zang@Sun.COM  * information: Portions Copyright [yyyy] [name of copyright owner]
187688SAaron.Zang@Sun.COM  *
197688SAaron.Zang@Sun.COM  * CDDL HEADER END
207688SAaron.Zang@Sun.COM  */
217688SAaron.Zang@Sun.COM 
227688SAaron.Zang@Sun.COM /*
23*12195SAaron.Zang@Sun.COM  * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
247688SAaron.Zang@Sun.COM  */
257688SAaron.Zang@Sun.COM 
267688SAaron.Zang@Sun.COM #ifndef _SYS_VT_IMPL_H
277688SAaron.Zang@Sun.COM #define	_SYS_VT_IMPL_H
287688SAaron.Zang@Sun.COM 
297688SAaron.Zang@Sun.COM #ifdef __cplusplus
307688SAaron.Zang@Sun.COM extern "C" {
317688SAaron.Zang@Sun.COM #endif
327688SAaron.Zang@Sun.COM 
337688SAaron.Zang@Sun.COM #include <sys/types.h>
347688SAaron.Zang@Sun.COM #include <sys/stream.h>
357688SAaron.Zang@Sun.COM #include <sys/vt.h>
367688SAaron.Zang@Sun.COM #include <sys/kd.h>
377688SAaron.Zang@Sun.COM #include <sys/tem.h>
387688SAaron.Zang@Sun.COM #include <sys/tty.h>
397688SAaron.Zang@Sun.COM #include <sys/cred.h>
407688SAaron.Zang@Sun.COM #include <sys/list.h>
417688SAaron.Zang@Sun.COM #include <sys/avl.h>
427688SAaron.Zang@Sun.COM #include <sys/note.h>
437688SAaron.Zang@Sun.COM 
447688SAaron.Zang@Sun.COM #define	WCS_INIT	0x00000001	/* tty is init */
457688SAaron.Zang@Sun.COM #define	WCS_ISOPEN	0x00000002	/* open is complete */
467688SAaron.Zang@Sun.COM #define	WCS_STOPPED	0x00000004	/* output is stopped */
477688SAaron.Zang@Sun.COM #define	WCS_DELAY	0x00000008	/* waiting for delay to finish */
487688SAaron.Zang@Sun.COM #define	WCS_BUSY	0x00000010	/* waiting for transmission to finish */
497688SAaron.Zang@Sun.COM 
507688SAaron.Zang@Sun.COM typedef struct vc_waitactive_msg {
517688SAaron.Zang@Sun.COM 	list_node_t	wa_list_node;
527688SAaron.Zang@Sun.COM 	int	wa_msg_minor;		/* minor number from which msg comes */
537688SAaron.Zang@Sun.COM 	int	wa_wait_minor;		/* which node we are waiting for */
547688SAaron.Zang@Sun.COM 	mblk_t *wa_mp;
557688SAaron.Zang@Sun.COM } vc_waitactive_msg_t;
567688SAaron.Zang@Sun.COM 
577688SAaron.Zang@Sun.COM /* virtual console soft state associated with each vt */
587688SAaron.Zang@Sun.COM typedef struct vc_state {
597688SAaron.Zang@Sun.COM 	minor_t	vc_minor;
607688SAaron.Zang@Sun.COM 	avl_node_t vc_avl_node;
617688SAaron.Zang@Sun.COM 	uchar_t	vc_switch_mode;		/* VT_AUTO or VT_PROCESS */
627688SAaron.Zang@Sun.COM 	char	vc_waitv;
637688SAaron.Zang@Sun.COM 	int	vc_relsig;
647688SAaron.Zang@Sun.COM 	int	vc_acqsig;
657688SAaron.Zang@Sun.COM 	pid_t	vc_pid;
667688SAaron.Zang@Sun.COM 	minor_t	vc_switchto;
677688SAaron.Zang@Sun.COM 	int	vc_flags;
687688SAaron.Zang@Sun.COM 
697688SAaron.Zang@Sun.COM 	int	vc_dispnum;
707688SAaron.Zang@Sun.COM 	int	vc_login;
717688SAaron.Zang@Sun.COM 
727688SAaron.Zang@Sun.COM 	tem_vt_state_t vc_tem;		/* Terminal emulator state */
737688SAaron.Zang@Sun.COM 	tty_common_t vc_ttycommon;	/* data common to all tty drivers */
747688SAaron.Zang@Sun.COM 	bufcall_id_t vc_bufcallid;	/* id returned by qbufcall */
757688SAaron.Zang@Sun.COM 	timeout_id_t vc_timeoutid;	/* id returned by qtimeout */
767688SAaron.Zang@Sun.COM 
777688SAaron.Zang@Sun.COM 	queue_t	*vc_wq;			/* write queue */
787688SAaron.Zang@Sun.COM 
797688SAaron.Zang@Sun.COM #ifdef _HAVE_TEM_FIRMWARE
807688SAaron.Zang@Sun.COM 	int	vc_pendc;		/* pending output character */
817688SAaron.Zang@Sun.COM #endif /* _HAVE_TEM_FIRMWARE */
827688SAaron.Zang@Sun.COM 
837688SAaron.Zang@Sun.COM 	/*
847688SAaron.Zang@Sun.COM 	 * vc_state_lock is currently only used to protect vc_flags,
857688SAaron.Zang@Sun.COM 	 * more precisely, the state change of vc_state_t.
867688SAaron.Zang@Sun.COM 	 * The existence of this lock is because wc_modechg_cb().
877688SAaron.Zang@Sun.COM 	 * wc_modechg_cb() is a callback function which may result in
887688SAaron.Zang@Sun.COM 	 * multiple threads accessing vc_flags regardless the STREAMS
897688SAaron.Zang@Sun.COM 	 * periemters of wc module.
907688SAaron.Zang@Sun.COM 	 * Since wc_modechg_cb() only conducts read access to vc_flags,
917688SAaron.Zang@Sun.COM 	 * we only need to hold this lock when writing to vc_flags in
927688SAaron.Zang@Sun.COM 	 * wc module (except wc_modechg_cb()).
937688SAaron.Zang@Sun.COM 	 * See locking policy in wscons.c for more info.
947688SAaron.Zang@Sun.COM 	 */
957688SAaron.Zang@Sun.COM 	kmutex_t vc_state_lock;
967688SAaron.Zang@Sun.COM } vc_state_t;
977688SAaron.Zang@Sun.COM _NOTE(MUTEX_PROTECTS_DATA(vc_state_t::vc_state_lock, vc_state_t::vc_flags))
987688SAaron.Zang@Sun.COM 
997688SAaron.Zang@Sun.COM #define	VC_DEFAULT_COUNT	16
1007688SAaron.Zang@Sun.COM 
1017688SAaron.Zang@Sun.COM /* Invalid VT minor number */
1027688SAaron.Zang@Sun.COM #define	VT_MINOR_INVALID	((minor_t)-1)
1037688SAaron.Zang@Sun.COM /* Argument to vt_minor2vc to get the softstate of the active VT */
1047688SAaron.Zang@Sun.COM #define	VT_ACTIVE		VT_MINOR_INVALID
1057688SAaron.Zang@Sun.COM 
1067688SAaron.Zang@Sun.COM /*
1077688SAaron.Zang@Sun.COM  * VC_INSTANCES_COUNT should be regarded as reading access to vc_avl_root
1087688SAaron.Zang@Sun.COM  */
1097688SAaron.Zang@Sun.COM #define	VC_INSTANCES_COUNT	(avl_numnodes(&vc_avl_root))
1107688SAaron.Zang@Sun.COM 
1117688SAaron.Zang@Sun.COM void vt_ioctl(queue_t *q, mblk_t *mp);
1127688SAaron.Zang@Sun.COM void vt_miocdata(queue_t *qp, mblk_t *mp);
1137688SAaron.Zang@Sun.COM void vt_clean(queue_t *q, vc_state_t *pvc);
1147688SAaron.Zang@Sun.COM void vt_close(queue_t *q, vc_state_t *pvc, cred_t *crp);
1157688SAaron.Zang@Sun.COM int vt_open(minor_t minor, queue_t *rq, cred_t *crp);
1167688SAaron.Zang@Sun.COM int vt_check_hotkeys(mblk_t *mp);
1177688SAaron.Zang@Sun.COM vc_state_t *vt_minor2vc(minor_t);
1187688SAaron.Zang@Sun.COM 
1197688SAaron.Zang@Sun.COM extern dev_info_t *wc_dip;
1207688SAaron.Zang@Sun.COM extern avl_tree_t vc_avl_root;
1217688SAaron.Zang@Sun.COM extern minor_t	vc_active_console;
122*12195SAaron.Zang@Sun.COM extern minor_t	vc_cons_user;
1237688SAaron.Zang@Sun.COM extern kmutex_t vc_lock;
1247688SAaron.Zang@Sun.COM extern minor_t vc_last_console;
1257688SAaron.Zang@Sun.COM 
1267688SAaron.Zang@Sun.COM major_t vt_wc_attached(void);
1277688SAaron.Zang@Sun.COM void vt_getactive(char *, int);
128*12195SAaron.Zang@Sun.COM void vt_getconsuser(char *, int);
1297688SAaron.Zang@Sun.COM boolean_t vt_minor_valid(minor_t minor);
1307688SAaron.Zang@Sun.COM void vt_resize(uint_t);
1317688SAaron.Zang@Sun.COM void vt_attach(void);
1327688SAaron.Zang@Sun.COM void vt_init(void);
1337688SAaron.Zang@Sun.COM 
1347688SAaron.Zang@Sun.COM #ifdef __cplusplus
1357688SAaron.Zang@Sun.COM }
1367688SAaron.Zang@Sun.COM #endif
1377688SAaron.Zang@Sun.COM 
1387688SAaron.Zang@Sun.COM #endif /* _SYS_VT_IMPL_H */
139