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