4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License (the "License").
6 * You may not use this file except in compliance with the License.
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
22 * Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
25 #include <sys/types.h>
26 #include <sys/param.h>
27 #include <sys/termios.h>
28 #include <sys/stream.h>
29 #include <sys/stropts.h>
32 #include <sys/sunddi.h>
34 #include <sys/bitmap.h>
35 #include <sys/sysmacros.h>
36 #include <sys/ddi_impldefs.h>
38 #include <sys/thread.h>
40 #include <sys/strlog.h>
43 #include <sys/consdev.h>
44 #include <sys/console.h>
45 #include <sys/wscons.h>
46 #include <sys/vt_impl.h>
50 /* set if console driver is attached */
51 dev_info_t
*wc_dip
= NULL
;
52 /* active virtual console minor number */
53 minor_t vc_active_console
= VT_MINOR_INVALID
;
55 * console_user symbol link minor number.
56 * VT_MINOR_INVALID : /dev/console
59 minor_t vc_cons_user
= VT_MINOR_INVALID
;
60 /* vc_state_t AVL tree */
61 avl_tree_t vc_avl_root
;
62 /* virtual console global lock */
65 _NOTE(MUTEX_PROTECTS_DATA(vc_lock
, wc_dip vc_avl_root vc_active_console
69 * Called from vt devname part. Checks if dip is attached. If it is,
70 * return its major number.
75 major_t maj
= (major_t
)-1;
77 mutex_enter(&vc_lock
);
80 maj
= ddi_driver_major(wc_dip
);
88 vt_getactive(char *buf
, int buflen
)
93 mutex_enter(&vc_lock
);
95 if (vc_active_console
== 0 || vc_active_console
== VT_MINOR_INVALID
)
96 (void) snprintf(buf
, buflen
, "/dev/console");
98 (void) snprintf(buf
, buflen
, "%u", vc_active_console
);
100 mutex_exit(&vc_lock
);
104 vt_getconsuser(char *buf
, int buflen
)
109 mutex_enter(&vc_lock
);
111 if (vc_cons_user
== VT_MINOR_INVALID
) {
112 (void) snprintf(buf
, buflen
, "/dev/console");
113 mutex_exit(&vc_lock
);
117 (void) snprintf(buf
, buflen
, "%u", vc_cons_user
);
118 mutex_exit(&vc_lock
);
122 vt_minor_valid(minor_t minor
)
124 if (consmode
== CONS_FW
) {
131 mutex_enter(&vc_lock
);
132 if (minor
< VC_INSTANCES_COUNT
) {
133 mutex_exit(&vc_lock
);
137 mutex_exit(&vc_lock
);