xref: /onnv-gate/usr/src/uts/common/io/consconfig.c (revision 10783:ef89ff673874)
10Sstevel@tonic-gate /*
20Sstevel@tonic-gate  * CDDL HEADER START
30Sstevel@tonic-gate  *
40Sstevel@tonic-gate  * The contents of this file are subject to the terms of the
57862SRichard.Bean@Sun.COM  * Common Development and Distribution License (the "License").
67862SRichard.Bean@Sun.COM  * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate  *
80Sstevel@tonic-gate  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate  * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate  * See the License for the specific language governing permissions
110Sstevel@tonic-gate  * and limitations under the License.
120Sstevel@tonic-gate  *
130Sstevel@tonic-gate  * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate  * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate  * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate  * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate  *
190Sstevel@tonic-gate  * CDDL HEADER END
200Sstevel@tonic-gate  */
210Sstevel@tonic-gate /*
228960SJan.Setje-Eilers@Sun.COM  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate  * Use is subject to license terms.
240Sstevel@tonic-gate  */
250Sstevel@tonic-gate 
260Sstevel@tonic-gate /*
270Sstevel@tonic-gate  * Console and mouse configuration
280Sstevel@tonic-gate  */
290Sstevel@tonic-gate 
300Sstevel@tonic-gate #include <sys/types.h>
310Sstevel@tonic-gate #include <sys/param.h>
320Sstevel@tonic-gate #include <sys/cmn_err.h>
330Sstevel@tonic-gate #include <sys/user.h>
340Sstevel@tonic-gate #include <sys/vfs.h>
350Sstevel@tonic-gate #include <sys/vnode.h>
360Sstevel@tonic-gate #include <sys/systm.h>
370Sstevel@tonic-gate #include <sys/file.h>
380Sstevel@tonic-gate #include <sys/klwp.h>
390Sstevel@tonic-gate #include <sys/stropts.h>
400Sstevel@tonic-gate #include <sys/stream.h>
410Sstevel@tonic-gate #include <sys/strsubr.h>
420Sstevel@tonic-gate 
430Sstevel@tonic-gate #include <sys/consdev.h>
440Sstevel@tonic-gate #include <sys/kbio.h>
450Sstevel@tonic-gate #include <sys/debug.h>
460Sstevel@tonic-gate #include <sys/reboot.h>
470Sstevel@tonic-gate #include <sys/termios.h>
480Sstevel@tonic-gate 
490Sstevel@tonic-gate #include <sys/ddi.h>
500Sstevel@tonic-gate #include <sys/sunddi.h>
510Sstevel@tonic-gate #include <sys/modctl.h>
520Sstevel@tonic-gate #include <sys/ddi_impldefs.h>
530Sstevel@tonic-gate 
540Sstevel@tonic-gate #include <sys/strsubr.h>
550Sstevel@tonic-gate #include <sys/errno.h>
560Sstevel@tonic-gate #include <sys/devops.h>
570Sstevel@tonic-gate #include <sys/note.h>
588960SJan.Setje-Eilers@Sun.COM #include <sys/consplat.h>
590Sstevel@tonic-gate 
600Sstevel@tonic-gate /*
610Sstevel@tonic-gate  * On supported configurations, the firmware defines the keyboard and mouse
620Sstevel@tonic-gate  * paths.  However, during USB development, it is useful to be able to use
630Sstevel@tonic-gate  * the USB keyboard and mouse on machines without full USB firmware support.
640Sstevel@tonic-gate  * These variables may be set in /etc/system according to a machine's
650Sstevel@tonic-gate  * USB configuration.  This module will override the firmware's values
660Sstevel@tonic-gate  * with these.
670Sstevel@tonic-gate  */
680Sstevel@tonic-gate static char *usb_kb_path = NULL;
690Sstevel@tonic-gate static char *usb_ms_path = NULL;
700Sstevel@tonic-gate 
710Sstevel@tonic-gate /*
720Sstevel@tonic-gate  * This is the loadable module wrapper.
730Sstevel@tonic-gate  */
740Sstevel@tonic-gate extern struct mod_ops mod_miscops;
750Sstevel@tonic-gate 
760Sstevel@tonic-gate /*
770Sstevel@tonic-gate  * Module linkage information for the kernel.
780Sstevel@tonic-gate  */
790Sstevel@tonic-gate static struct modlmisc modlmisc = {
807862SRichard.Bean@Sun.COM 	&mod_miscops, "console configuration"
810Sstevel@tonic-gate };
820Sstevel@tonic-gate 
830Sstevel@tonic-gate static struct modlinkage modlinkage = {
840Sstevel@tonic-gate 	MODREV_1, (void *)&modlmisc, NULL
850Sstevel@tonic-gate };
860Sstevel@tonic-gate 
870Sstevel@tonic-gate int
_init(void)880Sstevel@tonic-gate _init(void)
890Sstevel@tonic-gate {
900Sstevel@tonic-gate 	return (mod_install(&modlinkage));
910Sstevel@tonic-gate }
920Sstevel@tonic-gate 
930Sstevel@tonic-gate int
_fini(void)940Sstevel@tonic-gate _fini(void)
950Sstevel@tonic-gate {
960Sstevel@tonic-gate 	return (mod_remove(&modlinkage));
970Sstevel@tonic-gate }
980Sstevel@tonic-gate 
990Sstevel@tonic-gate int
_info(struct modinfo * modinfop)1000Sstevel@tonic-gate _info(struct modinfo *modinfop)
1010Sstevel@tonic-gate {
1020Sstevel@tonic-gate 	return (mod_info(&modlinkage, modinfop));
1030Sstevel@tonic-gate }
1040Sstevel@tonic-gate 
1050Sstevel@tonic-gate extern void dynamic_console_config(void);
106*10783SVincent.Wang@Sun.COM extern boolean_t consconfig_dacf_initialized(void);
1070Sstevel@tonic-gate 
1080Sstevel@tonic-gate /*
1090Sstevel@tonic-gate  * Configure keyboard and mouse. Main entry here.
1100Sstevel@tonic-gate  */
1110Sstevel@tonic-gate void
consconfig(void)1120Sstevel@tonic-gate consconfig(void)
1130Sstevel@tonic-gate {
1140Sstevel@tonic-gate 	dynamic_console_config();
1150Sstevel@tonic-gate }
1160Sstevel@tonic-gate 
1170Sstevel@tonic-gate extern char *
consconfig_get_usb_kb_path(void)1180Sstevel@tonic-gate consconfig_get_usb_kb_path(void) {
1190Sstevel@tonic-gate 	if (usb_kb_path)
1200Sstevel@tonic-gate 		return (i_ddi_strdup(usb_kb_path, KM_SLEEP));
1210Sstevel@tonic-gate 	return (NULL);
1220Sstevel@tonic-gate }
1230Sstevel@tonic-gate 
1240Sstevel@tonic-gate extern char *
consconfig_get_usb_ms_path(void)1250Sstevel@tonic-gate consconfig_get_usb_ms_path(void) {
1260Sstevel@tonic-gate 	if (usb_ms_path)
1270Sstevel@tonic-gate 		return (i_ddi_strdup(usb_ms_path, KM_SLEEP));
1280Sstevel@tonic-gate 	return (NULL);
1290Sstevel@tonic-gate }
1308960SJan.Setje-Eilers@Sun.COM 
1318960SJan.Setje-Eilers@Sun.COM extern char *
consconfig_get_plat_fbpath(void)1328960SJan.Setje-Eilers@Sun.COM consconfig_get_plat_fbpath(void) {
1338960SJan.Setje-Eilers@Sun.COM 	return (plat_fbpath());
1348960SJan.Setje-Eilers@Sun.COM }
135*10783SVincent.Wang@Sun.COM 
136*10783SVincent.Wang@Sun.COM extern boolean_t
consconfig_console_is_ready(void)137*10783SVincent.Wang@Sun.COM consconfig_console_is_ready(void) {
138*10783SVincent.Wang@Sun.COM 	return (consconfig_dacf_initialized());
139*10783SVincent.Wang@Sun.COM }
140